Skip to content
This repository was archived by the owner on Jun 1, 2024. It is now read-only.

Commit 36d562d

Browse files
author
Your Name
committed
Add UI for configuring post-hiding
1 parent a38749a commit 36d562d

File tree

5 files changed

+61
-1
lines changed

5 files changed

+61
-1
lines changed

app/src/main/java/me/ccrama/redditslide/Fragments/SettingsHistoryFragment.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
3232

3333
if (isChecked) {
3434
context.findViewById(R.id.settings_history_scrollseen).setEnabled(true);
35+
context.findViewById(R.id.settings_history_scrollseenhide).setEnabled(true);
3536
context.findViewById(R.id.settings_history_storensfw).setEnabled(true);
3637
} else {
3738
((SwitchCompat) context.findViewById(R.id.settings_history_storensfw)).setChecked(false);
@@ -43,6 +44,11 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
4344
((SwitchCompat) context.findViewById(R.id.settings_history_scrollseen)).setEnabled(false);
4445
SettingValues.scrollSeen = false;
4546
SettingValues.prefs.edit().putBoolean(SettingValues.PREF_SCROLL_SEEN, false).apply();
47+
48+
((SwitchCompat) context.findViewById(R.id.settings_history_scrollseenhide)).setChecked(false);
49+
((SwitchCompat) context.findViewById(R.id.settings_history_scrollseenhide)).setEnabled(false);
50+
SettingValues.scrollSeenHide = false;
51+
SettingValues.prefs.edit().putBoolean(SettingValues.PREF_SCROLL_SEEN_HIDE, false).apply();
4652
}
4753
}
4854
});
@@ -87,6 +93,19 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
8793
}
8894
});
8995
}
96+
97+
{
98+
SwitchCompat single = (SwitchCompat) context.findViewById(R.id.settings_history_scrollseenhide);
99+
single.setChecked(SettingValues.scrollSeenHide);
100+
single.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
101+
@Override
102+
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
103+
SettingValues.scrollSeenHide = isChecked;
104+
SettingValues.prefs.edit().putBoolean(SettingValues.PREF_SCROLL_SEEN_HIDE, isChecked).apply();
105+
106+
}
107+
});
108+
}
90109
}
91110

92111
}

app/src/main/java/me/ccrama/redditslide/HasSeen.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import java.util.HashSet;
1616
import java.util.List;
1717

18+
import me.ccrama.redditslide.SettingValues;
1819
import me.ccrama.redditslide.Synccit.SynccitRead;
1920

2021
import static com.lusfold.androidkeyvaluestore.core.KVManagerImpl.COLUMN_KEY;
@@ -184,7 +185,7 @@ public static void addSeenScrolling(final Submission submission) {
184185
SynccitRead.newVisited.add(fullname);
185186
SynccitRead.visitedIds.add(fullname);
186187
}
187-
if (hide) {
188+
if (hide && SettingValues.scrollSeenHide) {
188189
Hidden.addSubmissionToHideQueue(submission);
189190
}
190191
}

app/src/main/java/me/ccrama/redditslide/SettingValues.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public class SettingValues {
4747
public static final String PREF_STORE_HISTORY = "storehistory";
4848
public static final String PREF_STORE_NSFW_HISTORY = "storensfw";
4949
public static final String PREF_SCROLL_SEEN = "scrollSeen";
50+
public static final String PREF_SCROLL_SEEN_HIDE = "scrollSeenHide";
5051
public static final String PREF_TITLE_FILTERS = "titleFilters";
5152
public static final String PREF_TEXT_FILTERS = "textFilters";
5253
public static final String PREF_DOMAIN_FILTERS = "domainFilters";
@@ -169,6 +170,7 @@ public class SettingValues {
169170
public static boolean showNSFWContent;
170171
public static boolean storeNSFWHistory;
171172
public static boolean scrollSeen;
173+
public static boolean scrollSeenHide;
172174
public static boolean saveButton;
173175
public static boolean voteGestures;
174176
public static boolean colorEverywhere;
@@ -364,6 +366,7 @@ public static void setAllValues(SharedPreferences settings) {
364366
upvotePercentage = prefs.getBoolean(PREF_UPVOTE_PERCENTAGE, false);
365367
storeNSFWHistory = prefs.getBoolean(PREF_STORE_NSFW_HISTORY, false);
366368
scrollSeen = prefs.getBoolean(PREF_SCROLL_SEEN, false);
369+
scrollSeenHide = prefs.getBoolean(PREF_SCROLL_SEEN_HIDE, false);
367370
synccitName = prefs.getString(SYNCCIT_NAME, "");
368371
synccitAuth = prefs.getString(SYNCCIT_AUTH, "");
369372
notifSound = prefs.getBoolean(PREF_SOUND_NOTIFS, false);

app/src/main/res/layout/activity_settings_history_child.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,42 @@
138138
android:textColorHint="?attr/fontColor" />
139139
</RelativeLayout>
140140

141+
<RelativeLayout
142+
android:layout_width="match_parent"
143+
android:layout_height="56dp"
144+
android:background="?android:selectableItemBackground"
145+
android:gravity="center_vertical"
146+
android:orientation="horizontal"
147+
android:paddingStart="16dp">
148+
149+
<LinearLayout
150+
android:layout_width="match_parent"
151+
android:layout_height="wrap_content"
152+
android:layout_centerVertical="true"
153+
android:layout_marginEnd="64dp"
154+
android:orientation="vertical">
155+
156+
<TextView
157+
android:layout_width="wrap_content"
158+
android:layout_height="wrap_content"
159+
android:text="@string/settings_general_scroll_read_hide"
160+
android:textColor="?attr/fontColor"
161+
android:textSize="14sp" />
162+
</LinearLayout>
163+
164+
<android.support.v7.widget.SwitchCompat
165+
android:id="@+id/settings_history_scrollseenhide"
166+
android:layout_width="match_parent"
167+
android:layout_height="match_parent"
168+
android:paddingEnd="16dp"
169+
android:backgroundTint="?attr/tintColor"
170+
android:button="@null"
171+
android:buttonTint="?attr/tintColor"
172+
android:hapticFeedbackEnabled="true"
173+
android:textColor="?attr/fontColor"
174+
android:textColorHint="?attr/fontColor" />
175+
</RelativeLayout>
176+
141177
<TextView
142178
style="@style/TextAppearance.AppCompat.Body2"
143179
android:id="@+id/settings_history_clearHistoryHeader"

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@
658658
<string name="settings_font_comment">Comment font</string>
659659
<string name="settings_comment_crop">Crop lead image in comment view</string>
660660
<string name="settings_general_scroll_read">Mark posts as seen when scrolled past</string>
661+
<string name="settings_general_scroll_read_hide">Hide posts when scrolled past</string>
661662
<string name="settings_link_chrome">Custom Tabs</string>
662663
<string name="settings_image_location">Select image/GIF save location</string>
663664
<string name="settings_image_location_unset">Not yet set</string>

0 commit comments

Comments
 (0)