Skip to content

Commit

Permalink
Positions in lists only depends on watch history
Browse files Browse the repository at this point in the history
  • Loading branch information
Stypox committed Feb 7, 2023
1 parent a3699ca commit 3ee3ddb
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 20 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import static com.google.android.exoplayer2.Player.RepeatMode;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
import static org.schabi.newpipe.player.helper.PlayerHelper.isPlaybackResumeEnabled;
import static org.schabi.newpipe.player.helper.PlayerHelper.nextRepeatMode;
import static org.schabi.newpipe.player.helper.PlayerHelper.retrievePlaybackParametersFromPrefs;
import static org.schabi.newpipe.player.helper.PlayerHelper.retrieveSeekDurationFromPreferences;
Expand Down Expand Up @@ -115,6 +114,7 @@
import org.schabi.newpipe.player.ui.PlayerUiList;
import org.schabi.newpipe.player.ui.PopupPlayerUi;
import org.schabi.newpipe.player.ui.VideoPlayerUi;
import org.schabi.newpipe.util.DependentPreferenceHelper;
import org.schabi.newpipe.util.DeviceUtils;
import org.schabi.newpipe.util.ListHelper;
import org.schabi.newpipe.util.NavigationHelper;
Expand Down Expand Up @@ -392,7 +392,7 @@ public void handleIntent(@NonNull final Intent intent) {
simpleExoPlayer.setPlayWhenReady(playWhenReady);

} else if (intent.getBooleanExtra(RESUME_PLAYBACK, false)
&& isPlaybackResumeEnabled(this)
&& DependentPreferenceHelper.getResumePlaybackEnabled(context)
&& !samePlayQueue
&& !newQueue.isEmpty()
&& newQueue.getItem() != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,6 @@ private static SinglePlayQueue getAutoQueuedSinglePlayQueue(
// Utils used by player
////////////////////////////////////////////////////////////////////////////

public static boolean isPlaybackResumeEnabled(final Player player) {
return player.getPrefs().getBoolean(
player.getContext().getString(R.string.enable_watch_history_key), true)
&& player.getPrefs().getBoolean(
player.getContext().getString(R.string.enable_playback_resume_key), true);
}

@RepeatMode
public static int nextRepeatMode(@RepeatMode final int repeatMode) {
switch (repeatMode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ private DependentPreferenceHelper() {
}

/**
* Option `Resume playback` depends on `Watch history`, this method can
* be used to retrieve if `Resume playback` and its dependencies are all enabled.
* Option `Resume playback` depends on `Watch history`, this method can be used to retrieve if
* `Resume playback` and its dependencies are all enabled.
*
* @param context the Android context
* @return returns true if `Resume playback` and `Watch history` are both
* enabled, otherwise returns false.
* @return returns true if `Resume playback` and `Watch history` are both enabled
*/
public static boolean getResumePlaybackEnabled(final Context context) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
Expand All @@ -34,19 +34,17 @@ public static boolean getResumePlaybackEnabled(final Context context) {
}

/**
* Option `Position in lists` depends on `Watch history` and `Resume playback`, this method can
* be used to retrieve if `Position in lists` and its dependencies are all enabled.
* Option `Position in lists` depends on `Watch history`, this method can be used to retrieve if
* `Position in lists` and its dependencies are all enabled.
*
* @param context the Android context
* @return returns true if `Positions in lists`, `Watch history` and `Resume playback` are all
* enabled, otherwise returns false.
* @return returns true if `Positions in lists` and `Watch history` are both enabled
*/
public static boolean getPositionsInListsEnabled(final Context context) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);

return prefs.getBoolean(context.getString(
R.string.enable_watch_history_key), true)
&& prefs.getBoolean(context.getString(
R.string.enable_playback_resume_key), true)
&& prefs.getBoolean(context.getString(
R.string.enable_playback_state_lists_key), true);
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/history_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<SwitchPreferenceCompat
android:defaultValue="true"
android:dependency="@string/enable_playback_resume_key"
android:dependency="@string/enable_watch_history_key"
android:key="@string/enable_playback_state_lists_key"
android:summary="@string/enable_playback_state_lists_summary"
android:title="@string/enable_playback_state_lists_title"
Expand Down

0 comments on commit 3ee3ddb

Please sign in to comment.