mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-30 04:22:18 -05:00
certs: display green dot for certified keys in KeyListFragment
This commit is contained in:
parent
194fc7507b
commit
bd8dc05b1c
@ -110,6 +110,7 @@ public class KeychainContract {
|
||||
public static class KeyRings implements BaseColumns, KeysColumns, UserIdsColumns {
|
||||
public static final String MASTER_KEY_ID = KeysColumns.MASTER_KEY_ID;
|
||||
public static final String IS_REVOKED = KeysColumns.IS_REVOKED;
|
||||
public static final String VERIFIED = CertsColumns.VERIFIED;
|
||||
public static final String HAS_SECRET = "has_secret";
|
||||
|
||||
public static final Uri CONTENT_URI = BASE_CONTENT_URI_INTERNAL.buildUpon()
|
||||
|
@ -257,11 +257,12 @@ public class KeychainProvider extends ContentProvider {
|
||||
projectionMap.put(KeyRings.CAN_CERTIFY, Keys.CAN_CERTIFY);
|
||||
projectionMap.put(KeyRings.CAN_ENCRYPT, Keys.CAN_ENCRYPT);
|
||||
projectionMap.put(KeyRings.CAN_SIGN, Keys.CAN_SIGN);
|
||||
projectionMap.put(KeyRings.CREATION, Keys.CREATION);
|
||||
projectionMap.put(KeyRings.CREATION, Tables.KEYS + "." + Keys.CREATION);
|
||||
projectionMap.put(KeyRings.EXPIRY, Keys.EXPIRY);
|
||||
projectionMap.put(KeyRings.ALGORITHM, Keys.ALGORITHM);
|
||||
projectionMap.put(KeyRings.FINGERPRINT, Keys.FINGERPRINT);
|
||||
projectionMap.put(KeyRings.USER_ID, UserIds.USER_ID);
|
||||
projectionMap.put(KeyRings.VERIFIED, KeyRings.VERIFIED);
|
||||
projectionMap.put(KeyRings.HAS_SECRET, "(" + Tables.KEY_RINGS_SECRET + "." + KeyRings.MASTER_KEY_ID + " IS NOT NULL) AS " + KeyRings.HAS_SECRET);
|
||||
qb.setProjectionMap(projectionMap);
|
||||
|
||||
@ -276,9 +277,17 @@ public class KeychainProvider extends ContentProvider {
|
||||
+ Tables.KEYS + "." + Keys.MASTER_KEY_ID
|
||||
+ " = "
|
||||
+ Tables.KEY_RINGS_SECRET + "." + KeyRings.MASTER_KEY_ID
|
||||
+ ") LEFT JOIN " + Tables.CERTS + " ON ("
|
||||
+ Tables.KEYS + "." + Keys.MASTER_KEY_ID
|
||||
+ " = "
|
||||
+ Tables.CERTS + "." + KeyRings.MASTER_KEY_ID
|
||||
+ " AND " + Tables.CERTS + "." + Certs.VERIFIED
|
||||
+ " = " + Certs.VERIFIED_SECRET
|
||||
+ ")"
|
||||
);
|
||||
qb.appendWhere(Tables.KEYS + "." + Keys.RANK + " = 0");
|
||||
// in case there are multiple verifying certificates
|
||||
groupBy = Tables.KEYS + "." + Keys.MASTER_KEY_ID;
|
||||
|
||||
switch(match) {
|
||||
case KEY_RING_UNIFIED: {
|
||||
|
@ -50,6 +50,7 @@ import android.widget.AbsListView.MultiChoiceModeListener;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import com.beardedhen.androidbootstrap.BootstrapButton;
|
||||
@ -251,13 +252,15 @@ public class KeyListFragment extends Fragment
|
||||
KeyRings.MASTER_KEY_ID,
|
||||
KeyRings.USER_ID,
|
||||
KeyRings.IS_REVOKED,
|
||||
KeyRings.VERIFIED,
|
||||
KeyRings.HAS_SECRET
|
||||
};
|
||||
|
||||
static final int INDEX_MASTER_KEY_ID = 1;
|
||||
static final int INDEX_USER_ID = 2;
|
||||
static final int INDEX_IS_REVOKED = 3;
|
||||
static final int INDEX_HAS_SECRET = 4;
|
||||
static final int INDEX_VERIFIED = 4;
|
||||
static final int INDEX_HAS_SECRET = 5;
|
||||
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||
@ -491,12 +494,14 @@ public class KeyListFragment extends Fragment
|
||||
FrameLayout statusLayout = (FrameLayout) view.findViewById(R.id.status_layout);
|
||||
Button button = (Button) view.findViewById(R.id.edit);
|
||||
TextView revoked = (TextView) view.findViewById(R.id.revoked);
|
||||
ImageView verified = (ImageView) view.findViewById(R.id.verified);
|
||||
|
||||
if (cursor.getInt(KeyListFragment.INDEX_HAS_SECRET) != 0) {
|
||||
// this is a secret key - show the edit button
|
||||
statusDivider.setVisibility(View.VISIBLE);
|
||||
statusLayout.setVisibility(View.VISIBLE);
|
||||
revoked.setVisibility(View.GONE);
|
||||
verified.setVisibility(View.GONE);
|
||||
button.setVisibility(View.VISIBLE);
|
||||
|
||||
final long id = cursor.getLong(INDEX_MASTER_KEY_ID);
|
||||
@ -514,8 +519,16 @@ public class KeyListFragment extends Fragment
|
||||
button.setVisibility(View.GONE);
|
||||
|
||||
boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0;
|
||||
if(isRevoked) {
|
||||
statusLayout.setVisibility(isRevoked ? View.VISIBLE : View.GONE);
|
||||
revoked.setVisibility(isRevoked ? View.VISIBLE : View.GONE);
|
||||
verified.setVisibility(View.GONE);
|
||||
} else {
|
||||
boolean isVerified = cursor.getInt(INDEX_VERIFIED) > 0;
|
||||
statusLayout.setVisibility(isVerified ? View.VISIBLE : View.GONE);
|
||||
revoked.setVisibility(View.GONE);
|
||||
verified.setVisibility(isVerified ? View.VISIBLE : View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,14 @@
|
||||
android:text="@string/revoked"
|
||||
android:textColor="#e00"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/verified"
|
||||
android:layout_gravity="center"
|
||||
android:src="@android:drawable/presence_online"
|
||||
android:paddingLeft="25dp" />
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user