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

Commit

Permalink
Add UI for configuring post-hiding
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Jul 21, 2020
1 parent 2bed537 commit 1378664
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

if (isChecked) {
context.findViewById(R.id.settings_history_scrollseen).setEnabled(true);
context.findViewById(R.id.settings_history_scrollseenhide).setEnabled(true);
context.findViewById(R.id.settings_history_storensfw).setEnabled(true);
} else {
((SwitchCompat) context.findViewById(R.id.settings_history_storensfw)).setChecked(false);
Expand All @@ -44,6 +45,11 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
((SwitchCompat) context.findViewById(R.id.settings_history_scrollseen)).setEnabled(false);
SettingValues.scrollSeen = false;
SettingValues.prefs.edit().putBoolean(SettingValues.PREF_SCROLL_SEEN, false).apply();

((SwitchCompat) context.findViewById(R.id.settings_history_scrollseenhide)).setChecked(false);
((SwitchCompat) context.findViewById(R.id.settings_history_scrollseenhide)).setEnabled(false);
SettingValues.scrollSeenHide = false;
SettingValues.prefs.edit().putBoolean(SettingValues.PREF_SCROLL_SEEN_HIDE, false).apply();
}
}
});
Expand Down Expand Up @@ -88,6 +94,19 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
}
});
}

{
SwitchCompat single = (SwitchCompat) context.findViewById(R.id.settings_history_scrollseenhide);
single.setChecked(SettingValues.scrollSeenHide);
single.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SettingValues.scrollSeenHide = isChecked;
SettingValues.prefs.edit().putBoolean(SettingValues.PREF_SCROLL_SEEN_HIDE, isChecked).apply();

}
});
}
}

}
3 changes: 2 additions & 1 deletion app/src/main/java/me/ccrama/redditslide/HasSeen.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.HashSet;
import java.util.List;

import me.ccrama.redditslide.SettingValues;
import me.ccrama.redditslide.Synccit.SynccitRead;

import static com.lusfold.androidkeyvaluestore.core.KVManagerImpl.COLUMN_KEY;
Expand Down Expand Up @@ -181,7 +182,7 @@ public static void addSeenScrolling(final Submission submission) {
SynccitRead.newVisited.add(fullname);
SynccitRead.visitedIds.add(fullname);
}
if (hide) {
if (hide && SettingValues.scrollSeenHide) {
Hidden.addSubmissionToHideQueue(submission);
}
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/me/ccrama/redditslide/SettingValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class SettingValues {
public static final String PREF_STORE_HISTORY = "storehistory";
public static final String PREF_STORE_NSFW_HISTORY = "storensfw";
public static final String PREF_SCROLL_SEEN = "scrollSeen";
public static final String PREF_SCROLL_SEEN_HIDE = "scrollSeenHide";
public static final String PREF_TITLE_FILTERS = "titleFilters";
public static final String PREF_TEXT_FILTERS = "textFilters";
public static final String PREF_DOMAIN_FILTERS = "domainFilters";
Expand Down Expand Up @@ -176,6 +177,7 @@ public class SettingValues {
public static boolean showNSFWContent;
public static boolean storeNSFWHistory;
public static boolean scrollSeen;
public static boolean scrollSeenHide;
public static boolean saveButton;
public static boolean voteGestures;
public static boolean colorEverywhere;
Expand Down Expand Up @@ -376,6 +378,7 @@ public static void setAllValues(SharedPreferences settings) {
upvotePercentage = prefs.getBoolean(PREF_UPVOTE_PERCENTAGE, false);
storeNSFWHistory = prefs.getBoolean(PREF_STORE_NSFW_HISTORY, false);
scrollSeen = prefs.getBoolean(PREF_SCROLL_SEEN, false);
scrollSeenHide = prefs.getBoolean(PREF_SCROLL_SEEN_HIDE, false);
synccitName = prefs.getString(SYNCCIT_NAME, "");
synccitAuth = prefs.getString(SYNCCIT_AUTH, "");
notifSound = prefs.getBoolean(PREF_SOUND_NOTIFS, false);
Expand Down
36 changes: 36 additions & 0 deletions app/src/main/res/layout/activity_settings_history_child.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,42 @@
android:textColorHint="?attr/fontColor" />
</RelativeLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="?android:selectableItemBackground"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingStart="16dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginEnd="64dp"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/settings_general_scroll_read_hide"
android:textColor="?attr/fontColor"
android:textSize="14sp" />
</LinearLayout>

<android.support.v7.widget.SwitchCompat
android:id="@+id/settings_history_scrollseenhide"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingEnd="16dp"
android:backgroundTint="?attr/tintColor"
android:button="@null"
android:buttonTint="?attr/tintColor"
android:hapticFeedbackEnabled="true"
android:textColor="?attr/fontColor"
android:textColorHint="?attr/fontColor" />
</RelativeLayout>

<TextView
style="@style/TextAppearance.AppCompat.Body2"
android:id="@+id/settings_history_clearHistoryHeader"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,7 @@
<string name="settings_font_comment">Comment font</string>
<string name="settings_comment_crop">Crop lead image in comment view</string>
<string name="settings_general_scroll_read">Mark posts as seen when scrolled past</string>
<string name="settings_general_scroll_read_hide">Hide posts when scrolled past</string>
<string name="settings_link_chrome">Custom Tabs</string>
<string name="settings_image_location">Select image/GIF save location</string>
<string name="settings_image_location_unset">Not yet set</string>
Expand Down

0 comments on commit 1378664

Please sign in to comment.