diff options
Diffstat (limited to '')
9 files changed, 87 insertions, 9 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java index 45c310c0..95e98f40 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/LinkResolverActivity.java @@ -7,7 +7,6 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; import android.os.Bundle; -import android.util.Log; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; @@ -30,6 +29,7 @@ public class LinkResolverActivity extends AppCompatActivity { public static final String EXTRA_MESSAGE_FULLNAME = "ENF"; public static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN"; + public static final String EXTRA_IS_NSFW = "EIN"; private static final String POST_PATTERN = "/r/\\w+/comments/\\w+/?\\w+/?"; private static final String COMMENT_PATTERN = "/(r|u|U|user)/\\w+/comments/\\w+/?\\w+/\\w+/?"; @@ -97,6 +97,7 @@ public class LinkResolverActivity extends AppCompatActivity { } else if (path.endsWith("mp4")) { Intent intent = new Intent(this, ViewVideoActivity.class); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_DIRECT); + intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, getIntent().getBooleanExtra(EXTRA_IS_NSFW, false)); intent.setData(uri); startActivity(intent); } else { @@ -186,6 +187,7 @@ public class LinkResolverActivity extends AppCompatActivity { Intent intent = new Intent(this, ViewVideoActivity.class); intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, path.substring(1)); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_GFYCAT); + intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, getIntent().getBooleanExtra(EXTRA_IS_NSFW, false)); startActivity(intent); } else { deepLinkError(uri); @@ -195,6 +197,7 @@ public class LinkResolverActivity extends AppCompatActivity { Intent intent = new Intent(this, ViewVideoActivity.class); intent.putExtra(ViewVideoActivity.EXTRA_GFYCAT_ID, path.substring(7)); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_REDGIFS); + intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, true); startActivity(intent); } else { deepLinkError(uri); @@ -220,6 +223,7 @@ public class LinkResolverActivity extends AppCompatActivity { url = url.substring(0, url.length() - 5) + ".mp4"; Intent intent = new Intent(this, ViewVideoActivity.class); intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_TYPE, ViewVideoActivity.VIDEO_TYPE_DIRECT); + intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, getIntent().getBooleanExtra(EXTRA_IS_NSFW, false)); intent.setData(Uri.parse(url)); startActivity(intent); } else { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java index 3db53108..d76d2c00 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewVideoActivity.java @@ -75,6 +75,7 @@ public class ViewVideoActivity extends AppCompatActivity { public static final String EXTRA_PROGRESS_SECONDS = "EPS"; public static final String EXTRA_VIDEO_TYPE = "EVT"; public static final String EXTRA_GFYCAT_ID = "EGI"; + public static final String EXTRA_IS_NSFW = "EIN"; public static final int VIDEO_TYPE_DIRECT = 3; public static final int VIDEO_TYPE_REDGIFS = 2; public static final int VIDEO_TYPE_GFYCAT = 1; @@ -107,6 +108,7 @@ public class ViewVideoActivity extends AppCompatActivity { private boolean isDownloading = false; private boolean isMute = false; private String postTitle; + private boolean isNSFW; private long resumePosition = -1; private int videoType; @@ -174,10 +176,12 @@ public class ViewVideoActivity extends AppCompatActivity { Intent intent = getIntent(); mVideoUri = intent.getData(); postTitle = intent.getStringExtra(EXTRA_POST_TITLE); + isNSFW = intent.getBooleanExtra(EXTRA_IS_NSFW, false); if (savedInstanceState == null) { resumePosition = intent.getLongExtra(EXTRA_PROGRESS_SECONDS, -1); } + if (postTitle != null) { setTitle(Html.fromHtml(String.format("<small>%s</small>", postTitle))); } else { @@ -264,7 +268,8 @@ public class ViewVideoActivity extends AppCompatActivity { player.setPlayWhenReady(true); wasPlaying = true; - boolean muteVideo = mSharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_VIDEO, false); + boolean muteVideo = mSharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_VIDEO, false) || + (mSharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_NSFW_VIDEO, false) && isNSFW); if (savedInstanceState != null) { isMute = savedInstanceState.getBoolean(IS_MUTE_STATE); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java index 3dea5729..96901e29 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java @@ -109,6 +109,7 @@ import ml.docilealligator.infinityforreddit.Utils.GlideImageGetter; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.Utils; import ml.docilealligator.infinityforreddit.VoteThing; +import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; import static ml.docilealligator.infinityforreddit.Activity.CommentActivity.WRITE_COMMENT_REQUEST_CODE; @@ -162,6 +163,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy private boolean mMuteAutoplayingVideos; private boolean mFullyCollapseComment; private double mStartAutoplayVisibleAreaOffset; + private boolean mMuteNSFWVideo; private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback; private boolean isInitiallyLoading; private boolean isInitiallyLoadingFailed; @@ -258,6 +260,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy } else { intent.setData(uri); } + intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, mPost.isNSFW()); mActivity.startActivity(intent); }).urlProcessor(new UrlProcessorRelativeToAbsolute("https://www.reddit.com")); } @@ -289,6 +292,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy } else { intent.setData(uri); } + intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, mPost.isNSFW()); mActivity.startActivity(intent); }).urlProcessor(new UrlProcessorRelativeToAbsolute("https://www.reddit.com")); } @@ -348,6 +352,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy sharedPreferences.getInt(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_PORTRAIT, 75) / 100.0 : sharedPreferences.getInt(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_LANDSCAPE, 50) / 100.0; + mMuteNSFWVideo = sharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_NSFW_VIDEO, false); + mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback; isInitiallyLoading = true; isInitiallyLoadingFailed = false; @@ -696,6 +702,9 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy if (holder instanceof PostDetailVideoAutoplayViewHolder) { ((PostDetailVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) mPost.getPreviewWidth() / mPost.getPreviewHeight()); + ((PostDetailVideoAutoplayViewHolder) holder).previewImageView.setVisibility(View.VISIBLE); + mGlide.load(mPost.getPreviewUrl()).apply(RequestOptions.noTransformation()).into(((PostDetailVideoAutoplayViewHolder) holder).previewImageView); + ((PostDetailVideoAutoplayViewHolder) holder).setVolume(mMuteAutoplayingVideos || (mPost.isNSFW() && mMuteNSFWVideo) ? 0f : 1f); ((PostDetailVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(mPost.getVideoUrl())); } else if (holder instanceof PostDetailVideoAndGifPreviewHolder) { if (mPost.getPostType() == Post.GIF_TYPE) { @@ -1604,6 +1613,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy if (holder instanceof PostDetailVideoAutoplayViewHolder) { ((PostDetailVideoAutoplayViewHolder) holder).muteButton.setVisibility(View.GONE); ((PostDetailVideoAutoplayViewHolder) holder).resetVolume(); + mGlide.clear(((PostDetailVideoAutoplayViewHolder) holder).previewImageView); + ((PostDetailVideoAutoplayViewHolder) holder).previewImageView.setVisibility(View.GONE); } else if (holder instanceof PostDetailVideoAndGifPreviewHolder) { mGlide.clear(((PostDetailVideoAndGifPreviewHolder) holder).mImageView); } else if (holder instanceof PostDetailImageAndGifAutoplayViewHolder) { @@ -2103,6 +2114,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy AspectRatioFrameLayout aspectRatioFrameLayout; @BindView(R.id.player_view_item_post_detail_video_autoplay) PlayerView playerView; + @BindView(R.id.preview_image_view_item_post_detail_video_autoplay) + GifImageView previewImageView; @BindView(R.id.mute_exo_playback_control_view) ImageView muteButton; @BindView(R.id.fullscreen_exo_playback_control_view) @@ -2154,8 +2167,6 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy aspectRatioFrameLayout.setOnClickListener(null); - volume = mMuteAutoplayingVideos ? 0f : 1f; - muteButton.setOnClickListener(view -> { if (helper != null) { if (helper.getVolume() != 0) { @@ -2178,6 +2189,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId()); intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, mPost.getTitle()); intent.putExtra(ViewVideoActivity.EXTRA_PROGRESS_SECONDS, helper.getLatestPlaybackInfo().getResumePosition()); + intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, mPost.isNSFW()); mActivity.startActivity(intent); }); } @@ -2186,6 +2198,10 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy mediaUri = videoUri; } + void setVolume(float volume) { + this.volume = volume; + } + void resetVolume() { volume = 0f; } @@ -2237,6 +2253,12 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy public void onCues(List<Cue> cues) { } + + @Override + public void onRenderedFirstFrame() { + mGlide.clear(previewImageView); + previewImageView.setVisibility(View.GONE); + } }); } helper.initialize(container, playbackInfo); @@ -2364,6 +2386,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, mPost.getSubredditName()); intent.putExtra(ViewVideoActivity.EXTRA_ID, mPost.getId()); intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, mPost.getTitle()); + intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, mPost.isNSFW()); mActivity.startActivity(intent); } else if (mPost.getPostType() == Post.GIF_TYPE) { Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class); @@ -2572,6 +2595,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy } else { intent.setData(uri); } + intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, mPost.isNSFW()); mActivity.startActivity(intent); }); } @@ -2663,6 +2687,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy } else { intent.setData(uri); } + intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, mPost.isNSFW()); mActivity.startActivity(intent); }); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java index fd277916..30136ff6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java @@ -90,6 +90,7 @@ import ml.docilealligator.infinityforreddit.Utils.APIUtils; import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.Utils.Utils; import ml.docilealligator.infinityforreddit.VoteThing; +import pl.droidsonroids.gif.GifImageView; import retrofit2.Retrofit; /** @@ -172,6 +173,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView private boolean mMuteAutoplayingVideos; private boolean mShowThumbnailOnTheRightInCompactLayout; private double mStartAutoplayVisibleAreaOffset; + private boolean mMuteNSFWVideo; private Drawable mCommentIcon; private NetworkState networkState; private ExoCreator mExoCreator; @@ -215,6 +217,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView sharedPreferences.getInt(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_PORTRAIT, 75) / 100.0 : sharedPreferences.getInt(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_LANDSCAPE, 50) / 100.0; + mMuteNSFWVideo = sharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_NSFW_VIDEO, false); + mPostLayout = postLayout; mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme(); @@ -534,6 +538,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView ((PostVideoAutoplayViewHolder) holder).aspectRatioFrameLayout.setAspectRatio((float) post.getPreviewWidth() / post.getPreviewHeight()); ((PostVideoAutoplayViewHolder) holder).previewImageView.setVisibility(View.VISIBLE); mGlide.load(post.getPreviewUrl()).apply(RequestOptions.noTransformation()).into(((PostVideoAutoplayViewHolder) holder).previewImageView); + ((PostVideoAutoplayViewHolder) holder).setVolume(mMuteAutoplayingVideos || (post.isNSFW() && mMuteNSFWVideo) ? 0f : 1f); ((PostVideoAutoplayViewHolder) holder).bindVideoUri(Uri.parse(post.getVideoUrl())); } else if (holder instanceof PostVideoAndGifPreviewViewHolder) { if (post.getPostType() == Post.VIDEO_TYPE) { @@ -875,6 +880,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } else { intent.setData(uri); } + intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, post.isNSFW()); mActivity.startActivity(intent); }); break; @@ -903,6 +909,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView intent.putExtra(ViewVideoActivity.EXTRA_VIDEO_DOWNLOAD_URL, post.getVideoDownloadUrl()); intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, subredditName); intent.putExtra(ViewVideoActivity.EXTRA_ID, id); + intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW()); mActivity.startActivity(intent); }); @@ -924,6 +931,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } else { intent.setData(uri); } + intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, post.isNSFW()); mActivity.startActivity(intent); }); break; @@ -1360,6 +1368,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView this.mStartAutoplayVisibleAreaOffset = startAutoplayVisibleAreaOffset / 100.0; } + public void setMuteNSFWVideo(boolean muteNSFWVideo) { + this.mMuteNSFWVideo = muteNSFWVideo; + } + @Override public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) { super.onViewRecycled(holder); @@ -1903,7 +1915,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView @BindView(R.id.aspect_ratio_frame_layout_item_post_video_type_autoplay) AspectRatioFrameLayout aspectRatioFrameLayout; @BindView(R.id.preview_image_view_item_post_video_type_autoplay) - ImageView previewImageView; + GifImageView previewImageView; @BindView(R.id.player_view_item_post_video_type_autoplay) PlayerView videoPlayer; @BindView(R.id.mute_exo_playback_control_view) @@ -1958,8 +1970,6 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView aspectRatioFrameLayout.setOnClickListener(null); - volume = mMuteAutoplayingVideos ? 0f : 1f; - muteButton.setOnClickListener(view -> { if (helper != null) { if (helper.getVolume() != 0) { @@ -1984,6 +1994,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getId()); intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle()); intent.putExtra(ViewVideoActivity.EXTRA_PROGRESS_SECONDS, helper.getLatestPlaybackInfo().getResumePosition()); + intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW()); mActivity.startActivity(intent); } }); @@ -1993,6 +2004,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView mediaUri = videoUri; } + void setVolume(float volume) { + this.volume = volume; + } + void resetVolume() { volume = 0f; } @@ -2182,6 +2197,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView intent.putExtra(ViewVideoActivity.EXTRA_SUBREDDIT, post.getSubredditName()); intent.putExtra(ViewVideoActivity.EXTRA_ID, post.getId()); intent.putExtra(ViewVideoActivity.EXTRA_POST_TITLE, post.getTitle()); + intent.putExtra(ViewVideoActivity.EXTRA_IS_NSFW, post.isNSFW()); mActivity.startActivity(intent); } else if (post.getPostType() == Post.GIF_TYPE) { Intent intent = new Intent(mActivity, ViewImageOrGifActivity.class); @@ -2398,6 +2414,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } else { intent.setData(uri); } + intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, post.isNSFW()); mActivity.startActivity(intent); } }); @@ -2493,6 +2510,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView } else { intent.setData(uri); } + intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, post.isNSFW()); mActivity.startActivity(intent); } }); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeMuteNSFWVideoEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeMuteNSFWVideoEvent.java new file mode 100644 index 00000000..92e26562 --- /dev/null +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeMuteNSFWVideoEvent.java @@ -0,0 +1,9 @@ +package ml.docilealligator.infinityforreddit.Event; + +public class ChangeMuteNSFWVideoEvent { + public boolean muteNSFWVideo; + + public ChangeMuteNSFWVideoEvent(boolean muteNSFWVideo) { + this.muteNSFWVideo = muteNSFWVideo; + } +} diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java index 71132f61..443a6cf0 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java @@ -62,6 +62,7 @@ import ml.docilealligator.infinityforreddit.CustomView.CustomToroContainer; import ml.docilealligator.infinityforreddit.Event.ChangeAutoplayNsfwVideosEvent; import ml.docilealligator.infinityforreddit.Event.ChangeDefaultPostLayoutEvent; import ml.docilealligator.infinityforreddit.Event.ChangeMuteAutoplayingVideosEvent; +import ml.docilealligator.infinityforreddit.Event.ChangeMuteNSFWVideoEvent; import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent; import ml.docilealligator.infinityforreddit.Event.ChangePostLayoutEvent; import ml.docilealligator.infinityforreddit.Event.ChangeShowAbsoluteNumberOfVotesEvent; @@ -944,6 +945,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator { } } + @Subscribe + public void onChangeMuteNSFWVideoEvent(ChangeMuteNSFWVideoEvent changeMuteNSFWVideoEvent) { + if (mAdapter != null) { + mAdapter.setMuteNSFWVideo(changeMuteNSFWVideoEvent.muteNSFWVideo); + refreshAdapter(); + } + } + private void refreshAdapter() { int previousPosition = -1; if (mLinearLayoutManager != null) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java index b958eba2..562ff432 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Service/DownloadRedditVideoService.java @@ -20,7 +20,6 @@ import android.os.Build; import android.os.Environment; import android.os.IBinder; import android.provider.MediaStore; -import android.util.Log; import androidx.annotation.NonNull; import androidx.annotation.RequiresApi; @@ -356,7 +355,6 @@ public class DownloadRedditVideoService extends Service { outputStream.write(fileReader, 0, read); fileSizeDownloaded += read; - Log.i("asdfsadf", "file download: " + fileSizeDownloaded + " of " + fileSize); } outputStream.flush(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/VideoPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/VideoPreferenceFragment.java index 4cd4ceda..aa8bc2dd 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/VideoPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/VideoPreferenceFragment.java @@ -21,6 +21,7 @@ import javax.inject.Named; import ml.docilealligator.infinityforreddit.Event.ChangeAutoplayNsfwVideosEvent; import ml.docilealligator.infinityforreddit.Event.ChangeMuteAutoplayingVideosEvent; +import ml.docilealligator.infinityforreddit.Event.ChangeMuteNSFWVideoEvent; import ml.docilealligator.infinityforreddit.Event.ChangeStartAutoplayVisibleAreaOffsetEvent; import ml.docilealligator.infinityforreddit.Event.ChangeVideoAutoplayEvent; import ml.docilealligator.infinityforreddit.Infinity; @@ -42,6 +43,7 @@ public class VideoPreferenceFragment extends PreferenceFragmentCompat { ListPreference videoAutoplayListPreference = findPreference(SharedPreferencesUtils.VIDEO_AUTOPLAY); SwitchPreference muteAutoplayingVideosSwitchPreference = findPreference(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS); + SwitchPreference muteNSFWVideosSwitchPreference = findPreference(SharedPreferencesUtils.MUTE_NSFW_VIDEO); SwitchPreference autoplayNsfwVideosSwitchPreference = findPreference(SharedPreferencesUtils.AUTOPLAY_NSFW_VIDEOS); SeekBarPreference startAutoplayVisibleAreaOffsetPortrait = findPreference(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_PORTRAIT); SeekBarPreference startAutoplayVisibleAreaOffsetLandscape = findPreference(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_LANDSCAPE); @@ -58,6 +60,13 @@ public class VideoPreferenceFragment extends PreferenceFragmentCompat { }); } + if (muteNSFWVideosSwitchPreference != null) { + muteNSFWVideosSwitchPreference.setOnPreferenceChangeListener((preference, newValue) -> { + EventBus.getDefault().post(new ChangeMuteNSFWVideoEvent((Boolean) newValue)); + return true; + }); + } + if (muteAutoplayingVideosSwitchPreference != null) { muteAutoplayingVideosSwitchPreference.setOnPreferenceChangeListener((preference, newValue) -> { EventBus.getDefault().post(new ChangeMuteAutoplayingVideosEvent((Boolean) newValue)); 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 eca06f7b..eb6402c2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java @@ -129,4 +129,5 @@ public class SharedPreferencesUtils { public static final String MAIN_PAGE_TAB_POST_TYPE_USER = "5"; public static final String START_AUTOPLAY_VISIBLE_AREA_OFFSET_PORTRAIT = "start_autoplay_visible_area_offset_portrait"; public static final String START_AUTOPLAY_VISIBLE_AREA_OFFSET_LANDSCAPE = "start_autoplay_visible_area_offset_landscape"; + public static final String MUTE_NSFW_VIDEO = "mute_nsfw_video"; } |