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.provider.KeychainContract;
|
||||
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.adapter.CursorAdapter;
|
||||
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.Arrays;
|
||||
|
||||
public class CertSectionedListAdapter extends SectionCursorAdapter<CertSectionedListAdapter.CertCursor, String,
|
||||
public class CertSectionedListAdapter extends SectionCursorAdapter<CertCursor, String,
|
||||
CertSectionedListAdapter.CertItemViewHolder, CertSectionedListAdapter.CertSectionViewHolder> {
|
||||
|
||||
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;
|
||||
static {
|
||||
ArrayList<String> projection = new ArrayList<>();
|
||||
projection.addAll(Arrays.asList(AbstractCursor.PROJECTION));
|
||||
projection.addAll(Arrays.asList(SimpleCursor.PROJECTION));
|
||||
projection.addAll(Arrays.asList(
|
||||
KeychainContract.Certs.MASTER_KEY_ID,
|
||||
KeychainContract.Certs.VERIFIED,
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.sufficientlysecure.keychain.ui.adapter;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -32,7 +31,7 @@ import android.database.Cursor;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
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.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
@ -43,9 +42,14 @@ import android.widget.TextView;
|
|||
import org.openintents.openpgp.util.OpenPgpApi;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
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[] {
|
||||
ApiTrustIdentity._ID,
|
||||
ApiTrustIdentity.PACKAGE_NAME,
|
||||
|
@ -55,39 +59,12 @@ public class TrustIdsAdapter extends CursorAdapter {
|
|||
private static final int INDEX_TRUST_ID = 2;
|
||||
|
||||
|
||||
protected LayoutInflater mInflater;
|
||||
private HashMap<String, Drawable> appIconCache = new HashMap<>();
|
||||
private Integer expandedPosition;
|
||||
private OnItemClickListener onItemClickListener;
|
||||
|
||||
|
||||
public TrustIdsAdapter(Context context, Cursor c, int flags) {
|
||||
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);
|
||||
}
|
||||
public TrustIdsAdapter(Context context, SimpleCursor simpleCursor) {
|
||||
super(context, simpleCursor, FLAG_REGISTER_CONTENT_OBSERVER);
|
||||
}
|
||||
|
||||
private void launchTrustIdActivity(String packageName, String trustId, Context context) {
|
||||
|
@ -118,7 +95,7 @@ public class TrustIdsAdapter extends CursorAdapter {
|
|||
return appIconCache.get(packageName);
|
||||
}
|
||||
|
||||
PackageManager pm = mContext.getPackageManager();
|
||||
PackageManager pm = getContext().getPackageManager();
|
||||
try {
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
public View newView(Context context, Cursor cursor, ViewGroup parent) {
|
||||
return mInflater.inflate(R.layout.view_key_trust_id_item, parent, false);
|
||||
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
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.support.v4.app.DialogFragment;
|
||||
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.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -128,7 +130,7 @@ public class ViewKeyFragment extends LoaderFragment implements ViewKeyMvpView {
|
|||
mKeyserverStatusPresenter.startLoader(getLoaderManager());
|
||||
|
||||
mTrustIdsPresenter = new TrustIdsPresenter(
|
||||
getContext(), mTrustIdsCard, LOADER_ID_TRUST_IDS, masterKeyId, false);
|
||||
getContext(), mTrustIdsCard, this, LOADER_ID_TRUST_IDS, masterKeyId, false);
|
||||
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.LoaderCallbacks;
|
||||
import android.support.v4.content.Loader;
|
||||
import android.view.View;
|
||||
|
||||
import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings;
|
||||
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> {
|
||||
private final Context context;
|
||||
private final TrustIdsMvpView view;
|
||||
private final ViewKeyMvpView viewKeyMvpView;
|
||||
private final int loaderId;
|
||||
|
||||
private final TrustIdsAdapter trustIdsAdapter;
|
||||
|
@ -40,21 +43,23 @@ public class TrustIdsPresenter implements LoaderCallbacks<Cursor> {
|
|||
private final long masterKeyId;
|
||||
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.view = view;
|
||||
this.viewKeyMvpView = viewKeyMvpView;
|
||||
this.loaderId = loaderId;
|
||||
|
||||
this.masterKeyId = masterKeyId;
|
||||
this.isSecret = isSecret;
|
||||
|
||||
trustIdsAdapter = new TrustIdsAdapter(context, null, 0);
|
||||
trustIdsAdapter = new TrustIdsAdapter(context, null);
|
||||
view.setTrustIdAdapter(trustIdsAdapter);
|
||||
|
||||
view.setTrustIdClickListener(new TrustIdsClickListener() {
|
||||
trustIdsAdapter.setOnItemClickListener(new OnItemClickListener() {
|
||||
@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
|
||||
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
||||
trustIdsAdapter.swapCursor(data);
|
||||
view.showCard(trustIdsAdapter.getCount() > 0);
|
||||
view.showCard(data.getCount() > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -79,14 +84,19 @@ public class TrustIdsPresenter implements LoaderCallbacks<Cursor> {
|
|||
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 {
|
||||
void setTrustIdAdapter(TrustIdsAdapter trustIdsAdapter);
|
||||
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 showDialogFragment(DialogFragment dialogFragment, final String tag);
|
||||
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.support.v7.widget.CardView;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
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.ui.adapter.LinkedIdsAdapter;
|
||||
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;
|
||||
|
||||
|
||||
public class TrustIdsIdCardView extends CardView implements TrustIdsMvpView {
|
||||
private ListView vTrustIds;
|
||||
|
||||
private TrustIdsClickListener trustIdsClickListener;
|
||||
private RecyclerView vTrustIds;
|
||||
|
||||
public TrustIdsIdCardView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
View view = LayoutInflater.from(context).inflate(R.layout.trust_ids_card, this, true);
|
||||
|
||||
vTrustIds = (ListView) view.findViewById(R.id.view_key_trust_ids);
|
||||
vTrustIds.setOnItemClickListener(new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
if (trustIdsClickListener != null) {
|
||||
trustIdsClickListener.onTrustIdItemClick(position);
|
||||
}
|
||||
}
|
||||
});
|
||||
vTrustIds = (RecyclerView) view.findViewById(R.id.view_key_trust_ids);
|
||||
vTrustIds.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,9 +52,4 @@ public class TrustIdsIdCardView extends CardView implements TrustIdsMvpView {
|
|||
public void showCard(boolean show) {
|
||||
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.provider.KeychainContract;
|
||||
import org.sufficientlysecure.keychain.ui.util.adapter.CursorAdapter.SimpleCursor;
|
||||
import org.sufficientlysecure.keychain.util.Log;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
@ -35,7 +36,7 @@ import java.util.Arrays;
|
|||
import java.util.Date;
|
||||
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> {
|
||||
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
|
||||
* 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}
|
||||
* 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
|
||||
* {@link #changeCursor(AbstractCursor)}, the returned old Cursor is <em>not</em>
|
||||
* {@link #changeCursor(SimpleCursor)}, the returned old Cursor is <em>not</em>
|
||||
* closed.
|
||||
*
|
||||
* @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 <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) {
|
||||
try {
|
||||
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.
|
||||
*/
|
||||
protected AbstractCursor(Cursor cursor) {
|
||||
public SimpleCursor(Cursor cursor) {
|
||||
super(cursor);
|
||||
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;
|
||||
|
||||
static {
|
||||
ArrayList<String> arr = new ArrayList<>();
|
||||
arr.addAll(Arrays.asList(AbstractCursor.PROJECTION));
|
||||
arr.addAll(Arrays.asList(SimpleCursor.PROJECTION));
|
||||
arr.addAll(Arrays.asList(
|
||||
KeychainContract.KeyRings.MASTER_KEY_ID,
|
||||
KeychainContract.KeyRings.USER_ID,
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
package org.sufficientlysecure.keychain.ui.util.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.support.v4.util.SparseArrayCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.View;
|
||||
|
@ -27,18 +26,16 @@ import android.view.ViewGroup;
|
|||
|
||||
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 java.util.Objects;
|
||||
|
||||
/**
|
||||
* @param <T> section type.
|
||||
* @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.
|
||||
*/
|
||||
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> {
|
||||
|
||||
public static final String TAG = "SectionCursorAdapter";
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
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:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -22,7 +22,8 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<TextView
|
||||
style="@style/CardViewHeader"
|
||||
|
|
|
@ -3,40 +3,68 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:orientation="horizontal"
|
||||
android:maxLines="1"
|
||||
android:padding="8dp"
|
||||
android:orientation="vertical"
|
||||
android:background="?selectableItemBackground"
|
||||
>
|
||||
|
||||
<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
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
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:minHeight="?android:attr/listPreferredItemHeight"
|
||||
android:orientation="horizontal"
|
||||
android:maxLines="1"
|
||||
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"
|
||||
tools:visibility="visible"
|
||||
/>
|
||||
style="?android:buttonBarStyle">
|
||||
|
||||
</LinearLayout>
|
||||
<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>
|
Loading…
Reference in a new issue