Remove non-required API M version checks
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
parent
8415b02c03
commit
7b03a9fc8b
3 changed files with 11 additions and 22 deletions
|
|
@ -23,7 +23,6 @@ import android.graphics.Color;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
@ -1584,19 +1583,15 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
|
||||||
// make sure there is nothing left over from previous calls
|
// make sure there is nothing left over from previous calls
|
||||||
clearVideoSurface();
|
clearVideoSurface();
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // >=API23
|
surfaceHolderCallback = new SurfaceHolderCallback(context, player.getExoPlayer());
|
||||||
surfaceHolderCallback = new SurfaceHolderCallback(context, player.getExoPlayer());
|
binding.surfaceView.getHolder().addCallback(surfaceHolderCallback);
|
||||||
binding.surfaceView.getHolder().addCallback(surfaceHolderCallback);
|
|
||||||
|
|
||||||
// ensure player is using an unreleased surface, which the surfaceView might not be
|
// ensure player is using an unreleased surface, which the surfaceView might not be
|
||||||
// when starting playback on background or during player switching
|
// when starting playback on background or during player switching
|
||||||
if (binding.surfaceView.getHolder().getSurface().isValid()) {
|
if (binding.surfaceView.getHolder().getSurface().isValid()) {
|
||||||
// initially set the surface manually otherwise
|
// initially set the surface manually otherwise
|
||||||
// onRenderedFirstFrame() will not be called
|
// onRenderedFirstFrame() will not be called
|
||||||
player.getExoPlayer().setVideoSurfaceHolder(binding.surfaceView.getHolder());
|
player.getExoPlayer().setVideoSurfaceHolder(binding.surfaceView.getHolder());
|
||||||
}
|
|
||||||
} else {
|
|
||||||
player.getExoPlayer().setVideoSurfaceView(binding.surfaceView);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
surfaceIsSetup = true;
|
surfaceIsSetup = true;
|
||||||
|
|
@ -1604,8 +1599,7 @@ public abstract class VideoPlayerUi extends PlayerUi implements SeekBar.OnSeekBa
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearVideoSurface() {
|
private void clearVideoSurface() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M // >=API23
|
if (surfaceHolderCallback != null) {
|
||||||
&& surfaceHolderCallback != null) {
|
|
||||||
binding.surfaceView.getHolder().removeCallback(surfaceHolderCallback);
|
binding.surfaceView.getHolder().removeCallback(surfaceHolderCallback);
|
||||||
surfaceHolderCallback.release();
|
surfaceHolderCallback.release();
|
||||||
surfaceHolderCallback = null;
|
surfaceHolderCallback = null;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package org.schabi.newpipe.settings;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
|
|
@ -33,8 +32,7 @@ public class VideoAudioSettingsFragment extends BasePreferenceFragment {
|
||||||
// on M and above, if user chooses to minimise to popup player on exit
|
// 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,
|
// and the app doesn't have display over other apps permission,
|
||||||
// show a snackbar to let the user give permission
|
// show a snackbar to let the user give permission
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
if (getString(R.string.minimize_on_exit_key).equals(key)) {
|
||||||
&& getString(R.string.minimize_on_exit_key).equals(key)) {
|
|
||||||
final String newSetting = sharedPreferences.getString(key, null);
|
final String newSetting = sharedPreferences.getString(key, null);
|
||||||
if (newSetting != null
|
if (newSetting != null
|
||||||
&& newSetting.equals(getString(R.string.minimize_on_exit_popup_key))
|
&& newSetting.equals(getString(R.string.minimize_on_exit_popup_key))
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ import android.provider.Settings;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.RequiresApi;
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
@ -116,7 +115,6 @@ public final class PermissionHelper {
|
||||||
* @param context {@link Context}
|
* @param context {@link Context}
|
||||||
* @return {@link Settings#canDrawOverlays(Context)}
|
* @return {@link Settings#canDrawOverlays(Context)}
|
||||||
**/
|
**/
|
||||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
|
||||||
public static boolean checkSystemAlertWindowPermission(final Context context) {
|
public static boolean checkSystemAlertWindowPermission(final Context context) {
|
||||||
if (!Settings.canDrawOverlays(context)) {
|
if (!Settings.canDrawOverlays(context)) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
|
||||||
|
|
@ -174,8 +172,7 @@ public final class PermissionHelper {
|
||||||
* @return whether the popup is enabled
|
* @return whether the popup is enabled
|
||||||
*/
|
*/
|
||||||
public static boolean isPopupEnabledElseAsk(final Context context) {
|
public static boolean isPopupEnabledElseAsk(final Context context) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M
|
if (checkSystemAlertWindowPermission(context)) {
|
||||||
|| checkSystemAlertWindowPermission(context)) {
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(context, R.string.msg_popup_permission, Toast.LENGTH_LONG).show();
|
Toast.makeText(context, R.string.msg_popup_permission, Toast.LENGTH_LONG).show();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue