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

Commit 1378664

Browse files
author
Your Name
committed
Add UI for configuring post-hiding
1 parent 2bed537 commit 1378664

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
@@ -33,6 +33,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
3333

3434
if (isChecked) {
3535
context.findViewById(R.id.settings_history_scrollseen).setEnabled(true);
36+
context.findViewById(R.id.settings_history_scrollseenhide).setEnabled(true);
3637
context.findViewById(R.id.settings_history_storensfw).setEnabled(true);
3738
} else {
3839
((SwitchCompat) context.findViewById(R.id.settings_history_storensfw)).setChecked(false);
@@ -44,6 +45,11 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
4445
((SwitchCompat) context.findViewById(R.id.settings_history_scrollseen)).setEnabled(false);
4546
SettingValues.scrollSeen = false;
4647
SettingValues.prefs.edit().putBoolean(SettingValues.PREF_SCROLL_SEEN, false).apply();
48+
49+
((SwitchCompat) context.findViewById(R.id.settings_history_scrollseenhide)).setChecked(false);
50+
((SwitchCompat) context.findViewById(R.id.settings_history_scrollseenhide)).setEnabled(false);
51+
SettingValues.scrollSeenHide = false;
52+
SettingValues.prefs.edit().putBoolean(SettingValues.PREF_SCROLL_SEEN_HIDE, false).apply();
4753
}
4854
}
4955
});
@@ -88,6 +94,19 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
8894
}
8995
});
9096
}
97+
98+
{
99+
SwitchCompat single = (SwitchCompat) context.findViewById(R.id.settings_history_scrollseenhide);
100+
single.setChecked(SettingValues.scrollSeenHide);
101+
single.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
102+
@Override
103+
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
104+
SettingValues.scrollSeenHide = isChecked;
105+
SettingValues.prefs.edit().putBoolean(SettingValues.PREF_SCROLL_SEEN_HIDE, isChecked).apply();
106+
107+
}
108+
});
109+
}
91110
}
92111

93112
}

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;
@@ -181,7 +182,7 @@ public static void addSeenScrolling(final Submission submission) {
181182
SynccitRead.newVisited.add(fullname);
182183
SynccitRead.visitedIds.add(fullname);
183184
}
184-
if (hide) {
185+
if (hide && SettingValues.scrollSeenHide) {
185186
Hidden.addSubmissionToHideQueue(submission);
186187
}
187188
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public class SettingValues {
5252
public static final String PREF_STORE_HISTORY = "storehistory";
5353
public static final String PREF_STORE_NSFW_HISTORY = "storensfw";
5454
public static final String PREF_SCROLL_SEEN = "scrollSeen";
55+
public static final String PREF_SCROLL_SEEN_HIDE = "scrollSeenHide";
5556
public static final String PREF_TITLE_FILTERS = "titleFilters";
5657
public static final String PREF_TEXT_FILTERS = "textFilters";
5758
public static final String PREF_DOMAIN_FILTERS = "domainFilters";
@@ -176,6 +177,7 @@ public class SettingValues {
176177
public static boolean showNSFWContent;
177178
public static boolean storeNSFWHistory;
178179
public static boolean scrollSeen;
180+
public static boolean scrollSeenHide;
179181
public static boolean saveButton;
180182
public static boolean voteGestures;
181183
public static boolean colorEverywhere;
@@ -376,6 +378,7 @@ public static void setAllValues(SharedPreferences settings) {
376378
upvotePercentage = prefs.getBoolean(PREF_UPVOTE_PERCENTAGE, false);
377379
storeNSFWHistory = prefs.getBoolean(PREF_STORE_NSFW_HISTORY, false);
378380
scrollSeen = prefs.getBoolean(PREF_SCROLL_SEEN, false);
381+
scrollSeenHide = prefs.getBoolean(PREF_SCROLL_SEEN_HIDE, false);
379382
synccitName = prefs.getString(SYNCCIT_NAME, "");
380383
synccitAuth = prefs.getString(SYNCCIT_AUTH, "");
381384
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
@@ -664,6 +664,7 @@
664664
<string name="settings_font_comment">Comment font</string>
665665
<string name="settings_comment_crop">Crop lead image in comment view</string>
666666
<string name="settings_general_scroll_read">Mark posts as seen when scrolled past</string>
667+
<string name="settings_general_scroll_read_hide">Hide posts when scrolled past</string>
667668
<string name="settings_link_chrome">Custom Tabs</string>
668669
<string name="settings_image_location">Select image/GIF save location</string>
669670
<string name="settings_image_location_unset">Not yet set</string>

0 commit comments

Comments
 (0)