blob: 26c1698439fbf699b6098c78595999daa632d004 [file] [log] [blame]
Chiao Cheng94b10b52012-08-17 16:59:12 -07001/*
Yorke Leec3766332013-07-31 11:13:16 -07002 * Copyright (C) 2013 The Android Open Source Project
Chiao Cheng94b10b52012-08-17 16:59:12 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.dialer;
18
Yorke Leecc4660d2014-04-24 11:22:57 -070019import android.animation.LayoutTransition;
Yorke Lee53a22302014-04-29 18:13:46 -070020import android.app.ActionBar;
Chiao Cheng94b10b52012-08-17 16:59:12 -070021import android.app.Activity;
22import android.app.Fragment;
Chiao Cheng94b10b52012-08-17 16:59:12 -070023import android.app.FragmentTransaction;
Chiao Cheng073b5cf2012-12-07 11:36:00 -080024import android.content.ActivityNotFoundException;
Chiao Cheng94b10b52012-08-17 16:59:12 -070025import android.content.Context;
26import android.content.Intent;
Yorke Leeda0f9042013-12-05 14:25:51 -080027import android.content.pm.PackageManager;
28import android.content.pm.ResolveInfo;
Andrew Lee2423a2f2014-05-29 14:14:45 -070029import android.content.res.Resources;
Yorke Lee33932ff2014-04-16 13:34:32 -070030import android.content.res.TypedArray;
Chiao Cheng94b10b52012-08-17 16:59:12 -070031import android.net.Uri;
32import android.os.Bundle;
33import android.os.RemoteException;
34import android.os.ServiceManager;
Chiao Cheng94b10b52012-08-17 16:59:12 -070035import android.provider.ContactsContract.Contacts;
Yorke Leee1424812013-09-04 18:24:48 -070036import android.provider.ContactsContract.Intents;
Yorke Leec3766332013-07-31 11:13:16 -070037import android.speech.RecognizerIntent;
Yorke Leecc4660d2014-04-24 11:22:57 -070038import android.support.v4.view.ViewPager;
Yorke Leec3766332013-07-31 11:13:16 -070039import android.telephony.TelephonyManager;
Yorke Lee53a22302014-04-29 18:13:46 -070040import android.text.Editable;
Chiao Cheng94b10b52012-08-17 16:59:12 -070041import android.text.TextUtils;
Yorke Lee53a22302014-04-29 18:13:46 -070042import android.text.TextWatcher;
Chiao Cheng94b10b52012-08-17 16:59:12 -070043import android.util.Log;
Yorke Lee28266192014-05-01 10:05:52 -070044import android.view.DragEvent;
Andrew Leeb1903842014-05-15 16:11:24 -070045import android.view.KeyEvent;
Chiao Cheng94b10b52012-08-17 16:59:12 -070046import android.view.Menu;
Chiao Cheng94b10b52012-08-17 16:59:12 -070047import android.view.MenuItem;
Andrew Leeb1903842014-05-15 16:11:24 -070048import android.view.MotionEvent;
Chiao Cheng94b10b52012-08-17 16:59:12 -070049import android.view.View;
Yorke Lee28266192014-05-01 10:05:52 -070050import android.view.View.OnDragListener;
Yorke Leec7b2a0e2014-05-20 17:21:25 -070051import android.view.View.OnTouchListener;
Yorke Lee86e21f72014-04-02 16:49:38 -070052import android.view.animation.AccelerateInterpolator;
Andrew Lee2a58ab82014-05-15 02:16:04 -070053import android.view.animation.Animation;
54import android.view.animation.Animation.AnimationListener;
55import android.view.animation.AnimationUtils;
Yorke Lee86e21f72014-04-02 16:49:38 -070056import android.view.animation.DecelerateInterpolator;
57import android.view.animation.Interpolator;
Chiao Cheng94b10b52012-08-17 16:59:12 -070058import android.view.inputmethod.InputMethodManager;
Yorke Leec3766332013-07-31 11:13:16 -070059import android.widget.AbsListView.OnScrollListener;
Yorke Lee53a22302014-04-29 18:13:46 -070060import android.widget.EditText;
Andrew Leea73e1892014-05-13 13:21:16 -070061import android.widget.ImageButton;
Chiao Cheng94b10b52012-08-17 16:59:12 -070062import android.widget.PopupMenu;
Yorke Leecc4660d2014-04-24 11:22:57 -070063import android.widget.RelativeLayout;
Chiao Cheng073b5cf2012-12-07 11:36:00 -080064import android.widget.Toast;
Chiao Cheng94b10b52012-08-17 16:59:12 -070065
Chiao Cheng9d4f3b22012-09-05 16:00:16 -070066import com.android.contacts.common.CallUtil;
Chiao Cheng603ff682012-10-24 15:18:40 -070067import com.android.contacts.common.activity.TransactionSafeActivity;
Andrew Lee3c14bc32014-05-28 15:43:03 -070068import com.android.contacts.common.animation.AnimationListenerAdapter;
Yorke Leec3766332013-07-31 11:13:16 -070069import com.android.contacts.common.dialog.ClearFrequentsDialog;
70import com.android.contacts.common.interactions.ImportExportDialogFragment;
Chiao Cheng8efbcf92012-12-04 17:43:02 -080071import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
Andrew Lee4cbc9732014-04-24 14:38:58 -070072import com.android.contacts.common.util.ViewUtil;
Yorke Leec3766332013-07-31 11:13:16 -070073import com.android.dialer.calllog.CallLogActivity;
Yorke Leefce269a2013-08-12 11:56:04 -070074import com.android.dialer.database.DialerDatabaseHelper;
Yorke Leef74011e2013-08-02 11:30:30 -070075import com.android.dialer.dialpad.DialpadFragment;
Yorke Leec3766332013-07-31 11:13:16 -070076import com.android.dialer.dialpad.SmartDialNameMatcher;
Yorke Leefce269a2013-08-12 11:56:04 -070077import com.android.dialer.dialpad.SmartDialPrefix;
Chiao Cheng1429f1a2012-11-01 16:35:28 -070078import com.android.dialer.interactions.PhoneNumberInteraction;
Yorke Lee3cefcc62014-01-16 11:26:46 -080079import com.android.dialer.list.DragDropController;
Yorke Leee00c9fe2014-04-12 12:42:06 -070080import com.android.dialer.list.ListsFragment;
Yorke Lee3cefcc62014-01-16 11:26:46 -080081import com.android.dialer.list.OnDragDropListener;
Yorke Leec3766332013-07-31 11:13:16 -070082import com.android.dialer.list.OnListFragmentScrolledListener;
Yorke Leed999b712014-04-23 15:10:58 -070083import com.android.dialer.list.SpeedDialFragment;
Yorke Leeefb2d9c2014-04-18 14:05:01 -070084import com.android.dialer.list.PhoneFavoriteSquareTileView;
Jay Shrauner2e5b34b2013-08-29 10:52:40 -070085import com.android.dialer.list.RegularSearchFragment;
Yorke Lee3cefcc62014-01-16 11:26:46 -080086import com.android.dialer.list.RemoveView;
Jay Shrauner2e5b34b2013-08-29 10:52:40 -070087import com.android.dialer.list.SearchFragment;
Yorke Leec3766332013-07-31 11:13:16 -070088import com.android.dialer.list.SmartDialSearchFragment;
Yorke Lee5253be02014-05-21 18:50:03 -070089import com.android.dialer.widget.ActionBarController;
Andrew Leeb1903842014-05-15 16:11:24 -070090import com.android.dialer.widget.SearchEditTextLayout;
Yorke Lee11ca39e2014-05-19 20:31:37 -070091import com.android.dialer.widget.SearchEditTextLayout.OnBackButtonClickedListener;
Yorke Lee0baa98b2013-08-22 10:55:16 -070092import com.android.dialerbind.DatabaseHelperManager;
Chiao Cheng94b10b52012-08-17 16:59:12 -070093
Yorke Leec3766332013-07-31 11:13:16 -070094import java.util.ArrayList;
Yorke Leeda0f9042013-12-05 14:25:51 -080095import java.util.List;
Yorke Leec3766332013-07-31 11:13:16 -070096
Chiao Cheng94b10b52012-08-17 16:59:12 -070097/**
Chiao Cheng94b10b52012-08-17 16:59:12 -070098 * The dialer tab's title is 'phone', a more common name (see strings.xml).
99 */
Yorke Leec3766332013-07-31 11:13:16 -0700100public class DialtactsActivity extends TransactionSafeActivity implements View.OnClickListener,
Yorke Lee86e21f72014-04-02 16:49:38 -0700101 DialpadFragment.OnDialpadQueryChangedListener,
Yorke Leec3766332013-07-31 11:13:16 -0700102 OnListFragmentScrolledListener,
Ihab Awad526c0b82014-02-27 12:55:36 -0800103 DialpadFragment.HostInterface,
Yorke Lee6a1461a2014-04-21 16:27:14 -0700104 ListsFragment.HostInterface,
Yorke Leed999b712014-04-23 15:10:58 -0700105 SpeedDialFragment.HostInterface,
Yorke Lee5253be02014-05-21 18:50:03 -0700106 SearchFragment.HostInterface,
Andrew Lee752956e2014-05-15 11:43:38 -0700107 OnDragDropListener,
Yorke Leecc4660d2014-04-24 11:22:57 -0700108 OnPhoneNumberPickerActionListener,
Andrew Leee74a10e2014-05-16 14:31:40 -0700109 PopupMenu.OnMenuItemClickListener,
Yorke Lee5253be02014-05-21 18:50:03 -0700110 ViewPager.OnPageChangeListener,
111 ActionBarController.ActivityUi {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700112 private static final String TAG = "DialtactsActivity";
113
Ihab Awad526c0b82014-02-27 12:55:36 -0800114 public static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700115
Yorke Leef74011e2013-08-02 11:30:30 -0700116 public static final String SHARED_PREFS_NAME = "com.android.dialer_preferences";
117
Chiao Cheng94b10b52012-08-17 16:59:12 -0700118 /** Used to open Call Setting */
119 private static final String PHONE_PACKAGE = "com.android.phone";
120 private static final String CALL_SETTINGS_CLASS_NAME =
121 "com.android.phone.CallFeaturesSetting";
Chiao Cheng94b10b52012-08-17 16:59:12 -0700122 /** @see #getCallOrigin() */
123 private static final String CALL_ORIGIN_DIALTACTS =
124 "com.android.dialer.DialtactsActivity";
125
Yorke Leeb207f8a2013-08-29 18:51:06 -0700126 private static final String KEY_IN_REGULAR_SEARCH_UI = "in_regular_search_ui";
127 private static final String KEY_IN_DIALPAD_SEARCH_UI = "in_dialpad_search_ui";
Yorke Leeef2b7382013-08-09 17:39:25 -0700128 private static final String KEY_SEARCH_QUERY = "search_query";
129 private static final String KEY_FIRST_LAUNCH = "first_launch";
Yorke Lee50aba882014-05-28 20:04:31 -0700130 private static final String KEY_IS_DIALPAD_SHOWN = "is_dialpad_shown";
Yorke Leeef2b7382013-08-09 17:39:25 -0700131
Yorke Leec3766332013-07-31 11:13:16 -0700132 private static final String TAG_DIALPAD_FRAGMENT = "dialpad";
133 private static final String TAG_REGULAR_SEARCH_FRAGMENT = "search";
134 private static final String TAG_SMARTDIAL_SEARCH_FRAGMENT = "smartdial";
135 private static final String TAG_FAVORITES_FRAGMENT = "favorites";
Yorke Leec3766332013-07-31 11:13:16 -0700136
Chiao Cheng94b10b52012-08-17 16:59:12 -0700137 /**
138 * Just for backward compatibility. Should behave as same as {@link Intent#ACTION_DIAL}.
139 */
140 private static final String ACTION_TOUCH_DIALER = "com.android.phone.action.TOUCH_DIALER";
141
Yorke Leec3766332013-07-31 11:13:16 -0700142 private static final int ACTIVITY_REQUEST_CODE_VOICE_SEARCH = 1;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700143
Andrew Lee0c667702014-05-12 14:31:45 -0700144 private RelativeLayout parentLayout;
145
Yorke Leec3766332013-07-31 11:13:16 -0700146 /**
Yorke Leec3766332013-07-31 11:13:16 -0700147 * Fragment containing the dialpad that slides into view
Chiao Cheng94b10b52012-08-17 16:59:12 -0700148 */
Yorke Leef74011e2013-08-02 11:30:30 -0700149 private DialpadFragment mDialpadFragment;
Yorke Leec3766332013-07-31 11:13:16 -0700150
151 /**
152 * Fragment for searching phone numbers using the alphanumeric keyboard.
153 */
Jay Shrauner2e5b34b2013-08-29 10:52:40 -0700154 private RegularSearchFragment mRegularSearchFragment;
Yorke Leec3766332013-07-31 11:13:16 -0700155
156 /**
157 * Fragment for searching phone numbers using the dialpad.
158 */
159 private SmartDialSearchFragment mSmartDialSearchFragment;
160
Yorke Leee00c9fe2014-04-12 12:42:06 -0700161 /**
162 * Fragment containing the speed dial list, recents list, and all contacts list.
163 */
164 private ListsFragment mListsFragment;
165
Andrew Leea73e1892014-05-13 13:21:16 -0700166 private View mFloatingActionButtonContainer;
167 private ImageButton mFloatingActionButton;
Yorke Leec3766332013-07-31 11:13:16 -0700168
Yorke Leeb207f8a2013-08-29 18:51:06 -0700169 private boolean mInDialpadSearch;
170 private boolean mInRegularSearch;
Yorke Lee8e5c8b12013-10-01 14:37:55 -0700171 private boolean mClearSearchOnPause;
Andrew Lee2a58ab82014-05-15 02:16:04 -0700172 private boolean mIsDialpadShown;
Yorke Lee50aba882014-05-28 20:04:31 -0700173 private boolean mShowDialpadOnResume;
Yorke Leeb207f8a2013-08-29 18:51:06 -0700174
Yorke Leeef2b7382013-08-09 17:39:25 -0700175 /**
Yorke Leecc4660d2014-04-24 11:22:57 -0700176 * The position of the currently selected tab in the attached {@link ListsFragment}.
177 */
178 private int mCurrentTabPosition = 0;
179
180 /**
Yorke Lee35127cd2013-09-10 14:09:29 -0700181 * True if the dialpad is only temporarily showing due to being in call
182 */
183 private boolean mInCallDialpadUp;
184
185 /**
Yorke Leeef2b7382013-08-09 17:39:25 -0700186 * True when this activity has been launched for the first time.
187 */
Yorke Lee98702de2013-08-06 12:03:32 -0700188 private boolean mFirstLaunch;
Yorke Lee86e21f72014-04-02 16:49:38 -0700189
Yorke Lee3c9e7cd2014-04-16 11:37:21 -0700190 /**
191 * Search query to be applied to the SearchView in the ActionBar once
192 * onCreateOptionsMenu has been called.
193 */
194 private String mPendingSearchViewQuery;
195
Yorke Lee53a22302014-04-29 18:13:46 -0700196 private EditText mSearchView;
Yorke Lee53a22302014-04-29 18:13:46 -0700197 private View mVoiceSearchButton;
Yorke Leeec489fb2014-05-19 15:39:27 -0700198 private SearchEditTextLayout mSearchEditTextLayout;
Andrew Leee74a10e2014-05-16 14:31:40 -0700199
Yorke Lee86e21f72014-04-02 16:49:38 -0700200 /**
201 * View that contains the "Remove" dialog that shows up when the user long presses a contact.
202 * If the user releases a contact when hovering on top of this, the contact is unfavorited and
203 * removed from the speed dial list.
204 */
Yorke Lee28266192014-05-01 10:05:52 -0700205 private View mRemoveViewContainer;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700206
Yorke Leeef2b7382013-08-09 17:39:25 -0700207 private String mSearchQuery;
208
Yorke Leefce269a2013-08-12 11:56:04 -0700209 private DialerDatabaseHelper mDialerDatabaseHelper;
Yorke Lee28266192014-05-01 10:05:52 -0700210 private DragDropController mDragDropController;
Yorke Lee5253be02014-05-21 18:50:03 -0700211 private ActionBarController mActionBarController;
Yorke Leefce269a2013-08-12 11:56:04 -0700212
Andrew Lee2423a2f2014-05-29 14:14:45 -0700213 private int mActionBarHeight;
214 private int mFloatingActionButtonMarginBottom;
215 private int mFloatingActionButtonDialpadMarginBottom;
216
Andrew Leee74a10e2014-05-16 14:31:40 -0700217 private class OptionsPopupMenu extends PopupMenu {
218 public OptionsPopupMenu(Context context, View anchor) {
Yorke Leee00c9fe2014-04-12 12:42:06 -0700219 super(context, anchor);
220 }
221
222 @Override
223 public void show() {
224 final Menu menu = getMenu();
225 final MenuItem clearFrequents = menu.findItem(R.id.menu_clear_frequents);
Andrew Leee74a10e2014-05-16 14:31:40 -0700226 clearFrequents.setVisible(mListsFragment != null &&
227 mListsFragment.getSpeedDialFragment() != null &&
228 mListsFragment.getSpeedDialFragment().hasFrequents());
Yorke Leee00c9fe2014-04-12 12:42:06 -0700229 super.show();
230 }
231 }
232
Chiao Cheng94b10b52012-08-17 16:59:12 -0700233 /**
Yorke Lee28266192014-05-01 10:05:52 -0700234 * Listener that listens to drag events and sends their x and y coordinates to a
235 * {@link DragDropController}.
236 */
237 private class LayoutOnDragListener implements OnDragListener {
238 @Override
239 public boolean onDrag(View v, DragEvent event) {
240 if (event.getAction() == DragEvent.ACTION_DRAG_LOCATION) {
241 mDragDropController.handleDragHovered(v, (int) event.getX(),
242 (int) event.getY());
243 }
244 return true;
245 }
246 }
247
248 /**
Chiao Cheng94b10b52012-08-17 16:59:12 -0700249 * Listener used to send search queries to the phone search fragment.
250 */
Yorke Lee53a22302014-04-29 18:13:46 -0700251 private final TextWatcher mPhoneSearchQueryTextListener = new TextWatcher() {
Andrew Lee99a570c2014-05-15 14:18:50 -0700252 @Override
253 public void beforeTextChanged(CharSequence s, int start, int count, int after) {
254 }
Yorke Leec3766332013-07-31 11:13:16 -0700255
Andrew Lee99a570c2014-05-15 14:18:50 -0700256 @Override
257 public void onTextChanged(CharSequence s, int start, int before, int count) {
258 final String newText = s.toString();
259 if (newText.equals(mSearchQuery)) {
260 // If the query hasn't changed (perhaps due to activity being destroyed
261 // and restored, or user launching the same DIAL intent twice), then there is
262 // no need to do anything here.
Yorke Lee53a22302014-04-29 18:13:46 -0700263 return;
264 }
Andrew Lee99a570c2014-05-15 14:18:50 -0700265 if (DEBUG) {
266 Log.d(TAG, "onTextChange for mSearchView called with new query: " + newText);
Yorke Lee710709d2014-05-29 07:18:42 -0700267 Log.d(TAG, "Previous Query: " + mSearchQuery);
Yorke Leec3766332013-07-31 11:13:16 -0700268 }
Yorke Lee710709d2014-05-29 07:18:42 -0700269 mSearchQuery = newText;
Andrew Lee99a570c2014-05-15 14:18:50 -0700270
Andrew Lee90374a72014-05-16 15:01:09 -0700271 // Show search fragment only when the query string is changed to non-empty text.
272 if (!TextUtils.isEmpty(newText)) {
273 // Call enterSearchUi only if we are switching search modes, or showing a search
274 // fragment for the first time.
275 final boolean sameSearchMode = (mIsDialpadShown && mInDialpadSearch) ||
276 (!mIsDialpadShown && mInRegularSearch);
277 if (!sameSearchMode) {
278 enterSearchUi(mIsDialpadShown, mSearchQuery);
279 }
Andrew Lee99a570c2014-05-15 14:18:50 -0700280 }
281
282 if (mIsDialpadShown && mSmartDialSearchFragment != null) {
Andrew Leeb1903842014-05-15 16:11:24 -0700283 mSmartDialSearchFragment.setQueryString(mSearchQuery, false /* delaySelection */);
Andrew Lee99a570c2014-05-15 14:18:50 -0700284 } else if (mRegularSearchFragment != null) {
Andrew Leeb1903842014-05-15 16:11:24 -0700285 mRegularSearchFragment.setQueryString(mSearchQuery, false /* delaySelection */);
Andrew Lee99a570c2014-05-15 14:18:50 -0700286 }
Andrew Lee99a570c2014-05-15 14:18:50 -0700287 }
288
289 @Override
290 public void afterTextChanged(Editable s) {
291 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700292 };
293
Andrew Leeb1903842014-05-15 16:11:24 -0700294
295 /**
Yorke Lee11ca39e2014-05-19 20:31:37 -0700296 * Open the search UI when the user clicks on the search box.
Andrew Leeb1903842014-05-15 16:11:24 -0700297 */
Yorke Lee11ca39e2014-05-19 20:31:37 -0700298 private final View.OnClickListener mSearchViewOnClickListener = new View.OnClickListener() {
Andrew Leeb1903842014-05-15 16:11:24 -0700299 @Override
Yorke Lee11ca39e2014-05-19 20:31:37 -0700300 public void onClick(View v) {
Andrew Leeb1903842014-05-15 16:11:24 -0700301 if (!isInSearchUi()) {
Yorke Lee5253be02014-05-21 18:50:03 -0700302 mActionBarController.onSearchBoxTapped();
Andrew Leeb1903842014-05-15 16:11:24 -0700303 enterSearchUi(false /* smartDialSearch */, mSearchView.getText().toString());
304 }
Andrew Leeb1903842014-05-15 16:11:24 -0700305 }
306 };
307
308 /**
309 * If the search term is empty and the user closes the soft keyboard, close the search UI.
310 */
311 private final View.OnKeyListener mSearchEditTextLayoutListener = new View.OnKeyListener() {
312 @Override
313 public boolean onKey(View v, int keyCode, KeyEvent event) {
314 if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN &&
315 TextUtils.isEmpty(mSearchView.getText().toString())) {
Yorke Leec7b2a0e2014-05-20 17:21:25 -0700316 maybeExitSearchUi();
Andrew Leeb1903842014-05-15 16:11:24 -0700317 }
318 return false;
319 }
320 };
321
Chiao Cheng94b10b52012-08-17 16:59:12 -0700322 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700323 protected void onCreate(Bundle savedInstanceState) {
324 super.onCreate(savedInstanceState);
Yorke Lee98702de2013-08-06 12:03:32 -0700325 mFirstLaunch = true;
326
Andrew Lee2423a2f2014-05-29 14:14:45 -0700327 final Resources resources = getResources();
328 mActionBarHeight = resources.getDimensionPixelSize(R.dimen.action_bar_height);
329 mFloatingActionButtonMarginBottom =
330 resources.getDimensionPixelOffset(R.dimen.floating_action_button_margin_bottom);
331 mFloatingActionButtonDialpadMarginBottom = resources.getDimensionPixelOffset(
332 R.dimen.floating_action_button_dialpad_margin_bottom);
333
Yorke Lee8898cd02013-08-08 10:24:27 -0700334 setContentView(R.layout.dialtacts_activity);
Yorke Lee9e91bb02014-03-05 17:50:50 -0800335 getWindow().setBackgroundDrawable(null);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700336
Yorke Lee53a22302014-04-29 18:13:46 -0700337 final ActionBar actionBar = getActionBar();
338 actionBar.setCustomView(R.layout.search_edittext);
339 actionBar.setDisplayShowCustomEnabled(true);
Yorke Leebcef9402014-05-21 15:33:00 -0700340 actionBar.setBackgroundDrawable(null);
Yorke Lee53a22302014-04-29 18:13:46 -0700341
Yorke Lee5253be02014-05-21 18:50:03 -0700342 mActionBarController = new ActionBarController(this,
343 (SearchEditTextLayout) actionBar.getCustomView());
344
Yorke Leeec489fb2014-05-19 15:39:27 -0700345 mSearchEditTextLayout = (SearchEditTextLayout) actionBar.getCustomView();
346 mSearchEditTextLayout.setPreImeKeyListener(mSearchEditTextLayoutListener);
Yorke Lee53a22302014-04-29 18:13:46 -0700347
Yorke Leeec489fb2014-05-19 15:39:27 -0700348 mSearchView = (EditText) mSearchEditTextLayout.findViewById(R.id.search_view);
Yorke Lee53a22302014-04-29 18:13:46 -0700349 mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener);
Yorke Lee11ca39e2014-05-19 20:31:37 -0700350 mVoiceSearchButton = mSearchEditTextLayout.findViewById(R.id.voice_search_button);
351 mSearchEditTextLayout.findViewById(R.id.search_box_start_search).setOnClickListener(
352 mSearchViewOnClickListener);
353 mSearchEditTextLayout.setOnBackButtonClickedListener(new OnBackButtonClickedListener() {
354 @Override
355 public void onBackButtonClicked() {
356 onBackPressed();
357 }
358 });
Chiao Cheng94b10b52012-08-17 16:59:12 -0700359
Yorke Leeec489fb2014-05-19 15:39:27 -0700360 ImageButton optionsMenuButton = (ImageButton) mSearchEditTextLayout.findViewById(
361 R.id.dialtacts_options_menu_button);
Andrew Leee74a10e2014-05-16 14:31:40 -0700362 optionsMenuButton.setOnClickListener(this);
363 final OptionsPopupMenu optionsMenu = buildOptionsMenu(optionsMenuButton);
364 optionsMenuButton.setOnTouchListener(optionsMenu.getDragToOpenListener());
365
Yorke Leeef2b7382013-08-09 17:39:25 -0700366 // Add the favorites fragment, and the dialpad fragment, but only if savedInstanceState
367 // is null. Otherwise the fragment manager takes care of recreating these fragments.
Yorke Leec3766332013-07-31 11:13:16 -0700368 if (savedInstanceState == null) {
Ihab Awad526c0b82014-02-27 12:55:36 -0800369 getFragmentManager().beginTransaction()
Yorke Leee00c9fe2014-04-12 12:42:06 -0700370 .add(R.id.dialtacts_frame, new ListsFragment(), TAG_FAVORITES_FRAGMENT)
Ihab Awad526c0b82014-02-27 12:55:36 -0800371 .add(R.id.dialtacts_container, new DialpadFragment(), TAG_DIALPAD_FRAGMENT)
372 .commit();
Yorke Leeef2b7382013-08-09 17:39:25 -0700373 } else {
374 mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY);
Yorke Leeb207f8a2013-08-29 18:51:06 -0700375 mInRegularSearch = savedInstanceState.getBoolean(KEY_IN_REGULAR_SEARCH_UI);
376 mInDialpadSearch = savedInstanceState.getBoolean(KEY_IN_DIALPAD_SEARCH_UI);
Yorke Leeef2b7382013-08-09 17:39:25 -0700377 mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH);
Yorke Lee50aba882014-05-28 20:04:31 -0700378 mShowDialpadOnResume = savedInstanceState.getBoolean(KEY_IS_DIALPAD_SHOWN);
Yorke Lee5253be02014-05-21 18:50:03 -0700379 mActionBarController.restoreInstanceState(savedInstanceState);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700380 }
381
Andrew Lee0c667702014-05-12 14:31:45 -0700382 parentLayout = (RelativeLayout) findViewById(R.id.dialtacts_mainlayout);
383 parentLayout.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
384 parentLayout.setOnDragListener(new LayoutOnDragListener());
385
Yorke Leec7b2a0e2014-05-20 17:21:25 -0700386 setupActivityOverlay();
387
Andrew Leea73e1892014-05-13 13:21:16 -0700388 mFloatingActionButtonContainer = findViewById(R.id.floating_action_button_container);
389 ViewUtil.setupFloatingActionButton(mFloatingActionButtonContainer, getResources());
Yorke Lee86e21f72014-04-02 16:49:38 -0700390
Andrew Leea73e1892014-05-13 13:21:16 -0700391 mFloatingActionButton = (ImageButton) findViewById(R.id.floating_action_button);
392 mFloatingActionButton.setOnClickListener(this);
Ihab Awad526c0b82014-02-27 12:55:36 -0800393
Yorke Lee28266192014-05-01 10:05:52 -0700394 mRemoveViewContainer = findViewById(R.id.remove_view_container);
Yorke Leeb0d19762014-03-05 14:43:28 -0800395
Yorke Lee0baa98b2013-08-22 10:55:16 -0700396 mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(this);
Yorke Leefce269a2013-08-12 11:56:04 -0700397 SmartDialPrefix.initializeNanpSettings(this);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700398 }
399
Yorke Leec7b2a0e2014-05-20 17:21:25 -0700400 private void setupActivityOverlay() {
401 final View activityOverlay = findViewById(R.id.activity_overlay);
402 activityOverlay.setOnTouchListener(new OnTouchListener() {
403 @Override
404 public boolean onTouch(View v, MotionEvent event) {
405 if (!mIsDialpadShown) {
406 maybeExitSearchUi();
407 }
408 return false;
409 }
410 });
411 }
412
Chiao Cheng94b10b52012-08-17 16:59:12 -0700413 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700414 protected void onResume() {
415 super.onResume();
Yorke Lee98702de2013-08-06 12:03:32 -0700416 if (mFirstLaunch) {
417 displayFragment(getIntent());
Yorke Lee35127cd2013-09-10 14:09:29 -0700418 } else if (!phoneIsInUse() && mInCallDialpadUp) {
419 hideDialpadFragment(false, true);
420 mInCallDialpadUp = false;
Yorke Lee50aba882014-05-28 20:04:31 -0700421 } else if (mShowDialpadOnResume) {
422 showDialpadFragment(false);
423 mShowDialpadOnResume = false;
Yorke Lee98702de2013-08-06 12:03:32 -0700424 }
425 mFirstLaunch = false;
Yorke Lee53a22302014-04-29 18:13:46 -0700426 prepareVoiceSearchButton();
Yorke Leefce269a2013-08-12 11:56:04 -0700427 mDialerDatabaseHelper.startSmartDialUpdateThread();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700428 }
429
430 @Override
Yorke Lee8e5c8b12013-10-01 14:37:55 -0700431 protected void onPause() {
432 if (mClearSearchOnPause) {
433 hideDialpadAndSearchUi();
434 mClearSearchOnPause = false;
435 }
436 super.onPause();
437 }
438
439 @Override
Yorke Leeef2b7382013-08-09 17:39:25 -0700440 protected void onSaveInstanceState(Bundle outState) {
441 super.onSaveInstanceState(outState);
442 outState.putString(KEY_SEARCH_QUERY, mSearchQuery);
Yorke Leeb207f8a2013-08-29 18:51:06 -0700443 outState.putBoolean(KEY_IN_REGULAR_SEARCH_UI, mInRegularSearch);
444 outState.putBoolean(KEY_IN_DIALPAD_SEARCH_UI, mInDialpadSearch);
Yorke Leeef2b7382013-08-09 17:39:25 -0700445 outState.putBoolean(KEY_FIRST_LAUNCH, mFirstLaunch);
Yorke Lee50aba882014-05-28 20:04:31 -0700446 outState.putBoolean(KEY_IS_DIALPAD_SHOWN, mIsDialpadShown);
Yorke Lee5253be02014-05-21 18:50:03 -0700447 mActionBarController.saveInstanceState(outState);
Yorke Leeef2b7382013-08-09 17:39:25 -0700448 }
449
450 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700451 public void onAttachFragment(Fragment fragment) {
Yorke Leeef2b7382013-08-09 17:39:25 -0700452 if (fragment instanceof DialpadFragment) {
453 mDialpadFragment = (DialpadFragment) fragment;
Yorke Lee50aba882014-05-28 20:04:31 -0700454 if (!mShowDialpadOnResume) {
455 final FragmentTransaction transaction = getFragmentManager().beginTransaction();
456 transaction.hide(mDialpadFragment);
457 transaction.commit();
458 }
Yorke Leeef2b7382013-08-09 17:39:25 -0700459 } else if (fragment instanceof SmartDialSearchFragment) {
460 mSmartDialSearchFragment = (SmartDialSearchFragment) fragment;
Yorke Lee4e28c1d2014-05-13 15:38:10 -0700461 mSmartDialSearchFragment.setOnPhoneNumberPickerActionListener(this);
Yorke Leeef2b7382013-08-09 17:39:25 -0700462 } else if (fragment instanceof SearchFragment) {
Jay Shrauner2e5b34b2013-08-29 10:52:40 -0700463 mRegularSearchFragment = (RegularSearchFragment) fragment;
Yorke Lee4e28c1d2014-05-13 15:38:10 -0700464 mRegularSearchFragment.setOnPhoneNumberPickerActionListener(this);
Yorke Leee00c9fe2014-04-12 12:42:06 -0700465 } else if (fragment instanceof ListsFragment) {
466 mListsFragment = (ListsFragment) fragment;
Yorke Leecc4660d2014-04-24 11:22:57 -0700467 mListsFragment.addOnPageChangeListener(this);
Yorke Leec3766332013-07-31 11:13:16 -0700468 }
Yorke Leec3766332013-07-31 11:13:16 -0700469 }
470
Alon Albertb453e5b2013-09-10 15:54:23 -0700471 protected void handleMenuSettings() {
472 openTelephonySetting(this);
473 }
474
475 public static void openTelephonySetting(Activity activity) {
476 final Intent settingsIntent = getCallSettingsIntent();
477 activity.startActivity(settingsIntent);
478 }
479
Chiao Cheng94b10b52012-08-17 16:59:12 -0700480 @Override
481 public void onClick(View view) {
482 switch (view.getId()) {
Andrew Leea73e1892014-05-13 13:21:16 -0700483 case R.id.floating_action_button:
Andrew Lee2a58ab82014-05-15 02:16:04 -0700484 if (!mIsDialpadShown) {
Andrew Leea73e1892014-05-13 13:21:16 -0700485 mInCallDialpadUp = false;
486 showDialpadFragment(true);
487 } else {
488 // Dial button was pressed; tell the Dialpad fragment
489 mDialpadFragment.dialButtonPressed();
490 }
Yorke Lee86e21f72014-04-02 16:49:38 -0700491 break;
Yorke Leec3766332013-07-31 11:13:16 -0700492 case R.id.search_close_button:
493 // Clear the search field
Yorke Lee53a22302014-04-29 18:13:46 -0700494 if (!TextUtils.isEmpty(mSearchView.getText())) {
Yorke Lee2eafb7a2013-09-10 14:34:01 -0700495 mDialpadFragment.clearDialpad();
Yorke Lee53a22302014-04-29 18:13:46 -0700496 mSearchView.setText(null);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700497 }
498 break;
Yorke Leec3766332013-07-31 11:13:16 -0700499 case R.id.voice_search_button:
Yorke Leeda0f9042013-12-05 14:25:51 -0800500 try {
501 startActivityForResult(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH),
502 ACTIVITY_REQUEST_CODE_VOICE_SEARCH);
503 } catch (ActivityNotFoundException e) {
504 Toast.makeText(DialtactsActivity.this, R.string.voice_search_not_available,
505 Toast.LENGTH_SHORT).show();
506 }
Yorke Leec3766332013-07-31 11:13:16 -0700507 break;
Andrew Leee74a10e2014-05-16 14:31:40 -0700508 case R.id.dialtacts_options_menu_button:
509 buildOptionsMenu(view).show();
510 break;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700511 default: {
512 Log.wtf(TAG, "Unexpected onClick event from " + view);
513 break;
514 }
515 }
516 }
517
Yorke Leec3766332013-07-31 11:13:16 -0700518 @Override
Andrew Leee74a10e2014-05-16 14:31:40 -0700519 public boolean onMenuItemClick(MenuItem item) {
Yorke Lee86e21f72014-04-02 16:49:38 -0700520 switch (item.getItemId()) {
521 case R.id.menu_history:
Yorke Lee6a1461a2014-04-21 16:27:14 -0700522 showCallHistory();
Yorke Lee86e21f72014-04-02 16:49:38 -0700523 break;
524 case R.id.menu_add_contact:
525 try {
526 startActivity(new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI));
527 } catch (ActivityNotFoundException e) {
528 Toast toast = Toast.makeText(this,
529 R.string.add_contact_not_available,
530 Toast.LENGTH_SHORT);
531 toast.show();
532 }
533 break;
534 case R.id.menu_import_export:
535 // We hard-code the "contactsAreAvailable" argument because doing it properly would
536 // involve querying a {@link ProviderStatusLoader}, which we don't want to do right
537 // now in Dialtacts for (potential) performance reasons. Compare with how it is
538 // done in {@link PeopleActivity}.
539 ImportExportDialogFragment.show(getFragmentManager(), true,
540 DialtactsActivity.class);
541 return true;
542 case R.id.menu_clear_frequents:
Yorke Lee86e21f72014-04-02 16:49:38 -0700543 ClearFrequentsDialog.show(getFragmentManager());
544 return true;
545 case R.id.menu_call_settings:
546 handleMenuSettings();
547 return true;
Yorke Lee86e21f72014-04-02 16:49:38 -0700548 }
549 return false;
550 }
551
552 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700553 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
554 if (requestCode == ACTIVITY_REQUEST_CODE_VOICE_SEARCH) {
555 if (resultCode == RESULT_OK) {
556 final ArrayList<String> matches = data.getStringArrayListExtra(
557 RecognizerIntent.EXTRA_RESULTS);
558 if (matches.size() > 0) {
559 final String match = matches.get(0);
Yorke Lee53a22302014-04-29 18:13:46 -0700560 mSearchView.setText(match);
Yorke Leec3766332013-07-31 11:13:16 -0700561 } else {
562 Log.e(TAG, "Voice search - nothing heard");
563 }
564 } else {
565 Log.e(TAG, "Voice search failed");
566 }
567 }
568 super.onActivityResult(requestCode, resultCode, data);
569 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700570
Andrew Lee2a58ab82014-05-15 02:16:04 -0700571 /**
572 * Initiates a fragment transaction to show the dialpad fragment. Animations and other visual
573 * updates are handled by a callback which is invoked after the dialpad fragment is shown.
574 * @see #onDialpadShown
575 */
Yorke Leec3766332013-07-31 11:13:16 -0700576 private void showDialpadFragment(boolean animate) {
Andrew Lee2a58ab82014-05-15 02:16:04 -0700577 if (mIsDialpadShown) {
578 return;
579 }
580 mIsDialpadShown = true;
Andrew Leecdfa6c62014-05-06 15:33:35 -0700581 mDialpadFragment.setAnimate(animate);
582
Chiao Cheng94b10b52012-08-17 16:59:12 -0700583 final FragmentTransaction ft = getFragmentManager().beginTransaction();
Yorke Leec3766332013-07-31 11:13:16 -0700584 ft.show(mDialpadFragment);
585 ft.commit();
Andrew Leeb1903842014-05-15 16:11:24 -0700586
Yorke Lee5253be02014-05-21 18:50:03 -0700587 mActionBarController.onDialpadUp();
588
Andrew Leeb1903842014-05-15 16:11:24 -0700589 if (!isInSearchUi()) {
590 enterSearchUi(true /* isSmartDial */, mSearchQuery);
591 }
Yorke Leec3766332013-07-31 11:13:16 -0700592 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700593
Andrew Lee2a58ab82014-05-15 02:16:04 -0700594 /**
595 * Callback from child DialpadFragment when the dialpad is shown.
596 */
597 public void onDialpadShown() {
598 updateFloatingActionButton();
599 if (mDialpadFragment.getAnimate()) {
600 Animation slideIn = AnimationUtils.loadAnimation(this, R.anim.slide_in);
601 mDialpadFragment.getView().startAnimation(slideIn);
602 } else {
603 mDialpadFragment.setYFraction(0);
604 }
605
Andrew Lee2a58ab82014-05-15 02:16:04 -0700606 updateSearchFragmentPosition();
Andrew Lee2a58ab82014-05-15 02:16:04 -0700607 }
608
609 /**
610 * Initiates animations and other visual updates to hide the dialpad. The fragment is hidden in
611 * a callback after the hide animation ends.
612 * @see #commitDialpadFragmentHide
613 */
Yorke Leeca195042013-09-25 16:29:38 -0700614 public void hideDialpadFragment(boolean animate, boolean clearDialpad) {
Andrew Lee2a58ab82014-05-15 02:16:04 -0700615 if (mDialpadFragment == null) {
616 return;
617 }
Yorke Leef6673d32013-08-23 15:34:17 -0700618 if (clearDialpad) {
619 mDialpadFragment.clearDialpad();
620 }
Andrew Lee2a58ab82014-05-15 02:16:04 -0700621 if (!mIsDialpadShown) {
622 return;
Yorke Leec3766332013-07-31 11:13:16 -0700623 }
Andrew Lee2a58ab82014-05-15 02:16:04 -0700624 mIsDialpadShown = false;
625 mDialpadFragment.setAnimate(animate);
626
Andrew Leedbe9a8c2014-05-16 15:18:40 -0700627 updateSearchFragmentPosition();
Andrew Lee2a58ab82014-05-15 02:16:04 -0700628 updateFloatingActionButton();
629 if (animate) {
630 Animation slideOut = AnimationUtils.loadAnimation(this, R.anim.slide_out);
Andrew Lee3c14bc32014-05-28 15:43:03 -0700631 slideOut.setAnimationListener(new AnimationListenerAdapter() {
Andrew Lee2a58ab82014-05-15 02:16:04 -0700632 @Override
633 public void onAnimationEnd(Animation animation) {
634 commitDialpadFragmentHide();
635 }
636 });
637 mDialpadFragment.getView().startAnimation(slideOut);
638 } else {
639 commitDialpadFragmentHide();
640 }
641
Yorke Lee5253be02014-05-21 18:50:03 -0700642 mActionBarController.onDialpadDown();
Yorke Lee11ca39e2014-05-19 20:31:37 -0700643
Andrew Leed4cde832014-05-16 15:56:48 -0700644 if (isInSearchUi()) {
Andrew Lee44e3daf2014-05-19 14:28:16 -0700645 if (TextUtils.isEmpty(mSearchQuery)) {
646 exitSearchUi();
Andrew Lee44e3daf2014-05-19 14:28:16 -0700647 }
Andrew Leed4cde832014-05-16 15:56:48 -0700648 }
Andrew Lee2a58ab82014-05-15 02:16:04 -0700649 }
650
651 /**
652 * Finishes hiding the dialpad fragment after any animations are completed.
653 */
654 private void commitDialpadFragmentHide() {
655 final FragmentTransaction ft = getFragmentManager().beginTransaction();
Yorke Leec3766332013-07-31 11:13:16 -0700656 ft.hide(mDialpadFragment);
657 ft.commit();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700658 }
659
Andrew Lee2a58ab82014-05-15 02:16:04 -0700660 private void updateSearchFragmentPosition() {
Andrew Lee2a58ab82014-05-15 02:16:04 -0700661 SearchFragment fragment = null;
Andrew Leedbe9a8c2014-05-16 15:18:40 -0700662 if (mSmartDialSearchFragment != null && mSmartDialSearchFragment.isVisible()) {
Andrew Lee2a58ab82014-05-15 02:16:04 -0700663 fragment = mSmartDialSearchFragment;
Andrew Leedbe9a8c2014-05-16 15:18:40 -0700664 } else if (mRegularSearchFragment != null && mRegularSearchFragment.isVisible()) {
Andrew Lee2a58ab82014-05-15 02:16:04 -0700665 fragment = mRegularSearchFragment;
666 }
667 if (fragment != null && fragment.isVisible()) {
Andrew Lee05b62672014-06-03 14:03:09 -0700668 fragment.updatePosition(true /* animate */);
Andrew Lee2a58ab82014-05-15 02:16:04 -0700669 }
670 }
671
Yorke Lee5253be02014-05-21 18:50:03 -0700672 @Override
673 public boolean isInSearchUi() {
Yorke Leeb207f8a2013-08-29 18:51:06 -0700674 return mInDialpadSearch || mInRegularSearch;
675 }
676
Yorke Lee5253be02014-05-21 18:50:03 -0700677 @Override
678 public boolean hasSearchQuery() {
679 return !TextUtils.isEmpty(mSearchQuery);
680 }
681
682 @Override
683 public boolean shouldShowActionBar() {
684 return mListsFragment.shouldShowActionBar();
685 }
686
Yorke Leeb207f8a2013-08-29 18:51:06 -0700687 private void setNotInSearchUi() {
688 mInDialpadSearch = false;
689 mInRegularSearch = false;
690 }
691
Yorke Lee311969c2013-08-26 06:31:11 -0700692 private void hideDialpadAndSearchUi() {
Yorke Lee710709d2014-05-29 07:18:42 -0700693 if (mIsDialpadShown) {
694 hideDialpadFragment(false, true);
695 } else {
696 exitSearchUi();
697 }
Yorke Lee311969c2013-08-26 06:31:11 -0700698 }
699
Yorke Leee00c9fe2014-04-12 12:42:06 -0700700 private void hideInputMethod(View view) {
701 final InputMethodManager imm = (InputMethodManager) getSystemService(
702 Context.INPUT_METHOD_SERVICE);
703 if (imm != null && view != null) {
704 imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
705 }
706 }
707
Yorke Lee53a22302014-04-29 18:13:46 -0700708 private void prepareVoiceSearchButton() {
Yorke Lee53a22302014-04-29 18:13:46 -0700709 final Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
710 if (canIntentBeHandled(voiceIntent)) {
711 mVoiceSearchButton.setVisibility(View.VISIBLE);
712 mVoiceSearchButton.setOnClickListener(this);
713 } else {
714 mVoiceSearchButton.setVisibility(View.GONE);
715 }
716 }
717
Andrew Leee74a10e2014-05-16 14:31:40 -0700718 private OptionsPopupMenu buildOptionsMenu(View invoker) {
719 final OptionsPopupMenu popupMenu = new OptionsPopupMenu(this, invoker);
720 popupMenu.inflate(R.menu.dialtacts_options);
721 popupMenu.setOnMenuItemClickListener(this);
722 return popupMenu;
723 }
724
Yorke Lee86e21f72014-04-02 16:49:38 -0700725 @Override
726 public boolean onCreateOptionsMenu(Menu menu) {
Yorke Lee3c9e7cd2014-04-16 11:37:21 -0700727 if (mPendingSearchViewQuery != null) {
Yorke Lee53a22302014-04-29 18:13:46 -0700728 mSearchView.setText(mPendingSearchViewQuery);
Yorke Lee3c9e7cd2014-04-16 11:37:21 -0700729 mPendingSearchViewQuery = null;
730 }
Andrew Leee74a10e2014-05-16 14:31:40 -0700731 return false;
Ihab Awadfb00cb82014-03-18 16:19:00 -0700732 }
733
Chiao Cheng94b10b52012-08-17 16:59:12 -0700734 /**
735 * Returns true if the intent is due to hitting the green send key (hardware call button:
736 * KEYCODE_CALL) while in a call.
737 *
738 * @param intent the intent that launched this activity
Chiao Cheng94b10b52012-08-17 16:59:12 -0700739 * @return true if the intent is due to hitting the green send key while in a call
740 */
Yorke Lee62e995c2014-03-28 10:02:56 -0700741 private boolean isSendKeyWhileInCall(Intent intent) {
742 // If there is a call in progress and the user launched the dialer by hitting the call
743 // button, go straight to the in-call screen.
744 final boolean callKey = Intent.ACTION_CALL_BUTTON.equals(intent.getAction());
Chiao Cheng94b10b52012-08-17 16:59:12 -0700745
Santos Cordon1d7ef6a2014-05-29 21:46:33 -0700746 if (callKey) {
747 getTelephonyManager().showCallScreen();
748 return true;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700749 }
750
751 return false;
752 }
753
754 /**
755 * Sets the current tab based on the intent's request type
756 *
757 * @param intent Intent that contains information about which tab should be selected
758 */
Yorke Leec3766332013-07-31 11:13:16 -0700759 private void displayFragment(Intent intent) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700760 // If we got here by hitting send and we're in call forward along to the in-call activity
Yorke Lee62e995c2014-03-28 10:02:56 -0700761 if (isSendKeyWhileInCall(intent)) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700762 finish();
763 return;
764 }
765
Yorke Lee669b6082013-09-17 15:43:38 -0700766 if (mDialpadFragment != null) {
767 final boolean phoneIsInUse = phoneIsInUse();
768 if (phoneIsInUse || isDialIntent(intent)) {
769 mDialpadFragment.setStartedFromNewIntent(true);
770 if (phoneIsInUse && !mDialpadFragment.isVisible()) {
771 mInCallDialpadUp = true;
772 }
773 showDialpadFragment(false);
Yorke Lee35127cd2013-09-10 14:09:29 -0700774 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700775 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700776 }
777
778 @Override
779 public void onNewIntent(Intent newIntent) {
780 setIntent(newIntent);
Yorke Leec3766332013-07-31 11:13:16 -0700781 displayFragment(newIntent);
Yorke Leec3766332013-07-31 11:13:16 -0700782
Chiao Cheng94b10b52012-08-17 16:59:12 -0700783 invalidateOptionsMenu();
784 }
785
786 /** Returns true if the given intent contains a phone number to populate the dialer with */
787 private boolean isDialIntent(Intent intent) {
788 final String action = intent.getAction();
789 if (Intent.ACTION_DIAL.equals(action) || ACTION_TOUCH_DIALER.equals(action)) {
790 return true;
791 }
792 if (Intent.ACTION_VIEW.equals(action)) {
793 final Uri data = intent.getData();
Chiao Cheng9d4f3b22012-09-05 16:00:16 -0700794 if (data != null && CallUtil.SCHEME_TEL.equals(data.getScheme())) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700795 return true;
796 }
797 }
798 return false;
799 }
800
801 /**
802 * Returns an appropriate call origin for this Activity. May return null when no call origin
803 * should be used (e.g. when some 3rd party application launched the screen. Call origin is
804 * for remembering the tab in which the user made a phone call, so the external app's DIAL
805 * request should not be counted.)
806 */
807 public String getCallOrigin() {
808 return !isDialIntent(getIntent()) ? CALL_ORIGIN_DIALTACTS : null;
809 }
810
Chiao Cheng94b10b52012-08-17 16:59:12 -0700811 /**
Yorke Leec3766332013-07-31 11:13:16 -0700812 * Shows the search fragment
Chiao Cheng94b10b52012-08-17 16:59:12 -0700813 */
Yorke Leeef2b7382013-08-09 17:39:25 -0700814 private void enterSearchUi(boolean smartDialSearch, String query) {
Andrew Lee90374a72014-05-16 15:01:09 -0700815 if (getFragmentManager().isDestroyed()) {
Yorke Lee34bdf872013-08-15 14:11:50 -0700816 // Weird race condition where fragment is doing work after the activity is destroyed
817 // due to talkback being on (b/10209937). Just return since we can't do any
818 // constructive here.
819 return;
820 }
821
Yorke Leeef2b7382013-08-09 17:39:25 -0700822 if (DEBUG) {
823 Log.d(TAG, "Entering search UI - smart dial " + smartDialSearch);
824 }
Yorke Leeef2b7382013-08-09 17:39:25 -0700825
Yorke Leec3766332013-07-31 11:13:16 -0700826 final FragmentTransaction transaction = getFragmentManager().beginTransaction();
Yorke Leee00c9fe2014-04-12 12:42:06 -0700827 if (mInDialpadSearch && mSmartDialSearchFragment != null) {
Yorke Leeb207f8a2013-08-29 18:51:06 -0700828 transaction.remove(mSmartDialSearchFragment);
Yorke Leee00c9fe2014-04-12 12:42:06 -0700829 } else if (mInRegularSearch && mRegularSearchFragment != null) {
Yorke Leeb207f8a2013-08-29 18:51:06 -0700830 transaction.remove(mRegularSearchFragment);
Yorke Leeb207f8a2013-08-29 18:51:06 -0700831 }
Yorke Leeef2b7382013-08-09 17:39:25 -0700832
Yorke Leeb207f8a2013-08-29 18:51:06 -0700833 final String tag;
834 if (smartDialSearch) {
835 tag = TAG_SMARTDIAL_SEARCH_FRAGMENT;
836 } else {
837 tag = TAG_REGULAR_SEARCH_FRAGMENT;
838 }
839 mInDialpadSearch = smartDialSearch;
840 mInRegularSearch = !smartDialSearch;
841
Andrew Lee752956e2014-05-15 11:43:38 -0700842 SearchFragment fragment = (SearchFragment) getFragmentManager().findFragmentByTag(tag);
Andrew Leeb1903842014-05-15 16:11:24 -0700843 transaction.setCustomAnimations(android.R.animator.fade_in, 0);
Yorke Leeef2b7382013-08-09 17:39:25 -0700844 if (fragment == null) {
845 if (smartDialSearch) {
846 fragment = new SmartDialSearchFragment();
847 } else {
Jay Shrauner2e5b34b2013-08-29 10:52:40 -0700848 fragment = new RegularSearchFragment();
Yorke Leeef2b7382013-08-09 17:39:25 -0700849 }
Andrew Leeb1903842014-05-15 16:11:24 -0700850 transaction.add(R.id.dialtacts_frame, fragment, tag);
851 } else {
852 transaction.show(fragment);
Yorke Leeef2b7382013-08-09 17:39:25 -0700853 }
Andrew Leeb1903842014-05-15 16:11:24 -0700854
Yorke Lee86e21f72014-04-02 16:49:38 -0700855 // DialtactsActivity will provide the options menu
856 fragment.setHasOptionsMenu(false);
Andrew Leeb1903842014-05-15 16:11:24 -0700857 fragment.setShowEmptyListForNullQuery(true);
Andrew Lee99a570c2014-05-15 14:18:50 -0700858 fragment.setQueryString(query, false /* delaySelection */);
Yorke Leeef2b7382013-08-09 17:39:25 -0700859 transaction.commit();
Andrew Leeb1903842014-05-15 16:11:24 -0700860
861 mListsFragment.getView().animate().alpha(0).withLayer();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700862 }
863
864 /**
Yorke Leec3766332013-07-31 11:13:16 -0700865 * Hides the search fragment
Chiao Cheng94b10b52012-08-17 16:59:12 -0700866 */
Yorke Leec3766332013-07-31 11:13:16 -0700867 private void exitSearchUi() {
Yorke Lee3487db72013-09-26 17:12:06 -0700868 // See related bug in enterSearchUI();
869 if (getFragmentManager().isDestroyed()) {
870 return;
871 }
Andrew Leeb1903842014-05-15 16:11:24 -0700872
Andrew Leeb1903842014-05-15 16:11:24 -0700873 mSearchView.setText(null);
874 mDialpadFragment.clearDialpad();
Yorke Leeb207f8a2013-08-29 18:51:06 -0700875 setNotInSearchUi();
Yorke Lee7eccf452014-03-14 12:52:42 -0700876
Andrew Leeb1903842014-05-15 16:11:24 -0700877 final FragmentTransaction transaction = getFragmentManager().beginTransaction();
Andrew Leeb1903842014-05-15 16:11:24 -0700878 if (mSmartDialSearchFragment != null) {
879 transaction.remove(mSmartDialSearchFragment);
Yorke Lee7eccf452014-03-14 12:52:42 -0700880 }
Andrew Leeb1903842014-05-15 16:11:24 -0700881 if (mRegularSearchFragment != null) {
882 transaction.remove(mRegularSearchFragment);
883 }
884 transaction.commit();
885
886 mListsFragment.getView().animate().alpha(1).withLayer();
Yorke Lee5253be02014-05-21 18:50:03 -0700887 mActionBarController.onSearchUiExited();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700888 }
889
890 /** Returns an Intent to launch Call Settings screen */
891 public static Intent getCallSettingsIntent() {
892 final Intent intent = new Intent(Intent.ACTION_MAIN);
893 intent.setClassName(PHONE_PACKAGE, CALL_SETTINGS_CLASS_NAME);
894 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
895 return intent;
896 }
897
898 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700899 public void onBackPressed() {
Andrew Lee2a58ab82014-05-15 02:16:04 -0700900 if (mIsDialpadShown) {
Andrew Leeb1903842014-05-15 16:11:24 -0700901 if (TextUtils.isEmpty(mSearchQuery)) {
902 exitSearchUi();
903 }
Yorke Leef6673d32013-08-23 15:34:17 -0700904 hideDialpadFragment(true, false);
Andrew Leeb1903842014-05-15 16:11:24 -0700905 } else if (isInSearchUi()) {
Andrew Lee99a570c2014-05-15 14:18:50 -0700906 exitSearchUi();
Yorke Lee11ca39e2014-05-19 20:31:37 -0700907 hideInputMethod(parentLayout);
Yorke Leec3766332013-07-31 11:13:16 -0700908 } else {
909 super.onBackPressed();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700910 }
Yorke Leec3766332013-07-31 11:13:16 -0700911 }
912
Yorke Leec7b2a0e2014-05-20 17:21:25 -0700913 /**
914 * @return True if the search UI was exited, false otherwise
915 */
916 private boolean maybeExitSearchUi() {
917 if (isInSearchUi() && TextUtils.isEmpty(mSearchQuery)) {
918 exitSearchUi();
919 hideInputMethod(parentLayout);
920 return true;
921 }
922 return false;
923 }
924
Yorke Leec3766332013-07-31 11:13:16 -0700925 @Override
926 public void onDialpadQueryChanged(String query) {
Yorke Lee46635872014-04-11 11:20:15 -0700927 if (mSmartDialSearchFragment != null) {
928 mSmartDialSearchFragment.setAddToContactNumber(query);
929 }
Yorke Leec3766332013-07-31 11:13:16 -0700930 final String normalizedQuery = SmartDialNameMatcher.normalizeNumber(query,
931 SmartDialNameMatcher.LATIN_SMART_DIAL_MAP);
Yorke Lee53a22302014-04-29 18:13:46 -0700932
933 if (!TextUtils.equals(mSearchView.getText(), normalizedQuery)) {
Yorke Leeef2b7382013-08-09 17:39:25 -0700934 if (DEBUG) {
935 Log.d(TAG, "onDialpadQueryChanged - new query: " + query);
936 }
937 if (mDialpadFragment == null || !mDialpadFragment.isVisible()) {
938 // This callback can happen if the dialpad fragment is recreated because of
939 // activity destruction. In that case, don't update the search view because
940 // that would bring the user back to the search fragment regardless of the
941 // previous state of the application. Instead, just return here and let the
942 // fragment manager correctly figure out whatever fragment was last displayed.
Yorke Lee53a22302014-04-29 18:13:46 -0700943 if (!TextUtils.isEmpty(normalizedQuery)) {
944 mPendingSearchViewQuery = normalizedQuery;
945 }
Yorke Leeef2b7382013-08-09 17:39:25 -0700946 return;
947 }
Yorke Lee53a22302014-04-29 18:13:46 -0700948 mSearchView.setText(normalizedQuery);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700949 }
950 }
Yorke Leec3766332013-07-31 11:13:16 -0700951
952 @Override
953 public void onListFragmentScrollStateChange(int scrollState) {
954 if (scrollState == OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
Yorke Leef6673d32013-08-23 15:34:17 -0700955 hideDialpadFragment(true, false);
Yorke Leec3766332013-07-31 11:13:16 -0700956 hideInputMethod(getCurrentFocus());
957 }
958 }
959
960 @Override
Yorke Lee86e21f72014-04-02 16:49:38 -0700961 public void onListFragmentScroll(int firstVisibleItem, int visibleItemCount,
Andrew Lee99a570c2014-05-15 14:18:50 -0700962 int totalItemCount) {
Yorke Leee00c9fe2014-04-12 12:42:06 -0700963 // TODO: No-op for now. This should eventually show/hide the actionBar based on
964 // interactions with the ListsFragments.
Yorke Lee86e21f72014-04-02 16:49:38 -0700965 }
966
Yorke Lee86e21f72014-04-02 16:49:38 -0700967 @Override
Andrew Leea73e1892014-05-13 13:21:16 -0700968 public void setFloatingActionButtonVisible(boolean visible) {
969 mFloatingActionButtonContainer.setVisibility(visible ? View.VISIBLE : View.GONE);
Yorke Leec3766332013-07-31 11:13:16 -0700970 }
971
972 private boolean phoneIsInUse() {
Santos Cordon1d7ef6a2014-05-29 21:46:33 -0700973 // TODO(santoscordon): Replace with a TelecommService method call.
974 return getTelephonyManager().getCallState() != TelephonyManager.CALL_STATE_IDLE;
Yorke Leec3766332013-07-31 11:13:16 -0700975 }
Yorke Lee8dd62002013-08-08 15:57:20 -0700976
Yorke Leee1424812013-09-04 18:24:48 -0700977 public static Intent getAddNumberToContactIntent(CharSequence text) {
978 final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
979 intent.putExtra(Intents.Insert.PHONE, text);
980 intent.setType(Contacts.CONTENT_ITEM_TYPE);
981 return intent;
982 }
983
Yorke Leeda0f9042013-12-05 14:25:51 -0800984 private boolean canIntentBeHandled(Intent intent) {
985 final PackageManager packageManager = getPackageManager();
986 final List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(intent,
987 PackageManager.MATCH_DEFAULT_ONLY);
988 return resolveInfo != null && resolveInfo.size() > 0;
989 }
Yorke Lee3cefcc62014-01-16 11:26:46 -0800990
Yorke Lee6a1461a2014-04-21 16:27:14 -0700991 @Override
992 public void showCallHistory() {
993 // Use explicit CallLogActivity intent instead of ACTION_VIEW +
994 // CONTENT_TYPE, so that we always open our call log from our dialer
995 final Intent intent = new Intent(this, CallLogActivity.class);
996 startActivity(intent);
997 }
998
Yorke Lee86e21f72014-04-02 16:49:38 -0700999 /**
1000 * Called when the user has long-pressed a contact tile to start a drag operation.
1001 */
Yorke Lee3cefcc62014-01-16 11:26:46 -08001002 @Override
Yorke Leeefb2d9c2014-04-18 14:05:01 -07001003 public void onDragStarted(int x, int y, PhoneFavoriteSquareTileView view) {
Andrew Leee9e0ba62014-05-30 14:03:05 -07001004 if (mListsFragment.isPaneOpen()) {
1005 mActionBarController.slideActionBarUp(true);
1006 }
Yorke Lee28266192014-05-01 10:05:52 -07001007 mRemoveViewContainer.setVisibility(View.VISIBLE);
Yorke Lee3cefcc62014-01-16 11:26:46 -08001008 }
1009
1010 @Override
Yorke Lee28266192014-05-01 10:05:52 -07001011 public void onDragHovered(int x, int y, PhoneFavoriteSquareTileView view) {
1012 }
Yorke Lee3cefcc62014-01-16 11:26:46 -08001013
Yorke Lee86e21f72014-04-02 16:49:38 -07001014 /**
1015 * Called when the user has released a contact tile after long-pressing it.
1016 */
Yorke Lee3cefcc62014-01-16 11:26:46 -08001017 @Override
1018 public void onDragFinished(int x, int y) {
Andrew Leee9e0ba62014-05-30 14:03:05 -07001019 if (mListsFragment.isPaneOpen()) {
1020 mActionBarController.slideActionBarDown(true);
1021 }
Yorke Lee28266192014-05-01 10:05:52 -07001022 mRemoveViewContainer.setVisibility(View.GONE);
Yorke Lee3cefcc62014-01-16 11:26:46 -08001023 }
1024
1025 @Override
1026 public void onDroppedOnRemove() {}
1027
1028 /**
Yorke Leed999b712014-04-23 15:10:58 -07001029 * Allows the SpeedDialFragment to attach the drag controller to mRemoveViewContainer
Yorke Lee3cefcc62014-01-16 11:26:46 -08001030 * once it has been attached to the activity.
1031 */
1032 @Override
1033 public void setDragDropController(DragDropController dragController) {
Yorke Lee28266192014-05-01 10:05:52 -07001034 mDragDropController = dragController;
1035 ((RemoveView) findViewById(R.id.remove_view))
1036 .setDragDropController(dragController);
Yorke Lee3cefcc62014-01-16 11:26:46 -08001037 }
Yorke Leee00c9fe2014-04-12 12:42:06 -07001038
1039 @Override
1040 public void onPickPhoneNumberAction(Uri dataUri) {
Yorke Lee4e28c1d2014-05-13 15:38:10 -07001041 // Specify call-origin so that users will see the previous tab instead of
1042 // CallLog screen (search UI will be automatically exited).
1043 PhoneNumberInteraction.startInteractionForPhoneCall(
Andrew Lee99a570c2014-05-15 14:18:50 -07001044 DialtactsActivity.this, dataUri, getCallOrigin());
Yorke Lee4e28c1d2014-05-13 15:38:10 -07001045 mClearSearchOnPause = true;
Yorke Leee00c9fe2014-04-12 12:42:06 -07001046 }
1047
1048 @Override
1049 public void onCallNumberDirectly(String phoneNumber) {
Yorke Lee4e28c1d2014-05-13 15:38:10 -07001050 Intent intent = CallUtil.getCallIntent(phoneNumber, getCallOrigin());
1051 startActivity(intent);
1052 mClearSearchOnPause = true;
Yorke Leee00c9fe2014-04-12 12:42:06 -07001053 }
1054
1055 @Override
1056 public void onShortcutIntentCreated(Intent intent) {
Yorke Lee4e28c1d2014-05-13 15:38:10 -07001057 Log.w(TAG, "Unsupported intent has come (" + intent + "). Ignoring.");
Yorke Leee00c9fe2014-04-12 12:42:06 -07001058 }
1059
1060 @Override
1061 public void onHomeInActionBarSelected() {
Yorke Lee4e28c1d2014-05-13 15:38:10 -07001062 exitSearchUi();
Yorke Leee00c9fe2014-04-12 12:42:06 -07001063 }
Yorke Lee33932ff2014-04-16 13:34:32 -07001064
Yorke Leecc4660d2014-04-24 11:22:57 -07001065 @Override
1066 public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
1067
1068 }
1069
1070 @Override
1071 public void onPageSelected(int position) {
1072 mCurrentTabPosition = position;
Yorke Leec61d4542014-05-01 10:43:24 -07001073 // If the dialpad is showing, the floating action button should always be middle aligned.
Andrew Lee2a58ab82014-05-15 02:16:04 -07001074 if (!mIsDialpadShown) {
Yorke Leec61d4542014-05-01 10:43:24 -07001075 alignFloatingActionButtonByTab(mCurrentTabPosition);
1076 }
Yorke Leecc4660d2014-04-24 11:22:57 -07001077 }
1078
1079 @Override
1080 public void onPageScrollStateChanged(int state) {
1081 }
1082
Andrew Lee2a58ab82014-05-15 02:16:04 -07001083 private void updateFloatingActionButton() {
1084 if (mIsDialpadShown) {
1085 mFloatingActionButton.setImageResource(R.drawable.fab_ic_call);
1086 mFloatingActionButton.setContentDescription(
1087 getResources().getString(R.string.description_dial_button));
Andrew Leec4643f72014-05-15 11:27:39 -07001088 alignFloatingActionButtonMiddle();
Andrew Lee2a58ab82014-05-15 02:16:04 -07001089 } else {
1090 mFloatingActionButton.setImageResource(R.drawable.fab_ic_dial);
1091 mFloatingActionButton.setContentDescription(
1092 getResources().getString(R.string.action_menu_dialpad_button));
Andrew Leec4643f72014-05-15 11:27:39 -07001093 alignFloatingActionButtonByTab(mCurrentTabPosition);
Andrew Lee2a58ab82014-05-15 02:16:04 -07001094 }
1095 }
1096
Yorke Leecc4660d2014-04-24 11:22:57 -07001097 private void alignFloatingActionButtonByTab(int position) {
1098 if (position == ListsFragment.TAB_INDEX_SPEED_DIAL) {
1099 alignFloatingActionButtonMiddle();
1100 } else {
1101 alignFloatingActionButtonRight();
1102 }
1103 }
1104
1105 private void alignFloatingActionButtonRight() {
1106 final RelativeLayout.LayoutParams params =
Andrew Leea73e1892014-05-13 13:21:16 -07001107 (RelativeLayout.LayoutParams) mFloatingActionButtonContainer.getLayoutParams();
Yorke Leecc4660d2014-04-24 11:22:57 -07001108 params.removeRule(RelativeLayout.CENTER_HORIZONTAL);
1109 params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
Andrew Lee2423a2f2014-05-29 14:14:45 -07001110 updateFloatingActionButtonMargin(params);
Andrew Leea73e1892014-05-13 13:21:16 -07001111 mFloatingActionButtonContainer.setLayoutParams(params);
Yorke Leecc4660d2014-04-24 11:22:57 -07001112 }
1113
1114 private void alignFloatingActionButtonMiddle() {
1115 final RelativeLayout.LayoutParams params =
Andrew Leea73e1892014-05-13 13:21:16 -07001116 (RelativeLayout.LayoutParams) mFloatingActionButtonContainer.getLayoutParams();
Yorke Leecc4660d2014-04-24 11:22:57 -07001117 params.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT);
1118 params.addRule(RelativeLayout.CENTER_HORIZONTAL);
Andrew Lee2423a2f2014-05-29 14:14:45 -07001119 updateFloatingActionButtonMargin(params);
Andrew Leea73e1892014-05-13 13:21:16 -07001120 mFloatingActionButtonContainer.setLayoutParams(params);
Yorke Leecc4660d2014-04-24 11:22:57 -07001121 }
Andrew Lee2a58ab82014-05-15 02:16:04 -07001122
Andrew Lee2423a2f2014-05-29 14:14:45 -07001123 private void updateFloatingActionButtonMargin(RelativeLayout.LayoutParams params) {
1124 params.setMarginsRelative(
1125 params.getMarginStart(),
1126 params.topMargin,
1127 params.getMarginEnd(),
1128 mIsDialpadShown ?
1129 mFloatingActionButtonDialpadMarginBottom :
1130 mFloatingActionButtonMarginBottom);
1131 }
1132
Santos Cordon1d7ef6a2014-05-29 21:46:33 -07001133 private TelephonyManager getTelephonyManager() {
1134 return (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
1135 }
1136
Yorke Lee5253be02014-05-21 18:50:03 -07001137 @Override
1138 public boolean isActionBarShowing() {
1139 return mActionBarController.isActionBarShowing();
1140 }
1141
Andrew Lee05b62672014-06-03 14:03:09 -07001142 public boolean isDialpadShown() {
1143 return mIsDialpadShown;
1144 }
1145
Yorke Lee5253be02014-05-21 18:50:03 -07001146 @Override
1147 public int getActionBarHideOffset() {
1148 return getActionBar().getHideOffset();
1149 }
1150
1151 @Override
1152 public int getActionBarHeight() {
1153 return mActionBarHeight;
1154 }
1155
1156 @Override
1157 public void setActionBarHideOffset(int hideOffset) {
1158 getActionBar().setHideOffset(hideOffset);
1159 }
Chiao Cheng94b10b52012-08-17 16:59:12 -07001160}