blob: 2d1e2a72331fa5aa74ae95e70e03a370ee72cf37 [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 -070093import com.android.internal.telephony.ITelephony;
94
Yorke Leec3766332013-07-31 11:13:16 -070095import java.util.ArrayList;
Yorke Leeda0f9042013-12-05 14:25:51 -080096import java.util.List;
Yorke Leec3766332013-07-31 11:13:16 -070097
Chiao Cheng94b10b52012-08-17 16:59:12 -070098/**
Chiao Cheng94b10b52012-08-17 16:59:12 -070099 * The dialer tab's title is 'phone', a more common name (see strings.xml).
100 */
Yorke Leec3766332013-07-31 11:13:16 -0700101public class DialtactsActivity extends TransactionSafeActivity implements View.OnClickListener,
Yorke Lee86e21f72014-04-02 16:49:38 -0700102 DialpadFragment.OnDialpadQueryChangedListener,
Yorke Leec3766332013-07-31 11:13:16 -0700103 OnListFragmentScrolledListener,
Ihab Awad526c0b82014-02-27 12:55:36 -0800104 DialpadFragment.HostInterface,
Yorke Lee6a1461a2014-04-21 16:27:14 -0700105 ListsFragment.HostInterface,
Yorke Leed999b712014-04-23 15:10:58 -0700106 SpeedDialFragment.HostInterface,
Yorke Lee5253be02014-05-21 18:50:03 -0700107 SearchFragment.HostInterface,
Andrew Lee752956e2014-05-15 11:43:38 -0700108 OnDragDropListener,
Yorke Leecc4660d2014-04-24 11:22:57 -0700109 OnPhoneNumberPickerActionListener,
Andrew Leee74a10e2014-05-16 14:31:40 -0700110 PopupMenu.OnMenuItemClickListener,
Yorke Lee5253be02014-05-21 18:50:03 -0700111 ViewPager.OnPageChangeListener,
112 ActionBarController.ActivityUi {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700113 private static final String TAG = "DialtactsActivity";
114
Ihab Awad526c0b82014-02-27 12:55:36 -0800115 public static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700116
Yorke Leef74011e2013-08-02 11:30:30 -0700117 public static final String SHARED_PREFS_NAME = "com.android.dialer_preferences";
118
Chiao Cheng94b10b52012-08-17 16:59:12 -0700119 /** Used to open Call Setting */
120 private static final String PHONE_PACKAGE = "com.android.phone";
121 private static final String CALL_SETTINGS_CLASS_NAME =
122 "com.android.phone.CallFeaturesSetting";
Chiao Cheng94b10b52012-08-17 16:59:12 -0700123 /** @see #getCallOrigin() */
124 private static final String CALL_ORIGIN_DIALTACTS =
125 "com.android.dialer.DialtactsActivity";
126
Yorke Leeb207f8a2013-08-29 18:51:06 -0700127 private static final String KEY_IN_REGULAR_SEARCH_UI = "in_regular_search_ui";
128 private static final String KEY_IN_DIALPAD_SEARCH_UI = "in_dialpad_search_ui";
Yorke Leeef2b7382013-08-09 17:39:25 -0700129 private static final String KEY_SEARCH_QUERY = "search_query";
130 private static final String KEY_FIRST_LAUNCH = "first_launch";
Yorke Lee50aba882014-05-28 20:04:31 -0700131 private static final String KEY_IS_DIALPAD_SHOWN = "is_dialpad_shown";
Yorke Leeef2b7382013-08-09 17:39:25 -0700132
Yorke Leec3766332013-07-31 11:13:16 -0700133 private static final String TAG_DIALPAD_FRAGMENT = "dialpad";
134 private static final String TAG_REGULAR_SEARCH_FRAGMENT = "search";
135 private static final String TAG_SMARTDIAL_SEARCH_FRAGMENT = "smartdial";
136 private static final String TAG_FAVORITES_FRAGMENT = "favorites";
Yorke Leec3766332013-07-31 11:13:16 -0700137
Chiao Cheng94b10b52012-08-17 16:59:12 -0700138 /**
139 * Just for backward compatibility. Should behave as same as {@link Intent#ACTION_DIAL}.
140 */
141 private static final String ACTION_TOUCH_DIALER = "com.android.phone.action.TOUCH_DIALER";
142
Yorke Leec3766332013-07-31 11:13:16 -0700143 private static final int ACTIVITY_REQUEST_CODE_VOICE_SEARCH = 1;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700144
Yorke Lee86e21f72014-04-02 16:49:38 -0700145 private static final int ANIMATION_DURATION = 250;
Yorke Lee3cefcc62014-01-16 11:26:46 -0800146
Andrew Lee0c667702014-05-12 14:31:45 -0700147 private RelativeLayout parentLayout;
148
Yorke Leec3766332013-07-31 11:13:16 -0700149 /**
Yorke Leec3766332013-07-31 11:13:16 -0700150 * Fragment containing the dialpad that slides into view
Chiao Cheng94b10b52012-08-17 16:59:12 -0700151 */
Yorke Leef74011e2013-08-02 11:30:30 -0700152 private DialpadFragment mDialpadFragment;
Yorke Leec3766332013-07-31 11:13:16 -0700153
154 /**
155 * Fragment for searching phone numbers using the alphanumeric keyboard.
156 */
Jay Shrauner2e5b34b2013-08-29 10:52:40 -0700157 private RegularSearchFragment mRegularSearchFragment;
Yorke Leec3766332013-07-31 11:13:16 -0700158
159 /**
160 * Fragment for searching phone numbers using the dialpad.
161 */
162 private SmartDialSearchFragment mSmartDialSearchFragment;
163
Yorke Leee00c9fe2014-04-12 12:42:06 -0700164 /**
165 * Fragment containing the speed dial list, recents list, and all contacts list.
166 */
167 private ListsFragment mListsFragment;
168
Andrew Leea73e1892014-05-13 13:21:16 -0700169 private View mFloatingActionButtonContainer;
170 private ImageButton mFloatingActionButton;
Yorke Leec3766332013-07-31 11:13:16 -0700171
Yorke Leeb207f8a2013-08-29 18:51:06 -0700172 private boolean mInDialpadSearch;
173 private boolean mInRegularSearch;
Yorke Lee8e5c8b12013-10-01 14:37:55 -0700174 private boolean mClearSearchOnPause;
Andrew Lee2a58ab82014-05-15 02:16:04 -0700175 private boolean mIsDialpadShown;
Yorke Lee50aba882014-05-28 20:04:31 -0700176 private boolean mShowDialpadOnResume;
Yorke Leeb207f8a2013-08-29 18:51:06 -0700177
Yorke Leeef2b7382013-08-09 17:39:25 -0700178 /**
Yorke Leecc4660d2014-04-24 11:22:57 -0700179 * The position of the currently selected tab in the attached {@link ListsFragment}.
180 */
181 private int mCurrentTabPosition = 0;
182
183 /**
Yorke Lee35127cd2013-09-10 14:09:29 -0700184 * True if the dialpad is only temporarily showing due to being in call
185 */
186 private boolean mInCallDialpadUp;
187
188 /**
Yorke Leeef2b7382013-08-09 17:39:25 -0700189 * True when this activity has been launched for the first time.
190 */
Yorke Lee98702de2013-08-06 12:03:32 -0700191 private boolean mFirstLaunch;
Yorke Lee86e21f72014-04-02 16:49:38 -0700192
Yorke Lee3c9e7cd2014-04-16 11:37:21 -0700193 /**
194 * Search query to be applied to the SearchView in the ActionBar once
195 * onCreateOptionsMenu has been called.
196 */
197 private String mPendingSearchViewQuery;
198
Yorke Lee53a22302014-04-29 18:13:46 -0700199 private EditText mSearchView;
Yorke Lee53a22302014-04-29 18:13:46 -0700200 private View mVoiceSearchButton;
Yorke Leeec489fb2014-05-19 15:39:27 -0700201 private SearchEditTextLayout mSearchEditTextLayout;
Andrew Leee74a10e2014-05-16 14:31:40 -0700202
Yorke Lee86e21f72014-04-02 16:49:38 -0700203 /**
204 * View that contains the "Remove" dialog that shows up when the user long presses a contact.
205 * If the user releases a contact when hovering on top of this, the contact is unfavorited and
206 * removed from the speed dial list.
207 */
Yorke Lee28266192014-05-01 10:05:52 -0700208 private View mRemoveViewContainer;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700209
Yorke Lee86e21f72014-04-02 16:49:38 -0700210 final Interpolator hideActionBarInterpolator = new AccelerateInterpolator(1.5f);
211 final Interpolator showActionBarInterpolator = new DecelerateInterpolator(1.5f);
Yorke Leeef2b7382013-08-09 17:39:25 -0700212 private String mSearchQuery;
213
Yorke Leefce269a2013-08-12 11:56:04 -0700214 private DialerDatabaseHelper mDialerDatabaseHelper;
Yorke Lee28266192014-05-01 10:05:52 -0700215 private DragDropController mDragDropController;
Yorke Lee5253be02014-05-21 18:50:03 -0700216 private ActionBarController mActionBarController;
Yorke Leefce269a2013-08-12 11:56:04 -0700217
Andrew Lee2423a2f2014-05-29 14:14:45 -0700218 private int mActionBarHeight;
219 private int mFloatingActionButtonMarginBottom;
220 private int mFloatingActionButtonDialpadMarginBottom;
221
Andrew Leee74a10e2014-05-16 14:31:40 -0700222 private class OptionsPopupMenu extends PopupMenu {
223 public OptionsPopupMenu(Context context, View anchor) {
Yorke Leee00c9fe2014-04-12 12:42:06 -0700224 super(context, anchor);
225 }
226
227 @Override
228 public void show() {
229 final Menu menu = getMenu();
230 final MenuItem clearFrequents = menu.findItem(R.id.menu_clear_frequents);
Andrew Leee74a10e2014-05-16 14:31:40 -0700231 clearFrequents.setVisible(mListsFragment != null &&
232 mListsFragment.getSpeedDialFragment() != null &&
233 mListsFragment.getSpeedDialFragment().hasFrequents());
Yorke Leee00c9fe2014-04-12 12:42:06 -0700234 super.show();
235 }
236 }
237
Chiao Cheng94b10b52012-08-17 16:59:12 -0700238 /**
Yorke Lee28266192014-05-01 10:05:52 -0700239 * Listener that listens to drag events and sends their x and y coordinates to a
240 * {@link DragDropController}.
241 */
242 private class LayoutOnDragListener implements OnDragListener {
243 @Override
244 public boolean onDrag(View v, DragEvent event) {
245 if (event.getAction() == DragEvent.ACTION_DRAG_LOCATION) {
246 mDragDropController.handleDragHovered(v, (int) event.getX(),
247 (int) event.getY());
248 }
249 return true;
250 }
251 }
252
253 /**
Chiao Cheng94b10b52012-08-17 16:59:12 -0700254 * Listener used to send search queries to the phone search fragment.
255 */
Yorke Lee53a22302014-04-29 18:13:46 -0700256 private final TextWatcher mPhoneSearchQueryTextListener = new TextWatcher() {
Andrew Lee99a570c2014-05-15 14:18:50 -0700257 @Override
258 public void beforeTextChanged(CharSequence s, int start, int count, int after) {
259 }
Yorke Leec3766332013-07-31 11:13:16 -0700260
Andrew Lee99a570c2014-05-15 14:18:50 -0700261 @Override
262 public void onTextChanged(CharSequence s, int start, int before, int count) {
263 final String newText = s.toString();
264 if (newText.equals(mSearchQuery)) {
265 // If the query hasn't changed (perhaps due to activity being destroyed
266 // and restored, or user launching the same DIAL intent twice), then there is
267 // no need to do anything here.
Yorke Lee53a22302014-04-29 18:13:46 -0700268 return;
269 }
Andrew Lee99a570c2014-05-15 14:18:50 -0700270 if (DEBUG) {
271 Log.d(TAG, "onTextChange for mSearchView called with new query: " + newText);
Yorke Lee710709d2014-05-29 07:18:42 -0700272 Log.d(TAG, "Previous Query: " + mSearchQuery);
Yorke Leec3766332013-07-31 11:13:16 -0700273 }
Yorke Lee710709d2014-05-29 07:18:42 -0700274 mSearchQuery = newText;
Andrew Lee99a570c2014-05-15 14:18:50 -0700275
Andrew Lee90374a72014-05-16 15:01:09 -0700276 // Show search fragment only when the query string is changed to non-empty text.
277 if (!TextUtils.isEmpty(newText)) {
278 // Call enterSearchUi only if we are switching search modes, or showing a search
279 // fragment for the first time.
280 final boolean sameSearchMode = (mIsDialpadShown && mInDialpadSearch) ||
281 (!mIsDialpadShown && mInRegularSearch);
282 if (!sameSearchMode) {
283 enterSearchUi(mIsDialpadShown, mSearchQuery);
284 }
Andrew Lee99a570c2014-05-15 14:18:50 -0700285 }
286
287 if (mIsDialpadShown && mSmartDialSearchFragment != null) {
Andrew Leeb1903842014-05-15 16:11:24 -0700288 mSmartDialSearchFragment.setQueryString(mSearchQuery, false /* delaySelection */);
Andrew Lee99a570c2014-05-15 14:18:50 -0700289 } else if (mRegularSearchFragment != null) {
Andrew Leeb1903842014-05-15 16:11:24 -0700290 mRegularSearchFragment.setQueryString(mSearchQuery, false /* delaySelection */);
Andrew Lee99a570c2014-05-15 14:18:50 -0700291 }
Andrew Lee99a570c2014-05-15 14:18:50 -0700292 }
293
294 @Override
295 public void afterTextChanged(Editable s) {
296 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700297 };
298
Andrew Leeb1903842014-05-15 16:11:24 -0700299
300 /**
Yorke Lee11ca39e2014-05-19 20:31:37 -0700301 * Open the search UI when the user clicks on the search box.
Andrew Leeb1903842014-05-15 16:11:24 -0700302 */
Yorke Lee11ca39e2014-05-19 20:31:37 -0700303 private final View.OnClickListener mSearchViewOnClickListener = new View.OnClickListener() {
Andrew Leeb1903842014-05-15 16:11:24 -0700304 @Override
Yorke Lee11ca39e2014-05-19 20:31:37 -0700305 public void onClick(View v) {
Andrew Leeb1903842014-05-15 16:11:24 -0700306 if (!isInSearchUi()) {
Yorke Lee5253be02014-05-21 18:50:03 -0700307 mActionBarController.onSearchBoxTapped();
Andrew Leeb1903842014-05-15 16:11:24 -0700308 enterSearchUi(false /* smartDialSearch */, mSearchView.getText().toString());
309 }
Andrew Leeb1903842014-05-15 16:11:24 -0700310 }
311 };
312
313 /**
314 * If the search term is empty and the user closes the soft keyboard, close the search UI.
315 */
316 private final View.OnKeyListener mSearchEditTextLayoutListener = new View.OnKeyListener() {
317 @Override
318 public boolean onKey(View v, int keyCode, KeyEvent event) {
319 if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN &&
320 TextUtils.isEmpty(mSearchView.getText().toString())) {
Yorke Leec7b2a0e2014-05-20 17:21:25 -0700321 maybeExitSearchUi();
Andrew Leeb1903842014-05-15 16:11:24 -0700322 }
323 return false;
324 }
325 };
326
Chiao Cheng94b10b52012-08-17 16:59:12 -0700327 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700328 protected void onCreate(Bundle savedInstanceState) {
329 super.onCreate(savedInstanceState);
Yorke Lee98702de2013-08-06 12:03:32 -0700330 mFirstLaunch = true;
331
Andrew Lee2423a2f2014-05-29 14:14:45 -0700332 final Resources resources = getResources();
333 mActionBarHeight = resources.getDimensionPixelSize(R.dimen.action_bar_height);
334 mFloatingActionButtonMarginBottom =
335 resources.getDimensionPixelOffset(R.dimen.floating_action_button_margin_bottom);
336 mFloatingActionButtonDialpadMarginBottom = resources.getDimensionPixelOffset(
337 R.dimen.floating_action_button_dialpad_margin_bottom);
338
Yorke Lee8898cd02013-08-08 10:24:27 -0700339 setContentView(R.layout.dialtacts_activity);
Yorke Lee9e91bb02014-03-05 17:50:50 -0800340 getWindow().setBackgroundDrawable(null);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700341
Yorke Lee53a22302014-04-29 18:13:46 -0700342 final ActionBar actionBar = getActionBar();
343 actionBar.setCustomView(R.layout.search_edittext);
344 actionBar.setDisplayShowCustomEnabled(true);
Yorke Leebcef9402014-05-21 15:33:00 -0700345 actionBar.setBackgroundDrawable(null);
Yorke Lee53a22302014-04-29 18:13:46 -0700346
Yorke Lee5253be02014-05-21 18:50:03 -0700347 mActionBarController = new ActionBarController(this,
348 (SearchEditTextLayout) actionBar.getCustomView());
349
Yorke Leeec489fb2014-05-19 15:39:27 -0700350 mSearchEditTextLayout = (SearchEditTextLayout) actionBar.getCustomView();
351 mSearchEditTextLayout.setPreImeKeyListener(mSearchEditTextLayoutListener);
Yorke Lee53a22302014-04-29 18:13:46 -0700352
Yorke Leeec489fb2014-05-19 15:39:27 -0700353 mSearchView = (EditText) mSearchEditTextLayout.findViewById(R.id.search_view);
Yorke Lee53a22302014-04-29 18:13:46 -0700354 mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener);
Yorke Lee11ca39e2014-05-19 20:31:37 -0700355 mVoiceSearchButton = mSearchEditTextLayout.findViewById(R.id.voice_search_button);
356 mSearchEditTextLayout.findViewById(R.id.search_box_start_search).setOnClickListener(
357 mSearchViewOnClickListener);
358 mSearchEditTextLayout.setOnBackButtonClickedListener(new OnBackButtonClickedListener() {
359 @Override
360 public void onBackButtonClicked() {
361 onBackPressed();
362 }
363 });
Chiao Cheng94b10b52012-08-17 16:59:12 -0700364
Yorke Leeec489fb2014-05-19 15:39:27 -0700365 ImageButton optionsMenuButton = (ImageButton) mSearchEditTextLayout.findViewById(
366 R.id.dialtacts_options_menu_button);
Andrew Leee74a10e2014-05-16 14:31:40 -0700367 optionsMenuButton.setOnClickListener(this);
368 final OptionsPopupMenu optionsMenu = buildOptionsMenu(optionsMenuButton);
369 optionsMenuButton.setOnTouchListener(optionsMenu.getDragToOpenListener());
370
Yorke Leeef2b7382013-08-09 17:39:25 -0700371 // Add the favorites fragment, and the dialpad fragment, but only if savedInstanceState
372 // is null. Otherwise the fragment manager takes care of recreating these fragments.
Yorke Leec3766332013-07-31 11:13:16 -0700373 if (savedInstanceState == null) {
Ihab Awad526c0b82014-02-27 12:55:36 -0800374 getFragmentManager().beginTransaction()
Yorke Leee00c9fe2014-04-12 12:42:06 -0700375 .add(R.id.dialtacts_frame, new ListsFragment(), TAG_FAVORITES_FRAGMENT)
Ihab Awad526c0b82014-02-27 12:55:36 -0800376 .add(R.id.dialtacts_container, new DialpadFragment(), TAG_DIALPAD_FRAGMENT)
377 .commit();
Yorke Leeef2b7382013-08-09 17:39:25 -0700378 } else {
379 mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY);
Yorke Leeb207f8a2013-08-29 18:51:06 -0700380 mInRegularSearch = savedInstanceState.getBoolean(KEY_IN_REGULAR_SEARCH_UI);
381 mInDialpadSearch = savedInstanceState.getBoolean(KEY_IN_DIALPAD_SEARCH_UI);
Yorke Leeef2b7382013-08-09 17:39:25 -0700382 mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH);
Yorke Lee50aba882014-05-28 20:04:31 -0700383 mShowDialpadOnResume = savedInstanceState.getBoolean(KEY_IS_DIALPAD_SHOWN);
Yorke Lee5253be02014-05-21 18:50:03 -0700384 mActionBarController.restoreInstanceState(savedInstanceState);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700385 }
386
Andrew Lee0c667702014-05-12 14:31:45 -0700387 parentLayout = (RelativeLayout) findViewById(R.id.dialtacts_mainlayout);
388 parentLayout.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
389 parentLayout.setOnDragListener(new LayoutOnDragListener());
390
Yorke Leec7b2a0e2014-05-20 17:21:25 -0700391 setupActivityOverlay();
392
Andrew Leea73e1892014-05-13 13:21:16 -0700393 mFloatingActionButtonContainer = findViewById(R.id.floating_action_button_container);
394 ViewUtil.setupFloatingActionButton(mFloatingActionButtonContainer, getResources());
Yorke Lee86e21f72014-04-02 16:49:38 -0700395
Andrew Leea73e1892014-05-13 13:21:16 -0700396 mFloatingActionButton = (ImageButton) findViewById(R.id.floating_action_button);
397 mFloatingActionButton.setOnClickListener(this);
Ihab Awad526c0b82014-02-27 12:55:36 -0800398
Yorke Lee28266192014-05-01 10:05:52 -0700399 mRemoveViewContainer = findViewById(R.id.remove_view_container);
Yorke Leeb0d19762014-03-05 14:43:28 -0800400
Yorke Lee0baa98b2013-08-22 10:55:16 -0700401 mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(this);
Yorke Leefce269a2013-08-12 11:56:04 -0700402 SmartDialPrefix.initializeNanpSettings(this);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700403 }
404
Yorke Leec7b2a0e2014-05-20 17:21:25 -0700405 private void setupActivityOverlay() {
406 final View activityOverlay = findViewById(R.id.activity_overlay);
407 activityOverlay.setOnTouchListener(new OnTouchListener() {
408 @Override
409 public boolean onTouch(View v, MotionEvent event) {
410 if (!mIsDialpadShown) {
411 maybeExitSearchUi();
412 }
413 return false;
414 }
415 });
416 }
417
Chiao Cheng94b10b52012-08-17 16:59:12 -0700418 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700419 protected void onResume() {
420 super.onResume();
Yorke Lee98702de2013-08-06 12:03:32 -0700421 if (mFirstLaunch) {
422 displayFragment(getIntent());
Yorke Lee35127cd2013-09-10 14:09:29 -0700423 } else if (!phoneIsInUse() && mInCallDialpadUp) {
424 hideDialpadFragment(false, true);
425 mInCallDialpadUp = false;
Yorke Lee50aba882014-05-28 20:04:31 -0700426 } else if (mShowDialpadOnResume) {
427 showDialpadFragment(false);
428 mShowDialpadOnResume = false;
Yorke Lee98702de2013-08-06 12:03:32 -0700429 }
430 mFirstLaunch = false;
Yorke Lee53a22302014-04-29 18:13:46 -0700431 prepareVoiceSearchButton();
Yorke Leefce269a2013-08-12 11:56:04 -0700432 mDialerDatabaseHelper.startSmartDialUpdateThread();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700433 }
434
435 @Override
Yorke Lee8e5c8b12013-10-01 14:37:55 -0700436 protected void onPause() {
437 if (mClearSearchOnPause) {
438 hideDialpadAndSearchUi();
439 mClearSearchOnPause = false;
440 }
441 super.onPause();
442 }
443
444 @Override
Yorke Leeef2b7382013-08-09 17:39:25 -0700445 protected void onSaveInstanceState(Bundle outState) {
446 super.onSaveInstanceState(outState);
447 outState.putString(KEY_SEARCH_QUERY, mSearchQuery);
Yorke Leeb207f8a2013-08-29 18:51:06 -0700448 outState.putBoolean(KEY_IN_REGULAR_SEARCH_UI, mInRegularSearch);
449 outState.putBoolean(KEY_IN_DIALPAD_SEARCH_UI, mInDialpadSearch);
Yorke Leeef2b7382013-08-09 17:39:25 -0700450 outState.putBoolean(KEY_FIRST_LAUNCH, mFirstLaunch);
Yorke Lee50aba882014-05-28 20:04:31 -0700451 outState.putBoolean(KEY_IS_DIALPAD_SHOWN, mIsDialpadShown);
Yorke Lee5253be02014-05-21 18:50:03 -0700452 mActionBarController.saveInstanceState(outState);
Yorke Leeef2b7382013-08-09 17:39:25 -0700453 }
454
455 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700456 public void onAttachFragment(Fragment fragment) {
Yorke Leeef2b7382013-08-09 17:39:25 -0700457 if (fragment instanceof DialpadFragment) {
458 mDialpadFragment = (DialpadFragment) fragment;
Yorke Lee50aba882014-05-28 20:04:31 -0700459 if (!mShowDialpadOnResume) {
460 final FragmentTransaction transaction = getFragmentManager().beginTransaction();
461 transaction.hide(mDialpadFragment);
462 transaction.commit();
463 }
Yorke Leeef2b7382013-08-09 17:39:25 -0700464 } else if (fragment instanceof SmartDialSearchFragment) {
465 mSmartDialSearchFragment = (SmartDialSearchFragment) fragment;
Yorke Lee4e28c1d2014-05-13 15:38:10 -0700466 mSmartDialSearchFragment.setOnPhoneNumberPickerActionListener(this);
Yorke Leeef2b7382013-08-09 17:39:25 -0700467 } else if (fragment instanceof SearchFragment) {
Jay Shrauner2e5b34b2013-08-29 10:52:40 -0700468 mRegularSearchFragment = (RegularSearchFragment) fragment;
Yorke Lee4e28c1d2014-05-13 15:38:10 -0700469 mRegularSearchFragment.setOnPhoneNumberPickerActionListener(this);
Yorke Leee00c9fe2014-04-12 12:42:06 -0700470 } else if (fragment instanceof ListsFragment) {
471 mListsFragment = (ListsFragment) fragment;
Yorke Leecc4660d2014-04-24 11:22:57 -0700472 mListsFragment.addOnPageChangeListener(this);
Yorke Leec3766332013-07-31 11:13:16 -0700473 }
Yorke Leec3766332013-07-31 11:13:16 -0700474 }
475
Alon Albertb453e5b2013-09-10 15:54:23 -0700476 protected void handleMenuSettings() {
477 openTelephonySetting(this);
478 }
479
480 public static void openTelephonySetting(Activity activity) {
481 final Intent settingsIntent = getCallSettingsIntent();
482 activity.startActivity(settingsIntent);
483 }
484
Chiao Cheng94b10b52012-08-17 16:59:12 -0700485 @Override
486 public void onClick(View view) {
487 switch (view.getId()) {
Andrew Leea73e1892014-05-13 13:21:16 -0700488 case R.id.floating_action_button:
Andrew Lee2a58ab82014-05-15 02:16:04 -0700489 if (!mIsDialpadShown) {
Andrew Leea73e1892014-05-13 13:21:16 -0700490 mInCallDialpadUp = false;
491 showDialpadFragment(true);
492 } else {
493 // Dial button was pressed; tell the Dialpad fragment
494 mDialpadFragment.dialButtonPressed();
495 }
Yorke Lee86e21f72014-04-02 16:49:38 -0700496 break;
Yorke Leec3766332013-07-31 11:13:16 -0700497 case R.id.search_close_button:
498 // Clear the search field
Yorke Lee53a22302014-04-29 18:13:46 -0700499 if (!TextUtils.isEmpty(mSearchView.getText())) {
Yorke Lee2eafb7a2013-09-10 14:34:01 -0700500 mDialpadFragment.clearDialpad();
Yorke Lee53a22302014-04-29 18:13:46 -0700501 mSearchView.setText(null);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700502 }
503 break;
Yorke Leec3766332013-07-31 11:13:16 -0700504 case R.id.voice_search_button:
Yorke Leeda0f9042013-12-05 14:25:51 -0800505 try {
506 startActivityForResult(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH),
507 ACTIVITY_REQUEST_CODE_VOICE_SEARCH);
508 } catch (ActivityNotFoundException e) {
509 Toast.makeText(DialtactsActivity.this, R.string.voice_search_not_available,
510 Toast.LENGTH_SHORT).show();
511 }
Yorke Leec3766332013-07-31 11:13:16 -0700512 break;
Andrew Leee74a10e2014-05-16 14:31:40 -0700513 case R.id.dialtacts_options_menu_button:
514 buildOptionsMenu(view).show();
515 break;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700516 default: {
517 Log.wtf(TAG, "Unexpected onClick event from " + view);
518 break;
519 }
520 }
521 }
522
Yorke Leec3766332013-07-31 11:13:16 -0700523 @Override
Andrew Leee74a10e2014-05-16 14:31:40 -0700524 public boolean onMenuItemClick(MenuItem item) {
Yorke Lee86e21f72014-04-02 16:49:38 -0700525 switch (item.getItemId()) {
526 case R.id.menu_history:
Yorke Lee6a1461a2014-04-21 16:27:14 -0700527 showCallHistory();
Yorke Lee86e21f72014-04-02 16:49:38 -0700528 break;
529 case R.id.menu_add_contact:
530 try {
531 startActivity(new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI));
532 } catch (ActivityNotFoundException e) {
533 Toast toast = Toast.makeText(this,
534 R.string.add_contact_not_available,
535 Toast.LENGTH_SHORT);
536 toast.show();
537 }
538 break;
539 case R.id.menu_import_export:
540 // We hard-code the "contactsAreAvailable" argument because doing it properly would
541 // involve querying a {@link ProviderStatusLoader}, which we don't want to do right
542 // now in Dialtacts for (potential) performance reasons. Compare with how it is
543 // done in {@link PeopleActivity}.
544 ImportExportDialogFragment.show(getFragmentManager(), true,
545 DialtactsActivity.class);
546 return true;
547 case R.id.menu_clear_frequents:
Yorke Lee86e21f72014-04-02 16:49:38 -0700548 ClearFrequentsDialog.show(getFragmentManager());
549 return true;
550 case R.id.menu_call_settings:
551 handleMenuSettings();
552 return true;
Yorke Lee86e21f72014-04-02 16:49:38 -0700553 }
554 return false;
555 }
556
557 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700558 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
559 if (requestCode == ACTIVITY_REQUEST_CODE_VOICE_SEARCH) {
560 if (resultCode == RESULT_OK) {
561 final ArrayList<String> matches = data.getStringArrayListExtra(
562 RecognizerIntent.EXTRA_RESULTS);
563 if (matches.size() > 0) {
564 final String match = matches.get(0);
Yorke Lee53a22302014-04-29 18:13:46 -0700565 mSearchView.setText(match);
Yorke Leec3766332013-07-31 11:13:16 -0700566 } else {
567 Log.e(TAG, "Voice search - nothing heard");
568 }
569 } else {
570 Log.e(TAG, "Voice search failed");
571 }
572 }
573 super.onActivityResult(requestCode, resultCode, data);
574 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700575
Andrew Lee2a58ab82014-05-15 02:16:04 -0700576 /**
577 * Initiates a fragment transaction to show the dialpad fragment. Animations and other visual
578 * updates are handled by a callback which is invoked after the dialpad fragment is shown.
579 * @see #onDialpadShown
580 */
Yorke Leec3766332013-07-31 11:13:16 -0700581 private void showDialpadFragment(boolean animate) {
Andrew Lee2a58ab82014-05-15 02:16:04 -0700582 if (mIsDialpadShown) {
583 return;
584 }
585 mIsDialpadShown = true;
Andrew Leecdfa6c62014-05-06 15:33:35 -0700586 mDialpadFragment.setAnimate(animate);
587
Chiao Cheng94b10b52012-08-17 16:59:12 -0700588 final FragmentTransaction ft = getFragmentManager().beginTransaction();
Yorke Leec3766332013-07-31 11:13:16 -0700589 ft.show(mDialpadFragment);
590 ft.commit();
Andrew Leeb1903842014-05-15 16:11:24 -0700591
Yorke Lee5253be02014-05-21 18:50:03 -0700592 mActionBarController.onDialpadUp();
593
Andrew Leeb1903842014-05-15 16:11:24 -0700594 if (!isInSearchUi()) {
595 enterSearchUi(true /* isSmartDial */, mSearchQuery);
596 }
Yorke Leec3766332013-07-31 11:13:16 -0700597 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700598
Andrew Lee2a58ab82014-05-15 02:16:04 -0700599 /**
600 * Callback from child DialpadFragment when the dialpad is shown.
601 */
602 public void onDialpadShown() {
603 updateFloatingActionButton();
604 if (mDialpadFragment.getAnimate()) {
605 Animation slideIn = AnimationUtils.loadAnimation(this, R.anim.slide_in);
606 mDialpadFragment.getView().startAnimation(slideIn);
607 } else {
608 mDialpadFragment.setYFraction(0);
609 }
610
Andrew Lee2a58ab82014-05-15 02:16:04 -0700611 updateSearchFragmentPosition();
Andrew Lee2a58ab82014-05-15 02:16:04 -0700612 }
613
614 /**
615 * Initiates animations and other visual updates to hide the dialpad. The fragment is hidden in
616 * a callback after the hide animation ends.
617 * @see #commitDialpadFragmentHide
618 */
Yorke Leeca195042013-09-25 16:29:38 -0700619 public void hideDialpadFragment(boolean animate, boolean clearDialpad) {
Andrew Lee2a58ab82014-05-15 02:16:04 -0700620 if (mDialpadFragment == null) {
621 return;
622 }
Yorke Leef6673d32013-08-23 15:34:17 -0700623 if (clearDialpad) {
624 mDialpadFragment.clearDialpad();
625 }
Andrew Lee2a58ab82014-05-15 02:16:04 -0700626 if (!mIsDialpadShown) {
627 return;
Yorke Leec3766332013-07-31 11:13:16 -0700628 }
Andrew Lee2a58ab82014-05-15 02:16:04 -0700629 mIsDialpadShown = false;
630 mDialpadFragment.setAnimate(animate);
631
Andrew Leedbe9a8c2014-05-16 15:18:40 -0700632 updateSearchFragmentPosition();
Andrew Lee2a58ab82014-05-15 02:16:04 -0700633 updateFloatingActionButton();
634 if (animate) {
635 Animation slideOut = AnimationUtils.loadAnimation(this, R.anim.slide_out);
Andrew Lee3c14bc32014-05-28 15:43:03 -0700636 slideOut.setAnimationListener(new AnimationListenerAdapter() {
Andrew Lee2a58ab82014-05-15 02:16:04 -0700637 @Override
638 public void onAnimationEnd(Animation animation) {
639 commitDialpadFragmentHide();
640 }
641 });
642 mDialpadFragment.getView().startAnimation(slideOut);
643 } else {
644 commitDialpadFragmentHide();
645 }
646
Yorke Lee5253be02014-05-21 18:50:03 -0700647 mActionBarController.onDialpadDown();
Yorke Lee11ca39e2014-05-19 20:31:37 -0700648
Andrew Leed4cde832014-05-16 15:56:48 -0700649 if (isInSearchUi()) {
Andrew Lee44e3daf2014-05-19 14:28:16 -0700650 if (TextUtils.isEmpty(mSearchQuery)) {
651 exitSearchUi();
Andrew Lee44e3daf2014-05-19 14:28:16 -0700652 }
Andrew Leed4cde832014-05-16 15:56:48 -0700653 }
Andrew Lee2a58ab82014-05-15 02:16:04 -0700654 }
655
656 /**
657 * Finishes hiding the dialpad fragment after any animations are completed.
658 */
659 private void commitDialpadFragmentHide() {
660 final FragmentTransaction ft = getFragmentManager().beginTransaction();
Yorke Leec3766332013-07-31 11:13:16 -0700661 ft.hide(mDialpadFragment);
662 ft.commit();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700663 }
664
Andrew Lee2a58ab82014-05-15 02:16:04 -0700665 private void updateSearchFragmentPosition() {
666 int translationValue = mIsDialpadShown ? -mActionBarHeight : 0;
667 SearchFragment fragment = null;
Andrew Leedbe9a8c2014-05-16 15:18:40 -0700668 if (mSmartDialSearchFragment != null && mSmartDialSearchFragment.isVisible()) {
Andrew Lee2a58ab82014-05-15 02:16:04 -0700669 fragment = mSmartDialSearchFragment;
Andrew Leedbe9a8c2014-05-16 15:18:40 -0700670 } else if (mRegularSearchFragment != null && mRegularSearchFragment.isVisible()) {
Andrew Lee2a58ab82014-05-15 02:16:04 -0700671 fragment = mRegularSearchFragment;
672 }
673 if (fragment != null && fragment.isVisible()) {
674 fragment.getView().animate().translationY(translationValue)
675 .setInterpolator(hideActionBarInterpolator).setDuration(ANIMATION_DURATION);
676 }
677 }
678
Yorke Lee5253be02014-05-21 18:50:03 -0700679 @Override
680 public boolean isInSearchUi() {
Yorke Leeb207f8a2013-08-29 18:51:06 -0700681 return mInDialpadSearch || mInRegularSearch;
682 }
683
Yorke Lee5253be02014-05-21 18:50:03 -0700684 @Override
685 public boolean hasSearchQuery() {
686 return !TextUtils.isEmpty(mSearchQuery);
687 }
688
689 @Override
690 public boolean shouldShowActionBar() {
691 return mListsFragment.shouldShowActionBar();
692 }
693
Yorke Leeb207f8a2013-08-29 18:51:06 -0700694 private void setNotInSearchUi() {
695 mInDialpadSearch = false;
696 mInRegularSearch = false;
697 }
698
Yorke Lee311969c2013-08-26 06:31:11 -0700699 private void hideDialpadAndSearchUi() {
Yorke Lee710709d2014-05-29 07:18:42 -0700700 if (mIsDialpadShown) {
701 hideDialpadFragment(false, true);
702 } else {
703 exitSearchUi();
704 }
Yorke Lee311969c2013-08-26 06:31:11 -0700705 }
706
Yorke Leee00c9fe2014-04-12 12:42:06 -0700707 private void hideInputMethod(View view) {
708 final InputMethodManager imm = (InputMethodManager) getSystemService(
709 Context.INPUT_METHOD_SERVICE);
710 if (imm != null && view != null) {
711 imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
712 }
713 }
714
Yorke Lee53a22302014-04-29 18:13:46 -0700715 private void prepareVoiceSearchButton() {
Yorke Lee53a22302014-04-29 18:13:46 -0700716 final Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
717 if (canIntentBeHandled(voiceIntent)) {
718 mVoiceSearchButton.setVisibility(View.VISIBLE);
719 mVoiceSearchButton.setOnClickListener(this);
720 } else {
721 mVoiceSearchButton.setVisibility(View.GONE);
722 }
723 }
724
Andrew Leee74a10e2014-05-16 14:31:40 -0700725 private OptionsPopupMenu buildOptionsMenu(View invoker) {
726 final OptionsPopupMenu popupMenu = new OptionsPopupMenu(this, invoker);
727 popupMenu.inflate(R.menu.dialtacts_options);
728 popupMenu.setOnMenuItemClickListener(this);
729 return popupMenu;
730 }
731
Yorke Lee86e21f72014-04-02 16:49:38 -0700732 @Override
733 public boolean onCreateOptionsMenu(Menu menu) {
Yorke Lee3c9e7cd2014-04-16 11:37:21 -0700734 if (mPendingSearchViewQuery != null) {
Yorke Lee53a22302014-04-29 18:13:46 -0700735 mSearchView.setText(mPendingSearchViewQuery);
Yorke Lee3c9e7cd2014-04-16 11:37:21 -0700736 mPendingSearchViewQuery = null;
737 }
Andrew Leee74a10e2014-05-16 14:31:40 -0700738 return false;
Ihab Awadfb00cb82014-03-18 16:19:00 -0700739 }
740
Chiao Cheng94b10b52012-08-17 16:59:12 -0700741 /**
742 * Returns true if the intent is due to hitting the green send key (hardware call button:
743 * KEYCODE_CALL) while in a call.
744 *
745 * @param intent the intent that launched this activity
Chiao Cheng94b10b52012-08-17 16:59:12 -0700746 * @return true if the intent is due to hitting the green send key while in a call
747 */
Yorke Lee62e995c2014-03-28 10:02:56 -0700748 private boolean isSendKeyWhileInCall(Intent intent) {
749 // If there is a call in progress and the user launched the dialer by hitting the call
750 // button, go straight to the in-call screen.
751 final boolean callKey = Intent.ACTION_CALL_BUTTON.equals(intent.getAction());
Chiao Cheng94b10b52012-08-17 16:59:12 -0700752
Yorke Lee62e995c2014-03-28 10:02:56 -0700753 try {
754 ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
755 if (callKey && phone != null && phone.showCallScreen()) {
756 return true;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700757 }
Yorke Lee62e995c2014-03-28 10:02:56 -0700758 } catch (RemoteException e) {
759 Log.e(TAG, "Failed to handle send while in call", e);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700760 }
761
762 return false;
763 }
764
765 /**
766 * Sets the current tab based on the intent's request type
767 *
768 * @param intent Intent that contains information about which tab should be selected
769 */
Yorke Leec3766332013-07-31 11:13:16 -0700770 private void displayFragment(Intent intent) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700771 // 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 -0700772 if (isSendKeyWhileInCall(intent)) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700773 finish();
774 return;
775 }
776
Yorke Lee669b6082013-09-17 15:43:38 -0700777 if (mDialpadFragment != null) {
778 final boolean phoneIsInUse = phoneIsInUse();
779 if (phoneIsInUse || isDialIntent(intent)) {
780 mDialpadFragment.setStartedFromNewIntent(true);
781 if (phoneIsInUse && !mDialpadFragment.isVisible()) {
782 mInCallDialpadUp = true;
783 }
784 showDialpadFragment(false);
Yorke Lee35127cd2013-09-10 14:09:29 -0700785 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700786 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700787 }
788
789 @Override
790 public void onNewIntent(Intent newIntent) {
791 setIntent(newIntent);
Yorke Leec3766332013-07-31 11:13:16 -0700792 displayFragment(newIntent);
Yorke Leec3766332013-07-31 11:13:16 -0700793
Chiao Cheng94b10b52012-08-17 16:59:12 -0700794 invalidateOptionsMenu();
795 }
796
797 /** Returns true if the given intent contains a phone number to populate the dialer with */
798 private boolean isDialIntent(Intent intent) {
799 final String action = intent.getAction();
800 if (Intent.ACTION_DIAL.equals(action) || ACTION_TOUCH_DIALER.equals(action)) {
801 return true;
802 }
803 if (Intent.ACTION_VIEW.equals(action)) {
804 final Uri data = intent.getData();
Chiao Cheng9d4f3b22012-09-05 16:00:16 -0700805 if (data != null && CallUtil.SCHEME_TEL.equals(data.getScheme())) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700806 return true;
807 }
808 }
809 return false;
810 }
811
812 /**
813 * Returns an appropriate call origin for this Activity. May return null when no call origin
814 * should be used (e.g. when some 3rd party application launched the screen. Call origin is
815 * for remembering the tab in which the user made a phone call, so the external app's DIAL
816 * request should not be counted.)
817 */
818 public String getCallOrigin() {
819 return !isDialIntent(getIntent()) ? CALL_ORIGIN_DIALTACTS : null;
820 }
821
Chiao Cheng94b10b52012-08-17 16:59:12 -0700822 /**
Yorke Leec3766332013-07-31 11:13:16 -0700823 * Shows the search fragment
Chiao Cheng94b10b52012-08-17 16:59:12 -0700824 */
Yorke Leeef2b7382013-08-09 17:39:25 -0700825 private void enterSearchUi(boolean smartDialSearch, String query) {
Andrew Lee90374a72014-05-16 15:01:09 -0700826 if (getFragmentManager().isDestroyed()) {
Yorke Lee34bdf872013-08-15 14:11:50 -0700827 // Weird race condition where fragment is doing work after the activity is destroyed
828 // due to talkback being on (b/10209937). Just return since we can't do any
829 // constructive here.
830 return;
831 }
832
Yorke Leeef2b7382013-08-09 17:39:25 -0700833 if (DEBUG) {
834 Log.d(TAG, "Entering search UI - smart dial " + smartDialSearch);
835 }
Yorke Leeef2b7382013-08-09 17:39:25 -0700836
Yorke Leec3766332013-07-31 11:13:16 -0700837 final FragmentTransaction transaction = getFragmentManager().beginTransaction();
Yorke Leee00c9fe2014-04-12 12:42:06 -0700838 if (mInDialpadSearch && mSmartDialSearchFragment != null) {
Yorke Leeb207f8a2013-08-29 18:51:06 -0700839 transaction.remove(mSmartDialSearchFragment);
Yorke Leee00c9fe2014-04-12 12:42:06 -0700840 } else if (mInRegularSearch && mRegularSearchFragment != null) {
Yorke Leeb207f8a2013-08-29 18:51:06 -0700841 transaction.remove(mRegularSearchFragment);
Yorke Leeb207f8a2013-08-29 18:51:06 -0700842 }
Yorke Leeef2b7382013-08-09 17:39:25 -0700843
Yorke Leeb207f8a2013-08-29 18:51:06 -0700844 final String tag;
845 if (smartDialSearch) {
846 tag = TAG_SMARTDIAL_SEARCH_FRAGMENT;
847 } else {
848 tag = TAG_REGULAR_SEARCH_FRAGMENT;
849 }
850 mInDialpadSearch = smartDialSearch;
851 mInRegularSearch = !smartDialSearch;
852
Andrew Lee752956e2014-05-15 11:43:38 -0700853 SearchFragment fragment = (SearchFragment) getFragmentManager().findFragmentByTag(tag);
Andrew Leeb1903842014-05-15 16:11:24 -0700854 transaction.setCustomAnimations(android.R.animator.fade_in, 0);
Yorke Leeef2b7382013-08-09 17:39:25 -0700855 if (fragment == null) {
856 if (smartDialSearch) {
857 fragment = new SmartDialSearchFragment();
858 } else {
Jay Shrauner2e5b34b2013-08-29 10:52:40 -0700859 fragment = new RegularSearchFragment();
Yorke Leeef2b7382013-08-09 17:39:25 -0700860 }
Andrew Leeb1903842014-05-15 16:11:24 -0700861 transaction.add(R.id.dialtacts_frame, fragment, tag);
862 } else {
863 transaction.show(fragment);
Yorke Leeef2b7382013-08-09 17:39:25 -0700864 }
Andrew Leeb1903842014-05-15 16:11:24 -0700865
Yorke Lee86e21f72014-04-02 16:49:38 -0700866 // DialtactsActivity will provide the options menu
867 fragment.setHasOptionsMenu(false);
Andrew Leeb1903842014-05-15 16:11:24 -0700868 fragment.setShowEmptyListForNullQuery(true);
Andrew Lee99a570c2014-05-15 14:18:50 -0700869 fragment.setQueryString(query, false /* delaySelection */);
Yorke Leeef2b7382013-08-09 17:39:25 -0700870 transaction.commit();
Andrew Leeb1903842014-05-15 16:11:24 -0700871
872 mListsFragment.getView().animate().alpha(0).withLayer();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700873 }
874
875 /**
Yorke Leec3766332013-07-31 11:13:16 -0700876 * Hides the search fragment
Chiao Cheng94b10b52012-08-17 16:59:12 -0700877 */
Yorke Leec3766332013-07-31 11:13:16 -0700878 private void exitSearchUi() {
Yorke Lee3487db72013-09-26 17:12:06 -0700879 // See related bug in enterSearchUI();
880 if (getFragmentManager().isDestroyed()) {
881 return;
882 }
Andrew Leeb1903842014-05-15 16:11:24 -0700883
Andrew Leeb1903842014-05-15 16:11:24 -0700884 mSearchView.setText(null);
885 mDialpadFragment.clearDialpad();
Yorke Leeb207f8a2013-08-29 18:51:06 -0700886 setNotInSearchUi();
Yorke Lee7eccf452014-03-14 12:52:42 -0700887
Andrew Leeb1903842014-05-15 16:11:24 -0700888 final FragmentTransaction transaction = getFragmentManager().beginTransaction();
Andrew Leeb1903842014-05-15 16:11:24 -0700889 if (mSmartDialSearchFragment != null) {
890 transaction.remove(mSmartDialSearchFragment);
Yorke Lee7eccf452014-03-14 12:52:42 -0700891 }
Andrew Leeb1903842014-05-15 16:11:24 -0700892 if (mRegularSearchFragment != null) {
893 transaction.remove(mRegularSearchFragment);
894 }
895 transaction.commit();
896
897 mListsFragment.getView().animate().alpha(1).withLayer();
Yorke Lee5253be02014-05-21 18:50:03 -0700898 mActionBarController.onSearchUiExited();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700899 }
900
901 /** Returns an Intent to launch Call Settings screen */
902 public static Intent getCallSettingsIntent() {
903 final Intent intent = new Intent(Intent.ACTION_MAIN);
904 intent.setClassName(PHONE_PACKAGE, CALL_SETTINGS_CLASS_NAME);
905 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
906 return intent;
907 }
908
909 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700910 public void onBackPressed() {
Andrew Lee2a58ab82014-05-15 02:16:04 -0700911 if (mIsDialpadShown) {
Andrew Leeb1903842014-05-15 16:11:24 -0700912 if (TextUtils.isEmpty(mSearchQuery)) {
913 exitSearchUi();
914 }
Yorke Leef6673d32013-08-23 15:34:17 -0700915 hideDialpadFragment(true, false);
Andrew Leeb1903842014-05-15 16:11:24 -0700916 } else if (isInSearchUi()) {
Andrew Lee99a570c2014-05-15 14:18:50 -0700917 exitSearchUi();
Yorke Lee11ca39e2014-05-19 20:31:37 -0700918 hideInputMethod(parentLayout);
Yorke Leec3766332013-07-31 11:13:16 -0700919 } else {
920 super.onBackPressed();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700921 }
Yorke Leec3766332013-07-31 11:13:16 -0700922 }
923
Yorke Leec7b2a0e2014-05-20 17:21:25 -0700924 /**
925 * @return True if the search UI was exited, false otherwise
926 */
927 private boolean maybeExitSearchUi() {
928 if (isInSearchUi() && TextUtils.isEmpty(mSearchQuery)) {
929 exitSearchUi();
930 hideInputMethod(parentLayout);
931 return true;
932 }
933 return false;
934 }
935
Yorke Leec3766332013-07-31 11:13:16 -0700936 @Override
937 public void onDialpadQueryChanged(String query) {
Yorke Lee46635872014-04-11 11:20:15 -0700938 if (mSmartDialSearchFragment != null) {
939 mSmartDialSearchFragment.setAddToContactNumber(query);
940 }
Yorke Leec3766332013-07-31 11:13:16 -0700941 final String normalizedQuery = SmartDialNameMatcher.normalizeNumber(query,
942 SmartDialNameMatcher.LATIN_SMART_DIAL_MAP);
Yorke Lee53a22302014-04-29 18:13:46 -0700943
944 if (!TextUtils.equals(mSearchView.getText(), normalizedQuery)) {
Yorke Leeef2b7382013-08-09 17:39:25 -0700945 if (DEBUG) {
946 Log.d(TAG, "onDialpadQueryChanged - new query: " + query);
947 }
948 if (mDialpadFragment == null || !mDialpadFragment.isVisible()) {
949 // This callback can happen if the dialpad fragment is recreated because of
950 // activity destruction. In that case, don't update the search view because
951 // that would bring the user back to the search fragment regardless of the
952 // previous state of the application. Instead, just return here and let the
953 // fragment manager correctly figure out whatever fragment was last displayed.
Yorke Lee53a22302014-04-29 18:13:46 -0700954 if (!TextUtils.isEmpty(normalizedQuery)) {
955 mPendingSearchViewQuery = normalizedQuery;
956 }
Yorke Leeef2b7382013-08-09 17:39:25 -0700957 return;
958 }
Yorke Lee53a22302014-04-29 18:13:46 -0700959 mSearchView.setText(normalizedQuery);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700960 }
961 }
Yorke Leec3766332013-07-31 11:13:16 -0700962
963 @Override
964 public void onListFragmentScrollStateChange(int scrollState) {
965 if (scrollState == OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
Yorke Leef6673d32013-08-23 15:34:17 -0700966 hideDialpadFragment(true, false);
Yorke Leec3766332013-07-31 11:13:16 -0700967 hideInputMethod(getCurrentFocus());
968 }
969 }
970
971 @Override
Yorke Lee86e21f72014-04-02 16:49:38 -0700972 public void onListFragmentScroll(int firstVisibleItem, int visibleItemCount,
Andrew Lee99a570c2014-05-15 14:18:50 -0700973 int totalItemCount) {
Yorke Leee00c9fe2014-04-12 12:42:06 -0700974 // TODO: No-op for now. This should eventually show/hide the actionBar based on
975 // interactions with the ListsFragments.
Yorke Lee86e21f72014-04-02 16:49:38 -0700976 }
977
Yorke Lee86e21f72014-04-02 16:49:38 -0700978 @Override
Andrew Leea73e1892014-05-13 13:21:16 -0700979 public void setFloatingActionButtonVisible(boolean visible) {
980 mFloatingActionButtonContainer.setVisibility(visible ? View.VISIBLE : View.GONE);
Yorke Leec3766332013-07-31 11:13:16 -0700981 }
982
983 private boolean phoneIsInUse() {
984 final TelephonyManager tm = (TelephonyManager) getSystemService(
985 Context.TELEPHONY_SERVICE);
986 return tm.getCallState() != TelephonyManager.CALL_STATE_IDLE;
987 }
Yorke Lee8dd62002013-08-08 15:57:20 -0700988
Yorke Leee1424812013-09-04 18:24:48 -0700989 public static Intent getAddNumberToContactIntent(CharSequence text) {
990 final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
991 intent.putExtra(Intents.Insert.PHONE, text);
992 intent.setType(Contacts.CONTENT_ITEM_TYPE);
993 return intent;
994 }
995
Yorke Leeda0f9042013-12-05 14:25:51 -0800996 private boolean canIntentBeHandled(Intent intent) {
997 final PackageManager packageManager = getPackageManager();
998 final List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(intent,
999 PackageManager.MATCH_DEFAULT_ONLY);
1000 return resolveInfo != null && resolveInfo.size() > 0;
1001 }
Yorke Lee3cefcc62014-01-16 11:26:46 -08001002
Yorke Lee6a1461a2014-04-21 16:27:14 -07001003 @Override
1004 public void showCallHistory() {
1005 // Use explicit CallLogActivity intent instead of ACTION_VIEW +
1006 // CONTENT_TYPE, so that we always open our call log from our dialer
1007 final Intent intent = new Intent(this, CallLogActivity.class);
1008 startActivity(intent);
1009 }
1010
Yorke Lee86e21f72014-04-02 16:49:38 -07001011 /**
1012 * Called when the user has long-pressed a contact tile to start a drag operation.
1013 */
Yorke Lee3cefcc62014-01-16 11:26:46 -08001014 @Override
Yorke Leeefb2d9c2014-04-18 14:05:01 -07001015 public void onDragStarted(int x, int y, PhoneFavoriteSquareTileView view) {
Yorke Lee5253be02014-05-21 18:50:03 -07001016 mActionBarController.slideActionBarUp(true);
Yorke Lee28266192014-05-01 10:05:52 -07001017 mRemoveViewContainer.setVisibility(View.VISIBLE);
Yorke Lee3cefcc62014-01-16 11:26:46 -08001018 }
1019
1020 @Override
Yorke Lee28266192014-05-01 10:05:52 -07001021 public void onDragHovered(int x, int y, PhoneFavoriteSquareTileView view) {
1022 }
Yorke Lee3cefcc62014-01-16 11:26:46 -08001023
Yorke Lee86e21f72014-04-02 16:49:38 -07001024 /**
1025 * Called when the user has released a contact tile after long-pressing it.
1026 */
Yorke Lee3cefcc62014-01-16 11:26:46 -08001027 @Override
1028 public void onDragFinished(int x, int y) {
Yorke Lee5253be02014-05-21 18:50:03 -07001029 mActionBarController.slideActionBarDown(true);
Yorke Lee28266192014-05-01 10:05:52 -07001030 mRemoveViewContainer.setVisibility(View.GONE);
Yorke Lee3cefcc62014-01-16 11:26:46 -08001031 }
1032
1033 @Override
1034 public void onDroppedOnRemove() {}
1035
1036 /**
Yorke Leed999b712014-04-23 15:10:58 -07001037 * Allows the SpeedDialFragment to attach the drag controller to mRemoveViewContainer
Yorke Lee3cefcc62014-01-16 11:26:46 -08001038 * once it has been attached to the activity.
1039 */
1040 @Override
1041 public void setDragDropController(DragDropController dragController) {
Yorke Lee28266192014-05-01 10:05:52 -07001042 mDragDropController = dragController;
1043 ((RemoveView) findViewById(R.id.remove_view))
1044 .setDragDropController(dragController);
Yorke Lee3cefcc62014-01-16 11:26:46 -08001045 }
Yorke Leee00c9fe2014-04-12 12:42:06 -07001046
1047 @Override
1048 public void onPickPhoneNumberAction(Uri dataUri) {
Yorke Lee4e28c1d2014-05-13 15:38:10 -07001049 // Specify call-origin so that users will see the previous tab instead of
1050 // CallLog screen (search UI will be automatically exited).
1051 PhoneNumberInteraction.startInteractionForPhoneCall(
Andrew Lee99a570c2014-05-15 14:18:50 -07001052 DialtactsActivity.this, dataUri, getCallOrigin());
Yorke Lee4e28c1d2014-05-13 15:38:10 -07001053 mClearSearchOnPause = true;
Yorke Leee00c9fe2014-04-12 12:42:06 -07001054 }
1055
1056 @Override
1057 public void onCallNumberDirectly(String phoneNumber) {
Yorke Lee4e28c1d2014-05-13 15:38:10 -07001058 Intent intent = CallUtil.getCallIntent(phoneNumber, getCallOrigin());
1059 startActivity(intent);
1060 mClearSearchOnPause = true;
Yorke Leee00c9fe2014-04-12 12:42:06 -07001061 }
1062
1063 @Override
1064 public void onShortcutIntentCreated(Intent intent) {
Yorke Lee4e28c1d2014-05-13 15:38:10 -07001065 Log.w(TAG, "Unsupported intent has come (" + intent + "). Ignoring.");
Yorke Leee00c9fe2014-04-12 12:42:06 -07001066 }
1067
1068 @Override
1069 public void onHomeInActionBarSelected() {
Yorke Lee4e28c1d2014-05-13 15:38:10 -07001070 exitSearchUi();
Yorke Leee00c9fe2014-04-12 12:42:06 -07001071 }
Yorke Lee33932ff2014-04-16 13:34:32 -07001072
Yorke Leecc4660d2014-04-24 11:22:57 -07001073 @Override
1074 public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
1075
1076 }
1077
1078 @Override
1079 public void onPageSelected(int position) {
1080 mCurrentTabPosition = position;
Yorke Leec61d4542014-05-01 10:43:24 -07001081 // If the dialpad is showing, the floating action button should always be middle aligned.
Andrew Lee2a58ab82014-05-15 02:16:04 -07001082 if (!mIsDialpadShown) {
Yorke Leec61d4542014-05-01 10:43:24 -07001083 alignFloatingActionButtonByTab(mCurrentTabPosition);
1084 }
Yorke Leecc4660d2014-04-24 11:22:57 -07001085 }
1086
1087 @Override
1088 public void onPageScrollStateChanged(int state) {
1089 }
1090
Andrew Lee2a58ab82014-05-15 02:16:04 -07001091 private void updateFloatingActionButton() {
1092 if (mIsDialpadShown) {
1093 mFloatingActionButton.setImageResource(R.drawable.fab_ic_call);
1094 mFloatingActionButton.setContentDescription(
1095 getResources().getString(R.string.description_dial_button));
Andrew Leec4643f72014-05-15 11:27:39 -07001096 alignFloatingActionButtonMiddle();
Andrew Lee2a58ab82014-05-15 02:16:04 -07001097 } else {
1098 mFloatingActionButton.setImageResource(R.drawable.fab_ic_dial);
1099 mFloatingActionButton.setContentDescription(
1100 getResources().getString(R.string.action_menu_dialpad_button));
Andrew Leec4643f72014-05-15 11:27:39 -07001101 alignFloatingActionButtonByTab(mCurrentTabPosition);
Andrew Lee2a58ab82014-05-15 02:16:04 -07001102 }
1103 }
1104
Yorke Leecc4660d2014-04-24 11:22:57 -07001105 private void alignFloatingActionButtonByTab(int position) {
1106 if (position == ListsFragment.TAB_INDEX_SPEED_DIAL) {
1107 alignFloatingActionButtonMiddle();
1108 } else {
1109 alignFloatingActionButtonRight();
1110 }
1111 }
1112
1113 private void alignFloatingActionButtonRight() {
1114 final RelativeLayout.LayoutParams params =
Andrew Leea73e1892014-05-13 13:21:16 -07001115 (RelativeLayout.LayoutParams) mFloatingActionButtonContainer.getLayoutParams();
Yorke Leecc4660d2014-04-24 11:22:57 -07001116 params.removeRule(RelativeLayout.CENTER_HORIZONTAL);
1117 params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
Andrew Lee2423a2f2014-05-29 14:14:45 -07001118 updateFloatingActionButtonMargin(params);
Andrew Leea73e1892014-05-13 13:21:16 -07001119 mFloatingActionButtonContainer.setLayoutParams(params);
Yorke Leecc4660d2014-04-24 11:22:57 -07001120 }
1121
1122 private void alignFloatingActionButtonMiddle() {
1123 final RelativeLayout.LayoutParams params =
Andrew Leea73e1892014-05-13 13:21:16 -07001124 (RelativeLayout.LayoutParams) mFloatingActionButtonContainer.getLayoutParams();
Yorke Leecc4660d2014-04-24 11:22:57 -07001125 params.removeRule(RelativeLayout.ALIGN_PARENT_RIGHT);
1126 params.addRule(RelativeLayout.CENTER_HORIZONTAL);
Andrew Lee2423a2f2014-05-29 14:14:45 -07001127 updateFloatingActionButtonMargin(params);
Andrew Leea73e1892014-05-13 13:21:16 -07001128 mFloatingActionButtonContainer.setLayoutParams(params);
Yorke Leecc4660d2014-04-24 11:22:57 -07001129 }
Andrew Lee2a58ab82014-05-15 02:16:04 -07001130
Andrew Lee2423a2f2014-05-29 14:14:45 -07001131 private void updateFloatingActionButtonMargin(RelativeLayout.LayoutParams params) {
1132 params.setMarginsRelative(
1133 params.getMarginStart(),
1134 params.topMargin,
1135 params.getMarginEnd(),
1136 mIsDialpadShown ?
1137 mFloatingActionButtonDialpadMarginBottom :
1138 mFloatingActionButtonMarginBottom);
1139 }
1140
Yorke Lee5253be02014-05-21 18:50:03 -07001141 @Override
1142 public boolean isActionBarShowing() {
1143 return mActionBarController.isActionBarShowing();
1144 }
1145
1146 @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}