From b7de91ad5167ac55abc3c438c706e6a8d5dd4634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 21 Aug 2014 14:07:37 +0200 Subject: [PATCH] Disable custom intent chooser --- .../keychain/ui/EncryptActivity.java | 107 +++++++++--------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java index d33e5116c..26df5cd26 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java @@ -309,59 +309,60 @@ public class EncryptActivity extends DrawerActivity implements EncryptActivityIn String title = isContentMessage() ? getString(R.string.title_share_message) : getString(R.string.title_share_file); - // fallback on Android 2.3, otherwise we would get weird results - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { - return Intent.createChooser(prototype, title); - } - - // prevent recursion aka Inception :P - String[] blacklist = new String[]{Constants.PACKAGE_NAME + ".ui.EncryptActivity"}; - - List targetedShareIntents = new ArrayList(); - - List resInfoList = getPackageManager().queryIntentActivities(prototype, 0); - List resInfoListFiltered = new ArrayList(); - if (!resInfoList.isEmpty()) { - for (ResolveInfo resolveInfo : resInfoList) { - // do not add blacklisted ones - if (resolveInfo.activityInfo == null || Arrays.asList(blacklist).contains(resolveInfo.activityInfo.name)) - continue; - - resInfoListFiltered.add(resolveInfo); - } - - if (!resInfoListFiltered.isEmpty()) { - // sorting for nice readability - Collections.sort(resInfoListFiltered, new Comparator() { - @Override - public int compare(ResolveInfo first, ResolveInfo second) { - String firstName = first.loadLabel(getPackageManager()).toString(); - String secondName = second.loadLabel(getPackageManager()).toString(); - return firstName.compareToIgnoreCase(secondName); - } - }); - - // create the custom intent list - for (ResolveInfo resolveInfo : resInfoListFiltered) { - Intent targetedShareIntent = (Intent) prototype.clone(); - targetedShareIntent.setPackage(resolveInfo.activityInfo.packageName); - targetedShareIntent.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name); - - LabeledIntent lIntent = new LabeledIntent(targetedShareIntent, - resolveInfo.activityInfo.packageName, - resolveInfo.loadLabel(getPackageManager()), - resolveInfo.activityInfo.icon); - targetedShareIntents.add(lIntent); - } - - // Create chooser with only one Intent in it - Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(targetedShareIntents.size() - 1), title); - // append all other Intents - chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{})); - return chooserIntent; - } - - } + // Disabled, produced an empty list on Sony (model will be inserted here) +// // fallback on Android 2.3, otherwise we would get weird results +// if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { +// return Intent.createChooser(prototype, title); +// } +// +// // prevent recursion aka Inception :P +// String[] blacklist = new String[]{Constants.PACKAGE_NAME + ".ui.EncryptActivity"}; +// +// List targetedShareIntents = new ArrayList(); +// +// List resInfoList = getPackageManager().queryIntentActivities(prototype, 0); +// List resInfoListFiltered = new ArrayList(); +// if (!resInfoList.isEmpty()) { +// for (ResolveInfo resolveInfo : resInfoList) { +// // do not add blacklisted ones +// if (resolveInfo.activityInfo == null || Arrays.asList(blacklist).contains(resolveInfo.activityInfo.name)) +// continue; +// +// resInfoListFiltered.add(resolveInfo); +// } +// +// if (!resInfoListFiltered.isEmpty()) { +// // sorting for nice readability +// Collections.sort(resInfoListFiltered, new Comparator() { +// @Override +// public int compare(ResolveInfo first, ResolveInfo second) { +// String firstName = first.loadLabel(getPackageManager()).toString(); +// String secondName = second.loadLabel(getPackageManager()).toString(); +// return firstName.compareToIgnoreCase(secondName); +// } +// }); +// +// // create the custom intent list +// for (ResolveInfo resolveInfo : resInfoListFiltered) { +// Intent targetedShareIntent = (Intent) prototype.clone(); +// targetedShareIntent.setPackage(resolveInfo.activityInfo.packageName); +// targetedShareIntent.setClassName(resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name); +// +// LabeledIntent lIntent = new LabeledIntent(targetedShareIntent, +// resolveInfo.activityInfo.packageName, +// resolveInfo.loadLabel(getPackageManager()), +// resolveInfo.activityInfo.icon); +// targetedShareIntents.add(lIntent); +// } +// +// // Create chooser with only one Intent in it +// Intent chooserIntent = Intent.createChooser(targetedShareIntents.remove(targetedShareIntents.size() - 1), title); +// // append all other Intents +// chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, targetedShareIntents.toArray(new Parcelable[]{})); +// return chooserIntent; +// } +// +// } // fallback to Android's default chooser return Intent.createChooser(prototype, title);