Prepare to implement customization options for post details page.

This commit is contained in:
Alex Ning 2021-07-30 18:00:42 +08:00
parent e660da55f0
commit 720aa0b6bd
7 changed files with 72 additions and 1 deletions

View File

@ -276,6 +276,12 @@ class AppModule {
return mApplication.getSharedPreferences(SharedPreferencesUtils.NAVIGATION_DRAWER_SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE);
}
@Provides
@Named("post_details")
SharedPreferences providePostDetailsSharedPreferences() {
return mApplication.getSharedPreferences(SharedPreferencesUtils.POST_DETAILS_SHARED_PREFERENCES_FILE, Context.MODE_PRIVATE);
}
@Provides
@Singleton
CustomThemeWrapper provideCustomThemeWrapper(@Named("light_theme") SharedPreferences lightThemeSharedPreferences,

View File

@ -0,0 +1,18 @@
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 PostDetailsPreferenceFragment extends PreferenceFragmentCompat {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
PreferenceManager preferenceManager = getPreferenceManager();
preferenceManager.setSharedPreferencesName(SharedPreferencesUtils.POST_DETAILS_SHARED_PREFERENCES_FILE);
setPreferencesFromResource(R.xml.post_details_preferences, rootKey);
}
}

View File

@ -319,6 +319,8 @@ public class SharedPreferencesUtils {
public static final String HIDE_FAVORITE_SUBREDDITS_SECTION = "hide_favorite_subreddits_sections";
public static final String HIDE_SUBSCRIBED_SUBREDDITS_SECTIONS = "hide_subscribed_subreddits_sections";
public static final String POST_DETAILS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.post_details";
//Legacy Settings
public static final String MAIN_PAGE_TAB_1_TITLE_LEGACY = "main_page_tab_1_title";
public static final String MAIN_PAGE_TAB_2_TITLE_LEGACY = "main_page_tab_2_title";

View File

@ -69,6 +69,7 @@
android:maxLines="2"
android:textColor="#FFFFFF"
android:textSize="?attr/title_font_20"
android:fontFamily="?attr/title_font_family" />
android:fontFamily="?attr/title_font_family"
android:textStyle="bold" />
</com.google.android.material.card.MaterialCardView>

View File

@ -588,6 +588,7 @@
<string name="settings_show_only_one_comment_level_indicator">Show Only One Comment Level Indicator</string>
<string name="settings_video_player_automatic_landscape_orientation">Switch to Landscape Orientation in Video Player Automatically</string>
<string name="settings_remember_muting_option_in_post_feed">Remember Muting Option in Post Feed</string>
<string name="settings_post_details_title">Post Details</string>
<string name="no_link_available">Cannot get the link</string>

View File

@ -53,6 +53,10 @@
app:title="@string/settings_category_post_title"
app:fragment="ml.docilealligator.infinityforreddit.settings.PostPreferenceFragment" />
<Preference
app:title="@string/settings_post_details_title"
app:fragment="ml.docilealligator.infinityforreddit.settings.PostDetailsPreferenceFragment" />
<Preference
app:title="@string/settings_category_comment_title"
app:fragment="ml.docilealligator.infinityforreddit.settings.CommentPreferenceFragment" />

View File

@ -0,0 +1,39 @@
<?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">
<!--<Preference
app:title="@string/settings_number_of_columns_in_post_feed_title"
app:fragment="ml.docilealligator.infinityforreddit.settings.NumberOfColumnsInPostFeedPreferenceFragment" />-->
<SwitchPreference
app:defaultValue="false"
app:key="hide_post_type"
app:title="@string/settings_hide_post_type" />
<SwitchPreference
app:defaultValue="false"
app:key="hide_post_flair"
app:title="@string/settings_hide_post_flair" />
<SwitchPreference
app:defaultValue="false"
app:key="hide_the_number_of_awards"
app:title="@string/settings_hide_the_number_of_awards" />
<SwitchPreference
app:defaultValue="false"
app:key="hide_subreddit_and_user_prefix"
app:title="@string/settings_hide_subreddit_and_user_prefix" />
<SwitchPreference
app:defaultValue="false"
app:key="hide_the_number_of_votes"
app:title="@string/settings_hide_the_number_of_votes" />
<SwitchPreference
app:defaultValue="false"
app:key="hide_the_number_of_comments"
app:title="@string/settings_hide_the_number_of_comments" />
</PreferenceScreen>