Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 1 | /* |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 2 | * Copyright (C) 2013 The Android Open Source Project |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.dialer; |
| 18 | |
Yorke Lee | 53a2230 | 2014-04-29 18:13:46 -0700 | [diff] [blame] | 19 | import android.app.ActionBar; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 20 | import android.app.Fragment; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 21 | import android.app.FragmentTransaction; |
Chiao Cheng | 073b5cf | 2012-12-07 11:36:00 -0800 | [diff] [blame] | 22 | import android.content.ActivityNotFoundException; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 23 | import android.content.Context; |
| 24 | import android.content.Intent; |
Yorke Lee | da0f904 | 2013-12-05 14:25:51 -0800 | [diff] [blame] | 25 | import android.content.pm.PackageManager; |
| 26 | import android.content.pm.ResolveInfo; |
Sai Cheemalapati | 82d6da5 | 2014-06-03 13:54:23 -0700 | [diff] [blame] | 27 | import android.content.res.Configuration; |
Andrew Lee | 2423a2f | 2014-05-29 14:14:45 -0700 | [diff] [blame] | 28 | import android.content.res.Resources; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 29 | import android.net.Uri; |
| 30 | import android.os.Bundle; |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame] | 31 | import android.os.Trace; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 32 | import android.speech.RecognizerIntent; |
Yorke Lee | cc4660d | 2014-04-24 11:22:57 -0700 | [diff] [blame] | 33 | import android.support.v4.view.ViewPager; |
Tyler Gunn | 9dc924c | 2014-09-12 09:33:50 -0700 | [diff] [blame] | 34 | import android.telecom.PhoneAccount; |
| 35 | import android.telecom.TelecomManager; |
Yorke Lee | 53a2230 | 2014-04-29 18:13:46 -0700 | [diff] [blame] | 36 | import android.text.Editable; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 37 | import android.text.TextUtils; |
Yorke Lee | 53a2230 | 2014-04-29 18:13:46 -0700 | [diff] [blame] | 38 | import android.text.TextWatcher; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 39 | import android.util.Log; |
Yorke Lee | 2826619 | 2014-05-01 10:05:52 -0700 | [diff] [blame] | 40 | import android.view.DragEvent; |
Yorke Lee | 74edcdc | 2014-07-11 16:15:08 -0700 | [diff] [blame] | 41 | import android.view.Gravity; |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 42 | import android.view.KeyEvent; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 43 | import android.view.Menu; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 44 | import android.view.MenuItem; |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 45 | import android.view.MotionEvent; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 46 | import android.view.View; |
Yorke Lee | 2826619 | 2014-05-01 10:05:52 -0700 | [diff] [blame] | 47 | import android.view.View.OnDragListener; |
Yorke Lee | c7b2a0e | 2014-05-20 17:21:25 -0700 | [diff] [blame] | 48 | import android.view.View.OnTouchListener; |
Ihab Awad | 9134e25 | 2014-07-09 12:32:52 -0700 | [diff] [blame] | 49 | import android.view.ViewTreeObserver; |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 50 | import android.view.animation.Animation; |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 51 | import android.view.animation.AnimationUtils; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 52 | import android.widget.AbsListView.OnScrollListener; |
Yorke Lee | 53a2230 | 2014-04-29 18:13:46 -0700 | [diff] [blame] | 53 | import android.widget.EditText; |
Yorke Lee | 28aab27 | 2014-06-11 10:24:19 -0700 | [diff] [blame] | 54 | import android.widget.FrameLayout; |
Andrew Lee | a73e189 | 2014-05-13 13:21:16 -0700 | [diff] [blame] | 55 | import android.widget.ImageButton; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 56 | import android.widget.PopupMenu; |
Chiao Cheng | 073b5cf | 2012-12-07 11:36:00 -0800 | [diff] [blame] | 57 | import android.widget.Toast; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 58 | |
Brian Attwell | c311af1 | 2014-10-22 18:28:58 -0700 | [diff] [blame] | 59 | import com.android.contacts.common.activity.TransactionSafeActivity; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 60 | import com.android.contacts.common.dialog.ClearFrequentsDialog; |
| 61 | import com.android.contacts.common.interactions.ImportExportDialogFragment; |
Nancy Chen | 0d3a739 | 2014-08-12 14:44:53 -0700 | [diff] [blame] | 62 | import com.android.contacts.common.interactions.TouchPointManager; |
Chiao Cheng | 8efbcf9 | 2012-12-04 17:43:02 -0800 | [diff] [blame] | 63 | import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; |
Yorke Lee | c16ea5a | 2015-05-19 15:51:01 -0700 | [diff] [blame] | 64 | import com.android.contacts.common.util.PermissionsUtil; |
Sai Cheemalapati | c4969ea | 2014-06-04 16:35:16 -0700 | [diff] [blame] | 65 | import com.android.contacts.common.widget.FloatingActionButtonController; |
Brian Attwell | beab3bb | 2014-10-27 12:24:49 -0700 | [diff] [blame] | 66 | import com.android.contacts.commonbind.analytics.AnalyticsUtil; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 67 | import com.android.dialer.calllog.CallLogActivity; |
Yorke Lee | fce269a | 2013-08-12 11:56:04 -0700 | [diff] [blame] | 68 | import com.android.dialer.database.DialerDatabaseHelper; |
Yorke Lee | f74011e | 2013-08-02 11:30:30 -0700 | [diff] [blame] | 69 | import com.android.dialer.dialpad.DialpadFragment; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 70 | import com.android.dialer.dialpad.SmartDialNameMatcher; |
Yorke Lee | fce269a | 2013-08-12 11:56:04 -0700 | [diff] [blame] | 71 | import com.android.dialer.dialpad.SmartDialPrefix; |
Chiao Cheng | 1429f1a | 2012-11-01 16:35:28 -0700 | [diff] [blame] | 72 | import com.android.dialer.interactions.PhoneNumberInteraction; |
Yorke Lee | 3cefcc6 | 2014-01-16 11:26:46 -0800 | [diff] [blame] | 73 | import com.android.dialer.list.DragDropController; |
Yorke Lee | e00c9fe | 2014-04-12 12:42:06 -0700 | [diff] [blame] | 74 | import com.android.dialer.list.ListsFragment; |
Yorke Lee | 3cefcc6 | 2014-01-16 11:26:46 -0800 | [diff] [blame] | 75 | import com.android.dialer.list.OnDragDropListener; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 76 | import com.android.dialer.list.OnListFragmentScrolledListener; |
Yorke Lee | efb2d9c | 2014-04-18 14:05:01 -0700 | [diff] [blame] | 77 | import com.android.dialer.list.PhoneFavoriteSquareTileView; |
Jay Shrauner | 2e5b34b | 2013-08-29 10:52:40 -0700 | [diff] [blame] | 78 | import com.android.dialer.list.RegularSearchFragment; |
| 79 | import com.android.dialer.list.SearchFragment; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 80 | import com.android.dialer.list.SmartDialSearchFragment; |
Ihab Awad | 9134e25 | 2014-07-09 12:32:52 -0700 | [diff] [blame] | 81 | import com.android.dialer.list.SpeedDialFragment; |
Yorke Lee | af6f195 | 2014-07-14 19:13:16 -0700 | [diff] [blame] | 82 | import com.android.dialer.settings.DialerSettingsActivity; |
Andrew Lee | 247df6e | 2015-05-12 19:09:00 -0700 | [diff] [blame] | 83 | import com.android.dialer.util.IntentUtil; |
Yorke Lee | 7d20f82 | 2014-06-19 17:09:33 -0700 | [diff] [blame] | 84 | import com.android.dialer.util.DialerUtils; |
Yorke Lee | 5253be0 | 2014-05-21 18:50:03 -0700 | [diff] [blame] | 85 | import com.android.dialer.widget.ActionBarController; |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 86 | import com.android.dialer.widget.SearchEditTextLayout; |
Andrew Lee | 6324f70 | 2015-06-16 14:45:58 -0700 | [diff] [blame] | 87 | import com.android.dialer.widget.SearchEditTextLayout.Callback; |
Yorke Lee | 0baa98b | 2013-08-22 10:55:16 -0700 | [diff] [blame] | 88 | import com.android.dialerbind.DatabaseHelperManager; |
Yorke Lee | 2fec47b | 2014-08-05 18:16:27 -0700 | [diff] [blame] | 89 | import com.android.phone.common.animation.AnimUtils; |
Sai Cheemalapati | fd723ca | 2014-06-19 12:30:07 -0700 | [diff] [blame] | 90 | import com.android.phone.common.animation.AnimationListenerAdapter; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 91 | |
Yorke Lee | d5c512a | 2015-01-30 14:42:53 -0800 | [diff] [blame] | 92 | import junit.framework.Assert; |
| 93 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 94 | import java.util.ArrayList; |
Yorke Lee | da0f904 | 2013-12-05 14:25:51 -0800 | [diff] [blame] | 95 | import java.util.List; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 96 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 97 | /** |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 98 | * The dialer tab's title is 'phone', a more common name (see strings.xml). |
| 99 | */ |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 100 | public class DialtactsActivity extends TransactionSafeActivity implements View.OnClickListener, |
Yorke Lee | 86e21f7 | 2014-04-02 16:49:38 -0700 | [diff] [blame] | 101 | DialpadFragment.OnDialpadQueryChangedListener, |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 102 | OnListFragmentScrolledListener, |
Yorke Lee | 6a1461a | 2014-04-21 16:27:14 -0700 | [diff] [blame] | 103 | ListsFragment.HostInterface, |
Yorke Lee | d999b71 | 2014-04-23 15:10:58 -0700 | [diff] [blame] | 104 | SpeedDialFragment.HostInterface, |
Yorke Lee | 5253be0 | 2014-05-21 18:50:03 -0700 | [diff] [blame] | 105 | SearchFragment.HostInterface, |
Andrew Lee | 752956e | 2014-05-15 11:43:38 -0700 | [diff] [blame] | 106 | OnDragDropListener, |
Yorke Lee | cc4660d | 2014-04-24 11:22:57 -0700 | [diff] [blame] | 107 | OnPhoneNumberPickerActionListener, |
Andrew Lee | e74a10e | 2014-05-16 14:31:40 -0700 | [diff] [blame] | 108 | PopupMenu.OnMenuItemClickListener, |
Yorke Lee | 5253be0 | 2014-05-21 18:50:03 -0700 | [diff] [blame] | 109 | ViewPager.OnPageChangeListener, |
| 110 | ActionBarController.ActivityUi { |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 111 | private static final String TAG = "DialtactsActivity"; |
| 112 | |
Yorke Lee | 7cc6149 | 2015-06-01 14:59:33 -0700 | [diff] [blame] | 113 | public static final boolean DEBUG = false; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 114 | |
Yorke Lee | f74011e | 2013-08-02 11:30:30 -0700 | [diff] [blame] | 115 | public static final String SHARED_PREFS_NAME = "com.android.dialer_preferences"; |
| 116 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 117 | /** @see #getCallOrigin() */ |
| 118 | private static final String CALL_ORIGIN_DIALTACTS = |
| 119 | "com.android.dialer.DialtactsActivity"; |
| 120 | |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 121 | private static final String KEY_IN_REGULAR_SEARCH_UI = "in_regular_search_ui"; |
| 122 | private static final String KEY_IN_DIALPAD_SEARCH_UI = "in_dialpad_search_ui"; |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 123 | private static final String KEY_SEARCH_QUERY = "search_query"; |
| 124 | private static final String KEY_FIRST_LAUNCH = "first_launch"; |
Yorke Lee | 50aba88 | 2014-05-28 20:04:31 -0700 | [diff] [blame] | 125 | private static final String KEY_IS_DIALPAD_SHOWN = "is_dialpad_shown"; |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 126 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 127 | private static final String TAG_DIALPAD_FRAGMENT = "dialpad"; |
| 128 | private static final String TAG_REGULAR_SEARCH_FRAGMENT = "search"; |
| 129 | private static final String TAG_SMARTDIAL_SEARCH_FRAGMENT = "smartdial"; |
| 130 | private static final String TAG_FAVORITES_FRAGMENT = "favorites"; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 131 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 132 | /** |
| 133 | * Just for backward compatibility. Should behave as same as {@link Intent#ACTION_DIAL}. |
| 134 | */ |
| 135 | private static final String ACTION_TOUCH_DIALER = "com.android.phone.action.TOUCH_DIALER"; |
Andrew Lee | 75d5b2d | 2015-06-19 16:53:54 -0700 | [diff] [blame^] | 136 | public static final String EXTRA_SHOW_TAB = "EXTRA_SHOW_TAB"; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 137 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 138 | private static final int ACTIVITY_REQUEST_CODE_VOICE_SEARCH = 1; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 139 | |
Andrew Lee | 6324f70 | 2015-06-16 14:45:58 -0700 | [diff] [blame] | 140 | private static final int FAB_SCALE_IN_DELAY_MS = 300; |
| 141 | |
Yorke Lee | f614f6f | 2014-10-03 10:44:19 -0700 | [diff] [blame] | 142 | private FrameLayout mParentLayout; |
Andrew Lee | 0c66770 | 2014-05-12 14:31:45 -0700 | [diff] [blame] | 143 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 144 | /** |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 145 | * Fragment containing the dialpad that slides into view |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 146 | */ |
Evan Charlton | 72d6625 | 2014-11-07 16:23:47 -0800 | [diff] [blame] | 147 | protected DialpadFragment mDialpadFragment; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 148 | |
| 149 | /** |
| 150 | * Fragment for searching phone numbers using the alphanumeric keyboard. |
| 151 | */ |
Jay Shrauner | 2e5b34b | 2013-08-29 10:52:40 -0700 | [diff] [blame] | 152 | private RegularSearchFragment mRegularSearchFragment; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 153 | |
| 154 | /** |
| 155 | * Fragment for searching phone numbers using the dialpad. |
| 156 | */ |
| 157 | private SmartDialSearchFragment mSmartDialSearchFragment; |
| 158 | |
Yorke Lee | e00c9fe | 2014-04-12 12:42:06 -0700 | [diff] [blame] | 159 | /** |
Sai Cheemalapati | 82d6da5 | 2014-06-03 13:54:23 -0700 | [diff] [blame] | 160 | * Animation that slides in. |
| 161 | */ |
| 162 | private Animation mSlideIn; |
| 163 | |
| 164 | /** |
| 165 | * Animation that slides out. |
| 166 | */ |
| 167 | private Animation mSlideOut; |
| 168 | |
Yorke Lee | 6c450eb | 2015-05-08 09:45:47 -0700 | [diff] [blame] | 169 | AnimationListenerAdapter mSlideInListener = new AnimationListenerAdapter() { |
| 170 | @Override |
| 171 | public void onAnimationEnd(Animation animation) { |
Yorke Lee | 81a313d | 2015-06-01 14:53:59 -0700 | [diff] [blame] | 172 | maybeEnterSearchUi(); |
Yorke Lee | 6c450eb | 2015-05-08 09:45:47 -0700 | [diff] [blame] | 173 | } |
| 174 | }; |
| 175 | |
Sai Cheemalapati | 82d6da5 | 2014-06-03 13:54:23 -0700 | [diff] [blame] | 176 | /** |
| 177 | * Listener for after slide out animation completes on dialer fragment. |
| 178 | */ |
| 179 | AnimationListenerAdapter mSlideOutListener = new AnimationListenerAdapter() { |
| 180 | @Override |
| 181 | public void onAnimationEnd(Animation animation) { |
| 182 | commitDialpadFragmentHide(); |
| 183 | } |
| 184 | }; |
| 185 | |
| 186 | /** |
Yorke Lee | e00c9fe | 2014-04-12 12:42:06 -0700 | [diff] [blame] | 187 | * Fragment containing the speed dial list, recents list, and all contacts list. |
| 188 | */ |
| 189 | private ListsFragment mListsFragment; |
| 190 | |
Yorke Lee | 19e68ca | 2014-10-28 11:51:40 -0700 | [diff] [blame] | 191 | /** |
| 192 | * Tracks whether onSaveInstanceState has been called. If true, no fragment transactions can |
| 193 | * be commited. |
| 194 | */ |
| 195 | private boolean mStateSaved; |
Yorke Lee | 7ee5c42 | 2014-11-04 10:29:32 -0800 | [diff] [blame] | 196 | private boolean mIsRestarting; |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 197 | private boolean mInDialpadSearch; |
| 198 | private boolean mInRegularSearch; |
Yorke Lee | 8e5c8b1 | 2013-10-01 14:37:55 -0700 | [diff] [blame] | 199 | private boolean mClearSearchOnPause; |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 200 | private boolean mIsDialpadShown; |
Yorke Lee | 50aba88 | 2014-05-28 20:04:31 -0700 | [diff] [blame] | 201 | private boolean mShowDialpadOnResume; |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 202 | |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 203 | /** |
Sai Cheemalapati | 4146065 | 2014-06-02 21:05:39 -0700 | [diff] [blame] | 204 | * Whether or not the device is in landscape orientation. |
| 205 | */ |
| 206 | private boolean mIsLandscape; |
| 207 | |
| 208 | /** |
Yorke Lee | 35127cd | 2013-09-10 14:09:29 -0700 | [diff] [blame] | 209 | * True if the dialpad is only temporarily showing due to being in call |
| 210 | */ |
| 211 | private boolean mInCallDialpadUp; |
| 212 | |
| 213 | /** |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 214 | * True when this activity has been launched for the first time. |
| 215 | */ |
Yorke Lee | 98702de | 2013-08-06 12:03:32 -0700 | [diff] [blame] | 216 | private boolean mFirstLaunch; |
Yorke Lee | 86e21f7 | 2014-04-02 16:49:38 -0700 | [diff] [blame] | 217 | |
Yorke Lee | 3c9e7cd | 2014-04-16 11:37:21 -0700 | [diff] [blame] | 218 | /** |
| 219 | * Search query to be applied to the SearchView in the ActionBar once |
| 220 | * onCreateOptionsMenu has been called. |
| 221 | */ |
| 222 | private String mPendingSearchViewQuery; |
| 223 | |
Yorke Lee | 74edcdc | 2014-07-11 16:15:08 -0700 | [diff] [blame] | 224 | private PopupMenu mOverflowMenu; |
Yorke Lee | 53a2230 | 2014-04-29 18:13:46 -0700 | [diff] [blame] | 225 | private EditText mSearchView; |
Yorke Lee | 53a2230 | 2014-04-29 18:13:46 -0700 | [diff] [blame] | 226 | private View mVoiceSearchButton; |
Andrew Lee | e74a10e | 2014-05-16 14:31:40 -0700 | [diff] [blame] | 227 | |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 228 | private String mSearchQuery; |
| 229 | |
Yorke Lee | fce269a | 2013-08-12 11:56:04 -0700 | [diff] [blame] | 230 | private DialerDatabaseHelper mDialerDatabaseHelper; |
Yorke Lee | 2826619 | 2014-05-01 10:05:52 -0700 | [diff] [blame] | 231 | private DragDropController mDragDropController; |
Yorke Lee | 5253be0 | 2014-05-21 18:50:03 -0700 | [diff] [blame] | 232 | private ActionBarController mActionBarController; |
Sai Cheemalapati | c4969ea | 2014-06-04 16:35:16 -0700 | [diff] [blame] | 233 | |
Sai Cheemalapati | 4146065 | 2014-06-02 21:05:39 -0700 | [diff] [blame] | 234 | private FloatingActionButtonController mFloatingActionButtonController; |
Yorke Lee | fce269a | 2013-08-12 11:56:04 -0700 | [diff] [blame] | 235 | |
Andrew Lee | 2423a2f | 2014-05-29 14:14:45 -0700 | [diff] [blame] | 236 | private int mActionBarHeight; |
Andrew Lee | 2423a2f | 2014-05-29 14:14:45 -0700 | [diff] [blame] | 237 | |
Tyler Gunn | c1cfae5 | 2014-11-20 13:22:54 -0800 | [diff] [blame] | 238 | /** |
| 239 | * The text returned from a voice search query. Set in {@link #onActivityResult} and used in |
| 240 | * {@link #onResume()} to populate the search box. |
| 241 | */ |
| 242 | private String mVoiceSearchQuery; |
| 243 | |
Andrew Lee | 467de3d | 2015-03-17 15:47:24 -0700 | [diff] [blame] | 244 | protected class OptionsPopupMenu extends PopupMenu { |
Andrew Lee | e74a10e | 2014-05-16 14:31:40 -0700 | [diff] [blame] | 245 | public OptionsPopupMenu(Context context, View anchor) { |
Yorke Lee | 74edcdc | 2014-07-11 16:15:08 -0700 | [diff] [blame] | 246 | super(context, anchor, Gravity.END); |
Yorke Lee | e00c9fe | 2014-04-12 12:42:06 -0700 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | @Override |
| 250 | public void show() { |
Yorke Lee | c16ea5a | 2015-05-19 15:51:01 -0700 | [diff] [blame] | 251 | final boolean hasContactsPermission = |
| 252 | PermissionsUtil.hasContactsPermissions(DialtactsActivity.this); |
Yorke Lee | e00c9fe | 2014-04-12 12:42:06 -0700 | [diff] [blame] | 253 | final Menu menu = getMenu(); |
| 254 | final MenuItem clearFrequents = menu.findItem(R.id.menu_clear_frequents); |
Andrew Lee | e74a10e | 2014-05-16 14:31:40 -0700 | [diff] [blame] | 255 | clearFrequents.setVisible(mListsFragment != null && |
| 256 | mListsFragment.getSpeedDialFragment() != null && |
Yorke Lee | c16ea5a | 2015-05-19 15:51:01 -0700 | [diff] [blame] | 257 | mListsFragment.getSpeedDialFragment().hasFrequents() && hasContactsPermission); |
| 258 | |
| 259 | menu.findItem(R.id.menu_import_export).setVisible(hasContactsPermission); |
| 260 | menu.findItem(R.id.menu_add_contact).setVisible(hasContactsPermission); |
Yorke Lee | b7330e3 | 2015-05-22 15:55:22 -0700 | [diff] [blame] | 261 | |
| 262 | menu.findItem(R.id.menu_history).setVisible( |
| 263 | PermissionsUtil.hasPhonePermissions(DialtactsActivity.this)); |
Yorke Lee | e00c9fe | 2014-04-12 12:42:06 -0700 | [diff] [blame] | 264 | super.show(); |
| 265 | } |
| 266 | } |
| 267 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 268 | /** |
Yorke Lee | 2826619 | 2014-05-01 10:05:52 -0700 | [diff] [blame] | 269 | * Listener that listens to drag events and sends their x and y coordinates to a |
| 270 | * {@link DragDropController}. |
| 271 | */ |
| 272 | private class LayoutOnDragListener implements OnDragListener { |
| 273 | @Override |
| 274 | public boolean onDrag(View v, DragEvent event) { |
| 275 | if (event.getAction() == DragEvent.ACTION_DRAG_LOCATION) { |
Andrew Lee | 1896344 | 2014-06-06 17:20:13 -0700 | [diff] [blame] | 276 | mDragDropController.handleDragHovered(v, (int) event.getX(), (int) event.getY()); |
Yorke Lee | 2826619 | 2014-05-01 10:05:52 -0700 | [diff] [blame] | 277 | } |
| 278 | return true; |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | /** |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 283 | * Listener used to send search queries to the phone search fragment. |
| 284 | */ |
Yorke Lee | 53a2230 | 2014-04-29 18:13:46 -0700 | [diff] [blame] | 285 | private final TextWatcher mPhoneSearchQueryTextListener = new TextWatcher() { |
Andrew Lee | 99a570c | 2014-05-15 14:18:50 -0700 | [diff] [blame] | 286 | @Override |
| 287 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { |
| 288 | } |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 289 | |
Andrew Lee | 99a570c | 2014-05-15 14:18:50 -0700 | [diff] [blame] | 290 | @Override |
| 291 | public void onTextChanged(CharSequence s, int start, int before, int count) { |
| 292 | final String newText = s.toString(); |
| 293 | if (newText.equals(mSearchQuery)) { |
| 294 | // If the query hasn't changed (perhaps due to activity being destroyed |
| 295 | // and restored, or user launching the same DIAL intent twice), then there is |
| 296 | // no need to do anything here. |
Yorke Lee | 53a2230 | 2014-04-29 18:13:46 -0700 | [diff] [blame] | 297 | return; |
| 298 | } |
Andrew Lee | 99a570c | 2014-05-15 14:18:50 -0700 | [diff] [blame] | 299 | if (DEBUG) { |
| 300 | Log.d(TAG, "onTextChange for mSearchView called with new query: " + newText); |
Yorke Lee | 710709d | 2014-05-29 07:18:42 -0700 | [diff] [blame] | 301 | Log.d(TAG, "Previous Query: " + mSearchQuery); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 302 | } |
Yorke Lee | 710709d | 2014-05-29 07:18:42 -0700 | [diff] [blame] | 303 | mSearchQuery = newText; |
Andrew Lee | 99a570c | 2014-05-15 14:18:50 -0700 | [diff] [blame] | 304 | |
Andrew Lee | 90374a7 | 2014-05-16 15:01:09 -0700 | [diff] [blame] | 305 | // Show search fragment only when the query string is changed to non-empty text. |
| 306 | if (!TextUtils.isEmpty(newText)) { |
| 307 | // Call enterSearchUi only if we are switching search modes, or showing a search |
| 308 | // fragment for the first time. |
| 309 | final boolean sameSearchMode = (mIsDialpadShown && mInDialpadSearch) || |
| 310 | (!mIsDialpadShown && mInRegularSearch); |
| 311 | if (!sameSearchMode) { |
Yorke Lee | 6c450eb | 2015-05-08 09:45:47 -0700 | [diff] [blame] | 312 | enterSearchUi(mIsDialpadShown, mSearchQuery, true /* animate */); |
Andrew Lee | 90374a7 | 2014-05-16 15:01:09 -0700 | [diff] [blame] | 313 | } |
Andrew Lee | 99a570c | 2014-05-15 14:18:50 -0700 | [diff] [blame] | 314 | } |
| 315 | |
Andrew Lee | a851542 | 2014-06-13 16:53:54 -0700 | [diff] [blame] | 316 | if (mSmartDialSearchFragment != null && mSmartDialSearchFragment.isVisible()) { |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 317 | mSmartDialSearchFragment.setQueryString(mSearchQuery, false /* delaySelection */); |
Andrew Lee | a851542 | 2014-06-13 16:53:54 -0700 | [diff] [blame] | 318 | } else if (mRegularSearchFragment != null && mRegularSearchFragment.isVisible()) { |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 319 | mRegularSearchFragment.setQueryString(mSearchQuery, false /* delaySelection */); |
Andrew Lee | 99a570c | 2014-05-15 14:18:50 -0700 | [diff] [blame] | 320 | } |
Andrew Lee | 99a570c | 2014-05-15 14:18:50 -0700 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | @Override |
| 324 | public void afterTextChanged(Editable s) { |
| 325 | } |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 326 | }; |
| 327 | |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 328 | |
| 329 | /** |
Yorke Lee | 11ca39e | 2014-05-19 20:31:37 -0700 | [diff] [blame] | 330 | * Open the search UI when the user clicks on the search box. |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 331 | */ |
Yorke Lee | 11ca39e | 2014-05-19 20:31:37 -0700 | [diff] [blame] | 332 | private final View.OnClickListener mSearchViewOnClickListener = new View.OnClickListener() { |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 333 | @Override |
Yorke Lee | 11ca39e | 2014-05-19 20:31:37 -0700 | [diff] [blame] | 334 | public void onClick(View v) { |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 335 | if (!isInSearchUi()) { |
Yorke Lee | 5253be0 | 2014-05-21 18:50:03 -0700 | [diff] [blame] | 336 | mActionBarController.onSearchBoxTapped(); |
Yorke Lee | 6c450eb | 2015-05-08 09:45:47 -0700 | [diff] [blame] | 337 | enterSearchUi(false /* smartDialSearch */, mSearchView.getText().toString(), |
| 338 | true /* animate */); |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 339 | } |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 340 | } |
| 341 | }; |
| 342 | |
| 343 | /** |
Andrew Lee | 6324f70 | 2015-06-16 14:45:58 -0700 | [diff] [blame] | 344 | * Handles the user closing the soft keyboard. |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 345 | */ |
| 346 | private final View.OnKeyListener mSearchEditTextLayoutListener = new View.OnKeyListener() { |
| 347 | @Override |
| 348 | public boolean onKey(View v, int keyCode, KeyEvent event) { |
Andrew Lee | 6324f70 | 2015-06-16 14:45:58 -0700 | [diff] [blame] | 349 | if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) { |
| 350 | if (TextUtils.isEmpty(mSearchView.getText().toString())) { |
| 351 | // If the search term is empty, close the search UI. |
| 352 | maybeExitSearchUi(); |
| 353 | } else { |
| 354 | // If the search term is not empty, show the dialpad fab. |
| 355 | showFabInSearchUi(); |
| 356 | } |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 357 | } |
| 358 | return false; |
| 359 | } |
| 360 | }; |
| 361 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 362 | @Override |
Nancy Chen | 49db1ad | 2014-08-18 20:10:17 -0700 | [diff] [blame] | 363 | public boolean dispatchTouchEvent(MotionEvent ev) { |
| 364 | if (ev.getAction() == MotionEvent.ACTION_DOWN) { |
| 365 | TouchPointManager.getInstance().setPoint((int) ev.getRawX(), (int) ev.getRawY()); |
| 366 | } |
| 367 | return super.dispatchTouchEvent(ev); |
| 368 | |
| 369 | } |
| 370 | |
| 371 | @Override |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 372 | protected void onCreate(Bundle savedInstanceState) { |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame] | 373 | Trace.beginSection(TAG + " onCreate"); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 374 | super.onCreate(savedInstanceState); |
Yorke Lee | c16ea5a | 2015-05-19 15:51:01 -0700 | [diff] [blame] | 375 | |
Yorke Lee | 98702de | 2013-08-06 12:03:32 -0700 | [diff] [blame] | 376 | mFirstLaunch = true; |
| 377 | |
Andrew Lee | 2423a2f | 2014-05-29 14:14:45 -0700 | [diff] [blame] | 378 | final Resources resources = getResources(); |
Nancy Chen | b8170de | 2014-07-28 10:41:08 -0700 | [diff] [blame] | 379 | mActionBarHeight = resources.getDimensionPixelSize(R.dimen.action_bar_height_large); |
Andrew Lee | 2423a2f | 2014-05-29 14:14:45 -0700 | [diff] [blame] | 380 | |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame] | 381 | Trace.beginSection(TAG + " setContentView"); |
Yorke Lee | 8898cd0 | 2013-08-08 10:24:27 -0700 | [diff] [blame] | 382 | setContentView(R.layout.dialtacts_activity); |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame] | 383 | Trace.endSection(); |
Yorke Lee | 9e91bb0 | 2014-03-05 17:50:50 -0800 | [diff] [blame] | 384 | getWindow().setBackgroundDrawable(null); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 385 | |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame] | 386 | Trace.beginSection(TAG + " setup Views"); |
Yorke Lee | 53a2230 | 2014-04-29 18:13:46 -0700 | [diff] [blame] | 387 | final ActionBar actionBar = getActionBar(); |
| 388 | actionBar.setCustomView(R.layout.search_edittext); |
| 389 | actionBar.setDisplayShowCustomEnabled(true); |
Yorke Lee | bcef940 | 2014-05-21 15:33:00 -0700 | [diff] [blame] | 390 | actionBar.setBackgroundDrawable(null); |
Yorke Lee | 53a2230 | 2014-04-29 18:13:46 -0700 | [diff] [blame] | 391 | |
Andrew Lee | 04675a5 | 2014-06-05 18:36:20 -0700 | [diff] [blame] | 392 | SearchEditTextLayout searchEditTextLayout = |
Andrew Lee | e3f59a8 | 2015-02-26 12:06:35 -0800 | [diff] [blame] | 393 | (SearchEditTextLayout) actionBar.getCustomView().findViewById(R.id.search_view_container); |
Andrew Lee | 04675a5 | 2014-06-05 18:36:20 -0700 | [diff] [blame] | 394 | searchEditTextLayout.setPreImeKeyListener(mSearchEditTextLayoutListener); |
| 395 | |
Andrew Lee | e3f59a8 | 2015-02-26 12:06:35 -0800 | [diff] [blame] | 396 | mActionBarController = new ActionBarController(this, searchEditTextLayout); |
| 397 | |
Andrew Lee | 04675a5 | 2014-06-05 18:36:20 -0700 | [diff] [blame] | 398 | mSearchView = (EditText) searchEditTextLayout.findViewById(R.id.search_view); |
Yorke Lee | 53a2230 | 2014-04-29 18:13:46 -0700 | [diff] [blame] | 399 | mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener); |
Andrew Lee | 04675a5 | 2014-06-05 18:36:20 -0700 | [diff] [blame] | 400 | mVoiceSearchButton = searchEditTextLayout.findViewById(R.id.voice_search_button); |
| 401 | searchEditTextLayout.findViewById(R.id.search_magnifying_glass) |
| 402 | .setOnClickListener(mSearchViewOnClickListener); |
| 403 | searchEditTextLayout.findViewById(R.id.search_box_start_search) |
| 404 | .setOnClickListener(mSearchViewOnClickListener); |
Andrew Lee | 6324f70 | 2015-06-16 14:45:58 -0700 | [diff] [blame] | 405 | searchEditTextLayout.setCallback(new SearchEditTextLayout.Callback() { |
Yorke Lee | 11ca39e | 2014-05-19 20:31:37 -0700 | [diff] [blame] | 406 | @Override |
| 407 | public void onBackButtonClicked() { |
| 408 | onBackPressed(); |
| 409 | } |
Andrew Lee | 6324f70 | 2015-06-16 14:45:58 -0700 | [diff] [blame] | 410 | |
| 411 | @Override |
| 412 | public void onSearchViewClicked() { |
| 413 | // Hide FAB, as the keyboard is shown. |
| 414 | mFloatingActionButtonController.scaleOut(); |
| 415 | } |
Yorke Lee | 11ca39e | 2014-05-19 20:31:37 -0700 | [diff] [blame] | 416 | }); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 417 | |
Sai Cheemalapati | c4969ea | 2014-06-04 16:35:16 -0700 | [diff] [blame] | 418 | mIsLandscape = getResources().getConfiguration().orientation |
Sai Cheemalapati | 4146065 | 2014-06-02 21:05:39 -0700 | [diff] [blame] | 419 | == Configuration.ORIENTATION_LANDSCAPE; |
Nancy Chen | 8e06629 | 2014-06-18 17:16:10 -0700 | [diff] [blame] | 420 | |
Sai Cheemalapati | c4969ea | 2014-06-04 16:35:16 -0700 | [diff] [blame] | 421 | final View floatingActionButtonContainer = findViewById( |
| 422 | R.id.floating_action_button_container); |
Andrew Lee | 405a6e6 | 2014-08-20 15:02:16 -0700 | [diff] [blame] | 423 | ImageButton floatingActionButton = (ImageButton) findViewById(R.id.floating_action_button); |
| 424 | floatingActionButton.setOnClickListener(this); |
Sai Cheemalapati | c4969ea | 2014-06-04 16:35:16 -0700 | [diff] [blame] | 425 | mFloatingActionButtonController = new FloatingActionButtonController(this, |
Andrew Lee | 405a6e6 | 2014-08-20 15:02:16 -0700 | [diff] [blame] | 426 | floatingActionButtonContainer, floatingActionButton); |
Sai Cheemalapati | 4146065 | 2014-06-02 21:05:39 -0700 | [diff] [blame] | 427 | |
Andrew Lee | 04675a5 | 2014-06-05 18:36:20 -0700 | [diff] [blame] | 428 | ImageButton optionsMenuButton = |
| 429 | (ImageButton) searchEditTextLayout.findViewById(R.id.dialtacts_options_menu_button); |
Andrew Lee | e74a10e | 2014-05-16 14:31:40 -0700 | [diff] [blame] | 430 | optionsMenuButton.setOnClickListener(this); |
Yorke Lee | 74edcdc | 2014-07-11 16:15:08 -0700 | [diff] [blame] | 431 | mOverflowMenu = buildOptionsMenu(searchEditTextLayout); |
| 432 | optionsMenuButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener()); |
Andrew Lee | e74a10e | 2014-05-16 14:31:40 -0700 | [diff] [blame] | 433 | |
Yorke Lee | d5c512a | 2015-01-30 14:42:53 -0800 | [diff] [blame] | 434 | // Add the favorites fragment but only if savedInstanceState is null. Otherwise the |
| 435 | // fragment manager is responsible for recreating it. |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 436 | if (savedInstanceState == null) { |
Ihab Awad | 526c0b8 | 2014-02-27 12:55:36 -0800 | [diff] [blame] | 437 | getFragmentManager().beginTransaction() |
Andrew Lee | 6a86624 | 2015-05-05 18:21:45 +0000 | [diff] [blame] | 438 | .add(R.id.dialtacts_frame, new ListsFragment(), TAG_FAVORITES_FRAGMENT) |
Ihab Awad | 526c0b8 | 2014-02-27 12:55:36 -0800 | [diff] [blame] | 439 | .commit(); |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 440 | } else { |
| 441 | mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY); |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 442 | mInRegularSearch = savedInstanceState.getBoolean(KEY_IN_REGULAR_SEARCH_UI); |
| 443 | mInDialpadSearch = savedInstanceState.getBoolean(KEY_IN_DIALPAD_SEARCH_UI); |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 444 | mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH); |
Yorke Lee | 50aba88 | 2014-05-28 20:04:31 -0700 | [diff] [blame] | 445 | mShowDialpadOnResume = savedInstanceState.getBoolean(KEY_IS_DIALPAD_SHOWN); |
Yorke Lee | 5253be0 | 2014-05-21 18:50:03 -0700 | [diff] [blame] | 446 | mActionBarController.restoreInstanceState(savedInstanceState); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 447 | } |
Sai Cheemalapati | 82d6da5 | 2014-06-03 13:54:23 -0700 | [diff] [blame] | 448 | |
Tyler Gunn | bf7a95e | 2014-08-12 12:16:28 -0700 | [diff] [blame] | 449 | final boolean isLayoutRtl = DialerUtils.isRtl(); |
| 450 | if (mIsLandscape) { |
| 451 | mSlideIn = AnimationUtils.loadAnimation(this, |
| 452 | isLayoutRtl ? R.anim.dialpad_slide_in_left : R.anim.dialpad_slide_in_right); |
| 453 | mSlideOut = AnimationUtils.loadAnimation(this, |
| 454 | isLayoutRtl ? R.anim.dialpad_slide_out_left : R.anim.dialpad_slide_out_right); |
| 455 | } else { |
| 456 | mSlideIn = AnimationUtils.loadAnimation(this, R.anim.dialpad_slide_in_bottom); |
| 457 | mSlideOut = AnimationUtils.loadAnimation(this, R.anim.dialpad_slide_out_bottom); |
| 458 | } |
Sai Cheemalapati | 82d6da5 | 2014-06-03 13:54:23 -0700 | [diff] [blame] | 459 | |
Yorke Lee | 2fec47b | 2014-08-05 18:16:27 -0700 | [diff] [blame] | 460 | mSlideIn.setInterpolator(AnimUtils.EASE_IN); |
| 461 | mSlideOut.setInterpolator(AnimUtils.EASE_OUT); |
| 462 | |
Yorke Lee | 6c450eb | 2015-05-08 09:45:47 -0700 | [diff] [blame] | 463 | mSlideIn.setAnimationListener(mSlideInListener); |
Sai Cheemalapati | 82d6da5 | 2014-06-03 13:54:23 -0700 | [diff] [blame] | 464 | mSlideOut.setAnimationListener(mSlideOutListener); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 465 | |
Yorke Lee | f614f6f | 2014-10-03 10:44:19 -0700 | [diff] [blame] | 466 | mParentLayout = (FrameLayout) findViewById(R.id.dialtacts_mainlayout); |
| 467 | mParentLayout.setOnDragListener(new LayoutOnDragListener()); |
Sai Cheemalapati | c4969ea | 2014-06-04 16:35:16 -0700 | [diff] [blame] | 468 | floatingActionButtonContainer.getViewTreeObserver().addOnGlobalLayoutListener( |
Sai Cheemalapati | 4146065 | 2014-06-02 21:05:39 -0700 | [diff] [blame] | 469 | new ViewTreeObserver.OnGlobalLayoutListener() { |
| 470 | @Override |
| 471 | public void onGlobalLayout() { |
Andrew Lee | 405a6e6 | 2014-08-20 15:02:16 -0700 | [diff] [blame] | 472 | final ViewTreeObserver observer = |
| 473 | floatingActionButtonContainer.getViewTreeObserver(); |
Sai Cheemalapati | c4969ea | 2014-06-04 16:35:16 -0700 | [diff] [blame] | 474 | if (!observer.isAlive()) { |
| 475 | return; |
| 476 | } |
| 477 | observer.removeOnGlobalLayoutListener(this); |
Yorke Lee | f614f6f | 2014-10-03 10:44:19 -0700 | [diff] [blame] | 478 | int screenWidth = mParentLayout.getWidth(); |
Sai Cheemalapati | 4146065 | 2014-06-02 21:05:39 -0700 | [diff] [blame] | 479 | mFloatingActionButtonController.setScreenWidth(screenWidth); |
Andrew Lee | 6324f70 | 2015-06-16 14:45:58 -0700 | [diff] [blame] | 480 | mFloatingActionButtonController.align( |
| 481 | getFabAlignment(), false /* animate */); |
Sai Cheemalapati | 4146065 | 2014-06-02 21:05:39 -0700 | [diff] [blame] | 482 | } |
| 483 | }); |
Andrew Lee | 0c66770 | 2014-05-12 14:31:45 -0700 | [diff] [blame] | 484 | |
Yorke Lee | c7b2a0e | 2014-05-20 17:21:25 -0700 | [diff] [blame] | 485 | setupActivityOverlay(); |
| 486 | |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame] | 487 | Trace.endSection(); |
| 488 | |
| 489 | Trace.beginSection(TAG + " initialize smart dialing"); |
Yorke Lee | 0baa98b | 2013-08-22 10:55:16 -0700 | [diff] [blame] | 490 | mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(this); |
Yorke Lee | fce269a | 2013-08-12 11:56:04 -0700 | [diff] [blame] | 491 | SmartDialPrefix.initializeNanpSettings(this); |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame] | 492 | Trace.endSection(); |
| 493 | Trace.endSection(); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 494 | } |
| 495 | |
Yorke Lee | c7b2a0e | 2014-05-20 17:21:25 -0700 | [diff] [blame] | 496 | private void setupActivityOverlay() { |
| 497 | final View activityOverlay = findViewById(R.id.activity_overlay); |
| 498 | activityOverlay.setOnTouchListener(new OnTouchListener() { |
| 499 | @Override |
| 500 | public boolean onTouch(View v, MotionEvent event) { |
| 501 | if (!mIsDialpadShown) { |
| 502 | maybeExitSearchUi(); |
| 503 | } |
| 504 | return false; |
| 505 | } |
| 506 | }); |
| 507 | } |
| 508 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 509 | @Override |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 510 | protected void onResume() { |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame] | 511 | Trace.beginSection(TAG + " onResume"); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 512 | super.onResume(); |
Yorke Lee | 19e68ca | 2014-10-28 11:51:40 -0700 | [diff] [blame] | 513 | mStateSaved = false; |
Yorke Lee | 98702de | 2013-08-06 12:03:32 -0700 | [diff] [blame] | 514 | if (mFirstLaunch) { |
| 515 | displayFragment(getIntent()); |
Yorke Lee | 35127cd | 2013-09-10 14:09:29 -0700 | [diff] [blame] | 516 | } else if (!phoneIsInUse() && mInCallDialpadUp) { |
| 517 | hideDialpadFragment(false, true); |
| 518 | mInCallDialpadUp = false; |
Yorke Lee | 50aba88 | 2014-05-28 20:04:31 -0700 | [diff] [blame] | 519 | } else if (mShowDialpadOnResume) { |
| 520 | showDialpadFragment(false); |
| 521 | mShowDialpadOnResume = false; |
Yorke Lee | 98702de | 2013-08-06 12:03:32 -0700 | [diff] [blame] | 522 | } |
Tyler Gunn | c1cfae5 | 2014-11-20 13:22:54 -0800 | [diff] [blame] | 523 | |
| 524 | // If there was a voice query result returned in the {@link #onActivityResult} callback, it |
| 525 | // will have been stashed in mVoiceSearchQuery since the search results fragment cannot be |
| 526 | // shown until onResume has completed. Active the search UI and set the search term now. |
| 527 | if (!TextUtils.isEmpty(mVoiceSearchQuery)) { |
| 528 | mActionBarController.onSearchBoxTapped(); |
| 529 | mSearchView.setText(mVoiceSearchQuery); |
| 530 | mVoiceSearchQuery = null; |
| 531 | } |
| 532 | |
Yorke Lee | 98702de | 2013-08-06 12:03:32 -0700 | [diff] [blame] | 533 | mFirstLaunch = false; |
Yorke Lee | 7ee5c42 | 2014-11-04 10:29:32 -0800 | [diff] [blame] | 534 | |
| 535 | if (mIsRestarting) { |
| 536 | // This is only called when the activity goes from resumed -> paused -> resumed, so it |
| 537 | // will not cause an extra view to be sent out on rotation |
| 538 | if (mIsDialpadShown) { |
| 539 | AnalyticsUtil.sendScreenView(mDialpadFragment, this); |
| 540 | } |
| 541 | mIsRestarting = false; |
| 542 | } |
Andrew Lee | 75d5b2d | 2015-06-19 16:53:54 -0700 | [diff] [blame^] | 543 | |
Yorke Lee | 53a2230 | 2014-04-29 18:13:46 -0700 | [diff] [blame] | 544 | prepareVoiceSearchButton(); |
Yorke Lee | fce269a | 2013-08-12 11:56:04 -0700 | [diff] [blame] | 545 | mDialerDatabaseHelper.startSmartDialUpdateThread(); |
Andrew Lee | 6324f70 | 2015-06-16 14:45:58 -0700 | [diff] [blame] | 546 | mFloatingActionButtonController.align(getFabAlignment(), false /* animate */); |
Yorke Lee | f5554ce | 2015-01-27 14:46:02 -0800 | [diff] [blame] | 547 | Trace.endSection(); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 548 | } |
| 549 | |
| 550 | @Override |
Yorke Lee | 7ee5c42 | 2014-11-04 10:29:32 -0800 | [diff] [blame] | 551 | protected void onRestart() { |
| 552 | super.onRestart(); |
| 553 | mIsRestarting = true; |
| 554 | } |
| 555 | |
| 556 | @Override |
Yorke Lee | 8e5c8b1 | 2013-10-01 14:37:55 -0700 | [diff] [blame] | 557 | protected void onPause() { |
| 558 | if (mClearSearchOnPause) { |
| 559 | hideDialpadAndSearchUi(); |
| 560 | mClearSearchOnPause = false; |
| 561 | } |
Yorke Lee | 19e68ca | 2014-10-28 11:51:40 -0700 | [diff] [blame] | 562 | if (mSlideOut.hasStarted() && !mSlideOut.hasEnded()) { |
| 563 | commitDialpadFragmentHide(); |
| 564 | } |
Yorke Lee | 8e5c8b1 | 2013-10-01 14:37:55 -0700 | [diff] [blame] | 565 | super.onPause(); |
| 566 | } |
| 567 | |
| 568 | @Override |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 569 | protected void onSaveInstanceState(Bundle outState) { |
| 570 | super.onSaveInstanceState(outState); |
| 571 | outState.putString(KEY_SEARCH_QUERY, mSearchQuery); |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 572 | outState.putBoolean(KEY_IN_REGULAR_SEARCH_UI, mInRegularSearch); |
| 573 | outState.putBoolean(KEY_IN_DIALPAD_SEARCH_UI, mInDialpadSearch); |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 574 | outState.putBoolean(KEY_FIRST_LAUNCH, mFirstLaunch); |
Yorke Lee | 50aba88 | 2014-05-28 20:04:31 -0700 | [diff] [blame] | 575 | outState.putBoolean(KEY_IS_DIALPAD_SHOWN, mIsDialpadShown); |
Yorke Lee | 5253be0 | 2014-05-21 18:50:03 -0700 | [diff] [blame] | 576 | mActionBarController.saveInstanceState(outState); |
Yorke Lee | 19e68ca | 2014-10-28 11:51:40 -0700 | [diff] [blame] | 577 | mStateSaved = true; |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | @Override |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 581 | public void onAttachFragment(Fragment fragment) { |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 582 | if (fragment instanceof DialpadFragment) { |
| 583 | mDialpadFragment = (DialpadFragment) fragment; |
Yorke Lee | d5c512a | 2015-01-30 14:42:53 -0800 | [diff] [blame] | 584 | if (!mIsDialpadShown && !mShowDialpadOnResume) { |
Yorke Lee | 50aba88 | 2014-05-28 20:04:31 -0700 | [diff] [blame] | 585 | final FragmentTransaction transaction = getFragmentManager().beginTransaction(); |
| 586 | transaction.hide(mDialpadFragment); |
| 587 | transaction.commit(); |
| 588 | } |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 589 | } else if (fragment instanceof SmartDialSearchFragment) { |
| 590 | mSmartDialSearchFragment = (SmartDialSearchFragment) fragment; |
Yorke Lee | 4e28c1d | 2014-05-13 15:38:10 -0700 | [diff] [blame] | 591 | mSmartDialSearchFragment.setOnPhoneNumberPickerActionListener(this); |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 592 | } else if (fragment instanceof SearchFragment) { |
Jay Shrauner | 2e5b34b | 2013-08-29 10:52:40 -0700 | [diff] [blame] | 593 | mRegularSearchFragment = (RegularSearchFragment) fragment; |
Yorke Lee | 4e28c1d | 2014-05-13 15:38:10 -0700 | [diff] [blame] | 594 | mRegularSearchFragment.setOnPhoneNumberPickerActionListener(this); |
Yorke Lee | e00c9fe | 2014-04-12 12:42:06 -0700 | [diff] [blame] | 595 | } else if (fragment instanceof ListsFragment) { |
| 596 | mListsFragment = (ListsFragment) fragment; |
Yorke Lee | cc4660d | 2014-04-24 11:22:57 -0700 | [diff] [blame] | 597 | mListsFragment.addOnPageChangeListener(this); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 598 | } |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 599 | } |
| 600 | |
Alon Albert | b453e5b | 2013-09-10 15:54:23 -0700 | [diff] [blame] | 601 | protected void handleMenuSettings() { |
Yorke Lee | af6f195 | 2014-07-14 19:13:16 -0700 | [diff] [blame] | 602 | final Intent intent = new Intent(this, DialerSettingsActivity.class); |
| 603 | startActivity(intent); |
Alon Albert | b453e5b | 2013-09-10 15:54:23 -0700 | [diff] [blame] | 604 | } |
| 605 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 606 | @Override |
| 607 | public void onClick(View view) { |
| 608 | switch (view.getId()) { |
Andrew Lee | a73e189 | 2014-05-13 13:21:16 -0700 | [diff] [blame] | 609 | case R.id.floating_action_button: |
Andrew Lee | 432d4b5 | 2015-05-20 16:52:00 -0700 | [diff] [blame] | 610 | if (mListsFragment.getCurrentTabIndex() == ListsFragment.TAB_INDEX_ALL_CONTACTS) { |
Andrew Lee | 247df6e | 2015-05-12 19:09:00 -0700 | [diff] [blame] | 611 | DialerUtils.startActivityWithErrorToast( |
| 612 | this, |
| 613 | IntentUtil.getNewContactIntent(), |
| 614 | R.string.add_contact_not_available); |
Andrew Lee | fdfeaaf | 2015-05-05 14:10:35 -0700 | [diff] [blame] | 615 | } else if (!mIsDialpadShown) { |
Andrew Lee | a73e189 | 2014-05-13 13:21:16 -0700 | [diff] [blame] | 616 | mInCallDialpadUp = false; |
| 617 | showDialpadFragment(true); |
Andrew Lee | a73e189 | 2014-05-13 13:21:16 -0700 | [diff] [blame] | 618 | } |
Yorke Lee | 86e21f7 | 2014-04-02 16:49:38 -0700 | [diff] [blame] | 619 | break; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 620 | case R.id.voice_search_button: |
Yorke Lee | da0f904 | 2013-12-05 14:25:51 -0800 | [diff] [blame] | 621 | try { |
| 622 | startActivityForResult(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), |
| 623 | ACTIVITY_REQUEST_CODE_VOICE_SEARCH); |
| 624 | } catch (ActivityNotFoundException e) { |
| 625 | Toast.makeText(DialtactsActivity.this, R.string.voice_search_not_available, |
| 626 | Toast.LENGTH_SHORT).show(); |
| 627 | } |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 628 | break; |
Andrew Lee | e74a10e | 2014-05-16 14:31:40 -0700 | [diff] [blame] | 629 | case R.id.dialtacts_options_menu_button: |
Yorke Lee | 74edcdc | 2014-07-11 16:15:08 -0700 | [diff] [blame] | 630 | mOverflowMenu.show(); |
Andrew Lee | e74a10e | 2014-05-16 14:31:40 -0700 | [diff] [blame] | 631 | break; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 632 | default: { |
| 633 | Log.wtf(TAG, "Unexpected onClick event from " + view); |
| 634 | break; |
| 635 | } |
| 636 | } |
| 637 | } |
| 638 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 639 | @Override |
Andrew Lee | e74a10e | 2014-05-16 14:31:40 -0700 | [diff] [blame] | 640 | public boolean onMenuItemClick(MenuItem item) { |
Yorke Lee | 86e21f7 | 2014-04-02 16:49:38 -0700 | [diff] [blame] | 641 | switch (item.getItemId()) { |
| 642 | case R.id.menu_history: |
Andrew Lee | 69705be | 2015-05-04 17:24:01 -0700 | [diff] [blame] | 643 | // Use explicit CallLogActivity intent instead of ACTION_VIEW + |
| 644 | // CONTENT_TYPE, so that we always open our call log from our dialer |
| 645 | final Intent intent = new Intent(this, CallLogActivity.class); |
| 646 | startActivity(intent); |
Yorke Lee | 86e21f7 | 2014-04-02 16:49:38 -0700 | [diff] [blame] | 647 | break; |
| 648 | case R.id.menu_add_contact: |
Andrew Lee | 247df6e | 2015-05-12 19:09:00 -0700 | [diff] [blame] | 649 | DialerUtils.startActivityWithErrorToast( |
| 650 | this, |
| 651 | IntentUtil.getNewContactIntent(), |
| 652 | R.string.add_contact_not_available); |
Yorke Lee | 86e21f7 | 2014-04-02 16:49:38 -0700 | [diff] [blame] | 653 | break; |
| 654 | case R.id.menu_import_export: |
| 655 | // We hard-code the "contactsAreAvailable" argument because doing it properly would |
| 656 | // involve querying a {@link ProviderStatusLoader}, which we don't want to do right |
| 657 | // now in Dialtacts for (potential) performance reasons. Compare with how it is |
| 658 | // done in {@link PeopleActivity}. |
| 659 | ImportExportDialogFragment.show(getFragmentManager(), true, |
| 660 | DialtactsActivity.class); |
| 661 | return true; |
| 662 | case R.id.menu_clear_frequents: |
Yorke Lee | 86e21f7 | 2014-04-02 16:49:38 -0700 | [diff] [blame] | 663 | ClearFrequentsDialog.show(getFragmentManager()); |
| 664 | return true; |
| 665 | case R.id.menu_call_settings: |
| 666 | handleMenuSettings(); |
| 667 | return true; |
Yorke Lee | 86e21f7 | 2014-04-02 16:49:38 -0700 | [diff] [blame] | 668 | } |
| 669 | return false; |
| 670 | } |
| 671 | |
| 672 | @Override |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 673 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 674 | if (requestCode == ACTIVITY_REQUEST_CODE_VOICE_SEARCH) { |
| 675 | if (resultCode == RESULT_OK) { |
| 676 | final ArrayList<String> matches = data.getStringArrayListExtra( |
| 677 | RecognizerIntent.EXTRA_RESULTS); |
| 678 | if (matches.size() > 0) { |
| 679 | final String match = matches.get(0); |
Tyler Gunn | c1cfae5 | 2014-11-20 13:22:54 -0800 | [diff] [blame] | 680 | mVoiceSearchQuery = match; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 681 | } else { |
| 682 | Log.e(TAG, "Voice search - nothing heard"); |
| 683 | } |
| 684 | } else { |
| 685 | Log.e(TAG, "Voice search failed"); |
| 686 | } |
| 687 | } |
| 688 | super.onActivityResult(requestCode, resultCode, data); |
| 689 | } |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 690 | |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 691 | /** |
| 692 | * Initiates a fragment transaction to show the dialpad fragment. Animations and other visual |
| 693 | * updates are handled by a callback which is invoked after the dialpad fragment is shown. |
| 694 | * @see #onDialpadShown |
| 695 | */ |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 696 | private void showDialpadFragment(boolean animate) { |
Yorke Lee | 19e68ca | 2014-10-28 11:51:40 -0700 | [diff] [blame] | 697 | if (mIsDialpadShown || mStateSaved) { |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 698 | return; |
| 699 | } |
| 700 | mIsDialpadShown = true; |
Yorke Lee | d5c512a | 2015-01-30 14:42:53 -0800 | [diff] [blame] | 701 | |
Yorke Lee | 7ee5c42 | 2014-11-04 10:29:32 -0800 | [diff] [blame] | 702 | mListsFragment.setUserVisibleHint(false); |
Andrew Lee | cdfa6c6 | 2014-05-06 15:33:35 -0700 | [diff] [blame] | 703 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 704 | final FragmentTransaction ft = getFragmentManager().beginTransaction(); |
Yorke Lee | d5c512a | 2015-01-30 14:42:53 -0800 | [diff] [blame] | 705 | if (mDialpadFragment == null) { |
| 706 | mDialpadFragment = new DialpadFragment(); |
| 707 | ft.add(R.id.dialtacts_container, mDialpadFragment, TAG_DIALPAD_FRAGMENT); |
| 708 | } else { |
| 709 | ft.show(mDialpadFragment); |
| 710 | } |
| 711 | |
| 712 | mDialpadFragment.setAnimate(animate); |
| 713 | AnalyticsUtil.sendScreenView(mDialpadFragment); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 714 | ft.commit(); |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 715 | |
Yorke Lee | 29ae4ae | 2014-09-09 16:30:34 -0700 | [diff] [blame] | 716 | if (animate) { |
| 717 | mFloatingActionButtonController.scaleOut(); |
| 718 | } else { |
| 719 | mFloatingActionButtonController.setVisible(false); |
Yorke Lee | 81a313d | 2015-06-01 14:53:59 -0700 | [diff] [blame] | 720 | maybeEnterSearchUi(); |
Yorke Lee | 29ae4ae | 2014-09-09 16:30:34 -0700 | [diff] [blame] | 721 | } |
Yorke Lee | 5253be0 | 2014-05-21 18:50:03 -0700 | [diff] [blame] | 722 | mActionBarController.onDialpadUp(); |
| 723 | |
Yorke Lee | 6c450eb | 2015-05-08 09:45:47 -0700 | [diff] [blame] | 724 | mListsFragment.getView().animate().alpha(0).withLayer(); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 725 | } |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 726 | |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 727 | /** |
| 728 | * Callback from child DialpadFragment when the dialpad is shown. |
| 729 | */ |
| 730 | public void onDialpadShown() { |
Yorke Lee | d5c512a | 2015-01-30 14:42:53 -0800 | [diff] [blame] | 731 | Assert.assertNotNull(mDialpadFragment); |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 732 | if (mDialpadFragment.getAnimate()) { |
Sai Cheemalapati | 82d6da5 | 2014-06-03 13:54:23 -0700 | [diff] [blame] | 733 | mDialpadFragment.getView().startAnimation(mSlideIn); |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 734 | } else { |
| 735 | mDialpadFragment.setYFraction(0); |
| 736 | } |
| 737 | |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 738 | updateSearchFragmentPosition(); |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 739 | } |
| 740 | |
| 741 | /** |
| 742 | * Initiates animations and other visual updates to hide the dialpad. The fragment is hidden in |
| 743 | * a callback after the hide animation ends. |
| 744 | * @see #commitDialpadFragmentHide |
| 745 | */ |
Yorke Lee | ca19504 | 2013-09-25 16:29:38 -0700 | [diff] [blame] | 746 | public void hideDialpadFragment(boolean animate, boolean clearDialpad) { |
Yorke Lee | 791b488 | 2015-05-15 10:52:27 -0700 | [diff] [blame] | 747 | if (mDialpadFragment == null || mDialpadFragment.getView() == null) { |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 748 | return; |
| 749 | } |
Yorke Lee | f6673d3 | 2013-08-23 15:34:17 -0700 | [diff] [blame] | 750 | if (clearDialpad) { |
| 751 | mDialpadFragment.clearDialpad(); |
| 752 | } |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 753 | if (!mIsDialpadShown) { |
| 754 | return; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 755 | } |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 756 | mIsDialpadShown = false; |
| 757 | mDialpadFragment.setAnimate(animate); |
Yorke Lee | 7ee5c42 | 2014-11-04 10:29:32 -0800 | [diff] [blame] | 758 | mListsFragment.setUserVisibleHint(true); |
| 759 | mListsFragment.sendScreenViewForCurrentPosition(); |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 760 | |
Andrew Lee | dbe9a8c | 2014-05-16 15:18:40 -0700 | [diff] [blame] | 761 | updateSearchFragmentPosition(); |
Sai Cheemalapati | c4969ea | 2014-06-04 16:35:16 -0700 | [diff] [blame] | 762 | |
Andrew Lee | 6324f70 | 2015-06-16 14:45:58 -0700 | [diff] [blame] | 763 | mFloatingActionButtonController.align(getFabAlignment(), animate); |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 764 | if (animate) { |
Sai Cheemalapati | 82d6da5 | 2014-06-03 13:54:23 -0700 | [diff] [blame] | 765 | mDialpadFragment.getView().startAnimation(mSlideOut); |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 766 | } else { |
| 767 | commitDialpadFragmentHide(); |
| 768 | } |
| 769 | |
Yorke Lee | 5253be0 | 2014-05-21 18:50:03 -0700 | [diff] [blame] | 770 | mActionBarController.onDialpadDown(); |
Yorke Lee | 11ca39e | 2014-05-19 20:31:37 -0700 | [diff] [blame] | 771 | |
Andrew Lee | d4cde83 | 2014-05-16 15:56:48 -0700 | [diff] [blame] | 772 | if (isInSearchUi()) { |
Andrew Lee | 44e3daf | 2014-05-19 14:28:16 -0700 | [diff] [blame] | 773 | if (TextUtils.isEmpty(mSearchQuery)) { |
| 774 | exitSearchUi(); |
Andrew Lee | 44e3daf | 2014-05-19 14:28:16 -0700 | [diff] [blame] | 775 | } |
Andrew Lee | d4cde83 | 2014-05-16 15:56:48 -0700 | [diff] [blame] | 776 | } |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 777 | } |
| 778 | |
| 779 | /** |
| 780 | * Finishes hiding the dialpad fragment after any animations are completed. |
| 781 | */ |
| 782 | private void commitDialpadFragmentHide() { |
Yorke Lee | d5c512a | 2015-01-30 14:42:53 -0800 | [diff] [blame] | 783 | if (!mStateSaved && mDialpadFragment != null && !mDialpadFragment.isHidden()) { |
Yorke Lee | 19e68ca | 2014-10-28 11:51:40 -0700 | [diff] [blame] | 784 | final FragmentTransaction ft = getFragmentManager().beginTransaction(); |
| 785 | ft.hide(mDialpadFragment); |
| 786 | ft.commit(); |
| 787 | } |
Andrew Lee | 405a6e6 | 2014-08-20 15:02:16 -0700 | [diff] [blame] | 788 | mFloatingActionButtonController.scaleIn(AnimUtils.NO_DELAY); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 789 | } |
| 790 | |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 791 | private void updateSearchFragmentPosition() { |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 792 | SearchFragment fragment = null; |
Andrew Lee | dbe9a8c | 2014-05-16 15:18:40 -0700 | [diff] [blame] | 793 | if (mSmartDialSearchFragment != null && mSmartDialSearchFragment.isVisible()) { |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 794 | fragment = mSmartDialSearchFragment; |
Andrew Lee | dbe9a8c | 2014-05-16 15:18:40 -0700 | [diff] [blame] | 795 | } else if (mRegularSearchFragment != null && mRegularSearchFragment.isVisible()) { |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 796 | fragment = mRegularSearchFragment; |
| 797 | } |
| 798 | if (fragment != null && fragment.isVisible()) { |
Andrew Lee | 9da8fb4 | 2014-06-03 14:03:09 -0700 | [diff] [blame] | 799 | fragment.updatePosition(true /* animate */); |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 800 | } |
| 801 | } |
| 802 | |
Yorke Lee | 5253be0 | 2014-05-21 18:50:03 -0700 | [diff] [blame] | 803 | @Override |
| 804 | public boolean isInSearchUi() { |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 805 | return mInDialpadSearch || mInRegularSearch; |
| 806 | } |
| 807 | |
Yorke Lee | 5253be0 | 2014-05-21 18:50:03 -0700 | [diff] [blame] | 808 | @Override |
| 809 | public boolean hasSearchQuery() { |
| 810 | return !TextUtils.isEmpty(mSearchQuery); |
| 811 | } |
| 812 | |
| 813 | @Override |
| 814 | public boolean shouldShowActionBar() { |
| 815 | return mListsFragment.shouldShowActionBar(); |
| 816 | } |
| 817 | |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 818 | private void setNotInSearchUi() { |
| 819 | mInDialpadSearch = false; |
| 820 | mInRegularSearch = false; |
| 821 | } |
| 822 | |
Yorke Lee | 311969c | 2013-08-26 06:31:11 -0700 | [diff] [blame] | 823 | private void hideDialpadAndSearchUi() { |
Yorke Lee | 710709d | 2014-05-29 07:18:42 -0700 | [diff] [blame] | 824 | if (mIsDialpadShown) { |
| 825 | hideDialpadFragment(false, true); |
| 826 | } else { |
| 827 | exitSearchUi(); |
| 828 | } |
Yorke Lee | 311969c | 2013-08-26 06:31:11 -0700 | [diff] [blame] | 829 | } |
| 830 | |
Yorke Lee | 53a2230 | 2014-04-29 18:13:46 -0700 | [diff] [blame] | 831 | private void prepareVoiceSearchButton() { |
Yorke Lee | 53a2230 | 2014-04-29 18:13:46 -0700 | [diff] [blame] | 832 | final Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); |
| 833 | if (canIntentBeHandled(voiceIntent)) { |
| 834 | mVoiceSearchButton.setVisibility(View.VISIBLE); |
| 835 | mVoiceSearchButton.setOnClickListener(this); |
| 836 | } else { |
| 837 | mVoiceSearchButton.setVisibility(View.GONE); |
| 838 | } |
| 839 | } |
| 840 | |
Andrew Lee | 467de3d | 2015-03-17 15:47:24 -0700 | [diff] [blame] | 841 | protected OptionsPopupMenu buildOptionsMenu(View invoker) { |
Andrew Lee | e74a10e | 2014-05-16 14:31:40 -0700 | [diff] [blame] | 842 | final OptionsPopupMenu popupMenu = new OptionsPopupMenu(this, invoker); |
| 843 | popupMenu.inflate(R.menu.dialtacts_options); |
| 844 | popupMenu.setOnMenuItemClickListener(this); |
| 845 | return popupMenu; |
| 846 | } |
| 847 | |
Yorke Lee | 86e21f7 | 2014-04-02 16:49:38 -0700 | [diff] [blame] | 848 | @Override |
| 849 | public boolean onCreateOptionsMenu(Menu menu) { |
Yorke Lee | 3c9e7cd | 2014-04-16 11:37:21 -0700 | [diff] [blame] | 850 | if (mPendingSearchViewQuery != null) { |
Yorke Lee | 53a2230 | 2014-04-29 18:13:46 -0700 | [diff] [blame] | 851 | mSearchView.setText(mPendingSearchViewQuery); |
Yorke Lee | 3c9e7cd | 2014-04-16 11:37:21 -0700 | [diff] [blame] | 852 | mPendingSearchViewQuery = null; |
| 853 | } |
Yorke Lee | c16ea5a | 2015-05-19 15:51:01 -0700 | [diff] [blame] | 854 | if (mActionBarController != null) { |
| 855 | mActionBarController.restoreActionBarOffset(); |
| 856 | } |
Andrew Lee | e74a10e | 2014-05-16 14:31:40 -0700 | [diff] [blame] | 857 | return false; |
Ihab Awad | fb00cb8 | 2014-03-18 16:19:00 -0700 | [diff] [blame] | 858 | } |
| 859 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 860 | /** |
| 861 | * Returns true if the intent is due to hitting the green send key (hardware call button: |
| 862 | * KEYCODE_CALL) while in a call. |
| 863 | * |
| 864 | * @param intent the intent that launched this activity |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 865 | * @return true if the intent is due to hitting the green send key while in a call |
| 866 | */ |
Yorke Lee | 62e995c | 2014-03-28 10:02:56 -0700 | [diff] [blame] | 867 | private boolean isSendKeyWhileInCall(Intent intent) { |
| 868 | // If there is a call in progress and the user launched the dialer by hitting the call |
| 869 | // button, go straight to the in-call screen. |
| 870 | final boolean callKey = Intent.ACTION_CALL_BUTTON.equals(intent.getAction()); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 871 | |
Santos Cordon | 1d7ef6a | 2014-05-29 21:46:33 -0700 | [diff] [blame] | 872 | if (callKey) { |
Tyler Gunn | 9dc924c | 2014-09-12 09:33:50 -0700 | [diff] [blame] | 873 | getTelecomManager().showInCallScreen(false); |
Santos Cordon | 1d7ef6a | 2014-05-29 21:46:33 -0700 | [diff] [blame] | 874 | return true; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 875 | } |
| 876 | |
| 877 | return false; |
| 878 | } |
| 879 | |
| 880 | /** |
| 881 | * Sets the current tab based on the intent's request type |
| 882 | * |
| 883 | * @param intent Intent that contains information about which tab should be selected |
| 884 | */ |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 885 | private void displayFragment(Intent intent) { |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 886 | // If we got here by hitting send and we're in call forward along to the in-call activity |
Yorke Lee | 62e995c | 2014-03-28 10:02:56 -0700 | [diff] [blame] | 887 | if (isSendKeyWhileInCall(intent)) { |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 888 | finish(); |
| 889 | return; |
| 890 | } |
| 891 | |
Yorke Lee | d5c512a | 2015-01-30 14:42:53 -0800 | [diff] [blame] | 892 | final boolean phoneIsInUse = phoneIsInUse(); |
| 893 | if (phoneIsInUse || (intent.getData() != null && isDialIntent(intent))) { |
| 894 | showDialpadFragment(false); |
| 895 | mDialpadFragment.setStartedFromNewIntent(true); |
| 896 | if (phoneIsInUse && !mDialpadFragment.isVisible()) { |
| 897 | mInCallDialpadUp = true; |
Yorke Lee | 35127cd | 2013-09-10 14:09:29 -0700 | [diff] [blame] | 898 | } |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 899 | } |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 900 | } |
| 901 | |
| 902 | @Override |
| 903 | public void onNewIntent(Intent newIntent) { |
| 904 | setIntent(newIntent); |
Nancy Chen | 199b7f0 | 2014-11-05 15:03:00 -0800 | [diff] [blame] | 905 | mStateSaved = false; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 906 | displayFragment(newIntent); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 907 | |
Andrew Lee | 75d5b2d | 2015-06-19 16:53:54 -0700 | [diff] [blame^] | 908 | if (newIntent.hasExtra(EXTRA_SHOW_TAB)) { |
| 909 | mListsFragment.showTab( |
| 910 | getIntent().getIntExtra(EXTRA_SHOW_TAB, mListsFragment.TAB_INDEX_SPEED_DIAL)); |
| 911 | } |
| 912 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 913 | invalidateOptionsMenu(); |
| 914 | } |
| 915 | |
| 916 | /** Returns true if the given intent contains a phone number to populate the dialer with */ |
| 917 | private boolean isDialIntent(Intent intent) { |
| 918 | final String action = intent.getAction(); |
| 919 | if (Intent.ACTION_DIAL.equals(action) || ACTION_TOUCH_DIALER.equals(action)) { |
| 920 | return true; |
| 921 | } |
| 922 | if (Intent.ACTION_VIEW.equals(action)) { |
| 923 | final Uri data = intent.getData(); |
Jay Shrauner | ae274c0 | 2014-09-06 10:09:24 -0700 | [diff] [blame] | 924 | if (data != null && PhoneAccount.SCHEME_TEL.equals(data.getScheme())) { |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 925 | return true; |
| 926 | } |
| 927 | } |
| 928 | return false; |
| 929 | } |
| 930 | |
| 931 | /** |
| 932 | * Returns an appropriate call origin for this Activity. May return null when no call origin |
| 933 | * should be used (e.g. when some 3rd party application launched the screen. Call origin is |
| 934 | * for remembering the tab in which the user made a phone call, so the external app's DIAL |
| 935 | * request should not be counted.) |
| 936 | */ |
| 937 | public String getCallOrigin() { |
| 938 | return !isDialIntent(getIntent()) ? CALL_ORIGIN_DIALTACTS : null; |
| 939 | } |
| 940 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 941 | /** |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 942 | * Shows the search fragment |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 943 | */ |
Yorke Lee | 6c450eb | 2015-05-08 09:45:47 -0700 | [diff] [blame] | 944 | private void enterSearchUi(boolean smartDialSearch, String query, boolean animate) { |
Yorke Lee | 19e68ca | 2014-10-28 11:51:40 -0700 | [diff] [blame] | 945 | if (mStateSaved || getFragmentManager().isDestroyed()) { |
Yorke Lee | 34bdf87 | 2013-08-15 14:11:50 -0700 | [diff] [blame] | 946 | // Weird race condition where fragment is doing work after the activity is destroyed |
| 947 | // due to talkback being on (b/10209937). Just return since we can't do any |
| 948 | // constructive here. |
| 949 | return; |
| 950 | } |
| 951 | |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 952 | if (DEBUG) { |
| 953 | Log.d(TAG, "Entering search UI - smart dial " + smartDialSearch); |
| 954 | } |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 955 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 956 | final FragmentTransaction transaction = getFragmentManager().beginTransaction(); |
Yorke Lee | e00c9fe | 2014-04-12 12:42:06 -0700 | [diff] [blame] | 957 | if (mInDialpadSearch && mSmartDialSearchFragment != null) { |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 958 | transaction.remove(mSmartDialSearchFragment); |
Yorke Lee | e00c9fe | 2014-04-12 12:42:06 -0700 | [diff] [blame] | 959 | } else if (mInRegularSearch && mRegularSearchFragment != null) { |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 960 | transaction.remove(mRegularSearchFragment); |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 961 | } |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 962 | |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 963 | final String tag; |
| 964 | if (smartDialSearch) { |
| 965 | tag = TAG_SMARTDIAL_SEARCH_FRAGMENT; |
| 966 | } else { |
| 967 | tag = TAG_REGULAR_SEARCH_FRAGMENT; |
| 968 | } |
| 969 | mInDialpadSearch = smartDialSearch; |
| 970 | mInRegularSearch = !smartDialSearch; |
| 971 | |
Andrew Lee | 6324f70 | 2015-06-16 14:45:58 -0700 | [diff] [blame] | 972 | mFloatingActionButtonController.scaleOut(); |
| 973 | |
Andrew Lee | 752956e | 2014-05-15 11:43:38 -0700 | [diff] [blame] | 974 | SearchFragment fragment = (SearchFragment) getFragmentManager().findFragmentByTag(tag); |
Yorke Lee | 6c450eb | 2015-05-08 09:45:47 -0700 | [diff] [blame] | 975 | if (animate) { |
| 976 | transaction.setCustomAnimations(android.R.animator.fade_in, 0); |
| 977 | } else { |
| 978 | transaction.setTransition(FragmentTransaction.TRANSIT_NONE); |
| 979 | } |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 980 | if (fragment == null) { |
| 981 | if (smartDialSearch) { |
| 982 | fragment = new SmartDialSearchFragment(); |
| 983 | } else { |
Jay Shrauner | 2e5b34b | 2013-08-29 10:52:40 -0700 | [diff] [blame] | 984 | fragment = new RegularSearchFragment(); |
Andrew Lee | 6324f70 | 2015-06-16 14:45:58 -0700 | [diff] [blame] | 985 | fragment.setOnTouchListener(new View.OnTouchListener() { |
| 986 | @Override |
| 987 | public boolean onTouch(View v, MotionEvent event) { |
| 988 | // Show the FAB when the user touches the lists fragment and the soft |
| 989 | // keyboard is hidden. |
| 990 | showFabInSearchUi(); |
| 991 | return false; |
| 992 | } |
| 993 | }); |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 994 | } |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 995 | transaction.add(R.id.dialtacts_frame, fragment, tag); |
| 996 | } else { |
| 997 | transaction.show(fragment); |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 998 | } |
Yorke Lee | 86e21f7 | 2014-04-02 16:49:38 -0700 | [diff] [blame] | 999 | // DialtactsActivity will provide the options menu |
| 1000 | fragment.setHasOptionsMenu(false); |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 1001 | fragment.setShowEmptyListForNullQuery(true); |
Yorke Lee | 6c450eb | 2015-05-08 09:45:47 -0700 | [diff] [blame] | 1002 | if (!smartDialSearch) { |
| 1003 | fragment.setQueryString(query, false /* delaySelection */); |
| 1004 | } |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 1005 | transaction.commit(); |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 1006 | |
Yorke Lee | 6c450eb | 2015-05-08 09:45:47 -0700 | [diff] [blame] | 1007 | if (animate) { |
| 1008 | mListsFragment.getView().animate().alpha(0).withLayer(); |
| 1009 | } |
Yorke Lee | 7ee5c42 | 2014-11-04 10:29:32 -0800 | [diff] [blame] | 1010 | mListsFragment.setUserVisibleHint(false); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 1011 | } |
| 1012 | |
| 1013 | /** |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 1014 | * Hides the search fragment |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 1015 | */ |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 1016 | private void exitSearchUi() { |
Yorke Lee | 3487db7 | 2013-09-26 17:12:06 -0700 | [diff] [blame] | 1017 | // See related bug in enterSearchUI(); |
Yorke Lee | 19e68ca | 2014-10-28 11:51:40 -0700 | [diff] [blame] | 1018 | if (getFragmentManager().isDestroyed() || mStateSaved) { |
Yorke Lee | 3487db7 | 2013-09-26 17:12:06 -0700 | [diff] [blame] | 1019 | return; |
| 1020 | } |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 1021 | |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 1022 | mSearchView.setText(null); |
Yorke Lee | d5c512a | 2015-01-30 14:42:53 -0800 | [diff] [blame] | 1023 | |
| 1024 | if (mDialpadFragment != null) { |
| 1025 | mDialpadFragment.clearDialpad(); |
| 1026 | } |
| 1027 | |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 1028 | setNotInSearchUi(); |
Yorke Lee | 7eccf45 | 2014-03-14 12:52:42 -0700 | [diff] [blame] | 1029 | |
Andrew Lee | 6324f70 | 2015-06-16 14:45:58 -0700 | [diff] [blame] | 1030 | // Restore the FAB for the lists fragment. |
| 1031 | if (getFabAlignment() != FloatingActionButtonController.ALIGN_END) { |
| 1032 | mFloatingActionButtonController.setVisible(false); |
| 1033 | } |
| 1034 | mFloatingActionButtonController.scaleIn(FAB_SCALE_IN_DELAY_MS); |
| 1035 | onPageScrolled(mListsFragment.getCurrentTabIndex(), 0 /* offset */, 0 /* pixelOffset */); |
| 1036 | onPageSelected(mListsFragment.getCurrentTabIndex()); |
| 1037 | |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 1038 | final FragmentTransaction transaction = getFragmentManager().beginTransaction(); |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 1039 | if (mSmartDialSearchFragment != null) { |
| 1040 | transaction.remove(mSmartDialSearchFragment); |
Yorke Lee | 7eccf45 | 2014-03-14 12:52:42 -0700 | [diff] [blame] | 1041 | } |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 1042 | if (mRegularSearchFragment != null) { |
| 1043 | transaction.remove(mRegularSearchFragment); |
| 1044 | } |
| 1045 | transaction.commit(); |
| 1046 | |
| 1047 | mListsFragment.getView().animate().alpha(1).withLayer(); |
Yorke Lee | d5c512a | 2015-01-30 14:42:53 -0800 | [diff] [blame] | 1048 | |
| 1049 | if (mDialpadFragment == null || !mDialpadFragment.isVisible()) { |
Yorke Lee | 7ee5c42 | 2014-11-04 10:29:32 -0800 | [diff] [blame] | 1050 | // If the dialpad fragment wasn't previously visible, then send a screen view because |
| 1051 | // we are exiting regular search. Otherwise, the screen view will be sent by |
| 1052 | // {@link #hideDialpadFragment}. |
| 1053 | mListsFragment.sendScreenViewForCurrentPosition(); |
| 1054 | mListsFragment.setUserVisibleHint(true); |
| 1055 | } |
| 1056 | |
Yorke Lee | 5253be0 | 2014-05-21 18:50:03 -0700 | [diff] [blame] | 1057 | mActionBarController.onSearchUiExited(); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 1058 | } |
| 1059 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 1060 | @Override |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 1061 | public void onBackPressed() { |
Yorke Lee | 19e68ca | 2014-10-28 11:51:40 -0700 | [diff] [blame] | 1062 | if (mStateSaved) { |
| 1063 | return; |
| 1064 | } |
Andrew Lee | 2a58ab8 | 2014-05-15 02:16:04 -0700 | [diff] [blame] | 1065 | if (mIsDialpadShown) { |
Andrew Lee | 9fd8f25 | 2014-06-13 17:09:26 -0700 | [diff] [blame] | 1066 | if (TextUtils.isEmpty(mSearchQuery) || |
| 1067 | (mSmartDialSearchFragment != null && mSmartDialSearchFragment.isVisible() |
| 1068 | && mSmartDialSearchFragment.getAdapter().getCount() == 0)) { |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 1069 | exitSearchUi(); |
| 1070 | } |
Yorke Lee | f6673d3 | 2013-08-23 15:34:17 -0700 | [diff] [blame] | 1071 | hideDialpadFragment(true, false); |
Andrew Lee | b190384 | 2014-05-15 16:11:24 -0700 | [diff] [blame] | 1072 | } else if (isInSearchUi()) { |
Andrew Lee | 99a570c | 2014-05-15 14:18:50 -0700 | [diff] [blame] | 1073 | exitSearchUi(); |
Yorke Lee | f614f6f | 2014-10-03 10:44:19 -0700 | [diff] [blame] | 1074 | DialerUtils.hideInputMethod(mParentLayout); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 1075 | } else { |
| 1076 | super.onBackPressed(); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 1077 | } |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 1078 | } |
| 1079 | |
Yorke Lee | 81a313d | 2015-06-01 14:53:59 -0700 | [diff] [blame] | 1080 | private void maybeEnterSearchUi() { |
| 1081 | if (!isInSearchUi()) { |
| 1082 | enterSearchUi(true /* isSmartDial */, mSearchQuery, false); |
| 1083 | } |
| 1084 | } |
| 1085 | |
Yorke Lee | c7b2a0e | 2014-05-20 17:21:25 -0700 | [diff] [blame] | 1086 | /** |
| 1087 | * @return True if the search UI was exited, false otherwise |
| 1088 | */ |
| 1089 | private boolean maybeExitSearchUi() { |
| 1090 | if (isInSearchUi() && TextUtils.isEmpty(mSearchQuery)) { |
| 1091 | exitSearchUi(); |
Yorke Lee | f614f6f | 2014-10-03 10:44:19 -0700 | [diff] [blame] | 1092 | DialerUtils.hideInputMethod(mParentLayout); |
Yorke Lee | c7b2a0e | 2014-05-20 17:21:25 -0700 | [diff] [blame] | 1093 | return true; |
| 1094 | } |
| 1095 | return false; |
| 1096 | } |
| 1097 | |
Andrew Lee | 6324f70 | 2015-06-16 14:45:58 -0700 | [diff] [blame] | 1098 | private void showFabInSearchUi() { |
| 1099 | mFloatingActionButtonController.changeIcon( |
| 1100 | getResources().getDrawable(R.drawable.fab_ic_dial), |
| 1101 | getResources().getString(R.string.action_menu_dialpad_button)); |
| 1102 | mFloatingActionButtonController.align(getFabAlignment(), false /* animate */); |
| 1103 | mFloatingActionButtonController.scaleIn(FAB_SCALE_IN_DELAY_MS); |
| 1104 | } |
| 1105 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 1106 | @Override |
| 1107 | public void onDialpadQueryChanged(String query) { |
Yorke Lee | 4663587 | 2014-04-11 11:20:15 -0700 | [diff] [blame] | 1108 | if (mSmartDialSearchFragment != null) { |
| 1109 | mSmartDialSearchFragment.setAddToContactNumber(query); |
| 1110 | } |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 1111 | final String normalizedQuery = SmartDialNameMatcher.normalizeNumber(query, |
| 1112 | SmartDialNameMatcher.LATIN_SMART_DIAL_MAP); |
Yorke Lee | 53a2230 | 2014-04-29 18:13:46 -0700 | [diff] [blame] | 1113 | |
| 1114 | if (!TextUtils.equals(mSearchView.getText(), normalizedQuery)) { |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 1115 | if (DEBUG) { |
| 1116 | Log.d(TAG, "onDialpadQueryChanged - new query: " + query); |
| 1117 | } |
| 1118 | if (mDialpadFragment == null || !mDialpadFragment.isVisible()) { |
| 1119 | // This callback can happen if the dialpad fragment is recreated because of |
| 1120 | // activity destruction. In that case, don't update the search view because |
| 1121 | // that would bring the user back to the search fragment regardless of the |
| 1122 | // previous state of the application. Instead, just return here and let the |
| 1123 | // fragment manager correctly figure out whatever fragment was last displayed. |
Yorke Lee | 53a2230 | 2014-04-29 18:13:46 -0700 | [diff] [blame] | 1124 | if (!TextUtils.isEmpty(normalizedQuery)) { |
| 1125 | mPendingSearchViewQuery = normalizedQuery; |
| 1126 | } |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 1127 | return; |
| 1128 | } |
Yorke Lee | 53a2230 | 2014-04-29 18:13:46 -0700 | [diff] [blame] | 1129 | mSearchView.setText(normalizedQuery); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 1130 | } |
Santos Cordon | 8313171 | 2015-04-16 21:25:35 -0700 | [diff] [blame] | 1131 | |
| 1132 | try { |
| 1133 | if (mDialpadFragment != null && mDialpadFragment.isVisible()) { |
| 1134 | mDialpadFragment.process_quote_emergency_unquote(normalizedQuery); |
| 1135 | } |
| 1136 | } catch (Exception ignored) { |
| 1137 | // Skip any exceptions for this piece of code |
| 1138 | } |
| 1139 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 1140 | } |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 1141 | |
| 1142 | @Override |
| 1143 | public void onListFragmentScrollStateChange(int scrollState) { |
| 1144 | if (scrollState == OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) { |
Yorke Lee | f6673d3 | 2013-08-23 15:34:17 -0700 | [diff] [blame] | 1145 | hideDialpadFragment(true, false); |
Yorke Lee | f614f6f | 2014-10-03 10:44:19 -0700 | [diff] [blame] | 1146 | DialerUtils.hideInputMethod(mParentLayout); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 1147 | } |
| 1148 | } |
| 1149 | |
| 1150 | @Override |
Yorke Lee | 86e21f7 | 2014-04-02 16:49:38 -0700 | [diff] [blame] | 1151 | public void onListFragmentScroll(int firstVisibleItem, int visibleItemCount, |
Andrew Lee | 99a570c | 2014-05-15 14:18:50 -0700 | [diff] [blame] | 1152 | int totalItemCount) { |
Yorke Lee | e00c9fe | 2014-04-12 12:42:06 -0700 | [diff] [blame] | 1153 | // TODO: No-op for now. This should eventually show/hide the actionBar based on |
| 1154 | // interactions with the ListsFragments. |
Yorke Lee | 86e21f7 | 2014-04-02 16:49:38 -0700 | [diff] [blame] | 1155 | } |
| 1156 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 1157 | private boolean phoneIsInUse() { |
Tyler Gunn | 9dc924c | 2014-09-12 09:33:50 -0700 | [diff] [blame] | 1158 | return getTelecomManager().isInCall(); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 1159 | } |
Yorke Lee | 8dd6200 | 2013-08-08 15:57:20 -0700 | [diff] [blame] | 1160 | |
Yorke Lee | da0f904 | 2013-12-05 14:25:51 -0800 | [diff] [blame] | 1161 | private boolean canIntentBeHandled(Intent intent) { |
| 1162 | final PackageManager packageManager = getPackageManager(); |
| 1163 | final List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(intent, |
| 1164 | PackageManager.MATCH_DEFAULT_ONLY); |
| 1165 | return resolveInfo != null && resolveInfo.size() > 0; |
| 1166 | } |
Yorke Lee | 3cefcc6 | 2014-01-16 11:26:46 -0800 | [diff] [blame] | 1167 | |
Yorke Lee | 86e21f7 | 2014-04-02 16:49:38 -0700 | [diff] [blame] | 1168 | /** |
| 1169 | * Called when the user has long-pressed a contact tile to start a drag operation. |
| 1170 | */ |
Yorke Lee | 3cefcc6 | 2014-01-16 11:26:46 -0800 | [diff] [blame] | 1171 | @Override |
Yorke Lee | efb2d9c | 2014-04-18 14:05:01 -0700 | [diff] [blame] | 1172 | public void onDragStarted(int x, int y, PhoneFavoriteSquareTileView view) { |
Andrew Lee | 1896344 | 2014-06-06 17:20:13 -0700 | [diff] [blame] | 1173 | mListsFragment.showRemoveView(true); |
Yorke Lee | 3cefcc6 | 2014-01-16 11:26:46 -0800 | [diff] [blame] | 1174 | } |
| 1175 | |
| 1176 | @Override |
Yorke Lee | 2826619 | 2014-05-01 10:05:52 -0700 | [diff] [blame] | 1177 | public void onDragHovered(int x, int y, PhoneFavoriteSquareTileView view) { |
| 1178 | } |
Yorke Lee | 3cefcc6 | 2014-01-16 11:26:46 -0800 | [diff] [blame] | 1179 | |
Yorke Lee | 86e21f7 | 2014-04-02 16:49:38 -0700 | [diff] [blame] | 1180 | /** |
| 1181 | * Called when the user has released a contact tile after long-pressing it. |
| 1182 | */ |
Yorke Lee | 3cefcc6 | 2014-01-16 11:26:46 -0800 | [diff] [blame] | 1183 | @Override |
| 1184 | public void onDragFinished(int x, int y) { |
Andrew Lee | 1896344 | 2014-06-06 17:20:13 -0700 | [diff] [blame] | 1185 | mListsFragment.showRemoveView(false); |
Yorke Lee | 3cefcc6 | 2014-01-16 11:26:46 -0800 | [diff] [blame] | 1186 | } |
| 1187 | |
| 1188 | @Override |
| 1189 | public void onDroppedOnRemove() {} |
| 1190 | |
| 1191 | /** |
Yorke Lee | d999b71 | 2014-04-23 15:10:58 -0700 | [diff] [blame] | 1192 | * Allows the SpeedDialFragment to attach the drag controller to mRemoveViewContainer |
Yorke Lee | 3cefcc6 | 2014-01-16 11:26:46 -0800 | [diff] [blame] | 1193 | * once it has been attached to the activity. |
| 1194 | */ |
| 1195 | @Override |
| 1196 | public void setDragDropController(DragDropController dragController) { |
Yorke Lee | 2826619 | 2014-05-01 10:05:52 -0700 | [diff] [blame] | 1197 | mDragDropController = dragController; |
Andrew Lee | 1896344 | 2014-06-06 17:20:13 -0700 | [diff] [blame] | 1198 | mListsFragment.getRemoveView().setDragDropController(dragController); |
Yorke Lee | 3cefcc6 | 2014-01-16 11:26:46 -0800 | [diff] [blame] | 1199 | } |
Yorke Lee | e00c9fe | 2014-04-12 12:42:06 -0700 | [diff] [blame] | 1200 | |
| 1201 | @Override |
| 1202 | public void onPickPhoneNumberAction(Uri dataUri) { |
Yorke Lee | 4e28c1d | 2014-05-13 15:38:10 -0700 | [diff] [blame] | 1203 | // Specify call-origin so that users will see the previous tab instead of |
| 1204 | // CallLog screen (search UI will be automatically exited). |
| 1205 | PhoneNumberInteraction.startInteractionForPhoneCall( |
Andrew Lee | 99a570c | 2014-05-15 14:18:50 -0700 | [diff] [blame] | 1206 | DialtactsActivity.this, dataUri, getCallOrigin()); |
Yorke Lee | 4e28c1d | 2014-05-13 15:38:10 -0700 | [diff] [blame] | 1207 | mClearSearchOnPause = true; |
Yorke Lee | e00c9fe | 2014-04-12 12:42:06 -0700 | [diff] [blame] | 1208 | } |
| 1209 | |
| 1210 | @Override |
| 1211 | public void onCallNumberDirectly(String phoneNumber) { |
Andrew Lee | fc1fed7 | 2014-07-02 11:05:53 -0700 | [diff] [blame] | 1212 | onCallNumberDirectly(phoneNumber, false /* isVideoCall */); |
| 1213 | } |
| 1214 | |
| 1215 | @Override |
| 1216 | public void onCallNumberDirectly(String phoneNumber, boolean isVideoCall) { |
Andrew Lee | d2a683f | 2014-07-08 15:54:50 -0700 | [diff] [blame] | 1217 | Intent intent = isVideoCall ? |
Andrew Lee | 247df6e | 2015-05-12 19:09:00 -0700 | [diff] [blame] | 1218 | IntentUtil.getVideoCallIntent(phoneNumber, getCallOrigin()) : |
| 1219 | IntentUtil.getCallIntent(phoneNumber, getCallOrigin()); |
Yorke Lee | 7d20f82 | 2014-06-19 17:09:33 -0700 | [diff] [blame] | 1220 | DialerUtils.startActivityWithErrorToast(this, intent); |
Yorke Lee | 4e28c1d | 2014-05-13 15:38:10 -0700 | [diff] [blame] | 1221 | mClearSearchOnPause = true; |
Yorke Lee | e00c9fe | 2014-04-12 12:42:06 -0700 | [diff] [blame] | 1222 | } |
| 1223 | |
| 1224 | @Override |
| 1225 | public void onShortcutIntentCreated(Intent intent) { |
Yorke Lee | 4e28c1d | 2014-05-13 15:38:10 -0700 | [diff] [blame] | 1226 | Log.w(TAG, "Unsupported intent has come (" + intent + "). Ignoring."); |
Yorke Lee | e00c9fe | 2014-04-12 12:42:06 -0700 | [diff] [blame] | 1227 | } |
| 1228 | |
| 1229 | @Override |
| 1230 | public void onHomeInActionBarSelected() { |
Yorke Lee | 4e28c1d | 2014-05-13 15:38:10 -0700 | [diff] [blame] | 1231 | exitSearchUi(); |
Yorke Lee | e00c9fe | 2014-04-12 12:42:06 -0700 | [diff] [blame] | 1232 | } |
Yorke Lee | 33932ff | 2014-04-16 13:34:32 -0700 | [diff] [blame] | 1233 | |
Yorke Lee | cc4660d | 2014-04-24 11:22:57 -0700 | [diff] [blame] | 1234 | @Override |
| 1235 | public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { |
Andrew Lee | 432d4b5 | 2015-05-20 16:52:00 -0700 | [diff] [blame] | 1236 | int tabIndex = mListsFragment.getCurrentTabIndex(); |
| 1237 | |
| 1238 | // Scroll the button from center to end when moving from the Speed Dial to Recents tab. |
| 1239 | // In RTL, scroll when the current tab is Recents instead of Speed Dial, because the order |
| 1240 | // of the tabs is reversed and the ViewPager returns the left tab position during scroll. |
| 1241 | boolean isRtl = DialerUtils.isRtl(); |
| 1242 | if (!isRtl && tabIndex == ListsFragment.TAB_INDEX_SPEED_DIAL && !mIsLandscape) { |
| 1243 | mFloatingActionButtonController.onPageScrolled(positionOffset); |
| 1244 | } else if (isRtl && tabIndex == ListsFragment.TAB_INDEX_RECENTS && !mIsLandscape) { |
| 1245 | mFloatingActionButtonController.onPageScrolled(1 - positionOffset); |
| 1246 | } else if (tabIndex != ListsFragment.TAB_INDEX_SPEED_DIAL) { |
Sai Cheemalapati | 00a3d5d | 2014-06-13 10:22:26 -0700 | [diff] [blame] | 1247 | mFloatingActionButtonController.onPageScrolled(1); |
Sai Cheemalapati | c4969ea | 2014-06-04 16:35:16 -0700 | [diff] [blame] | 1248 | } |
Andrew Lee | 432d4b5 | 2015-05-20 16:52:00 -0700 | [diff] [blame] | 1249 | } |
Andrew Lee | fdfeaaf | 2015-05-05 14:10:35 -0700 | [diff] [blame] | 1250 | |
Andrew Lee | 432d4b5 | 2015-05-20 16:52:00 -0700 | [diff] [blame] | 1251 | @Override |
| 1252 | public void onPageSelected(int position) { |
| 1253 | int tabIndex = mListsFragment.getCurrentTabIndex(); |
| 1254 | if (tabIndex == ListsFragment.TAB_INDEX_ALL_CONTACTS) { |
Andrew Lee | fdfeaaf | 2015-05-05 14:10:35 -0700 | [diff] [blame] | 1255 | mFloatingActionButtonController.changeIcon( |
| 1256 | getResources().getDrawable(R.drawable.ic_person_add_24dp), |
| 1257 | getResources().getString(R.string.search_shortcut_create_new_contact)); |
| 1258 | } else { |
| 1259 | mFloatingActionButtonController.changeIcon( |
| 1260 | getResources().getDrawable(R.drawable.fab_ic_dial), |
| 1261 | getResources().getString(R.string.action_menu_dialpad_button)); |
| 1262 | } |
Yorke Lee | cc4660d | 2014-04-24 11:22:57 -0700 | [diff] [blame] | 1263 | } |
| 1264 | |
| 1265 | @Override |
Yorke Lee | cc4660d | 2014-04-24 11:22:57 -0700 | [diff] [blame] | 1266 | public void onPageScrollStateChanged(int state) { |
| 1267 | } |
| 1268 | |
Tyler Gunn | 9dc924c | 2014-09-12 09:33:50 -0700 | [diff] [blame] | 1269 | private TelecomManager getTelecomManager() { |
| 1270 | return (TelecomManager) getSystemService(Context.TELECOM_SERVICE); |
Santos Cordon | d15629d | 2014-07-07 15:15:29 -0700 | [diff] [blame] | 1271 | } |
| 1272 | |
Yorke Lee | 5253be0 | 2014-05-21 18:50:03 -0700 | [diff] [blame] | 1273 | @Override |
| 1274 | public boolean isActionBarShowing() { |
| 1275 | return mActionBarController.isActionBarShowing(); |
| 1276 | } |
| 1277 | |
Yorke Lee | c98a5bb | 2014-10-28 16:12:05 -0700 | [diff] [blame] | 1278 | @Override |
| 1279 | public ActionBarController getActionBarController() { |
| 1280 | return mActionBarController; |
| 1281 | } |
| 1282 | |
Andrew Lee | 9da8fb4 | 2014-06-03 14:03:09 -0700 | [diff] [blame] | 1283 | public boolean isDialpadShown() { |
| 1284 | return mIsDialpadShown; |
| 1285 | } |
| 1286 | |
Yorke Lee | 5253be0 | 2014-05-21 18:50:03 -0700 | [diff] [blame] | 1287 | @Override |
| 1288 | public int getActionBarHideOffset() { |
| 1289 | return getActionBar().getHideOffset(); |
| 1290 | } |
| 1291 | |
| 1292 | @Override |
Yorke Lee | c98a5bb | 2014-10-28 16:12:05 -0700 | [diff] [blame] | 1293 | public void setActionBarHideOffset(int offset) { |
| 1294 | getActionBar().setHideOffset(offset); |
Yorke Lee | 5253be0 | 2014-05-21 18:50:03 -0700 | [diff] [blame] | 1295 | } |
| 1296 | |
| 1297 | @Override |
Yorke Lee | c98a5bb | 2014-10-28 16:12:05 -0700 | [diff] [blame] | 1298 | public int getActionBarHeight() { |
| 1299 | return mActionBarHeight; |
Yorke Lee | 5253be0 | 2014-05-21 18:50:03 -0700 | [diff] [blame] | 1300 | } |
Sai Cheemalapati | c4969ea | 2014-06-04 16:35:16 -0700 | [diff] [blame] | 1301 | |
Andrew Lee | 6324f70 | 2015-06-16 14:45:58 -0700 | [diff] [blame] | 1302 | |
| 1303 | private int getFabAlignment() { |
| 1304 | if (!mIsLandscape && !isInSearchUi() && |
| 1305 | mListsFragment.getCurrentTabIndex() == ListsFragment.TAB_INDEX_SPEED_DIAL) { |
| 1306 | return FloatingActionButtonController.ALIGN_MIDDLE; |
| 1307 | } |
| 1308 | return FloatingActionButtonController.ALIGN_END; |
Sai Cheemalapati | c4969ea | 2014-06-04 16:35:16 -0700 | [diff] [blame] | 1309 | } |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 1310 | } |