From 06d54ef77ea33117237cd89aa5fc10fc4d2a0e23 Mon Sep 17 00:00:00 2001 From: TacoTheDank Date: Thu, 27 Aug 2020 16:59:29 -0400 Subject: [PATCH] Clean up SDK version checks --- app/src/main/java/org/schabi/newpipe/App.java | 2 +- app/src/main/java/org/schabi/newpipe/ExitActivity.java | 2 +- .../java/org/schabi/newpipe/PanicResponderActivity.java | 2 +- .../main/java/org/schabi/newpipe/player/MainPlayer.java | 4 +--- .../main/java/org/schabi/newpipe/player/VideoPlayer.java | 2 +- .../java/org/schabi/newpipe/player/VideoPlayerImpl.java | 2 +- .../org/schabi/newpipe/player/helper/PlayerHelper.java | 9 --------- .../java/org/schabi/newpipe/report/ErrorActivity.java | 3 ++- .../java/org/schabi/newpipe/util/PermissionHelper.java | 6 ++---- .../java/org/schabi/newpipe/views/FocusOverlayView.java | 2 +- .../org/schabi/newpipe/views/NewPipeRecyclerView.java | 2 +- .../us/shandian/giga/service/DownloadManagerService.java | 8 ++++---- 12 files changed, 16 insertions(+), 28 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/App.java b/app/src/main/java/org/schabi/newpipe/App.java index 00842ec46..962679cd0 100644 --- a/app/src/main/java/org/schabi/newpipe/App.java +++ b/app/src/main/java/org/schabi/newpipe/App.java @@ -220,7 +220,7 @@ public class App extends Application { } public void initNotificationChannel() { - if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { return; } diff --git a/app/src/main/java/org/schabi/newpipe/ExitActivity.java b/app/src/main/java/org/schabi/newpipe/ExitActivity.java index d4a4e3125..d457500aa 100644 --- a/app/src/main/java/org/schabi/newpipe/ExitActivity.java +++ b/app/src/main/java/org/schabi/newpipe/ExitActivity.java @@ -42,7 +42,7 @@ public class ExitActivity extends Activity { protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - if (Build.VERSION.SDK_INT >= 21) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { finishAndRemoveTask(); } else { finish(); diff --git a/app/src/main/java/org/schabi/newpipe/PanicResponderActivity.java b/app/src/main/java/org/schabi/newpipe/PanicResponderActivity.java index 75304a2b9..b4fbdfb28 100644 --- a/app/src/main/java/org/schabi/newpipe/PanicResponderActivity.java +++ b/app/src/main/java/org/schabi/newpipe/PanicResponderActivity.java @@ -40,7 +40,7 @@ public class PanicResponderActivity extends Activity { ExitActivity.exitAndRemoveFromRecentApps(this); } - if (Build.VERSION.SDK_INT >= 21) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { finishAndRemoveTask(); } else { finish(); diff --git a/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java index e562deb61..273f37cc8 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainPlayer.java @@ -310,9 +310,7 @@ public final class MainPlayer extends Service { setLockScreenThumbnail(builder); } - if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) { - builder.setPriority(NotificationCompat.PRIORITY_MAX); - } + builder.setPriority(NotificationCompat.PRIORITY_MAX); return builder; } diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java index 587d414a9..a5a53f7a9 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java @@ -250,7 +250,7 @@ public abstract class VideoPlayer extends BasePlayer simpleExoPlayer.addTextOutput(cues -> subtitleView.onCues(cues)); // Setup audio session with onboard equalizer - if (Build.VERSION.SDK_INT >= 21) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { trackSelector.setParameters(trackSelector.buildUponParameters() .setTunnelingAudioSessionId(C.generateAudioSessionIdV21(context))); } diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java index 9dfefec0b..05680baeb 100644 --- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java +++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayerImpl.java @@ -1925,7 +1925,7 @@ public class VideoPlayerImpl extends VideoPlayer } private int popupLayoutParamType() { - return Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O + return Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? WindowManager.LayoutParams.TYPE_PHONE : WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; } 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 2d29082f0..6667d0ecb 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 @@ -2,7 +2,6 @@ package org.schabi.newpipe.player.helper; import android.content.Context; import android.content.SharedPreferences; -import android.os.Build; import androidx.preference.PreferenceManager; import android.provider.Settings; import android.view.accessibility.CaptioningManager; @@ -303,10 +302,6 @@ public final class PlayerHelper { @NonNull public static CaptionStyleCompat getCaptionStyle(@NonNull final Context context) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - return CaptionStyleCompat.DEFAULT; - } - final CaptioningManager captioningManager = (CaptioningManager) context.getSystemService(Context.CAPTIONING_SERVICE); if (captioningManager == null || !captioningManager.isEnabled()) { @@ -331,10 +326,6 @@ public final class PlayerHelper { * @return caption scaling */ public static float getCaptionScale(@NonNull final Context context) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { - return 1f; - } - final CaptioningManager captioningManager = (CaptioningManager) context.getSystemService(Context.CAPTIONING_SERVICE); if (captioningManager == null || !captioningManager.isEnabled()) { diff --git a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java index 433fcf7ae..b83f9fd97 100644 --- a/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/report/ErrorActivity.java @@ -466,7 +466,8 @@ public class ErrorActivity extends AppCompatActivity { } private String getOsString() { - final String osBase = Build.VERSION.SDK_INT >= 23 ? Build.VERSION.BASE_OS : "Android"; + final String osBase = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M + ? Build.VERSION.BASE_OS : "Android"; return System.getProperty("os.name") + " " + (osBase.isEmpty() ? "Android" : osBase) + " " + Build.VERSION.RELEASE diff --git a/app/src/main/java/org/schabi/newpipe/util/PermissionHelper.java b/app/src/main/java/org/schabi/newpipe/util/PermissionHelper.java index ba157e6be..03400bdbb 100644 --- a/app/src/main/java/org/schabi/newpipe/util/PermissionHelper.java +++ b/app/src/main/java/org/schabi/newpipe/util/PermissionHelper.java @@ -26,10 +26,8 @@ public final class PermissionHelper { private PermissionHelper() { } public static boolean checkStoragePermissions(final Activity activity, final int requestCode) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { - if (!checkReadStoragePermissions(activity, requestCode)) { - return false; - } + if (!checkReadStoragePermissions(activity, requestCode)) { + return false; } return checkWriteStoragePermissions(activity, requestCode); } diff --git a/app/src/main/java/org/schabi/newpipe/views/FocusOverlayView.java b/app/src/main/java/org/schabi/newpipe/views/FocusOverlayView.java index 4a342784e..dc5bf7133 100644 --- a/app/src/main/java/org/schabi/newpipe/views/FocusOverlayView.java +++ b/app/src/main/java/org/schabi/newpipe/views/FocusOverlayView.java @@ -259,7 +259,7 @@ public final class FocusOverlayView extends Drawable implements // keyboard META key for moving between clusters). We have to fix this unfortunate accident // While we are at it, let's deal with touchscreenBlocksFocus too. - if (Build.VERSION.SDK_INT < 26) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { return; } diff --git a/app/src/main/java/org/schabi/newpipe/views/NewPipeRecyclerView.java b/app/src/main/java/org/schabi/newpipe/views/NewPipeRecyclerView.java index 6350f80a5..a4f7a0506 100644 --- a/app/src/main/java/org/schabi/newpipe/views/NewPipeRecyclerView.java +++ b/app/src/main/java/org/schabi/newpipe/views/NewPipeRecyclerView.java @@ -142,7 +142,7 @@ public class NewPipeRecyclerView extends RecyclerView { } private boolean tryFocusFinder(final int direction) { - if (Build.VERSION.SDK_INT >= 28) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { // Android 9 implemented bunch of handy changes to focus, that render code below less // useful, and also broke findNextFocusFromRect in way, that render this hack useless return false; diff --git a/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java b/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java index a78c0db42..828f1adaf 100755 --- a/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java +++ b/app/src/main/java/us/shandian/giga/service/DownloadManagerService.java @@ -160,7 +160,7 @@ public class DownloadManagerService extends Service { mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); - if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mNetworkStateListenerL = new ConnectivityManager.NetworkCallback() { @Override public void onAvailable(Network network) { @@ -240,7 +240,7 @@ public class DownloadManagerService extends Service { manageLock(false); - if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) mConnectivityManager.unregisterNetworkCallback(mNetworkStateListenerL); else unregisterReceiver(mNetworkStateListener); @@ -466,7 +466,7 @@ public class DownloadManagerService extends Service { if (downloadDoneCount < 1) { downloadDoneList.append(name); - if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { downloadDoneNotification.setContentTitle(getString(R.string.app_name)); } else { downloadDoneNotification.setContentTitle(null); @@ -505,7 +505,7 @@ public class DownloadManagerService extends Service { .setContentIntent(mOpenDownloadList); } - if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { downloadFailedNotification.setContentTitle(getString(R.string.app_name)); downloadFailedNotification.setStyle(new NotificationCompat.BigTextStyle() .bigText(getString(R.string.download_failed).concat(": ").concat(mission.storage.getName())));