summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Lee <anwlee@google.com>2015-05-07 08:18:16 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-05-07 08:18:16 +0000
commit46c90e5f0905a030ea5cc640d9e99bc8a2fe3440 (patch)
treef4116f50d97d89c804f849458b921e441e36ff15 /src
parentff4ef7e48b2f707bcf1e2c426de730bd7153acc6 (diff)
parent99413b41c5af53bf00d6726822aceba3f5baea73 (diff)
am 99413b41: Hide "clear" action if search text is empty.
* commit '99413b41c5af53bf00d6726822aceba3f5baea73': Hide "clear" action if search text is empty.
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) {