mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 19:22:14 -05:00
Disable custom intent chooser
This commit is contained in:
parent
acff54d7d7
commit
b7de91ad51
@ -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<LabeledIntent> targetedShareIntents = new ArrayList<LabeledIntent>();
|
||||
|
||||
List<ResolveInfo> resInfoList = getPackageManager().queryIntentActivities(prototype, 0);
|
||||
List<ResolveInfo> resInfoListFiltered = new ArrayList<ResolveInfo>();
|
||||
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<ResolveInfo>() {
|
||||
@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<LabeledIntent> targetedShareIntents = new ArrayList<LabeledIntent>();
|
||||
//
|
||||
// List<ResolveInfo> resInfoList = getPackageManager().queryIntentActivities(prototype, 0);
|
||||
// List<ResolveInfo> resInfoListFiltered = new ArrayList<ResolveInfo>();
|
||||
// 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<ResolveInfo>() {
|
||||
// @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);
|
||||
|
Loading…
Reference in New Issue
Block a user