Group detail page and list of members
- Click on group in group list goes to a detail page
- Temporarily show members, TODO: Move list as
an expanded list in group browser activity
- TODO: Populate detail page with group info and
group actions
Bug: 4413116
Change-Id: I114d276f96aed318307d185910ae8799228262c9
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index ed03e77..5969097 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -352,6 +352,11 @@
</intent-filter>
</activity>
+ <!-- Views the details of a single group -->
+ <activity android:name=".activities.GroupDetailActivity"
+ android:label=""
+ android:theme="@style/GroupDetailTheme" />
+
<!-- Used to show QuickContact window over a translucent activity, which is a
temporary hack until we add better framework support. -->
<activity
diff --git a/res/layout/group_detail_activity.xml b/res/layout/group_detail_activity.xml
new file mode 100644
index 0000000..707a65c
--- /dev/null
+++ b/res/layout/group_detail_activity.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <fragment
+ class="com.android.contacts.group.GroupDetailFragment"
+ android:id="@+id/group_detail_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+</FrameLayout>
diff --git a/res/layout/group_detail_fragment.xml b/res/layout/group_detail_fragment.xml
new file mode 100644
index 0000000..70d67b6
--- /dev/null
+++ b/res/layout/group_detail_fragment.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/group_detail"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <ListView
+ android:id="@+id/member_list"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:scrollbarStyle="outsideOverlay"/>
+
+</LinearLayout>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 2469a3d..2c2f791 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -111,6 +111,30 @@
<item name="contact_filter_popup_width">320dip</item>
</style>
+ <!-- TODO: Clean up this file so themes aren't copied. -->
+ <style name="GroupDetailTheme" parent="@android:Theme">
+ <item name="list_item_height">?android:attr/listPreferredItemHeight</item>
+ <item name="activated_background">@drawable/list_item_activated_background</item>
+ <item name="section_header_background">@drawable/list_title_holo</item>
+ <item name="list_section_header_height">32dip</item>
+ <item name="list_item_divider">@drawable/list_item_divider</item>
+ <item name="list_item_padding_top">4dip</item>
+ <item name="list_item_padding_right">11dip</item>
+ <item name="list_item_padding_bottom">4dip</item>
+ <item name="list_item_padding_left">4dip</item>
+ <item name="list_item_gap_between_image_and_text">8dip</item>
+ <item name="list_item_gap_between_label_and_data">5dip</item>
+ <item name="list_item_call_button_padding">14dip</item>
+ <item name="list_item_vertical_divider_margin">5dip</item>
+ <item name="list_item_presence_icon_margin">5dip</item>
+ <item name="list_item_photo_size">56dip</item>
+ <item name="list_item_prefix_highlight_color">#729a27</item>
+ <item name="list_item_header_text_indent">56dip</item>
+ <item name="list_item_header_text_color">?color/section_header_text_color</item>
+ <item name="list_item_header_text_size">14sp</item>
+ <item name="contact_filter_popup_width">320dip</item>
+ </style>
+
<style name="ContactPickerTheme" parent="@android:Theme">
<item name="section_header_background">@drawable/section_header</item>
<item name="list_item_divider">@drawable/list_item_divider</item>
diff --git a/src/com/android/contacts/activities/GroupDetailActivity.java b/src/com/android/contacts/activities/GroupDetailActivity.java
new file mode 100644
index 0000000..edc460c
--- /dev/null
+++ b/src/com/android/contacts/activities/GroupDetailActivity.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.contacts.activities;
+
+import com.android.contacts.ContactsActivity;
+import com.android.contacts.R;
+
+import android.os.Bundle;
+
+public class GroupDetailActivity extends ContactsActivity {
+
+ private static final String TAG = "GroupDetailActivity";
+
+ public static final String KEY_ACCOUNT_TYPE = "accountType";
+ public static final String KEY_ACCOUNT_NAME = "accountName";
+ public static final String KEY_GROUP_ID = "groupId";
+ public static final String KEY_GROUP_SOURCE_ID = "groupSourceId";
+ public static final String KEY_GROUP_READ_ONLY = "groupReadOnly";
+ public static final String KEY_GROUP_TITLE = "title";
+
+ @Override
+ public void onCreate(Bundle savedState) {
+ super.onCreate(savedState);
+
+ // TODO: Create Intent Resolver to handle the different ways users can get to this list.
+ // TODO: Handle search or key down
+
+ setContentView(R.layout.group_detail_activity);
+ }
+}
diff --git a/src/com/android/contacts/group/GroupBrowseListAdapter.java b/src/com/android/contacts/group/GroupBrowseListAdapter.java
index ed69776..bccc207 100644
--- a/src/com/android/contacts/group/GroupBrowseListAdapter.java
+++ b/src/com/android/contacts/group/GroupBrowseListAdapter.java
@@ -69,6 +69,10 @@
icon.setImageResource(R.drawable.ic_menu_display_all_holo_light);
label.setText(group.getTitle());
account.setText(group.getAccountName());
+
+ // Set the tag to be the GroupMetaData object, in order to extract group attributes from the
+ // view later.
+ convertView.setTag(group);
return convertView;
}
diff --git a/src/com/android/contacts/group/GroupBrowseListFragment.java b/src/com/android/contacts/group/GroupBrowseListFragment.java
index 978ce13..d9d020e 100644
--- a/src/com/android/contacts/group/GroupBrowseListFragment.java
+++ b/src/com/android/contacts/group/GroupBrowseListFragment.java
@@ -19,6 +19,7 @@
import com.android.contacts.GroupMetaData;
import com.android.contacts.GroupMetaDataLoader;
import com.android.contacts.R;
+import com.android.contacts.activities.GroupDetailActivity;
import android.app.Activity;
import android.app.Fragment;
@@ -26,6 +27,7 @@
import android.app.LoaderManager.LoaderCallbacks;
import android.content.Context;
import android.content.CursorLoader;
+import android.content.Intent;
import android.content.Loader;
import android.database.Cursor;
import android.os.Bundle;
@@ -36,6 +38,8 @@
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import java.util.ArrayList;
@@ -137,6 +141,24 @@
mListView.setAdapter(new GroupBrowseListAdapter(mContext, mGroupList));
mListView.setEmptyView(mEmptyView);
+ mListView.setOnItemClickListener(new OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ startGroupDetailActivity((GroupMetaData) view.getTag());
+ }
+ });
+ }
+
+ private void startGroupDetailActivity(GroupMetaData group) {
+ if (group == null) {
+ return;
+ }
+ Intent intent = new Intent(mContext, GroupDetailActivity.class);
+ intent.putExtra(GroupDetailActivity.KEY_ACCOUNT_TYPE, group.getAccountType());
+ intent.putExtra(GroupDetailActivity.KEY_ACCOUNT_NAME, group.getAccountName());
+ intent.putExtra(GroupDetailActivity.KEY_GROUP_ID, group.getGroupId());
+ intent.putExtra(GroupDetailActivity.KEY_GROUP_TITLE, group.getTitle());
+ mContext.startActivity(intent);
}
private void hideSoftKeyboard() {
diff --git a/src/com/android/contacts/group/GroupDetailFragment.java b/src/com/android/contacts/group/GroupDetailFragment.java
new file mode 100644
index 0000000..98babac
--- /dev/null
+++ b/src/com/android/contacts/group/GroupDetailFragment.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.contacts.group;
+
+import com.android.contacts.ContactPhotoManager;
+import com.android.contacts.R;
+import com.android.contacts.activities.GroupDetailActivity;
+import com.android.contacts.list.ContactListAdapter;
+import com.android.contacts.list.ContactListFilter;
+import com.android.contacts.list.DefaultContactListAdapter;
+
+import android.app.Activity;
+import android.app.Fragment;
+import android.app.LoaderManager;
+import android.app.LoaderManager.LoaderCallbacks;
+import android.content.Context;
+import android.content.CursorLoader;
+import android.content.Intent;
+import android.content.Loader;
+import android.database.Cursor;
+import android.os.Bundle;
+import android.provider.ContactsContract;
+import android.provider.ContactsContract.Directory;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AbsListView;
+import android.widget.AbsListView.OnScrollListener;
+import android.widget.AdapterView;
+import android.widget.AdapterView.OnItemClickListener;
+import android.widget.ListView;
+
+/**
+ * Displays the details of a group and shows a list of actions possible for the group.
+ */
+public class GroupDetailFragment extends Fragment implements OnScrollListener {
+
+ private static final String TAG = "GroupDetailFragment";
+
+ private static final int LOADER_MEMBERS = 0;
+
+ private Context mContext;
+
+ private View mRootView;
+ private ListView mMemberListView;
+
+ private ContactListAdapter mAdapter;
+ private ContactPhotoManager mPhotoManager;
+
+ public GroupDetailFragment() {
+ }
+
+ @Override
+ public void onAttach(Activity activity) {
+ super.onAttach(activity);
+ mContext = activity;
+ configurePhotoLoader();
+ }
+
+ @Override
+ public void onDetach() {
+ super.onDetach();
+ mContext = null;
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
+ mRootView = inflater.inflate(R.layout.group_detail_fragment, container, false);
+ mMemberListView = (ListView) mRootView.findViewById(R.id.member_list);
+ mMemberListView.setOnItemClickListener(new OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ // TODO: Open contact detail for this person
+ }
+ });
+ return mRootView;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ Intent intent = getActivity().getIntent();
+ String accountType = intent.getStringExtra(GroupDetailActivity.KEY_ACCOUNT_TYPE);
+ String accountName = intent.getStringExtra(GroupDetailActivity.KEY_ACCOUNT_NAME);
+ long groupId = intent.getLongExtra(GroupDetailActivity.KEY_GROUP_ID, -1);
+ String groupTitle = intent.getStringExtra(GroupDetailActivity.KEY_GROUP_TITLE);
+
+ configureAdapter(accountType, accountName, groupId, groupTitle);
+ startGroupMembersLoader();
+ }
+
+ private void configureAdapter(String accountType, String accountName,
+ long groupId, String groupTitle) {
+ mAdapter = new DefaultContactListAdapter(getActivity());
+ mAdapter.setSectionHeaderDisplayEnabled(false);
+ mAdapter.setDisplayPhotos(true);
+ mAdapter.setHasHeader(0, false);
+ mAdapter.setQuickContactEnabled(false);
+ mAdapter.setPinnedPartitionHeadersEnabled(false);
+ mAdapter.setContactNameDisplayOrder(ContactsContract.Preferences.DISPLAY_ORDER_PRIMARY);
+ mAdapter.setSortOrder(ContactsContract.Preferences.SORT_ORDER_PRIMARY);
+ mAdapter.setPhotoLoader(mPhotoManager);
+ mAdapter.setFilter(new ContactListFilter(accountType, accountName, groupId, "", false,
+ groupTitle));
+ mMemberListView.setAdapter(mAdapter);
+ }
+
+ private void configurePhotoLoader() {
+ if (mContext != null) {
+ if (mPhotoManager == null) {
+ mPhotoManager = ContactPhotoManager.getInstance(mContext);
+ }
+ if (mMemberListView != null) {
+ mMemberListView.setOnScrollListener(this);
+ }
+ if (mAdapter != null) {
+ mAdapter.setPhotoLoader(mPhotoManager);
+ }
+ }
+ }
+
+ /**
+ * Start the loader to retrieve the list of group members.
+ */
+ private void startGroupMembersLoader() {
+ getLoaderManager().destroyLoader(LOADER_MEMBERS);
+ getLoaderManager().restartLoader(LOADER_MEMBERS, null, mGroupMemberListLoaderListener);
+ }
+
+ /**
+ * The listener for the group members list loader
+ */
+ private final LoaderManager.LoaderCallbacks<Cursor> mGroupMemberListLoaderListener =
+ new LoaderCallbacks<Cursor>() {
+
+ @Override
+ public CursorLoader onCreateLoader(int id, Bundle args) {
+ CursorLoader loader = new CursorLoader(mContext, null, null, null, null, null);
+ mAdapter.configureLoader(loader, Directory.DEFAULT);
+ return loader;
+ }
+
+ @Override
+ public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
+ mAdapter.changeCursor(loader.getId(), data);
+ }
+
+ @Override
+ public void onLoaderReset(Loader<Cursor> loader) {}
+ };
+
+ @Override
+ public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount,
+ int totalItemCount) {
+ }
+
+ @Override
+ public void onScrollStateChanged(AbsListView view, int scrollState) {
+ if (scrollState == OnScrollListener.SCROLL_STATE_FLING) {
+ mPhotoManager.pause();
+ } else {
+ mPhotoManager.resume();
+ }
+ }
+}