Start adding more options for Hide Read Posts Automatically.

This commit is contained in:
Docile-Alligator
2026-01-14 11:11:47 -05:00
parent a011a8d6a0
commit 5e069c23b5
4 changed files with 142 additions and 30 deletions

View File

@ -87,6 +87,9 @@ public class PostHistoryFragment extends Fragment {
binding.markPostsAsReadAfterVotingLinearLayoutPostHistoryFragment.setVisibility(View.GONE);
binding.markPostsAsReadOnScrollLinearLayoutPostHistoryFragment.setVisibility(View.GONE);
binding.hideReadPostsAutomaticallyLinearLayoutPostHistoryFragment.setVisibility(View.GONE);
binding.hideReadPostsAutomaticallyInSubredditsLinearLayoutPostHistoryFragment.setVisibility(View.GONE);
binding.hideReadPostsAutomaticallyInUsersLinearLayoutPostHistoryFragment.setVisibility(View.GONE);
binding.hideReadPostsAutomaticallyInSearchLinearLayoutPostHistoryFragment.setVisibility(View.GONE);
return binding.getRoot();
}
@ -102,6 +105,12 @@ public class PostHistoryFragment extends Fragment {
mActivity.accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_ON_SCROLL_BASE, false));
binding.hideReadPostsAutomaticallySwitchPostHistoryFragment.setChecked(postHistorySharedPreferences.getBoolean(
mActivity.accountName + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, false));
binding.hideReadPostsAutomaticallyInSubredditsSwitchPostHistoryFragment.setChecked(postHistorySharedPreferences.getBoolean(
mActivity.accountName + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_IN_SUBREDDITS_BASE, false));
binding.hideReadPostsAutomaticallyInUsersSwitchPostHistoryFragment.setChecked(postHistorySharedPreferences.getBoolean(
mActivity.accountName + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_IN_USERS_BASE, false));
binding.hideReadPostsAutomaticallyInSearchSwitchPostHistoryFragment.setChecked(postHistorySharedPreferences.getBoolean(
mActivity.accountName + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_IN_SEARCH_BASE, false));
updateOptions();
@ -136,17 +145,26 @@ public class PostHistoryFragment extends Fragment {
});
binding.markPostsAsReadAfterVotingLinearLayoutPostHistoryFragment.setOnClickListener(view -> binding.markPostsAsReadAfterVotingSwitchPostHistoryFragment.performClick());
binding.markPostsAsReadAfterVotingSwitchPostHistoryFragment.setOnCheckedChangeListener((compoundButton, b) ->
postHistorySharedPreferences.edit().putBoolean(mActivity.accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_AFTER_VOTING_BASE, b).apply());
binding.markPostsAsReadOnScrollLinearLayoutPostHistoryFragment.setOnClickListener(view -> binding.markPostsAsReadOnScrollSwitchPostHistoryFragment.performClick());
binding.markPostsAsReadOnScrollSwitchPostHistoryFragment.setOnCheckedChangeListener((compoundButton, b) -> postHistorySharedPreferences.edit().putBoolean(mActivity.accountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_ON_SCROLL_BASE, b).apply());
binding.hideReadPostsAutomaticallyLinearLayoutPostHistoryFragment.setOnClickListener(view -> binding.hideReadPostsAutomaticallySwitchPostHistoryFragment.performClick());
binding.hideReadPostsAutomaticallySwitchPostHistoryFragment.setOnCheckedChangeListener((compoundButton, b) -> {
postHistorySharedPreferences.edit().putBoolean(mActivity.accountName + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, b).apply();
updateOptions();
});
binding.hideReadPostsAutomaticallySwitchPostHistoryFragment.setOnCheckedChangeListener((compoundButton, b) -> postHistorySharedPreferences.edit().putBoolean(mActivity.accountName + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_BASE, b).apply());
binding.hideReadPostsAutomaticallyInSubredditsLinearLayoutPostHistoryFragment.setOnClickListener(view -> binding.hideReadPostsAutomaticallyInSubredditsSwitchPostHistoryFragment.performClick());
binding.hideReadPostsAutomaticallyInSubredditsSwitchPostHistoryFragment.setOnCheckedChangeListener((compoundButton, b) -> postHistorySharedPreferences.edit().putBoolean(mActivity.accountName + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_IN_SUBREDDITS_BASE, b).apply());
binding.hideReadPostsAutomaticallyInUsersLinearLayoutPostHistoryFragment.setOnClickListener(view -> binding.hideReadPostsAutomaticallyInUsersSwitchPostHistoryFragment.performClick());
binding.hideReadPostsAutomaticallyInUsersSwitchPostHistoryFragment.setOnCheckedChangeListener((compoundButton, b) -> postHistorySharedPreferences.edit().putBoolean(mActivity.accountName + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_IN_USERS_BASE, b).apply());
binding.hideReadPostsAutomaticallyInSearchLinearLayoutPostHistoryFragment.setOnClickListener(view -> binding.hideReadPostsAutomaticallyInSearchSwitchPostHistoryFragment.performClick());
binding.hideReadPostsAutomaticallyInSearchSwitchPostHistoryFragment.setOnCheckedChangeListener((compoundButton, b) -> postHistorySharedPreferences.edit().putBoolean(mActivity.accountName + SharedPreferencesUtils.HIDE_READ_POSTS_AUTOMATICALLY_IN_SEARCH_BASE, b).apply());
return binding.getRoot();
}
@ -158,6 +176,9 @@ public class PostHistoryFragment extends Fragment {
binding.markPostsAsReadAfterVotingLinearLayoutPostHistoryFragment.setVisibility(View.VISIBLE);
binding.markPostsAsReadOnScrollLinearLayoutPostHistoryFragment.setVisibility(View.VISIBLE);
binding.hideReadPostsAutomaticallyLinearLayoutPostHistoryFragment.setVisibility(View.VISIBLE);
binding.hideReadPostsAutomaticallyInSubredditsLinearLayoutPostHistoryFragment.setVisibility(binding.hideReadPostsAutomaticallySwitchPostHistoryFragment.isChecked() ? View.VISIBLE : View.GONE);
binding.hideReadPostsAutomaticallyInUsersLinearLayoutPostHistoryFragment.setVisibility(binding.hideReadPostsAutomaticallySwitchPostHistoryFragment.isChecked() ? View.VISIBLE : View.GONE);
binding.hideReadPostsAutomaticallyInSearchLinearLayoutPostHistoryFragment.setVisibility(binding.hideReadPostsAutomaticallySwitchPostHistoryFragment.isChecked() ? View.VISIBLE : View.GONE);
boolean limitReadPosts = postHistorySharedPreferences.getBoolean(
mActivity.accountName + SharedPreferencesUtils.READ_POSTS_LIMIT_ENABLED, true);
@ -168,6 +189,9 @@ public class PostHistoryFragment extends Fragment {
binding.markPostsAsReadAfterVotingLinearLayoutPostHistoryFragment.setVisibility(View.GONE);
binding.markPostsAsReadOnScrollLinearLayoutPostHistoryFragment.setVisibility(View.GONE);
binding.hideReadPostsAutomaticallyLinearLayoutPostHistoryFragment.setVisibility(View.GONE);
binding.hideReadPostsAutomaticallyInSubredditsLinearLayoutPostHistoryFragment.setVisibility(View.GONE);
binding.hideReadPostsAutomaticallyInUsersLinearLayoutPostHistoryFragment.setVisibility(View.GONE);
binding.hideReadPostsAutomaticallyInSearchLinearLayoutPostHistoryFragment.setVisibility(View.GONE);
}
}
@ -184,7 +208,9 @@ public class PostHistoryFragment extends Fragment {
binding.markPostsAsReadAfterVotingTextViewPostHistoryFragment.setTextColor(primaryTextColor);
binding.markPostsAsReadOnScrollTextViewPostHistoryFragment.setTextColor(primaryTextColor);
binding.hideReadPostsAutomaticallyTextViewPostHistoryFragment.setTextColor(primaryTextColor);
binding.hideReadPostsAutomaticallySummaryTextViewPostHistoryFragment.setTextColor(mActivity.customThemeWrapper.getSecondaryTextColor());
binding.hideReadPostsAutomaticallyInSubredditsTextViewPostHistoryFragment.setTextColor(primaryTextColor);
binding.hideReadPostsAutomaticallyInUsersTextViewPostHistoryFragment.setTextColor(primaryTextColor);
binding.hideReadPostsAutomaticallyInSearchTextViewPostHistoryFragment.setTextColor(primaryTextColor);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
binding.readPostsLimitTextInputLayoutPostHistoryFragment.setCursorColor(ColorStateList.valueOf(primaryTextColor));

View File

@ -401,6 +401,9 @@ public class SharedPreferencesUtils {
public static final String MARK_POSTS_AS_READ_AFTER_VOTING_BASE = "_mark_posts_as_read_after_voting";
public static final String MARK_POSTS_AS_READ_ON_SCROLL_BASE = "_mark_posts_as_read_on_scroll";
public static final String HIDE_READ_POSTS_AUTOMATICALLY_BASE = "_hide_read_posts_automatically";
public static final String HIDE_READ_POSTS_AUTOMATICALLY_IN_SUBREDDITS_BASE = "_hide_read_posts_automatically_in_subreddits";
public static final String HIDE_READ_POSTS_AUTOMATICALLY_IN_USERS_BASE = "_hide_read_posts_automatically_in_users";
public static final String HIDE_READ_POSTS_AUTOMATICALLY_IN_SEARCH_BASE = "_hide_read_posts_automatically_in_search";
public static final String CURRENT_ACCOUNT_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.current_account";
public static final String ACCOUNT_NAME = "account_name";

View File

@ -182,41 +182,25 @@
android:id="@+id/hide_read_posts_automatically_linear_layout_post_history_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:paddingStart="72dp"
android:paddingEnd="16dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground">
<LinearLayout
<TextView
android:id="@+id/hide_read_posts_automatically_text_view_post_history_fragment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:paddingStart="0dp"
android:paddingEnd="16dp">
<TextView
android:id="@+id/hide_read_posts_automatically_text_view_post_history_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/settings_hide_read_posts_automatically_title"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_16"
android:fontFamily="?attr/font_family" />
<TextView
android:id="@+id/hide_read_posts_automatically_summary_text_view_post_history_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/settings_hide_read_posts_automatically_summary"
android:textColor="?attr/secondaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />
</LinearLayout>
android:layout_marginEnd="16dp"
android:layout_gravity="center_vertical"
android:text="@string/settings_hide_read_posts_automatically_title"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_16"
android:fontFamily="?attr/font_family" />
<ml.docilealligator.infinityforreddit.customviews.ThemedMaterialSwitch
android:id="@+id/hide_read_posts_automatically_switch_post_history_fragment"
@ -226,6 +210,102 @@
</LinearLayout>
<LinearLayout
android:id="@+id/hide_read_posts_automatically_in_subreddits_linear_layout_post_history_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:paddingStart="72dp"
android:paddingEnd="16dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground">
<TextView
android:id="@+id/hide_read_posts_automatically_in_subreddits_text_view_post_history_fragment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="16dp"
android:layout_gravity="center_vertical"
android:text="@string/settings_hide_read_posts_automatically_in_subreddits_title"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_16"
android:fontFamily="?attr/font_family" />
<ml.docilealligator.infinityforreddit.customviews.ThemedMaterialSwitch
android:id="@+id/hide_read_posts_automatically_in_subreddits_switch_post_history_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
</LinearLayout>
<LinearLayout
android:id="@+id/hide_read_posts_automatically_in_users_linear_layout_post_history_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:paddingStart="72dp"
android:paddingTop="4dp"
android:paddingEnd="16dp"
android:paddingBottom="4dp">
<TextView
android:id="@+id/hide_read_posts_automatically_in_users_text_view_post_history_fragment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="16dp"
android:layout_weight="1"
android:fontFamily="?attr/font_family"
android:text="@string/settings_hide_read_posts_automatically_in_users_title"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_16" />
<ml.docilealligator.infinityforreddit.customviews.ThemedMaterialSwitch
android:id="@+id/hide_read_posts_automatically_in_users_switch_post_history_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
</LinearLayout>
<LinearLayout
android:id="@+id/hide_read_posts_automatically_in_search_linear_layout_post_history_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:paddingStart="72dp"
android:paddingEnd="16dp"
android:clickable="true"
android:focusable="true"
android:background="?attr/selectableItemBackground">
<TextView
android:id="@+id/hide_read_posts_automatically_in_search_text_view_post_history_fragment"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginEnd="16dp"
android:layout_gravity="center_vertical"
android:text="@string/settings_hide_read_posts_automatically_in_search_title"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_16"
android:fontFamily="?attr/font_family" />
<ml.docilealligator.infinityforreddit.customviews.ThemedMaterialSwitch
android:id="@+id/hide_read_posts_automatically_in_search_switch_post_history_fragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -584,6 +584,9 @@
<string name="settings_mark_posts_as_read_after_voting_title">Mark Posts as Read After Voting</string>
<string name="settings_mark_posts_as_read_on_scroll_title">Mark Posts as Read on Scroll</string>
<string name="settings_hide_read_posts_automatically_title">Hide Read Posts Automatically</string>
<string name="settings_hide_read_posts_automatically_in_subreddits_title">Hide Read Posts Automatically in Subreddits</string>
<string name="settings_hide_read_posts_automatically_in_users_title">Hide Read Posts Automatically in Users</string>
<string name="settings_hide_read_posts_automatically_in_search_title">Hide Read Posts Automatically in Search</string>
<string name="settings_hide_read_posts_automatically_summary">The setting is not applied when viewing posts from searches, specific users, or subreddits.</string>
<string name="settings_sort_type_title">Sort Type</string>
<string name="settings_save_sort_type_title">Save Sort Type</string>