add expand item to linked id list
This commit is contained in:
@@ -37,6 +37,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
@@ -70,6 +71,7 @@ public class ViewKeyFragment extends LoaderFragment implements
|
||||
private ListView mLinkedIds;
|
||||
private CardView mLinkedIdsCard;
|
||||
private byte[] mFingerprint;
|
||||
private TextView mLinkedIdsExpander;
|
||||
|
||||
/**
|
||||
* Creates new instance of this fragment
|
||||
@@ -113,6 +115,8 @@ public class ViewKeyFragment extends LoaderFragment implements
|
||||
|
||||
mLinkedIds = (ListView) view.findViewById(R.id.view_key_linked_ids);
|
||||
|
||||
mLinkedIdsExpander = (TextView) view.findViewById(R.id.view_key_linked_ids_expander);
|
||||
|
||||
mUserIds.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
@@ -198,7 +202,8 @@ public class ViewKeyFragment extends LoaderFragment implements
|
||||
mUserIds.setAdapter(mUserIdsAdapter);
|
||||
getLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this);
|
||||
|
||||
mLinkedIdsAdapter = new LinkedIdsAdapter(getActivity(), null, 0, !mIsSecret);
|
||||
mLinkedIdsAdapter = new LinkedIdsAdapter(getActivity(), null, 0,
|
||||
!mIsSecret, mLinkedIdsExpander);
|
||||
mLinkedIds.setAdapter(mLinkedIdsAdapter);
|
||||
getLoaderManager().initLoader(LOADER_ID_LINKED_IDS, null, this);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ 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;
|
||||
@@ -50,19 +51,36 @@ public class LinkedIdsAdapter extends UserAttributesAdapter {
|
||||
protected LayoutInflater mInflater;
|
||||
WeakHashMap<Integer,RawLinkedIdentity> mLinkedIdentityCache = new WeakHashMap<>();
|
||||
|
||||
public LinkedIdsAdapter(Context context, Cursor c, int flags, boolean showCertification) {
|
||||
private Cursor mUnfilteredCursor;
|
||||
|
||||
private TextView mExpander;
|
||||
|
||||
public LinkedIdsAdapter(Context context, Cursor c, int flags,
|
||||
boolean showCertification, TextView expander) {
|
||||
super(context, c, flags);
|
||||
mInflater = LayoutInflater.from(context);
|
||||
mShowCertification = showCertification;
|
||||
|
||||
if (expander != null) {
|
||||
mExpander = expander;
|
||||
mExpander.setVisibility(View.GONE);
|
||||
mExpander.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showUnfiltered();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor swapCursor(Cursor cursor) {
|
||||
if (cursor == null) {
|
||||
mUnfilteredCursor = null;
|
||||
return super.swapCursor(null);
|
||||
}
|
||||
|
||||
Cursor filteredCursor = new FilterCursorWrapper(cursor) {
|
||||
mUnfilteredCursor = cursor;
|
||||
FilterCursorWrapper filteredCursor = new FilterCursorWrapper(cursor) {
|
||||
@Override
|
||||
public boolean isVisible(Cursor cursor) {
|
||||
RawLinkedIdentity id = getItemAtPosition(cursor);
|
||||
@@ -70,9 +88,25 @@ public class LinkedIdsAdapter extends UserAttributesAdapter {
|
||||
}
|
||||
};
|
||||
|
||||
if (mExpander != null) {
|
||||
int hidden = filteredCursor.getHiddenCount();
|
||||
if (hidden == 0) {
|
||||
mExpander.setVisibility(View.GONE);
|
||||
} else {
|
||||
mExpander.setVisibility(View.VISIBLE);
|
||||
mExpander.setText(mContext.getResources().getQuantityString(
|
||||
R.plurals.linked_id_expand, hidden));
|
||||
}
|
||||
}
|
||||
|
||||
return super.swapCursor(filteredCursor);
|
||||
}
|
||||
|
||||
private void showUnfiltered() {
|
||||
mExpander.setVisibility(View.GONE);
|
||||
super.swapCursor(mUnfilteredCursor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindView(View view, Context context, Cursor cursor) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user