diff options
Diffstat (limited to 'OpenPGP-Keychain/src')
4 files changed, 46 insertions, 46 deletions
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java index 2f55f4fe7..41539d0f8 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java @@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.ui.adapter; import java.util.List; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import android.annotation.SuppressLint; import android.app.Activity; @@ -52,7 +53,7 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> { clear(); if (data != null) { this.data = data; - + // add data to extended ArrayAdapter if (Build.VERSION.SDK_INT >= 11) { addAll(data); @@ -92,25 +93,30 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> { String userId = entry.userIds.get(0); if (userId != null) { - String chunks[] = userId.split(" <", 2); - userId = chunks[0]; - if (chunks.length > 1) { - mainUserIdRest.setText("<" + chunks[1]); + String[] userIdSplit = PgpKeyHelper.splitUserId(userId); + + if (userIdSplit[0] != null && userIdSplit[0].length() > 0) { + // show red user id if it is a secret key + if (entry.secretKey) { + userId = mActivity.getString(R.string.secret_key) + " " + userId; + mainUserId.setTextColor(Color.RED); + } else { + mainUserId.setText(userIdSplit[0]); + } } - if (entry.secretKey) { - userId = mActivity.getString(R.string.secret_key) + " " + userId; - mainUserId.setTextColor(Color.RED); + + if (userIdSplit[1] != null && userIdSplit[1].length() > 0) { + mainUserIdRest.setText(userIdSplit[1]); + mainUserIdRest.setVisibility(View.VISIBLE); + } else { + mainUserIdRest.setVisibility(View.GONE); } - mainUserId.setText(userId); + } keyId.setText(entry.hexKeyId); fingerprint.setText(mActivity.getString(R.string.fingerprint) + " " + entry.fingerPrint); - if (mainUserIdRest.getText().length() == 0) { - mainUserIdRest.setVisibility(View.GONE); - } - algorithm.setText("" + entry.bitStrength + "/" + entry.algorithm); if (entry.revoked) { diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListPublicAdapter.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListPublicAdapter.java index 2b9c36888..42afa2e95 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListPublicAdapter.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListPublicAdapter.java @@ -55,7 +55,7 @@ public class KeyListPublicAdapter extends CursorAdapter implements StickyListHea mSectionColumnIndex = sectionColumnIndex; initIndex(c); } - + @Override public Cursor swapCursor(Cursor newCursor) { initIndex(newCursor); @@ -92,20 +92,13 @@ public class KeyListPublicAdapter extends CursorAdapter implements StickyListHea if (userId != null) { String[] userIdSplit = PgpKeyHelper.splitUserId(userId); - if (userIdSplit[1] != null) { - mainUserIdRest.setText(userIdSplit[1]); + if (userIdSplit[0] != null && userIdSplit[0].length() > 0) { + mainUserId.setText(userIdSplit[0]); } - mainUserId.setText(userIdSplit[0]); - } - if (mainUserId.getText().length() == 0) { - mainUserId.setText(R.string.unknown_user_id); - } - - if (mainUserIdRest.getText().length() == 0) { - mainUserIdRest.setVisibility(View.GONE); - } else { - mainUserIdRest.setVisibility(View.VISIBLE); + if (userIdSplit[1] != null && userIdSplit[1].length() > 0) { + mainUserIdRest.setText(userIdSplit[1]); + } } } @@ -144,7 +137,11 @@ public class KeyListPublicAdapter extends CursorAdapter implements StickyListHea } // set header text as first char in user id - String headerText = "" + mCursor.getString(mSectionColumnIndex).subSequence(0, 1).charAt(0); + String userId = mCursor.getString(mSectionColumnIndex); + String headerText = convertView.getResources().getString(R.string.unknown_user_id); + if (userId != null && userId.length() > 0) { + headerText = "" + mCursor.getString(mSectionColumnIndex).subSequence(0, 1).charAt(0); + } holder.text.setText(headerText); return convertView; } @@ -167,7 +164,12 @@ public class KeyListPublicAdapter extends CursorAdapter implements StickyListHea // return the first character of the name as ID because this is what // headers private HashMap<Integer, Boolean> mSelection = new HashMap<Integer, // Boolean>();are based upon - return mCursor.getString(mSectionColumnIndex).subSequence(0, 1).charAt(0); + String userId = mCursor.getString(mSectionColumnIndex); + if (userId != null && userId.length() > 0) { + return userId.subSequence(0, 1).charAt(0); + } else { + return Long.MAX_VALUE; + } } class HeaderViewHolder { diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListSecretAdapter.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListSecretAdapter.java index 80bfeebd8..0043203bf 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListSecretAdapter.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/KeyListSecretAdapter.java @@ -79,20 +79,13 @@ public class KeyListSecretAdapter extends CursorAdapter { if (userId != null) { String[] userIdSplit = PgpKeyHelper.splitUserId(userId); - if (userIdSplit[1] != null) { - mainUserIdRest.setText(userIdSplit[1]); + if (userIdSplit[0] != null && userIdSplit[0].length() > 0) { + mainUserId.setText(userIdSplit[0]); } - mainUserId.setText(userIdSplit[0]); - } - - if (mainUserId.getText().length() == 0) { - mainUserId.setText(R.string.unknown_user_id); - } - if (mainUserIdRest.getText().length() == 0) { - mainUserIdRest.setVisibility(View.GONE); - } else { - mainUserIdRest.setVisibility(View.VISIBLE); + if (userIdSplit[1] != null && userIdSplit[1].length() > 0) { + mainUserIdRest.setText(userIdSplit[1]); + } } } diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java index 2dde2ab83..f4a5e1a5d 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java @@ -108,19 +108,18 @@ public class SelectKeyCursorAdapter extends CursorAdapter { if (userId != null) { String[] userIdSplit = PgpKeyHelper.splitUserId(userId); - if (userIdSplit[1] != null) { + if (userIdSplit[0] != null && userIdSplit[0].length() > 0) { + mainUserId.setText(userIdSplit[0]); + } + + if (userIdSplit[1] != null && userIdSplit[1].length() > 0) { mainUserIdRest.setText(userIdSplit[1]); } - mainUserId.setText(userIdSplit[0]); } long masterKeyId = cursor.getLong(mIndexMasterKeyId); keyId.setText(PgpKeyHelper.convertKeyIdToHex(masterKeyId)); - if (mainUserIdRest.getText().length() == 0) { - mainUserIdRest.setVisibility(View.GONE); - } - if (valid) { if (mKeyType == Id.type.public_key) { status.setText(R.string.can_encrypt); |