aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java14
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/SortTypePreferenceFragment.java15
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java5
-rw-r--r--app/src/main/res/values/arrays.xml48
-rw-r--r--app/src/main/res/values/strings.xml8
-rw-r--r--app/src/main/res/xml/main_preferences.xml7
-rw-r--r--app/src/main/res/xml/miscellaneous_preferences.xml6
-rw-r--r--app/src/main/res/xml/sort_type_preferences.xml48
8 files changed, 139 insertions, 12 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
index 5f64e1e1..0f1ee2d8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -68,8 +68,8 @@ import ml.docilealligator.infinityforreddit.FetchPostFilterAndReadPosts;
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.NetworkState;
-import ml.docilealligator.infinityforreddit.RecyclerViewContentScrollingInterface;
import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.RecyclerViewContentScrollingInterface;
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
import ml.docilealligator.infinityforreddit.SortType;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
@@ -488,9 +488,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
String sort;
String sortTime = null;
- sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName, SortType.Type.HOT.name());
+ sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + subredditName,
+ mSharedPreferences.getString(SharedPreferencesUtils.SUBREDDIT_DEFAULT_SORT_TYPE, SortType.Type.HOT.name()));
if (sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
- sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + subredditName, SortType.Time.ALL.name());
+ sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + subredditName,
+ mSharedPreferences.getString(SharedPreferencesUtils.SUBREDDIT_DEFAULT_SORT_TIME, SortType.Time.ALL.name()));
}
boolean displaySubredditName = subredditName != null && (subredditName.equals("popular") || subredditName.equals("all"));
postLayout = mPostLayoutSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, defaultPostLayout);
@@ -618,9 +620,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mFetchPostInfoLinearLayout.setLayoutParams(params);
}
- String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username, SortType.Type.NEW.name());
+ String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_POST_BASE + username,
+ mSharedPreferences.getString(SharedPreferencesUtils.USER_DEFAULT_SORT_TYPE, SortType.Type.NEW.name()));
if (sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
- String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username, SortType.Time.ALL.name());
+ String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_USER_POST_BASE + username,
+ mSharedPreferences.getString(SharedPreferencesUtils.USER_DEFAULT_SORT_TIME, SortType.Time.ALL.name()));
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
} else {
sortType = new SortType(SortType.Type.valueOf(sort));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/SortTypePreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/SortTypePreferenceFragment.java
new file mode 100644
index 00000000..78d32b46
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/SortTypePreferenceFragment.java
@@ -0,0 +1,15 @@
+package ml.docilealligator.infinityforreddit.settings;
+
+import android.os.Bundle;
+
+import androidx.preference.PreferenceFragmentCompat;
+
+import ml.docilealligator.infinityforreddit.R;
+
+public class SortTypePreferenceFragment extends PreferenceFragmentCompat {
+
+ @Override
+ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
+ setPreferencesFromResource(R.xml.sort_type_preferences, rootKey);
+ }
+} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
index 85be7c4e..b0e2d901 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -151,6 +151,11 @@ public class SharedPreferencesUtils {
public static final String ENABLE_SEARCH_HISTORY = "enable_search_history";
public static final String POST_FILTER = "post_filter";
public static final String ONLY_DISABLE_PREVIEW_IN_VIDEO_AND_GIF_POSTS = "only_disable_preview_in_video_and_gif_posts";
+ public static final String SAVE_SORT_TYPE = "save_sort_type";
+ public static final String SUBREDDIT_DEFAULT_SORT_TYPE = "subreddit_default_sort_type";
+ public static final String SUBREDDIT_DEFAULT_SORT_TIME = "subreddit_default_sort_time";
+ public static final String USER_DEFAULT_SORT_TYPE = "user_default_sort_type";
+ public static final String USER_DEFAULT_SORT_TIME = "user_default_sort_time";
public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs";
public static final String MAIN_PAGE_TAB_COUNT = "_main_page_tab_count";
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 79819832..52191982 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -349,4 +349,52 @@
<item>tr-rTR</item>
</string-array>
+ <string-array name="settings_subreddit_default_sort_type">
+ <item>Hot</item>
+ <item>New</item>
+ <item>Rising</item>
+ <item>Top</item>
+ <item>Controversial</item>
+ </string-array>
+
+ <string-array name="settings_subreddit_default_sort_type_values">
+ <item>HOT</item>
+ <item>NEW</item>
+ <item>RISING</item>
+ <item>TOP</item>
+ <item>CONTROVERSIAL</item>
+ </string-array>
+
+ <string-array name="settings_user_default_sort_type">
+ <item>New</item>
+ <item>Hot</item>
+ <item>Top</item>
+ <item>Controversial</item>
+ </string-array>
+
+ <string-array name="settings_user_default_sort_type_values">
+ <item>NEW</item>
+ <item>HOT</item>
+ <item>TOP</item>
+ <item>CONTROVERSIAL</item>
+ </string-array>
+
+ <string-array name="settings_default_sort_time">
+ <item>Hour</item>
+ <item>Day</item>
+ <item>Week</item>
+ <item>Month</item>
+ <item>Year</item>
+ <item>All Time</item>
+ </string-array>
+
+ <string-array name="settings_default_sort_time_values">
+ <item>HOUR</item>
+ <item>DAY</item>
+ <item>WEEK</item>
+ <item>MONTH</item>
+ <item>YEAR</item>
+ <item>ALL</item>
+ </string-array>
+
</resources> \ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index f5410e92..50eab52f 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -528,6 +528,12 @@
<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_sort_type_title">Sort Type</string>
+ <string name="settings_save_sort_type_title">Save Sort Type</string>
+ <string name="settings_subreddit_default_sort_type_title">Subreddit Default Sort Type</string>
+ <string name="settings_subreddit_default_sort_time_title">Subreddit Default Sort Time</string>
+ <string name="settings_user_default_sort_type_title">User Default Sort Type</string>
+ <string name="settings_user_default_sort_time_title">User Default Sort Time</string>
<string name="no_link_available">Cannot get the link</string>
@@ -1010,5 +1016,7 @@
<string name="add_subreddit_or_user_to_multireddit_failed">Unable to add %1$s to multireddit %2$s</string>
<string name="choose_a_user">Choose a user</string>
+ <!-- TODO: Remove or change this placeholder text -->
+ <string name="hello_blank_fragment">Hello blank fragment</string>
</resources>
diff --git a/app/src/main/res/xml/main_preferences.xml b/app/src/main/res/xml/main_preferences.xml
index e2dac88d..82a4689e 100644
--- a/app/src/main/res/xml/main_preferences.xml
+++ b/app/src/main/res/xml/main_preferences.xml
@@ -68,9 +68,14 @@
app:title="@string/settings_post_filter_title" />
<Preference
+ app:icon="@drawable/ic_sort_24dp"
+ app:title="@string/settings_sort_type_title"
+ app:fragment="ml.docilealligator.infinityforreddit.settings.SortTypePreferenceFragment" />
+
+ <Preference
app:icon="@drawable/ic_miscellaneous_24dp"
app:title="@string/settings_miscellaneous_title"
- app:fragment="ml.docilealligator.infinityforreddit.settings.MiscellaneousPreferenceFragment"/>
+ app:fragment="ml.docilealligator.infinityforreddit.settings.MiscellaneousPreferenceFragment" />
<Preference
android:icon="@drawable/ic_advanced_24dp"
diff --git a/app/src/main/res/xml/miscellaneous_preferences.xml b/app/src/main/res/xml/miscellaneous_preferences.xml
index 6fb763f6..b17e7545 100644
--- a/app/src/main/res/xml/miscellaneous_preferences.xml
+++ b/app/src/main/res/xml/miscellaneous_preferences.xml
@@ -20,12 +20,6 @@
app:title="@string/settings_confirm_to_exit" />
<SwitchPreference
- app:defaultValue="false"
- app:key="respect_subreddit_recommended_comment_sort_type"
- app:title="@string/settings_respect_subreddit_recommended_comment_sort_type_title"
- app:summary="@string/settings_respect_subreddit_recommended_comment_sort_type_summary" />
-
- <SwitchPreference
app:defaultValue="true"
app:key="enable_search_history"
app:title="@string/settings_enable_search_history_title"
diff --git a/app/src/main/res/xml/sort_type_preferences.xml b/app/src/main/res/xml/sort_type_preferences.xml
new file mode 100644
index 00000000..88b2a5f0
--- /dev/null
+++ b/app/src/main/res/xml/sort_type_preferences.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+
+ <SwitchPreference
+ app:defaultValue="true"
+ app:key="save_sort_type"
+ app:title="@string/settings_save_sort_type_title" />
+
+ <ListPreference
+ app:defaultValue="HOT"
+ app:entries="@array/settings_subreddit_default_sort_type"
+ app:entryValues="@array/settings_subreddit_default_sort_type_values"
+ app:key="subreddit_default_sort_type"
+ app:title="@string/settings_subreddit_default_sort_type_title"
+ app:useSimpleSummaryProvider="true" />
+
+ <ListPreference
+ app:defaultValue="ALL"
+ app:entries="@array/settings_default_sort_time"
+ app:entryValues="@array/settings_default_sort_time_values"
+ app:key="subreddit_default_sort_time"
+ app:title="@string/settings_subreddit_default_sort_time_title"
+ app:useSimpleSummaryProvider="true" />
+
+ <ListPreference
+ app:defaultValue="NEW"
+ app:entries="@array/settings_user_default_sort_type"
+ app:entryValues="@array/settings_user_default_sort_type_values"
+ app:key="user_default_sort_type"
+ app:title="@string/settings_user_default_sort_type_title"
+ app:useSimpleSummaryProvider="true" />
+
+ <ListPreference
+ app:defaultValue="ALL"
+ app:entries="@array/settings_default_sort_time"
+ app:entryValues="@array/settings_default_sort_time_values"
+ app:key="user_default_sort_time"
+ app:title="@string/settings_user_default_sort_time_title"
+ app:useSimpleSummaryProvider="true" />
+
+ <SwitchPreference
+ app:defaultValue="false"
+ app:key="respect_subreddit_recommended_comment_sort_type"
+ app:title="@string/settings_respect_subreddit_recommended_comment_sort_type_title"
+ app:summary="@string/settings_respect_subreddit_recommended_comment_sort_type_summary" />
+
+</PreferenceScreen> \ No newline at end of file