mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-04 16:25:05 -05:00
Fixes for selection of certify key
This commit is contained in:
parent
ff60e80d42
commit
e873bac880
@ -93,22 +93,31 @@ public class CertifyKeySpinner extends KeySpinner {
|
||||
mIndexIsRevoked = data.getColumnIndex(KeychainContract.KeyRings.IS_REVOKED);
|
||||
mIndexIsExpired = data.getColumnIndex(KeychainContract.KeyRings.IS_EXPIRED);
|
||||
|
||||
// If there is more than one choice, pick a key
|
||||
if (mAdapter.getCount() >= 2) {
|
||||
// If:
|
||||
// - no key has been pre-selected (e.g. by SageSlinger)
|
||||
// - there are actually keys (not just "none" entry)
|
||||
// Then:
|
||||
// - select key that is capable of certifying, but only if there is only one key capable of it
|
||||
if (mSelectedKeyId == Constants.key.none && mAdapter.getCount() > 1) {
|
||||
// preselect if key can certify
|
||||
if (data.moveToPosition(0)) {
|
||||
do {
|
||||
if (!data.isNull(mIndexHasCertify)) {
|
||||
setSelection(data.getPosition() + 1);
|
||||
break;
|
||||
int selection = -1;
|
||||
while (data.moveToNext()) {
|
||||
if (!data.isNull(mIndexHasCertify)) {
|
||||
if (selection == -1) {
|
||||
selection = data.getPosition() + 1;
|
||||
} else {
|
||||
// if selection is already set, we have more than one certify key!
|
||||
// get back to "none"!
|
||||
selection = 0;
|
||||
}
|
||||
}
|
||||
while (data.moveToNext());
|
||||
}
|
||||
setSelection(selection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
boolean setStatus(Context context, Cursor cursor, ImageView statusView) {
|
||||
if (cursor.getInt(mIndexIsRevoked) != 0) {
|
||||
|
@ -55,7 +55,7 @@ public abstract class KeySpinner extends TintSpinner implements LoaderManager.Lo
|
||||
public void onKeyChanged(long masterKeyId);
|
||||
}
|
||||
|
||||
protected long mSelectedKeyId;
|
||||
protected long mSelectedKeyId = Constants.key.none;
|
||||
protected SelectKeyAdapter mAdapter = new SelectKeyAdapter();
|
||||
protected OnKeyChangedListener mListener;
|
||||
|
||||
@ -227,7 +227,9 @@ public abstract class KeySpinner extends TintSpinner implements LoaderManager.Lo
|
||||
mIndexUserId = newCursor.getColumnIndex(KeychainContract.KeyRings.USER_ID);
|
||||
mIndexMasterKeyId = newCursor.getColumnIndex(KeychainContract.KeyRings.MASTER_KEY_ID);
|
||||
mIndexCreationDate = newCursor.getColumnIndex(KeychainContract.KeyRings.CREATION);
|
||||
if (newCursor.moveToFirst()) {
|
||||
|
||||
// pre-select key if mSelectedKeyId is given
|
||||
if (mSelectedKeyId != Constants.key.none && newCursor.moveToFirst()) {
|
||||
do {
|
||||
if (newCursor.getLong(mIndexMasterKeyId) == mSelectedKeyId) {
|
||||
setSelection(newCursor.getPosition() + 1);
|
||||
|
Loading…
Reference in New Issue
Block a user