diff options
Diffstat (limited to 'src/com/android/dialer/widget/SearchEditTextLayout.java')
-rw-r--r-- | src/com/android/dialer/widget/SearchEditTextLayout.java | 25 |
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) { |