aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-09-06 17:39:00 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2014-09-06 17:39:00 +0200
commitf2f1a9516d2c877eda994b3debdaa462319f4941 (patch)
treec23ff716b2300706328310ed4b5ad97dbc14c08f /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java
parent59f32c4fca48b226fc13b649a7f6a635aeaa9041 (diff)
downloadopen-keychain-f2f1a9516d2c877eda994b3debdaa462319f4941.tar.gz
open-keychain-f2f1a9516d2c877eda994b3debdaa462319f4941.tar.bz2
open-keychain-f2f1a9516d2c877eda994b3debdaa462319f4941.zip
Share helper
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java69
1 files changed, 5 insertions, 64 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java
index d1bdfe14b..5386178f0 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextActivity.java
@@ -33,6 +33,7 @@ import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.compatibility.ClipboardReflection;
import org.sufficientlysecure.keychain.helper.Preferences;
+import org.sufficientlysecure.keychain.helper.ShareHelper;
import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
@@ -245,74 +246,13 @@ public class EncryptTextActivity extends DrawerActivity implements EncryptActivi
/**
* Create Intent Chooser but exclude OK's EncryptActivity.
- * <p/>
- * Put together from some stackoverflow posts...
- *
- * @param message
- * @return
*/
private Intent sendWithChooserExcludingEncrypt(Message message) {
Intent prototype = createSendIntent(message);
-
String title = getString(R.string.title_share_message);
+ String[] blacklist = new String[]{Constants.PACKAGE_NAME + ".ui.EncryptActivity"};
- // Disabled, produced an empty list on Huawei U8860 with Android Version 4.0.3
-// // 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);
+ return new ShareHelper(this).createChooserExcluding(prototype, title, blacklist);
}
private Intent createSendIntent(Message message) {
@@ -418,7 +358,8 @@ public class EncryptTextActivity extends DrawerActivity implements EncryptActivi
.replace(R.id.encrypt_pager_mode,
mCurrentMode == MODE_SYMMETRIC
? new EncryptSymmetricFragment()
- : new EncryptAsymmetricFragment())
+ : new EncryptAsymmetricFragment()
+ )
.commitAllowingStateLoss();
getSupportFragmentManager().executePendingTransactions();
}