1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-11-11 12:59:37 +01:00

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() { public void initNotificationChannel() {
if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
return; return;
} }

View File

@ -42,7 +42,7 @@ public class ExitActivity extends Activity {
protected void onCreate(final Bundle savedInstanceState) { protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
finishAndRemoveTask(); finishAndRemoveTask();
} else { } else {
finish(); finish();

View File

@ -40,7 +40,7 @@ public class PanicResponderActivity extends Activity {
ExitActivity.exitAndRemoveFromRecentApps(this); ExitActivity.exitAndRemoveFromRecentApps(this);
} }
if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
finishAndRemoveTask(); finishAndRemoveTask();
} else { } else {
finish(); finish();

View File

@ -310,9 +310,7 @@ public final class MainPlayer extends Service {
setLockScreenThumbnail(builder); 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; return builder;
} }

View File

@ -250,7 +250,7 @@ public abstract class VideoPlayer extends BasePlayer
simpleExoPlayer.addTextOutput(cues -> subtitleView.onCues(cues)); simpleExoPlayer.addTextOutput(cues -> subtitleView.onCues(cues));
// Setup audio session with onboard equalizer // 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() trackSelector.setParameters(trackSelector.buildUponParameters()
.setTunnelingAudioSessionId(C.generateAudioSessionIdV21(context))); .setTunnelingAudioSessionId(C.generateAudioSessionIdV21(context)));
} }

View File

@ -1925,7 +1925,7 @@ public class VideoPlayerImpl extends VideoPlayer
} }
private int popupLayoutParamType() { 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_PHONE
: WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; : WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
} }

View File

@ -2,7 +2,6 @@ package org.schabi.newpipe.player.helper;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Build;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import android.provider.Settings; import android.provider.Settings;
import android.view.accessibility.CaptioningManager; import android.view.accessibility.CaptioningManager;
@ -303,10 +302,6 @@ public final class PlayerHelper {
@NonNull @NonNull
public static CaptionStyleCompat getCaptionStyle(@NonNull final Context context) { public static CaptionStyleCompat getCaptionStyle(@NonNull final Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return CaptionStyleCompat.DEFAULT;
}
final CaptioningManager captioningManager = (CaptioningManager) final CaptioningManager captioningManager = (CaptioningManager)
context.getSystemService(Context.CAPTIONING_SERVICE); context.getSystemService(Context.CAPTIONING_SERVICE);
if (captioningManager == null || !captioningManager.isEnabled()) { if (captioningManager == null || !captioningManager.isEnabled()) {
@ -331,10 +326,6 @@ public final class PlayerHelper {
* @return caption scaling * @return caption scaling
*/ */
public static float getCaptionScale(@NonNull final Context context) { public static float getCaptionScale(@NonNull final Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return 1f;
}
final CaptioningManager captioningManager final CaptioningManager captioningManager
= (CaptioningManager) context.getSystemService(Context.CAPTIONING_SERVICE); = (CaptioningManager) context.getSystemService(Context.CAPTIONING_SERVICE);
if (captioningManager == null || !captioningManager.isEnabled()) { if (captioningManager == null || !captioningManager.isEnabled()) {

View File

@ -466,7 +466,8 @@ public class ErrorActivity extends AppCompatActivity {
} }
private String getOsString() { 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") return System.getProperty("os.name")
+ " " + (osBase.isEmpty() ? "Android" : osBase) + " " + (osBase.isEmpty() ? "Android" : osBase)
+ " " + Build.VERSION.RELEASE + " " + Build.VERSION.RELEASE

View File

@ -26,10 +26,8 @@ public final class PermissionHelper {
private PermissionHelper() { } private PermissionHelper() { }
public static boolean checkStoragePermissions(final Activity activity, final int requestCode) { public static boolean checkStoragePermissions(final Activity activity, final int requestCode) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { if (!checkReadStoragePermissions(activity, requestCode)) {
if (!checkReadStoragePermissions(activity, requestCode)) { return false;
return false;
}
} }
return checkWriteStoragePermissions(activity, requestCode); 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 // 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. // 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; return;
} }

View File

@ -142,7 +142,7 @@ public class NewPipeRecyclerView extends RecyclerView {
} }
private boolean tryFocusFinder(final int direction) { 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 // 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 // useful, and also broke findNextFocusFromRect in way, that render this hack useless
return false; return false;

View File

@ -160,7 +160,7 @@ public class DownloadManagerService extends Service {
mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mConnectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_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() { mNetworkStateListenerL = new ConnectivityManager.NetworkCallback() {
@Override @Override
public void onAvailable(Network network) { public void onAvailable(Network network) {
@ -240,7 +240,7 @@ public class DownloadManagerService extends Service {
manageLock(false); 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); mConnectivityManager.unregisterNetworkCallback(mNetworkStateListenerL);
else else
unregisterReceiver(mNetworkStateListener); unregisterReceiver(mNetworkStateListener);
@ -466,7 +466,7 @@ public class DownloadManagerService extends Service {
if (downloadDoneCount < 1) { if (downloadDoneCount < 1) {
downloadDoneList.append(name); 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)); downloadDoneNotification.setContentTitle(getString(R.string.app_name));
} else { } else {
downloadDoneNotification.setContentTitle(null); downloadDoneNotification.setContentTitle(null);
@ -505,7 +505,7 @@ public class DownloadManagerService extends Service {
.setContentIntent(mOpenDownloadList); .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.setContentTitle(getString(R.string.app_name));
downloadFailedNotification.setStyle(new NotificationCompat.BigTextStyle() downloadFailedNotification.setStyle(new NotificationCompat.BigTextStyle()
.bigText(getString(R.string.download_failed).concat(": ").concat(mission.storage.getName()))); .bigText(getString(R.string.download_failed).concat(": ").concat(mission.storage.getName())));