mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-01-09 12:37:59 -05:00
made CryptoOpHelper work in the presence of other helpers
This commit is contained in:
parent
010d6328af
commit
20354ca393
@ -62,6 +62,11 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
|
|||||||
public static final int REQUEST_CODE_PASSPHRASE = 0x00008001;
|
public static final int REQUEST_CODE_PASSPHRASE = 0x00008001;
|
||||||
public static final int REQUEST_CODE_NFC = 0x00008002;
|
public static final int REQUEST_CODE_NFC = 0x00008002;
|
||||||
|
|
||||||
|
// keeps track of request code used to start an activity from this CryptoOperationHelper.
|
||||||
|
// this is necessary when multiple CryptoOperationHelpers are used in the same fragment/activity
|
||||||
|
// otherwise all CryptoOperationHandlers may respond to the same onActivityResult
|
||||||
|
private int mRequestedCode = -1;
|
||||||
|
|
||||||
private int mProgressMessageString;
|
private int mProgressMessageString;
|
||||||
|
|
||||||
private FragmentActivity mActivity;
|
private FragmentActivity mActivity;
|
||||||
@ -117,10 +122,11 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
|
|||||||
case NFC_SIGN: {
|
case NFC_SIGN: {
|
||||||
Intent intent = new Intent(activity, NfcOperationActivity.class);
|
Intent intent = new Intent(activity, NfcOperationActivity.class);
|
||||||
intent.putExtra(NfcOperationActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
intent.putExtra(NfcOperationActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
||||||
|
mRequestedCode = REQUEST_CODE_NFC;
|
||||||
if (mUseFragment) {
|
if (mUseFragment) {
|
||||||
mFragment.startActivityForResult(intent, REQUEST_CODE_NFC);
|
mFragment.startActivityForResult(intent, mRequestedCode);
|
||||||
} else {
|
} else {
|
||||||
mActivity.startActivityForResult(intent, REQUEST_CODE_NFC);
|
mActivity.startActivityForResult(intent, mRequestedCode);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -129,10 +135,11 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
|
|||||||
case PASSPHRASE_SYMMETRIC: {
|
case PASSPHRASE_SYMMETRIC: {
|
||||||
Intent intent = new Intent(activity, PassphraseDialogActivity.class);
|
Intent intent = new Intent(activity, PassphraseDialogActivity.class);
|
||||||
intent.putExtra(PassphraseDialogActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
intent.putExtra(PassphraseDialogActivity.EXTRA_REQUIRED_INPUT, requiredInput);
|
||||||
|
mRequestedCode = REQUEST_CODE_PASSPHRASE;
|
||||||
if (mUseFragment) {
|
if (mUseFragment) {
|
||||||
mFragment.startActivityForResult(intent, REQUEST_CODE_PASSPHRASE);
|
mFragment.startActivityForResult(intent, mRequestedCode);
|
||||||
} else {
|
} else {
|
||||||
mActivity.startActivityForResult(intent, REQUEST_CODE_PASSPHRASE);
|
mActivity.startActivityForResult(intent, mRequestedCode);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -152,6 +159,13 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
|
|||||||
*/
|
*/
|
||||||
public boolean handleActivityResult(int requestCode, int resultCode, Intent data) {
|
public boolean handleActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
Log.d("PHILIP", "received activity result in OperationHelper");
|
Log.d("PHILIP", "received activity result in OperationHelper");
|
||||||
|
|
||||||
|
if (mRequestedCode != requestCode) {
|
||||||
|
// this wasn't meant for us to handle
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
mRequestedCode = -1;
|
||||||
|
}
|
||||||
if (resultCode == Activity.RESULT_CANCELED) {
|
if (resultCode == Activity.RESULT_CANCELED) {
|
||||||
mCallback.onCryptoOperationCancelled();
|
mCallback.onCryptoOperationCancelled();
|
||||||
return true;
|
return true;
|
||||||
@ -187,10 +201,12 @@ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResu
|
|||||||
|
|
||||||
protected void dismissProgress() {
|
protected void dismissProgress() {
|
||||||
FragmentManager fragmentManager =
|
FragmentManager fragmentManager =
|
||||||
mUseFragment ? mFragment.getFragmentManager() : mActivity.getSupportFragmentManager();
|
mUseFragment ? mFragment.getFragmentManager() :
|
||||||
|
mActivity.getSupportFragmentManager();
|
||||||
|
|
||||||
ProgressDialogFragment progressDialogFragment =
|
ProgressDialogFragment progressDialogFragment =
|
||||||
(ProgressDialogFragment) fragmentManager.findFragmentByTag(ServiceProgressHandler.TAG_PROGRESS_DIALOG);
|
(ProgressDialogFragment) fragmentManager.findFragmentByTag(
|
||||||
|
ServiceProgressHandler.TAG_PROGRESS_DIALOG);
|
||||||
|
|
||||||
if (progressDialogFragment == null) {
|
if (progressDialogFragment == null) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user