From 6aafb314125f016e2215f7d33baf600b5768d72c Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Wed, 7 May 2014 02:14:47 +0200 Subject: ui: move revocation/expiry notes above tab slider --- .../keychain/ui/ViewKeyActivity.java | 26 +++++++++++++++ .../keychain/ui/ViewKeyMainFragment.java | 38 ++++------------------ .../src/main/res/layout/view_key_activity.xml | 29 +++++++++++++++++ .../src/main/res/layout/view_key_main_fragment.xml | 22 ------------- 4 files changed, 61 insertions(+), 54 deletions(-) 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 56aaba57b..a7ac2587a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -40,6 +40,7 @@ import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.view.Menu; import android.view.MenuItem; +import android.view.View; import android.view.Window; import com.devspark.appmsg.AppMsg; @@ -55,6 +56,7 @@ import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.SlidingTabLayout; import java.io.IOException; +import java.util.Date; import java.util.HashMap; public class ViewKeyActivity extends ActionBarActivity implements @@ -75,6 +77,8 @@ public class ViewKeyActivity extends ActionBarActivity implements private ViewPager mViewPager; private SlidingTabLayout mSlidingTabLayout; private PagerTabStripAdapter mTabsAdapter; + private View mStatusRevoked; + private View mStatusExpired; public static final int REQUEST_CODE_LOOKUP_KEY = 0x00007006; @@ -104,6 +108,9 @@ public class ViewKeyActivity extends ActionBarActivity implements setContentView(R.layout.view_key_activity); + mStatusRevoked = findViewById(R.id.view_key_revoked); + mStatusExpired = findViewById(R.id.view_key_expired); + mViewPager = (ViewPager) findViewById(R.id.view_key_pager); mSlidingTabLayout = (SlidingTabLayout) findViewById(R.id.view_key_sliding_tab_layout); @@ -363,10 +370,14 @@ public class ViewKeyActivity extends ActionBarActivity implements KeychainContract.KeyRings._ID, KeychainContract.KeyRings.MASTER_KEY_ID, KeychainContract.KeyRings.USER_ID, + KeychainContract.KeyRings.IS_REVOKED, + KeychainContract.KeyRings.EXPIRY, }; static final int INDEX_UNIFIED_MASTER_KEY_ID = 1; static final int INDEX_UNIFIED_USER_ID = 2; + static final int INDEX_UNIFIED_IS_REVOKED = 3; + static final int INDEX_UNIFIED_EXPIRY = 4; @Override public Loader onCreateLoader(int id, Bundle args) { @@ -408,6 +419,21 @@ 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) { + mStatusRevoked.setVisibility(View.VISIBLE); + mStatusExpired.setVisibility(View.GONE); + } 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())) { + mStatusExpired.setVisibility(View.VISIBLE); + } else { + mStatusExpired.setVisibility(View.GONE); + } + } + break; } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index ded457eca..389455a9a 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -49,8 +49,6 @@ public class ViewKeyMainFragment extends Fragment implements public static final String ARG_DATA_URI = "uri"; private LinearLayout mContainer; - private View mStatusRevoked; - private View mStatusExpired; private View mActionEdit; private View mActionEditDivider; private View mActionEncrypt; @@ -72,8 +70,6 @@ public class ViewKeyMainFragment extends Fragment implements mContainer = (LinearLayout) view.findViewById(R.id.container); mUserIds = (ListView) view.findViewById(R.id.view_key_user_ids); - mStatusRevoked = view.findViewById(R.id.view_key_revoked); - mStatusExpired = view.findViewById(R.id.view_key_expired); mActionEdit = view.findViewById(R.id.view_key_action_edit); mActionEditDivider = view.findViewById(R.id.view_key_action_edit_divider); mActionEncrypt = view.findViewById(R.id.view_key_action_encrypt); @@ -132,30 +128,14 @@ public class ViewKeyMainFragment extends Fragment implements } static final String[] UNIFIED_PROJECTION = new String[]{ - KeyRings._ID, KeyRings.MASTER_KEY_ID, KeyRings.HAS_ANY_SECRET, KeyRings.IS_REVOKED, - KeyRings.USER_ID, KeyRings.FINGERPRINT, - KeyRings.ALGORITHM, KeyRings.KEY_SIZE, KeyRings.CREATION, KeyRings.EXPIRY, - KeyRings.HAS_ENCRYPT - + KeyRings._ID, KeyRings.MASTER_KEY_ID, + KeyRings.HAS_ANY_SECRET, KeyRings.IS_REVOKED, KeyRings.EXPIRY, KeyRings.HAS_ENCRYPT }; static final int INDEX_UNIFIED_MASTER_KEY_ID = 1; static final int INDEX_UNIFIED_HAS_ANY_SECRET = 2; static final int INDEX_UNIFIED_IS_REVOKED = 3; - static final int INDEX_UNIFIED_USER_ID = 4; - static final int INDEX_UNIFIED_FINGERPRINT = 5; - static final int INDEX_UNIFIED_ALGORITHM = 6; - static final int INDEX_UNIFIED_KEY_SIZE = 7; - static final int INDEX_UNIFIED_CREATION = 8; - static final int INDEX_UNIFIED_EXPIRY = 9; - static final int INDEX_UNIFIED_HAS_ENCRYPT = 10; - - static final String[] KEYS_PROJECTION = new String[]{ - Keys._ID, - Keys.KEY_ID, Keys.RANK, Keys.ALGORITHM, Keys.KEY_SIZE, Keys.HAS_SECRET, - Keys.CAN_CERTIFY, Keys.CAN_ENCRYPT, Keys.CAN_SIGN, Keys.IS_REVOKED, - Keys.CREATION, Keys.EXPIRY, Keys.FINGERPRINT - }; - static final int KEYS_INDEX_CAN_ENCRYPT = 7; + static final int INDEX_UNIFIED_EXPIRY = 4; + static final int INDEX_UNIFIED_HAS_ENCRYPT = 5; public Loader onCreateLoader(int id, Bundle args) { switch (id) { @@ -165,7 +145,8 @@ public class ViewKeyMainFragment extends Fragment implements } case LOADER_ID_USER_IDS: { Uri baseUri = UserIds.buildUserIdsUri(mDataUri); - return new CursorLoader(getActivity(), baseUri, ViewKeyUserIdsAdapter.USER_IDS_PROJECTION, null, null, null); + return new CursorLoader(getActivity(), baseUri, + ViewKeyUserIdsAdapter.USER_IDS_PROJECTION, null, null, null); } default: @@ -206,9 +187,6 @@ public class ViewKeyMainFragment extends Fragment implements // If this key is revoked, it cannot be used for anything! if (data.getInt(INDEX_UNIFIED_IS_REVOKED) != 0) { - mStatusRevoked.setVisibility(View.VISIBLE); - mStatusExpired.setVisibility(View.GONE); - mActionEdit.setEnabled(false); mActionCertify.setEnabled(false); mActionEncrypt.setEnabled(false); @@ -217,13 +195,9 @@ public class ViewKeyMainFragment extends Fragment implements Date expiryDate = new Date(data.getLong(INDEX_UNIFIED_EXPIRY) * 1000); if (!data.isNull(INDEX_UNIFIED_EXPIRY) && expiryDate.before(new Date())) { - mStatusRevoked.setVisibility(View.GONE); - mStatusExpired.setVisibility(View.VISIBLE); mActionCertify.setEnabled(false); mActionEncrypt.setEnabled(false); } else { - mStatusRevoked.setVisibility(View.GONE); - mStatusExpired.setVisibility(View.GONE); mActionCertify.setEnabled(true); mActionEncrypt.setEnabled(true); } diff --git a/OpenKeychain/src/main/res/layout/view_key_activity.xml b/OpenKeychain/src/main/res/layout/view_key_activity.xml index eed71945b..aa6089aa2 100644 --- a/OpenKeychain/src/main/res/layout/view_key_activity.xml +++ b/OpenKeychain/src/main/res/layout/view_key_activity.xml @@ -4,6 +4,35 @@ android:layout_height="match_parent" android:orientation="vertical"> + + + + + + - - - -