mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-11 03:25:05 -05:00
ui: move revocation/expiry notes above tab slider
This commit is contained in:
parent
96125b1976
commit
6aafb31412
@ -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<Cursor> 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;
|
||||
}
|
||||
}
|
||||
|
@ -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<Cursor> 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);
|
||||
}
|
||||
|
@ -4,6 +4,35 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="This key is expired!"
|
||||
android:id="@+id/view_key_expired"
|
||||
android:textColor="@color/alert"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:gravity="center_vertical|center_horizontal"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="This key has been revoked!"
|
||||
android:id="@+id/view_key_revoked"
|
||||
android:textColor="@color/alert"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:gravity="center_vertical|center_horizontal"
|
||||
android:visibility="gone"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dip"
|
||||
android:background="?android:attr/listDivider" />
|
||||
|
||||
<org.sufficientlysecure.keychain.util.SlidingTabLayout
|
||||
android:id="@+id/view_key_sliding_tab_layout"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -16,28 +16,6 @@
|
||||
android:id="@+id/container"
|
||||
android:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="This key is expired!"
|
||||
android:id="@+id/view_key_expired"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:textColor="@color/alert"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:gravity="center_vertical|center_horizontal"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="This key has been revoked!"
|
||||
android:id="@+id/view_key_revoked"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:textColor="@color/alert"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:gravity="center_vertical|center_horizontal"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
style="@style/SectionHeader"
|
||||
android:layout_width="wrap_content"
|
||||
|
Loading…
Reference in New Issue
Block a user