add option to disable show new posts button

This commit is contained in:
sk 2023-01-24 06:53:11 -03:00 committed by LucasGGamerM
parent 0008b07072
commit a726bf6101
5 changed files with 21 additions and 2 deletions

View File

@ -23,6 +23,7 @@ public class GlobalUserPreferences{
public static boolean showReplies;
public static boolean showBoosts;
public static boolean loadNewPosts;
public static boolean showNewPostsButton;
public static boolean showInteractionCounts;
public static boolean alwaysExpandContentWarnings;
public static boolean disableMarquee;
@ -69,6 +70,7 @@ public class GlobalUserPreferences{
showReplies=prefs.getBoolean("showReplies", true);
showBoosts=prefs.getBoolean("showBoosts", true);
loadNewPosts=prefs.getBoolean("loadNewPosts", true);
showNewPostsButton=prefs.getBoolean("showNewPostsButton", true);
uniformNotificationIcon=prefs.getBoolean("uniformNotificationIcon", true);
showInteractionCounts=prefs.getBoolean("showInteractionCounts", false);
alwaysExpandContentWarnings=prefs.getBoolean("alwaysExpandContentWarnings", false);
@ -111,6 +113,7 @@ public class GlobalUserPreferences{
.putBoolean("showReplies", showReplies)
.putBoolean("showBoosts", showBoosts)
.putBoolean("loadNewPosts", loadNewPosts)
.putBoolean("showNewPostsButton", showNewPostsButton)
.putBoolean("trueBlackTheme", trueBlackTheme)
.putBoolean("showInteractionCounts", showInteractionCounts)
.putBoolean("alwaysExpandContentWarnings", alwaysExpandContentWarnings)

View File

@ -150,7 +150,7 @@ public class HomeTimelineFragment extends FabStatusListFragment {
toAdd=toAdd.stream().filter(filterPredicate).collect(Collectors.toList());
if(!toAdd.isEmpty()){
prependItems(toAdd, true);
if (parent != null) parent.showNewPostsButton();
if (parent != null && GlobalUserPreferences.showNewPostsButton) parent.showNewPostsButton();
AccountSessionManager.getInstance().getAccount(accountID).getCacheController().putHomeTimeline(toAdd, false);
}
}

View File

@ -78,6 +78,7 @@ public class SettingsFragment extends MastodonToolbarFragment{
private ArrayList<Item> items=new ArrayList<>();
private ThemeItem themeItem;
private NotificationPolicyItem notificationPolicyItem;
private SwitchItem loadNewPostsItem, showNewPostsButtonItem;
private String accountID;
private boolean needUpdateNotificationSettings;
private boolean needAppRestart;
@ -245,10 +246,21 @@ public class SettingsFragment extends MastodonToolbarFragment{
GlobalUserPreferences.showBoosts=i.checked;
GlobalUserPreferences.save();
}));
items.add(new SwitchItem(R.string.sk_settings_load_new_posts, R.drawable.ic_fluent_arrow_up_24_regular, GlobalUserPreferences.loadNewPosts, i->{
items.add(loadNewPostsItem = new SwitchItem(R.string.sk_settings_load_new_posts, R.drawable.ic_fluent_arrow_sync_24_regular, GlobalUserPreferences.loadNewPosts, i->{
GlobalUserPreferences.loadNewPosts=i.checked;
showNewPostsButtonItem.enabled = i.checked;
if (!i.checked) {
GlobalUserPreferences.showNewPostsButton = false;
showNewPostsButtonItem.checked = false;
}
if (list.findViewHolderForAdapterPosition(items.indexOf(showNewPostsButtonItem)) instanceof SwitchViewHolder svh) svh.rebind();
GlobalUserPreferences.save();
}));
items.add(showNewPostsButtonItem = new SwitchItem(R.string.sk_settings_show_new_posts_button, R.drawable.ic_fluent_arrow_up_24_regular, GlobalUserPreferences.showNewPostsButton, i->{
GlobalUserPreferences.showNewPostsButton=i.checked;
GlobalUserPreferences.save();
}));
showNewPostsButtonItem.enabled = GlobalUserPreferences.loadNewPosts;
items.add(new HeaderItem(R.string.settings_notifications));
items.add(notificationPolicyItem=new NotificationPolicyItem());

View File

@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<path android:pathData="M16.25 5.18c-0.25 0.33-0.187 0.8 0.142 1.051C18.18 7.595 19.25 9.708 19.25 12c0 3.736-2.826 6.812-6.457 7.207l0.677-0.677c0.293-0.293 0.293-0.767 0-1.06-0.267-0.267-0.683-0.29-0.977-0.073L12.41 17.47l-2 2c-0.266 0.266-0.29 0.683-0.073 0.976l0.073 0.084 2 2c0.293 0.293 0.768 0.293 1.06 0 0.267-0.266 0.291-0.683 0.073-0.976L13.47 21.47l-0.75-0.75c4.495-0.365 8.03-4.13 8.03-8.72 0-2.765-1.292-5.317-3.448-6.961-0.33-0.252-0.8-0.188-1.051 0.141zm-5.72-3.71c-0.293 0.293-0.293 0.767 0 1.06l0.75 0.75C6.784 3.645 3.25 7.41 3.25 12c0 2.645 1.181 5.097 3.18 6.75 0.32 0.263 0.793 0.218 1.057-0.102 0.263-0.319 0.218-0.792-0.1-1.055-1.66-1.37-2.637-3.4-2.637-5.593 0-3.736 2.825-6.811 6.456-7.207L10.53 5.47c-0.293 0.293-0.293 0.767 0 1.06 0.293 0.293 0.768 0.293 1.061 0l2-2c0.293-0.293 0.293-0.767 0-1.06l-2-2c-0.293-0.293-0.768-0.293-1.06 0z" android:fillColor="@color/fluent_default_icon_tint"/>
</vector>

View File

@ -235,4 +235,5 @@
<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_updater_enable_pre_releases">Enable pre-releases</string>
<string name="sk_settings_show_new_posts_button">“Show new posts” button</string>
</resources>