Add missing columns for projections, remove use of raw user id
This commit is contained in:
@@ -174,16 +174,6 @@ public class SelectPublicKeyFragment extends RecyclerFragment<SelectEncryptKeyAd
|
|||||||
getAdapter().getMasterKeyIds() : new long[0];
|
getAdapter().getMasterKeyIds() : new long[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getSelectedRawUserIds() {
|
|
||||||
return getAdapter() != null ?
|
|
||||||
getAdapter().getRawUserIds() : new String[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
public OpenPgpUtils.UserId[] getSelectedUserIds() {
|
|
||||||
return getAdapter() != null ?
|
|
||||||
getAdapter().getUserIds() : new OpenPgpUtils.UserId[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
Uri baseUri = KeyRings.buildUnifiedKeyRingsUri();
|
Uri baseUri = KeyRings.buildUnifiedKeyRingsUri();
|
||||||
@@ -199,6 +189,9 @@ public class SelectPublicKeyFragment extends RecyclerFragment<SelectEncryptKeyAd
|
|||||||
KeyRings.VERIFIED,
|
KeyRings.VERIFIED,
|
||||||
KeyRings.HAS_DUPLICATE_USER_ID,
|
KeyRings.HAS_DUPLICATE_USER_ID,
|
||||||
KeyRings.CREATION,
|
KeyRings.CREATION,
|
||||||
|
KeyRings.NAME,
|
||||||
|
KeyRings.EMAIL,
|
||||||
|
KeyRings.COMMENT
|
||||||
};
|
};
|
||||||
|
|
||||||
String inMasterKeyList = null;
|
String inMasterKeyList = null;
|
||||||
|
|||||||
@@ -121,6 +121,9 @@ public class SelectSignKeyIdListFragment extends RecyclerFragment<SelectSignKeyA
|
|||||||
KeyRings.HAS_ANY_SECRET,
|
KeyRings.HAS_ANY_SECRET,
|
||||||
KeyRings.HAS_DUPLICATE_USER_ID,
|
KeyRings.HAS_DUPLICATE_USER_ID,
|
||||||
KeyRings.CREATION,
|
KeyRings.CREATION,
|
||||||
|
KeyRings.NAME,
|
||||||
|
KeyRings.EMAIL,
|
||||||
|
KeyRings.COMMENT
|
||||||
};
|
};
|
||||||
|
|
||||||
String selection = KeyRings.HAS_ANY_SECRET + " != 0";
|
String selection = KeyRings.HAS_ANY_SECRET + " != 0";
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import android.widget.CheckBox;
|
|||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import org.openintents.openpgp.util.OpenPgpUtils;
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.KeyCursorAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.KeyCursorAdapter;
|
||||||
@@ -113,34 +112,6 @@ public class SelectEncryptKeyAdapter extends KeyCursorAdapter<SelectEncryptKeyAd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getRawUserIds() {
|
|
||||||
String[] selected = new String[mSelected.size()];
|
|
||||||
for (int i = 0; i < selected.length; i++) {
|
|
||||||
int position = mSelected.get(i);
|
|
||||||
if (!moveCursor(position)) {
|
|
||||||
return selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
selected[i] = getCursor().getRawUserId();
|
|
||||||
}
|
|
||||||
|
|
||||||
return selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OpenPgpUtils.UserId[] getUserIds() {
|
|
||||||
OpenPgpUtils.UserId[] selected = new OpenPgpUtils.UserId[mSelected.size()];
|
|
||||||
for (int i = 0; i < selected.length; i++) {
|
|
||||||
int position = mSelected.get(i);
|
|
||||||
if (!moveCursor(position)) {
|
|
||||||
return selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
selected[i] = getCursor().getUserId();
|
|
||||||
}
|
|
||||||
|
|
||||||
return selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onContentChanged() {
|
public void onContentChanged() {
|
||||||
mSelected.clear();
|
mSelected.clear();
|
||||||
|
|||||||
@@ -192,11 +192,11 @@ public class KeySectionedListAdapter extends SectionCursorAdapter<KeySectionedLi
|
|||||||
|
|
||||||
return '#';
|
return '#';
|
||||||
} else {
|
} else {
|
||||||
String userId = cursor.getRawUserId();
|
String name = cursor.getName();
|
||||||
if (TextUtils.isEmpty(userId)) {
|
if (name != null) {
|
||||||
return '?';
|
return Character.toUpperCase(name.charAt(0));
|
||||||
} else {
|
} else {
|
||||||
return Character.toUpperCase(userId.charAt(0));
|
return '?';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -313,11 +313,11 @@ public class KeySectionedListAdapter extends SectionCursorAdapter<KeySectionedLi
|
|||||||
|
|
||||||
return "My";
|
return "My";
|
||||||
} else {
|
} else {
|
||||||
String userId = cursor.getRawUserId();
|
String name = cursor.getName();
|
||||||
if (TextUtils.isEmpty(userId)) {
|
if (name != null) {
|
||||||
return null;
|
return name.substring(0, 1).toUpperCase();
|
||||||
} else {
|
} else {
|
||||||
return userId.substring(0, 1).toUpperCase();
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ import org.sufficientlysecure.keychain.provider.KeychainContract;
|
|||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
@@ -65,7 +64,7 @@ public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH e
|
|||||||
* When using this constructor, {@link #FLAG_REGISTER_CONTENT_OBSERVER}
|
* When using this constructor, {@link #FLAG_REGISTER_CONTENT_OBSERVER}
|
||||||
* will always be set.
|
* will always be set.
|
||||||
*
|
*
|
||||||
* @param c The cursor from which to get the data.
|
* @param c The cursor from which to get the data.
|
||||||
* @param context The context
|
* @param context The context
|
||||||
*/
|
*/
|
||||||
public CursorAdapter(Context context, C c) {
|
public CursorAdapter(Context context, C c) {
|
||||||
@@ -76,9 +75,9 @@ public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH e
|
|||||||
/**
|
/**
|
||||||
* Recommended constructor.
|
* Recommended constructor.
|
||||||
*
|
*
|
||||||
* @param c The cursor from which to get the data.
|
* @param c The cursor from which to get the data.
|
||||||
* @param context The context
|
* @param context The context
|
||||||
* @param flags Flags used to determine the behavior of the adapter
|
* @param flags Flags used to determine the behavior of the adapter
|
||||||
* @see #FLAG_REGISTER_CONTENT_OBSERVER
|
* @see #FLAG_REGISTER_CONTENT_OBSERVER
|
||||||
*/
|
*/
|
||||||
public CursorAdapter(Context context, C c, int flags) {
|
public CursorAdapter(Context context, C c, int flags) {
|
||||||
@@ -109,6 +108,7 @@ public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH e
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the cursor.
|
* Returns the cursor.
|
||||||
|
*
|
||||||
* @return the cursor.
|
* @return the cursor.
|
||||||
*/
|
*/
|
||||||
public C getCursor() {
|
public C getCursor() {
|
||||||
@@ -147,10 +147,9 @@ public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH e
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see android.support.v7.widget.RecyclerView.Adapter#getItemId(int)
|
|
||||||
*
|
|
||||||
* @param position Adapter position to query
|
* @param position Adapter position to query
|
||||||
* @return the id of the item
|
* @return the id of the item
|
||||||
|
* @see android.support.v7.widget.RecyclerView.Adapter#getItemId(int)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public long getItemId(int position) {
|
public long getItemId(int position) {
|
||||||
@@ -168,11 +167,12 @@ public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH e
|
|||||||
/**
|
/**
|
||||||
* Return the id of the item represented by the row the cursor
|
* Return the id of the item represented by the row the cursor
|
||||||
* is currently moved to.
|
* is currently moved to.
|
||||||
|
*
|
||||||
* @param cursor The cursor moved to the correct position.
|
* @param cursor The cursor moved to the correct position.
|
||||||
* @return The id of the dataset
|
* @return The id of the dataset
|
||||||
*/
|
*/
|
||||||
public long getIdFromCursor(C cursor) {
|
public long getIdFromCursor(C cursor) {
|
||||||
if(cursor != null) {
|
if (cursor != null) {
|
||||||
return cursor.getEntryId();
|
return cursor.getEntryId();
|
||||||
} else {
|
} else {
|
||||||
return RecyclerView.NO_ID;
|
return RecyclerView.NO_ID;
|
||||||
@@ -182,28 +182,28 @@ public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH e
|
|||||||
public void moveCursorOrThrow(int position)
|
public void moveCursorOrThrow(int position)
|
||||||
throws IndexOutOfBoundsException, IllegalStateException {
|
throws IndexOutOfBoundsException, IllegalStateException {
|
||||||
|
|
||||||
if(position >= getItemCount() || position < -1) {
|
if (position >= getItemCount() || position < -1) {
|
||||||
throw new IndexOutOfBoundsException("Position: " + position
|
throw new IndexOutOfBoundsException("Position: " + position
|
||||||
+ " is invalid for this data set!");
|
+ " is invalid for this data set!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mDataValid) {
|
if (!mDataValid) {
|
||||||
throw new IllegalStateException("Attempt to move cursor over invalid data set!");
|
throw new IllegalStateException("Attempt to move cursor over invalid data set!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mCursor.moveToPosition(position)) {
|
if (!mCursor.moveToPosition(position)) {
|
||||||
throw new IllegalStateException("Couldn't move cursor from position: "
|
throw new IllegalStateException("Couldn't move cursor from position: "
|
||||||
+ mCursor.getPosition() + " to position: " + position + "!");
|
+ mCursor.getPosition() + " to position: " + position + "!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean moveCursor(int position) {
|
public boolean moveCursor(int position) {
|
||||||
if(position >= getItemCount() || position < -1) {
|
if (position >= getItemCount() || position < -1) {
|
||||||
Log.w(TAG, "Position: %d is invalid for this data set!");
|
Log.w(TAG, "Position: %d is invalid for this data set!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!mDataValid) {
|
if (!mDataValid) {
|
||||||
Log.d(TAG, "Attempt to move cursor over invalid data set!");
|
Log.d(TAG, "Attempt to move cursor over invalid data set!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,7 +315,7 @@ public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH e
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class AbstractCursor extends CursorWrapper {
|
public static abstract class AbstractCursor extends CursorWrapper {
|
||||||
public static final String[] PROJECTION = { "_id" };
|
public static final String[] PROJECTION = {"_id"};
|
||||||
|
|
||||||
public static <T extends AbstractCursor> T wrap(Cursor cursor, Class<T> type) {
|
public static <T extends AbstractCursor> T wrap(Cursor cursor, Class<T> type) {
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
@@ -356,10 +356,10 @@ public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH e
|
|||||||
@Override
|
@Override
|
||||||
public final int getColumnIndexOrThrow(String colName) {
|
public final int getColumnIndexOrThrow(String colName) {
|
||||||
Integer colIndex = mColumnIndices.get(colName);
|
Integer colIndex = mColumnIndices.get(colName);
|
||||||
if(colIndex == null) {
|
if (colIndex == null) {
|
||||||
colIndex = super.getColumnIndexOrThrow(colName);
|
colIndex = super.getColumnIndexOrThrow(colName);
|
||||||
mColumnIndices.put(colName, colIndex);
|
mColumnIndices.put(colName, colIndex);
|
||||||
} else if (colIndex < 0){
|
} else if (colIndex < 0) {
|
||||||
throw new IllegalArgumentException("Could not get column index for name: \"" + colName + "\"");
|
throw new IllegalArgumentException("Could not get column index for name: \"" + colName + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,7 +369,7 @@ public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH e
|
|||||||
@Override
|
@Override
|
||||||
public final int getColumnIndex(String colName) {
|
public final int getColumnIndex(String colName) {
|
||||||
Integer colIndex = mColumnIndices.get(colName);
|
Integer colIndex = mColumnIndices.get(colName);
|
||||||
if(colIndex == null) {
|
if (colIndex == null) {
|
||||||
colIndex = super.getColumnIndex(colName);
|
colIndex = super.getColumnIndex(colName);
|
||||||
mColumnIndices.put(colName, colIndex);
|
mColumnIndices.put(colName, colIndex);
|
||||||
}
|
}
|
||||||
@@ -421,11 +421,6 @@ public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH e
|
|||||||
return getLong(index);
|
return getLong(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRawUserId() {
|
|
||||||
int index = getColumnIndexOrThrow(KeychainContract.KeyRings.USER_ID);
|
|
||||||
return getString(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
int index = getColumnIndexOrThrow(KeychainContract.KeyRings.NAME);
|
int index = getColumnIndexOrThrow(KeychainContract.KeyRings.NAME);
|
||||||
return getString(index);
|
return getString(index);
|
||||||
@@ -441,11 +436,6 @@ public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH e
|
|||||||
return getString(index);
|
return getString(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public OpenPgpUtils.UserId getUserId() {
|
|
||||||
return KeyRing.splitUserId(getRawUserId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasDuplicate() {
|
public boolean hasDuplicate() {
|
||||||
int index = getColumnIndexOrThrow(KeychainContract.KeyRings.HAS_DUPLICATE_USER_ID);
|
int index = getColumnIndexOrThrow(KeychainContract.KeyRings.HAS_DUPLICATE_USER_ID);
|
||||||
return getLong(index) > 0L;
|
return getLong(index) > 0L;
|
||||||
|
|||||||
Reference in New Issue
Block a user