diff options
Diffstat (limited to 'OpenKeychain')
5 files changed, 79 insertions, 5 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java index cfc1075af..153065bb7 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyFragment.java @@ -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); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/LinkedIdsAdapter.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/LinkedIdsAdapter.java index e0f28efb8..c5bb58c3d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/LinkedIdsAdapter.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/LinkedIdsAdapter.java @@ -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) { diff --git a/OpenKeychain/src/main/res/drawable/divider.xml b/OpenKeychain/src/main/res/drawable/divider.xml new file mode 100644 index 000000000..b0695f89a --- /dev/null +++ b/OpenKeychain/src/main/res/drawable/divider.xml @@ -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>
\ No newline at end of file diff --git a/OpenKeychain/src/main/res/layout/view_key_fragment.xml b/OpenKeychain/src/main/res/layout/view_key_fragment.xml index 3d9e4fde8..a3d7250f9 100644 --- a/OpenKeychain/src/main/res/layout/view_key_fragment.xml +++ b/OpenKeychain/src/main/res/layout/view_key_fragment.xml @@ -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> diff --git a/OpenKeychain/src/main/res/values/strings.xml b/OpenKeychain/src/main/res/values/strings.xml index 9753e4d60..72ba98ed9 100644 --- a/OpenKeychain/src/main/res/values/strings.xml +++ b/OpenKeychain/src/main/res/values/strings.xml @@ -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> |