blob: d8fe1ab471f004db5d33f03067f135e5e8f73049 [file] [log] [blame]
Chiao Cheng94b10b52012-08-17 16:59:12 -07001/*
Yorke Leec3766332013-07-31 11:13:16 -07002 * Copyright (C) 2013 The Android Open Source Project
Chiao Cheng94b10b52012-08-17 16:59:12 -07003 *
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
17package com.android.dialer;
18
Yorke Leec3766332013-07-31 11:13:16 -070019import android.animation.Animator;
20import android.animation.Animator.AnimatorListener;
21import android.animation.AnimatorListenerAdapter;
Chiao Cheng94b10b52012-08-17 16:59:12 -070022import android.app.Activity;
Christine Chen9c1e0652013-05-23 15:40:19 -070023import android.app.backup.BackupManager;
Chiao Cheng94b10b52012-08-17 16:59:12 -070024import android.app.Fragment;
25import android.app.FragmentManager;
26import android.app.FragmentTransaction;
Chiao Cheng073b5cf2012-12-07 11:36:00 -080027import android.content.ActivityNotFoundException;
Chiao Cheng94b10b52012-08-17 16:59:12 -070028import android.content.Context;
29import android.content.Intent;
30import android.content.SharedPreferences;
Yorke Leec3766332013-07-31 11:13:16 -070031import android.content.res.Resources;
Chiao Cheng94b10b52012-08-17 16:59:12 -070032import android.net.Uri;
33import android.os.Bundle;
34import android.os.RemoteException;
35import android.os.ServiceManager;
Chiao Cheng94b10b52012-08-17 16:59:12 -070036import android.provider.CallLog.Calls;
Yorke Leec3766332013-07-31 11:13:16 -070037import android.provider.ContactsContract;
Chiao Cheng94b10b52012-08-17 16:59:12 -070038import android.provider.ContactsContract.Contacts;
39import android.provider.ContactsContract.Intents.UI;
Yorke Leec3766332013-07-31 11:13:16 -070040import android.provider.Settings;
41import android.speech.RecognizerIntent;
42import android.support.v4.app.NavUtils;
43import android.telephony.TelephonyManager;
44import android.text.Editable;
Chiao Cheng94b10b52012-08-17 16:59:12 -070045import android.text.TextUtils;
Yorke Leec3766332013-07-31 11:13:16 -070046import android.text.TextWatcher;
Chiao Cheng94b10b52012-08-17 16:59:12 -070047import android.util.Log;
48import android.view.Menu;
Chiao Cheng94b10b52012-08-17 16:59:12 -070049import android.view.MenuItem;
Chiao Cheng94b10b52012-08-17 16:59:12 -070050import android.view.View;
Chiao Cheng94b10b52012-08-17 16:59:12 -070051import android.view.View.OnFocusChangeListener;
52import android.view.ViewConfiguration;
Chiao Cheng94b10b52012-08-17 16:59:12 -070053import android.view.inputmethod.InputMethodManager;
Yorke Leec3766332013-07-31 11:13:16 -070054import android.widget.AbsListView.OnScrollListener;
55import android.widget.EditText;
56import android.widget.ImageView;
Chiao Cheng94b10b52012-08-17 16:59:12 -070057import android.widget.PopupMenu;
58import android.widget.SearchView;
59import android.widget.SearchView.OnCloseListener;
60import android.widget.SearchView.OnQueryTextListener;
Chiao Cheng073b5cf2012-12-07 11:36:00 -080061import android.widget.Toast;
Chiao Cheng94b10b52012-08-17 16:59:12 -070062
Chiao Cheng9d4f3b22012-09-05 16:00:16 -070063import com.android.contacts.common.CallUtil;
Chiao Cheng603ff682012-10-24 15:18:40 -070064import com.android.contacts.common.activity.TransactionSafeActivity;
Yorke Leec3766332013-07-31 11:13:16 -070065import com.android.contacts.common.dialog.ClearFrequentsDialog;
66import com.android.contacts.common.interactions.ImportExportDialogFragment;
Chiao Cheng1429f1a2012-11-01 16:35:28 -070067import com.android.contacts.common.list.ContactListItemView;
Chiao Cheng8efbcf92012-12-04 17:43:02 -080068import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
69import com.android.contacts.common.list.PhoneNumberPickerFragment;
Yorke Leec3766332013-07-31 11:13:16 -070070import com.android.dialer.calllog.CallLogActivity;
Yorke Leefce269a2013-08-12 11:56:04 -070071import com.android.dialer.database.DialerDatabaseHelper;
Yorke Leef74011e2013-08-02 11:30:30 -070072import com.android.dialer.dialpad.DialpadFragment;
Yorke Leec3766332013-07-31 11:13:16 -070073import com.android.dialer.dialpad.SmartDialNameMatcher;
Yorke Leefce269a2013-08-12 11:56:04 -070074import com.android.dialer.dialpad.SmartDialPrefix;
Chiao Cheng1429f1a2012-11-01 16:35:28 -070075import com.android.dialer.interactions.PhoneNumberInteraction;
Yorke Lee8dd62002013-08-08 15:57:20 -070076import com.android.dialer.list.AllContactsActivity;
Yorke Lee8898cd02013-08-08 10:24:27 -070077import com.android.dialer.list.PhoneFavoriteFragment;
Yorke Leec3766332013-07-31 11:13:16 -070078import com.android.dialer.list.OnListFragmentScrolledListener;
Yorke Leec3766332013-07-31 11:13:16 -070079import com.android.dialer.list.SmartDialSearchFragment;
Yorke Lee0baa98b2013-08-22 10:55:16 -070080import com.android.dialerbind.DatabaseHelperManager;
Chiao Cheng94b10b52012-08-17 16:59:12 -070081import com.android.internal.telephony.ITelephony;
82
Yorke Leec3766332013-07-31 11:13:16 -070083import java.util.ArrayList;
84
Chiao Cheng94b10b52012-08-17 16:59:12 -070085/**
Chiao Cheng94b10b52012-08-17 16:59:12 -070086 * The dialer tab's title is 'phone', a more common name (see strings.xml).
87 */
Yorke Leec3766332013-07-31 11:13:16 -070088public class DialtactsActivity extends TransactionSafeActivity implements View.OnClickListener,
Yorke Leef74011e2013-08-02 11:30:30 -070089 DialpadFragment.OnDialpadQueryChangedListener, PopupMenu.OnMenuItemClickListener,
Yorke Leec3766332013-07-31 11:13:16 -070090 OnListFragmentScrolledListener,
Yorke Lee8898cd02013-08-08 10:24:27 -070091 PhoneFavoriteFragment.OnPhoneFavoriteFragmentStartedListener,
Yorke Lee8dd62002013-08-08 15:57:20 -070092 DialpadFragment.OnDialpadFragmentStartedListener,
93 PhoneFavoriteFragment.OnShowAllContactsListener {
Chiao Cheng94b10b52012-08-17 16:59:12 -070094 private static final String TAG = "DialtactsActivity";
95
96 public static final boolean DEBUG = false;
97
Yorke Leef74011e2013-08-02 11:30:30 -070098 public static final String SHARED_PREFS_NAME = "com.android.dialer_preferences";
99
Chiao Cheng94b10b52012-08-17 16:59:12 -0700100 /** Used to open Call Setting */
101 private static final String PHONE_PACKAGE = "com.android.phone";
102 private static final String CALL_SETTINGS_CLASS_NAME =
103 "com.android.phone.CallFeaturesSetting";
Chiao Cheng94b10b52012-08-17 16:59:12 -0700104 /** @see #getCallOrigin() */
105 private static final String CALL_ORIGIN_DIALTACTS =
106 "com.android.dialer.DialtactsActivity";
107
Yorke Leeef2b7382013-08-09 17:39:25 -0700108 private static final String KEY_IN_SEARCH_UI = "in_search_ui";
109 private static final String KEY_SEARCH_QUERY = "search_query";
110 private static final String KEY_FIRST_LAUNCH = "first_launch";
111
Yorke Leec3766332013-07-31 11:13:16 -0700112 private static final String TAG_DIALPAD_FRAGMENT = "dialpad";
113 private static final String TAG_REGULAR_SEARCH_FRAGMENT = "search";
114 private static final String TAG_SMARTDIAL_SEARCH_FRAGMENT = "smartdial";
115 private static final String TAG_FAVORITES_FRAGMENT = "favorites";
Yorke Leec3766332013-07-31 11:13:16 -0700116
Chiao Cheng94b10b52012-08-17 16:59:12 -0700117 /**
118 * Just for backward compatibility. Should behave as same as {@link Intent#ACTION_DIAL}.
119 */
120 private static final String ACTION_TOUCH_DIALER = "com.android.phone.action.TOUCH_DIALER";
121
Chiao Cheng94b10b52012-08-17 16:59:12 -0700122 private static final int SUBACTIVITY_ACCOUNT_FILTER = 1;
123
Yorke Leec3766332013-07-31 11:13:16 -0700124 private static final int ACTIVITY_REQUEST_CODE_VOICE_SEARCH = 1;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700125
126 private String mFilterText;
127
Yorke Leec3766332013-07-31 11:13:16 -0700128 /**
129 * The main fragment displaying the user's favorites and frequent contacts
130 */
Yorke Lee8898cd02013-08-08 10:24:27 -0700131 private PhoneFavoriteFragment mPhoneFavoriteFragment;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700132
133 /**
Yorke Leec3766332013-07-31 11:13:16 -0700134 * Fragment containing the dialpad that slides into view
Chiao Cheng94b10b52012-08-17 16:59:12 -0700135 */
Yorke Leef74011e2013-08-02 11:30:30 -0700136 private DialpadFragment mDialpadFragment;
Yorke Leec3766332013-07-31 11:13:16 -0700137
138 /**
139 * Fragment for searching phone numbers using the alphanumeric keyboard.
140 */
Yorke Lee8898cd02013-08-08 10:24:27 -0700141 private SearchFragment mRegularSearchFragment;
Yorke Leec3766332013-07-31 11:13:16 -0700142
143 /**
144 * Fragment for searching phone numbers using the dialpad.
145 */
146 private SmartDialSearchFragment mSmartDialSearchFragment;
147
Yorke Leec3766332013-07-31 11:13:16 -0700148 private View mMenuButton;
149 private View mCallHistoryButton;
150 private View mDialpadButton;
151
152 // Padding view used to shift the fragments up when the dialpad is shown.
153 private View mBottomPaddingView;
154
Chiao Cheng94b10b52012-08-17 16:59:12 -0700155 /**
156 * True when this Activity is in its search UI (with a {@link SearchView} and
157 * {@link PhoneNumberPickerFragment}).
158 */
159 private boolean mInSearchUi;
Yorke Leeef2b7382013-08-09 17:39:25 -0700160 /**
161 * True when this activity has been launched for the first time.
162 */
Yorke Lee98702de2013-08-06 12:03:32 -0700163 private boolean mFirstLaunch;
Yorke Leec3766332013-07-31 11:13:16 -0700164 private View mSearchViewContainer;
165 private View mSearchViewCloseButton;
166 private View mVoiceSearchButton;
167 private EditText mSearchView;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700168
Yorke Leeef2b7382013-08-09 17:39:25 -0700169 private String mSearchQuery;
170
Yorke Leefce269a2013-08-12 11:56:04 -0700171 private DialerDatabaseHelper mDialerDatabaseHelper;
172
Chiao Cheng94b10b52012-08-17 16:59:12 -0700173 /**
174 * Listener used when one of phone numbers in search UI is selected. This will initiate a
175 * phone call using the phone number.
176 */
177 private final OnPhoneNumberPickerActionListener mPhoneNumberPickerActionListener =
178 new OnPhoneNumberPickerActionListener() {
179 @Override
180 public void onPickPhoneNumberAction(Uri dataUri) {
181 // Specify call-origin so that users will see the previous tab instead of
182 // CallLog screen (search UI will be automatically exited).
183 PhoneNumberInteraction.startInteractionForPhoneCall(
Yorke Leec3766332013-07-31 11:13:16 -0700184 DialtactsActivity.this, dataUri, getCallOrigin());
Yorke Leef6673d32013-08-23 15:34:17 -0700185 hideDialpadAndSearchUi();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700186 }
187
188 @Override
Jay Shrauner31a760b2013-07-26 09:34:49 -0700189 public void onCallNumberDirectly(String phoneNumber) {
190 Intent intent = CallUtil.getCallIntent(phoneNumber, getCallOrigin());
191 startActivity(intent);
Yorke Leef6673d32013-08-23 15:34:17 -0700192 hideDialpadAndSearchUi();
Jay Shrauner31a760b2013-07-26 09:34:49 -0700193 }
194
195 @Override
Chiao Cheng94b10b52012-08-17 16:59:12 -0700196 public void onShortcutIntentCreated(Intent intent) {
197 Log.w(TAG, "Unsupported intent has come (" + intent + "). Ignoring.");
198 }
199
200 @Override
201 public void onHomeInActionBarSelected() {
202 exitSearchUi();
203 }
204 };
205
206 /**
207 * Listener used to send search queries to the phone search fragment.
208 */
Yorke Leec3766332013-07-31 11:13:16 -0700209 private final TextWatcher mPhoneSearchQueryTextListener = new TextWatcher() {
210 @Override
211 public void beforeTextChanged(CharSequence s, int start, int count, int after) {
212 }
213
214 @Override
215 public void onTextChanged(CharSequence s, int start, int before, int count) {
Yorke Leec3766332013-07-31 11:13:16 -0700216 final String newText = s.toString();
Yorke Leeef2b7382013-08-09 17:39:25 -0700217 if (newText.equals(mSearchQuery)) {
218 // If the query hasn't changed (perhaps due to activity being destroyed
219 // and restored, or user launching the same DIAL intent twice), then there is
220 // no need to do anything here.
221 return;
222 }
223 mSearchQuery = newText;
224 if (DEBUG) {
225 Log.d(TAG, "onTextChange for mSearchView called with new query: " + s);
226 }
227 final boolean smartDialSearch = isDialpadShowing();
228
Yorke Leec3766332013-07-31 11:13:16 -0700229 // Show search result with non-empty text. Show a bare list otherwise.
230 if (TextUtils.isEmpty(newText) && mInSearchUi) {
231 exitSearchUi();
232 mSearchViewCloseButton.setVisibility(View.GONE);
233 return;
234 } else if (!TextUtils.isEmpty(newText) && !mInSearchUi) {
Yorke Leeef2b7382013-08-09 17:39:25 -0700235 enterSearchUi(smartDialSearch, newText);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700236 }
237
Yorke Leeef2b7382013-08-09 17:39:25 -0700238 if (smartDialSearch && mSmartDialSearchFragment != null) {
239 mSmartDialSearchFragment.setQueryString(newText, false);
240 } else if (mRegularSearchFragment != null) {
Yorke Leec3766332013-07-31 11:13:16 -0700241 mRegularSearchFragment.setQueryString(newText, false);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700242 }
Yorke Leec3766332013-07-31 11:13:16 -0700243 mSearchViewCloseButton.setVisibility(View.VISIBLE);
244 return;
245 }
246
247 @Override
248 public void afterTextChanged(Editable s) {
249 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700250 };
251
Yorke Leec3766332013-07-31 11:13:16 -0700252 private boolean isDialpadShowing() {
253 return mDialpadFragment != null && mDialpadFragment.isVisible();
254 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700255
256 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700257 protected void onCreate(Bundle savedInstanceState) {
258 super.onCreate(savedInstanceState);
Yorke Lee98702de2013-08-06 12:03:32 -0700259 mFirstLaunch = true;
260
Chiao Cheng94b10b52012-08-17 16:59:12 -0700261 final Intent intent = getIntent();
262 fixIntent(intent);
263
Yorke Lee8898cd02013-08-08 10:24:27 -0700264 setContentView(R.layout.dialtacts_activity);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700265
Yorke Leec3766332013-07-31 11:13:16 -0700266 getActionBar().hide();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700267
Yorke Leeef2b7382013-08-09 17:39:25 -0700268 // Add the favorites fragment, and the dialpad fragment, but only if savedInstanceState
269 // is null. Otherwise the fragment manager takes care of recreating these fragments.
Yorke Leec3766332013-07-31 11:13:16 -0700270 if (savedInstanceState == null) {
Yorke Leeef2b7382013-08-09 17:39:25 -0700271 final PhoneFavoriteFragment phoneFavoriteFragment = new PhoneFavoriteFragment();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700272
Yorke Leec3766332013-07-31 11:13:16 -0700273 final FragmentTransaction ft = getFragmentManager().beginTransaction();
Yorke Leeef2b7382013-08-09 17:39:25 -0700274 ft.add(R.id.dialtacts_frame, phoneFavoriteFragment, TAG_FAVORITES_FRAGMENT);
275 ft.add(R.id.dialtacts_container, new DialpadFragment(), TAG_DIALPAD_FRAGMENT);
Yorke Leec3766332013-07-31 11:13:16 -0700276 ft.commit();
Yorke Leeef2b7382013-08-09 17:39:25 -0700277 } else {
278 mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY);
279 mInSearchUi = savedInstanceState.getBoolean(KEY_IN_SEARCH_UI);
280 mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700281 }
282
Yorke Leec3766332013-07-31 11:13:16 -0700283 mBottomPaddingView = findViewById(R.id.dialtacts_bottom_padding);
284 prepareSearchView();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700285
Chiao Cheng94b10b52012-08-17 16:59:12 -0700286 if (UI.FILTER_CONTACTS_ACTION.equals(intent.getAction())
Yorke Leec3766332013-07-31 11:13:16 -0700287 && savedInstanceState == null) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700288 setupFilterText(intent);
289 }
Yorke Leefce269a2013-08-12 11:56:04 -0700290
Yorke Lee0baa98b2013-08-22 10:55:16 -0700291 mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(this);
Yorke Leefce269a2013-08-12 11:56:04 -0700292 SmartDialPrefix.initializeNanpSettings(this);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700293 }
294
295 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700296 protected void onResume() {
297 super.onResume();
Yorke Lee98702de2013-08-06 12:03:32 -0700298 if (mFirstLaunch) {
299 displayFragment(getIntent());
300 }
301 mFirstLaunch = false;
Yorke Leefce269a2013-08-12 11:56:04 -0700302 mDialerDatabaseHelper.startSmartDialUpdateThread();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700303 }
304
305 @Override
Yorke Leeef2b7382013-08-09 17:39:25 -0700306 protected void onSaveInstanceState(Bundle outState) {
307 super.onSaveInstanceState(outState);
308 outState.putString(KEY_SEARCH_QUERY, mSearchQuery);
309 outState.putBoolean(KEY_IN_SEARCH_UI, mInSearchUi);
310 outState.putBoolean(KEY_FIRST_LAUNCH, mFirstLaunch);
311 }
312
313 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700314 public void onAttachFragment(Fragment fragment) {
Yorke Leeef2b7382013-08-09 17:39:25 -0700315 if (fragment instanceof DialpadFragment) {
316 mDialpadFragment = (DialpadFragment) fragment;
Yorke Leec3766332013-07-31 11:13:16 -0700317 final FragmentTransaction transaction = getFragmentManager().beginTransaction();
Yorke Leeef2b7382013-08-09 17:39:25 -0700318 transaction.hide(mDialpadFragment);
Yorke Leec3766332013-07-31 11:13:16 -0700319 transaction.commit();
Yorke Leeef2b7382013-08-09 17:39:25 -0700320 } else if (fragment instanceof SmartDialSearchFragment) {
321 mSmartDialSearchFragment = (SmartDialSearchFragment) fragment;
Yorke Lee63ea4cd2013-08-12 11:04:47 -0700322 mSmartDialSearchFragment.setOnPhoneNumberPickerActionListener(
323 mPhoneNumberPickerActionListener);
Yorke Leeef2b7382013-08-09 17:39:25 -0700324 } else if (fragment instanceof SearchFragment) {
325 mRegularSearchFragment = (SearchFragment) fragment;
Yorke Lee63ea4cd2013-08-12 11:04:47 -0700326 mRegularSearchFragment.setOnPhoneNumberPickerActionListener(
327 mPhoneNumberPickerActionListener);
Yorke Leeef2b7382013-08-09 17:39:25 -0700328 } else if (fragment instanceof PhoneFavoriteFragment) {
329 mPhoneFavoriteFragment = (PhoneFavoriteFragment) fragment;
Yorke Lee5781afe2013-08-12 11:12:59 -0700330 mPhoneFavoriteFragment.setListener(mPhoneFavoriteListener);
Yorke Leec3766332013-07-31 11:13:16 -0700331 }
Yorke Leec3766332013-07-31 11:13:16 -0700332 }
333
334 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700335 public boolean onMenuItemClick(MenuItem item) {
336 switch (item.getItemId()) {
337 case R.id.menu_import_export:
338 // We hard-code the "contactsAreAvailable" argument because doing it properly would
339 // involve querying a {@link ProviderStatusLoader}, which we don't want to do right
340 // now in Dialtacts for (potential) performance reasons. Compare with how it is
341 // done in {@link PeopleActivity}.
342 ImportExportDialogFragment.show(getFragmentManager(), true,
Yorke Leef74011e2013-08-02 11:30:30 -0700343 DialtactsActivity.class);
Yorke Leec3766332013-07-31 11:13:16 -0700344 return true;
345 case R.id.menu_clear_frequents:
346 ClearFrequentsDialog.show(getFragmentManager());
347 return true;
348 case R.id.add_contact:
349 try {
350 startActivity(new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI));
351 } catch (ActivityNotFoundException e) {
352 Toast toast = Toast.makeText(this,
353 R.string.add_contact_not_available,
354 Toast.LENGTH_SHORT);
355 toast.show();
356 }
357 return true;
358 case R.id.menu_call_settings:
Yorke Leef74011e2013-08-02 11:30:30 -0700359 final Intent settingsIntent = DialtactsActivity.getCallSettingsIntent();
Yorke Leec3766332013-07-31 11:13:16 -0700360 startActivity(settingsIntent);
361 }
362 return false;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700363 }
364
365 @Override
366 public void onClick(View view) {
367 switch (view.getId()) {
Yorke Leec3766332013-07-31 11:13:16 -0700368 case R.id.overflow_menu: {
369 final PopupMenu popupMenu = new PopupMenu(DialtactsActivity.this, view);
370 final Menu menu = popupMenu.getMenu();
Yorke Lee8898cd02013-08-08 10:24:27 -0700371 popupMenu.inflate(R.menu.dialtacts_options);
Yorke Leef420a532013-08-09 15:16:10 -0700372 final MenuItem clearFrequents = menu.findItem(R.id.menu_clear_frequents);
Yorke Lee0d391b42013-08-09 17:27:00 -0700373 clearFrequents.setVisible(mPhoneFavoriteFragment.hasFrequents());
Yorke Leec3766332013-07-31 11:13:16 -0700374 popupMenu.setOnMenuItemClickListener(this);
375 popupMenu.show();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700376 break;
377 }
Yorke Leec3766332013-07-31 11:13:16 -0700378 case R.id.dialpad_button:
379 showDialpadFragment(true);
380 break;
381 case R.id.call_history_on_dialpad_button:
382 case R.id.call_history_button:
Yorke Leef420a532013-08-09 15:16:10 -0700383 // Use explicit CallLogActivity intent instead of ACTION_VIEW +
384 // CONTENT_TYPE, so that we always open our call log from our dialer
Yorke Leec3766332013-07-31 11:13:16 -0700385 final Intent intent = new Intent(this, CallLogActivity.class);
386 startActivity(intent);
387 break;
388 case R.id.search_close_button:
389 // Clear the search field
390 if (!TextUtils.isEmpty(mSearchView.getText())) {
391 mSearchView.setText("");
Chiao Cheng94b10b52012-08-17 16:59:12 -0700392 }
393 break;
Yorke Leec3766332013-07-31 11:13:16 -0700394 case R.id.voice_search_button:
395 final Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
396 startActivityForResult(voiceIntent, ACTIVITY_REQUEST_CODE_VOICE_SEARCH);
397 break;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700398 default: {
399 Log.wtf(TAG, "Unexpected onClick event from " + view);
400 break;
401 }
402 }
403 }
404
Yorke Leec3766332013-07-31 11:13:16 -0700405 @Override
406 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
407 if (requestCode == ACTIVITY_REQUEST_CODE_VOICE_SEARCH) {
408 if (resultCode == RESULT_OK) {
409 final ArrayList<String> matches = data.getStringArrayListExtra(
410 RecognizerIntent.EXTRA_RESULTS);
411 if (matches.size() > 0) {
412 final String match = matches.get(0);
413 mSearchView.setText(match);
414 } else {
415 Log.e(TAG, "Voice search - nothing heard");
416 }
417 } else {
418 Log.e(TAG, "Voice search failed");
419 }
420 }
421 super.onActivityResult(requestCode, resultCode, data);
422 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700423
Yorke Leec3766332013-07-31 11:13:16 -0700424 private void showDialpadFragment(boolean animate) {
Yorke Leeea695cb2013-08-09 11:02:26 -0700425 mDialpadFragment.setAdjustTranslationForAnimation(animate);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700426 final FragmentTransaction ft = getFragmentManager().beginTransaction();
Yorke Leec3766332013-07-31 11:13:16 -0700427 if (animate) {
428 ft.setCustomAnimations(R.anim.slide_in, 0);
Yorke Leeea695cb2013-08-09 11:02:26 -0700429 } else {
430 mDialpadFragment.setYFraction(0);
Yorke Leec3766332013-07-31 11:13:16 -0700431 }
432 ft.show(mDialpadFragment);
433 ft.commit();
434 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700435
Yorke Leef6673d32013-08-23 15:34:17 -0700436 private void hideDialpadFragment(boolean animate, boolean clearDialpad) {
437 if (mDialpadFragment == null) return;
438 if (clearDialpad) {
439 mDialpadFragment.clearDialpad();
440 }
441 if (!mDialpadFragment.isVisible()) return;
Yorke Leeea695cb2013-08-09 11:02:26 -0700442 mDialpadFragment.setAdjustTranslationForAnimation(animate);
Yorke Leec3766332013-07-31 11:13:16 -0700443 final FragmentTransaction ft = getFragmentManager().beginTransaction();
444 if (animate) {
445 ft.setCustomAnimations(0, R.anim.slide_out);
446 }
447 ft.hide(mDialpadFragment);
448 ft.commit();
449 }
450
Chiao Cheng94b10b52012-08-17 16:59:12 -0700451 private void prepareSearchView() {
Yorke Leec3766332013-07-31 11:13:16 -0700452 mSearchViewContainer = findViewById(R.id.search_view_container);
453 mSearchViewCloseButton = findViewById(R.id.search_close_button);
454 mSearchViewCloseButton.setOnClickListener(this);
455 mVoiceSearchButton = findViewById(R.id.voice_search_button);
456 mVoiceSearchButton.setOnClickListener(this);
457 mSearchView = (EditText) findViewById(R.id.search_view);
458 mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener);
459 mSearchView.setHint(getString(R.string.dialer_hint_find_contact));
460 mSearchView.setOnFocusChangeListener(new OnFocusChangeListener() {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700461 @Override
462 public void onFocusChange(View view, boolean hasFocus) {
463 if (hasFocus) {
464 showInputMethod(view.findFocus());
465 }
466 }
467 });
Chiao Cheng94b10b52012-08-17 16:59:12 -0700468 }
469
Yorke Leec3766332013-07-31 11:13:16 -0700470 final AnimatorListener mHideListener = new AnimatorListenerAdapter() {
471 @Override
472 public void onAnimationEnd(Animator animation) {
473 mSearchViewContainer.setVisibility(View.GONE);
474 }
475 };
Chiao Cheng94b10b52012-08-17 16:59:12 -0700476
Yorke Lee311969c2013-08-26 06:31:11 -0700477 private void hideDialpadAndSearchUi() {
478 if (mInSearchUi) {
479 exitSearchUi();
480 }
481 hideDialpadFragment(false, true);
482 }
483
Yorke Leec3766332013-07-31 11:13:16 -0700484 public void hideSearchBar() {
485 hideSearchBar(true);
Christine Chen9c1e0652013-05-23 15:40:19 -0700486 }
487
Yorke Leec3766332013-07-31 11:13:16 -0700488 public void hideSearchBar(boolean shiftView) {
489 if (shiftView) {
490 mSearchViewContainer.animate().cancel();
491 mSearchViewContainer.setAlpha(1);
492 mSearchViewContainer.setTranslationY(0);
493 mSearchViewContainer.animate().withLayer().alpha(0).translationY(-mSearchView.getHeight())
494 .setDuration(200).setListener(mHideListener);
495
Yorke Leeef2b7382013-08-09 17:39:25 -0700496 if (mPhoneFavoriteFragment == null || mPhoneFavoriteFragment.getView() == null) {
497 mBottomPaddingView.setVisibility(View.VISIBLE);
498 return;
499 }
500
Yorke Leec3766332013-07-31 11:13:16 -0700501 mPhoneFavoriteFragment.getView().animate().withLayer()
502 .translationY(-mSearchViewContainer.getHeight()).setDuration(200).setListener(
503 new AnimatorListenerAdapter() {
504 @Override
505 public void onAnimationEnd(Animator animation) {
506 mBottomPaddingView.setVisibility(View.VISIBLE);
Yorke Leeef2b7382013-08-09 17:39:25 -0700507 if (mPhoneFavoriteFragment.getView() != null) {
508 mPhoneFavoriteFragment.getView().setTranslationY(0);
509 }
Yorke Leec3766332013-07-31 11:13:16 -0700510 }
511 });
512 } else {
513 mSearchViewContainer.setTranslationY(-mSearchView.getHeight());
514 }
515 }
516
517 public void showSearchBar() {
Yorke Leeef2b7382013-08-09 17:39:25 -0700518
519
Yorke Leec3766332013-07-31 11:13:16 -0700520 mSearchViewContainer.animate().cancel();
521 mSearchViewContainer.setAlpha(0);
522 mSearchViewContainer.setTranslationY(-mSearchViewContainer.getHeight());
523 mSearchViewContainer.animate().withLayer().alpha(1).translationY(0).setDuration(200)
524 .setListener(new AnimatorListenerAdapter() {
525 @Override
526 public void onAnimationStart(Animator animation) {
527 mSearchViewContainer.setVisibility(View.VISIBLE);
528 }
529 });
530
Yorke Leeef2b7382013-08-09 17:39:25 -0700531 // If the favorites fragment hasn't been fully created before the dialpad fragment
532 // is hidden (i.e. onResume), don't bother animating
533 if (mPhoneFavoriteFragment == null || mPhoneFavoriteFragment.getView() == null) {
534 mBottomPaddingView.setVisibility(View.GONE);
535 return;
536 }
Yorke Leec3766332013-07-31 11:13:16 -0700537 mPhoneFavoriteFragment.getView().setTranslationY(-mSearchViewContainer.getHeight());
538 mPhoneFavoriteFragment.getView().animate().withLayer().translationY(0).setDuration(200)
539 .setListener(
540 new AnimatorListenerAdapter() {
541 @Override
542 public void onAnimationStart(Animator animation) {
543 mBottomPaddingView.setVisibility(View.GONE);
544 }
545 });
546 }
547
548
549 public void setupFakeActionBarItemsForFavoritesFragment() {
550 mMenuButton = findViewById(R.id.overflow_menu);
551 if (mMenuButton != null) {
552 mMenuButton.setOnClickListener(this);
553 }
554
555 mCallHistoryButton = findViewById(R.id.call_history_button);
556 // mCallHistoryButton.setMinimumWidth(fakeMenuItemWidth);
557 mCallHistoryButton.setOnClickListener(this);
558
559 mDialpadButton = findViewById(R.id.dialpad_button);
560 // DialpadButton.setMinimumWidth(fakeMenuItemWidth);
561 mDialpadButton.setOnClickListener(this);
562 }
563
564 public void setupFakeActionBarItemsForDialpadFragment() {
565 final View callhistoryButton = findViewById(R.id.call_history_on_dialpad_button);
566 callhistoryButton.setOnClickListener(this);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700567 }
568
569 private void fixIntent(Intent intent) {
570 // This should be cleaned up: the call key used to send an Intent
571 // that just said to go to the recent calls list. It now sends this
572 // abstract action, but this class hasn't been rewritten to deal with it.
573 if (Intent.ACTION_CALL_BUTTON.equals(intent.getAction())) {
574 intent.setDataAndType(Calls.CONTENT_URI, Calls.CONTENT_TYPE);
575 intent.putExtra("call_key", true);
576 setIntent(intent);
577 }
578 }
579
Chiao Cheng94b10b52012-08-17 16:59:12 -0700580 /**
581 * Returns true if the intent is due to hitting the green send key (hardware call button:
582 * KEYCODE_CALL) while in a call.
583 *
584 * @param intent the intent that launched this activity
585 * @param recentCallsRequest true if the intent is requesting to view recent calls
586 * @return true if the intent is due to hitting the green send key while in a call
587 */
Yorke Leec3766332013-07-31 11:13:16 -0700588 private boolean isSendKeyWhileInCall(Intent intent, boolean recentCallsRequest) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700589 // If there is a call in progress go to the call screen
590 if (recentCallsRequest) {
591 final boolean callKey = intent.getBooleanExtra("call_key", false);
592
593 try {
594 ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
595 if (callKey && phone != null && phone.showCallScreen()) {
596 return true;
597 }
598 } catch (RemoteException e) {
599 Log.e(TAG, "Failed to handle send while in call", e);
600 }
601 }
602
603 return false;
604 }
605
606 /**
607 * Sets the current tab based on the intent's request type
608 *
609 * @param intent Intent that contains information about which tab should be selected
610 */
Yorke Leec3766332013-07-31 11:13:16 -0700611 private void displayFragment(Intent intent) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700612 // If we got here by hitting send and we're in call forward along to the in-call activity
613 boolean recentCallsRequest = Calls.CONTENT_TYPE.equals(intent.resolveType(
614 getContentResolver()));
615 if (isSendKeyWhileInCall(intent, recentCallsRequest)) {
616 finish();
617 return;
618 }
619
Yorke Lee98702de2013-08-06 12:03:32 -0700620 if (mDialpadFragment != null && (phoneIsInUse() || isDialIntent(intent))) {
Yorke Leec3766332013-07-31 11:13:16 -0700621 mDialpadFragment.setStartedFromNewIntent(true);
Yorke Leeea695cb2013-08-09 11:02:26 -0700622 showDialpadFragment(false);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700623 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700624 }
625
626 @Override
627 public void onNewIntent(Intent newIntent) {
628 setIntent(newIntent);
629 fixIntent(newIntent);
Yorke Leec3766332013-07-31 11:13:16 -0700630 displayFragment(newIntent);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700631 final String action = newIntent.getAction();
Yorke Leec3766332013-07-31 11:13:16 -0700632
Chiao Cheng94b10b52012-08-17 16:59:12 -0700633 invalidateOptionsMenu();
634 }
635
636 /** Returns true if the given intent contains a phone number to populate the dialer with */
637 private boolean isDialIntent(Intent intent) {
638 final String action = intent.getAction();
639 if (Intent.ACTION_DIAL.equals(action) || ACTION_TOUCH_DIALER.equals(action)) {
640 return true;
641 }
642 if (Intent.ACTION_VIEW.equals(action)) {
643 final Uri data = intent.getData();
Chiao Cheng9d4f3b22012-09-05 16:00:16 -0700644 if (data != null && CallUtil.SCHEME_TEL.equals(data.getScheme())) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700645 return true;
646 }
647 }
648 return false;
649 }
650
651 /**
652 * Returns an appropriate call origin for this Activity. May return null when no call origin
653 * should be used (e.g. when some 3rd party application launched the screen. Call origin is
654 * for remembering the tab in which the user made a phone call, so the external app's DIAL
655 * request should not be counted.)
656 */
657 public String getCallOrigin() {
658 return !isDialIntent(getIntent()) ? CALL_ORIGIN_DIALTACTS : null;
659 }
660
661 /**
662 * Retrieves the filter text stored in {@link #setupFilterText(Intent)}.
663 * This text originally came from a FILTER_CONTACTS_ACTION intent received
664 * by this activity. The stored text will then be cleared after after this
665 * method returns.
666 *
667 * @return The stored filter text
668 */
669 public String getAndClearFilterText() {
670 String filterText = mFilterText;
671 mFilterText = null;
672 return filterText;
673 }
674
675 /**
676 * Stores the filter text associated with a FILTER_CONTACTS_ACTION intent.
677 * This is so child activities can check if they are supposed to display a filter.
678 *
679 * @param intent The intent received in {@link #onNewIntent(Intent)}
680 */
681 private void setupFilterText(Intent intent) {
682 // If the intent was relaunched from history, don't apply the filter text.
683 if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
684 return;
685 }
686 String filter = intent.getStringExtra(UI.FILTER_TEXT_EXTRA_KEY);
687 if (filter != null && filter.length() > 0) {
688 mFilterText = filter;
689 }
690 }
691
Yorke Lee8898cd02013-08-08 10:24:27 -0700692 private final PhoneFavoriteFragment.Listener mPhoneFavoriteListener =
693 new PhoneFavoriteFragment.Listener() {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700694 @Override
695 public void onContactSelected(Uri contactUri) {
696 PhoneNumberInteraction.startInteractionForPhoneCall(
Yorke Leec3766332013-07-31 11:13:16 -0700697 DialtactsActivity.this, contactUri, getCallOrigin());
Chiao Cheng94b10b52012-08-17 16:59:12 -0700698 }
699
700 @Override
701 public void onCallNumberDirectly(String phoneNumber) {
Chiao Cheng9d4f3b22012-09-05 16:00:16 -0700702 Intent intent = CallUtil.getCallIntent(phoneNumber, getCallOrigin());
Chiao Cheng94b10b52012-08-17 16:59:12 -0700703 startActivity(intent);
704 }
705 };
706
Yorke Leec3766332013-07-31 11:13:16 -0700707 /* TODO krelease: This is only relevant for phones that have a hard button search key (i.e.
708 * Nexus S). Supporting it is a little more tricky because of the dialpad fragment might
709 * be showing when the search key is pressed so there is more state management involved.
Chiao Cheng94b10b52012-08-17 16:59:12 -0700710
711 @Override
712 public void startSearch(String initialQuery, boolean selectInitialQuery,
713 Bundle appSearchData, boolean globalSearch) {
Yorke Leec3766332013-07-31 11:13:16 -0700714 if (mRegularSearchFragment != null && mRegularSearchFragment.isAdded() && !globalSearch) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700715 if (mInSearchUi) {
716 if (mSearchView.hasFocus()) {
717 showInputMethod(mSearchView.findFocus());
718 } else {
719 mSearchView.requestFocus();
720 }
721 } else {
722 enterSearchUi();
723 }
724 } else {
725 super.startSearch(initialQuery, selectInitialQuery, appSearchData, globalSearch);
726 }
Yorke Leec3766332013-07-31 11:13:16 -0700727 }*/
Chiao Cheng94b10b52012-08-17 16:59:12 -0700728
729 private void showInputMethod(View view) {
Yorke Leec3766332013-07-31 11:13:16 -0700730 final InputMethodManager imm = (InputMethodManager) getSystemService(
731 Context.INPUT_METHOD_SERVICE);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700732 if (imm != null) {
Yorke Leec3766332013-07-31 11:13:16 -0700733 imm.showSoftInput(view, 0);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700734 }
735 }
736
737 private void hideInputMethod(View view) {
Yorke Leec3766332013-07-31 11:13:16 -0700738 final InputMethodManager imm = (InputMethodManager) getSystemService(
739 Context.INPUT_METHOD_SERVICE);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700740 if (imm != null && view != null) {
741 imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
742 }
743 }
744
745 /**
Yorke Leec3766332013-07-31 11:13:16 -0700746 * Shows the search fragment
Chiao Cheng94b10b52012-08-17 16:59:12 -0700747 */
Yorke Leeef2b7382013-08-09 17:39:25 -0700748 private void enterSearchUi(boolean smartDialSearch, String query) {
Yorke Lee34bdf872013-08-15 14:11:50 -0700749 if (getFragmentManager().isDestroyed()) {
750 // Weird race condition where fragment is doing work after the activity is destroyed
751 // due to talkback being on (b/10209937). Just return since we can't do any
752 // constructive here.
753 return;
754 }
755
Yorke Leeef2b7382013-08-09 17:39:25 -0700756 if (DEBUG) {
757 Log.d(TAG, "Entering search UI - smart dial " + smartDialSearch);
758 }
759 final String tag = smartDialSearch ? TAG_SMARTDIAL_SEARCH_FRAGMENT :
760 TAG_REGULAR_SEARCH_FRAGMENT;
761
Yorke Leec3766332013-07-31 11:13:16 -0700762 final FragmentTransaction transaction = getFragmentManager().beginTransaction();
763 transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700764
Yorke Leeef2b7382013-08-09 17:39:25 -0700765 SearchFragment fragment;
766
767 transaction.remove(mPhoneFavoriteFragment);
768 fragment = (SearchFragment) getFragmentManager().findFragmentByTag(tag);
769 if (fragment == null) {
770 if (smartDialSearch) {
771 fragment = new SmartDialSearchFragment();
772 } else {
773 fragment = new SearchFragment();
774 }
775 transaction.replace(R.id.dialtacts_frame, fragment, tag);
776 } else {
777 transaction.attach(fragment);
778 }
779
780 transaction.addToBackStack(null);
781 fragment.setQueryString(query, false);
782 transaction.commit();
Yorke Leec3766332013-07-31 11:13:16 -0700783 mInSearchUi = true;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700784 }
785
786 /**
Yorke Leec3766332013-07-31 11:13:16 -0700787 * Hides the search fragment
Chiao Cheng94b10b52012-08-17 16:59:12 -0700788 */
Yorke Leec3766332013-07-31 11:13:16 -0700789 private void exitSearchUi() {
Yorke Leeef2b7382013-08-09 17:39:25 -0700790 getFragmentManager().popBackStack();
Yorke Leec3766332013-07-31 11:13:16 -0700791 mInSearchUi = false;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700792 }
793
794 /** Returns an Intent to launch Call Settings screen */
795 public static Intent getCallSettingsIntent() {
796 final Intent intent = new Intent(Intent.ACTION_MAIN);
797 intent.setClassName(PHONE_PACKAGE, CALL_SETTINGS_CLASS_NAME);
798 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
799 return intent;
800 }
801
802 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700803 public void onBackPressed() {
Yorke Leeef2b7382013-08-09 17:39:25 -0700804 if (mDialpadFragment != null && mDialpadFragment.isVisible()) {
Yorke Leef6673d32013-08-23 15:34:17 -0700805 hideDialpadFragment(true, false);
Yorke Leec3766332013-07-31 11:13:16 -0700806 } else if (mInSearchUi) {
807 mSearchView.setText(null);
Yorke Leef6673d32013-08-23 15:34:17 -0700808 mDialpadFragment.clearDialpad();
Yorke Leec3766332013-07-31 11:13:16 -0700809 } else if (isTaskRoot()) {
810 // Instead of stopping, simply push this to the back of the stack.
811 // This is only done when running at the top of the stack;
812 // otherwise, we have been launched by someone else so need to
813 // allow the user to go back to the caller.
814 moveTaskToBack(false);
815 } else {
816 super.onBackPressed();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700817 }
Yorke Leec3766332013-07-31 11:13:16 -0700818 }
819
820 @Override
821 public void onDialpadQueryChanged(String query) {
822 final String normalizedQuery = SmartDialNameMatcher.normalizeNumber(query,
823 SmartDialNameMatcher.LATIN_SMART_DIAL_MAP);
824 if (!TextUtils.equals(mSearchView.getText(), normalizedQuery)) {
Yorke Leeef2b7382013-08-09 17:39:25 -0700825 if (DEBUG) {
826 Log.d(TAG, "onDialpadQueryChanged - new query: " + query);
827 }
828 if (mDialpadFragment == null || !mDialpadFragment.isVisible()) {
829 // This callback can happen if the dialpad fragment is recreated because of
830 // activity destruction. In that case, don't update the search view because
831 // that would bring the user back to the search fragment regardless of the
832 // previous state of the application. Instead, just return here and let the
833 // fragment manager correctly figure out whatever fragment was last displayed.
834 return;
835 }
Yorke Leec3766332013-07-31 11:13:16 -0700836 mSearchView.setText(normalizedQuery);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700837 }
838 }
Yorke Leec3766332013-07-31 11:13:16 -0700839
840 @Override
841 public void onListFragmentScrollStateChange(int scrollState) {
842 if (scrollState == OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
Yorke Leef6673d32013-08-23 15:34:17 -0700843 hideDialpadFragment(true, false);
Yorke Leec3766332013-07-31 11:13:16 -0700844 hideInputMethod(getCurrentFocus());
845 }
846 }
847
848 @Override
849 public void onPhoneFavoriteFragmentStarted() {
850 setupFakeActionBarItemsForFavoritesFragment();
851 }
852
853 @Override
854 public void onDialpadFragmentStarted() {
855 setupFakeActionBarItemsForDialpadFragment();
856 }
857
858 private boolean phoneIsInUse() {
859 final TelephonyManager tm = (TelephonyManager) getSystemService(
860 Context.TELEPHONY_SERVICE);
861 return tm.getCallState() != TelephonyManager.CALL_STATE_IDLE;
862 }
Yorke Lee8dd62002013-08-08 15:57:20 -0700863
864 @Override
865 public void onShowAllContacts() {
866 final Intent intent = new Intent(this, AllContactsActivity.class);
867 startActivity(intent);
868 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700869}