Fix group size string
It should be of the format "X people from Y" where X is the size
and Y is the account type display label
Change-Id: Ic46d287e42b0d69c8f5dc1275d4894ada5ff67d1
diff --git a/res/layout-sw580dp/group_detail_fragment.xml b/res/layout-sw580dp/group_detail_fragment.xml
index a824319..7c65036 100644
--- a/res/layout-sw580dp/group_detail_fragment.xml
+++ b/res/layout-sw580dp/group_detail_fragment.xml
@@ -37,8 +37,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/group_detail_border_padding"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:textColor="?android:attr/textColorSecondary" />
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:textColor="?android:attr/textColorTertiary" />
<View
android:layout_width="match_parent"
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 52f8394..baadf58 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1569,6 +1569,12 @@
(Contacts themselves will not be deleted.)
</string>
+ <!-- Subtitle of the group detail page that describes how many people are in the current group [CHAR LIMIT=30] -->
+ <plurals name="num_contacts_in_group">
+ <item quantity="one"><xliff:g id="count">%1$d</xliff:g> person from <xliff:g id="account_type">%2$s</xliff:g></item>
+ <item quantity="other"><xliff:g id="count">%1$d</xliff:g> people from <xliff:g id="account_type">%2$s</xliff:g></item>
+ </plurals>
+
<!-- Toast displayed when the user creates a new contact and attempts to join it
with another before entering any data [CHAR LIMIT=256] -->
<string name="toast_join_with_empty_contact">Please enter contact name before joining
diff --git a/src/com/android/contacts/group/GroupDetailFragment.java b/src/com/android/contacts/group/GroupDetailFragment.java
index c5f6ef4..7f0536f 100644
--- a/src/com/android/contacts/group/GroupDetailFragment.java
+++ b/src/com/android/contacts/group/GroupDetailFragment.java
@@ -23,6 +23,8 @@
import com.android.contacts.interactions.GroupDeletionDialogFragment;
import com.android.contacts.list.ContactTileAdapter;
import com.android.contacts.list.ContactTileAdapter.DisplayType;
+import com.android.contacts.model.AccountType;
+import com.android.contacts.model.AccountTypeManager;
import android.app.Activity;
import android.app.Fragment;
@@ -90,10 +92,12 @@
private ContactTileAdapter mAdapter;
private ContactPhotoManager mPhotoManager;
+ private AccountTypeManager mAccountTypeManager;
private Uri mGroupUri;
private long mGroupId;
private String mGroupName;
+ private String mAccountTypeString;
private boolean mOptionsMenuEditable;
private boolean mCloseActivityAfterDelete;
@@ -105,6 +109,7 @@
public void onAttach(Activity activity) {
super.onAttach(activity);
mContext = activity;
+ mAccountTypeManager = AccountTypeManager.getInstance(mContext);
Resources res = getResources();
int columnCount = res.getInteger(R.integer.contact_tile_column_count);
@@ -214,7 +219,7 @@
return;
}
}
- updateSize(null);
+ updateSize(-1);
updateTitle(null);
}
@@ -235,7 +240,7 @@
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
- updateSize(Integer.toString(data.getCount()));
+ updateSize(data.getCount());
mAdapter.loadFromCursor(data);
}
@@ -246,6 +251,7 @@
private void bindGroupMetaData(Cursor cursor) {
cursor.moveToPosition(-1);
if (cursor.moveToNext()) {
+ mAccountTypeString = cursor.getString(GroupMetaDataLoader.ACCOUNT_TYPE);
mGroupId = cursor.getLong(GroupMetaDataLoader.GROUP_ID);
mGroupName = cursor.getString(GroupMetaDataLoader.TITLE);
updateTitle(mGroupName);
@@ -265,11 +271,26 @@
}
}
- private void updateSize(String size) {
- if (mGroupSize != null) {
- mGroupSize.setText(size);
+ /**
+ * Display the count of the number of group members.
+ * @param size of the group (can be -1 if no size could be determined)
+ */
+ private void updateSize(int size) {
+ String groupSizeString;
+ if (size == -1) {
+ groupSizeString = null;
} else {
- mListener.onGroupSizeUpdated(size);
+ String groupSizeTemplateString = getResources().getQuantityString(
+ R.plurals.num_contacts_in_group, size);
+ AccountType accountType = mAccountTypeManager.getAccountType(mAccountTypeString);
+ groupSizeString = String.format(groupSizeTemplateString, size,
+ accountType.getDisplayLabel(mContext));
+ }
+
+ if (mGroupSize != null) {
+ mGroupSize.setText(groupSizeString);
+ } else {
+ mListener.onGroupSizeUpdated(groupSizeString);
}
}