mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 21:07:11 +01:00
Setting default sort for subreddits and users is available.
This commit is contained in:
parent
b0bf06e0c0
commit
569283ea93
@ -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));
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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";
|
||||
|
@ -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>
|
@ -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>
|
||||
|
@ -67,10 +67,15 @@
|
||||
app:icon="@drawable/ic_filter_24dp"
|
||||
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"
|
||||
|
@ -19,12 +19,6 @@
|
||||
app:icon="@drawable/ic_exit_24dp"
|
||||
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"
|
||||
|
48
app/src/main/res/xml/sort_type_preferences.xml
Normal file
48
app/src/main/res/xml/sort_type_preferences.xml
Normal file
@ -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>
|
Loading…
Reference in New Issue
Block a user