From a5482a6b33155ec01e778006ca7c2ddfb465b8b2 Mon Sep 17 00:00:00 2001 From: Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:04:11 -0400 Subject: [PATCH] Continue adding Card Layout 3. Settings entry for Card Layout 3. --- .../adapters/PostRecyclerViewAdapter.java | 89 +++++++++++++++---- .../PostLayoutBottomSheetFragment.java | 35 +++----- .../utils/SharedPreferencesUtils.java | 1 + ... => fragment_post_layout_bottom_sheet.xml} | 16 ++++ app/src/main/res/values/arrays.xml | 4 + app/src/main/res/values/strings.xml | 1 + 6 files changed, 106 insertions(+), 40 deletions(-) rename app/src/main/res/layout/{fragment_post_layot_bottom_sheet.xml => fragment_post_layout_bottom_sheet.xml} (82%) 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 df951ee7..700ae3c7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java @@ -135,6 +135,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter DIFF_CALLBACK = new DiffUtil.ItemCallback() { @Override @@ -404,6 +408,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter { + binding.cardLayoutTextViewPostLayoutBottomSheetFragment.setOnClickListener(view -> { ((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_CARD); dismiss(); }); - compactLayoutTextView.setOnClickListener(view -> { + binding.compactLayoutTextViewPostLayoutBottomSheetFragment.setOnClickListener(view -> { ((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_COMPACT); dismiss(); }); - galleryLayoutTextView.setOnClickListener(view -> { + binding.galleryLayoutTextViewPostLayoutBottomSheetFragment.setOnClickListener(view -> { ((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_GALLERY); dismiss(); }); - cardLayout2TextView.setOnClickListener(view -> { + binding.cardLayout2TextViewPostLayoutBottomSheetFragment.setOnClickListener(view -> { ((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_CARD_2); dismiss(); }); + binding.cardLayout3TextViewPostLayoutBottomSheetFragment.setOnClickListener(view -> { + ((PostLayoutSelectionCallback) activity).postLayoutSelected(SharedPreferencesUtils.POST_LAYOUT_CARD_3); + dismiss(); + }); if (activity.typeface != null) { - Utils.setFontToAllTextViews(rootView, activity.typeface); + Utils.setFontToAllTextViews(binding.getRoot(), activity.typeface); } - return rootView; + return binding.getRoot(); } @Override 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 3749ff99..f27253d6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -74,6 +74,7 @@ public class SharedPreferencesUtils { public static final int POST_LAYOUT_COMPACT = 1; public static final int POST_LAYOUT_GALLERY = 2; public static final int POST_LAYOUT_CARD_2 = 3; + public static final int POST_LAYOUT_CARD_3 = 4; public static final String FRONT_PAGE_SCROLLED_POSITION_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.front_page_scrolled_position"; public static final String FRONT_PAGE_SCROLLED_POSITION_FRONT_PAGE_BASE = "_front_page"; diff --git a/app/src/main/res/layout/fragment_post_layot_bottom_sheet.xml b/app/src/main/res/layout/fragment_post_layout_bottom_sheet.xml similarity index 82% rename from app/src/main/res/layout/fragment_post_layot_bottom_sheet.xml rename to app/src/main/res/layout/fragment_post_layout_bottom_sheet.xml index e42263a0..5f714e39 100644 --- a/app/src/main/res/layout/fragment_post_layot_bottom_sheet.xml +++ b/app/src/main/res/layout/fragment_post_layout_bottom_sheet.xml @@ -44,6 +44,22 @@ android:textSize="?attr/font_default" android:fontFamily="?attr/font_family" /> + + @string/post_layout_card @string/post_layout_card_2 + @string/post_layout_card_3 @string/post_layout_compact @string/post_layout_gallery @@ -51,6 +52,7 @@ 0 3 + 4 1 2 @@ -59,6 +61,7 @@ @string/link_post_layout_auto @string/post_layout_card @string/post_layout_card_2 + @string/post_layout_card_3 @string/post_layout_compact @string/post_layout_gallery @@ -67,6 +70,7 @@ -1 0 3 + 4 1 2 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 641a647f..0b5bdac1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -684,6 +684,7 @@ Compact Layout Gallery Layout Card Layout 2 + Card Layout 3 Just Now 1 Minute