Fix revoked/expired state in decrypt activity

This commit is contained in:
Dominik Schürmann 2015-05-04 21:13:07 +02:00
parent 2583f77f07
commit 291f95db5a
4 changed files with 27 additions and 37 deletions

View File

@ -309,7 +309,7 @@ public class DecryptFilesFragment extends DecryptFragment {
} }
@Override @Override
protected void onVerifyLoaded(boolean verified) { protected void onVerifyLoaded(boolean hideErrorOverlay) {
} }
} }

View File

@ -55,7 +55,6 @@ import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.ui.util.Notify.Style; import org.sufficientlysecure.keychain.ui.util.Notify.Style;
import org.sufficientlysecure.keychain.util.Preferences; import org.sufficientlysecure.keychain.util.Preferences;
public abstract class DecryptFragment extends CryptoOperationFragment implements public abstract class DecryptFragment extends CryptoOperationFragment implements
LoaderManager.LoaderCallbacks<Cursor> { LoaderManager.LoaderCallbacks<Cursor> {
@ -91,7 +90,6 @@ public abstract class DecryptFragment extends CryptoOperationFragment implements
mSignatureName = (TextView) getActivity().findViewById(R.id.result_signature_name); mSignatureName = (TextView) getActivity().findViewById(R.id.result_signature_name);
mSignatureEmail = (TextView) getActivity().findViewById(R.id.result_signature_email); mSignatureEmail = (TextView) getActivity().findViewById(R.id.result_signature_email);
mSignatureAction = (TextView) getActivity().findViewById(R.id.result_signature_action); mSignatureAction = (TextView) getActivity().findViewById(R.id.result_signature_action);
} }
private void lookupUnknownKey(long unknownKeyId) { private void lookupUnknownKey(long unknownKeyId) {
@ -113,12 +111,9 @@ public abstract class DecryptFragment extends CryptoOperationFragment implements
final ImportKeyResult result = final ImportKeyResult result =
returnData.getParcelable(OperationResult.EXTRA_RESULT); returnData.getParcelable(OperationResult.EXTRA_RESULT);
// if (!result.success()) { result.createNotify(getActivity()).show();
result.createNotify(getActivity()).show();
// }
getLoaderManager().restartLoader(LOADER_ID_UNIFIED, null, DecryptFragment.this); getLoaderManager().restartLoader(LOADER_ID_UNIFIED, null, DecryptFragment.this);
} }
} }
}; };
@ -153,7 +148,6 @@ public abstract class DecryptFragment extends CryptoOperationFragment implements
intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger); intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);
getActivity().startService(intent); getActivity().startService(intent);
} }
private void showKey(long keyId) { private void showKey(long keyId) {
@ -205,7 +199,6 @@ public abstract class DecryptFragment extends CryptoOperationFragment implements
} }
getLoaderManager().restartLoader(LOADER_ID_UNIFIED, null, this); getLoaderManager().restartLoader(LOADER_ID_UNIFIED, null, this);
} }
private void setSignatureLayoutVisibility(int visibility) { private void setSignatureLayoutVisibility(int visibility) {
@ -228,8 +221,6 @@ public abstract class DecryptFragment extends CryptoOperationFragment implements
KeychainContract.KeyRings._ID, KeychainContract.KeyRings._ID,
KeychainContract.KeyRings.MASTER_KEY_ID, KeychainContract.KeyRings.MASTER_KEY_ID,
KeychainContract.KeyRings.USER_ID, KeychainContract.KeyRings.USER_ID,
KeychainContract.KeyRings.IS_REVOKED,
KeychainContract.KeyRings.IS_EXPIRED,
KeychainContract.KeyRings.VERIFIED, KeychainContract.KeyRings.VERIFIED,
KeychainContract.KeyRings.HAS_ANY_SECRET, KeychainContract.KeyRings.HAS_ANY_SECRET,
}; };
@ -237,10 +228,8 @@ public abstract class DecryptFragment extends CryptoOperationFragment implements
@SuppressWarnings("unused") @SuppressWarnings("unused")
static final int INDEX_MASTER_KEY_ID = 1; static final int INDEX_MASTER_KEY_ID = 1;
static final int INDEX_USER_ID = 2; static final int INDEX_USER_ID = 2;
static final int INDEX_IS_REVOKED = 3; static final int INDEX_VERIFIED = 3;
static final int INDEX_IS_EXPIRED = 4; static final int INDEX_HAS_ANY_SECRET = 4;
static final int INDEX_VERIFIED = 5;
static final int INDEX_HAS_ANY_SECRET = 6;
@Override @Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) { public Loader<Cursor> onCreateLoader(int id, Bundle args) {
@ -282,8 +271,10 @@ public abstract class DecryptFragment extends CryptoOperationFragment implements
getActivity(), mSignatureResult.getKeyId())); getActivity(), mSignatureResult.getKeyId()));
} }
boolean isRevoked = data.getInt(INDEX_IS_REVOKED) != 0; // NOTE: Don't use revoked and expired fields from database, they don't show
boolean isExpired = data.getInt(INDEX_IS_EXPIRED) != 0; // revoked/expired subkeys
boolean isRevoked = mSignatureResult.getStatus() == OpenPgpSignatureResult.SIGNATURE_KEY_REVOKED;
boolean isExpired = mSignatureResult.getStatus() == OpenPgpSignatureResult.SIGNATURE_KEY_EXPIRED;
boolean isVerified = data.getInt(INDEX_VERIFIED) > 0; boolean isVerified = data.getInt(INDEX_VERIFIED) > 0;
boolean isYours = data.getInt(INDEX_HAS_ANY_SECRET) != 0; boolean isYours = data.getInt(INDEX_HAS_ANY_SECRET) != 0;
@ -344,7 +335,6 @@ public abstract class DecryptFragment extends CryptoOperationFragment implements
} }
setSignatureLayoutVisibility(View.GONE); setSignatureLayoutVisibility(View.GONE);
} }
private void showUnknownKeyStatus() { private void showUnknownKeyStatus() {
@ -407,6 +397,6 @@ public abstract class DecryptFragment extends CryptoOperationFragment implements
} }
protected abstract void onVerifyLoaded(boolean verified); protected abstract void onVerifyLoaded(boolean hideErrorOverlay);
} }

