mirror of
https://github.com/moparisthebest/open-keychain
synced 2025-02-23 14:41:54 -05:00
add expand item to linked id list
This commit is contained in:
parent
deafe946fd
commit
3b7f21d98a
@ -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) {
|
||||
|
||||
|
11
OpenKeychain/src/main/res/drawable/divider.xml
Normal file
11
OpenKeychain/src/main/res/drawable/divider.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle" >
|
||||
|
||||
<size
|
||||
android:height="1px"
|
||||
android:width="1000dp" />
|
||||
|
||||
<solid android:color="@color/bg_gray" />
|
||||
|
||||
</shape>
|
@ -55,7 +55,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"
|
||||
@ -68,6 +69,25 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="4dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/view_key_linked_ids_expander"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:gravity="center_vertical"
|
||||
android:drawableTop="@drawable/divider"
|
||||
android:drawableRight="@drawable/ic_expand_more_black_24dp"
|
||||
android:drawableEnd="@drawable/ic_expand_more_black_24dp"
|
||||
android:drawablePadding="3dp"
|
||||
android:clickable="true"
|
||||
android:textColor="@color/tertiary_text_light"
|
||||
android:text="%d more unknown identity types"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
style="@style/SelectableItem" />
|
||||
|
||||
</LinearLayout>
|
||||
</android.support.v7.widget.CardView>
|
||||
|
||||
|
@ -1310,5 +1310,9 @@
|
||||
<string name="linked_need_verify">The resource needs to be verified before you can proceed!</string>
|
||||
<string name="menu_linked_add_identity">"Add Linked Identity"</string>
|
||||
<string name="section_linked_identities">Linked Identities</string>
|
||||
<plurals name="linked_id_expand">
|
||||
<item quantity="one">"There is one more unknown identity type"</item>
|
||||
<item quantity="other">"There are %d more unknown identity types"</item>
|
||||
</plurals>
|
||||
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user