From 568aa7a78f37f7dd4c4c027e9701467887da799f Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Tue, 20 Jul 2021 20:13:11 +0800 Subject: New option: Default Link Post Layout. --- .../adapters/PostRecyclerViewAdapter.java | 55 +++++++++++++++++++++- .../events/ChangeDefaultLinkPostLayoutEvent.java | 9 ++++ .../infinityforreddit/fragments/PostFragment.java | 9 ++++ .../settings/PostPreferenceFragment.java | 9 ++++ .../utils/SharedPreferencesUtils.java | 1 + app/src/main/res/values/arrays.xml | 16 +++++++ app/src/main/res/values/strings.xml | 2 + app/src/main/res/xml/post_preferences.xml | 8 ++++ 8 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeDefaultLinkPostLayoutEvent.java (limited to 'app') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java index c0f29cce..ff3ff317 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -148,6 +148,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter { + EventBus.getDefault().post(new ChangeDefaultLinkPostLayoutEvent(Integer.parseInt((String) newValue))); + return true; + }); + } + if (showDividerInCompactLayoutSwitch != null) { showDividerInCompactLayoutSwitch.setOnPreferenceChangeListener((preference, newValue) -> { EventBus.getDefault().post(new ShowDividerInCompactLayoutPreferenceEvent((Boolean) newValue)); 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 a9a75626..470aad37 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -184,6 +184,7 @@ public class SharedPreferencesUtils { public static final String APPLY_MATERIAL_YOU = "apply_material_you"; public static final String VIDEO_PLAYER_AUTOMATIC_LANDSCAPE_ORIENTATION = "video_player_automatic_landscape_orientation"; public static final String REMEMBER_MUTING_OPTION_IN_POST_FEED = "remember_muting_option_in_post_feed"; + public static final String DEFAULT_LINK_POST_LAYOUT_KEY = "default_link_post_layout"; public static final String DEFAULT_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit_preferences"; public static final String MAIN_PAGE_TABS_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.main_page_tabs"; diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 38370d05..a22e1f60 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -55,6 +55,22 @@ 2 + + @string/link_post_layout_auto + @string/post_layout_card + @string/post_layout_card_2 + @string/post_layout_compact + @string/post_layout_gallery + + + + -1 + 0 + 3 + 1 + 2 + + @string/always_on @string/only_on_wifi diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f44c7c92..b0cf0dde 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -401,6 +401,7 @@ Time Format Post Default Post Layout + Default Link Post Layout Show Divider Show Thumbnail on the Left The Number of Columns in Post Feed @@ -619,6 +620,7 @@ Favorites All + Auto Card Layout Compact Layout Gallery Layout diff --git a/app/src/main/res/xml/post_preferences.xml b/app/src/main/res/xml/post_preferences.xml index 7ea526a5..55f9f5c2 100644 --- a/app/src/main/res/xml/post_preferences.xml +++ b/app/src/main/res/xml/post_preferences.xml @@ -10,6 +10,14 @@ app:title="@string/settings_default_post_layout" app:useSimpleSummaryProvider="true" /> + + -- cgit v1.2.3