Clean up SDK version checks

This commit is contained in:
TacoTheDank 2020-08-27 16:59:29 -04:00 committed by Stypox
parent 6c5ef567ed
commit 06d54ef77e
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
12 changed files with 16 additions and 28 deletions

View File

@ -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;
}

View File

@ -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();

View File

@ -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();

View File

@ -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;
}

View File

@ -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)));
}

View File

@ -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;
}

View File

@ -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()) {

View File

@ -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

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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())));