194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng/* 2c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee * Copyright (C) 2013 The Android Open Source Project 394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * 494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Licensed under the Apache License, Version 2.0 (the "License"); 594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * you may not use this file except in compliance with the License. 694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * You may obtain a copy of the License at 794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * 894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * http://www.apache.org/licenses/LICENSE-2.0 994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * 1094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Unless required by applicable law or agreed to in writing, software 1194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * distributed under the License is distributed on an "AS IS" BASIS, 1294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * See the License for the specific language governing permissions and 1494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * limitations under the License. 1594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng */ 1694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 1794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengpackage com.android.dialer; 1894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 1994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.app.Fragment; 2094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.app.FragmentTransaction; 21073b5cf341964796ccf082d30aff63225d3adb28Chiao Chengimport android.content.ActivityNotFoundException; 2294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.content.Context; 2394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.content.Intent; 24da0f9046b2457c8adc0b97896d7ea1e880eccf96Yorke Leeimport android.content.pm.PackageManager; 25da0f9046b2457c8adc0b97896d7ea1e880eccf96Yorke Leeimport android.content.pm.ResolveInfo; 2682d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapatiimport android.content.res.Configuration; 272423a2ff42989f7706f0da60961c1f79687db974Andrew Leeimport android.content.res.Resources; 2894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.net.Uri; 2994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.os.Bundle; 30f5554ceb3c152949b4b6278b7f5e1522148a574cYorke Leeimport android.os.Trace; 31019713e2b85ff6868c7a77f556b03702d5d07cb0Nancy Chenimport android.provider.CallLog.Calls; 32c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Leeimport android.speech.RecognizerIntent; 33f3d9f829cef463eb328285ed478a9323e2c085e6Nancy Chenimport android.support.design.widget.CoordinatorLayout; 34cc4660d463daa11b969fd9b8bdd308ae3416c67aYorke Leeimport android.support.v4.view.ViewPager; 3544898ad0aa2a12788fc9cfc6b78fa7adc9d90f23Nancy Chenimport android.support.v7.app.ActionBar; 369dc924c8bcc0bc8d996452e9ce3215b5f064962eTyler Gunnimport android.telecom.PhoneAccount; 3753a2230258d105299c7f1b8bbd25de54fed5d66aYorke Leeimport android.text.Editable; 3894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.text.TextUtils; 3953a2230258d105299c7f1b8bbd25de54fed5d66aYorke Leeimport android.text.TextWatcher; 4094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.util.Log; 412826619b274772beebc7369d5dfe616344f74b6fYorke Leeimport android.view.DragEvent; 4274edcdcac9e211d2764c1831e12ad37f84e36502Yorke Leeimport android.view.Gravity; 43b19038436ce8e4683eb19af02255eda9969a6a94Andrew Leeimport android.view.KeyEvent; 4494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.view.Menu; 4594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.view.MenuItem; 46b19038436ce8e4683eb19af02255eda9969a6a94Andrew Leeimport android.view.MotionEvent; 4794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.view.View; 482826619b274772beebc7369d5dfe616344f74b6fYorke Leeimport android.view.View.OnDragListener; 499134e25d7ab8eb687a36ce7ba199e66f44550fddIhab Awadimport android.view.ViewTreeObserver; 502a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Leeimport android.view.animation.Animation; 512a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Leeimport android.view.animation.AnimationUtils; 52c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Leeimport android.widget.AbsListView.OnScrollListener; 5353a2230258d105299c7f1b8bbd25de54fed5d66aYorke Leeimport android.widget.EditText; 54a73e189f57d70e81e6c5150d10032dae29846fd7Andrew Leeimport android.widget.ImageButton; 5594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Chengimport android.widget.PopupMenu; 563520800e124f5871ab64721f9fb7049ecfa0cc54Anne Rongimport android.widget.TextView; 57073b5cf341964796ccf082d30aff63225d3adb28Chiao Chengimport android.widget.Toast; 5894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 59c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Leeimport com.android.contacts.common.dialog.ClearFrequentsDialog; 60c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Leeimport com.android.contacts.common.interactions.ImportExportDialogFragment; 610d3a73932a23cb07168d25ec331a9abf72817346Nancy Chenimport com.android.contacts.common.interactions.TouchPointManager; 628efbcf920eeebc826c18b3c474e9c62b77dcd232Chiao Chengimport com.android.contacts.common.list.OnPhoneNumberPickerActionListener; 63c16ea5ad67bf454158b364dec2f26c95a879c350Yorke Leeimport com.android.contacts.common.util.PermissionsUtil; 64c4969ea3d2ac04f58f0caccef709bc95a182c378Sai Cheemalapatiimport com.android.contacts.common.widget.FloatingActionButtonController; 65c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Leeimport com.android.dialer.calllog.CallLogActivity; 6638019af70eb1ca084d36291390bbc54dc81027deYorke Leeimport com.android.dialer.calllog.CallLogFragment; 67fce269a30e2ec112ea4c287d97e08ef7b3b31b89Yorke Leeimport com.android.dialer.database.DialerDatabaseHelper; 68f74011e7a9b4007f6795ecee5adc2739d5fad4e6Yorke Leeimport com.android.dialer.dialpad.DialpadFragment; 69c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Leeimport com.android.dialer.dialpad.SmartDialNameMatcher; 70fce269a30e2ec112ea4c287d97e08ef7b3b31b89Yorke Leeimport com.android.dialer.dialpad.SmartDialPrefix; 711429f1a5c2b993a5013bfda7cfd75a2c43ead2bfChiao Chengimport com.android.dialer.interactions.PhoneNumberInteraction; 723cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Leeimport com.android.dialer.list.DragDropController; 73e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Leeimport com.android.dialer.list.ListsFragment; 743cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Leeimport com.android.dialer.list.OnDragDropListener; 75c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Leeimport com.android.dialer.list.OnListFragmentScrolledListener; 76efb2d9c2e32ca4ed434ff785c4b3d18c9e08db6dYorke Leeimport com.android.dialer.list.PhoneFavoriteSquareTileView; 772e5b34b14181f367ec90198f5cbcd39f261b7bf5Jay Shraunerimport com.android.dialer.list.RegularSearchFragment; 782e5b34b14181f367ec90198f5cbcd39f261b7bf5Jay Shraunerimport com.android.dialer.list.SearchFragment; 79c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Leeimport com.android.dialer.list.SmartDialSearchFragment; 809134e25d7ab8eb687a36ce7ba199e66f44550fddIhab Awadimport com.android.dialer.list.SpeedDialFragment; 816e0fd6b77759baf43cb37d407041be051b4856b5Yorke Leeimport com.android.dialer.logging.Logger; 8258e68a9513495cbe76188d6066c4ffa467313175Yorke Leeimport com.android.dialer.logging.ScreenEvent; 83af6f195af0bb200d1bb06ad11dac476e8dff0073Yorke Leeimport com.android.dialer.settings.DialerSettingsActivity; 84bcb15f99dff4e01343bb7470135f5392a65a01f4Ta-wei Yenimport com.android.dialer.util.Assert; 85e3cae63fc19a431d902fb8ae50eab732e735b2a0Ta-wei Yenimport com.android.dialer.util.DialerUtils; 86247df6ee4f43af916f7e7f339ed181a18807ef36Andrew Leeimport com.android.dialer.util.IntentUtil; 87e3a2d133a9fdf12462dab75ed7d6c6c6061fa5e3Yorke Leeimport com.android.dialer.util.IntentUtil.CallIntentBuilder; 88e3cae63fc19a431d902fb8ae50eab732e735b2a0Ta-wei Yenimport com.android.dialer.util.TelecomUtil; 89bcb15f99dff4e01343bb7470135f5392a65a01f4Ta-wei Yenimport com.android.dialer.voicemail.VoicemailArchiveActivity; 905253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Leeimport com.android.dialer.widget.ActionBarController; 91b19038436ce8e4683eb19af02255eda9969a6a94Andrew Leeimport com.android.dialer.widget.SearchEditTextLayout; 920baa98b5163f83a715b37e3cffe1488ac88ab049Yorke Leeimport com.android.dialerbind.DatabaseHelperManager; 93807afd8a39366b7423eacd83fb18bff2ba7a0422Yorke Leeimport com.android.dialerbind.ObjectFactory; 942fec47bc040148b4de1d5c32391cb0cd1a36f413Yorke Leeimport com.android.phone.common.animation.AnimUtils; 95fd723cae1dc2de0f83ec14639d4431674dd3b82eSai Cheemalapatiimport com.android.phone.common.animation.AnimationListenerAdapter; 96bcb15f99dff4e01343bb7470135f5392a65a01f4Ta-wei Yenimport com.google.common.annotations.VisibleForTesting; 97d5c512afca0341039e494e4df976b18ff07d146aYorke Lee 98c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Leeimport java.util.ArrayList; 99da0f9046b2457c8adc0b97896d7ea1e880eccf96Yorke Leeimport java.util.List; 100c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee 10194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng/** 10294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * The dialer tab's title is 'phone', a more common name (see strings.xml). 10394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng */ 104c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Leepublic class DialtactsActivity extends TransactionSafeActivity implements View.OnClickListener, 10586e21f733049560e77b92f17a58474312d72ec3eYorke Lee DialpadFragment.OnDialpadQueryChangedListener, 106c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee OnListFragmentScrolledListener, 10738019af70eb1ca084d36291390bbc54dc81027deYorke Lee CallLogFragment.HostInterface, 108575ae388961252a771488c357e425fca191594b2Yorke Lee DialpadFragment.HostInterface, 1096a1461a86ad861b0e04333452e47cb81675459d5Yorke Lee ListsFragment.HostInterface, 110d999b71452baebec789f6f58f1955d30e834826dYorke Lee SpeedDialFragment.HostInterface, 1115253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee SearchFragment.HostInterface, 112752956e3add8b9fff107e1637120a74a61a5feadAndrew Lee OnDragDropListener, 113cc4660d463daa11b969fd9b8bdd308ae3416c67aYorke Lee OnPhoneNumberPickerActionListener, 114e74a10eab5d8a43918a540bc42f0c159bdf5ab7cAndrew Lee PopupMenu.OnMenuItemClickListener, 1155253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee ViewPager.OnPageChangeListener, 1165253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee ActionBarController.ActivityUi { 11794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng private static final String TAG = "DialtactsActivity"; 11894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 1197cc6149445fbfaaef33b3a351e76829390a87226Yorke Lee public static final boolean DEBUG = false; 12094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 121f74011e7a9b4007f6795ecee5adc2739d5fad4e6Yorke Lee public static final String SHARED_PREFS_NAME = "com.android.dialer_preferences"; 122f74011e7a9b4007f6795ecee5adc2739d5fad4e6Yorke Lee 123b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee private static final String KEY_IN_REGULAR_SEARCH_UI = "in_regular_search_ui"; 124b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee private static final String KEY_IN_DIALPAD_SEARCH_UI = "in_dialpad_search_ui"; 125ef2b7388569a94432278a617b528f628385fbb8cYorke Lee private static final String KEY_SEARCH_QUERY = "search_query"; 126ef2b7388569a94432278a617b528f628385fbb8cYorke Lee private static final String KEY_FIRST_LAUNCH = "first_launch"; 12750aba888d4563e755251d97c2ba11a96caee58b1Yorke Lee private static final String KEY_IS_DIALPAD_SHOWN = "is_dialpad_shown"; 128ef2b7388569a94432278a617b528f628385fbb8cYorke Lee 129135e465360dc36f1b9602660e290825d1e1fd00eYorke Lee @VisibleForTesting 130135e465360dc36f1b9602660e290825d1e1fd00eYorke Lee public static final String TAG_DIALPAD_FRAGMENT = "dialpad"; 131c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee private static final String TAG_REGULAR_SEARCH_FRAGMENT = "search"; 132c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee private static final String TAG_SMARTDIAL_SEARCH_FRAGMENT = "smartdial"; 133c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee private static final String TAG_FAVORITES_FRAGMENT = "favorites"; 134c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee 13594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng /** 13694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Just for backward compatibility. Should behave as same as {@link Intent#ACTION_DIAL}. 13794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng */ 13894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng private static final String ACTION_TOUCH_DIALER = "com.android.phone.action.TOUCH_DIALER"; 13975d5b2d7d73e184ed813cc5b42b19d7e21b6bd8cAndrew Lee public static final String EXTRA_SHOW_TAB = "EXTRA_SHOW_TAB"; 14094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 141c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee private static final int ACTIVITY_REQUEST_CODE_VOICE_SEARCH = 1; 14294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 1436324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee private static final int FAB_SCALE_IN_DELAY_MS = 300; 1446324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee 145f3d9f829cef463eb328285ed478a9323e2c085e6Nancy Chen private CoordinatorLayout mParentLayout; 1460c66770b304d03367f093e1916cf565d9cf70146Andrew Lee 14794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng /** 148c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee * Fragment containing the dialpad that slides into view 14994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng */ 15072d6625a51804acec2d9c9b38dc740a65443bc56Evan Charlton protected DialpadFragment mDialpadFragment; 15194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 152c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee /** 153c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee * Fragment for searching phone numbers using the alphanumeric keyboard. 154c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee */ 1552e5b34b14181f367ec90198f5cbcd39f261b7bf5Jay Shrauner private RegularSearchFragment mRegularSearchFragment; 15694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 157c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee /** 158c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee * Fragment for searching phone numbers using the dialpad. 159c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee */ 160c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee private SmartDialSearchFragment mSmartDialSearchFragment; 16194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 162e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee /** 16382d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati * Animation that slides in. 16482d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati */ 16582d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati private Animation mSlideIn; 16682d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati 16782d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati /** 16882d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati * Animation that slides out. 16982d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati */ 17082d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati private Animation mSlideOut; 17182d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati 1726c450eb606f9e052a152e37759d3866cb605e1baYorke Lee AnimationListenerAdapter mSlideInListener = new AnimationListenerAdapter() { 1736c450eb606f9e052a152e37759d3866cb605e1baYorke Lee @Override 1746c450eb606f9e052a152e37759d3866cb605e1baYorke Lee public void onAnimationEnd(Animation animation) { 17581a313dfd824a4aafe86e636c537a08bae0c1e0bYorke Lee maybeEnterSearchUi(); 1766c450eb606f9e052a152e37759d3866cb605e1baYorke Lee } 1776c450eb606f9e052a152e37759d3866cb605e1baYorke Lee }; 1786c450eb606f9e052a152e37759d3866cb605e1baYorke Lee 17982d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati /** 18082d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati * Listener for after slide out animation completes on dialer fragment. 18182d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati */ 18282d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati AnimationListenerAdapter mSlideOutListener = new AnimationListenerAdapter() { 18382d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati @Override 18482d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati public void onAnimationEnd(Animation animation) { 18582d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati commitDialpadFragmentHide(); 18682d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati } 18782d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati }; 18882d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati 18982d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati /** 1904de59fb9ceac10ed429cd8416251329aa03ad266Andrew Lee * Fragment containing the speed dial list, call history list, and all contacts list. 191e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee */ 192e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee private ListsFragment mListsFragment; 193e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee 19419e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee /** 19519e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee * Tracks whether onSaveInstanceState has been called. If true, no fragment transactions can 19619e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee * be commited. 19719e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee */ 19819e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee private boolean mStateSaved; 1997ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee private boolean mIsRestarting; 200b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee private boolean mInDialpadSearch; 201b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee private boolean mInRegularSearch; 2028e5c8b11eb9516fa9b8407e0aa16c0405b5e717eYorke Lee private boolean mClearSearchOnPause; 2032a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee private boolean mIsDialpadShown; 20450aba888d4563e755251d97c2ba11a96caee58b1Yorke Lee private boolean mShowDialpadOnResume; 20594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 206ef2b7388569a94432278a617b528f628385fbb8cYorke Lee /** 207414606561a0ae18d47a263eaa2b2d9622c317ae0Sai Cheemalapati * Whether or not the device is in landscape orientation. 208414606561a0ae18d47a263eaa2b2d9622c317ae0Sai Cheemalapati */ 209414606561a0ae18d47a263eaa2b2d9622c317ae0Sai Cheemalapati private boolean mIsLandscape; 210414606561a0ae18d47a263eaa2b2d9622c317ae0Sai Cheemalapati 211414606561a0ae18d47a263eaa2b2d9622c317ae0Sai Cheemalapati /** 21235127cdea7f9043626ae9d0c6becb31730d0b236Yorke Lee * True if the dialpad is only temporarily showing due to being in call 21335127cdea7f9043626ae9d0c6becb31730d0b236Yorke Lee */ 21435127cdea7f9043626ae9d0c6becb31730d0b236Yorke Lee private boolean mInCallDialpadUp; 21535127cdea7f9043626ae9d0c6becb31730d0b236Yorke Lee 21635127cdea7f9043626ae9d0c6becb31730d0b236Yorke Lee /** 217ef2b7388569a94432278a617b528f628385fbb8cYorke Lee * True when this activity has been launched for the first time. 218ef2b7388569a94432278a617b528f628385fbb8cYorke Lee */ 21998702de246d42c844fabdb8a1f3407bf1747d379Yorke Lee private boolean mFirstLaunch; 22086e21f733049560e77b92f17a58474312d72ec3eYorke Lee 2213c9e7cd12f28c7e79a4b2af442c32f2b519122f1Yorke Lee /** 2223c9e7cd12f28c7e79a4b2af442c32f2b519122f1Yorke Lee * Search query to be applied to the SearchView in the ActionBar once 2233c9e7cd12f28c7e79a4b2af442c32f2b519122f1Yorke Lee * onCreateOptionsMenu has been called. 2243c9e7cd12f28c7e79a4b2af442c32f2b519122f1Yorke Lee */ 2253c9e7cd12f28c7e79a4b2af442c32f2b519122f1Yorke Lee private String mPendingSearchViewQuery; 2263c9e7cd12f28c7e79a4b2af442c32f2b519122f1Yorke Lee 22774edcdcac9e211d2764c1831e12ad37f84e36502Yorke Lee private PopupMenu mOverflowMenu; 22853a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee private EditText mSearchView; 22953a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee private View mVoiceSearchButton; 230e74a10eab5d8a43918a540bc42f0c159bdf5ab7cAndrew Lee 231ef2b7388569a94432278a617b528f628385fbb8cYorke Lee private String mSearchQuery; 232d9a9316985a77fb8a9562f8086e36d3722f19d5cYorke Lee private String mDialpadQuery; 233ef2b7388569a94432278a617b528f628385fbb8cYorke Lee 234fce269a30e2ec112ea4c287d97e08ef7b3b31b89Yorke Lee private DialerDatabaseHelper mDialerDatabaseHelper; 2352826619b274772beebc7369d5dfe616344f74b6fYorke Lee private DragDropController mDragDropController; 2365253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee private ActionBarController mActionBarController; 237c4969ea3d2ac04f58f0caccef709bc95a182c378Sai Cheemalapati 238414606561a0ae18d47a263eaa2b2d9622c317ae0Sai Cheemalapati private FloatingActionButtonController mFloatingActionButtonController; 239fce269a30e2ec112ea4c287d97e08ef7b3b31b89Yorke Lee 2402423a2ff42989f7706f0da60961c1f79687db974Andrew Lee private int mActionBarHeight; 241cb55981252b49e476e1adf9f2d5ec19a658d2aa4Sarmad Hashmi private int mPreviouslySelectedTabIndex; 2422423a2ff42989f7706f0da60961c1f79687db974Andrew Lee 243c1cfae553cc08c832155eb5b951690a4e349b5bcTyler Gunn /** 244c1cfae553cc08c832155eb5b951690a4e349b5bcTyler Gunn * The text returned from a voice search query. Set in {@link #onActivityResult} and used in 245c1cfae553cc08c832155eb5b951690a4e349b5bcTyler Gunn * {@link #onResume()} to populate the search box. 246c1cfae553cc08c832155eb5b951690a4e349b5bcTyler Gunn */ 247c1cfae553cc08c832155eb5b951690a4e349b5bcTyler Gunn private String mVoiceSearchQuery; 248c1cfae553cc08c832155eb5b951690a4e349b5bcTyler Gunn 249467de3dc2be8fa6c815782852f47a752eb77a6dcAndrew Lee protected class OptionsPopupMenu extends PopupMenu { 250e74a10eab5d8a43918a540bc42f0c159bdf5ab7cAndrew Lee public OptionsPopupMenu(Context context, View anchor) { 25174edcdcac9e211d2764c1831e12ad37f84e36502Yorke Lee super(context, anchor, Gravity.END); 252e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee } 253e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee 254e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee @Override 255e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee public void show() { 256c16ea5ad67bf454158b364dec2f26c95a879c350Yorke Lee final boolean hasContactsPermission = 257c16ea5ad67bf454158b364dec2f26c95a879c350Yorke Lee PermissionsUtil.hasContactsPermissions(DialtactsActivity.this); 258e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee final Menu menu = getMenu(); 259e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee final MenuItem clearFrequents = menu.findItem(R.id.menu_clear_frequents); 260e74a10eab5d8a43918a540bc42f0c159bdf5ab7cAndrew Lee clearFrequents.setVisible(mListsFragment != null && 261e74a10eab5d8a43918a540bc42f0c159bdf5ab7cAndrew Lee mListsFragment.getSpeedDialFragment() != null && 262c16ea5ad67bf454158b364dec2f26c95a879c350Yorke Lee mListsFragment.getSpeedDialFragment().hasFrequents() && hasContactsPermission); 263c16ea5ad67bf454158b364dec2f26c95a879c350Yorke Lee 264c16ea5ad67bf454158b364dec2f26c95a879c350Yorke Lee menu.findItem(R.id.menu_import_export).setVisible(hasContactsPermission); 265c16ea5ad67bf454158b364dec2f26c95a879c350Yorke Lee menu.findItem(R.id.menu_add_contact).setVisible(hasContactsPermission); 266b7330e3802e8f9182ae1f5e54857a713b2f13547Yorke Lee 267b7330e3802e8f9182ae1f5e54857a713b2f13547Yorke Lee menu.findItem(R.id.menu_history).setVisible( 268b7330e3802e8f9182ae1f5e54857a713b2f13547Yorke Lee PermissionsUtil.hasPhonePermissions(DialtactsActivity.this)); 269e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee super.show(); 270e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee } 271e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee } 272e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee 27394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng /** 2742826619b274772beebc7369d5dfe616344f74b6fYorke Lee * Listener that listens to drag events and sends their x and y coordinates to a 2752826619b274772beebc7369d5dfe616344f74b6fYorke Lee * {@link DragDropController}. 2762826619b274772beebc7369d5dfe616344f74b6fYorke Lee */ 2772826619b274772beebc7369d5dfe616344f74b6fYorke Lee private class LayoutOnDragListener implements OnDragListener { 2782826619b274772beebc7369d5dfe616344f74b6fYorke Lee @Override 2792826619b274772beebc7369d5dfe616344f74b6fYorke Lee public boolean onDrag(View v, DragEvent event) { 2802826619b274772beebc7369d5dfe616344f74b6fYorke Lee if (event.getAction() == DragEvent.ACTION_DRAG_LOCATION) { 2811896344b53ddf6cdaf17dc02a05c45f587879d99Andrew Lee mDragDropController.handleDragHovered(v, (int) event.getX(), (int) event.getY()); 2822826619b274772beebc7369d5dfe616344f74b6fYorke Lee } 2832826619b274772beebc7369d5dfe616344f74b6fYorke Lee return true; 2842826619b274772beebc7369d5dfe616344f74b6fYorke Lee } 2852826619b274772beebc7369d5dfe616344f74b6fYorke Lee } 2862826619b274772beebc7369d5dfe616344f74b6fYorke Lee 2872826619b274772beebc7369d5dfe616344f74b6fYorke Lee /** 28894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Listener used to send search queries to the phone search fragment. 28994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng */ 29053a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee private final TextWatcher mPhoneSearchQueryTextListener = new TextWatcher() { 29199a570c40193320e8640f91a2eb4693e46153703Andrew Lee @Override 29299a570c40193320e8640f91a2eb4693e46153703Andrew Lee public void beforeTextChanged(CharSequence s, int start, int count, int after) { 29399a570c40193320e8640f91a2eb4693e46153703Andrew Lee } 29494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 29599a570c40193320e8640f91a2eb4693e46153703Andrew Lee @Override 29699a570c40193320e8640f91a2eb4693e46153703Andrew Lee public void onTextChanged(CharSequence s, int start, int before, int count) { 29799a570c40193320e8640f91a2eb4693e46153703Andrew Lee final String newText = s.toString(); 29899a570c40193320e8640f91a2eb4693e46153703Andrew Lee if (newText.equals(mSearchQuery)) { 29999a570c40193320e8640f91a2eb4693e46153703Andrew Lee // If the query hasn't changed (perhaps due to activity being destroyed 30099a570c40193320e8640f91a2eb4693e46153703Andrew Lee // and restored, or user launching the same DIAL intent twice), then there is 30199a570c40193320e8640f91a2eb4693e46153703Andrew Lee // no need to do anything here. 30253a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee return; 30353a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee } 30499a570c40193320e8640f91a2eb4693e46153703Andrew Lee if (DEBUG) { 30599a570c40193320e8640f91a2eb4693e46153703Andrew Lee Log.d(TAG, "onTextChange for mSearchView called with new query: " + newText); 306710709da8389d401d3089bbf9836dfca527f15c3Yorke Lee Log.d(TAG, "Previous Query: " + mSearchQuery); 30799a570c40193320e8640f91a2eb4693e46153703Andrew Lee } 308710709da8389d401d3089bbf9836dfca527f15c3Yorke Lee mSearchQuery = newText; 30953a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee 31090374a77ce339f30a04fbb5d3c5faa0c84901c71Andrew Lee // Show search fragment only when the query string is changed to non-empty text. 31190374a77ce339f30a04fbb5d3c5faa0c84901c71Andrew Lee if (!TextUtils.isEmpty(newText)) { 31290374a77ce339f30a04fbb5d3c5faa0c84901c71Andrew Lee // Call enterSearchUi only if we are switching search modes, or showing a search 31390374a77ce339f30a04fbb5d3c5faa0c84901c71Andrew Lee // fragment for the first time. 31490374a77ce339f30a04fbb5d3c5faa0c84901c71Andrew Lee final boolean sameSearchMode = (mIsDialpadShown && mInDialpadSearch) || 31590374a77ce339f30a04fbb5d3c5faa0c84901c71Andrew Lee (!mIsDialpadShown && mInRegularSearch); 31690374a77ce339f30a04fbb5d3c5faa0c84901c71Andrew Lee if (!sameSearchMode) { 3176c450eb606f9e052a152e37759d3866cb605e1baYorke Lee enterSearchUi(mIsDialpadShown, mSearchQuery, true /* animate */); 31890374a77ce339f30a04fbb5d3c5faa0c84901c71Andrew Lee } 319c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee } 32099a570c40193320e8640f91a2eb4693e46153703Andrew Lee 321a851542c69872ffa6c5615fd8cdd1381f1b13b93Andrew Lee if (mSmartDialSearchFragment != null && mSmartDialSearchFragment.isVisible()) { 322b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee mSmartDialSearchFragment.setQueryString(mSearchQuery, false /* delaySelection */); 323a851542c69872ffa6c5615fd8cdd1381f1b13b93Andrew Lee } else if (mRegularSearchFragment != null && mRegularSearchFragment.isVisible()) { 324b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee mRegularSearchFragment.setQueryString(mSearchQuery, false /* delaySelection */); 32599a570c40193320e8640f91a2eb4693e46153703Andrew Lee } 32699a570c40193320e8640f91a2eb4693e46153703Andrew Lee } 32799a570c40193320e8640f91a2eb4693e46153703Andrew Lee 32899a570c40193320e8640f91a2eb4693e46153703Andrew Lee @Override 32999a570c40193320e8640f91a2eb4693e46153703Andrew Lee public void afterTextChanged(Editable s) { 33099a570c40193320e8640f91a2eb4693e46153703Andrew Lee } 33194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng }; 33294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 333b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee 334b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee /** 33511ca39eae2bd8ed5c3e21e8c4fa09c9b2b6bda51Yorke Lee * Open the search UI when the user clicks on the search box. 336b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee */ 33711ca39eae2bd8ed5c3e21e8c4fa09c9b2b6bda51Yorke Lee private final View.OnClickListener mSearchViewOnClickListener = new View.OnClickListener() { 338b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee @Override 33911ca39eae2bd8ed5c3e21e8c4fa09c9b2b6bda51Yorke Lee public void onClick(View v) { 340b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee if (!isInSearchUi()) { 3415253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee mActionBarController.onSearchBoxTapped(); 3426c450eb606f9e052a152e37759d3866cb605e1baYorke Lee enterSearchUi(false /* smartDialSearch */, mSearchView.getText().toString(), 3436c450eb606f9e052a152e37759d3866cb605e1baYorke Lee true /* animate */); 344b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee } 345b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee } 346b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee }; 347b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee 348b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee /** 3496324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee * Handles the user closing the soft keyboard. 350b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee */ 351b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee private final View.OnKeyListener mSearchEditTextLayoutListener = new View.OnKeyListener() { 352b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee @Override 353b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee public boolean onKey(View v, int keyCode, KeyEvent event) { 3546324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) { 3556324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee if (TextUtils.isEmpty(mSearchView.getText().toString())) { 3566324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee // If the search term is empty, close the search UI. 3576324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee maybeExitSearchUi(); 3586324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee } else { 3596324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee // If the search term is not empty, show the dialpad fab. 3606324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee showFabInSearchUi(); 3616324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee } 362b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee } 363b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee return false; 364b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee } 365b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee }; 366b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee 36794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng @Override 36849db1addc0a5c8b111f810766a3f04d15747f49aNancy Chen public boolean dispatchTouchEvent(MotionEvent ev) { 36949db1addc0a5c8b111f810766a3f04d15747f49aNancy Chen if (ev.getAction() == MotionEvent.ACTION_DOWN) { 37049db1addc0a5c8b111f810766a3f04d15747f49aNancy Chen TouchPointManager.getInstance().setPoint((int) ev.getRawX(), (int) ev.getRawY()); 37149db1addc0a5c8b111f810766a3f04d15747f49aNancy Chen } 37249db1addc0a5c8b111f810766a3f04d15747f49aNancy Chen return super.dispatchTouchEvent(ev); 37349db1addc0a5c8b111f810766a3f04d15747f49aNancy Chen } 37449db1addc0a5c8b111f810766a3f04d15747f49aNancy Chen 37549db1addc0a5c8b111f810766a3f04d15747f49aNancy Chen @Override 376c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee protected void onCreate(Bundle savedInstanceState) { 377f5554ceb3c152949b4b6278b7f5e1522148a574cYorke Lee Trace.beginSection(TAG + " onCreate"); 378c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee super.onCreate(savedInstanceState); 379c16ea5ad67bf454158b364dec2f26c95a879c350Yorke Lee 38098702de246d42c844fabdb8a1f3407bf1747d379Yorke Lee mFirstLaunch = true; 38198702de246d42c844fabdb8a1f3407bf1747d379Yorke Lee 3822423a2ff42989f7706f0da60961c1f79687db974Andrew Lee final Resources resources = getResources(); 383b8170de2a2d0e5cd3812720fe50616fae319413cNancy Chen mActionBarHeight = resources.getDimensionPixelSize(R.dimen.action_bar_height_large); 3842423a2ff42989f7706f0da60961c1f79687db974Andrew Lee 385f5554ceb3c152949b4b6278b7f5e1522148a574cYorke Lee Trace.beginSection(TAG + " setContentView"); 3868898cd0577d41cfa4e6acf785c9e904bd71fbdfdYorke Lee setContentView(R.layout.dialtacts_activity); 387f5554ceb3c152949b4b6278b7f5e1522148a574cYorke Lee Trace.endSection(); 3889e91bb0709f420a8c19c344965cc1410a38bccd5Yorke Lee getWindow().setBackgroundDrawable(null); 38994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 390f5554ceb3c152949b4b6278b7f5e1522148a574cYorke Lee Trace.beginSection(TAG + " setup Views"); 39144898ad0aa2a12788fc9cfc6b78fa7adc9d90f23Nancy Chen final ActionBar actionBar = getSupportActionBar(); 39253a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee actionBar.setCustomView(R.layout.search_edittext); 39353a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee actionBar.setDisplayShowCustomEnabled(true); 394bcef940ebcd0b85d2acef46b28e6622ed596f569Yorke Lee actionBar.setBackgroundDrawable(null); 39553a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee 3963520800e124f5871ab64721f9fb7049ecfa0cc54Anne Rong SearchEditTextLayout searchEditTextLayout = (SearchEditTextLayout) actionBar 3973520800e124f5871ab64721f9fb7049ecfa0cc54Anne Rong .getCustomView().findViewById(R.id.search_view_container); 39804675a5123b50eec37ab84b431afda000541f573Andrew Lee searchEditTextLayout.setPreImeKeyListener(mSearchEditTextLayoutListener); 39904675a5123b50eec37ab84b431afda000541f573Andrew Lee 400e3f59a8f06add2edade829ff043ebee8da5fdc85Andrew Lee mActionBarController = new ActionBarController(this, searchEditTextLayout); 401e3f59a8f06add2edade829ff043ebee8da5fdc85Andrew Lee 40204675a5123b50eec37ab84b431afda000541f573Andrew Lee mSearchView = (EditText) searchEditTextLayout.findViewById(R.id.search_view); 40353a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener); 40404675a5123b50eec37ab84b431afda000541f573Andrew Lee mVoiceSearchButton = searchEditTextLayout.findViewById(R.id.voice_search_button); 40504675a5123b50eec37ab84b431afda000541f573Andrew Lee searchEditTextLayout.findViewById(R.id.search_magnifying_glass) 40604675a5123b50eec37ab84b431afda000541f573Andrew Lee .setOnClickListener(mSearchViewOnClickListener); 40704675a5123b50eec37ab84b431afda000541f573Andrew Lee searchEditTextLayout.findViewById(R.id.search_box_start_search) 40804675a5123b50eec37ab84b431afda000541f573Andrew Lee .setOnClickListener(mSearchViewOnClickListener); 4097a6f189bf6a3edfc5d24aa030a3ba915c6771c2cYorke Lee searchEditTextLayout.setOnClickListener(mSearchViewOnClickListener); 4106324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee searchEditTextLayout.setCallback(new SearchEditTextLayout.Callback() { 41111ca39eae2bd8ed5c3e21e8c4fa09c9b2b6bda51Yorke Lee @Override 41211ca39eae2bd8ed5c3e21e8c4fa09c9b2b6bda51Yorke Lee public void onBackButtonClicked() { 41311ca39eae2bd8ed5c3e21e8c4fa09c9b2b6bda51Yorke Lee onBackPressed(); 41411ca39eae2bd8ed5c3e21e8c4fa09c9b2b6bda51Yorke Lee } 4156324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee 4166324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee @Override 4176324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee public void onSearchViewClicked() { 4186324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee // Hide FAB, as the keyboard is shown. 4196324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee mFloatingActionButtonController.scaleOut(); 4206324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee } 42111ca39eae2bd8ed5c3e21e8c4fa09c9b2b6bda51Yorke Lee }); 42294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 423c4969ea3d2ac04f58f0caccef709bc95a182c378Sai Cheemalapati mIsLandscape = getResources().getConfiguration().orientation 424414606561a0ae18d47a263eaa2b2d9622c317ae0Sai Cheemalapati == Configuration.ORIENTATION_LANDSCAPE; 425cb55981252b49e476e1adf9f2d5ec19a658d2aa4Sarmad Hashmi mPreviouslySelectedTabIndex = ListsFragment.TAB_INDEX_SPEED_DIAL; 426c4969ea3d2ac04f58f0caccef709bc95a182c378Sai Cheemalapati final View floatingActionButtonContainer = findViewById( 427c4969ea3d2ac04f58f0caccef709bc95a182c378Sai Cheemalapati R.id.floating_action_button_container); 428405a6e6822fb19a9d14329da92e03e75e2e72703Andrew Lee ImageButton floatingActionButton = (ImageButton) findViewById(R.id.floating_action_button); 429405a6e6822fb19a9d14329da92e03e75e2e72703Andrew Lee floatingActionButton.setOnClickListener(this); 430c4969ea3d2ac04f58f0caccef709bc95a182c378Sai Cheemalapati mFloatingActionButtonController = new FloatingActionButtonController(this, 431405a6e6822fb19a9d14329da92e03e75e2e72703Andrew Lee floatingActionButtonContainer, floatingActionButton); 432414606561a0ae18d47a263eaa2b2d9622c317ae0Sai Cheemalapati 43304675a5123b50eec37ab84b431afda000541f573Andrew Lee ImageButton optionsMenuButton = 43404675a5123b50eec37ab84b431afda000541f573Andrew Lee (ImageButton) searchEditTextLayout.findViewById(R.id.dialtacts_options_menu_button); 435e74a10eab5d8a43918a540bc42f0c159bdf5ab7cAndrew Lee optionsMenuButton.setOnClickListener(this); 43674edcdcac9e211d2764c1831e12ad37f84e36502Yorke Lee mOverflowMenu = buildOptionsMenu(searchEditTextLayout); 43774edcdcac9e211d2764c1831e12ad37f84e36502Yorke Lee optionsMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener()); 438e74a10eab5d8a43918a540bc42f0c159bdf5ab7cAndrew Lee 439d5c512afca0341039e494e4df976b18ff07d146aYorke Lee // Add the favorites fragment but only if savedInstanceState is null. Otherwise the 440d5c512afca0341039e494e4df976b18ff07d146aYorke Lee // fragment manager is responsible for recreating it. 441c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee if (savedInstanceState == null) { 442526c0b832e27dc38a8dc6eae1f16c50acb51c6e8Ihab Awad getFragmentManager().beginTransaction() 4436a86624270b51df0adc4fc1529661a45a2bb9f03Andrew Lee .add(R.id.dialtacts_frame, new ListsFragment(), TAG_FAVORITES_FRAGMENT) 444526c0b832e27dc38a8dc6eae1f16c50acb51c6e8Ihab Awad .commit(); 445ef2b7388569a94432278a617b528f628385fbb8cYorke Lee } else { 446ef2b7388569a94432278a617b528f628385fbb8cYorke Lee mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY); 447b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee mInRegularSearch = savedInstanceState.getBoolean(KEY_IN_REGULAR_SEARCH_UI); 448b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee mInDialpadSearch = savedInstanceState.getBoolean(KEY_IN_DIALPAD_SEARCH_UI); 449ef2b7388569a94432278a617b528f628385fbb8cYorke Lee mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH); 45050aba888d4563e755251d97c2ba11a96caee58b1Yorke Lee mShowDialpadOnResume = savedInstanceState.getBoolean(KEY_IS_DIALPAD_SHOWN); 4515253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee mActionBarController.restoreInstanceState(savedInstanceState); 45294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 45382d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati 454bf7a95e47facece917e99f19848c014c1438cd77Tyler Gunn final boolean isLayoutRtl = DialerUtils.isRtl(); 455bf7a95e47facece917e99f19848c014c1438cd77Tyler Gunn if (mIsLandscape) { 456bf7a95e47facece917e99f19848c014c1438cd77Tyler Gunn mSlideIn = AnimationUtils.loadAnimation(this, 457bf7a95e47facece917e99f19848c014c1438cd77Tyler Gunn isLayoutRtl ? R.anim.dialpad_slide_in_left : R.anim.dialpad_slide_in_right); 458bf7a95e47facece917e99f19848c014c1438cd77Tyler Gunn mSlideOut = AnimationUtils.loadAnimation(this, 459bf7a95e47facece917e99f19848c014c1438cd77Tyler Gunn isLayoutRtl ? R.anim.dialpad_slide_out_left : R.anim.dialpad_slide_out_right); 460bf7a95e47facece917e99f19848c014c1438cd77Tyler Gunn } else { 461bf7a95e47facece917e99f19848c014c1438cd77Tyler Gunn mSlideIn = AnimationUtils.loadAnimation(this, R.anim.dialpad_slide_in_bottom); 462bf7a95e47facece917e99f19848c014c1438cd77Tyler Gunn mSlideOut = AnimationUtils.loadAnimation(this, R.anim.dialpad_slide_out_bottom); 463bf7a95e47facece917e99f19848c014c1438cd77Tyler Gunn } 46482d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati 4652fec47bc040148b4de1d5c32391cb0cd1a36f413Yorke Lee mSlideIn.setInterpolator(AnimUtils.EASE_IN); 4662fec47bc040148b4de1d5c32391cb0cd1a36f413Yorke Lee mSlideOut.setInterpolator(AnimUtils.EASE_OUT); 4672fec47bc040148b4de1d5c32391cb0cd1a36f413Yorke Lee 4686c450eb606f9e052a152e37759d3866cb605e1baYorke Lee mSlideIn.setAnimationListener(mSlideInListener); 46982d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati mSlideOut.setAnimationListener(mSlideOutListener); 47094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 471f3d9f829cef463eb328285ed478a9323e2c085e6Nancy Chen mParentLayout = (CoordinatorLayout) findViewById(R.id.dialtacts_mainlayout); 472f614f6fbe3351316af5a6119a866bdf25cb0d7e4Yorke Lee mParentLayout.setOnDragListener(new LayoutOnDragListener()); 473c4969ea3d2ac04f58f0caccef709bc95a182c378Sai Cheemalapati floatingActionButtonContainer.getViewTreeObserver().addOnGlobalLayoutListener( 474414606561a0ae18d47a263eaa2b2d9622c317ae0Sai Cheemalapati new ViewTreeObserver.OnGlobalLayoutListener() { 475414606561a0ae18d47a263eaa2b2d9622c317ae0Sai Cheemalapati @Override 476414606561a0ae18d47a263eaa2b2d9622c317ae0Sai Cheemalapati public void onGlobalLayout() { 477405a6e6822fb19a9d14329da92e03e75e2e72703Andrew Lee final ViewTreeObserver observer = 478405a6e6822fb19a9d14329da92e03e75e2e72703Andrew Lee floatingActionButtonContainer.getViewTreeObserver(); 479c4969ea3d2ac04f58f0caccef709bc95a182c378Sai Cheemalapati if (!observer.isAlive()) { 480c4969ea3d2ac04f58f0caccef709bc95a182c378Sai Cheemalapati return; 481c4969ea3d2ac04f58f0caccef709bc95a182c378Sai Cheemalapati } 482c4969ea3d2ac04f58f0caccef709bc95a182c378Sai Cheemalapati observer.removeOnGlobalLayoutListener(this); 483f614f6fbe3351316af5a6119a866bdf25cb0d7e4Yorke Lee int screenWidth = mParentLayout.getWidth(); 484414606561a0ae18d47a263eaa2b2d9622c317ae0Sai Cheemalapati mFloatingActionButtonController.setScreenWidth(screenWidth); 4856324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee mFloatingActionButtonController.align( 4866324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee getFabAlignment(), false /* animate */); 487414606561a0ae18d47a263eaa2b2d9622c317ae0Sai Cheemalapati } 488414606561a0ae18d47a263eaa2b2d9622c317ae0Sai Cheemalapati }); 4890c66770b304d03367f093e1916cf565d9cf70146Andrew Lee 490f5554ceb3c152949b4b6278b7f5e1522148a574cYorke Lee Trace.endSection(); 491f5554ceb3c152949b4b6278b7f5e1522148a574cYorke Lee 492f5554ceb3c152949b4b6278b7f5e1522148a574cYorke Lee Trace.beginSection(TAG + " initialize smart dialing"); 4930baa98b5163f83a715b37e3cffe1488ac88ab049Yorke Lee mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(this); 494fce269a30e2ec112ea4c287d97e08ef7b3b31b89Yorke Lee SmartDialPrefix.initializeNanpSettings(this); 495f5554ceb3c152949b4b6278b7f5e1522148a574cYorke Lee Trace.endSection(); 496f5554ceb3c152949b4b6278b7f5e1522148a574cYorke Lee Trace.endSection(); 49794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 49894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 49994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng @Override 500c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee protected void onResume() { 501f5554ceb3c152949b4b6278b7f5e1522148a574cYorke Lee Trace.beginSection(TAG + " onResume"); 502c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee super.onResume(); 5032a613022dbb278f0f7dd94cf49885cde9d36100cYorke Lee 50419e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee mStateSaved = false; 50598702de246d42c844fabdb8a1f3407bf1747d379Yorke Lee if (mFirstLaunch) { 50698702de246d42c844fabdb8a1f3407bf1747d379Yorke Lee displayFragment(getIntent()); 50735127cdea7f9043626ae9d0c6becb31730d0b236Yorke Lee } else if (!phoneIsInUse() && mInCallDialpadUp) { 50835127cdea7f9043626ae9d0c6becb31730d0b236Yorke Lee hideDialpadFragment(false, true); 50935127cdea7f9043626ae9d0c6becb31730d0b236Yorke Lee mInCallDialpadUp = false; 51050aba888d4563e755251d97c2ba11a96caee58b1Yorke Lee } else if (mShowDialpadOnResume) { 51150aba888d4563e755251d97c2ba11a96caee58b1Yorke Lee showDialpadFragment(false); 51250aba888d4563e755251d97c2ba11a96caee58b1Yorke Lee mShowDialpadOnResume = false; 51398702de246d42c844fabdb8a1f3407bf1747d379Yorke Lee } 514c1cfae553cc08c832155eb5b951690a4e349b5bcTyler Gunn 515c1cfae553cc08c832155eb5b951690a4e349b5bcTyler Gunn // If there was a voice query result returned in the {@link #onActivityResult} callback, it 516c1cfae553cc08c832155eb5b951690a4e349b5bcTyler Gunn // will have been stashed in mVoiceSearchQuery since the search results fragment cannot be 517c1cfae553cc08c832155eb5b951690a4e349b5bcTyler Gunn // shown until onResume has completed. Active the search UI and set the search term now. 518c1cfae553cc08c832155eb5b951690a4e349b5bcTyler Gunn if (!TextUtils.isEmpty(mVoiceSearchQuery)) { 519c1cfae553cc08c832155eb5b951690a4e349b5bcTyler Gunn mActionBarController.onSearchBoxTapped(); 520c1cfae553cc08c832155eb5b951690a4e349b5bcTyler Gunn mSearchView.setText(mVoiceSearchQuery); 521c1cfae553cc08c832155eb5b951690a4e349b5bcTyler Gunn mVoiceSearchQuery = null; 522c1cfae553cc08c832155eb5b951690a4e349b5bcTyler Gunn } 523c1cfae553cc08c832155eb5b951690a4e349b5bcTyler Gunn 52498702de246d42c844fabdb8a1f3407bf1747d379Yorke Lee mFirstLaunch = false; 5257ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee 5267ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee if (mIsRestarting) { 5277ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee // This is only called when the activity goes from resumed -> paused -> resumed, so it 5287ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee // will not cause an extra view to be sent out on rotation 5297ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee if (mIsDialpadShown) { 53058e68a9513495cbe76188d6066c4ffa467313175Yorke Lee Logger.logScreenView(ScreenEvent.DIALPAD, this); 5317ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee } 5327ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee mIsRestarting = false; 5337ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee } 53475d5b2d7d73e184ed813cc5b42b19d7e21b6bd8cAndrew Lee 53553a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee prepareVoiceSearchButton(); 536fce269a30e2ec112ea4c287d97e08ef7b3b31b89Yorke Lee mDialerDatabaseHelper.startSmartDialUpdateThread(); 5376324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee mFloatingActionButtonController.align(getFabAlignment(), false /* animate */); 538d5de03bcc20fcdb667fdc9d0eb56f0d6c57da0c8Nancy Chen 53949aa5bf33be8b96d6409168cddbb819bc7539fabYorke Lee if (Calls.CONTENT_TYPE.equals(getIntent().getType())) { 54049aa5bf33be8b96d6409168cddbb819bc7539fabYorke Lee // Externally specified extras take precedence to EXTRA_SHOW_TAB, which is only 54149aa5bf33be8b96d6409168cddbb819bc7539fabYorke Lee // used internally. 54249aa5bf33be8b96d6409168cddbb819bc7539fabYorke Lee final Bundle extras = getIntent().getExtras(); 54349aa5bf33be8b96d6409168cddbb819bc7539fabYorke Lee if (extras != null 54449aa5bf33be8b96d6409168cddbb819bc7539fabYorke Lee && extras.getInt(Calls.EXTRA_CALL_TYPE_FILTER) == Calls.VOICEMAIL_TYPE) { 54549aa5bf33be8b96d6409168cddbb819bc7539fabYorke Lee mListsFragment.showTab(ListsFragment.TAB_INDEX_VOICEMAIL); 54649aa5bf33be8b96d6409168cddbb819bc7539fabYorke Lee } else { 54749aa5bf33be8b96d6409168cddbb819bc7539fabYorke Lee mListsFragment.showTab(ListsFragment.TAB_INDEX_HISTORY); 54849aa5bf33be8b96d6409168cddbb819bc7539fabYorke Lee } 54949aa5bf33be8b96d6409168cddbb819bc7539fabYorke Lee } else if (getIntent().hasExtra(EXTRA_SHOW_TAB)) { 550d5de03bcc20fcdb667fdc9d0eb56f0d6c57da0c8Nancy Chen int index = getIntent().getIntExtra(EXTRA_SHOW_TAB, ListsFragment.TAB_INDEX_SPEED_DIAL); 551d5de03bcc20fcdb667fdc9d0eb56f0d6c57da0c8Nancy Chen if (index < mListsFragment.getTabCount()) { 552d5de03bcc20fcdb667fdc9d0eb56f0d6c57da0c8Nancy Chen mListsFragment.showTab(index); 553d5de03bcc20fcdb667fdc9d0eb56f0d6c57da0c8Nancy Chen } 554d5de03bcc20fcdb667fdc9d0eb56f0d6c57da0c8Nancy Chen } 555d5de03bcc20fcdb667fdc9d0eb56f0d6c57da0c8Nancy Chen 5563520800e124f5871ab64721f9fb7049ecfa0cc54Anne Rong setSearchBoxHint(); 5573520800e124f5871ab64721f9fb7049ecfa0cc54Anne Rong 558f5554ceb3c152949b4b6278b7f5e1522148a574cYorke Lee Trace.endSection(); 559c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee } 56094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 561c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee @Override 5627ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee protected void onRestart() { 5637ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee super.onRestart(); 5647ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee mIsRestarting = true; 5657ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee } 5667ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee 5677ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee @Override 5688e5c8b11eb9516fa9b8407e0aa16c0405b5e717eYorke Lee protected void onPause() { 569cb55981252b49e476e1adf9f2d5ec19a658d2aa4Sarmad Hashmi // Only clear missed calls if the pause was not triggered by an orientation change 570cb55981252b49e476e1adf9f2d5ec19a658d2aa4Sarmad Hashmi // (or any other confirguration change) 571cb55981252b49e476e1adf9f2d5ec19a658d2aa4Sarmad Hashmi if (!isChangingConfigurations()) { 572cb55981252b49e476e1adf9f2d5ec19a658d2aa4Sarmad Hashmi updateMissedCalls(); 573cb55981252b49e476e1adf9f2d5ec19a658d2aa4Sarmad Hashmi } 5748e5c8b11eb9516fa9b8407e0aa16c0405b5e717eYorke Lee if (mClearSearchOnPause) { 5758e5c8b11eb9516fa9b8407e0aa16c0405b5e717eYorke Lee hideDialpadAndSearchUi(); 5768e5c8b11eb9516fa9b8407e0aa16c0405b5e717eYorke Lee mClearSearchOnPause = false; 5778e5c8b11eb9516fa9b8407e0aa16c0405b5e717eYorke Lee } 57819e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee if (mSlideOut.hasStarted() && !mSlideOut.hasEnded()) { 57919e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee commitDialpadFragmentHide(); 58019e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee } 5818e5c8b11eb9516fa9b8407e0aa16c0405b5e717eYorke Lee super.onPause(); 5828e5c8b11eb9516fa9b8407e0aa16c0405b5e717eYorke Lee } 5838e5c8b11eb9516fa9b8407e0aa16c0405b5e717eYorke Lee 5848e5c8b11eb9516fa9b8407e0aa16c0405b5e717eYorke Lee @Override 585ef2b7388569a94432278a617b528f628385fbb8cYorke Lee protected void onSaveInstanceState(Bundle outState) { 586ef2b7388569a94432278a617b528f628385fbb8cYorke Lee super.onSaveInstanceState(outState); 587ef2b7388569a94432278a617b528f628385fbb8cYorke Lee outState.putString(KEY_SEARCH_QUERY, mSearchQuery); 588b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee outState.putBoolean(KEY_IN_REGULAR_SEARCH_UI, mInRegularSearch); 589b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee outState.putBoolean(KEY_IN_DIALPAD_SEARCH_UI, mInDialpadSearch); 590ef2b7388569a94432278a617b528f628385fbb8cYorke Lee outState.putBoolean(KEY_FIRST_LAUNCH, mFirstLaunch); 59150aba888d4563e755251d97c2ba11a96caee58b1Yorke Lee outState.putBoolean(KEY_IS_DIALPAD_SHOWN, mIsDialpadShown); 5925253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee mActionBarController.saveInstanceState(outState); 59319e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee mStateSaved = true; 594ef2b7388569a94432278a617b528f628385fbb8cYorke Lee } 595ef2b7388569a94432278a617b528f628385fbb8cYorke Lee 596ef2b7388569a94432278a617b528f628385fbb8cYorke Lee @Override 597c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee public void onAttachFragment(Fragment fragment) { 598ef2b7388569a94432278a617b528f628385fbb8cYorke Lee if (fragment instanceof DialpadFragment) { 599ef2b7388569a94432278a617b528f628385fbb8cYorke Lee mDialpadFragment = (DialpadFragment) fragment; 600d5c512afca0341039e494e4df976b18ff07d146aYorke Lee if (!mIsDialpadShown && !mShowDialpadOnResume) { 60150aba888d4563e755251d97c2ba11a96caee58b1Yorke Lee final FragmentTransaction transaction = getFragmentManager().beginTransaction(); 60250aba888d4563e755251d97c2ba11a96caee58b1Yorke Lee transaction.hide(mDialpadFragment); 60350aba888d4563e755251d97c2ba11a96caee58b1Yorke Lee transaction.commit(); 60450aba888d4563e755251d97c2ba11a96caee58b1Yorke Lee } 605ef2b7388569a94432278a617b528f628385fbb8cYorke Lee } else if (fragment instanceof SmartDialSearchFragment) { 606ef2b7388569a94432278a617b528f628385fbb8cYorke Lee mSmartDialSearchFragment = (SmartDialSearchFragment) fragment; 6074e28c1d175a1a9e565b974c85a54709f41ee925bYorke Lee mSmartDialSearchFragment.setOnPhoneNumberPickerActionListener(this); 608d9a9316985a77fb8a9562f8086e36d3722f19d5cYorke Lee if (!TextUtils.isEmpty(mDialpadQuery)) { 609d9a9316985a77fb8a9562f8086e36d3722f19d5cYorke Lee mSmartDialSearchFragment.setAddToContactNumber(mDialpadQuery); 610d9a9316985a77fb8a9562f8086e36d3722f19d5cYorke Lee } 611ef2b7388569a94432278a617b528f628385fbb8cYorke Lee } else if (fragment instanceof SearchFragment) { 6122e5b34b14181f367ec90198f5cbcd39f261b7bf5Jay Shrauner mRegularSearchFragment = (RegularSearchFragment) fragment; 6134e28c1d175a1a9e565b974c85a54709f41ee925bYorke Lee mRegularSearchFragment.setOnPhoneNumberPickerActionListener(this); 614e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee } else if (fragment instanceof ListsFragment) { 615e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee mListsFragment = (ListsFragment) fragment; 616cc4660d463daa11b969fd9b8bdd308ae3416c67aYorke Lee mListsFragment.addOnPageChangeListener(this); 61794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 618c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee } 619c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee 620b453e5b0ce106987c75901321ceba13ed111222cAlon Albert protected void handleMenuSettings() { 621af6f195af0bb200d1bb06ad11dac476e8dff0073Yorke Lee final Intent intent = new Intent(this, DialerSettingsActivity.class); 622af6f195af0bb200d1bb06ad11dac476e8dff0073Yorke Lee startActivity(intent); 623b453e5b0ce106987c75901321ceba13ed111222cAlon Albert } 624b453e5b0ce106987c75901321ceba13ed111222cAlon Albert 62594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng @Override 62694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public void onClick(View view) { 62768d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal int resId = view.getId(); 62868d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal if (resId == R.id.floating_action_button) { 62968d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal if (mListsFragment.getCurrentTabIndex() 63068d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal == ListsFragment.TAB_INDEX_ALL_CONTACTS && !mInRegularSearch) { 63168d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal DialerUtils.startActivityWithErrorToast( 63268d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal this, 63368d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal IntentUtil.getNewContactIntent(), 63468d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal R.string.add_contact_not_available); 63568d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal } else if (!mIsDialpadShown) { 63668d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal mInCallDialpadUp = false; 63768d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal showDialpadFragment(true); 63868d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal } 63968d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal } else if (resId == R.id.voice_search_button) { 64068d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal try { 64168d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal startActivityForResult(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 64268d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal ACTIVITY_REQUEST_CODE_VOICE_SEARCH); 64368d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal } catch (ActivityNotFoundException e) { 64468d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal Toast.makeText(DialtactsActivity.this, R.string.voice_search_not_available, 64568d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal Toast.LENGTH_SHORT).show(); 64694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 64768d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal } else if (resId == R.id.dialtacts_options_menu_button) { 64868d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal mOverflowMenu.show(); 64968d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal } else { 65068d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal Log.wtf(TAG, "Unexpected onClick event from " + view); 65194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 65294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 65394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 654c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee @Override 655e74a10eab5d8a43918a540bc42f0c159bdf5ab7cAndrew Lee public boolean onMenuItemClick(MenuItem item) { 656193cfc5458c5c2bb1f9800c98f179292732aa0a8Jay Shrauner if (!isSafeToCommitTransactions()) { 657119b06565c54f3bbe70555d8c5aba6065e6c9ad2Jay Shrauner return true; 658119b06565c54f3bbe70555d8c5aba6065e6c9ad2Jay Shrauner } 659119b06565c54f3bbe70555d8c5aba6065e6c9ad2Jay Shrauner 66068d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal int resId = item.getItemId(); 66168d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal if (resId == R.id.menu_history) {// Use explicit CallLogActivity intent instead of ACTION_VIEW + 66268d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal // CONTENT_TYPE, so that we always open our call log from our dialer 66368d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal final Intent intent = new Intent(this, CallLogActivity.class); 66468d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal startActivity(intent); 66568d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal } else if (resId == R.id.menu_add_contact) { 66668d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal DialerUtils.startActivityWithErrorToast( 66768d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal this, 66868d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal IntentUtil.getNewContactIntent(), 66968d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal R.string.add_contact_not_available); 67068d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal } else if (resId == R.id.menu_import_export) {// We hard-code the "contactsAreAvailable" argument because doing it properly would 67168d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal // involve querying a {@link ProviderStatusLoader}, which we don't want to do right 67268d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal // now in Dialtacts for (potential) performance reasons. Compare with how it is 67368d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal // done in {@link PeopleActivity}. 67468d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal if (mListsFragment.getCurrentTabIndex() == ListsFragment.TAB_INDEX_SPEED_DIAL) { 67568d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal ImportExportDialogFragment.show(getFragmentManager(), true, 67668d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal DialtactsActivity.class, ImportExportDialogFragment.EXPORT_MODE_FAVORITES); 67768d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal } else { 67868d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal ImportExportDialogFragment.show(getFragmentManager(), true, 67968d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal DialtactsActivity.class, ImportExportDialogFragment.EXPORT_MODE_DEFAULT); 68068d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal } 68168d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal Logger.logScreenView(ScreenEvent.IMPORT_EXPORT_CONTACTS, this); 68268d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal return true; 68368d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal } else if (resId == R.id.menu_clear_frequents) { 68468d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal ClearFrequentsDialog.show(getFragmentManager()); 68568d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal Logger.logScreenView(ScreenEvent.CLEAR_FREQUENTS, this); 68668d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal return true; 68768d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal } else if (resId == R.id.menu_call_settings) { 68868d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal handleMenuSettings(); 68968d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal Logger.logScreenView(ScreenEvent.SETTINGS, this); 69068d86c656e5522dec1b04e85ebc0e0f78e436c3dSailesh Nepal return true; 6913694b119843c161c3fdcf0820ec8bf755c79158fSarmad Hashmi } else if (resId == R.id.menu_archive) { 6923694b119843c161c3fdcf0820ec8bf755c79158fSarmad Hashmi final Intent intent = new Intent(this, VoicemailArchiveActivity.class); 6933694b119843c161c3fdcf0820ec8bf755c79158fSarmad Hashmi startActivity(intent); 6943694b119843c161c3fdcf0820ec8bf755c79158fSarmad Hashmi return true; 69586e21f733049560e77b92f17a58474312d72ec3eYorke Lee } 69686e21f733049560e77b92f17a58474312d72ec3eYorke Lee return false; 69786e21f733049560e77b92f17a58474312d72ec3eYorke Lee } 69886e21f733049560e77b92f17a58474312d72ec3eYorke Lee 69986e21f733049560e77b92f17a58474312d72ec3eYorke Lee @Override 700c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee protected void onActivityResult(int requestCode, int resultCode, Intent data) { 701c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee if (requestCode == ACTIVITY_REQUEST_CODE_VOICE_SEARCH) { 702c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee if (resultCode == RESULT_OK) { 703c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee final ArrayList<String> matches = data.getStringArrayListExtra( 704c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee RecognizerIntent.EXTRA_RESULTS); 705c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee if (matches.size() > 0) { 706c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee final String match = matches.get(0); 707c1cfae553cc08c832155eb5b951690a4e349b5bcTyler Gunn mVoiceSearchQuery = match; 708c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee } else { 709c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee Log.e(TAG, "Voice search - nothing heard"); 710c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee } 711c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee } else { 712c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee Log.e(TAG, "Voice search failed"); 713c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee } 714c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee } 715c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee super.onActivityResult(requestCode, resultCode, data); 716c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee } 71794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 7182a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee /** 719ea7c0b859a57a5c61c701bf0b710b44775f537c3Nancy Chen * Update the number of unread voicemails (potentially other tabs) displayed next to the tab 720ea7c0b859a57a5c61c701bf0b710b44775f537c3Nancy Chen * icon. 721ea7c0b859a57a5c61c701bf0b710b44775f537c3Nancy Chen */ 722ea7c0b859a57a5c61c701bf0b710b44775f537c3Nancy Chen public void updateTabUnreadCounts() { 723ea7c0b859a57a5c61c701bf0b710b44775f537c3Nancy Chen mListsFragment.updateTabUnreadCounts(); 724ea7c0b859a57a5c61c701bf0b710b44775f537c3Nancy Chen } 725ea7c0b859a57a5c61c701bf0b710b44775f537c3Nancy Chen 726ea7c0b859a57a5c61c701bf0b710b44775f537c3Nancy Chen /** 7272a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee * Initiates a fragment transaction to show the dialpad fragment. Animations and other visual 7282a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee * updates are handled by a callback which is invoked after the dialpad fragment is shown. 7292a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee * @see #onDialpadShown 7302a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee */ 731c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee private void showDialpadFragment(boolean animate) { 73219e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee if (mIsDialpadShown || mStateSaved) { 7332a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee return; 7342a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee } 7352a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee mIsDialpadShown = true; 736d5c512afca0341039e494e4df976b18ff07d146aYorke Lee 7377ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee mListsFragment.setUserVisibleHint(false); 738cdfa6c66fa29ee0de675cd77b3bc72f6fba5ef0cAndrew Lee 739c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee final FragmentTransaction ft = getFragmentManager().beginTransaction(); 740d5c512afca0341039e494e4df976b18ff07d146aYorke Lee if (mDialpadFragment == null) { 741d5c512afca0341039e494e4df976b18ff07d146aYorke Lee mDialpadFragment = new DialpadFragment(); 742d5c512afca0341039e494e4df976b18ff07d146aYorke Lee ft.add(R.id.dialtacts_container, mDialpadFragment, TAG_DIALPAD_FRAGMENT); 743d5c512afca0341039e494e4df976b18ff07d146aYorke Lee } else { 744d5c512afca0341039e494e4df976b18ff07d146aYorke Lee ft.show(mDialpadFragment); 745d5c512afca0341039e494e4df976b18ff07d146aYorke Lee } 746d5c512afca0341039e494e4df976b18ff07d146aYorke Lee 747d5c512afca0341039e494e4df976b18ff07d146aYorke Lee mDialpadFragment.setAnimate(animate); 74858e68a9513495cbe76188d6066c4ffa467313175Yorke Lee Logger.logScreenView(ScreenEvent.DIALPAD, this); 7492a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee ft.commit(); 750b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee 75129ae4ae721a1f6d89a8fdca0fd4d49a1e5ecc4a7Yorke Lee if (animate) { 75229ae4ae721a1f6d89a8fdca0fd4d49a1e5ecc4a7Yorke Lee mFloatingActionButtonController.scaleOut(); 75329ae4ae721a1f6d89a8fdca0fd4d49a1e5ecc4a7Yorke Lee } else { 75429ae4ae721a1f6d89a8fdca0fd4d49a1e5ecc4a7Yorke Lee mFloatingActionButtonController.setVisible(false); 75581a313dfd824a4aafe86e636c537a08bae0c1e0bYorke Lee maybeEnterSearchUi(); 75629ae4ae721a1f6d89a8fdca0fd4d49a1e5ecc4a7Yorke Lee } 7575253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee mActionBarController.onDialpadUp(); 7585253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee 7596c450eb606f9e052a152e37759d3866cb605e1baYorke Lee mListsFragment.getView().animate().alpha(0).withLayer(); 760e3cae63fc19a431d902fb8ae50eab732e735b2a0Ta-wei Yen 761e3cae63fc19a431d902fb8ae50eab732e735b2a0Ta-wei Yen //adjust the title, so the user will know where we're at when the activity start/resumes. 762e3cae63fc19a431d902fb8ae50eab732e735b2a0Ta-wei Yen setTitle(R.string.launcherDialpadActivityLabel); 7632a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee } 7642a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee 7652a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee /** 7662a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee * Callback from child DialpadFragment when the dialpad is shown. 7672a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee */ 7682a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee public void onDialpadShown() { 769d5c512afca0341039e494e4df976b18ff07d146aYorke Lee Assert.assertNotNull(mDialpadFragment); 7702a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee if (mDialpadFragment.getAnimate()) { 77182d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati mDialpadFragment.getView().startAnimation(mSlideIn); 772ea695cb0f877ad49a98df184efe982de83ed09d7Yorke Lee } else { 773ea695cb0f877ad49a98df184efe982de83ed09d7Yorke Lee mDialpadFragment.setYFraction(0); 774c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee } 7752a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee 7762a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee updateSearchFragmentPosition(); 777c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee } 778c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee 7792a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee /** 7802a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee * Initiates animations and other visual updates to hide the dialpad. The fragment is hidden in 7812a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee * a callback after the hide animation ends. 7822a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee * @see #commitDialpadFragmentHide 7832a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee */ 784ca19504ff58c91497885d9705905f7ab25e97ce0Yorke Lee public void hideDialpadFragment(boolean animate, boolean clearDialpad) { 785791b488fb8f835bb7976cb1f839a0b3ccf04132cYorke Lee if (mDialpadFragment == null || mDialpadFragment.getView() == null) { 7862a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee return; 7872a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee } 788f6673d3e5cbd10febea04f02035591ab15c5c7c0Yorke Lee if (clearDialpad) { 789af875ddb29639a62125f667bd8488ab9f07f11b5Ta-wei Yen // Temporarily disable accessibility when we clear the dialpad, since it should be 790af875ddb29639a62125f667bd8488ab9f07f11b5Ta-wei Yen // invisible and should not announce anything. 791af875ddb29639a62125f667bd8488ab9f07f11b5Ta-wei Yen mDialpadFragment.getDigitsWidget().setImportantForAccessibility( 792af875ddb29639a62125f667bd8488ab9f07f11b5Ta-wei Yen View.IMPORTANT_FOR_ACCESSIBILITY_NO); 793f6673d3e5cbd10febea04f02035591ab15c5c7c0Yorke Lee mDialpadFragment.clearDialpad(); 794af875ddb29639a62125f667bd8488ab9f07f11b5Ta-wei Yen mDialpadFragment.getDigitsWidget().setImportantForAccessibility( 795af875ddb29639a62125f667bd8488ab9f07f11b5Ta-wei Yen View.IMPORTANT_FOR_ACCESSIBILITY_AUTO); 796f6673d3e5cbd10febea04f02035591ab15c5c7c0Yorke Lee } 7972a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee if (!mIsDialpadShown) { 7982a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee return; 7992a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee } 8002a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee mIsDialpadShown = false; 801cdfa6c66fa29ee0de675cd77b3bc72f6fba5ef0cAndrew Lee mDialpadFragment.setAnimate(animate); 8027ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee mListsFragment.setUserVisibleHint(true); 8037ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee mListsFragment.sendScreenViewForCurrentPosition(); 8042a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee 805dbe9a8c18bec55943c2239f1381774a6a4ba2a59Andrew Lee updateSearchFragmentPosition(); 806c4969ea3d2ac04f58f0caccef709bc95a182c378Sai Cheemalapati 8076324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee mFloatingActionButtonController.align(getFabAlignment(), animate); 808c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee if (animate) { 80982d6da53d993bb3a5cabf7c9f5f0c0e62488c15fSai Cheemalapati mDialpadFragment.getView().startAnimation(mSlideOut); 8102a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee } else { 8112a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee commitDialpadFragmentHide(); 812c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee } 813b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee 8145253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee mActionBarController.onDialpadDown(); 81511ca39eae2bd8ed5c3e21e8c4fa09c9b2b6bda51Yorke Lee 816d4cde838ea2bc23679e8656d04ed096e82d938d4Andrew Lee if (isInSearchUi()) { 81744e3daf13a1dfe5a0c7b4b0737f4000aea8fda27Andrew Lee if (TextUtils.isEmpty(mSearchQuery)) { 81844e3daf13a1dfe5a0c7b4b0737f4000aea8fda27Andrew Lee exitSearchUi(); 81944e3daf13a1dfe5a0c7b4b0737f4000aea8fda27Andrew Lee } 820d4cde838ea2bc23679e8656d04ed096e82d938d4Andrew Lee } 821e3cae63fc19a431d902fb8ae50eab732e735b2a0Ta-wei Yen //reset the title to normal. 822e3cae63fc19a431d902fb8ae50eab732e735b2a0Ta-wei Yen setTitle(R.string.launcherActivityLabel); 823311969c96e36da85118d4aabdddbd98e5ab6a3c8Yorke Lee } 824311969c96e36da85118d4aabdddbd98e5ab6a3c8Yorke Lee 82586e21f733049560e77b92f17a58474312d72ec3eYorke Lee /** 8262a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee * Finishes hiding the dialpad fragment after any animations are completed. 82786e21f733049560e77b92f17a58474312d72ec3eYorke Lee */ 8282a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee private void commitDialpadFragmentHide() { 829d5c512afca0341039e494e4df976b18ff07d146aYorke Lee if (!mStateSaved && mDialpadFragment != null && !mDialpadFragment.isHidden()) { 83019e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee final FragmentTransaction ft = getFragmentManager().beginTransaction(); 83119e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee ft.hide(mDialpadFragment); 83219e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee ft.commit(); 83319e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee } 834405a6e6822fb19a9d14329da92e03e75e2e72703Andrew Lee mFloatingActionButtonController.scaleIn(AnimUtils.NO_DELAY); 8352a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee } 83686e21f733049560e77b92f17a58474312d72ec3eYorke Lee 8372a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee private void updateSearchFragmentPosition() { 83886e21f733049560e77b92f17a58474312d72ec3eYorke Lee SearchFragment fragment = null; 839dbe9a8c18bec55943c2239f1381774a6a4ba2a59Andrew Lee if (mSmartDialSearchFragment != null && mSmartDialSearchFragment.isVisible()) { 84086e21f733049560e77b92f17a58474312d72ec3eYorke Lee fragment = mSmartDialSearchFragment; 841dbe9a8c18bec55943c2239f1381774a6a4ba2a59Andrew Lee } else if (mRegularSearchFragment != null && mRegularSearchFragment.isVisible()) { 84286e21f733049560e77b92f17a58474312d72ec3eYorke Lee fragment = mRegularSearchFragment; 84386e21f733049560e77b92f17a58474312d72ec3eYorke Lee } 84486e21f733049560e77b92f17a58474312d72ec3eYorke Lee if (fragment != null && fragment.isVisible()) { 8459da8fb46fa21159321295119e1b2075747cfbbf9Andrew Lee fragment.updatePosition(true /* animate */); 84686e21f733049560e77b92f17a58474312d72ec3eYorke Lee } 847c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee } 848c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee 8495253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee @Override 8505253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee public boolean isInSearchUi() { 8512a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee return mInDialpadSearch || mInRegularSearch; 8522a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee } 853526c0b832e27dc38a8dc6eae1f16c50acb51c6e8Ihab Awad 8545253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee @Override 8555253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee public boolean hasSearchQuery() { 8565253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee return !TextUtils.isEmpty(mSearchQuery); 8575253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee } 8585253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee 8595253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee @Override 8605253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee public boolean shouldShowActionBar() { 8615253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee return mListsFragment.shouldShowActionBar(); 8625253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee } 8635253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee 8642a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee private void setNotInSearchUi() { 8652a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee mInDialpadSearch = false; 8662a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee mInRegularSearch = false; 8672a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee } 8680c66770b304d03367f093e1916cf565d9cf70146Andrew Lee 8692a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee private void hideDialpadAndSearchUi() { 870710709da8389d401d3089bbf9836dfca527f15c3Yorke Lee if (mIsDialpadShown) { 871710709da8389d401d3089bbf9836dfca527f15c3Yorke Lee hideDialpadFragment(false, true); 872710709da8389d401d3089bbf9836dfca527f15c3Yorke Lee } else { 873710709da8389d401d3089bbf9836dfca527f15c3Yorke Lee exitSearchUi(); 874710709da8389d401d3089bbf9836dfca527f15c3Yorke Lee } 8759c1e0653addc1fff03601289a9f9a57b1daeaf57Christine Chen } 8769c1e0653addc1fff03601289a9f9a57b1daeaf57Christine Chen 87753a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee private void prepareVoiceSearchButton() { 87853a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee final Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); 87953a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee if (canIntentBeHandled(voiceIntent)) { 88053a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee mVoiceSearchButton.setVisibility(View.VISIBLE); 88153a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee mVoiceSearchButton.setOnClickListener(this); 88253a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee } else { 88353a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee mVoiceSearchButton.setVisibility(View.GONE); 88453a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee } 88553a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee } 88653a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee 887e9c8233a77d6daa5374e146e1c871e000d7657e4Yorke Lee public boolean isNearbyPlacesSearchEnabled() { 888e9c8233a77d6daa5374e146e1c871e000d7657e4Yorke Lee return false; 889e9c8233a77d6daa5374e146e1c871e000d7657e4Yorke Lee } 890e9c8233a77d6daa5374e146e1c871e000d7657e4Yorke Lee 8913520800e124f5871ab64721f9fb7049ecfa0cc54Anne Rong protected int getSearchBoxHint () { 8923520800e124f5871ab64721f9fb7049ecfa0cc54Anne Rong return R.string.dialer_hint_find_contact; 8933520800e124f5871ab64721f9fb7049ecfa0cc54Anne Rong } 8943520800e124f5871ab64721f9fb7049ecfa0cc54Anne Rong 8953520800e124f5871ab64721f9fb7049ecfa0cc54Anne Rong /** 8963520800e124f5871ab64721f9fb7049ecfa0cc54Anne Rong * Sets the hint text for the contacts search box 8973520800e124f5871ab64721f9fb7049ecfa0cc54Anne Rong */ 8983520800e124f5871ab64721f9fb7049ecfa0cc54Anne Rong private void setSearchBoxHint() { 89944898ad0aa2a12788fc9cfc6b78fa7adc9d90f23Nancy Chen SearchEditTextLayout searchEditTextLayout = (SearchEditTextLayout) getSupportActionBar() 9003520800e124f5871ab64721f9fb7049ecfa0cc54Anne Rong .getCustomView().findViewById(R.id.search_view_container); 9013520800e124f5871ab64721f9fb7049ecfa0cc54Anne Rong ((TextView) searchEditTextLayout.findViewById(R.id.search_box_start_search)) 9023520800e124f5871ab64721f9fb7049ecfa0cc54Anne Rong .setHint(getSearchBoxHint()); 9033520800e124f5871ab64721f9fb7049ecfa0cc54Anne Rong } 9043520800e124f5871ab64721f9fb7049ecfa0cc54Anne Rong 905467de3dc2be8fa6c815782852f47a752eb77a6dcAndrew Lee protected OptionsPopupMenu buildOptionsMenu(View invoker) { 906e74a10eab5d8a43918a540bc42f0c159bdf5ab7cAndrew Lee final OptionsPopupMenu popupMenu = new OptionsPopupMenu(this, invoker); 907e74a10eab5d8a43918a540bc42f0c159bdf5ab7cAndrew Lee popupMenu.inflate(R.menu.dialtacts_options); 90878f55ff9587f427ea97017dd270c9a772b82082dSarmad Hashmi if (ObjectFactory.isVoicemailArchiveEnabled(this)) { 90978f55ff9587f427ea97017dd270c9a772b82082dSarmad Hashmi popupMenu.getMenu().findItem(R.id.menu_archive).setVisible(true); 91078f55ff9587f427ea97017dd270c9a772b82082dSarmad Hashmi } 911e74a10eab5d8a43918a540bc42f0c159bdf5ab7cAndrew Lee popupMenu.setOnMenuItemClickListener(this); 912e74a10eab5d8a43918a540bc42f0c159bdf5ab7cAndrew Lee return popupMenu; 913e74a10eab5d8a43918a540bc42f0c159bdf5ab7cAndrew Lee } 914e74a10eab5d8a43918a540bc42f0c159bdf5ab7cAndrew Lee 91586e21f733049560e77b92f17a58474312d72ec3eYorke Lee @Override 91686e21f733049560e77b92f17a58474312d72ec3eYorke Lee public boolean onCreateOptionsMenu(Menu menu) { 9173c9e7cd12f28c7e79a4b2af442c32f2b519122f1Yorke Lee if (mPendingSearchViewQuery != null) { 91853a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee mSearchView.setText(mPendingSearchViewQuery); 9193c9e7cd12f28c7e79a4b2af442c32f2b519122f1Yorke Lee mPendingSearchViewQuery = null; 9203c9e7cd12f28c7e79a4b2af442c32f2b519122f1Yorke Lee } 921c16ea5ad67bf454158b364dec2f26c95a879c350Yorke Lee if (mActionBarController != null) { 922c16ea5ad67bf454158b364dec2f26c95a879c350Yorke Lee mActionBarController.restoreActionBarOffset(); 923c16ea5ad67bf454158b364dec2f26c95a879c350Yorke Lee } 924e74a10eab5d8a43918a540bc42f0c159bdf5ab7cAndrew Lee return false; 925fb00cb8395f99842a41fd68980b2e87ae840c617Ihab Awad } 926fb00cb8395f99842a41fd68980b2e87ae840c617Ihab Awad 92794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng /** 92894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Returns true if the intent is due to hitting the green send key (hardware call button: 92994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * KEYCODE_CALL) while in a call. 93094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * 93194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * @param intent the intent that launched this activity 93294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * @return true if the intent is due to hitting the green send key while in a call 93394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng */ 93462e995c9bebc02c1a33ffb8d8df142b9a31cab1bYorke Lee private boolean isSendKeyWhileInCall(Intent intent) { 93562e995c9bebc02c1a33ffb8d8df142b9a31cab1bYorke Lee // If there is a call in progress and the user launched the dialer by hitting the call 93662e995c9bebc02c1a33ffb8d8df142b9a31cab1bYorke Lee // button, go straight to the in-call screen. 93762e995c9bebc02c1a33ffb8d8df142b9a31cab1bYorke Lee final boolean callKey = Intent.ACTION_CALL_BUTTON.equals(intent.getAction()); 93862e995c9bebc02c1a33ffb8d8df142b9a31cab1bYorke Lee 9391d7ef6a59ae175d1577ca707e2682924a60d341dSantos Cordon if (callKey) { 940762b357ec94aef3e7ee6f991c553aa950840a8bcYorke Lee TelecomUtil.showInCallScreen(this, false); 9411d7ef6a59ae175d1577ca707e2682924a60d341dSantos Cordon return true; 94294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 94394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 94494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng return false; 94594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 94694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 94794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng /** 94894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * Sets the current tab based on the intent's request type 94994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * 95094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng * @param intent Intent that contains information about which tab should be selected 95194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng */ 952c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee private void displayFragment(Intent intent) { 95394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng // If we got here by hitting send and we're in call forward along to the in-call activity 95462e995c9bebc02c1a33ffb8d8df142b9a31cab1bYorke Lee if (isSendKeyWhileInCall(intent)) { 95594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng finish(); 95694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng return; 95794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 95894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 959d77017d981b11611657f74f48290e88b7fa99c7bYorke Lee final boolean showDialpadChooser = phoneIsInUse() && !DialpadFragment.isAddCallMode(intent); 960d77017d981b11611657f74f48290e88b7fa99c7bYorke Lee if (showDialpadChooser || (intent.getData() != null && isDialIntent(intent))) { 961d5c512afca0341039e494e4df976b18ff07d146aYorke Lee showDialpadFragment(false); 962d5c512afca0341039e494e4df976b18ff07d146aYorke Lee mDialpadFragment.setStartedFromNewIntent(true); 963d77017d981b11611657f74f48290e88b7fa99c7bYorke Lee if (showDialpadChooser && !mDialpadFragment.isVisible()) { 964d5c512afca0341039e494e4df976b18ff07d146aYorke Lee mInCallDialpadUp = true; 96535127cdea7f9043626ae9d0c6becb31730d0b236Yorke Lee } 96694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 96794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 96894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 96994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng @Override 97094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng public void onNewIntent(Intent newIntent) { 97194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng setIntent(newIntent); 97224d034f92998a52868c10039e9c728f9ab5a44aaYorke Lee 973199b7f007decf08652d3f7825ed1e042fc68d8edNancy Chen mStateSaved = false; 974c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee displayFragment(newIntent); 975c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee 97694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng invalidateOptionsMenu(); 97794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 97894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 97994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng /** Returns true if the given intent contains a phone number to populate the dialer with */ 98094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng private boolean isDialIntent(Intent intent) { 98194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng final String action = intent.getAction(); 98294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng if (Intent.ACTION_DIAL.equals(action) || ACTION_TOUCH_DIALER.equals(action)) { 98394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng return true; 98494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 98594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng if (Intent.ACTION_VIEW.equals(action)) { 98694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng final Uri data = intent.getData(); 987ae274c05cdb6707ca9593bedf20c016cd8164c0bJay Shrauner if (data != null && PhoneAccount.SCHEME_TEL.equals(data.getScheme())) { 98894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng return true; 98994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 99094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 99194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng return false; 99294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 99394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 99494b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng /** 995c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee * Shows the search fragment 99694b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng */ 9976c450eb606f9e052a152e37759d3866cb605e1baYorke Lee private void enterSearchUi(boolean smartDialSearch, String query, boolean animate) { 99819e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee if (mStateSaved || getFragmentManager().isDestroyed()) { 99934bdf87700194c35ab8f43c001391bb2ac8bc993Yorke Lee // Weird race condition where fragment is doing work after the activity is destroyed 100034bdf87700194c35ab8f43c001391bb2ac8bc993Yorke Lee // due to talkback being on (b/10209937). Just return since we can't do any 100134bdf87700194c35ab8f43c001391bb2ac8bc993Yorke Lee // constructive here. 100234bdf87700194c35ab8f43c001391bb2ac8bc993Yorke Lee return; 100334bdf87700194c35ab8f43c001391bb2ac8bc993Yorke Lee } 100434bdf87700194c35ab8f43c001391bb2ac8bc993Yorke Lee 1005ef2b7388569a94432278a617b528f628385fbb8cYorke Lee if (DEBUG) { 1006ef2b7388569a94432278a617b528f628385fbb8cYorke Lee Log.d(TAG, "Entering search UI - smart dial " + smartDialSearch); 1007ef2b7388569a94432278a617b528f628385fbb8cYorke Lee } 1008ef2b7388569a94432278a617b528f628385fbb8cYorke Lee 1009c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee final FragmentTransaction transaction = getFragmentManager().beginTransaction(); 1010e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee if (mInDialpadSearch && mSmartDialSearchFragment != null) { 1011b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee transaction.remove(mSmartDialSearchFragment); 1012e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee } else if (mInRegularSearch && mRegularSearchFragment != null) { 1013b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee transaction.remove(mRegularSearchFragment); 1014b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee } 1015b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee 1016b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee final String tag; 1017b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee if (smartDialSearch) { 1018b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee tag = TAG_SMARTDIAL_SEARCH_FRAGMENT; 1019b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee } else { 1020b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee tag = TAG_REGULAR_SEARCH_FRAGMENT; 1021b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee } 1022b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee mInDialpadSearch = smartDialSearch; 1023b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee mInRegularSearch = !smartDialSearch; 1024ef2b7388569a94432278a617b528f628385fbb8cYorke Lee 10256324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee mFloatingActionButtonController.scaleOut(); 10266324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee 1027752956e3add8b9fff107e1637120a74a61a5feadAndrew Lee SearchFragment fragment = (SearchFragment) getFragmentManager().findFragmentByTag(tag); 10286c450eb606f9e052a152e37759d3866cb605e1baYorke Lee if (animate) { 10296c450eb606f9e052a152e37759d3866cb605e1baYorke Lee transaction.setCustomAnimations(android.R.animator.fade_in, 0); 10306c450eb606f9e052a152e37759d3866cb605e1baYorke Lee } else { 10316c450eb606f9e052a152e37759d3866cb605e1baYorke Lee transaction.setTransition(FragmentTransaction.TRANSIT_NONE); 10326c450eb606f9e052a152e37759d3866cb605e1baYorke Lee } 1033ef2b7388569a94432278a617b528f628385fbb8cYorke Lee if (fragment == null) { 1034ef2b7388569a94432278a617b528f628385fbb8cYorke Lee if (smartDialSearch) { 1035ef2b7388569a94432278a617b528f628385fbb8cYorke Lee fragment = new SmartDialSearchFragment(); 1036ef2b7388569a94432278a617b528f628385fbb8cYorke Lee } else { 1037807afd8a39366b7423eacd83fb18bff2ba7a0422Yorke Lee fragment = ObjectFactory.newRegularSearchFragment(); 10386324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee fragment.setOnTouchListener(new View.OnTouchListener() { 10396324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee @Override 10406324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee public boolean onTouch(View v, MotionEvent event) { 10416324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee // Show the FAB when the user touches the lists fragment and the soft 10426324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee // keyboard is hidden. 10430bb96ac051bd1d515004db384281452e42f0394eNancy Chen hideDialpadFragment(true, false); 10446324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee showFabInSearchUi(); 10456324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee return false; 10466324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee } 10476324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee }); 1048ef2b7388569a94432278a617b528f628385fbb8cYorke Lee } 1049b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee transaction.add(R.id.dialtacts_frame, fragment, tag); 1050b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee } else { 1051b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee transaction.show(fragment); 105294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 105386e21f733049560e77b92f17a58474312d72ec3eYorke Lee // DialtactsActivity will provide the options menu 105486e21f733049560e77b92f17a58474312d72ec3eYorke Lee fragment.setHasOptionsMenu(false); 1055b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee fragment.setShowEmptyListForNullQuery(true); 10566c450eb606f9e052a152e37759d3866cb605e1baYorke Lee if (!smartDialSearch) { 10576c450eb606f9e052a152e37759d3866cb605e1baYorke Lee fragment.setQueryString(query, false /* delaySelection */); 10586c450eb606f9e052a152e37759d3866cb605e1baYorke Lee } 1059ef2b7388569a94432278a617b528f628385fbb8cYorke Lee transaction.commit(); 1060b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee 10616c450eb606f9e052a152e37759d3866cb605e1baYorke Lee if (animate) { 10626c450eb606f9e052a152e37759d3866cb605e1baYorke Lee mListsFragment.getView().animate().alpha(0).withLayer(); 10636c450eb606f9e052a152e37759d3866cb605e1baYorke Lee } 10647ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee mListsFragment.setUserVisibleHint(false); 1065f96bb18b904dada96002cb72d862097ae344db57Yorke Lee 1066f96bb18b904dada96002cb72d862097ae344db57Yorke Lee if (smartDialSearch) { 1067f96bb18b904dada96002cb72d862097ae344db57Yorke Lee Logger.logScreenView(ScreenEvent.SMART_DIAL_SEARCH, this); 1068f96bb18b904dada96002cb72d862097ae344db57Yorke Lee } else { 1069f96bb18b904dada96002cb72d862097ae344db57Yorke Lee Logger.logScreenView(ScreenEvent.REGULAR_SEARCH, this); 1070f96bb18b904dada96002cb72d862097ae344db57Yorke Lee } 107194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 107294b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 107394b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng /** 1074c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee * Hides the search fragment 107594b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng */ 1076c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee private void exitSearchUi() { 10773487db78fd47ccecef4e6b86e5cacfc0a8e6ba83Yorke Lee // See related bug in enterSearchUI(); 107819e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee if (getFragmentManager().isDestroyed() || mStateSaved) { 10793487db78fd47ccecef4e6b86e5cacfc0a8e6ba83Yorke Lee return; 10803487db78fd47ccecef4e6b86e5cacfc0a8e6ba83Yorke Lee } 1081b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee 1082b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee mSearchView.setText(null); 1083d5c512afca0341039e494e4df976b18ff07d146aYorke Lee 1084d5c512afca0341039e494e4df976b18ff07d146aYorke Lee if (mDialpadFragment != null) { 1085d5c512afca0341039e494e4df976b18ff07d146aYorke Lee mDialpadFragment.clearDialpad(); 1086d5c512afca0341039e494e4df976b18ff07d146aYorke Lee } 1087d5c512afca0341039e494e4df976b18ff07d146aYorke Lee 1088b207f8a073e8b3c001986b31c951f2c951cc631bYorke Lee setNotInSearchUi(); 10897eccf4559e3660da5715b69840b325fd7aa677a4Yorke Lee 10906324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee // Restore the FAB for the lists fragment. 10916324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee if (getFabAlignment() != FloatingActionButtonController.ALIGN_END) { 10926324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee mFloatingActionButtonController.setVisible(false); 10936324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee } 10946324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee mFloatingActionButtonController.scaleIn(FAB_SCALE_IN_DELAY_MS); 10956324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee onPageScrolled(mListsFragment.getCurrentTabIndex(), 0 /* offset */, 0 /* pixelOffset */); 10966324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee onPageSelected(mListsFragment.getCurrentTabIndex()); 10976324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee 1098b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee final FragmentTransaction transaction = getFragmentManager().beginTransaction(); 1099b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee if (mSmartDialSearchFragment != null) { 1100b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee transaction.remove(mSmartDialSearchFragment); 1101b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee } 1102b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee if (mRegularSearchFragment != null) { 1103b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee transaction.remove(mRegularSearchFragment); 11047eccf4559e3660da5715b69840b325fd7aa677a4Yorke Lee } 1105b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee transaction.commit(); 1106b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee 1107b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee mListsFragment.getView().animate().alpha(1).withLayer(); 1108d5c512afca0341039e494e4df976b18ff07d146aYorke Lee 1109d5c512afca0341039e494e4df976b18ff07d146aYorke Lee if (mDialpadFragment == null || !mDialpadFragment.isVisible()) { 11107ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee // If the dialpad fragment wasn't previously visible, then send a screen view because 11117ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee // we are exiting regular search. Otherwise, the screen view will be sent by 11127ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee // {@link #hideDialpadFragment}. 11137ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee mListsFragment.sendScreenViewForCurrentPosition(); 11147ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee mListsFragment.setUserVisibleHint(true); 11157ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee } 11167ee5c422e36cf3d40cbd24bbb5b87754b4820d02Yorke Lee 11175253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee mActionBarController.onSearchUiExited(); 111894b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 111994b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng 112094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng @Override 1121c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee public void onBackPressed() { 112219e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee if (mStateSaved) { 112319e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee return; 112419e68ca002b7586b84fcde5e32eca125e7a033adYorke Lee } 11252a58ab88d23238f252d5ccc6a6798f58b0e9ef56Andrew Lee if (mIsDialpadShown) { 11269fd8f25659185a031b2a7c6120da899e54e41127Andrew Lee if (TextUtils.isEmpty(mSearchQuery) || 11279fd8f25659185a031b2a7c6120da899e54e41127Andrew Lee (mSmartDialSearchFragment != null && mSmartDialSearchFragment.isVisible() 11289fd8f25659185a031b2a7c6120da899e54e41127Andrew Lee && mSmartDialSearchFragment.getAdapter().getCount() == 0)) { 1129b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee exitSearchUi(); 1130b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee } 1131f6673d3e5cbd10febea04f02035591ab15c5c7c0Yorke Lee hideDialpadFragment(true, false); 1132b19038436ce8e4683eb19af02255eda9969a6a94Andrew Lee } else if (isInSearchUi()) { 113399a570c40193320e8640f91a2eb4693e46153703Andrew Lee exitSearchUi(); 1134f614f6fbe3351316af5a6119a866bdf25cb0d7e4Yorke Lee DialerUtils.hideInputMethod(mParentLayout); 1135c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee } else { 1136c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee super.onBackPressed(); 113794b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 1138c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee } 1139c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee 114081a313dfd824a4aafe86e636c537a08bae0c1e0bYorke Lee private void maybeEnterSearchUi() { 114181a313dfd824a4aafe86e636c537a08bae0c1e0bYorke Lee if (!isInSearchUi()) { 114281a313dfd824a4aafe86e636c537a08bae0c1e0bYorke Lee enterSearchUi(true /* isSmartDial */, mSearchQuery, false); 114381a313dfd824a4aafe86e636c537a08bae0c1e0bYorke Lee } 114481a313dfd824a4aafe86e636c537a08bae0c1e0bYorke Lee } 114581a313dfd824a4aafe86e636c537a08bae0c1e0bYorke Lee 1146c7b2a0e30aba4505a041a9ad0f8889f4891d30f8Yorke Lee /** 1147c7b2a0e30aba4505a041a9ad0f8889f4891d30f8Yorke Lee * @return True if the search UI was exited, false otherwise 1148c7b2a0e30aba4505a041a9ad0f8889f4891d30f8Yorke Lee */ 1149c7b2a0e30aba4505a041a9ad0f8889f4891d30f8Yorke Lee private boolean maybeExitSearchUi() { 1150c7b2a0e30aba4505a041a9ad0f8889f4891d30f8Yorke Lee if (isInSearchUi() && TextUtils.isEmpty(mSearchQuery)) { 1151c7b2a0e30aba4505a041a9ad0f8889f4891d30f8Yorke Lee exitSearchUi(); 1152f614f6fbe3351316af5a6119a866bdf25cb0d7e4Yorke Lee DialerUtils.hideInputMethod(mParentLayout); 1153c7b2a0e30aba4505a041a9ad0f8889f4891d30f8Yorke Lee return true; 1154c7b2a0e30aba4505a041a9ad0f8889f4891d30f8Yorke Lee } 1155c7b2a0e30aba4505a041a9ad0f8889f4891d30f8Yorke Lee return false; 1156c7b2a0e30aba4505a041a9ad0f8889f4891d30f8Yorke Lee } 1157c7b2a0e30aba4505a041a9ad0f8889f4891d30f8Yorke Lee 11586324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee private void showFabInSearchUi() { 11596324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee mFloatingActionButtonController.changeIcon( 11606324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee getResources().getDrawable(R.drawable.fab_ic_dial), 11616324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee getResources().getString(R.string.action_menu_dialpad_button)); 11626324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee mFloatingActionButtonController.align(getFabAlignment(), false /* animate */); 11636324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee mFloatingActionButtonController.scaleIn(FAB_SCALE_IN_DELAY_MS); 11646324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee } 11656324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee 1166c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee @Override 1167c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee public void onDialpadQueryChanged(String query) { 1168d9a9316985a77fb8a9562f8086e36d3722f19d5cYorke Lee mDialpadQuery = query; 1169466358780c0bd5cbb2c2300c321e94e60372b5e1Yorke Lee if (mSmartDialSearchFragment != null) { 1170466358780c0bd5cbb2c2300c321e94e60372b5e1Yorke Lee mSmartDialSearchFragment.setAddToContactNumber(query); 1171466358780c0bd5cbb2c2300c321e94e60372b5e1Yorke Lee } 1172c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee final String normalizedQuery = SmartDialNameMatcher.normalizeNumber(query, 1173c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee SmartDialNameMatcher.LATIN_SMART_DIAL_MAP); 117453a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee 117553a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee if (!TextUtils.equals(mSearchView.getText(), normalizedQuery)) { 1176ef2b7388569a94432278a617b528f628385fbb8cYorke Lee if (DEBUG) { 1177ef2b7388569a94432278a617b528f628385fbb8cYorke Lee Log.d(TAG, "onDialpadQueryChanged - new query: " + query); 1178ef2b7388569a94432278a617b528f628385fbb8cYorke Lee } 1179ef2b7388569a94432278a617b528f628385fbb8cYorke Lee if (mDialpadFragment == null || !mDialpadFragment.isVisible()) { 1180ef2b7388569a94432278a617b528f628385fbb8cYorke Lee // This callback can happen if the dialpad fragment is recreated because of 1181ef2b7388569a94432278a617b528f628385fbb8cYorke Lee // activity destruction. In that case, don't update the search view because 1182ef2b7388569a94432278a617b528f628385fbb8cYorke Lee // that would bring the user back to the search fragment regardless of the 1183ef2b7388569a94432278a617b528f628385fbb8cYorke Lee // previous state of the application. Instead, just return here and let the 1184ef2b7388569a94432278a617b528f628385fbb8cYorke Lee // fragment manager correctly figure out whatever fragment was last displayed. 118553a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee if (!TextUtils.isEmpty(normalizedQuery)) { 118653a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee mPendingSearchViewQuery = normalizedQuery; 118753a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee } 1188ef2b7388569a94432278a617b528f628385fbb8cYorke Lee return; 1189ef2b7388569a94432278a617b528f628385fbb8cYorke Lee } 119053a2230258d105299c7f1b8bbd25de54fed5d66aYorke Lee mSearchView.setText(normalizedQuery); 119194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 119283131715419e89eebe8e4ea7ada7f96ec37dd8f9Santos Cordon 119383131715419e89eebe8e4ea7ada7f96ec37dd8f9Santos Cordon try { 119483131715419e89eebe8e4ea7ada7f96ec37dd8f9Santos Cordon if (mDialpadFragment != null && mDialpadFragment.isVisible()) { 119583131715419e89eebe8e4ea7ada7f96ec37dd8f9Santos Cordon mDialpadFragment.process_quote_emergency_unquote(normalizedQuery); 119683131715419e89eebe8e4ea7ada7f96ec37dd8f9Santos Cordon } 119783131715419e89eebe8e4ea7ada7f96ec37dd8f9Santos Cordon } catch (Exception ignored) { 119883131715419e89eebe8e4ea7ada7f96ec37dd8f9Santos Cordon // Skip any exceptions for this piece of code 119983131715419e89eebe8e4ea7ada7f96ec37dd8f9Santos Cordon } 1200575ae388961252a771488c357e425fca191594b2Yorke Lee } 120183131715419e89eebe8e4ea7ada7f96ec37dd8f9Santos Cordon 1202575ae388961252a771488c357e425fca191594b2Yorke Lee @Override 1203575ae388961252a771488c357e425fca191594b2Yorke Lee public boolean onDialpadSpacerTouchWithEmptyQuery() { 1204575ae388961252a771488c357e425fca191594b2Yorke Lee if (mInDialpadSearch && mSmartDialSearchFragment != null 1205575ae388961252a771488c357e425fca191594b2Yorke Lee && !mSmartDialSearchFragment.isShowingPermissionRequest()) { 1206575ae388961252a771488c357e425fca191594b2Yorke Lee hideDialpadFragment(true /* animate */, true /* clearDialpad */); 1207575ae388961252a771488c357e425fca191594b2Yorke Lee return true; 1208575ae388961252a771488c357e425fca191594b2Yorke Lee } 1209575ae388961252a771488c357e425fca191594b2Yorke Lee return false; 121094b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng } 1211c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee 1212c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee @Override 1213c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee public void onListFragmentScrollStateChange(int scrollState) { 1214c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee if (scrollState == OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) { 1215f6673d3e5cbd10febea04f02035591ab15c5c7c0Yorke Lee hideDialpadFragment(true, false); 1216f614f6fbe3351316af5a6119a866bdf25cb0d7e4Yorke Lee DialerUtils.hideInputMethod(mParentLayout); 1217c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee } 1218c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee } 1219c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee 1220c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee @Override 122186e21f733049560e77b92f17a58474312d72ec3eYorke Lee public void onListFragmentScroll(int firstVisibleItem, int visibleItemCount, 122299a570c40193320e8640f91a2eb4693e46153703Andrew Lee int totalItemCount) { 1223e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee // TODO: No-op for now. This should eventually show/hide the actionBar based on 1224e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee // interactions with the ListsFragments. 122586e21f733049560e77b92f17a58474312d72ec3eYorke Lee } 122686e21f733049560e77b92f17a58474312d72ec3eYorke Lee 1227c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee private boolean phoneIsInUse() { 1228827a90fb309fd26f5b155c1ad612512011d58437Yorke Lee return TelecomUtil.isInCall(this); 1229c3766338b312f9c8a6bdb2facaf4b0a4bd199de4Yorke Lee } 12308dd6200bef2eb07486f4c7e288941cfcfed35e79Yorke Lee 1231da0f9046b2457c8adc0b97896d7ea1e880eccf96Yorke Lee private boolean canIntentBeHandled(Intent intent) { 1232da0f9046b2457c8adc0b97896d7ea1e880eccf96Yorke Lee final PackageManager packageManager = getPackageManager(); 1233da0f9046b2457c8adc0b97896d7ea1e880eccf96Yorke Lee final List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(intent, 1234da0f9046b2457c8adc0b97896d7ea1e880eccf96Yorke Lee PackageManager.MATCH_DEFAULT_ONLY); 1235da0f9046b2457c8adc0b97896d7ea1e880eccf96Yorke Lee return resolveInfo != null && resolveInfo.size() > 0; 1236da0f9046b2457c8adc0b97896d7ea1e880eccf96Yorke Lee } 12373cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee 123886e21f733049560e77b92f17a58474312d72ec3eYorke Lee /** 123986e21f733049560e77b92f17a58474312d72ec3eYorke Lee * Called when the user has long-pressed a contact tile to start a drag operation. 124086e21f733049560e77b92f17a58474312d72ec3eYorke Lee */ 12413cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee @Override 1242efb2d9c2e32ca4ed434ff785c4b3d18c9e08db6dYorke Lee public void onDragStarted(int x, int y, PhoneFavoriteSquareTileView view) { 12431896344b53ddf6cdaf17dc02a05c45f587879d99Andrew Lee mListsFragment.showRemoveView(true); 12443cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee } 12453cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee 12463cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee @Override 12472826619b274772beebc7369d5dfe616344f74b6fYorke Lee public void onDragHovered(int x, int y, PhoneFavoriteSquareTileView view) { 12482826619b274772beebc7369d5dfe616344f74b6fYorke Lee } 12493cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee 125086e21f733049560e77b92f17a58474312d72ec3eYorke Lee /** 125186e21f733049560e77b92f17a58474312d72ec3eYorke Lee * Called when the user has released a contact tile after long-pressing it. 125286e21f733049560e77b92f17a58474312d72ec3eYorke Lee */ 12533cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee @Override 12543cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee public void onDragFinished(int x, int y) { 12551896344b53ddf6cdaf17dc02a05c45f587879d99Andrew Lee mListsFragment.showRemoveView(false); 12563cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee } 12573cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee 12583cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee @Override 12593cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee public void onDroppedOnRemove() {} 12603cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee 12613cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee /** 1262d999b71452baebec789f6f58f1955d30e834826dYorke Lee * Allows the SpeedDialFragment to attach the drag controller to mRemoveViewContainer 12633cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee * once it has been attached to the activity. 12643cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee */ 12653cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee @Override 12663cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee public void setDragDropController(DragDropController dragController) { 12672826619b274772beebc7369d5dfe616344f74b6fYorke Lee mDragDropController = dragController; 12681896344b53ddf6cdaf17dc02a05c45f587879d99Andrew Lee mListsFragment.getRemoveView().setDragDropController(dragController); 12693cefcc69c10ab12bd782a0b53779dbd1cc0e2aa1Yorke Lee } 1270e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee 127138019af70eb1ca084d36291390bbc54dc81027deYorke Lee /** 127238019af70eb1ca084d36291390bbc54dc81027deYorke Lee * Implemented to satisfy {@link SpeedDialFragment.HostInterface} 127338019af70eb1ca084d36291390bbc54dc81027deYorke Lee */ 127438019af70eb1ca084d36291390bbc54dc81027deYorke Lee @Override 127538019af70eb1ca084d36291390bbc54dc81027deYorke Lee public void showAllContactsTab() { 127638019af70eb1ca084d36291390bbc54dc81027deYorke Lee if (mListsFragment != null) { 127738019af70eb1ca084d36291390bbc54dc81027deYorke Lee mListsFragment.showTab(ListsFragment.TAB_INDEX_ALL_CONTACTS); 127838019af70eb1ca084d36291390bbc54dc81027deYorke Lee } 127938019af70eb1ca084d36291390bbc54dc81027deYorke Lee } 128038019af70eb1ca084d36291390bbc54dc81027deYorke Lee 128138019af70eb1ca084d36291390bbc54dc81027deYorke Lee /** 128238019af70eb1ca084d36291390bbc54dc81027deYorke Lee * Implemented to satisfy {@link CallLogFragment.HostInterface} 128338019af70eb1ca084d36291390bbc54dc81027deYorke Lee */ 128438019af70eb1ca084d36291390bbc54dc81027deYorke Lee @Override 128538019af70eb1ca084d36291390bbc54dc81027deYorke Lee public void showDialpad() { 128638019af70eb1ca084d36291390bbc54dc81027deYorke Lee showDialpadFragment(true); 128738019af70eb1ca084d36291390bbc54dc81027deYorke Lee } 128838019af70eb1ca084d36291390bbc54dc81027deYorke Lee 1289e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee @Override 1290b31f5d16deb442c7aae2fe232f4799948dd7195dTyler Gunn public void onPickDataUri(Uri dataUri, boolean isVideoCall, int callInitiationType) { 12914e28c1d175a1a9e565b974c85a54709f41ee925bYorke Lee mClearSearchOnPause = true; 1292c8d6e16572f900f01545ebf947d15e7006fe4e46Yorke Lee PhoneNumberInteraction.startInteractionForPhoneCall( 1293b31f5d16deb442c7aae2fe232f4799948dd7195dTyler Gunn DialtactsActivity.this, dataUri, isVideoCall, callInitiationType); 1294e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee } 1295e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee 1296e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee @Override 1297071d0a4f1c8cf6b6131b7aeabfd2c6b0560b413fAnne Rong public void onPickPhoneNumber(String phoneNumber, boolean isVideoCall, int callInitiationType) { 129824d034f92998a52868c10039e9c728f9ab5a44aaYorke Lee if (phoneNumber == null) { 129924d034f92998a52868c10039e9c728f9ab5a44aaYorke Lee // Invalid phone number, but let the call go through so that InCallUI can show 130024d034f92998a52868c10039e9c728f9ab5a44aaYorke Lee // an error message. 130124d034f92998a52868c10039e9c728f9ab5a44aaYorke Lee phoneNumber = ""; 130224d034f92998a52868c10039e9c728f9ab5a44aaYorke Lee } 1303e3a2d133a9fdf12462dab75ed7d6c6c6061fa5e3Yorke Lee 1304e3a2d133a9fdf12462dab75ed7d6c6c6061fa5e3Yorke Lee final Intent intent = new CallIntentBuilder(phoneNumber) 1305e3a2d133a9fdf12462dab75ed7d6c6c6061fa5e3Yorke Lee .setIsVideoCall(isVideoCall) 1306c8d6e16572f900f01545ebf947d15e7006fe4e46Yorke Lee .setCallInitiationType(callInitiationType) 1307e3a2d133a9fdf12462dab75ed7d6c6c6061fa5e3Yorke Lee .build(); 1308e3a2d133a9fdf12462dab75ed7d6c6c6061fa5e3Yorke Lee 13097d20f8273886411ffc864231d59f780e450de3dbYorke Lee DialerUtils.startActivityWithErrorToast(this, intent); 13104e28c1d175a1a9e565b974c85a54709f41ee925bYorke Lee mClearSearchOnPause = true; 1311e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee } 1312e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee 1313e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee @Override 1314e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee public void onShortcutIntentCreated(Intent intent) { 13154e28c1d175a1a9e565b974c85a54709f41ee925bYorke Lee Log.w(TAG, "Unsupported intent has come (" + intent + "). Ignoring."); 1316e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee } 1317e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee 1318e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee @Override 1319e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee public void onHomeInActionBarSelected() { 13204e28c1d175a1a9e565b974c85a54709f41ee925bYorke Lee exitSearchUi(); 1321e00c9fe163d19ee380b922e3fcbe736216d78cccYorke Lee } 132233932ff9433bcd172749d416c23655c8d8bdafc2Yorke Lee 1323cc4660d463daa11b969fd9b8bdd308ae3416c67aYorke Lee @Override 1324cc4660d463daa11b969fd9b8bdd308ae3416c67aYorke Lee public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { 1325432d4b57728981f55a5ab5ee502e927e8d1d15fbAndrew Lee int tabIndex = mListsFragment.getCurrentTabIndex(); 1326432d4b57728981f55a5ab5ee502e927e8d1d15fbAndrew Lee 13274de59fb9ceac10ed429cd8416251329aa03ad266Andrew Lee // Scroll the button from center to end when moving from the Speed Dial to Call History tab. 13284de59fb9ceac10ed429cd8416251329aa03ad266Andrew Lee // In RTL, scroll when the current tab is Call History instead, since the order of the tabs 13294de59fb9ceac10ed429cd8416251329aa03ad266Andrew Lee // is reversed and the ViewPager returns the left tab position during scroll. 1330432d4b57728981f55a5ab5ee502e927e8d1d15fbAndrew Lee boolean isRtl = DialerUtils.isRtl(); 1331432d4b57728981f55a5ab5ee502e927e8d1d15fbAndrew Lee if (!isRtl && tabIndex == ListsFragment.TAB_INDEX_SPEED_DIAL && !mIsLandscape) { 1332432d4b57728981f55a5ab5ee502e927e8d1d15fbAndrew Lee mFloatingActionButtonController.onPageScrolled(positionOffset); 13334de59fb9ceac10ed429cd8416251329aa03ad266Andrew Lee } else if (isRtl && tabIndex == ListsFragment.TAB_INDEX_HISTORY && !mIsLandscape) { 1334432d4b57728981f55a5ab5ee502e927e8d1d15fbAndrew Lee mFloatingActionButtonController.onPageScrolled(1 - positionOffset); 1335432d4b57728981f55a5ab5ee502e927e8d1d15fbAndrew Lee } else if (tabIndex != ListsFragment.TAB_INDEX_SPEED_DIAL) { 133600a3d5d576d53b43a46849bf40c43bccde44a9b2Sai Cheemalapati mFloatingActionButtonController.onPageScrolled(1); 1337c4969ea3d2ac04f58f0caccef709bc95a182c378Sai Cheemalapati } 1338432d4b57728981f55a5ab5ee502e927e8d1d15fbAndrew Lee } 1339fdfeaaf4e5ae0277a03529e501eb1c562f769851Andrew Lee 1340432d4b57728981f55a5ab5ee502e927e8d1d15fbAndrew Lee @Override 1341432d4b57728981f55a5ab5ee502e927e8d1d15fbAndrew Lee public void onPageSelected(int position) { 1342cb55981252b49e476e1adf9f2d5ec19a658d2aa4Sarmad Hashmi updateMissedCalls(); 1343432d4b57728981f55a5ab5ee502e927e8d1d15fbAndrew Lee int tabIndex = mListsFragment.getCurrentTabIndex(); 1344cb55981252b49e476e1adf9f2d5ec19a658d2aa4Sarmad Hashmi mPreviouslySelectedTabIndex = tabIndex; 1345432d4b57728981f55a5ab5ee502e927e8d1d15fbAndrew Lee if (tabIndex == ListsFragment.TAB_INDEX_ALL_CONTACTS) { 1346fdfeaaf4e5ae0277a03529e501eb1c562f769851Andrew Lee mFloatingActionButtonController.changeIcon( 1347fdfeaaf4e5ae0277a03529e501eb1c562f769851Andrew Lee getResources().getDrawable(R.drawable.ic_person_add_24dp), 1348fdfeaaf4e5ae0277a03529e501eb1c562f769851Andrew Lee getResources().getString(R.string.search_shortcut_create_new_contact)); 1349fdfeaaf4e5ae0277a03529e501eb1c562f769851Andrew Lee } else { 1350fdfeaaf4e5ae0277a03529e501eb1c562f769851Andrew Lee mFloatingActionButtonController.changeIcon( 1351fdfeaaf4e5ae0277a03529e501eb1c562f769851Andrew Lee getResources().getDrawable(R.drawable.fab_ic_dial), 1352fdfeaaf4e5ae0277a03529e501eb1c562f769851Andrew Lee getResources().getString(R.string.action_menu_dialpad_button)); 1353fdfeaaf4e5ae0277a03529e501eb1c562f769851Andrew Lee } 1354cc4660d463daa11b969fd9b8bdd308ae3416c67aYorke Lee } 1355cc4660d463daa11b969fd9b8bdd308ae3416c67aYorke Lee 1356cc4660d463daa11b969fd9b8bdd308ae3416c67aYorke Lee @Override 1357cc4660d463daa11b969fd9b8bdd308ae3416c67aYorke Lee public void onPageScrollStateChanged(int state) { 1358cc4660d463daa11b969fd9b8bdd308ae3416c67aYorke Lee } 1359cc4660d463daa11b969fd9b8bdd308ae3416c67aYorke Lee 13605253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee @Override 13615253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee public boolean isActionBarShowing() { 13625253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee return mActionBarController.isActionBarShowing(); 13635253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee } 13645253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee 1365c98a5bb2d806dde99325a15466a2bf144d216ae8Yorke Lee @Override 1366c98a5bb2d806dde99325a15466a2bf144d216ae8Yorke Lee public ActionBarController getActionBarController() { 1367c98a5bb2d806dde99325a15466a2bf144d216ae8Yorke Lee return mActionBarController; 1368c98a5bb2d806dde99325a15466a2bf144d216ae8Yorke Lee } 1369c98a5bb2d806dde99325a15466a2bf144d216ae8Yorke Lee 13706bc6716bcecf319109d47a90e8f223c96c5a66fbYorke Lee @Override 13719da8fb46fa21159321295119e1b2075747cfbbf9Andrew Lee public boolean isDialpadShown() { 13729da8fb46fa21159321295119e1b2075747cfbbf9Andrew Lee return mIsDialpadShown; 13739da8fb46fa21159321295119e1b2075747cfbbf9Andrew Lee } 13749da8fb46fa21159321295119e1b2075747cfbbf9Andrew Lee 13755253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee @Override 13766bc6716bcecf319109d47a90e8f223c96c5a66fbYorke Lee public int getDialpadHeight() { 13776bc6716bcecf319109d47a90e8f223c96c5a66fbYorke Lee if (mDialpadFragment != null) { 13786bc6716bcecf319109d47a90e8f223c96c5a66fbYorke Lee return mDialpadFragment.getDialpadHeight(); 13796bc6716bcecf319109d47a90e8f223c96c5a66fbYorke Lee } 13806bc6716bcecf319109d47a90e8f223c96c5a66fbYorke Lee return 0; 13816bc6716bcecf319109d47a90e8f223c96c5a66fbYorke Lee } 13826bc6716bcecf319109d47a90e8f223c96c5a66fbYorke Lee 13836bc6716bcecf319109d47a90e8f223c96c5a66fbYorke Lee @Override 13845253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee public int getActionBarHideOffset() { 138544898ad0aa2a12788fc9cfc6b78fa7adc9d90f23Nancy Chen return getSupportActionBar().getHideOffset(); 13865253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee } 13875253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee 13885253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee @Override 1389c98a5bb2d806dde99325a15466a2bf144d216ae8Yorke Lee public void setActionBarHideOffset(int offset) { 139044898ad0aa2a12788fc9cfc6b78fa7adc9d90f23Nancy Chen getSupportActionBar().setHideOffset(offset); 13915253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee } 13925253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee 13935253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee @Override 1394c98a5bb2d806dde99325a15466a2bf144d216ae8Yorke Lee public int getActionBarHeight() { 1395c98a5bb2d806dde99325a15466a2bf144d216ae8Yorke Lee return mActionBarHeight; 13965253be0d57edd4cdf5fbc0a980188e13e009c083Yorke Lee } 1397c4969ea3d2ac04f58f0caccef709bc95a182c378Sai Cheemalapati 13986324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee private int getFabAlignment() { 13996324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee if (!mIsLandscape && !isInSearchUi() && 14006324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee mListsFragment.getCurrentTabIndex() == ListsFragment.TAB_INDEX_SPEED_DIAL) { 14016324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee return FloatingActionButtonController.ALIGN_MIDDLE; 14026324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee } 14036324f707bc35d9d3336f58f6004d1f3b1e6de1a3Andrew Lee return FloatingActionButtonController.ALIGN_END; 1404c4969ea3d2ac04f58f0caccef709bc95a182c378Sai Cheemalapati } 1405cb55981252b49e476e1adf9f2d5ec19a658d2aa4Sarmad Hashmi 1406cb55981252b49e476e1adf9f2d5ec19a658d2aa4Sarmad Hashmi private void updateMissedCalls() { 1407cb55981252b49e476e1adf9f2d5ec19a658d2aa4Sarmad Hashmi if (mPreviouslySelectedTabIndex == ListsFragment.TAB_INDEX_HISTORY) { 1408cb55981252b49e476e1adf9f2d5ec19a658d2aa4Sarmad Hashmi mListsFragment.markMissedCallsAsReadAndRemoveNotifications(); 1409cb55981252b49e476e1adf9f2d5ec19a658d2aa4Sarmad Hashmi } 1410cb55981252b49e476e1adf9f2d5ec19a658d2aa4Sarmad Hashmi } 141194b10b530c0fc297e2974e57e094c500d3ee6003Chiao Cheng} 1412