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 5637c3b05..691e28864 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java @@ -350,14 +350,19 @@ private void bindView() { if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) { adapter = new SearchActivityRecyclerViewAdapter(this, mCustomThemeWrapper, new SearchActivityRecyclerViewAdapter.ItemOnClickListener() { @Override - public void onClick(RecentSearchQuery recentSearchQuery) { - searchInSubredditOrUserName = recentSearchQuery.getSearchInSubredditOrUserName(); - searchInMultiReddit = MultiReddit.getDummyMultiReddit(recentSearchQuery.getMultiRedditPath()); - if (searchInMultiReddit != null && recentSearchQuery.getMultiRedditDisplayName() != null) { - searchInMultiReddit.setDisplayName(recentSearchQuery.getMultiRedditDisplayName()); + public void onClick(RecentSearchQuery recentSearchQuery, boolean searchImmediately) { + if (searchImmediately) { + searchInSubredditOrUserName = recentSearchQuery.getSearchInSubredditOrUserName(); + searchInMultiReddit = MultiReddit.getDummyMultiReddit(recentSearchQuery.getMultiRedditPath()); + if (searchInMultiReddit != null && recentSearchQuery.getMultiRedditDisplayName() != null) { + searchInMultiReddit.setDisplayName(recentSearchQuery.getMultiRedditDisplayName()); + } + searchInThingType = recentSearchQuery.getSearchInThingType(); + search(recentSearchQuery.getSearchQuery()); + } else { + binding.searchEditTextSearchActivity.setText(recentSearchQuery.getSearchQuery()); + binding.searchEditTextSearchActivity.setSelection(recentSearchQuery.getSearchQuery().length()); } - searchInThingType = recentSearchQuery.getSearchInThingType(); - search(recentSearchQuery.getSearchQuery()); } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java index e7bf496e8..bb788bcc5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java @@ -22,12 +22,13 @@ public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter { if (recentSearchQueries != null && !recentSearchQueries.isEmpty()) { - itemOnClickListener.onClick(recentSearchQueries.get(getBindingAdapterPosition())); + itemOnClickListener.onClick(recentSearchQueries.get(getBindingAdapterPosition()), true); } }); itemView.setOnLongClickListener(view -> { - itemOnClickListener.onDelete(recentSearchQueries.get(getBindingAdapterPosition())); + if (recentSearchQueries != null && !recentSearchQueries.isEmpty()) { + itemOnClickListener.onDelete(recentSearchQueries.get(getBindingAdapterPosition())); + } return true; }); + + binding.selectQueryImageViewItemRecentSearchQuery.setOnClickListener(view -> { + if (recentSearchQueries != null && !recentSearchQueries.isEmpty()) { + itemOnClickListener.onClick(recentSearchQueries.get(getBindingAdapterPosition()), false); + } + }); } } } \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_select_query_24dp.xml b/app/src/main/res/drawable/ic_select_query_24dp.xml new file mode 100644 index 000000000..f331fde3e --- /dev/null +++ b/app/src/main/res/drawable/ic_select_query_24dp.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/layout/item_recent_search_query.xml b/app/src/main/res/layout/item_recent_search_query.xml index 97dc36279..99679b805 100644 --- a/app/src/main/res/layout/item_recent_search_query.xml +++ b/app/src/main/res/layout/item_recent_search_query.xml @@ -8,39 +8,59 @@ android:focusable="true" style="?attr/materialCardViewFilledStyle"> - + android:marqueeRepeatLimit="marquee_forever" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toStartOf="@id/select_query_image_view_item_recent_search_query" /> + android:marqueeRepeatLimit="marquee_forever" + app:layout_constraintTop_toBottomOf="@id/recent_search_query_text_view_item_recent_search_query" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintEnd_toStartOf="@id/select_query_image_view_item_recent_search_query" /> - + + +