aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-01-02 14:28:03 +0100
committerVincent Breitmoser <valodim@mugenguild.com>2015-01-02 14:28:03 +0100
commit5057ea1744eac05fc999db1756cf0d739ae41a72 (patch)
tree54c74cc7ccd91eff2d9a60803fbfb6e404a1fd34
parent9cf800bcd8870961acc1719fc56f5e8dab21d0a3 (diff)
downloadopen-keychain-5057ea1744eac05fc999db1756cf0d739ae41a72.tar.gz
open-keychain-5057ea1744eac05fc999db1756cf0d739ae41a72.tar.bz2
open-keychain-5057ea1744eac05fc999db1756cf0d739ae41a72.zip
deal with non-existent user ids during import (#994)
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java3
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedPublicKey.java6
-rw-r--r--OpenKeychain/src/main/res/values/strings.xml13
3 files changed, 13 insertions, 9 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java
index 854a90713..d60d7757b 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/keyimport/ImportKeysListEntry.java
@@ -21,6 +21,7 @@ import android.content.Context;
import android.os.Parcel;
import android.os.Parcelable;
+import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.pgp.UncachedKeyRing;
@@ -287,7 +288,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable {
// if there was no user id flagged as primary, use the first one
if (mPrimaryUserId == null) {
- mPrimaryUserId = mUserIds.get(0);
+ mPrimaryUserId = context.getString(R.string.user_id_none);
}
mKeyId = key.getKeyId();
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedPublicKey.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedPublicKey.java
index c4cacaca7..fe3ab96a5 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedPublicKey.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedPublicKey.java
@@ -186,12 +186,14 @@ public class UncachedPublicKey {
}
/**
- * Returns primary user id if existing. If not, return first encountered user id.
+ * Returns primary user id if existing. If not, return first encountered user id. If there
+ * is no user id, return null (this can only happen for not yet canonicalized keys during import)
*/
public String getPrimaryUserIdWithFallback() {
String userId = getPrimaryUserId();
if (userId == null) {
- userId = (String) mPublicKey.getUserIDs().next();
+ Iterator<String> it = mPublicKey.getUserIDs();
+ userId = it.hasNext() ? it.next() : null;
}
return userId;
}
diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml
index 8788038aa..55497361b 100644
--- a/OpenKeychain/src/main/res/values/strings.xml
+++ b/OpenKeychain/src/main/res/values/strings.xml
@@ -1024,6 +1024,12 @@
<string name="passp_cache_notif_clear">"Clear Cache"</string>
<string name="passp_cache_notif_pwd">"Passphrase"</string>
+ <!-- First Time -->
+ <string name="first_time_text1">"Take back your privacy with OpenKeychain!"</string>
+ <string name="first_time_create_key">"Create my key"</string>
+ <string name="first_time_import_key">"Import from file"</string>
+ <string name="first_time_skip">"Skip Setup"</string>
+
<!-- unsorted -->
<string name="section_certifier_id">"Certifier"</string>
<string name="section_cert">"Certificate Details"</string>
@@ -1054,11 +1060,6 @@
<string name="error_multi_not_supported">"Saving of multiple files not supported. This is a limitation on current Android."</string>
<string name="key_colon">"Key:"</string>
<string name="exchange_description">"To start a key exchange, choose the number of participants on the right side, then hit the “Start exchange” button.\n\nYou will be asked two more questions to make sure only the right participants are in the exchange and their fingerprints are correct."</string>
-
- <!-- First Time -->
- <string name="first_time_text1">"Take back your privacy with OpenKeychain!"</string>
- <string name="first_time_create_key">"Create my key"</string>
- <string name="first_time_import_key">"Import from file"</string>
- <string name="first_time_skip">"Skip Setup"</string>
+ <string name="user_id_none"><![CDATA[<none>]]></string>
</resources>