blob: c247d43289f267489cf3c000fb021e15e6c66658 [file] [log] [blame]
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -08001/*
Dmitri Plotnikovfcfdffb2010-07-15 18:00:55 -07002 * Copyright (C) 2010 The Android Open Source Project
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -08003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Dmitri Plotnikov27834b22010-07-01 14:10:08 -070017package com.android.contacts.activities;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080018
Katherine Kuan79700882011-06-14 17:40:33 -070019import com.android.contacts.ContactLoader;
Dmitri Plotnikov18ffaa22010-12-03 14:28:00 -080020import com.android.contacts.ContactSaveService;
Dmitri Plotnikov6f667b52011-01-09 12:53:13 -080021import com.android.contacts.ContactsActivity;
Dmitri Plotnikov27834b22010-07-01 14:10:08 -070022import com.android.contacts.R;
Dmitri Plotnikov18ffaa22010-12-03 14:28:00 -080023import com.android.contacts.detail.ContactDetailFragment;
Katherine Kuanb5760b92011-06-01 16:19:40 -070024import com.android.contacts.group.GroupBrowseListFragment;
Katherine Kuanbe18de02011-06-07 12:38:29 -070025import com.android.contacts.group.GroupBrowseListFragment.OnGroupBrowserActionListener;
26import com.android.contacts.group.GroupDetailFragment;
Dmitri Plotnikov9692f262010-06-29 18:53:11 -070027import com.android.contacts.interactions.ContactDeletionInteraction;
Daniel Lehmann261cd562011-05-17 14:53:17 -070028import com.android.contacts.interactions.ImportExportDialogFragment;
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -070029import com.android.contacts.interactions.PhoneNumberInteraction;
Dmitri Plotnikov416b5692010-04-27 18:14:58 -070030import com.android.contacts.list.ContactBrowseListContextMenuAdapter;
Dmitri Plotnikov08e1c4e2010-07-02 17:57:51 -070031import com.android.contacts.list.ContactBrowseListFragment;
Dmitri Plotnikov59fb48e2010-04-26 17:09:19 -070032import com.android.contacts.list.ContactEntryListFragment;
Dmitri Plotnikov009676f2010-10-08 12:13:57 -070033import com.android.contacts.list.ContactListFilter;
Dmitri Plotnikov15ccbb42010-10-05 17:29:07 -070034import com.android.contacts.list.ContactListFilterController;
Dmitri Plotnikov0906ee32010-04-22 10:46:00 -070035import com.android.contacts.list.ContactsIntentResolver;
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -070036import com.android.contacts.list.ContactsRequest;
Dmitri Plotnikov8b826462010-11-17 14:52:24 -080037import com.android.contacts.list.ContactsUnavailableFragment;
Dmitri Plotnikov6e850a02010-10-28 10:46:21 -070038import com.android.contacts.list.CustomContactListFilterActivity;
Katherine Kuanb5760b92011-06-01 16:19:40 -070039import com.android.contacts.list.DefaultContactBrowseListFragment;
Dmitri Plotnikov4d174aa2010-10-25 15:38:54 -070040import com.android.contacts.list.DirectoryListLoader;
Dmitri Plotnikov732f6522010-04-27 10:30:59 -070041import com.android.contacts.list.OnContactBrowserActionListener;
Dmitri Plotnikov8b826462010-11-17 14:52:24 -080042import com.android.contacts.list.OnContactsUnavailableActionListener;
43import com.android.contacts.list.ProviderStatusLoader;
44import com.android.contacts.list.ProviderStatusLoader.ProviderStatusListener;
Katherine Kuanb5760b92011-06-01 16:19:40 -070045import com.android.contacts.list.StrequentContactListFragment;
Dmitri Plotnikovc85ad182010-09-17 18:12:49 -070046import com.android.contacts.preference.ContactsPreferenceActivity;
Dmitri Plotnikov8b826462010-11-17 14:52:24 -080047import com.android.contacts.util.AccountSelectionUtil;
Daniel Lehmann3391dbe2010-07-12 09:50:22 -070048import com.android.contacts.util.DialogManager;
Dmitri Plotnikov1323d692010-04-27 14:54:27 -070049import com.android.contacts.widget.ContextMenuAdapter;
Tadashi G. Takaoka57cf30f2009-09-21 19:54:39 +090050
Dmitri Plotnikovcaf0bc72010-09-03 15:16:21 -070051import android.accounts.Account;
Dmitri Plotnikov3d48a462010-12-09 15:55:27 -080052import android.app.ActionBar;
Katherine Kuanb5760b92011-06-01 16:19:40 -070053import android.app.ActionBar.Tab;
54import android.app.ActionBar.TabListener;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080055import android.app.Activity;
Jeff Sharkey49d17b32009-09-07 02:14:21 -070056import android.app.Dialog;
Dmitri Plotnikov92a6fdf2010-07-09 13:19:33 -070057import android.app.Fragment;
Katherine Kuanb5760b92011-06-01 16:19:40 -070058import android.app.FragmentManager;
59import android.app.FragmentTransaction;
Daniel Lehmann60be1a12010-08-05 18:37:21 -070060import android.content.ActivityNotFoundException;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080061import android.content.ContentValues;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080062import android.content.Intent;
Katherine Kuanb5760b92011-06-01 16:19:40 -070063import android.content.res.TypedArray;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080064import android.net.Uri;
65import android.os.Bundle;
Dmitri Plotnikovd7c4af22009-06-19 18:31:00 -070066import android.provider.ContactsContract;
Jeff Hamiltone0529662009-08-21 02:43:47 -050067import android.provider.ContactsContract.Contacts;
Dmitri Plotnikov8b826462010-11-17 14:52:24 -080068import android.provider.ContactsContract.ProviderStatus;
Dmitri Plotnikov9692f262010-06-29 18:53:11 -070069import android.provider.Settings;
Daniel Lehmanna35a7e22010-08-03 18:13:14 -070070import android.util.Log;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080071import android.view.KeyEvent;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080072import android.view.Menu;
Jeff Sharkeyd9798ae2009-08-24 20:46:23 -070073import android.view.MenuInflater;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080074import android.view.MenuItem;
75import android.view.View;
Dmitri Plotnikov4af3b072010-07-01 18:40:51 -070076import android.view.Window;
Katherine Kuanb5760b92011-06-01 16:19:40 -070077import android.widget.SearchView;
Dmitri Plotnikov424440b2010-07-01 14:48:44 -070078import android.widget.Toast;
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080079
Dmitri Plotnikovcaf0bc72010-09-03 15:16:21 -070080import java.util.ArrayList;
81
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080082/**
Daniel Lehmannbd772a52010-07-14 11:22:13 -070083 * Displays a list to browse contacts. For xlarge screens, this also displays a detail-pane on
Dmitri Plotnikova3f0bce2011-01-13 11:46:16 -080084 * the right.
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080085 */
Katherine Kuan9856fce2011-06-01 10:24:09 -070086public class PeopleActivity extends ContactsActivity
Dmitri Plotnikovfcfdffb2010-07-15 18:00:55 -070087 implements View.OnCreateContextMenuListener, ActionBarAdapter.Listener,
Dmitri Plotnikov6e850a02010-10-28 10:46:21 -070088 DialogManager.DialogShowingViewActivity,
Dmitri Plotnikov8b826462010-11-17 14:52:24 -080089 ContactListFilterController.ContactListFilterListener, ProviderStatusListener {
Dmitri Plotnikov57d27da2009-09-28 18:06:11 -070090
Dave Santoro5e684a42011-06-10 13:23:35 -070091 private static final String TAG = "PeopleActivity";
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -080092
Daniel Lehmann22fb2052010-07-27 19:59:21 -070093 private static final int SUBACTIVITY_NEW_CONTACT = 2;
Daniel Lehmannc1506272011-05-13 13:21:15 -070094 private static final int SUBACTIVITY_EDIT_CONTACT = 3;
95 private static final int SUBACTIVITY_CUSTOMIZE_FILTER = 4;
Dmitri Plotnikov3c69e212010-09-27 11:43:39 -070096
Dmitri Plotnikov15ccbb42010-10-05 17:29:07 -070097 private static final String KEY_SEARCH_MODE = "searchMode";
98
Daniel Lehmann3b7d5942010-07-22 18:10:50 -070099 private DialogManager mDialogManager = new DialogManager(this);
Daniel Lehmann3391dbe2010-07-12 09:50:22 -0700100
Dmitri Plotnikovac0f7832010-04-22 13:26:52 -0700101 private ContactsIntentResolver mIntentResolver;
Dmitri Plotnikovfcfdffb2010-07-15 18:00:55 -0700102 private ContactsRequest mRequest;
103
Dmitri Plotnikovfcfdffb2010-07-15 18:00:55 -0700104 private ActionBarAdapter mActionBarAdapter;
105
Dmitri Plotnikov15ccbb42010-10-05 17:29:07 -0700106 private boolean mSearchMode;
Dmitri Plotnikovfcfdffb2010-07-15 18:00:55 -0700107
Dmitri Plotnikov08e1c4e2010-07-02 17:57:51 -0700108 private ContactBrowseListFragment mListFragment;
Dave Santoro0dfbe032011-04-15 13:52:52 -0700109
110 /**
Katherine Kuanbe18de02011-06-07 12:38:29 -0700111 * Whether we have a right-side contact or group detail pane for displaying info on that
112 * contact or group while browsing. Generally means "this is a tablet".
Dave Santoro0dfbe032011-04-15 13:52:52 -0700113 */
Katherine Kuanbe18de02011-06-07 12:38:29 -0700114 private boolean mContentPaneDisplayed;
Dave Santoro0dfbe032011-04-15 13:52:52 -0700115
Katherine Kuanbe18de02011-06-07 12:38:29 -0700116 private ContactDetailFragment mContactDetailFragment;
117 private ContactDetailFragmentListener mContactDetailFragmentListener =
118 new ContactDetailFragmentListener();
119
120 private GroupDetailFragment mGroupDetailFragment;
Dmitri Plotnikov424440b2010-07-01 14:48:44 -0700121
Dmitri Plotnikovfcfdffb2010-07-15 18:00:55 -0700122 private PhoneNumberInteraction mPhoneNumberCallInteraction;
123 private PhoneNumberInteraction mSendTextMessageInteraction;
Dmitri Plotnikovfcfdffb2010-07-15 18:00:55 -0700124
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700125 private boolean mSearchInitiated;
126
Dmitri Plotnikov15ccbb42010-10-05 17:29:07 -0700127 private ContactListFilterController mContactListFilterController;
Dmitri Plotnikov3c69e212010-09-27 11:43:39 -0700128
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800129 private ContactsUnavailableFragment mContactsUnavailableFragment;
130 private ProviderStatusLoader mProviderStatusLoader;
131 private int mProviderStatus = -1;
132
Dmitri Plotnikov0cd01302010-12-17 18:41:57 -0800133 private boolean mOptionsMenuContactsAvailable;
Dmitri Plotnikov0cd01302010-12-17 18:41:57 -0800134
Katherine Kuanb5760b92011-06-01 16:19:40 -0700135 private DefaultContactBrowseListFragment mContactsFragment;
136 private StrequentContactListFragment mFavoritesFragment;
137 private GroupBrowseListFragment mGroupsFragment;
138
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700139 private enum TabState {
140 FAVORITES, CONTACTS, GROUPS
141 }
142
143 private TabState mSelectedTab;
144
Katherine Kuan9856fce2011-06-01 10:24:09 -0700145 public PeopleActivity() {
Dmitri Plotnikov15406742010-05-07 09:22:49 -0700146 mIntentResolver = new ContactsIntentResolver(this);
Katherine Kuanb5760b92011-06-01 16:19:40 -0700147 // TODO: Get rid of the ContactListFilterController class because there aren't any
148 // dropdown filters anymore. Just store the selected filter as a member variable.
Dmitri Plotnikov15ccbb42010-10-05 17:29:07 -0700149 mContactListFilterController = new ContactListFilterController(this);
Dmitri Plotnikov6e850a02010-10-28 10:46:21 -0700150 mContactListFilterController.addListener(this);
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800151 mProviderStatusLoader = new ProviderStatusLoader(this);
Dmitri Plotnikov6178cb42010-04-20 11:26:05 -0700152 }
153
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800154 public boolean areContactsAvailable() {
155 return mProviderStatus == ProviderStatus.STATUS_NORMAL;
156 }
157
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800158 @Override
Dmitri Plotnikov92a6fdf2010-07-09 13:19:33 -0700159 public void onAttachFragment(Fragment fragment) {
160 if (fragment instanceof ContactBrowseListFragment) {
161 mListFragment = (ContactBrowseListFragment)fragment;
162 mListFragment.setOnContactListActionListener(new ContactBrowserActionListener());
Dmitri Plotnikova3f0bce2011-01-13 11:46:16 -0800163 if (!getWindow().hasFeature(Window.FEATURE_ACTION_BAR)) {
Dmitri Plotnikovfa49a662011-01-13 11:04:56 -0800164 mListFragment.setContextMenuAdapter(
165 new ContactBrowseListContextMenuAdapter(mListFragment));
Dmitri Plotnikov8daa1792010-12-20 17:50:57 -0800166 }
Katherine Kuanbe18de02011-06-07 12:38:29 -0700167 } else if (fragment instanceof GroupBrowseListFragment) {
168 mGroupsFragment = (GroupBrowseListFragment) fragment;
169 mGroupsFragment.setListener(new GroupBrowserActionListener());
Dmitri Plotnikovd3643142010-07-09 13:49:07 -0700170 } else if (fragment instanceof ContactDetailFragment) {
Katherine Kuanbe18de02011-06-07 12:38:29 -0700171 mContactDetailFragment = (ContactDetailFragment) fragment;
172 mContactDetailFragment.setListener(mContactDetailFragmentListener);
173 mContentPaneDisplayed = true;
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800174 } else if (fragment instanceof ContactsUnavailableFragment) {
175 mContactsUnavailableFragment = (ContactsUnavailableFragment)fragment;
176 mContactsUnavailableFragment.setProviderStatusLoader(mProviderStatusLoader);
177 mContactsUnavailableFragment.setOnContactsUnavailableActionListener(
178 new ContactsUnavailableFragmentListener());
Katherine Kuanbe18de02011-06-07 12:38:29 -0700179 } else if (fragment instanceof GroupDetailFragment) {
180 mGroupDetailFragment = (GroupDetailFragment) fragment;
181 mContentPaneDisplayed = true;
Dmitri Plotnikov92a6fdf2010-07-09 13:19:33 -0700182 }
183 }
184
185 @Override
Dmitri Plotnikov08e1c4e2010-07-02 17:57:51 -0700186 protected void onCreate(Bundle savedState) {
187 super.onCreate(savedState);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800188
Dmitri Plotnikovfa49a662011-01-13 11:04:56 -0800189 configureContentView(true, savedState);
190 }
191
192 @Override
193 protected void onNewIntent(Intent intent) {
194 setIntent(intent);
195 configureContentView(false, null);
196 }
197
198 private void configureContentView(boolean createContentView, Bundle savedState) {
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700199 // Extract relevant information from the intent
200 mRequest = mIntentResolver.resolveIntent(getIntent());
201 if (!mRequest.isValid()) {
202 setResult(RESULT_CANCELED);
203 finish();
Dmitri Plotnikov59fb48e2010-04-26 17:09:19 -0700204 return;
205 }
206
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700207 Intent redirect = mRequest.getRedirectIntent();
208 if (redirect != null) {
209 // Need to start a different activity
210 startActivity(redirect);
211 finish();
212 return;
213 }
214
Dmitri Plotnikovfa49a662011-01-13 11:04:56 -0800215 if (createContentView) {
Katherine Kuan9856fce2011-06-01 10:24:09 -0700216 setContentView(R.layout.people_activity);
Katherine Kuanb5760b92011-06-01 16:19:40 -0700217
218 final FragmentManager fragmentManager = getFragmentManager();
219 mFavoritesFragment = (StrequentContactListFragment) fragmentManager
220 .findFragmentById(R.id.favorites_fragment);
221 mContactsFragment = (DefaultContactBrowseListFragment) fragmentManager
222 .findFragmentById(R.id.contacts_fragment);
223 mGroupsFragment = (GroupBrowseListFragment) fragmentManager
224 .findFragmentById(R.id.groups_fragment);
225
226 // Hide all tabs (the current tab will later be reshown once a tab is selected)
227 final FragmentTransaction transaction = fragmentManager.beginTransaction();
228 transaction.hide(mFavoritesFragment);
229 transaction.hide(mContactsFragment);
230 transaction.hide(mGroupsFragment);
Katherine Kuanbe18de02011-06-07 12:38:29 -0700231 if (mContactDetailFragment != null) {
232 transaction.hide(mContactDetailFragment);
233 }
234 if (mGroupDetailFragment != null) {
235 transaction.hide(mGroupDetailFragment);
236 }
Katherine Kuanb5760b92011-06-01 16:19:40 -0700237 transaction.commit();
Dmitri Plotnikovfa49a662011-01-13 11:04:56 -0800238 }
Dmitri Plotnikov65ad5ee2010-07-15 18:09:21 -0700239
Dmitri Plotnikov90715b32010-11-23 10:57:23 -0800240 if (mRequest.getActionCode() == ContactsRequest.ACTION_VIEW_CONTACT
Katherine Kuanbe18de02011-06-07 12:38:29 -0700241 && !mContentPaneDisplayed) {
Dmitri Plotnikov90715b32010-11-23 10:57:23 -0800242 redirect = new Intent(this, ContactDetailActivity.class);
243 redirect.setAction(Intent.ACTION_VIEW);
244 redirect.setData(mRequest.getContactUri());
245 startActivity(redirect);
246 finish();
247 return;
Dmitri Plotnikov27b97bc2010-10-07 18:06:09 -0700248 }
249
Dmitri Plotnikov90715b32010-11-23 10:57:23 -0800250 setTitle(mRequest.getActivityTitle());
Katherine Kuanb5760b92011-06-01 16:19:40 -0700251 ActionBar actionBar = getActionBar();
Katherine Kuan1ee9df62011-06-11 16:54:01 -0700252 mActionBarAdapter = new ActionBarAdapter(this, this);
253 mActionBarAdapter.onCreate(savedState, mRequest, getActionBar(), !mContentPaneDisplayed);
Katherine Kuanb5760b92011-06-01 16:19:40 -0700254 mActionBarAdapter.setContactListFilterController(mContactListFilterController);
Dmitri Plotnikovfa49a662011-01-13 11:04:56 -0800255
Daniel Lehmann3bf12642011-04-15 19:57:30 -0700256 if (createContentView) {
Katherine Kuanb5760b92011-06-01 16:19:40 -0700257 actionBar.removeAllTabs();
258 Tab favoritesTab = actionBar.newTab();
259 favoritesTab.setText(getString(R.string.strequentList));
Katherine Kuanbe18de02011-06-07 12:38:29 -0700260 favoritesTab.setTabListener(new TabChangeListener(mFavoritesFragment,
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700261 mContactDetailFragment, TabState.FAVORITES));
Katherine Kuanb5760b92011-06-01 16:19:40 -0700262 actionBar.addTab(favoritesTab);
Dmitri Plotnikov3d48a462010-12-09 15:55:27 -0800263
Katherine Kuanb5760b92011-06-01 16:19:40 -0700264 Tab peopleTab = actionBar.newTab();
265 peopleTab.setText(getString(R.string.people));
Katherine Kuanbe18de02011-06-07 12:38:29 -0700266 peopleTab.setTabListener(new TabChangeListener(mContactsFragment,
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700267 mContactDetailFragment, TabState.CONTACTS));
Katherine Kuanb5760b92011-06-01 16:19:40 -0700268 actionBar.addTab(peopleTab);
269
270 Tab groupsTab = actionBar.newTab();
271 groupsTab.setText(getString(R.string.contactsGroupsLabel));
Katherine Kuanbe18de02011-06-07 12:38:29 -0700272 groupsTab.setTabListener(new TabChangeListener(mGroupsFragment,
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700273 mGroupDetailFragment, TabState.GROUPS));
Katherine Kuanb5760b92011-06-01 16:19:40 -0700274 actionBar.addTab(groupsTab);
275 actionBar.setDisplayShowTitleEnabled(true);
276
277 TypedArray a = obtainStyledAttributes(null, R.styleable.ActionBarHomeIcon);
278 boolean showHomeIcon = a.getBoolean(R.styleable.ActionBarHomeIcon_show_home_icon, true);
279 actionBar.setDisplayShowHomeEnabled(showHomeIcon);
280
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700281 invalidateOptionsMenuIfNeeded();
Dmitri Plotnikovfe42e552010-05-14 14:50:32 -0700282 }
Dmitri Plotnikov424440b2010-07-01 14:48:44 -0700283
Dmitri Plotnikovfa49a662011-01-13 11:04:56 -0800284 configureFragments(savedState == null);
Dmitri Plotnikovcaf0bc72010-09-03 15:16:21 -0700285 }
286
Katherine Kuanb5760b92011-06-01 16:19:40 -0700287 /**
288 * Tab change listener that is instantiated once for each tab. Handles showing/hiding fragments.
289 * TODO: Use ViewPager so that tabs can be swiped left and right. Figure out how to use the
290 * support library in our app.
291 */
292 private class TabChangeListener implements TabListener {
Katherine Kuanbe18de02011-06-07 12:38:29 -0700293 private final Fragment mBrowseListFragment;
Katherine Kuanb5760b92011-06-01 16:19:40 -0700294
Katherine Kuanbe18de02011-06-07 12:38:29 -0700295 /**
296 * Right pane fragment that is present on larger screen sizes (can be
297 * null for smaller screen sizes).
298 */
299 private final Fragment mDetailFragment;
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700300 private final TabState mTabState;
Katherine Kuanbe18de02011-06-07 12:38:29 -0700301
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700302 public TabChangeListener(Fragment listFragment, Fragment detailFragment, TabState state) {
Katherine Kuanbe18de02011-06-07 12:38:29 -0700303 mBrowseListFragment = listFragment;
304 mDetailFragment = detailFragment;
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700305 mTabState = state;
Katherine Kuanb5760b92011-06-01 16:19:40 -0700306 }
307
308 @Override
309 public void onTabUnselected(Tab tab, FragmentTransaction ft) {
Katherine Kuanbe18de02011-06-07 12:38:29 -0700310 ft.hide(mBrowseListFragment);
311 if (mDetailFragment != null) {
312 ft.hide(mDetailFragment);
313 }
Katherine Kuanb5760b92011-06-01 16:19:40 -0700314 }
315
316 @Override
317 public void onTabSelected(Tab tab, FragmentTransaction ft) {
Katherine Kuanbe18de02011-06-07 12:38:29 -0700318 ft.show(mBrowseListFragment);
319 if (mDetailFragment != null) {
320 ft.show(mDetailFragment);
321 }
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700322 setSelectedTab(mTabState);
323 invalidateOptionsMenu();
Katherine Kuanb5760b92011-06-01 16:19:40 -0700324 }
325
326 @Override
327 public void onTabReselected(Tab tab, FragmentTransaction ft) {
328 }
329 }
330
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700331 private void setSelectedTab(TabState tab) {
332 mSelectedTab = tab;
333 }
334
Dmitri Plotnikov6e850a02010-10-28 10:46:21 -0700335 @Override
Dmitri Plotnikov174fdc22010-10-29 13:55:01 -0700336 protected void onPause() {
337 if (mActionBarAdapter != null) {
338 mActionBarAdapter.setListener(null);
339 }
Dmitri Plotnikovfa49a662011-01-13 11:04:56 -0800340
341 mOptionsMenuContactsAvailable = false;
Dmitri Plotnikovfa49a662011-01-13 11:04:56 -0800342
343 mProviderStatus = -1;
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800344 mProviderStatusLoader.setProviderStatusListener(null);
Dmitri Plotnikov174fdc22010-10-29 13:55:01 -0700345 super.onPause();
346 }
347
348 @Override
349 protected void onResume() {
350 super.onResume();
351 if (mActionBarAdapter != null) {
352 mActionBarAdapter.setListener(this);
353 }
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800354 mProviderStatusLoader.setProviderStatusListener(this);
355 updateFragmentVisibility();
Dmitri Plotnikov174fdc22010-10-29 13:55:01 -0700356 }
357
358 @Override
Dmitri Plotnikov6e850a02010-10-28 10:46:21 -0700359 protected void onStart() {
Dmitri Plotnikove4e52192010-12-14 11:17:13 -0800360 mContactListFilterController.onStart();
Dmitri Plotnikov6e850a02010-10-28 10:46:21 -0700361 super.onStart();
Dmitri Plotnikov3c69e212010-09-27 11:43:39 -0700362 }
363
Dmitri Plotnikov955846e2010-11-11 22:31:28 -0800364 private void configureFragments(boolean fromRequest) {
Dmitri Plotnikov009676f2010-10-08 12:13:57 -0700365 if (fromRequest) {
Dmitri Plotnikov91ab5b42010-10-08 15:26:31 -0700366 ContactListFilter filter = null;
367 int actionCode = mRequest.getActionCode();
368 switch (actionCode) {
369 case ContactsRequest.ACTION_ALL_CONTACTS:
Katherine Kuanbe18de02011-06-07 12:38:29 -0700370 filter = ContactListFilter.createFilterWithType(
371 ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS);
Dmitri Plotnikov91ab5b42010-10-08 15:26:31 -0700372 break;
373 case ContactsRequest.ACTION_CONTACTS_WITH_PHONES:
Katherine Kuanbe18de02011-06-07 12:38:29 -0700374 filter = ContactListFilter.createFilterWithType(
Dmitri Plotnikov91ab5b42010-10-08 15:26:31 -0700375 ContactListFilter.FILTER_TYPE_WITH_PHONE_NUMBERS_ONLY);
376 break;
377
378 // TODO: handle FREQUENT and STREQUENT according to the spec
379 case ContactsRequest.ACTION_FREQUENT:
380 case ContactsRequest.ACTION_STREQUENT:
381 // For now they are treated the same as STARRED
382 case ContactsRequest.ACTION_STARRED:
Katherine Kuanbe18de02011-06-07 12:38:29 -0700383 filter = ContactListFilter.createFilterWithType(
384 ContactListFilter.FILTER_TYPE_STARRED);
Dmitri Plotnikov91ab5b42010-10-08 15:26:31 -0700385 break;
386 }
387
Dmitri Plotnikov0edd4072011-01-19 10:10:10 -0800388 mSearchMode = mRequest.isSearchMode();
Dmitri Plotnikov91ab5b42010-10-08 15:26:31 -0700389 if (filter != null) {
390 mContactListFilterController.setContactListFilter(filter, false);
Dmitri Plotnikovfa49a662011-01-13 11:04:56 -0800391 mSearchMode = false;
Dmitri Plotnikov48cc2502010-10-08 14:56:04 -0700392 } else if (mRequest.getActionCode() == ContactsRequest.ACTION_ALL_CONTACTS) {
Katherine Kuanbe18de02011-06-07 12:38:29 -0700393 mContactListFilterController.setContactListFilter(
394 ContactListFilter.createFilterWithType(
Dmitri Plotnikov48cc2502010-10-08 14:56:04 -0700395 ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS), false);
Dmitri Plotnikov009676f2010-10-08 12:13:57 -0700396 }
Dmitri Plotnikovd9591042010-11-23 09:25:03 -0800397
398 if (mRequest.getContactUri() != null) {
Dmitri Plotnikovfa49a662011-01-13 11:04:56 -0800399 mSearchMode = false;
Dmitri Plotnikovd9591042010-11-23 09:25:03 -0800400 }
401
Dmitri Plotnikova3f0bce2011-01-13 11:46:16 -0800402 mListFragment.setContactsRequest(mRequest);
Katherine Kuan0ff0e312011-06-08 17:43:51 -0700403 configureContactListFragmentForRequest();
Dmitri Plotnikova3f0bce2011-01-13 11:46:16 -0800404
Katherine Kuanb5760b92011-06-01 16:19:40 -0700405 } else {
Dmitri Plotnikovfa49a662011-01-13 11:04:56 -0800406 mSearchMode = mActionBarAdapter.isSearchMode();
Dmitri Plotnikov08e1c4e2010-07-02 17:57:51 -0700407 }
408
Katherine Kuan0ff0e312011-06-08 17:43:51 -0700409 configureContactListFragment();
410 configureGroupListFragment();
Dmitri Plotnikovfa49a662011-01-13 11:04:56 -0800411
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700412 invalidateOptionsMenuIfNeeded();
Dmitri Plotnikov92a6fdf2010-07-09 13:19:33 -0700413 }
414
Dmitri Plotnikov6e850a02010-10-28 10:46:21 -0700415 @Override
416 public void onContactListFiltersLoaded() {
Dmitri Plotnikov8daa1792010-12-20 17:50:57 -0800417 if (mListFragment == null || !mListFragment.isAdded()) {
Dmitri Plotnikovd9591042010-11-23 09:25:03 -0800418 return;
419 }
420
421 mListFragment.setFilter(mContactListFilterController.getFilter());
Dmitri Plotnikov6e850a02010-10-28 10:46:21 -0700422
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700423 invalidateOptionsMenuIfNeeded();
Dmitri Plotnikov6e850a02010-10-28 10:46:21 -0700424 }
425
426 @Override
427 public void onContactListFilterChanged() {
Dmitri Plotnikov8daa1792010-12-20 17:50:57 -0800428 if (mListFragment == null || !mListFragment.isAdded()) {
Dmitri Plotnikov955846e2010-11-11 22:31:28 -0800429 return;
430 }
431
Dmitri Plotnikovd9591042010-11-23 09:25:03 -0800432 mListFragment.setFilter(mContactListFilterController.getFilter());
Dmitri Plotnikove898a9f2010-11-18 16:58:25 -0800433
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700434 invalidateOptionsMenuIfNeeded();
Dmitri Plotnikov6e850a02010-10-28 10:46:21 -0700435 }
436
Dmitri Plotnikov6e850a02010-10-28 10:46:21 -0700437 @Override
438 public void onContactListFilterCustomizationRequest() {
439 startActivityForResult(new Intent(this, CustomContactListFilterActivity.class),
440 SUBACTIVITY_CUSTOMIZE_FILTER);
441 }
442
Dmitri Plotnikova6c21982010-10-27 10:21:16 -0700443 private void setupContactDetailFragment(final Uri contactLookupUri) {
Katherine Kuanbe18de02011-06-07 12:38:29 -0700444 mContactDetailFragment.loadUri(contactLookupUri);
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700445 invalidateOptionsMenuIfNeeded();
Katherine Kuanbe18de02011-06-07 12:38:29 -0700446 }
447
448 private void setupGroupDetailFragment(Uri groupUri) {
449 mGroupDetailFragment.loadGroup(groupUri);
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700450 invalidateOptionsMenuIfNeeded();
Dmitri Plotnikovc0ca13a2010-07-08 14:25:37 -0700451 }
452
Dmitri Plotnikovfcfdffb2010-07-15 18:00:55 -0700453 /**
454 * Handler for action bar actions.
455 */
Dmitri Plotnikovfe42e552010-05-14 14:50:32 -0700456 @Override
Katherine Kuanb5760b92011-06-01 16:19:40 -0700457 public void onAction(Action action) {
458 switch (action) {
459 case START_SEARCH_MODE:
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700460 // Bring the contact list fragment (and detail fragment if applicable) to the front
Katherine Kuanb5760b92011-06-01 16:19:40 -0700461 FragmentTransaction ft = getFragmentManager().beginTransaction();
462 ft.show(mContactsFragment);
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700463 if (mContactDetailFragment != null) ft.show(mContactDetailFragment);
Katherine Kuanb5760b92011-06-01 16:19:40 -0700464 ft.commit();
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700465 clearSearch();
Katherine Kuanb5760b92011-06-01 16:19:40 -0700466 break;
467 case STOP_SEARCH_MODE:
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700468 // Refresh the fragments because search mode was using them to display search
469 // results.
470 clearSearch();
471
472 // If the last selected tab was not the "All contacts" tab, then hide these
473 // fragments because we need to show favorites or groups.
474 if (mSelectedTab != null && !mSelectedTab.equals(TabState.CONTACTS)) {
475 FragmentTransaction transaction = getFragmentManager().beginTransaction();
476 transaction.hide(mContactsFragment);
477 if (mContactDetailFragment != null) transaction.hide(mContactDetailFragment);
478 transaction.commit();
479 }
480 break;
Katherine Kuanb5760b92011-06-01 16:19:40 -0700481 case CHANGE_SEARCH_QUERY:
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700482 loadSearch(mActionBarAdapter.getQueryString());
Katherine Kuanb5760b92011-06-01 16:19:40 -0700483 break;
484 default:
485 throw new IllegalStateException("Unkonwn ActionBarAdapter action: " + action);
486 }
Dmitri Plotnikovfe42e552010-05-14 14:50:32 -0700487 }
488
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700489 private void clearSearch() {
490 loadSearch("");
491 }
492
493 private void loadSearch(String query) {
494 configureFragments(false /* from request */);
495 mListFragment.setQueryString(query, true);
496 }
497
Katherine Kuan0ff0e312011-06-08 17:43:51 -0700498 private void configureContactListFragmentForRequest() {
Dmitri Plotnikovfa49a662011-01-13 11:04:56 -0800499 Uri contactUri = mRequest.getContactUri();
500 if (contactUri != null) {
501 mListFragment.setSelectedContactUri(contactUri);
502 }
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700503
Dmitri Plotnikov0edd4072011-01-19 10:10:10 -0800504 mListFragment.setSearchMode(mRequest.isSearchMode());
Dmitri Plotnikov52518842011-01-19 10:39:58 -0800505 mListFragment.setQueryString(mRequest.getQueryString(), false);
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700506
Dmitri Plotnikovfa49a662011-01-13 11:04:56 -0800507 if (mRequest.isDirectorySearchEnabled()) {
508 mListFragment.setDirectorySearchMode(DirectoryListLoader.SEARCH_MODE_DEFAULT);
509 } else {
510 mListFragment.setDirectorySearchMode(DirectoryListLoader.SEARCH_MODE_NONE);
511 }
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700512
Dmitri Plotnikovfa49a662011-01-13 11:04:56 -0800513 if (mContactListFilterController.isLoaded()) {
514 mListFragment.setFilter(mContactListFilterController.getFilter());
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700515 }
Dmitri Plotnikov08e1c4e2010-07-02 17:57:51 -0700516 }
517
Katherine Kuan0ff0e312011-06-08 17:43:51 -0700518 private void configureContactListFragment() {
Dmitri Plotnikovfa49a662011-01-13 11:04:56 -0800519 mListFragment.setSearchMode(mSearchMode);
520
521 mListFragment.setVisibleScrollbarEnabled(!mSearchMode);
522 mListFragment.setVerticalScrollbarPosition(
Katherine Kuanbe18de02011-06-07 12:38:29 -0700523 mContentPaneDisplayed
Dmitri Plotnikov5245ea62010-12-10 15:03:13 -0800524 ? View.SCROLLBAR_POSITION_LEFT
525 : View.SCROLLBAR_POSITION_RIGHT);
Katherine Kuanbe18de02011-06-07 12:38:29 -0700526 mListFragment.setSelectionVisible(mContentPaneDisplayed);
527 mListFragment.setQuickContactEnabled(!mContentPaneDisplayed);
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700528 }
529
Katherine Kuan0ff0e312011-06-08 17:43:51 -0700530 private void configureGroupListFragment() {
531 mGroupsFragment.setVerticalScrollbarPosition(
532 mContentPaneDisplayed
533 ? View.SCROLLBAR_POSITION_LEFT
534 : View.SCROLLBAR_POSITION_RIGHT);
535 mGroupsFragment.setSelectionVisible(mContentPaneDisplayed);
536 }
537
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800538 @Override
539 public void onProviderStatusChange() {
540 updateFragmentVisibility();
541 }
542
543 private void updateFragmentVisibility() {
544 int providerStatus = mProviderStatusLoader.getProviderStatus();
545 if (providerStatus == mProviderStatus) {
546 return;
547 }
548
549 mProviderStatus = providerStatus;
550
551 View contactsUnavailableView = findViewById(R.id.contacts_unavailable_view);
552 View mainView = findViewById(R.id.main_view);
553
554 if (mProviderStatus == ProviderStatus.STATUS_NORMAL) {
Dmitri Plotnikovc3f2a522010-11-17 18:36:17 -0800555 contactsUnavailableView.setVisibility(View.GONE);
Katherine Kuanb5760b92011-06-01 16:19:40 -0700556 if (mainView != null) {
557 mainView.setVisibility(View.VISIBLE);
558 }
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800559 if (mListFragment != null) {
560 mListFragment.setEnabled(true);
561 }
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800562 } else {
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800563 if (mListFragment != null) {
564 mListFragment.setEnabled(false);
565 }
566 if (mContactsUnavailableFragment == null) {
567 mContactsUnavailableFragment = new ContactsUnavailableFragment();
568 mContactsUnavailableFragment.setProviderStatusLoader(mProviderStatusLoader);
569 mContactsUnavailableFragment.setOnContactsUnavailableActionListener(
570 new ContactsUnavailableFragmentListener());
Dianne Hackborn3ed426c2011-01-17 12:30:32 -0800571 getFragmentManager().beginTransaction()
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800572 .replace(R.id.contacts_unavailable_container, mContactsUnavailableFragment)
573 .commit();
574 } else {
575 mContactsUnavailableFragment.update();
576 }
577 contactsUnavailableView.setVisibility(View.VISIBLE);
Katherine Kuanb5760b92011-06-01 16:19:40 -0700578 if (mainView != null) {
579 mainView.setVisibility(View.INVISIBLE);
580 }
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800581 }
582
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700583 invalidateOptionsMenuIfNeeded();
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800584 }
585
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700586 private final class ContactBrowserActionListener implements OnContactBrowserActionListener {
Dmitri Plotnikovd9591042010-11-23 09:25:03 -0800587
588 @Override
589 public void onSelectionChange() {
Katherine Kuanbe18de02011-06-07 12:38:29 -0700590 if (mContentPaneDisplayed) {
Dmitri Plotnikovd9591042010-11-23 09:25:03 -0800591 setupContactDetailFragment(mListFragment.getSelectedContactUri());
592 }
593 }
594
Daniel Lehmanne20d3432010-10-10 18:37:51 -0700595 @Override
596 public void onViewContactAction(Uri contactLookupUri) {
Katherine Kuanbe18de02011-06-07 12:38:29 -0700597 if (mContentPaneDisplayed) {
Dmitri Plotnikovd3643142010-07-09 13:49:07 -0700598 setupContactDetailFragment(contactLookupUri);
Dmitri Plotnikov424440b2010-07-01 14:48:44 -0700599 } else {
600 startActivity(new Intent(Intent.ACTION_VIEW, contactLookupUri));
601 }
Dmitri Plotnikov26cda1a2010-04-08 17:21:36 -0700602 }
Dmitri Plotnikov59fb48e2010-04-26 17:09:19 -0700603
Daniel Lehmanne20d3432010-10-10 18:37:51 -0700604 @Override
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700605 public void onCreateNewContactAction() {
606 Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
607 Bundle extras = getIntent().getExtras();
608 if (extras != null) {
609 intent.putExtras(extras);
610 }
611 startActivity(intent);
612 }
613
Daniel Lehmanne20d3432010-10-10 18:37:51 -0700614 @Override
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700615 public void onEditContactAction(Uri contactLookupUri) {
Daniel Lehmanne20d3432010-10-10 18:37:51 -0700616 Intent intent = new Intent(Intent.ACTION_EDIT, contactLookupUri);
617 Bundle extras = getIntent().getExtras();
618 if (extras != null) {
619 intent.putExtras(extras);
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700620 }
Daniel Lehmanne20d3432010-10-10 18:37:51 -0700621 startActivityForResult(intent, SUBACTIVITY_EDIT_CONTACT);
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700622 }
623
Daniel Lehmanne20d3432010-10-10 18:37:51 -0700624 @Override
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700625 public void onAddToFavoritesAction(Uri contactUri) {
626 ContentValues values = new ContentValues(1);
627 values.put(Contacts.STARRED, 1);
628 getContentResolver().update(contactUri, values, null, null);
629 }
630
Daniel Lehmanne20d3432010-10-10 18:37:51 -0700631 @Override
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700632 public void onRemoveFromFavoritesAction(Uri contactUri) {
633 ContentValues values = new ContentValues(1);
634 values.put(Contacts.STARRED, 0);
635 getContentResolver().update(contactUri, values, null, null);
636 }
637
Daniel Lehmanne20d3432010-10-10 18:37:51 -0700638 @Override
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700639 public void onCallContactAction(Uri contactUri) {
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -0700640 getPhoneNumberCallInteraction().startInteraction(contactUri);
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700641 }
642
Daniel Lehmanne20d3432010-10-10 18:37:51 -0700643 @Override
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700644 public void onSmsContactAction(Uri contactUri) {
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -0700645 getSendTextMessageInteraction().startInteraction(contactUri);
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700646 }
647
Daniel Lehmanne20d3432010-10-10 18:37:51 -0700648 @Override
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700649 public void onDeleteContactAction(Uri contactUri) {
Katherine Kuan9856fce2011-06-01 10:24:09 -0700650 ContactDeletionInteraction.start(PeopleActivity.this, contactUri, false);
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700651 }
652
Daniel Lehmanne20d3432010-10-10 18:37:51 -0700653 @Override
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700654 public void onFinishAction() {
655 onBackPressed();
656 }
Dmitri Plotnikov6e850a02010-10-28 10:46:21 -0700657
658 @Override
659 public void onInvalidSelection() {
Dmitri Plotnikov8fe78212011-01-16 17:58:42 -0800660 ContactListFilter filter;
661 ContactListFilter currentFilter = mListFragment.getFilter();
662 if (currentFilter != null
663 && currentFilter.filterType == ContactListFilter.FILTER_TYPE_SINGLE_CONTACT) {
Katherine Kuanbe18de02011-06-07 12:38:29 -0700664 filter = ContactListFilter.createFilterWithType(
665 ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS);
Dmitri Plotnikov8fe78212011-01-16 17:58:42 -0800666 mListFragment.setFilter(filter);
667 } else {
Katherine Kuanbe18de02011-06-07 12:38:29 -0700668 filter = ContactListFilter.createFilterWithType(
669 ContactListFilter.FILTER_TYPE_SINGLE_CONTACT);
Dmitri Plotnikov8fe78212011-01-16 17:58:42 -0800670 mListFragment.setFilter(filter, false);
671 }
Dmitri Plotnikovd9591042010-11-23 09:25:03 -0800672 mContactListFilterController.setContactListFilter(filter, true);
Dmitri Plotnikov6e850a02010-10-28 10:46:21 -0700673 }
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700674 }
675
Katherine Kuanbe18de02011-06-07 12:38:29 -0700676 private class ContactDetailFragmentListener implements ContactDetailFragment.Listener {
Daniel Lehmann69e7fec2010-07-20 14:14:56 -0700677 @Override
Dmitri Plotnikov424440b2010-07-01 14:48:44 -0700678 public void onContactNotFound() {
Dmitri Plotnikovd9591042010-11-23 09:25:03 -0800679 // Nothing needs to be done here
Dmitri Plotnikov424440b2010-07-01 14:48:44 -0700680 }
681
Daniel Lehmann69e7fec2010-07-20 14:14:56 -0700682 @Override
Katherine Kuan79700882011-06-14 17:40:33 -0700683 public void onDetailsLoaded(ContactLoader.Result result) {
684 // Nothing needs to be done here
685 }
686
687 @Override
Dmitri Plotnikov424440b2010-07-01 14:48:44 -0700688 public void onEditRequested(Uri contactLookupUri) {
Dmitri Plotnikov8c6955f2010-09-08 20:46:36 -0700689 startActivityForResult(
690 new Intent(Intent.ACTION_EDIT, contactLookupUri), SUBACTIVITY_EDIT_CONTACT);
Dmitri Plotnikov424440b2010-07-01 14:48:44 -0700691 }
692
Daniel Lehmann69e7fec2010-07-20 14:14:56 -0700693 @Override
Dmitri Plotnikov424440b2010-07-01 14:48:44 -0700694 public void onItemClicked(Intent intent) {
Daniel Lehmann60be1a12010-08-05 18:37:21 -0700695 try {
696 startActivity(intent);
697 } catch (ActivityNotFoundException e) {
698 Log.e(TAG, "No activity found for intent: " + intent);
699 }
Dmitri Plotnikov424440b2010-07-01 14:48:44 -0700700 }
701
Daniel Lehmann69e7fec2010-07-20 14:14:56 -0700702 @Override
Dmitri Plotnikov66bca8f2010-11-24 16:59:24 -0800703 public void onDeleteRequested(Uri contactUri) {
Katherine Kuan9856fce2011-06-01 10:24:09 -0700704 ContactDeletionInteraction.start(PeopleActivity.this, contactUri, false);
Dmitri Plotnikov424440b2010-07-01 14:48:44 -0700705 }
Dmitri Plotnikovcaf0bc72010-09-03 15:16:21 -0700706
707 @Override
708 public void onCreateRawContactRequested(ArrayList<ContentValues> values, Account account) {
Katherine Kuan9856fce2011-06-01 10:24:09 -0700709 Toast.makeText(PeopleActivity.this, R.string.toast_making_personal_copy,
Dmitri Plotnikovcaf0bc72010-09-03 15:16:21 -0700710 Toast.LENGTH_LONG).show();
711 Intent serviceIntent = ContactSaveService.createNewRawContactIntent(
Katherine Kuan9856fce2011-06-01 10:24:09 -0700712 PeopleActivity.this, values, account,
713 PeopleActivity.class, Intent.ACTION_VIEW);
Dmitri Plotnikovcaf0bc72010-09-03 15:16:21 -0700714 startService(serviceIntent);
715 }
Dmitri Plotnikov424440b2010-07-01 14:48:44 -0700716 }
717
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800718 private class ContactsUnavailableFragmentListener
719 implements OnContactsUnavailableActionListener {
720
721 @Override
722 public void onCreateNewContactAction() {
723 startActivity(new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI));
724 }
725
726 @Override
727 public void onAddAccountAction() {
728 Intent intent = new Intent(Settings.ACTION_ADD_ACCOUNT);
Dmitri Plotnikov1fbcbd12011-01-16 18:09:09 -0800729 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800730 intent.putExtra(Settings.EXTRA_AUTHORITIES,
731 new String[] { ContactsContract.AUTHORITY });
732 startActivity(intent);
733 }
734
735 @Override
736 public void onImportContactsFromFileAction() {
Katherine Kuan9856fce2011-06-01 10:24:09 -0700737 AccountSelectionUtil.doImportFromSdCard(PeopleActivity.this, null);
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800738 }
739
740 @Override
741 public void onFreeInternalStorageAction() {
742 startActivity(new Intent(Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS));
743 }
744 }
745
Katherine Kuanbe18de02011-06-07 12:38:29 -0700746 private final class GroupBrowserActionListener implements OnGroupBrowserActionListener {
747
748 @Override
749 public void onViewGroupAction(Uri groupUri) {
750 if (mContentPaneDisplayed) {
751 setupGroupDetailFragment(groupUri);
752 } else {
753 Intent intent = new Intent(PeopleActivity.this, GroupDetailActivity.class);
754 intent.setData(groupUri);
755 startActivity(intent);
756 }
757 }
758 }
759
Dmitri Plotnikov732f6522010-04-27 10:30:59 -0700760 public void startActivityAndForwardResult(final Intent intent) {
761 intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
762
763 // Forward extras to the new activity
764 Bundle extras = getIntent().getExtras();
765 if (extras != null) {
766 intent.putExtras(extras);
767 }
768 startActivity(intent);
769 finish();
770 }
771
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800772 @Override
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800773 public boolean onCreatePanelMenu(int featureId, Menu menu) {
774 // No menu if contacts are unavailable
775 if (!areContactsAvailable()) {
776 return false;
777 }
778
779 return super.onCreatePanelMenu(featureId, menu);
780 }
781
782 @Override
783 public boolean onPreparePanel(int featureId, View view, Menu menu) {
784 // No menu if contacts are unavailable
785 if (!areContactsAvailable()) {
786 return false;
787 }
788
789 return super.onPreparePanel(featureId, view, menu);
790 }
791
792 @Override
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800793 public boolean onCreateOptionsMenu(Menu menu) {
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800794 if (!areContactsAvailable()) {
795 return false;
796 }
Jeff Sharkeyd9798ae2009-08-24 20:46:23 -0700797 super.onCreateOptionsMenu(menu);
798
Dmitri Plotnikovd3758b02010-06-17 11:34:59 -0700799 MenuInflater inflater = getMenuInflater();
Katherine Kuanb5760b92011-06-01 16:19:40 -0700800 inflater.inflate(R.menu.actions, menu);
Katherine Kuanb5760b92011-06-01 16:19:40 -0700801 MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
802 if (searchMenuItem != null && searchMenuItem.getActionView() instanceof SearchView) {
803 SearchView searchView = (SearchView) searchMenuItem.getActionView();
804 searchView.setQueryHint(getString(R.string.hint_findContacts));
805 searchView.setIconifiedByDefault(false);
Daniel Lehmann20130582010-10-21 20:51:15 -0700806
Katherine Kuanb5760b92011-06-01 16:19:40 -0700807 if (mActionBarAdapter != null) {
808 mActionBarAdapter.setSearchView(searchView);
809 }
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800810 }
Katherine Kuanb5760b92011-06-01 16:19:40 -0700811 return true;
Jeff Sharkeyd9798ae2009-08-24 20:46:23 -0700812 }
Jeff Sharkey3f0b7b82009-08-12 11:28:53 -0700813
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700814 private void invalidateOptionsMenuIfNeeded() {
Dmitri Plotnikov0cd01302010-12-17 18:41:57 -0800815 if (isOptionsMenuChanged()) {
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700816 invalidateOptionsMenu();
Dmitri Plotnikov0cd01302010-12-17 18:41:57 -0800817 }
818 }
819
820 public boolean isOptionsMenuChanged() {
821 if (mOptionsMenuContactsAvailable != areContactsAvailable()) {
822 return true;
823 }
824
Dmitri Plotnikov0cd01302010-12-17 18:41:57 -0800825 if (mListFragment != null && mListFragment.isOptionsMenuChanged()) {
826 return true;
827 }
828
Katherine Kuanbe18de02011-06-07 12:38:29 -0700829 if (mContactDetailFragment != null && mContactDetailFragment.isOptionsMenuChanged()) {
Dmitri Plotnikov0cd01302010-12-17 18:41:57 -0800830 return true;
831 }
832
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700833 if (mGroupDetailFragment != null && mGroupDetailFragment.isOptionsMenuChanged()) {
834 return true;
835 }
836
Dmitri Plotnikov0cd01302010-12-17 18:41:57 -0800837 return false;
838 }
839
840 @Override
Jeff Sharkeyd9798ae2009-08-24 20:46:23 -0700841 public boolean onPrepareOptionsMenu(Menu menu) {
Dmitri Plotnikov0cd01302010-12-17 18:41:57 -0800842 mOptionsMenuContactsAvailable = areContactsAvailable();
843 if (!mOptionsMenuContactsAvailable) {
Dmitri Plotnikov8b826462010-11-17 14:52:24 -0800844 return false;
845 }
846
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700847 final MenuItem addContactMenu = menu.findItem(R.id.menu_add_contact);
848 final MenuItem addGroupMenu = menu.findItem(R.id.menu_add_group);
Katherine Kuan1ee9df62011-06-11 16:54:01 -0700849 final MenuItem searchMenu = menu.findItem(R.id.menu_search);
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700850
851 if (mActionBarAdapter.isSearchMode()) {
852 addContactMenu.setVisible(false);
853 addGroupMenu.setVisible(false);
Katherine Kuan1ee9df62011-06-11 16:54:01 -0700854 // If search is normally in the overflow menu, when we are in search
855 // mode, hide this option.
856 if (mActionBarAdapter.isSearchInOverflowMenu()) {
857 searchMenu.setVisible(false);
858 }
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700859 } else {
860 switch (mSelectedTab) {
861 case FAVORITES:
862 // TODO: Fall through until we determine what the menu items should be for
863 // this tab
864 case CONTACTS:
865 addContactMenu.setVisible(true);
866 addGroupMenu.setVisible(false);
867 break;
868 case GROUPS:
869 addContactMenu.setVisible(false);
870 addGroupMenu.setVisible(true);
871 break;
872 }
873 }
874
Dmitri Plotnikova053d612010-11-23 13:31:10 -0800875 MenuItem settings = menu.findItem(R.id.menu_settings);
Daniel Lehmann0f1f66a2011-03-16 15:46:36 -0700876 if (settings != null) {
877 settings.setVisible(!ContactsPreferenceActivity.isEmpty(this));
878 }
Dmitri Plotnikova053d612010-11-23 13:31:10 -0800879
Dmitri Plotnikov0cd01302010-12-17 18:41:57 -0800880 return true;
881 }
882
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800883 @Override
884 public boolean onOptionsItemSelected(MenuItem item) {
885 switch (item.getItemId()) {
Dmitri Plotnikovc85ad182010-09-17 18:12:49 -0700886 case R.id.menu_settings: {
887 final Intent intent = new Intent(this, ContactsPreferenceActivity.class);
Daniel Lehmannc1506272011-05-13 13:21:15 -0700888 startActivity(intent);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800889 return true;
Jeff Sharkeyd9798ae2009-08-24 20:46:23 -0700890 }
Katherine Kuanb5760b92011-06-01 16:19:40 -0700891 case R.id.menu_contacts_filter: {
892 final Intent intent = new Intent(this, CustomContactListFilterActivity.class);
893 startActivityForResult(intent, SUBACTIVITY_CUSTOMIZE_FILTER);
894 return true;
895 }
Jeff Sharkeyd9798ae2009-08-24 20:46:23 -0700896 case R.id.menu_search: {
Dmitri Plotnikov8e86b752010-02-22 17:47:57 -0800897 onSearchRequested();
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800898 return true;
Jeff Sharkeyd9798ae2009-08-24 20:46:23 -0700899 }
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700900 case R.id.menu_add_contact: {
Jeff Sharkeyd9798ae2009-08-24 20:46:23 -0700901 final Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI);
Daniel Lehmann22fb2052010-07-27 19:59:21 -0700902 startActivityForResult(intent, SUBACTIVITY_NEW_CONTACT);
Jeff Sharkeyd9798ae2009-08-24 20:46:23 -0700903 return true;
904 }
Katherine Kuan8268bbe2011-06-10 17:48:21 -0700905 case R.id.menu_add_group: {
906 // TODO: Hook up "new group" functionality
907 Toast.makeText(this, "NEW GROUP", Toast.LENGTH_SHORT).show();
908 return true;
909 }
Jeff Sharkey49d17b32009-09-07 02:14:21 -0700910 case R.id.menu_import_export: {
Daniel Lehmann261cd562011-05-17 14:53:17 -0700911 ImportExportDialogFragment.show(getFragmentManager());
Jeff Sharkeyd9798ae2009-08-24 20:46:23 -0700912 return true;
913 }
914 case R.id.menu_accounts: {
915 final Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
Dmitri Plotnikovfe42e552010-05-14 14:50:32 -0700916 intent.putExtra(Settings.EXTRA_AUTHORITIES, new String[] {
Jeff Sharkeyd9798ae2009-08-24 20:46:23 -0700917 ContactsContract.AUTHORITY
918 });
Dmitri Plotnikov1fbcbd12011-01-16 18:09:09 -0800919 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
Jeff Sharkeyd9798ae2009-08-24 20:46:23 -0700920 startActivity(intent);
921 return true;
922 }
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800923 }
924 return false;
925 }
926
Dmitri Plotnikov8e86b752010-02-22 17:47:57 -0800927 @Override
928 public void startSearch(String initialQuery, boolean selectInitialQuery, Bundle appSearchData,
929 boolean globalSearch) {
Dmitri Plotnikov691e9332010-12-16 18:49:24 -0800930 if (mListFragment != null && mListFragment.isAdded() && !globalSearch) {
Dmitri Plotnikovd3758b02010-06-17 11:34:59 -0700931 mListFragment.startSearch(initialQuery);
Dmitri Plotnikov691e9332010-12-16 18:49:24 -0800932 } else {
933 super.startSearch(initialQuery, selectInitialQuery, appSearchData, globalSearch);
Dmitri Plotnikovdb3d1432010-02-09 17:45:47 -0800934 }
Dmitri Plotnikovdb3d1432010-02-09 17:45:47 -0800935 }
936
Jeff Sharkey49d17b32009-09-07 02:14:21 -0700937 @Override
Dmitri Plotnikov3b73d8b2010-03-12 19:28:21 -0800938 protected Dialog onCreateDialog(int id, Bundle bundle) {
Daniel Lehmann3b7d5942010-07-22 18:10:50 -0700939 if (DialogManager.isManagedId(id)) return mDialogManager.onCreateDialog(id, bundle);
Daniel Lehmann3391dbe2010-07-12 09:50:22 -0700940
Dmitri Plotnikov66bca8f2010-11-24 16:59:24 -0800941 Dialog dialog = getPhoneNumberCallInteraction().onCreateDialog(id, bundle);
Daniel Lehmanna35a7e22010-08-03 18:13:14 -0700942 if (dialog != null) return dialog;
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -0700943
944 dialog = getSendTextMessageInteraction().onCreateDialog(id, bundle);
Daniel Lehmanna35a7e22010-08-03 18:13:14 -0700945 if (dialog != null) return dialog;
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -0700946
Dmitri Plotnikov3b73d8b2010-03-12 19:28:21 -0800947 return super.onCreateDialog(id, bundle);
Jeff Sharkey49d17b32009-09-07 02:14:21 -0700948 }
949
Dmitri Plotnikov9692f262010-06-29 18:53:11 -0700950 @Override
951 protected void onPrepareDialog(int id, Dialog dialog, Bundle bundle) {
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -0700952 if (getPhoneNumberCallInteraction().onPrepareDialog(id, dialog, bundle)) {
953 return;
954 }
955
956 if (getSendTextMessageInteraction().onPrepareDialog(id, dialog, bundle)) {
957 return;
958 }
959
Dmitri Plotnikov9692f262010-06-29 18:53:11 -0700960 super.onPrepareDialog(id, dialog, bundle);
961 }
Jeff Sharkeyd9798ae2009-08-24 20:46:23 -0700962
Dmitri Plotnikovd3758b02010-06-17 11:34:59 -0700963 @Override
964 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
965 switch (requestCode) {
Dmitri Plotnikov6e850a02010-10-28 10:46:21 -0700966 case SUBACTIVITY_CUSTOMIZE_FILTER: {
967 if (resultCode == Activity.RESULT_OK) {
968 mContactListFilterController.selectCustomFilter();
969 }
970 break;
971 }
Dmitri Plotnikov8c6955f2010-09-08 20:46:36 -0700972
Dmitri Plotnikovd9591042010-11-23 09:25:03 -0800973 case SUBACTIVITY_EDIT_CONTACT:
Daniel Lehmann22fb2052010-07-27 19:59:21 -0700974 case SUBACTIVITY_NEW_CONTACT: {
Katherine Kuanbe18de02011-06-07 12:38:29 -0700975 if (resultCode == RESULT_OK && mContentPaneDisplayed) {
Dmitri Plotnikov6e850a02010-10-28 10:46:21 -0700976 mRequest.setActionCode(ContactsRequest.ACTION_VIEW_CONTACT);
Dmitri Plotnikova5a27442010-12-27 21:06:38 -0800977 mListFragment.reloadDataAndSetSelectedUri(data.getData());
Daniel Lehmann22fb2052010-07-27 19:59:21 -0700978 }
979 break;
980 }
Dmitri Plotnikovd3758b02010-06-17 11:34:59 -0700981
Daniel Lehmann7aa9b282010-07-27 20:33:27 -0700982 // TODO: Using the new startActivityWithResultFromFragment API this should not be needed
983 // anymore
Dmitri Plotnikove8a95172010-06-23 16:18:10 -0700984 case ContactEntryListFragment.ACTIVITY_REQUEST_CODE_PICKER:
Dmitri Plotnikovd3758b02010-06-17 11:34:59 -0700985 if (resultCode == RESULT_OK) {
Dmitri Plotnikove8a95172010-06-23 16:18:10 -0700986 mListFragment.onPickerResult(data);
Dmitri Plotnikovd3758b02010-06-17 11:34:59 -0700987 }
988
989// TODO fix or remove multipicker code
990// else if (resultCode == RESULT_CANCELED && mMode == MODE_PICK_MULTIPLE_PHONES) {
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -0700991// // Finish the activity if the sub activity was canceled as back key is used
992// // to confirm user selection in MODE_PICK_MULTIPLE_PHONES.
993// finish();
994// }
995// break;
Dmitri Plotnikovd3758b02010-06-17 11:34:59 -0700996 }
997 }
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -0800998
999 @Override
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -08001000 public boolean onContextItemSelected(MenuItem item) {
Dmitri Plotnikov502741d2010-04-27 19:06:23 -07001001 ContextMenuAdapter menuAdapter = mListFragment.getContextMenuAdapter();
1002 if (menuAdapter != null) {
1003 return menuAdapter.onContextItemSelected(item);
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -08001004 }
1005
1006 return super.onContextItemSelected(item);
1007 }
1008
1009 @Override
1010 public boolean onKeyDown(int keyCode, KeyEvent event) {
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -07001011 // TODO move to the fragment
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -08001012 switch (keyCode) {
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -07001013// case KeyEvent.KEYCODE_CALL: {
1014// if (callSelection()) {
1015// return true;
1016// }
1017// break;
1018// }
Dmitri Plotnikovdb3d1432010-02-09 17:45:47 -08001019
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -08001020 case KeyEvent.KEYCODE_DEL: {
Dmitri Plotnikov6c776bc2010-03-10 10:12:31 -08001021 if (deleteSelection()) {
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -08001022 return true;
1023 }
1024 break;
1025 }
Daniel Lehmann7bb2add2010-07-14 21:15:17 -07001026 default: {
1027 // Bring up the search UI if the user starts typing
1028 final int unicodeChar = event.getUnicodeChar();
Daniel Lehmann4f3aa852011-03-22 17:31:21 -07001029 if (unicodeChar != 0 && !Character.isWhitespace(unicodeChar)) {
Daniel Lehmann7bb2add2010-07-14 21:15:17 -07001030 String query = new String(new int[]{ unicodeChar }, 0, 1);
Katherine Kuanb5760b92011-06-01 16:19:40 -07001031 if (!mActionBarAdapter.isSearchMode()) {
1032 mActionBarAdapter.setQueryString(query);
1033 mActionBarAdapter.setSearchMode(true);
1034 return true;
Daniel Lehmann7bb2add2010-07-14 21:15:17 -07001035 } else if (!mRequest.isSearchMode()) {
1036 if (!mSearchInitiated) {
1037 mSearchInitiated = true;
1038 startSearch(query, false, null, false);
1039 return true;
1040 }
1041 }
1042 }
1043 }
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -08001044 }
1045
1046 return super.onKeyDown(keyCode, event);
1047 }
1048
Dmitri Plotnikovab4d29f2010-10-28 12:43:54 -07001049 @Override
1050 public void onBackPressed() {
1051 if (mSearchMode && mActionBarAdapter != null) {
1052 mActionBarAdapter.setSearchMode(false);
1053 } else {
1054 super.onBackPressed();
1055 }
1056 }
1057
Dmitri Plotnikov6c776bc2010-03-10 10:12:31 -08001058 private boolean deleteSelection() {
Dmitri Plotnikov1ce1e7c2010-05-13 16:41:00 -07001059 // TODO move to the fragment
1060// if (mActionCode == ContactsRequest.ACTION_DEFAULT) {
1061// final int position = mListView.getSelectedItemPosition();
1062// if (position != ListView.INVALID_POSITION) {
1063// Uri contactUri = getContactUri(position);
1064// if (contactUri != null) {
1065// doContactDelete(contactUri);
1066// return true;
1067// }
1068// }
1069// }
Dmitri Plotnikov6c776bc2010-03-10 10:12:31 -08001070 return false;
1071 }
1072
Dmitri Plotnikov08e1c4e2010-07-02 17:57:51 -07001073 @Override
1074 protected void onSaveInstanceState(Bundle outState) {
1075 super.onSaveInstanceState(outState);
Dmitri Plotnikov15ccbb42010-10-05 17:29:07 -07001076 outState.putBoolean(KEY_SEARCH_MODE, mSearchMode);
Dmitri Plotnikovfcfdffb2010-07-15 18:00:55 -07001077 if (mActionBarAdapter != null) {
1078 mActionBarAdapter.onSaveInstanceState(outState);
Dmitri Plotnikov08e1c4e2010-07-02 17:57:51 -07001079 }
1080 }
1081
Dmitri Plotnikovfa49a662011-01-13 11:04:56 -08001082 @Override
1083 protected void onRestoreInstanceState(Bundle inState) {
1084 super.onRestoreInstanceState(inState);
1085 mSearchMode = inState.getBoolean(KEY_SEARCH_MODE);
1086 if (mActionBarAdapter != null) {
1087 mActionBarAdapter.onRestoreInstanceState(inState);
1088 }
1089 }
1090
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -07001091 private PhoneNumberInteraction getPhoneNumberCallInteraction() {
1092 if (mPhoneNumberCallInteraction == null) {
1093 mPhoneNumberCallInteraction = new PhoneNumberInteraction(this, false, null);
Dmitri Plotnikov7c5286e2010-05-04 16:49:36 -07001094 }
Dmitri Plotnikovb4e88862010-06-30 21:24:35 -07001095 return mPhoneNumberCallInteraction;
1096 }
1097
1098 private PhoneNumberInteraction getSendTextMessageInteraction() {
1099 if (mSendTextMessageInteraction == null) {
1100 mSendTextMessageInteraction = new PhoneNumberInteraction(this, true, null);
1101 }
1102 return mSendTextMessageInteraction;
Dmitri Plotnikov7c5286e2010-05-04 16:49:36 -07001103 }
Dmitri Plotnikov9692f262010-06-29 18:53:11 -07001104
Daniel Lehmann3391dbe2010-07-12 09:50:22 -07001105 @Override
1106 public DialogManager getDialogManager() {
1107 return mDialogManager;
1108 }
Dmitri Plotnikovab75f822011-01-10 11:21:59 -08001109
1110 // Visible for testing
1111 public ContactBrowseListFragment getListFragment() {
1112 return mListFragment;
1113 }
1114
1115 // Visible for testing
1116 public ContactDetailFragment getDetailFragment() {
Katherine Kuanbe18de02011-06-07 12:38:29 -07001117 return mContactDetailFragment;
Dmitri Plotnikovab75f822011-01-10 11:21:59 -08001118 }
The Android Open Source Project7aa0e4c2009-03-03 19:32:21 -08001119}