mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-06 18:57:26 +01:00
Added a clear search bar text button (#1063)
This commit is contained in:
parent
935471d95c
commit
401dba6d83
@ -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);
|
||||
|
10
app/src/main/res/drawable-xhdpi/ic_cancel_24dp.xml
Normal file
10
app/src/main/res/drawable-xhdpi/ic_cancel_24dp.xml
Normal file
@ -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>
|
@ -39,6 +39,16 @@
|
||||
android:inputType="textNoSuggestions"
|
||||
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"
|
||||
|
Loading…
Reference in New Issue
Block a user