Merge branch 'feature/hide_alttext'
# Conflicts: # mastodon/src/androidTest/java/org/joinmastodon/android/utils/StatusFilterPredicateTest.java # mastodon/src/main/java/org/joinmastodon/android/fragments/settings/TimeLineFragment.java # mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/WarningFilteredStatusDisplayItem.java # mastodon/src/main/java/org/joinmastodon/android/utils/StatusFilterPredicate.java # mastodon/src/main/res/values-de-rDE/strings_mo.xml # mastodon/src/main/res/values/strings_mo.xml
This commit is contained in:
@@ -14,6 +14,7 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class StatusFilterPredicate implements Predicate<Status>{
|
||||
private List<LegacyFilter> clientFilters;
|
||||
private final List<LegacyFilter> filters;
|
||||
private final FilterContext context;
|
||||
private final FilterAction action;
|
||||
@@ -22,12 +23,14 @@ public class StatusFilterPredicate implements Predicate<Status>{
|
||||
/**
|
||||
* @param context null makes the predicate pass automatically
|
||||
* @param action defines what the predicate should check:
|
||||
* status should not be hidden or should not display with warning
|
||||
* status should not be hidden or should not display with warning
|
||||
*/
|
||||
public StatusFilterPredicate(List<LegacyFilter> filters, FilterContext context, FilterAction action){
|
||||
this.filters = filters;
|
||||
this.context = context;
|
||||
this.action = action;
|
||||
this.clientFilters = GlobalUserPreferences.showPostsWithoutAlt ? List.of()
|
||||
: List.of(new AltTextFilter(HIDE, HOME, PUBLIC, ACCOUNT), new AltTextFilter(WARN, THREAD, NOTIFICATIONS));
|
||||
}
|
||||
|
||||
public StatusFilterPredicate(List<LegacyFilter> filters, FilterContext context){
|
||||
@@ -54,7 +57,7 @@ public class StatusFilterPredicate implements Predicate<Status>{
|
||||
|
||||
/**
|
||||
* @return whether the status should be displayed without being hidden/warned about.
|
||||
* will always return true if the context is null.
|
||||
* will always return true if the context is null.
|
||||
* true = display this status,
|
||||
* false = filter this status
|
||||
*/
|
||||
@@ -77,6 +80,15 @@ public class StatusFilterPredicate implements Predicate<Status>{
|
||||
.filter(filter -> filter.filterAction == null ? action == FilterAction.HIDE : filter.filterAction == action)
|
||||
.findAny();
|
||||
|
||||
//Apply client filters if no server filter is triggered
|
||||
if (applyingFilter.isEmpty()) {
|
||||
applyingFilter = clientFilters.stream()
|
||||
.filter(filter -> filter.context.contains(context))
|
||||
.filter(filter -> filter.filterAction == null ? action == HIDE : filter.filterAction == action)
|
||||
.filter(filter -> filter.matches(status))
|
||||
.findAny();
|
||||
}
|
||||
|
||||
this.applyingFilter = applyingFilter.orElse(null);
|
||||
return applyingFilter.isEmpty();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user