Merge branch 'daquexian-issue_1846'
This commit is contained in:
@@ -109,6 +109,40 @@ public class CachedPublicKeyRing extends KeyRing {
|
|||||||
return getPrimaryUserId();
|
return getPrimaryUserId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getName() throws PgpKeyNotFoundException {
|
||||||
|
try {
|
||||||
|
Object data = mProviderHelper.getGenericData(mUri,
|
||||||
|
KeyRings.NAME,
|
||||||
|
ProviderHelper.FIELD_TYPE_STRING);
|
||||||
|
return (String) data;
|
||||||
|
} catch(ProviderHelper.NotFoundException e) {
|
||||||
|
throw new PgpKeyNotFoundException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() throws PgpKeyNotFoundException {
|
||||||
|
try {
|
||||||
|
Object data = mProviderHelper.getGenericData(mUri,
|
||||||
|
KeyRings.EMAIL,
|
||||||
|
ProviderHelper.FIELD_TYPE_STRING);
|
||||||
|
return (String) data;
|
||||||
|
} catch(ProviderHelper.NotFoundException e) {
|
||||||
|
throw new PgpKeyNotFoundException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getComment() throws PgpKeyNotFoundException {
|
||||||
|
try {
|
||||||
|
Object data = mProviderHelper.getGenericData(mUri,
|
||||||
|
KeyRings.COMMENT,
|
||||||
|
ProviderHelper.FIELD_TYPE_STRING);
|
||||||
|
return (String) data;
|
||||||
|
} catch(ProviderHelper.NotFoundException e) {
|
||||||
|
throw new PgpKeyNotFoundException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRevoked() throws PgpKeyNotFoundException {
|
public boolean isRevoked() throws PgpKeyNotFoundException {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -526,6 +526,9 @@ public class KeychainProvider extends ContentProvider {
|
|||||||
projectionMap.put(UserPackets.MASTER_KEY_ID, Tables.USER_PACKETS + "." + UserPackets.MASTER_KEY_ID);
|
projectionMap.put(UserPackets.MASTER_KEY_ID, Tables.USER_PACKETS + "." + UserPackets.MASTER_KEY_ID);
|
||||||
projectionMap.put(UserPackets.TYPE, Tables.USER_PACKETS + "." + UserPackets.TYPE);
|
projectionMap.put(UserPackets.TYPE, Tables.USER_PACKETS + "." + UserPackets.TYPE);
|
||||||
projectionMap.put(UserPackets.USER_ID, Tables.USER_PACKETS + "." + UserPackets.USER_ID);
|
projectionMap.put(UserPackets.USER_ID, Tables.USER_PACKETS + "." + UserPackets.USER_ID);
|
||||||
|
projectionMap.put(UserPackets.NAME, Tables.USER_PACKETS + "." + UserPackets.NAME);
|
||||||
|
projectionMap.put(UserPackets.EMAIL, Tables.USER_PACKETS + "." + UserPackets.EMAIL);
|
||||||
|
projectionMap.put(UserPackets.COMMENT, Tables.USER_PACKETS + "." + UserPackets.COMMENT);
|
||||||
projectionMap.put(UserPackets.ATTRIBUTE_DATA, Tables.USER_PACKETS + "." + UserPackets.ATTRIBUTE_DATA);
|
projectionMap.put(UserPackets.ATTRIBUTE_DATA, Tables.USER_PACKETS + "." + UserPackets.ATTRIBUTE_DATA);
|
||||||
projectionMap.put(UserPackets.RANK, Tables.USER_PACKETS + "." + UserPackets.RANK);
|
projectionMap.put(UserPackets.RANK, Tables.USER_PACKETS + "." + UserPackets.RANK);
|
||||||
projectionMap.put(UserPackets.IS_PRIMARY, Tables.USER_PACKETS + "." + UserPackets.IS_PRIMARY);
|
projectionMap.put(UserPackets.IS_PRIMARY, Tables.USER_PACKETS + "." + UserPackets.IS_PRIMARY);
|
||||||
|
|||||||
@@ -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();
|
||||||
@@ -181,14 +152,15 @@ public class SelectEncryptKeyAdapter extends KeyCursorAdapter<SelectEncryptKeyAd
|
|||||||
Context context = itemView.getContext();
|
Context context = itemView.getContext();
|
||||||
|
|
||||||
{ // set name and stuff, common to both key types
|
{ // set name and stuff, common to both key types
|
||||||
OpenPgpUtils.UserId userIdSplit = cursor.getUserId();
|
String name = cursor.getName();
|
||||||
if (userIdSplit.name != null) {
|
String email = cursor.getEmail();
|
||||||
mUserIdText.setText(highlighter.highlight(userIdSplit.name));
|
if (name != null) {
|
||||||
|
mUserIdText.setText(highlighter.highlight(name));
|
||||||
} else {
|
} else {
|
||||||
mUserIdText.setText(R.string.user_id_no_name);
|
mUserIdText.setText(R.string.user_id_no_name);
|
||||||
}
|
}
|
||||||
if (userIdSplit.email != null) {
|
if (email != null) {
|
||||||
mUserIdRestText.setText(highlighter.highlight(userIdSplit.email));
|
mUserIdRestText.setText(highlighter.highlight(email));
|
||||||
mUserIdRestText.setVisibility(View.VISIBLE);
|
mUserIdRestText.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
mUserIdRestText.setVisibility(View.GONE);
|
mUserIdRestText.setVisibility(View.GONE);
|
||||||
|
|||||||
@@ -141,14 +141,15 @@ public class SelectSignKeyAdapter extends KeyCursorAdapter<CursorAdapter.KeyCurs
|
|||||||
Context context = itemView.getContext();
|
Context context = itemView.getContext();
|
||||||
|
|
||||||
{ // set name and stuff, common to both key types
|
{ // set name and stuff, common to both key types
|
||||||
OpenPgpUtils.UserId userIdSplit = cursor.getUserId();
|
String name = cursor.getName();
|
||||||
if (userIdSplit.name != null) {
|
String email = cursor.getEmail();
|
||||||
mUserIdText.setText(highlighter.highlight(userIdSplit.name));
|
if (name != null) {
|
||||||
|
mUserIdText.setText(highlighter.highlight(name));
|
||||||
} else {
|
} else {
|
||||||
mUserIdText.setText(R.string.user_id_no_name);
|
mUserIdText.setText(R.string.user_id_no_name);
|
||||||
}
|
}
|
||||||
if (userIdSplit.email != null) {
|
if (email != null) {
|
||||||
mUserIdRestText.setText(highlighter.highlight(userIdSplit.email));
|
mUserIdRestText.setText(highlighter.highlight(email));
|
||||||
mUserIdRestText.setVisibility(View.VISIBLE);
|
mUserIdRestText.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
mUserIdRestText.setVisibility(View.GONE);
|
mUserIdRestText.setVisibility(View.GONE);
|
||||||
|
|||||||
@@ -275,6 +275,9 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
|||||||
KeychainContract.KeyRings.USER_ID,
|
KeychainContract.KeyRings.USER_ID,
|
||||||
KeychainContract.KeyRings.VERIFIED,
|
KeychainContract.KeyRings.VERIFIED,
|
||||||
KeychainContract.KeyRings.HAS_ANY_SECRET,
|
KeychainContract.KeyRings.HAS_ANY_SECRET,
|
||||||
|
KeyRings.NAME,
|
||||||
|
KeyRings.EMAIL,
|
||||||
|
KeyRings.COMMENT,
|
||||||
};
|
};
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@@ -282,6 +285,9 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
|||||||
static final int INDEX_USER_ID = 2;
|
static final int INDEX_USER_ID = 2;
|
||||||
static final int INDEX_VERIFIED = 3;
|
static final int INDEX_VERIFIED = 3;
|
||||||
static final int INDEX_HAS_ANY_SECRET = 4;
|
static final int INDEX_HAS_ANY_SECRET = 4;
|
||||||
|
static final int INDEX_NAME = 5;
|
||||||
|
static final int INDEX_EMAIL = 6;
|
||||||
|
static final int INDEX_COMMENT = 7;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
@@ -309,15 +315,15 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
|
|||||||
|
|
||||||
long signatureKeyId = mSignatureResult.getKeyId();
|
long signatureKeyId = mSignatureResult.getKeyId();
|
||||||
|
|
||||||
String userId = data.getString(INDEX_USER_ID);
|
String name = data.getString(INDEX_NAME);
|
||||||
OpenPgpUtils.UserId userIdSplit = KeyRing.splitUserId(userId);
|
String email = data.getString(INDEX_EMAIL);
|
||||||
if (userIdSplit.name != null) {
|
if (name != null) {
|
||||||
mSignatureName.setText(userIdSplit.name);
|
mSignatureName.setText(name);
|
||||||
} else {
|
} else {
|
||||||
mSignatureName.setText(R.string.user_id_no_name);
|
mSignatureName.setText(R.string.user_id_no_name);
|
||||||
}
|
}
|
||||||
if (userIdSplit.email != null) {
|
if (email != null) {
|
||||||
mSignatureEmail.setText(userIdSplit.email);
|
mSignatureEmail.setText(email);
|
||||||
} else {
|
} else {
|
||||||
mSignatureEmail.setText(KeyFormattingUtils.beautifyKeyIdWithPrefix(
|
mSignatureEmail.setText(KeyFormattingUtils.beautifyKeyIdWithPrefix(
|
||||||
mSignatureResult.getKeyId()));
|
mSignatureResult.getKeyId()));
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
|||||||
try {
|
try {
|
||||||
HashMap<String, Object> data = new ProviderHelper(this).getUnifiedData(
|
HashMap<String, Object> data = new ProviderHelper(this).getUnifiedData(
|
||||||
mMasterKeyIds[0], new String[]{
|
mMasterKeyIds[0], new String[]{
|
||||||
KeychainContract.KeyRings.USER_ID,
|
KeychainContract.KeyRings.NAME,
|
||||||
KeychainContract.KeyRings.IS_REVOKED
|
KeychainContract.KeyRings.IS_REVOKED
|
||||||
}, new int[]{
|
}, new int[]{
|
||||||
ProviderHelper.FIELD_TYPE_STRING,
|
ProviderHelper.FIELD_TYPE_STRING,
|
||||||
@@ -102,11 +102,10 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
|||||||
);
|
);
|
||||||
|
|
||||||
String name;
|
String name;
|
||||||
OpenPgpUtils.UserId mainUserId = KeyRing.splitUserId(
|
|
||||||
(String) data.get(KeychainContract.KeyRings.USER_ID));
|
name = (String) data.get(KeychainContract.KeyRings.NAME);
|
||||||
if (mainUserId.name != null) {
|
|
||||||
name = mainUserId.name;
|
if (name == null) {
|
||||||
} else {
|
|
||||||
name = getString(R.string.user_id_no_name);
|
name = getString(R.string.user_id_no_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,7 +273,7 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
|||||||
try {
|
try {
|
||||||
HashMap<String, Object> data = new ProviderHelper(activity).getUnifiedData(
|
HashMap<String, Object> data = new ProviderHelper(activity).getUnifiedData(
|
||||||
masterKeyId, new String[]{
|
masterKeyId, new String[]{
|
||||||
KeychainContract.KeyRings.USER_ID,
|
KeychainContract.KeyRings.NAME,
|
||||||
KeychainContract.KeyRings.HAS_ANY_SECRET
|
KeychainContract.KeyRings.HAS_ANY_SECRET
|
||||||
}, new int[]{
|
}, new int[]{
|
||||||
ProviderHelper.FIELD_TYPE_STRING,
|
ProviderHelper.FIELD_TYPE_STRING,
|
||||||
@@ -282,10 +281,9 @@ public class DeleteKeyDialogActivity extends FragmentActivity {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
String name;
|
String name;
|
||||||
OpenPgpUtils.UserId mainUserId = KeyRing.splitUserId((String) data.get(KeychainContract.KeyRings.USER_ID));
|
|
||||||
if (mainUserId.name != null) {
|
name = (String) data.get(KeychainContract.KeyRings.NAME);
|
||||||
name = mainUserId.name;
|
if (name == null) {
|
||||||
} else {
|
|
||||||
name = getString(R.string.user_id_no_name);
|
name = getString(R.string.user_id_no_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,10 @@ public class MultiUserIdsFragment extends Fragment implements LoaderManager.Load
|
|||||||
KeychainContract.UserPackets.MASTER_KEY_ID,
|
KeychainContract.UserPackets.MASTER_KEY_ID,
|
||||||
KeychainContract.UserPackets.USER_ID,
|
KeychainContract.UserPackets.USER_ID,
|
||||||
KeychainContract.UserPackets.IS_PRIMARY,
|
KeychainContract.UserPackets.IS_PRIMARY,
|
||||||
KeychainContract.UserPackets.IS_REVOKED
|
KeychainContract.UserPackets.IS_REVOKED,
|
||||||
|
KeychainContract.UserPackets.NAME,
|
||||||
|
KeychainContract.UserPackets.EMAIL,
|
||||||
|
KeychainContract.UserPackets.COMMENT,
|
||||||
};
|
};
|
||||||
private static final int INDEX_MASTER_KEY_ID = 1;
|
private static final int INDEX_MASTER_KEY_ID = 1;
|
||||||
private static final int INDEX_USER_ID = 2;
|
private static final int INDEX_USER_ID = 2;
|
||||||
@@ -67,6 +70,9 @@ public class MultiUserIdsFragment extends Fragment implements LoaderManager.Load
|
|||||||
private static final int INDEX_IS_PRIMARY = 3;
|
private static final int INDEX_IS_PRIMARY = 3;
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private static final int INDEX_IS_REVOKED = 4;
|
private static final int INDEX_IS_REVOKED = 4;
|
||||||
|
private static final int INDEX_NAME = 5;
|
||||||
|
private static final int INDEX_EMAIL = 6;
|
||||||
|
private static final int INDEX_COMMENT = 7;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
@@ -169,14 +175,14 @@ public class MultiUserIdsFragment extends Fragment implements LoaderManager.Load
|
|||||||
while (!data.isAfterLast()) {
|
while (!data.isAfterLast()) {
|
||||||
long masterKeyId = data.getLong(INDEX_MASTER_KEY_ID);
|
long masterKeyId = data.getLong(INDEX_MASTER_KEY_ID);
|
||||||
String userId = data.getString(INDEX_USER_ID);
|
String userId = data.getString(INDEX_USER_ID);
|
||||||
OpenPgpUtils.UserId pieces = KeyRing.splitUserId(userId);
|
String name = data.getString(INDEX_NAME);
|
||||||
|
|
||||||
// Two cases:
|
// Two cases:
|
||||||
|
|
||||||
boolean grouped = masterKeyId == lastMasterKeyId;
|
boolean grouped = masterKeyId == lastMasterKeyId;
|
||||||
boolean subGrouped = data.isFirst() || grouped && lastName.equals(pieces.name);
|
boolean subGrouped = data.isFirst() || grouped && lastName.equals(name);
|
||||||
// Remember for next loop
|
// Remember for next loop
|
||||||
lastName = pieces.name;
|
lastName = name;
|
||||||
|
|
||||||
Log.d(Constants.TAG, Long.toString(masterKeyId, 16) + (grouped ? "grouped" : "not grouped"));
|
Log.d(Constants.TAG, Long.toString(masterKeyId, 16) + (grouped ? "grouped" : "not grouped"));
|
||||||
|
|
||||||
|
|||||||
@@ -822,7 +822,10 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
|||||||
KeychainContract.KeyRings.VERIFIED,
|
KeychainContract.KeyRings.VERIFIED,
|
||||||
KeychainContract.KeyRings.HAS_ANY_SECRET,
|
KeychainContract.KeyRings.HAS_ANY_SECRET,
|
||||||
KeychainContract.KeyRings.FINGERPRINT,
|
KeychainContract.KeyRings.FINGERPRINT,
|
||||||
KeychainContract.KeyRings.HAS_ENCRYPT
|
KeychainContract.KeyRings.HAS_ENCRYPT,
|
||||||
|
KeyRings.NAME,
|
||||||
|
KeyRings.EMAIL,
|
||||||
|
KeyRings.COMMENT
|
||||||
};
|
};
|
||||||
|
|
||||||
static final int INDEX_MASTER_KEY_ID = 1;
|
static final int INDEX_MASTER_KEY_ID = 1;
|
||||||
@@ -833,6 +836,9 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
|||||||
static final int INDEX_HAS_ANY_SECRET = 6;
|
static final int INDEX_HAS_ANY_SECRET = 6;
|
||||||
static final int INDEX_FINGERPRINT = 7;
|
static final int INDEX_FINGERPRINT = 7;
|
||||||
static final int INDEX_HAS_ENCRYPT = 8;
|
static final int INDEX_HAS_ENCRYPT = 8;
|
||||||
|
static final int INDEX_NAME = 9;
|
||||||
|
static final int INDEX_EMAIL = 10;
|
||||||
|
static final int INDEX_COMMENT = 11;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
@@ -885,12 +891,10 @@ public class ViewKeyActivity extends BaseSecurityTokenActivity implements
|
|||||||
|
|
||||||
if (data.moveToFirst()) {
|
if (data.moveToFirst()) {
|
||||||
// get name, email, and comment from USER_ID
|
// get name, email, and comment from USER_ID
|
||||||
OpenPgpUtils.UserId mainUserId = KeyRing.splitUserId(data.getString(INDEX_USER_ID));
|
|
||||||
if (mainUserId.name != null) {
|
String name = data.getString(INDEX_NAME);
|
||||||
mCollapsingToolbarLayout.setTitle(mainUserId.name);
|
|
||||||
} else {
|
mCollapsingToolbarLayout.setTitle(name != null ? name : getString(R.string.user_id_no_name));
|
||||||
mCollapsingToolbarLayout.setTitle(getString(R.string.user_id_no_name));
|
|
||||||
}
|
|
||||||
|
|
||||||
mMasterKeyId = data.getLong(INDEX_MASTER_KEY_ID);
|
mMasterKeyId = data.getLong(INDEX_MASTER_KEY_ID);
|
||||||
mFingerprint = data.getBlob(INDEX_FINGERPRINT);
|
mFingerprint = data.getBlob(INDEX_FINGERPRINT);
|
||||||
|
|||||||
@@ -179,6 +179,9 @@ public class ViewKeyAdvActivity extends BaseActivity implements
|
|||||||
KeychainContract.KeyRings.VERIFIED,
|
KeychainContract.KeyRings.VERIFIED,
|
||||||
KeychainContract.KeyRings.HAS_ANY_SECRET,
|
KeychainContract.KeyRings.HAS_ANY_SECRET,
|
||||||
KeychainContract.KeyRings.FINGERPRINT,
|
KeychainContract.KeyRings.FINGERPRINT,
|
||||||
|
KeychainContract.KeyRings.NAME,
|
||||||
|
KeychainContract.KeyRings.EMAIL,
|
||||||
|
KeychainContract.KeyRings.COMMENT,
|
||||||
};
|
};
|
||||||
|
|
||||||
static final int INDEX_MASTER_KEY_ID = 1;
|
static final int INDEX_MASTER_KEY_ID = 1;
|
||||||
@@ -188,6 +191,9 @@ public class ViewKeyAdvActivity extends BaseActivity implements
|
|||||||
static final int INDEX_VERIFIED = 5;
|
static final int INDEX_VERIFIED = 5;
|
||||||
static final int INDEX_HAS_ANY_SECRET = 6;
|
static final int INDEX_HAS_ANY_SECRET = 6;
|
||||||
static final int INDEX_FINGERPRINT = 7;
|
static final int INDEX_FINGERPRINT = 7;
|
||||||
|
static final int INDEX_NAME = 8;
|
||||||
|
static final int INDEX_EMAIL = 9;
|
||||||
|
static final int INDEX_COMMENT = 10;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
@@ -214,9 +220,10 @@ public class ViewKeyAdvActivity extends BaseActivity implements
|
|||||||
case LOADER_ID_UNIFIED: {
|
case LOADER_ID_UNIFIED: {
|
||||||
if (data.moveToFirst()) {
|
if (data.moveToFirst()) {
|
||||||
// get name, email, and comment from USER_ID
|
// get name, email, and comment from USER_ID
|
||||||
OpenPgpUtils.UserId mainUserId = KeyRing.splitUserId(data.getString(INDEX_USER_ID));
|
String name = data.getString(INDEX_NAME);
|
||||||
if (mainUserId.name != null) {
|
|
||||||
setTitle(mainUserId.name);
|
if (name != null) {
|
||||||
|
setTitle(name);
|
||||||
} else {
|
} else {
|
||||||
setTitle(R.string.user_id_no_name);
|
setTitle(R.string.user_id_no_name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,8 +233,19 @@ public class CertSectionedListAdapter extends SectionCursorAdapter<CertSectioned
|
|||||||
return getString(index);
|
return getString(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OpenPgpUtils.UserId getUserId() {
|
public String getName() {
|
||||||
return KeyRing.splitUserId(getRawUserId());
|
int index = getColumnIndexOrThrow(KeychainContract.Certs.NAME);
|
||||||
|
return getString(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
int index = getColumnIndexOrThrow(KeychainContract.Certs.EMAIL);
|
||||||
|
return getString(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComment() {
|
||||||
|
int index = getColumnIndexOrThrow(KeychainContract.Certs.COMMENT);
|
||||||
|
return getString(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OpenPgpUtils.UserId getSignerUserId() {
|
public OpenPgpUtils.UserId getSignerUserId() {
|
||||||
|
|||||||
@@ -66,7 +66,10 @@ public class KeyAdapter extends CursorAdapter {
|
|||||||
KeyRings.HAS_DUPLICATE_USER_ID,
|
KeyRings.HAS_DUPLICATE_USER_ID,
|
||||||
KeyRings.FINGERPRINT,
|
KeyRings.FINGERPRINT,
|
||||||
KeyRings.CREATION,
|
KeyRings.CREATION,
|
||||||
KeyRings.HAS_ENCRYPT
|
KeyRings.HAS_ENCRYPT,
|
||||||
|
KeyRings.NAME,
|
||||||
|
KeyRings.EMAIL,
|
||||||
|
KeyRings.COMMENT
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final int INDEX_MASTER_KEY_ID = 1;
|
public static final int INDEX_MASTER_KEY_ID = 1;
|
||||||
@@ -79,6 +82,9 @@ public class KeyAdapter extends CursorAdapter {
|
|||||||
public static final int INDEX_FINGERPRINT = 8;
|
public static final int INDEX_FINGERPRINT = 8;
|
||||||
public static final int INDEX_CREATION = 9;
|
public static final int INDEX_CREATION = 9;
|
||||||
public static final int INDEX_HAS_ENCRYPT = 10;
|
public static final int INDEX_HAS_ENCRYPT = 10;
|
||||||
|
public static final int INDEX_NAME = 11;
|
||||||
|
public static final int INDEX_EMAIL = 12;
|
||||||
|
public static final int INDEX_COMMENT = 13;
|
||||||
|
|
||||||
public KeyAdapter(Context context, Cursor c, int flags) {
|
public KeyAdapter(Context context, Cursor c, int flags) {
|
||||||
super(context, c, flags);
|
super(context, c, flags);
|
||||||
@@ -266,6 +272,9 @@ public class KeyAdapter extends CursorAdapter {
|
|||||||
|
|
||||||
public final String mUserIdFull;
|
public final String mUserIdFull;
|
||||||
public final OpenPgpUtils.UserId mUserId;
|
public final OpenPgpUtils.UserId mUserId;
|
||||||
|
public final String mName;
|
||||||
|
public final String mEmail;
|
||||||
|
public final String mComment;
|
||||||
public final long mKeyId;
|
public final long mKeyId;
|
||||||
public final boolean mHasDuplicate;
|
public final boolean mHasDuplicate;
|
||||||
public final boolean mHasEncrypt;
|
public final boolean mHasEncrypt;
|
||||||
@@ -276,6 +285,9 @@ public class KeyAdapter extends CursorAdapter {
|
|||||||
private KeyItem(Cursor cursor) {
|
private KeyItem(Cursor cursor) {
|
||||||
String userId = cursor.getString(INDEX_USER_ID);
|
String userId = cursor.getString(INDEX_USER_ID);
|
||||||
mUserId = KeyRing.splitUserId(userId);
|
mUserId = KeyRing.splitUserId(userId);
|
||||||
|
mName = cursor.getString(INDEX_NAME);
|
||||||
|
mEmail = cursor.getString(INDEX_EMAIL);
|
||||||
|
mComment = cursor.getString(INDEX_COMMENT);
|
||||||
mUserIdFull = userId;
|
mUserIdFull = userId;
|
||||||
mKeyId = cursor.getLong(INDEX_MASTER_KEY_ID);
|
mKeyId = cursor.getLong(INDEX_MASTER_KEY_ID);
|
||||||
mHasDuplicate = cursor.getLong(INDEX_HAS_DUPLICATE_USER_ID) > 0;
|
mHasDuplicate = cursor.getLong(INDEX_HAS_DUPLICATE_USER_ID) > 0;
|
||||||
@@ -293,6 +305,9 @@ public class KeyAdapter extends CursorAdapter {
|
|||||||
CanonicalizedPublicKey key = ring.getPublicKey();
|
CanonicalizedPublicKey key = ring.getPublicKey();
|
||||||
String userId = key.getPrimaryUserIdWithFallback();
|
String userId = key.getPrimaryUserIdWithFallback();
|
||||||
mUserId = KeyRing.splitUserId(userId);
|
mUserId = KeyRing.splitUserId(userId);
|
||||||
|
mName = mUserId.name;
|
||||||
|
mEmail = mUserId.email;
|
||||||
|
mComment = mUserId.comment;
|
||||||
mUserIdFull = userId;
|
mUserIdFull = userId;
|
||||||
mKeyId = ring.getMasterKeyId();
|
mKeyId = ring.getMasterKeyId();
|
||||||
mHasDuplicate = false;
|
mHasDuplicate = false;
|
||||||
@@ -309,10 +324,10 @@ public class KeyAdapter extends CursorAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getReadableName() {
|
public String getReadableName() {
|
||||||
if (mUserId.name != null) {
|
if (mName != null) {
|
||||||
return mUserId.name;
|
return mName;
|
||||||
} else {
|
} else {
|
||||||
return mUserId.email;
|
return mEmail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 {
|
||||||
@@ -380,14 +380,15 @@ public class KeySectionedListAdapter extends SectionCursorAdapter<KeySectionedLi
|
|||||||
Context context = itemView.getContext();
|
Context context = itemView.getContext();
|
||||||
|
|
||||||
{ // set name and stuff, common to both key types
|
{ // set name and stuff, common to both key types
|
||||||
OpenPgpUtils.UserId userIdSplit = keyItem.getUserId();
|
String name = keyItem.getName();
|
||||||
if (userIdSplit.name != null) {
|
String email = keyItem.getEmail();
|
||||||
mMainUserId.setText(highlighter.highlight(userIdSplit.name));
|
if (name != null) {
|
||||||
|
mMainUserId.setText(highlighter.highlight(name));
|
||||||
} else {
|
} else {
|
||||||
mMainUserId.setText(R.string.user_id_no_name);
|
mMainUserId.setText(R.string.user_id_no_name);
|
||||||
}
|
}
|
||||||
if (userIdSplit.email != null) {
|
if (email != null) {
|
||||||
mMainUserIdRest.setText(highlighter.highlight(userIdSplit.email));
|
mMainUserIdRest.setText(highlighter.highlight(email));
|
||||||
mMainUserIdRest.setVisibility(View.VISIBLE);
|
mMainUserIdRest.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
mMainUserIdRest.setVisibility(View.GONE);
|
mMainUserIdRest.setVisibility(View.GONE);
|
||||||
|
|||||||
@@ -33,7 +33,10 @@ public abstract class UserAttributesAdapter extends CursorAdapter {
|
|||||||
UserPackets.RANK,
|
UserPackets.RANK,
|
||||||
UserPackets.VERIFIED,
|
UserPackets.VERIFIED,
|
||||||
UserPackets.IS_PRIMARY,
|
UserPackets.IS_PRIMARY,
|
||||||
UserPackets.IS_REVOKED
|
UserPackets.IS_REVOKED,
|
||||||
|
UserPackets.NAME,
|
||||||
|
UserPackets.EMAIL,
|
||||||
|
UserPackets.COMMENT,
|
||||||
};
|
};
|
||||||
public static final int INDEX_ID = 0;
|
public static final int INDEX_ID = 0;
|
||||||
public static final int INDEX_TYPE = 1;
|
public static final int INDEX_TYPE = 1;
|
||||||
@@ -43,6 +46,9 @@ public abstract class UserAttributesAdapter extends CursorAdapter {
|
|||||||
public static final int INDEX_VERIFIED = 5;
|
public static final int INDEX_VERIFIED = 5;
|
||||||
public static final int INDEX_IS_PRIMARY = 6;
|
public static final int INDEX_IS_PRIMARY = 6;
|
||||||
public static final int INDEX_IS_REVOKED = 7;
|
public static final int INDEX_IS_REVOKED = 7;
|
||||||
|
public static final int INDEX_NAME = 8;
|
||||||
|
public static final int INDEX_EMAIL = 9;
|
||||||
|
public static final int INDEX_COMMENT = 10;
|
||||||
|
|
||||||
public UserAttributesAdapter(Context context, Cursor c, int flags) {
|
public UserAttributesAdapter(Context context, Cursor c, int flags) {
|
||||||
super(context, c, flags);
|
super(context, c, flags);
|
||||||
|
|||||||
@@ -71,20 +71,22 @@ public class UserIdsAdapter extends UserAttributesAdapter {
|
|||||||
vDeleteButton.setVisibility(View.GONE); // not used
|
vDeleteButton.setVisibility(View.GONE); // not used
|
||||||
|
|
||||||
String userId = cursor.getString(INDEX_USER_ID);
|
String userId = cursor.getString(INDEX_USER_ID);
|
||||||
OpenPgpUtils.UserId splitUserId = KeyRing.splitUserId(userId);
|
String name = cursor.getString(INDEX_NAME);
|
||||||
if (splitUserId.name != null) {
|
String email = cursor.getString(INDEX_EMAIL);
|
||||||
vName.setText(splitUserId.name);
|
String comment = cursor.getString(INDEX_COMMENT);
|
||||||
|
if (name != null) {
|
||||||
|
vName.setText(name);
|
||||||
} else {
|
} else {
|
||||||
vName.setText(R.string.user_id_no_name);
|
vName.setText(R.string.user_id_no_name);
|
||||||
}
|
}
|
||||||
if (splitUserId.email != null) {
|
if (email != null) {
|
||||||
vAddress.setText(splitUserId.email);
|
vAddress.setText(email);
|
||||||
vAddress.setVisibility(View.VISIBLE);
|
vAddress.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
vAddress.setVisibility(View.GONE);
|
vAddress.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
if (splitUserId.comment != null) {
|
if (comment != null) {
|
||||||
vComment.setText(splitUserId.comment);
|
vComment.setText(comment);
|
||||||
vComment.setVisibility(View.VISIBLE);
|
vComment.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
vComment.setVisibility(View.GONE);
|
vComment.setVisibility(View.GONE);
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
@@ -390,7 +390,10 @@ public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH e
|
|||||||
KeychainContract.KeyRings.IS_REVOKED,
|
KeychainContract.KeyRings.IS_REVOKED,
|
||||||
KeychainContract.KeyRings.IS_EXPIRED,
|
KeychainContract.KeyRings.IS_EXPIRED,
|
||||||
KeychainContract.KeyRings.HAS_DUPLICATE_USER_ID,
|
KeychainContract.KeyRings.HAS_DUPLICATE_USER_ID,
|
||||||
KeychainContract.KeyRings.CREATION
|
KeychainContract.KeyRings.CREATION,
|
||||||
|
KeychainContract.KeyRings.NAME,
|
||||||
|
KeychainContract.KeyRings.EMAIL,
|
||||||
|
KeychainContract.KeyRings.COMMENT
|
||||||
));
|
));
|
||||||
|
|
||||||
PROJECTION = arr.toArray(new String[arr.size()]);
|
PROJECTION = arr.toArray(new String[arr.size()]);
|
||||||
@@ -418,13 +421,19 @@ public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH e
|
|||||||
return getLong(index);
|
return getLong(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRawUserId() {
|
public String getName() {
|
||||||
int index = getColumnIndexOrThrow(KeychainContract.KeyRings.USER_ID);
|
int index = getColumnIndexOrThrow(KeychainContract.KeyRings.NAME);
|
||||||
return getString(index);
|
return getString(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OpenPgpUtils.UserId getUserId() {
|
public String getEmail() {
|
||||||
return KeyRing.splitUserId(getRawUserId());
|
int index = getColumnIndexOrThrow(KeychainContract.KeyRings.EMAIL);
|
||||||
|
return getString(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getComment() {
|
||||||
|
int index = getColumnIndexOrThrow(KeychainContract.KeyRings.COMMENT);
|
||||||
|
return getString(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasDuplicate() {
|
public boolean hasDuplicate() {
|
||||||
|
|||||||
@@ -451,7 +451,10 @@ public class ContactHelper {
|
|||||||
KeychainContract.KeyRings.IS_REVOKED,
|
KeychainContract.KeyRings.IS_REVOKED,
|
||||||
KeychainContract.KeyRings.VERIFIED,
|
KeychainContract.KeyRings.VERIFIED,
|
||||||
KeychainContract.KeyRings.HAS_SECRET,
|
KeychainContract.KeyRings.HAS_SECRET,
|
||||||
KeychainContract.KeyRings.HAS_ANY_SECRET};
|
KeychainContract.KeyRings.HAS_ANY_SECRET,
|
||||||
|
KeychainContract.KeyRings.NAME,
|
||||||
|
KeychainContract.KeyRings.EMAIL,
|
||||||
|
KeychainContract.KeyRings.COMMENT };
|
||||||
|
|
||||||
public static final int INDEX_MASTER_KEY_ID = 0;
|
public static final int INDEX_MASTER_KEY_ID = 0;
|
||||||
public static final int INDEX_USER_ID = 1;
|
public static final int INDEX_USER_ID = 1;
|
||||||
@@ -460,6 +463,9 @@ public class ContactHelper {
|
|||||||
public static final int INDEX_VERIFIED = 4;
|
public static final int INDEX_VERIFIED = 4;
|
||||||
public static final int INDEX_HAS_SECRET = 5;
|
public static final int INDEX_HAS_SECRET = 5;
|
||||||
public static final int INDEX_HAS_ANY_SECRET = 6;
|
public static final int INDEX_HAS_ANY_SECRET = 6;
|
||||||
|
public static final int INDEX_NAME = 7;
|
||||||
|
public static final int INDEX_EMAIL = 8;
|
||||||
|
public static final int INDEX_COMMENT = 9;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write/Update the current OpenKeychain keys to the contact db
|
* Write/Update the current OpenKeychain keys to the contact db
|
||||||
@@ -504,7 +510,7 @@ public class ContactHelper {
|
|||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
long masterKeyId = cursor.getLong(INDEX_MASTER_KEY_ID);
|
long masterKeyId = cursor.getLong(INDEX_MASTER_KEY_ID);
|
||||||
OpenPgpUtils.UserId userIdSplit = KeyRing.splitUserId(cursor.getString(INDEX_USER_ID));
|
String name = cursor.getString(INDEX_NAME);
|
||||||
boolean isExpired = cursor.getInt(INDEX_IS_EXPIRED) != 0;
|
boolean isExpired = cursor.getInt(INDEX_IS_EXPIRED) != 0;
|
||||||
boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;
|
boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;
|
||||||
boolean isVerified = cursor.getInt(INDEX_VERIFIED) > 0;
|
boolean isVerified = cursor.getInt(INDEX_VERIFIED) > 0;
|
||||||
@@ -523,7 +529,7 @@ public class ContactHelper {
|
|||||||
if (masterKeyId != -1) {
|
if (masterKeyId != -1) {
|
||||||
deleteRawContactByMasterKeyId(masterKeyId);
|
deleteRawContactByMasterKeyId(masterKeyId);
|
||||||
}
|
}
|
||||||
} else if (userIdSplit.name != null) {
|
} else if (name != null) {
|
||||||
|
|
||||||
// get raw contact to this master key id
|
// get raw contact to this master key id
|
||||||
long rawContactId = findRawContactId(masterKeyId);
|
long rawContactId = findRawContactId(masterKeyId);
|
||||||
@@ -534,12 +540,12 @@ public class ContactHelper {
|
|||||||
Log.d(Constants.TAG, "Insert new raw contact with masterKeyId " + masterKeyId);
|
Log.d(Constants.TAG, "Insert new raw contact with masterKeyId " + masterKeyId);
|
||||||
|
|
||||||
insertContact(ops, masterKeyId);
|
insertContact(ops, masterKeyId);
|
||||||
writeContactKey(ops, rawContactId, masterKeyId, userIdSplit.name);
|
writeContactKey(ops, rawContactId, masterKeyId, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We always update the display name (which is derived from primary user id)
|
// We always update the display name (which is derived from primary user id)
|
||||||
// and email addresses from user id
|
// and email addresses from user id
|
||||||
writeContactDisplayName(ops, rawContactId, userIdSplit.name);
|
writeContactDisplayName(ops, rawContactId, name);
|
||||||
writeContactEmail(ops, rawContactId, masterKeyId);
|
writeContactEmail(ops, rawContactId, masterKeyId);
|
||||||
try {
|
try {
|
||||||
mContentResolver.applyBatch(ContactsContract.AUTHORITY, ops);
|
mContentResolver.applyBatch(ContactsContract.AUTHORITY, ops);
|
||||||
@@ -579,9 +585,9 @@ public class ContactHelper {
|
|||||||
long masterKeyId = cursor.getLong(INDEX_MASTER_KEY_ID);
|
long masterKeyId = cursor.getLong(INDEX_MASTER_KEY_ID);
|
||||||
boolean isExpired = cursor.getInt(INDEX_IS_EXPIRED) != 0;
|
boolean isExpired = cursor.getInt(INDEX_IS_EXPIRED) != 0;
|
||||||
boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;
|
boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;
|
||||||
OpenPgpUtils.UserId userIdSplit = KeyRing.splitUserId(cursor.getString(INDEX_USER_ID));
|
String name = cursor.getString(INDEX_NAME);
|
||||||
|
|
||||||
if (!isExpired && !isRevoked && userIdSplit.name != null) {
|
if (!isExpired && !isRevoked && name != null) {
|
||||||
// if expired or revoked will not be removed from keysToDelete or inserted
|
// if expired or revoked will not be removed from keysToDelete or inserted
|
||||||
// into main profile ("me" contact)
|
// into main profile ("me" contact)
|
||||||
boolean existsInMainProfile = keysToDelete.remove(masterKeyId);
|
boolean existsInMainProfile = keysToDelete.remove(masterKeyId);
|
||||||
@@ -592,7 +598,7 @@ public class ContactHelper {
|
|||||||
|
|
||||||
ArrayList<ContentProviderOperation> ops = new ArrayList<>();
|
ArrayList<ContentProviderOperation> ops = new ArrayList<>();
|
||||||
insertMainProfileRawContact(ops, masterKeyId);
|
insertMainProfileRawContact(ops, masterKeyId);
|
||||||
writeContactKey(ops, rawContactId, masterKeyId, userIdSplit.name);
|
writeContactKey(ops, rawContactId, masterKeyId, name);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mContentResolver.applyBatch(ContactsContract.AUTHORITY, ops);
|
mContentResolver.applyBatch(ContactsContract.AUTHORITY, ops);
|
||||||
|
|||||||
Reference in New Issue
Block a user