Remove ShareHelper: Not compat with Android >= 5, reduce code complexity
This commit is contained in:
@@ -36,7 +36,6 @@ import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.operations.results.DecryptVerifyResult;
|
||||
import org.sufficientlysecure.keychain.ui.util.Notify;
|
||||
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
|
||||
import org.sufficientlysecure.keychain.util.ShareHelper;
|
||||
|
||||
public class DisplayTextFragment extends DecryptFragment {
|
||||
|
||||
@@ -60,22 +59,6 @@ public class DisplayTextFragment extends DecryptFragment {
|
||||
return frag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Intent Chooser but exclude decrypt activites
|
||||
*/
|
||||
private Intent sendWithChooserExcludingDecrypt(String text) {
|
||||
Intent prototype = createSendIntent(text);
|
||||
String title = getString(R.string.title_share_message);
|
||||
|
||||
// we don't want to decrypt the decrypted, no inception ;)
|
||||
String[] blacklist = new String[]{
|
||||
Constants.PACKAGE_NAME + ".ui.DecryptActivity",
|
||||
"org.thialfihar.android.apg.ui.DecryptActivity"
|
||||
};
|
||||
|
||||
return new ShareHelper(getActivity()).createChooserExcluding(prototype, title, blacklist);
|
||||
}
|
||||
|
||||
private Intent createSendIntent(String text) {
|
||||
Intent sendIntent = new Intent(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, text);
|
||||
@@ -146,7 +129,8 @@ public class DisplayTextFragment extends DecryptFragment {
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.decrypt_share: {
|
||||
startActivity(sendWithChooserExcludingDecrypt(mText.getText().toString()));
|
||||
startActivity(Intent.createChooser(createSendIntent(mText.getText().toString()),
|
||||
getString(R.string.title_share_message)));
|
||||
break;
|
||||
}
|
||||
case R.id.decrypt_copy: {
|
||||
|
||||
@@ -69,7 +69,6 @@ import org.sufficientlysecure.keychain.util.FileHelper;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
import org.sufficientlysecure.keychain.util.Preferences;
|
||||
import org.sufficientlysecure.keychain.util.ShareHelper;
|
||||
|
||||
public class EncryptFilesFragment
|
||||
extends CachingCryptoOperationFragment<SignEncryptParcel, SignEncryptResult> {
|
||||
@@ -404,7 +403,7 @@ public class EncryptFilesFragment
|
||||
public void onDeleted() {
|
||||
if (mAfterEncryptAction == AfterEncryptAction.SHARE) {
|
||||
// Share encrypted message/file
|
||||
startActivity(sendWithChooserExcludingEncrypt());
|
||||
startActivity(Intent.createChooser(createSendIntent(), getString(R.string.title_share_file)));
|
||||
} else {
|
||||
Activity activity = getActivity();
|
||||
if (activity == null) {
|
||||
@@ -424,7 +423,7 @@ public class EncryptFilesFragment
|
||||
|
||||
case SHARE:
|
||||
// Share encrypted message/file
|
||||
startActivity(sendWithChooserExcludingEncrypt());
|
||||
startActivity(Intent.createChooser(createSendIntent(), getString(R.string.title_share_file)));
|
||||
break;
|
||||
|
||||
case COPY:
|
||||
@@ -620,22 +619,6 @@ public class EncryptFilesFragment
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Intent Chooser but exclude OK's EncryptActivity.
|
||||
*/
|
||||
private Intent sendWithChooserExcludingEncrypt() {
|
||||
Intent prototype = createSendIntent();
|
||||
String title = getString(R.string.title_share_file);
|
||||
|
||||
// we don't want to encrypt the encrypted, no inception ;)
|
||||
String[] blacklist = new String[]{
|
||||
Constants.PACKAGE_NAME + ".ui.EncryptFilesActivity",
|
||||
"org.thialfihar.android.apg.ui.EncryptActivity"
|
||||
};
|
||||
|
||||
return new ShareHelper(getActivity()).createChooserExcluding(prototype, title, blacklist);
|
||||
}
|
||||
|
||||
private Intent createSendIntent() {
|
||||
Intent sendIntent;
|
||||
// file
|
||||
|
||||
@@ -46,7 +46,6 @@ import org.sufficientlysecure.keychain.ui.util.Notify.ActionListener;
|
||||
import org.sufficientlysecure.keychain.ui.util.Notify.Style;
|
||||
import org.sufficientlysecure.keychain.util.Passphrase;
|
||||
import org.sufficientlysecure.keychain.util.Preferences;
|
||||
import org.sufficientlysecure.keychain.util.ShareHelper;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
@@ -289,22 +288,6 @@ public class EncryptTextFragment
|
||||
result.createNotify(activity).show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Intent Chooser but exclude OK's EncryptActivity.
|
||||
*/
|
||||
private Intent sendWithChooserExcludingEncrypt(byte[] resultBytes) {
|
||||
Intent prototype = createSendIntent(resultBytes);
|
||||
String title = getString(R.string.title_share_message);
|
||||
|
||||
// we don't want to encrypt the encrypted, no inception ;)
|
||||
String[] blacklist = new String[]{
|
||||
Constants.PACKAGE_NAME + ".ui.EncryptTextActivity",
|
||||
"org.thialfihar.android.apg.ui.EncryptActivity"
|
||||
};
|
||||
|
||||
return new ShareHelper(getActivity()).createChooserExcluding(prototype, title, blacklist);
|
||||
}
|
||||
|
||||
private Intent createSendIntent(byte[] resultBytes) {
|
||||
Intent sendIntent;
|
||||
sendIntent = new Intent(Intent.ACTION_SEND);
|
||||
@@ -343,7 +326,8 @@ public class EncryptTextFragment
|
||||
|
||||
if (mShareAfterEncrypt) {
|
||||
// Share encrypted message/file
|
||||
startActivity(sendWithChooserExcludingEncrypt(result.getResultBytes()));
|
||||
startActivity(Intent.createChooser(createSendIntent(result.getResultBytes()),
|
||||
getString(R.string.title_share_message)));
|
||||
} else {
|
||||
// Copy to clipboard
|
||||
copyToClipboard(result);
|
||||
|
||||
Reference in New Issue
Block a user