summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/app/DialtactsActivity.java
diff options
context:
space:
mode:
authorcalderwoodra <calderwoodra@google.com>2017-09-01 15:25:00 -0700
committerEric Erfanian <erfanian@google.com>2017-09-07 15:49:45 +0000
commitee5bce98231b96bc7f3ecf2d12276571786863f5 (patch)
tree5563c5de980bc12aaeb109db22ae164ad9784f73 /java/com/android/dialer/app/DialtactsActivity.java
parent12b50c650c4fc61ff9f59670e3edf08a0bdb3620 (diff)
Improved behavior of back button in search ui.
Pressing the back button in the search UI now functions as follows: - If the keyboard is opened, the keyboard is minimized - If the dialpad is opened, the dialpad is closed - If the keyboard and dialpad is closed, the search ui is closed Our existing behavior was dependent on whether a query had been built yet. basically, if the user pressed back with no query selected, the search ui was closed. From the bugbash: 7. No scroll bar in the search results if the results do not fill the entire view. The keyboard overlaps the results and there is no way to get to the enter list without dismissing the keyboard. 10. Dismiss the keyboard on tapping the down arrow on the keyboard. Arrow points down but works like back button Bug: 64902476,64137632,62685859,63691995,63939331 Test: manual PiperOrigin-RevId: 167332236 Change-Id: I1c0b5b429316dae119b5fb21be4303d7fe052e35
Diffstat (limited to 'java/com/android/dialer/app/DialtactsActivity.java')
-rw-r--r--java/com/android/dialer/app/DialtactsActivity.java113
1 files changed, 41 insertions, 72 deletions
diff --git a/java/com/android/dialer/app/DialtactsActivity.java b/java/com/android/dialer/app/DialtactsActivity.java
index 74bc8cc33..fc557f0b6 100644
--- a/java/com/android/dialer/app/DialtactsActivity.java
+++ b/java/com/android/dialer/app/DialtactsActivity.java
@@ -49,7 +49,6 @@ import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.DragEvent;
import android.view.Gravity;
-import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
@@ -169,6 +168,7 @@ public class DialtactsActivity extends TransactionSafeActivity
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";
+ private static final String KEY_IN_NEW_SEARCH_UI = "in_new_search_ui";
private static final String KEY_SEARCH_QUERY = "search_query";
private static final String KEY_FIRST_LAUNCH = "first_launch";
private static final String KEY_WAS_CONFIGURATION_CHANGE = "was_configuration_change";
@@ -213,6 +213,8 @@ public class DialtactsActivity extends TransactionSafeActivity
*/
private boolean mStateSaved;
+ private boolean mIsKeyboardOpen;
+ private boolean mInNewSearch;
private boolean mIsRestarting;
private boolean mInDialpadSearch;
private boolean mInRegularSearch;
@@ -333,27 +335,6 @@ public class DialtactsActivity extends TransactionSafeActivity
private int mActionBarHeight;
private int mPreviouslySelectedTabIndex;
- /** Handles the user closing the soft keyboard. */
- private final View.OnKeyListener mSearchEditTextLayoutListener =
- new View.OnKeyListener() {
- @Override
- public boolean onKey(View v, int keyCode, KeyEvent event) {
- 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();
- }
- }
- return false;
- }
- };
/**
* The text returned from a voice search query. Set in {@link #onActivityResult} and used in
@@ -413,30 +394,20 @@ public class DialtactsActivity extends TransactionSafeActivity
SearchEditTextLayout searchEditTextLayout =
actionBar.getCustomView().findViewById(R.id.search_view_container);
- searchEditTextLayout.setPreImeKeyListener(mSearchEditTextLayoutListener);
mActionBarController = new ActionBarController(this, searchEditTextLayout);
mSearchView = searchEditTextLayout.findViewById(R.id.search_view);
mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener);
mSearchView.setHint(getSearchBoxHint());
+
mVoiceSearchButton = searchEditTextLayout.findViewById(R.id.voice_search_button);
searchEditTextLayout
.findViewById(R.id.search_box_collapsed)
.setOnClickListener(mSearchViewOnClickListener);
- searchEditTextLayout.setCallback(
- new SearchEditTextLayout.Callback() {
- @Override
- public void onBackButtonClicked() {
- onBackPressed();
- }
-
- @Override
- public void onSearchViewClicked() {
- // Hide FAB, as the keyboard is shown.
- mFloatingActionButtonController.scaleOut();
- }
- });
+ searchEditTextLayout
+ .findViewById(R.id.search_back_button)
+ .setOnClickListener(v -> exitSearchUi());
mIsLandscape =
getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;
@@ -463,6 +434,7 @@ public class DialtactsActivity extends TransactionSafeActivity
mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY);
mInRegularSearch = savedInstanceState.getBoolean(KEY_IN_REGULAR_SEARCH_UI);
mInDialpadSearch = savedInstanceState.getBoolean(KEY_IN_DIALPAD_SEARCH_UI);
+ mInNewSearch = savedInstanceState.getBoolean(KEY_IN_NEW_SEARCH_UI);
mFirstLaunch = savedInstanceState.getBoolean(KEY_FIRST_LAUNCH);
mWasConfigurationChange = savedInstanceState.getBoolean(KEY_WAS_CONFIGURATION_CHANGE);
mShowDialpadOnResume = savedInstanceState.getBoolean(KEY_IS_DIALPAD_SHOWN);
@@ -657,6 +629,7 @@ public class DialtactsActivity extends TransactionSafeActivity
outState.putString(KEY_SEARCH_QUERY, mSearchQuery);
outState.putBoolean(KEY_IN_REGULAR_SEARCH_UI, mInRegularSearch);
outState.putBoolean(KEY_IN_DIALPAD_SEARCH_UI, mInDialpadSearch);
+ outState.putBoolean(KEY_IN_NEW_SEARCH_UI, mInNewSearch);
outState.putBoolean(KEY_FIRST_LAUNCH, mFirstLaunch);
outState.putBoolean(KEY_IS_DIALPAD_SHOWN, mIsDialpadShown);
outState.putBoolean(KEY_WAS_CONFIGURATION_CHANGE, isChangingConfigurations());
@@ -896,14 +869,19 @@ public class DialtactsActivity extends TransactionSafeActivity
updateSearchFragmentPosition();
}
+ @Override
+ public void onCallPlacedFromDialpad() {
+ hideDialpadFragment(false /* animate */, true /*clearDialpad */);
+ exitSearchUi();
+ }
+
/**
* Initiates animations and other visual updates to hide the dialpad. The fragment is hidden in a
* callback after the hide animation ends.
*
* @see #commitDialpadFragmentHide
*/
- @Override
- public void hideDialpadFragment(boolean animate, boolean clearDialpad) {
+ private void hideDialpadFragment(boolean animate, boolean clearDialpad) {
LogUtil.enterBlock("DialtactsActivity.hideDialpadFragment");
if (mDialpadFragment == null || mDialpadFragment.getView() == null) {
return;
@@ -938,11 +916,6 @@ public class DialtactsActivity extends TransactionSafeActivity
mActionBarController.onDialpadDown();
- if (isInSearchUi()) {
- if (TextUtils.isEmpty(mSearchQuery)) {
- exitSearchUi();
- }
- }
// reset the title to normal.
setTitle(R.string.launcherActivityLabel);
}
@@ -990,7 +963,7 @@ public class DialtactsActivity extends TransactionSafeActivity
@Override
public boolean isInSearchUi() {
- return mInDialpadSearch || mInRegularSearch;
+ return mInDialpadSearch || mInRegularSearch || mInNewSearch;
}
@Override
@@ -1001,6 +974,7 @@ public class DialtactsActivity extends TransactionSafeActivity
private void setNotInSearchUi() {
mInDialpadSearch = false;
mInRegularSearch = false;
+ mInNewSearch = false;
}
private void hideDialpadAndSearchUi() {
@@ -1174,17 +1148,21 @@ public class DialtactsActivity extends TransactionSafeActivity
}
final String tag;
+ mInDialpadSearch = false;
+ mInRegularSearch = false;
+ mInNewSearch = false;
boolean useNewSearch =
ConfigProviderBindings.get(this).getBoolean("enable_new_search_fragment", false);
if (useNewSearch) {
tag = TAG_NEW_SEARCH_FRAGMENT;
+ mInNewSearch = true;
} else if (smartDialSearch) {
tag = TAG_SMARTDIAL_SEARCH_FRAGMENT;
+ mInDialpadSearch = true;
} else {
tag = TAG_REGULAR_SEARCH_FRAGMENT;
+ mInRegularSearch = true;
}
- mInDialpadSearch = smartDialSearch;
- mInRegularSearch = !smartDialSearch;
mFloatingActionButtonController.scaleOut();
@@ -1308,43 +1286,34 @@ public class DialtactsActivity extends TransactionSafeActivity
return;
}
if (mIsDialpadShown) {
- if (TextUtils.isEmpty(mSearchQuery)
- || (mSmartDialSearchFragment != null
- && mSmartDialSearchFragment.isVisible()
- && mSmartDialSearchFragment.getAdapter().getCount() == 0)) {
- exitSearchUi();
- }
hideDialpadFragment(true, false);
} else if (isInSearchUi()) {
- exitSearchUi();
- DialerUtils.hideInputMethod(mParentLayout);
+ if (mIsKeyboardOpen) {
+ DialerUtils.hideInputMethod(mParentLayout);
+ PerformanceReport.recordClick(UiAction.Type.HIDE_KEYBOARD_IN_SEARCH);
+ } else {
+ exitSearchUi();
+ }
} else {
super.onBackPressed();
}
}
- private void maybeEnterSearchUi() {
- if (!isInSearchUi()) {
- enterSearchUi(true /* isSmartDial */, mSearchQuery, false);
+ @Override
+ public void onConfigurationChanged(Configuration configuration) {
+ super.onConfigurationChanged(configuration);
+ // Checks whether a hardware keyboard is available
+ if (configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_NO) {
+ mIsKeyboardOpen = true;
+ } else if (configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
+ mIsKeyboardOpen = false;
}
}
- /** @return True if the search UI was exited, false otherwise */
- private boolean maybeExitSearchUi() {
- if (isInSearchUi() && TextUtils.isEmpty(mSearchQuery)) {
- exitSearchUi();
- DialerUtils.hideInputMethod(mParentLayout);
- return true;
+ private void maybeEnterSearchUi() {
+ if (!isInSearchUi()) {
+ enterSearchUi(true /* isSmartDial */, mSearchQuery, false);
}
- return false;
- }
-
- private void showFabInSearchUi() {
- mFloatingActionButtonController.changeIcon(
- getResources().getDrawable(R.drawable.quantum_ic_dialpad_white_24, null),
- getResources().getString(R.string.action_menu_dialpad_button));
- mFloatingActionButtonController.align(getFabAlignment(), false /* animate */);
- mFloatingActionButtonController.scaleIn(FAB_SCALE_IN_DELAY_MS);
}
@Override