make loading of databases through third party app possible again (Android < 7) or hide third party app (Android >= 7)

This commit is contained in:
Philipp Crocoll
2017-10-25 22:46:44 +02:00
parent 6eee282fa4
commit fcc7d126f9
2 changed files with 11 additions and 3 deletions

View File

@@ -74,7 +74,7 @@ namespace keepass2android
}
if (context.Intent.GetBooleanExtra(AllowThirdPartyAppGet, false))
if ((context.Intent.GetBooleanExtra(AllowThirdPartyAppGet, false)) && (Util.ActionGetContentAvailable))
_displayedProtocolIds.Add("androidget");
if (context.Intent.GetBooleanExtra(AllowThirdPartyAppSend, false))
_displayedProtocolIds.Add("androidsend");

View File

@@ -200,8 +200,10 @@ namespace keepass2android
/// is more for one-time access, but therefore allows possibly more available sources.</param>
public static void ShowBrowseDialog(Activity activity, int requestCodeBrowse, bool forSaving, bool tryGetPermanentAccess)
{
var loadAction = IsKitKatOrLater ?
Intent.ActionOpenDocument : Intent.ActionGetContent;
var loadAction = (tryGetPermanentAccess && IsKitKatOrLater) || !ActionGetContentAvailable
? Intent.ActionOpenDocument
: Intent.ActionGetContent;
if ((!forSaving) && (IsIntentAvailable(activity, loadAction, "*/*", new List<string> { Intent.CategoryOpenable})))
{
Intent i = new Intent(loadAction);
@@ -230,6 +232,12 @@ 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; }