diff --git a/anilist/src/commonMain/kotlin/dev/datlag/aniflow/anilist/common/ExtendApollo.kt b/anilist/src/commonMain/kotlin/dev/datlag/aniflow/anilist/common/ExtendApollo.kt index 053eb06..8be24c8 100644 --- a/anilist/src/commonMain/kotlin/dev/datlag/aniflow/anilist/common/ExtendApollo.kt +++ b/anilist/src/commonMain/kotlin/dev/datlag/aniflow/anilist/common/ExtendApollo.kt @@ -63,4 +63,8 @@ fun Optional.Companion.presentIfNot(predicate: Boolean, value: V) = if (pred present(value) } -fun Optional.Companion.presentAsList(vararg value: V) = present(persistentListOf(*value)) \ No newline at end of file +fun Optional.Companion.presentAsList(vararg value: V) = if (value.isEmpty()) { + absent() +} else { + present(persistentListOf(*value)) +} \ No newline at end of file diff --git a/composeApp/src/androidMain/kotlin/dev/datlag/aniflow/other/BurningSeriesResolver.android.kt b/composeApp/src/androidMain/kotlin/dev/datlag/aniflow/other/BurningSeriesResolver.android.kt index f1471e3..8b7a531 100644 --- a/composeApp/src/androidMain/kotlin/dev/datlag/aniflow/other/BurningSeriesResolver.android.kt +++ b/composeApp/src/androidMain/kotlin/dev/datlag/aniflow/other/BurningSeriesResolver.android.kt @@ -3,6 +3,7 @@ package dev.datlag.aniflow.other import android.content.ContentProviderClient import android.content.ContentResolver import android.content.Context +import android.content.pm.PackageInfo import android.content.pm.PackageManager import android.net.Uri import android.os.Build @@ -26,15 +27,28 @@ actual class BurningSeriesResolver( constructor(context: Context) : this(context.packageManager, context.contentResolver) - actual val isAvailable: Boolean - get() = scopeCatching { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - packageManager.getApplicationInfo(packageName, PackageManager.ApplicationInfoFlags.of(0)) + private val packageInfo: PackageInfo? = scopeCatching { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + packageManager.getPackageInfo(packageName, PackageManager.PackageInfoFlags.of(0)) + } else { + packageManager.getPackageInfo(packageName, 0) + } + }.getOrNull() + + @Suppress("DEPRECATION") + actual val versionCode: Int + get() { + return (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + packageInfo?.longVersionCode?.toInt() ?: packageInfo?.versionCode } else { - packageManager.getApplicationInfo(packageName, 0) - } - true - }.getOrNull() ?: false + packageInfo?.versionCode + }) ?: -1 + } + + actual val versionName: String? = packageInfo?.versionName?.ifBlank { null } + + actual val isAvailable: Boolean + get() = packageInfo != null actual fun resolveWatchedEpisodes(): ImmutableSet { if (episodeClient == null) { diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/other/BurningSeriesResolver.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/other/BurningSeriesResolver.kt index 1d0fae6..479ad20 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/other/BurningSeriesResolver.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/other/BurningSeriesResolver.kt @@ -4,6 +4,9 @@ import kotlinx.collections.immutable.ImmutableSet expect class BurningSeriesResolver { val isAvailable: Boolean + val versionCode: Int + val versionName: String? + fun resolveWatchedEpisodes(): ImmutableSet fun resolveByName(english: String?, romaji: String?): ImmutableSet fun resolveByName(value: String): ImmutableSet diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/component/CollapsingToolbar.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/component/CollapsingToolbar.kt index 3a01b7a..de99bb9 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/component/CollapsingToolbar.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/component/CollapsingToolbar.kt @@ -10,6 +10,7 @@ import androidx.compose.material.icons.automirrored.filled.MenuBook import androidx.compose.material.icons.automirrored.rounded.MenuBook import androidx.compose.material.icons.filled.AccountCircle import androidx.compose.material.icons.filled.PlayCircleFilled +import androidx.compose.material.icons.rounded.PlayCircleFilled import androidx.compose.material3.* import androidx.compose.runtime.* import androidx.compose.ui.Alignment @@ -154,7 +155,7 @@ fun CollapsingToolbar( enabled = isManga ) { Icon( - imageVector = Icons.Filled.PlayCircleFilled, + imageVector = Icons.Rounded.PlayCircleFilled, contentDescription = null, tint = if (isManga) { LocalContentColor.current diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/MediumComponent.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/MediumComponent.kt index b86f223..bb0e268 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/MediumComponent.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/MediumComponent.kt @@ -61,6 +61,8 @@ interface MediumComponent : ContentHolderComponent { val dialog: Value> val bsAvailable: Boolean + val bsVersionCode: Int + val bsVersionName: String? val bsOptions: Flow> fun back() diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/MediumScreenComponent.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/MediumScreenComponent.kt index a7e4d38..db6d3be 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/MediumScreenComponent.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/MediumScreenComponent.kt @@ -200,6 +200,12 @@ class MediumScreenComponent( override val bsAvailable: Boolean get() = burningSeriesResolver.isAvailable + override val bsVersionCode: Int + get() = burningSeriesResolver.versionCode + + override val bsVersionName: String? + get() = burningSeriesResolver.versionName + @OptIn(ExperimentalCoroutinesApi::class) private val bsDefaultOptions = title.mapLatest { burningSeriesResolver.resolveByName(it.english, it.romaji) diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/component/BSDialog.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/component/BSDialog.kt index e4b6bcb..4e0d8d4 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/component/BSDialog.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/component/BSDialog.kt @@ -1,5 +1,7 @@ package dev.datlag.aniflow.ui.navigation.screen.medium.component +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.material3.* @@ -26,6 +28,8 @@ import kotlinx.coroutines.flow.StateFlow @Composable fun BSDialog( state: UseCaseState, + bsVersionCode: Int, + bsVersionName: String?, bsOptions: ImmutableCollection, onSearch: suspend (String) -> Unit ) { @@ -58,20 +62,28 @@ fun BSDialog( onSearch(value) } - OutlinedTextField( + Column( modifier = Modifier.fillMaxWidth().padding(horizontal = 24.dp), - value = value, - onValueChange = { value = it }, - placeholder = { - Text( - modifier = Modifier.fillMaxWidth(), - text = stringResource(SharedRes.strings.search), - textAlign = TextAlign.Center - ) - }, - shape = MaterialTheme.shapes.medium, - textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Center) - ) + verticalArrangement = Arrangement.spacedBy(8.dp) + ) { + OutlinedTextField( + modifier = Modifier.fillMaxWidth(), + value = value, + onValueChange = { value = it }, + placeholder = { + Text( + modifier = Modifier.fillMaxWidth(), + text = stringResource(SharedRes.strings.search), + textAlign = TextAlign.Center + ) + }, + shape = MaterialTheme.shapes.medium, + textStyle = LocalTextStyle.current.copy(textAlign = TextAlign.Center) + ) + if (bsVersionCode < 600) { + Text(text = stringResource(SharedRes.strings.bs_version_requirement)) + } + } } ) } \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/component/FABContent.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/component/FABContent.kt index b280a3d..62c1c29 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/component/FABContent.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/component/FABContent.kt @@ -81,6 +81,8 @@ fun FABContent( BSDialog( state = bsState, + bsVersionCode = component.bsVersionCode, + bsVersionName = component.bsVersionName, bsOptions = bsOptions, onSearch = component::searchBS ) diff --git a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/component/TrailerSection.kt b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/component/TrailerSection.kt index 4ac6efb..9f346a0 100644 --- a/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/component/TrailerSection.kt +++ b/composeApp/src/commonMain/kotlin/dev/datlag/aniflow/ui/navigation/screen/medium/component/TrailerSection.kt @@ -4,6 +4,7 @@ import androidx.compose.foundation.Image import androidx.compose.foundation.layout.* import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.PlayCircleFilled +import androidx.compose.material.icons.rounded.PlayCircleFilled import androidx.compose.material3.* import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue @@ -76,7 +77,7 @@ fun TrailerSection( } else { Icon( modifier = Modifier.size(48.dp), - imageVector = Icons.Filled.PlayCircleFilled, + imageVector = Icons.Rounded.PlayCircleFilled, contentDescription = null ) } diff --git a/composeApp/src/commonMain/moko-resources/base/strings.xml b/composeApp/src/commonMain/moko-resources/base/strings.xml index 605f45a..81a136a 100644 --- a/composeApp/src/commonMain/moko-resources/base/strings.xml +++ b/composeApp/src/commonMain/moko-resources/base/strings.xml @@ -112,11 +112,10 @@ Read Chapter Search Anime Search Manga - Top 100 - Top Movies Spring Summer Fall Winter Recommendation + This feature will be supported with Burning-Series version 6.0.0 and upwards. diff --git a/composeApp/src/commonMain/moko-resources/de-DE/strings.xml b/composeApp/src/commonMain/moko-resources/de-DE/strings.xml index 74939de..e0585fb 100644 --- a/composeApp/src/commonMain/moko-resources/de-DE/strings.xml +++ b/composeApp/src/commonMain/moko-resources/de-DE/strings.xml @@ -112,4 +112,10 @@ Gelesenes Kapitel Anime suchen Manga suchen + Frühling + Sommer + Herbst + Winter + Empfehlung + Diese Option wird mit Burning-Series Version 6.0.0 und höher unterstützt. diff --git a/composeApp/src/iosMain/kotlin/dev/datlag/aniflow/other/BurningSeriesResolver.ios.kt b/composeApp/src/iosMain/kotlin/dev/datlag/aniflow/other/BurningSeriesResolver.ios.kt index 6c20c33..2aa259e 100644 --- a/composeApp/src/iosMain/kotlin/dev/datlag/aniflow/other/BurningSeriesResolver.ios.kt +++ b/composeApp/src/iosMain/kotlin/dev/datlag/aniflow/other/BurningSeriesResolver.ios.kt @@ -8,6 +8,9 @@ actual class BurningSeriesResolver { actual val isAvailable: Boolean get() = false + actual val versionCode: Int = -1 + actual val versionName: String? = null + actual fun resolveWatchedEpisodes(): ImmutableSet { // ToDo("Check if something like content provider exists") return persistentSetOf()