summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/main/impl/toolbar/SearchBarView.java
diff options
context:
space:
mode:
authorcalderwoodra <calderwoodra@google.com>2018-01-18 14:03:17 -0800
committerCopybara-Service <copybara-piper@google.com>2018-01-18 15:17:47 -0800
commit3b735de1525313b0517473aff849914b1722a445 (patch)
tree3eb39e7d9d3b990ce76119acd1dd231f4611fd35 /java/com/android/dialer/main/impl/toolbar/SearchBarView.java
parent5f8c7c7637a7dcb2c1b7e54565191d7f357d0336 (diff)
Fixed regression with search not reacting properly to on touch events.
There are a few interesting UX niceties that we support in search: 1) When in regular search with an empty query, close the UI if the user touches the blank space. 2) When in regular search with a non-empty query, hide the keyboard if the user touches the the list so they can see all results. 2) When in dialpad search with an empty query, close the UI if the user touches the blank space. 3) When in dialpad search with a non-empty query, hide the dialpad so the user can see the full list of results. This change also adds logic to transfer the dialpad query to the search bar. Bug: 64655802 Test: MainActivityIntegrationTest PiperOrigin-RevId: 182434126 Change-Id: Iabb73b0018fa20e2811010a73a35d3aa3b35343b
Diffstat (limited to 'java/com/android/dialer/main/impl/toolbar/SearchBarView.java')
-rw-r--r--java/com/android/dialer/main/impl/toolbar/SearchBarView.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/java/com/android/dialer/main/impl/toolbar/SearchBarView.java b/java/com/android/dialer/main/impl/toolbar/SearchBarView.java
index 306a5bb4e..6b9f39dc9 100644
--- a/java/com/android/dialer/main/impl/toolbar/SearchBarView.java
+++ b/java/com/android/dialer/main/impl/toolbar/SearchBarView.java
@@ -30,6 +30,7 @@ import android.view.View;
import android.widget.EditText;
import android.widget.FrameLayout;
import com.android.dialer.animation.AnimUtils;
+import com.android.dialer.common.UiUtil;
import com.android.dialer.util.DialerUtils;
import com.google.common.base.Optional;
@@ -44,6 +45,9 @@ final class SearchBarView extends FrameLayout {
private SearchBarListener listener;
private EditText searchBox;
+ // This useful for when the query didn't actually change. We want to avoid making excessive calls
+ // where we can since IPCs can take a long time on slow networks.
+ private boolean skipLatestTextChange;
private int initialHeight;
private boolean isExpanded;
@@ -177,6 +181,24 @@ final class SearchBarView extends FrameLayout {
this.listener = listener;
}
+ public String getQuery() {
+ return searchBox.getText().toString();
+ }
+
+ public void setQueryWithoutUpdate(String query) {
+ skipLatestTextChange = true;
+ searchBox.setText(query);
+ searchBox.setSelection(searchBox.getText().length());
+ }
+
+ public void hideKeyboard() {
+ UiUtil.hideKeyboardFrom(getContext(), searchBox);
+ }
+
+ public void showKeyboard() {
+ UiUtil.openKeyboardFrom(getContext(), searchBox);
+ }
+
/** Handles logic for text changes in the search box. */
private class SearchBoxTextWatcher implements TextWatcher {
@@ -189,6 +211,11 @@ final class SearchBarView extends FrameLayout {
@Override
public void afterTextChanged(Editable s) {
clearButton.setVisibility(TextUtils.isEmpty(s) ? GONE : VISIBLE);
+ if (skipLatestTextChange) {
+ skipLatestTextChange = false;
+ return;
+ }
+
listener.onSearchQueryUpdated(s.toString());
}
}