From 5f630407e99eb1508a165d715ee467f8b3feb1b0 Mon Sep 17 00:00:00 2001 From: Secozzi Date: Fri, 10 May 2024 17:29:42 +0200 Subject: [PATCH] Remove aniyomi-specific android 6/7 support --- .../eu/kanade/domain/base/BasePreferences.kt | 3 +- .../tachiyomi/ui/player/ExternalIntents.kt | 2 +- .../tachiyomi/ui/player/PlayerActivity.kt | 32 ++++--------------- .../player/viewer/PictureInPictureHandler.kt | 4 --- .../tachiyomi/ui/player/viewer/PlayerEnums.kt | 5 +-- .../tachiyomi/util/storage/FFmpegUtils.kt | 4 +-- 6 files changed, 11 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt b/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt index cb1665a9c..bf3e6b2fd 100644 --- a/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt +++ b/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt @@ -2,7 +2,6 @@ package eu.kanade.domain.base import android.content.Context import android.content.pm.PackageManager -import android.os.Build import dev.icerock.moko.resources.StringResource import eu.kanade.tachiyomi.util.system.isPreviewBuildType import eu.kanade.tachiyomi.util.system.isReleaseBuildType @@ -29,7 +28,7 @@ class BasePreferences( isPreviewBuildType || isReleaseBuildType, ) - fun deviceHasPip() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && context.packageManager.hasSystemFeature( + fun deviceHasPip() = context.packageManager.hasSystemFeature( PackageManager.FEATURE_PICTURE_IN_PICTURE, ) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/player/ExternalIntents.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/player/ExternalIntents.kt index 46fe22b9e..426441e76 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/player/ExternalIntents.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/player/ExternalIntents.kt @@ -124,7 +124,7 @@ class ExternalIntents { ) } - return if (isOnDevice && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && uri.scheme != "content") { + return if (isOnDevice && uri.scheme != "content") { FileProvider.getUriForFile( context, context.applicationContext.packageName + ".provider", diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerActivity.kt index a006cddc1..935c0b5a3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/player/PlayerActivity.kt @@ -28,7 +28,6 @@ import android.view.WindowManager import android.view.animation.AnimationUtils import android.widget.ImageView import androidx.activity.viewModels -import androidx.annotation.RequiresApi import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.constraintlayout.widget.ConstraintLayout @@ -230,38 +229,20 @@ class PlayerActivity : BaseActivity() { private var hasAudioFocus = false - private val audioFocusRequest = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN) - .setOnAudioFocusChangeListener(audioFocusChangeListener) - .build() - } else { - null - } + private val audioFocusRequest = AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN) + .setOnAudioFocusChangeListener(audioFocusChangeListener) + .build() - @Suppress("DEPRECATION") private fun requestAudioFocus() { if (hasAudioFocus) return hasAudioFocus = true - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - audioManager!!.requestAudioFocus(audioFocusRequest!!) - } else { - audioManager!!.requestAudioFocus( - audioFocusChangeListener, - AudioManager.STREAM_MUSIC, - AudioManager.AUDIOFOCUS_GAIN, - ) - } + audioManager!!.requestAudioFocus(audioFocusRequest!!) } - @Suppress("DEPRECATION") private fun abandonAudioFocus() { if (!hasAudioFocus) return hasAudioFocus = false - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - audioManager!!.abandonAudioFocusRequest(audioFocusRequest!!) - } else { - audioManager!!.abandonAudioFocus(audioFocusChangeListener) - } + audioManager!!.abandonAudioFocusRequest(audioFocusRequest!!) } private fun setAudioFocus(paused: Boolean) { @@ -1476,7 +1457,7 @@ class PlayerActivity : BaseActivity() { val episode = viewModel.currentEpisode ?: return val paused = player.paused ?: return val videoAspect = player.videoAspect ?: return - if (supportedAndEnabled && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + if (supportedAndEnabled) { PictureInPictureHandler().update( context = this, title = anime.title, @@ -1499,7 +1480,6 @@ class PlayerActivity : BaseActivity() { } @Deprecated("Deprecated in Java") - @RequiresApi(Build.VERSION_CODES.O) override fun onPictureInPictureModeChanged(isInPictureInPictureMode: Boolean) { PipState.mode = if (isInPictureInPictureMode) PipState.ON else PipState.OFF diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/player/viewer/PictureInPictureHandler.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/player/viewer/PictureInPictureHandler.kt index 9a758f485..5b66a75a2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/player/viewer/PictureInPictureHandler.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/player/viewer/PictureInPictureHandler.kt @@ -8,7 +8,6 @@ import android.content.Intent import android.graphics.drawable.Icon import android.os.Build import android.util.Rational -import androidx.annotation.RequiresApi import dev.icerock.moko.resources.StringResource import eu.kanade.tachiyomi.R import tachiyomi.core.i18n.stringResource @@ -16,7 +15,6 @@ import tachiyomi.i18n.MR class PictureInPictureHandler { - @RequiresApi(Build.VERSION_CODES.O) fun update( context: Context, title: String, @@ -51,7 +49,6 @@ class PictureInPictureHandler { return pictureInPictureParams.build() } - @RequiresApi(Build.VERSION_CODES.O) private fun pipActions( context: Context, paused: Boolean, @@ -106,7 +103,6 @@ class PictureInPictureHandler { ) } - @RequiresApi(Build.VERSION_CODES.O) private fun createRemoteAction( context: Context, iconResId: Int, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/player/viewer/PlayerEnums.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/player/viewer/PlayerEnums.kt index a752fea6c..f7e318ba4 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/player/viewer/PlayerEnums.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/player/viewer/PlayerEnums.kt @@ -60,16 +60,13 @@ enum class HwDecState(val title: String, val mpvValue: String) { ; companion object { - internal val isHwSupported = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O - internal val isWSA = Build.MODEL == "Subsystem for Android(TM)" || Build.BRAND == "Windows" || Build.BOARD == "windows" internal val defaultHwDec = when { isWSA -> SW - isHwSupported -> HW_PLUS - else -> HW + else -> HW_PLUS } } } diff --git a/core/src/main/java/eu/kanade/tachiyomi/util/storage/FFmpegUtils.kt b/core/src/main/java/eu/kanade/tachiyomi/util/storage/FFmpegUtils.kt index 793615903..bc649dc9a 100644 --- a/core/src/main/java/eu/kanade/tachiyomi/util/storage/FFmpegUtils.kt +++ b/core/src/main/java/eu/kanade/tachiyomi/util/storage/FFmpegUtils.kt @@ -12,7 +12,7 @@ fun String.toFFmpegString(context: Context): String { } fun Uri.toFFmpegString(context: Context): String { - return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && this.scheme == "content") { + return if (this.scheme == "content") { FFmpegKitConfig.getSafParameter(context, this, "rw") } else { this.path!! @@ -20,7 +20,7 @@ fun Uri.toFFmpegString(context: Context): String { } fun UniFile.toFFmpegString(context: Context? = null): String { - return if (context != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && this.uri.scheme == "content") { + return if (context != null && this.uri.scheme == "content") { FFmpegKitConfig.getSafParameter(context, this.uri, "rw") } else { this.filePath!!