diff options
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java index 118449b9b..6de03198e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java @@ -41,18 +41,22 @@ public class SelectSecretKeyFragment extends ListFragment implements private SelectSecretKeyActivity mActivity; private SelectKeyCursorAdapter mAdapter; - private boolean mFilterCertify; + private boolean mFilterCertify, mFilterSign; private static final String ARG_FILTER_CERTIFY = "filter_certify"; + private static final String ARG_FILTER_SIGN = "filter_sign"; /** * Creates new instance of this fragment + * + * filterCertify and filterSign must not both be set! */ - public static SelectSecretKeyFragment newInstance(boolean filterCertify) { + public static SelectSecretKeyFragment newInstance(boolean filterCertify, boolean filterSign) { SelectSecretKeyFragment frag = new SelectSecretKeyFragment(); Bundle args = new Bundle(); args.putBoolean(ARG_FILTER_CERTIFY, filterCertify); + args.putBoolean(ARG_FILTER_CERTIFY, filterSign); frag.setArguments(args); return frag; @@ -63,6 +67,7 @@ public class SelectSecretKeyFragment extends ListFragment implements super.onCreate(savedInstanceState); mFilterCertify = getArguments().getBoolean(ARG_FILTER_CERTIFY); + mFilterSign = getArguments().getBoolean(ARG_FILTER_SIGN); } /** @@ -115,9 +120,10 @@ public class SelectSecretKeyFragment extends ListFragment implements KeyRings.USER_ID, KeyRings.EXPIRY, KeyRings.IS_REVOKED, + // can certify info only related to master key KeyRings.CAN_CERTIFY, + // has sign may be any subkey KeyRings.HAS_SIGN, - KeyRings.HAS_SECRET, KeyRings.HAS_ANY_SECRET }; @@ -152,7 +158,7 @@ public class SelectSecretKeyFragment extends ListFragment implements private class SelectSecretKeyCursorAdapter extends SelectKeyCursorAdapter { - private int mIndexHasSecret, mIndexHasSign, mIndexCanCertify; + private int mIndexHasSign, mIndexCanCertify; public SelectSecretKeyCursorAdapter(Context context, Cursor c, int flags, ListView listView) { super(context, c, flags, listView); @@ -162,7 +168,6 @@ public class SelectSecretKeyFragment extends ListFragment implements protected void initIndex(Cursor cursor) { super.initIndex(cursor); if (cursor != null) { - mIndexHasSecret = cursor.getColumnIndexOrThrow(KeyRings.HAS_SECRET); mIndexCanCertify = cursor.getColumnIndexOrThrow(KeyRings.CAN_CERTIFY); mIndexHasSign = cursor.getColumnIndexOrThrow(KeyRings.HAS_SIGN); } @@ -179,23 +184,26 @@ public class SelectSecretKeyFragment extends ListFragment implements // Special from superclass: Te boolean enabled = false; if((Boolean) h.status.getTag()) { - if (cursor.getInt(mIndexHasSecret) == 0) { - h.status.setText(R.string.no_subkey); // Check if key is viable for our purposes (certify or sign) - } else if(mFilterCertify) { + if(mFilterCertify) { + // Only enable if can certify if (cursor.getInt(mIndexCanCertify) == 0) { h.status.setText(R.string.can_certify_not); } else { h.status.setText(R.string.can_certify); enabled = true; } - } else { + } else if(mFilterSign) { + // Only enable if can sign if (cursor.getInt(mIndexHasSign) == 0) { - h.status.setText(R.string.no_key); + h.status.setText(R.string.can_sign_not); } else { h.status.setText(R.string.can_sign); enabled = true; } + } else { + // No filters, just enable + enabled = true; } } h.setEnabled(enabled); |