mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-28 11:58:23 +01:00
Add an option for video autoplay. Rewrite some viewholders in PostRecyclerViewAdapter.
This commit is contained in:
parent
5c05350119
commit
4678caa92b
@ -88,8 +88,8 @@ import retrofit2.Retrofit;
|
||||
|
||||
public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView.ViewHolder> implements CacheManager {
|
||||
private static final int VIEW_TYPE_POST_CARD_VIDEO_TYPE_AUTOPLAY = 1;
|
||||
private static final int VIEW_TYPE_POST_CARD_GIF_TYPE = 2;
|
||||
private static final int VIEW_TYPE_POST_CARD_IMAGE_TYPE = 3;
|
||||
private static final int VIEW_TYPE_POST_CARD_VIDEO_AND_GIF_PREVIEW_TYPE = 2;
|
||||
private static final int VIEW_TYPE_POST_CARD_IMAGE_AND_GIF_AUTOPLAY_TYPE = 3;
|
||||
private static final int VIEW_TYPE_POST_CARD_LINK_TYPE = 4;
|
||||
private static final int VIEW_TYPE_POST_CARD_NO_PREVIEW_LINK_TYPE = 5;
|
||||
private static final int VIEW_TYPE_POST_CARD_TEXT_TYPE = 6;
|
||||
@ -153,7 +153,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
private boolean mShowElapsedTime;
|
||||
private boolean mShowDividerInCompactLayout;
|
||||
private boolean mShowAbsoluteNumberOfVotes;
|
||||
private boolean mAutoplay = true;
|
||||
private boolean mAutoplay = false;
|
||||
private Drawable mCommentIcon;
|
||||
private NetworkState networkState;
|
||||
private ExoCreator mExoCreator;
|
||||
@ -180,6 +180,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
mShowElapsedTime = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
|
||||
mShowDividerInCompactLayout = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_DIVIDER_IN_COMPACT_LAYOUT, true);
|
||||
mShowAbsoluteNumberOfVotes = sharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ABSOLUTE_NUMBER_OF_VOTES, true);
|
||||
String autoplayString = sharedPreferences.getString(SharedPreferencesUtils.VIDEO_AUTOPLAY, SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_NEVER);
|
||||
if (autoplayString.equals(SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_ALWAYS_ON)) {
|
||||
mAutoplay = true;
|
||||
} else if (autoplayString.equals(SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_ON_WIFI)) {
|
||||
mAutoplay = Utils.isConnectedToWifi(activity);
|
||||
}
|
||||
mPostLayout = postLayout;
|
||||
|
||||
mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
|
||||
@ -244,11 +250,17 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
if (post != null) {
|
||||
switch (post.getPostType()) {
|
||||
case Post.VIDEO_TYPE:
|
||||
return VIEW_TYPE_POST_CARD_VIDEO_TYPE_AUTOPLAY;
|
||||
if (mAutoplay) {
|
||||
return VIEW_TYPE_POST_CARD_VIDEO_TYPE_AUTOPLAY;
|
||||
}
|
||||
return VIEW_TYPE_POST_CARD_VIDEO_AND_GIF_PREVIEW_TYPE;
|
||||
case Post.GIF_TYPE:
|
||||
return VIEW_TYPE_POST_CARD_GIF_TYPE;
|
||||
if (mAutoplay) {
|
||||
return VIEW_TYPE_POST_CARD_IMAGE_AND_GIF_AUTOPLAY_TYPE;
|
||||
}
|
||||
return VIEW_TYPE_POST_CARD_VIDEO_AND_GIF_PREVIEW_TYPE;
|
||||
case Post.IMAGE_TYPE:
|
||||
return VIEW_TYPE_POST_CARD_IMAGE_TYPE;
|
||||
return VIEW_TYPE_POST_CARD_IMAGE_AND_GIF_AUTOPLAY_TYPE;
|
||||
case Post.LINK_TYPE:
|
||||
return VIEW_TYPE_POST_CARD_LINK_TYPE;
|
||||
case Post.NO_PREVIEW_LINK_TYPE:
|
||||
@ -269,10 +281,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
if (viewType == VIEW_TYPE_POST_CARD_VIDEO_TYPE_AUTOPLAY) {
|
||||
return new PostVideoAutoplayViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_video_type_autoplay, parent, false));
|
||||
} else if (viewType == VIEW_TYPE_POST_CARD_GIF_TYPE) {
|
||||
return new PostGifTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_gif_type, parent, false));
|
||||
} else if (viewType == VIEW_TYPE_POST_CARD_IMAGE_TYPE) {
|
||||
return new PostImageTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_image_type, parent, false));
|
||||
} else if (viewType == VIEW_TYPE_POST_CARD_VIDEO_AND_GIF_PREVIEW_TYPE) {
|
||||
return new PostGifAndVideoPreviewViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_video_and_gif_preview_type, parent, false));
|
||||
} else if (viewType == VIEW_TYPE_POST_CARD_IMAGE_AND_GIF_AUTOPLAY_TYPE) {
|
||||
return new PostImageAndGifAutoplayTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_image_and_gif_autoplay_type, parent, false));
|
||||
} else if (viewType == VIEW_TYPE_POST_CARD_LINK_TYPE) {
|
||||
return new PostLinkTypeViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_post_link_type, parent, false));
|
||||
} else if (viewType == VIEW_TYPE_POST_CARD_NO_PREVIEW_LINK_TYPE) {
|
||||
@ -479,56 +491,37 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
}
|
||||
|
||||
if (holder instanceof PostVideoAutoplayViewHolder) {
|
||||
/*final Uri gifVideoUri = Uri.parse(post.getVideoUrl());
|
||||
((PostBaseViewHolder) holder).imageView.setOnClickListener(view -> {
|
||||
Intent intent = new Intent(mActivity, ViewGIFActivity.class);
|
||||
intent.setData(gifVideoUri);
|
||||
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, subredditName
|
||||
+ "-" + id + ".gif");
|
||||
intent.putExtra(ViewGIFActivity.GIF_URL_KEY, post.getVideoUrl());
|
||||
intent.putExtra(ViewGIFActivity.POST_TITLE_KEY, post.getTitle());
|
||||
mActivity.startActivity(intent);
|
||||
});
|
||||
|
||||
((PostBaseViewHolder) holder).playButtonImageView.setVisibility(View.VISIBLE);*/
|
||||
|
||||
|
||||
/*final Uri videoUri = Uri.parse(post.getVideoUrl());
|
||||
((PostBaseViewHolder) holder).imageView.setOnClickListener(view -> {
|
||||
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
||||
intent.setData(videoUri);
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, subredditName);
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_ID, fullName);
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle());
|
||||
mActivity.startActivity(intent);
|
||||
});
|
||||
|
||||
((PostBaseViewHolder) holder).playButtonImageView.setVisibility(View.VISIBLE);*/
|
||||
/*((PostVideoAutoplayViewHolder) holder).videoPlayer.setRatio(
|
||||
(float) post.getPreviewHeight() / post.getPreviewWidth()
|
||||
);*/
|
||||
((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) post.getPreviewWidth() / post.getPreviewHeight());
|
||||
((PostVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl()));
|
||||
} else if (holder instanceof PostGifTypeViewHolder) {
|
||||
((PostGifTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
((PostGifTypeViewHolder) holder).imageView
|
||||
.setRatio((float) post.getPreviewHeight() / post.getPreviewWidth());
|
||||
loadImage(holder, post);
|
||||
|
||||
if (post.getPreviewWidth() <= 0 || post.getPreviewHeight() <= 0) {
|
||||
((PostGifTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
((PostGifTypeViewHolder) holder).imageView.getLayoutParams().height = (int) (400 * mScale);
|
||||
} else if (holder instanceof PostGifAndVideoPreviewViewHolder) {
|
||||
if (post.getPostType() == Post.VIDEO_TYPE) {
|
||||
((PostGifAndVideoPreviewViewHolder) holder).typeTextView.setText(mActivity.getString(R.string.video));
|
||||
} else {
|
||||
((PostGifAndVideoPreviewViewHolder) holder).typeTextView.setText(mActivity.getString(R.string.gif));
|
||||
}
|
||||
} else if (holder instanceof PostImageTypeViewHolder) {
|
||||
((PostImageTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
((PostImageTypeViewHolder) holder).imageView
|
||||
((PostGifAndVideoPreviewViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
((PostGifAndVideoPreviewViewHolder) holder).imageView
|
||||
.setRatio((float) post.getPreviewHeight() / post.getPreviewWidth());
|
||||
loadImage(holder, post);
|
||||
|
||||
if (post.getPreviewWidth() <= 0 || post.getPreviewHeight() <= 0) {
|
||||
((PostImageTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
((PostImageTypeViewHolder) holder).imageView.getLayoutParams().height = (int) (400 * mScale);
|
||||
((PostGifAndVideoPreviewViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
((PostGifAndVideoPreviewViewHolder) holder).imageView.getLayoutParams().height = (int) (400 * mScale);
|
||||
}
|
||||
} else if (holder instanceof PostImageAndGifAutoplayTypeViewHolder) {
|
||||
if (post.getPostType() == Post.GIF_TYPE) {
|
||||
((PostImageAndGifAutoplayTypeViewHolder) holder).typeTextView.setText(mActivity.getString(R.string.gif));
|
||||
} else {
|
||||
((PostImageAndGifAutoplayTypeViewHolder) holder).typeTextView.setText(mActivity.getString(R.string.image));
|
||||
}
|
||||
((PostImageAndGifAutoplayTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
((PostImageAndGifAutoplayTypeViewHolder) holder).imageView
|
||||
.setRatio((float) post.getPreviewHeight() / post.getPreviewWidth());
|
||||
loadImage(holder, post);
|
||||
|
||||
if (post.getPreviewWidth() <= 0 || post.getPreviewHeight() <= 0) {
|
||||
((PostImageAndGifAutoplayTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
((PostImageAndGifAutoplayTypeViewHolder) holder).imageView.getLayoutParams().height = (int) (400 * mScale);
|
||||
}
|
||||
} else if (holder instanceof PostLinkTypeViewHolder) {
|
||||
((PostLinkTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
@ -1104,44 +1097,16 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
}
|
||||
|
||||
private void loadImage(final RecyclerView.ViewHolder holder, final Post post) {
|
||||
if (holder instanceof PostImageTypeViewHolder) {
|
||||
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(post.getPreviewUrl()).listener(new RequestListener<Drawable>() {
|
||||
@Override
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
||||
((PostImageTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
|
||||
((PostImageTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.VISIBLE);
|
||||
((PostImageTypeViewHolder) holder).errorRelativeLayout.setOnClickListener(view -> {
|
||||
((PostImageTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
((PostImageTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
|
||||
loadImage(holder, post);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
||||
((PostImageTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
|
||||
((PostImageTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if ((post.isNSFW() && mNeedBlurNSFW) || post.isSpoiler() && mNeedBlurSpoiler) {
|
||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
||||
.into(((PostImageTypeViewHolder) holder).imageView);
|
||||
} else {
|
||||
imageRequestBuilder.into(((PostImageTypeViewHolder) holder).imageView);
|
||||
}
|
||||
} else if (holder instanceof PostGifTypeViewHolder) {
|
||||
String url = mAutoplay ? post.getUrl() : post.getPreviewUrl();
|
||||
if (holder instanceof PostImageAndGifAutoplayTypeViewHolder) {
|
||||
String url = mAutoplay && post.getPostType() == Post.GIF_TYPE ? post.getUrl() : post.getPreviewUrl();
|
||||
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(url).listener(new RequestListener<Drawable>() {
|
||||
@Override
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
||||
((PostGifTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
|
||||
((PostGifTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.VISIBLE);
|
||||
((PostGifTypeViewHolder) holder).errorRelativeLayout.setOnClickListener(view -> {
|
||||
((PostGifTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
((PostGifTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
|
||||
((PostImageAndGifAutoplayTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
|
||||
((PostImageAndGifAutoplayTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.VISIBLE);
|
||||
((PostImageAndGifAutoplayTypeViewHolder) holder).errorRelativeLayout.setOnClickListener(view -> {
|
||||
((PostImageAndGifAutoplayTypeViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
((PostImageAndGifAutoplayTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
|
||||
loadImage(holder, post);
|
||||
});
|
||||
return false;
|
||||
@ -1149,17 +1114,45 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
||||
((PostGifTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
|
||||
((PostGifTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
|
||||
((PostImageAndGifAutoplayTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
|
||||
((PostImageAndGifAutoplayTypeViewHolder) holder).progressBar.setVisibility(View.GONE);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if ((post.isNSFW() && mNeedBlurNSFW) || post.isSpoiler() && mNeedBlurSpoiler) {
|
||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
||||
.into(((PostGifTypeViewHolder) holder).imageView);
|
||||
.into(((PostImageAndGifAutoplayTypeViewHolder) holder).imageView);
|
||||
} else {
|
||||
imageRequestBuilder.into(((PostGifTypeViewHolder) holder).imageView);
|
||||
imageRequestBuilder.into(((PostImageAndGifAutoplayTypeViewHolder) holder).imageView);
|
||||
}
|
||||
} else if (holder instanceof PostGifAndVideoPreviewViewHolder) {
|
||||
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(post.getPreviewUrl()).listener(new RequestListener<Drawable>() {
|
||||
@Override
|
||||
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
|
||||
((PostGifAndVideoPreviewViewHolder) holder).progressBar.setVisibility(View.GONE);
|
||||
((PostGifAndVideoPreviewViewHolder) holder).errorRelativeLayout.setVisibility(View.VISIBLE);
|
||||
((PostGifAndVideoPreviewViewHolder) holder).errorRelativeLayout.setOnClickListener(view -> {
|
||||
((PostGifAndVideoPreviewViewHolder) holder).progressBar.setVisibility(View.VISIBLE);
|
||||
((PostGifAndVideoPreviewViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
|
||||
loadImage(holder, post);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
|
||||
((PostGifAndVideoPreviewViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
|
||||
((PostGifAndVideoPreviewViewHolder) holder).progressBar.setVisibility(View.GONE);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if ((post.isNSFW() && mNeedBlurNSFW) || post.isSpoiler() && mNeedBlurSpoiler) {
|
||||
imageRequestBuilder.apply(RequestOptions.bitmapTransform(new BlurTransformation(50, 10)))
|
||||
.into(((PostGifAndVideoPreviewViewHolder) holder).imageView);
|
||||
} else {
|
||||
imageRequestBuilder.into(((PostGifAndVideoPreviewViewHolder) holder).imageView);
|
||||
}
|
||||
} else if (holder instanceof PostLinkTypeViewHolder) {
|
||||
RequestBuilder<Drawable> imageRequestBuilder = mGlide.load(post.getPreviewUrl()).listener(new RequestListener<Drawable>() {
|
||||
@ -1300,16 +1293,19 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
networkState = null;
|
||||
}
|
||||
|
||||
public void setAutoplay(boolean autoplay) {
|
||||
mAutoplay = autoplay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
||||
super.onViewRecycled(holder);
|
||||
if (holder instanceof PostBaseViewHolder) {
|
||||
if (holder instanceof PostVideoAutoplayViewHolder) {
|
||||
} else if (holder instanceof PostImageTypeViewHolder) {
|
||||
mGlide.clear(((PostImageTypeViewHolder) holder).imageView);
|
||||
((PostImageTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.FIT_START);
|
||||
((PostImageTypeViewHolder) holder).imageView.getLayoutParams().height = FrameLayout.LayoutParams.WRAP_CONTENT;
|
||||
((PostImageTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
|
||||
if (holder instanceof PostImageAndGifAutoplayTypeViewHolder) {
|
||||
mGlide.clear(((PostImageAndGifAutoplayTypeViewHolder) holder).imageView);
|
||||
((PostImageAndGifAutoplayTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.FIT_START);
|
||||
((PostImageAndGifAutoplayTypeViewHolder) holder).imageView.getLayoutParams().height = FrameLayout.LayoutParams.WRAP_CONTENT;
|
||||
((PostImageAndGifAutoplayTypeViewHolder) holder).errorRelativeLayout.setVisibility(View.GONE);
|
||||
} else if (holder instanceof PostLinkTypeViewHolder) {
|
||||
mGlide.clear(((PostLinkTypeViewHolder) holder).imageView);
|
||||
((PostLinkTypeViewHolder) holder).imageView.setScaleType(ImageView.ScaleType.FIT_START);
|
||||
@ -1945,61 +1941,61 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
}
|
||||
}
|
||||
|
||||
class PostGifTypeViewHolder extends PostBaseViewHolder {
|
||||
@BindView(R.id.card_view_item_post_gif_type)
|
||||
class PostGifAndVideoPreviewViewHolder extends PostBaseViewHolder {
|
||||
@BindView(R.id.card_view_item_post_gif_type_autoplay)
|
||||
MaterialCardView cardView;
|
||||
@BindView(R.id.icon_gif_image_view_item_post_gif_type)
|
||||
@BindView(R.id.icon_gif_image_view_item_post_gif_type_autoplay)
|
||||
AspectRatioGifImageView iconGifImageView;
|
||||
@BindView(R.id.subreddit_name_text_view_item_post_gif_type)
|
||||
@BindView(R.id.subreddit_name_text_view_item_post_gif_type_autoplay)
|
||||
TextView subredditTextView;
|
||||
@BindView(R.id.user_text_view_item_post_gif_type)
|
||||
@BindView(R.id.user_text_view_item_post_gif_type_autoplay)
|
||||
TextView userTextView;
|
||||
@BindView(R.id.stickied_post_image_view_item_post_gif_type)
|
||||
@BindView(R.id.stickied_post_image_view_item_post_gif_type_autoplay)
|
||||
ImageView stickiedPostImageView;
|
||||
@BindView(R.id.post_time_text_view_best_item_post_gif_type)
|
||||
@BindView(R.id.post_time_text_view_best_item_post_gif_type_autoplay)
|
||||
TextView postTimeTextView;
|
||||
@BindView(R.id.title_text_view_best_item_post_gif_type)
|
||||
@BindView(R.id.title_text_view_best_item_post_gif_type_autoplay)
|
||||
TextView titleTextView;
|
||||
@BindView(R.id.type_text_view_item_post_gif_type)
|
||||
@BindView(R.id.type_text_view_item_post_gif_type_autoplay)
|
||||
CustomTextView typeTextView;
|
||||
@BindView(R.id.archived_image_view_item_post_gif_type)
|
||||
@BindView(R.id.archived_image_view_item_post_gif_type_autoplay)
|
||||
ImageView archivedImageView;
|
||||
@BindView(R.id.locked_image_view_item_post_gif_type)
|
||||
@BindView(R.id.locked_image_view_item_post_gif_type_autoplay)
|
||||
ImageView lockedImageView;
|
||||
@BindView(R.id.crosspost_image_view_item_post_gif_type)
|
||||
@BindView(R.id.crosspost_image_view_item_post_gif_type_autoplay)
|
||||
ImageView crosspostImageView;
|
||||
@BindView(R.id.nsfw_text_view_item_post_gif_type)
|
||||
@BindView(R.id.nsfw_text_view_item_post_gif_type_autoplay)
|
||||
CustomTextView nsfwTextView;
|
||||
@BindView(R.id.spoiler_custom_text_view_item_post_gif_type)
|
||||
@BindView(R.id.spoiler_custom_text_view_item_post_gif_type_autoplay)
|
||||
CustomTextView spoilerTextView;
|
||||
@BindView(R.id.flair_custom_text_view_item_post_gif_type)
|
||||
@BindView(R.id.flair_custom_text_view_item_post_gif_type_autoplay)
|
||||
CustomTextView flairTextView;
|
||||
@BindView(R.id.awards_text_view_item_post_gif_type)
|
||||
@BindView(R.id.awards_text_view_item_post_gif_type_autoplay)
|
||||
CustomTextView awardsTextView;
|
||||
@BindView(R.id.image_view_wrapper_item_post_gif_type)
|
||||
@BindView(R.id.image_view_wrapper_item_post_gif_type_autoplay)
|
||||
RelativeLayout relativeLayout;
|
||||
@BindView(R.id.progress_bar_item_post_gif_type)
|
||||
@BindView(R.id.progress_bar_item_post_gif_type_autoplay)
|
||||
ProgressBar progressBar;
|
||||
@BindView(R.id.image_view_best_post_item)
|
||||
@BindView(R.id.image_view_item_post_gif_type_autoplay)
|
||||
AspectRatioGifImageView imageView;
|
||||
@BindView(R.id.load_image_error_relative_layout_item_post_gif_type)
|
||||
@BindView(R.id.load_image_error_relative_layout_item_post_gif_type_autoplay)
|
||||
RelativeLayout errorRelativeLayout;
|
||||
@BindView(R.id.bottom_constraint_layout_item_post_gif_type)
|
||||
@BindView(R.id.bottom_constraint_layout_item_post_gif_type_autoplay)
|
||||
ConstraintLayout bottomConstraintLayout;
|
||||
@BindView(R.id.plus_button_item_post_gif_type)
|
||||
@BindView(R.id.plus_button_item_post_gif_type_autoplay)
|
||||
ImageView upvoteButton;
|
||||
@BindView(R.id.score_text_view_item_post_gif_type)
|
||||
@BindView(R.id.score_text_view_item_post_gif_type_autoplay)
|
||||
TextView scoreTextView;
|
||||
@BindView(R.id.minus_button_item_post_gif_type)
|
||||
@BindView(R.id.minus_button_item_post_gif_type_autoplay)
|
||||
ImageView downvoteButton;
|
||||
@BindView(R.id.comments_count_item_post_gif_type)
|
||||
@BindView(R.id.comments_count_item_post_gif_type_autoplay)
|
||||
TextView commentsCountTextView;
|
||||
@BindView(R.id.save_button_item_post_gif_type)
|
||||
@BindView(R.id.save_button_item_post_gif_type_autoplay)
|
||||
ImageView saveButton;
|
||||
@BindView(R.id.share_button_item_post_gif_type)
|
||||
@BindView(R.id.share_button_item_post_gif_type_autoplay)
|
||||
ImageView shareButton;
|
||||
|
||||
PostGifTypeViewHolder(View itemView) {
|
||||
PostGifAndVideoPreviewViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
setBaseView(cardView,
|
||||
@ -2030,18 +2026,29 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
imageView.setOnClickListener(view -> {
|
||||
Post post = getItem(getAdapterPosition());
|
||||
if (post != null) {
|
||||
Intent intent = new Intent(mActivity, ViewImageActivity.class);
|
||||
intent.putExtra(ViewImageActivity.IMAGE_URL_KEY, post.getUrl());
|
||||
intent.putExtra(ViewImageActivity.FILE_NAME_KEY, post.getSubredditName()
|
||||
+ "-" + post.getId() + ".jpg");
|
||||
intent.putExtra(ViewImageActivity.POST_TITLE_KEY, post.getTitle());
|
||||
mActivity.startActivity(intent);
|
||||
if (post.getPostType() == Post.VIDEO_TYPE) {
|
||||
Intent intent = new Intent(mActivity, ViewVideoActivity.class);
|
||||
intent.setData(Uri.parse(post.getVideoUrl()));
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl());
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, post.getSubredditName());
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getFullName());
|
||||
intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle());
|
||||
mActivity.startActivity(intent);
|
||||
} else if (post.getPostType() == Post.GIF_TYPE) {
|
||||
Intent intent = new Intent(mActivity, ViewGIFActivity.class);
|
||||
intent.setData(Uri.parse(post.getVideoUrl()));
|
||||
intent.putExtra(ViewGIFActivity.FILE_NAME_KEY, post.getSubredditName()
|
||||
+ "-" + post.getId() + ".gif");
|
||||
intent.putExtra(ViewGIFActivity.GIF_URL_KEY, post.getVideoUrl());
|
||||
intent.putExtra(ViewGIFActivity.POST_TITLE_KEY, post.getTitle());
|
||||
mActivity.startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class PostImageTypeViewHolder extends PostBaseViewHolder {
|
||||
class PostImageAndGifAutoplayTypeViewHolder extends PostBaseViewHolder {
|
||||
@BindView(R.id.card_view_item_post_image_type)
|
||||
MaterialCardView cardView;
|
||||
@BindView(R.id.icon_gif_image_view_item_post_image_type)
|
||||
@ -2095,7 +2102,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
@BindView(R.id.share_button_item_post_image_type)
|
||||
ImageView shareButton;
|
||||
|
||||
PostImageTypeViewHolder(View itemView) {
|
||||
PostImageAndGifAutoplayTypeViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
ButterKnife.bind(this, itemView);
|
||||
setBaseView(cardView,
|
||||
|
@ -0,0 +1,9 @@
|
||||
package ml.docilealligator.infinityforreddit.Event;
|
||||
|
||||
public class ChangeVideoAutoplayEvent {
|
||||
public String autoplay;
|
||||
|
||||
public ChangeVideoAutoplayEvent(String autoplay) {
|
||||
this.autoplay = autoplay;
|
||||
}
|
||||
}
|
@ -47,7 +47,6 @@ import javax.inject.Named;
|
||||
import butterknife.BindView;
|
||||
import butterknife.ButterKnife;
|
||||
import im.ene.toro.exoplayer.ExoCreator;
|
||||
import im.ene.toro.widget.Container;
|
||||
import ml.docilealligator.infinityforreddit.Activity.BaseActivity;
|
||||
import ml.docilealligator.infinityforreddit.Activity.FilteredThingActivity;
|
||||
import ml.docilealligator.infinityforreddit.Activity.MainActivity;
|
||||
@ -61,6 +60,7 @@ import ml.docilealligator.infinityforreddit.Event.ChangePostLayoutEvent;
|
||||
import ml.docilealligator.infinityforreddit.Event.ChangeShowAbsoluteNumberOfVotesEvent;
|
||||
import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
|
||||
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
|
||||
import ml.docilealligator.infinityforreddit.Event.ChangeVideoAutoplayEvent;
|
||||
import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
|
||||
import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToPostList;
|
||||
import ml.docilealligator.infinityforreddit.Event.ShowDividerInCompactLayoutPreferenceEvent;
|
||||
@ -74,6 +74,7 @@ import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||
import ml.docilealligator.infinityforreddit.SortType;
|
||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||
import ml.docilealligator.infinityforreddit.Utils.Utils;
|
||||
import retrofit2.Retrofit;
|
||||
|
||||
|
||||
@ -839,6 +840,20 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onChangeVideoAutoplayEvent(ChangeVideoAutoplayEvent changeVideoAutoplayEvent) {
|
||||
if (mAdapter != null) {
|
||||
boolean autoplay = false;
|
||||
if (changeVideoAutoplayEvent.autoplay.equals(SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_ALWAYS_ON)) {
|
||||
autoplay = true;
|
||||
} else if (changeVideoAutoplayEvent.autoplay.equals(SharedPreferencesUtils.VIDEO_AUTOPLAY_VALUE_ON_WIFI)) {
|
||||
autoplay = Utils.isConnectedToWifi(activity);
|
||||
}
|
||||
mAdapter.setAutoplay(autoplay);
|
||||
refreshAdapter();
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshAdapter() {
|
||||
int previousPosition = -1;
|
||||
if (mLinearLayoutManager != null) {
|
||||
|
@ -7,7 +7,7 @@ import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
@ -19,6 +19,7 @@ import javax.inject.Named;
|
||||
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent;
|
||||
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
|
||||
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
|
||||
import ml.docilealligator.infinityforreddit.Event.ChangeVideoAutoplayEvent;
|
||||
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
|
||||
import ml.docilealligator.infinityforreddit.Infinity;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
@ -39,18 +40,22 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
|
||||
setPreferencesFromResource(R.xml.main_preferences, rootKey);
|
||||
((Infinity) activity.getApplication()).getAppComponent().inject(this);
|
||||
|
||||
ListPreference videoAutoplaySwitch = findPreference(SharedPreferencesUtils.VIDEO_AUTOPLAY);
|
||||
SwitchPreference confirmToExitSwitch = findPreference(SharedPreferencesUtils.CONFIRM_TO_EXIT);
|
||||
SwitchPreference nsfwSwitch = findPreference(SharedPreferencesUtils.NSFW_KEY);
|
||||
SwitchPreference blurNSFWSwitch = findPreference(SharedPreferencesUtils.BLUR_NSFW_KEY);
|
||||
SwitchPreference blurSpoilerSwitch = findPreference(SharedPreferencesUtils.BLUR_SPOILER_KEY);
|
||||
|
||||
if (videoAutoplaySwitch != null) {
|
||||
videoAutoplaySwitch.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
EventBus.getDefault().post(new ChangeVideoAutoplayEvent((String) newValue));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
if (confirmToExitSwitch != null) {
|
||||
confirmToExitSwitch.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
EventBus.getDefault().post(new RecreateActivityEvent());
|
||||
return true;
|
||||
}
|
||||
confirmToExitSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
EventBus.getDefault().post(new RecreateActivityEvent());
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -76,6 +76,10 @@ public class SharedPreferencesUtils {
|
||||
public static final String VOLUME_KEYS_NAVIGATE_POSTS = "volume_keys_navigate_posts";
|
||||
public static final String MUTE_VIDEO = "mute_video";
|
||||
public static final String OPEN_LINK_IN_APP = "open_link_in_app";
|
||||
public static final String VIDEO_AUTOPLAY = "video_autoplay";
|
||||
public static final String VIDEO_AUTOPLAY_VALUE_ALWAYS_ON = "2";
|
||||
public static final String VIDEO_AUTOPLAY_VALUE_ON_WIFI = "1";
|
||||
public static final String VIDEO_AUTOPLAY_VALUE_NEVER = "0";
|
||||
public static final String LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON = "lock_jump_to_next_top_level_comment_button";
|
||||
public static final String SWIPE_UP_TO_HIDE_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON = "swipe_up_to_hide_jump_to_next_top_level_comments_button";
|
||||
public static final String SHOW_TOP_LEVEL_COMMENTS_FIRST = "show_top_level_comments_first";
|
||||
@ -89,10 +93,10 @@ public class SharedPreferencesUtils {
|
||||
public static final String CUSTOMIZE_DARK_THEME = "customize_dark_theme";
|
||||
public static final String CUSTOMIZE_AMOLED_THEME = "customize_amoled_theme";
|
||||
public static final String MANAGE_THEMES = "manage_themes";
|
||||
public static final String DELETE_ALL_SUBREDDITS_DATA_IN_DATABASE= "delete_all_subreddits_data_in_database";
|
||||
public static final String DELETE_ALL_USERS_DATA_IN_DATABASE= "delete_all_users_data_in_database";
|
||||
public static final String DELETE_ALL_SORT_TYPE_DATA_IN_DATABASE= "delete_all_sort_type_data_in_database";
|
||||
public static final String DELETE_ALL_POST_LAYOUT_DATA_IN_DATABASE= "delete_all_post_layout_data_in_database";
|
||||
public static final String DELETE_ALL_SUBREDDITS_DATA_IN_DATABASE = "delete_all_subreddits_data_in_database";
|
||||
public static final String DELETE_ALL_USERS_DATA_IN_DATABASE = "delete_all_users_data_in_database";
|
||||
public static final String DELETE_ALL_SORT_TYPE_DATA_IN_DATABASE = "delete_all_sort_type_data_in_database";
|
||||
public static final String DELETE_ALL_POST_LAYOUT_DATA_IN_DATABASE = "delete_all_post_layout_data_in_database";
|
||||
public static final String DELETE_ALL_THEMES_IN_DATABASE = "delete_all_themes_in_database";
|
||||
public static final String RESET_ALL_SETTINGS = "reset_all_settings";
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
package ml.docilealligator.infinityforreddit.Utils;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.Network;
|
||||
import android.net.NetworkInfo;
|
||||
import android.text.Html;
|
||||
import android.text.Spannable;
|
||||
import android.widget.TextView;
|
||||
@ -87,4 +90,18 @@ public class Utils {
|
||||
}
|
||||
textView.setText(html);
|
||||
}
|
||||
|
||||
public static boolean isConnectedToWifi(Context context) {
|
||||
ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
if (connMgr != null) {
|
||||
for (Network network : connMgr.getAllNetworks()) {
|
||||
NetworkInfo networkInfo = connMgr.getNetworkInfo(network);
|
||||
if (networkInfo != null && networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
|
||||
return networkInfo.isConnected();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,6 @@
|
||||
android:gravity="bottom"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:paddingBottom="16dp"
|
||||
android:background="@color/transparentActionBarAndExoPlayerControllerColor"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RelativeLayout
|
||||
|
@ -10,12 +10,6 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<!--<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view_post_fragment"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipToPadding="false" />-->
|
||||
|
||||
<ml.docilealligator.infinityforreddit.CustomView.CustomToroContainer
|
||||
android:id="@+id/recycler_view_post_fragment"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -109,7 +109,6 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
android:text="@string/image"
|
||||
android:textSize="?attr/font_12"
|
||||
app:lib_setRadius="3dp"
|
||||
app:lib_setRoundedView="true"
|
@ -5,7 +5,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:id="@+id/card_view_item_post_gif_type"
|
||||
android:id="@+id/card_view_item_post_gif_type_autoplay"
|
||||
app:cardBackgroundColor="?attr/cardViewBackgroundColor"
|
||||
app:cardElevation="2dp"
|
||||
app:cardCornerRadius="16dp">
|
||||
@ -21,7 +21,7 @@
|
||||
android:padding="16dp">
|
||||
|
||||
<ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView
|
||||
android:id="@+id/icon_gif_image_view_item_post_gif_type"
|
||||
android:id="@+id/icon_gif_image_view_item_post_gif_type_autoplay"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_gravity="center"
|
||||
@ -30,20 +30,20 @@
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/subreddit_name_text_view_item_post_gif_type"
|
||||
android:id="@+id/subreddit_name_text_view_item_post_gif_type_autoplay"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:textSize="?attr/font_default"
|
||||
app:layout_constraintBottom_toTopOf="@id/user_text_view_item_post_gif_type"
|
||||
app:layout_constraintStart_toEndOf="@id/icon_gif_image_view_item_post_gif_type"
|
||||
app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_gif_type"
|
||||
app:layout_constraintBottom_toTopOf="@id/user_text_view_item_post_gif_type_autoplay"
|
||||
app:layout_constraintStart_toEndOf="@id/icon_gif_image_view_item_post_gif_type_autoplay"
|
||||
app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_gif_type_autoplay"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/user_text_view_item_post_gif_type"
|
||||
android:id="@+id/user_text_view_item_post_gif_type_autoplay"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
@ -52,24 +52,24 @@
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_gif_type"
|
||||
app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_gif_type"
|
||||
app:layout_constraintTop_toBottomOf="@+id/subreddit_name_text_view_item_post_gif_type"
|
||||
app:layout_constraintStart_toEndOf="@+id/icon_gif_image_view_item_post_gif_type_autoplay"
|
||||
app:layout_constraintEnd_toStartOf="@id/stickied_post_image_view_item_post_gif_type_autoplay"
|
||||
app:layout_constraintTop_toBottomOf="@+id/subreddit_name_text_view_item_post_gif_type_autoplay"
|
||||
app:layout_constraintHorizontal_bias="0" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/stickied_post_image_view_item_post_gif_type"
|
||||
android:id="@+id/stickied_post_image_view_item_post_gif_type_autoplay"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/subreddit_name_text_view_item_post_gif_type"
|
||||
app:layout_constraintStart_toEndOf="@id/subreddit_name_text_view_item_post_gif_type_autoplay"
|
||||
app:layout_constraintEnd_toStartOf="@+id/guideline2"
|
||||
app:layout_constraintTop_toTopOf="parent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/post_time_text_view_best_item_post_gif_type"
|
||||
android:id="@+id/post_time_text_view_best_item_post_gif_type_autoplay"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="end"
|
||||
@ -89,7 +89,7 @@
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/title_text_view_best_item_post_gif_type"
|
||||
android:id="@+id/title_text_view_best_item_post_gif_type_autoplay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="16dp"
|
||||
@ -105,7 +105,7 @@
|
||||
app:flRowSpacing="8dp">
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/type_text_view_item_post_gif_type"
|
||||
android:id="@+id/type_text_view_item_post_gif_type_autoplay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
@ -116,7 +116,7 @@
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/spoiler_custom_text_view_item_post_gif_type"
|
||||
android:id="@+id/spoiler_custom_text_view_item_post_gif_type_autoplay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
@ -129,7 +129,7 @@
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/nsfw_text_view_item_post_gif_type"
|
||||
android:id="@+id/nsfw_text_view_item_post_gif_type_autoplay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
@ -141,7 +141,7 @@
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/flair_custom_text_view_item_post_gif_type"
|
||||
android:id="@+id/flair_custom_text_view_item_post_gif_type_autoplay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
@ -153,7 +153,7 @@
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
<com.libRG.CustomTextView
|
||||
android:id="@+id/awards_text_view_item_post_gif_type"
|
||||
android:id="@+id/awards_text_view_item_post_gif_type_autoplay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="4dp"
|
||||
@ -164,21 +164,21 @@
|
||||
app:lib_setShape="rectangle" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/archived_image_view_item_post_gif_type"
|
||||
android:id="@+id/archived_image_view_item_post_gif_type_autoplay"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/ic_archive_outline"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/locked_image_view_item_post_gif_type"
|
||||
android:id="@+id/locked_image_view_item_post_gif_type_autoplay"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/ic_outline_lock_24dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/crosspost_image_view_item_post_gif_type"
|
||||
android:id="@+id/crosspost_image_view_item_post_gif_type_autoplay"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:src="@drawable/crosspost"
|
||||
@ -187,25 +187,39 @@
|
||||
</com.nex3z.flowlayout.FlowLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/image_view_wrapper_item_post_gif_type"
|
||||
android:id="@+id/image_view_wrapper_item_post_gif_type_autoplay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView
|
||||
android:id="@+id/image_view_best_post_item"
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitStart" />
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ml.docilealligator.infinityforreddit.CustomView.AspectRatioGifImageView
|
||||
android:id="@+id/image_view_item_post_gif_type_autoplay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:adjustViewBounds="true"
|
||||
android:scaleType="fitStart" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="16dp"
|
||||
android:layout_gravity="start"
|
||||
android:background="@drawable/play_button_round_background"
|
||||
android:src="@drawable/ic_play_circle_36dp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progress_bar_item_post_gif_type"
|
||||
android:id="@+id/progress_bar_item_post_gif_type_autoplay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/load_image_error_relative_layout_item_post_gif_type"
|
||||
android:id="@+id/load_image_error_relative_layout_item_post_gif_type_autoplay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
@ -225,12 +239,12 @@
|
||||
</RelativeLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/bottom_constraint_layout_item_post_gif_type"
|
||||
android:id="@+id/bottom_constraint_layout_item_post_gif_type_autoplay"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/plus_button_item_post_gif_type"
|
||||
android:id="@+id/plus_button_item_post_gif_type_autoplay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="12dp"
|
||||
@ -243,7 +257,7 @@
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/score_text_view_item_post_gif_type"
|
||||
android:id="@+id/score_text_view_item_post_gif_type_autoplay"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
@ -251,10 +265,10 @@
|
||||
android:textStyle="bold"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/plus_button_item_post_gif_type" />
|
||||
app:layout_constraintStart_toEndOf="@id/plus_button_item_post_gif_type_autoplay" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/minus_button_item_post_gif_type"
|
||||
android:id="@+id/minus_button_item_post_gif_type_autoplay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="12dp"
|
||||
@ -264,10 +278,10 @@
|
||||
android:focusable="true"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/score_text_view_item_post_gif_type" />
|
||||
app:layout_constraintStart_toEndOf="@id/score_text_view_item_post_gif_type_autoplay" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comments_count_item_post_gif_type"
|
||||
android:id="@+id/comments_count_item_post_gif_type_autoplay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="12dp"
|
||||
@ -278,10 +292,10 @@
|
||||
android:drawablePadding="12dp"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/minus_button_item_post_gif_type" />
|
||||
app:layout_constraintStart_toEndOf="@id/minus_button_item_post_gif_type_autoplay" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/save_button_item_post_gif_type"
|
||||
android:id="@+id/save_button_item_post_gif_type_autoplay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="12dp"
|
||||
@ -291,11 +305,11 @@
|
||||
app:layout_constraintHorizontal_bias="1"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/comments_count_item_post_gif_type"
|
||||
app:layout_constraintEnd_toStartOf="@id/share_button_item_post_gif_type" />
|
||||
app:layout_constraintStart_toEndOf="@id/comments_count_item_post_gif_type_autoplay"
|
||||
app:layout_constraintEnd_toStartOf="@id/share_button_item_post_gif_type_autoplay" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/share_button_item_post_gif_type"
|
||||
android:id="@+id/share_button_item_post_gif_type_autoplay"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="12dp"
|
@ -47,6 +47,18 @@
|
||||
<item>1</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="settings_video_autoplay">
|
||||
<item>Always On</item>
|
||||
<item>Only on Wifi</item>
|
||||
<item>Never</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="settings_video_autoplay_values">
|
||||
<item>2</item>
|
||||
<item>1</item>
|
||||
<item>0</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="settings_lazy_mode_interval">
|
||||
<item>1s</item>
|
||||
<item>2s</item>
|
||||
|
@ -311,6 +311,7 @@
|
||||
<string name="settings_interface_title">Interface</string>
|
||||
<string name="settings_gestures_and_buttons_title">Gestures & Buttons</string>
|
||||
<string name="settings_open_link_in_app_title">Open Link In App</string>
|
||||
<string name="settings_video_autoplay_title">Video Autoplay</string>
|
||||
<string name="settings_immersive_interface_title">Immersive Interface</string>
|
||||
<string name="settings_immersive_interface_ignore_nav_bar_title">Ignore Navigation Bar in Immersive Interface</string>
|
||||
<string name="settings_immersive_interface_ignore_nav_bar_summary">Prevent the Bottom Navigation Bar Having Extra Padding</string>
|
||||
|
@ -28,6 +28,14 @@
|
||||
app:key="open_link_in_app"
|
||||
app:title="@string/settings_open_link_in_app_title" />
|
||||
|
||||
<ListPreference
|
||||
app:defaultValue="0"
|
||||
android:entries="@array/settings_video_autoplay"
|
||||
app:entryValues="@array/settings_video_autoplay_values"
|
||||
app:key="video_autoplay"
|
||||
app:title="@string/settings_video_autoplay_title"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<SwitchPreference
|
||||
app:defaultValue="false"
|
||||
app:key="mute_video"
|
||||
|
Loading…
Reference in New Issue
Block a user