diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java index 4e63656ec..80f4610a4 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java @@ -335,13 +335,13 @@ public class KeychainProvider extends ContentProvider { + " >= " + new Date().getTime() / 1000 + " )" + ")" : "") + (plist.contains(KeyRings.HAS_AUTHENTICATE) ? - " LEFT JOIN " + Tables.KEYS + " AS kS ON (" - +"kS." + Keys.MASTER_KEY_ID + " LEFT JOIN " + Tables.KEYS + " AS kA ON (" + +"kA." + Keys.MASTER_KEY_ID + " = " + Tables.KEYS + "." + Keys.MASTER_KEY_ID - + " AND kS." + Keys.IS_REVOKED + " = 0" - + " AND kS." + Keys.CAN_AUTHENTICATE + " = 1" - + " AND kS." + Keys.HAS_SECRET + " > 1" - + " AND ( kS." + Keys.EXPIRY + " IS NULL OR kS." + Keys.EXPIRY + + " AND kA." + Keys.IS_REVOKED + " = 0" + + " AND kA." + Keys.CAN_AUTHENTICATE + " = 1" + + " AND kA." + Keys.HAS_SECRET + " > 1" + + " AND ( kA." + Keys.EXPIRY + " IS NULL OR kA." + Keys.EXPIRY + " >= " + new Date().getTime() / 1000 + " )" + ")" : "") + (plist.contains(KeyRings.HAS_CERTIFY) ? 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 5aadaa2a2..70276bba3 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyFragment.java @@ -237,7 +237,7 @@ public class CertifyKeyFragment extends LoaderFragment if (data.moveToFirst()) { mPubKeyId = data.getLong(INDEX_MASTER_KEY_ID); mCertifyKeySpinner.setHiddenMasterKeyId(mPubKeyId); - String keyIdStr = KeyFormattingUtils.convertKeyIdToHex(mPubKeyId); + String keyIdStr = KeyFormattingUtils.beautifyKeyId(mPubKeyId); mInfoKeyId.setText(keyIdStr); String mainUserId = data.getString(INDEX_USER_ID); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeySpinner.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeySpinner.java index 975ea17c7..bb4ae3ab6 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeySpinner.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeySpinner.java @@ -151,21 +151,7 @@ public abstract class KeySpinner extends Spinner implements LoaderManager.Loader vKeyId.setText(KeyFormattingUtils.beautifyKeyIdWithPrefix(getContext(), cursor.getLong(mIndexKeyId))); boolean valid = setStatus(getContext(), cursor, vKeyStatus); - if (valid) { - vKeyName.setTextColor(Color.BLACK); - vKeyEmail.setTextColor(Color.BLACK); - vKeyId.setTextColor(Color.BLACK); - vKeyStatus.setVisibility(View.GONE); - view.setClickable(false); - } else { - vKeyName.setTextColor(Color.GRAY); - vKeyEmail.setTextColor(Color.GRAY); - vKeyId.setTextColor(Color.GRAY); - vKeyStatus.setVisibility(View.VISIBLE); - // this is a HACK. the trick is, if the element itself is clickable, the - // click is not passed on to the view list - view.setClickable(true); - } + setItemEnabled(view, valid); } @Override @@ -180,6 +166,29 @@ public abstract class KeySpinner extends Spinner implements LoaderManager.Loader }; } + private void setItemEnabled(View view, boolean enabled) { + TextView vKeyName = (TextView) view.findViewById(R.id.keyspinner_key_name); + ImageView vKeyStatus = (ImageView) view.findViewById(R.id.keyspinner_key_status); + TextView vKeyEmail = (TextView) view.findViewById(R.id.keyspinner_key_email); + TextView vKeyId = (TextView) view.findViewById(R.id.keyspinner_key_id); + + if (enabled) { + vKeyName.setTextColor(Color.BLACK); + vKeyEmail.setTextColor(Color.BLACK); + vKeyId.setTextColor(Color.BLACK); + vKeyStatus.setVisibility(View.GONE); + view.setClickable(false); + } else { + vKeyName.setTextColor(Color.GRAY); + vKeyEmail.setTextColor(Color.GRAY); + vKeyId.setTextColor(Color.GRAY); + vKeyStatus.setVisibility(View.VISIBLE); + // this is a HACK. the trick is, if the element itself is clickable, the + // click is not passed on to the view list + view.setClickable(true); + } + } + public Cursor swapCursor(Cursor newCursor) { if (newCursor == null) return inner.swapCursor(null); @@ -227,23 +236,31 @@ public abstract class KeySpinner extends Spinner implements LoaderManager.Loader @Override public View getDropDownView(int position, View convertView, ViewGroup parent) { - View v; + View view; if (position == 0) { if (convertView == null) { - v = inner.newView(null, null, parent); + view = inner.newView(null, null, parent); } else { - v = convertView; + view = convertView; } - ((TextView) v.findViewById(R.id.keyspinner_key_name)).setText(R.string.choice_none); - v.findViewById(R.id.keyspinner_key_email).setVisibility(View.GONE); - v.findViewById(R.id.keyspinner_key_id).setVisibility(View.GONE); - v.findViewById(R.id.keyspinner_key_status).setVisibility(View.GONE); + TextView vKeyName = (TextView) view.findViewById(R.id.keyspinner_key_name); + ImageView vKeyStatus = (ImageView) view.findViewById(R.id.keyspinner_key_status); + TextView vKeyEmail = (TextView) view.findViewById(R.id.keyspinner_key_email); + TextView vKeyId = (TextView) view.findViewById(R.id.keyspinner_key_id); + + vKeyName.setText(R.string.choice_none); + vKeyEmail.setVisibility(View.GONE); + vKeyId.setVisibility(View.GONE); + vKeyStatus.setVisibility(View.GONE); + setItemEnabled(view, true); } else { - v = inner.getView(position - 1, convertView, parent); - v.findViewById(R.id.keyspinner_key_email).setVisibility(View.VISIBLE); - v.findViewById(R.id.keyspinner_key_id).setVisibility(View.VISIBLE); + view = inner.getView(position - 1, convertView, parent); + TextView vKeyEmail = (TextView) view.findViewById(R.id.keyspinner_key_email); + TextView vKeyId = (TextView) view.findViewById(R.id.keyspinner_key_id); + vKeyEmail.setVisibility(View.VISIBLE); + vKeyId.setVisibility(View.VISIBLE); } - return v; + return view; } }