diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2016-01-05 19:24:43 +0100 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2016-01-05 19:24:43 +0100 |
commit | b09336574769ea4098a29d52fa8cd4303b1f0500 (patch) | |
tree | a8beecc3026627d9a3c922bad7bcd38133b332a5 /OpenKeychain/src/main/java/org/sufficientlysecure | |
parent | c2491982798756ab211c6ad811390b57c648cd51 (diff) | |
download | open-keychain-b09336574769ea4098a29d52fa8cd4303b1f0500.tar.gz open-keychain-b09336574769ea4098a29d52fa8cd4303b1f0500.tar.bz2 open-keychain-b09336574769ea4098a29d52fa8cd4303b1f0500.zip |
minor fixes to ViewKeyActivity
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure')
5 files changed, 41 insertions, 57 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditIdentitiesActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditIdentitiesActivity.java index 6f65e9cef..cbe025eea 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditIdentitiesActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditIdentitiesActivity.java @@ -54,17 +54,11 @@ public class EditIdentitiesActivity extends BaseActivity { return; } - // Create an instance of the fragment - EditIdentitiesFragment mEditIdentitiesFragment; - mEditIdentitiesFragment = EditIdentitiesFragment.newInstance(dataUri); + EditIdentitiesFragment editIdentitiesFragment = EditIdentitiesFragment.newInstance(dataUri); - // Add the fragment to the 'fragment_container' FrameLayout - // NOTE: We use commitAllowingStateLoss() to prevent weird crashes! getSupportFragmentManager().beginTransaction() - .replace(R.id.edit_key_fragment_container, mEditIdentitiesFragment) - .commitAllowingStateLoss(); - // do it immediately! - getSupportFragmentManager().executePendingTransactions(); + .replace(R.id.edit_key_fragment_container, editIdentitiesFragment) + .commit(); } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditIdentitiesFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditIdentitiesFragment.java index cfd3f3cea..aec0bb711 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditIdentitiesFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EditIdentitiesFragment.java @@ -17,6 +17,7 @@ package org.sufficientlysecure.keychain.ui; + import android.app.Activity; import android.content.Intent; import android.database.Cursor; @@ -344,7 +345,7 @@ public class EditIdentitiesFragment extends Fragment @Override public void onCryptoOperationSuccess(EditKeyResult result) { - if (result.mMasterKeyId != null && mUploadKeyCheckbox.isChecked()) { + if (mUploadKeyCheckbox.isChecked()) { // result will be displayed after upload uploadKey(result); return; @@ -381,7 +382,10 @@ public class EditIdentitiesFragment extends Fragment return; } - // set data uri as path to keyring + if (editKeyResult.mMasterKeyId == null) { + throw new AssertionError("A successful edit key result must include a master key id!"); + } + final long masterKeyId = editKeyResult.mMasterKeyId; // upload to favorite keyserver final String keyserver = Preferences.getPreferences(activity).getPreferredKeyserver(); @@ -424,20 +428,6 @@ public class EditIdentitiesFragment extends Fragment mUploadOpHelper.cryptoOperation(); } - /** - * Closes this activity, returning a result parcel with a single error log entry. - */ - void finishWithError(LogType reason) { - // Prepare an intent with an EXTRA_RESULT - Intent intent = new Intent(); - intent.putExtra(OperationResult.EXTRA_RESULT, - new SingletonResult(SingletonResult.RESULT_ERROR, reason)); - - // Finish with result - getActivity().setResult(Activity.RESULT_OK, intent); - getActivity().finish(); - } - private void displayResult(OperationResult result) { Activity activity = getActivity(); if (activity == null) { @@ -446,6 +436,11 @@ public class EditIdentitiesFragment extends Fragment result.createNotify(activity).show(); } + void finishWithError(LogType reason) { + SingletonResult errorResult = new SingletonResult(SingletonResult.RESULT_ERROR, reason); + finishWithResult(errorResult); + } + public void finishWithResult(OperationResult result) { Activity activity = getActivity(); if (activity == null) { @@ -457,5 +452,4 @@ public class EditIdentitiesFragment extends Fragment activity.setResult(Activity.RESULT_OK, data); activity.finish(); } - } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index 1db273e48..4de89d859 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -20,6 +20,8 @@ package org.sufficientlysecure.keychain.ui; import java.io.IOException; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import android.animation.ArgbEvaluator; @@ -39,6 +41,7 @@ import android.os.Handler; import android.os.Message; import android.os.Messenger; import android.provider.ContactsContract; +import android.support.annotation.IntDef; import android.support.design.widget.AppBarLayout; import android.support.design.widget.CollapsingToolbarLayout; import android.support.design.widget.CoordinatorLayout; @@ -106,6 +109,9 @@ public class ViewKeyActivity extends BaseNfcActivity implements public static final String EXTRA_NFC_AID = "nfc_aid"; public static final String EXTRA_NFC_FINGERPRINTS = "nfc_fingerprints"; + @Retention(RetentionPolicy.SOURCE) + @IntDef({REQUEST_QR_FINGERPRINT, REQUEST_BACKUP, REQUEST_CERTIFY, REQUEST_DELETE}) + private @interface RequestType {} static final int REQUEST_QR_FINGERPRINT = 1; static final int REQUEST_BACKUP = 2; static final int REQUEST_CERTIFY = 3; @@ -574,7 +580,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements } @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { + protected void onActivityResult(@RequestType int requestCode, int resultCode, Intent data) { if (mImportOpHelper.handleActivityResult(requestCode, resultCode, data)) { return; } @@ -582,13 +588,14 @@ public class ViewKeyActivity extends BaseNfcActivity implements mEditOpHelper.handleActivityResult(requestCode, resultCode, data); } + if (resultCode != Activity.RESULT_OK) { + super.onActivityResult(requestCode, resultCode, data); + return; + } + switch (requestCode) { case REQUEST_QR_FINGERPRINT: { - if (resultCode != Activity.RESULT_OK) { - return; - } - // If there is an EXTRA_RESULT, that's an error. Just show it. if (data.hasExtra(OperationResult.EXTRA_RESULT)) { OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT); @@ -610,19 +617,17 @@ public class ViewKeyActivity extends BaseNfcActivity implements } case REQUEST_BACKUP: { - if (resultCode != Activity.RESULT_OK) { - return; - } - startBackupActivity(); return; } - case REQUEST_CERTIFY: { - if (resultCode != Activity.RESULT_OK) { - return; - } + case REQUEST_DELETE: { + setResult(RESULT_OK, data); + finish(); + return; + } + case REQUEST_CERTIFY: { if (data.hasExtra(OperationResult.EXTRA_RESULT)) { OperationResult result = data.getParcelableExtra(OperationResult.EXTRA_RESULT); result.createNotify(this).show(); @@ -630,15 +635,6 @@ public class ViewKeyActivity extends BaseNfcActivity implements return; } - case REQUEST_DELETE: { - if (resultCode != Activity.RESULT_OK) { - return; - } - - setResult(RESULT_OK, data); - finish(); - return; - } } super.onActivityResult(requestCode, resultCode, data); @@ -935,7 +931,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements mStatusImage.setVisibility(View.VISIBLE); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, State.REVOKED, R.color.icons, true); - color = getResources().getColor(R.color.key_flag_red); + color = getResources().getColor(R.color.key_flag_red, null); mActionEncryptFile.setVisibility(View.INVISIBLE); mActionEncryptText.setVisibility(View.INVISIBLE); @@ -951,7 +947,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements mStatusImage.setVisibility(View.VISIBLE); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, State.EXPIRED, R.color.icons, true); - color = getResources().getColor(R.color.key_flag_red); + color = getResources().getColor(R.color.key_flag_red, null); mActionEncryptFile.setVisibility(View.INVISIBLE); mActionEncryptText.setVisibility(View.INVISIBLE); @@ -961,7 +957,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements } else if (mIsSecret) { mStatusText.setText(R.string.view_key_my_key); mStatusImage.setVisibility(View.GONE); - color = getResources().getColor(R.color.key_flag_green); + color = getResources().getColor(R.color.key_flag_green, null); // reload qr code only if the fingerprint changed if (!mFingerprintString.equals(mQrCodeLoaded)) { loadQrCode(mFingerprintString); @@ -1013,7 +1009,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements mStatusImage.setVisibility(View.VISIBLE); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, State.VERIFIED, R.color.icons, true); - color = getResources().getColor(R.color.key_flag_green); + color = getResources().getColor(R.color.key_flag_green, null); photoTask.execute(mMasterKeyId); hideFab(); @@ -1022,7 +1018,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements mStatusImage.setVisibility(View.VISIBLE); KeyFormattingUtils.setStatusImage(this, mStatusImage, mStatusText, State.UNVERIFIED, R.color.icons, true); - color = getResources().getColor(R.color.key_flag_orange); + color = getResources().getColor(R.color.key_flag_orange, null); showFab(); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java index 89dd90ff7..8cb1e03af 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java @@ -79,7 +79,7 @@ public class ViewKeyFragment extends LoaderFragment implements private ListView mUserIds; enum PostponeType { - NONE, LINKED; + NONE, LINKED } boolean mIsSecret = false; @@ -118,7 +118,7 @@ public class ViewKeyFragment extends LoaderFragment implements ViewKeyFragment frag = new ViewKeyFragment(); Bundle args = new Bundle(); args.putParcelable(ARG_DATA_URI, dataUri); - args.putInt(ARG_POSTPONE_TYPE, postponeType.ordinal()); + args.putString(ARG_POSTPONE_TYPE, postponeType.toString()); frag.setArguments(args); @@ -316,7 +316,7 @@ public class ViewKeyFragment extends LoaderFragment implements super.onActivityCreated(savedInstanceState); Uri dataUri = getArguments().getParcelable(ARG_DATA_URI); - mPostponeType = PostponeType.values()[getArguments().getInt(ARG_POSTPONE_TYPE, 0)]; + mPostponeType = PostponeType.valueOf(getArguments().getString(ARG_POSTPONE_TYPE)); if (dataUri == null) { Log.e(Constants.TAG, "Data missing. Should be Uri of key!"); getActivity().finish(); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java index 7dee90b4e..e86a7812e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java @@ -65,7 +65,7 @@ public class UserIdsAdapter extends UserAttributesAdapter { TextView vComment = (TextView) view.findViewById(R.id.user_id_item_comment); ImageView vVerified = (ImageView) view.findViewById(R.id.user_id_item_certified); ViewAnimator vVerifiedLayout = (ViewAnimator) view.findViewById(R.id.user_id_icon_animator); - ImageView vEditImage = (ImageView) view.findViewById(R.id.user_id_item_edit_image); + ImageView vDeleteButton = (ImageView) view.findViewById(R.id.user_id_item_delete_button); vDeleteButton.setVisibility(View.GONE); // not used |