Skip to content

Commit

Permalink
Clean up SDK version checks
Browse files Browse the repository at this point in the history
  • Loading branch information
TacoTheDank authored and Stypox committed Sep 6, 2020
1 parent 6c5ef56 commit 06d54ef
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 28 deletions.
2 changes: 1 addition & 1 deletion app/src/main/java/org/schabi/newpipe/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ protected void initACRA() {
}

public void initNotificationChannel() {
if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/schabi/newpipe/ExitActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static void exitAndRemoveFromRecentApps(final Activity 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected void onCreate(final Bundle savedInstanceState) {
ExitActivity.exitAndRemoveFromRecentApps(this);
}

if (Build.VERSION.SDK_INT >= 21) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
finishAndRemoveTask();
} else {
finish();
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/java/org/schabi/newpipe/player/MainPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,7 @@ private NotificationCompat.Builder createNotification() {
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public void initPlayer(final boolean playOnReady) {
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)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,7 @@ private void updateWindowFlags(final int flags) {
}

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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

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;
Expand Down Expand Up @@ -303,10 +302,6 @@ public static int getTossFlingVelocity(@NonNull final Context context) {

@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()) {
Expand All @@ -331,10 +326,6 @@ public static CaptionStyleCompat getCaptionStyle(@NonNull final Context context)
* @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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ private String getAppLanguage() {
}

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private static void fixFocusHierarchy(final View decor) {
// 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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public boolean dispatchUnhandledMove(final View focused, 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
// useful, and also broke findNextFocusFromRect in way, that render this hack useless
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public void onCreate() {
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) {
Expand Down Expand Up @@ -240,7 +240,7 @@ public void onDestroy() {

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);
Expand Down Expand Up @@ -466,7 +466,7 @@ public void notifyFinishedDownload(String name) {
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);
Expand Down Expand Up @@ -505,7 +505,7 @@ public void notifyFailedDownload(DownloadMission mission) {
.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())));
Expand Down

0 comments on commit 06d54ef

Please sign in to comment.