View File

@ -50,8 +50,8 @@ public class DecryptTextFragment extends DecryptFragment {
public static final String ARG_CIPHERTEXT = "ciphertext"; public static final String ARG_CIPHERTEXT = "ciphertext";
// view // view
private LinearLayout mValidLayout; private LinearLayout mContentLayout;
private LinearLayout mInvalidLayout; private LinearLayout mErrorOverlayLayout;
private TextView mText; private TextView mText;
// model // model
@ -78,16 +78,16 @@ public class DecryptTextFragment extends DecryptFragment {
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.decrypt_text_fragment, container, false); View view = inflater.inflate(R.layout.decrypt_text_fragment, container, false);
mValidLayout = (LinearLayout) view.findViewById(R.id.decrypt_text_valid); mContentLayout = (LinearLayout) view.findViewById(R.id.decrypt_content);
mInvalidLayout = (LinearLayout) view.findViewById(R.id.decrypt_text_invalid); mErrorOverlayLayout = (LinearLayout) view.findViewById(R.id.decrypt_error_overlay);
mText = (TextView) view.findViewById(R.id.decrypt_text_plaintext); mText = (TextView) view.findViewById(R.id.decrypt_text_plaintext);
Button vInvalidButton = (Button) view.findViewById(R.id.decrypt_text_invalid_button); Button vErrorOverlayButton = (Button) view.findViewById(R.id.decrypt_error_overlay_button);
vInvalidButton.setOnClickListener(new View.OnClickListener() { vErrorOverlayButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
mInvalidLayout.setVisibility(View.GONE); mErrorOverlayLayout.setVisibility(View.GONE);
mValidLayout.setVisibility(View.VISIBLE); mContentLayout.setVisibility(View.VISIBLE);
} }
}); });
@ -244,17 +244,17 @@ public class DecryptTextFragment extends DecryptFragment {
} }
@Override @Override
protected void onVerifyLoaded(boolean verified) { protected void onVerifyLoaded(boolean hideErrorOverlay) {
mShowMenuOptions = verified; mShowMenuOptions = hideErrorOverlay;
getActivity().supportInvalidateOptionsMenu(); getActivity().supportInvalidateOptionsMenu();
if (verified) { if (hideErrorOverlay) {
mInvalidLayout.setVisibility(View.GONE); mErrorOverlayLayout.setVisibility(View.GONE);
mValidLayout.setVisibility(View.VISIBLE); mContentLayout.setVisibility(View.VISIBLE);
} else { } else {
mInvalidLayout.setVisibility(View.VISIBLE); mErrorOverlayLayout.setVisibility(View.VISIBLE);
mValidLayout.setVisibility(View.GONE); mContentLayout.setVisibility(View.GONE);
} }
} }

View File

@ -6,7 +6,7 @@
<LinearLayout <LinearLayout
android:visibility="gone" android:visibility="gone"
android:id="@+id/decrypt_text_valid" android:id="@+id/decrypt_content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical"> android:orientation="vertical">
@ -36,7 +36,7 @@
<LinearLayout <LinearLayout
android:visibility="gone" android:visibility="gone"
android:id="@+id/decrypt_text_invalid" android:id="@+id/decrypt_error_overlay"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
@ -52,7 +52,7 @@
android:textColor="@color/android_red_light" /> android:textColor="@color/android_red_light" />
<Button <Button
android:id="@+id/decrypt_text_invalid_button" android:id="@+id/decrypt_error_overlay_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/button_edgy" android:background="@drawable/button_edgy"