diff options
Diffstat (limited to 'OpenKeychain/src/main/java')
11 files changed, 33 insertions, 59 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java index c92ee10df..891c2268c 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java @@ -295,7 +295,7 @@ public class CertifyKeyFragment } @Override - protected CertifyActionsParcel createOperationInput() { + public CertifyActionsParcel createOperationInput() { // Bail out if there is not at least one user id selected ArrayList<CertifyAction> certifyActions = mUserIdsAdapter.getSelectedCertifyActions(); @@ -318,7 +318,7 @@ public class CertifyKeyFragment } @Override - protected void onCryptoOperationSuccess(CertifyResult result) { + public void onCryptoOperationSuccess(CertifyResult result) { Intent intent = new Intent(); intent.putExtra(CertifyResult.EXTRA_RESULT, result); getActivity().setResult(Activity.RESULT_OK, intent); @@ -326,7 +326,7 @@ public class CertifyKeyFragment } @Override - protected void onCryptoOperationCancelled() { + public void onCryptoOperationCancelled() { super.onCryptoOperationCancelled(); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java index a045b34f5..c420e5af9 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyFinalFragment.java @@ -151,12 +151,12 @@ public class CreateKeyFinalFragment } @Override - protected SaveKeyringParcel createOperationInput() { + public SaveKeyringParcel createOperationInput() { return mSaveKeyringParcel; } @Override - protected void onCryptoOperationSuccess(EditKeyResult result) { + public void onCryptoOperationSuccess(EditKeyResult result) { if (result.mMasterKeyId != null && mUploadCheckbox.isChecked()) { // result will be displayed after upload uploadKey(result); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyYubiKeyImportFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyYubiKeyImportFragment.java index f9ddd9e73..7997d8025 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyYubiKeyImportFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CreateKeyYubiKeyImportFragment.java @@ -211,12 +211,12 @@ public class CreateKeyYubiKeyImportFragment } @Override - protected ImportKeyringParcel createOperationInput() { + public ImportKeyringParcel createOperationInput() { return new ImportKeyringParcel(mKeyList, mKeyserver); } @Override - protected void onCryptoOperationSuccess(ImportKeyResult result) { + public void onCryptoOperationSuccess(ImportKeyResult result) { long[] masterKeyIds = result.getImportedMasterKeyIds(); if (masterKeyIds.length == 0) { super.onCryptoOperationError(result); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java index d70af4058..96767463e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptListFragment.java @@ -254,12 +254,12 @@ public class DecryptListFragment } @Override - protected boolean onCryptoSetProgress(String msg, int progress, int max) { + public boolean onCryptoSetProgress(String msg, int progress, int max) { mAdapter.setProgress(mCurrentInputUri, progress, max, msg); return true; } @Override - protected void onCryptoOperationError(DecryptVerifyResult result) { + public void onCryptoOperationError(DecryptVerifyResult result) { final Uri uri = mCurrentInputUri; mCurrentInputUri = null; @@ -269,7 +269,7 @@ public class DecryptListFragment } @Override - protected void onCryptoOperationSuccess(DecryptVerifyResult result) { + public void onCryptoOperationSuccess(DecryptVerifyResult result) { Uri uri = mCurrentInputUri; mCurrentInputUri = null; @@ -433,7 +433,7 @@ public class DecryptListFragment } @Override - protected PgpDecryptVerifyInputParcel createOperationInput() { + public PgpDecryptVerifyInputParcel createOperationInput() { if (mCurrentInputUri == null) { if (mPendingInputUris.isEmpty()) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java index 2cd916544..1363d44f2 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyFragment.java @@ -607,12 +607,12 @@ public class EditKeyFragment extends CryptoOperationFragment<SaveKeyringParcel, } @Override - protected SaveKeyringParcel createOperationInput() { + public SaveKeyringParcel createOperationInput() { return mSaveKeyringParcel; } @Override - protected void onCryptoOperationSuccess(OperationResult result) { + public void onCryptoOperationSuccess(OperationResult result) { // if good -> finish, return result to showkey and display there! Intent intent = new Intent(); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java index d7c6b2049..215af5885 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java @@ -386,7 +386,7 @@ public class EncryptFilesFragment } @Override - protected void onCryptoOperationSuccess(final SignEncryptResult result) { + public void onCryptoOperationSuccess(final SignEncryptResult result) { if (mDeleteAfterEncrypt) { // TODO make behavior coherent here @@ -485,7 +485,7 @@ public class EncryptFilesFragment } - protected SignEncryptParcel createOperationInput() { + public SignEncryptParcel createOperationInput() { SignEncryptParcel actionsParcel = getCachedActionsParcel(); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextFragment.java index e0629eb73..886c52651 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextFragment.java @@ -202,7 +202,7 @@ public class EncryptTextFragment } - protected SignEncryptParcel createOperationInput() { + public SignEncryptParcel createOperationInput() { if (mMessage == null || mMessage.isEmpty()) { Notify.create(getActivity(), R.string.error_empty_text, Notify.Style.ERROR) @@ -316,7 +316,7 @@ public class EncryptTextFragment } @Override - protected void onCryptoOperationSuccess(SignEncryptResult result) { + public void onCryptoOperationSuccess(SignEncryptResult result) { if (mShareAfterEncrypt) { // Share encrypted message/file diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyYubiKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyYubiKeyFragment.java index 10ce679f6..f8c3b59ea 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyYubiKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyYubiKeyFragment.java @@ -205,7 +205,7 @@ public class ViewKeyYubiKeyFragment } @Override - protected PromoteKeyringParcel createOperationInput() { + public PromoteKeyringParcel createOperationInput() { return new PromoteKeyringParcel(mMasterKeyId, mCardAid, mSubKeyIds); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/CachingCryptoOperationFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/CachingCryptoOperationFragment.java index 0f9601153..17e4e6ede 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/CachingCryptoOperationFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/CachingCryptoOperationFragment.java @@ -37,7 +37,7 @@ public abstract class CachingCryptoOperationFragment <T extends Parcelable, S ex } @Override - protected abstract T createOperationInput(); + public abstract T createOperationInput(); protected T getCachedActionsParcel() { return mCachedActionsParcel; @@ -47,7 +47,7 @@ public abstract class CachingCryptoOperationFragment <T extends Parcelable, S ex mCachedActionsParcel = cachedActionsParcel; } - protected void onCryptoOperationCancelled() { + public void onCryptoOperationCancelled() { mCachedActionsParcel = null; } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/CryptoOperationFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/CryptoOperationFragment.java index 31450c841..19d808ba6 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/CryptoOperationFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/CryptoOperationFragment.java @@ -29,43 +29,13 @@ import org.sufficientlysecure.keychain.service.input.CryptoInputParcel; * All fragments executing crypto operations need to extend this class. */ public abstract class CryptoOperationFragment<T extends Parcelable, S extends OperationResult> - extends Fragment { + extends Fragment implements CryptoOperationHelper.Callback<T, S> { private CryptoOperationHelper<T, S> mOperationHelper; public CryptoOperationFragment() { - // this is implemented here instead of by the fragment so that the corresponding methods in - // CryptoOperationFragment may continue using the "protected" modifier. - CryptoOperationHelper.Callback callback = new CryptoOperationHelper.Callback<T, S>() { - - @Override - public T createOperationInput() { - return CryptoOperationFragment.this.createOperationInput(); - } - - @Override - public void onCryptoOperationSuccess(S result) { - CryptoOperationFragment.this.onCryptoOperationSuccess(result); - } - - @Override - public void onCryptoOperationCancelled() { - CryptoOperationFragment.this.onCryptoOperationCancelled(); - } - - @Override - public void onCryptoOperationError(S result) { - CryptoOperationFragment.this.onCryptoOperationError(result); - } - - @Override - public boolean onCryptoSetProgress(String msg, int progress, int max) { - return CryptoOperationFragment.this.onCryptoSetProgress(msg, progress, max); - } - - }; - - mOperationHelper = new CryptoOperationHelper<>(this, callback); + + mOperationHelper = new CryptoOperationHelper<>(this, this); } public void setProgressMessageResource(int id) { @@ -78,7 +48,8 @@ public abstract class CryptoOperationFragment<T extends Parcelable, S extends Op mOperationHelper.handleActivityResult(requestCode, resultCode, data); } - protected abstract T createOperationInput(); + @Override + public abstract T createOperationInput(); protected void cryptoOperation() { cryptoOperation(new CryptoInputParcel()); @@ -92,19 +63,22 @@ public abstract class CryptoOperationFragment<T extends Parcelable, S extends Op mOperationHelper.cryptoOperation(cryptoInput, showProgress); } - protected boolean onCryptoSetProgress(String msg, int progress, int max) { + public boolean onCryptoSetProgress(String msg, int progress, int max) { return false; } - protected void onCryptoOperationError(S result) { + @Override + public void onCryptoOperationError(S result) { onCryptoOperationResult(result); result.createNotify(getActivity()).show(); } - protected void onCryptoOperationCancelled() { + @Override + public void onCryptoOperationCancelled() { } - protected void onCryptoOperationSuccess(S result) { + @Override + public void onCryptoOperationSuccess(S result) { onCryptoOperationResult(result); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/CryptoOperationHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/CryptoOperationHelper.java index 44c36e5f1..acac84e88 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/CryptoOperationHelper.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/CryptoOperationHelper.java @@ -52,7 +52,7 @@ import org.sufficientlysecure.keychain.util.Log; */ public class CryptoOperationHelper<T extends Parcelable, S extends OperationResult> { - public interface Callback <T extends Parcelable, S extends OperationResult> { + public interface Callback <T extends Parcelable, S extends OperationResult> { T createOperationInput(); void onCryptoOperationSuccess(S result); void onCryptoOperationCancelled(); |