key spinner fixes

This commit is contained in:
Dominik Schürmann 2014-09-21 12:03:25 +02:00
parent 08ad0cb305
commit 1d38365a61
3 changed files with 50 additions and 33 deletions

View File

@ -335,13 +335,13 @@ public class KeychainProvider extends ContentProvider {
+ " >= " + new Date().getTime() / 1000 + " )" + " >= " + new Date().getTime() / 1000 + " )"
+ ")" : "") + ")" : "")
+ (plist.contains(KeyRings.HAS_AUTHENTICATE) ? + (plist.contains(KeyRings.HAS_AUTHENTICATE) ?
" LEFT JOIN " + Tables.KEYS + " AS kS ON (" " LEFT JOIN " + Tables.KEYS + " AS kA ON ("
+"kS." + Keys.MASTER_KEY_ID +"kA." + Keys.MASTER_KEY_ID
+ " = " + Tables.KEYS + "." + Keys.MASTER_KEY_ID + " = " + Tables.KEYS + "." + Keys.MASTER_KEY_ID
+ " AND kS." + Keys.IS_REVOKED + " = 0" + " AND kA." + Keys.IS_REVOKED + " = 0"
+ " AND kS." + Keys.CAN_AUTHENTICATE + " = 1" + " AND kA." + Keys.CAN_AUTHENTICATE + " = 1"
+ " AND kS." + Keys.HAS_SECRET + " > 1" + " AND kA." + Keys.HAS_SECRET + " > 1"
+ " AND ( kS." + Keys.EXPIRY + " IS NULL OR kS." + Keys.EXPIRY + " AND ( kA." + Keys.EXPIRY + " IS NULL OR kA." + Keys.EXPIRY
+ " >= " + new Date().getTime() / 1000 + " )" + " >= " + new Date().getTime() / 1000 + " )"
+ ")" : "") + ")" : "")
+ (plist.contains(KeyRings.HAS_CERTIFY) ? + (plist.contains(KeyRings.HAS_CERTIFY) ?

View File

@ -237,7 +237,7 @@ public class CertifyKeyFragment extends LoaderFragment
if (data.moveToFirst()) { if (data.moveToFirst()) {
mPubKeyId = data.getLong(INDEX_MASTER_KEY_ID); mPubKeyId = data.getLong(INDEX_MASTER_KEY_ID);
mCertifyKeySpinner.setHiddenMasterKeyId(mPubKeyId); mCertifyKeySpinner.setHiddenMasterKeyId(mPubKeyId);
String keyIdStr = KeyFormattingUtils.convertKeyIdToHex(mPubKeyId); String keyIdStr = KeyFormattingUtils.beautifyKeyId(mPubKeyId);
mInfoKeyId.setText(keyIdStr); mInfoKeyId.setText(keyIdStr);
String mainUserId = data.getString(INDEX_USER_ID); String mainUserId = data.getString(INDEX_USER_ID);

View File

@ -151,21 +151,7 @@ public abstract class KeySpinner extends Spinner implements LoaderManager.Loader
vKeyId.setText(KeyFormattingUtils.beautifyKeyIdWithPrefix(getContext(), cursor.getLong(mIndexKeyId))); vKeyId.setText(KeyFormattingUtils.beautifyKeyIdWithPrefix(getContext(), cursor.getLong(mIndexKeyId)));
boolean valid = setStatus(getContext(), cursor, vKeyStatus); boolean valid = setStatus(getContext(), cursor, vKeyStatus);
if (valid) { setItemEnabled(view, 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);
}
} }
@Override @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) { public Cursor swapCursor(Cursor newCursor) {
if (newCursor == null) return inner.swapCursor(null); if (newCursor == null) return inner.swapCursor(null);
@ -227,23 +236,31 @@ public abstract class KeySpinner extends Spinner implements LoaderManager.Loader
@Override @Override
public View getDropDownView(int position, View convertView, ViewGroup parent) { public View getDropDownView(int position, View convertView, ViewGroup parent) {
View v; View view;
if (position == 0) { if (position == 0) {
if (convertView == null) { if (convertView == null) {
v = inner.newView(null, null, parent); view = inner.newView(null, null, parent);
} else { } else {
v = convertView; view = convertView;
} }
((TextView) v.findViewById(R.id.keyspinner_key_name)).setText(R.string.choice_none); TextView vKeyName = (TextView) view.findViewById(R.id.keyspinner_key_name);
v.findViewById(R.id.keyspinner_key_email).setVisibility(View.GONE); ImageView vKeyStatus = (ImageView) view.findViewById(R.id.keyspinner_key_status);
v.findViewById(R.id.keyspinner_key_id).setVisibility(View.GONE); TextView vKeyEmail = (TextView) view.findViewById(R.id.keyspinner_key_email);
v.findViewById(R.id.keyspinner_key_status).setVisibility(View.GONE); 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 { } else {
v = inner.getView(position - 1, convertView, parent); view = inner.getView(position - 1, convertView, parent);
v.findViewById(R.id.keyspinner_key_email).setVisibility(View.VISIBLE); TextView vKeyEmail = (TextView) view.findViewById(R.id.keyspinner_key_email);
v.findViewById(R.id.keyspinner_key_id).setVisibility(View.VISIBLE); TextView vKeyId = (TextView) view.findViewById(R.id.keyspinner_key_id);
vKeyEmail.setVisibility(View.VISIBLE);
vKeyId.setVisibility(View.VISIBLE);
} }
return v; return view;
} }
} }