diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-08-11 15:44:43 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-08-11 15:44:43 +0000 |
commit | c1862f334ef76b009b4423cbb92cf47d11f7431d (patch) | |
tree | db3dde401d5a812af6fe94770594f848c360d45f /app/src/main | |
parent | dc248735c707fe85ceb01899ff7bc73e3196ff08 (diff) | |
download | infinity-for-reddit-c1862f334ef76b009b4423cbb92cf47d11f7431d.tar infinity-for-reddit-c1862f334ef76b009b4423cbb92cf47d11f7431d.tar.gz infinity-for-reddit-c1862f334ef76b009b4423cbb92cf47d11f7431d.tar.bz2 infinity-for-reddit-c1862f334ef76b009b4423cbb92cf47d11f7431d.tar.lz infinity-for-reddit-c1862f334ef76b009b4423cbb92cf47d11f7431d.tar.xz infinity-for-reddit-c1862f334ef76b009b4423cbb92cf47d11f7431d.tar.zst infinity-for-reddit-c1862f334ef76b009b4423cbb92cf47d11f7431d.zip |
Disable video autoplay when separating post and comments in post detail page is enabled.
Diffstat (limited to 'app/src/main')
5 files changed, 27 insertions, 17 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java index 2fa784eb..b75bce36 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java @@ -166,6 +166,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler private boolean mHideSubredditAndUserPrefix; private boolean mHideTheNumberOfVotes; private boolean mHideTheNumberOfComments; + private boolean mSeparatePostAndComments; private PostDetailRecyclerViewAdapterCallback mPostDetailRecyclerViewAdapterCallback; private int mColorAccent; @@ -203,7 +204,8 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler Executor executor, CustomThemeWrapper customThemeWrapper, Retrofit retrofit, Retrofit oauthRetrofit, Retrofit gfycatRetrofit, Retrofit redgifsRetrofit, RedditDataRoomDatabase redditDataRoomDatabase, - RequestManager glide, int imageViewWidth, String accessToken, + RequestManager glide, int imageViewWidth, + boolean separatePostAndComments, String accessToken, String accountName, Post post, Locale locale, SharedPreferences sharedPreferences, SharedPreferences nsfwAndSpoilerSharedPreferences, @@ -335,6 +337,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler .textLayoutIsRoot(R.layout.view_table_entry_cell))) .build(); mImageViewWidth = imageViewWidth; + mSeparatePostAndComments = separatePostAndComments; mAccessToken = accessToken; mAccountName = accountName; mPost = post; @@ -424,7 +427,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler public int getItemViewType(int position) { switch (mPost.getPostType()) { case Post.VIDEO_TYPE: - if (mAutoplay) { + if (mAutoplay && !mSeparatePostAndComments) { if (!mAutoplayNsfwVideos && mPost.isNSFW()) { return VIEW_TYPE_POST_DETAIL_VIDEO_AND_GIF_PREVIEW; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java index 1a97ab9f..27fa301f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java @@ -1,5 +1,10 @@ package ml.docilealligator.infinityforreddit.fragments; +import static im.ene.toro.media.PlaybackInfo.INDEX_UNSET; +import static im.ene.toro.media.PlaybackInfo.TIME_UNSET; +import static ml.docilealligator.infinityforreddit.activities.CommentActivity.RETURN_EXTRA_COMMENT_DATA_KEY; +import static ml.docilealligator.infinityforreddit.activities.CommentActivity.WRITE_COMMENT_REQUEST_CODE; + import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; @@ -111,11 +116,6 @@ import retrofit2.Callback; import retrofit2.Response; import retrofit2.Retrofit; -import static im.ene.toro.media.PlaybackInfo.INDEX_UNSET; -import static im.ene.toro.media.PlaybackInfo.TIME_UNSET; -import static ml.docilealligator.infinityforreddit.activities.CommentActivity.RETURN_EXTRA_COMMENT_DATA_KEY; -import static ml.docilealligator.infinityforreddit.activities.CommentActivity.WRITE_COMMENT_REQUEST_CODE; - public class ViewPostDetailFragment extends Fragment implements FragmentCommunicator { public static final String EXTRA_POST_DATA = "EPD"; @@ -218,6 +218,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic private boolean mLockFab; private boolean mSwipeUpToHideFab; private boolean mExpandChildren; + private boolean mSeparatePostAndComments = false; private int mWindowWidth; private ConcatAdapter mConcatAdapter; private PostDetailRecyclerViewAdapter mPostAdapter; @@ -272,6 +273,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic mCommentsRecyclerView.setVisibility(View.GONE); mCommentsRecyclerView = null; } + } else { + mSeparatePostAndComments = true; } if (activity != null && activity.isImmersiveInterface()) { @@ -541,7 +544,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic mPostAdapter = new PostDetailRecyclerViewAdapter(activity, this, mExecutor, mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mGfycatRetrofit, mRedgifsRetrofit, mRedditDataRoomDatabase, mGlide, - mWindowWidth, mAccessToken, mAccountName, mPost, mLocale, + mWindowWidth, mSeparatePostAndComments, mAccessToken, mAccountName, mPost, mLocale, mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostDetailsSharedPreferences, mExoCreator, post -> EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition))); mCommentsAdapter = new CommentsRecyclerViewAdapter(activity, @@ -1176,8 +1179,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic mPostAdapter = new PostDetailRecyclerViewAdapter(activity, ViewPostDetailFragment.this, mExecutor, mCustomThemeWrapper, mRetrofit, mOauthRetrofit, mGfycatRetrofit, mRedgifsRetrofit, - mRedditDataRoomDatabase, mGlide, mWindowWidth, mAccessToken, - mAccountName, mPost, mLocale, mSharedPreferences, + mRedditDataRoomDatabase, mGlide, mWindowWidth, mSeparatePostAndComments, + mAccessToken, mAccountName, mPost, mLocale, mSharedPreferences, mNsfwAndSpoilerSharedPreferences, mPostDetailsSharedPreferences, mExoCreator, post1 -> EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition))); @@ -1725,7 +1728,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic } mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null ? nextParentPosition + 1 : nextParentPosition); mIsSmoothScrolling = true; - ((LinearLayoutManager) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).startSmoothScroll(mSmoothScroller); + (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().startSmoothScroll(mSmoothScroller); } } @@ -1738,7 +1741,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic } mSmoothScroller.setTargetPosition(mCommentsRecyclerView == null ? previousParentPosition + 1 : previousParentPosition); mIsSmoothScrolling = true; - ((LinearLayoutManager) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).startSmoothScroll(mSmoothScroller); + (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().startSmoothScroll(mSmoothScroller); } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f0fba961..76afcacb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -590,8 +590,9 @@ <string name="settings_video_player_automatic_landscape_orientation">Switch to Landscape Orientation in Video Player Automatically</string> <string name="settings_remember_muting_option_in_post_feed">Remember Muting Option in Post Feed</string> <string name="settings_post_details_title">Post Details</string> - <string name="settings_separate_post_and_comments_in_portrait_mode">Separate Post And Comments in Portrait Mode</string> - <string name="settings_separate_post_and_comments_in_landscape_mode">Separate Post And Comments in Landscape Mode</string> + <string name="settings_separate_post_and_comments_in_portrait_mode_title">Separate Post And Comments in Portrait Mode</string> + <string name="settings_separate_post_and_comments_in_landscape_mode_title">Separate Post And Comments in Landscape Mode</string> + <string name="settings_separate_post_and_comments_summary">Video autoplay will be disabled in the post detail page</string> <string name="settings_use_bottom_toolbar_in_media_viewer_title">Use Bottom Toolbar in Media Viewer</string> <string name="settings_secure_mode_title">Secure Mode</string> <string name="settings_secure_mode_summary">Screenshot and video recording are not allowed. No preview in recent app screen.</string> diff --git a/app/src/main/res/xml-sw600dp/post_details_preferences.xml b/app/src/main/res/xml-sw600dp/post_details_preferences.xml index 1bb6f4c9..0a8cf2c9 100644 --- a/app/src/main/res/xml-sw600dp/post_details_preferences.xml +++ b/app/src/main/res/xml-sw600dp/post_details_preferences.xml @@ -5,12 +5,14 @@ <SwitchPreference app:defaultValue="true" app:key="separate_post_and_comments_in_portrait_mode" - app:title="@string/settings_separate_post_and_comments_in_portrait_mode" /> + app:title="@string/settings_separate_post_and_comments_in_portrait_mode_title" + app:summary="@string/settings_separate_post_and_comments_summary" /> <SwitchPreference app:defaultValue="true" app:key="separate_post_and_comments_in_landscape_mode" - app:title="@string/settings_separate_post_and_comments_in_landscape_mode" /> + app:title="@string/settings_separate_post_and_comments_in_landscape_mode_title" + app:summary="@string/settings_separate_post_and_comments_summary" /> <SwitchPreference app:defaultValue="false" diff --git a/app/src/main/res/xml/post_details_preferences.xml b/app/src/main/res/xml/post_details_preferences.xml index a082c1ee..e549cb42 100644 --- a/app/src/main/res/xml/post_details_preferences.xml +++ b/app/src/main/res/xml/post_details_preferences.xml @@ -5,7 +5,8 @@ <SwitchPreference app:defaultValue="true" app:key="separate_post_and_comments_in_landscape_mode" - app:title="@string/settings_separate_post_and_comments_in_landscape_mode" /> + app:title="@string/settings_separate_post_and_comments_in_landscape_mode_title" + app:summary="@string/settings_separate_post_and_comments_summary" /> <SwitchPreference app:defaultValue="false" |