66import static org .schabi .newpipe .player .helper .PlayerHelper .MinimizeMode .MINIMIZE_ON_EXIT_MODE_BACKGROUND ;
77import static org .schabi .newpipe .player .helper .PlayerHelper .MinimizeMode .MINIMIZE_ON_EXIT_MODE_NONE ;
88import static org .schabi .newpipe .player .helper .PlayerHelper .MinimizeMode .MINIMIZE_ON_EXIT_MODE_POPUP ;
9- import static java .lang .annotation .RetentionPolicy .SOURCE ;
109
1110import android .annotation .SuppressLint ;
1211import android .content .Context ;
1514import android .provider .Settings ;
1615import android .view .accessibility .CaptioningManager ;
1716
18- import androidx .annotation .IntDef ;
1917import androidx .annotation .NonNull ;
2018import androidx .annotation .Nullable ;
2119import androidx .core .content .ContextCompat ;
4341import org .schabi .newpipe .util .ListHelper ;
4442import org .schabi .newpipe .util .Localization ;
4543
46- import java .lang .annotation .Retention ;
4744import java .text .DecimalFormat ;
4845import java .text .DecimalFormatSymbols ;
4946import java .text .NumberFormat ;
5956public final class PlayerHelper {
6057 private static final FormattersProvider FORMATTERS_PROVIDER = new FormattersProvider ();
6158
62- @ Retention (SOURCE )
63- @ IntDef ({AUTOPLAY_TYPE_ALWAYS , AUTOPLAY_TYPE_WIFI ,
64- AUTOPLAY_TYPE_NEVER })
65- public @interface AutoplayType {
66- int AUTOPLAY_TYPE_ALWAYS = 0 ;
67- int AUTOPLAY_TYPE_WIFI = 1 ;
68- int AUTOPLAY_TYPE_NEVER = 2 ;
59+ public enum AutoplayType {
60+ AUTOPLAY_TYPE_ALWAYS ,
61+ AUTOPLAY_TYPE_WIFI ,
62+ AUTOPLAY_TYPE_NEVER
6963 }
7064
7165 public enum MinimizeMode {
@@ -245,8 +239,8 @@ public static MinimizeMode getMinimizeOnExitAction(@NonNull final Context contex
245239 }
246240 }
247241
248- @ AutoplayType
249- public static int getAutoplayType (@ NonNull final Context context ) {
242+
243+ public static AutoplayType getAutoplayType (@ NonNull final Context context ) {
250244 final String type = getPreferences (context ).getString (
251245 context .getString (R .string .autoplay_key ), "" );
252246 if (type .equals (context .getString (R .string .autoplay_always_key ))) {
@@ -259,15 +253,11 @@ public static int getAutoplayType(@NonNull final Context context) {
259253 }
260254
261255 public static boolean isAutoplayAllowedByUser (@ NonNull final Context context ) {
262- switch (PlayerHelper .getAutoplayType (context )) {
263- case PlayerHelper .AutoplayType .AUTOPLAY_TYPE_NEVER :
264- return false ;
265- case PlayerHelper .AutoplayType .AUTOPLAY_TYPE_WIFI :
266- return !ListHelper .isMeteredNetwork (context );
267- case PlayerHelper .AutoplayType .AUTOPLAY_TYPE_ALWAYS :
268- default :
269- return true ;
270- }
256+ return switch (PlayerHelper .getAutoplayType (context )) {
257+ case AUTOPLAY_TYPE_NEVER -> false ;
258+ case AUTOPLAY_TYPE_WIFI -> !ListHelper .isMeteredNetwork (context );
259+ case AUTOPLAY_TYPE_ALWAYS -> true ;
260+ };
271261 }
272262
273263 @ NonNull
0 commit comments