PR comments:
- StatusFilterPredicate sets clientFilters bases on settings - Reverted changes on SettingsFragment - Resources in strings_mo.xml - removed duplicate comments - conditional in onBind method
This commit is contained in:
@@ -296,10 +296,6 @@ public class SettingsFragment extends MastodonToolbarFragment implements Provide
|
||||
GlobalUserPreferences.showNoAltIndicator=i.checked;
|
||||
GlobalUserPreferences.save();
|
||||
}));
|
||||
items.add(new SwitchItem(R.string.sk_settings_show_posts_without_alt, R.drawable.ic_fluent_eye_tracking_on_24_regular, GlobalUserPreferences.showPostsWithoutAlt, i->{
|
||||
GlobalUserPreferences.showPostsWithoutAlt =i.checked;
|
||||
GlobalUserPreferences.save();
|
||||
}));
|
||||
items.add(new SwitchItem(R.string.sk_settings_collapse_long_posts, R.drawable.ic_fluent_chevron_down_24_regular, GlobalUserPreferences.collapseLongPosts, i->{
|
||||
GlobalUserPreferences.collapseLongPosts=i.checked;
|
||||
GlobalUserPreferences.save();
|
||||
|
||||
@@ -64,7 +64,7 @@ public class TimeLineFragment extends SettingsBaseFragment{
|
||||
GlobalUserPreferences.save();
|
||||
needAppRestart=true;
|
||||
}));
|
||||
items.add(new SwitchItem(R.string.sk_settings_show_posts_without_alt, R.drawable.ic_fluent_eye_tracking_on_24_regular, GlobalUserPreferences.showPostsWithoutAlt, i->{
|
||||
items.add(new SwitchItem(R.string.mo_settings_show_posts_without_alt, R.string.mo_settings_show_posts_without_alt_summary, R.drawable.ic_fluent_eye_tracking_on_24_regular, GlobalUserPreferences.showPostsWithoutAlt, i->{
|
||||
GlobalUserPreferences.showPostsWithoutAlt =i.checked;
|
||||
GlobalUserPreferences.save();
|
||||
needAppRestart=true;
|
||||
|
||||
@@ -16,6 +16,6 @@ public class AltTextFilter extends Filter {
|
||||
|
||||
@Override
|
||||
public boolean matches(Status status) {
|
||||
return !GlobalUserPreferences.showPostsWithoutAlt && status.getContentStatus().mediaAttachments.stream().map(attachment -> attachment.description).anyMatch(StringUtil::isBlank);
|
||||
return status.getContentStatus().mediaAttachments.stream().map(attachment -> attachment.description).anyMatch(StringUtil::isBlank);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,11 +51,8 @@ public class WarningFilteredStatusDisplayItem extends StatusDisplayItem{
|
||||
@Override
|
||||
public void onBind(WarningFilteredStatusDisplayItem item) {
|
||||
filteredItems = item.filteredItems;
|
||||
if(item.applyingFilter instanceof AltTextFilter){
|
||||
text.setText(item.parentFragment.getString(R.string.sk_filtered,item.parentFragment.getString(R.string.sk_no_alt_text)));
|
||||
}else{
|
||||
text.setText(item.parentFragment.getString(R.string.sk_filtered, item.applyingFilter.title));
|
||||
}
|
||||
String title = item.applyingFilter instanceof AltTextFilter ? item.parentFragment.getString(R.string.sk_no_alt_text) : item.applyingFilter.title;
|
||||
text.setText(item.parentFragment.getString(R.string.sk_filtered, title));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,6 +8,7 @@ import static org.joinmastodon.android.model.Filter.FilterContext.NOTIFICATIONS;
|
||||
import static org.joinmastodon.android.model.Filter.FilterContext.PUBLIC;
|
||||
import static org.joinmastodon.android.model.Filter.FilterContext.THREAD;
|
||||
|
||||
import org.joinmastodon.android.GlobalUserPreferences;
|
||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||
import org.joinmastodon.android.model.AltTextFilter;
|
||||
import org.joinmastodon.android.model.Filter;
|
||||
@@ -23,8 +24,7 @@ import java.util.stream.Stream;
|
||||
public class StatusFilterPredicate implements Predicate<Status> {
|
||||
|
||||
//Hide in timelines and warn in threads
|
||||
private final List<Filter> clientFilters = List.of( new AltTextFilter(HIDE, HOME, PUBLIC, ACCOUNT),
|
||||
new AltTextFilter(WARN, THREAD, NOTIFICATIONS));
|
||||
private final List<Filter> clientFilters;
|
||||
private final List<Filter> filters;
|
||||
private final Filter.FilterContext context;
|
||||
private final Filter.FilterAction action;
|
||||
@@ -39,6 +39,8 @@ public class StatusFilterPredicate implements Predicate<Status> {
|
||||
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<Filter> filters, Filter.FilterContext context) {
|
||||
@@ -51,9 +53,9 @@ public class StatusFilterPredicate implements Predicate<Status> {
|
||||
* status should not be hidden or should not display with warning
|
||||
*/
|
||||
public StatusFilterPredicate(String accountID, Filter.FilterContext context, Filter.FilterAction action) {
|
||||
filters = AccountSessionManager.getInstance().getAccount(accountID).wordFilters.stream().filter(f -> f.context.contains(context)).collect(Collectors.toList());
|
||||
this.context = context;
|
||||
this.action = action;
|
||||
this(AccountSessionManager.getInstance().getAccount(accountID).wordFilters.stream().filter(f -> f.context.contains(context)).collect(Collectors.toList()),
|
||||
context,
|
||||
action);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,9 +67,9 @@ 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.
|
||||
* true = display this status,
|
||||
* false = filter this status
|
||||
* will always return true if the context is null.
|
||||
* true = display this status,
|
||||
* false = filter this status
|
||||
*/
|
||||
@Override
|
||||
public boolean test(Status status) {
|
||||
@@ -91,11 +93,8 @@ public class StatusFilterPredicate implements Predicate<Status> {
|
||||
//Apply client filters if no server filter is triggered
|
||||
if (applyingFilter.isEmpty()) {
|
||||
applyingFilter = clientFilters.stream()
|
||||
// only apply filters for given context
|
||||
.filter(filter -> filter.context.contains(context))
|
||||
// treating filterAction = null (from filters list) as FilterAction.HIDE
|
||||
.filter(filter -> filter.filterAction == null ? action == HIDE : filter.filterAction == action)
|
||||
//client filter has to match the status
|
||||
.filter(filter -> filter.matches(status))
|
||||
.findAny();
|
||||
}
|
||||
|
||||
@@ -75,4 +75,7 @@
|
||||
<string name="mo_setting_uniform_summary">App-Symbol für alle Benachrichtigungen verwenden</string>
|
||||
<string name="mo_setting_reduced_motion_summary">Animationen für Interaktionen deaktivieren</string>
|
||||
<string name="mo_setting_play_gif_summary">GIFs in Profilbildern und Emojis automatisch abspielen</string>
|
||||
<string name="mo_settings_show_posts_without_alt">Zeige Medienbeiträge ohne Bildbeschreibung</string>
|
||||
<string name="mo_settings_show_posts_without_alt_summary">Beiräge werden in allen Timelines ausgeblendet, können aber in Threads und Benachrichtungen ausgeklappt werden</string>
|
||||
|
||||
</resources>
|
||||
@@ -231,7 +231,6 @@
|
||||
<string name="sk_no_alt_text">Keine Bildbeschreibung</string>
|
||||
<string name="sk_settings_show_alt_indicator">Indikator für Bildbeschreibungen</string>
|
||||
<string name="sk_settings_show_no_alt_indicator">Indikator für fehlende Bildbeschreibungen</string>
|
||||
<string name="sk_settings_show_posts_without_alt">Zeige Medienbeiträge ohne Bildbeschreibung</string>
|
||||
<string name="sk_updater_enable_pre_releases">Vorab-Versionen einschalten</string>
|
||||
<string name="sk_searching">Wird gesucht…</string>
|
||||
<string name="sk_save_draft_message">Änderungen speichern oder Entwurf jetzt veröffentlichen\?</string>
|
||||
|
||||
@@ -87,7 +87,10 @@
|
||||
<string name="mo_setting_disable_swipe_summary">Swipe to change viewed timeline</string>
|
||||
<string name="mo_setting_haptic_feedback_summary">Vibrate when interacting with posts</string>
|
||||
<string name="mo_swap_bookmark_with_reblog_summary">Bookmark or reblog posts from the notification</string>
|
||||
<string name="mo_settings_show_posts_without_alt_summary">Posts will be hidden in all timelines, but can be revealed in threads and notifications</string>
|
||||
|
||||
<!-- Settings -->
|
||||
<string name="mo_notification_audience_settings">Notification Audience</string>
|
||||
<string name="mo_settings_show_posts_without_alt">Show media posts with missing alt text</string>
|
||||
|
||||
</resources>
|
||||
@@ -259,7 +259,6 @@
|
||||
<string name="sk_no_alt_text">No alt text available</string>
|
||||
<string name="sk_settings_show_alt_indicator">Indicator for alt texts</string>
|
||||
<string name="sk_settings_show_no_alt_indicator">Indicator for missing alt texts</string>
|
||||
<string name="sk_settings_show_posts_without_alt">Show media posts with missing alt text</string>
|
||||
<string name="sk_updater_enable_pre_releases">Enable pre-releases</string>
|
||||
<string name="sk_settings_show_new_posts_button">“Show new posts” button</string>
|
||||
<string name="sk_inline_local_only">local-only</string>
|
||||
|
||||
Reference in New Issue
Block a user