add contact count to My Keys header

This commit is contained in:
Vincent Breitmoser 2014-03-08 14:41:25 +01:00
parent de6daf5c30
commit be558944b5
3 changed files with 30 additions and 2 deletions

View File

@ -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;
}
/**

View File

@ -11,6 +11,20 @@
android:padding="8dp"
android:textColor="@color/emphasis"
android:textSize="17sp"
android:textStyle="bold" />
android:textStyle="bold"
android:text="header text" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="contact count"
android:id="@+id/contacts_num"
android:layout_centerVertical="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginRight="10px"
android:visibility="visible"
android:textColor="@android:color/darker_gray" />
</RelativeLayout>

View File

@ -145,6 +145,11 @@
<string name="expired">expired</string>
<string name="revoked">revoked</string>
<plurals name="n_contacts">
<item quantity="one">1 contact</item>
<item quantity="other">%d contacts</item>
</plurals>
<plurals name="n_key_servers">
<item quantity="one">%d keyserver</item>
<item quantity="other">%d keyservers</item>