aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-06-20 06:02:33 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-06-20 06:02:33 +0000
commit9f16b6c25aedce4511f9190f9f80e5ae782de55f (patch)
tree07d6e2a7e240f901e75a2d13d373cc0b6d8f2c8b /app/src/main
parent02af3edd094955802bd063d2f79ceb2bd21b2e8b (diff)
downloadinfinity-for-reddit-9f16b6c25aedce4511f9190f9f80e5ae782de55f.tar
infinity-for-reddit-9f16b6c25aedce4511f9190f9f80e5ae782de55f.tar.gz
infinity-for-reddit-9f16b6c25aedce4511f9190f9f80e5ae782de55f.tar.bz2
infinity-for-reddit-9f16b6c25aedce4511f9190f9f80e5ae782de55f.tar.lz
infinity-for-reddit-9f16b6c25aedce4511f9190f9f80e5ae782de55f.tar.xz
infinity-for-reddit-9f16b6c25aedce4511f9190f9f80e5ae782de55f.tar.zst
infinity-for-reddit-9f16b6c25aedce4511f9190f9f80e5ae782de55f.zip
Add an option: Mute Autoplaying Videos.
Diffstat (limited to '')
-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
-rw-r--r--app/src/main/res/layout/activity_comment.xml6
-rw-r--r--app/src/main/res/layout/item_post_detail_no_preview_link.xml2
-rw-r--r--app/src/main/res/layout/item_post_detail_text.xml2
-rw-r--r--app/src/main/res/values/strings.xml3
-rw-r--r--app/src/main/res/xml/autoplay_preferences.xml6
12 files changed, 60 insertions, 15 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";
diff --git a/app/src/main/res/layout/activity_comment.xml b/app/src/main/res/layout/activity_comment.xml
index 100db899..1fe93f50 100644
--- a/app/src/main/res/layout/activity_comment.xml
+++ b/app/src/main/res/layout/activity_comment.xml
@@ -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
diff --git a/app/src/main/res/layout/item_post_detail_no_preview_link.xml b/app/src/main/res/layout/item_post_detail_no_preview_link.xml
index 7b1f1eb7..f294801a 100644
--- a/app/src/main/res/layout/item_post_detail_no_preview_link.xml
+++ b/app/src/main/res/layout/item_post_detail_no_preview_link.xml
@@ -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" />
diff --git a/app/src/main/res/layout/item_post_detail_text.xml b/app/src/main/res/layout/item_post_detail_text.xml
index de939064..7828687d 100644
--- a/app/src/main/res/layout/item_post_detail_text.xml
+++ b/app/src/main/res/layout/item_post_detail_text.xml
@@ -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" />
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 4b8e20e4..34dc43cb 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -330,6 +330,7 @@
<string name="settings_gestures_and_buttons_title">Gestures &amp; 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>
diff --git a/app/src/main/res/xml/autoplay_preferences.xml b/app/src/main/res/xml/autoplay_preferences.xml
index 6cb07dd9..5cc344aa 100644
--- a/app/src/main/res/xml/autoplay_preferences.xml
+++ b/app/src/main/res/xml/autoplay_preferences.xml
@@ -12,6 +12,12 @@
<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"
app:title="@string/settings_autoplay_nsfw_videos_title" />