From be558944b52ac038c40bdf84a3d52c9ae2e7a218 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 8 Mar 2014 14:41:25 +0100 Subject: [PATCH] add contact count to My Keys header --- .../keychain/ui/KeyListFragment.java | 11 ++++++++++- .../src/main/res/layout/key_list_header.xml | 16 +++++++++++++++- OpenPGP-Keychain/src/main/res/values/strings.xml | 5 +++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 941abdd6d..96b75cf11 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -19,7 +19,6 @@ package org.sufficientlysecure.keychain.ui; import java.util.HashMap; import java.util.ArrayList; -import java.util.Set; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; @@ -473,6 +472,7 @@ public class KeyListFragment extends Fragment implements AdapterView.OnItemClick holder = new HeaderViewHolder(); convertView = mInflater.inflate(R.layout.key_list_header, parent, false); holder.text = (TextView) convertView.findViewById(R.id.stickylist_header_text); + holder.count = (TextView) convertView.findViewById(R.id.contacts_num); convertView.setTag(holder); } else { holder = (HeaderViewHolder) convertView.getTag(); @@ -489,6 +489,13 @@ public class KeyListFragment extends Fragment implements AdapterView.OnItemClick } if(mCursor.getInt(KeyListFragment.INDEX_TYPE) == KeyTypes.SECRET) { + { // set contact count + int num = mCursor.getCount(); + String contactsTotal = getResources().getQuantityString(R.plurals.n_contacts, num, num); + holder.count.setText(contactsTotal); + holder.count.setVisibility(View.VISIBLE); + } + holder.text.setText(convertView.getResources().getString(R.string.my_keys)); return convertView; } @@ -500,6 +507,7 @@ public class KeyListFragment extends Fragment implements AdapterView.OnItemClick headerText = "" + mCursor.getString(KeyListFragment.INDEX_UID).subSequence(0, 1).charAt(0); } holder.text.setText(headerText); + holder.count.setVisibility(View.GONE); return convertView; } @@ -533,6 +541,7 @@ public class KeyListFragment extends Fragment implements AdapterView.OnItemClick class HeaderViewHolder { TextView text; + TextView count; } /** diff --git a/OpenPGP-Keychain/src/main/res/layout/key_list_header.xml b/OpenPGP-Keychain/src/main/res/layout/key_list_header.xml index 5768e4153..09ac1c856 100644 --- a/OpenPGP-Keychain/src/main/res/layout/key_list_header.xml +++ b/OpenPGP-Keychain/src/main/res/layout/key_list_header.xml @@ -11,6 +11,20 @@ android:padding="8dp" android:textColor="@color/emphasis" android:textSize="17sp" - android:textStyle="bold" /> + android:textStyle="bold" + android:text="header text" /> + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index 4a5b142ab..e13b9e0c6 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -145,6 +145,11 @@ expired revoked + + 1 contact + %d contacts + + %d keyserver %d keyservers