pre-select certification key if only one is available

This commit is contained in:
Vincent Breitmoser 2015-02-26 10:48:17 +01:00
parent 72acaaa41f
commit ad8209bd94

View File

@ -86,16 +86,17 @@ public class CertifyKeySpinner extends KeySpinner {
super.onLoadFinished(loader, data); super.onLoadFinished(loader, data);
if (loader.getId() == LOADER_ID) { if (loader.getId() == LOADER_ID) {
// If there is only one choice, pick it by default
if (mAdapter.getCount() == 2) {
// preselect if key can certify
if (data.moveToPosition(1) && !data.isNull(mIndexHasCertify)) {
setSelection(1);
}
}
mIndexHasCertify = data.getColumnIndex(KeychainContract.KeyRings.HAS_CERTIFY); mIndexHasCertify = data.getColumnIndex(KeychainContract.KeyRings.HAS_CERTIFY);
mIndexIsRevoked = data.getColumnIndex(KeychainContract.KeyRings.IS_REVOKED); mIndexIsRevoked = data.getColumnIndex(KeychainContract.KeyRings.IS_REVOKED);
mIndexIsExpired = data.getColumnIndex(KeychainContract.KeyRings.IS_EXPIRED); mIndexIsExpired = data.getColumnIndex(KeychainContract.KeyRings.IS_EXPIRED);
// If there is only one choice, pick it by default
if (mAdapter.getCount() == 2) {
// preselect if key can certify
if (data.moveToPosition(0) && !data.isNull(mIndexHasCertify)) {
setSelection(1);
}
}
} }
} }