aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-10-05 04:09:55 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2014-10-05 04:09:55 +0200
commit0b9308753d7339251f9051316b00f6f0c9b0efbc (patch)
treedb1811306fa10eaffaf5366b153b9c1f26ef970c
parentd38b200b0107e8eab937aa94b8f74d23603c23cc (diff)
downloadopen-keychain-0b9308753d7339251f9051316b00f6f0c9b0efbc.tar.gz
open-keychain-0b9308753d7339251f9051316b00f6f0c9b0efbc.tar.bz2
open-keychain-0b9308753d7339251f9051316b00f6f0c9b0efbc.zip
use status icons in public key selection
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java4
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java20
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java34
-rw-r--r--OpenKeychain/src/main/res/layout/key_list_item.xml2
-rw-r--r--OpenKeychain/src/main/res/layout/keyspinner_item.xml7
-rw-r--r--OpenKeychain/src/main/res/layout/select_key_item.xml20
-rw-r--r--OpenKeychain/src/main/res/layout/select_secret_key_activity.xml12
-rw-r--r--OpenKeychain/src/main/res/layout/select_secret_key_layout_fragment.xml75
8 files changed, 45 insertions, 129 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java
index 0e8444316..9c261cc49 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java
@@ -59,7 +59,6 @@ import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.util.ExportHelper;
import org.sufficientlysecure.keychain.util.KeyUpdateHelper;
-import org.sufficientlysecure.keychain.util.Preferences;
import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
@@ -224,7 +223,6 @@ public class KeyListFragment extends LoaderFragment
*/
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
mStickyList.setFastScrollAlwaysVisible(true);
- mStickyList.addHeaderView();
mStickyList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);
mStickyList.getWrappedList().setMultiChoiceModeListener(new MultiChoiceModeListener() {
@@ -554,7 +552,7 @@ public class KeyListFragment extends LoaderFragment
ItemViewHolder holder = new ItemViewHolder();
holder.mMainUserId = (TextView) view.findViewById(R.id.mainUserId);
holder.mMainUserIdRest = (TextView) view.findViewById(R.id.mainUserIdRest);
- holder.mStatus = (ImageView) view.findViewById(R.id.status_image);
+ holder.mStatus = (ImageView) view.findViewById(R.id.status_icon);
view.setTag(holder);
return view;
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java
index 9343b166a..621b6b7e1 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java
@@ -42,9 +42,11 @@ import android.widget.TextView;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.compatibility.ListFragmentWorkaround;
+import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables;
import org.sufficientlysecure.keychain.ui.adapter.SelectKeyCursorAdapter;
+import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import java.util.Vector;
@@ -257,9 +259,10 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
KeyRings._ID,
KeyRings.MASTER_KEY_ID,
KeyRings.USER_ID,
- KeyRings.EXPIRY,
+ KeyRings.IS_EXPIRED,
KeyRings.IS_REVOKED,
KeyRings.HAS_ENCRYPT,
+ KeyRings.VERIFIED,
};
String inMasterKeyList = null;
@@ -344,7 +347,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
private class SelectPublicKeyCursorAdapter extends SelectKeyCursorAdapter {
- private int mIndexHasEncrypt;
+ private int mIndexHasEncrypt, mIndexIsVerified;
public SelectPublicKeyCursorAdapter(Context context, Cursor c, int flags, ListView listView) {
super(context, c, flags, listView);
@@ -355,6 +358,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
super.initIndex(cursor);
if (cursor != null) {
mIndexHasEncrypt = cursor.getColumnIndexOrThrow(KeyRings.HAS_ENCRYPT);
+ mIndexIsVerified = cursor.getColumnIndexOrThrow(KeyRings.VERIFIED);
}
}
@@ -369,12 +373,18 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
h.selected.setChecked(getListView().isItemChecked(cursor.getPosition()));
boolean enabled = false;
- if((Boolean) h.status.getTag()) {
+ if((Boolean) h.statusIcon.getTag()) {
// Check if key is viable for our purposes
if (cursor.getInt(mIndexHasEncrypt) == 0) {
- h.status.setText(R.string.no_key);
+ h.statusIcon.setVisibility(View.VISIBLE);
+ KeyFormattingUtils.setStatusImage(mContext, h.statusIcon, KeyFormattingUtils.STATE_UNAVAILABLE);
+ enabled = false;
+ } else if (cursor.getInt(mIndexIsVerified) != 0) {
+ h.statusIcon.setVisibility(View.VISIBLE);
+ KeyFormattingUtils.setStatusImage(mContext, h.statusIcon, KeyFormattingUtils.STATE_VERIFIED);
+ enabled = true;
} else {
- h.status.setText(R.string.can_encrypt);
+ h.statusIcon.setVisibility(View.GONE);
enabled = true;
}
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java
index 6947fc1ff..c864c7138 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java
@@ -24,6 +24,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
+import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
@@ -33,8 +34,6 @@ import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
import org.sufficientlysecure.keychain.ui.util.Highlighter;
-import java.util.Date;
-
/**
* Yes this class is abstract!
@@ -44,7 +43,7 @@ abstract public class SelectKeyCursorAdapter extends CursorAdapter {
private String mQuery;
private LayoutInflater mInflater;
- protected int mIndexUserId, mIndexMasterKeyId, mIndexRevoked, mIndexExpiry;
+ protected int mIndexUserId, mIndexMasterKeyId, mIndexIsExpiry, mIndexIsRevoked;
public SelectKeyCursorAdapter(Context context, Cursor c, int flags, ListView listView) {
super(context, c, flags);
@@ -73,8 +72,8 @@ abstract public class SelectKeyCursorAdapter extends CursorAdapter {
if (cursor != null) {
mIndexUserId = cursor.getColumnIndexOrThrow(KeyRings.USER_ID);
mIndexMasterKeyId = cursor.getColumnIndexOrThrow(KeyRings.MASTER_KEY_ID);
- mIndexExpiry = cursor.getColumnIndexOrThrow(KeyRings.EXPIRY);
- mIndexRevoked = cursor.getColumnIndexOrThrow(KeyRings.IS_REVOKED);
+ mIndexIsExpiry = cursor.getColumnIndexOrThrow(KeyRings.IS_EXPIRED);
+ mIndexIsRevoked = cursor.getColumnIndexOrThrow(KeyRings.IS_REVOKED);
}
}
@@ -90,7 +89,8 @@ abstract public class SelectKeyCursorAdapter extends CursorAdapter {
public static class ViewHolderItem {
public View view;
- public TextView mainUserId, mainUserIdRest, keyId, status;
+ public TextView mainUserId, mainUserIdRest, keyId;
+ public ImageView statusIcon;
public CheckBox selected;
public void setEnabled(boolean enabled) {
@@ -99,7 +99,7 @@ abstract public class SelectKeyCursorAdapter extends CursorAdapter {
mainUserId.setEnabled(enabled);
mainUserIdRest.setEnabled(enabled);
keyId.setEnabled(enabled);
- status.setEnabled(enabled);
+ statusIcon.setEnabled(enabled);
// Sorta special: We set an item as clickable to disable it in the ListView. This works
// because the list item will handle the clicks itself (which is a nop)
@@ -130,19 +130,21 @@ abstract public class SelectKeyCursorAdapter extends CursorAdapter {
long masterKeyId = cursor.getLong(mIndexMasterKeyId);
h.keyId.setText(KeyFormattingUtils.beautifyKeyIdWithPrefix(mContext, masterKeyId));
- boolean enabled = true;
- if (cursor.getInt(mIndexRevoked) != 0) {
- h.status.setText(R.string.revoked);
+ boolean enabled;
+ if (cursor.getInt(mIndexIsRevoked) != 0) {
+ h.statusIcon.setVisibility(View.VISIBLE);
+ KeyFormattingUtils.setStatusImage(mContext, h.statusIcon, KeyFormattingUtils.STATE_REVOKED);
enabled = false;
- } else if (!cursor.isNull(mIndexExpiry)
- && new Date(cursor.getLong(mIndexExpiry) * 1000).before(new Date())) {
- h.status.setText(R.string.expired);
+ } else if (cursor.getInt(mIndexIsExpiry) != 0) {
+ h.statusIcon.setVisibility(View.VISIBLE);
+ KeyFormattingUtils.setStatusImage(mContext, h.statusIcon, KeyFormattingUtils.STATE_EXPIRED);
enabled = false;
} else {
- h.status.setText("");
+ h.statusIcon.setVisibility(View.GONE);
+ enabled = true;
}
- h.status.setTag(enabled);
+ h.statusIcon.setTag(enabled);
}
@Override
@@ -153,7 +155,7 @@ abstract public class SelectKeyCursorAdapter extends CursorAdapter {
holder.mainUserId = (TextView) view.findViewById(R.id.mainUserId);
holder.mainUserIdRest = (TextView) view.findViewById(R.id.mainUserIdRest);
holder.keyId = (TextView) view.findViewById(R.id.subkey_item_key_id);
- holder.status = (TextView) view.findViewById(R.id.status);
+ holder.statusIcon = (ImageView) view.findViewById(R.id.status_icon);
holder.selected = (CheckBox) view.findViewById(R.id.selected);
view.setTag(holder);
return view;
diff --git a/OpenKeychain/src/main/res/layout/key_list_item.xml b/OpenKeychain/src/main/res/layout/key_list_item.xml
index a7a195ffa..bddc2ad97 100644
--- a/OpenKeychain/src/main/res/layout/key_list_item.xml
+++ b/OpenKeychain/src/main/res/layout/key_list_item.xml
@@ -39,7 +39,7 @@
</LinearLayout>
<ImageView
- android:id="@+id/status_image"
+ android:id="@+id/status_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
diff --git a/OpenKeychain/src/main/res/layout/keyspinner_item.xml b/OpenKeychain/src/main/res/layout/keyspinner_item.xml
index 16a20542b..b75bb808e 100644
--- a/OpenKeychain/src/main/res/layout/keyspinner_item.xml
+++ b/OpenKeychain/src/main/res/layout/keyspinner_item.xml
@@ -17,8 +17,7 @@
android:focusable="true"
android:orientation="vertical"
android:paddingLeft="8dp"
- android:paddingRight="4dp"
- >
+ android:paddingRight="4dp">
<TextView
android:id="@+id/keyspinner_key_name"
@@ -43,7 +42,7 @@
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="end"
- android:textAppearance="?android:attr/textAppearanceSmall"/>
+ android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
<ImageView
@@ -53,6 +52,6 @@
android:layout_gravity="center"
android:src="@drawable/status_signature_revoked_cutout"
android:paddingLeft="16dp"
- android:paddingRight="16dp"/>
+ android:paddingRight="16dp" />
</LinearLayout> \ No newline at end of file
diff --git a/OpenKeychain/src/main/res/layout/select_key_item.xml b/OpenKeychain/src/main/res/layout/select_key_item.xml
index 4fe80c7e1..b6cbfd973 100644
--- a/OpenKeychain/src/main/res/layout/select_key_item.xml
+++ b/OpenKeychain/src/main/res/layout/select_key_item.xml
@@ -42,22 +42,16 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0xBBBBBBBBBBBBBBB"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:typeface="monospace" />
+ android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
-
- <TextView
- android:gravity="right"
- android:paddingLeft="4dp"
- android:minWidth="90dip"
- android:id="@+id/status"
- android:paddingTop="4dp"
+ <ImageView
+ android:id="@+id/status_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:text="expired"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textStyle="italic"
- android:layout_gravity="right" />
+ android:layout_gravity="center"
+ android:src="@drawable/status_signature_revoked_cutout"
+ android:paddingLeft="16dp"
+ android:paddingRight="16dp" />
</LinearLayout> \ No newline at end of file
diff --git a/OpenKeychain/src/main/res/layout/select_secret_key_activity.xml b/OpenKeychain/src/main/res/layout/select_secret_key_activity.xml
deleted file mode 100644
index c4cdd7576..000000000
--- a/OpenKeychain/src/main/res/layout/select_secret_key_activity.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_centerHorizontal="true" >
-
- <FrameLayout
- android:id="@+id/select_secret_key_fragment_container"
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
-</RelativeLayout> \ No newline at end of file
diff --git a/OpenKeychain/src/main/res/layout/select_secret_key_layout_fragment.xml b/OpenKeychain/src/main/res/layout/select_secret_key_layout_fragment.xml
deleted file mode 100644
index e5fd3f9f2..000000000
--- a/OpenKeychain/src/main/res/layout/select_secret_key_layout_fragment.xml
+++ /dev/null
@@ -1,75 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal">
-
- <Button
- android:id="@+id/select_secret_key_select_key_button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:layout_marginBottom="4dp"
- android:layout_marginRight="4dp"
- android:layout_marginTop="4dp"
- android:text="@string/api_settings_select_key"
- android:drawableLeft="@drawable/ic_action_accounts"
- android:background="@drawable/button_edgy"
- android:textSize="14sp"/>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginBottom="4dp"
- android:layout_marginLeft="4dp"
- android:layout_marginTop="4dp"
- android:orientation="vertical"
- android:paddingLeft="4dp">
-
- <!-- Has been made focusable to display error messages with setError -->
- <TextView
- android:id="@+id/select_secret_key_user_id"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="left"
- android:focusable="true"
- android:focusableInTouchMode="true"
- android:singleLine="true"
- android:ellipsize="end"
- android:visibility="gone"
- android:layout_marginRight="5dip"
- android:text=""
- android:textAppearance="?android:attr/textAppearanceSmall" />
-
- <TextView
- android:id="@+id/select_secret_key_user_id_rest"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="left"
- android:ellipsize="end"
- android:singleLine="true"
- android:layout_marginRight="5dip"
- android:text=""
- android:visibility="gone"
- android:textAppearance="?android:attr/textAppearanceSmall" />
-
- <TextView
- android:id="@+id/select_secret_key_master_key_hex"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:visibility="gone"
- android:layout_marginRight="15dip" />
-
- <TextView
- android:id="@+id/no_key_selected"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:text="@string/api_settings_no_key"
- android:layout_marginTop="15dp" />
-
- </LinearLayout>
-
-</LinearLayout> \ No newline at end of file