mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 03:02:15 -05:00
certs: fix CertifyKeyActivity and improve user id list
This commit is contained in:
parent
120e1eada7
commit
6e2b21b6b7
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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++) {
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user