Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 1 | /* |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 2 | * Copyright (C) 2013 The Android Open Source Project |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.dialer; |
| 18 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 19 | import android.animation.Animator; |
| 20 | import android.animation.Animator.AnimatorListener; |
| 21 | import android.animation.AnimatorListenerAdapter; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 22 | import android.app.Activity; |
Christine Chen | 9c1e065 | 2013-05-23 15:40:19 -0700 | [diff] [blame] | 23 | import android.app.backup.BackupManager; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 24 | import android.app.Fragment; |
| 25 | import android.app.FragmentManager; |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 26 | import android.app.FragmentManager.BackStackEntry; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 27 | import android.app.FragmentTransaction; |
Chiao Cheng | 073b5cf | 2012-12-07 11:36:00 -0800 | [diff] [blame] | 28 | import android.content.ActivityNotFoundException; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 29 | import android.content.Context; |
| 30 | import android.content.Intent; |
| 31 | import android.content.SharedPreferences; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 32 | import android.content.res.Resources; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 33 | import android.net.Uri; |
| 34 | import android.os.Bundle; |
| 35 | import android.os.RemoteException; |
| 36 | import android.os.ServiceManager; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 37 | import android.provider.CallLog.Calls; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 38 | import android.provider.ContactsContract; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 39 | import android.provider.ContactsContract.Contacts; |
Yorke Lee | e142481 | 2013-09-04 18:24:48 -0700 | [diff] [blame] | 40 | import android.provider.ContactsContract.Intents; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 41 | import android.provider.ContactsContract.Intents.UI; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 42 | import android.provider.Settings; |
| 43 | import android.speech.RecognizerIntent; |
| 44 | import android.support.v4.app.NavUtils; |
| 45 | import android.telephony.TelephonyManager; |
| 46 | import android.text.Editable; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 47 | import android.text.TextUtils; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 48 | import android.text.TextWatcher; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 49 | import android.util.Log; |
| 50 | import android.view.Menu; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 51 | import android.view.MenuItem; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 52 | import android.view.View; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 53 | import android.view.View.OnFocusChangeListener; |
| 54 | import android.view.ViewConfiguration; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 55 | import android.view.inputmethod.InputMethodManager; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 56 | import android.widget.AbsListView.OnScrollListener; |
| 57 | import android.widget.EditText; |
| 58 | import android.widget.ImageView; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 59 | import android.widget.PopupMenu; |
| 60 | import android.widget.SearchView; |
| 61 | import android.widget.SearchView.OnCloseListener; |
| 62 | import android.widget.SearchView.OnQueryTextListener; |
Chiao Cheng | 073b5cf | 2012-12-07 11:36:00 -0800 | [diff] [blame] | 63 | import android.widget.Toast; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 64 | |
Chiao Cheng | 9d4f3b2 | 2012-09-05 16:00:16 -0700 | [diff] [blame] | 65 | import com.android.contacts.common.CallUtil; |
Chiao Cheng | 603ff68 | 2012-10-24 15:18:40 -0700 | [diff] [blame] | 66 | import com.android.contacts.common.activity.TransactionSafeActivity; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 67 | import com.android.contacts.common.dialog.ClearFrequentsDialog; |
| 68 | import com.android.contacts.common.interactions.ImportExportDialogFragment; |
Chiao Cheng | 1429f1a | 2012-11-01 16:35:28 -0700 | [diff] [blame] | 69 | import com.android.contacts.common.list.ContactListItemView; |
Chiao Cheng | 8efbcf9 | 2012-12-04 17:43:02 -0800 | [diff] [blame] | 70 | import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; |
| 71 | import com.android.contacts.common.list.PhoneNumberPickerFragment; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 72 | import com.android.dialer.calllog.CallLogActivity; |
Yorke Lee | fce269a | 2013-08-12 11:56:04 -0700 | [diff] [blame] | 73 | import com.android.dialer.database.DialerDatabaseHelper; |
Yorke Lee | f74011e | 2013-08-02 11:30:30 -0700 | [diff] [blame] | 74 | import com.android.dialer.dialpad.DialpadFragment; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 75 | import com.android.dialer.dialpad.SmartDialNameMatcher; |
Yorke Lee | fce269a | 2013-08-12 11:56:04 -0700 | [diff] [blame] | 76 | import com.android.dialer.dialpad.SmartDialPrefix; |
Chiao Cheng | 1429f1a | 2012-11-01 16:35:28 -0700 | [diff] [blame] | 77 | import com.android.dialer.interactions.PhoneNumberInteraction; |
Yorke Lee | 8dd6200 | 2013-08-08 15:57:20 -0700 | [diff] [blame] | 78 | import com.android.dialer.list.AllContactsActivity; |
Yorke Lee | 8898cd0 | 2013-08-08 10:24:27 -0700 | [diff] [blame] | 79 | import com.android.dialer.list.PhoneFavoriteFragment; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 80 | import com.android.dialer.list.OnListFragmentScrolledListener; |
Jay Shrauner | 2e5b34b | 2013-08-29 10:52:40 -0700 | [diff] [blame] | 81 | import com.android.dialer.list.RegularSearchFragment; |
| 82 | import com.android.dialer.list.SearchFragment; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 83 | import com.android.dialer.list.SmartDialSearchFragment; |
Yorke Lee | 0baa98b | 2013-08-22 10:55:16 -0700 | [diff] [blame] | 84 | import com.android.dialerbind.DatabaseHelperManager; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 85 | import com.android.internal.telephony.ITelephony; |
| 86 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 87 | import java.util.ArrayList; |
| 88 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 89 | /** |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 90 | * The dialer tab's title is 'phone', a more common name (see strings.xml). |
| 91 | */ |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 92 | public class DialtactsActivity extends TransactionSafeActivity implements View.OnClickListener, |
Yorke Lee | f74011e | 2013-08-02 11:30:30 -0700 | [diff] [blame] | 93 | DialpadFragment.OnDialpadQueryChangedListener, PopupMenu.OnMenuItemClickListener, |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 94 | OnListFragmentScrolledListener, |
Yorke Lee | 8dd6200 | 2013-08-08 15:57:20 -0700 | [diff] [blame] | 95 | DialpadFragment.OnDialpadFragmentStartedListener, |
| 96 | PhoneFavoriteFragment.OnShowAllContactsListener { |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 97 | private static final String TAG = "DialtactsActivity"; |
| 98 | |
| 99 | public static final boolean DEBUG = false; |
| 100 | |
Yorke Lee | f74011e | 2013-08-02 11:30:30 -0700 | [diff] [blame] | 101 | public static final String SHARED_PREFS_NAME = "com.android.dialer_preferences"; |
| 102 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 103 | /** Used to open Call Setting */ |
| 104 | private static final String PHONE_PACKAGE = "com.android.phone"; |
| 105 | private static final String CALL_SETTINGS_CLASS_NAME = |
| 106 | "com.android.phone.CallFeaturesSetting"; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 107 | /** @see #getCallOrigin() */ |
| 108 | private static final String CALL_ORIGIN_DIALTACTS = |
| 109 | "com.android.dialer.DialtactsActivity"; |
| 110 | |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 111 | private static final String KEY_IN_REGULAR_SEARCH_UI = "in_regular_search_ui"; |
| 112 | private static final String KEY_IN_DIALPAD_SEARCH_UI = "in_dialpad_search_ui"; |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 113 | private static final String KEY_SEARCH_QUERY = "search_query"; |
| 114 | private static final String KEY_FIRST_LAUNCH = "first_launch"; |
| 115 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 116 | private static final String TAG_DIALPAD_FRAGMENT = "dialpad"; |
| 117 | private static final String TAG_REGULAR_SEARCH_FRAGMENT = "search"; |
| 118 | private static final String TAG_SMARTDIAL_SEARCH_FRAGMENT = "smartdial"; |
| 119 | private static final String TAG_FAVORITES_FRAGMENT = "favorites"; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 120 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 121 | /** |
| 122 | * Just for backward compatibility. Should behave as same as {@link Intent#ACTION_DIAL}. |
| 123 | */ |
| 124 | private static final String ACTION_TOUCH_DIALER = "com.android.phone.action.TOUCH_DIALER"; |
| 125 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 126 | private static final int SUBACTIVITY_ACCOUNT_FILTER = 1; |
| 127 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 128 | private static final int ACTIVITY_REQUEST_CODE_VOICE_SEARCH = 1; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 129 | |
| 130 | private String mFilterText; |
| 131 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 132 | /** |
| 133 | * The main fragment displaying the user's favorites and frequent contacts |
| 134 | */ |
Yorke Lee | 8898cd0 | 2013-08-08 10:24:27 -0700 | [diff] [blame] | 135 | private PhoneFavoriteFragment mPhoneFavoriteFragment; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 136 | |
| 137 | /** |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 138 | * Fragment containing the dialpad that slides into view |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 139 | */ |
Yorke Lee | f74011e | 2013-08-02 11:30:30 -0700 | [diff] [blame] | 140 | private DialpadFragment mDialpadFragment; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 141 | |
| 142 | /** |
| 143 | * Fragment for searching phone numbers using the alphanumeric keyboard. |
| 144 | */ |
Jay Shrauner | 2e5b34b | 2013-08-29 10:52:40 -0700 | [diff] [blame] | 145 | private RegularSearchFragment mRegularSearchFragment; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 146 | |
| 147 | /** |
| 148 | * Fragment for searching phone numbers using the dialpad. |
| 149 | */ |
| 150 | private SmartDialSearchFragment mSmartDialSearchFragment; |
| 151 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 152 | private View mMenuButton; |
| 153 | private View mCallHistoryButton; |
| 154 | private View mDialpadButton; |
| 155 | |
| 156 | // Padding view used to shift the fragments up when the dialpad is shown. |
| 157 | private View mBottomPaddingView; |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 158 | private View mFragmentsFrame; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 159 | |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 160 | private boolean mInDialpadSearch; |
| 161 | private boolean mInRegularSearch; |
| 162 | |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 163 | /** |
| 164 | * True when this activity has been launched for the first time. |
| 165 | */ |
Yorke Lee | 98702de | 2013-08-06 12:03:32 -0700 | [diff] [blame] | 166 | private boolean mFirstLaunch; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 167 | private View mSearchViewContainer; |
| 168 | private View mSearchViewCloseButton; |
| 169 | private View mVoiceSearchButton; |
| 170 | private EditText mSearchView; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 171 | |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 172 | private String mSearchQuery; |
| 173 | |
Yorke Lee | fce269a | 2013-08-12 11:56:04 -0700 | [diff] [blame] | 174 | private DialerDatabaseHelper mDialerDatabaseHelper; |
| 175 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 176 | /** |
| 177 | * Listener used when one of phone numbers in search UI is selected. This will initiate a |
| 178 | * phone call using the phone number. |
| 179 | */ |
| 180 | private final OnPhoneNumberPickerActionListener mPhoneNumberPickerActionListener = |
| 181 | new OnPhoneNumberPickerActionListener() { |
| 182 | @Override |
| 183 | public void onPickPhoneNumberAction(Uri dataUri) { |
| 184 | // Specify call-origin so that users will see the previous tab instead of |
| 185 | // CallLog screen (search UI will be automatically exited). |
| 186 | PhoneNumberInteraction.startInteractionForPhoneCall( |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 187 | DialtactsActivity.this, dataUri, getCallOrigin()); |
Yorke Lee | f6673d3 | 2013-08-23 15:34:17 -0700 | [diff] [blame] | 188 | hideDialpadAndSearchUi(); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | @Override |
Jay Shrauner | 31a760b | 2013-07-26 09:34:49 -0700 | [diff] [blame] | 192 | public void onCallNumberDirectly(String phoneNumber) { |
| 193 | Intent intent = CallUtil.getCallIntent(phoneNumber, getCallOrigin()); |
| 194 | startActivity(intent); |
Yorke Lee | f6673d3 | 2013-08-23 15:34:17 -0700 | [diff] [blame] | 195 | hideDialpadAndSearchUi(); |
Jay Shrauner | 31a760b | 2013-07-26 09:34:49 -0700 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | @Override |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 199 | public void onShortcutIntentCreated(Intent intent) { |
| 200 | Log.w(TAG, "Unsupported intent has come (" + intent + "). Ignoring."); |
| 201 | } |
| 202 | |
| 203 | @Override |
| 204 | public void onHomeInActionBarSelected() { |
| 205 | exitSearchUi(); |
| 206 | } |
| 207 | }; |
| 208 | |
| 209 | /** |
| 210 | * Listener used to send search queries to the phone search fragment. |
| 211 | */ |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 212 | private final TextWatcher mPhoneSearchQueryTextListener = new TextWatcher() { |
| 213 | @Override |
| 214 | public void beforeTextChanged(CharSequence s, int start, int count, int after) { |
| 215 | } |
| 216 | |
| 217 | @Override |
| 218 | public void onTextChanged(CharSequence s, int start, int before, int count) { |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 219 | final String newText = s.toString(); |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 220 | if (newText.equals(mSearchQuery)) { |
| 221 | // If the query hasn't changed (perhaps due to activity being destroyed |
| 222 | // and restored, or user launching the same DIAL intent twice), then there is |
| 223 | // no need to do anything here. |
| 224 | return; |
| 225 | } |
| 226 | mSearchQuery = newText; |
| 227 | if (DEBUG) { |
| 228 | Log.d(TAG, "onTextChange for mSearchView called with new query: " + s); |
| 229 | } |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 230 | final boolean dialpadSearch = isDialpadShowing(); |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 231 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 232 | // Show search result with non-empty text. Show a bare list otherwise. |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 233 | if (TextUtils.isEmpty(newText) && getInSearchUi()) { |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 234 | exitSearchUi(); |
| 235 | mSearchViewCloseButton.setVisibility(View.GONE); |
Yorke Lee | 3b82fc1 | 2013-09-09 08:42:38 -0700 | [diff] [blame^] | 236 | mVoiceSearchButton.setVisibility(View.VISIBLE); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 237 | return; |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 238 | } else if (!TextUtils.isEmpty(newText)) { |
| 239 | final boolean sameSearchMode = (dialpadSearch && mInDialpadSearch) || |
| 240 | (!dialpadSearch && mInRegularSearch); |
| 241 | if (!sameSearchMode) { |
| 242 | // call enterSearchUi only if we are switching search modes, or entering |
| 243 | // search ui for the first time |
| 244 | enterSearchUi(dialpadSearch, newText); |
| 245 | } |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 246 | |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 247 | if (dialpadSearch && mSmartDialSearchFragment != null) { |
| 248 | mSmartDialSearchFragment.setQueryString(newText, false); |
| 249 | } else if (mRegularSearchFragment != null) { |
| 250 | mRegularSearchFragment.setQueryString(newText, false); |
| 251 | } |
| 252 | mSearchViewCloseButton.setVisibility(View.VISIBLE); |
Yorke Lee | 3b82fc1 | 2013-09-09 08:42:38 -0700 | [diff] [blame^] | 253 | mVoiceSearchButton.setVisibility(View.GONE); |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 254 | return; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 255 | } |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | @Override |
| 259 | public void afterTextChanged(Editable s) { |
| 260 | } |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 261 | }; |
| 262 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 263 | private boolean isDialpadShowing() { |
| 264 | return mDialpadFragment != null && mDialpadFragment.isVisible(); |
| 265 | } |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 266 | |
| 267 | @Override |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 268 | protected void onCreate(Bundle savedInstanceState) { |
| 269 | super.onCreate(savedInstanceState); |
Yorke Lee | 98702de | 2013-08-06 12:03:32 -0700 | [diff] [blame] | 270 | mFirstLaunch = true; |
| 271 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 272 | final Intent intent = getIntent(); |
| 273 | fixIntent(intent); |
| 274 | |
Yorke Lee | 8898cd0 | 2013-08-08 10:24:27 -0700 | [diff] [blame] | 275 | setContentView(R.layout.dialtacts_activity); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 276 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 277 | getActionBar().hide(); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 278 | |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 279 | // Add the favorites fragment, and the dialpad fragment, but only if savedInstanceState |
| 280 | // is null. Otherwise the fragment manager takes care of recreating these fragments. |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 281 | if (savedInstanceState == null) { |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 282 | final PhoneFavoriteFragment phoneFavoriteFragment = new PhoneFavoriteFragment(); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 283 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 284 | final FragmentTransaction ft = getFragmentManager().beginTransaction(); |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 285 | ft.add(R.id.dialtacts_frame, phoneFavoriteFragment, TAG_FAVORITES_FRAGMENT); |
| 286 | ft.add(R.id.dialtacts_container, new DialpadFragment(), TAG_DIALPAD_FRAGMENT); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 287 | ft.commit(); |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 288 | } else { |
| 289 | mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY); |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 290 | mInRegularSearch = savedInstanceState.getBoolean(KEY_IN_REGULAR_SEARCH_UI); |
| 291 | mInDialpadSearch = savedInstanceState.getBoolean(KEY_IN_DIALPAD_SEARCH_UI); |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 292 | mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 293 | } |
| 294 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 295 | mBottomPaddingView = findViewById(R.id.dialtacts_bottom_padding); |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 296 | mFragmentsFrame = findViewById(R.id.dialtacts_frame); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 297 | prepareSearchView(); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 298 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 299 | if (UI.FILTER_CONTACTS_ACTION.equals(intent.getAction()) |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 300 | && savedInstanceState == null) { |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 301 | setupFilterText(intent); |
| 302 | } |
Yorke Lee | fce269a | 2013-08-12 11:56:04 -0700 | [diff] [blame] | 303 | |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 304 | setupFakeActionBarItems(); |
| 305 | |
Yorke Lee | 0baa98b | 2013-08-22 10:55:16 -0700 | [diff] [blame] | 306 | mDialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(this); |
Yorke Lee | fce269a | 2013-08-12 11:56:04 -0700 | [diff] [blame] | 307 | SmartDialPrefix.initializeNanpSettings(this); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | @Override |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 311 | protected void onResume() { |
| 312 | super.onResume(); |
Yorke Lee | 98702de | 2013-08-06 12:03:32 -0700 | [diff] [blame] | 313 | if (mFirstLaunch) { |
| 314 | displayFragment(getIntent()); |
| 315 | } |
| 316 | mFirstLaunch = false; |
Yorke Lee | fce269a | 2013-08-12 11:56:04 -0700 | [diff] [blame] | 317 | mDialerDatabaseHelper.startSmartDialUpdateThread(); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | @Override |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 321 | protected void onSaveInstanceState(Bundle outState) { |
| 322 | super.onSaveInstanceState(outState); |
| 323 | outState.putString(KEY_SEARCH_QUERY, mSearchQuery); |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 324 | outState.putBoolean(KEY_IN_REGULAR_SEARCH_UI, mInRegularSearch); |
| 325 | outState.putBoolean(KEY_IN_DIALPAD_SEARCH_UI, mInDialpadSearch); |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 326 | outState.putBoolean(KEY_FIRST_LAUNCH, mFirstLaunch); |
| 327 | } |
| 328 | |
| 329 | @Override |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 330 | public void onAttachFragment(Fragment fragment) { |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 331 | if (fragment instanceof DialpadFragment) { |
| 332 | mDialpadFragment = (DialpadFragment) fragment; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 333 | final FragmentTransaction transaction = getFragmentManager().beginTransaction(); |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 334 | transaction.hide(mDialpadFragment); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 335 | transaction.commit(); |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 336 | } else if (fragment instanceof SmartDialSearchFragment) { |
| 337 | mSmartDialSearchFragment = (SmartDialSearchFragment) fragment; |
Yorke Lee | 63ea4cd | 2013-08-12 11:04:47 -0700 | [diff] [blame] | 338 | mSmartDialSearchFragment.setOnPhoneNumberPickerActionListener( |
| 339 | mPhoneNumberPickerActionListener); |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 340 | } else if (fragment instanceof SearchFragment) { |
Jay Shrauner | 2e5b34b | 2013-08-29 10:52:40 -0700 | [diff] [blame] | 341 | mRegularSearchFragment = (RegularSearchFragment) fragment; |
Yorke Lee | 63ea4cd | 2013-08-12 11:04:47 -0700 | [diff] [blame] | 342 | mRegularSearchFragment.setOnPhoneNumberPickerActionListener( |
| 343 | mPhoneNumberPickerActionListener); |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 344 | } else if (fragment instanceof PhoneFavoriteFragment) { |
| 345 | mPhoneFavoriteFragment = (PhoneFavoriteFragment) fragment; |
Yorke Lee | 5781afe | 2013-08-12 11:12:59 -0700 | [diff] [blame] | 346 | mPhoneFavoriteFragment.setListener(mPhoneFavoriteListener); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 347 | } |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | @Override |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 351 | public boolean onMenuItemClick(MenuItem item) { |
| 352 | switch (item.getItemId()) { |
| 353 | case R.id.menu_import_export: |
| 354 | // We hard-code the "contactsAreAvailable" argument because doing it properly would |
| 355 | // involve querying a {@link ProviderStatusLoader}, which we don't want to do right |
| 356 | // now in Dialtacts for (potential) performance reasons. Compare with how it is |
| 357 | // done in {@link PeopleActivity}. |
| 358 | ImportExportDialogFragment.show(getFragmentManager(), true, |
Yorke Lee | f74011e | 2013-08-02 11:30:30 -0700 | [diff] [blame] | 359 | DialtactsActivity.class); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 360 | return true; |
| 361 | case R.id.menu_clear_frequents: |
| 362 | ClearFrequentsDialog.show(getFragmentManager()); |
| 363 | return true; |
Yorke Lee | 5e93197 | 2013-08-30 11:37:53 -0700 | [diff] [blame] | 364 | case R.id.menu_add_contact: |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 365 | try { |
| 366 | startActivity(new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI)); |
| 367 | } catch (ActivityNotFoundException e) { |
| 368 | Toast toast = Toast.makeText(this, |
| 369 | R.string.add_contact_not_available, |
| 370 | Toast.LENGTH_SHORT); |
| 371 | toast.show(); |
| 372 | } |
| 373 | return true; |
| 374 | case R.id.menu_call_settings: |
Yorke Lee | f74011e | 2013-08-02 11:30:30 -0700 | [diff] [blame] | 375 | final Intent settingsIntent = DialtactsActivity.getCallSettingsIntent(); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 376 | startActivity(settingsIntent); |
Yorke Lee | 5e93197 | 2013-08-30 11:37:53 -0700 | [diff] [blame] | 377 | return true; |
| 378 | case R.id.menu_all_contacts: |
| 379 | onShowAllContacts(); |
| 380 | return true; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 381 | } |
| 382 | return false; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | @Override |
| 386 | public void onClick(View view) { |
| 387 | switch (view.getId()) { |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 388 | case R.id.overflow_menu: { |
| 389 | final PopupMenu popupMenu = new PopupMenu(DialtactsActivity.this, view); |
| 390 | final Menu menu = popupMenu.getMenu(); |
Yorke Lee | 8898cd0 | 2013-08-08 10:24:27 -0700 | [diff] [blame] | 391 | popupMenu.inflate(R.menu.dialtacts_options); |
Yorke Lee | f420a53 | 2013-08-09 15:16:10 -0700 | [diff] [blame] | 392 | final MenuItem clearFrequents = menu.findItem(R.id.menu_clear_frequents); |
Yorke Lee | 0d391b4 | 2013-08-09 17:27:00 -0700 | [diff] [blame] | 393 | clearFrequents.setVisible(mPhoneFavoriteFragment.hasFrequents()); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 394 | popupMenu.setOnMenuItemClickListener(this); |
| 395 | popupMenu.show(); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 396 | break; |
| 397 | } |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 398 | case R.id.dialpad_button: |
| 399 | showDialpadFragment(true); |
| 400 | break; |
| 401 | case R.id.call_history_on_dialpad_button: |
| 402 | case R.id.call_history_button: |
Yorke Lee | f420a53 | 2013-08-09 15:16:10 -0700 | [diff] [blame] | 403 | // Use explicit CallLogActivity intent instead of ACTION_VIEW + |
| 404 | // CONTENT_TYPE, so that we always open our call log from our dialer |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 405 | final Intent intent = new Intent(this, CallLogActivity.class); |
| 406 | startActivity(intent); |
| 407 | break; |
| 408 | case R.id.search_close_button: |
| 409 | // Clear the search field |
| 410 | if (!TextUtils.isEmpty(mSearchView.getText())) { |
| 411 | mSearchView.setText(""); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 412 | } |
| 413 | break; |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 414 | case R.id.voice_search_button: |
| 415 | final Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); |
| 416 | startActivityForResult(voiceIntent, ACTIVITY_REQUEST_CODE_VOICE_SEARCH); |
| 417 | break; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 418 | default: { |
| 419 | Log.wtf(TAG, "Unexpected onClick event from " + view); |
| 420 | break; |
| 421 | } |
| 422 | } |
| 423 | } |
| 424 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 425 | @Override |
| 426 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 427 | if (requestCode == ACTIVITY_REQUEST_CODE_VOICE_SEARCH) { |
| 428 | if (resultCode == RESULT_OK) { |
| 429 | final ArrayList<String> matches = data.getStringArrayListExtra( |
| 430 | RecognizerIntent.EXTRA_RESULTS); |
| 431 | if (matches.size() > 0) { |
| 432 | final String match = matches.get(0); |
| 433 | mSearchView.setText(match); |
| 434 | } else { |
| 435 | Log.e(TAG, "Voice search - nothing heard"); |
| 436 | } |
| 437 | } else { |
| 438 | Log.e(TAG, "Voice search failed"); |
| 439 | } |
| 440 | } |
| 441 | super.onActivityResult(requestCode, resultCode, data); |
| 442 | } |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 443 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 444 | private void showDialpadFragment(boolean animate) { |
Yorke Lee | ea695cb | 2013-08-09 11:02:26 -0700 | [diff] [blame] | 445 | mDialpadFragment.setAdjustTranslationForAnimation(animate); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 446 | final FragmentTransaction ft = getFragmentManager().beginTransaction(); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 447 | if (animate) { |
| 448 | ft.setCustomAnimations(R.anim.slide_in, 0); |
Yorke Lee | ea695cb | 2013-08-09 11:02:26 -0700 | [diff] [blame] | 449 | } else { |
| 450 | mDialpadFragment.setYFraction(0); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 451 | } |
| 452 | ft.show(mDialpadFragment); |
| 453 | ft.commit(); |
| 454 | } |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 455 | |
Yorke Lee | f6673d3 | 2013-08-23 15:34:17 -0700 | [diff] [blame] | 456 | private void hideDialpadFragment(boolean animate, boolean clearDialpad) { |
| 457 | if (mDialpadFragment == null) return; |
| 458 | if (clearDialpad) { |
| 459 | mDialpadFragment.clearDialpad(); |
| 460 | } |
| 461 | if (!mDialpadFragment.isVisible()) return; |
Yorke Lee | ea695cb | 2013-08-09 11:02:26 -0700 | [diff] [blame] | 462 | mDialpadFragment.setAdjustTranslationForAnimation(animate); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 463 | final FragmentTransaction ft = getFragmentManager().beginTransaction(); |
| 464 | if (animate) { |
| 465 | ft.setCustomAnimations(0, R.anim.slide_out); |
| 466 | } |
| 467 | ft.hide(mDialpadFragment); |
| 468 | ft.commit(); |
| 469 | } |
| 470 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 471 | private void prepareSearchView() { |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 472 | mSearchViewContainer = findViewById(R.id.search_view_container); |
| 473 | mSearchViewCloseButton = findViewById(R.id.search_close_button); |
| 474 | mSearchViewCloseButton.setOnClickListener(this); |
| 475 | mVoiceSearchButton = findViewById(R.id.voice_search_button); |
| 476 | mVoiceSearchButton.setOnClickListener(this); |
| 477 | mSearchView = (EditText) findViewById(R.id.search_view); |
| 478 | mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener); |
| 479 | mSearchView.setHint(getString(R.string.dialer_hint_find_contact)); |
| 480 | mSearchView.setOnFocusChangeListener(new OnFocusChangeListener() { |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 481 | @Override |
| 482 | public void onFocusChange(View view, boolean hasFocus) { |
| 483 | if (hasFocus) { |
| 484 | showInputMethod(view.findFocus()); |
| 485 | } |
| 486 | } |
| 487 | }); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 488 | } |
| 489 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 490 | final AnimatorListener mHideListener = new AnimatorListenerAdapter() { |
| 491 | @Override |
| 492 | public void onAnimationEnd(Animator animation) { |
| 493 | mSearchViewContainer.setVisibility(View.GONE); |
| 494 | } |
| 495 | }; |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 496 | |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 497 | private boolean getInSearchUi() { |
| 498 | return mInDialpadSearch || mInRegularSearch; |
| 499 | } |
| 500 | |
| 501 | private void setNotInSearchUi() { |
| 502 | mInDialpadSearch = false; |
| 503 | mInRegularSearch = false; |
| 504 | } |
| 505 | |
Yorke Lee | 311969c | 2013-08-26 06:31:11 -0700 | [diff] [blame] | 506 | private void hideDialpadAndSearchUi() { |
Yorke Lee | 7a06c44 | 2013-09-04 15:49:51 -0700 | [diff] [blame] | 507 | mSearchView.setText(null); |
Yorke Lee | 311969c | 2013-08-26 06:31:11 -0700 | [diff] [blame] | 508 | hideDialpadFragment(false, true); |
| 509 | } |
| 510 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 511 | public void hideSearchBar() { |
| 512 | hideSearchBar(true); |
Christine Chen | 9c1e065 | 2013-05-23 15:40:19 -0700 | [diff] [blame] | 513 | } |
| 514 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 515 | public void hideSearchBar(boolean shiftView) { |
| 516 | if (shiftView) { |
| 517 | mSearchViewContainer.animate().cancel(); |
| 518 | mSearchViewContainer.setAlpha(1); |
| 519 | mSearchViewContainer.setTranslationY(0); |
| 520 | mSearchViewContainer.animate().withLayer().alpha(0).translationY(-mSearchView.getHeight()) |
| 521 | .setDuration(200).setListener(mHideListener); |
| 522 | |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 523 | mFragmentsFrame.animate().withLayer() |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 524 | .translationY(-mSearchViewContainer.getHeight()).setDuration(200).setListener( |
| 525 | new AnimatorListenerAdapter() { |
| 526 | @Override |
| 527 | public void onAnimationEnd(Animator animation) { |
| 528 | mBottomPaddingView.setVisibility(View.VISIBLE); |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 529 | mFragmentsFrame.setTranslationY(0); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 530 | } |
| 531 | }); |
| 532 | } else { |
| 533 | mSearchViewContainer.setTranslationY(-mSearchView.getHeight()); |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | public void showSearchBar() { |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 538 | mSearchViewContainer.animate().cancel(); |
| 539 | mSearchViewContainer.setAlpha(0); |
| 540 | mSearchViewContainer.setTranslationY(-mSearchViewContainer.getHeight()); |
| 541 | mSearchViewContainer.animate().withLayer().alpha(1).translationY(0).setDuration(200) |
| 542 | .setListener(new AnimatorListenerAdapter() { |
| 543 | @Override |
| 544 | public void onAnimationStart(Animator animation) { |
| 545 | mSearchViewContainer.setVisibility(View.VISIBLE); |
| 546 | } |
| 547 | }); |
| 548 | |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 549 | mFragmentsFrame.setTranslationY(-mSearchViewContainer.getHeight()); |
| 550 | mFragmentsFrame.animate().withLayer().translationY(0).setDuration(200) |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 551 | .setListener( |
| 552 | new AnimatorListenerAdapter() { |
| 553 | @Override |
| 554 | public void onAnimationStart(Animator animation) { |
| 555 | mBottomPaddingView.setVisibility(View.GONE); |
| 556 | } |
| 557 | }); |
| 558 | } |
| 559 | |
| 560 | |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 561 | public void setupFakeActionBarItems() { |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 562 | mMenuButton = findViewById(R.id.overflow_menu); |
| 563 | if (mMenuButton != null) { |
| 564 | mMenuButton.setOnClickListener(this); |
| 565 | } |
| 566 | |
| 567 | mCallHistoryButton = findViewById(R.id.call_history_button); |
| 568 | // mCallHistoryButton.setMinimumWidth(fakeMenuItemWidth); |
| 569 | mCallHistoryButton.setOnClickListener(this); |
| 570 | |
| 571 | mDialpadButton = findViewById(R.id.dialpad_button); |
| 572 | // DialpadButton.setMinimumWidth(fakeMenuItemWidth); |
| 573 | mDialpadButton.setOnClickListener(this); |
| 574 | } |
| 575 | |
| 576 | public void setupFakeActionBarItemsForDialpadFragment() { |
| 577 | final View callhistoryButton = findViewById(R.id.call_history_on_dialpad_button); |
| 578 | callhistoryButton.setOnClickListener(this); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 579 | } |
| 580 | |
| 581 | private void fixIntent(Intent intent) { |
| 582 | // This should be cleaned up: the call key used to send an Intent |
| 583 | // that just said to go to the recent calls list. It now sends this |
| 584 | // abstract action, but this class hasn't been rewritten to deal with it. |
| 585 | if (Intent.ACTION_CALL_BUTTON.equals(intent.getAction())) { |
| 586 | intent.setDataAndType(Calls.CONTENT_URI, Calls.CONTENT_TYPE); |
| 587 | intent.putExtra("call_key", true); |
| 588 | setIntent(intent); |
| 589 | } |
| 590 | } |
| 591 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 592 | /** |
| 593 | * Returns true if the intent is due to hitting the green send key (hardware call button: |
| 594 | * KEYCODE_CALL) while in a call. |
| 595 | * |
| 596 | * @param intent the intent that launched this activity |
| 597 | * @param recentCallsRequest true if the intent is requesting to view recent calls |
| 598 | * @return true if the intent is due to hitting the green send key while in a call |
| 599 | */ |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 600 | private boolean isSendKeyWhileInCall(Intent intent, boolean recentCallsRequest) { |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 601 | // If there is a call in progress go to the call screen |
| 602 | if (recentCallsRequest) { |
| 603 | final boolean callKey = intent.getBooleanExtra("call_key", false); |
| 604 | |
| 605 | try { |
| 606 | ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone")); |
| 607 | if (callKey && phone != null && phone.showCallScreen()) { |
| 608 | return true; |
| 609 | } |
| 610 | } catch (RemoteException e) { |
| 611 | Log.e(TAG, "Failed to handle send while in call", e); |
| 612 | } |
| 613 | } |
| 614 | |
| 615 | return false; |
| 616 | } |
| 617 | |
| 618 | /** |
| 619 | * Sets the current tab based on the intent's request type |
| 620 | * |
| 621 | * @param intent Intent that contains information about which tab should be selected |
| 622 | */ |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 623 | private void displayFragment(Intent intent) { |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 624 | // If we got here by hitting send and we're in call forward along to the in-call activity |
| 625 | boolean recentCallsRequest = Calls.CONTENT_TYPE.equals(intent.resolveType( |
| 626 | getContentResolver())); |
| 627 | if (isSendKeyWhileInCall(intent, recentCallsRequest)) { |
| 628 | finish(); |
| 629 | return; |
| 630 | } |
| 631 | |
Yorke Lee | 98702de | 2013-08-06 12:03:32 -0700 | [diff] [blame] | 632 | if (mDialpadFragment != null && (phoneIsInUse() || isDialIntent(intent))) { |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 633 | mDialpadFragment.setStartedFromNewIntent(true); |
Yorke Lee | ea695cb | 2013-08-09 11:02:26 -0700 | [diff] [blame] | 634 | showDialpadFragment(false); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 635 | } |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 636 | } |
| 637 | |
| 638 | @Override |
| 639 | public void onNewIntent(Intent newIntent) { |
| 640 | setIntent(newIntent); |
| 641 | fixIntent(newIntent); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 642 | displayFragment(newIntent); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 643 | final String action = newIntent.getAction(); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 644 | |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 645 | invalidateOptionsMenu(); |
| 646 | } |
| 647 | |
| 648 | /** Returns true if the given intent contains a phone number to populate the dialer with */ |
| 649 | private boolean isDialIntent(Intent intent) { |
| 650 | final String action = intent.getAction(); |
| 651 | if (Intent.ACTION_DIAL.equals(action) || ACTION_TOUCH_DIALER.equals(action)) { |
| 652 | return true; |
| 653 | } |
| 654 | if (Intent.ACTION_VIEW.equals(action)) { |
| 655 | final Uri data = intent.getData(); |
Chiao Cheng | 9d4f3b2 | 2012-09-05 16:00:16 -0700 | [diff] [blame] | 656 | if (data != null && CallUtil.SCHEME_TEL.equals(data.getScheme())) { |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 657 | return true; |
| 658 | } |
| 659 | } |
| 660 | return false; |
| 661 | } |
| 662 | |
| 663 | /** |
| 664 | * Returns an appropriate call origin for this Activity. May return null when no call origin |
| 665 | * should be used (e.g. when some 3rd party application launched the screen. Call origin is |
| 666 | * for remembering the tab in which the user made a phone call, so the external app's DIAL |
| 667 | * request should not be counted.) |
| 668 | */ |
| 669 | public String getCallOrigin() { |
| 670 | return !isDialIntent(getIntent()) ? CALL_ORIGIN_DIALTACTS : null; |
| 671 | } |
| 672 | |
| 673 | /** |
| 674 | * Retrieves the filter text stored in {@link #setupFilterText(Intent)}. |
| 675 | * This text originally came from a FILTER_CONTACTS_ACTION intent received |
| 676 | * by this activity. The stored text will then be cleared after after this |
| 677 | * method returns. |
| 678 | * |
| 679 | * @return The stored filter text |
| 680 | */ |
| 681 | public String getAndClearFilterText() { |
| 682 | String filterText = mFilterText; |
| 683 | mFilterText = null; |
| 684 | return filterText; |
| 685 | } |
| 686 | |
| 687 | /** |
| 688 | * Stores the filter text associated with a FILTER_CONTACTS_ACTION intent. |
| 689 | * This is so child activities can check if they are supposed to display a filter. |
| 690 | * |
| 691 | * @param intent The intent received in {@link #onNewIntent(Intent)} |
| 692 | */ |
| 693 | private void setupFilterText(Intent intent) { |
| 694 | // If the intent was relaunched from history, don't apply the filter text. |
| 695 | if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) { |
| 696 | return; |
| 697 | } |
| 698 | String filter = intent.getStringExtra(UI.FILTER_TEXT_EXTRA_KEY); |
| 699 | if (filter != null && filter.length() > 0) { |
| 700 | mFilterText = filter; |
| 701 | } |
| 702 | } |
| 703 | |
Yorke Lee | 8898cd0 | 2013-08-08 10:24:27 -0700 | [diff] [blame] | 704 | private final PhoneFavoriteFragment.Listener mPhoneFavoriteListener = |
| 705 | new PhoneFavoriteFragment.Listener() { |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 706 | @Override |
| 707 | public void onContactSelected(Uri contactUri) { |
| 708 | PhoneNumberInteraction.startInteractionForPhoneCall( |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 709 | DialtactsActivity.this, contactUri, getCallOrigin()); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 710 | } |
| 711 | |
| 712 | @Override |
| 713 | public void onCallNumberDirectly(String phoneNumber) { |
Chiao Cheng | 9d4f3b2 | 2012-09-05 16:00:16 -0700 | [diff] [blame] | 714 | Intent intent = CallUtil.getCallIntent(phoneNumber, getCallOrigin()); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 715 | startActivity(intent); |
| 716 | } |
| 717 | }; |
| 718 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 719 | /* TODO krelease: This is only relevant for phones that have a hard button search key (i.e. |
| 720 | * Nexus S). Supporting it is a little more tricky because of the dialpad fragment might |
| 721 | * be showing when the search key is pressed so there is more state management involved. |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 722 | |
| 723 | @Override |
| 724 | public void startSearch(String initialQuery, boolean selectInitialQuery, |
| 725 | Bundle appSearchData, boolean globalSearch) { |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 726 | if (mRegularSearchFragment != null && mRegularSearchFragment.isAdded() && !globalSearch) { |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 727 | if (mInSearchUi) { |
| 728 | if (mSearchView.hasFocus()) { |
| 729 | showInputMethod(mSearchView.findFocus()); |
| 730 | } else { |
| 731 | mSearchView.requestFocus(); |
| 732 | } |
| 733 | } else { |
| 734 | enterSearchUi(); |
| 735 | } |
| 736 | } else { |
| 737 | super.startSearch(initialQuery, selectInitialQuery, appSearchData, globalSearch); |
| 738 | } |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 739 | }*/ |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 740 | |
| 741 | private void showInputMethod(View view) { |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 742 | final InputMethodManager imm = (InputMethodManager) getSystemService( |
| 743 | Context.INPUT_METHOD_SERVICE); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 744 | if (imm != null) { |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 745 | imm.showSoftInput(view, 0); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 746 | } |
| 747 | } |
| 748 | |
| 749 | private void hideInputMethod(View view) { |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 750 | final InputMethodManager imm = (InputMethodManager) getSystemService( |
| 751 | Context.INPUT_METHOD_SERVICE); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 752 | if (imm != null && view != null) { |
| 753 | imm.hideSoftInputFromWindow(view.getWindowToken(), 0); |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | /** |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 758 | * Shows the search fragment |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 759 | */ |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 760 | private void enterSearchUi(boolean smartDialSearch, String query) { |
Yorke Lee | 34bdf87 | 2013-08-15 14:11:50 -0700 | [diff] [blame] | 761 | if (getFragmentManager().isDestroyed()) { |
| 762 | // Weird race condition where fragment is doing work after the activity is destroyed |
| 763 | // due to talkback being on (b/10209937). Just return since we can't do any |
| 764 | // constructive here. |
| 765 | return; |
| 766 | } |
| 767 | |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 768 | if (DEBUG) { |
| 769 | Log.d(TAG, "Entering search UI - smart dial " + smartDialSearch); |
| 770 | } |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 771 | |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 772 | final FragmentTransaction transaction = getFragmentManager().beginTransaction(); |
| 773 | transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 774 | |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 775 | SearchFragment fragment; |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 776 | if (mInDialpadSearch) { |
| 777 | transaction.remove(mSmartDialSearchFragment); |
| 778 | } else if (mInRegularSearch) { |
| 779 | transaction.remove(mRegularSearchFragment); |
| 780 | } else { |
| 781 | transaction.remove(mPhoneFavoriteFragment); |
| 782 | } |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 783 | |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 784 | final String tag; |
| 785 | if (smartDialSearch) { |
| 786 | tag = TAG_SMARTDIAL_SEARCH_FRAGMENT; |
| 787 | } else { |
| 788 | tag = TAG_REGULAR_SEARCH_FRAGMENT; |
| 789 | } |
| 790 | mInDialpadSearch = smartDialSearch; |
| 791 | mInRegularSearch = !smartDialSearch; |
| 792 | |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 793 | fragment = (SearchFragment) getFragmentManager().findFragmentByTag(tag); |
| 794 | if (fragment == null) { |
| 795 | if (smartDialSearch) { |
| 796 | fragment = new SmartDialSearchFragment(); |
| 797 | } else { |
Jay Shrauner | 2e5b34b | 2013-08-29 10:52:40 -0700 | [diff] [blame] | 798 | fragment = new RegularSearchFragment(); |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 799 | } |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 800 | } |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 801 | transaction.replace(R.id.dialtacts_frame, fragment, tag); |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 802 | transaction.addToBackStack(null); |
| 803 | fragment.setQueryString(query, false); |
| 804 | transaction.commit(); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 805 | } |
| 806 | |
| 807 | /** |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 808 | * Hides the search fragment |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 809 | */ |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 810 | private void exitSearchUi() { |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 811 | // Go all the way back to the favorites fragment, regardless of how many times we |
| 812 | // transitioned between search fragments |
| 813 | final BackStackEntry entry = getFragmentManager().getBackStackEntryAt(0); |
| 814 | getFragmentManager().popBackStack(0, FragmentManager.POP_BACK_STACK_INCLUSIVE); |
| 815 | setNotInSearchUi(); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 816 | } |
| 817 | |
| 818 | /** Returns an Intent to launch Call Settings screen */ |
| 819 | public static Intent getCallSettingsIntent() { |
| 820 | final Intent intent = new Intent(Intent.ACTION_MAIN); |
| 821 | intent.setClassName(PHONE_PACKAGE, CALL_SETTINGS_CLASS_NAME); |
| 822 | intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); |
| 823 | return intent; |
| 824 | } |
| 825 | |
| 826 | @Override |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 827 | public void onBackPressed() { |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 828 | if (mDialpadFragment != null && mDialpadFragment.isVisible()) { |
Yorke Lee | f6673d3 | 2013-08-23 15:34:17 -0700 | [diff] [blame] | 829 | hideDialpadFragment(true, false); |
Yorke Lee | b207f8a | 2013-08-29 18:51:06 -0700 | [diff] [blame] | 830 | } else if (getInSearchUi()) { |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 831 | mSearchView.setText(null); |
Yorke Lee | f6673d3 | 2013-08-23 15:34:17 -0700 | [diff] [blame] | 832 | mDialpadFragment.clearDialpad(); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 833 | } else if (isTaskRoot()) { |
| 834 | // Instead of stopping, simply push this to the back of the stack. |
| 835 | // This is only done when running at the top of the stack; |
| 836 | // otherwise, we have been launched by someone else so need to |
| 837 | // allow the user to go back to the caller. |
| 838 | moveTaskToBack(false); |
| 839 | } else { |
| 840 | super.onBackPressed(); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 841 | } |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 842 | } |
| 843 | |
| 844 | @Override |
| 845 | public void onDialpadQueryChanged(String query) { |
| 846 | final String normalizedQuery = SmartDialNameMatcher.normalizeNumber(query, |
| 847 | SmartDialNameMatcher.LATIN_SMART_DIAL_MAP); |
| 848 | if (!TextUtils.equals(mSearchView.getText(), normalizedQuery)) { |
Yorke Lee | ef2b738 | 2013-08-09 17:39:25 -0700 | [diff] [blame] | 849 | if (DEBUG) { |
| 850 | Log.d(TAG, "onDialpadQueryChanged - new query: " + query); |
| 851 | } |
| 852 | if (mDialpadFragment == null || !mDialpadFragment.isVisible()) { |
| 853 | // This callback can happen if the dialpad fragment is recreated because of |
| 854 | // activity destruction. In that case, don't update the search view because |
| 855 | // that would bring the user back to the search fragment regardless of the |
| 856 | // previous state of the application. Instead, just return here and let the |
| 857 | // fragment manager correctly figure out whatever fragment was last displayed. |
| 858 | return; |
| 859 | } |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 860 | mSearchView.setText(normalizedQuery); |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 861 | } |
| 862 | } |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 863 | |
| 864 | @Override |
| 865 | public void onListFragmentScrollStateChange(int scrollState) { |
| 866 | if (scrollState == OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) { |
Yorke Lee | f6673d3 | 2013-08-23 15:34:17 -0700 | [diff] [blame] | 867 | hideDialpadFragment(true, false); |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 868 | hideInputMethod(getCurrentFocus()); |
| 869 | } |
| 870 | } |
| 871 | |
| 872 | @Override |
Yorke Lee | c376633 | 2013-07-31 11:13:16 -0700 | [diff] [blame] | 873 | public void onDialpadFragmentStarted() { |
| 874 | setupFakeActionBarItemsForDialpadFragment(); |
| 875 | } |
| 876 | |
| 877 | private boolean phoneIsInUse() { |
| 878 | final TelephonyManager tm = (TelephonyManager) getSystemService( |
| 879 | Context.TELEPHONY_SERVICE); |
| 880 | return tm.getCallState() != TelephonyManager.CALL_STATE_IDLE; |
| 881 | } |
Yorke Lee | 8dd6200 | 2013-08-08 15:57:20 -0700 | [diff] [blame] | 882 | |
| 883 | @Override |
| 884 | public void onShowAllContacts() { |
| 885 | final Intent intent = new Intent(this, AllContactsActivity.class); |
| 886 | startActivity(intent); |
| 887 | } |
Yorke Lee | e142481 | 2013-09-04 18:24:48 -0700 | [diff] [blame] | 888 | |
| 889 | public static Intent getAddNumberToContactIntent(CharSequence text) { |
| 890 | final Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT); |
| 891 | intent.putExtra(Intents.Insert.PHONE, text); |
| 892 | intent.setType(Contacts.CONTENT_ITEM_TYPE); |
| 893 | return intent; |
| 894 | } |
| 895 | |
| 896 | public static Intent getInsertContactWithNameIntent(CharSequence text) { |
| 897 | final Intent intent = new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI); |
| 898 | intent.putExtra(Intents.Insert.NAME, text); |
| 899 | return intent; |
| 900 | } |
Chiao Cheng | 94b10b5 | 2012-08-17 16:59:12 -0700 | [diff] [blame] | 901 | } |