aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostRecyclerViewAdapter.java28
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeFixedHeightPreviewInCardEvent.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java1
-rw-r--r--app/src/main/res/drawable/ic_play_circle_24dp.xml5
-rw-r--r--app/src/main/res/layout/item_post_compact.xml1
-rw-r--r--app/src/main/res/values/strings.xml1
-rw-r--r--app/src/main/res/xml/post_preferences.xml5
9 files changed, 57 insertions, 11 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 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<Post, RecyclerVie
private boolean mHideTheNumberOfVotes;
private boolean mHideTheNumberOfComments;
private boolean mLegacyAutoplayVideoControllerUI;
+ private boolean mFixedHeightPreviewInCard;
private Drawable mCommentIcon;
private ExoCreator mExoCreator;
private Callback mCallback;
@@ -282,6 +283,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mHideTheNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES, false);
mHideTheNumberOfComments = sharedPreferences.getBoolean(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_COMMENTS, false);
mLegacyAutoplayVideoControllerUI = sharedPreferences.getBoolean(SharedPreferencesUtils.LEGACY_AUTOPLAY_VIDEO_CONTROLLER_UI, false);
+ mFixedHeightPreviewInCard = sharedPreferences.getBoolean(SharedPreferencesUtils.FIXED_HEIGHT_PREVIEW_IN_CARD, false);
mPostLayout = postLayout;
mDefaultLinkPostLayout = Integer.parseInt(sharedPreferences.getString(SharedPreferencesUtils.DEFAULT_LINK_POST_LAYOUT_KEY, "-1"));
@@ -681,7 +683,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
if (holder instanceof PostVideoAutoplayViewHolder) {
((PostVideoAutoplayViewHolder) holder).previewImageView.setVisibility(View.VISIBLE);
Post.Preview preview = getSuitablePreview(post.getPreviews());
- if (preview != null) {
+ if (!mFixedHeightPreviewInCard && preview != null) {
((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewWidth() / preview.getPreviewHeight());
mGlide.load(preview.getPreviewUrl()).centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostVideoAutoplayViewHolder) holder).previewImageView);
} else {
@@ -798,7 +800,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostWithPreviewTypeViewHolder) holder).preview = preview;
if (preview != null) {
((PostWithPreviewTypeViewHolder) holder).imageWrapperRelativeLayout.setVisibility(View.VISIBLE);
- if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
+ if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
int height = (int) (400 * mScale);
((PostWithPreviewTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
((PostWithPreviewTypeViewHolder) holder).imageView.getLayoutParams().height = height;
@@ -833,7 +835,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
} else if (holder instanceof PostCard2VideoAutoplayViewHolder) {
((PostCard2VideoAutoplayViewHolder) holder).previewImageView.setVisibility(View.VISIBLE);
Post.Preview preview = getSuitablePreview(post.getPreviews());
- if (preview != null) {
+ if (!mFixedHeightPreviewInCard && preview != null) {
((PostCard2VideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) preview.getPreviewWidth() / preview.getPreviewHeight());
mGlide.load(preview.getPreviewUrl()).centerInside().downsample(new SaveMemoryCenterInisdeDownsampleStrategy()).into(((PostCard2VideoAutoplayViewHolder) holder).previewImageView);
} else {
@@ -952,7 +954,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostCard2WithPreviewViewHolder) holder).preview = preview;
if (preview != null) {
((PostCard2WithPreviewViewHolder) holder).imageView.setVisibility(View.VISIBLE);
- if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
+ if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
int height = (int) (400 * mScale);
((PostCard2WithPreviewViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
((PostCard2WithPreviewViewHolder) holder).imageView.getLayoutParams().height = height;
@@ -1261,7 +1263,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostCompactBaseViewHolder) holder).noPreviewPostImageView.setImageResource(R.drawable.ic_image_24dp);
} else {
((PostCompactBaseViewHolder) holder).playButtonImageView.setVisibility(View.VISIBLE);
- ((PostCompactBaseViewHolder) holder).playButtonImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_play_circle_36dp));
+ ((PostCompactBaseViewHolder) holder).playButtonImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_play_circle_24dp));
}
break;
case Post.VIDEO_TYPE:
@@ -1271,7 +1273,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
((PostCompactBaseViewHolder) holder).noPreviewPostImageView.setImageResource(R.drawable.ic_outline_video_24dp);
} else {
((PostCompactBaseViewHolder) holder).playButtonImageView.setVisibility(View.VISIBLE);
- ((PostCompactBaseViewHolder) holder).playButtonImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_play_circle_36dp));
+ ((PostCompactBaseViewHolder) holder).playButtonImageView.setImageDrawable(ContextCompat.getDrawable(mActivity, R.drawable.ic_play_circle_24dp));
}
break;
case Post.NO_PREVIEW_LINK_TYPE:
@@ -1332,7 +1334,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
Post.Preview preview = getSuitablePreview(post.getPreviews());
((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) {
- if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
+ if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
int height = (int) (400 * mScale);
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
@@ -1366,7 +1368,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
Post.Preview preview = getSuitablePreview(post.getPreviews());
((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) {
- if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
+ if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
int height = (int) (400 * mScale);
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
@@ -1390,7 +1392,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
Post.Preview preview = getSuitablePreview(post.getPreviews());
((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) {
- if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
+ if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
int height = (int) (400 * mScale);
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
@@ -1414,7 +1416,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
Post.Preview preview = getSuitablePreview(post.getPreviews());
((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) {
- if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
+ if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
int height = (int) (400 * mScale);
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
@@ -1448,7 +1450,7 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
Post.Preview preview = getSuitablePreview(post.getPreviews());
((PostGalleryViewHolder) holder).preview = preview;
if (preview != null) {
- if (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0) {
+ if (mFixedHeightPreviewInCard || (preview.getPreviewWidth() <= 0 || preview.getPreviewHeight() <= 0)) {
int height = (int) (400 * mScale);
((PostGalleryViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
((PostGalleryViewHolder) holder).imageView.getLayoutParams().height = height;
@@ -1731,6 +1733,10 @@ public class PostRecyclerViewAdapter extends PagingDataAdapter<Post, RecyclerVie
mDefaultLinkPostLayout = defaultLinkPostLayout;
}
+ public void setFixedHeightPreviewInCard(boolean fixedHeightPreviewInCard) {
+ mFixedHeightPreviewInCard = fixedHeightPreviewInCard;
+ }
+
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
super.onViewRecycled(holder);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeFixedHeightPreviewInCardEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeFixedHeightPreviewInCardEvent.java
new file mode 100644
index 00000000..fff0c816
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/events/ChangeFixedHeightPreviewInCardEvent.java
@@ -0,0 +1,9 @@
+package ml.docilealligator.infinityforreddit.events;
+
+public class ChangeFixedHeightPreviewInCardEvent {
+ public boolean fixedHeightPreviewInCard;
+
+ public ChangeFixedHeightPreviewInCardEvent(boolean fixedHeightPreviewInCard) {
+ this.fixedHeightPreviewInCard = fixedHeightPreviewInCard;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
index 6d63b6c7..3638190c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java
@@ -95,6 +95,7 @@ import ml.docilealligator.infinityforreddit.events.ChangeDefaultLinkPostLayoutEv
import ml.docilealligator.infinityforreddit.events.ChangeDefaultPostLayoutEvent;
import ml.docilealligator.infinityforreddit.events.ChangeDisableImagePreviewEvent;
import ml.docilealligator.infinityforreddit.events.ChangeEnableSwipeActionSwitchEvent;
+import ml.docilealligator.infinityforreddit.events.ChangeFixedHeightPreviewInCardEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHidePostFlairEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHidePostTypeEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideSubredditAndUserPrefixEvent;
@@ -2065,6 +2066,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
}
+ @Subscribe
+ public void onChangeFixedHeightPreviewCardEvent(ChangeFixedHeightPreviewInCardEvent event) {
+ if (mAdapter != null) {
+ mAdapter.setFixedHeightPreviewInCard(event.fixedHeightPreviewInCard);
+ refreshAdapter();
+ }
+ }
+
private void refreshAdapter() {
int previousPosition = -1;
if (mLinearLayoutManager != null) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java
index a93bc592..d4785cc7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/PostPreferenceFragment.java
@@ -13,6 +13,7 @@ import ml.docilealligator.infinityforreddit.customviews.CustomFontPreferenceFrag
import ml.docilealligator.infinityforreddit.events.ChangeCompactLayoutToolbarHiddenByDefaultEvent;
import ml.docilealligator.infinityforreddit.events.ChangeDefaultLinkPostLayoutEvent;
import ml.docilealligator.infinityforreddit.events.ChangeDefaultPostLayoutEvent;
+import ml.docilealligator.infinityforreddit.events.ChangeFixedHeightPreviewInCardEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHidePostFlairEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHidePostTypeEvent;
import ml.docilealligator.infinityforreddit.events.ChangeHideSubredditAndUserPrefixEvent;
@@ -48,6 +49,7 @@ public class PostPreferenceFragment extends CustomFontPreferenceFragmentCompat {
SwitchPreference hideSubredditAndUserPrefixSwitch = findPreference(SharedPreferencesUtils.HIDE_SUBREDDIT_AND_USER_PREFIX);
SwitchPreference hideTheNumberOfVotesSwitch = findPreference(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_VOTES);
SwitchPreference hideTheNumberOfCommentsSwitch = findPreference(SharedPreferencesUtils.HIDE_THE_NUMBER_OF_COMMENTS);
+ SwitchPreference fixedHeightPreviewInCardSwitch = findPreference(SharedPreferencesUtils.FIXED_HEIGHT_PREVIEW_IN_CARD);
if (defaultPostLayoutList != null) {
defaultPostLayoutList.setOnPreferenceChangeListener((preference, newValue) -> {
@@ -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 @@
+<vector android:height="24dp" android:tint="#FFFFFF"
+ android:viewportHeight="24" android:viewportWidth="24"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="@android:color/white" android:pathData="M10,16.5l6,-4.5 -6,-4.5zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8z"/>
+</vector>
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 @@
<string name="settings_custom_font_family_title">Custom Font Family</string>
<string name="settings_custom_title_font_family_title">Custom Title Font Family</string>
<string name="settings_custom_content_font_family_title">Custom Content Font Family</string>
+ <string name="settings_fixed_height_preview_in_card_title">Fixed Height in Card</string>
<string name="no_link_available">Cannot get the link</string>
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" />
+ <ml.docilealligator.infinityforreddit.customviews.CustomFontSwitchPreference
+ app:defaultValue="false"
+ app:key="fixed_height_preview_in_card"
+ app:title="@string/settings_fixed_height_preview_in_card_title" />
+
<ml.docilealligator.infinityforreddit.customviews.CustomFontPreferenceCategory
app:title="@string/post_layout_compact" />