don't show key spinner for a single entry

This commit is contained in:
Vincent Breitmoser
2015-04-24 15:44:53 +02:00
parent b12aa63cb3
commit ead7597afc
2 changed files with 10 additions and 1 deletions

View File

@@ -298,7 +298,9 @@ public class LinkedIdViewFragment extends CryptoOperationFragment implements
vProgress.setDisplayedChild(1);
if (!isSecret) {
showButton(2);
vKeySpinnerContainer.setVisibility(View.VISIBLE);
if (!vKeySpinner.isSingleEntry()) {
vKeySpinnerContainer.setVisibility(View.VISIBLE);
}
} else {
showButton(1);
vKeySpinnerContainer.setVisibility(View.GONE);

View File

@@ -36,6 +36,7 @@ import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils.State;
public class CertifyKeySpinner extends KeySpinner {
private long mHiddenMasterKeyId = Constants.key.none;
private boolean mIsSingle;
public CertifyKeySpinner(Context context) {
super(context);
@@ -99,6 +100,7 @@ public class CertifyKeySpinner extends KeySpinner {
// - 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
mIsSingle = false;
if (mSelectedKeyId == Constants.key.none && mAdapter.getCount() > 1) {
// preselect if key can certify
int selection = -1;
@@ -106,9 +108,11 @@ public class CertifyKeySpinner extends KeySpinner {
if (!data.isNull(mIndexHasCertify)) {
if (selection == -1) {
selection = data.getPosition() + 1;
mIsSingle = true;
} else {
// if selection is already set, we have more than one certify key!
// get back to "none"!
mIsSingle = false;
selection = 0;
}
}
@@ -118,6 +122,9 @@ public class CertifyKeySpinner extends KeySpinner {
}
}
public boolean isSingleEntry() {
return mIsSingle && getSelectedItemPosition() != 0;
}
@Override
boolean setStatus(Context context, Cursor cursor, ImageView statusView) {