summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2015-05-05 17:38:23 -0700
committerAndrew Lee <anwlee@google.com>2015-05-06 14:15:43 -0700
commit99413b41c5af53bf00d6726822aceba3f5baea73 (patch)
tree291bee63a92bde50e7690ebded30e9f9d2e413cd /src
parentf4ea223170ab5aaf63562d7d46b08fd24664bdce (diff)
Hide "clear" action if search text is empty.
Bug: 20700084 Change-Id: Id2574f5b721dbaa4d7aab04945c2ad08c390835f
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/widget/SearchEditTextLayout.java25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/com/android/dialer/widget/SearchEditTextLayout.java b/src/com/android/dialer/widget/SearchEditTextLayout.java
index f22a3be9e..f1fa9868a 100644
--- a/src/com/android/dialer/widget/SearchEditTextLayout.java
+++ b/src/com/android/dialer/widget/SearchEditTextLayout.java
@@ -20,6 +20,9 @@ import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
import android.util.AttributeSet;
+import android.text.Editable;
+import android.text.TextUtils;
+import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
@@ -123,6 +126,21 @@ public class SearchEditTextLayout extends FrameLayout {
}
});
+ mSearchView.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+ mClearButtonView.setVisibility(TextUtils.isEmpty(s) ? View.GONE : View.VISIBLE);
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ }
+ });
+
findViewById(R.id.search_close_button).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
@@ -177,6 +195,7 @@ public class SearchEditTextLayout extends FrameLayout {
mIsFadedOut = true;
}
}
+
public void expand(boolean animate, boolean requestFocus) {
updateVisibility(true /* isExpand */);
@@ -245,7 +264,11 @@ public class SearchEditTextLayout extends FrameLayout {
// TODO: Prevents keyboard from jumping up in landscape mode after exiting the
// SearchFragment when the query string is empty. More elegant fix?
//mExpandedSearchBox.setVisibility(expandedViewVisibility);
- mClearButtonView.setVisibility(expandedViewVisibility);
+ if (TextUtils.isEmpty(mSearchView.getText())) {
+ mClearButtonView.setVisibility(View.GONE);
+ } else {
+ mClearButtonView.setVisibility(expandedViewVisibility);
+ }
}
private void prepareAnimator(final boolean expand) {