Bugfix: OI really not required anymore for open dialog

This commit is contained in:
PhilippC 2013-05-11 22:11:11 +02:00
parent fd60316448
commit 7e0a4c9d20
2 changed files with 7 additions and 3 deletions

View File

@ -44,12 +44,16 @@ namespace keepass2android
* @return True if an Intent with the specified action can be sent and * @return True if an Intent with the specified action can be sent and
* responded to, false otherwise. * 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; PackageManager packageManager = context.PackageManager;
Intent intent = new Intent(action); Intent intent = new Intent(action);
if (type != null)
intent.SetType(type);
IList<ResolveInfo> list = IList<ResolveInfo> list =
packageManager.QueryIntentActivities(intent, packageManager.QueryIntentActivities(intent,
PackageInfoFlags.MatchDefaultOnly); PackageInfoFlags.MatchDefaultOnly);
foreach (ResolveInfo i in list)
Android.Util.Log.Debug("DEBUG", i.ActivityInfo.ApplicationInfo.PackageName);
return list.Count > 0; return list.Count > 0;
} }
} }

View File

@ -90,14 +90,14 @@ namespace keepass2android
public static void showBrowseDialog(string filename, Activity act, int requestCodeBrowse, bool forSaving) 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); Intent i = new Intent(Intent.ActionGetContent);
i.SetType("file/*"); i.SetType("file/*");
act.StartActivityForResult(i, requestCodeBrowse); act.StartActivityForResult(i, requestCodeBrowse);
return; return;
} }
if (Interaction.isIntentAvailable(act, Intents.FILE_BROWSE)) if (Interaction.isIntentAvailable(act, Intents.FILE_BROWSE, null))
{ {
Intent i = new Intent(Intents.FILE_BROWSE); Intent i = new Intent(Intents.FILE_BROWSE);
if (filename != null) if (filename != null)