diff --git a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java index 0f9579352a5..94350c9b28c 100644 --- a/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java +++ b/app/src/main/java/org/schabi/newpipe/player/helper/PlayerHelper.java @@ -6,7 +6,6 @@ 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.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.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 @@ 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 static boolean isClearingQueueConfirmationRequired(@NonNull final Context .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 static int getMinimizeOnExitAction(@NonNull final Context context) { } } - @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 static int getAutoplayType(@NonNull final Context context) { } 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 diff --git a/app/src/main/java/org/schabi/newpipe/player/seekbarpreview/SeekbarPreviewThumbnailHelper.java b/app/src/main/java/org/schabi/newpipe/player/seekbarpreview/SeekbarPreviewThumbnailHelper.java index 28856d606b4..f55296c4e37 100644 --- a/app/src/main/java/org/schabi/newpipe/player/seekbarpreview/SeekbarPreviewThumbnailHelper.java +++ b/app/src/main/java/org/schabi/newpipe/player/seekbarpreview/SeekbarPreviewThumbnailHelper.java @@ -6,7 +6,6 @@ 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 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 @@ private 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))) { diff --git a/app/src/main/java/org/schabi/newpipe/player/seekbarpreview/SeekbarPreviewThumbnailHolder.java b/app/src/main/java/org/schabi/newpipe/player/seekbarpreview/SeekbarPreviewThumbnailHolder.java index 09c61b8b35a..77012acbcbb 100644 --- a/app/src/main/java/org/schabi/newpipe/player/seekbarpreview/SeekbarPreviewThumbnailHolder.java +++ b/app/src/main/java/org/schabi/newpipe/player/seekbarpreview/SeekbarPreviewThumbnailHolder.java @@ -41,7 +41,7 @@ public class SeekbarPreviewThumbnailHolder { private UUID currentUpdateRequestIdentifier = UUID.randomUUID(); public void resetFrom(@NonNull final Context context, final List