mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-23 06:12:20 -05:00
show certificates for secret keys differently
This commit is contained in:
parent
3f844cc70b
commit
ba7d8a5867
@ -262,7 +262,7 @@ public class ViewKeyFragment extends LoaderFragment implements
|
|||||||
getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this);
|
getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this);
|
||||||
|
|
||||||
mLinkedIdsAdapter = new LinkedIdsAdapter(getActivity(), null, 0,
|
mLinkedIdsAdapter = new LinkedIdsAdapter(getActivity(), null, 0,
|
||||||
!mIsSecret, mLinkedIdsExpander);
|
mIsSecret, mLinkedIdsExpander);
|
||||||
mLinkedIds.setAdapter(mLinkedIdsAdapter);
|
mLinkedIds.setAdapter(mLinkedIdsAdapter);
|
||||||
getLoaderManager().initLoader(LOADER_ID_LINKED_IDS, null, this);
|
getLoaderManager().initLoader(LOADER_ID_LINKED_IDS, null, this);
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ import android.support.v4.content.CursorLoader;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@ -46,7 +45,7 @@ import java.io.IOException;
|
|||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
public class LinkedIdsAdapter extends UserAttributesAdapter {
|
public class LinkedIdsAdapter extends UserAttributesAdapter {
|
||||||
private final boolean mShowCertification;
|
private final boolean mIsSecret;
|
||||||
protected LayoutInflater mInflater;
|
protected LayoutInflater mInflater;
|
||||||
WeakHashMap<Integer,RawLinkedIdentity> mLinkedIdentityCache = new WeakHashMap<>();
|
WeakHashMap<Integer,RawLinkedIdentity> mLinkedIdentityCache = new WeakHashMap<>();
|
||||||
|
|
||||||
@ -55,10 +54,10 @@ public class LinkedIdsAdapter extends UserAttributesAdapter {
|
|||||||
private TextView mExpander;
|
private TextView mExpander;
|
||||||
|
|
||||||
public LinkedIdsAdapter(Context context, Cursor c, int flags,
|
public LinkedIdsAdapter(Context context, Cursor c, int flags,
|
||||||
boolean showCertification, TextView expander) {
|
boolean isSecret, TextView expander) {
|
||||||
super(context, c, flags);
|
super(context, c, flags);
|
||||||
mInflater = LayoutInflater.from(context);
|
mInflater = LayoutInflater.from(context);
|
||||||
mShowCertification = showCertification;
|
mIsSecret = isSecret;
|
||||||
|
|
||||||
if (expander != null) {
|
if (expander != null) {
|
||||||
expander.setVisibility(View.GONE);
|
expander.setVisibility(View.GONE);
|
||||||
@ -113,7 +112,7 @@ public class LinkedIdsAdapter extends UserAttributesAdapter {
|
|||||||
|
|
||||||
ViewHolder holder = (ViewHolder) view.getTag();
|
ViewHolder holder = (ViewHolder) view.getTag();
|
||||||
|
|
||||||
if (mShowCertification) {
|
if (!mIsSecret) {
|
||||||
holder.vVerified.setVisibility(View.VISIBLE);
|
holder.vVerified.setVisibility(View.VISIBLE);
|
||||||
int isVerified = cursor.getInt(INDEX_VERIFIED);
|
int isVerified = cursor.getInt(INDEX_VERIFIED);
|
||||||
switch (isVerified) {
|
switch (isVerified) {
|
||||||
@ -192,7 +191,7 @@ public class LinkedIdsAdapter extends UserAttributesAdapter {
|
|||||||
int rank = c.getInt(UserIdsAdapter.INDEX_RANK);
|
int rank = c.getInt(UserIdsAdapter.INDEX_RANK);
|
||||||
|
|
||||||
Uri dataUri = UserPackets.buildLinkedIdsUri(baseUri);
|
Uri dataUri = UserPackets.buildLinkedIdsUri(baseUri);
|
||||||
return LinkedIdViewFragment.newInstance(dataUri, rank, mShowCertification, fingerprint);
|
return LinkedIdViewFragment.newInstance(dataUri, rank, mIsSecret, fingerprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ViewHolder {
|
public static class ViewHolder {
|
||||||
|
@ -62,13 +62,13 @@ public class LinkedIdViewFragment extends Fragment implements
|
|||||||
|
|
||||||
private static final String ARG_DATA_URI = "data_uri";
|
private static final String ARG_DATA_URI = "data_uri";
|
||||||
private static final String ARG_LID_RANK = "rank";
|
private static final String ARG_LID_RANK = "rank";
|
||||||
private static final String ARG_SHOWCERT = "verified";
|
private static final String ARG_IS_SECRET = "verified";
|
||||||
private static final String ARG_FINGERPRINT = "fingerprint";
|
private static final String ARG_FINGERPRINT = "fingerprint";
|
||||||
private static final int LOADER_ID_LINKED_ID = 1;
|
private static final int LOADER_ID_LINKED_ID = 1;
|
||||||
|
|
||||||
private RawLinkedIdentity mLinkedId;
|
private RawLinkedIdentity mLinkedId;
|
||||||
private LinkedCookieResource mLinkedResource;
|
private LinkedCookieResource mLinkedResource;
|
||||||
private boolean mShowCert;
|
private boolean mIsSecret;
|
||||||
|
|
||||||
private Context mContext;
|
private Context mContext;
|
||||||
private byte[] mFingerprint;
|
private byte[] mFingerprint;
|
||||||
@ -81,13 +81,13 @@ public class LinkedIdViewFragment extends Fragment implements
|
|||||||
private OnIdentityLoadedListener mIdLoadedListener;
|
private OnIdentityLoadedListener mIdLoadedListener;
|
||||||
|
|
||||||
public static LinkedIdViewFragment newInstance(Uri dataUri, int rank,
|
public static LinkedIdViewFragment newInstance(Uri dataUri, int rank,
|
||||||
boolean showCertified, byte[] fingerprint) throws IOException {
|
boolean isSecret, byte[] fingerprint) throws IOException {
|
||||||
LinkedIdViewFragment frag = new LinkedIdViewFragment();
|
LinkedIdViewFragment frag = new LinkedIdViewFragment();
|
||||||
|
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putParcelable(ARG_DATA_URI, dataUri);
|
args.putParcelable(ARG_DATA_URI, dataUri);
|
||||||
args.putInt(ARG_LID_RANK, rank);
|
args.putInt(ARG_LID_RANK, rank);
|
||||||
args.putBoolean(ARG_SHOWCERT, showCertified);
|
args.putBoolean(ARG_IS_SECRET, isSecret);
|
||||||
args.putByteArray(ARG_FINGERPRINT, fingerprint);
|
args.putByteArray(ARG_FINGERPRINT, fingerprint);
|
||||||
frag.setArguments(args);
|
frag.setArguments(args);
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ public class LinkedIdViewFragment extends Fragment implements
|
|||||||
mDataUri = args.getParcelable(ARG_DATA_URI);
|
mDataUri = args.getParcelable(ARG_DATA_URI);
|
||||||
mLidRank = args.getInt(ARG_LID_RANK);
|
mLidRank = args.getInt(ARG_LID_RANK);
|
||||||
|
|
||||||
mShowCert = args.getBoolean(ARG_SHOWCERT);
|
mIsSecret = args.getBoolean(ARG_IS_SECRET);
|
||||||
mFingerprint = args.getByteArray(ARG_FINGERPRINT);
|
mFingerprint = args.getByteArray(ARG_FINGERPRINT);
|
||||||
|
|
||||||
mContext = getActivity();
|
mContext = getActivity();
|
||||||
@ -184,7 +184,7 @@ public class LinkedIdViewFragment extends Fragment implements
|
|||||||
mLinkedResource = (LinkedCookieResource) res;
|
mLinkedResource = (LinkedCookieResource) res;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mShowCert) {
|
if (!mIsSecret) {
|
||||||
mViewHolder.mLinkedIdHolder.vVerified.setVisibility(View.VISIBLE);
|
mViewHolder.mLinkedIdHolder.vVerified.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
switch (certStatus) {
|
switch (certStatus) {
|
||||||
@ -276,7 +276,7 @@ public class LinkedIdViewFragment extends Fragment implements
|
|||||||
VERIFYING, VERIFY_OK, VERIFY_ERROR, CERTIFYING
|
VERIFYING, VERIFY_OK, VERIFY_ERROR, CERTIFYING
|
||||||
}
|
}
|
||||||
|
|
||||||
void setVerifyingState(VerifyState state) {
|
void setVerifyingState(VerifyState state, boolean isSecret) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case VERIFYING:
|
case VERIFYING:
|
||||||
vProgress.setDisplayedChild(0);
|
vProgress.setDisplayedChild(0);
|
||||||
@ -285,10 +285,15 @@ public class LinkedIdViewFragment extends Fragment implements
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VERIFY_OK:
|
case VERIFY_OK:
|
||||||
showButton(2);
|
|
||||||
vText.setText("Ok");
|
vText.setText("Ok");
|
||||||
vProgress.setDisplayedChild(1);
|
vProgress.setDisplayedChild(1);
|
||||||
vKeySpinner.setVisibility(View.VISIBLE);
|
if (!isSecret) {
|
||||||
|
showButton(2);
|
||||||
|
vKeySpinner.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
showButton(1);
|
||||||
|
vKeySpinner.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VERIFY_ERROR:
|
case VERIFY_ERROR:
|
||||||
@ -411,6 +416,7 @@ public class LinkedIdViewFragment extends Fragment implements
|
|||||||
{
|
{
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
args.putParcelable(CertListWidget.ARG_URI, Certs.buildLinkedIdCertsUri(mDataUri, mLidRank));
|
args.putParcelable(CertListWidget.ARG_URI, Certs.buildLinkedIdCertsUri(mDataUri, mLidRank));
|
||||||
|
args.putBoolean(CertListWidget.ARG_IS_SECRET, mIsSecret);
|
||||||
getLoaderManager().initLoader(CertListWidget.LOADER_ID_LINKED_CERTS,
|
getLoaderManager().initLoader(CertListWidget.LOADER_ID_LINKED_CERTS,
|
||||||
args, mViewHolder.vLinkedCerts);
|
args, mViewHolder.vLinkedCerts);
|
||||||
}
|
}
|
||||||
@ -428,7 +434,7 @@ public class LinkedIdViewFragment extends Fragment implements
|
|||||||
setShowVerifying(true);
|
setShowVerifying(true);
|
||||||
|
|
||||||
mViewHolder.vKeySpinner.setVisibility(View.GONE);
|
mViewHolder.vKeySpinner.setVisibility(View.GONE);
|
||||||
mViewHolder.setVerifyingState(VerifyState.VERIFYING);
|
mViewHolder.setVerifyingState(VerifyState.VERIFYING, mIsSecret);
|
||||||
|
|
||||||
mInProgress = new AsyncTask<Void,Void,LinkedVerifyResult>() {
|
mInProgress = new AsyncTask<Void,Void,LinkedVerifyResult>() {
|
||||||
@Override
|
@Override
|
||||||
@ -453,9 +459,9 @@ public class LinkedIdViewFragment extends Fragment implements
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (result.success()) {
|
if (result.success()) {
|
||||||
mViewHolder.setVerifyingState(VerifyState.VERIFY_OK);
|
mViewHolder.setVerifyingState(VerifyState.VERIFY_OK, mIsSecret);
|
||||||
} else {
|
} else {
|
||||||
mViewHolder.setVerifyingState(VerifyState.VERIFY_ERROR);
|
mViewHolder.setVerifyingState(VerifyState.VERIFY_ERROR, mIsSecret);
|
||||||
}
|
}
|
||||||
mInProgress = null;
|
mInProgress = null;
|
||||||
}
|
}
|
||||||
@ -464,6 +470,11 @@ public class LinkedIdViewFragment extends Fragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initiateCertifying() {
|
private void initiateCertifying() {
|
||||||
|
|
||||||
|
if (mIsSecret) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// get the user's passphrase for this key (if required)
|
// get the user's passphrase for this key (if required)
|
||||||
String passphrase;
|
String passphrase;
|
||||||
long certifyKeyId = mViewHolder.vKeySpinner.getSelectedItemId();
|
long certifyKeyId = mViewHolder.vKeySpinner.getSelectedItemId();
|
||||||
@ -509,7 +520,11 @@ public class LinkedIdViewFragment extends Fragment implements
|
|||||||
|
|
||||||
private void certifyResource(long certifyKeyId, String passphrase) {
|
private void certifyResource(long certifyKeyId, String passphrase) {
|
||||||
|
|
||||||
mViewHolder.setVerifyingState(VerifyState.CERTIFYING);
|
if (mIsSecret) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mViewHolder.setVerifyingState(VerifyState.CERTIFYING, mIsSecret);
|
||||||
|
|
||||||
Bundle data = new Bundle();
|
Bundle data = new Bundle();
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package org.sufficientlysecure.keychain.ui.widget;
|
package org.sufficientlysecure.keychain.ui.widget;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -11,7 +9,6 @@ import android.os.Bundle;
|
|||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.content.CursorLoader;
|
import android.support.v4.content.CursorLoader;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
import android.text.SpannableStringBuilder;
|
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
@ -29,7 +26,7 @@ public class CertListWidget extends ViewAnimator
|
|||||||
public static final int LOADER_ID_LINKED_CERTS = 38572;
|
public static final int LOADER_ID_LINKED_CERTS = 38572;
|
||||||
|
|
||||||
public static final String ARG_URI = "uri";
|
public static final String ARG_URI = "uri";
|
||||||
public static final String ARG_RANK = "rank";
|
public static final String ARG_IS_SECRET = "is_secret";
|
||||||
|
|
||||||
|
|
||||||
// These are the rows that we will retrieve.
|
// These are the rows that we will retrieve.
|
||||||
@ -56,6 +53,7 @@ public class CertListWidget extends ViewAnimator
|
|||||||
private TextView vCollapsed;
|
private TextView vCollapsed;
|
||||||
private ListView vExpanded;
|
private ListView vExpanded;
|
||||||
private View vExpandButton;
|
private View vExpandButton;
|
||||||
|
private boolean mIsSecret;
|
||||||
|
|
||||||
public CertListWidget(Context context, AttributeSet attrs) {
|
public CertListWidget(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
@ -94,6 +92,7 @@ public class CertListWidget extends ViewAnimator
|
|||||||
@Override
|
@Override
|
||||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||||
Uri uri = args.getParcelable(ARG_URI);
|
Uri uri = args.getParcelable(ARG_URI);
|
||||||
|
mIsSecret = args.getBoolean(ARG_IS_SECRET, false);
|
||||||
return new CursorLoader(getContext(), uri,
|
return new CursorLoader(getContext(), uri,
|
||||||
CERTS_PROJECTION, null, null, null);
|
CERTS_PROJECTION, null, null, null);
|
||||||
}
|
}
|
||||||
@ -105,8 +104,6 @@ public class CertListWidget extends ViewAnimator
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
// TODO support external certificates
|
// TODO support external certificates
|
||||||
Date userCert = null;
|
Date userCert = null;
|
||||||
while (!data.isAfterLast()) {
|
while (!data.isAfterLast()) {
|
||||||
@ -125,12 +122,19 @@ public class CertListWidget extends ViewAnimator
|
|||||||
|
|
||||||
if (userCert != null) {
|
if (userCert != null) {
|
||||||
PrettyTime format = new PrettyTime();
|
PrettyTime format = new PrettyTime();
|
||||||
vCollapsed.setText("You verified and confirmed this identity "
|
if (mIsSecret) {
|
||||||
+ format.format(userCert) + ".");
|
vCollapsed.setText("You created this identity "
|
||||||
|
+ format.format(userCert) + ".");
|
||||||
|
} else {
|
||||||
|
vCollapsed.setText("You verified and confirmed this identity "
|
||||||
|
+ format.format(userCert) + ".");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
vCollapsed.setText("This identity is not yet verified or confirmed.");
|
vCollapsed.setText("This identity is not yet verified or confirmed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user