aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java89
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostLayoutBottomSheetFragment.java35
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java1
-rw-r--r--app/src/main/res/layout/fragment_post_layout_bottom_sheet.xml (renamed from app/src/main/res/layout/fragment_post_layot_bottom_sheet.xml)16
-rw-r--r--app/src/main/res/values/arrays.xml4
-rw-r--r--app/src/main/res/values/strings.xml1
6 files changed, 106 insertions, 40 deletions
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<Post, RecyclerVie
private static final int VIEW_TYPE_POST_CARD_2_WITH_PREVIEW_TYPE = 9;
private static final int VIEW_TYPE_POST_CARD_2_GALLERY_TYPE = 10;
private static final int VIEW_TYPE_POST_CARD_2_TEXT_TYPE = 11;
+ private static final int VIEW_TYPE_POST_CARD_3_VIDEO_AUTOPLAY_TYPE = 12;
+ private static final int VIEW_TYPE_POST_CARD_3_WITH_PREVIEW_TYPE = 13;
+ private static final int VIEW_TYPE_POST_CARD_3_GALLERY_TYPE = 14;
+ private static final int VIEW_TYPE_POST_CARD_3_TEXT_TYPE = 15;
private static final DiffUtil.ItemCallback<Post> DIFF_CALLBACK = new DiffUtil.ItemCallback<Post>() {
@Override
@@ -404,6 +408,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
switch (mDefaultLinkPostLayout) {
case SharedPreferencesUtils.POST_LAYOUT_CARD_2:
return VIEW_TYPE_POST_CARD_2_WITH_PREVIEW_TYPE;
+ case SharedPreferencesUtils.POST_LAYOUT_CARD_3:
+ return VIEW_TYPE_POST_CARD_3_WITH_PREVIEW_TYPE;
case SharedPreferencesUtils.POST_LAYOUT_GALLERY:
return VIEW_TYPE_POST_GALLERY;
case SharedPreferencesUtils.POST_LAYOUT_COMPACT:
@@ -422,10 +428,12 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
switch (mDefaultLinkPostLayout) {
case SharedPreferencesUtils.POST_LAYOUT_CARD:
return VIEW_TYPE_POST_CARD_WITH_PREVIEW_TYPE;
- case SharedPreferencesUtils.POST_LAYOUT_GALLERY:
- return VIEW_TYPE_POST_GALLERY;
case SharedPreferencesUtils.POST_LAYOUT_CARD_2:
return VIEW_TYPE_POST_CARD_2_WITH_PREVIEW_TYPE;
+ case SharedPreferencesUtils.POST_LAYOUT_CARD_3:
+ return VIEW_TYPE_POST_CARD_3_WITH_PREVIEW_TYPE;
+ case SharedPreferencesUtils.POST_LAYOUT_GALLERY:
+ return VIEW_TYPE_POST_GALLERY;
}
}
}
@@ -441,7 +449,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} else {
return VIEW_TYPE_POST_GALLERY;
}
- } else {
+ } else if (mPostLayout == SharedPreferencesUtils.POST_LAYOUT_CARD_2) {
Post post = getItem(position);
if (post != null) {
switch (post.getPostType()) {
@@ -463,6 +471,8 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
switch (mDefaultLinkPostLayout) {
case SharedPreferencesUtils.POST_LAYOUT_CARD:
return VIEW_TYPE_POST_CARD_WITH_PREVIEW_TYPE;
+ case SharedPreferencesUtils.POST_LAYOUT_CARD_3:
+ return VIEW_TYPE_POST_CARD_3_WITH_PREVIEW_TYPE;
case SharedPreferencesUtils.POST_LAYOUT_GALLERY:
return VIEW_TYPE_POST_GALLERY;
case SharedPreferencesUtils.POST_LAYOUT_COMPACT:
@@ -474,6 +484,41 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
}
}
return VIEW_TYPE_POST_CARD_2_TEXT_TYPE;
+ } else {
+ Post post = getItem(position);
+ if (post != null) {
+ switch (post.getPostType()) {
+ case Post.VIDEO_TYPE:
+ if (mAutoplay) {
+ if ((!mAutoplayNsfwVideos && post.isNSFW()) || post.isSpoiler()) {
+ return VIEW_TYPE_POST_CARD_3_WITH_PREVIEW_TYPE;
+ }
+ return VIEW_TYPE_POST_CARD_3_VIDEO_AUTOPLAY_TYPE;
+ }
+ return VIEW_TYPE_POST_CARD_3_WITH_PREVIEW_TYPE;
+ case Post.GIF_TYPE:
+ case Post.IMAGE_TYPE:
+ return VIEW_TYPE_POST_CARD_3_WITH_PREVIEW_TYPE;
+ case Post.GALLERY_TYPE:
+ return VIEW_TYPE_POST_CARD_3_GALLERY_TYPE;
+ case Post.LINK_TYPE:
+ case Post.NO_PREVIEW_LINK_TYPE:
+ switch (mDefaultLinkPostLayout) {
+ case SharedPreferencesUtils.POST_LAYOUT_CARD:
+ return VIEW_TYPE_POST_CARD_WITH_PREVIEW_TYPE;
+ case SharedPreferencesUtils.POST_LAYOUT_CARD_2:
+ return VIEW_TYPE_POST_CARD_2_WITH_PREVIEW_TYPE;
+ case SharedPreferencesUtils.POST_LAYOUT_GALLERY:
+ return VIEW_TYPE_POST_GALLERY;
+ case SharedPreferencesUtils.POST_LAYOUT_COMPACT:
+ return VIEW_TYPE_POST_COMPACT;
+ }
+ return VIEW_TYPE_POST_CARD_3_WITH_PREVIEW_TYPE;
+ default:
+ return VIEW_TYPE_POST_CARD_3_TEXT_TYPE;
+ }
+ }
+ return VIEW_TYPE_POST_CARD_3_TEXT_TYPE;
}
}
@@ -482,24 +527,15 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (viewType == VIEW_TYPE_POST_CARD_VIDEO_AUTOPLAY_TYPE) {
if (mDataSavingMode) {
- return new PostMaterial3CardWithPreviewViewHolder(ItemPostCard3WithPreviewBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
- //return new PostWithPreviewTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_with_preview, parent, false));
- }
- //return new PostVideoAutoplayViewHolder(LayoutInflater.from(parent.getContext()).inflate(mLegacyAutoplayVideoControllerUI ? R.layout.item_post_video_type_autoplay_legacy_controller : R.layout.item_post_video_type_autoplay, parent, false));
- if (mLegacyAutoplayVideoControllerUI) {
- return new PostMaterial3CardVideoAutoplayLegacyControllerViewHolder(ItemPostCard3VideoTypeAutoplayLegacyControllerBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
- } else {
- return new PostMaterial3CardVideoAutoplayViewHolder(ItemPostCard3VideoTypeAutoplayBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
+ return new PostWithPreviewTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_with_preview, parent, false));
}
+ return new PostVideoAutoplayViewHolder(LayoutInflater.from(parent.getContext()).inflate(mLegacyAutoplayVideoControllerUI ? R.layout.item_post_video_type_autoplay_legacy_controller : R.layout.item_post_video_type_autoplay, parent, false));
} else if (viewType == VIEW_TYPE_POST_CARD_WITH_PREVIEW_TYPE) {
- //return new PostWithPreviewTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_with_preview, parent, false));
- return new PostMaterial3CardWithPreviewViewHolder(ItemPostCard3WithPreviewBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
+ return new PostWithPreviewTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_with_preview, parent, false));
} else if (viewType == VIEW_TYPE_POST_CARD_GALLERY_TYPE) {
- //return new PostGalleryTypeViewHolder(ItemPostGalleryTypeBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
- return new PostMaterial3CardGalleryTypeViewHolder(ItemPostCard3GalleryTypeBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
+ return new PostGalleryTypeViewHolder(ItemPostGalleryTypeBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
} else if (viewType == VIEW_TYPE_POST_CARD_TEXT_TYPE) {
- //return new PostTextTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_text, parent, false));
- return new PostMaterial3CardTextTypeViewHolder(ItemPostCard3TextBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
+ return new PostTextTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_text, parent, false));
} else if (viewType == VIEW_TYPE_POST_COMPACT) {
if (mShowThumbnailOnTheRightInCompactLayout) {
return new PostCompactRightThumbnailViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_compact_right_thumbnail, parent, false));
@@ -519,9 +555,24 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
return new PostCard2WithPreviewViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_card_2_with_preview, parent, false));
} else if (viewType == VIEW_TYPE_POST_CARD_2_GALLERY_TYPE) {
return new PostCard2GalleryTypeViewHolder(ItemPostCard2GalleryTypeBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
- } else {
- //VIEW_TYPE_POST_CARD_2_TEXT_TYPE
+ } else if (viewType == VIEW_TYPE_POST_CARD_2_TEXT_TYPE) {
return new PostCard2TextTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_card_2_text, parent, false));
+ } else if (viewType == VIEW_TYPE_POST_CARD_3_VIDEO_AUTOPLAY_TYPE) {
+ if (mDataSavingMode) {
+ return new PostMaterial3CardWithPreviewViewHolder(ItemPostCard3WithPreviewBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
+ }
+ if (mLegacyAutoplayVideoControllerUI) {
+ return new PostMaterial3CardVideoAutoplayLegacyControllerViewHolder(ItemPostCard3VideoTypeAutoplayLegacyControllerBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
+ } else {
+ return new PostMaterial3CardVideoAutoplayViewHolder(ItemPostCard3VideoTypeAutoplayBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
+ }
+ } else if (viewType == VIEW_TYPE_POST_CARD_3_WITH_PREVIEW_TYPE) {
+ return new PostMaterial3CardWithPreviewViewHolder(ItemPostCard3WithPreviewBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
+ } else if (viewType == VIEW_TYPE_POST_CARD_3_GALLERY_TYPE) {
+ return new PostMaterial3CardGalleryTypeViewHolder(ItemPostCard3GalleryTypeBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
+ } else {
+ //VIEW_TYPE_POST_CARD_3_TEXT_TYPE
+ return new PostMaterial3CardTextTypeViewHolder(ItemPostCard3TextBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false));
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostLayoutBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostLayoutBottomSheetFragment.java
index 58fcef0a..e11a8867 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostLayoutBottomSheetFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostLayoutBottomSheetFragment.java
@@ -6,16 +6,13 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
-import butterknife.BindView;
-import butterknife.ButterKnife;
-import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity;
import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
+import ml.docilealligator.infinityforreddit.databinding.FragmentPostLayoutBottomSheetBinding;
import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils;
import ml.docilealligator.infinityforreddit.utils.Utils;
@@ -24,14 +21,7 @@ import ml.docilealligator.infinityforreddit.utils.Utils;
*/
public class PostLayoutBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
- @BindView(R.id.card_layout_text_view_post_layout_bottom_sheet_fragment)
- TextView cardLayoutTextView;
- @BindView(R.id.card_layout_2_text_view_post_layout_bottom_sheet_fragment)
- TextView cardLayout2TextView;
- @BindView(R.id.compact_layout_text_view_post_layout_bottom_sheet_fragment)
- TextView compactLayoutTextView;
- @BindView(R.id.gallery_layout_text_view_post_layout_bottom_sheet_fragment)
- TextView galleryLayoutTextView;
+ private FragmentPostLayoutBottomSheetBinding binding;
private BaseActivity activity;
public PostLayoutBottomSheetFragment() {
// Required empty public constructor
@@ -39,33 +29,36 @@ public class PostLayoutBottomSheetFragment extends LandscapeExpandedRoundedBotto
@Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
- View rootView = inflater.inflate(R.layout.fragment_post_layot_bottom_sheet, container, false);
- ButterKnife.bind(this, rootView);
+ binding = FragmentPostLayoutBottomSheetBinding.inflate(inflater, container, false);
- cardLayoutTextView.setOnClickListener(view -> {
+ 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
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
@@ -45,6 +45,22 @@
android:fontFamily="?attr/font_family" />
<TextView
+ android:id="@+id/card_layout_3_text_view_post_layout_bottom_sheet_fragment"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="?attr/selectableItemBackground"
+ android:clickable="true"
+ android:focusable="true"
+ android:paddingStart="32dp"
+ android:paddingTop="16dp"
+ android:paddingEnd="32dp"
+ android:paddingBottom="16dp"
+ android:text="@string/post_layout_card_2"
+ android:textColor="?attr/primaryTextColor"
+ android:textSize="?attr/font_default"
+ android:fontFamily="?attr/font_family" />
+
+ <TextView
android:id="@+id/compact_layout_text_view_post_layout_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 79a54712..7d82435d 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -44,6 +44,7 @@
<string-array name="settings_default_post_layout">
<item>@string/post_layout_card</item>
<item>@string/post_layout_card_2</item>
+ <item>@string/post_layout_card_3</item>
<item>@string/post_layout_compact</item>
<item>@string/post_layout_gallery</item>
</string-array>
@@ -51,6 +52,7 @@
<string-array name="settings_default_post_layout_values">
<item>0</item>
<item>3</item>
+ <item>4</item>
<item>1</item>
<item>2</item>
</string-array>
@@ -59,6 +61,7 @@
<item>@string/link_post_layout_auto</item>
<item>@string/post_layout_card</item>
<item>@string/post_layout_card_2</item>
+ <item>@string/post_layout_card_3</item>
<item>@string/post_layout_compact</item>
<item>@string/post_layout_gallery</item>
</string-array>
@@ -67,6 +70,7 @@
<item>-1</item>
<item>0</item>
<item>3</item>
+ <item>4</item>
<item>1</item>
<item>2</item>
</string-array>
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 @@
<string name="post_layout_compact">Compact Layout</string>
<string name="post_layout_gallery">Gallery Layout</string>
<string name="post_layout_card_2">Card Layout 2</string>
+ <string name="post_layout_card_3">Card Layout 3</string>
<string name="elapsed_time_just_now">Just Now</string>
<string name="elapsed_time_a_minute_ago">1 Minute</string>