diff options
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java | 51 |
1 files changed, 41 insertions, 10 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java index 77da1d0e3..7a7acfe89 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/UserIdsAdapter.java @@ -122,21 +122,23 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC TextView vAddress = (TextView) view.findViewById(R.id.address); TextView vComment = (TextView) view.findViewById(R.id.comment); ImageView vVerified = (ImageView) view.findViewById(R.id.certified); + ImageView vHasChanges = (ImageView) view.findViewById(R.id.has_changes); - String[] userId = KeyRing.splitUserId(cursor.getString(mIndexUserId)); - if (userId[0] != null) { - vName.setText(userId[0]); + String userId = cursor.getString(mIndexUserId); + String[] splitUserId = KeyRing.splitUserId(userId); + if (splitUserId[0] != null) { + vName.setText(splitUserId[0]); } else { vName.setText(R.string.user_id_no_name); } - if (userId[1] != null) { - vAddress.setText(userId[1]); + if (splitUserId[1] != null) { + vAddress.setText(splitUserId[1]); vAddress.setVisibility(View.VISIBLE); } else { vAddress.setVisibility(View.GONE); } - if (userId[2] != null) { - vComment.setText(userId[2]); + if (splitUserId[2] != null) { + vComment.setText(splitUserId[2]); vComment.setVisibility(View.VISIBLE); } else { vComment.setVisibility(View.GONE); @@ -144,9 +146,33 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC // show small star icon for primary user ids boolean isPrimary = cursor.getInt(mIsPrimary) != 0; + boolean isRevoked = cursor.getInt(mIsRevoked) > 0; - if (cursor.getInt(mIsRevoked) > 0) { + // for edit key + if (mSaveKeyringParcel != null) { + boolean changeUserId = (mSaveKeyringParcel.changePrimaryUserId != null + && mSaveKeyringParcel.changePrimaryUserId.equals(userId)); + boolean revoke = (mSaveKeyringParcel.revokeUserIds.contains(userId)); + if (changeUserId) { + isPrimary = !isPrimary; + } + if (revoke) { + if (!isRevoked) { + isRevoked = true; + } + } + + if (changeUserId || revoke) { + vHasChanges.setVisibility(View.VISIBLE); + } else { + vHasChanges.setVisibility(View.GONE); + } + } else { + vHasChanges.setVisibility(View.GONE); + } + + if (isRevoked) { // set revocation icon (can this even be primary?) vVerified.setImageResource(R.drawable.key_certify_revoke); @@ -213,6 +239,11 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC return result; } + public String getUserId(int position) { + mCursor.moveToPosition(position); + return mCursor.getString(mIndexUserId); + } + @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { View view = mInflater.inflate(R.layout.view_key_userids_item, null); @@ -224,7 +255,7 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC // Disable selection of items for lists without checkboxes, http://stackoverflow.com/a/4075045 @Override public boolean areAllItemsEnabled() { - if (mCheckStates == null) { + if (mCheckStates == null && mSaveKeyringParcel == null) { return false; } else { return super.areAllItemsEnabled(); @@ -234,7 +265,7 @@ public class UserIdsAdapter extends CursorAdapter implements AdapterView.OnItemC // Disable selection of items for lists without checkboxes, http://stackoverflow.com/a/4075045 @Override public boolean isEnabled(int position) { - if (mCheckStates == null) { + if (mCheckStates == null && mSaveKeyringParcel == null) { return false; } else { return super.isEnabled(position); |