Merge cf3b901a6c62bc8f6e0f1ccd5f21bdf8a207b35a into 35b70c5e9e8d791ae268bac677a3b760b1b4e8bf
This commit is contained in:
commit
f2d403cbd2
@ -6,7 +6,6 @@ import static org.schabi.newpipe.player.helper.PlayerHelper.AutoplayType.AUTOPLA
|
||||
import static org.schabi.newpipe.player.helper.PlayerHelper.MinimizeMode.MINIMIZE_ON_EXIT_MODE_BACKGROUND;
|
||||
import static org.schabi.newpipe.player.helper.PlayerHelper.MinimizeMode.MINIMIZE_ON_EXIT_MODE_NONE;
|
||||
import static org.schabi.newpipe.player.helper.PlayerHelper.MinimizeMode.MINIMIZE_ON_EXIT_MODE_POPUP;
|
||||
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
@ -15,7 +14,6 @@ import android.content.pm.PackageManager;
|
||||
import android.provider.Settings;
|
||||
import android.view.accessibility.CaptioningManager;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
@ -43,7 +41,6 @@ import org.schabi.newpipe.player.playqueue.SinglePlayQueue;
|
||||
import org.schabi.newpipe.util.ListHelper;
|
||||
import org.schabi.newpipe.util.Localization;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.text.NumberFormat;
|
||||
@ -59,22 +56,16 @@ import java.util.concurrent.TimeUnit;
|
||||
public final class PlayerHelper {
|
||||
private static final FormattersProvider FORMATTERS_PROVIDER = new FormattersProvider();
|
||||
|
||||
@Retention(SOURCE)
|
||||
@IntDef({AUTOPLAY_TYPE_ALWAYS, AUTOPLAY_TYPE_WIFI,
|
||||
AUTOPLAY_TYPE_NEVER})
|
||||
public @interface AutoplayType {
|
||||
int AUTOPLAY_TYPE_ALWAYS = 0;
|
||||
int AUTOPLAY_TYPE_WIFI = 1;
|
||||
int AUTOPLAY_TYPE_NEVER = 2;
|
||||
public enum AutoplayType {
|
||||
AUTOPLAY_TYPE_ALWAYS,
|
||||
AUTOPLAY_TYPE_WIFI,
|
||||
AUTOPLAY_TYPE_NEVER
|
||||
}
|
||||
|
||||
@Retention(SOURCE)
|
||||
@IntDef({MINIMIZE_ON_EXIT_MODE_NONE, MINIMIZE_ON_EXIT_MODE_BACKGROUND,
|
||||
MINIMIZE_ON_EXIT_MODE_POPUP})
|
||||
public @interface MinimizeMode {
|
||||
int MINIMIZE_ON_EXIT_MODE_NONE = 0;
|
||||
int MINIMIZE_ON_EXIT_MODE_BACKGROUND = 1;
|
||||
int MINIMIZE_ON_EXIT_MODE_POPUP = 2;
|
||||
public enum MinimizeMode {
|
||||
MINIMIZE_ON_EXIT_MODE_NONE,
|
||||
MINIMIZE_ON_EXIT_MODE_BACKGROUND,
|
||||
MINIMIZE_ON_EXIT_MODE_POPUP
|
||||
}
|
||||
|
||||
private PlayerHelper() {
|
||||
@ -236,8 +227,7 @@ public final class PlayerHelper {
|
||||
.getBoolean(context.getString(R.string.clear_queue_confirmation_key), false);
|
||||
}
|
||||
|
||||
@MinimizeMode
|
||||
public static int getMinimizeOnExitAction(@NonNull final Context context) {
|
||||
public static MinimizeMode getMinimizeOnExitAction(@NonNull final Context context) {
|
||||
final String action = getPreferences(context)
|
||||
.getString(context.getString(R.string.minimize_on_exit_key), "");
|
||||
if (action.equals(context.getString(R.string.minimize_on_exit_popup_key))) {
|
||||
@ -249,8 +239,8 @@ public final class PlayerHelper {
|
||||
}
|
||||
}
|
||||
|
||||
@AutoplayType
|
||||
public static int getAutoplayType(@NonNull final Context context) {
|
||||
|
||||
public static AutoplayType getAutoplayType(@NonNull final Context context) {
|
||||
final String type = getPreferences(context).getString(
|
||||
context.getString(R.string.autoplay_key), "");
|
||||
if (type.equals(context.getString(R.string.autoplay_always_key))) {
|
||||
@ -263,15 +253,11 @@ public final class PlayerHelper {
|
||||
}
|
||||
|
||||
public static boolean isAutoplayAllowedByUser(@NonNull final Context context) {
|
||||
switch (PlayerHelper.getAutoplayType(context)) {
|
||||
case PlayerHelper.AutoplayType.AUTOPLAY_TYPE_NEVER:
|
||||
return false;
|
||||
case PlayerHelper.AutoplayType.AUTOPLAY_TYPE_WIFI:
|
||||
return !ListHelper.isMeteredNetwork(context);
|
||||
case PlayerHelper.AutoplayType.AUTOPLAY_TYPE_ALWAYS:
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
return switch (PlayerHelper.getAutoplayType(context)) {
|
||||
case AUTOPLAY_TYPE_NEVER -> false;
|
||||
case AUTOPLAY_TYPE_WIFI -> !ListHelper.isMeteredNetwork(context);
|
||||
case AUTOPLAY_TYPE_ALWAYS -> true;
|
||||
};
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@ -6,7 +6,6 @@ import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.graphics.BitmapCompat;
|
||||
@ -16,10 +15,8 @@ import androidx.preference.PreferenceManager;
|
||||
import org.schabi.newpipe.R;
|
||||
import org.schabi.newpipe.util.DeviceUtils;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.util.function.IntSupplier;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.SOURCE;
|
||||
import static org.schabi.newpipe.player.seekbarpreview.SeekbarPreviewThumbnailHelper.SeekbarPreviewThumbnailType.HIGH_QUALITY;
|
||||
import static org.schabi.newpipe.player.seekbarpreview.SeekbarPreviewThumbnailHelper.SeekbarPreviewThumbnailType.LOW_QUALITY;
|
||||
import static org.schabi.newpipe.player.seekbarpreview.SeekbarPreviewThumbnailHelper.SeekbarPreviewThumbnailType.NONE;
|
||||
@ -38,21 +35,19 @@ public final class SeekbarPreviewThumbnailHelper {
|
||||
// No impl pls
|
||||
}
|
||||
|
||||
@Retention(SOURCE)
|
||||
@IntDef({HIGH_QUALITY, LOW_QUALITY,
|
||||
NONE})
|
||||
public @interface SeekbarPreviewThumbnailType {
|
||||
int HIGH_QUALITY = 0;
|
||||
int LOW_QUALITY = 1;
|
||||
int NONE = 2;
|
||||
|
||||
public enum SeekbarPreviewThumbnailType {
|
||||
HIGH_QUALITY,
|
||||
LOW_QUALITY,
|
||||
NONE,
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Settings Resolution
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@SeekbarPreviewThumbnailType
|
||||
public static int getSeekbarPreviewThumbnailType(@NonNull final Context context) {
|
||||
public static SeekbarPreviewThumbnailType getSeekbarPreviewThumbnailType(
|
||||
@NonNull final Context context) {
|
||||
final String type = PreferenceManager.getDefaultSharedPreferences(context).getString(
|
||||
context.getString(R.string.seekbar_preview_thumbnail_key), "");
|
||||
if (type.equals(context.getString(R.string.seekbar_preview_thumbnail_none))) {
|
||||
|
||||
@ -41,7 +41,7 @@ public class SeekbarPreviewThumbnailHolder {
|
||||
private UUID currentUpdateRequestIdentifier = UUID.randomUUID();
|
||||
|
||||
public void resetFrom(@NonNull final Context context, final List<Frameset> framesets) {
|
||||
final int seekbarPreviewType = getSeekbarPreviewThumbnailType(context);
|
||||
final var seekbarPreviewType = getSeekbarPreviewThumbnailType(context);
|
||||
|
||||
final UUID updateRequestIdentifier = UUID.randomUUID();
|
||||
this.currentUpdateRequestIdentifier = updateRequestIdentifier;
|
||||
@ -59,7 +59,8 @@ public class SeekbarPreviewThumbnailHolder {
|
||||
executorService.shutdown();
|
||||
}
|
||||
|
||||
private void resetFromAsync(final int seekbarPreviewType, final List<Frameset> framesets,
|
||||
private void resetFromAsync(final SeekbarPreviewThumbnailType seekbarPreviewType,
|
||||
final List<Frameset> framesets,
|
||||
final UUID updateRequestIdentifier) {
|
||||
Log.d(TAG, "Clearing seekbarPreviewData");
|
||||
synchronized (seekbarPreviewData) {
|
||||
@ -90,7 +91,7 @@ public class SeekbarPreviewThumbnailHolder {
|
||||
}
|
||||
|
||||
private Frameset getFrameSetForType(final List<Frameset> framesets,
|
||||
final int seekbarPreviewType) {
|
||||
final SeekbarPreviewThumbnailType seekbarPreviewType) {
|
||||
if (seekbarPreviewType == SeekbarPreviewThumbnailType.HIGH_QUALITY) {
|
||||
Log.d(TAG, "Strategy for seekbarPreviewData: high quality");
|
||||
return framesets.stream()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user