aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-08-15 00:20:26 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2024-08-15 00:20:26 +0000
commit75f5a3637a6707bcc2ff17783e08985390bb88ef (patch)
tree19c37f774569f7e68d962c4e924e12a5078e4579 /app/src/main
parentc29aae3b9703aae75d3c31bef01741251b979a6c (diff)
downloadinfinity-for-reddit-75f5a3637a6707bcc2ff17783e08985390bb88ef.tar
infinity-for-reddit-75f5a3637a6707bcc2ff17783e08985390bb88ef.tar.gz
infinity-for-reddit-75f5a3637a6707bcc2ff17783e08985390bb88ef.tar.bz2
infinity-for-reddit-75f5a3637a6707bcc2ff17783e08985390bb88ef.tar.lz
infinity-for-reddit-75f5a3637a6707bcc2ff17783e08985390bb88ef.tar.xz
infinity-for-reddit-75f5a3637a6707bcc2ff17783e08985390bb88ef.tar.zst
infinity-for-reddit-75f5a3637a6707bcc2ff17783e08985390bb88ef.zip
Show 'All subreddits' in recent searches in SearchActivity if applicable.
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java25
-rw-r--r--app/src/main/res/layout/item_recent_search_query.xml3
2 files changed, 21 insertions, 7 deletions
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 60d6c634..0761ed08 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java
@@ -2,7 +2,6 @@ package ml.docilealligator.infinityforreddit.adapters;
import android.content.res.ColorStateList;
import android.view.LayoutInflater;
-import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
@@ -10,6 +9,7 @@ import androidx.recyclerview.widget.RecyclerView;
import java.util.List;
+import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.databinding.ItemRecentSearchQueryBinding;
@@ -21,6 +21,8 @@ public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private final int filledCardViewBackgroundColor;
private final int primaryTextColor;
private final int secondaryTextColor;
+ private final int subredditTextColor;
+ private final int userTextColor;
private final ItemOnClickListener itemOnClickListener;
public interface ItemOnClickListener {
@@ -34,6 +36,8 @@ public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<Recy
this.filledCardViewBackgroundColor = customThemeWrapper.getFilledCardViewBackgroundColor();
this.primaryTextColor = customThemeWrapper.getPrimaryTextColor();
this.secondaryTextColor = customThemeWrapper.getSecondaryTextColor();
+ this.subredditTextColor = customThemeWrapper.getSubreddit();
+ this.userTextColor = customThemeWrapper.getUsername();
this.itemOnClickListener = itemOnClickListener;
}
@@ -50,9 +54,22 @@ public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<Recy
RecentSearchQuery recentSearchQuery = recentSearchQueries.get(position);
((RecentSearchQueryViewHolder) holder).binding.recentSearchQueryTextViewItemRecentSearchQuery.setText(recentSearchQuery.getSearchQuery());
if (recentSearchQuery.getSearchInSubredditOrUserName() != null && !recentSearchQuery.getSearchInSubredditOrUserName().isEmpty()) {
- ((RecentSearchQueryViewHolder) holder).binding.recentSearchQueryWhereTextViewItemRecentSearchQuery.setVisibility(View.VISIBLE);
+ if (recentSearchQuery.isSearchInIsUser()) {
+ ((RecentSearchQueryViewHolder) holder).binding.recentSearchQueryWhereTextViewItemRecentSearchQuery
+ .setTextColor(userTextColor);
+ ((RecentSearchQueryViewHolder) holder).binding.recentSearchQueryWhereTextViewItemRecentSearchQuery
+ .setText("u/" + recentSearchQuery.getSearchQuery());
+ } else {
+ ((RecentSearchQueryViewHolder) holder).binding.recentSearchQueryWhereTextViewItemRecentSearchQuery
+ .setTextColor(subredditTextColor);
+ ((RecentSearchQueryViewHolder) holder).binding.recentSearchQueryWhereTextViewItemRecentSearchQuery
+ .setText("r/" + recentSearchQuery.getSearchQuery());
+ }
+ } else {
((RecentSearchQueryViewHolder) holder).binding.recentSearchQueryWhereTextViewItemRecentSearchQuery
- .setText((recentSearchQuery.isSearchInIsUser() ? "u/" : "r/") + recentSearchQuery.getSearchQuery());
+ .setTextColor(secondaryTextColor);
+ ((RecentSearchQueryViewHolder) holder).binding.recentSearchQueryWhereTextViewItemRecentSearchQuery
+ .setText(R.string.all_subreddits);
}
holder.itemView.postDelayed(() -> {
((RecentSearchQueryViewHolder) holder).binding.recentSearchQueryTextViewItemRecentSearchQuery.setSelected(true);
@@ -71,7 +88,6 @@ public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<Recy
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
super.onViewRecycled(holder);
if (holder instanceof RecentSearchQueryViewHolder) {
- ((RecentSearchQueryViewHolder) holder).binding.recentSearchQueryWhereTextViewItemRecentSearchQuery.setVisibility(View.GONE);
((RecentSearchQueryViewHolder) holder).binding.recentSearchQueryTextViewItemRecentSearchQuery.setSelected(false);
((RecentSearchQueryViewHolder) holder).binding.recentSearchQueryWhereTextViewItemRecentSearchQuery.setSelected(false);
}
@@ -92,7 +108,6 @@ public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<Recy
itemView.setBackgroundTintList(ColorStateList.valueOf(filledCardViewBackgroundColor));
binding.recentSearchQueryTextViewItemRecentSearchQuery.setTextColor(primaryTextColor);
- binding.recentSearchQueryWhereTextViewItemRecentSearchQuery.setTextColor(secondaryTextColor);
if (activity.typeface != null) {
binding.recentSearchQueryTextViewItemRecentSearchQuery.setTypeface(activity.typeface);
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 dc732c03..2ca122f4 100644
--- a/app/src/main/res/layout/item_recent_search_query.xml
+++ b/app/src/main/res/layout/item_recent_search_query.xml
@@ -35,8 +35,7 @@
android:textSize="?attr/font_default"
android:singleLine="true"
android:ellipsize="marquee"
- android:marqueeRepeatLimit="marquee_forever"
- android:visibility="gone" />
+ android:marqueeRepeatLimit="marquee_forever" />
</LinearLayout>