Add missing columns for projections, remove use of raw user id

This commit is contained in:
Dominik Schürmann
2017-01-27 00:52:54 +01:00
parent 732aa0de60
commit 78bbe20149
5 changed files with 30 additions and 73 deletions

View File

@@ -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;

View File

@@ -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";

View File

@@ -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();

View File

@@ -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 {

View File

@@ -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;
@@ -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,6 +167,7 @@ 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
*/ */
@@ -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;