From ba840822bcc8204017c23f2a40c69591c350d597 Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Mon, 13 Nov 2017 09:53:19 +0100 Subject: [PATCH] revert removal of external file pickers to fix #77 --- src/keepass2android/EntryEditActivity.cs | 2 +- .../FileStorageSelectionActivity.cs | 2 +- src/keepass2android/Utils/Util.cs | 14 ++++---------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/keepass2android/EntryEditActivity.cs b/src/keepass2android/EntryEditActivity.cs index 10c12f11..b860d0db 100644 --- a/src/keepass2android/EntryEditActivity.cs +++ b/src/keepass2android/EntryEditActivity.cs @@ -805,7 +805,7 @@ namespace keepass2android addBinaryButton.Enabled = !State.Entry.Binaries.Any(); addBinaryButton.Click += (sender, e) => { - Util.ShowBrowseDialog(this, Intents.RequestCodeFileBrowseForBinary, false, false); + Util.ShowBrowseDialog(this, Intents.RequestCodeFileBrowseForBinary, false, true /*force OpenDocument if available, GetContent is not well support starting with Android 7 */); }; binariesGroup.AddView(addBinaryButton,layoutParams); diff --git a/src/keepass2android/FileStorageSelectionActivity.cs b/src/keepass2android/FileStorageSelectionActivity.cs index ca7fd8a5..e1b6eae3 100644 --- a/src/keepass2android/FileStorageSelectionActivity.cs +++ b/src/keepass2android/FileStorageSelectionActivity.cs @@ -74,7 +74,7 @@ namespace keepass2android } - if ((context.Intent.GetBooleanExtra(AllowThirdPartyAppGet, false)) && (Util.ActionGetContentAvailable)) + if (context.Intent.GetBooleanExtra(AllowThirdPartyAppGet, false)) _displayedProtocolIds.Add("androidget"); if (context.Intent.GetBooleanExtra(AllowThirdPartyAppSend, false)) _displayedProtocolIds.Add("androidsend"); diff --git a/src/keepass2android/Utils/Util.cs b/src/keepass2android/Utils/Util.cs index b5a69ea8..26e85bd0 100644 --- a/src/keepass2android/Utils/Util.cs +++ b/src/keepass2android/Utils/Util.cs @@ -200,10 +200,10 @@ namespace keepass2android /// is more for one-time access, but therefore allows possibly more available sources. public static void ShowBrowseDialog(Activity activity, int requestCodeBrowse, bool forSaving, bool tryGetPermanentAccess) { - var loadAction = (tryGetPermanentAccess && IsKitKatOrLater) || !ActionGetContentAvailable - ? Intent.ActionOpenDocument - : Intent.ActionGetContent; - + //even though GetContent is not well supported (since Android 7, see https://commonsware.com/Android/previews/appendix-b-android-70) + //we still offer it. + var loadAction = (tryGetPermanentAccess && IsKitKatOrLater) ? + Intent.ActionOpenDocument : Intent.ActionGetContent; if ((!forSaving) && (IsIntentAvailable(activity, loadAction, "*/*", new List { Intent.CategoryOpenable}))) { Intent i = new Intent(loadAction); @@ -232,12 +232,6 @@ namespace keepass2android } } - public static bool ActionGetContentAvailable - { - //https://commonsware.com/Android/previews/appendix-b-android-70 - get { return ((int) Build.VERSION.SdkInt < 24); } - } - public static bool IsKitKatOrLater { get { return (int)Build.VERSION.SdkInt >= 19; }