diff options
-rw-r--r-- | res/layout/group_browse_list_account_header.xml | 8 | ||||
-rw-r--r-- | src/com/android/contacts/GroupListLoader.java | 17 | ||||
-rw-r--r-- | src/com/android/contacts/group/GroupBrowseListAdapter.java | 10 | ||||
-rw-r--r-- | src/com/android/contacts/group/GroupListItem.java | 22 |
4 files changed, 40 insertions, 17 deletions
diff --git a/res/layout/group_browse_list_account_header.xml b/res/layout/group_browse_list_account_header.xml index 73684c154..7c07497a0 100644 --- a/res/layout/group_browse_list_account_header.xml +++ b/res/layout/group_browse_list_account_header.xml @@ -38,20 +38,22 @@ <TextView android:id="@+id/account_name" - android:layout_width="wrap_content" + android:layout_width="0dip" android:layout_height="wrap_content" + android:layout_weight="1" android:layout_marginLeft="@dimen/group_list_header_padding" android:textAppearance="?android:attr/textAppearanceSmall" android:singleLine="true" + android:ellipsize="middle" android:textColor="@color/people_app_theme_color"/> <TextView android:id="@+id/group_count" - android:layout_width="0dip" + android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_weight="1" android:gravity="right" android:singleLine="true" + android:layout_marginLeft="@dimen/group_list_header_padding" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="?android:attr/textColorTertiary"/> diff --git a/src/com/android/contacts/GroupListLoader.java b/src/com/android/contacts/GroupListLoader.java index 49aa602a4..f5716e385 100644 --- a/src/com/android/contacts/GroupListLoader.java +++ b/src/com/android/contacts/GroupListLoader.java @@ -17,11 +17,14 @@ package com.android.contacts; import android.content.Context; import android.content.CursorLoader; +import android.net.Uri; import android.provider.ContactsContract.Groups; /** - * Group loader for the group list that includes details such as the number of contacts per group. - * This group list excludes default, favorite, and deleted groups. + * Group loader for the group list that includes details such as the number of contacts per group + * and number of groups per account. This list is sorted by account type, account name, where the + * group names are in alphabetical order. Note that the list excludes default, favorite, and deleted + * groups. */ public final class GroupListLoader extends CursorLoader { @@ -33,6 +36,7 @@ public final class GroupListLoader extends CursorLoader { Groups.ACTION, Groups.ACTION_URI, Groups.SUMMARY_COUNT, + Groups.SUMMARY_GROUP_COUNT_PER_ACCOUNT, }; public final static int ACCOUNT_NAME = 0; @@ -42,11 +46,16 @@ public final class GroupListLoader extends CursorLoader { public final static int ACTION = 4; public final static int ACTION_URI = 5; public final static int MEMBER_COUNT = 6; + public final static int GROUP_COUNT_PER_ACCOUNT = 7; + + private static final Uri GROUP_LIST_URI = Groups.CONTENT_SUMMARY_URI.buildUpon() + .appendQueryParameter(Groups.PARAM_RETURN_GROUP_COUNT_PER_ACCOUNT, "true").build(); public GroupListLoader(Context context) { - super(context, Groups.CONTENT_SUMMARY_URI, COLUMNS, Groups.ACCOUNT_TYPE + " NOT NULL AND " + super(context, GROUP_LIST_URI, COLUMNS, Groups.ACCOUNT_TYPE + " NOT NULL AND " + Groups.ACCOUNT_NAME + " NOT NULL AND " + Groups.AUTO_ADD + "=0 AND " + Groups.FAVORITES + "=0 AND " + Groups.DELETED + "=0", null, - Groups.ACCOUNT_NAME + " ASC"); + Groups.ACCOUNT_TYPE + ", " + Groups.ACCOUNT_NAME + ", " + + Groups.TITLE + " COLLATE LOCALIZED ASC"); } } diff --git a/src/com/android/contacts/group/GroupBrowseListAdapter.java b/src/com/android/contacts/group/GroupBrowseListAdapter.java index d44733b6c..be997380d 100644 --- a/src/com/android/contacts/group/GroupBrowseListAdapter.java +++ b/src/com/android/contacts/group/GroupBrowseListAdapter.java @@ -107,6 +107,7 @@ public class GroupBrowseListAdapter extends BaseAdapter { long groupId = mCursor.getLong(GroupListLoader.GROUP_ID); String title = mCursor.getString(GroupListLoader.TITLE); int memberCount = mCursor.getInt(GroupListLoader.MEMBER_COUNT); + int groupCountForThisAccount = mCursor.getInt(GroupListLoader.GROUP_COUNT_PER_ACCOUNT); // Figure out if this is the first group for this account name / account type pair by // checking the previous entry. This is to determine whether or not we need to display an @@ -123,7 +124,7 @@ public class GroupBrowseListAdapter extends BaseAdapter { } return new GroupListItem(accountName, accountType, groupId, title, isFirstGroupInAccount, - memberCount); + memberCount, groupCountForThisAccount); } @Override @@ -170,8 +171,9 @@ public class GroupBrowseListAdapter extends BaseAdapter { viewCache.accountType.setText(accountType.getDisplayLabel(mContext).toString()); viewCache.accountName.setText(entry.getAccountName()); - // TODO: Add in number of groups within this account name / type using this string: - // getQuantityString(R.plurals.num_groups_in_account, entry.count, entry.count); + int count = entry.getGroupCountForThisAccount(); + viewCache.groupCountForAccount.setText(mContext.getResources().getQuantityString( + R.plurals.num_groups_in_account, count, count)); } private static Uri getGroupUriFromId(long groupId) { @@ -185,6 +187,7 @@ public class GroupBrowseListAdapter extends BaseAdapter { public static class GroupListItemViewCache { public final TextView accountType; public final TextView accountName; + public final TextView groupCountForAccount; public final TextView groupTitle; public final TextView groupMemberCount; public final View accountHeader; @@ -194,6 +197,7 @@ public class GroupBrowseListAdapter extends BaseAdapter { public GroupListItemViewCache(View view) { accountType = (TextView) view.findViewById(R.id.account_type); accountName = (TextView) view.findViewById(R.id.account_name); + groupCountForAccount = (TextView) view.findViewById(R.id.group_count); groupTitle = (TextView) view.findViewById(R.id.label); groupMemberCount = (TextView) view.findViewById(R.id.count); accountHeader = view.findViewById(R.id.group_list_header); diff --git a/src/com/android/contacts/group/GroupListItem.java b/src/com/android/contacts/group/GroupListItem.java index 4740c4461..349b86ed0 100644 --- a/src/com/android/contacts/group/GroupListItem.java +++ b/src/com/android/contacts/group/GroupListItem.java @@ -27,14 +27,18 @@ public final class GroupListItem { private final boolean mIsFirstGroupInAccount; private final int mMemberCount; + /** Number of groups in the account that this group belongs to */ + private final int mGroupCountForThisAccount; + public GroupListItem(String accountName, String accountType, long groupId, String title, - boolean isFirstGroupInAccount, int memberCount) { - this.mAccountName = accountName; - this.mAccountType = accountType; - this.mGroupId = groupId; - this.mTitle = title; - this.mIsFirstGroupInAccount = isFirstGroupInAccount; - this.mMemberCount = memberCount; + boolean isFirstGroupInAccount, int memberCount, int groupCountForThisAccount) { + mAccountName = accountName; + mAccountType = accountType; + mGroupId = groupId; + mTitle = title; + mIsFirstGroupInAccount = isFirstGroupInAccount; + mMemberCount = memberCount; + mGroupCountForThisAccount = groupCountForThisAccount; } public String getAccountName() { @@ -64,4 +68,8 @@ public final class GroupListItem { public boolean isFirstGroupInAccount() { return mIsFirstGroupInAccount; } + + public int getGroupCountForThisAccount() { + return mGroupCountForThisAccount; + } }
\ No newline at end of file |