diff options
Diffstat (limited to 'java/com/android/dialer/app/DialtactsActivity.java')
-rw-r--r-- | java/com/android/dialer/app/DialtactsActivity.java | 94 |
1 files changed, 71 insertions, 23 deletions
diff --git a/java/com/android/dialer/app/DialtactsActivity.java b/java/com/android/dialer/app/DialtactsActivity.java index b5e615075..527dbff18 100644 --- a/java/com/android/dialer/app/DialtactsActivity.java +++ b/java/com/android/dialer/app/DialtactsActivity.java @@ -71,10 +71,12 @@ import com.android.contacts.common.widget.FloatingActionButtonController; import com.android.dialer.animation.AnimUtils; import com.android.dialer.animation.AnimationListenerAdapter; import com.android.dialer.app.calllog.CallLogActivity; +import com.android.dialer.app.calllog.CallLogAdapter; import com.android.dialer.app.calllog.CallLogFragment; import com.android.dialer.app.calllog.CallLogNotificationsService; import com.android.dialer.app.dialpad.DialpadFragment; import com.android.dialer.app.list.DialtactsPagerAdapter; +import com.android.dialer.app.list.DialtactsPagerAdapter.TabIndex; import com.android.dialer.app.list.DragDropController; import com.android.dialer.app.list.ListsFragment; import com.android.dialer.app.list.OldSpeedDialFragment; @@ -91,8 +93,8 @@ import com.android.dialer.callcomposer.CallComposerActivity; import com.android.dialer.callintent.CallIntentBuilder; import com.android.dialer.callintent.CallSpecificAppData; import com.android.dialer.common.Assert; -import com.android.dialer.common.ConfigProviderBindings; import com.android.dialer.common.LogUtil; +import com.android.dialer.configprovider.ConfigProviderBindings; import com.android.dialer.database.Database; import com.android.dialer.database.DialerDatabaseHelper; import com.android.dialer.interactions.PhoneNumberInteraction; @@ -100,21 +102,24 @@ import com.android.dialer.interactions.PhoneNumberInteraction.InteractionErrorCo import com.android.dialer.logging.DialerImpression; import com.android.dialer.logging.Logger; import com.android.dialer.logging.ScreenEvent; +import com.android.dialer.logging.UiAction; +import com.android.dialer.main.Main; +import com.android.dialer.main.MainComponent; import com.android.dialer.p13n.inference.P13nRanking; import com.android.dialer.p13n.inference.protocol.P13nRanker; import com.android.dialer.p13n.inference.protocol.P13nRanker.P13nRefreshCompleteListener; import com.android.dialer.p13n.logging.P13nLogger; import com.android.dialer.p13n.logging.P13nLogging; +import com.android.dialer.performancereport.PerformanceReport; import com.android.dialer.postcall.PostCall; import com.android.dialer.proguard.UsedByReflection; -import com.android.dialer.searchfragment.NewSearchFragment; +import com.android.dialer.searchfragment.list.NewSearchFragment; import com.android.dialer.simulator.Simulator; import com.android.dialer.simulator.SimulatorComponent; import com.android.dialer.smartdial.SmartDialNameMatcher; import com.android.dialer.smartdial.SmartDialPrefix; import com.android.dialer.telecom.TelecomUtil; import com.android.dialer.util.DialerUtils; -import com.android.dialer.util.IntentUtil; import com.android.dialer.util.PermissionsUtil; import com.android.dialer.util.TouchPointManager; import com.android.dialer.util.TransactionSafeActivity; @@ -132,6 +137,7 @@ public class DialtactsActivity extends TransactionSafeActivity DialpadFragment.OnDialpadQueryChangedListener, OnListFragmentScrolledListener, CallLogFragment.HostInterface, + CallLogAdapter.OnActionModeStateChangedListener, DialpadFragment.HostInterface, OldSpeedDialFragment.HostInterface, SearchFragment.HostInterface, @@ -149,6 +155,7 @@ public class DialtactsActivity extends TransactionSafeActivity private static final String ACTION_SHOW_TAB = "ACTION_SHOW_TAB"; @VisibleForTesting public static final String EXTRA_SHOW_TAB = "EXTRA_SHOW_TAB"; public static final String EXTRA_CLEAR_NEW_VOICEMAILS = "EXTRA_CLEAR_NEW_VOICEMAILS"; + private static final String KEY_LAST_TAB = "last_tab"; private static final String TAG = "DialtactsActivity"; private static final String KEY_IN_REGULAR_SEARCH_UI = "in_regular_search_ui"; private static final String KEY_IN_DIALPAD_SEARCH_UI = "in_dialpad_search_ui"; @@ -232,6 +239,9 @@ public class DialtactsActivity extends TransactionSafeActivity private P13nLogger mP13nLogger; private P13nRanker mP13nRanker; + public boolean isMultiSelectModeEnabled; + + private boolean isLastTabEnabled; AnimationListenerAdapter mSlideInListener = new AnimationListenerAdapter() { @@ -263,6 +273,11 @@ public class DialtactsActivity extends TransactionSafeActivity // no need to do anything here. return; } + + if (count != 0) { + PerformanceReport.recordClick(UiAction.Type.TEXT_CHANGE_WITH_INPUT); + } + if (DEBUG) { LogUtil.v("DialtactsActivity.onTextChanged", "called with new query: " + newText); LogUtil.v("DialtactsActivity.onTextChanged", "previous query: " + mSearchQuery); @@ -299,6 +314,7 @@ public class DialtactsActivity extends TransactionSafeActivity @Override public void onClick(View v) { if (!isInSearchUi()) { + PerformanceReport.recordClick(UiAction.Type.OPEN_SEARCH); mActionBarController.onSearchBoxTapped(); enterSearchUi( false /* smartDialSearch */, mSearchView.getText().toString(), true /* animate */); @@ -316,9 +332,13 @@ public class DialtactsActivity extends TransactionSafeActivity if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) { if (TextUtils.isEmpty(mSearchView.getText().toString())) { // If the search term is empty, close the search UI. + PerformanceReport.recordClick(UiAction.Type.CLOSE_SEARCH_WITH_HIDE_BUTTON); maybeExitSearchUi(); } else { // If the search term is not empty, show the dialpad fab. + if (!mFloatingActionButtonController.isVisible()) { + PerformanceReport.recordClick(UiAction.Type.HIDE_KEYBOARD_IN_SEARCH); + } showFabInSearchUi(); } } @@ -365,6 +385,7 @@ public class DialtactsActivity extends TransactionSafeActivity super.onCreate(savedInstanceState); mFirstLaunch = true; + isLastTabEnabled = ConfigProviderBindings.get(this).getBoolean("last_tab_enabled", false); final Resources resources = getResources(); mActionBarHeight = resources.getDimensionPixelSize(R.dimen.action_bar_height_large); @@ -490,6 +511,13 @@ public class DialtactsActivity extends TransactionSafeActivity Trace.beginSection(TAG + " onResume"); super.onResume(); + // Some calls may not be recorded (eg. from quick contact), + // so we should restart recording after these calls. (Recorded call is stopped) + PostCall.restartPerformanceRecordingIfARecentCallExist(this); + if (!PerformanceReport.isRecording()) { + PerformanceReport.startRecording(); + } + mStateSaved = false; if (mFirstLaunch) { displayFragment(getIntent()); @@ -552,7 +580,8 @@ public class DialtactsActivity extends TransactionSafeActivity } if (getIntent().getBooleanExtra(EXTRA_CLEAR_NEW_VOICEMAILS, false)) { - CallLogNotificationsService.markNewVoicemailsAsOld(this, null); + LogUtil.i("DialtactsActivity.onResume", "clearing all new voicemails"); + CallLogNotificationsService.markAllNewVoicemailsAsOld(this); } } @@ -603,6 +632,10 @@ public class DialtactsActivity extends TransactionSafeActivity && !getSystemService(KeyguardManager.class).isKeyguardLocked()) { mListsFragment.markMissedCallsAsReadAndRemoveNotifications(); } + DialerUtils.getDefaultSharedPreferenceForDeviceProtectedStorageContext(this) + .edit() + .putInt(KEY_LAST_TAB, mListsFragment.getCurrentTabIndex()) + .apply(); } @Override @@ -676,13 +709,8 @@ public class DialtactsActivity extends TransactionSafeActivity public void onClick(View view) { int resId = view.getId(); if (resId == R.id.floating_action_button) { - if (mListsFragment.getCurrentTabIndex() == DialtactsPagerAdapter.TAB_INDEX_ALL_CONTACTS - && !mInRegularSearch - && !mInDialpadSearch) { - DialerUtils.startActivityWithErrorToast( - this, IntentUtil.getNewContactIntent(), R.string.add_contact_not_available); - Logger.get(this).logImpression(DialerImpression.Type.NEW_CONTACT_FAB); - } else if (!mIsDialpadShown) { + if (!mIsDialpadShown) { + PerformanceReport.recordClick(UiAction.Type.OPEN_DIALPAD); mInCallDialpadUp = false; showDialpadFragment(true); PostCall.closePrompt(); @@ -712,6 +740,7 @@ public class DialtactsActivity extends TransactionSafeActivity int resId = item.getItemId(); if (resId == R.id.menu_history) { + PerformanceReport.recordClick(UiAction.Type.OPEN_CALL_HISTORY); final Intent intent = new Intent(this, CallLogActivity.class); startActivity(intent); } else if (resId == R.id.menu_clear_frequents) { @@ -722,6 +751,9 @@ public class DialtactsActivity extends TransactionSafeActivity handleMenuSettings(); Logger.get(this).logScreenView(ScreenEvent.Type.SETTINGS, this); return true; + } else if (resId == R.id.menu_new_ui_launcher_shortcut) { + MainComponent.get(this).getMain().createNewUiLauncherShortcut(this); + return true; } return false; } @@ -1020,6 +1052,16 @@ public class DialtactsActivity extends TransactionSafeActivity if (showDialpadChooser && !mDialpadFragment.isVisible()) { mInCallDialpadUp = true; } + } else if (isLastTabEnabled) { + @TabIndex + int tabIndex = + DialerUtils.getDefaultSharedPreferenceForDeviceProtectedStorageContext(this) + .getInt(KEY_LAST_TAB, DialtactsPagerAdapter.TAB_INDEX_SPEED_DIAL); + // If voicemail tab is saved and its availability changes, we still move to the voicemail tab + // but it is quickly removed and shown the contacts tab. + if (mListsFragment != null) { + mListsFragment.showTab(tabIndex); + } } } @@ -1195,6 +1237,8 @@ public class DialtactsActivity extends TransactionSafeActivity @Override public void onBackPressed() { + PerformanceReport.recordClick(UiAction.Type.PRESS_ANDROID_BACK_BUTTON); + if (mStateSaved) { return; } @@ -1279,6 +1323,7 @@ public class DialtactsActivity extends TransactionSafeActivity if (mInDialpadSearch && mSmartDialSearchFragment != null && !mSmartDialSearchFragment.isShowingPermissionRequest()) { + PerformanceReport.recordClick(UiAction.Type.CLOSE_DIALPAD); hideDialpadFragment(true /* animate */, true /* clearDialpad */); return true; } @@ -1287,6 +1332,7 @@ public class DialtactsActivity extends TransactionSafeActivity @Override public void onListFragmentScrollStateChange(int scrollState) { + PerformanceReport.recordScrollStateChange(scrollState); if (scrollState == OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) { hideDialpadFragment(true, false); DialerUtils.hideInputMethod(mParentLayout); @@ -1413,18 +1459,6 @@ public class DialtactsActivity extends TransactionSafeActivity int tabIndex = mListsFragment.getCurrentTabIndex(); mPreviouslySelectedTabIndex = tabIndex; mFloatingActionButtonController.setVisible(true); - if (tabIndex == DialtactsPagerAdapter.TAB_INDEX_ALL_CONTACTS - && !mInRegularSearch - && !mInDialpadSearch) { - mFloatingActionButtonController.changeIcon( - getResources().getDrawable(R.drawable.quantum_ic_person_add_white_24, null), - getResources().getString(R.string.search_shortcut_create_new_contact)); - } else { - mFloatingActionButtonController.changeIcon( - getResources().getDrawable(R.drawable.quantum_ic_dialpad_white_24, null), - getResources().getString(R.string.action_menu_dialpad_button)); - } - timeTabSelected = SystemClock.elapsedRealtime(); } @@ -1509,6 +1543,16 @@ public class DialtactsActivity extends TransactionSafeActivity Arrays.toString(grantResults))); } + @Override + public void onActionModeStateChanged(boolean isEnabled) { + isMultiSelectModeEnabled = isEnabled; + } + + @Override + public boolean isActionModeStateEnabled() { + return isMultiSelectModeEnabled; + } + /** Popup menu accessible from the search bar */ protected class OptionsPopupMenu extends PopupMenu { @@ -1538,6 +1582,10 @@ public class DialtactsActivity extends TransactionSafeActivity simulatorMenuItem.setVisible(false); } + Main dialtacts = MainComponent.get(context).getMain(); + menu.findItem(R.id.menu_new_ui_launcher_shortcut) + .setVisible(dialtacts.isNewUiEnabled(context)); + super.show(); } } |