From 3d6edd11903898b8dc95a52d26b8dc3716d85e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 28 Jul 2014 11:11:23 +0200 Subject: Use icons in key view --- .../keychain/ui/KeyListFragment.java | 6 +-- .../keychain/ui/ViewKeyActivity.java | 55 ++++++++++++++-------- 2 files changed, 39 insertions(+), 22 deletions(-) (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure') 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 ef3c0a1c1..ee05a5fe4 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -494,19 +494,19 @@ public class KeyListFragment extends LoaderFragment if (isRevoked) { h.mStatus.setVisibility(View.VISIBLE); h.mStatus.setImageDrawable( - getResources().getDrawable(R.drawable.status_signature_revoked_cutout)); + getResources().getDrawable(R.drawable.status_signature_revoked)); h.mStatus.setColorFilter(getResources().getColor(R.color.result_red), PorterDuff.Mode.SRC_ATOP); } else if (isExpired) { h.mStatus.setVisibility(View.VISIBLE); h.mStatus.setImageDrawable( - getResources().getDrawable(R.drawable.status_signature_expired_cutout)); + getResources().getDrawable(R.drawable.status_signature_expired)); h.mStatus.setColorFilter(getResources().getColor(R.color.result_orange), PorterDuff.Mode.SRC_ATOP); } else if (isVerified) { h.mStatus.setVisibility(View.VISIBLE); h.mStatus.setImageDrawable( - getResources().getDrawable(R.drawable.status_signature_verified_cutout)); + getResources().getDrawable(R.drawable.status_signature_verified)); h.mStatus.setColorFilter(getResources().getColor(R.color.result_green), PorterDuff.Mode.SRC_ATOP); } else { diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index a9cd0976b..8407ab66d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -22,6 +22,7 @@ import android.annotation.TargetApi; import android.app.Activity; import android.content.Intent; import android.database.Cursor; +import android.graphics.PorterDuff; import android.net.Uri; import android.nfc.NdefMessage; import android.nfc.NdefRecord; @@ -43,6 +44,9 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.view.Window; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; import com.devspark.appmsg.AppMsg; @@ -81,9 +85,11 @@ public class ViewKeyActivity extends ActionBarActivity implements private ViewPager mViewPager; private SlidingTabLayout mSlidingTabLayout; private PagerTabStripAdapter mTabsAdapter; + + private LinearLayout mStatusLayout; + private TextView mStatusText; + private ImageView mStatusImage; private View mStatusDivider; - private View mStatusRevoked; - private View mStatusExpired; public static final int REQUEST_CODE_LOOKUP_KEY = 0x00007006; @@ -115,9 +121,10 @@ public class ViewKeyActivity extends ActionBarActivity implements setContentView(R.layout.view_key_activity); - mStatusDivider = findViewById(R.id.status_divider); - mStatusRevoked = findViewById(R.id.view_key_revoked); - mStatusExpired = findViewById(R.id.view_key_expired); + mStatusLayout = (LinearLayout) findViewById(R.id.view_key_status_layout); + mStatusText = (TextView) findViewById(R.id.view_key_status_text); + mStatusImage = (ImageView) findViewById(R.id.view_key_status_image); + mStatusDivider = findViewById(R.id.view_key_status_divider); mViewPager = (ViewPager) findViewById(R.id.view_key_pager); mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.view_key_sliding_tab_layout); @@ -515,22 +522,32 @@ public class ViewKeyActivity extends ActionBarActivity implements String keyIdStr = PgpKeyHelper.convertKeyIdToHex(masterKeyId); getSupportActionBar().setSubtitle(keyIdStr); - // If this key is revoked, it cannot be used for anything! - if (data.getInt(INDEX_UNIFIED_IS_REVOKED) != 0) { + boolean isRevoked = data.getInt(INDEX_UNIFIED_IS_REVOKED) > 0; + boolean isExpired = !data.isNull(INDEX_UNIFIED_EXPIRY) + && new Date(data.getLong(INDEX_UNIFIED_EXPIRY) * 1000).before(new Date()); + + // Note: order is important + if (isRevoked) { + mStatusDivider.setVisibility(View.VISIBLE); + mStatusLayout.setVisibility(View.VISIBLE); + mStatusText.setText(R.string.view_key_revoked); + mStatusText.setTextColor(getResources().getColor(R.color.result_red)); + mStatusImage.setImageDrawable( + getResources().getDrawable(R.drawable.status_signature_revoked)); + mStatusImage.setColorFilter(getResources().getColor(R.color.result_red), + PorterDuff.Mode.SRC_ATOP); + } else if (isExpired) { mStatusDivider.setVisibility(View.VISIBLE); - mStatusRevoked.setVisibility(View.VISIBLE); - mStatusExpired.setVisibility(View.GONE); + mStatusLayout.setVisibility(View.VISIBLE); + mStatusText.setText(R.string.view_key_expired); + mStatusText.setTextColor(getResources().getColor(R.color.result_orange)); + mStatusImage.setImageDrawable( + getResources().getDrawable(R.drawable.status_signature_expired_cutout)); + mStatusImage.setColorFilter(getResources().getColor(R.color.result_orange), + PorterDuff.Mode.SRC_ATOP); } else { - mStatusRevoked.setVisibility(View.GONE); - - Date expiryDate = new Date(data.getLong(INDEX_UNIFIED_EXPIRY) * 1000); - if (!data.isNull(INDEX_UNIFIED_EXPIRY) && expiryDate.before(new Date())) { - mStatusDivider.setVisibility(View.VISIBLE); - mStatusExpired.setVisibility(View.VISIBLE); - } else { - mStatusDivider.setVisibility(View.GONE); - mStatusExpired.setVisibility(View.GONE); - } + mStatusDivider.setVisibility(View.GONE); + mStatusLayout.setVisibility(View.GONE); } break; -- cgit v1.2.3