mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-30 12:32:17 -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.R;
|
||||||
import org.sufficientlysecure.keychain.helper.Preferences;
|
import org.sufficientlysecure.keychain.helper.Preferences;
|
||||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
import org.sufficientlysecure.keychain.service.KeychainIntentService;
|
||||||
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
|
||||||
@ -148,43 +148,37 @@ public class CertifyKeyActivity extends ActionBarActivity implements
|
|||||||
|
|
||||||
mUserIdsAdapter = new ViewKeyUserIdsAdapter(this, null, 0, true);
|
mUserIdsAdapter = new ViewKeyUserIdsAdapter(this, null, 0, true);
|
||||||
mUserIds.setAdapter(mUserIdsAdapter);
|
mUserIds.setAdapter(mUserIdsAdapter);
|
||||||
|
mUserIds.setOnItemClickListener(mUserIdsAdapter);
|
||||||
|
|
||||||
getSupportLoaderManager().initLoader(LOADER_ID_KEYRING, null, this);
|
getSupportLoaderManager().initLoader(LOADER_ID_KEYRING, null, this);
|
||||||
getSupportLoaderManager().initLoader(LOADER_ID_USER_IDS, 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 =
|
static final String[] KEYRING_PROJECTION =
|
||||||
new String[] {
|
new String[] {
|
||||||
KeychainContract.KeyRings._ID,
|
KeyRings._ID,
|
||||||
KeychainContract.Keys.MASTER_KEY_ID,
|
KeyRings.MASTER_KEY_ID,
|
||||||
KeychainContract.Keys.FINGERPRINT,
|
KeyRings.FINGERPRINT,
|
||||||
KeychainContract.UserIds.USER_ID,
|
KeyRings.USER_ID,
|
||||||
};
|
};
|
||||||
static final int INDEX_MASTER_KEY_ID = 1;
|
static final int INDEX_MASTER_KEY_ID = 1;
|
||||||
static final int INDEX_FINGERPRINT = 2;
|
static final int INDEX_FINGERPRINT = 2;
|
||||||
static final int INDEX_USER_ID = 3;
|
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
|
@Override
|
||||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
switch(id) {
|
switch(id) {
|
||||||
case LOADER_ID_KEYRING: {
|
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);
|
return new CursorLoader(this, uri, KEYRING_PROJECTION, null, null, null);
|
||||||
}
|
}
|
||||||
case LOADER_ID_USER_IDS: {
|
case LOADER_ID_USER_IDS: {
|
||||||
Uri uri = KeychainContract.UserIds.buildUserIdsUri(mDataUri);
|
Uri uri = UserIds.buildUserIdsUri(mDataUri);
|
||||||
return new CursorLoader(this, uri, USER_IDS_PROJECTION, null, null, USER_IDS_SORT_ORDER);
|
return new CursorLoader(this, uri,
|
||||||
|
ViewKeyUserIdsAdapter.USER_IDS_PROJECTION, USER_IDS_SELECTION, null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 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_CREATION = 7;
|
||||||
static final int INDEX_UNIFIED_EXPIRY = 8;
|
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[] {
|
static final String[] KEYS_PROJECTION = new String[] {
|
||||||
Keys._ID,
|
Keys._ID,
|
||||||
Keys.KEY_ID, Keys.RANK, Keys.ALGORITHM, Keys.KEY_SIZE,
|
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: {
|
case LOADER_ID_USER_IDS: {
|
||||||
Uri baseUri = UserIds.buildUserIdsUri(mDataUri);
|
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: {
|
case LOADER_ID_KEYS: {
|
||||||
Uri baseUri = Keys.buildKeysUri(mDataUri);
|
Uri baseUri = Keys.buildKeysUri(mDataUri);
|
||||||
|
@ -23,6 +23,7 @@ import android.support.v4.widget.CursorAdapter;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
import android.widget.CompoundButton;
|
import android.widget.CompoundButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
@ -34,7 +35,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.Certs;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class ViewKeyUserIdsAdapter extends CursorAdapter {
|
public class ViewKeyUserIdsAdapter extends CursorAdapter implements AdapterView.OnItemClickListener {
|
||||||
private LayoutInflater mInflater;
|
private LayoutInflater mInflater;
|
||||||
|
|
||||||
private int mIndexUserId, mIndexRank;
|
private int mIndexUserId, mIndexRank;
|
||||||
@ -42,6 +43,11 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter {
|
|||||||
|
|
||||||
private final ArrayList<Boolean> mCheckStates;
|
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) {
|
public ViewKeyUserIdsAdapter(Context context, Cursor c, int flags, boolean showCheckBoxes) {
|
||||||
super(context, c, flags);
|
super(context, c, flags);
|
||||||
|
|
||||||
@ -67,7 +73,7 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter {
|
|||||||
for(int i = 0; i < count; i++) {
|
for(int i = 0; i < count; i++) {
|
||||||
newCursor.moveToPosition(i);
|
newCursor.moveToPosition(i);
|
||||||
int verified = newCursor.getInt(mVerifiedId);
|
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]);
|
vAddress.setText(userId[1]);
|
||||||
|
|
||||||
if(cursor.getInt(mIsRevoked) > 0) {
|
if(cursor.getInt(mIsRevoked) > 0) {
|
||||||
|
vRank.setText(" ");
|
||||||
vVerified.setImageResource(android.R.drawable.presence_away);
|
vVerified.setImageResource(android.R.drawable.presence_away);
|
||||||
} else {
|
} else {
|
||||||
int verified = cursor.getInt(mVerifiedId);
|
int verified = cursor.getInt(mVerifiedId);
|
||||||
@ -141,15 +148,17 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter {
|
|||||||
mCheckStates.set(position, b);
|
mCheckStates.set(position, b);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
view.setOnClickListener(new View.OnClickListener() {
|
vCheckBox.setClickable(false);
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
vCheckBox.toggle();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
public ArrayList<String> getSelectedUserIds() {
|
||||||
ArrayList<String> result = new ArrayList<String>();
|
ArrayList<String> result = new ArrayList<String>();
|
||||||
for (int i = 0; i < mCheckStates.size(); i++) {
|
for (int i = 0; i < mCheckStates.size(); i++) {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
|
xmlns:bootstrapbutton="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent" >
|
android:layout_height="match_parent" >
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@ -114,7 +114,8 @@
|
|||||||
<org.sufficientlysecure.keychain.ui.widget.FixedListView
|
<org.sufficientlysecure.keychain.ui.widget.FixedListView
|
||||||
android:id="@+id/user_ids"
|
android:id="@+id/user_ids"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
android:descendantFocusability="blocksDescendants" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
style="@style/SectionHeader"
|
style="@style/SectionHeader"
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
<CheckBox
|
<CheckBox
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:id="@+id/checkBox" />
|
android:id="@+id/checkBox"
|
||||||
|
android:clickable="false"
|
||||||
|
android:focusable="false" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/rank"
|
android:id="@+id/rank"
|
||||||
@ -19,7 +21,8 @@
|
|||||||
android:text="0"
|
android:text="0"
|
||||||
android:paddingLeft="10dp"
|
android:paddingLeft="10dp"
|
||||||
android:paddingRight="10dp"
|
android:paddingRight="10dp"
|
||||||
android:layout_gravity="center_vertical" />
|
android:layout_gravity="center_vertical"
|
||||||
|
android:width="30sp" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
Loading…
Reference in New Issue
Block a user