diff options
author | MChen321 <76930316+MChen321@users.noreply.github.com> | 2022-09-09 02:05:30 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-09 02:05:30 +0000 |
commit | 401dba6d83052cf0c9c60a74e8460e356f39bcb2 (patch) | |
tree | ae746f44ada7cfa47fb6a511a39910b72d155029 /app/src/main/java/ml | |
parent | 935471d95cba81d4e4f5463ffc0a905a6481a8ef (diff) | |
download | infinity-for-reddit-401dba6d83052cf0c9c60a74e8460e356f39bcb2.tar infinity-for-reddit-401dba6d83052cf0c9c60a74e8460e356f39bcb2.tar.gz infinity-for-reddit-401dba6d83052cf0c9c60a74e8460e356f39bcb2.tar.bz2 infinity-for-reddit-401dba6d83052cf0c9c60a74e8460e356f39bcb2.tar.lz infinity-for-reddit-401dba6d83052cf0c9c60a74e8460e356f39bcb2.tar.xz infinity-for-reddit-401dba6d83052cf0c9c60a74e8460e356f39bcb2.tar.zst infinity-for-reddit-401dba6d83052cf0c9c60a74e8460e356f39bcb2.zip |
Added a clear search bar text button (#1063)
Diffstat (limited to 'app/src/main/java/ml')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java index cf28ff85..f9fa34f3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java @@ -92,6 +92,8 @@ public class SearchActivity extends BaseActivity { Toolbar toolbar; @BindView(R.id.search_edit_text_search_activity) EditText searchEditText; + @BindView(R.id.clear_search_edit_view_search_activity) + ImageView clearSearchTextImageView; @BindView(R.id.link_handler_image_view_search_activity) ImageView linkHandlerImageView; @BindView(R.id.subreddit_name_relative_layout_search_activity) @@ -154,6 +156,8 @@ public class SearchActivity extends BaseActivity { setSupportActionBar(toolbar); + clearSearchTextImageView.setVisibility(View.GONE); + searchOnlySubreddits = getIntent().getBooleanExtra(EXTRA_SEARCH_ONLY_SUBREDDITS, false); searchOnlyUsers = getIntent().getBooleanExtra(EXTRA_SEARCH_ONLY_USERS, false); @@ -236,6 +240,9 @@ public class SearchActivity extends BaseActivity { } }); + clearSearchTextImageView.setVisibility(View.VISIBLE); + } else { + clearSearchTextImageView.setVisibility(View.GONE); } } }); @@ -250,6 +257,10 @@ public class SearchActivity extends BaseActivity { return false; }); + clearSearchTextImageView.setOnClickListener(view -> { + searchEditText.getText().clear(); + }); + linkHandlerImageView.setOnClickListener(view -> { if (!searchEditText.getText().toString().equals("")) { Intent intent = new Intent(this, LinkResolverActivity.class); @@ -378,6 +389,7 @@ public class SearchActivity extends BaseActivity { int toolbarPrimaryTextAndIconColorColor = mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor(); searchEditText.setTextColor(toolbarPrimaryTextAndIconColorColor); searchEditText.setHintTextColor(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor()); + clearSearchTextImageView.setColorFilter(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor(), android.graphics.PorterDuff.Mode.SRC_IN); linkHandlerImageView.setColorFilter(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor(), android.graphics.PorterDuff.Mode.SRC_IN); int colorAccent = mCustomThemeWrapper.getColorAccent(); searchInTextView.setTextColor(colorAccent); |