Add settings for navigation drawer.

This commit is contained in:
Alex Ning 2021-03-14 21:26:36 +08:00
parent 5811ca9ff0
commit c0937304cc
4 changed files with 63 additions and 0 deletions

View File

@ -0,0 +1,19 @@
package ml.docilealligator.infinityforreddit.settings;
import android.os.Bundle;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
public class NavigationDrawerPreferenceFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
PreferenceManager preferenceManager = getPreferenceManager();
preferenceManager.setSharedPreferencesName(SharedPreferencesUtils.NAVIGATION_DRAWER_SHARED_PREFERENCES_FILE);
setPreferencesFromResource(R.xml.navigation_drawer_preferences, rootKey);
}
}

View File

@ -547,6 +547,12 @@
<string name="settings_restore_settings_title">Restore Settings</string> <string name="settings_restore_settings_title">Restore Settings</string>
<string name="settings_credits_love_animation_title">Love Animation</string> <string name="settings_credits_love_animation_title">Love Animation</string>
<string name="settings_swipe_between_posts_title">Swipe Between Posts</string> <string name="settings_swipe_between_posts_title">Swipe Between Posts</string>
<string name="settings_navigation_drawer_title">Navigation Drawer</string>
<string name="settings_collapse_account_section_title">Collapse Account Section</string>
<string name="settings_collapse_post_section_title">Collapse Post Section</string>
<string name="settings_collapse_preferences_section_title">Collapse Preferences Section</string>
<string name="settings_collapse_favorite_subreddits_section_title">Collapse Favorite Subreddits Section</string>
<string name="settings_collapse_subscribed_subreddits_section_title">Collapse Subscribed Subreddits Section</string>
<string name="no_link_available">Cannot get the link</string> <string name="no_link_available">Cannot get the link</string>

View File

@ -13,6 +13,10 @@
app:fragment="ml.docilealligator.infinityforreddit.settings.ImmersiveInterfacePreferenceFragment" app:fragment="ml.docilealligator.infinityforreddit.settings.ImmersiveInterfacePreferenceFragment"
app:isPreferenceVisible="false" /> app:isPreferenceVisible="false" />
<Preference
app:title="@string/settings_navigation_drawer_title"
app:fragment="ml.docilealligator.infinityforreddit.settings.NavigationDrawerPreferenceFragment" />
<Preference <Preference
app:title="@string/settings_customize_tabs_in_main_page_title" app:title="@string/settings_customize_tabs_in_main_page_title"
app:summary="@string/only_for_logged_in_user" app:summary="@string/only_for_logged_in_user"

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:app="http://schemas.android.com/apk/res-auto">
<Preference
app:icon="@drawable/ic_info_preference_24dp"
app:summary="@string/restart_app_see_changes"
app:enabled="false" />
<SwitchPreference
app:defaultValue="false"
app:key="collapse_account_section"
app:title="@string/settings_collapse_account_section_title" />
<SwitchPreference
app:defaultValue="false"
app:key="collapse_post_section"
app:title="@string/settings_collapse_post_section_title" />
<SwitchPreference
app:defaultValue="false"
app:key="collapse_preferences_section"
app:title="@string/settings_collapse_preferences_section_title" />
<SwitchPreference
app:defaultValue="false"
app:key="collapse_favorite_subreddits_section"
app:title="@string/settings_collapse_favorite_subreddits_section_title" />
<SwitchPreference
app:defaultValue="false"
app:key="collapse_subscribed_subreddits_section"
app:title="@string/settings_collapse_subscribed_subreddits_section_title" />
</PreferenceScreen>