mirror of
https://github.com/jellyfin/jellyfin-android.git
synced 2026-09-03 05:10:27 +03:00
Require Android 6 at minimum (API 23)
This commit is contained in:
committed by
Niels van Velzen
parent
13abdff1cf
commit
4622f14e1d
@@ -57,7 +57,7 @@ class NativeInterface(private val context: Context) : KoinComponent {
|
||||
val clientInfo = apiClient.clientInfo
|
||||
|
||||
buildJsonObject {
|
||||
put("deviceId", deviceInfo.id.toString())
|
||||
put("deviceId", deviceInfo.id)
|
||||
// normalize the name by removing special characters
|
||||
// and making sure it's at least 1 character long
|
||||
// otherwise the webui will fail to send it to the server
|
||||
|
||||
@@ -10,14 +10,6 @@ import android.os.Build
|
||||
* @see Build.VERSION.SDK_INT
|
||||
*/
|
||||
object AndroidVersion {
|
||||
/**
|
||||
* Checks whether the current Android version is at least Android 6 Marshmallow, API 23.
|
||||
*
|
||||
* @see Build.VERSION_CODES.M
|
||||
*/
|
||||
inline val isAtLeastM: Boolean
|
||||
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||
|
||||
/**
|
||||
* Checks whether the current Android version is at least Android 7 Nougat, API 24.
|
||||
*
|
||||
|
||||
@@ -62,10 +62,7 @@ object Constants {
|
||||
const val PLAYBACK_MANAGER_COMMAND_VOL_DOWN = "volumeDown"
|
||||
|
||||
// Notification
|
||||
val PENDING_INTENT_FLAGS = PendingIntent.FLAG_UPDATE_CURRENT or when {
|
||||
AndroidVersion.isAtLeastM -> PendingIntent.FLAG_IMMUTABLE
|
||||
else -> 0
|
||||
}
|
||||
const val PENDING_INTENT_FLAGS = PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
||||
const val MEDIA_NOTIFICATION_CHANNEL_ID = "org.jellyfin.mobile.media.NOW_PLAYING"
|
||||
const val DOWNLOAD_NOTIFICATION_CHANNEL_ID = "org.jellyfin.mobile.download.DOWNLOAD_PROGRESS"
|
||||
|
||||
|
||||
@@ -33,26 +33,24 @@ import java.util.UUID
|
||||
import kotlin.coroutines.resume
|
||||
|
||||
fun WebViewFragment.requestNoBatteryOptimizations(rootView: CoordinatorLayout) {
|
||||
if (AndroidVersion.isAtLeastM) {
|
||||
val powerManager = requireContext().getSystemService(Activity.POWER_SERVICE) as PowerManager
|
||||
if (
|
||||
!appPreferences.ignoreBatteryOptimizations &&
|
||||
!powerManager.isIgnoringBatteryOptimizations(BuildConfig.APPLICATION_ID)
|
||||
) {
|
||||
Snackbar.make(rootView, R.string.battery_optimizations_message, Snackbar.LENGTH_INDEFINITE).apply {
|
||||
setAction(android.R.string.ok) {
|
||||
try {
|
||||
val intent = Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS)
|
||||
startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Timber.e(e)
|
||||
}
|
||||
|
||||
// Ignore after the user interacted with the snackbar at least once
|
||||
appPreferences.ignoreBatteryOptimizations = true
|
||||
val powerManager = requireContext().getSystemService(Activity.POWER_SERVICE) as PowerManager
|
||||
if (
|
||||
!appPreferences.ignoreBatteryOptimizations &&
|
||||
!powerManager.isIgnoringBatteryOptimizations(BuildConfig.APPLICATION_ID)
|
||||
) {
|
||||
Snackbar.make(rootView, R.string.battery_optimizations_message, Snackbar.LENGTH_INDEFINITE).apply {
|
||||
setAction(android.R.string.ok) {
|
||||
try {
|
||||
val intent = Intent(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS)
|
||||
startActivity(intent)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
Timber.e(e)
|
||||
}
|
||||
show()
|
||||
|
||||
// Ignore after the user interacted with the snackbar at least once
|
||||
appPreferences.ignoreBatteryOptimizations = true
|
||||
}
|
||||
show()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[versions]
|
||||
# Android
|
||||
android-compileSdk = "36"
|
||||
android-minSdk = "21"
|
||||
android-minSdk = "23"
|
||||
android-targetSdk = "36"
|
||||
|
||||
# Plugins
|
||||
|
||||
Reference in New Issue
Block a user