From 85a51d7dc8e0d36563f7a3e1f5ec40a68967c835 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Sun, 16 Jan 2022 15:19:55 +0800 Subject: New option: Fixed height preview in card. --- .../adapters/PostRecyclerViewAdapter.java | 28 +++++++++++++--------- .../ChangeFixedHeightPreviewInCardEvent.java | 9 +++++++ .../infinityforreddit/fragments/PostFragment.java | 9 +++++++ .../settings/PostPreferenceFragment.java | 9 +++++++ .../utils/SharedPreferencesUtils.java | 1 + app/src/main/res/drawable/ic_play_circle_24dp.xml | 5 ++++ app/src/main/res/layout/item_post_compact.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/post_preferences.xml | 5 ++++ 9 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeFixedHeightPreviewInCardEvent.java create mode 100644 app/src/main/res/drawable/ic_play_circle_24dp.xml 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 cec20a29..82ccc212 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -206,6 +206,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { @@ -142,5 +144,12 @@ public class PostPreferenceFragment extends CustomFontPreferenceFragmentCompat { } }); } + + if (fixedHeightPreviewInCardSwitch != null) { + fixedHeightPreviewInCardSwitch.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new ChangeFixedHeightPreviewInCardEvent((Boolean) newValue)); + return true; + }); + } } } \ 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 fad3a640..e5713e4f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -200,6 +200,7 @@ public class SharedPreferencesUtils { public static final String DEFAULT_PLAYBACK_SPEED = "default_playback_speed"; public static final String LEGACY_AUTOPLAY_VIDEO_CONTROLLER_UI = "legacy_autoplay_video_controller_ui"; public static final String PINCH_TO_ZOOM_VIDEO = "pinch_to_zoom_video"; + public static final String FIXED_HEIGHT_PREVIEW_IN_CARD = "fixed_height_preview_in_card"; 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/drawable/ic_play_circle_24dp.xml b/app/src/main/res/drawable/ic_play_circle_24dp.xml new file mode 100644 index 00000000..3b89d612 --- /dev/null +++ b/app/src/main/res/drawable/ic_play_circle_24dp.xml @@ -0,0 +1,5 @@ + + + diff --git a/app/src/main/res/layout/item_post_compact.xml b/app/src/main/res/layout/item_post_compact.xml index 5bab3835..83335fbd 100644 --- a/app/src/main/res/layout/item_post_compact.xml +++ b/app/src/main/res/layout/item_post_compact.xml @@ -233,6 +233,7 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:layout_margin="0dp" + android:padding="4dp" android:background="@drawable/play_button_round_background" android:visibility="gone" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9a04f2e2..733343bf 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -624,6 +624,7 @@ Custom Font Family Custom Title Font Family Custom Content Font Family + Fixed Height in Card Cannot get the link diff --git a/app/src/main/res/xml/post_preferences.xml b/app/src/main/res/xml/post_preferences.xml index 7b3059e6..3bc09d0f 100644 --- a/app/src/main/res/xml/post_preferences.xml +++ b/app/src/main/res/xml/post_preferences.xml @@ -52,6 +52,11 @@ app:key="hide_the_number_of_comments" app:title="@string/settings_hide_the_number_of_comments" /> + + -- cgit v1.2.3