Merge Mihon 0.21.2 updates and use BookOasis updater
Build & Test / Build & Test App (push) Has been cancelled
Release / Extract tag name (push) Has been cancelled
Update website / update_website (release) Has been cancelled
Release / Build (push) Has been cancelled
Release / Build (FOSS) (push) Has been cancelled
Release / Create GitHub Release (push) Has been cancelled
Build & Test / Build & Test App (push) Has been cancelled
Release / Extract tag name (push) Has been cancelled
Update website / update_website (release) Has been cancelled
Release / Build (push) Has been cancelled
Release / Build (FOSS) (push) Has been cancelled
Release / Create GitHub Release (push) Has been cancelled
This commit is contained in:
+119
-26
@@ -1,11 +1,14 @@
|
||||
import com.android.build.api.variant.ApplicationVariant
|
||||
import com.android.build.api.variant.BuildConfigField
|
||||
import com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension
|
||||
import mihon.gradle.Config
|
||||
import mihon.gradle.getBuildTime
|
||||
import mihon.gradle.getCurrentTime
|
||||
import mihon.gradle.getLatestCommitCount
|
||||
import mihon.gradle.getLatestCommitSha
|
||||
import mihon.gradle.getLatestCommitTime
|
||||
import mihon.gradle.tasks.ReplaceShortcutsPlaceholderTask
|
||||
import java.io.FileInputStream
|
||||
import java.util.Properties
|
||||
import kotlin.io.encoding.Base64
|
||||
|
||||
plugins {
|
||||
alias(mihonx.plugins.android.application)
|
||||
@@ -16,6 +19,7 @@ plugins {
|
||||
alias(libs.plugins.aboutLibraries)
|
||||
alias(libs.plugins.androidx.baselineProfile)
|
||||
alias(libs.plugins.kotlin.serialization)
|
||||
alias(libs.plugins.apollo)
|
||||
}
|
||||
|
||||
if (Config.includeTelemetry) {
|
||||
@@ -25,7 +29,7 @@ if (Config.includeTelemetry) {
|
||||
}
|
||||
}
|
||||
|
||||
val keystorePropertiesFile = rootProject.file("keystore.properties")
|
||||
val keystorePropertiesFile = layout.settingsDirectory.file("keystore.properties").asFile
|
||||
|
||||
android {
|
||||
namespace = "eu.kanade.tachiyomi"
|
||||
@@ -33,12 +37,9 @@ android {
|
||||
defaultConfig {
|
||||
applicationId = "app.mihon"
|
||||
|
||||
versionCode = 31
|
||||
versionName = "0.20.5"
|
||||
versionCode = 38
|
||||
versionName = "0.21.2-bookoasis-r15"
|
||||
|
||||
buildConfigField("String", "COMMIT_COUNT", "\"${getLatestCommitCount()}\"")
|
||||
buildConfigField("String", "COMMIT_SHA", "\"${getLatestCommitSha()}\"")
|
||||
buildConfigField("String", "BUILD_TIME", "\"${getBuildTime(useLatestCommitTime = false)}\"")
|
||||
buildConfigField("boolean", "TELEMETRY_INCLUDED", "${Config.includeTelemetry}")
|
||||
buildConfigField("boolean", "UPDATER_ENABLED", "${Config.enableUpdater}")
|
||||
|
||||
@@ -46,14 +47,9 @@ android {
|
||||
}
|
||||
|
||||
if (System.getenv("MIHON_GITHUB_RELEASE").toBoolean()) {
|
||||
val tempStoreFile = file(System.getenv("RUNNER_TEMP")).resolve("antsy.keystore")
|
||||
|
||||
val storeFileBytes = System.getenv("storeFileBase64").let(Base64::decode)
|
||||
tempStoreFile.outputStream().use { it.write(storeFileBytes) }
|
||||
|
||||
signingConfigs {
|
||||
named("debug") {
|
||||
storeFile = tempStoreFile
|
||||
storeFile = file(System.getenv("storeFile"))
|
||||
storePassword = System.getenv("storePassword")
|
||||
keyAlias = System.getenv("keyAlias")
|
||||
keyPassword = System.getenv("keyPassword")
|
||||
@@ -75,7 +71,6 @@ android {
|
||||
buildTypes {
|
||||
val debug = getByName("debug") {
|
||||
applicationIdSuffix = ".dev"
|
||||
versionNameSuffix = "-${getLatestCommitCount()}"
|
||||
isPseudoLocalesEnabled = true
|
||||
}
|
||||
val release = getByName("release") {
|
||||
@@ -87,8 +82,6 @@ android {
|
||||
isProfileable = true
|
||||
|
||||
proguardFiles("proguard-android-optimize.txt", "proguard-rules.pro")
|
||||
|
||||
buildConfigField("String", "BUILD_TIME", "\"${getBuildTime(useLatestCommitTime = true)}\"")
|
||||
}
|
||||
|
||||
val commonMatchingFallbacks = listOf(release.name)
|
||||
@@ -105,11 +98,7 @@ android {
|
||||
|
||||
applicationIdSuffix = ".debug"
|
||||
|
||||
versionNameSuffix = debug.versionNameSuffix
|
||||
|
||||
matchingFallbacks.addAll(commonMatchingFallbacks)
|
||||
|
||||
buildConfigField("String", "BUILD_TIME", "\"${getBuildTime(useLatestCommitTime = false)}\"")
|
||||
}
|
||||
create("benchmark") {
|
||||
initWith(release)
|
||||
@@ -119,6 +108,14 @@ android {
|
||||
|
||||
matchingFallbacks.addAll(commonMatchingFallbacks)
|
||||
}
|
||||
|
||||
if (Config.includeTelemetry) {
|
||||
configureEach {
|
||||
configure<CrashlyticsExtension> {
|
||||
mappingFileUploadEnabled = Config.uploadCrashlyticsMapping
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
@@ -208,6 +205,7 @@ dependencies {
|
||||
baselineProfile(projects.baselineProfile)
|
||||
|
||||
implementation(projects.i18n)
|
||||
implementation(projects.icons.customMaterialSymbols)
|
||||
implementation(projects.icons.materialSymbols)
|
||||
implementation(projects.icons.simpleIcons)
|
||||
implementation(projects.core.archive)
|
||||
@@ -216,7 +214,6 @@ dependencies {
|
||||
implementation(projects.coreMetadata)
|
||||
implementation(projects.sourceApi)
|
||||
implementation(projects.sourceLocal)
|
||||
implementation(libs.jsoup)
|
||||
implementation(projects.data)
|
||||
implementation(projects.domain)
|
||||
implementation(projects.presentationCore)
|
||||
@@ -232,20 +229,17 @@ dependencies {
|
||||
debugImplementation(libs.androidx.compose.uiTooling)
|
||||
implementation(libs.androidx.compose.uiToolingPreview)
|
||||
implementation(libs.androidx.compose.uiUtil)
|
||||
implementation(libs.androidx.navigationEvent)
|
||||
|
||||
implementation(libs.androidx.interpolator)
|
||||
|
||||
implementation(libs.androidx.paging.runtime)
|
||||
implementation(libs.androidx.paging.compose)
|
||||
|
||||
implementation(libs.androidx.sqlite.bundled)
|
||||
|
||||
implementation(libs.kotlin.reflect)
|
||||
|
||||
implementation(libs.bundles.kotlinx.coroutines)
|
||||
|
||||
implementation(libs.sqldelight.async)
|
||||
|
||||
implementation(libs.kotlinx.datetime)
|
||||
|
||||
// AndroidX libraries
|
||||
@@ -327,6 +321,10 @@ dependencies {
|
||||
// String similarity
|
||||
implementation(libs.stringSimilarity)
|
||||
|
||||
// GraphQL generation
|
||||
implementation(libs.apollo)
|
||||
implementation(libs.apollo.adapters)
|
||||
|
||||
// Tests
|
||||
testImplementation(libs.bundles.test)
|
||||
testRuntimeOnly(libs.junit.platform.launcher)
|
||||
@@ -338,7 +336,102 @@ dependencies {
|
||||
testImplementation(libs.kotlinx.coroutines.test)
|
||||
}
|
||||
|
||||
apollo {
|
||||
val schemaBasePath = "src/main/graphql/mihon/graphql"
|
||||
service("anilist") {
|
||||
packageName.set("mihon.graphql.anilist")
|
||||
val srcDir = "$schemaBasePath/anilist"
|
||||
srcDir(file(srcDir))
|
||||
|
||||
introspection {
|
||||
endpointUrl.set("https://graphql.anilist.co")
|
||||
schemaFile.set(file("$srcDir/anilist.graphqls"))
|
||||
}
|
||||
|
||||
// ISO 3166-1 alpha-2 country code
|
||||
mapScalarToKotlinString("CountryCode")
|
||||
}
|
||||
|
||||
service("kitsu") {
|
||||
packageName.set("mihon.graphql.kitsu")
|
||||
val srcDir = "$schemaBasePath/kitsu"
|
||||
srcDir(file(srcDir))
|
||||
android.defaultConfig.versionCode
|
||||
|
||||
introspection {
|
||||
// Kitsu doesn't like requests without a UA
|
||||
headers.put(
|
||||
"User-Agent",
|
||||
"Mihon v${android.defaultConfig.versionName} (${android.defaultConfig.applicationId})",
|
||||
)
|
||||
endpointUrl.set("https://kitsu.app/api/graphql")
|
||||
schemaFile.set(file("$srcDir/kitsu.graphqls"))
|
||||
}
|
||||
|
||||
// A date, expressed as an ISO8601 string
|
||||
mapScalarToKotlinString("Date")
|
||||
// An ISO 8601-encoded datetime
|
||||
mapScalar("ISO8601DateTime", "kotlin.time.Instant", "com.apollographql.adapter.core.KotlinInstantAdapter")
|
||||
// A loose key-value map in GraphQL
|
||||
mapScalar(
|
||||
"Map",
|
||||
"kotlin.collections.Map<String, Any?>",
|
||||
"mihon.graphql.kitsu.adapter.KitsuMapAdapter",
|
||||
)
|
||||
}
|
||||
|
||||
service("shikimori") {
|
||||
packageName.set("mihon.graphql.shikimori")
|
||||
val srcDir = "$schemaBasePath/shikimori"
|
||||
srcDir(file(srcDir))
|
||||
|
||||
introspection {
|
||||
endpointUrl.set("https://shikimori.io/api/graphql")
|
||||
schemaFile.set(file("$srcDir/shikimori.graphqls"))
|
||||
}
|
||||
|
||||
// An ISO 8601-encoded date
|
||||
mapScalarToKotlinString("ISO8601Date")
|
||||
}
|
||||
|
||||
service("suwayomi") {
|
||||
packageName.set("mihon.graphql.suwayomi")
|
||||
val srcDir = "$schemaBasePath/suwayomi"
|
||||
srcDir(file(srcDir))
|
||||
|
||||
introspection {
|
||||
endpointUrl.set("http://localhost:4567/api/graphql")
|
||||
schemaFile.set(file("$srcDir/suwayomi.graphqls"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val latestCommitCount = getLatestCommitCount()
|
||||
val latestCommitSha = getLatestCommitSha()
|
||||
val latestCommitTime = getLatestCommitTime()
|
||||
val currentTime = getCurrentTime()
|
||||
|
||||
fun ApplicationVariant.buildConfigField(type: String, name: String, value: Provider<String>) {
|
||||
buildConfigFields?.put(name, value.map { BuildConfigField(type, it, null) })
|
||||
}
|
||||
|
||||
androidComponents {
|
||||
onVariants { variant ->
|
||||
val isUnstableBuild = variant.buildType == "debug" || variant.buildType == "nightly"
|
||||
val buildTime = if (isUnstableBuild) currentTime else latestCommitTime
|
||||
|
||||
variant.buildConfigField("String", "COMMIT_COUNT", latestCommitCount.map { "\"$it\"" })
|
||||
variant.buildConfigField("String", "COMMIT_SHA", latestCommitSha.map { "\"$it\"" })
|
||||
variant.buildConfigField("String", "BUILD_TIME", buildTime.map { "\"$it\"" })
|
||||
|
||||
if (isUnstableBuild) {
|
||||
variant.outputs.forEach { output ->
|
||||
val versionName = output.versionName.get()
|
||||
output.versionName.set(latestCommitCount.map { "$versionName-$it" })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onVariants { variant ->
|
||||
val resSource = variant.sources.res ?: return@onVariants
|
||||
|
||||
|
||||
Vendored
+3
-11
@@ -1,8 +1,8 @@
|
||||
-dontobfuscate
|
||||
|
||||
-keep,allowoptimization class eu.kanade.**
|
||||
-keep,allowoptimization class tachiyomi.**
|
||||
-keep,allowoptimization class mihon.**
|
||||
# Injekt reads the injected type from the generic superclass of its type tokens
|
||||
-keepattributes Signature
|
||||
-keep,allowshrinking class * extends uy.kohesive.injekt.api.FullTypeReference
|
||||
|
||||
# Keep common dependencies used in extensions
|
||||
-keep,allowoptimization class androidx.preference.** { public protected *; }
|
||||
@@ -18,14 +18,6 @@
|
||||
-keep,allowoptimization class uy.kohesive.injekt.** { public protected *; }
|
||||
-keep,allowoptimization class com.squareup.zstd.** { public protected *; }
|
||||
|
||||
# From extensions-lib
|
||||
-keep,allowoptimization class eu.kanade.tachiyomi.network.interceptor.RateLimitInterceptorKt { public protected *; }
|
||||
-keep,allowoptimization class eu.kanade.tachiyomi.network.interceptor.SpecificHostRateLimitInterceptorKt { public protected *; }
|
||||
-keep,allowoptimization class eu.kanade.tachiyomi.network.NetworkHelper { public protected *; }
|
||||
-keep,allowoptimization class eu.kanade.tachiyomi.network.OkHttpExtensionsKt { public protected *; }
|
||||
-keep,allowoptimization class eu.kanade.tachiyomi.network.RequestsKt { public protected *; }
|
||||
-keep,allowoptimization class eu.kanade.tachiyomi.AppInfo { public protected *; }
|
||||
|
||||
-keepclassmembers class * implements java.io.Serializable {
|
||||
java.lang.Object writeReplace();
|
||||
java.lang.Object readResolve();
|
||||
|
||||
@@ -199,6 +199,17 @@
|
||||
<data android:host="shikimori-auth" />
|
||||
<data android:host="hikka-auth" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<!-- Comick requires native reverse-domain schemes -->
|
||||
<data android:scheme="app.mihon" />
|
||||
<data android:host="comick-auth" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<receiver
|
||||
|
||||
+11266
-13116
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,15 @@
|
||||
mutation AniListAddManga(
|
||||
$manga_id: Int!,
|
||||
$progress: Int!,
|
||||
$status: MediaListStatus!,
|
||||
$private: Boolean!,
|
||||
) {
|
||||
SaveMediaListEntry (
|
||||
mediaId: $manga_id,
|
||||
progress: $progress,
|
||||
status: $status,
|
||||
private: $private,
|
||||
) {
|
||||
id
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
mutation AniListDeleteManga(
|
||||
$library_id: Int!,
|
||||
) {
|
||||
DeleteMediaListEntry(
|
||||
id: $library_id,
|
||||
) {
|
||||
deleted
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
query AniListGetCurrentUser {
|
||||
Viewer {
|
||||
id
|
||||
name
|
||||
mediaListOptions {
|
||||
scoreFormat
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
query AniListGetLibManga(
|
||||
$user_id: Int!,
|
||||
$manga_id: Int!,
|
||||
) {
|
||||
Page {
|
||||
mediaList(
|
||||
userId: $user_id,
|
||||
type: MANGA,
|
||||
mediaId: $manga_id,
|
||||
) {
|
||||
id
|
||||
status
|
||||
scoreRaw: score(format: POINT_100)
|
||||
progress
|
||||
private
|
||||
startedAt {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
completedAt {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
media {
|
||||
...MangaFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
query AniListGetMangaDetails(
|
||||
$manga_id: Int!,
|
||||
) {
|
||||
Page (perPage: 1) {
|
||||
media(
|
||||
id: $manga_id,
|
||||
type: MANGA,
|
||||
format_not_in: [NOVEL],
|
||||
) {
|
||||
...MangaFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
query AniListSearchManga(
|
||||
$search: String!,
|
||||
) {
|
||||
Page (perPage: 50) {
|
||||
media(
|
||||
search: $search,
|
||||
type: MANGA,
|
||||
format_not_in: [NOVEL],
|
||||
) {
|
||||
...MangaFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
mutation AniListUpdateManga(
|
||||
$library_id: Int!,
|
||||
$progress: Int!,
|
||||
$status: MediaListStatus!,
|
||||
$private: Boolean!,
|
||||
$score: Int!,
|
||||
$startedAt: FuzzyDateInput!,
|
||||
$completedAt: FuzzyDateInput!,
|
||||
) {
|
||||
SaveMediaListEntry(
|
||||
id: $library_id,
|
||||
progress: $progress,
|
||||
status: $status,
|
||||
private: $private,
|
||||
scoreRaw: $score,
|
||||
startedAt: $startedAt,
|
||||
completedAt: $completedAt,
|
||||
) {
|
||||
id
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
fragment MangaFragment on Media {
|
||||
id
|
||||
staff {
|
||||
edges {
|
||||
role
|
||||
node {
|
||||
name {
|
||||
userPreferred
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
title {
|
||||
userPreferred
|
||||
}
|
||||
coverImage {
|
||||
large
|
||||
}
|
||||
format
|
||||
countryOfOrigin
|
||||
status
|
||||
chapters
|
||||
description
|
||||
startDate {
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
averageScore
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,27 @@
|
||||
mutation KitsuAddLibManga(
|
||||
$media_id: ID!,
|
||||
$status: LibraryEntryStatusEnum!,
|
||||
$progress: Int!,
|
||||
$private: Boolean!,
|
||||
$rating: Int,
|
||||
) {
|
||||
libraryEntry {
|
||||
create(
|
||||
input: {
|
||||
mediaId: $media_id,
|
||||
mediaType: MANGA,
|
||||
status: $status,
|
||||
progress: $progress,
|
||||
private: $private,
|
||||
rating: $rating,
|
||||
}
|
||||
) {
|
||||
errors {
|
||||
message
|
||||
}
|
||||
libraryEntry {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
mutation KitsuDeleteLibEntry(
|
||||
$library_id: ID!,
|
||||
) {
|
||||
libraryEntry {
|
||||
delete(
|
||||
input: {
|
||||
id: $library_id,
|
||||
}
|
||||
) {
|
||||
errors {
|
||||
message
|
||||
}
|
||||
libraryEntry {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
query KitsuFindLibManga(
|
||||
$remote_id: ID!,
|
||||
) {
|
||||
findMangaById(
|
||||
id: $remote_id,
|
||||
) {
|
||||
...MangaFragment
|
||||
myLibraryEntry {
|
||||
id
|
||||
private
|
||||
progress
|
||||
rating
|
||||
status
|
||||
startedAt
|
||||
finishedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
query KitsuGetCurrentAccount {
|
||||
currentAccount {
|
||||
id
|
||||
ratingSystem
|
||||
profile {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
query KitsuGetMangaDetailsById(
|
||||
$id: ID!,
|
||||
) {
|
||||
findMangaById(
|
||||
id: $id,
|
||||
) {
|
||||
...MangaFragment
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
query KitsuGetMangaDetailsBySlug(
|
||||
$slug: String!,
|
||||
) {
|
||||
findMangaBySlug(
|
||||
slug: $slug,
|
||||
) {
|
||||
...MangaFragment
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
query KitsuSearchMangaByTitle(
|
||||
$query: String!,
|
||||
) {
|
||||
searchMangaByTitle(
|
||||
title: $query,
|
||||
first: 20,
|
||||
) {
|
||||
nodes {
|
||||
...MangaFragment
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
mutation KitsuUpdateLibManga(
|
||||
$library_id: ID!,
|
||||
$status: LibraryEntryStatusEnum!,
|
||||
$progress: Int!,
|
||||
$private: Boolean!,
|
||||
$rating: Int,
|
||||
$startedAt: ISO8601DateTime,
|
||||
$finishedAt: ISO8601DateTime,
|
||||
) {
|
||||
libraryEntry {
|
||||
update(
|
||||
input: {
|
||||
id: $library_id,
|
||||
status: $status,
|
||||
progress: $progress,
|
||||
private: $private,
|
||||
rating: $rating,
|
||||
startedAt: $startedAt,
|
||||
finishedAt: $finishedAt,
|
||||
}
|
||||
) {
|
||||
errors {
|
||||
message
|
||||
}
|
||||
libraryEntry {
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
fragment MangaFragment on Manga {
|
||||
id
|
||||
titles {
|
||||
preferred
|
||||
}
|
||||
chapterCount
|
||||
staff(first: 5) {
|
||||
nodes {
|
||||
role
|
||||
person {
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
posterImage {
|
||||
views(names: "small") {
|
||||
name
|
||||
url
|
||||
}
|
||||
original {
|
||||
name
|
||||
url
|
||||
}
|
||||
}
|
||||
description(locales: "en")
|
||||
status
|
||||
subtype
|
||||
startDate
|
||||
slug
|
||||
averageRating
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,22 @@
|
||||
fragment MangaFragment on Manga {
|
||||
id
|
||||
name
|
||||
chapters
|
||||
kind
|
||||
poster {
|
||||
mainUrl
|
||||
}
|
||||
score
|
||||
url
|
||||
status
|
||||
airedOn {
|
||||
date
|
||||
}
|
||||
description
|
||||
personRoles {
|
||||
person {
|
||||
name
|
||||
}
|
||||
rolesEn
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
query ShikimoriGetCurrentUser {
|
||||
currentUser {
|
||||
id
|
||||
nickname
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
query ShikimoriGetLibManga(
|
||||
$remote_id: String!,
|
||||
) {
|
||||
mangas(
|
||||
ids: $remote_id,
|
||||
limit: 1,
|
||||
) {
|
||||
id
|
||||
url
|
||||
name
|
||||
chapters
|
||||
userRate {
|
||||
id
|
||||
chapters
|
||||
status
|
||||
score
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
query ShikimoriGetMangaDetails(
|
||||
$query: String!,
|
||||
) {
|
||||
mangas(
|
||||
ids: $query,
|
||||
limit: 1,
|
||||
kind: "!light_novel,!novel",
|
||||
) {
|
||||
...MangaFragment
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
query ShikimoriSearchManga(
|
||||
$search: String!
|
||||
) {
|
||||
mangas(
|
||||
search: $search,
|
||||
limit: 20,
|
||||
kind: "!light_novel,!novel",
|
||||
) {
|
||||
...MangaFragment
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,15 @@
|
||||
fragment MangaFragment on MangaType {
|
||||
description
|
||||
id
|
||||
status
|
||||
thumbnailUrl
|
||||
title
|
||||
url
|
||||
chapters {
|
||||
totalCount
|
||||
}
|
||||
latestReadChapter {
|
||||
chapterNumber
|
||||
}
|
||||
unreadCount
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
query SuwayomiGetManga(
|
||||
$mangaId: Int!,
|
||||
) {
|
||||
manga(
|
||||
id: $mangaId,
|
||||
) {
|
||||
...MangaFragment
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
query SuwayomiGetMangaUnreadChapters(
|
||||
$mangaId: Int!,
|
||||
$chapterNumber: Float!,
|
||||
) {
|
||||
chapters(
|
||||
condition: {
|
||||
mangaId: $mangaId,
|
||||
isRead: false,
|
||||
},
|
||||
filter: {
|
||||
and: [
|
||||
{
|
||||
chapterNumber: {
|
||||
lessThanOrEqualTo: $chapterNumber
|
||||
}
|
||||
},
|
||||
{
|
||||
chapterNumber: {
|
||||
greaterThan: 0
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
){
|
||||
nodes {
|
||||
id
|
||||
chapterNumber
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
mutation SuwayomiMarkChaptersRead(
|
||||
$chapters: [Int!]!,
|
||||
) {
|
||||
updateChapters(
|
||||
input: {
|
||||
ids: $chapters,
|
||||
patch: {
|
||||
isRead: true,
|
||||
},
|
||||
},
|
||||
) {
|
||||
__typename
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
mutation SuwayomiMarkAndDeleteChapters(
|
||||
$chapters: [Int!]!,
|
||||
) {
|
||||
updateChapters(
|
||||
input: {
|
||||
ids: $chapters,
|
||||
patch: {
|
||||
isRead: true,
|
||||
},
|
||||
},
|
||||
) {
|
||||
__typename
|
||||
}
|
||||
|
||||
deleteDownloadedChapters(
|
||||
input: {
|
||||
ids: $chapters,
|
||||
},
|
||||
) {
|
||||
__typename
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
mutation SuwayomiUpdateMangaProgress(
|
||||
$mangaId: Int!,
|
||||
) {
|
||||
trackProgress(
|
||||
input: {
|
||||
mangaId: $mangaId,
|
||||
},
|
||||
) {
|
||||
__typename
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -45,4 +45,9 @@ class BasePreferences(
|
||||
Preference.appStateKey("donation_campaign_shown"),
|
||||
false,
|
||||
)
|
||||
|
||||
val skippedAppUpdate: Preference<String> = preferenceStore.getString(
|
||||
Preference.appStateKey("skipped_app_update"),
|
||||
"",
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package eu.kanade.domain.chapter.interactor
|
||||
import dev.zacsweers.metro.Inject
|
||||
import eu.kanade.domain.download.interactor.DeleteDownload
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.common.util.lang.withNonCancellableContext
|
||||
import tachiyomi.core.common.util.system.logcat
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.chapter.model.ChapterUpdate
|
||||
@@ -21,14 +20,13 @@ class SetReadStatus(
|
||||
) {
|
||||
|
||||
private val mapper = { chapter: Chapter, read: Boolean ->
|
||||
ChapterUpdate(
|
||||
read = read,
|
||||
lastPageRead = if (!read) 0 else null,
|
||||
id = chapter.id,
|
||||
)
|
||||
ChapterUpdate(chapter.id) {
|
||||
this.read = read
|
||||
if (!read) lastPageRead = 0
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun await(read: Boolean, vararg chapters: Chapter): Result = withNonCancellableContext {
|
||||
suspend fun await(read: Boolean, vararg chapters: Chapter): Result {
|
||||
val chaptersToUpdate = chapters.filter {
|
||||
when (read) {
|
||||
true -> !it.read
|
||||
@@ -36,7 +34,7 @@ class SetReadStatus(
|
||||
}
|
||||
}
|
||||
if (chaptersToUpdate.isEmpty()) {
|
||||
return@withNonCancellableContext Result.NoChapters
|
||||
return Result.NoChapters
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -45,11 +43,14 @@ class SetReadStatus(
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
return@withNonCancellableContext Result.InternalError(e)
|
||||
return Result.InternalError(e)
|
||||
}
|
||||
|
||||
if (read && downloadPreferences.removeAfterMarkedAsRead.get()) {
|
||||
chaptersToUpdate
|
||||
// Chapters here still carry their pre-update read state; downstream
|
||||
// deletion filtering (excluded categories) relies on the new state.
|
||||
.map { it.copy(read = true) }
|
||||
.groupBy { it.mangaId }
|
||||
.forEach { (mangaId, chapters) ->
|
||||
deleteDownload.awaitAll(
|
||||
@@ -59,17 +60,16 @@ class SetReadStatus(
|
||||
}
|
||||
}
|
||||
|
||||
Result.Success
|
||||
return Result.Success
|
||||
}
|
||||
|
||||
suspend fun await(mangaId: Long, read: Boolean): Result = withNonCancellableContext {
|
||||
suspend fun await(mangaId: Long, read: Boolean): Result =
|
||||
await(
|
||||
read = read,
|
||||
chapters = chapterRepository
|
||||
.getChapterByMangaId(mangaId)
|
||||
.toTypedArray(),
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun await(manga: Manga, read: Boolean) =
|
||||
await(manga.id, read)
|
||||
|
||||
@@ -15,12 +15,10 @@ import kotlinx.datetime.TimeZone
|
||||
import kotlinx.datetime.toInstant
|
||||
import kotlinx.datetime.toLocalDateTime
|
||||
import tachiyomi.data.chapter.ChapterSanitizer
|
||||
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
||||
import tachiyomi.domain.chapter.interactor.ShouldUpdateDbChapter
|
||||
import tachiyomi.domain.chapter.interactor.UpdateChapter
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.chapter.model.ChapterRemoteUpdate
|
||||
import tachiyomi.domain.chapter.model.NoChaptersException
|
||||
import tachiyomi.domain.chapter.model.toChapterUpdate
|
||||
import tachiyomi.domain.chapter.repository.ChapterRepository
|
||||
import tachiyomi.domain.chapter.service.ChapterRecognition
|
||||
import tachiyomi.domain.library.service.LibraryPreferences
|
||||
@@ -29,6 +27,8 @@ import tachiyomi.source.local.isLocal
|
||||
import java.lang.Long.max
|
||||
import java.util.TreeSet
|
||||
import kotlin.time.Clock
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
import kotlin.time.Instant
|
||||
|
||||
@Inject
|
||||
class SyncChaptersWithSource(
|
||||
@@ -37,8 +37,6 @@ class SyncChaptersWithSource(
|
||||
private val chapterRepository: ChapterRepository,
|
||||
private val shouldUpdateDbChapter: ShouldUpdateDbChapter,
|
||||
private val updateManga: UpdateManga,
|
||||
private val updateChapter: UpdateChapter,
|
||||
private val getChaptersByMangaId: GetChaptersByMangaId,
|
||||
private val getExcludedScanlators: GetExcludedScanlators,
|
||||
private val libraryPreferences: LibraryPreferences,
|
||||
) {
|
||||
@@ -56,7 +54,7 @@ class SyncChaptersWithSource(
|
||||
manga: Manga,
|
||||
source: Source,
|
||||
manualFetch: Boolean = false,
|
||||
fetchWindow: Pair<Long, Long> = Pair(0, 0),
|
||||
fetchWindow: ClosedRange<Instant>? = null,
|
||||
): List<Chapter> {
|
||||
if (rawSourceChapters.isEmpty() && !source.isLocal()) {
|
||||
throw NoChaptersException()
|
||||
@@ -64,7 +62,7 @@ class SyncChaptersWithSource(
|
||||
|
||||
val timeZone = TimeZone.currentSystemDefault()
|
||||
val now = Clock.System.now().toLocalDateTime(timeZone)
|
||||
val nowMillis = now.toInstant(timeZone).toEpochMilliseconds()
|
||||
val nowInstant = now.toInstant(timeZone)
|
||||
|
||||
val sourceChapters = rawSourceChapters
|
||||
.distinctBy { it.url }
|
||||
@@ -75,43 +73,46 @@ class SyncChaptersWithSource(
|
||||
.copy(mangaId = manga.id, sourceOrder = i.toLong())
|
||||
}
|
||||
|
||||
val dbChapters = getChaptersByMangaId.await(manga.id)
|
||||
val dbChapters = chapterRepository.getChapterByMangaId(manga.id)
|
||||
val dbChaptersByUrl = dbChapters.associateBy { it.url }
|
||||
|
||||
val newChapters = mutableListOf<Chapter>()
|
||||
val updatedChapters = mutableListOf<Chapter>()
|
||||
val removedChapters = dbChapters.filterNot { dbChapter ->
|
||||
sourceChapters.any { sourceChapter ->
|
||||
dbChapter.url == sourceChapter.url
|
||||
}
|
||||
}
|
||||
val updatedChapters = mutableListOf<ChapterRemoteUpdate>()
|
||||
val sourceUrls = mutableSetOf<String>()
|
||||
|
||||
// Used to not set upload date of older chapters
|
||||
// to a higher value than newer chapters
|
||||
var maxSeenUploadDate = 0L
|
||||
var maxSeenUploadDate: Instant? = null
|
||||
|
||||
for (sourceChapter in sourceChapters) {
|
||||
var chapter = sourceChapter
|
||||
|
||||
// Update metadata from source if necessary.
|
||||
if (source is HttpSource) {
|
||||
// Update metadata from source if necessary.
|
||||
val preparedChapters = if (source is HttpSource) {
|
||||
val sManga = manga.toSManga()
|
||||
sourceChapters.map { chapter ->
|
||||
val sChapter = chapter.toSChapter()
|
||||
@Suppress("DEPRECATION")
|
||||
source.prepareNewChapter(sChapter, manga.toSManga())
|
||||
chapter = chapter.copyFromSChapter(sChapter)
|
||||
source.prepareNewChapter(sChapter, sManga)
|
||||
chapter.copyFromSChapter(sChapter)
|
||||
}
|
||||
} else {
|
||||
sourceChapters
|
||||
}
|
||||
|
||||
// Recognize chapter numbers, from the whole list since names alone don't always tell.
|
||||
val recognizedChapters = preparedChapters
|
||||
.zip(ChapterRecognition.parseChapterNumbers(manga.title, preparedChapters)) { chapter, numbering ->
|
||||
chapter.copy(chapterNumber = numbering.chapter?.let(ChapterRecognition::toDouble) ?: -1.0)
|
||||
}
|
||||
|
||||
// Recognize chapter number for the chapter.
|
||||
val chapterNumber = ChapterRecognition.parseChapterNumber(manga.title, chapter.name, chapter.chapterNumber)
|
||||
chapter = chapter.copy(chapterNumber = chapterNumber)
|
||||
for (chapter in recognizedChapters) {
|
||||
if (!sourceUrls.add(chapter.url)) continue
|
||||
|
||||
val dbChapter = dbChapters.find { it.url == chapter.url }
|
||||
val dbChapter = dbChaptersByUrl[chapter.url]
|
||||
|
||||
if (dbChapter == null) {
|
||||
val toAddChapter = if (chapter.dateUpload == 0L) {
|
||||
val altDateUpload = if (maxSeenUploadDate == 0L) nowMillis else maxSeenUploadDate
|
||||
chapter.copy(dateUpload = altDateUpload)
|
||||
val toAddChapter = if (chapter.dateUpload == null) {
|
||||
chapter.copy(dateUpload = maxSeenUploadDate ?: nowInstant)
|
||||
} else {
|
||||
maxSeenUploadDate = max(maxSeenUploadDate, sourceChapter.dateUpload)
|
||||
maxSeenUploadDate = listOfNotNull(maxSeenUploadDate, chapter.dateUpload).maxOrNull()
|
||||
chapter
|
||||
}
|
||||
newChapters.add(toAddChapter)
|
||||
@@ -130,25 +131,33 @@ class SyncChaptersWithSource(
|
||||
downloadManager.renameChapter(source, manga, dbChapter, chapter)
|
||||
}
|
||||
|
||||
var toChangeChapter = dbChapter.copy(
|
||||
name = chapter.name,
|
||||
chapterNumber = chapter.chapterNumber,
|
||||
scanlator = chapter.scanlator,
|
||||
sourceOrder = chapter.sourceOrder,
|
||||
memo = chapter.memo,
|
||||
updatedChapters.add(
|
||||
ChapterRemoteUpdate(
|
||||
id = dbChapter.id,
|
||||
name = chapter.name,
|
||||
chapterNumber = chapter.chapterNumber,
|
||||
scanlator = chapter.scanlator,
|
||||
sourceOrder = chapter.sourceOrder,
|
||||
dateUpload = chapter.dateUpload,
|
||||
memo = chapter.memo,
|
||||
),
|
||||
)
|
||||
|
||||
if (chapter.dateUpload != 0L) {
|
||||
toChangeChapter = toChangeChapter.copy(dateUpload = chapter.dateUpload)
|
||||
}
|
||||
updatedChapters.add(toChangeChapter)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val removedChapters = dbChapters.filterNot { it.url in sourceUrls }
|
||||
|
||||
// The source no longer lists these, so their queued downloads could only fail
|
||||
removedChapters.mapNotNull { downloadManager.getQueuedDownloadOrNull(it.id) }
|
||||
.takeIf { it.isNotEmpty() }
|
||||
?.let { downloadManager.cancelQueuedDownloads(it) }
|
||||
|
||||
// Return if there's nothing to add, delete, or update to avoid unnecessary db transactions.
|
||||
if (newChapters.isEmpty() && removedChapters.isEmpty() && updatedChapters.isEmpty()) {
|
||||
if (manualFetch || manga.fetchInterval == 0 || manga.nextUpdate < fetchWindow.first) {
|
||||
val isNextUpdateBeforeWindow = fetchWindow != null &&
|
||||
manga.nextUpdate.let { it == null || it < fetchWindow.start }
|
||||
if (manualFetch || manga.fetchInterval == 0 || isNextUpdateBeforeWindow) {
|
||||
updateManga.awaitUpdateFetchInterval(
|
||||
manga,
|
||||
timeZone,
|
||||
@@ -186,8 +195,8 @@ class SyncChaptersWithSource(
|
||||
// Date fetch is set in such a way that the upper ones will have bigger value than the lower ones
|
||||
// Sources MUST return the chapters from most to less recent, which is common.
|
||||
var itemCount = newChapters.size
|
||||
var updatedToAdd = newChapters.map { toAddItem ->
|
||||
var chapter = toAddItem.copy(dateFetch = nowMillis + itemCount--)
|
||||
val toAdd = newChapters.map { toAddItem ->
|
||||
var chapter = toAddItem.copy(dateFetch = nowInstant + (itemCount--).milliseconds)
|
||||
|
||||
if (chapter.chapterNumber in readChapterNumbers && markDuplicateAsRead) {
|
||||
changedOrDuplicateReadUrls.add(chapter.url)
|
||||
@@ -211,27 +220,25 @@ class SyncChaptersWithSource(
|
||||
chapter
|
||||
}
|
||||
|
||||
if (removedChapters.isNotEmpty()) {
|
||||
val toDeleteIds = removedChapters.map { it.id }
|
||||
chapterRepository.removeChaptersWithIds(toDeleteIds)
|
||||
}
|
||||
|
||||
if (updatedToAdd.isNotEmpty()) {
|
||||
updatedToAdd = chapterRepository.addAll(updatedToAdd)
|
||||
}
|
||||
|
||||
if (updatedChapters.isNotEmpty()) {
|
||||
val chapterUpdates = updatedChapters.map { it.toChapterUpdate() }
|
||||
updateChapter.awaitAll(chapterUpdates)
|
||||
}
|
||||
updateManga.awaitUpdateFetchInterval(manga, timeZone, now, fetchWindow)
|
||||
|
||||
// Set this manga as updated since chapters were changed
|
||||
// Note that last_update actually represents last time the chapter list changed at all
|
||||
updateManga.awaitUpdateLastUpdate(manga.id)
|
||||
val added = chapterRepository.updateFromRemote(
|
||||
removedIds = removedChapters.map { it.id },
|
||||
added = toAdd,
|
||||
updated = updatedChapters,
|
||||
)
|
||||
|
||||
val excludedScanlators = getExcludedScanlators.await(manga.id).toHashSet()
|
||||
|
||||
return updatedToAdd.filterNot { it.url in changedOrDuplicateReadUrls || it.scanlator in excludedScanlators }
|
||||
// A first fetch lists the back catalogue, and chapters coming back under a deleted number were out already
|
||||
val foundRelease = dbChapters.isNotEmpty() &&
|
||||
toAdd.any { chapter ->
|
||||
chapter.scanlator !in excludedScanlators &&
|
||||
!(chapter.isRecognizedNumber && chapter.chapterNumber in deletedChapterNumbers)
|
||||
}
|
||||
|
||||
// Set this manga as updated since chapters were changed
|
||||
// Note that last_update actually represents last time the chapter list changed at all
|
||||
updateManga.awaitUpdateFetchIntervalAndLastUpdate(manga, timeZone, now, fetchWindow, foundRelease)
|
||||
|
||||
return added.filterNot { it.url in changedOrDuplicateReadUrls || it.scanlator in excludedScanlators }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package eu.kanade.domain.chapter.model
|
||||
|
||||
import eu.kanade.tachiyomi.data.database.models.ChapterImpl
|
||||
import eu.kanade.tachiyomi.source.model.SChapter
|
||||
import mihon.core.common.extensions.toEpochMillisOrZero
|
||||
import mihon.core.common.extensions.toInstantOrNull
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import eu.kanade.tachiyomi.data.database.models.Chapter as DbChapter
|
||||
|
||||
// TODO: Remove when all deps are migrated
|
||||
fun Chapter.toSChapter(): SChapter {
|
||||
return SChapter.create().also {
|
||||
it.url = url
|
||||
it.name = name
|
||||
it.date_upload = dateUpload
|
||||
it.date_upload = dateUpload.toEpochMillisOrZero()
|
||||
it.chapter_number = chapterNumber.toFloat()
|
||||
it.scanlator = scanlator
|
||||
it.memo = memo
|
||||
@@ -21,25 +20,9 @@ fun Chapter.copyFromSChapter(sChapter: SChapter): Chapter {
|
||||
return this.copy(
|
||||
name = sChapter.name,
|
||||
url = sChapter.url,
|
||||
dateUpload = sChapter.date_upload,
|
||||
dateUpload = sChapter.date_upload.toInstantOrNull(),
|
||||
chapterNumber = sChapter.chapter_number.toDouble(),
|
||||
scanlator = sChapter.scanlator?.ifBlank { null }?.trim(),
|
||||
memo = sChapter.memo,
|
||||
)
|
||||
}
|
||||
|
||||
fun Chapter.toDbChapter(): DbChapter = ChapterImpl().also {
|
||||
it.id = id
|
||||
it.manga_id = mangaId
|
||||
it.url = url
|
||||
it.name = name
|
||||
it.scanlator = scanlator
|
||||
it.read = read
|
||||
it.bookmark = bookmark
|
||||
it.last_page_read = lastPageRead.toInt()
|
||||
it.date_fetch = dateFetch
|
||||
it.date_upload = dateUpload
|
||||
it.chapter_number = chapterNumber.toFloat()
|
||||
it.source_order = sourceOrder.toInt()
|
||||
it.memo = memo
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package eu.kanade.domain.download.interactor
|
||||
|
||||
import dev.zacsweers.metro.Inject
|
||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||
import tachiyomi.core.common.util.lang.withNonCancellableContext
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.source.service.SourceManager
|
||||
@@ -13,7 +12,7 @@ class DeleteDownload(
|
||||
private val downloadManager: DownloadManager,
|
||||
) {
|
||||
|
||||
suspend fun awaitAll(manga: Manga, vararg chapters: Chapter) = withNonCancellableContext {
|
||||
suspend fun awaitAll(manga: Manga, vararg chapters: Chapter) {
|
||||
sourceManager.get(manga.source)?.let { source ->
|
||||
downloadManager.deleteChapters(chapters.toList(), manga, source)
|
||||
}
|
||||
|
||||
@@ -23,20 +23,17 @@ class GetExtensionsByType(
|
||||
extensionManager.notLoadedExtensionsFlow,
|
||||
extensionManager.availableExtensionsFlow,
|
||||
) { enabledLanguages, _loaded, _notLoaded, _available ->
|
||||
val (updates, loaded) = _loaded
|
||||
.sortedWith(
|
||||
compareBy<Extension.Loaded> { !it.isObsolete }
|
||||
.thenBy(String.CASE_INSENSITIVE_ORDER) { it.name },
|
||||
)
|
||||
.partition { it.hasUpdate }
|
||||
val byName = compareBy<Extension, String>(String.CASE_INSENSITIVE_ORDER) { it.name }
|
||||
|
||||
val notLoaded = _notLoaded
|
||||
.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name })
|
||||
val (loadedUpdates, loaded) = _loaded.partition { it.hasUpdate }
|
||||
val (notLoadedUpdates, notLoaded) = _notLoaded.partition { it.hasUpdate }
|
||||
|
||||
val updates = (loadedUpdates + notLoadedUpdates).sortedWith(byName)
|
||||
|
||||
val installedSignatures = (_loaded + _notLoaded).groupBy({ it.pkgName }, { it.signatures })
|
||||
val available = _available
|
||||
.filter { extension ->
|
||||
_loaded.none { it.pkgName == extension.pkgName } &&
|
||||
_notLoaded.none { it.pkgName == extension.pkgName } &&
|
||||
installedSignatures[extension.pkgName].orEmpty().none { extension.store.signingKey in it } &&
|
||||
extension.contentWarning in enabledContentWarnings
|
||||
}
|
||||
.flatMap { ext ->
|
||||
@@ -50,9 +47,17 @@ class GetExtensionsByType(
|
||||
)
|
||||
}
|
||||
}
|
||||
.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name })
|
||||
.sortedWith(
|
||||
compareBy<Extension.Available, String>(String.CASE_INSENSITIVE_ORDER) { it.name }
|
||||
.thenBy { it.store.signingKey },
|
||||
)
|
||||
|
||||
Extensions(updates, loaded, available, notLoaded)
|
||||
Extensions(
|
||||
updates = updates,
|
||||
loaded = loaded.sortedWith(compareBy<Extension.Loaded> { !it.isObsolete }.then(byName)),
|
||||
available = available,
|
||||
notLoaded = notLoaded.sortedWith(byName),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.drop
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.merge
|
||||
import mihon.domain.extension.model.ExtensionStore
|
||||
import mihon.domain.extension.repository.ExtensionStoreRepository
|
||||
import tachiyomi.core.common.preference.getAndSet
|
||||
|
||||
@@ -18,8 +19,8 @@ class TrustExtension(
|
||||
private val preferences: SourcePreferences,
|
||||
) {
|
||||
|
||||
suspend fun isTrusted(pkgInfo: PackageInfo, fingerprints: List<String>): Boolean {
|
||||
val trustedFingerprints = repository.getAll().map { it.signingKey }.toHashSet()
|
||||
fun isTrusted(pkgInfo: PackageInfo, fingerprints: List<String>, stores: List<ExtensionStore>): Boolean {
|
||||
val trustedFingerprints = stores.mapTo(HashSet()) { it.signingKey }
|
||||
val key = "${pkgInfo.packageName}:${PackageInfoCompat.getLongVersionCode(pkgInfo)}:${fingerprints.last()}"
|
||||
return trustedFingerprints.any { fingerprints.contains(it) } || key in preferences.trustedExtensions.get()
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package eu.kanade.domain.extension.model
|
||||
import eu.kanade.tachiyomi.extension.model.Extension
|
||||
|
||||
data class Extensions(
|
||||
val updates: List<Extension.Loaded>,
|
||||
val updates: List<Extension.Installed>,
|
||||
val loaded: List<Extension.Loaded>,
|
||||
val available: List<Extension.Available>,
|
||||
val notLoaded: List<Extension.NotLoaded>,
|
||||
|
||||
@@ -1,28 +1,19 @@
|
||||
package eu.kanade.domain.manga.interactor
|
||||
|
||||
import app.cash.sqldelight.async.coroutines.awaitAsList
|
||||
import dev.zacsweers.metro.Inject
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import tachiyomi.data.Database
|
||||
import tachiyomi.data.subscribeToList
|
||||
import tachiyomi.domain.manga.repository.MangaRepository
|
||||
|
||||
@Inject
|
||||
class GetExcludedScanlators(
|
||||
private val database: Database,
|
||||
private val mangaRepository: MangaRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(mangaId: Long): Set<String> {
|
||||
return database.excluded_scanlatorsQueries
|
||||
.getExcludedScanlatorsByMangaId(mangaId)
|
||||
.awaitAsList()
|
||||
.toSet()
|
||||
return mangaRepository.getExcludedScanlators(mangaId)
|
||||
}
|
||||
|
||||
fun subscribe(mangaId: Long): Flow<Set<String>> {
|
||||
return database.excluded_scanlatorsQueries
|
||||
.getExcludedScanlatorsByMangaId(mangaId)
|
||||
.subscribeToList()
|
||||
.map { it.toSet() }
|
||||
return mangaRepository.getExcludedScanlatorsAsFlow(mangaId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,14 @@
|
||||
package eu.kanade.domain.manga.interactor
|
||||
|
||||
import app.cash.sqldelight.async.coroutines.awaitAsList
|
||||
import dev.zacsweers.metro.Inject
|
||||
import tachiyomi.data.Database
|
||||
import tachiyomi.domain.manga.repository.MangaRepository
|
||||
|
||||
@Inject
|
||||
class SetExcludedScanlators(
|
||||
private val database: Database,
|
||||
private val mangaRepository: MangaRepository,
|
||||
) {
|
||||
|
||||
suspend fun await(mangaId: Long, excludedScanlators: Set<String>) {
|
||||
database.transaction {
|
||||
val currentExcluded = database.excluded_scanlatorsQueries
|
||||
.getExcludedScanlatorsByMangaId(mangaId)
|
||||
.awaitAsList()
|
||||
.toSet()
|
||||
val toAdd = excludedScanlators.minus(currentExcluded)
|
||||
for (scanlator in toAdd) {
|
||||
database.excluded_scanlatorsQueries.insert(mangaId, scanlator)
|
||||
}
|
||||
val toRemove = currentExcluded.minus(excludedScanlators)
|
||||
database.excluded_scanlatorsQueries.remove(mangaId, toRemove)
|
||||
}
|
||||
mangaRepository.setExcludedScanlators(mangaId, excludedScanlators)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,20 +14,18 @@ class SetMangaViewerFlags(
|
||||
suspend fun awaitSetReadingMode(id: Long, flag: Long) {
|
||||
val manga = mangaRepository.getMangaById(id)
|
||||
mangaRepository.update(
|
||||
MangaUpdate(
|
||||
id = id,
|
||||
viewerFlags = manga.viewerFlags.setFlag(flag, ReadingMode.MASK.toLong()),
|
||||
),
|
||||
MangaUpdate(id) {
|
||||
viewerFlags = manga.viewerFlags.setFlag(flag, ReadingMode.MASK.toLong())
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun awaitSetOrientation(id: Long, flag: Long) {
|
||||
val manga = mangaRepository.getMangaById(id)
|
||||
mangaRepository.update(
|
||||
MangaUpdate(
|
||||
id = id,
|
||||
viewerFlags = manga.viewerFlags.setFlag(flag, ReaderOrientation.MASK.toLong()),
|
||||
),
|
||||
MangaUpdate(id) {
|
||||
viewerFlags = manga.viewerFlags.setFlag(flag, ReaderOrientation.MASK.toLong())
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.model.MangaUpdate
|
||||
import tachiyomi.domain.manga.repository.MangaRepository
|
||||
import kotlin.time.Clock
|
||||
import kotlin.time.Instant
|
||||
|
||||
@Inject
|
||||
class UpdateManga(
|
||||
@@ -28,33 +29,43 @@ class UpdateManga(
|
||||
manga: Manga,
|
||||
timeZone: TimeZone = TimeZone.currentSystemDefault(),
|
||||
dateTime: LocalDateTime = Clock.System.now().toLocalDateTime(timeZone),
|
||||
window: Pair<Long, Long> = fetchInterval.getWindow(dateTime.date, timeZone),
|
||||
window: ClosedRange<Instant>? = fetchInterval.getWindow(dateTime.date, timeZone),
|
||||
): Boolean {
|
||||
return mangaRepository.update(
|
||||
fetchInterval.toMangaUpdate(manga, dateTime, timeZone, window),
|
||||
fetchInterval.withFetchInterval(manga, dateTime, timeZone, window),
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun awaitUpdateLastUpdate(mangaId: Long): Boolean {
|
||||
return mangaRepository.update(MangaUpdate(id = mangaId, lastUpdate = Clock.System.now().toEpochMilliseconds()))
|
||||
/**
|
||||
* Updates the fetch interval and marks the chapter list as changed in a single write.
|
||||
*/
|
||||
suspend fun awaitUpdateFetchIntervalAndLastUpdate(
|
||||
manga: Manga,
|
||||
timeZone: TimeZone,
|
||||
dateTime: LocalDateTime,
|
||||
window: ClosedRange<Instant>?,
|
||||
foundRelease: Boolean,
|
||||
): Boolean {
|
||||
return mangaRepository.update(
|
||||
fetchInterval.withFetchInterval(manga, dateTime, timeZone, window, foundRelease).apply {
|
||||
lastUpdate = Clock.System.now()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun awaitUpdateCoverLastModified(mangaId: Long): Boolean {
|
||||
return mangaRepository.update(
|
||||
MangaUpdate(
|
||||
id = mangaId,
|
||||
coverLastModified = Clock.System.now().toEpochMilliseconds(),
|
||||
),
|
||||
MangaUpdate(mangaId) {
|
||||
coverLastModified = Clock.System.now()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun awaitUpdateFavorite(mangaId: Long, favorite: Boolean): Boolean {
|
||||
val dateAdded = when (favorite) {
|
||||
true -> Clock.System.now().toEpochMilliseconds()
|
||||
false -> 0
|
||||
val update = when (favorite) {
|
||||
true -> MangaUpdate(mangaId) { favoriteAt = Clock.System.now() }
|
||||
false -> MangaUpdate(mangaId) { favoriteAt = null }
|
||||
}
|
||||
return mangaRepository.update(
|
||||
MangaUpdate(id = mangaId, favorite = favorite, dateAdded = dateAdded),
|
||||
)
|
||||
return mangaRepository.update(update)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import kotlin.time.Instant
|
||||
|
||||
// TODO: move these into the domain model
|
||||
val Manga.readingMode: Long
|
||||
@@ -77,7 +76,7 @@ fun Manga.copyFrom(other: SManga): Manga {
|
||||
}
|
||||
|
||||
fun Manga.hasCustomCover(coverCache: CoverCache = Injekt.get<Context>().appGraph.coverCache): Boolean {
|
||||
return coverCache.getCustomCoverFile(id).exists()
|
||||
return coverCache.hasCustomCover(id)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,11 +89,7 @@ fun getComicInfo(
|
||||
categories: List<String>?,
|
||||
sourceName: String,
|
||||
): ComicInfo {
|
||||
val date = chapter.dateUpload
|
||||
.takeIf { it != 0L }
|
||||
?.let {
|
||||
Instant.fromEpochMilliseconds(it).toLocalDateTime(TimeZone.currentSystemDefault())
|
||||
}
|
||||
val date = chapter.dateUpload?.toLocalDateTime(TimeZone.currentSystemDefault())
|
||||
|
||||
return ComicInfo(
|
||||
title = ComicInfo.Title(chapter.name),
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
package eu.kanade.domain.source.model
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.ui.graphics.ImageBitmap
|
||||
import androidx.compose.ui.graphics.asImageBitmap
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import mihon.app.di.appGraph
|
||||
import tachiyomi.core.common.util.lang.withIOContext
|
||||
import tachiyomi.domain.source.model.Source
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
suspend fun Source.icon(): ImageBitmap? = withIOContext {
|
||||
Injekt.get<Context>().appGraph.extensionManager.getAppIconForSource(id)
|
||||
?.toBitmap()
|
||||
?.asImageBitmap()
|
||||
}
|
||||
@@ -8,20 +8,19 @@ import eu.kanade.tachiyomi.data.track.EnhancedTracker
|
||||
import eu.kanade.tachiyomi.data.track.Tracker
|
||||
import eu.kanade.tachiyomi.data.track.TrackerManager
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.util.lang.convertEpochMillisZone
|
||||
import kotlinx.datetime.TimeZone
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.common.util.lang.withIOContext
|
||||
import tachiyomi.core.common.util.lang.withNonCancellableContext
|
||||
import tachiyomi.core.common.util.system.logcat
|
||||
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
||||
import tachiyomi.domain.history.interactor.GetHistory
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.track.interactor.InsertTrack
|
||||
import tachiyomi.domain.track.interactor.UpsertTrack
|
||||
import kotlin.time.Instant
|
||||
|
||||
@Inject
|
||||
class AddTracks(
|
||||
private val insertTrack: InsertTrack,
|
||||
private val upsertTrack: UpsertTrack,
|
||||
private val syncChapterProgressWithTrack: SyncChapterProgressWithTrack,
|
||||
private val getChaptersByMangaId: GetChaptersByMangaId,
|
||||
private val trackerManager: TrackerManager,
|
||||
@@ -29,80 +28,72 @@ class AddTracks(
|
||||
) {
|
||||
|
||||
// TODO: update all trackers based on common data
|
||||
suspend fun bind(tracker: Tracker, item: Track, mangaId: Long) = withNonCancellableContext {
|
||||
withIOContext {
|
||||
val allChapters = getChaptersByMangaId.await(mangaId)
|
||||
val hasReadChapters = allChapters.any { it.read }
|
||||
tracker.bind(item, hasReadChapters)
|
||||
suspend fun bind(tracker: Tracker, item: Track, mangaId: Long) = withContext(Dispatchers.IO) {
|
||||
val allChapters = getChaptersByMangaId.await(mangaId)
|
||||
val hasReadChapters = allChapters.any { it.read }
|
||||
tracker.bind(item, hasReadChapters)
|
||||
|
||||
var track = item.toDomainTrack(idRequired = false) ?: return@withIOContext
|
||||
var track = item.toDomainTrack(idRequired = false) ?: return@withContext
|
||||
|
||||
insertTrack.await(track)
|
||||
upsertTrack.await(track)
|
||||
|
||||
// TODO: merge into [SyncChapterProgressWithTrack]?
|
||||
// Update chapter progress if newer chapters marked read locally
|
||||
if (hasReadChapters) {
|
||||
val latestLocalReadChapterNumber = allChapters
|
||||
.sortedBy { it.chapterNumber }
|
||||
.takeWhile { it.read }
|
||||
.lastOrNull()
|
||||
?.chapterNumber ?: -1.0
|
||||
// TODO: merge into [SyncChapterProgressWithTrack]?
|
||||
// Update chapter progress if newer chapters marked read locally
|
||||
if (hasReadChapters) {
|
||||
val latestLocalReadChapterNumber = allChapters
|
||||
.sortedBy { it.chapterNumber }
|
||||
.takeWhile { it.read }
|
||||
.lastOrNull()
|
||||
?.chapterNumber ?: -1.0
|
||||
|
||||
if (latestLocalReadChapterNumber > track.lastChapterRead) {
|
||||
track = track.copy(
|
||||
lastChapterRead = latestLocalReadChapterNumber,
|
||||
)
|
||||
tracker.setRemoteLastChapterRead(track.toDbTrack(), latestLocalReadChapterNumber.toInt())
|
||||
}
|
||||
|
||||
if (track.startDate <= 0) {
|
||||
val firstReadChapterDate = getHistory.await(mangaId)
|
||||
.sortedBy { it.readAt }
|
||||
.firstOrNull()
|
||||
?.readAt
|
||||
|
||||
firstReadChapterDate?.let {
|
||||
val startDate = firstReadChapterDate.time.convertEpochMillisZone(
|
||||
TimeZone.currentSystemDefault(),
|
||||
TimeZone.UTC,
|
||||
)
|
||||
track = track.copy(
|
||||
startDate = startDate,
|
||||
)
|
||||
tracker.setRemoteStartDate(track.toDbTrack(), startDate)
|
||||
}
|
||||
}
|
||||
if (latestLocalReadChapterNumber > track.lastChapterRead) {
|
||||
track = track.copy(
|
||||
lastChapterRead = latestLocalReadChapterNumber,
|
||||
)
|
||||
tracker.setRemoteLastChapterRead(track.toDbTrack(), latestLocalReadChapterNumber.toInt())
|
||||
}
|
||||
|
||||
syncChapterProgressWithTrack.await(mangaId, track, tracker)
|
||||
if (track.startDate == null) {
|
||||
val firstReadChapterDate = getHistory.await(mangaId)
|
||||
.mapNotNull { it.readAt }
|
||||
.minOrNull()
|
||||
|
||||
firstReadChapterDate?.let {
|
||||
val startDate = firstReadChapterDate.toEpochMilliseconds()
|
||||
track = track.copy(
|
||||
startDate = Instant.fromEpochMilliseconds(startDate),
|
||||
)
|
||||
tracker.setRemoteStartDate(track.toDbTrack(), startDate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
syncChapterProgressWithTrack.await(mangaId, track, tracker)
|
||||
}
|
||||
|
||||
suspend fun bindEnhancedTrackers(manga: Manga, source: Source) = withNonCancellableContext {
|
||||
withIOContext {
|
||||
trackerManager.loggedInTrackers()
|
||||
.filterIsInstance<EnhancedTracker>()
|
||||
.filter { it.accept(source) }
|
||||
.forEach { service ->
|
||||
try {
|
||||
service.match(manga)?.let { track ->
|
||||
track.manga_id = manga.id
|
||||
(service as Tracker).bind(track)
|
||||
insertTrack.await(track.toDomainTrack(idRequired = false)!!)
|
||||
suspend fun bindEnhancedTrackers(manga: Manga, source: Source) = withContext(Dispatchers.IO) {
|
||||
trackerManager.loggedInTrackers()
|
||||
.filterIsInstance<EnhancedTracker>()
|
||||
.filter { it.accept(source) }
|
||||
.forEach { service ->
|
||||
try {
|
||||
service.match(manga)?.let { track ->
|
||||
track.manga_id = manga.id
|
||||
(service as Tracker).bind(track)
|
||||
upsertTrack.await(track.toDomainTrack(idRequired = false)!!)
|
||||
|
||||
syncChapterProgressWithTrack.await(
|
||||
manga.id,
|
||||
track.toDomainTrack(idRequired = false)!!,
|
||||
service,
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logcat(
|
||||
LogPriority.WARN,
|
||||
e,
|
||||
) { "Could not match manga: ${manga.title} with service $service" }
|
||||
syncChapterProgressWithTrack.await(
|
||||
manga.id,
|
||||
track.toDomainTrack(idRequired = false)!!,
|
||||
service,
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logcat(
|
||||
LogPriority.WARN,
|
||||
e,
|
||||
) { "Could not match manga: ${manga.title} with service $service" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,17 +5,18 @@ import eu.kanade.domain.track.model.toDbTrack
|
||||
import eu.kanade.domain.track.model.toDomainTrack
|
||||
import eu.kanade.tachiyomi.data.track.Tracker
|
||||
import eu.kanade.tachiyomi.data.track.TrackerManager
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.supervisorScope
|
||||
import tachiyomi.domain.track.interactor.GetTracks
|
||||
import tachiyomi.domain.track.interactor.InsertTrack
|
||||
import tachiyomi.domain.track.interactor.UpsertTrack
|
||||
|
||||
@Inject
|
||||
class RefreshTracks(
|
||||
private val getTracks: GetTracks,
|
||||
private val trackerManager: TrackerManager,
|
||||
private val insertTrack: InsertTrack,
|
||||
private val upsertTrack: UpsertTrack,
|
||||
private val syncChapterProgressWithTrack: SyncChapterProgressWithTrack,
|
||||
) {
|
||||
|
||||
@@ -30,10 +31,10 @@ class RefreshTracks(
|
||||
.map { it to trackerManager.get(it.trackerId) }
|
||||
.filter { (_, service) -> service?.isLoggedIn == true }
|
||||
.map { (track, service) ->
|
||||
async {
|
||||
async(Dispatchers.IO) {
|
||||
return@async try {
|
||||
val updatedTrack = service!!.refresh(track.toDbTrack()).toDomainTrack()!!
|
||||
insertTrack.await(updatedTrack)
|
||||
upsertTrack.await(updatedTrack)
|
||||
syncChapterProgressWithTrack.await(mangaId, updatedTrack, service)
|
||||
null
|
||||
} catch (e: Throwable) {
|
||||
|
||||
@@ -8,15 +8,15 @@ import logcat.LogPriority
|
||||
import tachiyomi.core.common.util.system.logcat
|
||||
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
||||
import tachiyomi.domain.chapter.interactor.UpdateChapter
|
||||
import tachiyomi.domain.chapter.model.toChapterUpdate
|
||||
import tachiyomi.domain.track.interactor.InsertTrack
|
||||
import tachiyomi.domain.chapter.model.ChapterUpdate
|
||||
import tachiyomi.domain.track.interactor.UpsertTrack
|
||||
import tachiyomi.domain.track.model.Track
|
||||
import kotlin.math.max
|
||||
|
||||
@Inject
|
||||
class SyncChapterProgressWithTrack(
|
||||
private val updateChapter: UpdateChapter,
|
||||
private val insertTrack: InsertTrack,
|
||||
private val upsertTrack: UpsertTrack,
|
||||
private val getChaptersByMangaId: GetChaptersByMangaId,
|
||||
) {
|
||||
|
||||
@@ -35,7 +35,7 @@ class SyncChapterProgressWithTrack(
|
||||
|
||||
val chapterUpdates = sortedChapters
|
||||
.filter { chapter -> chapter.chapterNumber <= remoteTrack.lastChapterRead && !chapter.read }
|
||||
.map { it.copy(read = true).toChapterUpdate() }
|
||||
.map { ChapterUpdate(it.id) { read = true } }
|
||||
|
||||
// only take into account continuous reading
|
||||
val localLastRead = sortedChapters.takeWhile { it.read }.lastOrNull()?.chapterNumber ?: 0F
|
||||
@@ -45,7 +45,7 @@ class SyncChapterProgressWithTrack(
|
||||
try {
|
||||
tracker.update(updatedTrack.toDbTrack())
|
||||
updateChapter.awaitAll(chapterUpdates)
|
||||
insertTrack.await(updatedTrack)
|
||||
upsertTrack.await(updatedTrack)
|
||||
} catch (e: Throwable) {
|
||||
logcat(LogPriority.WARN, e)
|
||||
}
|
||||
|
||||
@@ -4,29 +4,29 @@ import android.content.Context
|
||||
import dev.zacsweers.metro.Inject
|
||||
import eu.kanade.domain.track.model.toDbTrack
|
||||
import eu.kanade.domain.track.model.toDomainTrack
|
||||
import eu.kanade.domain.track.service.DelayedTrackingUpdateJob
|
||||
import eu.kanade.domain.track.service.DelayedTrackingUpdateWorker
|
||||
import eu.kanade.domain.track.store.DelayedTrackingStore
|
||||
import eu.kanade.tachiyomi.data.track.TrackerManager
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.common.util.lang.withNonCancellableContext
|
||||
import tachiyomi.core.common.util.system.logcat
|
||||
import tachiyomi.domain.track.interactor.GetTracks
|
||||
import tachiyomi.domain.track.interactor.InsertTrack
|
||||
import tachiyomi.domain.track.interactor.UpsertTrack
|
||||
|
||||
@Inject
|
||||
class TrackChapter(
|
||||
private val getTracks: GetTracks,
|
||||
private val trackerManager: TrackerManager,
|
||||
private val insertTrack: InsertTrack,
|
||||
private val upsertTrack: UpsertTrack,
|
||||
private val delayedTrackingStore: DelayedTrackingStore,
|
||||
) {
|
||||
|
||||
suspend fun await(context: Context, mangaId: Long, chapterNumber: Double, setupJobOnFailure: Boolean = true) {
|
||||
withNonCancellableContext {
|
||||
coroutineScope {
|
||||
val tracks = getTracks.await(mangaId)
|
||||
if (tracks.isEmpty()) return@withNonCancellableContext
|
||||
if (tracks.isEmpty()) return@coroutineScope
|
||||
|
||||
tracks.mapNotNull { track ->
|
||||
val service = trackerManager.get(track.trackerId)
|
||||
@@ -41,12 +41,12 @@ class TrackChapter(
|
||||
.toDomainTrack(idRequired = true)!!
|
||||
.copy(lastChapterRead = chapterNumber)
|
||||
service.update(updatedTrack.toDbTrack(), true)
|
||||
insertTrack.await(updatedTrack)
|
||||
upsertTrack.await(updatedTrack)
|
||||
delayedTrackingStore.remove(track.id)
|
||||
} catch (e: Exception) {
|
||||
delayedTrackingStore.add(track.id, chapterNumber)
|
||||
if (setupJobOnFailure) {
|
||||
DelayedTrackingUpdateJob.setupTask(context)
|
||||
DelayedTrackingUpdateWorker.setupTask(context)
|
||||
}
|
||||
throw e
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package eu.kanade.domain.track.model
|
||||
|
||||
import mihon.core.common.extensions.toEpochMillisOrZero
|
||||
import mihon.core.common.extensions.toInstantOrNull
|
||||
import tachiyomi.domain.track.model.Track
|
||||
import eu.kanade.tachiyomi.data.database.models.Track as DbTrack
|
||||
|
||||
@@ -25,8 +27,8 @@ fun Track.toDbTrack(): DbTrack = DbTrack.create(trackerId).also {
|
||||
it.status = status
|
||||
it.score = score
|
||||
it.tracking_url = remoteUrl
|
||||
it.started_reading_date = startDate
|
||||
it.finished_reading_date = finishDate
|
||||
it.started_reading_date = startDate.toEpochMillisOrZero()
|
||||
it.finished_reading_date = finishDate.toEpochMillisOrZero()
|
||||
it.private = private
|
||||
}
|
||||
|
||||
@@ -44,8 +46,8 @@ fun DbTrack.toDomainTrack(idRequired: Boolean = true): Track? {
|
||||
status = status,
|
||||
score = score,
|
||||
remoteUrl = tracking_url,
|
||||
startDate = started_reading_date,
|
||||
finishDate = finished_reading_date,
|
||||
startDate = started_reading_date.toInstantOrNull(),
|
||||
finishDate = finished_reading_date.toInstantOrNull(),
|
||||
private = private,
|
||||
)
|
||||
}
|
||||
|
||||
+5
-4
@@ -12,15 +12,16 @@ import dev.zacsweers.metro.Inject
|
||||
import eu.kanade.domain.track.interactor.TrackChapter
|
||||
import eu.kanade.domain.track.store.DelayedTrackingStore
|
||||
import eu.kanade.tachiyomi.util.system.workManager
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import logcat.LogPriority
|
||||
import mihon.app.di.AppGraph
|
||||
import mihon.core.metro.metroGraph
|
||||
import tachiyomi.core.common.util.lang.withIOContext
|
||||
import tachiyomi.core.common.util.system.logcat
|
||||
import tachiyomi.domain.track.interactor.GetTracks
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class DelayedTrackingUpdateJob(private val context: Context, workerParams: WorkerParameters) :
|
||||
class DelayedTrackingUpdateWorker(private val context: Context, workerParams: WorkerParameters) :
|
||||
CoroutineWorker(context, workerParams) {
|
||||
|
||||
private val graph: AppGraph = context.metroGraph()
|
||||
@@ -38,7 +39,7 @@ class DelayedTrackingUpdateJob(private val context: Context, workerParams: Worke
|
||||
return Result.failure()
|
||||
}
|
||||
|
||||
withIOContext {
|
||||
withContext(Dispatchers.IO) {
|
||||
delayedTrackingStore.getItems()
|
||||
.mapNotNull {
|
||||
val track = getTracks.awaitOne(it.trackId)
|
||||
@@ -66,7 +67,7 @@ class DelayedTrackingUpdateJob(private val context: Context, workerParams: Worke
|
||||
requiredNetworkType = NetworkType.CONNECTED,
|
||||
)
|
||||
|
||||
val request = OneTimeWorkRequestBuilder<DelayedTrackingUpdateJob>()
|
||||
val request = OneTimeWorkRequestBuilder<DelayedTrackingUpdateWorker>()
|
||||
.setConstraints(constraints)
|
||||
.setBackoffCriteria(BackoffPolicy.EXPONENTIAL, 5, TimeUnit.MINUTES)
|
||||
.addTag(TAG)
|
||||
@@ -15,7 +15,7 @@ class DelayedTrackingStore(context: Context) {
|
||||
/**
|
||||
* Preference file where queued tracking updates are stored.
|
||||
*/
|
||||
private val preferences = context.getSharedPreferences("tracking_queue", Context.MODE_PRIVATE)
|
||||
private val preferences by lazy { context.getSharedPreferences("tracking_queue", Context.MODE_PRIVATE) }
|
||||
|
||||
fun add(trackId: Long, lastChapterRead: Double) {
|
||||
val previousLastChapterRead = preferences.getFloat(trackId.toString(), 0f)
|
||||
|
||||
@@ -32,31 +32,30 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.res.vectorResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import dev.icerock.moko.resources.StringResource
|
||||
import eu.kanade.domain.extension.interactor.ExtensionSourceItem
|
||||
import eu.kanade.presentation.browse.components.ExtensionIcon
|
||||
import eu.kanade.presentation.browse.components.ExtensionPill
|
||||
import eu.kanade.presentation.browse.components.label
|
||||
import eu.kanade.presentation.components.AppBar
|
||||
import eu.kanade.presentation.components.AppBarActions
|
||||
import eu.kanade.presentation.components.WarningBanner
|
||||
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
|
||||
import eu.kanade.presentation.more.settings.widget.TrailingWidgetBuffer
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.extension.model.Extension
|
||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||
import eu.kanade.tachiyomi.ui.browse.extension.details.ExtensionDetailsViewModel
|
||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.automirroredrounded.OpenInNew
|
||||
import mihon.icons.materialsymbols.rounded.Eyeglasses2
|
||||
import mihon.icons.materialsymbols.rounded.Settings
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.ScrollbarLazyColumn
|
||||
@@ -77,15 +76,6 @@ fun ExtensionDetailsScreen(
|
||||
onClickIncognito: (Boolean) -> Unit,
|
||||
) {
|
||||
val uriHandler = LocalUriHandler.current
|
||||
val url = remember(state.extension) {
|
||||
val regex = """https://raw.githubusercontent.com/(.+?)/(.+?)/.+""".toRegex()
|
||||
regex.find(state.extension.store?.indexUrl.orEmpty())
|
||||
?.let {
|
||||
val (user, repo) = it.destructured
|
||||
"https://github.com/$user/$repo"
|
||||
}
|
||||
?: state.extension.store?.indexUrl
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
topBar = { scrollBehavior ->
|
||||
@@ -94,35 +84,20 @@ fun ExtensionDetailsScreen(
|
||||
navigateUp = navigateUp,
|
||||
actions = {
|
||||
AppBarActions(
|
||||
actions = buildList {
|
||||
if (url != null) {
|
||||
add(
|
||||
AppBar.Action(
|
||||
title = stringResource(MR.strings.action_open_repo),
|
||||
icon = MaterialSymbols.AutoMirroredRounded.OpenInNew,
|
||||
onClick = {
|
||||
uriHandler.openUri(url)
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
addAll(
|
||||
listOf(
|
||||
AppBar.OverflowAction(
|
||||
title = stringResource(MR.strings.action_enable_all),
|
||||
onClick = onClickEnableAll,
|
||||
),
|
||||
AppBar.OverflowAction(
|
||||
title = stringResource(MR.strings.action_disable_all),
|
||||
onClick = onClickDisableAll,
|
||||
),
|
||||
AppBar.OverflowAction(
|
||||
title = stringResource(MR.strings.pref_clear_cookies),
|
||||
onClick = onClickClearCookies,
|
||||
),
|
||||
),
|
||||
)
|
||||
},
|
||||
actions = listOf(
|
||||
AppBar.OverflowAction(
|
||||
title = stringResource(MR.strings.action_enable_all),
|
||||
onClick = onClickEnableAll,
|
||||
),
|
||||
AppBar.OverflowAction(
|
||||
title = stringResource(MR.strings.action_disable_all),
|
||||
onClick = onClickDisableAll,
|
||||
),
|
||||
AppBar.OverflowAction(
|
||||
title = stringResource(MR.strings.pref_clear_cookies),
|
||||
onClick = onClickClearCookies,
|
||||
),
|
||||
),
|
||||
)
|
||||
},
|
||||
scrollBehavior = scrollBehavior,
|
||||
@@ -132,6 +107,11 @@ fun ExtensionDetailsScreen(
|
||||
ExtensionDetails(
|
||||
contentPadding = paddingValues,
|
||||
extension = state.extension,
|
||||
onClickStore = state.extension.store
|
||||
?.contact
|
||||
?.website
|
||||
?.takeIf { it.isNotBlank() }
|
||||
?.let { website -> { uriHandler.openUri(website) } },
|
||||
sources = state.sources,
|
||||
incognitoMode = state.isIncognito,
|
||||
onClickSourcePreferences = onClickSourcePreferences,
|
||||
@@ -146,6 +126,7 @@ fun ExtensionDetailsScreen(
|
||||
private fun ExtensionDetails(
|
||||
contentPadding: PaddingValues,
|
||||
extension: Extension.Loaded,
|
||||
onClickStore: (() -> Unit)?,
|
||||
sources: List<ExtensionSourceItem>,
|
||||
incognitoMode: Boolean,
|
||||
onClickSourcePreferences: (sourceId: Long) -> Unit,
|
||||
@@ -178,6 +159,7 @@ private fun ExtensionDetails(
|
||||
}
|
||||
Unit
|
||||
}.takeIf { extension.isShared },
|
||||
onClickStore = onClickStore,
|
||||
onClickContentWarning = {
|
||||
showContentWarning = true
|
||||
},
|
||||
@@ -210,8 +192,9 @@ private fun ExtensionDetails(
|
||||
|
||||
@Composable
|
||||
private fun DetailsHeader(
|
||||
extension: Extension,
|
||||
extension: Extension.Installed,
|
||||
extIncognitoMode: Boolean,
|
||||
onClickStore: (() -> Unit)?,
|
||||
onClickContentWarning: () -> Unit,
|
||||
onClickUninstall: () -> Unit,
|
||||
onClickAppInfo: (() -> Unit)?,
|
||||
@@ -271,12 +254,35 @@ private fun DetailsHeader(
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
|
||||
val strippedPkgName = extension.pkgName.substringAfter("eu.kanade.tachiyomi.extension.")
|
||||
|
||||
Text(
|
||||
text = strippedPkgName,
|
||||
text = extension.pkgName,
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
|
||||
extension.store?.let { store ->
|
||||
Text(
|
||||
text = store.name,
|
||||
modifier = Modifier
|
||||
.clip(MaterialTheme.shapes.small)
|
||||
.clickable(enabled = onClickStore != null) { onClickStore?.invoke() }
|
||||
.padding(
|
||||
horizontal = MaterialTheme.padding.extraSmall,
|
||||
vertical = MaterialTheme.padding.extraSmall / 2,
|
||||
),
|
||||
textAlign = TextAlign.Center,
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
)
|
||||
}
|
||||
|
||||
if ((extension as? Extension.Loaded)?.isShared == false) {
|
||||
ExtensionPill(
|
||||
text = stringResource(MR.strings.ext_installer_private),
|
||||
modifier = Modifier.padding(top = MaterialTheme.padding.small),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Row(
|
||||
@@ -334,10 +340,7 @@ private fun DetailsHeader(
|
||||
modifier = Modifier.weight(1f),
|
||||
onClick = onClickAppInfo,
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(MR.strings.ext_app_info),
|
||||
color = MaterialTheme.colorScheme.onPrimary,
|
||||
)
|
||||
Text(stringResource(MR.strings.ext_app_info))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -346,7 +349,7 @@ private fun DetailsHeader(
|
||||
modifier = Modifier.padding(horizontal = MaterialTheme.padding.small),
|
||||
title = stringResource(MR.strings.pref_incognito_mode),
|
||||
subtitle = stringResource(MR.strings.pref_incognito_mode_extension_summary),
|
||||
icon = ImageVector.vectorResource(R.drawable.ic_glasses_24dp),
|
||||
icon = MaterialSymbols.Rounded.Eyeglasses2,
|
||||
widget = {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
|
||||
@@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.RowScope
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
@@ -20,7 +21,6 @@ import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.LocalTextStyle
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ProvideTextStyle
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -30,6 +30,7 @@ import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
@@ -39,9 +40,9 @@ import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import dev.icerock.moko.resources.StringResource
|
||||
import eu.kanade.presentation.browse.components.BaseBrowseItem
|
||||
import eu.kanade.presentation.browse.components.ExtensionIcon
|
||||
import eu.kanade.presentation.browse.components.ExtensionPill
|
||||
import eu.kanade.presentation.browse.components.label
|
||||
import eu.kanade.presentation.components.WarningBanner
|
||||
import eu.kanade.presentation.manga.components.DotSeparatorNoSpaceText
|
||||
import eu.kanade.presentation.more.settings.screen.browse.ExtensionStoresScreen
|
||||
import eu.kanade.presentation.util.rememberRequestPackageInstallsPermissionState
|
||||
import eu.kanade.tachiyomi.extension.model.Extension
|
||||
@@ -51,6 +52,7 @@ import eu.kanade.tachiyomi.ui.browse.extension.ExtensionsViewModel
|
||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||
import eu.kanade.tachiyomi.util.system.launchRequestPackageInstallsPermission
|
||||
import mihon.domain.extension.model.ExtensionStore
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.rounded.Close
|
||||
import mihon.icons.materialsymbols.rounded.Download
|
||||
@@ -71,7 +73,6 @@ import tachiyomi.presentation.core.screens.EmptyScreenAction
|
||||
import tachiyomi.presentation.core.screens.LoadingScreen
|
||||
import tachiyomi.presentation.core.theme.header
|
||||
import tachiyomi.presentation.core.util.plus
|
||||
import tachiyomi.presentation.core.util.secondaryItemAlpha
|
||||
|
||||
@Composable
|
||||
fun ExtensionScreen(
|
||||
@@ -83,7 +84,7 @@ fun ExtensionScreen(
|
||||
onOpenWebView: (Extension.Available) -> Unit,
|
||||
onInstallExtension: (Extension.Available) -> Unit,
|
||||
onUninstallExtension: (Extension.Installed) -> Unit,
|
||||
onUpdateExtension: (Extension.Loaded) -> Unit,
|
||||
onUpdateExtension: (Extension.Installed) -> Unit,
|
||||
onTrustExtension: (Extension.NotLoaded) -> Unit,
|
||||
onOpenExtension: (Extension.Loaded) -> Unit,
|
||||
onClickUpdateAll: () -> Unit,
|
||||
@@ -144,7 +145,7 @@ private fun ExtensionContent(
|
||||
onOpenWebView: (Extension.Available) -> Unit,
|
||||
onInstallExtension: (Extension.Available) -> Unit,
|
||||
onUninstallExtension: (Extension.Installed) -> Unit,
|
||||
onUpdateExtension: (Extension.Loaded) -> Unit,
|
||||
onUpdateExtension: (Extension.Installed) -> Unit,
|
||||
onTrustExtension: (Extension.NotLoaded) -> Unit,
|
||||
onOpenExtension: (Extension.Loaded) -> Unit,
|
||||
onClickUpdateAll: () -> Unit,
|
||||
@@ -232,7 +233,9 @@ private fun ExtensionContent(
|
||||
when (it) {
|
||||
is Extension.Available -> onOpenWebView(it)
|
||||
is Extension.Loaded -> onOpenExtension(it)
|
||||
else -> {}
|
||||
is Extension.NotLoaded -> {
|
||||
notLoadedState = it
|
||||
}
|
||||
}
|
||||
},
|
||||
onClickItemCancel = onClickItemCancel,
|
||||
@@ -247,7 +250,11 @@ private fun ExtensionContent(
|
||||
}
|
||||
}
|
||||
is Extension.NotLoaded -> {
|
||||
notLoadedState = it
|
||||
if (it.hasUpdate) {
|
||||
onUpdateExtension(it)
|
||||
} else {
|
||||
notLoadedState = it
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -293,39 +300,17 @@ private fun ExtensionItem(
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val (extension, installStep) = item
|
||||
val store = when (extension) {
|
||||
is Extension.Available -> extension.store
|
||||
is Extension.Installed -> extension.store
|
||||
}
|
||||
|
||||
BaseBrowseItem(
|
||||
modifier = modifier
|
||||
.combinedClickable(
|
||||
onClick = { onClickItem(extension) },
|
||||
onLongClick = { onLongClickItem(extension) },
|
||||
),
|
||||
modifier = modifier,
|
||||
onClickItem = { onClickItem(extension) },
|
||||
onLongClickItem = { onLongClickItem(extension) },
|
||||
icon = {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(40.dp),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
val idle = installStep.isCompleted()
|
||||
if (!idle) {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier.size(40.dp),
|
||||
strokeWidth = 2.dp,
|
||||
)
|
||||
}
|
||||
|
||||
val padding by animateDpAsState(
|
||||
targetValue = if (idle) 0.dp else 8.dp,
|
||||
label = "iconPadding",
|
||||
)
|
||||
ExtensionIcon(
|
||||
extension = extension,
|
||||
modifier = Modifier
|
||||
.matchParentSize()
|
||||
.padding(padding),
|
||||
)
|
||||
}
|
||||
ExtensionItemIcon(extension = extension, installStep = installStep)
|
||||
},
|
||||
action = {
|
||||
ExtensionItemActions(
|
||||
@@ -340,6 +325,7 @@ private fun ExtensionItem(
|
||||
ExtensionItemContent(
|
||||
extension = extension,
|
||||
installStep = installStep,
|
||||
store = store,
|
||||
modifier = Modifier.weight(1f),
|
||||
)
|
||||
}
|
||||
@@ -349,6 +335,7 @@ private fun ExtensionItem(
|
||||
private fun ExtensionItemContent(
|
||||
extension: Extension,
|
||||
installStep: InstallStep,
|
||||
store: ExtensionStore?,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Column(
|
||||
@@ -360,68 +347,106 @@ private fun ExtensionItemContent(
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
// Won't look good but it's not like we can ellipsize overflowing content
|
||||
FlowRow(
|
||||
modifier = Modifier.secondaryItemAlpha(),
|
||||
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.extraSmall),
|
||||
) {
|
||||
ProvideTextStyle(value = MaterialTheme.typography.bodySmall) {
|
||||
var hasAlreadyShownAnElement by remember { mutableStateOf(false) }
|
||||
if (extension is Extension.Loaded && extension.lang.isNotEmpty()) {
|
||||
hasAlreadyShownAnElement = true
|
||||
Text(
|
||||
text = LocaleHelper.getSourceDisplayName(extension.lang, LocalContext.current),
|
||||
)
|
||||
}
|
||||
|
||||
if (extension.versionName.isNotEmpty()) {
|
||||
if (hasAlreadyShownAnElement) DotSeparatorNoSpaceText()
|
||||
hasAlreadyShownAnElement = true
|
||||
Text(
|
||||
text = extension.versionName,
|
||||
)
|
||||
}
|
||||
if (store != null) {
|
||||
Text(
|
||||
text = store.name,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
|
||||
val warnings = listOfNotNull(
|
||||
when {
|
||||
extension is Extension.NotLoaded ->
|
||||
extension.reason.labelRes?.let { it to MaterialTheme.colorScheme.error }
|
||||
extension is Extension.Loaded && extension.isObsolete ->
|
||||
MR.strings.ext_obsolete to MaterialTheme.colorScheme.error
|
||||
else -> null
|
||||
},
|
||||
extension.contentWarning.label?.let { it.title to it.color },
|
||||
)
|
||||
warnings.forEach { (label, color) ->
|
||||
if (hasAlreadyShownAnElement) DotSeparatorNoSpaceText()
|
||||
hasAlreadyShownAnElement = true
|
||||
Text(
|
||||
text = stringResource(label).uppercase(),
|
||||
color = color,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
ExtensionItemMetadata(extension = extension, installStep = installStep)
|
||||
}
|
||||
}
|
||||
|
||||
if (extension is Extension.Loaded && !extension.isShared) {
|
||||
if (hasAlreadyShownAnElement) DotSeparatorNoSpaceText()
|
||||
Text(
|
||||
text = stringResource(MR.strings.ext_installer_private),
|
||||
)
|
||||
}
|
||||
@Composable
|
||||
private fun ExtensionItemIcon(
|
||||
extension: Extension,
|
||||
installStep: InstallStep,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Box(
|
||||
modifier = modifier.size(48.dp),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
val idle = installStep.isCompleted()
|
||||
if (!idle) {
|
||||
CircularProgressIndicator(
|
||||
modifier = Modifier.size(48.dp),
|
||||
strokeWidth = 2.dp,
|
||||
)
|
||||
}
|
||||
|
||||
if (!installStep.isCompleted()) {
|
||||
DotSeparatorNoSpaceText()
|
||||
Text(
|
||||
text = when (installStep) {
|
||||
InstallStep.Pending -> stringResource(MR.strings.ext_pending)
|
||||
InstallStep.Downloading -> stringResource(MR.strings.ext_downloading)
|
||||
InstallStep.Installing -> stringResource(MR.strings.ext_installing)
|
||||
else -> error("Must not show non-install process text")
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
val padding by animateDpAsState(
|
||||
targetValue = if (idle) 0.dp else 8.dp,
|
||||
label = "iconPadding",
|
||||
)
|
||||
ExtensionIcon(
|
||||
extension = extension,
|
||||
modifier = Modifier
|
||||
.matchParentSize()
|
||||
.padding(padding),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Plain text for what an extension simply is, pills for the few things worth noticing about it.
|
||||
* Won't look good when it wraps, but it's not like overflowing content can be ellipsized.
|
||||
*/
|
||||
@Composable
|
||||
private fun ExtensionItemMetadata(
|
||||
extension: Extension,
|
||||
installStep: InstallStep,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
FlowRow(
|
||||
modifier = modifier,
|
||||
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.extraSmall),
|
||||
verticalArrangement = Arrangement.spacedBy(MaterialTheme.padding.extraSmall / 2),
|
||||
itemVerticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
val facts = listOfNotNull(
|
||||
(extension as? Extension.Loaded)
|
||||
?.lang
|
||||
?.takeIf { it.isNotEmpty() }
|
||||
?.let { LocaleHelper.getSourceDisplayName(it, LocalContext.current) },
|
||||
extension.versionName.takeIf { it.isNotEmpty() },
|
||||
)
|
||||
if (facts.isNotEmpty()) {
|
||||
Text(
|
||||
text = facts.joinToString(" \u2022 "),
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
)
|
||||
}
|
||||
|
||||
val notable = listOfNotNull(
|
||||
when (installStep) {
|
||||
InstallStep.Pending -> MR.strings.ext_pending
|
||||
InstallStep.Downloading -> MR.strings.ext_downloading
|
||||
InstallStep.Installing -> MR.strings.ext_installing
|
||||
else -> null
|
||||
}?.let { it to MaterialTheme.colorScheme.primary },
|
||||
when {
|
||||
extension is Extension.NotLoaded ->
|
||||
extension.reason.labelRes?.let { it to MaterialTheme.colorScheme.error }
|
||||
extension is Extension.Loaded && extension.isObsolete ->
|
||||
MR.strings.ext_obsolete to MaterialTheme.colorScheme.error
|
||||
else -> null
|
||||
},
|
||||
extension.contentWarning.label?.let { it.title to it.color },
|
||||
(extension as? Extension.Loaded)
|
||||
?.takeIf { !it.isShared }
|
||||
?.let { MR.strings.ext_installer_private to MaterialTheme.colorScheme.onSurfaceVariant },
|
||||
)
|
||||
notable.forEach { (label, color) ->
|
||||
ExtensionPill(text = stringResource(label), color = color)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -435,85 +460,50 @@ private fun ExtensionItemActions(
|
||||
onClickItemAction: (Extension) -> Unit = {},
|
||||
onClickItemSecondaryAction: (Extension) -> Unit = {},
|
||||
) {
|
||||
val isIdle = installStep.isCompleted()
|
||||
|
||||
Row(
|
||||
modifier = modifier,
|
||||
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
when {
|
||||
!isIdle -> {
|
||||
IconButton(onClick = { onClickItemCancel(extension) }) {
|
||||
Icon(
|
||||
imageVector = MaterialSymbols.Rounded.Close,
|
||||
contentDescription = stringResource(MR.strings.action_cancel),
|
||||
)
|
||||
}
|
||||
if (!installStep.isCompleted()) {
|
||||
IconButton(onClick = { onClickItemCancel(extension) }) {
|
||||
Icon(
|
||||
imageVector = MaterialSymbols.Rounded.Close,
|
||||
contentDescription = stringResource(MR.strings.action_cancel),
|
||||
)
|
||||
}
|
||||
installStep == InstallStep.Error -> {
|
||||
IconButton(onClick = { onClickItemAction(extension) }) {
|
||||
Icon(
|
||||
imageVector = MaterialSymbols.Rounded.Refresh,
|
||||
contentDescription = stringResource(MR.strings.action_retry),
|
||||
)
|
||||
}
|
||||
return@Row
|
||||
}
|
||||
|
||||
val secondaryAction = when (extension) {
|
||||
is Extension.Available -> {
|
||||
(MaterialSymbols.Rounded.Public to MR.strings.action_open_in_web_view)
|
||||
.takeIf { extension.sources.isNotEmpty() }
|
||||
}
|
||||
installStep == InstallStep.Idle -> {
|
||||
when (extension) {
|
||||
is Extension.Loaded -> {
|
||||
IconButton(onClick = { onClickItemSecondaryAction(extension) }) {
|
||||
Icon(
|
||||
imageVector = MaterialSymbols.Rounded.Settings,
|
||||
contentDescription = stringResource(MR.strings.action_settings),
|
||||
)
|
||||
}
|
||||
is Extension.Loaded -> MaterialSymbols.Rounded.Settings to MR.strings.action_settings
|
||||
is Extension.NotLoaded -> if (extension.reason is Extension.NotLoaded.Reason.Untrusted) {
|
||||
MaterialSymbols.Rounded.VerifiedUser to MR.strings.ext_trust
|
||||
} else {
|
||||
MaterialSymbols.Rounded.Info to MR.strings.ext_not_loaded_details
|
||||
}
|
||||
}
|
||||
secondaryAction?.let { (icon, label) ->
|
||||
IconButton(onClick = { onClickItemSecondaryAction(extension) }) {
|
||||
Icon(imageVector = icon, contentDescription = stringResource(label))
|
||||
}
|
||||
}
|
||||
|
||||
if (extension.hasUpdate) {
|
||||
IconButton(onClick = { onClickItemAction(extension) }) {
|
||||
Icon(
|
||||
imageVector = MaterialSymbols.Rounded.Download,
|
||||
contentDescription = stringResource(MR.strings.ext_update),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
is Extension.NotLoaded -> {
|
||||
val isUntrusted = extension.reason is Extension.NotLoaded.Reason.Untrusted
|
||||
IconButton(onClick = { onClickItemAction(extension) }) {
|
||||
Icon(
|
||||
imageVector = if (isUntrusted) {
|
||||
MaterialSymbols.Rounded.VerifiedUser
|
||||
} else {
|
||||
MaterialSymbols.Rounded.Info
|
||||
},
|
||||
contentDescription = if (isUntrusted) {
|
||||
stringResource(MR.strings.ext_trust)
|
||||
} else {
|
||||
stringResource(MR.strings.ext_not_loaded)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
is Extension.Available -> {
|
||||
if (extension.sources.isNotEmpty()) {
|
||||
IconButton(
|
||||
onClick = { onClickItemSecondaryAction(extension) },
|
||||
) {
|
||||
Icon(
|
||||
imageVector = MaterialSymbols.Rounded.Public,
|
||||
contentDescription = stringResource(MR.strings.action_open_in_web_view),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
IconButton(onClick = { onClickItemAction(extension) }) {
|
||||
Icon(
|
||||
imageVector = MaterialSymbols.Rounded.Download,
|
||||
contentDescription = stringResource(MR.strings.ext_install),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
val action = when {
|
||||
installStep == InstallStep.Error -> MaterialSymbols.Rounded.Refresh to MR.strings.action_retry
|
||||
extension is Extension.Available -> MaterialSymbols.Rounded.Download to MR.strings.ext_install
|
||||
extension is Extension.Installed && extension.hasUpdate -> {
|
||||
MaterialSymbols.Rounded.Download to MR.strings.ext_update
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
action?.let { (icon, label) ->
|
||||
IconButton(onClick = { onClickItemAction(extension) }) {
|
||||
Icon(imageVector = icon, contentDescription = stringResource(label))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
@@ -16,6 +17,7 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import eu.kanade.domain.source.interactor.SetMigrateSorting
|
||||
import eu.kanade.presentation.browse.components.BaseSourceItem
|
||||
import eu.kanade.presentation.browse.components.SourceIcon
|
||||
@@ -156,7 +158,7 @@ private fun MigrateSourceItem(
|
||||
showLanguageInContent = source.lang != "",
|
||||
onClickItem = onClickItem,
|
||||
onLongClickItem = onLongClickItem,
|
||||
icon = { SourceIcon(source = source) },
|
||||
icon = { SourceIcon(source = source, modifier = Modifier.size(48.dp)) },
|
||||
action = {
|
||||
BadgeGroup {
|
||||
Badge(text = "$count")
|
||||
|
||||
@@ -22,8 +22,8 @@ import eu.kanade.tachiyomi.ui.browse.source.SourcesViewModel
|
||||
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceViewModel.Listing
|
||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.rounded.PushPin
|
||||
import mihon.icons.materialsymbols.roundedfilled.PushPin
|
||||
import mihon.icons.materialsymbols.rounded.Keep
|
||||
import mihon.icons.materialsymbols.roundedfilled.Keep
|
||||
import tachiyomi.domain.source.model.Pin
|
||||
import tachiyomi.domain.source.model.Source
|
||||
import tachiyomi.i18n.MR
|
||||
@@ -143,7 +143,7 @@ private fun SourcePinButton(
|
||||
isPinned: Boolean,
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
val icon = if (isPinned) MaterialSymbols.RoundedFilled.PushPin else MaterialSymbols.Rounded.PushPin
|
||||
val icon = if (isPinned) MaterialSymbols.RoundedFilled.Keep else MaterialSymbols.Rounded.Keep
|
||||
val tint = if (isPinned) {
|
||||
MaterialTheme.colorScheme.primary
|
||||
} else {
|
||||
|
||||
@@ -3,12 +3,14 @@ package eu.kanade.presentation.browse.components
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.RowScope
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||
import tachiyomi.domain.source.model.Source
|
||||
import tachiyomi.presentation.core.components.material.padding
|
||||
@@ -39,7 +41,7 @@ fun BaseSourceItem(
|
||||
}
|
||||
|
||||
private val defaultIcon: @Composable RowScope.(Source) -> Unit = { source ->
|
||||
SourceIcon(source = source)
|
||||
SourceIcon(source = source, modifier = Modifier.size(48.dp))
|
||||
}
|
||||
|
||||
private val defaultContent: @Composable RowScope.(Source, String?) -> Unit = { source, sourceLangString ->
|
||||
|
||||
@@ -2,36 +2,26 @@ package eu.kanade.presentation.browse.components
|
||||
|
||||
import android.util.DisplayMetrics
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.produceState
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.ColorFilter
|
||||
import androidx.compose.ui.graphics.ImageBitmap
|
||||
import androidx.compose.ui.graphics.asImageBitmap
|
||||
import androidx.compose.ui.graphics.painter.ColorPainter
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.imageResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import coil3.compose.AsyncImage
|
||||
import eu.kanade.domain.source.model.icon
|
||||
import eu.kanade.presentation.util.rememberResourceBitmapPainter
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.coil.InstalledExtensionIcon
|
||||
import eu.kanade.tachiyomi.data.coil.InstalledSourceIcon
|
||||
import eu.kanade.tachiyomi.extension.model.Extension
|
||||
import eu.kanade.tachiyomi.extension.util.ExtensionLoader
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.rounded.Dangerous
|
||||
import mihon.icons.materialsymbols.rounded.Warning
|
||||
import tachiyomi.core.common.util.lang.withIOContext
|
||||
import mihon.icons.materialsymbols.roundedfilled.Dangerous
|
||||
import mihon.icons.materialsymbols.roundedfilled.Warning
|
||||
import tachiyomi.domain.source.model.Source
|
||||
import tachiyomi.source.local.isLocal
|
||||
|
||||
@@ -44,24 +34,15 @@ fun SourceIcon(
|
||||
source: Source,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val icon = produceState<ImageBitmap?>(initialValue = null, source.id) { value = source.icon() }.value
|
||||
|
||||
when {
|
||||
source.isStub && icon == null -> {
|
||||
source.isStub -> {
|
||||
Image(
|
||||
imageVector = MaterialSymbols.Rounded.Warning,
|
||||
imageVector = MaterialSymbols.RoundedFilled.Warning,
|
||||
contentDescription = null,
|
||||
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.error),
|
||||
modifier = modifier.then(defaultModifier),
|
||||
)
|
||||
}
|
||||
icon != null -> {
|
||||
Image(
|
||||
bitmap = icon,
|
||||
contentDescription = null,
|
||||
modifier = modifier.then(defaultModifier),
|
||||
)
|
||||
}
|
||||
source.isLocal() -> {
|
||||
Image(
|
||||
painter = painterResource(R.mipmap.ic_local_source),
|
||||
@@ -70,9 +51,12 @@ fun SourceIcon(
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
Image(
|
||||
painter = painterResource(R.mipmap.ic_default_source),
|
||||
val defaultIcon = painterResource(R.mipmap.ic_default_source)
|
||||
AsyncImage(
|
||||
model = InstalledSourceIcon(source.id),
|
||||
contentDescription = null,
|
||||
placeholder = defaultIcon,
|
||||
error = defaultIcon,
|
||||
modifier = modifier.then(defaultModifier),
|
||||
)
|
||||
}
|
||||
@@ -97,52 +81,20 @@ fun ExtensionIcon(
|
||||
)
|
||||
}
|
||||
is Extension.Loaded -> {
|
||||
val icon by extension.getIcon(density)
|
||||
when (icon) {
|
||||
Result.Loading -> Box(modifier = modifier)
|
||||
is Result.Success -> Image(
|
||||
bitmap = (icon as Result.Success<ImageBitmap>).value,
|
||||
contentDescription = null,
|
||||
modifier = modifier,
|
||||
)
|
||||
Result.Error -> Image(
|
||||
bitmap = ImageBitmap.imageResource(id = R.mipmap.ic_default_source),
|
||||
contentDescription = null,
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
val defaultIcon = painterResource(R.mipmap.ic_default_source)
|
||||
AsyncImage(
|
||||
model = InstalledExtensionIcon(extension.pkgName, extension.versionCode, density),
|
||||
contentDescription = null,
|
||||
placeholder = defaultIcon,
|
||||
error = defaultIcon,
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
is Extension.NotLoaded -> Image(
|
||||
imageVector = MaterialSymbols.Rounded.Dangerous,
|
||||
imageVector = MaterialSymbols.RoundedFilled.Dangerous,
|
||||
contentDescription = null,
|
||||
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.error),
|
||||
modifier = modifier.then(defaultModifier),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun Extension.getIcon(density: Int = DisplayMetrics.DENSITY_DEFAULT): State<Result<ImageBitmap>> {
|
||||
val context = LocalContext.current
|
||||
return produceState<Result<ImageBitmap>>(initialValue = Result.Loading, this) {
|
||||
withIOContext {
|
||||
value = try {
|
||||
val appInfo = ExtensionLoader.getExtensionPackageInfoFromPkgName(context, pkgName)!!.applicationInfo!!
|
||||
val appResources = context.packageManager.getResourcesForApplication(appInfo)
|
||||
Result.Success(
|
||||
appResources.getDrawableForDensity(appInfo.icon, density, null)!!
|
||||
.toBitmap()
|
||||
.asImageBitmap(),
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Result.Error
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sealed class Result<out T> {
|
||||
data object Loading : Result<Nothing>()
|
||||
data object Error : Result<Nothing>()
|
||||
data class Success<out T>(val value: T) : Result<T>()
|
||||
}
|
||||
|
||||
@@ -16,8 +16,9 @@ import eu.kanade.presentation.components.SearchToolbar
|
||||
import eu.kanade.tachiyomi.source.ConfigurableSource
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.automirroredrounded.ViewList
|
||||
import mihon.icons.materialsymbols.rounded.ViewModule
|
||||
import mihon.icons.materialsymbols.automirroredroundedfilled.ViewList
|
||||
import mihon.icons.materialsymbols.roundedfilled.ViewCompact
|
||||
import mihon.icons.materialsymbols.roundedfilled.ViewModule
|
||||
import tachiyomi.domain.library.model.LibraryDisplayMode
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
@@ -57,10 +58,12 @@ fun BrowseSourceToolbar(
|
||||
add(
|
||||
AppBar.Action(
|
||||
title = stringResource(MR.strings.action_display_mode),
|
||||
icon = if (displayMode == LibraryDisplayMode.List) {
|
||||
MaterialSymbols.AutoMirroredRounded.ViewList
|
||||
} else {
|
||||
MaterialSymbols.Rounded.ViewModule
|
||||
icon = when (displayMode) {
|
||||
LibraryDisplayMode.List -> MaterialSymbols.AutoMirroredRoundedFilled.ViewList
|
||||
LibraryDisplayMode.ComfortableGrid -> MaterialSymbols.RoundedFilled.ViewModule
|
||||
LibraryDisplayMode.CompactGrid,
|
||||
LibraryDisplayMode.CoverOnlyGrid,
|
||||
-> MaterialSymbols.RoundedFilled.ViewCompact
|
||||
},
|
||||
onClick = { selectingDisplayMode = true },
|
||||
),
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package eu.kanade.presentation.browse.components
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import tachiyomi.presentation.core.components.material.padding
|
||||
|
||||
@Composable
|
||||
internal fun ExtensionPill(
|
||||
text: String,
|
||||
modifier: Modifier = Modifier,
|
||||
color: Color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
) {
|
||||
Text(
|
||||
text = text,
|
||||
modifier = modifier
|
||||
.background(color = color.copy(alpha = PILL_BACKGROUND_ALPHA), shape = MaterialTheme.shapes.small)
|
||||
.padding(horizontal = MaterialTheme.padding.small, vertical = 2.dp),
|
||||
color = color,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
)
|
||||
}
|
||||
|
||||
private const val PILL_BACKGROUND_ALPHA = 0.12f
|
||||
+2
-2
@@ -22,7 +22,7 @@ import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.automirroredrounded.ArrowForward
|
||||
import mihon.icons.materialsymbols.rounded.Error
|
||||
import mihon.icons.materialsymbols.roundedfilled.Error
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.material.padding
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
@@ -90,7 +90,7 @@ fun GlobalSearchErrorResultItem(message: String?) {
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Icon(imageVector = MaterialSymbols.Rounded.Error, contentDescription = null)
|
||||
Icon(imageVector = MaterialSymbols.RoundedFilled.Error, contentDescription = null)
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Text(
|
||||
text = message ?: stringResource(MR.strings.unknown_error),
|
||||
|
||||
@@ -28,7 +28,7 @@ import eu.kanade.tachiyomi.ui.browse.source.globalsearch.SourceFilter
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.rounded.DoneAll
|
||||
import mihon.icons.materialsymbols.rounded.FilterList
|
||||
import mihon.icons.materialsymbols.rounded.PushPin
|
||||
import mihon.icons.materialsymbols.rounded.Keep
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.material.padding
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
@@ -82,7 +82,7 @@ fun GlobalSearchToolbar(
|
||||
onClick = { onChangeSearchFilter(SourceFilter.PinnedOnly) },
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
imageVector = MaterialSymbols.Rounded.PushPin,
|
||||
imageVector = MaterialSymbols.Rounded.Keep,
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.size(FilterChipDefaults.IconSize),
|
||||
|
||||
@@ -110,7 +110,7 @@ fun CategoryRenameDialog(
|
||||
onDismissRequest = onDismissRequest,
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
enabled = valueHasChanged && !nameAlreadyExists,
|
||||
enabled = valueHasChanged && name.isNotEmpty() && !nameAlreadyExists,
|
||||
onClick = {
|
||||
onRename(name)
|
||||
onDismissRequest()
|
||||
|
||||
@@ -15,13 +15,10 @@ import kotlin.time.Instant
|
||||
|
||||
@Composable
|
||||
fun relativeDateText(
|
||||
dateEpochMillis: Long,
|
||||
date: Instant?,
|
||||
): String {
|
||||
return relativeDateText(
|
||||
localDate = Instant.fromEpochMilliseconds(dateEpochMillis)
|
||||
.toLocalDateTime(TimeZone.currentSystemDefault())
|
||||
.date
|
||||
.takeIf { dateEpochMillis != 0L },
|
||||
localDate = date?.toLocalDateTime(TimeZone.currentSystemDefault())?.date,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,10 @@ import kotlinx.datetime.TimeZone
|
||||
import kotlinx.datetime.toLocalDateTime
|
||||
import tachiyomi.domain.history.model.HistoryWithRelations
|
||||
import tachiyomi.domain.manga.model.MangaCover
|
||||
import java.util.Date
|
||||
import kotlin.random.Random
|
||||
import kotlin.time.Clock
|
||||
import kotlin.time.Duration.Companion.days
|
||||
import kotlin.time.Instant
|
||||
import kotlin.time.toJavaInstant
|
||||
|
||||
class HistoryviewModelStateProvider : PreviewParameterProvider<HistoryViewModel.State> {
|
||||
|
||||
@@ -99,14 +97,14 @@ class HistoryviewModelStateProvider : PreviewParameterProvider<HistoryViewModel.
|
||||
mangaId = Random.nextLong(),
|
||||
title = "Test Title",
|
||||
chapterNumber = Random.nextDouble(),
|
||||
readAt = Date.from(Clock.System.now().toJavaInstant()),
|
||||
readAt = Clock.System.now(),
|
||||
readDuration = Random.nextLong(),
|
||||
coverData = MangaCover(
|
||||
mangaId = Random.nextLong(),
|
||||
sourceId = Random.nextLong(),
|
||||
isMangaFavorite = Random.nextBoolean(),
|
||||
url = "https://example.com/cover.png",
|
||||
lastModified = Random.nextLong(),
|
||||
lastModified = Instant.fromEpochMilliseconds(Random.nextLong()),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
+6
-6
@@ -2,7 +2,7 @@ package eu.kanade.presentation.history.components
|
||||
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||
import tachiyomi.domain.history.model.HistoryWithRelations
|
||||
import java.util.Date
|
||||
import kotlin.time.Instant
|
||||
|
||||
internal class HistoryWithRelationsProvider : PreviewParameterProvider<HistoryWithRelations> {
|
||||
|
||||
@@ -12,14 +12,14 @@ internal class HistoryWithRelationsProvider : PreviewParameterProvider<HistoryWi
|
||||
mangaId = 3L,
|
||||
title = "Test Title",
|
||||
chapterNumber = 10.2,
|
||||
readAt = Date(1697247357L),
|
||||
readAt = Instant.fromEpochMilliseconds(1697247357L),
|
||||
readDuration = 123L,
|
||||
coverData = tachiyomi.domain.manga.model.MangaCover(
|
||||
mangaId = 3L,
|
||||
sourceId = 4L,
|
||||
isMangaFavorite = false,
|
||||
url = "https://example.com/cover.png",
|
||||
lastModified = 5L,
|
||||
lastModified = Instant.fromEpochMilliseconds(5L),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -36,7 +36,7 @@ internal class HistoryWithRelationsProvider : PreviewParameterProvider<HistoryWi
|
||||
sourceId = 4L,
|
||||
isMangaFavorite = false,
|
||||
url = "https://example.com/cover.png",
|
||||
lastModified = 5L,
|
||||
lastModified = Instant.fromEpochMilliseconds(5L),
|
||||
),
|
||||
)
|
||||
|
||||
@@ -46,14 +46,14 @@ internal class HistoryWithRelationsProvider : PreviewParameterProvider<HistoryWi
|
||||
mangaId = 3L,
|
||||
title = "Test Title",
|
||||
chapterNumber = -2.0,
|
||||
readAt = Date(1697247357L),
|
||||
readAt = Instant.fromEpochMilliseconds(1697247357L),
|
||||
readDuration = 123L,
|
||||
coverData = tachiyomi.domain.manga.model.MangaCover(
|
||||
mangaId = 3L,
|
||||
sourceId = 4L,
|
||||
isMangaFavorite = false,
|
||||
url = "https://example.com/cover.png",
|
||||
lastModified = 5L,
|
||||
lastModified = Instant.fromEpochMilliseconds(5L),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ fun LibraryContent(
|
||||
onContinueReadingClicked: ((LibraryManga) -> Unit)?,
|
||||
onToggleSelection: (Category, LibraryManga) -> Unit,
|
||||
onToggleRangeSelection: (Category, LibraryManga) -> Unit,
|
||||
onRefresh: () -> Boolean,
|
||||
onRefresh: suspend () -> Boolean,
|
||||
onGlobalSearchClicked: () -> Unit,
|
||||
getItemCountForCategory: (Category) -> Int?,
|
||||
getDisplayMode: (Int) -> PreferenceMutableState<LibraryDisplayMode>,
|
||||
@@ -80,9 +80,8 @@ fun LibraryContent(
|
||||
refreshing = isRefreshing,
|
||||
enabled = selection.isEmpty(),
|
||||
onRefresh = {
|
||||
val started = onRefresh()
|
||||
if (!started) return@PullRefresh
|
||||
scope.launch {
|
||||
if (!onRefresh()) return@launch
|
||||
// Fake refresh status but hide it after a second as it's a long running task
|
||||
isRefreshing = true
|
||||
delay(1.seconds)
|
||||
|
||||
@@ -31,7 +31,7 @@ import eu.kanade.presentation.components.TabbedDialog
|
||||
import eu.kanade.presentation.components.TabbedDialogPaddings
|
||||
import mihon.app.di.appGraph
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.rounded.PeopleAlt
|
||||
import mihon.icons.materialsymbols.rounded.Group
|
||||
import tachiyomi.core.common.preference.TriState
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.i18n.MR
|
||||
@@ -174,7 +174,7 @@ fun ScanlatorFilterItem(
|
||||
horizontalArrangement = Arrangement.spacedBy(24.dp),
|
||||
) {
|
||||
Icon(
|
||||
imageVector = MaterialSymbols.Rounded.PeopleAlt,
|
||||
imageVector = MaterialSymbols.Rounded.Group,
|
||||
contentDescription = null,
|
||||
tint = if (active) {
|
||||
MaterialTheme.colorScheme.active
|
||||
|
||||
@@ -58,14 +58,14 @@ import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.rounded.Add
|
||||
import mihon.icons.materialsymbols.rounded.AttachMoney
|
||||
import mihon.icons.materialsymbols.rounded.Block
|
||||
import mihon.icons.materialsymbols.rounded.Brush
|
||||
import mihon.icons.materialsymbols.rounded.Check
|
||||
import mihon.icons.materialsymbols.rounded.Close
|
||||
import mihon.icons.materialsymbols.rounded.Done
|
||||
import mihon.icons.materialsymbols.rounded.DoneAll
|
||||
import mihon.icons.materialsymbols.rounded.Pause
|
||||
import mihon.icons.materialsymbols.rounded.Person
|
||||
import mihon.icons.materialsymbols.rounded.Schedule
|
||||
import mihon.icons.materialsymbols.rounded.Warning
|
||||
import mihon.icons.materialsymbols.roundedfilled.Brush
|
||||
import mihon.icons.materialsymbols.roundedfilled.Pause
|
||||
import mihon.icons.materialsymbols.roundedfilled.Warning
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.manga.model.MangaWithChapterCount
|
||||
import tachiyomi.domain.source.model.StubSource
|
||||
@@ -238,7 +238,7 @@ private fun DuplicateMangaListItem(
|
||||
if (!manga.artist.isNullOrBlank() && manga.author != manga.artist) {
|
||||
MangaDetailRow(
|
||||
text = manga.artist!!,
|
||||
iconImageVector = MaterialSymbols.Rounded.Brush,
|
||||
iconImageVector = MaterialSymbols.RoundedFilled.Brush,
|
||||
maxLines = 2,
|
||||
)
|
||||
}
|
||||
@@ -257,9 +257,9 @@ private fun DuplicateMangaListItem(
|
||||
SManga.ONGOING.toLong() -> MaterialSymbols.Rounded.Schedule
|
||||
SManga.COMPLETED.toLong() -> MaterialSymbols.Rounded.DoneAll
|
||||
SManga.LICENSED.toLong() -> MaterialSymbols.Rounded.AttachMoney
|
||||
SManga.PUBLISHING_FINISHED.toLong() -> MaterialSymbols.Rounded.Done
|
||||
SManga.PUBLISHING_FINISHED.toLong() -> MaterialSymbols.Rounded.Check
|
||||
SManga.CANCELLED.toLong() -> MaterialSymbols.Rounded.Close
|
||||
SManga.ON_HIATUS.toLong() -> MaterialSymbols.Rounded.Pause
|
||||
SManga.ON_HIATUS.toLong() -> MaterialSymbols.RoundedFilled.Pause
|
||||
else -> MaterialSymbols.Rounded.Block
|
||||
},
|
||||
)
|
||||
@@ -272,7 +272,7 @@ private fun DuplicateMangaListItem(
|
||||
) {
|
||||
if (source is StubSource) {
|
||||
Icon(
|
||||
imageVector = MaterialSymbols.Rounded.Warning,
|
||||
imageVector = MaterialSymbols.RoundedFilled.Warning,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(16.dp),
|
||||
tint = MaterialTheme.colorScheme.error,
|
||||
|
||||
@@ -15,6 +15,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.only
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.systemBars
|
||||
import androidx.compose.foundation.layout.wrapContentWidth
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.LazyListScope
|
||||
import androidx.compose.foundation.lazy.items
|
||||
@@ -63,7 +64,6 @@ import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.roundedfilled.PlayArrow
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
import tachiyomi.domain.chapter.service.missingChaptersCount
|
||||
import tachiyomi.domain.library.service.LibraryPreferences
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
import tachiyomi.domain.source.model.StubSource
|
||||
@@ -88,6 +88,7 @@ fun MangaScreen(
|
||||
navigateUp: () -> Unit,
|
||||
onChapterClicked: (Chapter) -> Unit,
|
||||
onDownloadChapter: ((List<ChapterList.Item>, ChapterDownloadAction) -> Unit)?,
|
||||
downloadProgressProvider: (chapterId: Long) -> Int,
|
||||
onAddToLibraryClicked: () -> Unit,
|
||||
onWebViewClicked: (() -> Unit)?,
|
||||
onWebViewLongClicked: (() -> Unit)?,
|
||||
@@ -143,6 +144,7 @@ fun MangaScreen(
|
||||
navigateUp = navigateUp,
|
||||
onChapterClicked = onChapterClicked,
|
||||
onDownloadChapter = onDownloadChapter,
|
||||
downloadProgressProvider = downloadProgressProvider,
|
||||
onAddToLibraryClicked = onAddToLibraryClicked,
|
||||
onWebViewClicked = onWebViewClicked,
|
||||
onWebViewLongClicked = onWebViewLongClicked,
|
||||
@@ -179,6 +181,7 @@ fun MangaScreen(
|
||||
navigateUp = navigateUp,
|
||||
onChapterClicked = onChapterClicked,
|
||||
onDownloadChapter = onDownloadChapter,
|
||||
downloadProgressProvider = downloadProgressProvider,
|
||||
onAddToLibraryClicked = onAddToLibraryClicked,
|
||||
onWebViewClicked = onWebViewClicked,
|
||||
onWebViewLongClicked = onWebViewLongClicked,
|
||||
@@ -218,6 +221,7 @@ private fun MangaScreenSmallImpl(
|
||||
navigateUp: () -> Unit,
|
||||
onChapterClicked: (Chapter) -> Unit,
|
||||
onDownloadChapter: ((List<ChapterList.Item>, ChapterDownloadAction) -> Unit)?,
|
||||
downloadProgressProvider: (chapterId: Long) -> Int,
|
||||
onAddToLibraryClicked: () -> Unit,
|
||||
onWebViewClicked: (() -> Unit)?,
|
||||
onWebViewLongClicked: (() -> Unit)?,
|
||||
@@ -273,9 +277,6 @@ private fun MangaScreenSmallImpl(
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
val selectedChapterCount: Int = remember(chapters) {
|
||||
chapters.count { it.selected }
|
||||
}
|
||||
val isFirstItemVisible by remember {
|
||||
derivedStateOf { chapterListState.firstVisibleItemIndex == 0 }
|
||||
}
|
||||
@@ -301,7 +302,7 @@ private fun MangaScreenSmallImpl(
|
||||
onClickRefresh = onRefresh,
|
||||
onClickMigrate = onMigrateClicked,
|
||||
onClickEditNotes = onEditNotesClicked,
|
||||
actionModeCounter = selectedChapterCount,
|
||||
actionModeCounter = state.selectedChapters.size,
|
||||
onCancelActionMode = { onAllChapterSelected(false) },
|
||||
onSelectAll = { onAllChapterSelected(true) },
|
||||
onInvertSelection = { onInvertSelection() },
|
||||
@@ -310,11 +311,8 @@ private fun MangaScreenSmallImpl(
|
||||
)
|
||||
},
|
||||
bottomBar = {
|
||||
val selectedChapters = remember(chapters) {
|
||||
chapters.filter { it.selected }
|
||||
}
|
||||
SharedMangaBottomActionMenu(
|
||||
selected = selectedChapters,
|
||||
selected = state.selectedChapters,
|
||||
onMultiBookmarkClicked = onMultiBookmarkClicked,
|
||||
onMultiMarkAsReadClicked = onMultiMarkAsReadClicked,
|
||||
onMarkPreviousAsReadClicked = onMarkPreviousAsReadClicked,
|
||||
@@ -325,16 +323,13 @@ private fun MangaScreenSmallImpl(
|
||||
},
|
||||
snackbarHost = { SnackbarHost(hostState = snackbarHostState) },
|
||||
floatingActionButton = {
|
||||
val isFABVisible = remember(chapters) {
|
||||
chapters.fastAny { !it.chapter.read } && !isAnySelected
|
||||
}
|
||||
val isFABVisible = state.hasUnreadChapters && !isAnySelected
|
||||
SmallExtendedFloatingActionButton(
|
||||
text = {
|
||||
val isReading = remember(state.chapters) {
|
||||
state.chapters.fastAny { it.chapter.read }
|
||||
}
|
||||
Text(
|
||||
text = stringResource(if (isReading) MR.strings.action_resume else MR.strings.action_start),
|
||||
text = stringResource(
|
||||
if (state.hasReadChapters) MR.strings.action_resume else MR.strings.action_start,
|
||||
),
|
||||
)
|
||||
},
|
||||
icon = { Icon(imageVector = MaterialSymbols.RoundedFilled.PlayArrow, contentDescription = null) },
|
||||
@@ -378,7 +373,7 @@ private fun MangaScreenSmallImpl(
|
||||
isTabletUi = false,
|
||||
appBarPadding = topPadding,
|
||||
manga = state.manga,
|
||||
sourceName = remember { state.source.getNameForMangaInfo() },
|
||||
source = remember { state.source },
|
||||
isStubSource = remember { state.source is StubSource },
|
||||
onCoverClick = onCoverClicked,
|
||||
doSearch = onSearch,
|
||||
@@ -422,13 +417,10 @@ private fun MangaScreenSmallImpl(
|
||||
key = MangaScreenItem.CHAPTER_HEADER,
|
||||
contentType = MangaScreenItem.CHAPTER_HEADER,
|
||||
) {
|
||||
val missingChapterCount = remember(chapters) {
|
||||
chapters.map { it.chapter.chapterNumber }.missingChaptersCount()
|
||||
}
|
||||
ChapterHeader(
|
||||
enabled = !isAnySelected,
|
||||
chapterCount = chapters.size,
|
||||
missingChapterCount = missingChapterCount,
|
||||
missingChapterCount = state.missingChapterCount,
|
||||
onClick = onFilterClicked,
|
||||
)
|
||||
}
|
||||
@@ -436,11 +428,12 @@ private fun MangaScreenSmallImpl(
|
||||
sharedChapterItems(
|
||||
manga = state.manga,
|
||||
chapters = listItem,
|
||||
isAnyChapterSelected = chapters.fastAny { it.selected },
|
||||
isAnyChapterSelected = state.selectedChapters.isNotEmpty(),
|
||||
chapterSwipeStartAction = chapterSwipeStartAction,
|
||||
chapterSwipeEndAction = chapterSwipeEndAction,
|
||||
onChapterClicked = onChapterClicked,
|
||||
onDownloadChapter = onDownloadChapter,
|
||||
downloadProgressProvider = downloadProgressProvider,
|
||||
onChapterSelected = onChapterSelected,
|
||||
onChapterSwipe = onChapterSwipe,
|
||||
)
|
||||
@@ -460,6 +453,7 @@ fun MangaScreenLargeImpl(
|
||||
navigateUp: () -> Unit,
|
||||
onChapterClicked: (Chapter) -> Unit,
|
||||
onDownloadChapter: ((List<ChapterList.Item>, ChapterDownloadAction) -> Unit)?,
|
||||
downloadProgressProvider: (chapterId: Long) -> Int,
|
||||
onAddToLibraryClicked: () -> Unit,
|
||||
onWebViewClicked: (() -> Unit)?,
|
||||
onWebViewLongClicked: (() -> Unit)?,
|
||||
@@ -521,9 +515,6 @@ fun MangaScreenLargeImpl(
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
val selectedChapterCount = remember(chapters) {
|
||||
chapters.count { it.selected }
|
||||
}
|
||||
MangaToolbar(
|
||||
modifier = Modifier.onSizeChanged { topBarHeight = it.height },
|
||||
title = state.manga.title,
|
||||
@@ -537,7 +528,7 @@ fun MangaScreenLargeImpl(
|
||||
onClickMigrate = onMigrateClicked,
|
||||
onClickEditNotes = onEditNotesClicked,
|
||||
onCancelActionMode = { onAllChapterSelected(false) },
|
||||
actionModeCounter = selectedChapterCount,
|
||||
actionModeCounter = state.selectedChapters.size,
|
||||
onSelectAll = { onAllChapterSelected(true) },
|
||||
onInvertSelection = { onInvertSelection() },
|
||||
titleAlphaProvider = { 1f },
|
||||
@@ -545,37 +536,29 @@ fun MangaScreenLargeImpl(
|
||||
)
|
||||
},
|
||||
bottomBar = {
|
||||
Box(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
contentAlignment = Alignment.BottomEnd,
|
||||
) {
|
||||
val selectedChapters = remember(chapters) {
|
||||
chapters.filter { it.selected }
|
||||
}
|
||||
SharedMangaBottomActionMenu(
|
||||
selected = selectedChapters,
|
||||
onMultiBookmarkClicked = onMultiBookmarkClicked,
|
||||
onMultiMarkAsReadClicked = onMultiMarkAsReadClicked,
|
||||
onMarkPreviousAsReadClicked = onMarkPreviousAsReadClicked,
|
||||
onDownloadChapter = onDownloadChapter,
|
||||
onMultiDeleteClicked = onMultiDeleteClicked,
|
||||
fillFraction = 0.5f,
|
||||
)
|
||||
}
|
||||
// Aligned by its own modifier: a wrapper would always be laid out, and the scaffold then drops the
|
||||
// navigation bar inset under the FAB
|
||||
SharedMangaBottomActionMenu(
|
||||
selected = state.selectedChapters,
|
||||
onMultiBookmarkClicked = onMultiBookmarkClicked,
|
||||
onMultiMarkAsReadClicked = onMultiMarkAsReadClicked,
|
||||
onMarkPreviousAsReadClicked = onMarkPreviousAsReadClicked,
|
||||
onDownloadChapter = onDownloadChapter,
|
||||
onMultiDeleteClicked = onMultiDeleteClicked,
|
||||
fillFraction = 0.5f,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.wrapContentWidth(Alignment.End),
|
||||
)
|
||||
},
|
||||
snackbarHost = { SnackbarHost(hostState = snackbarHostState) },
|
||||
floatingActionButton = {
|
||||
val isFABVisible = remember(chapters) {
|
||||
chapters.fastAny { !it.chapter.read } && !isAnySelected
|
||||
}
|
||||
val isFABVisible = state.hasUnreadChapters && !isAnySelected
|
||||
SmallExtendedFloatingActionButton(
|
||||
text = {
|
||||
val isReading = remember(state.chapters) {
|
||||
state.chapters.fastAny { it.chapter.read }
|
||||
}
|
||||
Text(
|
||||
text = stringResource(
|
||||
if (isReading) MR.strings.action_resume else MR.strings.action_start,
|
||||
if (state.hasReadChapters) MR.strings.action_resume else MR.strings.action_start,
|
||||
),
|
||||
)
|
||||
},
|
||||
@@ -614,7 +597,7 @@ fun MangaScreenLargeImpl(
|
||||
isTabletUi = true,
|
||||
appBarPadding = contentPadding.calculateTopPadding(),
|
||||
manga = state.manga,
|
||||
sourceName = remember { state.source.getNameForMangaInfo() },
|
||||
source = remember { state.source },
|
||||
isStubSource = remember { state.source is StubSource },
|
||||
onCoverClick = onCoverClicked,
|
||||
doSearch = onSearch,
|
||||
@@ -659,13 +642,10 @@ fun MangaScreenLargeImpl(
|
||||
key = MangaScreenItem.CHAPTER_HEADER,
|
||||
contentType = MangaScreenItem.CHAPTER_HEADER,
|
||||
) {
|
||||
val missingChapterCount = remember(chapters) {
|
||||
chapters.map { it.chapter.chapterNumber }.missingChaptersCount()
|
||||
}
|
||||
ChapterHeader(
|
||||
enabled = !isAnySelected,
|
||||
chapterCount = chapters.size,
|
||||
missingChapterCount = missingChapterCount,
|
||||
missingChapterCount = state.missingChapterCount,
|
||||
onClick = onFilterButtonClicked,
|
||||
)
|
||||
}
|
||||
@@ -673,11 +653,12 @@ fun MangaScreenLargeImpl(
|
||||
sharedChapterItems(
|
||||
manga = state.manga,
|
||||
chapters = listItem,
|
||||
isAnyChapterSelected = chapters.fastAny { it.selected },
|
||||
isAnyChapterSelected = state.selectedChapters.isNotEmpty(),
|
||||
chapterSwipeStartAction = chapterSwipeStartAction,
|
||||
chapterSwipeEndAction = chapterSwipeEndAction,
|
||||
onChapterClicked = onChapterClicked,
|
||||
onDownloadChapter = onDownloadChapter,
|
||||
downloadProgressProvider = downloadProgressProvider,
|
||||
onChapterSelected = onChapterSelected,
|
||||
onChapterSwipe = onChapterSwipe,
|
||||
)
|
||||
@@ -714,7 +695,7 @@ private fun SharedMangaBottomActionMenu(
|
||||
}.takeIf { selected.fastAny { !it.chapter.read } },
|
||||
onMarkAsUnreadClicked = {
|
||||
onMultiMarkAsReadClicked(selected.fastMap { it.chapter }, false)
|
||||
}.takeIf { selected.fastAny { it.chapter.read || it.chapter.lastPageRead > 0L } },
|
||||
}.takeIf { selected.fastAny { it.chapter.read || it.chapter.lastPageRead > 0 } },
|
||||
onMarkPreviousAsReadClicked = {
|
||||
onMarkPreviousAsReadClicked(selected[0].chapter)
|
||||
}.takeIf { selected.size == 1 },
|
||||
@@ -739,6 +720,7 @@ private fun LazyListScope.sharedChapterItems(
|
||||
chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction,
|
||||
onChapterClicked: (Chapter) -> Unit,
|
||||
onDownloadChapter: ((List<ChapterList.Item>, ChapterDownloadAction) -> Unit)?,
|
||||
downloadProgressProvider: (chapterId: Long) -> Int,
|
||||
onChapterSelected: (ChapterList.Item, Boolean, Boolean) -> Unit,
|
||||
onChapterSwipe: (ChapterList.Item, LibraryPreferences.ChapterSwipeAction) -> Unit,
|
||||
) {
|
||||
@@ -783,7 +765,7 @@ private fun LazyListScope.sharedChapterItems(
|
||||
selected = item.selected,
|
||||
downloadIndicatorEnabled = !isAnyChapterSelected && !manga.isLocal(),
|
||||
downloadStateProvider = { item.downloadState },
|
||||
downloadProgressProvider = { item.downloadProgress },
|
||||
downloadProgressProvider = { downloadProgressProvider(item.id) },
|
||||
chapterSwipeStartAction = chapterSwipeStartAction,
|
||||
chapterSwipeEndAction = chapterSwipeEndAction,
|
||||
onLongClick = {
|
||||
|
||||
@@ -12,6 +12,7 @@ enum class DownloadAction {
|
||||
enum class EditCoverAction {
|
||||
EDIT,
|
||||
DELETE,
|
||||
ADD_TO_LIBRARY,
|
||||
}
|
||||
|
||||
enum class MangaScreenItem {
|
||||
|
||||
+34
-31
@@ -5,12 +5,12 @@ import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.CircularWavyProgressIndicator
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ProgressIndicatorDefaults
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.WavyProgressIndicatorDefaults
|
||||
import androidx.compose.material3.ripple
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
@@ -21,17 +21,19 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.StrokeCap
|
||||
import androidx.compose.ui.graphics.drawscope.Stroke
|
||||
import androidx.compose.ui.hapticfeedback.HapticFeedback
|
||||
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.unit.dp
|
||||
import eu.kanade.presentation.components.DropdownMenu
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.download.model.Download
|
||||
import mihon.icons.custommaterialsymbols.CustomMaterialSymbols
|
||||
import mihon.icons.custommaterialsymbols.rounded.DownloadArrow
|
||||
import mihon.icons.custommaterialsymbols.rounded.DownloadCircle
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.rounded.ArrowDownward
|
||||
import mihon.icons.materialsymbols.rounded.Error
|
||||
import mihon.icons.materialsymbols.roundedfilled.CheckCircle
|
||||
import tachiyomi.i18n.MR
|
||||
@@ -99,7 +101,7 @@ private fun NotDownloadedIndicator(
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.ic_download_chapter_24dp),
|
||||
imageVector = CustomMaterialSymbols.Rounded.DownloadCircle,
|
||||
contentDescription = stringResource(MR.strings.manga_download),
|
||||
modifier = Modifier.size(IndicatorSize),
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
@@ -127,39 +129,38 @@ private fun DownloadingIndicator(
|
||||
),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
val arrowColor: Color
|
||||
val strokeColor = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
val color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
val trackColor = color.copy(alpha = TRACK_ALPHA)
|
||||
val stroke = Stroke(width = with(LocalDensity.current) { IndicatorStrokeWidth.toPx() }, cap = StrokeCap.Round)
|
||||
val downloadProgress = downloadProgressProvider()
|
||||
val indeterminate = downloadState == Download.State.QUEUE ||
|
||||
(downloadState == Download.State.DOWNLOADING && downloadProgress == 0)
|
||||
if (indeterminate) {
|
||||
arrowColor = strokeColor
|
||||
CircularProgressIndicator(
|
||||
CircularWavyProgressIndicator(
|
||||
modifier = IndicatorModifier,
|
||||
color = strokeColor,
|
||||
strokeWidth = IndicatorStrokeWidth,
|
||||
color = color,
|
||||
trackColor = Color.Transparent,
|
||||
strokeCap = StrokeCap.Butt,
|
||||
stroke = stroke,
|
||||
trackStroke = stroke,
|
||||
// Only an active download waves, so a queued one reads as waiting
|
||||
amplitude = if (downloadState == Download.State.DOWNLOADING) INDICATOR_AMPLITUDE else 0f,
|
||||
wavelength = IndicatorWavelength,
|
||||
)
|
||||
} else {
|
||||
val animatedProgress by animateFloatAsState(
|
||||
targetValue = downloadProgress / 100f,
|
||||
animationSpec = ProgressIndicatorDefaults.ProgressAnimationSpec,
|
||||
animationSpec = WavyProgressIndicatorDefaults.ProgressAnimationSpec,
|
||||
label = "progress",
|
||||
)
|
||||
arrowColor = if (animatedProgress < 0.5f) {
|
||||
strokeColor
|
||||
} else {
|
||||
MaterialTheme.colorScheme.background
|
||||
}
|
||||
CircularProgressIndicator(
|
||||
CircularWavyProgressIndicator(
|
||||
progress = { animatedProgress },
|
||||
modifier = IndicatorModifier,
|
||||
color = strokeColor,
|
||||
strokeWidth = IndicatorSize / 2,
|
||||
trackColor = Color.Transparent,
|
||||
strokeCap = StrokeCap.Butt,
|
||||
gapSize = 0.dp,
|
||||
color = color,
|
||||
trackColor = trackColor,
|
||||
stroke = stroke,
|
||||
trackStroke = stroke,
|
||||
amplitude = { WavyProgressIndicatorDefaults.indicatorAmplitude(it) * INDICATOR_AMPLITUDE },
|
||||
wavelength = IndicatorWavelength,
|
||||
)
|
||||
}
|
||||
DropdownMenu(expanded = isMenuExpanded, onDismissRequest = { isMenuExpanded = false }) {
|
||||
@@ -179,10 +180,10 @@ private fun DownloadingIndicator(
|
||||
)
|
||||
}
|
||||
Icon(
|
||||
imageVector = MaterialSymbols.Rounded.ArrowDownward,
|
||||
imageVector = CustomMaterialSymbols.Rounded.DownloadArrow,
|
||||
contentDescription = null,
|
||||
modifier = ArrowModifier,
|
||||
tint = arrowColor,
|
||||
tint = color,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -270,13 +271,15 @@ private fun Modifier.commonClickable(
|
||||
)
|
||||
|
||||
private val IndicatorSize = 26.dp
|
||||
private val IndicatorPadding = 2.dp
|
||||
private val IndicatorPadding = 1.dp
|
||||
private val IndicatorWavelength = 7.dp
|
||||
private const val INDICATOR_AMPLITUDE = 0.6f
|
||||
private const val TRACK_ALPHA = 0.25f
|
||||
|
||||
// To match composable parameter name when used later
|
||||
private val IndicatorStrokeWidth = IndicatorPadding
|
||||
private val IndicatorStrokeWidth = 2.dp
|
||||
|
||||
private val IndicatorModifier = Modifier
|
||||
.size(IndicatorSize)
|
||||
.padding(IndicatorPadding)
|
||||
private val ArrowModifier = Modifier
|
||||
.size(IndicatorSize - 7.dp)
|
||||
.size(IndicatorSize)
|
||||
|
||||
@@ -40,18 +40,18 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
|
||||
import androidx.compose.ui.platform.LocalHapticFeedback
|
||||
import androidx.compose.ui.res.vectorResource
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.DpOffset
|
||||
import androidx.compose.ui.unit.dp
|
||||
import eu.kanade.presentation.components.DownloadDropdownMenu
|
||||
import eu.kanade.presentation.components.DropdownMenu
|
||||
import eu.kanade.presentation.manga.DownloadAction
|
||||
import eu.kanade.tachiyomi.R
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.isActive
|
||||
import kotlinx.coroutines.launch
|
||||
import mihon.icons.custommaterialsymbols.CustomMaterialSymbols
|
||||
import mihon.icons.custommaterialsymbols.rounded.DonePrevious
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.automirroredrounded.Label
|
||||
import mihon.icons.materialsymbols.rounded.BookmarkAdd
|
||||
@@ -149,7 +149,7 @@ fun MangaBottomActionMenu(
|
||||
if (onMarkPreviousAsReadClicked != null) {
|
||||
Button(
|
||||
title = stringResource(MR.strings.action_mark_previous_as_read),
|
||||
icon = ImageVector.vectorResource(R.drawable.ic_done_prev_24dp),
|
||||
icon = CustomMaterialSymbols.Rounded.DonePrevious,
|
||||
toConfirm = confirm[4],
|
||||
onLongClick = { onLongClickItem(4) },
|
||||
onClick = onMarkPreviousAsReadClicked,
|
||||
|
||||
@@ -31,8 +31,8 @@ import me.saket.swipe.SwipeableActionsBox
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.rounded.BookmarkAdd
|
||||
import mihon.icons.materialsymbols.rounded.BookmarkRemove
|
||||
import mihon.icons.materialsymbols.rounded.Check
|
||||
import mihon.icons.materialsymbols.rounded.Delete
|
||||
import mihon.icons.materialsymbols.rounded.Done
|
||||
import mihon.icons.materialsymbols.rounded.Download
|
||||
import mihon.icons.materialsymbols.rounded.FileDownloadOff
|
||||
import mihon.icons.materialsymbols.rounded.RemoveDone
|
||||
@@ -192,7 +192,7 @@ private fun getSwipeAction(
|
||||
): me.saket.swipe.SwipeAction? {
|
||||
return when (action) {
|
||||
LibraryPreferences.ChapterSwipeAction.ToggleRead -> swipeAction(
|
||||
icon = if (!read) MaterialSymbols.Rounded.Done else MaterialSymbols.Rounded.RemoveDone,
|
||||
icon = if (!read) MaterialSymbols.Rounded.Check else MaterialSymbols.Rounded.RemoveDone,
|
||||
background = background,
|
||||
isUndo = read,
|
||||
onSwipe = onSwipe,
|
||||
|
||||
@@ -18,6 +18,7 @@ import androidx.compose.material3.SnackbarHost
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
@@ -44,6 +45,7 @@ import coil3.asDrawable
|
||||
import coil3.imageLoader
|
||||
import coil3.request.CachePolicy
|
||||
import coil3.request.ImageRequest
|
||||
import coil3.request.SuccessResult
|
||||
import coil3.size.Size
|
||||
import eu.kanade.presentation.components.AppBar
|
||||
import eu.kanade.presentation.components.AppBarActions
|
||||
@@ -53,7 +55,7 @@ import eu.kanade.tachiyomi.data.coil.ImageDecoder
|
||||
import eu.kanade.tachiyomi.data.coil.newDecoder
|
||||
import eu.kanade.tachiyomi.ui.reader.viewer.ReaderPageImageView
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.withContext
|
||||
import mihon.app.di.appGraph
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.rounded.Close
|
||||
@@ -65,6 +67,7 @@ import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.material.Scaffold
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
import tachiyomi.presentation.core.util.clickableNoIndication
|
||||
import tachiyomi.source.local.isLocal
|
||||
|
||||
@Composable
|
||||
fun MangaCoverDialog(
|
||||
@@ -125,10 +128,12 @@ fun MangaCoverDialog(
|
||||
var expanded by remember { mutableStateOf(false) }
|
||||
IconButton(
|
||||
onClick = {
|
||||
if (isCustomCover) {
|
||||
expanded = true
|
||||
} else {
|
||||
onEditClick(EditCoverAction.EDIT)
|
||||
when {
|
||||
!manga.favorite && !manga.isLocal() -> {
|
||||
onEditClick(EditCoverAction.ADD_TO_LIBRARY)
|
||||
}
|
||||
isCustomCover -> expanded = true
|
||||
else -> onEditClick(EditCoverAction.EDIT)
|
||||
}
|
||||
},
|
||||
) {
|
||||
@@ -164,16 +169,20 @@ fun MangaCoverDialog(
|
||||
},
|
||||
) { contentPadding ->
|
||||
if (useNewRenderer) {
|
||||
val state = ImageViewerState()
|
||||
|
||||
ImageRequest.Builder(view.context)
|
||||
.data(manga)
|
||||
.size(Size.ORIGINAL)
|
||||
.memoryCachePolicy(CachePolicy.DISABLED)
|
||||
.newDecoder(true)
|
||||
.target { result ->
|
||||
val res = (result as ImageDecoder.DecodeResultImage).res
|
||||
val page = runBlocking(Dispatchers.Default) {
|
||||
val state = remember(manga) { ImageViewerState() }
|
||||
LaunchedEffect(manga) {
|
||||
val request = ImageRequest.Builder(view.context)
|
||||
.data(manga)
|
||||
.size(Size.ORIGINAL)
|
||||
.memoryCachePolicy(CachePolicy.DISABLED)
|
||||
.newDecoder(true)
|
||||
.build()
|
||||
val result = view.context.imageLoader.execute(request) as? SuccessResult ?: return@LaunchedEffect
|
||||
val res = result.image as? ImageDecoder.DecodeResultImage ?: return@LaunchedEffect
|
||||
// Held, then freed, around the upload: its buffer alone doesn't keep
|
||||
// the frame's native pixels alive.
|
||||
val page = res.frame.use {
|
||||
withContext(Dispatchers.Default) {
|
||||
ImagePage.ImageSingle(
|
||||
Image(
|
||||
res.image,
|
||||
@@ -199,15 +208,14 @@ fun MangaCoverDialog(
|
||||
),
|
||||
)
|
||||
}
|
||||
state.apply {
|
||||
fetchPage = { index ->
|
||||
if (index == 0) page else null
|
||||
}
|
||||
invalidate()
|
||||
}
|
||||
}
|
||||
.build()
|
||||
.let(view.context.imageLoader::enqueue)
|
||||
state.apply {
|
||||
fetchPage = { index ->
|
||||
if (index == 0) page else null
|
||||
}
|
||||
invalidate()
|
||||
}
|
||||
}
|
||||
|
||||
ImageViewer(state = state)
|
||||
return@Scaffold
|
||||
|
||||
@@ -72,6 +72,8 @@ import com.mikepenz.markdown.model.markdownAnnotatorConfig
|
||||
import com.mikepenz.markdown.utils.getUnescapedTextInNode
|
||||
import eu.kanade.presentation.components.DropdownMenu
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.getNameForMangaInfo
|
||||
import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||
import kotlinx.datetime.TimeZone
|
||||
@@ -80,19 +82,19 @@ import mihon.app.di.appGraph
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.rounded.AttachMoney
|
||||
import mihon.icons.materialsymbols.rounded.Block
|
||||
import mihon.icons.materialsymbols.rounded.Brush
|
||||
import mihon.icons.materialsymbols.rounded.Check
|
||||
import mihon.icons.materialsymbols.rounded.Close
|
||||
import mihon.icons.materialsymbols.rounded.Done
|
||||
import mihon.icons.materialsymbols.rounded.DoneAll
|
||||
import mihon.icons.materialsymbols.rounded.Favorite
|
||||
import mihon.icons.materialsymbols.rounded.HourglassEmpty
|
||||
import mihon.icons.materialsymbols.rounded.Pause
|
||||
import mihon.icons.materialsymbols.rounded.Person
|
||||
import mihon.icons.materialsymbols.rounded.Public
|
||||
import mihon.icons.materialsymbols.rounded.Schedule
|
||||
import mihon.icons.materialsymbols.rounded.Sync
|
||||
import mihon.icons.materialsymbols.rounded.Warning
|
||||
import mihon.icons.materialsymbols.roundedfilled.Brush
|
||||
import mihon.icons.materialsymbols.roundedfilled.Favorite
|
||||
import mihon.icons.materialsymbols.roundedfilled.Pause
|
||||
import mihon.icons.materialsymbols.roundedfilled.Warning
|
||||
import org.intellij.markdown.MarkdownElementTypes
|
||||
import org.intellij.markdown.MarkdownTokenTypes
|
||||
import org.intellij.markdown.ast.findChildOfType
|
||||
@@ -114,7 +116,7 @@ fun MangaInfoBox(
|
||||
isTabletUi: Boolean,
|
||||
appBarPadding: Dp,
|
||||
manga: Manga,
|
||||
sourceName: String,
|
||||
source: Source,
|
||||
isStubSource: Boolean,
|
||||
onCoverClick: () -> Unit,
|
||||
doSearch: (query: String, global: Boolean) -> Unit,
|
||||
@@ -151,7 +153,7 @@ fun MangaInfoBox(
|
||||
MangaAndSourceTitlesSmall(
|
||||
appBarPadding = appBarPadding,
|
||||
manga = manga,
|
||||
sourceName = sourceName,
|
||||
source = source,
|
||||
isStubSource = isStubSource,
|
||||
onCoverClick = onCoverClick,
|
||||
doSearch = doSearch,
|
||||
@@ -160,7 +162,7 @@ fun MangaInfoBox(
|
||||
MangaAndSourceTitlesLarge(
|
||||
appBarPadding = appBarPadding,
|
||||
manga = manga,
|
||||
sourceName = sourceName,
|
||||
source = source,
|
||||
isStubSource = isStubSource,
|
||||
onCoverClick = onCoverClick,
|
||||
doSearch = doSearch,
|
||||
@@ -228,7 +230,7 @@ fun MangaActionRow(
|
||||
} else {
|
||||
pluralStringResource(MR.plurals.num_trackers, count = trackingCount, trackingCount)
|
||||
},
|
||||
icon = if (trackingCount == 0) MaterialSymbols.Rounded.Sync else MaterialSymbols.Rounded.Done,
|
||||
icon = if (trackingCount == 0) MaterialSymbols.Rounded.Sync else MaterialSymbols.Rounded.Check,
|
||||
color = if (trackingCount == 0) defaultActionButtonColor else MaterialTheme.colorScheme.primary,
|
||||
onClick = onTrackingClicked,
|
||||
)
|
||||
@@ -344,7 +346,7 @@ fun ExpandableMangaDescription(
|
||||
private fun MangaAndSourceTitlesLarge(
|
||||
appBarPadding: Dp,
|
||||
manga: Manga,
|
||||
sourceName: String,
|
||||
source: Source,
|
||||
isStubSource: Boolean,
|
||||
onCoverClick: () -> Unit,
|
||||
doSearch: (query: String, global: Boolean) -> Unit,
|
||||
@@ -370,7 +372,7 @@ private fun MangaAndSourceTitlesLarge(
|
||||
author = manga.author,
|
||||
artist = manga.artist,
|
||||
status = manga.status,
|
||||
sourceName = sourceName,
|
||||
source = source,
|
||||
isStubSource = isStubSource,
|
||||
doSearch = doSearch,
|
||||
textAlign = TextAlign.Center,
|
||||
@@ -382,7 +384,7 @@ private fun MangaAndSourceTitlesLarge(
|
||||
private fun MangaAndSourceTitlesSmall(
|
||||
appBarPadding: Dp,
|
||||
manga: Manga,
|
||||
sourceName: String,
|
||||
source: Source,
|
||||
isStubSource: Boolean,
|
||||
onCoverClick: () -> Unit,
|
||||
doSearch: (query: String, global: Boolean) -> Unit,
|
||||
@@ -413,7 +415,7 @@ private fun MangaAndSourceTitlesSmall(
|
||||
author = manga.author,
|
||||
artist = manga.artist,
|
||||
status = manga.status,
|
||||
sourceName = sourceName,
|
||||
source = source,
|
||||
isStubSource = isStubSource,
|
||||
doSearch = doSearch,
|
||||
)
|
||||
@@ -427,7 +429,7 @@ private fun ColumnScope.MangaContentInfo(
|
||||
author: String?,
|
||||
artist: String?,
|
||||
status: Long,
|
||||
sourceName: String,
|
||||
source: Source,
|
||||
isStubSource: Boolean,
|
||||
doSearch: (query: String, global: Boolean) -> Unit,
|
||||
textAlign: TextAlign? = LocalTextStyle.current.textAlign,
|
||||
@@ -489,7 +491,7 @@ private fun ColumnScope.MangaContentInfo(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
Icon(
|
||||
imageVector = MaterialSymbols.Rounded.Brush,
|
||||
imageVector = MaterialSymbols.RoundedFilled.Brush,
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(16.dp),
|
||||
)
|
||||
@@ -517,9 +519,9 @@ private fun ColumnScope.MangaContentInfo(
|
||||
SManga.ONGOING.toLong() -> MaterialSymbols.Rounded.Schedule
|
||||
SManga.COMPLETED.toLong() -> MaterialSymbols.Rounded.DoneAll
|
||||
SManga.LICENSED.toLong() -> MaterialSymbols.Rounded.AttachMoney
|
||||
SManga.PUBLISHING_FINISHED.toLong() -> MaterialSymbols.Rounded.Done
|
||||
SManga.PUBLISHING_FINISHED.toLong() -> MaterialSymbols.Rounded.Check
|
||||
SManga.CANCELLED.toLong() -> MaterialSymbols.Rounded.Close
|
||||
SManga.ON_HIATUS.toLong() -> MaterialSymbols.Rounded.Pause
|
||||
SManga.ON_HIATUS.toLong() -> MaterialSymbols.RoundedFilled.Pause
|
||||
else -> MaterialSymbols.Rounded.Block
|
||||
},
|
||||
contentDescription = null,
|
||||
@@ -544,7 +546,7 @@ private fun ColumnScope.MangaContentInfo(
|
||||
DotSeparatorText()
|
||||
if (isStubSource) {
|
||||
Icon(
|
||||
imageVector = MaterialSymbols.Rounded.Warning,
|
||||
imageVector = MaterialSymbols.RoundedFilled.Warning,
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.padding(end = 4.dp)
|
||||
@@ -553,12 +555,9 @@ private fun ColumnScope.MangaContentInfo(
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = sourceName,
|
||||
text = source.getNameForMangaInfo(),
|
||||
modifier = Modifier.clickableNoIndication {
|
||||
doSearch(
|
||||
sourceName,
|
||||
false,
|
||||
)
|
||||
doSearch(source.query(), false)
|
||||
},
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 1,
|
||||
@@ -567,6 +566,8 @@ private fun ColumnScope.MangaContentInfo(
|
||||
}
|
||||
}
|
||||
|
||||
private fun Source.query(): String = """src:"$name" lang:$lang""".takeIf { name.isNotBlank() } ?: "srcid:$id"
|
||||
|
||||
@Composable
|
||||
private fun descriptionAnnotator(loadImages: Boolean, linkStyle: SpanStyle) = remember(loadImages, linkStyle) {
|
||||
markdownAnnotator(
|
||||
@@ -666,7 +667,7 @@ private fun MangaSummary(
|
||||
modifier = Modifier.background(Brush.verticalGradient(colors = colors)),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
val image = AnimatedImageVector.animatedVectorResource(R.drawable.anim_caret_down)
|
||||
val image = AnimatedImageVector.animatedVectorResource(R.drawable.animated_caret_flip)
|
||||
Icon(
|
||||
painter = rememberAnimatedVectorPainter(image, !expanded),
|
||||
contentDescription = stringResource(
|
||||
|
||||
@@ -45,7 +45,7 @@ import com.mikepenz.markdown.model.MarkdownTypography
|
||||
import com.mikepenz.markdown.model.NoOpImageTransformerImpl
|
||||
import com.mikepenz.markdown.model.markdownAlertPadding
|
||||
import com.mikepenz.markdown.model.markdownAnnotator
|
||||
import com.mikepenz.markdown.model.rememberMarkdownState
|
||||
import com.mikepenz.markdown.model.parseMarkdown
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.rounded.Image
|
||||
import org.intellij.markdown.MarkdownTokenTypes.Companion.HTML_TAG
|
||||
@@ -79,11 +79,9 @@ fun MarkdownRender(
|
||||
loadImages: Boolean = true,
|
||||
) {
|
||||
Markdown(
|
||||
markdownState = rememberMarkdownState(
|
||||
content = content,
|
||||
flavour = flavour,
|
||||
immediate = true,
|
||||
),
|
||||
// rememberMarkdownState parses again in the background even when it already parsed immediately, and its
|
||||
// new result recomposes the whole content a second time
|
||||
state = remember(content, flavour) { parseMarkdown(content = content, flavour = flavour) },
|
||||
annotator = annotator,
|
||||
colors = getMarkdownColors(),
|
||||
typography = getMarkdownTypography(),
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package eu.kanade.presentation.more
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.safeDrawingPadding
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
|
||||
/**
|
||||
* Shown instead of the app while migrations from the previous version run, so a slow first launch
|
||||
* after an update doesn't look like the app hanging.
|
||||
*/
|
||||
@Composable
|
||||
fun AppMigratingScreen() {
|
||||
Surface(modifier = Modifier.fillMaxSize()) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.safeDrawingPadding()
|
||||
.padding(horizontal = 32.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp, Alignment.CenterVertically),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
CircularProgressIndicator()
|
||||
Text(
|
||||
text = stringResource(MR.strings.app_migrating_title),
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
Text(
|
||||
text = stringResource(MR.strings.app_migrating_summary),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,24 +3,22 @@ package eu.kanade.presentation.more
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.res.vectorResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import eu.kanade.presentation.more.settings.widget.SwitchPreferenceWidget
|
||||
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.ui.more.DownloadQueueState
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.automirroredrounded.Help
|
||||
import mihon.icons.materialsymbols.automirroredrounded.Label
|
||||
import mihon.icons.materialsymbols.rounded.CloudOff
|
||||
import mihon.icons.materialsymbols.rounded.Download
|
||||
import mihon.icons.materialsymbols.rounded.Eyeglasses2
|
||||
import mihon.icons.materialsymbols.rounded.Info
|
||||
import mihon.icons.materialsymbols.rounded.QueryStats
|
||||
import mihon.icons.materialsymbols.rounded.Settings
|
||||
import mihon.icons.materialsymbols.rounded.Storage
|
||||
import mihon.icons.materialsymbols.rounded.VolunteerActivism
|
||||
import mihon.icons.materialsymbols.roundedfilled.VolunteerActivism
|
||||
import tachiyomi.core.common.Constants
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.ScrollbarLazyColumn
|
||||
@@ -65,7 +63,7 @@ fun MoreScreen(
|
||||
SwitchPreferenceWidget(
|
||||
title = stringResource(MR.strings.pref_incognito_mode),
|
||||
subtitle = stringResource(MR.strings.pref_incognito_mode_summary),
|
||||
icon = ImageVector.vectorResource(R.drawable.ic_glasses_24dp),
|
||||
icon = MaterialSymbols.Rounded.Eyeglasses2,
|
||||
checked = incognitoMode,
|
||||
onCheckedChanged = onIncognitoModeChange,
|
||||
)
|
||||
@@ -136,7 +134,7 @@ fun MoreScreen(
|
||||
item {
|
||||
TextPreferenceWidget(
|
||||
title = stringResource(MR.strings.label_support_us),
|
||||
icon = MaterialSymbols.Rounded.VolunteerActivism,
|
||||
icon = MaterialSymbols.RoundedFilled.VolunteerActivism,
|
||||
onPreferenceClick = onClickSupport,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,12 +5,17 @@ import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.tooling.preview.PreviewLightDark
|
||||
import eu.kanade.presentation.manga.components.MarkdownRender
|
||||
@@ -18,7 +23,8 @@ import eu.kanade.presentation.theme.TachiyomiPreviewTheme
|
||||
import eu.kanade.tachiyomi.ui.more.NewUpdateScreenModel
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.automirroredrounded.OpenInNew
|
||||
import mihon.icons.materialsymbols.rounded.NewReleases
|
||||
import mihon.icons.materialsymbols.rounded.UpdateDisabled
|
||||
import mihon.icons.materialsymbols.rounded.Verified
|
||||
import org.intellij.markdown.flavours.gfm.GFMFlavourDescriptor
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.material.padding
|
||||
@@ -34,9 +40,35 @@ fun NewUpdateScreen(
|
||||
onOpenInBrowser: () -> Unit,
|
||||
onAcceptUpdate: () -> Unit,
|
||||
onRejectUpdate: () -> Unit,
|
||||
onSkipUpdate: () -> Unit,
|
||||
) {
|
||||
var showSkipDialog by remember { mutableStateOf(false) }
|
||||
if (showSkipDialog) {
|
||||
val dismiss = { showSkipDialog = false }
|
||||
AlertDialog(
|
||||
onDismissRequest = dismiss,
|
||||
title = { Text(text = stringResource(MR.strings.update_check_skip_title, versionName)) },
|
||||
text = { Text(text = stringResource(MR.strings.update_check_skip_message)) },
|
||||
dismissButton = {
|
||||
TextButton(onClick = dismiss) {
|
||||
Text(text = stringResource(MR.strings.action_cancel))
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = {
|
||||
dismiss()
|
||||
onSkipUpdate()
|
||||
},
|
||||
) {
|
||||
Text(text = stringResource(MR.strings.action_ok))
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
InfoScreen(
|
||||
icon = MaterialSymbols.Rounded.NewReleases,
|
||||
icon = MaterialSymbols.Rounded.Verified,
|
||||
headingText = stringResource(MR.strings.update_check_notification_update_available),
|
||||
subtitleText = versionName,
|
||||
acceptText = when (stage) {
|
||||
@@ -52,6 +84,14 @@ fun NewUpdateScreen(
|
||||
canAccept = stage != NewUpdateScreenModel.Stage.Downloading,
|
||||
rejectText = stringResource(MR.strings.action_not_now),
|
||||
onRejectClick = onRejectUpdate,
|
||||
rejectAction = {
|
||||
OutlinedButton(onClick = { showSkipDialog = true }) {
|
||||
Icon(
|
||||
imageVector = MaterialSymbols.Rounded.UpdateDisabled,
|
||||
contentDescription = stringResource(MR.strings.update_check_skip),
|
||||
)
|
||||
}
|
||||
},
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
@@ -94,6 +134,7 @@ private fun NewUpdateScreenPreview() {
|
||||
onOpenInBrowser = {},
|
||||
onAcceptUpdate = {},
|
||||
onRejectUpdate = {},
|
||||
onSkipUpdate = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import tachiyomi.core.common.preference.Preference as PreferenceData
|
||||
|
||||
sealed class Preference {
|
||||
abstract val title: String
|
||||
abstract val enabled: Boolean
|
||||
abstract val visible: Boolean
|
||||
|
||||
sealed class PreferenceItem<T, R> : Preference() {
|
||||
abstract val subtitle: String?
|
||||
@@ -24,7 +24,7 @@ sealed class Preference {
|
||||
data class TextPreference(
|
||||
override val title: String,
|
||||
override val subtitle: String? = null,
|
||||
override val enabled: Boolean = true,
|
||||
override val visible: Boolean = true,
|
||||
val widget: @Composable (() -> Unit)? = null,
|
||||
val onClick: (() -> Unit)? = null,
|
||||
) : PreferenceItem<String, Unit>() {
|
||||
@@ -39,7 +39,7 @@ sealed class Preference {
|
||||
val preference: PreferenceData<Boolean>,
|
||||
override val title: String,
|
||||
override val subtitle: String? = null,
|
||||
override val enabled: Boolean = true,
|
||||
override val visible: Boolean = true,
|
||||
override val onValueChanged: suspend (value: Boolean) -> Boolean = { true },
|
||||
) : PreferenceItem<Boolean, Boolean>() {
|
||||
override val icon: ImageVector? = null
|
||||
@@ -49,15 +49,15 @@ sealed class Preference {
|
||||
* A [PreferenceItem] that provides a slider to select an integer number.
|
||||
*/
|
||||
data class SliderPreference(
|
||||
val value: Int,
|
||||
val preference: PreferenceData<Int>,
|
||||
override val title: String,
|
||||
override val subtitle: String? = null,
|
||||
val valueString: String? = null,
|
||||
val valueText: @Composable (Int) -> String = { it.toString() },
|
||||
val valueRange: IntProgression = 0..1,
|
||||
@IntRange(from = 0) val steps: Int = with(valueRange) { (last - first) - 1 },
|
||||
override val enabled: Boolean = true,
|
||||
override val onValueChanged: suspend (value: Int) -> Unit = {},
|
||||
) : PreferenceItem<Int, Unit>() {
|
||||
@IntRange(from = 0) val steps: Int = with(valueRange) { ((last - first) / step) - 1 },
|
||||
override val visible: Boolean = true,
|
||||
override val onValueChanged: suspend (value: Int) -> Boolean = { true },
|
||||
) : PreferenceItem<Int, Boolean>() {
|
||||
override val icon: ImageVector? = null
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ sealed class Preference {
|
||||
val subtitleProvider: @Composable (value: T, entries: Map<T, String>) -> String? =
|
||||
{ v, e -> subtitle?.format(e[v]) },
|
||||
override val icon: ImageVector? = null,
|
||||
override val enabled: Boolean = true,
|
||||
override val visible: Boolean = true,
|
||||
override val onValueChanged: suspend (value: T) -> Boolean = { true },
|
||||
) : PreferenceItem<T, Boolean>() {
|
||||
internal fun internalSet(value: Any) = preference.set(value as T)
|
||||
@@ -95,7 +95,7 @@ sealed class Preference {
|
||||
val subtitleProvider: @Composable (value: String, entries: Map<String, String>) -> String? =
|
||||
{ v, e -> subtitle?.format(e[v]) },
|
||||
override val icon: ImageVector? = null,
|
||||
override val enabled: Boolean = true,
|
||||
override val visible: Boolean = true,
|
||||
override val onValueChanged: suspend (value: String) -> Unit = {},
|
||||
) : PreferenceItem<String, Unit>()
|
||||
|
||||
@@ -120,7 +120,7 @@ sealed class Preference {
|
||||
subtitle?.format(combined)
|
||||
},
|
||||
override val icon: ImageVector? = null,
|
||||
override val enabled: Boolean = true,
|
||||
override val visible: Boolean = true,
|
||||
override val onValueChanged: suspend (value: Set<T>) -> Boolean = { true },
|
||||
) : PreferenceItem<Set<T>, Boolean>() {
|
||||
internal fun internalSet(value: Set<Any?>) = preference.set(value as Set<T>)
|
||||
@@ -138,7 +138,7 @@ sealed class Preference {
|
||||
val preference: PreferenceData<String>,
|
||||
override val title: String,
|
||||
override val subtitle: String? = "%s",
|
||||
override val enabled: Boolean = true,
|
||||
override val visible: Boolean = true,
|
||||
override val onValueChanged: suspend (value: String) -> Boolean = { true },
|
||||
) : PreferenceItem<String, Boolean>() {
|
||||
override val icon: ImageVector? = null
|
||||
@@ -153,7 +153,7 @@ sealed class Preference {
|
||||
val logout: () -> Unit,
|
||||
) : PreferenceItem<String, Unit>() {
|
||||
override val title: String = ""
|
||||
override val enabled: Boolean = true
|
||||
override val visible: Boolean = true
|
||||
override val subtitle: String? = null
|
||||
override val icon: ImageVector? = null
|
||||
override val onValueChanged: suspend (value: String) -> Unit = {}
|
||||
@@ -162,7 +162,7 @@ sealed class Preference {
|
||||
data class InfoPreference(
|
||||
override val title: String,
|
||||
) : PreferenceItem<String, Unit>() {
|
||||
override val enabled: Boolean = true
|
||||
override val visible: Boolean = true
|
||||
override val subtitle: String? = null
|
||||
override val icon: ImageVector? = null
|
||||
override val onValueChanged: suspend (value: String) -> Unit = {}
|
||||
@@ -172,7 +172,7 @@ sealed class Preference {
|
||||
override val title: String,
|
||||
val content: @Composable () -> Unit,
|
||||
) : PreferenceItem<Unit, Unit>() {
|
||||
override val enabled: Boolean = true
|
||||
override val visible: Boolean = true
|
||||
override val subtitle: String? = null
|
||||
override val icon: ImageVector? = null
|
||||
override val onValueChanged: suspend (value: Unit) -> Unit = {}
|
||||
@@ -181,7 +181,7 @@ sealed class Preference {
|
||||
|
||||
data class PreferenceGroup(
|
||||
override val title: String,
|
||||
override val enabled: Boolean = true,
|
||||
override val visible: Boolean = true,
|
||||
|
||||
val preferenceItems: List<PreferenceItem<out Any, out Any>>,
|
||||
) : Preference()
|
||||
|
||||
@@ -9,12 +9,14 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.compositionLocalOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.structuralEqualityPolicy
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.unit.dp
|
||||
import eu.kanade.presentation.more.settings.widget.EditTextPreferenceWidget
|
||||
import eu.kanade.presentation.more.settings.widget.InfoWidget
|
||||
@@ -26,7 +28,11 @@ import eu.kanade.presentation.more.settings.widget.SwitchPreferenceWidget
|
||||
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
|
||||
import eu.kanade.presentation.more.settings.widget.TitleFontSize
|
||||
import eu.kanade.presentation.more.settings.widget.TrackingPreferenceWidget
|
||||
import eu.kanade.tachiyomi.data.track.RefreshResult
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import kotlinx.coroutines.launch
|
||||
import tachiyomi.core.common.i18n.stringResource
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.BaseSliderItem
|
||||
import tachiyomi.presentation.core.util.collectAsState
|
||||
|
||||
@@ -39,7 +45,7 @@ fun StatusWrapper(
|
||||
highlightKey: String?,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
val enabled = item.enabled
|
||||
val enabled = item.visible
|
||||
val highlighted = item.title == highlightKey
|
||||
AnimatedVisibility(
|
||||
visible = enabled,
|
||||
@@ -82,16 +88,19 @@ internal fun PreferenceItem(
|
||||
)
|
||||
}
|
||||
is Preference.PreferenceItem.SliderPreference -> {
|
||||
val value by item.preference.collectAsState()
|
||||
BaseSliderItem(
|
||||
value = item.value,
|
||||
value = value,
|
||||
valueRange = item.valueRange,
|
||||
steps = item.steps,
|
||||
title = item.title,
|
||||
subtitle = item.subtitle,
|
||||
valueString = item.valueString.takeUnless { it.isNullOrEmpty() } ?: item.value.toString(),
|
||||
onChange = {
|
||||
valueString = item.valueText(value),
|
||||
onChange = { newValue ->
|
||||
scope.launch {
|
||||
item.onValueChanged(it)
|
||||
if (item.onValueChanged(newValue)) {
|
||||
item.preference.set(newValue)
|
||||
}
|
||||
}
|
||||
},
|
||||
titleStyle = MaterialTheme.typography.titleLarge.copy(fontSize = TitleFontSize),
|
||||
@@ -169,12 +178,28 @@ internal fun PreferenceItem(
|
||||
)
|
||||
}
|
||||
is Preference.PreferenceItem.TrackerPreference -> {
|
||||
val context = LocalContext.current
|
||||
LaunchedEffect(item.tracker) {
|
||||
item.tracker.refreshResultFlow.collect {
|
||||
when (it) {
|
||||
RefreshResult.Success -> context.toast(
|
||||
context.stringResource(MR.strings.refresh_tracker_success, item.tracker.name),
|
||||
)
|
||||
|
||||
is RefreshResult.Error -> context.toast(
|
||||
context.stringResource(MR.strings.refresh_tracker_error, item.tracker.name, it.msg),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
val isLoggedIn by item.tracker.let { tracker ->
|
||||
tracker.isLoggedInFlow.collectAsState(tracker.isLoggedIn)
|
||||
}
|
||||
val isRefreshing by item.tracker.isRefreshingFlow.collectAsState()
|
||||
TrackingPreferenceWidget(
|
||||
tracker = item.tracker,
|
||||
isLoggedIn = isLoggedIn,
|
||||
isRefreshing = isRefreshing,
|
||||
onClick = { if (isLoggedIn) item.logout() else item.login() },
|
||||
)
|
||||
}
|
||||
|
||||
@@ -50,11 +50,14 @@ fun PreferenceScreen(
|
||||
when (preference) {
|
||||
// Create Preference Group
|
||||
is Preference.PreferenceGroup -> {
|
||||
if (!preference.enabled) return@fastForEachIndexed
|
||||
if (!preference.visible) return@fastForEachIndexed
|
||||
|
||||
item {
|
||||
Column {
|
||||
PreferenceGroupHeader(title = preference.title)
|
||||
PreferenceGroupHeader(
|
||||
title = preference.title,
|
||||
highlighted = preference.title == highlightKey,
|
||||
)
|
||||
}
|
||||
}
|
||||
items(preference.preferenceItems) { item ->
|
||||
@@ -86,7 +89,7 @@ private fun List<Preference>.findHighlightedIndex(highlightKey: String): Int {
|
||||
return flatMap {
|
||||
if (it is Preference.PreferenceGroup) {
|
||||
buildList<String?> {
|
||||
add(null) // Header
|
||||
add(it.title) // Header
|
||||
addAll(it.preferenceItems.map { groupItem -> groupItem.title })
|
||||
add(null) // Spacer
|
||||
}
|
||||
|
||||
+21
-15
@@ -26,7 +26,7 @@ import eu.kanade.domain.base.BasePreferences
|
||||
import eu.kanade.presentation.more.settings.Preference
|
||||
import eu.kanade.presentation.more.settings.screen.advanced.ClearDatabaseScreen
|
||||
import eu.kanade.presentation.more.settings.screen.debug.DebugInfoScreen
|
||||
import eu.kanade.tachiyomi.data.library.MetadataUpdateJob
|
||||
import eu.kanade.tachiyomi.data.library.MetadataUpdateWorker
|
||||
import eu.kanade.tachiyomi.network.NetworkPreferences
|
||||
import eu.kanade.tachiyomi.network.PREF_DOH_360
|
||||
import eu.kanade.tachiyomi.network.PREF_DOH_ADGUARD
|
||||
@@ -47,12 +47,12 @@ import eu.kanade.tachiyomi.util.system.powerManager
|
||||
import eu.kanade.tachiyomi.util.system.setDefaultSettings
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.system.workManager
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import logcat.LogPriority
|
||||
import mihon.app.di.appGraph
|
||||
import okhttp3.Headers
|
||||
import tachiyomi.core.common.util.lang.launchNonCancellable
|
||||
import tachiyomi.core.common.util.lang.withUIContext
|
||||
import tachiyomi.core.common.util.system.logcat
|
||||
import tachiyomi.domain.library.service.LibraryPreferences
|
||||
import tachiyomi.i18n.MR
|
||||
@@ -193,6 +193,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
||||
): Preference.PreferenceGroup {
|
||||
val context = LocalContext.current
|
||||
val networkHelper = remember { context.appGraph.networkHelper }
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
val userAgentPref = networkPreferences.defaultUserAgent
|
||||
val userAgent by userAgentPref.collectAsState()
|
||||
@@ -219,8 +220,10 @@ object SettingsAdvancedScreen : SearchableSettings {
|
||||
clearSslPreferences()
|
||||
}
|
||||
WebStorage.getInstance().deleteAllData()
|
||||
context.applicationInfo?.dataDir?.let { File("$it/app_webview/").deleteRecursively() }
|
||||
context.toast(MR.strings.webview_data_deleted)
|
||||
scope.launch(Dispatchers.IO) {
|
||||
context.applicationInfo?.dataDir?.let { File("$it/app_webview/").deleteRecursively() }
|
||||
withContext(Dispatchers.Main) { context.toast(MR.strings.webview_data_deleted) }
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
logcat(LogPriority.ERROR, e)
|
||||
context.toast(MR.strings.cache_delete_error)
|
||||
@@ -267,7 +270,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
||||
),
|
||||
Preference.PreferenceItem.TextPreference(
|
||||
title = stringResource(MR.strings.pref_reset_user_agent_string),
|
||||
enabled = remember(userAgent) { userAgent != userAgentPref.defaultValue() },
|
||||
visible = remember(userAgent) { userAgent != userAgentPref.defaultValue() },
|
||||
onClick = {
|
||||
userAgentPref.delete()
|
||||
context.toast(MR.strings.requires_app_restart)
|
||||
@@ -289,22 +292,20 @@ object SettingsAdvancedScreen : SearchableSettings {
|
||||
preferenceItems = listOf(
|
||||
Preference.PreferenceItem.TextPreference(
|
||||
title = stringResource(MR.strings.pref_refresh_library_covers),
|
||||
onClick = { MetadataUpdateJob.startNow(context.workManager) },
|
||||
onClick = { scope.launch { MetadataUpdateWorker.startNow(context.workManager) } },
|
||||
),
|
||||
Preference.PreferenceItem.TextPreference(
|
||||
title = stringResource(MR.strings.pref_reset_viewer_flags),
|
||||
subtitle = stringResource(MR.strings.pref_reset_viewer_flags_summary),
|
||||
onClick = {
|
||||
scope.launchNonCancellable {
|
||||
scope.launch {
|
||||
val success = context.appGraph.resetViewerFlags.await()
|
||||
withUIContext {
|
||||
val message = if (success) {
|
||||
MR.strings.pref_reset_viewer_flags_success
|
||||
} else {
|
||||
MR.strings.pref_reset_viewer_flags_error
|
||||
}
|
||||
context.toast(message)
|
||||
val message = if (success) {
|
||||
MR.strings.pref_reset_viewer_flags_success
|
||||
} else {
|
||||
MR.strings.pref_reset_viewer_flags_error
|
||||
}
|
||||
context.toast(message)
|
||||
}
|
||||
},
|
||||
),
|
||||
@@ -318,6 +319,11 @@ object SettingsAdvancedScreen : SearchableSettings {
|
||||
title = stringResource(MR.strings.pref_disallow_non_ascii_filenames),
|
||||
subtitle = stringResource(MR.strings.pref_disallow_non_ascii_filenames_details),
|
||||
),
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = libraryPreferences.enableChapterNameHash,
|
||||
title = stringResource(MR.strings.pref_enable_chapter_name_hash),
|
||||
subtitle = stringResource(MR.strings.pref_enable_chapter_name_hash_details),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@ object SettingsAppearanceScreen : SearchableSettings {
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = amoledPref,
|
||||
title = stringResource(MR.strings.pref_dark_theme_pure_black),
|
||||
enabled = themeMode != ThemeMode.LIGHT,
|
||||
visible = themeMode != ThemeMode.LIGHT,
|
||||
onValueChanged = {
|
||||
(context as? Activity)?.let { ActivityCompat.recreate(it) }
|
||||
true
|
||||
|
||||
+25
-20
@@ -28,6 +28,7 @@ import androidx.compose.runtime.ReadOnlyComposable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableIntStateOf
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.produceState
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
@@ -46,23 +47,23 @@ import eu.kanade.presentation.more.settings.screen.data.StorageInfo
|
||||
import eu.kanade.presentation.more.settings.widget.BasePreferenceWidget
|
||||
import eu.kanade.presentation.more.settings.widget.PrefsHorizontalPadding
|
||||
import eu.kanade.presentation.util.relativeTimeSpanString
|
||||
import eu.kanade.tachiyomi.data.backup.create.BackupCreateJob
|
||||
import eu.kanade.tachiyomi.data.backup.restore.BackupRestoreJob
|
||||
import eu.kanade.tachiyomi.data.backup.create.BackupCreateWorker
|
||||
import eu.kanade.tachiyomi.data.backup.restore.BackupRestoreWorker
|
||||
import eu.kanade.tachiyomi.data.export.LibraryExporter
|
||||
import eu.kanade.tachiyomi.data.export.LibraryExporter.ExportOptions
|
||||
import eu.kanade.tachiyomi.util.system.DeviceUtil
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.system.workManager
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import logcat.LogPriority
|
||||
import mihon.app.di.appGraph
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.automirroredrounded.Help
|
||||
import tachiyomi.core.common.i18n.stringResource
|
||||
import tachiyomi.core.common.storage.displayablePath
|
||||
import tachiyomi.core.common.util.lang.launchNonCancellable
|
||||
import tachiyomi.core.common.util.lang.withUIContext
|
||||
import tachiyomi.core.common.util.system.logcat
|
||||
import tachiyomi.domain.backup.service.BackupPreferences
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
@@ -181,6 +182,7 @@ object SettingsDataScreen : SearchableSettings {
|
||||
private fun getBackupAndRestoreGroup(backupPreferences: BackupPreferences): Preference.PreferenceGroup {
|
||||
val context = LocalContext.current
|
||||
val navigator = LocalNavigator.currentOrThrow
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
val lastAutoBackup by backupPreferences.lastAutoBackupTimestamp.collectAsState()
|
||||
|
||||
@@ -231,13 +233,15 @@ object SettingsDataScreen : SearchableSettings {
|
||||
modifier = Modifier.fillMaxHeight(),
|
||||
checked = false,
|
||||
onCheckedChange = {
|
||||
if (!BackupRestoreJob.isRunning(context.workManager)) {
|
||||
if (DeviceUtil.isMiui && DeviceUtil.isMiuiOptimizationDisabled()) {
|
||||
context.toast(MR.strings.restore_miui_warning)
|
||||
scope.launch {
|
||||
if (!BackupRestoreWorker.isRunning(context.workManager)) {
|
||||
if (DeviceUtil.isMiui && DeviceUtil.isMiuiOptimizationDisabled()) {
|
||||
context.toast(MR.strings.restore_miui_warning)
|
||||
}
|
||||
chooseBackup.launch(arrayOf("*/*"))
|
||||
} else {
|
||||
context.toast(MR.strings.restore_in_progress)
|
||||
}
|
||||
chooseBackup.launch(arrayOf("*/*"))
|
||||
} else {
|
||||
context.toast(MR.strings.restore_in_progress)
|
||||
}
|
||||
},
|
||||
shape = SegmentedButtonDefaults.itemShape(1, 2),
|
||||
@@ -262,7 +266,7 @@ object SettingsDataScreen : SearchableSettings {
|
||||
),
|
||||
title = stringResource(MR.strings.pref_backup_interval),
|
||||
onValueChanged = {
|
||||
BackupCreateJob.setupTask(context, it)
|
||||
BackupCreateWorker.setupTask(context, it)
|
||||
true
|
||||
},
|
||||
),
|
||||
@@ -282,7 +286,9 @@ object SettingsDataScreen : SearchableSettings {
|
||||
|
||||
val chapterCache = remember { context.appGraph.chapterCache }
|
||||
var cacheReadableSizeSema by remember { mutableIntStateOf(0) }
|
||||
val cacheReadableSize = remember(cacheReadableSizeSema) { chapterCache.readableSize }
|
||||
val cacheReadableSize by produceState("", cacheReadableSizeSema) {
|
||||
value = withContext(Dispatchers.IO) { chapterCache.readableSize }
|
||||
}
|
||||
|
||||
return Preference.PreferenceGroup(
|
||||
title = stringResource(MR.strings.pref_storage_usage),
|
||||
@@ -303,16 +309,15 @@ object SettingsDataScreen : SearchableSettings {
|
||||
title = stringResource(MR.strings.pref_clear_chapter_cache),
|
||||
subtitle = stringResource(MR.strings.used_cache, cacheReadableSize),
|
||||
onClick = {
|
||||
scope.launchNonCancellable {
|
||||
scope.launch {
|
||||
try {
|
||||
val deletedFiles = chapterCache.clear()
|
||||
withUIContext {
|
||||
context.toast(context.stringResource(MR.strings.cache_deleted, deletedFiles))
|
||||
cacheReadableSizeSema++
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
val deletedFiles = withContext(Dispatchers.IO) { chapterCache.clear() }
|
||||
context.toast(context.stringResource(MR.strings.cache_deleted, deletedFiles))
|
||||
cacheReadableSizeSema++
|
||||
} catch (e: Exception) {
|
||||
if (e is CancellationException) throw e
|
||||
logcat(LogPriority.ERROR, e)
|
||||
withUIContext { context.toast(MR.strings.cache_delete_error) }
|
||||
context.toast(MR.strings.cache_delete_error)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+4
-8
@@ -34,8 +34,6 @@ object SettingsDownloadScreen : SearchableSettings {
|
||||
val allCategories by getCategories.subscribe().collectAsState(initial = emptyList())
|
||||
|
||||
val downloadPreferences = remember { context.appGraph.downloadPreferences }
|
||||
val parallelSourceLimit by downloadPreferences.parallelSourceLimit.collectAsState()
|
||||
val parallelPageLimit by downloadPreferences.parallelPageLimit.collectAsState()
|
||||
return listOf(
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = downloadPreferences.downloadOnlyOverWifi,
|
||||
@@ -51,17 +49,15 @@ object SettingsDownloadScreen : SearchableSettings {
|
||||
subtitle = stringResource(MR.strings.split_tall_images_summary),
|
||||
),
|
||||
Preference.PreferenceItem.SliderPreference(
|
||||
value = parallelSourceLimit,
|
||||
preference = downloadPreferences.parallelSourceLimit,
|
||||
valueRange = 1..10,
|
||||
title = stringResource(MR.strings.pref_download_concurrent_sources),
|
||||
onValueChanged = { downloadPreferences.parallelSourceLimit.set(it) },
|
||||
),
|
||||
Preference.PreferenceItem.SliderPreference(
|
||||
value = parallelPageLimit,
|
||||
preference = downloadPreferences.parallelPageLimit,
|
||||
valueRange = 1..15,
|
||||
title = stringResource(MR.strings.pref_download_concurrent_pages),
|
||||
subtitle = stringResource(MR.strings.pref_download_concurrent_pages_summary),
|
||||
onValueChanged = { downloadPreferences.parallelPageLimit.set(it) },
|
||||
),
|
||||
getDeleteChaptersGroup(
|
||||
downloadPreferences = downloadPreferences,
|
||||
@@ -166,7 +162,7 @@ object SettingsDownloadScreen : SearchableSettings {
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = downloadNewUnreadChaptersOnlyPref,
|
||||
title = stringResource(MR.strings.pref_download_new_unread_chapters_only),
|
||||
enabled = downloadNewChapters,
|
||||
visible = downloadNewChapters,
|
||||
),
|
||||
Preference.PreferenceItem.TextPreference(
|
||||
title = stringResource(MR.strings.categories),
|
||||
@@ -175,7 +171,7 @@ object SettingsDownloadScreen : SearchableSettings {
|
||||
included = included,
|
||||
excluded = excluded,
|
||||
),
|
||||
enabled = downloadNewChapters,
|
||||
visible = downloadNewChapters,
|
||||
onClick = { showDialog = true },
|
||||
),
|
||||
),
|
||||
|
||||
+4
-4
@@ -18,7 +18,7 @@ import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import eu.kanade.presentation.category.visualName
|
||||
import eu.kanade.presentation.more.settings.Preference
|
||||
import eu.kanade.presentation.more.settings.widget.TriStateListDialog
|
||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateWorker
|
||||
import eu.kanade.tachiyomi.ui.category.CategoryScreen
|
||||
import kotlinx.coroutines.launch
|
||||
import mihon.app.di.appGraph
|
||||
@@ -155,7 +155,7 @@ object SettingsLibraryScreen : SearchableSettings {
|
||||
),
|
||||
title = stringResource(MR.strings.pref_library_update_interval),
|
||||
onValueChanged = {
|
||||
LibraryUpdateJob.setupTask(context, it)
|
||||
LibraryUpdateWorker.setupTask(context, it)
|
||||
true
|
||||
},
|
||||
),
|
||||
@@ -168,11 +168,11 @@ object SettingsLibraryScreen : SearchableSettings {
|
||||
),
|
||||
title = stringResource(MR.strings.pref_library_update_restriction),
|
||||
subtitle = stringResource(MR.strings.restrictions),
|
||||
enabled = autoUpdateInterval > 0,
|
||||
visible = autoUpdateInterval > 0,
|
||||
onValueChanged = {
|
||||
// Post to event looper to allow the preference to be updated.
|
||||
ContextCompat.getMainExecutor(context).execute {
|
||||
LibraryUpdateJob.setupTask(context)
|
||||
LibraryUpdateWorker.setupTask(context)
|
||||
}
|
||||
true
|
||||
},
|
||||
|
||||
+28
-37
@@ -59,6 +59,11 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
preference = readerPref.pageTransitions,
|
||||
title = stringResource(MR.strings.pref_page_transitions),
|
||||
),
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = readerPref.loadAheadOnlyOverWifi,
|
||||
title = stringResource(MR.strings.pref_load_ahead_only_over_wifi),
|
||||
subtitle = stringResource(MR.strings.pref_load_ahead_only_over_wifi_summary),
|
||||
),
|
||||
getDisplayGroup(readerPreferences = readerPref),
|
||||
getEInkGroup(readerPreferences = readerPref),
|
||||
getReadingGroup(readerPreferences = readerPref),
|
||||
@@ -98,7 +103,7 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = readerPreferences.drawUnderCutout,
|
||||
title = stringResource(MR.strings.pref_cutout_short),
|
||||
enabled = LocalView.current.hasDisplayCutout() && fullscreen,
|
||||
visible = LocalView.current.hasDisplayCutout() && fullscreen,
|
||||
),
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = readerPreferences.keepScreenOn,
|
||||
@@ -116,12 +121,6 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
private fun getEInkGroup(readerPreferences: ReaderPreferences): Preference.PreferenceGroup {
|
||||
val flashPageState by readerPreferences.flashOnPageChange.collectAsState()
|
||||
|
||||
val flashMillisPref = readerPreferences.flashDurationMillis
|
||||
val flashMillis by flashMillisPref.collectAsState()
|
||||
|
||||
val flashIntervalPref = readerPreferences.flashPageInterval
|
||||
val flashInterval by flashIntervalPref.collectAsState()
|
||||
|
||||
val flashColorPref = readerPreferences.flashColor
|
||||
|
||||
return Preference.PreferenceGroup(
|
||||
@@ -133,20 +132,18 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
subtitle = stringResource(MR.strings.pref_flash_page_summ),
|
||||
),
|
||||
Preference.PreferenceItem.SliderPreference(
|
||||
value = flashMillis / ReaderPreferences.MILLI_CONVERSION,
|
||||
valueRange = 1..15,
|
||||
preference = readerPreferences.flashDurationMillis,
|
||||
valueRange = ReaderPreferences.MILLI_CONVERSION.let { it..it * 15 step it },
|
||||
title = stringResource(MR.strings.pref_flash_duration),
|
||||
valueString = stringResource(MR.strings.pref_flash_duration_summary, flashMillis),
|
||||
enabled = flashPageState,
|
||||
onValueChanged = { flashMillisPref.set(it * ReaderPreferences.MILLI_CONVERSION) },
|
||||
valueText = { stringResource(MR.strings.pref_flash_duration_summary, it) },
|
||||
visible = flashPageState,
|
||||
),
|
||||
Preference.PreferenceItem.SliderPreference(
|
||||
value = flashInterval,
|
||||
preference = readerPreferences.flashPageInterval,
|
||||
valueRange = 1..10,
|
||||
title = stringResource(MR.strings.pref_flash_page_interval),
|
||||
valueString = pluralStringResource(MR.plurals.pref_pages, flashInterval, flashInterval),
|
||||
enabled = flashPageState,
|
||||
onValueChanged = { flashIntervalPref.set(it) },
|
||||
valueText = { pluralStringResource(MR.plurals.pref_pages, it, it) },
|
||||
visible = flashPageState,
|
||||
),
|
||||
Preference.PreferenceItem.ListPreference(
|
||||
preference = flashColorPref,
|
||||
@@ -157,7 +154,7 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
to stringResource(MR.strings.pref_flash_style_white_black),
|
||||
),
|
||||
title = stringResource(MR.strings.pref_flash_with),
|
||||
enabled = flashPageState,
|
||||
visible = flashPageState,
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -220,7 +217,7 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
)
|
||||
.associateWith { stringResource(it.titleRes) },
|
||||
title = stringResource(MR.strings.pref_read_with_tapping_inverted),
|
||||
enabled = navMode != 5,
|
||||
visible = navMode != 5,
|
||||
),
|
||||
Preference.PreferenceItem.ListPreference(
|
||||
preference = imageScaleTypePref,
|
||||
@@ -243,12 +240,12 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = readerPreferences.landscapeZoom,
|
||||
title = stringResource(MR.strings.pref_landscape_zoom),
|
||||
enabled = imageScaleType == 1,
|
||||
visible = imageScaleType == 1,
|
||||
),
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = readerPreferences.navigateToPan,
|
||||
title = stringResource(MR.strings.pref_navigate_pan),
|
||||
enabled = navMode != 5,
|
||||
visible = navMode != 5,
|
||||
),
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = dualPageSplitPref,
|
||||
@@ -262,7 +259,7 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
preference = readerPreferences.dualPageInvertPaged,
|
||||
title = stringResource(MR.strings.pref_dual_page_invert),
|
||||
subtitle = stringResource(MR.strings.pref_dual_page_invert_summary),
|
||||
enabled = dualPageSplit,
|
||||
visible = dualPageSplit,
|
||||
),
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = rotateToFitPref,
|
||||
@@ -275,7 +272,7 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = readerPreferences.dualPageRotateToFitInvert,
|
||||
title = stringResource(MR.strings.pref_page_rotate_invert),
|
||||
enabled = rotateToFit,
|
||||
visible = rotateToFit,
|
||||
),
|
||||
),
|
||||
)
|
||||
@@ -288,12 +285,10 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
val navModePref = readerPreferences.navigationModeWebtoon
|
||||
val dualPageSplitPref = readerPreferences.dualPageSplitWebtoon
|
||||
val rotateToFitPref = readerPreferences.dualPageRotateToFitWebtoon
|
||||
val webtoonSidePaddingPref = readerPreferences.webtoonSidePadding
|
||||
|
||||
val navMode by navModePref.collectAsState()
|
||||
val dualPageSplit by dualPageSplitPref.collectAsState()
|
||||
val rotateToFit by rotateToFitPref.collectAsState()
|
||||
val webtoonSidePadding by webtoonSidePaddingPref.collectAsState()
|
||||
|
||||
return Preference.PreferenceGroup(
|
||||
title = stringResource(MR.strings.webtoon_viewer),
|
||||
@@ -315,16 +310,15 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
)
|
||||
.associateWith { stringResource(it.titleRes) },
|
||||
title = stringResource(MR.strings.pref_read_with_tapping_inverted),
|
||||
enabled = navMode != 5,
|
||||
visible = navMode != 5,
|
||||
),
|
||||
Preference.PreferenceItem.SliderPreference(
|
||||
value = webtoonSidePadding,
|
||||
preference = readerPreferences.webtoonSidePadding,
|
||||
valueRange = ReaderPreferences.let {
|
||||
it.WEBTOON_PADDING_MIN..it.WEBTOON_PADDING_MAX
|
||||
},
|
||||
title = stringResource(MR.strings.pref_webtoon_side_padding),
|
||||
valueString = numberFormat.format(webtoonSidePadding / 100f),
|
||||
onValueChanged = { webtoonSidePaddingPref.set(it) },
|
||||
valueText = { numberFormat.format(it / 100f) },
|
||||
),
|
||||
Preference.PreferenceItem.ListPreference(
|
||||
preference = readerPreferences.readerHideThreshold,
|
||||
@@ -352,7 +346,7 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
preference = readerPreferences.dualPageInvertWebtoon,
|
||||
title = stringResource(MR.strings.pref_dual_page_invert),
|
||||
subtitle = stringResource(MR.strings.pref_dual_page_invert_summary),
|
||||
enabled = dualPageSplit,
|
||||
visible = dualPageSplit,
|
||||
),
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = rotateToFitPref,
|
||||
@@ -365,7 +359,7 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = readerPreferences.dualPageRotateToFitInvertWebtoon,
|
||||
title = stringResource(MR.strings.pref_page_rotate_invert),
|
||||
enabled = rotateToFit,
|
||||
visible = rotateToFit,
|
||||
),
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = readerPreferences.webtoonDoubleTapZoomEnabled,
|
||||
@@ -385,8 +379,6 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
val readWithVolumeKeys by readWithVolumeKeysPref.collectAsState()
|
||||
|
||||
val verticalNavigator by readerPreferences.verticalNavigator.collectAsState()
|
||||
val verticalNavigatorHeightPref = readerPreferences.verticalNavigatorHeight
|
||||
val verticalNavigatorHeight by verticalNavigatorHeightPref.collectAsState()
|
||||
|
||||
return Preference.PreferenceGroup(
|
||||
title = stringResource(MR.strings.pref_reader_navigation),
|
||||
@@ -398,7 +390,7 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = readerPreferences.readWithVolumeKeysInverted,
|
||||
title = stringResource(MR.strings.pref_read_with_volume_keys_inverted),
|
||||
enabled = readWithVolumeKeys,
|
||||
visible = readWithVolumeKeys,
|
||||
),
|
||||
Preference.PreferenceItem.MultiSelectListPreference(
|
||||
preference = readerPreferences.verticalNavigator,
|
||||
@@ -409,15 +401,14 @@ object SettingsReaderScreen : SearchableSettings {
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = readerPreferences.verticalNavigatorOnLeft,
|
||||
title = stringResource(MR.strings.pref_webtoon_vertical_navigator_on_left),
|
||||
enabled = verticalNavigator.isNotEmpty(),
|
||||
visible = verticalNavigator.isNotEmpty(),
|
||||
),
|
||||
Preference.PreferenceItem.SliderPreference(
|
||||
value = verticalNavigatorHeight,
|
||||
preference = readerPreferences.verticalNavigatorHeight,
|
||||
valueRange = 65..100,
|
||||
steps = 6,
|
||||
title = stringResource(MR.strings.pref_vertical_navigator_height),
|
||||
onValueChanged = { verticalNavigatorHeightPref.set(it) },
|
||||
enabled = verticalNavigator.isNotEmpty(),
|
||||
visible = verticalNavigator.isNotEmpty(),
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
+58
-49
@@ -30,6 +30,7 @@ import androidx.compose.runtime.NonRestartableComposable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.produceState
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.snapshotFlow
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
@@ -48,6 +49,7 @@ import cafe.adriel.voyager.navigator.currentOrThrow
|
||||
import eu.kanade.presentation.components.UpIcon
|
||||
import eu.kanade.presentation.more.settings.Preference
|
||||
import eu.kanade.presentation.util.Screen
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.rounded.Close
|
||||
import tachiyomi.i18n.MR
|
||||
@@ -141,7 +143,7 @@ class SettingsSearchScreen : Screen() {
|
||||
},
|
||||
) { contentPadding ->
|
||||
SearchResult(
|
||||
searchKey = textFieldState.text.toString(),
|
||||
searchKey = { textFieldState.text.toString() },
|
||||
listState = listState,
|
||||
contentPadding = contentPadding,
|
||||
) { result ->
|
||||
@@ -154,62 +156,20 @@ class SettingsSearchScreen : Screen() {
|
||||
|
||||
@Composable
|
||||
private fun SearchResult(
|
||||
searchKey: String,
|
||||
searchKey: () -> String,
|
||||
modifier: Modifier = Modifier,
|
||||
listState: LazyListState = rememberLazyListState(),
|
||||
contentPadding: PaddingValues = PaddingValues(),
|
||||
onItemClick: (SearchResultItem) -> Unit,
|
||||
) {
|
||||
if (searchKey.isEmpty()) return
|
||||
|
||||
val isLtr = LocalLayoutDirection.current == LayoutDirection.Ltr
|
||||
|
||||
val index = getIndex()
|
||||
val result by produceState<List<SearchResultItem>?>(initialValue = null, searchKey) {
|
||||
value = index.asSequence()
|
||||
.flatMap { settingsData ->
|
||||
settingsData.contents.asSequence()
|
||||
// Only search from enabled prefs and one with valid title
|
||||
.filter { it.enabled && it.title.isNotBlank() }
|
||||
// Flatten items contained inside *enabled* PreferenceGroup
|
||||
.flatMap { p ->
|
||||
when (p) {
|
||||
is Preference.PreferenceGroup -> {
|
||||
if (p.enabled) {
|
||||
p.preferenceItems.asSequence()
|
||||
.filter { it.enabled && it.title.isNotBlank() }
|
||||
.map { p.title to it }
|
||||
} else {
|
||||
emptySequence()
|
||||
}
|
||||
}
|
||||
is Preference.PreferenceItem<*, *> -> sequenceOf(null to p)
|
||||
}
|
||||
}
|
||||
// Don't show info preference
|
||||
.filterNot { it.second is Preference.PreferenceItem.InfoPreference }
|
||||
// Filter by search query
|
||||
.filter { (_, p) ->
|
||||
val inTitle = p.title.contains(searchKey, true)
|
||||
val inSummary = p.subtitle?.contains(searchKey, true) ?: false
|
||||
inTitle || inSummary
|
||||
}
|
||||
// Map result data
|
||||
.map { (categoryTitle, p) ->
|
||||
SearchResultItem(
|
||||
route = settingsData.route,
|
||||
title = p.title,
|
||||
breadcrumbs = getLocalizedBreadcrumb(
|
||||
path = settingsData.title,
|
||||
node = categoryTitle,
|
||||
isLtr = isLtr,
|
||||
),
|
||||
highlightKey = p.title,
|
||||
)
|
||||
}
|
||||
}
|
||||
.take(10) // Just take top 10 result for quicker result
|
||||
.toList()
|
||||
// The query is read here rather than in composition, so typing doesn't rebuild the index on every key
|
||||
val result by produceState<List<SearchResultItem>?>(initialValue = null, index) {
|
||||
snapshotFlow(searchKey).collectLatest { searchKey ->
|
||||
value = if (searchKey.isEmpty()) null else search(index, searchKey, isLtr)
|
||||
}
|
||||
}
|
||||
|
||||
Crossfade(
|
||||
@@ -260,6 +220,55 @@ private fun SearchResult(
|
||||
}
|
||||
}
|
||||
|
||||
private fun search(index: List<SettingsData>, searchKey: String, isLtr: Boolean): List<SearchResultItem> {
|
||||
return index.asSequence()
|
||||
.flatMap { settingsData ->
|
||||
fun result(title: String, categoryTitle: String?) = SearchResultItem(
|
||||
route = settingsData.route,
|
||||
title = title,
|
||||
breadcrumbs = getLocalizedBreadcrumb(
|
||||
path = settingsData.title,
|
||||
node = categoryTitle,
|
||||
isLtr = isLtr,
|
||||
),
|
||||
highlightKey = title,
|
||||
)
|
||||
|
||||
fun Preference.PreferenceItem<*, *>.matches(): Boolean {
|
||||
// Don't show info preference
|
||||
if (this is Preference.PreferenceItem.InfoPreference) return false
|
||||
val inTitle = title.contains(searchKey, true)
|
||||
val inSummary = subtitle?.contains(searchKey, true) ?: false
|
||||
return inTitle || inSummary
|
||||
}
|
||||
|
||||
settingsData.contents.asSequence()
|
||||
// Only search from enabled prefs and one with valid title
|
||||
.filter { it.visible && it.title.isNotBlank() }
|
||||
.flatMap { p ->
|
||||
when (p) {
|
||||
is Preference.PreferenceGroup -> {
|
||||
// A matching heading leads to the group itself, not to one of its items
|
||||
val heading = if (p.title.contains(searchKey, true)) {
|
||||
sequenceOf(result(p.title, null))
|
||||
} else {
|
||||
emptySequence()
|
||||
}
|
||||
val items = p.preferenceItems.asSequence()
|
||||
.filter { it.visible && it.title.isNotBlank() && it.matches() }
|
||||
.map { result(it.title, p.title) }
|
||||
heading + items
|
||||
}
|
||||
is Preference.PreferenceItem<*, *> -> {
|
||||
if (p.matches()) sequenceOf(result(p.title, null)) else emptySequence()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.take(10) // Just take top 10 result for quicker result
|
||||
.toList()
|
||||
}
|
||||
|
||||
@Composable
|
||||
@NonRestartableComposable
|
||||
private fun getIndex() = settingScreens
|
||||
|
||||
+2
-2
@@ -52,7 +52,7 @@ object SettingsSecurityScreen : SearchableSettings {
|
||||
Preference.PreferenceItem.SwitchPreference(
|
||||
preference = useAuthPref,
|
||||
title = stringResource(MR.strings.lock_with_biometrics),
|
||||
enabled = authSupported,
|
||||
visible = authSupported,
|
||||
onValueChanged = {
|
||||
(context as FragmentActivity).authenticate(
|
||||
title = context.stringResource(MR.strings.lock_with_biometrics),
|
||||
@@ -70,7 +70,7 @@ object SettingsSecurityScreen : SearchableSettings {
|
||||
}
|
||||
},
|
||||
title = stringResource(MR.strings.lock_when_idle),
|
||||
enabled = authSupported && useAuth,
|
||||
visible = authSupported && useAuth,
|
||||
onValueChanged = {
|
||||
(context as FragmentActivity).authenticate(
|
||||
title = context.stringResource(MR.strings.lock_when_idle),
|
||||
|
||||
+16
-9
@@ -46,20 +46,22 @@ import eu.kanade.tachiyomi.data.track.EnhancedTracker
|
||||
import eu.kanade.tachiyomi.data.track.Tracker
|
||||
import eu.kanade.tachiyomi.data.track.anilist.AnilistApi
|
||||
import eu.kanade.tachiyomi.data.track.bangumi.BangumiApi
|
||||
import eu.kanade.tachiyomi.data.track.comick.ComickApi
|
||||
import eu.kanade.tachiyomi.data.track.hikka.HikkaApi
|
||||
import eu.kanade.tachiyomi.data.track.mangabaka.MangaBakaApi
|
||||
import eu.kanade.tachiyomi.data.track.myanimelist.MyAnimeListApi
|
||||
import eu.kanade.tachiyomi.data.track.shikimori.ShikimoriApi
|
||||
import eu.kanade.tachiyomi.util.system.openInBrowser
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import mihon.app.di.appGraph
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.automirroredrounded.Help
|
||||
import mihon.icons.materialsymbols.rounded.Close
|
||||
import mihon.icons.materialsymbols.rounded.Visibility
|
||||
import mihon.icons.materialsymbols.rounded.VisibilityOff
|
||||
import tachiyomi.core.common.util.lang.launchIO
|
||||
import tachiyomi.core.common.util.lang.withUIContext
|
||||
import mihon.icons.materialsymbols.roundedfilled.Visibility
|
||||
import mihon.icons.materialsymbols.roundedfilled.VisibilityOff
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.material.padding
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
@@ -177,6 +179,11 @@ object SettingsTrackingScreen : SearchableSettings {
|
||||
login = { context.openInBrowser(HikkaApi.authUrl(), forceDefaultBrowser = true) },
|
||||
logout = { dialog = LogoutDialog(trackerManager.hikka) },
|
||||
),
|
||||
Preference.PreferenceItem.TrackerPreference(
|
||||
tracker = trackerManager.comick,
|
||||
login = { context.openInBrowser(ComickApi.authUrl(), forceDefaultBrowser = true) },
|
||||
logout = { dialog = LogoutDialog(trackerManager.comick) },
|
||||
),
|
||||
Preference.PreferenceItem.InfoPreference(stringResource(MR.strings.tracking_info)),
|
||||
),
|
||||
),
|
||||
@@ -250,9 +257,9 @@ object SettingsTrackingScreen : SearchableSettings {
|
||||
IconButton(onClick = { hidePassword = !hidePassword }) {
|
||||
Icon(
|
||||
imageVector = if (hidePassword) {
|
||||
MaterialSymbols.Rounded.Visibility
|
||||
MaterialSymbols.RoundedFilled.Visibility
|
||||
} else {
|
||||
MaterialSymbols.Rounded.VisibilityOff
|
||||
MaterialSymbols.RoundedFilled.VisibilityOff
|
||||
},
|
||||
contentDescription = null,
|
||||
)
|
||||
@@ -276,7 +283,7 @@ object SettingsTrackingScreen : SearchableSettings {
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
enabled = !processing && username.text.isNotBlank() && password.text.isNotBlank(),
|
||||
onClick = {
|
||||
scope.launchIO {
|
||||
scope.launch(Dispatchers.IO) {
|
||||
processing = true
|
||||
val result = checkLogin(
|
||||
context = context,
|
||||
@@ -305,11 +312,11 @@ object SettingsTrackingScreen : SearchableSettings {
|
||||
): Boolean {
|
||||
return try {
|
||||
tracker.login(username, password)
|
||||
withUIContext { context.toast(MR.strings.login_success) }
|
||||
withContext(Dispatchers.Main) { context.toast(MR.strings.login_success) }
|
||||
true
|
||||
} catch (e: Throwable) {
|
||||
tracker.logout()
|
||||
withUIContext { context.toast(e.message.toString()) }
|
||||
withContext(Dispatchers.Main) { context.toast(e.message.toString()) }
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,9 @@ import eu.kanade.tachiyomi.util.system.isFossBuildType
|
||||
import eu.kanade.tachiyomi.util.system.isNightlyBuildType
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.util.system.updaterEnabled
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.datetime.TimeZone
|
||||
import kotlinx.datetime.toLocalDateTime
|
||||
import logcat.LogPriority
|
||||
@@ -50,8 +52,6 @@ import mihon.icons.simpleicons.Reddit
|
||||
import mihon.icons.simpleicons.SimpleIcons
|
||||
import mihon.icons.simpleicons.X
|
||||
import tachiyomi.core.common.Constants
|
||||
import tachiyomi.core.common.util.lang.withIOContext
|
||||
import tachiyomi.core.common.util.lang.withUIContext
|
||||
import tachiyomi.core.common.util.system.logcat
|
||||
import tachiyomi.domain.release.interactor.GetApplicationRelease
|
||||
import tachiyomi.i18n.MR
|
||||
@@ -218,9 +218,9 @@ object AboutScreen : Screen() {
|
||||
onFinish: () -> Unit,
|
||||
) {
|
||||
val updateChecker = context.appGraph.updateChecker
|
||||
withUIContext {
|
||||
withContext(Dispatchers.Main) {
|
||||
try {
|
||||
when (val result = withIOContext { updateChecker.checkForUpdate(forceCheck = true) }) {
|
||||
when (val result = updateChecker.checkForUpdate(forceCheck = true)) {
|
||||
is GetApplicationRelease.Result.NewUpdate -> {
|
||||
onAvailableUpdate(result)
|
||||
}
|
||||
|
||||
+18
-12
@@ -42,18 +42,19 @@ import eu.kanade.presentation.components.AppBar
|
||||
import eu.kanade.presentation.components.AppBarActions
|
||||
import eu.kanade.presentation.util.Screen
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.launch
|
||||
import mihon.core.metro.AppCoroutineScope
|
||||
import mihon.icons.materialsymbols.MaterialSymbols
|
||||
import mihon.icons.materialsymbols.rounded.FlipToBack
|
||||
import mihon.icons.materialsymbols.rounded.SelectAll
|
||||
import tachiyomi.core.common.util.lang.launchIO
|
||||
import tachiyomi.core.common.util.lang.launchUI
|
||||
import tachiyomi.core.common.util.lang.toLong
|
||||
import tachiyomi.core.common.util.lang.withNonCancellableContext
|
||||
import tachiyomi.data.Database
|
||||
import tachiyomi.domain.history.repository.HistoryRepository
|
||||
import tachiyomi.domain.manga.repository.MangaRepository
|
||||
import tachiyomi.domain.source.interactor.GetSourcesWithNonLibraryManga
|
||||
import tachiyomi.domain.source.model.Source
|
||||
import tachiyomi.domain.source.model.SourceWithCount
|
||||
@@ -117,7 +118,7 @@ class ClearDatabaseScreen : Screen() {
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = {
|
||||
scope.launchUI {
|
||||
scope.launch(Dispatchers.Main) {
|
||||
viewModel.removeMangaBySourceId(keepReadManga)
|
||||
viewModel.clearSelection()
|
||||
viewModel.hideConfirmation()
|
||||
@@ -229,7 +230,9 @@ class ClearDatabaseScreen : Screen() {
|
||||
@ViewModelKey
|
||||
@ContributesIntoMap(AppScope::class, binding = binding<ViewModel>())
|
||||
class ClearDatabaseViewModel(
|
||||
private val database: Database,
|
||||
@AppCoroutineScope private val appScope: CoroutineScope,
|
||||
private val mangaRepository: MangaRepository,
|
||||
private val historyRepository: HistoryRepository,
|
||||
private val getSourcesWithNonLibraryManga: GetSourcesWithNonLibraryManga,
|
||||
) : ViewModel() {
|
||||
|
||||
@@ -237,7 +240,7 @@ class ClearDatabaseViewModel(
|
||||
field = MutableStateFlow<ClearDatabaseViewModel.State>(State.Loading)
|
||||
|
||||
init {
|
||||
viewModelScope.launchIO {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
getSourcesWithNonLibraryManga.subscribe()
|
||||
.collectLatest { list ->
|
||||
state.update { old ->
|
||||
@@ -251,10 +254,13 @@ class ClearDatabaseViewModel(
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun removeMangaBySourceId(keepReadManga: Boolean) = withNonCancellableContext {
|
||||
val state = state.value as? State.Ready ?: return@withNonCancellableContext
|
||||
database.mangasQueries.deleteNonLibraryManga(state.selection, keepReadManga.toLong())
|
||||
database.historyQueries.removeResettedHistory()
|
||||
suspend fun removeMangaBySourceId(keepReadManga: Boolean) {
|
||||
val state = state.value as? State.Ready ?: return
|
||||
// Finishes even if the screen is left while it runs
|
||||
appScope.launch {
|
||||
mangaRepository.deleteNonLibraryManga(state.selection, keepReadManga)
|
||||
historyRepository.deleteResetHistory()
|
||||
}.join()
|
||||
}
|
||||
|
||||
fun toggleSelection(source: Source) = state.update { state ->
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user