From db0684ccbe0d221d894445c7e0505c9eedeac69f Mon Sep 17 00:00:00 2001 From: KazemM <76521159+kazemcodes@users.noreply.github.com> Date: Sat, 12 Nov 2022 18:36:47 +0330 Subject: [PATCH] Release 0.1.32 --- buildSrc/src/main/kotlin/ProjectConfig.kt | 4 +- .../commonMain/kotlin/source/model/Page.kt | 37 ++++++++++++++++--- gradle/libs.versions.toml | 4 +- .../ui/video/VideoPlayerBottomSheet.kt | 26 ++++++++++--- .../ui/video/VideoPlayerViewModel.kt | 6 +-- .../ui/video/component/core/MediaState.kt | 8 ++-- 6 files changed, 64 insertions(+), 21 deletions(-) diff --git a/buildSrc/src/main/kotlin/ProjectConfig.kt b/buildSrc/src/main/kotlin/ProjectConfig.kt index ee8ca90d1..69982ec77 100644 --- a/buildSrc/src/main/kotlin/ProjectConfig.kt +++ b/buildSrc/src/main/kotlin/ProjectConfig.kt @@ -3,7 +3,7 @@ object ProjectConfig { const val targetSdk = 29 const val compileSdk = 33 const val ndk = "21.3.6528147" - const val versionName = "0.1.31" - const val versionCode = 38 + const val versionName = "0.1.32" + const val versionCode = 39 const val applicationId = "ir.kazemcodes.infinityreader" } diff --git a/core/src/commonMain/kotlin/source/model/Page.kt b/core/src/commonMain/kotlin/source/model/Page.kt index c491919c1..0cdff802e 100644 --- a/core/src/commonMain/kotlin/source/model/Page.kt +++ b/core/src/commonMain/kotlin/source/model/Page.kt @@ -8,7 +8,25 @@ sealed class Page @Serializable data class PageUrl(val url: String) : Page() @Serializable -sealed class PageComplete : Page() +sealed class PageComplete : Page() { + companion object { + + } + +} +data class Quality(val quality: String) { + companion object { + const val UNSPECIFIC = -1 + const val QUALITY_360 = 360 + const val QUALITY_480 = 480 + const val QUALITY_720 = 720 + const val QUALITY_1080 = 1080 + const val QUALITY_1440 = 1440 + const val QUALITY_2K = 2000 + const val QUALITY_4K = 4000 + const val QUALITY_8K = 8000 + } +} @Serializable data class ImageUrl(val url: String) : PageComplete() @@ -20,21 +38,30 @@ data class Text(val text: String) : PageComplete() // need to add a listOf string for subtitles @Serializable data class MovieUrl(val url: String) : PageComplete() + +//@Serializable +//data class MovieUrl(val url: String,val name : String? = null, val quality: Int = Quality.UNSPECIFIC, val id: Long = -1) : PageComplete() @Serializable -data class Subtitles(val url: String) : PageComplete() +data class Subtitle(val url: String) : PageComplete() + +//@Serializable +//data class Subtitle(val url: String, val language: String, val name: String? = null) : PageComplete() // creating a customized encoding and decoding because kotlin serialization may cause some problem in future. // Unlike tachiyomi, right now ireader is using saving files in app db const val SEPARATOR = "##$$%%@@" const val EQUAL = "##$$@@" + + + fun Page.encode() :String { val type = when(this) { is ImageUrl -> "image" is ImageBase64 -> "image64" is Text -> "text" is MovieUrl -> "movie" - is Subtitles -> "subtitles" + is Subtitle -> "subtitles" is PageUrl -> "page" } val key = when(this) { @@ -42,7 +69,7 @@ fun Page.encode() :String { is ImageBase64 -> this.data is Text -> this.text is MovieUrl -> this.url - is Subtitles -> this.url + is Subtitle -> this.url is PageUrl -> this.url } if(key.isBlank()) { @@ -59,7 +86,7 @@ fun String.decode() : List { type.contains("image64",true) -> ImageBase64(key) type.contains("text" ,true) -> Text(key) type.contains("movie" ,true) -> MovieUrl(key) - type.contains("subtitles",true) -> Subtitles(key) + type.contains("subtitles",true) -> Subtitle(key) type.contains("page",true) -> PageUrl(key) else -> null } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 534b1979a..0667d50c5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -104,7 +104,7 @@ sqldelight-android-paging = { module = "com.squareup.sqldelight:android-paging3- detekt = { module = "com.twitter.compose.rules:detekt", version.ref = "detekt" } requerySqlite = "com.github.requery:sqlite-android:3.36.0" -androidSqlite = "androidx.sqlite:sqlite-framework:2.3.0-alpha01" +androidSqlite = "androidx.sqlite:sqlite-framework:2.1.0" exoplayer-core = { module = "androidx.media3:media3-exoplayer", version.ref = "exoplayer" } exoplayer-ui = { module = "androidx.media3:media3-ui", version.ref = "exoplayer" } @@ -131,7 +131,7 @@ ireader = ["ireader-ktorCore", "ireader-ktorContentNegotiation","ireader-ktorSer ideaExt = { id = "org.jetbrains.gradle.plugin.idea-ext", version.ref = "ideaExt" } -jetbrainCompose = { id = "org.jetbrains.compose", version = "1.2.0" } +jetbrainCompose = { id = "org.jetbrains.compose", version = "1.2.1" } vanniktech = { id = "com.vanniktech.maven.publish", version = "0.21.0" } dependencyAnalysis = { id = "com.autonomousapps.dependency-analysis", version = "1.13.1" } diff --git a/presentation/src/main/java/ireader/presentation/ui/video/VideoPlayerBottomSheet.kt b/presentation/src/main/java/ireader/presentation/ui/video/VideoPlayerBottomSheet.kt index 772e0bc90..6aae9beca 100644 --- a/presentation/src/main/java/ireader/presentation/ui/video/VideoPlayerBottomSheet.kt +++ b/presentation/src/main/java/ireader/presentation/ui/video/VideoPlayerBottomSheet.kt @@ -1,5 +1,7 @@ package ireader.presentation.ui.video +import android.content.Intent +import android.net.Uri import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize @@ -10,13 +12,15 @@ import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalUriHandler import androidx.lifecycle.lifecycleScope import com.anggrayudi.storage.file.getAbsolutePath import ireader.core.source.model.MovieUrl -import ireader.core.source.model.Subtitles +import ireader.core.source.model.Subtitle import ireader.domain.utils.extensions.* import ireader.i18n.UiText import ireader.presentation.ui.component.Controller +import ireader.presentation.ui.component.components.component.PreferenceRow import ireader.presentation.ui.video.bottomsheet.audioTracksComposable import ireader.presentation.ui.video.bottomsheet.loadLocalFileComposable import ireader.presentation.ui.video.bottomsheet.playBackSpeedComposable @@ -36,13 +40,22 @@ fun VideoPlayerBottomSheet( ) { val scope = rememberCoroutineScope() val context = LocalContext.current - + val uriHandler = LocalUriHandler.current Box( modifier = Modifier .fillMaxSize() .background(Color.White), ) { LazyColumn { + item { + PreferenceRow(title = "Open in external app", onClick = { + + (vm.mediaState.currentLink ?: vm.mediaState.currentDownloadedFile)?.let { + val webIntent: Intent = Intent(Intent.ACTION_VIEW, Uri.parse(it)) + context.startActivity(webIntent) + } + }) + } playBackSpeedComposable(playerState) { playerState.playbackSpeed = it vm.player?.value?.setPlaybackSpeed(it) @@ -58,7 +71,10 @@ fun VideoPlayerBottomSheet( } vm.showSnackBar(UiText.DynamicString("Audio Tracks: $it.")) } - subtitleSelectorComposable(playerState, mediaState.activeSubtitles.value) { subtitleData -> + subtitleSelectorComposable( + playerState, + mediaState.activeSubtitles.value + ) { subtitleData -> playerState.currentSubtitle = subtitleData mediaState.setPreferredSubtitles(subtitleData).let { result -> @@ -101,8 +117,8 @@ fun VideoPlayerBottomSheet( context.findComponentActivity()?.lifecycleScope?.launchIO { val file = files.first() val path = file.getAbsolutePath(context) - val sub = Subtitles(path).toSubtitleData() - val subs = mediaState.activeSubtitles.value + listOf(sub) + val sub = Subtitle(path).toSubtitleData() + val subs = mediaState.activeSubtitles.value + listOf(sub) withUIContext { mediaState.saveData() mediaState.setActiveSubtitles(subs) diff --git a/presentation/src/main/java/ireader/presentation/ui/video/VideoPlayerViewModel.kt b/presentation/src/main/java/ireader/presentation/ui/video/VideoPlayerViewModel.kt index 182ffad69..8152d4f9f 100644 --- a/presentation/src/main/java/ireader/presentation/ui/video/VideoPlayerViewModel.kt +++ b/presentation/src/main/java/ireader/presentation/ui/video/VideoPlayerViewModel.kt @@ -11,7 +11,7 @@ import ireader.core.http.HttpClients import ireader.core.log.Log import ireader.core.source.HttpSource import ireader.core.source.model.MovieUrl -import ireader.core.source.model.Subtitles +import ireader.core.source.model.Subtitle import ireader.domain.catalogs.interactor.GetLocalCatalog import ireader.domain.models.entities.CatalogLocal import ireader.domain.usecases.files.GetSimpleStorage @@ -71,7 +71,7 @@ class VideoScreenViewModel( chapter = chapter1 chapter1?.content?.let { pages -> val movies = pages.filterIsInstance() - val subs = pages.filterIsInstance() + val subs = pages.filterIsInstance() mediaState.subtitleHelper.internalSubtitles.value = subs.map { it.toSubtitleData() }.toSet() mediaState.subs = emptyList() @@ -125,7 +125,7 @@ class VideoScreenViewModel( fun loadMedia(chapter: Chapter?) { val movieUrl = chapter?.content?.filterIsInstance()?.firstOrNull()?.url ?: "" chapter?.content?.let { - val subtitles = it.filterIsInstance() + val subtitles = it.filterIsInstance() mediaState.subtitleHelper.setActiveSubtitles(subtitles.map { sub -> SubtitleData( name = sub.url.substringBeforeLast(".").substringAfterLast("/"), diff --git a/presentation/src/main/java/ireader/presentation/ui/video/component/core/MediaState.kt b/presentation/src/main/java/ireader/presentation/ui/video/component/core/MediaState.kt index f5520d16e..3daa02a51 100644 --- a/presentation/src/main/java/ireader/presentation/ui/video/component/core/MediaState.kt +++ b/presentation/src/main/java/ireader/presentation/ui/video/component/core/MediaState.kt @@ -33,7 +33,7 @@ import ireader.core.source.HttpSource import ireader.core.source.model.ImageUrl import ireader.core.source.model.MovieUrl import ireader.core.source.model.Page -import ireader.core.source.model.Subtitles +import ireader.core.source.model.Subtitle import ireader.presentation.imageloader.coil.image_loaders.convertToOkHttpRequest import ireader.presentation.ui.video.component.cores.* import ireader.presentation.ui.video.component.cores.PlayerSubtitleHelper.Companion.toSubtitleMimeType @@ -113,7 +113,7 @@ class MediaState( else ControllerVisibility.Invisible } var medias = emptyList() - var subs = emptyList() + var subs = emptyList() /** * The current [visibility][ControllerVisibility] of the controller. @@ -541,7 +541,7 @@ class MediaState( var ignoreSSL = false private fun loadOnlinePlayer(context: Context, link: List) { val movies = link.filterIsInstance() ?: emptyList() - val subtitles = link.filterIsInstance() ?: emptyList() + val subtitles = link.filterIsInstance() ?: emptyList() Log.i("TAG", "loadOnlinePlayer $link") try { currentLink = movies.firstOrNull()?.url @@ -714,7 +714,7 @@ private val Painter.aspectRatio } -fun Subtitles.toSubtitleData() : SubtitleData { +fun Subtitle.toSubtitleData() : SubtitleData { val origin = if (url.contains("http")) { SubtitleOrigin.URL } else {