minor fixes to ViewKeyActivity
This commit is contained in:
parent
c249198279
commit
b093365747
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
android:id="@+id/user_id_item_comment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="?attr/colorTertiaryText"
|
||||
android:text="comment"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
|
|
Loading…
Reference in a new issue