deal with non-existent user ids during import (#994)

This commit is contained in:
Vincent Breitmoser 2015-01-02 14:28:03 +01:00
parent 9cf800bcd8
commit 5057ea1744
3 changed files with 13 additions and 9 deletions

View File

@ -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();

View File

@ -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;
}

View File

@ -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>