Auto select first group in group list on tablet
- If no groups are selected yet
Bug: 5061848
Change-Id: I52f464791dd0f96dbb00108cdd34895989bbd3d4
diff --git a/src/com/android/contacts/group/GroupBrowseListAdapter.java b/src/com/android/contacts/group/GroupBrowseListAdapter.java
index 753261a..630a397 100644
--- a/src/com/android/contacts/group/GroupBrowseListAdapter.java
+++ b/src/com/android/contacts/group/GroupBrowseListAdapter.java
@@ -56,6 +56,15 @@
public void setCursor(Cursor cursor) {
mCursor = cursor;
+
+ // If there's no selected group already and the cursor is valid, then by default, select the
+ // first group
+ if (mSelectedGroupUri == null && cursor != null && cursor.getCount() > 0) {
+ GroupListItem firstItem = getItem(0);
+ long groupId = (firstItem == null) ? null : firstItem.getGroupId();
+ mSelectedGroupUri = getGroupUriFromId(groupId);
+ }
+
notifyDataSetChanged();
}
@@ -89,6 +98,10 @@
return mSelectedGroupUri != null && mSelectedGroupUri.equals(groupUri);
}
+ public Uri getSelectedGroup() {
+ return mSelectedGroupUri;
+ }
+
@Override
public int getCount() {
return mCursor == null ? 0 : mCursor.getCount();
diff --git a/src/com/android/contacts/group/GroupBrowseListFragment.java b/src/com/android/contacts/group/GroupBrowseListFragment.java
index a1544cf..835400f 100644
--- a/src/com/android/contacts/group/GroupBrowseListFragment.java
+++ b/src/com/android/contacts/group/GroupBrowseListFragment.java
@@ -223,6 +223,7 @@
}
mListView.setEmptyView(mEmptyView);
+ mSelectedGroupUri = mAdapter.getSelectedGroup();
if (mSelectionVisible && mSelectedGroupUri != null) {
viewGroup(mSelectedGroupUri);
}