blob: 5826afd69f2ba6cd48d7cef909ebf89df9b775cc [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 Leec3766332013-07-31 11:13:16 -070019import android.animation.Animator;
20import android.animation.Animator.AnimatorListener;
21import android.animation.AnimatorListenerAdapter;
Chiao Cheng94b10b52012-08-17 16:59:12 -070022import android.app.Activity;
Christine Chen9c1e0652013-05-23 15:40:19 -070023import android.app.backup.BackupManager;
Chiao Cheng94b10b52012-08-17 16:59:12 -070024import android.app.Fragment;
25import android.app.FragmentManager;
26import android.app.FragmentTransaction;
Chiao Cheng073b5cf2012-12-07 11:36:00 -080027import android.content.ActivityNotFoundException;
Chiao Cheng94b10b52012-08-17 16:59:12 -070028import android.content.Context;
29import android.content.Intent;
30import android.content.SharedPreferences;
Yorke Leec3766332013-07-31 11:13:16 -070031import android.content.res.Resources;
Chiao Cheng94b10b52012-08-17 16:59:12 -070032import android.net.Uri;
33import android.os.Bundle;
34import android.os.RemoteException;
35import android.os.ServiceManager;
Chiao Cheng94b10b52012-08-17 16:59:12 -070036import android.provider.CallLog.Calls;
Yorke Leec3766332013-07-31 11:13:16 -070037import android.provider.ContactsContract;
Chiao Cheng94b10b52012-08-17 16:59:12 -070038import android.provider.ContactsContract.Contacts;
39import android.provider.ContactsContract.Intents.UI;
Yorke Leec3766332013-07-31 11:13:16 -070040import android.provider.Settings;
41import android.speech.RecognizerIntent;
42import android.support.v4.app.NavUtils;
43import android.telephony.TelephonyManager;
44import android.text.Editable;
Chiao Cheng94b10b52012-08-17 16:59:12 -070045import android.text.TextUtils;
Yorke Leec3766332013-07-31 11:13:16 -070046import android.text.TextWatcher;
Chiao Cheng94b10b52012-08-17 16:59:12 -070047import android.util.Log;
48import android.view.Menu;
Chiao Cheng94b10b52012-08-17 16:59:12 -070049import android.view.MenuItem;
Chiao Cheng94b10b52012-08-17 16:59:12 -070050import android.view.View;
Chiao Cheng94b10b52012-08-17 16:59:12 -070051import android.view.View.OnFocusChangeListener;
52import android.view.ViewConfiguration;
Chiao Cheng94b10b52012-08-17 16:59:12 -070053import android.view.inputmethod.InputMethodManager;
Yorke Leec3766332013-07-31 11:13:16 -070054import android.widget.AbsListView.OnScrollListener;
55import android.widget.EditText;
56import android.widget.ImageView;
Chiao Cheng94b10b52012-08-17 16:59:12 -070057import android.widget.PopupMenu;
58import android.widget.SearchView;
59import android.widget.SearchView.OnCloseListener;
60import android.widget.SearchView.OnQueryTextListener;
Chiao Cheng073b5cf2012-12-07 11:36:00 -080061import android.widget.Toast;
Chiao Cheng94b10b52012-08-17 16:59:12 -070062
Chiao Cheng9d4f3b22012-09-05 16:00:16 -070063import com.android.contacts.common.CallUtil;
Chiao Cheng603ff682012-10-24 15:18:40 -070064import com.android.contacts.common.activity.TransactionSafeActivity;
Yorke Leec3766332013-07-31 11:13:16 -070065import com.android.contacts.common.dialog.ClearFrequentsDialog;
66import com.android.contacts.common.interactions.ImportExportDialogFragment;
Chiao Cheng1429f1a2012-11-01 16:35:28 -070067import com.android.contacts.common.list.ContactListItemView;
Chiao Cheng8efbcf92012-12-04 17:43:02 -080068import com.android.contacts.common.list.OnPhoneNumberPickerActionListener;
69import com.android.contacts.common.list.PhoneNumberPickerFragment;
Yorke Leec3766332013-07-31 11:13:16 -070070import com.android.dialer.calllog.CallLogActivity;
Yorke Leefce269a2013-08-12 11:56:04 -070071import com.android.dialer.database.DialerDatabaseHelper;
Yorke Leef74011e2013-08-02 11:30:30 -070072import com.android.dialer.dialpad.DialpadFragment;
Yorke Leec3766332013-07-31 11:13:16 -070073import com.android.dialer.dialpad.SmartDialNameMatcher;
Yorke Leefce269a2013-08-12 11:56:04 -070074import com.android.dialer.dialpad.SmartDialPrefix;
Chiao Cheng1429f1a2012-11-01 16:35:28 -070075import com.android.dialer.interactions.PhoneNumberInteraction;
Yorke Lee8dd62002013-08-08 15:57:20 -070076import com.android.dialer.list.AllContactsActivity;
Yorke Lee8898cd02013-08-08 10:24:27 -070077import com.android.dialer.list.PhoneFavoriteFragment;
Yorke Leec3766332013-07-31 11:13:16 -070078import com.android.dialer.list.OnListFragmentScrolledListener;
Yorke Leec3766332013-07-31 11:13:16 -070079import com.android.dialer.list.SmartDialSearchFragment;
Chiao Cheng94b10b52012-08-17 16:59:12 -070080import com.android.internal.telephony.ITelephony;
81
Yorke Leec3766332013-07-31 11:13:16 -070082import java.util.ArrayList;
83
Chiao Cheng94b10b52012-08-17 16:59:12 -070084/**
Chiao Cheng94b10b52012-08-17 16:59:12 -070085 * The dialer tab's title is 'phone', a more common name (see strings.xml).
86 */
Yorke Leec3766332013-07-31 11:13:16 -070087public class DialtactsActivity extends TransactionSafeActivity implements View.OnClickListener,
Yorke Leef74011e2013-08-02 11:30:30 -070088 DialpadFragment.OnDialpadQueryChangedListener, PopupMenu.OnMenuItemClickListener,
Yorke Leec3766332013-07-31 11:13:16 -070089 OnListFragmentScrolledListener,
Yorke Lee8898cd02013-08-08 10:24:27 -070090 PhoneFavoriteFragment.OnPhoneFavoriteFragmentStartedListener,
Yorke Lee8dd62002013-08-08 15:57:20 -070091 DialpadFragment.OnDialpadFragmentStartedListener,
92 PhoneFavoriteFragment.OnShowAllContactsListener {
Chiao Cheng94b10b52012-08-17 16:59:12 -070093 private static final String TAG = "DialtactsActivity";
94
95 public static final boolean DEBUG = false;
96
Yorke Leef74011e2013-08-02 11:30:30 -070097 public static final String SHARED_PREFS_NAME = "com.android.dialer_preferences";
98
Chiao Cheng94b10b52012-08-17 16:59:12 -070099 /** Used to open Call Setting */
100 private static final String PHONE_PACKAGE = "com.android.phone";
101 private static final String CALL_SETTINGS_CLASS_NAME =
102 "com.android.phone.CallFeaturesSetting";
Chiao Cheng94b10b52012-08-17 16:59:12 -0700103 /** @see #getCallOrigin() */
104 private static final String CALL_ORIGIN_DIALTACTS =
105 "com.android.dialer.DialtactsActivity";
106
Yorke Leeef2b7382013-08-09 17:39:25 -0700107 private static final String KEY_IN_SEARCH_UI = "in_search_ui";
108 private static final String KEY_SEARCH_QUERY = "search_query";
109 private static final String KEY_FIRST_LAUNCH = "first_launch";
110
Yorke Leec3766332013-07-31 11:13:16 -0700111 private static final String TAG_DIALPAD_FRAGMENT = "dialpad";
112 private static final String TAG_REGULAR_SEARCH_FRAGMENT = "search";
113 private static final String TAG_SMARTDIAL_SEARCH_FRAGMENT = "smartdial";
114 private static final String TAG_FAVORITES_FRAGMENT = "favorites";
Yorke Leec3766332013-07-31 11:13:16 -0700115
Chiao Cheng94b10b52012-08-17 16:59:12 -0700116 /**
117 * Just for backward compatibility. Should behave as same as {@link Intent#ACTION_DIAL}.
118 */
119 private static final String ACTION_TOUCH_DIALER = "com.android.phone.action.TOUCH_DIALER";
120
Chiao Cheng94b10b52012-08-17 16:59:12 -0700121 private static final int SUBACTIVITY_ACCOUNT_FILTER = 1;
122
Yorke Leec3766332013-07-31 11:13:16 -0700123 private static final int ACTIVITY_REQUEST_CODE_VOICE_SEARCH = 1;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700124
125 private String mFilterText;
126
Yorke Leec3766332013-07-31 11:13:16 -0700127 /**
128 * The main fragment displaying the user's favorites and frequent contacts
129 */
Yorke Lee8898cd02013-08-08 10:24:27 -0700130 private PhoneFavoriteFragment mPhoneFavoriteFragment;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700131
132 /**
Yorke Leec3766332013-07-31 11:13:16 -0700133 * Fragment containing the dialpad that slides into view
Chiao Cheng94b10b52012-08-17 16:59:12 -0700134 */
Yorke Leef74011e2013-08-02 11:30:30 -0700135 private DialpadFragment mDialpadFragment;
Yorke Leec3766332013-07-31 11:13:16 -0700136
137 /**
138 * Fragment for searching phone numbers using the alphanumeric keyboard.
139 */
Yorke Lee8898cd02013-08-08 10:24:27 -0700140 private SearchFragment mRegularSearchFragment;
Yorke Leec3766332013-07-31 11:13:16 -0700141
142 /**
143 * Fragment for searching phone numbers using the dialpad.
144 */
145 private SmartDialSearchFragment mSmartDialSearchFragment;
146
Yorke Leec3766332013-07-31 11:13:16 -0700147 private View mMenuButton;
148 private View mCallHistoryButton;
149 private View mDialpadButton;
150
151 // Padding view used to shift the fragments up when the dialpad is shown.
152 private View mBottomPaddingView;
153
Chiao Cheng94b10b52012-08-17 16:59:12 -0700154 /**
155 * True when this Activity is in its search UI (with a {@link SearchView} and
156 * {@link PhoneNumberPickerFragment}).
157 */
158 private boolean mInSearchUi;
Yorke Leeef2b7382013-08-09 17:39:25 -0700159 /**
160 * True when this activity has been launched for the first time.
161 */
Yorke Lee98702de2013-08-06 12:03:32 -0700162 private boolean mFirstLaunch;
Yorke Leec3766332013-07-31 11:13:16 -0700163 private View mSearchViewContainer;
164 private View mSearchViewCloseButton;
165 private View mVoiceSearchButton;
166 private EditText mSearchView;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700167
Yorke Leeef2b7382013-08-09 17:39:25 -0700168 private String mSearchQuery;
169
Yorke Leefce269a2013-08-12 11:56:04 -0700170 private DialerDatabaseHelper mDialerDatabaseHelper;
171
Chiao Cheng94b10b52012-08-17 16:59:12 -0700172 /**
173 * Listener used when one of phone numbers in search UI is selected. This will initiate a
174 * phone call using the phone number.
175 */
176 private final OnPhoneNumberPickerActionListener mPhoneNumberPickerActionListener =
177 new OnPhoneNumberPickerActionListener() {
178 @Override
179 public void onPickPhoneNumberAction(Uri dataUri) {
180 // Specify call-origin so that users will see the previous tab instead of
181 // CallLog screen (search UI will be automatically exited).
182 PhoneNumberInteraction.startInteractionForPhoneCall(
Yorke Leec3766332013-07-31 11:13:16 -0700183 DialtactsActivity.this, dataUri, getCallOrigin());
Yorke Leef6673d32013-08-23 15:34:17 -0700184 hideDialpadAndSearchUi();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700185 }
186
187 @Override
Jay Shrauner31a760b2013-07-26 09:34:49 -0700188 public void onCallNumberDirectly(String phoneNumber) {
189 Intent intent = CallUtil.getCallIntent(phoneNumber, getCallOrigin());
190 startActivity(intent);
Yorke Leef6673d32013-08-23 15:34:17 -0700191 hideDialpadAndSearchUi();
Jay Shrauner31a760b2013-07-26 09:34:49 -0700192 }
193
194 @Override
Chiao Cheng94b10b52012-08-17 16:59:12 -0700195 public void onShortcutIntentCreated(Intent intent) {
196 Log.w(TAG, "Unsupported intent has come (" + intent + "). Ignoring.");
197 }
198
199 @Override
200 public void onHomeInActionBarSelected() {
201 exitSearchUi();
202 }
203 };
204
205 /**
206 * Listener used to send search queries to the phone search fragment.
207 */
Yorke Leec3766332013-07-31 11:13:16 -0700208 private final TextWatcher mPhoneSearchQueryTextListener = new TextWatcher() {
209 @Override
210 public void beforeTextChanged(CharSequence s, int start, int count, int after) {
211 }
212
213 @Override
214 public void onTextChanged(CharSequence s, int start, int before, int count) {
Yorke Leec3766332013-07-31 11:13:16 -0700215 final String newText = s.toString();
Yorke Leeef2b7382013-08-09 17:39:25 -0700216 if (newText.equals(mSearchQuery)) {
217 // If the query hasn't changed (perhaps due to activity being destroyed
218 // and restored, or user launching the same DIAL intent twice), then there is
219 // no need to do anything here.
220 return;
221 }
222 mSearchQuery = newText;
223 if (DEBUG) {
224 Log.d(TAG, "onTextChange for mSearchView called with new query: " + s);
225 }
226 final boolean smartDialSearch = isDialpadShowing();
227
Yorke Leec3766332013-07-31 11:13:16 -0700228 // Show search result with non-empty text. Show a bare list otherwise.
229 if (TextUtils.isEmpty(newText) && mInSearchUi) {
230 exitSearchUi();
231 mSearchViewCloseButton.setVisibility(View.GONE);
232 return;
233 } else if (!TextUtils.isEmpty(newText) && !mInSearchUi) {
Yorke Leeef2b7382013-08-09 17:39:25 -0700234 enterSearchUi(smartDialSearch, newText);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700235 }
236
Yorke Leeef2b7382013-08-09 17:39:25 -0700237 if (smartDialSearch && mSmartDialSearchFragment != null) {
238 mSmartDialSearchFragment.setQueryString(newText, false);
239 } else if (mRegularSearchFragment != null) {
Yorke Leec3766332013-07-31 11:13:16 -0700240 mRegularSearchFragment.setQueryString(newText, false);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700241 }
Yorke Leec3766332013-07-31 11:13:16 -0700242 mSearchViewCloseButton.setVisibility(View.VISIBLE);
243 return;
244 }
245
246 @Override
247 public void afterTextChanged(Editable s) {
248 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700249 };
250
Yorke Leec3766332013-07-31 11:13:16 -0700251 private boolean isDialpadShowing() {
252 return mDialpadFragment != null && mDialpadFragment.isVisible();
253 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700254
255 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700256 protected void onCreate(Bundle savedInstanceState) {
257 super.onCreate(savedInstanceState);
Yorke Lee98702de2013-08-06 12:03:32 -0700258 mFirstLaunch = true;
259
Chiao Cheng94b10b52012-08-17 16:59:12 -0700260 final Intent intent = getIntent();
261 fixIntent(intent);
262
Yorke Lee8898cd02013-08-08 10:24:27 -0700263 setContentView(R.layout.dialtacts_activity);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700264
Yorke Leec3766332013-07-31 11:13:16 -0700265 getActionBar().hide();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700266
Yorke Leeef2b7382013-08-09 17:39:25 -0700267 // Add the favorites fragment, and the dialpad fragment, but only if savedInstanceState
268 // is null. Otherwise the fragment manager takes care of recreating these fragments.
Yorke Leec3766332013-07-31 11:13:16 -0700269 if (savedInstanceState == null) {
Yorke Leeef2b7382013-08-09 17:39:25 -0700270 final PhoneFavoriteFragment phoneFavoriteFragment = new PhoneFavoriteFragment();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700271
Yorke Leec3766332013-07-31 11:13:16 -0700272 final FragmentTransaction ft = getFragmentManager().beginTransaction();
Yorke Leeef2b7382013-08-09 17:39:25 -0700273 ft.add(R.id.dialtacts_frame, phoneFavoriteFragment, TAG_FAVORITES_FRAGMENT);
274 ft.add(R.id.dialtacts_container, new DialpadFragment(), TAG_DIALPAD_FRAGMENT);
Yorke Leec3766332013-07-31 11:13:16 -0700275 ft.commit();
Yorke Leeef2b7382013-08-09 17:39:25 -0700276 } else {
277 mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY);
278 mInSearchUi = savedInstanceState.getBoolean(KEY_IN_SEARCH_UI);
279 mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700280 }
281
Yorke Leec3766332013-07-31 11:13:16 -0700282 mBottomPaddingView = findViewById(R.id.dialtacts_bottom_padding);
283 prepareSearchView();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700284
Chiao Cheng94b10b52012-08-17 16:59:12 -0700285 if (UI.FILTER_CONTACTS_ACTION.equals(intent.getAction())
Yorke Leec3766332013-07-31 11:13:16 -0700286 && savedInstanceState == null) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700287 setupFilterText(intent);
288 }
Yorke Leefce269a2013-08-12 11:56:04 -0700289
290 mDialerDatabaseHelper = DialerDatabaseHelper.getInstance(this);
291 SmartDialPrefix.initializeNanpSettings(this);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700292 }
293
294 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700295 protected void onResume() {
296 super.onResume();
Yorke Lee98702de2013-08-06 12:03:32 -0700297 if (mFirstLaunch) {
298 displayFragment(getIntent());
299 }
300 mFirstLaunch = false;
Yorke Leefce269a2013-08-12 11:56:04 -0700301 mDialerDatabaseHelper.startSmartDialUpdateThread();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700302 }
303
304 @Override
Yorke Leeef2b7382013-08-09 17:39:25 -0700305 protected void onSaveInstanceState(Bundle outState) {
306 super.onSaveInstanceState(outState);
307 outState.putString(KEY_SEARCH_QUERY, mSearchQuery);
308 outState.putBoolean(KEY_IN_SEARCH_UI, mInSearchUi);
309 outState.putBoolean(KEY_FIRST_LAUNCH, mFirstLaunch);
310 }
311
312 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700313 public void onAttachFragment(Fragment fragment) {
Yorke Leeef2b7382013-08-09 17:39:25 -0700314 if (fragment instanceof DialpadFragment) {
315 mDialpadFragment = (DialpadFragment) fragment;
Yorke Leec3766332013-07-31 11:13:16 -0700316 final FragmentTransaction transaction = getFragmentManager().beginTransaction();
Yorke Leeef2b7382013-08-09 17:39:25 -0700317 transaction.hide(mDialpadFragment);
Yorke Leec3766332013-07-31 11:13:16 -0700318 transaction.commit();
Yorke Leeef2b7382013-08-09 17:39:25 -0700319 } else if (fragment instanceof SmartDialSearchFragment) {
320 mSmartDialSearchFragment = (SmartDialSearchFragment) fragment;
Yorke Lee63ea4cd2013-08-12 11:04:47 -0700321 mSmartDialSearchFragment.setOnPhoneNumberPickerActionListener(
322 mPhoneNumberPickerActionListener);
Yorke Leeef2b7382013-08-09 17:39:25 -0700323 } else if (fragment instanceof SearchFragment) {
324 mRegularSearchFragment = (SearchFragment) fragment;
Yorke Lee63ea4cd2013-08-12 11:04:47 -0700325 mRegularSearchFragment.setOnPhoneNumberPickerActionListener(
326 mPhoneNumberPickerActionListener);
Yorke Leeef2b7382013-08-09 17:39:25 -0700327 } else if (fragment instanceof PhoneFavoriteFragment) {
328 mPhoneFavoriteFragment = (PhoneFavoriteFragment) fragment;
Yorke Lee5781afe2013-08-12 11:12:59 -0700329 mPhoneFavoriteFragment.setListener(mPhoneFavoriteListener);
Yorke Leec3766332013-07-31 11:13:16 -0700330 }
Yorke Leec3766332013-07-31 11:13:16 -0700331 }
332
333 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700334 public boolean onMenuItemClick(MenuItem item) {
335 switch (item.getItemId()) {
336 case R.id.menu_import_export:
337 // We hard-code the "contactsAreAvailable" argument because doing it properly would
338 // involve querying a {@link ProviderStatusLoader}, which we don't want to do right
339 // now in Dialtacts for (potential) performance reasons. Compare with how it is
340 // done in {@link PeopleActivity}.
341 ImportExportDialogFragment.show(getFragmentManager(), true,
Yorke Leef74011e2013-08-02 11:30:30 -0700342 DialtactsActivity.class);
Yorke Leec3766332013-07-31 11:13:16 -0700343 return true;
344 case R.id.menu_clear_frequents:
345 ClearFrequentsDialog.show(getFragmentManager());
346 return true;
347 case R.id.add_contact:
348 try {
349 startActivity(new Intent(Intent.ACTION_INSERT, Contacts.CONTENT_URI));
350 } catch (ActivityNotFoundException e) {
351 Toast toast = Toast.makeText(this,
352 R.string.add_contact_not_available,
353 Toast.LENGTH_SHORT);
354 toast.show();
355 }
356 return true;
357 case R.id.menu_call_settings:
Yorke Leef74011e2013-08-02 11:30:30 -0700358 final Intent settingsIntent = DialtactsActivity.getCallSettingsIntent();
Yorke Leec3766332013-07-31 11:13:16 -0700359 startActivity(settingsIntent);
360 }
361 return false;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700362 }
363
364 @Override
365 public void onClick(View view) {
366 switch (view.getId()) {
Yorke Leec3766332013-07-31 11:13:16 -0700367 case R.id.overflow_menu: {
368 final PopupMenu popupMenu = new PopupMenu(DialtactsActivity.this, view);
369 final Menu menu = popupMenu.getMenu();
Yorke Lee8898cd02013-08-08 10:24:27 -0700370 popupMenu.inflate(R.menu.dialtacts_options);
Yorke Leef420a532013-08-09 15:16:10 -0700371 final MenuItem clearFrequents = menu.findItem(R.id.menu_clear_frequents);
Yorke Lee0d391b42013-08-09 17:27:00 -0700372 clearFrequents.setVisible(mPhoneFavoriteFragment.hasFrequents());
Yorke Leec3766332013-07-31 11:13:16 -0700373 popupMenu.setOnMenuItemClickListener(this);
374 popupMenu.show();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700375 break;
376 }
Yorke Leec3766332013-07-31 11:13:16 -0700377 case R.id.dialpad_button:
378 showDialpadFragment(true);
379 break;
380 case R.id.call_history_on_dialpad_button:
381 case R.id.call_history_button:
Yorke Leef420a532013-08-09 15:16:10 -0700382 // Use explicit CallLogActivity intent instead of ACTION_VIEW +
383 // CONTENT_TYPE, so that we always open our call log from our dialer
Yorke Leec3766332013-07-31 11:13:16 -0700384 final Intent intent = new Intent(this, CallLogActivity.class);
385 startActivity(intent);
386 break;
387 case R.id.search_close_button:
388 // Clear the search field
389 if (!TextUtils.isEmpty(mSearchView.getText())) {
390 mSearchView.setText("");
Chiao Cheng94b10b52012-08-17 16:59:12 -0700391 }
392 break;
Yorke Leec3766332013-07-31 11:13:16 -0700393 case R.id.voice_search_button:
394 final Intent voiceIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
395 startActivityForResult(voiceIntent, ACTIVITY_REQUEST_CODE_VOICE_SEARCH);
396 break;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700397 default: {
398 Log.wtf(TAG, "Unexpected onClick event from " + view);
399 break;
400 }
401 }
402 }
403
Yorke Leec3766332013-07-31 11:13:16 -0700404 @Override
405 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
406 if (requestCode == ACTIVITY_REQUEST_CODE_VOICE_SEARCH) {
407 if (resultCode == RESULT_OK) {
408 final ArrayList<String> matches = data.getStringArrayListExtra(
409 RecognizerIntent.EXTRA_RESULTS);
410 if (matches.size() > 0) {
411 final String match = matches.get(0);
412 mSearchView.setText(match);
413 } else {
414 Log.e(TAG, "Voice search - nothing heard");
415 }
416 } else {
417 Log.e(TAG, "Voice search failed");
418 }
419 }
420 super.onActivityResult(requestCode, resultCode, data);
421 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700422
Yorke Leec3766332013-07-31 11:13:16 -0700423 private void showDialpadFragment(boolean animate) {
Yorke Leeea695cb2013-08-09 11:02:26 -0700424 mDialpadFragment.setAdjustTranslationForAnimation(animate);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700425 final FragmentTransaction ft = getFragmentManager().beginTransaction();
Yorke Leec3766332013-07-31 11:13:16 -0700426 if (animate) {
427 ft.setCustomAnimations(R.anim.slide_in, 0);
Yorke Leeea695cb2013-08-09 11:02:26 -0700428 } else {
429 mDialpadFragment.setYFraction(0);
Yorke Leec3766332013-07-31 11:13:16 -0700430 }
431 ft.show(mDialpadFragment);
432 ft.commit();
433 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700434
Yorke Leef6673d32013-08-23 15:34:17 -0700435 private void hideDialpadFragment(boolean animate, boolean clearDialpad) {
436 if (mDialpadFragment == null) return;
437 if (clearDialpad) {
438 mDialpadFragment.clearDialpad();
439 }
440 if (!mDialpadFragment.isVisible()) return;
Yorke Leeea695cb2013-08-09 11:02:26 -0700441 mDialpadFragment.setAdjustTranslationForAnimation(animate);
Yorke Leec3766332013-07-31 11:13:16 -0700442 final FragmentTransaction ft = getFragmentManager().beginTransaction();
443 if (animate) {
444 ft.setCustomAnimations(0, R.anim.slide_out);
445 }
446 ft.hide(mDialpadFragment);
447 ft.commit();
448 }
449
Chiao Cheng94b10b52012-08-17 16:59:12 -0700450 private void prepareSearchView() {
Yorke Leec3766332013-07-31 11:13:16 -0700451 mSearchViewContainer = findViewById(R.id.search_view_container);
452 mSearchViewCloseButton = findViewById(R.id.search_close_button);
453 mSearchViewCloseButton.setOnClickListener(this);
454 mVoiceSearchButton = findViewById(R.id.voice_search_button);
455 mVoiceSearchButton.setOnClickListener(this);
456 mSearchView = (EditText) findViewById(R.id.search_view);
457 mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener);
458 mSearchView.setHint(getString(R.string.dialer_hint_find_contact));
459 mSearchView.setOnFocusChangeListener(new OnFocusChangeListener() {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700460 @Override
461 public void onFocusChange(View view, boolean hasFocus) {
462 if (hasFocus) {
463 showInputMethod(view.findFocus());
464 }
465 }
466 });
Chiao Cheng94b10b52012-08-17 16:59:12 -0700467 }
468
Yorke Leec3766332013-07-31 11:13:16 -0700469 final AnimatorListener mHideListener = new AnimatorListenerAdapter() {
470 @Override
471 public void onAnimationEnd(Animator animation) {
472 mSearchViewContainer.setVisibility(View.GONE);
473 }
474 };
Chiao Cheng94b10b52012-08-17 16:59:12 -0700475
Yorke Leec3766332013-07-31 11:13:16 -0700476 public void hideSearchBar() {
477 hideSearchBar(true);
Christine Chen9c1e0652013-05-23 15:40:19 -0700478 }
479
Yorke Leec3766332013-07-31 11:13:16 -0700480 public void hideSearchBar(boolean shiftView) {
481 if (shiftView) {
482 mSearchViewContainer.animate().cancel();
483 mSearchViewContainer.setAlpha(1);
484 mSearchViewContainer.setTranslationY(0);
485 mSearchViewContainer.animate().withLayer().alpha(0).translationY(-mSearchView.getHeight())
486 .setDuration(200).setListener(mHideListener);
487
Yorke Leeef2b7382013-08-09 17:39:25 -0700488 if (mPhoneFavoriteFragment == null || mPhoneFavoriteFragment.getView() == null) {
489 mBottomPaddingView.setVisibility(View.VISIBLE);
490 return;
491 }
492
Yorke Leec3766332013-07-31 11:13:16 -0700493 mPhoneFavoriteFragment.getView().animate().withLayer()
494 .translationY(-mSearchViewContainer.getHeight()).setDuration(200).setListener(
495 new AnimatorListenerAdapter() {
496 @Override
497 public void onAnimationEnd(Animator animation) {
498 mBottomPaddingView.setVisibility(View.VISIBLE);
Yorke Leeef2b7382013-08-09 17:39:25 -0700499 if (mPhoneFavoriteFragment.getView() != null) {
500 mPhoneFavoriteFragment.getView().setTranslationY(0);
501 }
Yorke Leec3766332013-07-31 11:13:16 -0700502 }
503 });
504 } else {
505 mSearchViewContainer.setTranslationY(-mSearchView.getHeight());
506 }
507 }
508
509 public void showSearchBar() {
Yorke Leeef2b7382013-08-09 17:39:25 -0700510
511
Yorke Leec3766332013-07-31 11:13:16 -0700512 mSearchViewContainer.animate().cancel();
513 mSearchViewContainer.setAlpha(0);
514 mSearchViewContainer.setTranslationY(-mSearchViewContainer.getHeight());
515 mSearchViewContainer.animate().withLayer().alpha(1).translationY(0).setDuration(200)
516 .setListener(new AnimatorListenerAdapter() {
517 @Override
518 public void onAnimationStart(Animator animation) {
519 mSearchViewContainer.setVisibility(View.VISIBLE);
520 }
521 });
522
Yorke Leeef2b7382013-08-09 17:39:25 -0700523 // If the favorites fragment hasn't been fully created before the dialpad fragment
524 // is hidden (i.e. onResume), don't bother animating
525 if (mPhoneFavoriteFragment == null || mPhoneFavoriteFragment.getView() == null) {
526 mBottomPaddingView.setVisibility(View.GONE);
527 return;
528 }
Yorke Leec3766332013-07-31 11:13:16 -0700529 mPhoneFavoriteFragment.getView().setTranslationY(-mSearchViewContainer.getHeight());
530 mPhoneFavoriteFragment.getView().animate().withLayer().translationY(0).setDuration(200)
531 .setListener(
532 new AnimatorListenerAdapter() {
533 @Override
534 public void onAnimationStart(Animator animation) {
535 mBottomPaddingView.setVisibility(View.GONE);
536 }
537 });
538 }
539
540
541 public void setupFakeActionBarItemsForFavoritesFragment() {
542 mMenuButton = findViewById(R.id.overflow_menu);
543 if (mMenuButton != null) {
544 mMenuButton.setOnClickListener(this);
545 }
546
547 mCallHistoryButton = findViewById(R.id.call_history_button);
548 // mCallHistoryButton.setMinimumWidth(fakeMenuItemWidth);
549 mCallHistoryButton.setOnClickListener(this);
550
551 mDialpadButton = findViewById(R.id.dialpad_button);
552 // DialpadButton.setMinimumWidth(fakeMenuItemWidth);
553 mDialpadButton.setOnClickListener(this);
554 }
555
556 public void setupFakeActionBarItemsForDialpadFragment() {
557 final View callhistoryButton = findViewById(R.id.call_history_on_dialpad_button);
558 callhistoryButton.setOnClickListener(this);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700559 }
560
561 private void fixIntent(Intent intent) {
562 // This should be cleaned up: the call key used to send an Intent
563 // that just said to go to the recent calls list. It now sends this
564 // abstract action, but this class hasn't been rewritten to deal with it.
565 if (Intent.ACTION_CALL_BUTTON.equals(intent.getAction())) {
566 intent.setDataAndType(Calls.CONTENT_URI, Calls.CONTENT_TYPE);
567 intent.putExtra("call_key", true);
568 setIntent(intent);
569 }
570 }
571
Chiao Cheng94b10b52012-08-17 16:59:12 -0700572 /**
573 * Returns true if the intent is due to hitting the green send key (hardware call button:
574 * KEYCODE_CALL) while in a call.
575 *
576 * @param intent the intent that launched this activity
577 * @param recentCallsRequest true if the intent is requesting to view recent calls
578 * @return true if the intent is due to hitting the green send key while in a call
579 */
Yorke Leec3766332013-07-31 11:13:16 -0700580 private boolean isSendKeyWhileInCall(Intent intent, boolean recentCallsRequest) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700581 // If there is a call in progress go to the call screen
582 if (recentCallsRequest) {
583 final boolean callKey = intent.getBooleanExtra("call_key", false);
584
585 try {
586 ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
587 if (callKey && phone != null && phone.showCallScreen()) {
588 return true;
589 }
590 } catch (RemoteException e) {
591 Log.e(TAG, "Failed to handle send while in call", e);
592 }
593 }
594
595 return false;
596 }
597
598 /**
599 * Sets the current tab based on the intent's request type
600 *
601 * @param intent Intent that contains information about which tab should be selected
602 */
Yorke Leec3766332013-07-31 11:13:16 -0700603 private void displayFragment(Intent intent) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700604 // If we got here by hitting send and we're in call forward along to the in-call activity
605 boolean recentCallsRequest = Calls.CONTENT_TYPE.equals(intent.resolveType(
606 getContentResolver()));
607 if (isSendKeyWhileInCall(intent, recentCallsRequest)) {
608 finish();
609 return;
610 }
611
Yorke Lee98702de2013-08-06 12:03:32 -0700612 if (mDialpadFragment != null && (phoneIsInUse() || isDialIntent(intent))) {
Yorke Leec3766332013-07-31 11:13:16 -0700613 mDialpadFragment.setStartedFromNewIntent(true);
Yorke Leeea695cb2013-08-09 11:02:26 -0700614 showDialpadFragment(false);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700615 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700616 }
617
618 @Override
619 public void onNewIntent(Intent newIntent) {
620 setIntent(newIntent);
621 fixIntent(newIntent);
Yorke Leec3766332013-07-31 11:13:16 -0700622 displayFragment(newIntent);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700623 final String action = newIntent.getAction();
Yorke Leec3766332013-07-31 11:13:16 -0700624
Chiao Cheng94b10b52012-08-17 16:59:12 -0700625 invalidateOptionsMenu();
626 }
627
628 /** Returns true if the given intent contains a phone number to populate the dialer with */
629 private boolean isDialIntent(Intent intent) {
630 final String action = intent.getAction();
631 if (Intent.ACTION_DIAL.equals(action) || ACTION_TOUCH_DIALER.equals(action)) {
632 return true;
633 }
634 if (Intent.ACTION_VIEW.equals(action)) {
635 final Uri data = intent.getData();
Chiao Cheng9d4f3b22012-09-05 16:00:16 -0700636 if (data != null && CallUtil.SCHEME_TEL.equals(data.getScheme())) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700637 return true;
638 }
639 }
640 return false;
641 }
642
643 /**
644 * Returns an appropriate call origin for this Activity. May return null when no call origin
645 * should be used (e.g. when some 3rd party application launched the screen. Call origin is
646 * for remembering the tab in which the user made a phone call, so the external app's DIAL
647 * request should not be counted.)
648 */
649 public String getCallOrigin() {
650 return !isDialIntent(getIntent()) ? CALL_ORIGIN_DIALTACTS : null;
651 }
652
653 /**
654 * Retrieves the filter text stored in {@link #setupFilterText(Intent)}.
655 * This text originally came from a FILTER_CONTACTS_ACTION intent received
656 * by this activity. The stored text will then be cleared after after this
657 * method returns.
658 *
659 * @return The stored filter text
660 */
661 public String getAndClearFilterText() {
662 String filterText = mFilterText;
663 mFilterText = null;
664 return filterText;
665 }
666
667 /**
668 * Stores the filter text associated with a FILTER_CONTACTS_ACTION intent.
669 * This is so child activities can check if they are supposed to display a filter.
670 *
671 * @param intent The intent received in {@link #onNewIntent(Intent)}
672 */
673 private void setupFilterText(Intent intent) {
674 // If the intent was relaunched from history, don't apply the filter text.
675 if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) {
676 return;
677 }
678 String filter = intent.getStringExtra(UI.FILTER_TEXT_EXTRA_KEY);
679 if (filter != null && filter.length() > 0) {
680 mFilterText = filter;
681 }
682 }
683
Yorke Lee8898cd02013-08-08 10:24:27 -0700684 private final PhoneFavoriteFragment.Listener mPhoneFavoriteListener =
685 new PhoneFavoriteFragment.Listener() {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700686 @Override
687 public void onContactSelected(Uri contactUri) {
688 PhoneNumberInteraction.startInteractionForPhoneCall(
Yorke Leec3766332013-07-31 11:13:16 -0700689 DialtactsActivity.this, contactUri, getCallOrigin());
Chiao Cheng94b10b52012-08-17 16:59:12 -0700690 }
691
692 @Override
693 public void onCallNumberDirectly(String phoneNumber) {
Chiao Cheng9d4f3b22012-09-05 16:00:16 -0700694 Intent intent = CallUtil.getCallIntent(phoneNumber, getCallOrigin());
Chiao Cheng94b10b52012-08-17 16:59:12 -0700695 startActivity(intent);
696 }
697 };
698
Yorke Leec3766332013-07-31 11:13:16 -0700699 /* TODO krelease: This is only relevant for phones that have a hard button search key (i.e.
700 * Nexus S). Supporting it is a little more tricky because of the dialpad fragment might
701 * be showing when the search key is pressed so there is more state management involved.
Chiao Cheng94b10b52012-08-17 16:59:12 -0700702
703 @Override
704 public void startSearch(String initialQuery, boolean selectInitialQuery,
705 Bundle appSearchData, boolean globalSearch) {
Yorke Leec3766332013-07-31 11:13:16 -0700706 if (mRegularSearchFragment != null && mRegularSearchFragment.isAdded() && !globalSearch) {
Chiao Cheng94b10b52012-08-17 16:59:12 -0700707 if (mInSearchUi) {
708 if (mSearchView.hasFocus()) {
709 showInputMethod(mSearchView.findFocus());
710 } else {
711 mSearchView.requestFocus();
712 }
713 } else {
714 enterSearchUi();
715 }
716 } else {
717 super.startSearch(initialQuery, selectInitialQuery, appSearchData, globalSearch);
718 }
Yorke Leec3766332013-07-31 11:13:16 -0700719 }*/
Chiao Cheng94b10b52012-08-17 16:59:12 -0700720
721 private void showInputMethod(View view) {
Yorke Leec3766332013-07-31 11:13:16 -0700722 final InputMethodManager imm = (InputMethodManager) getSystemService(
723 Context.INPUT_METHOD_SERVICE);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700724 if (imm != null) {
Yorke Leec3766332013-07-31 11:13:16 -0700725 imm.showSoftInput(view, 0);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700726 }
727 }
728
729 private void hideInputMethod(View view) {
Yorke Leec3766332013-07-31 11:13:16 -0700730 final InputMethodManager imm = (InputMethodManager) getSystemService(
731 Context.INPUT_METHOD_SERVICE);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700732 if (imm != null && view != null) {
733 imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
734 }
735 }
736
737 /**
Yorke Leec3766332013-07-31 11:13:16 -0700738 * Shows the search fragment
Chiao Cheng94b10b52012-08-17 16:59:12 -0700739 */
Yorke Leeef2b7382013-08-09 17:39:25 -0700740 private void enterSearchUi(boolean smartDialSearch, String query) {
Yorke Lee34bdf872013-08-15 14:11:50 -0700741 if (getFragmentManager().isDestroyed()) {
742 // Weird race condition where fragment is doing work after the activity is destroyed
743 // due to talkback being on (b/10209937). Just return since we can't do any
744 // constructive here.
745 return;
746 }
747
Yorke Leeef2b7382013-08-09 17:39:25 -0700748 if (DEBUG) {
749 Log.d(TAG, "Entering search UI - smart dial " + smartDialSearch);
750 }
751 final String tag = smartDialSearch ? TAG_SMARTDIAL_SEARCH_FRAGMENT :
752 TAG_REGULAR_SEARCH_FRAGMENT;
753
Yorke Leec3766332013-07-31 11:13:16 -0700754 final FragmentTransaction transaction = getFragmentManager().beginTransaction();
755 transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700756
Yorke Leeef2b7382013-08-09 17:39:25 -0700757 SearchFragment fragment;
758
759 transaction.remove(mPhoneFavoriteFragment);
760 fragment = (SearchFragment) getFragmentManager().findFragmentByTag(tag);
761 if (fragment == null) {
762 if (smartDialSearch) {
763 fragment = new SmartDialSearchFragment();
764 } else {
765 fragment = new SearchFragment();
766 }
767 transaction.replace(R.id.dialtacts_frame, fragment, tag);
768 } else {
769 transaction.attach(fragment);
770 }
771
772 transaction.addToBackStack(null);
773 fragment.setQueryString(query, false);
774 transaction.commit();
Yorke Leec3766332013-07-31 11:13:16 -0700775 mInSearchUi = true;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700776 }
777
778 /**
Yorke Leec3766332013-07-31 11:13:16 -0700779 * Hides the search fragment
Chiao Cheng94b10b52012-08-17 16:59:12 -0700780 */
Yorke Leec3766332013-07-31 11:13:16 -0700781 private void exitSearchUi() {
Yorke Leeef2b7382013-08-09 17:39:25 -0700782 getFragmentManager().popBackStack();
Yorke Leec3766332013-07-31 11:13:16 -0700783 mInSearchUi = false;
Chiao Cheng94b10b52012-08-17 16:59:12 -0700784 }
785
786 /** Returns an Intent to launch Call Settings screen */
787 public static Intent getCallSettingsIntent() {
788 final Intent intent = new Intent(Intent.ACTION_MAIN);
789 intent.setClassName(PHONE_PACKAGE, CALL_SETTINGS_CLASS_NAME);
790 intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
791 return intent;
792 }
793
794 @Override
Yorke Leec3766332013-07-31 11:13:16 -0700795 public void onBackPressed() {
Yorke Leeef2b7382013-08-09 17:39:25 -0700796 if (mDialpadFragment != null && mDialpadFragment.isVisible()) {
Yorke Leef6673d32013-08-23 15:34:17 -0700797 hideDialpadFragment(true, false);
Yorke Leec3766332013-07-31 11:13:16 -0700798 } else if (mInSearchUi) {
799 mSearchView.setText(null);
Yorke Leef6673d32013-08-23 15:34:17 -0700800 mDialpadFragment.clearDialpad();
Yorke Leec3766332013-07-31 11:13:16 -0700801 } else if (isTaskRoot()) {
802 // Instead of stopping, simply push this to the back of the stack.
803 // This is only done when running at the top of the stack;
804 // otherwise, we have been launched by someone else so need to
805 // allow the user to go back to the caller.
806 moveTaskToBack(false);
807 } else {
808 super.onBackPressed();
Chiao Cheng94b10b52012-08-17 16:59:12 -0700809 }
Yorke Leec3766332013-07-31 11:13:16 -0700810 }
811
812 @Override
813 public void onDialpadQueryChanged(String query) {
814 final String normalizedQuery = SmartDialNameMatcher.normalizeNumber(query,
815 SmartDialNameMatcher.LATIN_SMART_DIAL_MAP);
816 if (!TextUtils.equals(mSearchView.getText(), normalizedQuery)) {
Yorke Leeef2b7382013-08-09 17:39:25 -0700817 if (DEBUG) {
818 Log.d(TAG, "onDialpadQueryChanged - new query: " + query);
819 }
820 if (mDialpadFragment == null || !mDialpadFragment.isVisible()) {
821 // This callback can happen if the dialpad fragment is recreated because of
822 // activity destruction. In that case, don't update the search view because
823 // that would bring the user back to the search fragment regardless of the
824 // previous state of the application. Instead, just return here and let the
825 // fragment manager correctly figure out whatever fragment was last displayed.
826 return;
827 }
Yorke Leec3766332013-07-31 11:13:16 -0700828 mSearchView.setText(normalizedQuery);
Chiao Cheng94b10b52012-08-17 16:59:12 -0700829 }
830 }
Yorke Leec3766332013-07-31 11:13:16 -0700831
832 @Override
833 public void onListFragmentScrollStateChange(int scrollState) {
834 if (scrollState == OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
Yorke Leef6673d32013-08-23 15:34:17 -0700835 hideDialpadFragment(true, false);
Yorke Leec3766332013-07-31 11:13:16 -0700836 hideInputMethod(getCurrentFocus());
837 }
838 }
839
840 @Override
841 public void onPhoneFavoriteFragmentStarted() {
842 setupFakeActionBarItemsForFavoritesFragment();
843 }
844
845 @Override
846 public void onDialpadFragmentStarted() {
847 setupFakeActionBarItemsForDialpadFragment();
848 }
849
850 private boolean phoneIsInUse() {
851 final TelephonyManager tm = (TelephonyManager) getSystemService(
852 Context.TELEPHONY_SERVICE);
853 return tm.getCallState() != TelephonyManager.CALL_STATE_IDLE;
854 }
Yorke Lee8dd62002013-08-08 15:57:20 -0700855
856 @Override
857 public void onShowAllContacts() {
858 final Intent intent = new Intent(this, AllContactsActivity.class);
859 startActivity(intent);
860 }
Chiao Cheng94b10b52012-08-17 16:59:12 -0700861}