mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 12:47:26 +01:00
Add an option: Mute Autoplaying Videos.
This commit is contained in:
parent
02af3edd09
commit
9f16b6c25a
@ -154,6 +154,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
||||
private boolean mShowAbsoluteNumberOfVotes;
|
||||
private boolean mAutoplay = false;
|
||||
private boolean mAutoplayNsfwVideos;
|
||||
private boolean mMuteAutoplayingVideos;
|
||||
private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback;
|
||||
private boolean isInitiallyLoading;
|
||||
private boolean isInitiallyLoadingFailed;
|
||||
@ -318,6 +319,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
||||
mAutoplay = Utils.isConnectedToWifi(activity);
|
||||
}
|
||||
mAutoplayNsfwVideos = mSharedPreferences.getBoolean(SharedPreferencesUtils.AUTOPLAY_NSFW_VIDEOS, true);
|
||||
mMuteAutoplayingVideos = mSharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS, true);
|
||||
|
||||
mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback;
|
||||
isInitiallyLoading = true;
|
||||
@ -2018,7 +2020,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
||||
@Nullable
|
||||
ExoPlayerViewHelper helper;
|
||||
private Uri mediaUri;
|
||||
private float volume = 0f;
|
||||
private float volume;
|
||||
|
||||
public PostDetailVideoAutoplayViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
@ -2047,6 +2049,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
||||
|
||||
aspectRatioFrameLayout.setOnClickListener(null);
|
||||
|
||||
volume = mMuteAutoplayingVideos ? 0f : 1f;
|
||||
|
||||
muteButton.setOnClickListener(view -> {
|
||||
if (helper != null) {
|
||||
if (helper.getVolume() != 0) {
|
||||
|
@ -164,6 +164,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
private boolean mShowAbsoluteNumberOfVotes;
|
||||
private boolean mAutoplay = false;
|
||||
private boolean mAutoplayNsfwVideos;
|
||||
private boolean mMuteAutoplayingVideos;
|
||||
private boolean mShowThumbnailOnTheRightInCompactLayout;
|
||||
private Drawable mCommentIcon;
|
||||
private NetworkState networkState;
|
||||
@ -198,6 +199,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
mAutoplay = Utils.isConnectedToWifi(activity);
|
||||
}
|
||||
mAutoplayNsfwVideos = sharedPreferences.getBoolean(SharedPreferencesUtils.AUTOPLAY_NSFW_VIDEOS, true);
|
||||
mMuteAutoplayingVideos = sharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS, true);
|
||||
mShowThumbnailOnTheRightInCompactLayout = sharedPreferences.getBoolean(
|
||||
SharedPreferencesUtils.SHOW_THUMBNAIL_ON_THE_RIGHT_IN_COMPACT_LAYOUT, false);
|
||||
mPostLayout = postLayout;
|
||||
@ -1327,6 +1329,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
mAutoplayNsfwVideos = autoplayNsfwVideos;
|
||||
}
|
||||
|
||||
public void setMuteAutoplayingVideos(boolean muteAutoplayingVideos) {
|
||||
mMuteAutoplayingVideos = muteAutoplayingVideos;
|
||||
}
|
||||
|
||||
public void setShowThumbnailOnTheRightInCompactLayout(boolean showThumbnailOnTheRightInCompactLayout) {
|
||||
mShowThumbnailOnTheRightInCompactLayout = showThumbnailOnTheRightInCompactLayout;
|
||||
}
|
||||
@ -1895,7 +1901,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
@Nullable
|
||||
ExoPlayerViewHelper helper;
|
||||
private Uri mediaUri;
|
||||
private float volume = 0f;
|
||||
private float volume;
|
||||
|
||||
PostVideoAutoplayViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
@ -1925,6 +1931,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
||||
|
||||
aspectRatioFrameLayout.setOnClickListener(null);
|
||||
|
||||
volume = mMuteAutoplayingVideos ? 0f : 1f;
|
||||
|
||||
muteButton.setOnClickListener(view -> {
|
||||
if (helper != null) {
|
||||
if (helper.getVolume() != 0) {
|
||||
|
@ -0,0 +1,9 @@
|
||||
package ml.docilealligator.infinityforreddit.Event;
|
||||
|
||||
public class ChangeMuteAutoplayingVideosEvent {
|
||||
public boolean muteAutoplayingVideos;
|
||||
|
||||
public ChangeMuteAutoplayingVideosEvent(boolean muteAutoplayingVideos) {
|
||||
this.muteAutoplayingVideos = muteAutoplayingVideos;
|
||||
}
|
||||
}
|
@ -59,6 +59,7 @@ import ml.docilealligator.infinityforreddit.CustomTheme.CustomThemeWrapper;
|
||||
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.ChangeNSFWBlurEvent;
|
||||
import ml.docilealligator.infinityforreddit.Event.ChangePostLayoutEvent;
|
||||
import ml.docilealligator.infinityforreddit.Event.ChangeShowAbsoluteNumberOfVotesEvent;
|
||||
@ -891,7 +892,15 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
||||
public void onChangeAutoplayNsfwVideosEvent(ChangeAutoplayNsfwVideosEvent changeAutoplayNsfwVideosEvent) {
|
||||
if (mAdapter != null) {
|
||||
mAdapter.setAutoplayNsfwVideos(changeAutoplayNsfwVideosEvent.autoplayNsfwVideos);
|
||||
refresh();
|
||||
refreshAdapter();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onChangeMuteAutoplayingVideosEvent(ChangeMuteAutoplayingVideosEvent changeMuteAutoplayingVideosEvent) {
|
||||
if (mAdapter != null) {
|
||||
mAdapter.setMuteAutoplayingVideos(changeMuteAutoplayingVideosEvent.muteAutoplayingVideos);
|
||||
refreshAdapter();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import androidx.preference.SwitchPreference;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import ml.docilealligator.infinityforreddit.Event.ChangeAutoplayNsfwVideosEvent;
|
||||
import ml.docilealligator.infinityforreddit.Event.ChangeMuteAutoplayingVideosEvent;
|
||||
import ml.docilealligator.infinityforreddit.Event.ChangeVideoAutoplayEvent;
|
||||
import ml.docilealligator.infinityforreddit.R;
|
||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||
@ -20,6 +21,7 @@ public class AutoplayPreferenceFragment extends PreferenceFragmentCompat {
|
||||
setPreferencesFromResource(R.xml.autoplay_preferences, rootKey);
|
||||
|
||||
ListPreference videoAutoplayListPreference = findPreference(SharedPreferencesUtils.VIDEO_AUTOPLAY);
|
||||
SwitchPreference muteAutoplayingVideosSwitchPreference = findPreference(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS);
|
||||
SwitchPreference autoplayNsfwVideosSwitchPreference = findPreference(SharedPreferencesUtils.AUTOPLAY_NSFW_VIDEOS);
|
||||
|
||||
if (videoAutoplayListPreference != null && autoplayNsfwVideosSwitchPreference != null) {
|
||||
@ -33,5 +35,12 @@ public class AutoplayPreferenceFragment extends PreferenceFragmentCompat {
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
if (muteAutoplayingVideosSwitchPreference != null) {
|
||||
muteAutoplayingVideosSwitchPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
EventBus.getDefault().post(new ChangeMuteAutoplayingVideosEvent((Boolean) newValue));
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -24,14 +24,14 @@ public class APIUtils {
|
||||
public static final String PUSHSHIFT_API_BASE_URI = "https://api.pushshift.io/";
|
||||
|
||||
public static final String CLIENT_ID_KEY = "client_id";
|
||||
public static final String CLIENT_ID = "";
|
||||
public static final String IMGUR_CLIENT_ID = "";
|
||||
public static final String CLIENT_ID = "NOe2iKrPPzwscA";
|
||||
public static final String IMGUR_CLIENT_ID = "Client-ID cc671794e0ab397";
|
||||
public static final String RESPONSE_TYPE_KEY = "response_type";
|
||||
public static final String RESPONSE_TYPE = "code";
|
||||
public static final String STATE_KEY = "state";
|
||||
public static final String STATE = "";
|
||||
public static final String STATE = "23ro8xlxvzp4asqd";
|
||||
public static final String REDIRECT_URI_KEY = "redirect_uri";
|
||||
public static final String REDIRECT_URI = "";
|
||||
public static final String REDIRECT_URI = "infinity://localhost";
|
||||
public static final String DURATION_KEY = "duration";
|
||||
public static final String DURATION = "permanent";
|
||||
public static final String SCOPE_KEY = "scope";
|
||||
@ -41,7 +41,7 @@ public class APIUtils {
|
||||
public static final String AUTHORIZATION_KEY = "Authorization";
|
||||
public static final String AUTHORIZATION_BASE = "bearer ";
|
||||
public static final String USER_AGENT_KEY = "User-Agent";
|
||||
public static final String USER_AGENT = "";
|
||||
public static final String USER_AGENT = "android:ml.docilealligator.infinityforreddit:v3.2.0 (by /u/Hostilenemy)";
|
||||
|
||||
public static final String GRANT_TYPE_KEY = "grant_type";
|
||||
public static final String GRANT_TYPE_REFRESH_TOKEN = "refresh_token";
|
||||
|
@ -86,6 +86,7 @@ public class SharedPreferencesUtils {
|
||||
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 MUTE_AUTOPLAYING_VIDEOS = "mute_autoplaying_videos";
|
||||
public static final String AUTOPLAY_NSFW_VIDEOS = "autoplay_nsfw_videos";
|
||||
public static final String LOCK_JUMP_TO_NEXT_TOP_LEVEL_COMMENT_BUTTON = "lock_jump_to_next_top_level_comment_button";
|
||||
public static final String SWAP_TAP_AND_LONG_COMMENTS = "swap_tap_and_long_in_comments";
|
||||
|
@ -45,9 +45,9 @@
|
||||
android:id="@+id/content_markdown_view_comment_activity"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<View
|
||||
|
@ -108,7 +108,7 @@
|
||||
android:id="@+id/content_markdown_view_item_post_detail_no_preview_link"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:visibility="gone" />
|
||||
|
@ -108,7 +108,7 @@
|
||||
android:id="@+id/content_markdown_view_item_post_detail_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:visibility="gone" />
|
||||
|
@ -330,6 +330,7 @@
|
||||
<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_mute_autoplaying_videos_title">Mute Autoplaying Videos</string>
|
||||
<string name="settings_autoplay_nsfw_videos_title">Autoplay NSFW Videos</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>
|
||||
@ -786,7 +787,5 @@
|
||||
<string name="set_to_both">Set to Both</string>
|
||||
|
||||
<string name="default_font_font_preview">Default</string>
|
||||
<!-- TODO: Remove or change this placeholder text -->
|
||||
<string name="hello_blank_fragment">Hello blank fragment</string>
|
||||
|
||||
</resources>
|
||||
|
@ -10,6 +10,12 @@
|
||||
app:title="@string/settings_video_autoplay_title"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<SwitchPreference
|
||||
app:defaultValue="true"
|
||||
app:key="mute_autoplaying_videos"
|
||||
app:icon="@drawable/ic_mute_preferences_24dp"
|
||||
app:title="@string/settings_mute_autoplaying_videos_title" />
|
||||
|
||||
<SwitchPreference
|
||||
app:defaultValue="true"
|
||||
app:key="autoplay_nsfw_videos"
|
||||
|
Loading…
Reference in New Issue
Block a user