Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions app/src/main/java/org/schabi/newpipe/player/ui/VideoPlayerUi.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
Expand Down Expand Up @@ -1584,28 +1583,23 @@ public void setupVideoSurfaceIfNeeded() {
// make sure there is nothing left over from previous calls
clearVideoSurface();

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // >=API23
surfaceHolderCallback = new SurfaceHolderCallback(context, player.getExoPlayer());
binding.surfaceView.getHolder().addCallback(surfaceHolderCallback);
surfaceHolderCallback = new SurfaceHolderCallback(context, player.getExoPlayer());
binding.surfaceView.getHolder().addCallback(surfaceHolderCallback);

// ensure player is using an unreleased surface, which the surfaceView might not be
// when starting playback on background or during player switching
if (binding.surfaceView.getHolder().getSurface().isValid()) {
// initially set the surface manually otherwise
// onRenderedFirstFrame() will not be called
player.getExoPlayer().setVideoSurfaceHolder(binding.surfaceView.getHolder());
}
} else {
player.getExoPlayer().setVideoSurfaceView(binding.surfaceView);
// ensure player is using an unreleased surface, which the surfaceView might not be
// when starting playback on background or during player switching
if (binding.surfaceView.getHolder().getSurface().isValid()) {
// initially set the surface manually otherwise
// onRenderedFirstFrame() will not be called
player.getExoPlayer().setVideoSurfaceHolder(binding.surfaceView.getHolder());
}

surfaceIsSetup = true;
}
}

private void clearVideoSurface() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M // >=API23
&& surfaceHolderCallback != null) {
if (surfaceHolderCallback != null) {
binding.surfaceView.getHolder().removeCallback(surfaceHolderCallback);
surfaceHolderCallback.release();
surfaceHolderCallback = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import android.content.SharedPreferences;
import android.content.res.Resources;
import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.text.format.DateUtils;
Expand Down Expand Up @@ -33,8 +32,7 @@ public void onCreatePreferences(final Bundle savedInstanceState, final String ro
// on M and above, if user chooses to minimise to popup player on exit
// and the app doesn't have display over other apps permission,
// show a snackbar to let the user give permission
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& getString(R.string.minimize_on_exit_key).equals(key)) {
if (getString(R.string.minimize_on_exit_key).equals(key)) {
final String newSetting = sharedPreferences.getString(key, null);
if (newSetting != null
&& newSetting.equals(getString(R.string.minimize_on_exit_popup_key))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import android.text.Html;
import android.widget.Toast;

import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AlertDialog;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
Expand Down Expand Up @@ -116,7 +115,6 @@ public static boolean checkPostNotificationsPermission(final Activity activity,
* @param context {@link Context}
* @return {@link Settings#canDrawOverlays(Context)}
**/
@RequiresApi(api = Build.VERSION_CODES.M)
public static boolean checkSystemAlertWindowPermission(final Context context) {
if (!Settings.canDrawOverlays(context)) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
Expand Down Expand Up @@ -174,8 +172,7 @@ public static boolean checkSystemAlertWindowPermission(final Context context) {
* @return whether the popup is enabled
*/
public static boolean isPopupEnabledElseAsk(final Context context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|| checkSystemAlertWindowPermission(context)) {
if (checkSystemAlertWindowPermission(context)) {
return true;
} else {
Toast.makeText(context, R.string.msg_popup_permission, Toast.LENGTH_LONG).show();
Expand Down
Loading