From af33c593b5ef2ae082f78a9d4f2ebf41390f3b44 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Thu, 25 Jul 2024 13:18:55 +0200 Subject: [PATCH] refactor(filter/AltText): set filter title --- .../android/model/AltTextFilter.java | 9 ++-- .../WarningFilteredStatusDisplayItem.java | 49 +++++++++---------- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/model/AltTextFilter.java b/mastodon/src/main/java/org/joinmastodon/android/model/AltTextFilter.java index 880f2ef62b..c0d2f99cdf 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/model/AltTextFilter.java +++ b/mastodon/src/main/java/org/joinmastodon/android/model/AltTextFilter.java @@ -1,6 +1,8 @@ package org.joinmastodon.android.model; import org.joinmastodon.android.GlobalUserPreferences; +import org.joinmastodon.android.MastodonApp; +import org.joinmastodon.android.R; import org.jsoup.internal.StringUtil; import java.util.EnumSet; @@ -8,9 +10,10 @@ public class AltTextFilter extends LegacyFilter { public AltTextFilter(FilterAction filterAction, EnumSet filterContexts) { - this.filterAction = filterAction; - isRemote = false; - context = filterContexts; + this.filterAction=filterAction; + this.title=MastodonApp.context.getString(R.string.sk_no_alt_text); + this.isRemote=false; + this.context=filterContexts; } @Override diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/WarningFilteredStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/WarningFilteredStatusDisplayItem.java index 37b9d5ec25..2d061a14d9 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/WarningFilteredStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/WarningFilteredStatusDisplayItem.java @@ -8,14 +8,11 @@ import org.joinmastodon.android.R; import org.joinmastodon.android.fragments.BaseStatusListFragment; -import org.joinmastodon.android.model.AltTextFilter; -import org.joinmastodon.android.model.Filter; import org.joinmastodon.android.model.LegacyFilter; import org.joinmastodon.android.model.Status; import java.util.List; -// Mind the gap! public class WarningFilteredStatusDisplayItem extends StatusDisplayItem{ public boolean loading; public List filteredItems; @@ -24,8 +21,8 @@ public class WarningFilteredStatusDisplayItem extends StatusDisplayItem{ public WarningFilteredStatusDisplayItem(String parentID, BaseStatusListFragment parentFragment, Status status, List filteredItems, LegacyFilter applyingFilter){ super(parentID, parentFragment); this.status=status; - this.filteredItems = filteredItems; - this.applyingFilter = applyingFilter; + this.filteredItems=filteredItems; + this.applyingFilter=applyingFilter; } @Override @@ -33,31 +30,31 @@ public Type getType(){ return Type.WARNING; } - public static class Holder extends StatusDisplayItem.Holder{ - public final View warningWrap; - public final Button showBtn; - public final TextView text; - public List filteredItems; - - public Holder(Context context, ViewGroup parent){ - super(context, R.layout.display_item_warning, parent); - warningWrap=findViewById(R.id.warning_wrap); - showBtn=findViewById(R.id.reveal_btn); - showBtn.setOnClickListener(i -> item.parentFragment.onWarningClick(this)); - itemView.setOnClickListener(v->item.parentFragment.onWarningClick(this)); - text=findViewById(R.id.text); - } + public static class Holder extends StatusDisplayItem.Holder{ + public final View warningWrap; + public final Button showBtn; + public final TextView text; + public List filteredItems; + + public Holder(Context context, ViewGroup parent){ + super(context, R.layout.display_item_warning, parent); + warningWrap=findViewById(R.id.warning_wrap); + showBtn=findViewById(R.id.reveal_btn); + showBtn.setOnClickListener(i->item.parentFragment.onWarningClick(this)); + itemView.setOnClickListener(v->item.parentFragment.onWarningClick(this)); + text=findViewById(R.id.text); + } @Override - public void onBind(WarningFilteredStatusDisplayItem item) { - filteredItems = item.filteredItems; - String title = item.applyingFilter instanceof AltTextFilter ? item.parentFragment.getString(R.string.sk_no_alt_text) : item.applyingFilter.title; + public void onBind(WarningFilteredStatusDisplayItem item){ + filteredItems=item.filteredItems; + String title=item.applyingFilter.title; text.setText(item.parentFragment.getString(R.string.sk_filtered, title)); } - @Override - public void onClick(){ + @Override + public void onClick(){ - } - } + } + } }