diff options
Diffstat (limited to 'OpenKeychain/src')
3 files changed, 26 insertions, 23 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/CachedPublicKeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/CachedPublicKeyRing.java index 34de0024d..7eb78a3d6 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/CachedPublicKeyRing.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/CachedPublicKeyRing.java @@ -62,7 +62,7 @@ public class CachedPublicKeyRing extends KeyRing { public String getPrimaryUserId() throws PgpGeneralException { try { Object data = mProviderHelper.getGenericData(mUri, - KeychainContract.KeyRings.MASTER_KEY_ID, + KeychainContract.KeyRings.USER_ID, ProviderHelper.FIELD_TYPE_STRING); return (String) data; } catch(ProviderHelper.NotFoundException e) { @@ -77,7 +77,7 @@ public class CachedPublicKeyRing extends KeyRing { public boolean isRevoked() throws PgpGeneralException { try { Object data = mProviderHelper.getGenericData(mUri, - KeychainContract.KeyRings.MASTER_KEY_ID, + KeychainContract.KeyRings.IS_REVOKED, ProviderHelper.FIELD_TYPE_INTEGER); return (Long) data > 0; } catch(ProviderHelper.NotFoundException e) { @@ -88,7 +88,7 @@ public class CachedPublicKeyRing extends KeyRing { public boolean canCertify() throws PgpGeneralException { try { Object data = mProviderHelper.getGenericData(mUri, - KeychainContract.KeyRings.MASTER_KEY_ID, + KeychainContract.KeyRings.CAN_CERTIFY, ProviderHelper.FIELD_TYPE_INTEGER); return (Long) data > 0; } catch(ProviderHelper.NotFoundException e) { @@ -99,7 +99,7 @@ public class CachedPublicKeyRing extends KeyRing { public long getEncryptId() throws PgpGeneralException { try { Object data = mProviderHelper.getGenericData(mUri, - KeychainContract.KeyRings.MASTER_KEY_ID, + KeychainContract.KeyRings.MASTER_KEY_ID, // TODO ProviderHelper.FIELD_TYPE_INTEGER); return (Long) data; } catch(ProviderHelper.NotFoundException e) { @@ -110,7 +110,7 @@ public class CachedPublicKeyRing extends KeyRing { public boolean hasEncrypt() throws PgpGeneralException { try { Object data = mProviderHelper.getGenericData(mUri, - KeychainContract.KeyRings.MASTER_KEY_ID, + KeychainContract.KeyRings.CAN_ENCRYPT, // TODO ProviderHelper.FIELD_TYPE_INTEGER); return (Long) data > 0; } catch(ProviderHelper.NotFoundException e) { @@ -121,7 +121,7 @@ public class CachedPublicKeyRing extends KeyRing { public long getSignId() throws PgpGeneralException { try { Object data = mProviderHelper.getGenericData(mUri, - KeychainContract.KeyRings.MASTER_KEY_ID, + KeychainContract.KeyRings.MASTER_KEY_ID, // TODO ProviderHelper.FIELD_TYPE_INTEGER); return (Long) data; } catch(ProviderHelper.NotFoundException e) { @@ -132,7 +132,7 @@ public class CachedPublicKeyRing extends KeyRing { public boolean hasSign() throws PgpGeneralException { try { Object data = mProviderHelper.getGenericData(mUri, - KeychainContract.KeyRings.MASTER_KEY_ID, + KeychainContract.KeyRings.CAN_SIGN, // TODO ProviderHelper.FIELD_TYPE_INTEGER); return (Long) data > 0; } catch(ProviderHelper.NotFoundException e) { @@ -143,7 +143,7 @@ public class CachedPublicKeyRing extends KeyRing { public int getVerified() throws PgpGeneralException { try { Object data = mProviderHelper.getGenericData(mUri, - KeychainContract.KeyRings.MASTER_KEY_ID, + KeychainContract.KeyRings.VERIFIED, ProviderHelper.FIELD_TYPE_INTEGER); return (Integer) data; } catch(ProviderHelper.NotFoundException e) { @@ -154,7 +154,7 @@ public class CachedPublicKeyRing extends KeyRing { public boolean hasAnySecret() throws PgpGeneralException { try { Object data = mProviderHelper.getGenericData(mUri, - KeychainContract.KeyRings.MASTER_KEY_ID, + KeychainContract.KeyRings.HAS_ANY_SECRET, ProviderHelper.FIELD_TYPE_INTEGER); return (Long) data > 0; } catch(ProviderHelper.NotFoundException e) { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java index dc0510189..eb807792b 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java @@ -31,11 +31,14 @@ import android.widget.Button; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.pgp.KeyRing; +import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.util.Log; +import org.sufficientlysecure.keychain.util.Notify; import java.util.Vector; @@ -195,22 +198,23 @@ public class EncryptAsymmetricFragment extends Fragment { mMainUserIdRest.setText(""); } else { // See if we can get a user_id from a unified query - String[] userId; try { - userId = mProviderHelper.getCachedPublicKeyRing( + String[] userIdSplit = mProviderHelper.getCachedPublicKeyRing( KeyRings.buildUnifiedKeyRingUri(mSecretKeyId)).getSplitPrimaryUserIdWithFallback(); + + if (userIdSplit[0] != null) { + mMainUserId.setText(userIdSplit[0]); + } else { + mMainUserId.setText(R.string.user_id_no_name); + } + if (userIdSplit[1] != null) { + mMainUserIdRest.setText(userIdSplit[1]); + } else { + mMainUserIdRest.setText(getString(R.string.label_key_id) + ": " + + PgpKeyHelper.convertKeyIdToHex(mSecretKeyId)); + } } catch (PgpGeneralException e) { - userId = null; - } - if (userId != null && userId[0] != null) { - mMainUserId.setText(String.format("%#16x", Long.parseLong(userId[0]))); - } else { - mMainUserId.setText(getResources().getString(R.string.user_id_no_name)); - } - if (userId != null && userId[1] != null) { - mMainUserIdRest.setText(userId[1]); - } else { - mMainUserIdRest.setText(""); + Notify.showNotify(getActivity(), "Key not found! This is a bug!", Notify.Style.ERROR); } mSign.setChecked(true); } diff --git a/OpenKeychain/src/main/res/layout/view_key_main_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_main_fragment.xml index 38769324e..7a54fab05 100644 --- a/OpenKeychain/src/main/res/layout/view_key_main_fragment.xml +++ b/OpenKeychain/src/main/res/layout/view_key_main_fragment.xml @@ -97,7 +97,6 @@ android:id="@+id/view_key_action_encrypt" android:paddingLeft="8dp" android:paddingRight="8dp" - android:layout_marginBottom="8dp" android:textAppearance="?android:attr/textAppearanceMedium" android:layout_width="match_parent" android:layout_height="wrap_content" |