mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-29 04:17:12 +01:00
Setting autoplay videos visible area offset is available. Remove Crashy because it will crash on some devices, such as Pixel Slate.
This commit is contained in:
parent
318b11da01
commit
6f34d854ea
@ -87,10 +87,6 @@ dependencies {
|
|||||||
implementation 'com.google.code.gson:gson:2.8.6'
|
implementation 'com.google.code.gson:gson:2.8.6'
|
||||||
implementation 'me.zhanghai.android.fastscroll:library:1.1.2'
|
implementation 'me.zhanghai.android.fastscroll:library:1.1.2'
|
||||||
implementation "com.thefuntasty.hauler:core:3.1.0"
|
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'
|
def toroVersion = '3.7.0.2010003'
|
||||||
implementation "im.ene.toro3:toro:$toroVersion"
|
implementation "im.ene.toro3:toro:$toroVersion"
|
||||||
|
@ -328,16 +328,6 @@
|
|||||||
android:resource="@xml/file_paths" />
|
android:resource="@xml/file_paths" />
|
||||||
</provider>
|
</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
|
<service
|
||||||
android:name=".Service.SubmitPostService"
|
android:name=".Service.SubmitPostService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
|
@ -3,6 +3,8 @@ package ml.docilealligator.infinityforreddit.Adapter;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.graphics.ColorFilter;
|
import android.graphics.ColorFilter;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
@ -159,6 +161,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
private boolean mAutoplayNsfwVideos;
|
private boolean mAutoplayNsfwVideos;
|
||||||
private boolean mMuteAutoplayingVideos;
|
private boolean mMuteAutoplayingVideos;
|
||||||
private boolean mFullyCollapseComment;
|
private boolean mFullyCollapseComment;
|
||||||
|
private double mStartAutoplayVisibleAreaOffset;
|
||||||
private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback;
|
private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback;
|
||||||
private boolean isInitiallyLoading;
|
private boolean isInitiallyLoading;
|
||||||
private boolean isInitiallyLoadingFailed;
|
private boolean isInitiallyLoadingFailed;
|
||||||
@ -340,12 +343,17 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
mMuteAutoplayingVideos = sharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS, true);
|
mMuteAutoplayingVideos = sharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS, true);
|
||||||
mFullyCollapseComment = sharedPreferences.getBoolean(SharedPreferencesUtils.FULLY_COLLAPSE_COMMENT, false);
|
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;
|
mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback;
|
||||||
isInitiallyLoading = true;
|
isInitiallyLoading = true;
|
||||||
isInitiallyLoadingFailed = false;
|
isInitiallyLoadingFailed = false;
|
||||||
mHasMoreComments = false;
|
mHasMoreComments = false;
|
||||||
loadMoreCommentsFailed = false;
|
loadMoreCommentsFailed = false;
|
||||||
mScale = activity.getResources().getDisplayMetrics().density;
|
mScale = resources.getDisplayMetrics().density;
|
||||||
|
|
||||||
mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
|
mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
|
||||||
mColorAccent = customThemeWrapper.getColorAccent();
|
mColorAccent = customThemeWrapper.getColorAccent();
|
||||||
@ -2259,7 +2267,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean wantsToPlay() {
|
public boolean wantsToPlay() {
|
||||||
return ToroUtil.visibleAreaOffset(this, itemView.getParent()) >= 0.85;
|
return ToroUtil.visibleAreaOffset(this, itemView.getParent()) >= mStartAutoplayVisibleAreaOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -3,6 +3,8 @@ package ml.docilealligator.infinityforreddit.Adapter;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.ColorStateList;
|
import android.content.res.ColorStateList;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.graphics.ColorFilter;
|
import android.graphics.ColorFilter;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
@ -169,6 +171,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
private boolean mAutoplayNsfwVideos;
|
private boolean mAutoplayNsfwVideos;
|
||||||
private boolean mMuteAutoplayingVideos;
|
private boolean mMuteAutoplayingVideos;
|
||||||
private boolean mShowThumbnailOnTheRightInCompactLayout;
|
private boolean mShowThumbnailOnTheRightInCompactLayout;
|
||||||
|
private double mStartAutoplayVisibleAreaOffset;
|
||||||
private Drawable mCommentIcon;
|
private Drawable mCommentIcon;
|
||||||
private NetworkState networkState;
|
private NetworkState networkState;
|
||||||
private ExoCreator mExoCreator;
|
private ExoCreator mExoCreator;
|
||||||
@ -206,6 +209,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
mMuteAutoplayingVideos = sharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS, true);
|
mMuteAutoplayingVideos = sharedPreferences.getBoolean(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS, true);
|
||||||
mShowThumbnailOnTheRightInCompactLayout = sharedPreferences.getBoolean(
|
mShowThumbnailOnTheRightInCompactLayout = sharedPreferences.getBoolean(
|
||||||
SharedPreferencesUtils.SHOW_THUMBNAIL_ON_THE_RIGHT_IN_COMPACT_LAYOUT, false);
|
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;
|
mPostLayout = postLayout;
|
||||||
|
|
||||||
mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
|
mColorPrimaryLightTheme = customThemeWrapper.getColorPrimaryLightTheme();
|
||||||
@ -243,7 +252,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
if (mCommentIcon != null) {
|
if (mCommentIcon != null) {
|
||||||
DrawableCompat.setTint(mCommentIcon, mPostIconAndInfoColor);
|
DrawableCompat.setTint(mCommentIcon, mPostIconAndInfoColor);
|
||||||
}
|
}
|
||||||
mScale = activity.getResources().getDisplayMetrics().density;
|
|
||||||
|
mScale = resources.getDisplayMetrics().density;
|
||||||
mGlide = Glide.with(mActivity);
|
mGlide = Glide.with(mActivity);
|
||||||
mRedditDataRoomDatabase = redditDataRoomDatabase;
|
mRedditDataRoomDatabase = redditDataRoomDatabase;
|
||||||
mLocale = locale;
|
mLocale = locale;
|
||||||
@ -1346,6 +1356,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
mShowThumbnailOnTheRightInCompactLayout = showThumbnailOnTheRightInCompactLayout;
|
mShowThumbnailOnTheRightInCompactLayout = showThumbnailOnTheRightInCompactLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setStartAutoplayVisibleAreaOffset(double startAutoplayVisibleAreaOffset) {
|
||||||
|
this.mStartAutoplayVisibleAreaOffset = startAutoplayVisibleAreaOffset / 100.0;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
||||||
super.onViewRecycled(holder);
|
super.onViewRecycled(holder);
|
||||||
@ -2066,7 +2080,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean wantsToPlay() {
|
public boolean wantsToPlay() {
|
||||||
return ToroUtil.visibleAreaOffset(this, itemView.getParent()) >= 0.75;
|
return ToroUtil.visibleAreaOffset(this, itemView.getParent()) >= mStartAutoplayVisibleAreaOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -61,6 +61,7 @@ import ml.docilealligator.infinityforreddit.Settings.GesturesAndButtonsPreferenc
|
|||||||
import ml.docilealligator.infinityforreddit.Settings.MainPreferenceFragment;
|
import ml.docilealligator.infinityforreddit.Settings.MainPreferenceFragment;
|
||||||
import ml.docilealligator.infinityforreddit.Settings.NotificationPreferenceFragment;
|
import ml.docilealligator.infinityforreddit.Settings.NotificationPreferenceFragment;
|
||||||
import ml.docilealligator.infinityforreddit.Settings.ThemePreferenceFragment;
|
import ml.docilealligator.infinityforreddit.Settings.ThemePreferenceFragment;
|
||||||
|
import ml.docilealligator.infinityforreddit.Settings.VideoPreferenceFragment;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@Component(modules = AppModule.class)
|
@Component(modules = AppModule.class)
|
||||||
@ -182,4 +183,6 @@ public interface AppComponent {
|
|||||||
void inject(ViewPrivateMessagesActivity viewPrivateMessagesActivity);
|
void inject(ViewPrivateMessagesActivity viewPrivateMessagesActivity);
|
||||||
|
|
||||||
void inject(SendPrivateMessageActivity sendPrivateMessageActivity);
|
void inject(SendPrivateMessageActivity sendPrivateMessageActivity);
|
||||||
|
|
||||||
|
void inject(VideoPreferenceFragment videoPreferenceFragment);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.Event;
|
||||||
|
|
||||||
|
public class ChangeStartAutoplayVisibleAreaOffsetEvent {
|
||||||
|
public double startAutoplayVisibleAreaOffset;
|
||||||
|
|
||||||
|
public ChangeStartAutoplayVisibleAreaOffsetEvent(double startAutoplayVisibleAreaOffset) {
|
||||||
|
this.startAutoplayVisibleAreaOffset = startAutoplayVisibleAreaOffset;
|
||||||
|
}
|
||||||
|
}
|
@ -67,6 +67,7 @@ import ml.docilealligator.infinityforreddit.Event.ChangePostLayoutEvent;
|
|||||||
import ml.docilealligator.infinityforreddit.Event.ChangeShowAbsoluteNumberOfVotesEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeShowAbsoluteNumberOfVotesEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
|
||||||
|
import ml.docilealligator.infinityforreddit.Event.ChangeStartAutoplayVisibleAreaOffsetEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeTimeFormatEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeTimeFormatEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeVideoAutoplayEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeVideoAutoplayEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
|
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() {
|
private void refreshAdapter() {
|
||||||
int previousPosition = -1;
|
int previousPosition = -1;
|
||||||
if (mLinearLayoutManager != null) {
|
if (mLinearLayoutManager != 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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +1,50 @@
|
|||||||
package ml.docilealligator.infinityforreddit.Settings;
|
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 android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.preference.ListPreference;
|
import androidx.preference.ListPreference;
|
||||||
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceFragmentCompat;
|
import androidx.preference.PreferenceFragmentCompat;
|
||||||
|
import androidx.preference.SeekBarPreference;
|
||||||
import androidx.preference.SwitchPreference;
|
import androidx.preference.SwitchPreference;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeAutoplayNsfwVideosEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeAutoplayNsfwVideosEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeMuteAutoplayingVideosEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeMuteAutoplayingVideosEvent;
|
||||||
|
import ml.docilealligator.infinityforreddit.Event.ChangeStartAutoplayVisibleAreaOffsetEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeVideoAutoplayEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeVideoAutoplayEvent;
|
||||||
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
|
|
||||||
public class VideoPreferenceFragment extends PreferenceFragmentCompat {
|
public class VideoPreferenceFragment extends PreferenceFragmentCompat {
|
||||||
|
|
||||||
|
private Activity activity;
|
||||||
|
@Inject
|
||||||
|
@Named("default")
|
||||||
|
SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
|
||||||
setPreferencesFromResource(R.xml.video_preferences, rootKey);
|
setPreferencesFromResource(R.xml.video_preferences, rootKey);
|
||||||
|
|
||||||
|
((Infinity) activity.getApplication()).getAppComponent().inject(this);
|
||||||
|
|
||||||
ListPreference videoAutoplayListPreference = findPreference(SharedPreferencesUtils.VIDEO_AUTOPLAY);
|
ListPreference videoAutoplayListPreference = findPreference(SharedPreferencesUtils.VIDEO_AUTOPLAY);
|
||||||
SwitchPreference muteAutoplayingVideosSwitchPreference = findPreference(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS);
|
SwitchPreference muteAutoplayingVideosSwitchPreference = findPreference(SharedPreferencesUtils.MUTE_AUTOPLAYING_VIDEOS);
|
||||||
SwitchPreference autoplayNsfwVideosSwitchPreference = findPreference(SharedPreferencesUtils.AUTOPLAY_NSFW_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) {
|
if (videoAutoplayListPreference != null && autoplayNsfwVideosSwitchPreference != null) {
|
||||||
videoAutoplayListPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
videoAutoplayListPreference.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
@ -42,5 +64,41 @@ public class VideoPreferenceFragment extends PreferenceFragmentCompat {
|
|||||||
return true;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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_SUBREDDIT = "3";
|
||||||
public static final String MAIN_PAGE_TAB_POST_TYPE_MULTIREDDIT = "4";
|
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 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";
|
||||||
}
|
}
|
||||||
|
@ -347,6 +347,10 @@
|
|||||||
<string name="settings_video_autoplay_title">Video Autoplay</string>
|
<string name="settings_video_autoplay_title">Video Autoplay</string>
|
||||||
<string name="settings_mute_autoplaying_videos_title">Mute Autoplaying Videos</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_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_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_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>
|
<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_title">Share</string>
|
||||||
<string name="settings_share_summary">Share this app to other people if you enjoy it</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_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_version_summary">Version %s</string>
|
||||||
<string name="settings_category_customization_title">Customization</string>
|
<string name="settings_category_customization_title">Customization</string>
|
||||||
<string name="settings_customize_light_theme_title">Light Theme</string>
|
<string name="settings_customize_light_theme_title">Light Theme</string>
|
||||||
|
@ -45,11 +45,6 @@
|
|||||||
app:title="@string/settings_share_title"
|
app:title="@string/settings_share_title"
|
||||||
app:summary="@string/settings_share_summary" />
|
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
|
<Preference
|
||||||
android:key="version"
|
android:key="version"
|
||||||
app:title="@string/settings_version_title"
|
app:title="@string/settings_version_title"
|
||||||
|
@ -35,4 +35,18 @@
|
|||||||
app:key="autoplay_nsfw_videos"
|
app:key="autoplay_nsfw_videos"
|
||||||
app:title="@string/settings_autoplay_nsfw_videos_title" />
|
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>
|
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user