Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public static boolean isRefreshRequired(final Context context, final String key)
|| key.equals(context.getString(R.string.pref_behaviour_fling_post_right_key))
|| key.equals(context.getString(R.string.pref_behaviour_nsfw_key))
|| key.equals(context.getString(R.string.pref_behaviour_postcount_key))
|| key.equals(context.getString(R.string.pref_behaviour_mark_read_on_scroll_key))
|| key.equals(context.getString(R.string.pref_behaviour_comment_min_key))
|| key.equals(context.getString(R.string.pref_behaviour_pinned_subredditsort_key))
|| key.equals(context.getString(
Expand Down Expand Up @@ -1784,6 +1785,12 @@ public static boolean pref_behaviour_keep_screen_awake() {
false);
}

public static boolean pref_mark_read_on_scroll() {
return getBoolean(
R.string.pref_behaviour_mark_read_on_scroll_key,
false);
}

@Nullable
public static String pref_reddit_client_id_override() {
final String value = getString(R.string.pref_reddit_client_id_override_key, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,43 @@ private void onLoadMoreItemsCheck() {

General.checkThisIsUIThread();

if(PrefsUtility.pref_mark_read_on_scroll()) {

final LinearLayoutManager layoutManager
= (LinearLayoutManager)mRecyclerView.getLayoutManager();

if(layoutManager != null) {

final int firstVisibleItemPosition
= layoutManager.findFirstVisibleItemPosition();

final int firstCompletelyVisibleItemPosition
= layoutManager.findFirstCompletelyVisibleItemPosition();

if(firstVisibleItemPosition >= 1
&& firstCompletelyVisibleItemPosition != 0) {

final RedditPostView view = (RedditPostView) layoutManager.getChildAt(0);

final int position =
(view != null) ? layoutManager.getPosition(view) : RecyclerView.NO_POSITION;

final RedditPreparedPost post
= (position == firstVisibleItemPosition) ? view.getPost() : null;

// Mark the first visible post read if it is unread
if((post != null) && !post.isRead()) {
new Thread() {
@Override
public void run() {
post.markAsRead(getActivity());
}
}.start();
}
}
}
}

if(mReadyToDownloadMore && mAfter != null && !mAfter.equals(mLastAfter)) {

final LinearLayoutManager layoutManager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,4 +667,8 @@ private void showPrefPrompt() {
.apply();
});
}

@Nullable public RedditPreparedPost getPost() {
return mPost;
}
}
6 changes: 5 additions & 1 deletion src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1924,4 +1924,8 @@

<!-- 2025-12-07 -->
<string name="no_messages_yet">No messages yet.</string>
</resources>

<!-- 2025-12-10 -->
<string name="pref_behaviour_mark_read_on_scroll_key" translatable="false">pref_behaviour_mark_read_on_scroll</string>
<string name="pref_behaviour_mark_read_on_scroll_title">Mark posts as read on scroll</string>
</resources>
4 changes: 4 additions & 0 deletions src/main/res/xml/prefs_behaviour.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@
android:entryValues="@array/pref_behaviour_postcount_items_return"
android:defaultValue="ALL"/>

<CheckBoxPreference android:title="@string/pref_behaviour_mark_read_on_scroll_title"
android:key="@string/pref_behaviour_mark_read_on_scroll_key"
android:defaultValue="false" />

</PreferenceCategory>

<PreferenceCategory android:title="@string/pref_behaviour_comments_header">
Expand Down
Loading