From 7e0a4c9d20cfabf1fb2f0559ba6eece5497889be Mon Sep 17 00:00:00 2001 From: PhilippC Date: Sat, 11 May 2013 22:11:11 +0200 Subject: [PATCH] Bugfix: OI really not required anymore for open dialog --- src/keepass2android/Utils/Interaction.cs | 6 +++++- src/keepass2android/Utils/Util.cs | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/keepass2android/Utils/Interaction.cs b/src/keepass2android/Utils/Interaction.cs index 71ceff85..39affe20 100644 --- a/src/keepass2android/Utils/Interaction.cs +++ b/src/keepass2android/Utils/Interaction.cs @@ -44,12 +44,16 @@ namespace keepass2android * @return True if an Intent with the specified action can be sent and * responded to, false otherwise. */ - public static bool isIntentAvailable(Context context, String action) { + public static bool isIntentAvailable(Context context, String action, String type) { PackageManager packageManager = context.PackageManager; Intent intent = new Intent(action); + if (type != null) + intent.SetType(type); IList list = packageManager.QueryIntentActivities(intent, PackageInfoFlags.MatchDefaultOnly); + foreach (ResolveInfo i in list) + Android.Util.Log.Debug("DEBUG", i.ActivityInfo.ApplicationInfo.PackageName); return list.Count > 0; } } diff --git a/src/keepass2android/Utils/Util.cs b/src/keepass2android/Utils/Util.cs index e9663251..b7018360 100644 --- a/src/keepass2android/Utils/Util.cs +++ b/src/keepass2android/Utils/Util.cs @@ -90,14 +90,14 @@ namespace keepass2android public static void showBrowseDialog(string filename, Activity act, int requestCodeBrowse, bool forSaving) { - if ((!forSaving) && (Interaction.isIntentAvailable(act, Intent.ActionGetContent))) { + if ((!forSaving) && (Interaction.isIntentAvailable(act, Intent.ActionGetContent, "file/*"))) { Intent i = new Intent(Intent.ActionGetContent); i.SetType("file/*"); act.StartActivityForResult(i, requestCodeBrowse); return; } - if (Interaction.isIntentAvailable(act, Intents.FILE_BROWSE)) + if (Interaction.isIntentAvailable(act, Intents.FILE_BROWSE, null)) { Intent i = new Intent(Intents.FILE_BROWSE); if (filename != null)