Skip to content

Commit

Permalink
refactor(filter/AltText): set filter title
Browse files Browse the repository at this point in the history
  • Loading branch information
FineFindus committed Jul 25, 2024
1 parent 1bb288e commit af33c59
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
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;

public class AltTextFilter extends LegacyFilter {

public AltTextFilter(FilterAction filterAction, EnumSet<FilterContext> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<StatusDisplayItem> filteredItems;
Expand All @@ -24,40 +21,40 @@ public class WarningFilteredStatusDisplayItem extends StatusDisplayItem{
public WarningFilteredStatusDisplayItem(String parentID, BaseStatusListFragment<?> parentFragment, Status status, List<StatusDisplayItem> filteredItems, LegacyFilter applyingFilter){
super(parentID, parentFragment);
this.status=status;
this.filteredItems = filteredItems;
this.applyingFilter = applyingFilter;
this.filteredItems=filteredItems;
this.applyingFilter=applyingFilter;
}

@Override
public Type getType(){
return Type.WARNING;
}

public static class Holder extends StatusDisplayItem.Holder<WarningFilteredStatusDisplayItem>{
public final View warningWrap;
public final Button showBtn;
public final TextView text;
public List<StatusDisplayItem> 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<WarningFilteredStatusDisplayItem>{
public final View warningWrap;
public final Button showBtn;
public final TextView text;
public List<StatusDisplayItem> 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(){

}
}
}
}
}

0 comments on commit af33c59

Please sign in to comment.