From f88b65f479e7c2ec84b8215c6f8d67f800b39696 Mon Sep 17 00:00:00 2001 From: sk Date: Mon, 6 Feb 2023 18:16:41 +0100 Subject: [PATCH] add spectator mode closes sk22#264 --- .../java/org/joinmastodon/android/GlobalUserPreferences.java | 3 +++ .../org/joinmastodon/android/fragments/SettingsFragment.java | 5 +++++ .../joinmastodon/android/fragments/StatusListFragment.java | 5 ++++- .../org/joinmastodon/android/fragments/ThreadFragment.java | 2 +- mastodon/src/main/res/values/strings_sk.xml | 1 + 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java index 93400787e..4aeefc228 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java +++ b/mastodon/src/main/java/org/joinmastodon/android/GlobalUserPreferences.java @@ -42,6 +42,7 @@ public class GlobalUserPreferences{ public static boolean prefixRepliesWithRe; public static boolean bottomEncoding; public static boolean collapseLongPosts; + public static boolean spectatorMode; public static String publishButtonText; public static ThemePreference theme; public static ColorPreference color; @@ -89,6 +90,7 @@ public class GlobalUserPreferences{ prefixRepliesWithRe=prefs.getBoolean("prefixRepliesWithRe", false); bottomEncoding=prefs.getBoolean("bottomEncoding", false); collapseLongPosts=prefs.getBoolean("collapseLongPosts", true); + spectatorMode=prefs.getBoolean("spectatorMode", false); publishButtonText=prefs.getString("publishButtonText", ""); theme=ThemePreference.values()[prefs.getInt("theme", 0)]; recentLanguages=fromJson(prefs.getString("recentLanguages", null), recentLanguagesType, new HashMap<>()); @@ -128,6 +130,7 @@ public class GlobalUserPreferences{ .putBoolean("enablePreReleases", enablePreReleases) .putBoolean("prefixRepliesWithRe", prefixRepliesWithRe) .putBoolean("collapseLongPosts", collapseLongPosts) + .putBoolean("spectatorMode", spectatorMode) .putString("publishButtonText", publishButtonText) .putBoolean("bottomEncoding", bottomEncoding) .putInt("theme", theme.ordinal()) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java index 841155b8d..b66f735cc 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java @@ -243,6 +243,11 @@ public class SettingsFragment extends MastodonToolbarFragment{ GlobalUserPreferences.collapseLongPosts=i.checked; GlobalUserPreferences.save(); })); + items.add(new SwitchItem(R.string.sk_spectator_mode, R.drawable.ic_fluent_eye_24_regular, GlobalUserPreferences.spectatorMode, i->{ + GlobalUserPreferences.spectatorMode=i.checked; + GlobalUserPreferences.save(); + needAppRestart=true; + })); items.add(new SwitchItem(R.string.sk_settings_translate_only_opened, R.drawable.ic_fluent_translate_24_regular, GlobalUserPreferences.translateButtonOpenedOnly, i->{ GlobalUserPreferences.translateButtonOpenedOnly=i.checked; GlobalUserPreferences.save(); diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/StatusListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/StatusListFragment.java index b8e68b272..7293a2fac 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/StatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/StatusListFragment.java @@ -6,6 +6,7 @@ import android.os.Bundle; import com.squareup.otto.Subscribe; import org.joinmastodon.android.E; +import org.joinmastodon.android.GlobalUserPreferences; import org.joinmastodon.android.events.PollUpdatedEvent; import org.joinmastodon.android.events.RemoveAccountPostsEvent; import org.joinmastodon.android.events.StatusCountersUpdatedEvent; @@ -31,7 +32,9 @@ public abstract class StatusListFragment extends BaseStatusListFragment{ protected EventListener eventListener=new EventListener(); protected List buildDisplayItems(Status s){ - return StatusDisplayItem.buildItems(this, s, accountID, s, knownAccounts, false, true, null, Filter.FilterContext.HOME); + boolean addFooter = !GlobalUserPreferences.spectatorMode || + (this instanceof ThreadFragment t && s.id.equals(t.mainStatus.id)); + return StatusDisplayItem.buildItems(this, s, accountID, s, knownAccounts, false, addFooter, null, Filter.FilterContext.HOME); } @Override diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java index da9918ece..03cadb3b0 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/ThreadFragment.java @@ -26,7 +26,7 @@ import java.util.stream.Collectors; import me.grishka.appkit.api.SimpleCallback; public class ThreadFragment extends StatusListFragment{ - private Status mainStatus; + protected Status mainStatus; @Override public void onCreate(Bundle savedInstanceState){ diff --git a/mastodon/src/main/res/values/strings_sk.xml b/mastodon/src/main/res/values/strings_sk.xml index 63187a504..9114dc908 100644 --- a/mastodon/src/main/res/values/strings_sk.xml +++ b/mastodon/src/main/res/values/strings_sk.xml @@ -258,4 +258,5 @@ Collapse very long posts Fix attachments? Some attachments haven’t finished uploading. + Spectator mode \ No newline at end of file