Skip to content

Commit 0533326

Browse files
authored
Merge pull request #13441 from TeamNewPipe/apiMChanges
Remove non-required API M version checks
2 parents 5836f3a + c4a6bdd commit 0533326

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

app/src/main/java/org/schabi/newpipe/player/ui/VideoPlayerUi.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import android.graphics.PorterDuff;
2424
import android.graphics.PorterDuffColorFilter;
2525
import android.net.Uri;
26-
import android.os.Build;
2726
import android.os.Handler;
2827
import android.os.Looper;
2928
import android.util.Log;
@@ -1584,28 +1583,23 @@ public void setupVideoSurfaceIfNeeded() {
15841583
// make sure there is nothing left over from previous calls
15851584
clearVideoSurface();
15861585

1587-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // >=API23
1588-
surfaceHolderCallback = new SurfaceHolderCallback(context, player.getExoPlayer());
1589-
binding.surfaceView.getHolder().addCallback(surfaceHolderCallback);
1586+
surfaceHolderCallback = new SurfaceHolderCallback(context, player.getExoPlayer());
1587+
binding.surfaceView.getHolder().addCallback(surfaceHolderCallback);
15901588

1591-
// ensure player is using an unreleased surface, which the surfaceView might not be
1592-
// when starting playback on background or during player switching
1593-
if (binding.surfaceView.getHolder().getSurface().isValid()) {
1594-
// initially set the surface manually otherwise
1595-
// onRenderedFirstFrame() will not be called
1596-
player.getExoPlayer().setVideoSurfaceHolder(binding.surfaceView.getHolder());
1597-
}
1598-
} else {
1599-
player.getExoPlayer().setVideoSurfaceView(binding.surfaceView);
1589+
// ensure player is using an unreleased surface, which the surfaceView might not be
1590+
// when starting playback on background or during player switching
1591+
if (binding.surfaceView.getHolder().getSurface().isValid()) {
1592+
// initially set the surface manually otherwise
1593+
// onRenderedFirstFrame() will not be called
1594+
player.getExoPlayer().setVideoSurfaceHolder(binding.surfaceView.getHolder());
16001595
}
16011596

16021597
surfaceIsSetup = true;
16031598
}
16041599
}
16051600

16061601
private void clearVideoSurface() {
1607-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M // >=API23
1608-
&& surfaceHolderCallback != null) {
1602+
if (surfaceHolderCallback != null) {
16091603
binding.surfaceView.getHolder().removeCallback(surfaceHolderCallback);
16101604
surfaceHolderCallback.release();
16111605
surfaceHolderCallback = null;

app/src/main/java/org/schabi/newpipe/settings/VideoAudioSettingsFragment.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import android.content.SharedPreferences;
44
import android.content.res.Resources;
5-
import android.os.Build;
65
import android.os.Bundle;
76
import android.provider.Settings;
87
import android.text.format.DateUtils;
@@ -33,8 +32,7 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro
3332
// on M and above, if user chooses to minimise to popup player on exit
3433
// and the app doesn't have display over other apps permission,
3534
// show a snackbar to let the user give permission
36-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
37-
&& getString(R.string.minimize_on_exit_key).equals(key)) {
35+
if (getString(R.string.minimize_on_exit_key).equals(key)) {
3836
final String newSetting = sharedPreferences.getString(key, null);
3937
if (newSetting != null
4038
&& newSetting.equals(getString(R.string.minimize_on_exit_popup_key))

app/src/main/java/org/schabi/newpipe/util/PermissionHelper.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import android.text.Html;
1313
import android.widget.Toast;
1414

15-
import androidx.annotation.RequiresApi;
1615
import androidx.appcompat.app.AlertDialog;
1716
import androidx.core.app.ActivityCompat;
1817
import androidx.core.content.ContextCompat;
@@ -116,7 +115,6 @@ public static boolean checkPostNotificationsPermission(final Activity activity,
116115
* @param context {@link Context}
117116
* @return {@link Settings#canDrawOverlays(Context)}
118117
**/
119-
@RequiresApi(api = Build.VERSION_CODES.M)
120118
public static boolean checkSystemAlertWindowPermission(final Context context) {
121119
if (!Settings.canDrawOverlays(context)) {
122120
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
@@ -174,8 +172,7 @@ public static boolean checkSystemAlertWindowPermission(final Context context) {
174172
* @return whether the popup is enabled
175173
*/
176174
public static boolean isPopupEnabledElseAsk(final Context context) {
177-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
178-
|| checkSystemAlertWindowPermission(context)) {
175+
if (checkSystemAlertWindowPermission(context)) {
179176
return true;
180177
} else {
181178
Toast.makeText(context, R.string.msg_popup_permission, Toast.LENGTH_LONG).show();

0 commit comments

Comments
 (0)