aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2020-07-08 14:19:08 +0000
committerAlex Ning <chineseperson5@gmail.com>2020-07-08 14:19:08 +0000
commit6f34d854ea7552fadd9b22e934b45cd86ebc162b (patch)
tree9b4c28f6f344d6b9ccf2a277e19d0f05fb7999eb /app
parent318b11da01ad843ad63d82b4ac87eb1eaa84b9dc (diff)
downloadinfinity-for-reddit-6f34d854ea7552fadd9b22e934b45cd86ebc162b.tar
infinity-for-reddit-6f34d854ea7552fadd9b22e934b45cd86ebc162b.tar.gz
infinity-for-reddit-6f34d854ea7552fadd9b22e934b45cd86ebc162b.tar.bz2
infinity-for-reddit-6f34d854ea7552fadd9b22e934b45cd86ebc162b.tar.lz
infinity-for-reddit-6f34d854ea7552fadd9b22e934b45cd86ebc162b.tar.xz
infinity-for-reddit-6f34d854ea7552fadd9b22e934b45cd86ebc162b.tar.zst
infinity-for-reddit-6f34d854ea7552fadd9b22e934b45cd86ebc162b.zip
Setting autoplay videos visible area offset is available. Remove Crashy because it will crash on some devices, such as Pixel Slate.
Diffstat (limited to 'app')
-rw-r--r--app/build.gradle4
-rw-r--r--app/src/main/AndroidManifest.xml10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java18
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeStartAutoplayVisibleAreaOffsetEvent.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CrashReportsFragment.java54
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CrashReportsRecyclerViewAdapter.java46
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Settings/VideoPreferenceFragment.java58
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java2
-rw-r--r--app/src/main/res/values/strings.xml6
-rw-r--r--app/src/main/res/xml/about_preferences.xml5
-rw-r--r--app/src/main/res/xml/video_preferences.xml14
14 files changed, 125 insertions, 125 deletions
diff --git a/app/build.gradle b/app/build.gradle
index e70eeda9..76f05962 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -87,10 +87,6 @@ dependencies {
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'me.zhanghai.android.fastscroll:library:1.1.2'
implementation "com.thefuntasty.hauler:core:3.1.0"
- // androidX startup for auto-init
- implementation "androidx.startup:startup-runtime:1.0.0-alpha01"
- //crashy
- implementation 'com.github.CraZyLegenD:Crashy:1.0.3'
def toroVersion = '3.7.0.2010003'
implementation "im.ene.toro3:toro:$toroVersion"
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index ca502970..4d30b837 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -328,16 +328,6 @@
android:resource="@xml/file_paths" />
</provider>
- <provider
- android:name="androidx.startup.InitializationProvider"
- android:authorities="${applicationId}.androidx-startup"
- android:exported="false"
- tools:node="merge">
- <meta-data
- android:name="com.crazylegend.crashyreporter.initializer.CrashyInitializer"
- android:value="androidx.startup" />
- </provider>
-
<service
android:name=".Service.SubmitPostService"
android:enabled="true"
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 1a02476c..3dea5729 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -3,6 +3,8 @@ package ml.docilealligator.infinityforreddit.Adapter;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
+import android.content.res.Configuration;
+import android.content.res.Resources;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
@@ -159,6 +161,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private boolean mAutoplayNsfwVideos;
private boolean mMuteAutoplayingVideos;
private boolean mFullyCollapseComment;
+ private double mStartAutoplayVisibleAreaOffset;
private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback;
private boolean isInitiallyLoading;
private boolean isInitiallyLoadingFailed;
@@ -340,12 +343,17 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
mMuteAutoplayingVideos = sharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS, true);
mFullyCollapseComment = sharedPreferences.getBoolean(SharedPreferencesUtils.FULLY_COLLAPSE_COMMENT, false);
+ Resources resources = activity.getResources();
+ mStartAutoplayVisibleAreaOffset = resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ?
+ sharedPreferences.getInt(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_PORTRAIT, 75) / 100.0 :
+ sharedPreferences.getInt(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_LANDSCAPE, 50) / 100.0;
+
mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback;
isInitiallyLoading = true;
isInitiallyLoadingFailed = false;
mHasMoreComments = false;
loadMoreCommentsFailed = false;
- mScale = activity.getResources().getDisplayMetrics().density;
+ mScale = resources.getDisplayMetrics().density;
mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
mColorAccent = customThemeWrapper.getColorAccent();
@@ -2259,7 +2267,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
@Override
public boolean wantsToPlay() {
- return ToroUtil.visibleAreaOffset(this, itemView.getParent()) >= 0.85;
+ return ToroUtil.visibleAreaOffset(this, itemView.getParent()) >= mStartAutoplayVisibleAreaOffset;
}
@Override
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 7bc347b6..fd277916 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
@@ -3,6 +3,8 @@ package ml.docilealligator.infinityforreddit.Adapter;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
+import android.content.res.Configuration;
+import android.content.res.Resources;
import android.graphics.ColorFilter;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
@@ -169,6 +171,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private boolean mAutoplayNsfwVideos;
private boolean mMuteAutoplayingVideos;
private boolean mShowThumbnailOnTheRightInCompactLayout;
+ private double mStartAutoplayVisibleAreaOffset;
private Drawable mCommentIcon;
private NetworkState networkState;
private ExoCreator mExoCreator;
@@ -206,6 +209,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mMuteAutoplayingVideos = sharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS, true);
mShowThumbnailOnTheRightInCompactLayout = sharedPreferences.getBoolean(
SharedPreferencesUtils.SHOW_THUMBNAIL_ON_THE_RIGHT_IN_COMPACT_LAYOUT, false);
+
+ Resources resources = activity.getResources();
+ mStartAutoplayVisibleAreaOffset = resources.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ?
+ sharedPreferences.getInt(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_PORTRAIT, 75) / 100.0 :
+ sharedPreferences.getInt(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_LANDSCAPE, 50) / 100.0;
+
mPostLayout = postLayout;
mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
@@ -243,7 +252,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
if (mCommentIcon != null) {
DrawableCompat.setTint(mCommentIcon, mPostIconAndInfoColor);
}
- mScale = activity.getResources().getDisplayMetrics().density;
+
+ mScale = resources.getDisplayMetrics().density;
mGlide = Glide.with(mActivity);
mRedditDataRoomDatabase = redditDataRoomDatabase;
mLocale = locale;
@@ -1346,6 +1356,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mShowThumbnailOnTheRightInCompactLayout = showThumbnailOnTheRightInCompactLayout;
}
+ public void setStartAutoplayVisibleAreaOffset(double startAutoplayVisibleAreaOffset) {
+ this.mStartAutoplayVisibleAreaOffset = startAutoplayVisibleAreaOffset / 100.0;
+ }
+
@Override
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
super.onViewRecycled(holder);
@@ -2066,7 +2080,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
@Override
public boolean wantsToPlay() {
- return ToroUtil.visibleAreaOffset(this, itemView.getParent()) >= 0.75;
+ return ToroUtil.visibleAreaOffset(this, itemView.getParent()) >= mStartAutoplayVisibleAreaOffset;
}
@Override
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
index 6bbc049a..d3c471cf 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/AppComponent.java
@@ -61,6 +61,7 @@ import ml.docilealligator.infinityforreddit.Settings.GesturesAndButtonsPreferenc
import ml.docilealligator.infinityforreddit.Settings.MainPreferenceFragment;
import ml.docilealligator.infinityforreddit.Settings.NotificationPreferenceFragment;
import ml.docilealligator.infinityforreddit.Settings.ThemePreferenceFragment;
+import ml.docilealligator.infinityforreddit.Settings.VideoPreferenceFragment;
@Singleton
@Component(modules = AppModule.class)
@@ -182,4 +183,6 @@ public interface AppComponent {
void inject(ViewPrivateMessagesActivity viewPrivateMessagesActivity);
void inject(SendPrivateMessageActivity sendPrivateMessageActivity);
+
+ void inject(VideoPreferenceFragment videoPreferenceFragment);
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeStartAutoplayVisibleAreaOffsetEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeStartAutoplayVisibleAreaOffsetEvent.java
new file mode 100644
index 00000000..34fc48a9
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeStartAutoplayVisibleAreaOffsetEvent.java
@@ -0,0 +1,9 @@
+package ml.docilealligator.infinityforreddit.Event;
+
+public class ChangeStartAutoplayVisibleAreaOffsetEvent {
+ public double startAutoplayVisibleAreaOffset;
+
+ public ChangeStartAutoplayVisibleAreaOffsetEvent(double startAutoplayVisibleAreaOffset) {
+ this.startAutoplayVisibleAreaOffset = startAutoplayVisibleAreaOffset;
+ }
+}
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 4f6a80fe..71132f61 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
@@ -67,6 +67,7 @@ import ml.docilealligator.infinityforreddit.Event.ChangePostLayoutEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeShowAbsoluteNumberOfVotesEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
+import ml.docilealligator.infinityforreddit.Event.ChangeStartAutoplayVisibleAreaOffsetEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeTimeFormatEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeVideoAutoplayEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
@@ -935,6 +936,14 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
}
+ @Subscribe
+ public void onChangeStartAutoplayVisibleAreaOffsetEvent(ChangeStartAutoplayVisibleAreaOffsetEvent changeStartAutoplayVisibleAreaOffsetEvent) {
+ if (mAdapter != null) {
+ mAdapter.setStartAutoplayVisibleAreaOffset(changeStartAutoplayVisibleAreaOffsetEvent.startAutoplayVisibleAreaOffset);
+ refreshAdapter();
+ }
+ }
+
private void refreshAdapter() {
int previousPosition = -1;
if (mLinearLayoutManager != null) {
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CrashReportsFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CrashReportsFragment.java
deleted file mode 100644
index 04bdc0e9..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CrashReportsFragment.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package ml.docilealligator.infinityforreddit.Settings;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-
-import androidx.annotation.NonNull;
-import androidx.fragment.app.Fragment;
-import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.crazylegend.crashyreporter.CrashyReporter;
-
-import butterknife.BindView;
-import butterknife.ButterKnife;
-import ml.docilealligator.infinityforreddit.R;
-
-public class CrashReportsFragment extends Fragment {
-
- @BindView(R.id.recycler_view_crash_reports_fragment)
- RecyclerView recyclerView;
- private Activity activity;
- private CrashReportsRecyclerViewAdapter adapter;
- private LinearLayoutManager linearLayoutManager;
-
- public CrashReportsFragment() {
- // Required empty public constructor
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- // Inflate the layout for this fragment
- View rootView = inflater.inflate(R.layout.fragment_crash_reports, container, false);
-
- ButterKnife.bind(this, rootView);
-
- adapter = new CrashReportsRecyclerViewAdapter(CrashyReporter.INSTANCE.getLogsAsStrings());
- linearLayoutManager = new LinearLayoutManager(activity);
- recyclerView.setLayoutManager(linearLayoutManager);
- recyclerView.setAdapter(adapter);
-
- return rootView;
- }
-
- @Override
- public void onAttach(@NonNull Context context) {
- super.onAttach(context);
- this.activity = (Activity) context;
- }
-} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CrashReportsRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CrashReportsRecyclerViewAdapter.java
deleted file mode 100644
index 47629585..00000000
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/CrashReportsRecyclerViewAdapter.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package ml.docilealligator.infinityforreddit.Settings;
-
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.TextView;
-
-import androidx.annotation.NonNull;
-import androidx.recyclerview.widget.RecyclerView;
-
-import java.util.List;
-
-import ml.docilealligator.infinityforreddit.R;
-
-class CrashReportsRecyclerViewAdapter extends RecyclerView.Adapter<CrashReportsRecyclerViewAdapter.CrashReportViewHolder> {
- private List<String> crashReports;
-
- public CrashReportsRecyclerViewAdapter(List<String> crashReports) {
- this.crashReports = crashReports;
- }
-
- @NonNull
- @Override
- public CrashReportViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
- return new CrashReportViewHolder(LayoutInflater.from(parent.getContext()).inflate(R.layout.item_crash_report, parent, false));
- }
-
- @Override
- public void onBindViewHolder(@NonNull CrashReportViewHolder holder, int position) {
- holder.crashReportTextView.setText(crashReports.get(holder.getAdapterPosition()));
- }
-
- @Override
- public int getItemCount() {
- return crashReports == null ? 0 : crashReports.size();
- }
-
- class CrashReportViewHolder extends RecyclerView.ViewHolder {
- TextView crashReportTextView;
-
- public CrashReportViewHolder(@NonNull View itemView) {
- super(itemView);
- crashReportTextView = (TextView) itemView;
- }
- }
-}
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 e7cd2432..4cd4ceda 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/VideoPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/VideoPreferenceFragment.java
@@ -1,28 +1,50 @@
package ml.docilealligator.infinityforreddit.Settings;
+import android.app.Activity;
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.content.res.Configuration;
import android.os.Bundle;
+import androidx.annotation.NonNull;
+import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.ListPreference;
+import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
+import androidx.preference.SeekBarPreference;
import androidx.preference.SwitchPreference;
import org.greenrobot.eventbus.EventBus;
+import javax.inject.Inject;
+import javax.inject.Named;
+
import ml.docilealligator.infinityforreddit.Event.ChangeAutoplayNsfwVideosEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeMuteAutoplayingVideosEvent;
+import ml.docilealligator.infinityforreddit.Event.ChangeStartAutoplayVisibleAreaOffsetEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeVideoAutoplayEvent;
+import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
public class VideoPreferenceFragment extends PreferenceFragmentCompat {
+ private Activity activity;
+ @Inject
+ @Named("default")
+ SharedPreferences sharedPreferences;
+
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setPreferencesFromResource(R.xml.video_preferences, rootKey);
+ ((Infinity) activity.getApplication()).getAppComponent().inject(this);
+
ListPreference videoAutoplayListPreference = findPreference(SharedPreferencesUtils.VIDEO_AUTOPLAY);
SwitchPreference muteAutoplayingVideosSwitchPreference = findPreference(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS);
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);
if (videoAutoplayListPreference != null && autoplayNsfwVideosSwitchPreference != null) {
videoAutoplayListPreference.setOnPreferenceChangeListener((preference, newValue) -> {
@@ -42,5 +64,41 @@ public class VideoPreferenceFragment extends PreferenceFragmentCompat {
return true;
});
}
+
+ int orientation = getResources().getConfiguration().orientation;
+
+ if (startAutoplayVisibleAreaOffsetPortrait != null) {
+ startAutoplayVisibleAreaOffsetPortrait.setSummary(
+ getString(R.string.settings_start_autoplay_visible_area_offset_portrait_summary,
+ sharedPreferences.getInt(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_PORTRAIT, 75)));
+ startAutoplayVisibleAreaOffsetPortrait.setOnPreferenceChangeListener((Preference.OnPreferenceChangeListener) (preference, newValue) -> {
+ if (orientation == Configuration.ORIENTATION_PORTRAIT) {
+ EventBus.getDefault().post(new ChangeStartAutoplayVisibleAreaOffsetEvent((Integer) newValue));
+ }
+ startAutoplayVisibleAreaOffsetPortrait.setSummary(
+ getString(R.string.settings_start_autoplay_visible_area_offset_portrait_summary, (Integer) newValue));
+ return true;
+ });
+ }
+
+ if (startAutoplayVisibleAreaOffsetLandscape != null) {
+ startAutoplayVisibleAreaOffsetLandscape.setSummary(
+ getString(R.string.settings_start_autoplay_visible_area_offset_portrait_summary,
+ sharedPreferences.getInt(SharedPreferencesUtils.START_AUTOPLAY_VISIBLE_AREA_OFFSET_LANDSCAPE, 50)));
+ startAutoplayVisibleAreaOffsetLandscape.setOnPreferenceChangeListener((Preference.OnPreferenceChangeListener) (preference, newValue) -> {
+ if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
+ EventBus.getDefault().post(new ChangeStartAutoplayVisibleAreaOffsetEvent((Integer) newValue));
+ }
+ startAutoplayVisibleAreaOffsetLandscape.setSummary(
+ getString(R.string.settings_start_autoplay_visible_area_offset_landscape_summary, (Integer) newValue));
+ return true;
+ });
+ }
+ }
+
+ @Override
+ public void onAttach(@NonNull Context context) {
+ super.onAttach(context);
+ this.activity = (AppCompatActivity) context;
}
} \ No newline at end of file
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 1b6d9df6..eca06f7b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Utils/SharedPreferencesUtils.java
@@ -127,4 +127,6 @@ public class SharedPreferencesUtils {
public static final String MAIN_PAGE_TAB_POST_TYPE_SUBREDDIT = "3";
public static final String MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT = "4";
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";
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 23c3e314..6c31ed48 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -347,6 +347,10 @@
<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_start_autoplay_visible_area_offset_portrait_title">Autoplay Videos Visible Area Offset (Portrait)</string>
+ <string name="settings_start_autoplay_visible_area_offset_portrait_summary">Start autoplaying videos when %1$d%% of them are visible</string>
+ <string name="settings_start_autoplay_visible_area_offset_landscape_title">Autoplay Videos Visible Area Offset (Landscape)</string>
+ <string name="settings_start_autoplay_visible_area_offset_landscape_summary">Start autoplaying videos when %1$d%% of them are visible</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>
<string name="settings_immersive_interface_ignore_nav_bar_summary">Prevent the Bottom Navigation Bar Having Extra Padding</string>
@@ -425,8 +429,6 @@
<string name="settings_share_title">Share</string>
<string name="settings_share_summary">Share this app to other people if you enjoy it</string>
<string name="settings_version_title">Infinity For Reddit</string>
- <string name="settings_crash_reports_title">Crash Reports</string>
- <string name="settings_crash_reports_summary">See the error logs and send them to me when you report bugs</string>
<string name="settings_version_summary">Version %s</string>
<string name="settings_category_customization_title">Customization</string>
<string name="settings_customize_light_theme_title">Light Theme</string>
diff --git a/app/src/main/res/xml/about_preferences.xml b/app/src/main/res/xml/about_preferences.xml
index 6561eec3..a73f9aaa 100644
--- a/app/src/main/res/xml/about_preferences.xml
+++ b/app/src/main/res/xml/about_preferences.xml
@@ -46,11 +46,6 @@
app:summary="@string/settings_share_summary" />
<Preference
- app:title="@string/settings_crash_reports_title"
- app:summary="@string/settings_crash_reports_summary"
- app:fragment="ml.docilealligator.infinityforreddit.Settings.CrashReportsFragment" />
-
- <Preference
android:key="version"
app:title="@string/settings_version_title"
app:summary="@string/settings_version_summary" />
diff --git a/app/src/main/res/xml/video_preferences.xml b/app/src/main/res/xml/video_preferences.xml
index bb690347..e570c478 100644
--- a/app/src/main/res/xml/video_preferences.xml
+++ b/app/src/main/res/xml/video_preferences.xml
@@ -35,4 +35,18 @@
app:key="autoplay_nsfw_videos"
app:title="@string/settings_autoplay_nsfw_videos_title" />
+ <SeekBarPreference
+ app:defaultValue="75"
+ android:max="100"
+ app:key="start_autoplay_visible_area_offset_portrait"
+ app:title="@string/settings_start_autoplay_visible_area_offset_portrait_title"
+ app:singleLineTitle="false" />
+
+ <SeekBarPreference
+ app:defaultValue="50"
+ android:max="100"
+ app:key="start_autoplay_visible_area_offset_landscape"
+ app:title="@string/settings_start_autoplay_visible_area_offset_landscape_title"
+ app:singleLineTitle="false" />
+
</PreferenceScreen> \ No newline at end of file