add "forget" button to trust ids
This commit is contained in:
parent
12dec8cba8
commit
846692e8ba
|
@ -32,6 +32,7 @@ import org.sufficientlysecure.keychain.pgp.KeyRing;
|
||||||
import org.sufficientlysecure.keychain.pgp.WrappedSignature;
|
import org.sufficientlysecure.keychain.pgp.WrappedSignature;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
|
import org.sufficientlysecure.keychain.provider.KeychainDatabase;
|
||||||
|
import org.sufficientlysecure.keychain.ui.adapter.CertSectionedListAdapter.CertCursor;
|
||||||
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
|
||||||
import org.sufficientlysecure.keychain.ui.util.adapter.CursorAdapter;
|
import org.sufficientlysecure.keychain.ui.util.adapter.CursorAdapter;
|
||||||
import org.sufficientlysecure.keychain.ui.util.adapter.SectionCursorAdapter;
|
import org.sufficientlysecure.keychain.ui.util.adapter.SectionCursorAdapter;
|
||||||
|
@ -39,7 +40,7 @@ import org.sufficientlysecure.keychain.ui.util.adapter.SectionCursorAdapter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class CertSectionedListAdapter extends SectionCursorAdapter<CertSectionedListAdapter.CertCursor, String,
|
public class CertSectionedListAdapter extends SectionCursorAdapter<CertCursor, String,
|
||||||
CertSectionedListAdapter.CertItemViewHolder, CertSectionedListAdapter.CertSectionViewHolder> {
|
CertSectionedListAdapter.CertItemViewHolder, CertSectionedListAdapter.CertSectionViewHolder> {
|
||||||
|
|
||||||
private CertListListener mListener;
|
private CertListListener mListener;
|
||||||
|
@ -162,11 +163,11 @@ public class CertSectionedListAdapter extends SectionCursorAdapter<CertSectioned
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class CertCursor extends CursorAdapter.AbstractCursor {
|
public static class CertCursor extends CursorAdapter.SimpleCursor {
|
||||||
public static final String[] CERTS_PROJECTION;
|
public static final String[] CERTS_PROJECTION;
|
||||||
static {
|
static {
|
||||||
ArrayList<String> projection = new ArrayList<>();
|
ArrayList<String> projection = new ArrayList<>();
|
||||||
projection.addAll(Arrays.asList(AbstractCursor.PROJECTION));
|
projection.addAll(Arrays.asList(SimpleCursor.PROJECTION));
|
||||||
projection.addAll(Arrays.asList(
|
projection.addAll(Arrays.asList(
|
||||||
KeychainContract.Certs.MASTER_KEY_ID,
|
KeychainContract.Certs.MASTER_KEY_ID,
|
||||||
KeychainContract.Certs.VERIFIED,
|
KeychainContract.Certs.VERIFIED,
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.sufficientlysecure.keychain.ui.adapter;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -32,7 +31,7 @@ import android.database.Cursor;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.support.v4.content.CursorLoader;
|
import android.support.v4.content.CursorLoader;
|
||||||
import android.support.v4.widget.CursorAdapter;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
|
@ -43,9 +42,14 @@ import android.widget.TextView;
|
||||||
import org.openintents.openpgp.util.OpenPgpApi;
|
import org.openintents.openpgp.util.OpenPgpApi;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiTrustIdentity;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.ApiTrustIdentity;
|
||||||
|
import org.sufficientlysecure.keychain.ui.adapter.TrustIdsAdapter.ViewHolder;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.adapter.CursorAdapter;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.adapter.CursorAdapter.SimpleCursor;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.recyclerview.RecyclerItemClickListener;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.recyclerview.RecyclerItemClickListener.OnItemClickListener;
|
||||||
|
|
||||||
|
|
||||||
public class TrustIdsAdapter extends CursorAdapter {
|
public class TrustIdsAdapter extends CursorAdapter<SimpleCursor, ViewHolder> {
|
||||||
private static final String[] TRUST_IDS_PROJECTION = new String[] {
|
private static final String[] TRUST_IDS_PROJECTION = new String[] {
|
||||||
ApiTrustIdentity._ID,
|
ApiTrustIdentity._ID,
|
||||||
ApiTrustIdentity.PACKAGE_NAME,
|
ApiTrustIdentity.PACKAGE_NAME,
|
||||||
|
@ -55,39 +59,12 @@ public class TrustIdsAdapter extends CursorAdapter {
|
||||||
private static final int INDEX_TRUST_ID = 2;
|
private static final int INDEX_TRUST_ID = 2;
|
||||||
|
|
||||||
|
|
||||||
protected LayoutInflater mInflater;
|
|
||||||
private HashMap<String, Drawable> appIconCache = new HashMap<>();
|
private HashMap<String, Drawable> appIconCache = new HashMap<>();
|
||||||
|
private Integer expandedPosition;
|
||||||
|
private OnItemClickListener onItemClickListener;
|
||||||
|
|
||||||
|
public TrustIdsAdapter(Context context, SimpleCursor simpleCursor) {
|
||||||
public TrustIdsAdapter(Context context, Cursor c, int flags) {
|
super(context, simpleCursor, FLAG_REGISTER_CONTENT_OBSERVER);
|
||||||
super(context, c, flags);
|
|
||||||
mInflater = LayoutInflater.from(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void bindView(View view, final Context context, Cursor cursor) {
|
|
||||||
final String packageName = cursor.getString(INDEX_PACKAGE_NAME);
|
|
||||||
final String trustId = cursor.getString(INDEX_TRUST_ID);
|
|
||||||
|
|
||||||
TextView vTrustId = (TextView) view.findViewById(R.id.trust_id_name);
|
|
||||||
ImageView vAppIcon = (ImageView) view.findViewById(R.id.trust_id_app_icon);
|
|
||||||
ImageView vActionIcon = (ImageView) view.findViewById(R.id.trust_id_action);
|
|
||||||
|
|
||||||
Drawable drawable = getDrawableForPackageName(packageName);
|
|
||||||
vTrustId.setText(trustId);
|
|
||||||
vAppIcon.setImageDrawable(drawable);
|
|
||||||
|
|
||||||
if (isTrustIdActivityAvailable(packageName, trustId, context)) {
|
|
||||||
vActionIcon.setVisibility(View.VISIBLE);
|
|
||||||
vActionIcon.setOnClickListener(new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
launchTrustIdActivity(packageName, trustId, context);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
vActionIcon.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void launchTrustIdActivity(String packageName, String trustId, Context context) {
|
private void launchTrustIdActivity(String packageName, String trustId, Context context) {
|
||||||
|
@ -118,7 +95,7 @@ public class TrustIdsAdapter extends CursorAdapter {
|
||||||
return appIconCache.get(packageName);
|
return appIconCache.get(packageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
PackageManager pm = mContext.getPackageManager();
|
PackageManager pm = getContext().getPackageManager();
|
||||||
try {
|
try {
|
||||||
ApplicationInfo ai = pm.getApplicationInfo(packageName, 0);
|
ApplicationInfo ai = pm.getApplicationInfo(packageName, 0);
|
||||||
|
|
||||||
|
@ -136,8 +113,88 @@ public class TrustIdsAdapter extends CursorAdapter {
|
||||||
return new CursorLoader(context, baseUri, TrustIdsAdapter.TRUST_IDS_PROJECTION, null, null, null);
|
return new CursorLoader(context, baseUri, TrustIdsAdapter.TRUST_IDS_PROJECTION, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setExpandedView(Integer position) {
|
||||||
|
if (position == null) {
|
||||||
|
if (expandedPosition != null) {
|
||||||
|
notifyItemChanged(expandedPosition);
|
||||||
|
}
|
||||||
|
expandedPosition = null;
|
||||||
|
} else if (expandedPosition == null || !expandedPosition.equals(position)) {
|
||||||
|
if (expandedPosition != null) {
|
||||||
|
notifyItemChanged(expandedPosition);
|
||||||
|
}
|
||||||
|
expandedPosition = position;
|
||||||
|
notifyItemChanged(position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnItemClickListener(RecyclerItemClickListener.OnItemClickListener onItemClickListener) {
|
||||||
|
this.onItemClickListener = onItemClickListener;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||||
return mInflater.inflate(R.layout.view_key_trust_id_item, parent, false);
|
View view = LayoutInflater.from(getContext()).inflate(R.layout.view_key_trust_id_item, parent, false);
|
||||||
|
return new ViewHolder(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(final ViewHolder holder, final int position) {
|
||||||
|
moveCursorOrThrow(position);
|
||||||
|
|
||||||
|
SimpleCursor cursor = getCursor();
|
||||||
|
final String packageName = cursor.getString(INDEX_PACKAGE_NAME);
|
||||||
|
final String trustId = cursor.getString(INDEX_TRUST_ID);
|
||||||
|
|
||||||
|
Drawable drawable = getDrawableForPackageName(packageName);
|
||||||
|
holder.vTrustId.setText(trustId);
|
||||||
|
holder.vAppIcon.setImageDrawable(drawable);
|
||||||
|
|
||||||
|
if (isTrustIdActivityAvailable(packageName, trustId, getContext())) {
|
||||||
|
holder.vActionIcon.setVisibility(View.VISIBLE);
|
||||||
|
holder.vActionIcon.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
launchTrustIdActivity(packageName, trustId, getContext());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
holder.vActionIcon.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (expandedPosition != null && position == expandedPosition) {
|
||||||
|
holder.vButtonBar.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
holder.vButtonBar.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.itemView.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View view) {
|
||||||
|
if (onItemClickListener != null) {
|
||||||
|
onItemClickListener.onItemClick(holder.itemView, position);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void swapCursor(Cursor data) {
|
||||||
|
swapCursor(new SimpleCursor(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
private final TextView vTrustId;
|
||||||
|
private final ImageView vAppIcon;
|
||||||
|
private final ImageView vActionIcon;
|
||||||
|
private final View vButtonBar;
|
||||||
|
|
||||||
|
public ViewHolder(View view) {
|
||||||
|
super(view);
|
||||||
|
|
||||||
|
vTrustId = (TextView) view.findViewById(R.id.trust_id_name);
|
||||||
|
vAppIcon = (ImageView) view.findViewById(R.id.trust_id_app_icon);
|
||||||
|
vActionIcon = (ImageView) view.findViewById(R.id.trust_id_action);
|
||||||
|
vButtonBar = view.findViewById(R.id.trust_id_button_bar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@ import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
|
import android.support.v4.app.FragmentManager;
|
||||||
|
import android.support.v4.app.FragmentManager.OnBackStackChangedListener;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -128,7 +130,7 @@ public class ViewKeyFragment extends LoaderFragment implements ViewKeyMvpView {
|
||||||
mKeyserverStatusPresenter.startLoader(getLoaderManager());
|
mKeyserverStatusPresenter.startLoader(getLoaderManager());
|
||||||
|
|
||||||
mTrustIdsPresenter = new TrustIdsPresenter(
|
mTrustIdsPresenter = new TrustIdsPresenter(
|
||||||
getContext(), mTrustIdsCard, LOADER_ID_TRUST_IDS, masterKeyId, false);
|
getContext(), mTrustIdsCard, this, LOADER_ID_TRUST_IDS, masterKeyId, false);
|
||||||
mTrustIdsPresenter.startLoader(getLoaderManager());
|
mTrustIdsPresenter.startLoader(getLoaderManager());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,4 +176,28 @@ public class ViewKeyFragment extends LoaderFragment implements ViewKeyMvpView {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addFakeBackStackItem(String tag, final OnBackStackPoppedListener listener) {
|
||||||
|
FragmentManager fragmentManager = getFragmentManager();
|
||||||
|
if (fragmentManager.getBackStackEntryCount() > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fragmentManager.beginTransaction()
|
||||||
|
.addToBackStack("expand_trust_id")
|
||||||
|
.commitAllowingStateLoss();
|
||||||
|
fragmentManager.executePendingTransactions();
|
||||||
|
|
||||||
|
fragmentManager.addOnBackStackChangedListener(new OnBackStackChangedListener() {
|
||||||
|
@Override
|
||||||
|
public void onBackStackChanged() {
|
||||||
|
FragmentManager fragMan = getFragmentManager();
|
||||||
|
fragMan.popBackStack("expand_trust_id", FragmentManager.POP_BACK_STACK_INCLUSIVE);
|
||||||
|
fragMan.removeOnBackStackChangedListener(this);
|
||||||
|
|
||||||
|
listener.onBackStackPopped();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,15 +24,18 @@ import android.os.Bundle;
|
||||||
import android.support.v4.app.LoaderManager;
|
import android.support.v4.app.LoaderManager;
|
||||||
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
import android.support.v4.app.LoaderManager.LoaderCallbacks;
|
||||||
import android.support.v4.content.Loader;
|
import android.support.v4.content.Loader;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.TrustIdsAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.TrustIdsAdapter;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
|
import org.sufficientlysecure.keychain.ui.keyview.presenter.ViewKeyMvpView.OnBackStackPoppedListener;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.recyclerview.RecyclerItemClickListener.OnItemClickListener;
|
||||||
|
|
||||||
|
|
||||||
public class TrustIdsPresenter implements LoaderCallbacks<Cursor> {
|
public class TrustIdsPresenter implements LoaderCallbacks<Cursor> {
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private final TrustIdsMvpView view;
|
private final TrustIdsMvpView view;
|
||||||
|
private final ViewKeyMvpView viewKeyMvpView;
|
||||||
private final int loaderId;
|
private final int loaderId;
|
||||||
|
|
||||||
private final TrustIdsAdapter trustIdsAdapter;
|
private final TrustIdsAdapter trustIdsAdapter;
|
||||||
|
@ -40,21 +43,23 @@ public class TrustIdsPresenter implements LoaderCallbacks<Cursor> {
|
||||||
private final long masterKeyId;
|
private final long masterKeyId;
|
||||||
private final boolean isSecret;
|
private final boolean isSecret;
|
||||||
|
|
||||||
public TrustIdsPresenter(Context context, TrustIdsMvpView view, int loaderId, long masterKeyId, boolean isSecret) {
|
public TrustIdsPresenter(Context context, TrustIdsMvpView view, ViewKeyMvpView viewKeyMvpView, int loaderId,
|
||||||
|
long masterKeyId, boolean isSecret) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
this.viewKeyMvpView = viewKeyMvpView;
|
||||||
this.loaderId = loaderId;
|
this.loaderId = loaderId;
|
||||||
|
|
||||||
this.masterKeyId = masterKeyId;
|
this.masterKeyId = masterKeyId;
|
||||||
this.isSecret = isSecret;
|
this.isSecret = isSecret;
|
||||||
|
|
||||||
trustIdsAdapter = new TrustIdsAdapter(context, null, 0);
|
trustIdsAdapter = new TrustIdsAdapter(context, null);
|
||||||
view.setTrustIdAdapter(trustIdsAdapter);
|
view.setTrustIdAdapter(trustIdsAdapter);
|
||||||
|
|
||||||
view.setTrustIdClickListener(new TrustIdsClickListener() {
|
trustIdsAdapter.setOnItemClickListener(new OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTrustIdItemClick(int position) {
|
public void onItemClick(View view, int position) {
|
||||||
|
onClickTrustId(position);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -71,7 +76,7 @@ public class TrustIdsPresenter implements LoaderCallbacks<Cursor> {
|
||||||
@Override
|
@Override
|
||||||
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
||||||
trustIdsAdapter.swapCursor(data);
|
trustIdsAdapter.swapCursor(data);
|
||||||
view.showCard(trustIdsAdapter.getCount() > 0);
|
view.showCard(data.getCount() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -79,14 +84,19 @@ public class TrustIdsPresenter implements LoaderCallbacks<Cursor> {
|
||||||
trustIdsAdapter.swapCursor(null);
|
trustIdsAdapter.swapCursor(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onClickTrustId(int position) {
|
||||||
|
trustIdsAdapter.setExpandedView(position);
|
||||||
|
|
||||||
|
viewKeyMvpView.addFakeBackStackItem("expand_trust_id", new OnBackStackPoppedListener() {
|
||||||
|
@Override
|
||||||
|
public void onBackStackPopped() {
|
||||||
|
trustIdsAdapter.setExpandedView(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public interface TrustIdsMvpView {
|
public interface TrustIdsMvpView {
|
||||||
void setTrustIdAdapter(TrustIdsAdapter trustIdsAdapter);
|
void setTrustIdAdapter(TrustIdsAdapter trustIdsAdapter);
|
||||||
void showCard(boolean show);
|
void showCard(boolean show);
|
||||||
|
|
||||||
void setTrustIdClickListener(TrustIdsClickListener trustIdsClickListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface TrustIdsClickListener {
|
|
||||||
void onTrustIdItemClick(int position);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,4 +12,10 @@ public interface ViewKeyMvpView {
|
||||||
void startActivityAndShowResultSnackbar(Intent intent);
|
void startActivityAndShowResultSnackbar(Intent intent);
|
||||||
void showDialogFragment(DialogFragment dialogFragment, final String tag);
|
void showDialogFragment(DialogFragment dialogFragment, final String tag);
|
||||||
void setContentShown(boolean show, boolean animate);
|
void setContentShown(boolean show, boolean animate);
|
||||||
|
|
||||||
|
void addFakeBackStackItem(String tag, OnBackStackPoppedListener listener);
|
||||||
|
|
||||||
|
interface OnBackStackPoppedListener {
|
||||||
|
void onBackStackPopped();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,45 +20,27 @@ package org.sufficientlysecure.keychain.ui.keyview.view;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.support.v7.widget.CardView;
|
import android.support.v7.widget.CardView;
|
||||||
|
import android.support.v7.widget.LinearLayoutManager;
|
||||||
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.AdapterView.OnItemClickListener;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ListView;
|
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.LinkedIdsAdapter;
|
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.TrustIdsAdapter;
|
import org.sufficientlysecure.keychain.ui.adapter.TrustIdsAdapter;
|
||||||
import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
|
|
||||||
import org.sufficientlysecure.keychain.ui.keyview.presenter.IdentitiesPresenter.IdentitiesCardListener;
|
|
||||||
import org.sufficientlysecure.keychain.ui.keyview.presenter.IdentitiesPresenter.IdentitiesMvpView;
|
|
||||||
import org.sufficientlysecure.keychain.ui.keyview.presenter.LinkedIdentitiesPresenter.LinkedIdsClickListener;
|
|
||||||
import org.sufficientlysecure.keychain.ui.keyview.presenter.LinkedIdentitiesPresenter.LinkedIdsMvpView;
|
|
||||||
import org.sufficientlysecure.keychain.ui.keyview.presenter.TrustIdsPresenter.TrustIdsClickListener;
|
|
||||||
import org.sufficientlysecure.keychain.ui.keyview.presenter.TrustIdsPresenter.TrustIdsMvpView;
|
import org.sufficientlysecure.keychain.ui.keyview.presenter.TrustIdsPresenter.TrustIdsMvpView;
|
||||||
|
|
||||||
|
|
||||||
public class TrustIdsIdCardView extends CardView implements TrustIdsMvpView {
|
public class TrustIdsIdCardView extends CardView implements TrustIdsMvpView {
|
||||||
private ListView vTrustIds;
|
private RecyclerView vTrustIds;
|
||||||
|
|
||||||
private TrustIdsClickListener trustIdsClickListener;
|
|
||||||
|
|
||||||
public TrustIdsIdCardView(Context context, AttributeSet attrs) {
|
public TrustIdsIdCardView(Context context, AttributeSet attrs) {
|
||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
|
|
||||||
View view = LayoutInflater.from(context).inflate(R.layout.trust_ids_card, this, true);
|
View view = LayoutInflater.from(context).inflate(R.layout.trust_ids_card, this, true);
|
||||||
|
|
||||||
vTrustIds = (ListView) view.findViewById(R.id.view_key_trust_ids);
|
vTrustIds = (RecyclerView) view.findViewById(R.id.view_key_trust_ids);
|
||||||
vTrustIds.setOnItemClickListener(new OnItemClickListener() {
|
vTrustIds.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
|
||||||
if (trustIdsClickListener != null) {
|
|
||||||
trustIdsClickListener.onTrustIdItemClick(position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -70,9 +52,4 @@ public class TrustIdsIdCardView extends CardView implements TrustIdsMvpView {
|
||||||
public void showCard(boolean show) {
|
public void showCard(boolean show) {
|
||||||
setVisibility(show ? View.VISIBLE : View.GONE);
|
setVisibility(show ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setTrustIdClickListener(TrustIdsClickListener trustIdsClickListener) {
|
|
||||||
this.trustIdsClickListener = trustIdsClickListener;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import android.support.v7.widget.RecyclerView;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
import org.sufficientlysecure.keychain.provider.KeychainContract;
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.adapter.CursorAdapter.SimpleCursor;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
@ -35,7 +36,7 @@ import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH extends RecyclerView.ViewHolder>
|
public abstract class CursorAdapter<C extends SimpleCursor, VH extends RecyclerView.ViewHolder>
|
||||||
extends RecyclerView.Adapter<VH> {
|
extends RecyclerView.Adapter<VH> {
|
||||||
public static final String TAG = "CursorAdapter";
|
public static final String TAG = "CursorAdapter";
|
||||||
|
|
||||||
|
@ -58,7 +59,7 @@ public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH e
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor that allows control over auto-requery. It is recommended
|
* Constructor that allows control over auto-requery. It is recommended
|
||||||
* you not use this, but instead {@link #CursorAdapter(Context, AbstractCursor, int)}.
|
* you not use this, but instead {@link #CursorAdapter(Context, SimpleCursor, int)}.
|
||||||
* When using this constructor, {@link #FLAG_REGISTER_CONTENT_OBSERVER}
|
* When using this constructor, {@link #FLAG_REGISTER_CONTENT_OBSERVER}
|
||||||
* will always be set.
|
* will always be set.
|
||||||
*
|
*
|
||||||
|
@ -223,7 +224,7 @@ public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH e
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swap in a new Cursor, returning the old Cursor. Unlike
|
* Swap in a new Cursor, returning the old Cursor. Unlike
|
||||||
* {@link #changeCursor(AbstractCursor)}, the returned old Cursor is <em>not</em>
|
* {@link #changeCursor(SimpleCursor)}, the returned old Cursor is <em>not</em>
|
||||||
* closed.
|
* closed.
|
||||||
*
|
*
|
||||||
* @param newCursor The new cursor to be used.
|
* @param newCursor The new cursor to be used.
|
||||||
|
@ -312,10 +313,10 @@ public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class AbstractCursor extends CursorWrapper {
|
public static class SimpleCursor extends CursorWrapper {
|
||||||
public static final String[] PROJECTION = {"_id"};
|
public static final String[] PROJECTION = {"_id"};
|
||||||
|
|
||||||
public static <T extends AbstractCursor> T wrap(Cursor cursor, Class<T> type) {
|
public static <T extends SimpleCursor> T wrap(Cursor cursor, Class<T> type) {
|
||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
try {
|
try {
|
||||||
Constructor<T> constructor = type.getConstructor(Cursor.class);
|
Constructor<T> constructor = type.getConstructor(Cursor.class);
|
||||||
|
@ -335,7 +336,7 @@ public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH e
|
||||||
*
|
*
|
||||||
* @param cursor The underlying cursor to wrap.
|
* @param cursor The underlying cursor to wrap.
|
||||||
*/
|
*/
|
||||||
protected AbstractCursor(Cursor cursor) {
|
public SimpleCursor(Cursor cursor) {
|
||||||
super(cursor);
|
super(cursor);
|
||||||
mColumnIndices = new HashMap<>(cursor.getColumnCount() * 4 / 3, 0.75f);
|
mColumnIndices = new HashMap<>(cursor.getColumnCount() * 4 / 3, 0.75f);
|
||||||
}
|
}
|
||||||
|
@ -376,12 +377,12 @@ public abstract class CursorAdapter<C extends CursorAdapter.AbstractCursor, VH e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class KeyCursor extends AbstractCursor {
|
public static class KeyCursor extends SimpleCursor {
|
||||||
public static final String[] PROJECTION;
|
public static final String[] PROJECTION;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
ArrayList<String> arr = new ArrayList<>();
|
ArrayList<String> arr = new ArrayList<>();
|
||||||
arr.addAll(Arrays.asList(AbstractCursor.PROJECTION));
|
arr.addAll(Arrays.asList(SimpleCursor.PROJECTION));
|
||||||
arr.addAll(Arrays.asList(
|
arr.addAll(Arrays.asList(
|
||||||
KeychainContract.KeyRings.MASTER_KEY_ID,
|
KeychainContract.KeyRings.MASTER_KEY_ID,
|
||||||
KeychainContract.KeyRings.USER_ID,
|
KeychainContract.KeyRings.USER_ID,
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
package org.sufficientlysecure.keychain.ui.util.adapter;
|
package org.sufficientlysecure.keychain.ui.util.adapter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.Cursor;
|
|
||||||
import android.support.v4.util.SparseArrayCompat;
|
import android.support.v4.util.SparseArrayCompat;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -27,18 +26,16 @@ import android.view.ViewGroup;
|
||||||
|
|
||||||
import com.tonicartos.superslim.LayoutManager;
|
import com.tonicartos.superslim.LayoutManager;
|
||||||
|
|
||||||
|
import org.sufficientlysecure.keychain.ui.util.adapter.CursorAdapter.SimpleCursor;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param <T> section type.
|
* @param <T> section type.
|
||||||
* @param <VH> the view holder extending {@code BaseViewHolder<Cursor>} that is bound to the cursor data.
|
* @param <VH> the view holder extending {@code BaseViewHolder<Cursor>} that is bound to the cursor data.
|
||||||
* @param <SH> the view holder extending {@code BaseViewHolder<<T>>} that is bound to the section data.
|
* @param <SH> the view holder extending {@code BaseViewHolder<<T>>} that is bound to the section data.
|
||||||
*/
|
*/
|
||||||
public abstract class SectionCursorAdapter<C extends CursorAdapter.AbstractCursor, T, VH extends SectionCursorAdapter.ViewHolder,
|
public abstract class SectionCursorAdapter<C extends SimpleCursor, T, VH extends SectionCursorAdapter.ViewHolder,
|
||||||
SH extends SectionCursorAdapter.ViewHolder> extends CursorAdapter<C, RecyclerView.ViewHolder> {
|
SH extends SectionCursorAdapter.ViewHolder> extends CursorAdapter<C, RecyclerView.ViewHolder> {
|
||||||
|
|
||||||
public static final String TAG = "SectionCursorAdapter";
|
public static final String TAG = "SectionCursorAdapter";
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Known to Apps as" />
|
android:text="Known to Apps as" />
|
||||||
|
|
||||||
<org.sufficientlysecure.keychain.ui.widget.FixedListView
|
<android.support.v7.widget.RecyclerView
|
||||||
android:id="@+id/view_key_trust_ids"
|
android:id="@+id/view_key_trust_ids"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:animateLayoutChanges="true">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
style="@style/CardViewHeader"
|
style="@style/CardViewHeader"
|
||||||
|
|
|
@ -3,40 +3,68 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
android:orientation="vertical"
|
||||||
android:orientation="horizontal"
|
android:background="?selectableItemBackground"
|
||||||
android:maxLines="1"
|
|
||||||
android:padding="8dp"
|
|
||||||
>
|
>
|
||||||
|
|
||||||
<ImageView
|
<LinearLayout
|
||||||
android:layout_width="48dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:padding="8dp"
|
|
||||||
android:id="@+id/trust_id_app_icon"
|
|
||||||
tools:src="@drawable/apps_k9"/>
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="0dp"
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
android:layout_weight="1"
|
android:orientation="horizontal"
|
||||||
android:layout_gravity="center_vertical"
|
android:maxLines="1"
|
||||||
android:id="@+id/trust_id_name"
|
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
|
||||||
tools:text="alice@example.com"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:padding="8dp"
|
android:padding="8dp"
|
||||||
android:id="@+id/trust_id_action"
|
>
|
||||||
android:background="?selectableItemBackground"
|
|
||||||
android:src="@drawable/ic_chat_black_24dp"
|
<ImageView
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="48dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:id="@+id/trust_id_app_icon"
|
||||||
|
tools:src="@drawable/apps_k9"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:id="@+id/trust_id_name"
|
||||||
|
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||||
|
tools:text="alice@example.com"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:id="@+id/trust_id_action"
|
||||||
|
android:background="?selectableItemBackground"
|
||||||
|
android:src="@drawable/ic_chat_black_24dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:id="@+id/trust_id_button_bar"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible"
|
tools:visibility="visible"
|
||||||
/>
|
style="?android:buttonBarStyle">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="36dp"
|
||||||
|
android:id="@+id/view_key_card_user_ids_edit"
|
||||||
|
android:text="Forget"
|
||||||
|
android:textColor="@color/card_view_button"
|
||||||
|
style="?android:attr/buttonBarButtonStyle"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
Loading…
Reference in a new issue