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 | |
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 '')
3 files changed, 32 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); diff --git a/app/src/main/res/drawable-xhdpi/ic_cancel_24dp.xml b/app/src/main/res/drawable-xhdpi/ic_cancel_24dp.xml new file mode 100644 index 00000000..b20b903f --- /dev/null +++ b/app/src/main/res/drawable-xhdpi/ic_cancel_24dp.xml @@ -0,0 +1,10 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="24dp" + android:height="24dp" + android:viewportWidth="48" + android:viewportHeight="48" + android:tint="?attr/colorControlNormal"> + <path + android:fillColor="@android:color/white" + android:pathData="M16.5,33.6 L24,26.1 31.5,33.6 33.6,31.5 26.1,24 33.6,16.5 31.5,14.4 24,21.9 16.5,14.4 14.4,16.5 21.9,24 14.4,31.5ZM24,44Q19.9,44 16.25,42.425Q12.6,40.85 9.875,38.125Q7.15,35.4 5.575,31.75Q4,28.1 4,24Q4,19.85 5.575,16.2Q7.15,12.55 9.875,9.85Q12.6,7.15 16.25,5.575Q19.9,4 24,4Q28.15,4 31.8,5.575Q35.45,7.15 38.15,9.85Q40.85,12.55 42.425,16.2Q44,19.85 44,24Q44,28.1 42.425,31.75Q40.85,35.4 38.15,38.125Q35.45,40.85 31.8,42.425Q28.15,44 24,44ZM24,41Q31.1,41 36.05,36.025Q41,31.05 41,24Q41,16.9 36.05,11.95Q31.1,7 24,7Q16.95,7 11.975,11.95Q7,16.9 7,24Q7,31.05 11.975,36.025Q16.95,41 24,41ZM24,24Q24,24 24,24Q24,24 24,24Q24,24 24,24Q24,24 24,24Q24,24 24,24Q24,24 24,24Q24,24 24,24Q24,24 24,24Z"/> +</vector> diff --git a/app/src/main/res/layout/activity_search.xml b/app/src/main/res/layout/activity_search.xml index 8d4055ca..3e68d158 100644 --- a/app/src/main/res/layout/activity_search.xml +++ b/app/src/main/res/layout/activity_search.xml @@ -40,6 +40,16 @@ android:imeOptions="actionSearch" /> <ImageView + android:id="@+id/clear_search_edit_view_search_activity" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="8dp" + android:src="@drawable/ic_cancel_24dp" + android:clickable="true" + android:focusable="true" + android:background="?attr/actionBarItemBackground" /> + + <ImageView android:id="@+id/link_handler_image_view_search_activity" android:layout_width="wrap_content" android:layout_height="wrap_content" |