diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2014-04-06 02:27:21 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2014-04-06 02:27:21 +0200 |
commit | 6e2b21b6b70c12995027f81acedb68c6069c5fb8 (patch) | |
tree | 32acf708c9c3fc8327833b7f3895b56978ded6c1 /OpenPGP-Keychain | |
parent | 120e1eada729c34bf138138b7df4e6827acb6535 (diff) | |
download | open-keychain-6e2b21b6b70c12995027f81acedb68c6069c5fb8.tar.gz open-keychain-6e2b21b6b70c12995027f81acedb68c6069c5fb8.tar.bz2 open-keychain-6e2b21b6b70c12995027f81acedb68c6069c5fb8.zip |
certs: fix CertifyKeyActivity and improve user id list
Diffstat (limited to 'OpenPGP-Keychain')
5 files changed, 39 insertions, 37 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java index 2efa8a69c..7027c114e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java @@ -46,8 +46,8 @@ import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.Preferences; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; -import org.sufficientlysecure.keychain.provider.KeychainContract; -import org.sufficientlysecure.keychain.provider.KeychainDatabase; +import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; +import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; @@ -148,43 +148,37 @@ public class CertifyKeyActivity extends ActionBarActivity implements mUserIdsAdapter = new ViewKeyUserIdsAdapter(this, null, 0, true); mUserIds.setAdapter(mUserIdsAdapter); + mUserIds.setOnItemClickListener(mUserIdsAdapter); getSupportLoaderManager().initLoader(LOADER_ID_KEYRING, null, this); getSupportLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this); } + static final String USER_IDS_SELECTION = UserIds.IS_REVOKED + " = 0"; + static final String[] KEYRING_PROJECTION = new String[] { - KeychainContract.KeyRings._ID, - KeychainContract.Keys.MASTER_KEY_ID, - KeychainContract.Keys.FINGERPRINT, - KeychainContract.UserIds.USER_ID, + KeyRings._ID, + KeyRings.MASTER_KEY_ID, + KeyRings.FINGERPRINT, + KeyRings.USER_ID, }; static final int INDEX_MASTER_KEY_ID = 1; static final int INDEX_FINGERPRINT = 2; static final int INDEX_USER_ID = 3; - static final String[] USER_IDS_PROJECTION = - new String[]{ - KeychainContract.UserIds._ID, - KeychainContract.UserIds.USER_ID, - KeychainContract.UserIds.RANK, - "verified" - }; - static final String USER_IDS_SORT_ORDER = - KeychainDatabase.Tables.USER_IDS + "." + KeychainContract.UserIds.RANK + " ASC"; - @Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { switch(id) { case LOADER_ID_KEYRING: { - Uri uri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(mDataUri); + Uri uri = KeyRings.buildUnifiedKeyRingUri(mDataUri); return new CursorLoader(this, uri, KEYRING_PROJECTION, null, null, null); } case LOADER_ID_USER_IDS: { - Uri uri = KeychainContract.UserIds.buildUserIdsUri(mDataUri); - return new CursorLoader(this, uri, USER_IDS_PROJECTION, null, null, USER_IDS_SORT_ORDER); + Uri uri = UserIds.buildUserIdsUri(mDataUri); + return new CursorLoader(this, uri, + ViewKeyUserIdsAdapter.USER_IDS_PROJECTION, USER_IDS_SELECTION, null, null); } } return null; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index 60df6970d..d12f00547 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -174,11 +174,6 @@ public class ViewKeyMainFragment extends Fragment implements static final int INDEX_UNIFIED_CREATION = 7; static final int INDEX_UNIFIED_EXPIRY = 8; - static final String[] USER_IDS_PROJECTION = new String[] { - UserIds._ID, UserIds.USER_ID, UserIds.RANK, - UserIds.VERIFIED, UserIds.IS_PRIMARY, UserIds.IS_REVOKED - }; - static final String[] KEYS_PROJECTION = new String[] { Keys._ID, Keys.KEY_ID, Keys.RANK, Keys.ALGORITHM, Keys.KEY_SIZE, @@ -195,7 +190,7 @@ public class ViewKeyMainFragment extends Fragment implements } case LOADER_ID_USER_IDS: { Uri baseUri = UserIds.buildUserIdsUri(mDataUri); - return new CursorLoader(getActivity(), baseUri, USER_IDS_PROJECTION, null, null, null); + return new CursorLoader(getActivity(), baseUri, ViewKeyUserIdsAdapter.USER_IDS_PROJECTION, null, null, null); } case LOADER_ID_KEYS: { Uri baseUri = Keys.buildKeysUri(mDataUri); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java index 023d3d660..09137f745 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java @@ -23,6 +23,7 @@ import android.support.v4.widget.CursorAdapter; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.ImageView; @@ -34,7 +35,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.Certs; import java.util.ArrayList; -public class ViewKeyUserIdsAdapter extends CursorAdapter { +public class ViewKeyUserIdsAdapter extends CursorAdapter implements AdapterView.OnItemClickListener { private LayoutInflater mInflater; private int mIndexUserId, mIndexRank; @@ -42,6 +43,11 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter { private final ArrayList<Boolean> mCheckStates; + public static final String[] USER_IDS_PROJECTION = new String[] { + UserIds._ID, UserIds.USER_ID, UserIds.RANK, + UserIds.VERIFIED, UserIds.IS_PRIMARY, UserIds.IS_REVOKED + }; + public ViewKeyUserIdsAdapter(Context context, Cursor c, int flags, boolean showCheckBoxes) { super(context, c, flags); @@ -67,7 +73,7 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter { for(int i = 0; i < count; i++) { newCursor.moveToPosition(i); int verified = newCursor.getInt(mVerifiedId); - mCheckStates.add(verified == 0); + mCheckStates.add(verified != Certs.VERIFIED_SECRET); } } } @@ -114,6 +120,7 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter { vAddress.setText(userId[1]); if(cursor.getInt(mIsRevoked) > 0) { + vRank.setText(" "); vVerified.setImageResource(android.R.drawable.presence_away); } else { int verified = cursor.getInt(mVerifiedId); @@ -141,15 +148,17 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter { mCheckStates.set(position, b); } }); - view.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - vCheckBox.toggle(); - } - }); + vCheckBox.setClickable(false); } + public void onItemClick(AdapterView<?> adapter, View view, int position, long id) { + CheckBox box = ((CheckBox) view.findViewById(R.id.checkBox)); + if(box != null) { + box.toggle(); + } + } + public ArrayList<String> getSelectedUserIds() { ArrayList<String> result = new ArrayList<String>(); for (int i = 0; i < mCheckStates.size(); i++) { diff --git a/OpenPGP-Keychain/src/main/res/layout/certify_key_activity.xml b/OpenPGP-Keychain/src/main/res/layout/certify_key_activity.xml index 6cd140739..3fa0468de 100644 --- a/OpenPGP-Keychain/src/main/res/layout/certify_key_activity.xml +++ b/OpenPGP-Keychain/src/main/res/layout/certify_key_activity.xml @@ -2,7 +2,7 @@ <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" - android:layout_width="match_parent" + android:layout_width="wrap_content" android:layout_height="match_parent" > <LinearLayout @@ -114,7 +114,8 @@ <org.sufficientlysecure.keychain.ui.widget.FixedListView android:id="@+id/user_ids" android:layout_width="match_parent" - android:layout_height="wrap_content" /> + android:layout_height="wrap_content" + android:descendantFocusability="blocksDescendants" /> <TextView style="@style/SectionHeader" diff --git a/OpenPGP-Keychain/src/main/res/layout/view_key_userids_item.xml b/OpenPGP-Keychain/src/main/res/layout/view_key_userids_item.xml index aa14e6d2f..e47f591cb 100644 --- a/OpenPGP-Keychain/src/main/res/layout/view_key_userids_item.xml +++ b/OpenPGP-Keychain/src/main/res/layout/view_key_userids_item.xml @@ -9,7 +9,9 @@ <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" - android:id="@+id/checkBox" /> + android:id="@+id/checkBox" + android:clickable="false" + android:focusable="false" /> <TextView android:id="@+id/rank" @@ -19,7 +21,8 @@ android:text="0" android:paddingLeft="10dp" android:paddingRight="10dp" - android:layout_gravity="center_vertical" /> + android:layout_gravity="center_vertical" + android:width="30sp" /> <LinearLayout android:orientation="vertical" |