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