aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java6
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeMuteAutoplayingVideosEvent.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java11
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AutoplayPreferenceFragment.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/APIUtils.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java1
7 files changed, 48 insertions, 8 deletions
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 41acea18..6103cea2 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -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) {
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 a7af4e11..81a685ee 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
@@ -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) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeMuteAutoplayingVideosEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeMuteAutoplayingVideosEvent.java
new file mode 100644
index 00000000..421be2a1
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeMuteAutoplayingVideosEvent.java
@@ -0,0 +1,9 @@
+package ml.docilealligator.infinityforreddit.Event;
+
+public class ChangeMuteAutoplayingVideosEvent {
+ public boolean muteAutoplayingVideos;
+
+ public ChangeMuteAutoplayingVideosEvent(boolean muteAutoplayingVideos) {
+ this.muteAutoplayingVideos = muteAutoplayingVideos;
+ }
+}
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 48972914..3aa0f16c 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
@@ -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();
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AutoplayPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AutoplayPreferenceFragment.java
index 91bd52d7..173b5934 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AutoplayPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/AutoplayPreferenceFragment.java
@@ -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;
+ });
+ }
}
} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/APIUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/APIUtils.java
index 7f49deee..029b4197 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/APIUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/APIUtils.java
@@ -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";
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 b36bb25d..0b40cc1d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
@@ -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";