Skip to content

Commit

Permalink
Release 0.1.32
Browse files Browse the repository at this point in the history
  • Loading branch information
kazemcodes committed Nov 12, 2022
1 parent 4999653 commit db0684c
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 21 deletions.
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/ProjectConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
37 changes: 32 additions & 5 deletions core/src/commonMain/kotlin/source/model/Page.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -20,29 +38,38 @@ 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) {
is ImageUrl -> this.url
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()) {
Expand All @@ -59,7 +86,7 @@ fun String.decode() : List<Page> {
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
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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" }
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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 ->
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -71,7 +71,7 @@ class VideoScreenViewModel(
chapter = chapter1
chapter1?.content?.let { pages ->
val movies = pages.filterIsInstance<MovieUrl>()
val subs = pages.filterIsInstance<Subtitles>()
val subs = pages.filterIsInstance<Subtitle>()
mediaState.subtitleHelper.internalSubtitles.value =
subs.map { it.toSubtitleData() }.toSet()
mediaState.subs = emptyList()
Expand Down Expand Up @@ -125,7 +125,7 @@ class VideoScreenViewModel(
fun loadMedia(chapter: Chapter?) {
val movieUrl = chapter?.content?.filterIsInstance<MovieUrl>()?.firstOrNull()?.url ?: ""
chapter?.content?.let {
val subtitles = it.filterIsInstance<Subtitles>()
val subtitles = it.filterIsInstance<Subtitle>()
mediaState.subtitleHelper.setActiveSubtitles(subtitles.map { sub ->
SubtitleData(
name = sub.url.substringBeforeLast(".").substringAfterLast("/"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -113,7 +113,7 @@ class MediaState(
else ControllerVisibility.Invisible
}
var medias = emptyList<MovieUrl>()
var subs = emptyList<Subtitles>()
var subs = emptyList<Subtitle>()

/**
* The current [visibility][ControllerVisibility] of the controller.
Expand Down Expand Up @@ -541,7 +541,7 @@ class MediaState(
var ignoreSSL = false
private fun loadOnlinePlayer(context: Context, link: List<Page>) {
val movies = link.filterIsInstance<MovieUrl>() ?: emptyList()
val subtitles = link.filterIsInstance<Subtitles>() ?: emptyList()
val subtitles = link.filterIsInstance<Subtitle>() ?: emptyList()
Log.i("TAG", "loadOnlinePlayer $link")
try {
currentLink = movies.firstOrNull()?.url
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit db0684c

Please sign in to comment.