mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 08:28:50 -05:00
preselect certify key
This commit is contained in:
parent
1dbb3db320
commit
d99115c263
@ -125,9 +125,9 @@ public class CachedPublicKeyRing extends KeyRing {
|
|||||||
public boolean canCertify() throws PgpGeneralException {
|
public boolean canCertify() throws PgpGeneralException {
|
||||||
try {
|
try {
|
||||||
Object data = mProviderHelper.getGenericData(mUri,
|
Object data = mProviderHelper.getGenericData(mUri,
|
||||||
KeychainContract.KeyRings.CAN_CERTIFY,
|
KeychainContract.KeyRings.HAS_CERTIFY,
|
||||||
ProviderHelper.FIELD_TYPE_INTEGER);
|
ProviderHelper.FIELD_TYPE_NULL);
|
||||||
return (Long) data > 0;
|
return !((Boolean) data);
|
||||||
} catch(ProviderHelper.NotFoundException e) {
|
} catch(ProviderHelper.NotFoundException e) {
|
||||||
throw new PgpGeneralException(e);
|
throw new PgpGeneralException(e);
|
||||||
}
|
}
|
||||||
|
@ -387,6 +387,7 @@ public class AddKeysActivity extends ActionBarActivity implements
|
|||||||
Intent certifyIntent = new Intent(AddKeysActivity.this, MultiCertifyKeyActivity.class);
|
Intent certifyIntent = new Intent(AddKeysActivity.this, MultiCertifyKeyActivity.class);
|
||||||
certifyIntent.putExtra(MultiCertifyKeyActivity.EXTRA_RESULT, result);
|
certifyIntent.putExtra(MultiCertifyKeyActivity.EXTRA_RESULT, result);
|
||||||
certifyIntent.putExtra(MultiCertifyKeyActivity.EXTRA_KEY_IDS, result.getImportedMasterKeyIds());
|
certifyIntent.putExtra(MultiCertifyKeyActivity.EXTRA_KEY_IDS, result.getImportedMasterKeyIds());
|
||||||
|
certifyIntent.putExtra(MultiCertifyKeyActivity.EXTRA_CERTIFY_KEY_ID, mExchangeMasterKeyId);
|
||||||
startActivity(certifyIntent);
|
startActivity(certifyIntent);
|
||||||
|
|
||||||
result.createNotify(AddKeysActivity.this).show();
|
result.createNotify(AddKeysActivity.this).show();
|
||||||
@ -448,7 +449,7 @@ public class AddKeysActivity extends ActionBarActivity implements
|
|||||||
|
|
||||||
final ImportKeysListEntry keyEntry = new ImportKeysListEntry();
|
final ImportKeysListEntry keyEntry = new ImportKeysListEntry();
|
||||||
keyEntry.setFingerprintHex(fingerprint);
|
keyEntry.setFingerprintHex(fingerprint);
|
||||||
keyEntry.setBitStrength(1337);
|
keyEntry.setBitStrength(1337); // TODO: make optional!
|
||||||
keyEntry.addOrigin(cloudPrefs.keyserver);
|
keyEntry.addOrigin(cloudPrefs.keyserver);
|
||||||
ArrayList<ImportKeysListEntry> selectedEntries = new ArrayList<ImportKeysListEntry>();
|
ArrayList<ImportKeysListEntry> selectedEntries = new ArrayList<ImportKeysListEntry>();
|
||||||
selectedEntries.add(keyEntry);
|
selectedEntries.add(keyEntry);
|
||||||
|
@ -30,6 +30,7 @@ public class MultiCertifyKeyActivity extends ActionBarActivity {
|
|||||||
|
|
||||||
public static final String EXTRA_RESULT = "operation_result";
|
public static final String EXTRA_RESULT = "operation_result";
|
||||||
public static final String EXTRA_KEY_IDS = "extra_key_ids";
|
public static final String EXTRA_KEY_IDS = "extra_key_ids";
|
||||||
|
public static final String EXTRA_CERTIFY_KEY_ID = "certify_key_id";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -45,8 +45,11 @@ import android.widget.ScrollView;
|
|||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||||
|
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
|
||||||
|
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
|
||||||
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
|
import org.sufficientlysecure.keychain.service.CertifyActionsParcel;
|
||||||
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
|
import org.sufficientlysecure.keychain.service.CertifyActionsParcel.CertifyAction;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
@ -106,10 +109,17 @@ public class MultiCertifyKeyFragment extends LoaderFragment
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OperationResult result = mActivity.getIntent().getParcelableExtra(MultiCertifyKeyActivity.EXTRA_RESULT);
|
// preselect certify key id if given
|
||||||
if (result != null) {
|
long certifyKeyId = mActivity.getIntent().getLongExtra(MultiCertifyKeyActivity.EXTRA_CERTIFY_KEY_ID, Constants.key.none);
|
||||||
// display result from import
|
if (certifyKeyId != Constants.key.none) {
|
||||||
result.createNotify(mActivity).show();
|
try {
|
||||||
|
CachedPublicKeyRing key = (new ProviderHelper(getActivity())).getCachedPublicKeyRing(certifyKeyId);
|
||||||
|
if (key.canCertify()) {
|
||||||
|
mCertifyKeySpinner.setSelectedKeyId(certifyKeyId);
|
||||||
|
}
|
||||||
|
} catch (PgpGeneralException e) {
|
||||||
|
Log.e(Constants.TAG, "certify certify check failed", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mUserIdsAdapter = new MultiUserIdsAdapter(mActivity, null, 0);
|
mUserIdsAdapter = new MultiUserIdsAdapter(mActivity, null, 0);
|
||||||
@ -117,6 +127,11 @@ public class MultiCertifyKeyFragment extends LoaderFragment
|
|||||||
|
|
||||||
getLoaderManager().initLoader(0, null, this);
|
getLoaderManager().initLoader(0, null, this);
|
||||||
|
|
||||||
|
OperationResult result = mActivity.getIntent().getParcelableExtra(MultiCertifyKeyActivity.EXTRA_RESULT);
|
||||||
|
if (result != null) {
|
||||||
|
// display result from import
|
||||||
|
result.createNotify(mActivity).show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -196,7 +211,8 @@ public class MultiCertifyKeyFragment extends LoaderFragment
|
|||||||
return new CursorLoader(mActivity, uri,
|
return new CursorLoader(mActivity, uri,
|
||||||
USER_IDS_PROJECTION, selection, ids,
|
USER_IDS_PROJECTION, selection, ids,
|
||||||
Tables.USER_IDS + "." + UserIds.MASTER_KEY_ID + " ASC"
|
Tables.USER_IDS + "." + UserIds.MASTER_KEY_ID + " ASC"
|
||||||
+ "," + Tables.USER_IDS + "." + UserIds.USER_ID + " ASC");
|
+ "," + Tables.USER_IDS + "." + UserIds.USER_ID + " ASC"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -88,8 +88,11 @@ public class CertifyKeySpinner extends KeySpinner {
|
|||||||
if (loader.getId() == LOADER_ID) {
|
if (loader.getId() == LOADER_ID) {
|
||||||
// If there is only one choice, pick it by default
|
// If there is only one choice, pick it by default
|
||||||
if (mAdapter.getCount() == 2) {
|
if (mAdapter.getCount() == 2) {
|
||||||
|
// preselect if key can certify
|
||||||
|
if (data.moveToPosition(1) && data.isNull(mIndexHasCertify)) {
|
||||||
setSelection(1);
|
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);
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
<string name="section_actions">"Actions"</string>
|
<string name="section_actions">"Actions"</string>
|
||||||
<string name="section_share_key">"Whole key"</string>
|
<string name="section_share_key">"Whole key"</string>
|
||||||
<string name="section_certification_key">"Your Key used for certification"</string>
|
<string name="section_certification_key">"Your Key used for certification"</string>
|
||||||
<string name="section_upload_key">"Upload Key"</string>
|
<string name="section_upload_key">"Synchronize Key"</string>
|
||||||
<string name="section_key_server">"Keyserver"</string>
|
<string name="section_key_server">"Keyserver"</string>
|
||||||
<string name="section_fingerprint">"Fingerprint"</string>
|
<string name="section_fingerprint">"Fingerprint"</string>
|
||||||
<string name="section_key_to_certify">"Key to be certified"</string>
|
<string name="section_key_to_certify">"Key to be certified"</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user