Remove aniyomi-specific android 6/7 support

This commit is contained in:
Secozzi 2024-05-10 17:29:42 +02:00
parent b85fc16ecd
commit 5f630407e9
No known key found for this signature in database
GPG key ID: 71E9C97D8DDC2662
6 changed files with 11 additions and 39 deletions

View file

@ -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,
)

View file

@ -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",

View file

@ -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

View file

@ -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,

View file

@ -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
}
}
}

View file

@ -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!!