Skip to content

Commit b84395d

Browse files
committed
Remove non-required API M version checks
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
1 parent 0b43dd2 commit b84395d

3 files changed

Lines changed: 11 additions & 22 deletions

File tree

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
@@ -24,7 +24,6 @@
2424
import android.graphics.PorterDuff;
2525
import android.graphics.PorterDuffColorFilter;
2626
import android.net.Uri;
27-
import android.os.Build;
2827
import android.os.Handler;
2928
import android.os.Looper;
3029
import android.util.Log;
@@ -1587,28 +1586,23 @@ public void setupVideoSurfaceIfNeeded() {
15871586
// make sure there is nothing left over from previous calls
15881587
clearVideoSurface();
15891588

1590-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // >=API23
1591-
surfaceHolderCallback = new SurfaceHolderCallback(context, player.getExoPlayer());
1592-
binding.surfaceView.getHolder().addCallback(surfaceHolderCallback);
1589+
surfaceHolderCallback = new SurfaceHolderCallback(context, player.getExoPlayer());
1590+
binding.surfaceView.getHolder().addCallback(surfaceHolderCallback);
15931591

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

16051600
surfaceIsSetup = true;
16061601
}
16071602
}
16081603

16091604
private void clearVideoSurface() {
1610-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M // >=API23
1611-
&& surfaceHolderCallback != null) {
1605+
if (surfaceHolderCallback != null) {
16121606
binding.surfaceView.getHolder().removeCallback(surfaceHolderCallback);
16131607
surfaceHolderCallback.release();
16141608
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)