Compare commits
No commits in common. "master" and "preview-170" have entirely different histories.
master
...
preview-17
@ -1,32 +1,12 @@
|
|||||||
root = true
|
|
||||||
|
|
||||||
[*]
|
|
||||||
charset = utf-8
|
|
||||||
indent_size = 2
|
|
||||||
indent_style = space
|
|
||||||
insert_final_newline = true
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
|
|
||||||
[*.{xml,sq,sqm}]
|
|
||||||
indent_size = 4
|
|
||||||
|
|
||||||
# noinspection EditorConfigKeyCorrectness
|
|
||||||
[*.{kt,kts}]
|
[*.{kt,kts}]
|
||||||
indent_size = 4
|
|
||||||
max_line_length = 120
|
max_line_length = 120
|
||||||
|
indent_size = 4
|
||||||
|
insert_final_newline = true
|
||||||
ij_kotlin_allow_trailing_comma = true
|
ij_kotlin_allow_trailing_comma = true
|
||||||
ij_kotlin_allow_trailing_comma_on_call_site = true
|
ij_kotlin_allow_trailing_comma_on_call_site = true
|
||||||
ij_kotlin_name_count_to_use_star_import = 2147483647
|
ij_kotlin_name_count_to_use_star_import = 2147483647
|
||||||
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
|
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
|
||||||
|
|
||||||
ktlint_code_style = intellij_idea
|
|
||||||
ktlint_function_naming_ignore_when_annotated_with = Composable
|
|
||||||
ktlint_standard_class-signature = disabled
|
|
||||||
ktlint_standard_discouraged-comment-location = disabled
|
|
||||||
ktlint_standard_function-expression-body = disabled
|
|
||||||
ktlint_standard_function-signature = disabled
|
|
||||||
# SY
|
|
||||||
ktlint_standard_filename = disabled
|
ktlint_standard_filename = disabled
|
||||||
ktlint_standard_argument-list-wrapping = disabled
|
ktlint_standard_argument-list-wrapping = disabled
|
||||||
ktlint_standard_function-naming = disabled
|
ktlint_standard_function-naming = disabled
|
||||||
@ -34,7 +14,3 @@ ktlint_standard_property-naming = disabled
|
|||||||
ktlint_standard_multiline-expression-wrapping = disabled
|
ktlint_standard_multiline-expression-wrapping = disabled
|
||||||
ktlint_standard_string-template-indent = disabled
|
ktlint_standard_string-template-indent = disabled
|
||||||
ktlint_standard_comment-wrapping = disabled
|
ktlint_standard_comment-wrapping = disabled
|
||||||
ktlint_standard_max-line-length = disabled
|
|
||||||
ktlint_standard_type-argument-comment = disabled
|
|
||||||
ktlint_standard_value-argument-comment = disabled
|
|
||||||
ktlint_standard_value-parameter-comment = disabled
|
|
||||||
|
3
.github/ISSUE_TEMPLATE/config.yml
vendored
3
.github/ISSUE_TEMPLATE/config.yml
vendored
@ -1,8 +1,5 @@
|
|||||||
blank_issues_enabled: false
|
blank_issues_enabled: false
|
||||||
contact_links:
|
contact_links:
|
||||||
- name: ❌ Help with Extensions
|
|
||||||
url: https://mihon.app/docs/faq/browse/extensions
|
|
||||||
about: For extension-related questions/issues
|
|
||||||
- name: 🖥️ Mihon website
|
- name: 🖥️ Mihon website
|
||||||
url: https://mihon.app/
|
url: https://mihon.app/
|
||||||
about: Guides, troubleshooting, and answers to common questions
|
about: Guides, troubleshooting, and answers to common questions
|
||||||
|
12
.github/ISSUE_TEMPLATE/report_issue.yml
vendored
12
.github/ISSUE_TEMPLATE/report_issue.yml
vendored
@ -43,9 +43,9 @@ body:
|
|||||||
attributes:
|
attributes:
|
||||||
label: Crash logs
|
label: Crash logs
|
||||||
description: |
|
description: |
|
||||||
If you're experiencing crashes, if possible, go to the app's **More → Settings → Advanced** page, press **Dump crash logs** and share the crash logs here.
|
If you're experiencing crashes, share the crash logs from **More → Settings → Advanced** then press **Dump crash logs**.
|
||||||
placeholder: |
|
placeholder: |
|
||||||
You can upload the crash log file as an attachment, or paste the crash logs in plain text if needed.
|
You can paste the crash logs in plain text or upload it as an attachment.
|
||||||
|
|
||||||
- type: input
|
- type: input
|
||||||
id: tachiyomisy-version
|
id: tachiyomisy-version
|
||||||
@ -53,7 +53,7 @@ body:
|
|||||||
label: TachiyomiSY version
|
label: TachiyomiSY version
|
||||||
description: You can find your TachiyomiSY version in **More → About**.
|
description: You can find your TachiyomiSY version in **More → About**.
|
||||||
placeholder: |
|
placeholder: |
|
||||||
Example: "1.12.0"
|
Example: "1.11.0"
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
@ -96,9 +96,9 @@ body:
|
|||||||
required: true
|
required: true
|
||||||
- label: I have gone through the [FAQ](https://mihon.app/docs/faq/general) and [troubleshooting guide](https://mihon.app/docs/guides/troubleshooting/).
|
- label: I have gone through the [FAQ](https://mihon.app/docs/faq/general) and [troubleshooting guide](https://mihon.app/docs/guides/troubleshooting/).
|
||||||
required: true
|
required: true
|
||||||
- label: I have updated the app to version **[1.12.0](https://github.com/jobobby04/tachiyomisy/releases/latest)**.
|
- label: I have updated the app to version **[1.11.0](https://github.com/jobobby04/tachiyomisy/releases/latest)**.
|
||||||
required: true
|
required: true
|
||||||
- label: I have filled out all of the requested information in this form, including specific version numbers.
|
- label: I have updated all installed extensions.
|
||||||
required: true
|
required: true
|
||||||
- label: I understand that **Mihon does not have or fix any extensions**, and I **will not receive help** for any issues related to sources or extensions.
|
- label: I will fill out all of the requested information in this form.
|
||||||
required: true
|
required: true
|
||||||
|
2
.github/ISSUE_TEMPLATE/request_feature.yml
vendored
2
.github/ISSUE_TEMPLATE/request_feature.yml
vendored
@ -31,7 +31,7 @@ body:
|
|||||||
required: true
|
required: true
|
||||||
- label: I have written a short but informative title.
|
- label: I have written a short but informative title.
|
||||||
required: true
|
required: true
|
||||||
- label: I have updated the app to version **[1.12.0](https://github.com/jobobby04/tachiyomisy/releases/latest)**.
|
- label: I have updated the app to version **[1.11.0](https://github.com/jobobby04/tachiyomisy/releases/latest)**.
|
||||||
required: true
|
required: true
|
||||||
- label: I will fill out all of the requested information in this form.
|
- label: I will fill out all of the requested information in this form.
|
||||||
required: true
|
required: true
|
||||||
|
2
.github/workflows/build_push.yml
vendored
2
.github/workflows/build_push.yml
vendored
@ -63,8 +63,6 @@ jobs:
|
|||||||
alias: ${{ secrets.ALIAS }}
|
alias: ${{ secrets.ALIAS }}
|
||||||
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
|
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
|
||||||
keyPassword: ${{ secrets.KEY_PASSWORD }}
|
keyPassword: ${{ secrets.KEY_PASSWORD }}
|
||||||
env:
|
|
||||||
BUILD_TOOLS_VERSION: '35.0.1'
|
|
||||||
|
|
||||||
- name: Clean up build artifacts
|
- name: Clean up build artifacts
|
||||||
run: |
|
run: |
|
||||||
|
13
.github/workflows/build_push_preview.yml
vendored
13
.github/workflows/build_push_preview.yml
vendored
@ -14,14 +14,8 @@ jobs:
|
|||||||
- name: Clone repo
|
- name: Clone repo
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Set up JDK
|
- name: Validate Gradle Wrapper
|
||||||
uses: actions/setup-java@v4
|
uses: gradle/actions/wrapper-validation@v4
|
||||||
with:
|
|
||||||
java-version: 17
|
|
||||||
distribution: temurin
|
|
||||||
|
|
||||||
- name: Set up gradle
|
|
||||||
uses: gradle/actions/setup-gradle@v4
|
|
||||||
|
|
||||||
- name: Create Tag
|
- name: Create Tag
|
||||||
run: |
|
run: |
|
||||||
@ -34,6 +28,3 @@ jobs:
|
|||||||
-H 'Accept: application/vnd.github.everest-preview+json' \
|
-H 'Accept: application/vnd.github.everest-preview+json' \
|
||||||
-u ${{ secrets.ACCESS_TOKEN }} \
|
-u ${{ secrets.ACCESS_TOKEN }} \
|
||||||
--data '{"event_type": "ping", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'" }}'
|
--data '{"event_type": "ping", "client_payload": { "repository": "'"$GITHUB_REPOSITORY"'" }}'
|
||||||
|
|
||||||
- name: Run unit tests
|
|
||||||
run: ./gradlew testDebugUnitTest testDevDebugUnitTest
|
|
||||||
|
2
.github/workflows/issue_moderator.yml
vendored
2
.github/workflows/issue_moderator.yml
vendored
@ -11,7 +11,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Moderate issues
|
- name: Moderate issues
|
||||||
uses: tachiyomiorg/issue-moderator-action@v2.6.1
|
uses: tachiyomiorg/issue-moderator-action@v2.6.0
|
||||||
with:
|
with:
|
||||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
duplicate-label: Duplicate
|
duplicate-label: Duplicate
|
||||||
|
19
.github/workflows/lock.yml
vendored
Normal file
19
.github/workflows/lock.yml
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
name: Lock threads
|
||||||
|
|
||||||
|
on:
|
||||||
|
# Daily
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * *'
|
||||||
|
# Manual trigger
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lock:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: dessant/lock-threads@v5
|
||||||
|
with:
|
||||||
|
github-token: ${{ github.token }}
|
||||||
|
issue-inactive-days: '2'
|
||||||
|
pr-inactive-days: '2'
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -19,6 +19,3 @@ local.properties
|
|||||||
google-services.json
|
google-services.json
|
||||||
/app/src/main/assets/client_secrets.json
|
/app/src/main/assets/client_secrets.json
|
||||||
*.apk
|
*.apk
|
||||||
|
|
||||||
# Custom ignores
|
|
||||||
/keys
|
|
@ -31,12 +31,12 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "eu.kanade.tachiyomi.sy"
|
applicationId = "eu.kanade.tachiyomi.sy"
|
||||||
|
|
||||||
versionCode = 75
|
versionCode = 71
|
||||||
versionName = "1.12.0"
|
versionName = "1.11.0"
|
||||||
|
|
||||||
buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"")
|
buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"")
|
||||||
buildConfigField("String", "COMMIT_SHA", "\"${getGitSha()}\"")
|
buildConfigField("String", "COMMIT_SHA", "\"${getGitSha()}\"")
|
||||||
buildConfigField("String", "BUILD_TIME", "\"${getBuildTime(useLastCommitTime = false)}\"")
|
buildConfigField("String", "BUILD_TIME", "\"${getBuildTime()}\"")
|
||||||
buildConfigField("boolean", "INCLUDE_UPDATER", "false")
|
buildConfigField("boolean", "INCLUDE_UPDATER", "false")
|
||||||
|
|
||||||
ndk {
|
ndk {
|
||||||
@ -71,8 +71,6 @@ android {
|
|||||||
isMinifyEnabled = true
|
isMinifyEnabled = true
|
||||||
isShrinkResources = true
|
isShrinkResources = true
|
||||||
setProguardFiles(listOf(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"))
|
setProguardFiles(listOf(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"))
|
||||||
|
|
||||||
buildConfigField("String", "BUILD_TIME", "\"${getBuildTime(useLastCommitTime = true)}\"")
|
|
||||||
}
|
}
|
||||||
create("benchmark") {
|
create("benchmark") {
|
||||||
initWith(getByName("release"))
|
initWith(getByName("release"))
|
||||||
@ -239,7 +237,7 @@ dependencies {
|
|||||||
implementation(libs.preferencektx)
|
implementation(libs.preferencektx)
|
||||||
|
|
||||||
// Dependency injection
|
// Dependency injection
|
||||||
implementation(libs.injekt)
|
implementation(libs.injekt.core)
|
||||||
|
|
||||||
// Image loading
|
// Image loading
|
||||||
implementation(platform(libs.coil.bom))
|
implementation(platform(libs.coil.bom))
|
||||||
@ -257,15 +255,13 @@ dependencies {
|
|||||||
exclude(group = "androidx.viewpager", module = "viewpager")
|
exclude(group = "androidx.viewpager", module = "viewpager")
|
||||||
}
|
}
|
||||||
implementation(libs.insetter)
|
implementation(libs.insetter)
|
||||||
implementation(libs.richeditor.compose)
|
implementation(libs.bundles.richtext)
|
||||||
implementation(libs.aboutLibraries.compose)
|
implementation(libs.aboutLibraries.compose)
|
||||||
implementation(libs.bundles.voyager)
|
implementation(libs.bundles.voyager)
|
||||||
implementation(libs.compose.materialmotion)
|
implementation(libs.compose.materialmotion)
|
||||||
implementation(libs.swipe)
|
implementation(libs.swipe)
|
||||||
implementation(libs.compose.webview)
|
implementation(libs.compose.webview)
|
||||||
implementation(libs.compose.grid)
|
implementation(libs.compose.grid)
|
||||||
implementation(libs.reorderable)
|
|
||||||
implementation(libs.bundles.markdown)
|
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
implementation(libs.logcat)
|
implementation(libs.logcat)
|
||||||
@ -310,12 +306,17 @@ dependencies {
|
|||||||
// Koin
|
// Koin
|
||||||
implementation(sylibs.koin.core)
|
implementation(sylibs.koin.core)
|
||||||
implementation(sylibs.koin.android)
|
implementation(sylibs.koin.android)
|
||||||
|
|
||||||
// ZXing Android Embedded
|
|
||||||
implementation(sylibs.zxing.android.embedded)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
androidComponents {
|
androidComponents {
|
||||||
|
beforeVariants { variantBuilder ->
|
||||||
|
// Disables standardBenchmark
|
||||||
|
if (variantBuilder.buildType == "benchmark") {
|
||||||
|
variantBuilder.enable = variantBuilder.productFlavors.containsAll(
|
||||||
|
listOf("default" to "dev"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
onVariants(selector().withFlavor("default" to "standard")) {
|
onVariants(selector().withFlavor("default" to "standard")) {
|
||||||
// Only excluding in standard flavor because this breaks
|
// Only excluding in standard flavor because this breaks
|
||||||
// Layout Inspector's Compose tree
|
// Layout Inspector's Compose tree
|
||||||
|
@ -359,7 +359,7 @@
|
|||||||
<data android:scheme="https" />
|
<data android:scheme="https" />
|
||||||
<data android:scheme="http" />
|
<data android:scheme="http" />
|
||||||
|
|
||||||
<data android:host="pururin.me" />
|
<data android:host="pururin.io" />
|
||||||
|
|
||||||
<data android:pathPattern="/gallery/..*" />
|
<data android:pathPattern="/gallery/..*" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
@ -413,10 +413,6 @@
|
|||||||
android:scheme="tachiyomisy" />
|
android:scheme="tachiyomisy" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name="com.journeyapps.barcodescanner.CaptureActivity"
|
|
||||||
tools:remove="screenOrientation" />
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<uses-sdk tools:overrideLibrary="rikka.shizuku.api"
|
<uses-sdk tools:overrideLibrary="rikka.shizuku.api"
|
||||||
|
@ -82,7 +82,6 @@ import tachiyomi.domain.manga.interactor.GetMangaWithChapters
|
|||||||
import tachiyomi.domain.manga.interactor.NetworkToLocalManga
|
import tachiyomi.domain.manga.interactor.NetworkToLocalManga
|
||||||
import tachiyomi.domain.manga.interactor.ResetViewerFlags
|
import tachiyomi.domain.manga.interactor.ResetViewerFlags
|
||||||
import tachiyomi.domain.manga.interactor.SetMangaChapterFlags
|
import tachiyomi.domain.manga.interactor.SetMangaChapterFlags
|
||||||
import tachiyomi.domain.manga.interactor.UpdateMangaNotes
|
|
||||||
import tachiyomi.domain.manga.repository.MangaRepository
|
import tachiyomi.domain.manga.repository.MangaRepository
|
||||||
import tachiyomi.domain.release.interactor.GetApplicationRelease
|
import tachiyomi.domain.release.interactor.GetApplicationRelease
|
||||||
import tachiyomi.domain.release.service.ReleaseService
|
import tachiyomi.domain.release.service.ReleaseService
|
||||||
@ -111,7 +110,7 @@ class DomainModule : InjektModule {
|
|||||||
addFactory { RenameCategory(get()) }
|
addFactory { RenameCategory(get()) }
|
||||||
addFactory { ReorderCategory(get()) }
|
addFactory { ReorderCategory(get()) }
|
||||||
addFactory { UpdateCategory(get()) }
|
addFactory { UpdateCategory(get()) }
|
||||||
addFactory { DeleteCategory(get(), get(), get()) }
|
addFactory { DeleteCategory(get()) }
|
||||||
|
|
||||||
addSingletonFactory<MangaRepository> { MangaRepositoryImpl(get()) }
|
addSingletonFactory<MangaRepository> { MangaRepositoryImpl(get()) }
|
||||||
addFactory { GetDuplicateLibraryManga(get()) }
|
addFactory { GetDuplicateLibraryManga(get()) }
|
||||||
@ -129,7 +128,6 @@ class DomainModule : InjektModule {
|
|||||||
addFactory { SetMangaViewerFlags(get()) }
|
addFactory { SetMangaViewerFlags(get()) }
|
||||||
addFactory { NetworkToLocalManga(get()) }
|
addFactory { NetworkToLocalManga(get()) }
|
||||||
addFactory { UpdateManga(get(), get()) }
|
addFactory { UpdateManga(get(), get()) }
|
||||||
addFactory { UpdateMangaNotes(get()) }
|
|
||||||
addFactory { SetMangaCategories(get()) }
|
addFactory { SetMangaCategories(get()) }
|
||||||
addFactory { GetExcludedScanlators(get()) }
|
addFactory { GetExcludedScanlators(get()) }
|
||||||
addFactory { SetExcludedScanlators(get()) }
|
addFactory { SetExcludedScanlators(get()) }
|
||||||
@ -154,7 +152,7 @@ class DomainModule : InjektModule {
|
|||||||
addFactory { UpdateChapter(get()) }
|
addFactory { UpdateChapter(get()) }
|
||||||
addFactory { SetReadStatus(get(), get(), get(), get(), get()) }
|
addFactory { SetReadStatus(get(), get(), get(), get(), get()) }
|
||||||
addFactory { ShouldUpdateDbChapter() }
|
addFactory { ShouldUpdateDbChapter() }
|
||||||
addFactory { SyncChaptersWithSource(get(), get(), get(), get(), get(), get(), get(), get(), get()) }
|
addFactory { SyncChaptersWithSource(get(), get(), get(), get(), get(), get(), get(), get()) }
|
||||||
addFactory { GetAvailableScanlators(get()) }
|
addFactory { GetAvailableScanlators(get()) }
|
||||||
addFactory { FilterChaptersForDownload(get(), get(), get(), get()) }
|
addFactory { FilterChaptersForDownload(get(), get(), get(), get()) }
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import tachiyomi.data.source.SavedSearchRepositoryImpl
|
|||||||
import tachiyomi.domain.chapter.interactor.DeleteChapters
|
import tachiyomi.domain.chapter.interactor.DeleteChapters
|
||||||
import tachiyomi.domain.chapter.interactor.GetChapterByUrl
|
import tachiyomi.domain.chapter.interactor.GetChapterByUrl
|
||||||
import tachiyomi.domain.chapter.interactor.GetMergedChaptersByMangaId
|
import tachiyomi.domain.chapter.interactor.GetMergedChaptersByMangaId
|
||||||
|
import tachiyomi.domain.history.interactor.GetHistoryByMangaId
|
||||||
import tachiyomi.domain.manga.interactor.DeleteByMergeId
|
import tachiyomi.domain.manga.interactor.DeleteByMergeId
|
||||||
import tachiyomi.domain.manga.interactor.DeleteFavoriteEntries
|
import tachiyomi.domain.manga.interactor.DeleteFavoriteEntries
|
||||||
import tachiyomi.domain.manga.interactor.DeleteMangaById
|
import tachiyomi.domain.manga.interactor.DeleteMangaById
|
||||||
@ -87,6 +88,7 @@ class SYDomainModule : InjektModule {
|
|||||||
addFactory { DeleteChapters(get()) }
|
addFactory { DeleteChapters(get()) }
|
||||||
addFactory { DeleteMangaById(get()) }
|
addFactory { DeleteMangaById(get()) }
|
||||||
addFactory { FilterSerializer() }
|
addFactory { FilterSerializer() }
|
||||||
|
addFactory { GetHistoryByMangaId(get()) }
|
||||||
addFactory { GetChapterByUrl(get()) }
|
addFactory { GetChapterByUrl(get()) }
|
||||||
addFactory { GetSourceCategories(get()) }
|
addFactory { GetSourceCategories(get()) }
|
||||||
addFactory { CreateSourceCategory(get()) }
|
addFactory { CreateSourceCategory(get()) }
|
||||||
|
@ -20,7 +20,6 @@ import tachiyomi.domain.chapter.model.NoChaptersException
|
|||||||
import tachiyomi.domain.chapter.model.toChapterUpdate
|
import tachiyomi.domain.chapter.model.toChapterUpdate
|
||||||
import tachiyomi.domain.chapter.repository.ChapterRepository
|
import tachiyomi.domain.chapter.repository.ChapterRepository
|
||||||
import tachiyomi.domain.chapter.service.ChapterRecognition
|
import tachiyomi.domain.chapter.service.ChapterRecognition
|
||||||
import tachiyomi.domain.library.service.LibraryPreferences
|
|
||||||
import tachiyomi.domain.manga.model.Manga
|
import tachiyomi.domain.manga.model.Manga
|
||||||
import tachiyomi.source.local.isLocal
|
import tachiyomi.source.local.isLocal
|
||||||
import java.lang.Long.max
|
import java.lang.Long.max
|
||||||
@ -36,7 +35,6 @@ class SyncChaptersWithSource(
|
|||||||
private val updateChapter: UpdateChapter,
|
private val updateChapter: UpdateChapter,
|
||||||
private val getChaptersByMangaId: GetChaptersByMangaId,
|
private val getChaptersByMangaId: GetChaptersByMangaId,
|
||||||
private val getExcludedScanlators: GetExcludedScanlators,
|
private val getExcludedScanlators: GetExcludedScanlators,
|
||||||
private val libraryPreferences: LibraryPreferences,
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -152,18 +150,12 @@ class SyncChaptersWithSource(
|
|||||||
return emptyList()
|
return emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
val changedOrDuplicateReadUrls = mutableSetOf<String>()
|
val reAdded = mutableListOf<Chapter>()
|
||||||
|
|
||||||
val deletedChapterNumbers = TreeSet<Double>()
|
val deletedChapterNumbers = TreeSet<Double>()
|
||||||
val deletedReadChapterNumbers = TreeSet<Double>()
|
val deletedReadChapterNumbers = TreeSet<Double>()
|
||||||
val deletedBookmarkedChapterNumbers = TreeSet<Double>()
|
val deletedBookmarkedChapterNumbers = TreeSet<Double>()
|
||||||
|
|
||||||
val readChapterNumbers = dbChapters
|
|
||||||
.asSequence()
|
|
||||||
.filter { it.read && it.isRecognizedNumber }
|
|
||||||
.map { it.chapterNumber }
|
|
||||||
.toSet()
|
|
||||||
|
|
||||||
removedChapters.forEach { chapter ->
|
removedChapters.forEach { chapter ->
|
||||||
if (chapter.read) deletedReadChapterNumbers.add(chapter.chapterNumber)
|
if (chapter.read) deletedReadChapterNumbers.add(chapter.chapterNumber)
|
||||||
if (chapter.bookmark) deletedBookmarkedChapterNumbers.add(chapter.chapterNumber)
|
if (chapter.bookmark) deletedBookmarkedChapterNumbers.add(chapter.chapterNumber)
|
||||||
@ -173,20 +165,12 @@ class SyncChaptersWithSource(
|
|||||||
val deletedChapterNumberDateFetchMap = removedChapters.sortedByDescending { it.dateFetch }
|
val deletedChapterNumberDateFetchMap = removedChapters.sortedByDescending { it.dateFetch }
|
||||||
.associate { it.chapterNumber to it.dateFetch }
|
.associate { it.chapterNumber to it.dateFetch }
|
||||||
|
|
||||||
val markDuplicateAsRead = libraryPreferences.markDuplicateReadChapterAsRead().get()
|
|
||||||
.contains(LibraryPreferences.MARK_DUPLICATE_CHAPTER_READ_NEW)
|
|
||||||
|
|
||||||
// Date fetch is set in such a way that the upper ones will have bigger value than the lower ones
|
// 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.
|
// Sources MUST return the chapters from most to less recent, which is common.
|
||||||
var itemCount = newChapters.size
|
var itemCount = newChapters.size
|
||||||
var updatedToAdd = newChapters.map { toAddItem ->
|
var updatedToAdd = newChapters.map { toAddItem ->
|
||||||
var chapter = toAddItem.copy(dateFetch = nowMillis + itemCount--)
|
var chapter = toAddItem.copy(dateFetch = nowMillis + itemCount--)
|
||||||
|
|
||||||
if (chapter.chapterNumber in readChapterNumbers && markDuplicateAsRead) {
|
|
||||||
changedOrDuplicateReadUrls.add(chapter.url)
|
|
||||||
chapter = chapter.copy(read = true)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!chapter.isRecognizedNumber || chapter.chapterNumber !in deletedChapterNumbers) return@map chapter
|
if (!chapter.isRecognizedNumber || chapter.chapterNumber !in deletedChapterNumbers) return@map chapter
|
||||||
|
|
||||||
chapter = chapter.copy(
|
chapter = chapter.copy(
|
||||||
@ -199,19 +183,19 @@ class SyncChaptersWithSource(
|
|||||||
chapter = chapter.copy(dateFetch = it)
|
chapter = chapter.copy(dateFetch = it)
|
||||||
}
|
}
|
||||||
|
|
||||||
changedOrDuplicateReadUrls.add(chapter.url)
|
reAdded.add(chapter)
|
||||||
|
|
||||||
chapter
|
chapter
|
||||||
}
|
}
|
||||||
|
|
||||||
// --> EXH (carry over reading progress)
|
// --> EXH (carry over reading progress)
|
||||||
if (manga.isEhBasedManga()) {
|
if (manga.isEhBasedManga()) {
|
||||||
val finalAdded = updatedToAdd.filterNot { it.url in changedOrDuplicateReadUrls }
|
val finalAdded = updatedToAdd.subtract(reAdded)
|
||||||
if (finalAdded.isNotEmpty()) {
|
if (finalAdded.isNotEmpty()) {
|
||||||
val max = dbChapters.maxOfOrNull { it.lastPageRead }
|
val max = dbChapters.maxOfOrNull { it.lastPageRead }
|
||||||
if (max != null && max > 0) {
|
if (max != null && max > 0) {
|
||||||
updatedToAdd = updatedToAdd.map {
|
updatedToAdd = updatedToAdd.map {
|
||||||
if (it.url !in changedOrDuplicateReadUrls) {
|
if (it !in reAdded) {
|
||||||
it.copy(lastPageRead = max)
|
it.copy(lastPageRead = max)
|
||||||
} else {
|
} else {
|
||||||
it
|
it
|
||||||
@ -241,8 +225,12 @@ class SyncChaptersWithSource(
|
|||||||
// Note that last_update actually represents last time the chapter list changed at all
|
// Note that last_update actually represents last time the chapter list changed at all
|
||||||
updateManga.awaitUpdateLastUpdate(manga.id)
|
updateManga.awaitUpdateLastUpdate(manga.id)
|
||||||
|
|
||||||
|
val reAddedUrls = reAdded.map { it.url }.toHashSet()
|
||||||
|
|
||||||
val excludedScanlators = getExcludedScanlators.await(manga.id).toHashSet()
|
val excludedScanlators = getExcludedScanlators.await(manga.id).toHashSet()
|
||||||
|
|
||||||
return updatedToAdd.filterNot { it.url in changedOrDuplicateReadUrls || it.scanlator in excludedScanlators }
|
return updatedToAdd.filterNot {
|
||||||
|
it.url in reAddedUrls || it.scanlator in excludedScanlators
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ class GetPagePreviews(
|
|||||||
return try {
|
return try {
|
||||||
val pagePreviews = try {
|
val pagePreviews = try {
|
||||||
pagePreviewCache.getPageListFromCache(manga, chapterIds, page)
|
pagePreviewCache.getPageListFromCache(manga, chapterIds, page)
|
||||||
} catch (_: Exception) {
|
} catch (e: Exception) {
|
||||||
source.getPagePreviewList(manga.toSManga(), chapters.map { it.toSChapter() }, page).also {
|
source.getPagePreviewList(manga.toSManga(), chapters.map { it.toSChapter() }, page).also {
|
||||||
pagePreviewCache.putPageListToCache(manga, chapterIds, it)
|
pagePreviewCache.putPageListToCache(manga, chapterIds, it)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import eu.kanade.domain.manga.model.hasCustomCover
|
|||||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import tachiyomi.domain.library.service.LibraryPreferences
|
|
||||||
import tachiyomi.domain.manga.interactor.FetchInterval
|
import tachiyomi.domain.manga.interactor.FetchInterval
|
||||||
import tachiyomi.domain.manga.model.Manga
|
import tachiyomi.domain.manga.model.Manga
|
||||||
import tachiyomi.domain.manga.model.MangaUpdate
|
import tachiyomi.domain.manga.model.MangaUpdate
|
||||||
@ -33,8 +32,9 @@ class UpdateManga(
|
|||||||
remoteManga: SManga,
|
remoteManga: SManga,
|
||||||
manualFetch: Boolean,
|
manualFetch: Boolean,
|
||||||
coverCache: CoverCache = Injekt.get(),
|
coverCache: CoverCache = Injekt.get(),
|
||||||
libraryPreferences: LibraryPreferences = Injekt.get(),
|
// SY -->
|
||||||
downloadManager: DownloadManager = Injekt.get(),
|
downloadManager: DownloadManager = Injekt.get(),
|
||||||
|
// SY <--
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val remoteTitle = try {
|
val remoteTitle = try {
|
||||||
remoteManga.title
|
remoteManga.title
|
||||||
@ -42,13 +42,14 @@ class UpdateManga(
|
|||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the manga isn't a favorite (or 'update titles' preference is enabled), set its title from source and update in db
|
// SY -->
|
||||||
val title =
|
val title = if (remoteTitle.isNotBlank() && localManga.ogTitle != remoteTitle) {
|
||||||
if (remoteTitle.isNotEmpty() && (!localManga.favorite || libraryPreferences.updateMangaTitles().get())) {
|
downloadManager.renameMangaDir(localManga.ogTitle, remoteTitle, localManga.source)
|
||||||
remoteTitle
|
remoteTitle
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
// SY <--
|
||||||
|
|
||||||
val coverLastModified =
|
val coverLastModified =
|
||||||
when {
|
when {
|
||||||
@ -68,7 +69,7 @@ class UpdateManga(
|
|||||||
|
|
||||||
val thumbnailUrl = remoteManga.thumbnail_url?.takeIf { it.isNotEmpty() }
|
val thumbnailUrl = remoteManga.thumbnail_url?.takeIf { it.isNotEmpty() }
|
||||||
|
|
||||||
val success = mangaRepository.update(
|
return mangaRepository.update(
|
||||||
MangaUpdate(
|
MangaUpdate(
|
||||||
id = localManga.id,
|
id = localManga.id,
|
||||||
title = title,
|
title = title,
|
||||||
@ -83,10 +84,6 @@ class UpdateManga(
|
|||||||
initialized = true,
|
initialized = true,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if (success && title != null) {
|
|
||||||
downloadManager.renameManga(localManga, title)
|
|
||||||
}
|
|
||||||
return success
|
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun awaitUpdateFetchInterval(
|
suspend fun awaitUpdateFetchInterval(
|
||||||
|
@ -23,7 +23,7 @@ val Manga.readerOrientation: Long
|
|||||||
|
|
||||||
val Manga.downloadedFilter: TriState
|
val Manga.downloadedFilter: TriState
|
||||||
get() {
|
get() {
|
||||||
if (Injekt.get<BasePreferences>().downloadedOnly().get()) return TriState.ENABLED_IS
|
if (forceDownloaded()) return TriState.ENABLED_IS
|
||||||
return when (downloadedFilterRaw) {
|
return when (downloadedFilterRaw) {
|
||||||
Manga.CHAPTER_SHOW_DOWNLOADED -> TriState.ENABLED_IS
|
Manga.CHAPTER_SHOW_DOWNLOADED -> TriState.ENABLED_IS
|
||||||
Manga.CHAPTER_SHOW_NOT_DOWNLOADED -> TriState.ENABLED_NOT
|
Manga.CHAPTER_SHOW_NOT_DOWNLOADED -> TriState.ENABLED_NOT
|
||||||
@ -35,17 +35,18 @@ fun Manga.chaptersFiltered(): Boolean {
|
|||||||
downloadedFilter != TriState.DISABLED ||
|
downloadedFilter != TriState.DISABLED ||
|
||||||
bookmarkedFilter != TriState.DISABLED
|
bookmarkedFilter != TriState.DISABLED
|
||||||
}
|
}
|
||||||
|
fun Manga.forceDownloaded(): Boolean {
|
||||||
|
return favorite && Injekt.get<BasePreferences>().downloadedOnly().get()
|
||||||
|
}
|
||||||
|
|
||||||
fun Manga.toSManga(): SManga = SManga.create().also {
|
fun Manga.toSManga(): SManga = SManga.create().also {
|
||||||
it.url = url
|
it.url = url
|
||||||
// SY -->
|
it.title = title
|
||||||
it.title = ogTitle
|
it.artist = artist
|
||||||
it.artist = ogArtist
|
it.author = author
|
||||||
it.author = ogAuthor
|
it.description = description
|
||||||
it.description = ogDescription
|
it.genre = genre.orEmpty().joinToString()
|
||||||
it.genre = ogGenre.orEmpty().joinToString()
|
it.status = status.toInt()
|
||||||
it.status = ogStatus.toInt()
|
|
||||||
// SY <--
|
|
||||||
it.thumbnail_url = thumbnailUrl
|
it.thumbnail_url = thumbnailUrl
|
||||||
it.initialized = initialized
|
it.initialized = initialized
|
||||||
}
|
}
|
||||||
@ -78,6 +79,24 @@ fun Manga.copyFrom(other: SManga): Manga {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun SManga.toDomainManga(sourceId: Long): Manga {
|
||||||
|
return Manga.create().copy(
|
||||||
|
url = url,
|
||||||
|
// SY -->
|
||||||
|
ogTitle = title,
|
||||||
|
ogArtist = artist,
|
||||||
|
ogAuthor = author,
|
||||||
|
ogThumbnailUrl = thumbnail_url,
|
||||||
|
ogDescription = description,
|
||||||
|
ogGenre = getGenres(),
|
||||||
|
ogStatus = status.toLong(),
|
||||||
|
// SY <--
|
||||||
|
updateStrategy = update_strategy,
|
||||||
|
initialized = initialized,
|
||||||
|
source = sourceId,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun Manga.hasCustomCover(coverCache: CoverCache = Injekt.get()): Boolean {
|
fun Manga.hasCustomCover(coverCache: CoverCache = Injekt.get()): Boolean {
|
||||||
return coverCache.getCustomCoverFile(id).exists()
|
return coverCache.getCustomCoverFile(id).exists()
|
||||||
}
|
}
|
||||||
|
@ -88,32 +88,5 @@ class SourcePreferences(
|
|||||||
BANDWIDTH_HERO,
|
BANDWIDTH_HERO,
|
||||||
WSRV_NL,
|
WSRV_NL,
|
||||||
}
|
}
|
||||||
|
|
||||||
fun migrateFlags() = preferenceStore.getInt("migrate_flags", Int.MAX_VALUE)
|
|
||||||
|
|
||||||
fun defaultMangaOrder() = preferenceStore.getString("default_manga_order", "")
|
|
||||||
|
|
||||||
fun migrationSources() = preferenceStore.getString("migrate_sources", "")
|
|
||||||
|
|
||||||
fun smartMigration() = preferenceStore.getBoolean("smart_migrate", false)
|
|
||||||
|
|
||||||
fun useSourceWithMost() = preferenceStore.getBoolean("use_source_with_most", false)
|
|
||||||
|
|
||||||
fun skipPreMigration() = preferenceStore.getBoolean(Preference.appStateKey("skip_pre_migration"), false)
|
|
||||||
|
|
||||||
fun hideNotFoundMigration() = preferenceStore.getBoolean("hide_not_found_migration", false)
|
|
||||||
|
|
||||||
fun showOnlyUpdatesMigration() = preferenceStore.getBoolean("show_only_updates_migration", false)
|
|
||||||
|
|
||||||
fun allowLocalSourceHiddenFolders() = preferenceStore.getBoolean("allow_local_source_hidden_folders", false)
|
|
||||||
|
|
||||||
fun preferredMangaDexId() = preferenceStore.getString("preferred_mangaDex_id", "0")
|
|
||||||
|
|
||||||
fun mangadexSyncToLibraryIndexes() = preferenceStore.getStringSet(
|
|
||||||
"pref_mangadex_sync_to_library_indexes",
|
|
||||||
emptySet(),
|
|
||||||
)
|
|
||||||
|
|
||||||
fun recommendationSearchFlags() = preferenceStore.getInt("rec_search_flags", Int.MAX_VALUE)
|
|
||||||
// SY <--
|
// SY <--
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ fun Track.copyPersonalFrom(other: Track): Track {
|
|||||||
status = other.status,
|
status = other.status,
|
||||||
startDate = other.startDate,
|
startDate = other.startDate,
|
||||||
finishDate = other.finishDate,
|
finishDate = other.finishDate,
|
||||||
private = other.private,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,7 +26,6 @@ fun Track.toDbTrack(): DbTrack = DbTrack.create(trackerId).also {
|
|||||||
it.tracking_url = remoteUrl
|
it.tracking_url = remoteUrl
|
||||||
it.started_reading_date = startDate
|
it.started_reading_date = startDate
|
||||||
it.finished_reading_date = finishDate
|
it.finished_reading_date = finishDate
|
||||||
it.private = private
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun DbTrack.toDomainTrack(idRequired: Boolean = true): Track? {
|
fun DbTrack.toDomainTrack(idRequired: Boolean = true): Track? {
|
||||||
@ -46,6 +44,5 @@ fun DbTrack.toDomainTrack(idRequired: Boolean = true): Track? {
|
|||||||
remoteUrl = tracking_url,
|
remoteUrl = tracking_url,
|
||||||
startDate = started_reading_date,
|
startDate = started_reading_date,
|
||||||
finishDate = finished_reading_date,
|
finishDate = finished_reading_date,
|
||||||
private = private,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -42,11 +42,4 @@ class TrackPreferences(
|
|||||||
"pref_auto_update_manga_on_mark_read",
|
"pref_auto_update_manga_on_mark_read",
|
||||||
AutoTrackState.ALWAYS,
|
AutoTrackState.ALWAYS,
|
||||||
)
|
)
|
||||||
|
|
||||||
// SY -->
|
|
||||||
fun resolveUsingSourceMetadata() = preferenceStore.getBoolean(
|
|
||||||
"pref_resolve_using_source_metadata_key",
|
|
||||||
true,
|
|
||||||
)
|
|
||||||
// SY <--
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package eu.kanade.domain.ui.model
|
package eu.kanade.domain.ui.model
|
||||||
|
|
||||||
import dev.icerock.moko.resources.StringResource
|
import dev.icerock.moko.resources.StringResource
|
||||||
|
import eu.kanade.tachiyomi.util.system.isDevFlavor
|
||||||
|
import eu.kanade.tachiyomi.util.system.isPreviewBuildType
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
|
|
||||||
enum class AppTheme(val titleRes: StringResource?) {
|
enum class AppTheme(val titleRes: StringResource?) {
|
||||||
@ -9,14 +11,15 @@ enum class AppTheme(val titleRes: StringResource?) {
|
|||||||
GREEN_APPLE(MR.strings.theme_greenapple),
|
GREEN_APPLE(MR.strings.theme_greenapple),
|
||||||
LAVENDER(MR.strings.theme_lavender),
|
LAVENDER(MR.strings.theme_lavender),
|
||||||
MIDNIGHT_DUSK(MR.strings.theme_midnightdusk),
|
MIDNIGHT_DUSK(MR.strings.theme_midnightdusk),
|
||||||
NORD(MR.strings.theme_nord),
|
|
||||||
|
// TODO: re-enable for preview
|
||||||
|
NORD(MR.strings.theme_nord.takeIf { isDevFlavor || isPreviewBuildType }),
|
||||||
STRAWBERRY_DAIQUIRI(MR.strings.theme_strawberrydaiquiri),
|
STRAWBERRY_DAIQUIRI(MR.strings.theme_strawberrydaiquiri),
|
||||||
TAKO(MR.strings.theme_tako),
|
TAKO(MR.strings.theme_tako),
|
||||||
TEALTURQUOISE(MR.strings.theme_tealturquoise),
|
TEALTURQUOISE(MR.strings.theme_tealturquoise),
|
||||||
TIDAL_WAVE(MR.strings.theme_tidalwave),
|
TIDAL_WAVE(MR.strings.theme_tidalwave),
|
||||||
YINYANG(MR.strings.theme_yinyang),
|
YINYANG(MR.strings.theme_yinyang),
|
||||||
YOTSUBA(MR.strings.theme_yotsuba),
|
YOTSUBA(MR.strings.theme_yotsuba),
|
||||||
MONOCHROME(MR.strings.theme_monochrome),
|
|
||||||
|
|
||||||
// Deprecated
|
// Deprecated
|
||||||
DARK_BLUE(null),
|
DARK_BLUE(null),
|
||||||
|
@ -82,18 +82,10 @@ fun BrowseSourceContent(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mangaList.itemCount == 0 && mangaList.loadState.refresh is LoadState.Loading) {
|
if (mangaList.itemCount <= 0 && errorState != null && errorState is LoadState.Error) {
|
||||||
LoadingScreen(Modifier.padding(contentPadding))
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mangaList.itemCount == 0) {
|
|
||||||
EmptyScreen(
|
EmptyScreen(
|
||||||
modifier = Modifier.padding(contentPadding),
|
modifier = Modifier.padding(contentPadding),
|
||||||
message = when (errorState) {
|
message = getErrorMessage(errorState),
|
||||||
is LoadState.Error -> getErrorMessage(errorState)
|
|
||||||
else -> stringResource(MR.strings.no_results_found)
|
|
||||||
},
|
|
||||||
actions = if (source is LocalSource /* SY --> */ && onLocalSourceHelpClick != null /* SY <-- */) {
|
actions = if (source is LocalSource /* SY --> */ && onLocalSourceHelpClick != null /* SY <-- */) {
|
||||||
persistentListOf(
|
persistentListOf(
|
||||||
EmptyScreenAction(
|
EmptyScreenAction(
|
||||||
@ -112,7 +104,7 @@ fun BrowseSourceContent(
|
|||||||
// SY -->
|
// SY -->
|
||||||
if (onWebViewClick != null) {
|
if (onWebViewClick != null) {
|
||||||
EmptyScreenAction(
|
EmptyScreenAction(
|
||||||
stringRes = MR.strings.action_open_in_web_view,
|
MR.strings.action_open_in_web_view,
|
||||||
icon = Icons.Outlined.Public,
|
icon = Icons.Outlined.Public,
|
||||||
onClick = onWebViewClick,
|
onClick = onWebViewClick,
|
||||||
)
|
)
|
||||||
@ -121,7 +113,7 @@ fun BrowseSourceContent(
|
|||||||
},
|
},
|
||||||
if (onHelpClick != null) {
|
if (onHelpClick != null) {
|
||||||
EmptyScreenAction(
|
EmptyScreenAction(
|
||||||
stringRes = MR.strings.label_help,
|
MR.strings.label_help,
|
||||||
icon = Icons.AutoMirrored.Outlined.HelpOutline,
|
icon = Icons.AutoMirrored.Outlined.HelpOutline,
|
||||||
onClick = onHelpClick,
|
onClick = onHelpClick,
|
||||||
)
|
)
|
||||||
@ -136,6 +128,13 @@ fun BrowseSourceContent(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mangaList.itemCount == 0 && mangaList.loadState.refresh is LoadState.Loading) {
|
||||||
|
LoadingScreen(
|
||||||
|
modifier = Modifier.padding(contentPadding),
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
if (source?.isEhBasedSource() == true && ehentaiBrowseDisplayMode) {
|
if (source?.isEhBasedSource() == true && ehentaiBrowseDisplayMode) {
|
||||||
BrowseSourceEHentaiList(
|
BrowseSourceEHentaiList(
|
||||||
|
@ -19,7 +19,6 @@ import eu.kanade.presentation.library.components.MangaComfortableGridItem
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import exh.metadata.metadata.MangaDexSearchMetadata
|
import exh.metadata.metadata.MangaDexSearchMetadata
|
||||||
import exh.metadata.metadata.RaisedSearchMetadata
|
import exh.metadata.metadata.RaisedSearchMetadata
|
||||||
import exh.metadata.metadata.RankedSearchMetadata
|
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
import tachiyomi.domain.manga.model.Manga
|
import tachiyomi.domain.manga.model.Manga
|
||||||
import tachiyomi.domain.manga.model.MangaCover
|
import tachiyomi.domain.manga.model.MangaCover
|
||||||
@ -120,14 +119,6 @@ private fun BrowseSourceComfortableGridItem(
|
|||||||
textColor = MaterialTheme.colorScheme.onTertiary,
|
textColor = MaterialTheme.colorScheme.onTertiary,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else if (metadata is RankedSearchMetadata) {
|
|
||||||
metadata.rank?.let {
|
|
||||||
Badge(
|
|
||||||
text = "+$it",
|
|
||||||
color = MaterialTheme.colorScheme.tertiary,
|
|
||||||
textColor = MaterialTheme.colorScheme.onTertiary,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// SY <--
|
// SY <--
|
||||||
|
@ -19,7 +19,6 @@ import eu.kanade.presentation.library.components.MangaCompactGridItem
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import exh.metadata.metadata.MangaDexSearchMetadata
|
import exh.metadata.metadata.MangaDexSearchMetadata
|
||||||
import exh.metadata.metadata.RaisedSearchMetadata
|
import exh.metadata.metadata.RaisedSearchMetadata
|
||||||
import exh.metadata.metadata.RankedSearchMetadata
|
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
import tachiyomi.domain.manga.model.Manga
|
import tachiyomi.domain.manga.model.Manga
|
||||||
import tachiyomi.domain.manga.model.MangaCover
|
import tachiyomi.domain.manga.model.MangaCover
|
||||||
@ -120,14 +119,6 @@ private fun BrowseSourceCompactGridItem(
|
|||||||
textColor = MaterialTheme.colorScheme.onTertiary,
|
textColor = MaterialTheme.colorScheme.onTertiary,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else if (metadata is RankedSearchMetadata) {
|
|
||||||
metadata.rank?.let {
|
|
||||||
Badge(
|
|
||||||
text = "+$it",
|
|
||||||
color = MaterialTheme.colorScheme.tertiary,
|
|
||||||
textColor = MaterialTheme.colorScheme.onTertiary,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// SY <--
|
// SY <--
|
||||||
|
@ -16,7 +16,6 @@ import eu.kanade.presentation.library.components.MangaListItem
|
|||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import exh.metadata.metadata.MangaDexSearchMetadata
|
import exh.metadata.metadata.MangaDexSearchMetadata
|
||||||
import exh.metadata.metadata.RaisedSearchMetadata
|
import exh.metadata.metadata.RaisedSearchMetadata
|
||||||
import exh.metadata.metadata.RankedSearchMetadata
|
|
||||||
import kotlinx.coroutines.flow.StateFlow
|
import kotlinx.coroutines.flow.StateFlow
|
||||||
import tachiyomi.domain.manga.model.Manga
|
import tachiyomi.domain.manga.model.Manga
|
||||||
import tachiyomi.domain.manga.model.MangaCover
|
import tachiyomi.domain.manga.model.MangaCover
|
||||||
@ -111,14 +110,6 @@ private fun BrowseSourceListItem(
|
|||||||
textColor = MaterialTheme.colorScheme.onTertiary,
|
textColor = MaterialTheme.colorScheme.onTertiary,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else if (metadata is RankedSearchMetadata) {
|
|
||||||
metadata.rank?.let {
|
|
||||||
Badge(
|
|
||||||
text = "+$it",
|
|
||||||
color = MaterialTheme.colorScheme.tertiary,
|
|
||||||
textColor = MaterialTheme.colorScheme.onTertiary,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// SY <--
|
// SY <--
|
||||||
},
|
},
|
||||||
|
@ -2,25 +2,23 @@ package eu.kanade.presentation.category
|
|||||||
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.LazyListState
|
import androidx.compose.foundation.lazy.LazyListState
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.outlined.SortByAlpha
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.runtime.toMutableStateList
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import eu.kanade.presentation.category.components.CategoryFloatingActionButton
|
import eu.kanade.presentation.category.components.CategoryFloatingActionButton
|
||||||
import eu.kanade.presentation.category.components.CategoryListItem
|
import eu.kanade.presentation.category.components.CategoryListItem
|
||||||
import eu.kanade.presentation.components.AppBar
|
import eu.kanade.presentation.components.AppBar
|
||||||
|
import eu.kanade.presentation.components.AppBarActions
|
||||||
import eu.kanade.tachiyomi.ui.category.CategoryScreenState
|
import eu.kanade.tachiyomi.ui.category.CategoryScreenState
|
||||||
import kotlinx.collections.immutable.ImmutableList
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
import sh.calvin.reorderable.ReorderableItem
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import sh.calvin.reorderable.rememberReorderableLazyListState
|
|
||||||
import tachiyomi.domain.category.model.Category
|
import tachiyomi.domain.category.model.Category
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import tachiyomi.presentation.core.components.material.Scaffold
|
import tachiyomi.presentation.core.components.material.Scaffold
|
||||||
@ -34,9 +32,11 @@ import tachiyomi.presentation.core.util.plus
|
|||||||
fun CategoryScreen(
|
fun CategoryScreen(
|
||||||
state: CategoryScreenState.Success,
|
state: CategoryScreenState.Success,
|
||||||
onClickCreate: () -> Unit,
|
onClickCreate: () -> Unit,
|
||||||
|
onClickSortAlphabetically: () -> Unit,
|
||||||
onClickRename: (Category) -> Unit,
|
onClickRename: (Category) -> Unit,
|
||||||
onClickDelete: (Category) -> Unit,
|
onClickDelete: (Category) -> Unit,
|
||||||
onChangeOrder: (Category, Int) -> Unit,
|
onClickMoveUp: (Category) -> Unit,
|
||||||
|
onClickMoveDown: (Category) -> Unit,
|
||||||
navigateUp: () -> Unit,
|
navigateUp: () -> Unit,
|
||||||
) {
|
) {
|
||||||
val lazyListState = rememberLazyListState()
|
val lazyListState = rememberLazyListState()
|
||||||
@ -45,6 +45,17 @@ fun CategoryScreen(
|
|||||||
AppBar(
|
AppBar(
|
||||||
title = stringResource(MR.strings.action_edit_categories),
|
title = stringResource(MR.strings.action_edit_categories),
|
||||||
navigateUp = navigateUp,
|
navigateUp = navigateUp,
|
||||||
|
actions = {
|
||||||
|
AppBarActions(
|
||||||
|
persistentListOf(
|
||||||
|
AppBar.Action(
|
||||||
|
title = stringResource(MR.strings.action_sort),
|
||||||
|
icon = Icons.Outlined.SortByAlpha,
|
||||||
|
onClick = onClickSortAlphabetically,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
},
|
||||||
scrollBehavior = scrollBehavior,
|
scrollBehavior = scrollBehavior,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@ -66,10 +77,12 @@ fun CategoryScreen(
|
|||||||
CategoryContent(
|
CategoryContent(
|
||||||
categories = state.categories,
|
categories = state.categories,
|
||||||
lazyListState = lazyListState,
|
lazyListState = lazyListState,
|
||||||
paddingValues = paddingValues,
|
paddingValues = paddingValues + topSmallPaddingValues +
|
||||||
|
PaddingValues(horizontal = MaterialTheme.padding.medium),
|
||||||
onClickRename = onClickRename,
|
onClickRename = onClickRename,
|
||||||
onClickDelete = onClickDelete,
|
onClickDelete = onClickDelete,
|
||||||
onChangeOrder = onChangeOrder,
|
onMoveUp = onClickMoveUp,
|
||||||
|
onMoveDown = onClickMoveDown,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,44 +94,28 @@ private fun CategoryContent(
|
|||||||
paddingValues: PaddingValues,
|
paddingValues: PaddingValues,
|
||||||
onClickRename: (Category) -> Unit,
|
onClickRename: (Category) -> Unit,
|
||||||
onClickDelete: (Category) -> Unit,
|
onClickDelete: (Category) -> Unit,
|
||||||
onChangeOrder: (Category, Int) -> Unit,
|
onMoveUp: (Category) -> Unit,
|
||||||
|
onMoveDown: (Category) -> Unit,
|
||||||
) {
|
) {
|
||||||
val categoriesState = remember { categories.toMutableStateList() }
|
|
||||||
val reorderableState = rememberReorderableLazyListState(lazyListState, paddingValues) { from, to ->
|
|
||||||
val item = categoriesState.removeAt(from.index)
|
|
||||||
categoriesState.add(to.index, item)
|
|
||||||
onChangeOrder(item, to.index)
|
|
||||||
}
|
|
||||||
|
|
||||||
LaunchedEffect(categories) {
|
|
||||||
if (!reorderableState.isAnyItemDragging) {
|
|
||||||
categoriesState.clear()
|
|
||||||
categoriesState.addAll(categories)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier.fillMaxSize(),
|
|
||||||
state = lazyListState,
|
state = lazyListState,
|
||||||
contentPadding = paddingValues +
|
contentPadding = paddingValues,
|
||||||
topSmallPaddingValues +
|
|
||||||
PaddingValues(horizontal = MaterialTheme.padding.medium),
|
|
||||||
verticalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
|
verticalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
|
||||||
) {
|
) {
|
||||||
items(
|
itemsIndexed(
|
||||||
items = categoriesState,
|
items = categories,
|
||||||
key = { category -> category.key },
|
key = { _, category -> "category-${category.id}" },
|
||||||
) { category ->
|
) { index, category ->
|
||||||
ReorderableItem(reorderableState, category.key) {
|
|
||||||
CategoryListItem(
|
CategoryListItem(
|
||||||
modifier = Modifier.animateItem(),
|
modifier = Modifier.animateItem(),
|
||||||
category = category,
|
category = category,
|
||||||
|
canMoveUp = index != 0,
|
||||||
|
canMoveDown = index != categories.lastIndex,
|
||||||
|
onMoveUp = onMoveUp,
|
||||||
|
onMoveDown = onMoveDown,
|
||||||
onRename = { onClickRename(category) },
|
onRename = { onClickRename(category) },
|
||||||
onDelete = { onClickDelete(category) },
|
onDelete = { onClickDelete(category) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private val Category.key inline get() = "category-$id"
|
|
||||||
|
@ -219,6 +219,35 @@ fun CategoryDeleteDialog(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun CategorySortAlphabeticallyDialog(
|
||||||
|
onDismissRequest: () -> Unit,
|
||||||
|
onSort: () -> Unit,
|
||||||
|
) {
|
||||||
|
AlertDialog(
|
||||||
|
onDismissRequest = onDismissRequest,
|
||||||
|
confirmButton = {
|
||||||
|
TextButton(onClick = {
|
||||||
|
onSort()
|
||||||
|
onDismissRequest()
|
||||||
|
}) {
|
||||||
|
Text(text = stringResource(MR.strings.action_ok))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dismissButton = {
|
||||||
|
TextButton(onClick = onDismissRequest) {
|
||||||
|
Text(text = stringResource(MR.strings.action_cancel))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
title = {
|
||||||
|
Text(text = stringResource(MR.strings.action_sort_category))
|
||||||
|
},
|
||||||
|
text = {
|
||||||
|
Text(text = stringResource(MR.strings.sort_category_confirmation))
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ChangeCategoryDialog(
|
fun ChangeCategoryDialog(
|
||||||
initialSelection: ImmutableList<CheckboxState<Category>>,
|
initialSelection: ImmutableList<CheckboxState<Category>>,
|
||||||
|
@ -2,11 +2,14 @@ package eu.kanade.presentation.category.components
|
|||||||
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.automirrored.outlined.Label
|
||||||
|
import androidx.compose.material.icons.outlined.ArrowDropDown
|
||||||
|
import androidx.compose.material.icons.outlined.ArrowDropUp
|
||||||
import androidx.compose.material.icons.outlined.Delete
|
import androidx.compose.material.icons.outlined.Delete
|
||||||
import androidx.compose.material.icons.outlined.DragHandle
|
|
||||||
import androidx.compose.material.icons.outlined.Edit
|
import androidx.compose.material.icons.outlined.Edit
|
||||||
import androidx.compose.material3.ElevatedCard
|
import androidx.compose.material3.ElevatedCard
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
@ -16,42 +19,57 @@ import androidx.compose.material3.Text
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import sh.calvin.reorderable.ReorderableCollectionItemScope
|
|
||||||
import tachiyomi.domain.category.model.Category
|
import tachiyomi.domain.category.model.Category
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import tachiyomi.presentation.core.components.material.padding
|
import tachiyomi.presentation.core.components.material.padding
|
||||||
import tachiyomi.presentation.core.i18n.stringResource
|
import tachiyomi.presentation.core.i18n.stringResource
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ReorderableCollectionItemScope.CategoryListItem(
|
fun CategoryListItem(
|
||||||
category: Category,
|
category: Category,
|
||||||
|
canMoveUp: Boolean,
|
||||||
|
canMoveDown: Boolean,
|
||||||
|
onMoveUp: (Category) -> Unit,
|
||||||
|
onMoveDown: (Category) -> Unit,
|
||||||
onRename: () -> Unit,
|
onRename: () -> Unit,
|
||||||
onDelete: () -> Unit,
|
onDelete: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
ElevatedCard(modifier = modifier) {
|
ElevatedCard(
|
||||||
|
modifier = modifier,
|
||||||
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.clickable(onClick = onRename)
|
.clickable { onRename() }
|
||||||
.padding(vertical = MaterialTheme.padding.small)
|
|
||||||
.padding(
|
.padding(
|
||||||
start = MaterialTheme.padding.small,
|
start = MaterialTheme.padding.medium,
|
||||||
|
top = MaterialTheme.padding.medium,
|
||||||
end = MaterialTheme.padding.medium,
|
end = MaterialTheme.padding.medium,
|
||||||
),
|
),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(imageVector = Icons.AutoMirrored.Outlined.Label, contentDescription = null)
|
||||||
imageVector = Icons.Outlined.DragHandle,
|
|
||||||
contentDescription = null,
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(MaterialTheme.padding.medium)
|
|
||||||
.draggableHandle(),
|
|
||||||
)
|
|
||||||
Text(
|
Text(
|
||||||
text = category.name,
|
text = category.name,
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier
|
||||||
|
.padding(start = MaterialTheme.padding.medium),
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
Row {
|
||||||
|
IconButton(
|
||||||
|
onClick = { onMoveUp(category) },
|
||||||
|
enabled = canMoveUp,
|
||||||
|
) {
|
||||||
|
Icon(imageVector = Icons.Outlined.ArrowDropUp, contentDescription = null)
|
||||||
|
}
|
||||||
|
IconButton(
|
||||||
|
onClick = { onMoveDown(category) },
|
||||||
|
enabled = canMoveDown,
|
||||||
|
) {
|
||||||
|
Icon(imageVector = Icons.Outlined.ArrowDropDown, contentDescription = null)
|
||||||
|
}
|
||||||
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
IconButton(onClick = onRename) {
|
IconButton(onClick = onRename) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Outlined.Edit,
|
imageVector = Icons.Outlined.Edit,
|
||||||
@ -59,10 +77,7 @@ fun ReorderableCollectionItemScope.CategoryListItem(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
IconButton(onClick = onDelete) {
|
IconButton(onClick = onDelete) {
|
||||||
Icon(
|
Icon(imageVector = Icons.Outlined.Delete, contentDescription = stringResource(MR.strings.action_delete))
|
||||||
imageVector = Icons.Outlined.Delete,
|
|
||||||
contentDescription = stringResource(MR.strings.action_delete),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package eu.kanade.presentation.components
|
package eu.kanade.presentation.components
|
||||||
|
|
||||||
import androidx.compose.animation.SizeTransform
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.compose.animation.core.tween
|
import androidx.compose.animation.core.tween
|
||||||
import androidx.compose.animation.fadeIn
|
import androidx.compose.animation.fadeIn
|
||||||
import androidx.compose.animation.fadeOut
|
import androidx.compose.animation.fadeOut
|
||||||
|
import androidx.compose.animation.togetherWith
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.window.Dialog
|
import androidx.compose.ui.window.Dialog
|
||||||
@ -27,14 +28,20 @@ fun NavigatorAdaptiveSheet(
|
|||||||
screen = screen,
|
screen = screen,
|
||||||
content = { sheetNavigator ->
|
content = { sheetNavigator ->
|
||||||
AdaptiveSheet(
|
AdaptiveSheet(
|
||||||
onDismissRequest = onDismissRequest,
|
|
||||||
enableSwipeDismiss = enableSwipeDismiss(sheetNavigator),
|
enableSwipeDismiss = enableSwipeDismiss(sheetNavigator),
|
||||||
|
onDismissRequest = onDismissRequest,
|
||||||
) {
|
) {
|
||||||
ScreenTransition(
|
ScreenTransition(
|
||||||
navigator = sheetNavigator,
|
navigator = sheetNavigator,
|
||||||
enterTransition = { fadeIn(animationSpec = tween(220, delayMillis = 90)) },
|
transition = {
|
||||||
exitTransition = { fadeOut(animationSpec = tween(90)) },
|
fadeIn(animationSpec = tween(220, delayMillis = 90)) togetherWith
|
||||||
sizeTransform = { SizeTransform() },
|
fadeOut(animationSpec = tween(90))
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
BackHandler(
|
||||||
|
enabled = sheetNavigator.size > 1,
|
||||||
|
onBack = sheetNavigator::pop,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,10 +79,10 @@ fun AdaptiveSheet(
|
|||||||
properties = dialogProperties,
|
properties = dialogProperties,
|
||||||
) {
|
) {
|
||||||
AdaptiveSheetImpl(
|
AdaptiveSheetImpl(
|
||||||
|
modifier = modifier,
|
||||||
isTabletUi = isTabletUi,
|
isTabletUi = isTabletUi,
|
||||||
enableSwipeDismiss = enableSwipeDismiss,
|
enableSwipeDismiss = enableSwipeDismiss,
|
||||||
onDismissRequest = onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
modifier = modifier,
|
|
||||||
) {
|
) {
|
||||||
content()
|
content()
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ import androidx.compose.runtime.mutableStateOf
|
|||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.focus.FocusDirection
|
|
||||||
import androidx.compose.ui.focus.FocusRequester
|
import androidx.compose.ui.focus.FocusRequester
|
||||||
import androidx.compose.ui.focus.focusRequester
|
import androidx.compose.ui.focus.focusRequester
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
@ -202,7 +201,6 @@ fun AppBarActions(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
state = rememberTooltipState(),
|
state = rememberTooltipState(),
|
||||||
focusable = false,
|
|
||||||
) {
|
) {
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = it.onClick,
|
onClick = it.onClick,
|
||||||
@ -227,7 +225,6 @@ fun AppBarActions(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
state = rememberTooltipState(),
|
state = rememberTooltipState(),
|
||||||
focusable = false,
|
|
||||||
) {
|
) {
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = { showMenu = !showMenu },
|
onClick = { showMenu = !showMenu },
|
||||||
@ -292,7 +289,6 @@ fun SearchToolbar(
|
|||||||
onSearch(searchQuery)
|
onSearch(searchQuery)
|
||||||
focusManager.clearFocus()
|
focusManager.clearFocus()
|
||||||
keyboardController?.hide()
|
keyboardController?.hide()
|
||||||
focusManager.moveFocus(FocusDirection.Next)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicTextField(
|
BasicTextField(
|
||||||
@ -356,7 +352,6 @@ fun SearchToolbar(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
state = rememberTooltipState(),
|
state = rememberTooltipState(),
|
||||||
focusable = false,
|
|
||||||
) {
|
) {
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = onClick,
|
onClick = onClick,
|
||||||
@ -376,7 +371,6 @@ fun SearchToolbar(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
state = rememberTooltipState(),
|
state = rememberTooltipState(),
|
||||||
focusable = false,
|
|
||||||
) {
|
) {
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
|
@ -39,7 +39,6 @@ fun HistoryScreen(
|
|||||||
onSearchQueryChange: (String?) -> Unit,
|
onSearchQueryChange: (String?) -> Unit,
|
||||||
onClickCover: (mangaId: Long) -> Unit,
|
onClickCover: (mangaId: Long) -> Unit,
|
||||||
onClickResume: (mangaId: Long, chapterId: Long) -> Unit,
|
onClickResume: (mangaId: Long, chapterId: Long) -> Unit,
|
||||||
onClickFavorite: (mangaId: Long) -> Unit,
|
|
||||||
onDialogChange: (HistoryScreenModel.Dialog?) -> Unit,
|
onDialogChange: (HistoryScreenModel.Dialog?) -> Unit,
|
||||||
) {
|
) {
|
||||||
Scaffold(
|
Scaffold(
|
||||||
@ -86,7 +85,6 @@ fun HistoryScreen(
|
|||||||
onClickCover = { history -> onClickCover(history.mangaId) },
|
onClickCover = { history -> onClickCover(history.mangaId) },
|
||||||
onClickResume = { history -> onClickResume(history.mangaId, history.chapterId) },
|
onClickResume = { history -> onClickResume(history.mangaId, history.chapterId) },
|
||||||
onClickDelete = { item -> onDialogChange(HistoryScreenModel.Dialog.Delete(item)) },
|
onClickDelete = { item -> onDialogChange(HistoryScreenModel.Dialog.Delete(item)) },
|
||||||
onClickFavorite = { history -> onClickFavorite(history.mangaId) },
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,7 +98,6 @@ private fun HistoryScreenContent(
|
|||||||
onClickCover: (HistoryWithRelations) -> Unit,
|
onClickCover: (HistoryWithRelations) -> Unit,
|
||||||
onClickResume: (HistoryWithRelations) -> Unit,
|
onClickResume: (HistoryWithRelations) -> Unit,
|
||||||
onClickDelete: (HistoryWithRelations) -> Unit,
|
onClickDelete: (HistoryWithRelations) -> Unit,
|
||||||
onClickFavorite: (HistoryWithRelations) -> Unit,
|
|
||||||
) {
|
) {
|
||||||
FastScrollLazyColumn(
|
FastScrollLazyColumn(
|
||||||
contentPadding = contentPadding,
|
contentPadding = contentPadding,
|
||||||
@ -130,7 +127,6 @@ private fun HistoryScreenContent(
|
|||||||
onClickCover = { onClickCover(value) },
|
onClickCover = { onClickCover(value) },
|
||||||
onClickResume = { onClickResume(value) },
|
onClickResume = { onClickResume(value) },
|
||||||
onClickDelete = { onClickDelete(value) },
|
onClickDelete = { onClickDelete(value) },
|
||||||
onClickFavorite = { onClickFavorite(value) },
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,7 +153,6 @@ internal fun HistoryScreenPreviews(
|
|||||||
onClickCover = {},
|
onClickCover = {},
|
||||||
onClickResume = { _, _ -> run {} },
|
onClickResume = { _, _ -> run {} },
|
||||||
onDialogChange = {},
|
onDialogChange = {},
|
||||||
onClickFavorite = {},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import androidx.compose.foundation.layout.height
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.Delete
|
import androidx.compose.material.icons.outlined.Delete
|
||||||
import androidx.compose.material.icons.outlined.FavoriteBorder
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
@ -40,7 +39,6 @@ fun HistoryItem(
|
|||||||
onClickCover: () -> Unit,
|
onClickCover: () -> Unit,
|
||||||
onClickResume: () -> Unit,
|
onClickResume: () -> Unit,
|
||||||
onClickDelete: () -> Unit,
|
onClickDelete: () -> Unit,
|
||||||
onClickFavorite: () -> Unit,
|
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
@ -84,16 +82,6 @@ fun HistoryItem(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!history.coverData.isMangaFavorite) {
|
|
||||||
IconButton(onClick = onClickFavorite) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Outlined.FavoriteBorder,
|
|
||||||
contentDescription = stringResource(MR.strings.add_to_library),
|
|
||||||
tint = MaterialTheme.colorScheme.onSurface,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IconButton(onClick = onClickDelete) {
|
IconButton(onClick = onClickDelete) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Outlined.Delete,
|
imageVector = Icons.Outlined.Delete,
|
||||||
@ -117,7 +105,6 @@ private fun HistoryItemPreviews(
|
|||||||
onClickCover = {},
|
onClickCover = {},
|
||||||
onClickResume = {},
|
onClickResume = {},
|
||||||
onClickDelete = {},
|
onClickDelete = {},
|
||||||
onClickFavorite = {},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import androidx.compose.foundation.verticalScroll
|
|||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Refresh
|
import androidx.compose.material.icons.filled.Refresh
|
||||||
import androidx.compose.material3.FilterChip
|
import androidx.compose.material3.FilterChip
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
@ -310,16 +309,15 @@ private fun ColumnScope.DisplayPage(
|
|||||||
|
|
||||||
val columns by columnPreference.collectAsState()
|
val columns by columnPreference.collectAsState()
|
||||||
SliderItem(
|
SliderItem(
|
||||||
value = columns,
|
|
||||||
valueRange = 0..10,
|
|
||||||
label = stringResource(MR.strings.pref_library_columns),
|
label = stringResource(MR.strings.pref_library_columns),
|
||||||
|
max = 10,
|
||||||
|
value = columns,
|
||||||
valueText = if (columns > 0) {
|
valueText = if (columns > 0) {
|
||||||
columns.toString()
|
stringResource(MR.strings.pref_library_columns_per_row, columns)
|
||||||
} else {
|
} else {
|
||||||
stringResource(MR.strings.label_auto)
|
stringResource(MR.strings.label_default)
|
||||||
},
|
},
|
||||||
onChange = columnPreference::set,
|
onChange = columnPreference::set,
|
||||||
pillColor = MaterialTheme.colorScheme.surfaceContainerHighest,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,10 +326,6 @@ private fun ColumnScope.DisplayPage(
|
|||||||
label = stringResource(MR.strings.action_display_download_badge),
|
label = stringResource(MR.strings.action_display_download_badge),
|
||||||
pref = screenModel.libraryPreferences.downloadBadge(),
|
pref = screenModel.libraryPreferences.downloadBadge(),
|
||||||
)
|
)
|
||||||
CheckboxItem(
|
|
||||||
label = stringResource(MR.strings.action_display_unread_badge),
|
|
||||||
pref = screenModel.libraryPreferences.unreadBadge(),
|
|
||||||
)
|
|
||||||
CheckboxItem(
|
CheckboxItem(
|
||||||
label = stringResource(MR.strings.action_display_local_badge),
|
label = stringResource(MR.strings.action_display_local_badge),
|
||||||
pref = screenModel.libraryPreferences.localBadge(),
|
pref = screenModel.libraryPreferences.localBadge(),
|
||||||
|
@ -21,14 +21,13 @@ import androidx.compose.material3.TextButton
|
|||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
import androidx.compose.runtime.saveable.rememberSaveable
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.kanade.domain.base.BasePreferences
|
|
||||||
import eu.kanade.domain.manga.model.downloadedFilter
|
import eu.kanade.domain.manga.model.downloadedFilter
|
||||||
|
import eu.kanade.domain.manga.model.forceDownloaded
|
||||||
import eu.kanade.presentation.components.TabbedDialog
|
import eu.kanade.presentation.components.TabbedDialog
|
||||||
import eu.kanade.presentation.components.TabbedDialogPaddings
|
import eu.kanade.presentation.components.TabbedDialogPaddings
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
@ -41,8 +40,6 @@ import tachiyomi.presentation.core.components.SortItem
|
|||||||
import tachiyomi.presentation.core.components.TriStateItem
|
import tachiyomi.presentation.core.components.TriStateItem
|
||||||
import tachiyomi.presentation.core.i18n.stringResource
|
import tachiyomi.presentation.core.i18n.stringResource
|
||||||
import tachiyomi.presentation.core.theme.active
|
import tachiyomi.presentation.core.theme.active
|
||||||
import uy.kohesive.injekt.Injekt
|
|
||||||
import uy.kohesive.injekt.api.get
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ChapterSettingsDialog(
|
fun ChapterSettingsDialog(
|
||||||
@ -66,8 +63,6 @@ fun ChapterSettingsDialog(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val downloadedOnly = remember { Injekt.get<BasePreferences>().downloadedOnly().get() }
|
|
||||||
|
|
||||||
TabbedDialog(
|
TabbedDialog(
|
||||||
onDismissRequest = onDismissRequest,
|
onDismissRequest = onDismissRequest,
|
||||||
tabTitles = persistentListOf(
|
tabTitles = persistentListOf(
|
||||||
@ -102,7 +97,7 @@ fun ChapterSettingsDialog(
|
|||||||
FilterPage(
|
FilterPage(
|
||||||
downloadFilter = manga?.downloadedFilter ?: TriState.DISABLED,
|
downloadFilter = manga?.downloadedFilter ?: TriState.DISABLED,
|
||||||
onDownloadFilterChanged = onDownloadFilterChanged
|
onDownloadFilterChanged = onDownloadFilterChanged
|
||||||
.takeUnless { downloadedOnly },
|
.takeUnless { manga?.forceDownloaded() == true },
|
||||||
unreadFilter = manga?.unreadFilter ?: TriState.DISABLED,
|
unreadFilter = manga?.unreadFilter ?: TriState.DISABLED,
|
||||||
onUnreadFilterChanged = onUnreadFilterChanged,
|
onUnreadFilterChanged = onUnreadFilterChanged,
|
||||||
bookmarkedFilter = manga?.bookmarkedFilter ?: TriState.DISABLED,
|
bookmarkedFilter = manga?.bookmarkedFilter ?: TriState.DISABLED,
|
||||||
|
@ -1,95 +1,44 @@
|
|||||||
package eu.kanade.presentation.manga
|
package eu.kanade.presentation.manga
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.combinedClickable
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Box
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
import androidx.compose.foundation.layout.PaddingValues
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.heightIn
|
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.sizeIn
|
||||||
import androidx.compose.foundation.layout.width
|
|
||||||
import androidx.compose.foundation.lazy.LazyRow
|
|
||||||
import androidx.compose.foundation.lazy.items
|
|
||||||
import androidx.compose.foundation.rememberScrollState
|
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
|
||||||
import androidx.compose.foundation.verticalScroll
|
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.Brush
|
|
||||||
import androidx.compose.material.icons.filled.PersonOutline
|
|
||||||
import androidx.compose.material.icons.filled.Warning
|
|
||||||
import androidx.compose.material.icons.outlined.Add
|
import androidx.compose.material.icons.outlined.Add
|
||||||
import androidx.compose.material.icons.outlined.AttachMoney
|
import androidx.compose.material.icons.outlined.Book
|
||||||
import androidx.compose.material.icons.outlined.Block
|
import androidx.compose.material.icons.outlined.SwapVert
|
||||||
import androidx.compose.material.icons.outlined.Close
|
|
||||||
import androidx.compose.material.icons.outlined.Done
|
|
||||||
import androidx.compose.material.icons.outlined.DoneAll
|
|
||||||
import androidx.compose.material.icons.outlined.Pause
|
|
||||||
import androidx.compose.material.icons.outlined.Schedule
|
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.material3.Icon
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.OutlinedButton
|
import androidx.compose.material3.OutlinedButton
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.Typography
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
|
||||||
import androidx.compose.ui.text.TextMeasurer
|
|
||||||
import androidx.compose.ui.text.TextStyle
|
|
||||||
import androidx.compose.ui.text.rememberTextMeasurer
|
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
|
||||||
import androidx.compose.ui.unit.Constraints
|
|
||||||
import androidx.compose.ui.unit.Density
|
|
||||||
import androidx.compose.ui.unit.Dp
|
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.util.fastMaxOfOrNull
|
import androidx.compose.ui.unit.sp
|
||||||
import coil3.request.ImageRequest
|
|
||||||
import coil3.request.crossfade
|
|
||||||
import eu.kanade.presentation.components.AdaptiveSheet
|
import eu.kanade.presentation.components.AdaptiveSheet
|
||||||
import eu.kanade.presentation.components.TabbedDialogPaddings
|
import eu.kanade.presentation.components.TabbedDialogPaddings
|
||||||
import eu.kanade.presentation.manga.components.MangaCover
|
|
||||||
import eu.kanade.presentation.more.settings.LocalPreferenceMinHeight
|
import eu.kanade.presentation.more.settings.LocalPreferenceMinHeight
|
||||||
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
|
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
|
||||||
import eu.kanade.tachiyomi.source.Source
|
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
|
||||||
import tachiyomi.domain.manga.model.Manga
|
|
||||||
import tachiyomi.domain.manga.model.MangaWithChapterCount
|
|
||||||
import tachiyomi.domain.source.model.StubSource
|
|
||||||
import tachiyomi.domain.source.service.SourceManager
|
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import tachiyomi.presentation.core.components.Badge
|
|
||||||
import tachiyomi.presentation.core.components.BadgeGroup
|
|
||||||
import tachiyomi.presentation.core.components.material.padding
|
|
||||||
import tachiyomi.presentation.core.i18n.pluralStringResource
|
|
||||||
import tachiyomi.presentation.core.i18n.stringResource
|
import tachiyomi.presentation.core.i18n.stringResource
|
||||||
import tachiyomi.presentation.core.util.secondaryItemAlpha
|
|
||||||
import uy.kohesive.injekt.Injekt
|
|
||||||
import uy.kohesive.injekt.api.get
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DuplicateMangaDialog(
|
fun DuplicateMangaDialog(
|
||||||
duplicates: List<MangaWithChapterCount>,
|
|
||||||
onDismissRequest: () -> Unit,
|
onDismissRequest: () -> Unit,
|
||||||
onConfirm: () -> Unit,
|
onConfirm: () -> Unit,
|
||||||
onOpenManga: (manga: Manga) -> Unit,
|
onOpenManga: () -> Unit,
|
||||||
onMigrate: (manga: Manga) -> Unit,
|
onMigrate: () -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
val sourceManager = remember { Injekt.get<SourceManager>() }
|
|
||||||
val minHeight = LocalPreferenceMinHeight.current
|
val minHeight = LocalPreferenceMinHeight.current
|
||||||
val horizontalPadding = PaddingValues(horizontal = TabbedDialogPaddings.Horizontal)
|
|
||||||
val horizontalPaddingModifier = Modifier.padding(horizontalPadding)
|
|
||||||
|
|
||||||
AdaptiveSheet(
|
AdaptiveSheet(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
@ -97,45 +46,45 @@ fun DuplicateMangaDialog(
|
|||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(vertical = TabbedDialogPaddings.Vertical)
|
.padding(
|
||||||
.verticalScroll(rememberScrollState())
|
vertical = TabbedDialogPaddings.Vertical,
|
||||||
|
horizontal = TabbedDialogPaddings.Horizontal,
|
||||||
|
)
|
||||||
.fillMaxWidth(),
|
.fillMaxWidth(),
|
||||||
verticalArrangement = Arrangement.spacedBy(MaterialTheme.padding.medium),
|
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(MR.strings.possible_duplicates_title),
|
modifier = Modifier.padding(TitlePadding),
|
||||||
|
text = stringResource(MR.strings.are_you_sure),
|
||||||
style = MaterialTheme.typography.headlineMedium,
|
style = MaterialTheme.typography.headlineMedium,
|
||||||
modifier = Modifier
|
|
||||||
.then(horizontalPaddingModifier)
|
|
||||||
.padding(top = MaterialTheme.padding.small),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(MR.strings.possible_duplicates_summary),
|
text = stringResource(MR.strings.confirm_add_duplicate_manga),
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
modifier = Modifier.then(horizontalPaddingModifier),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
LazyRow(
|
Spacer(Modifier.height(PaddingSize))
|
||||||
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
|
|
||||||
modifier = Modifier.height(getMaximumMangaCardHeight(duplicates)),
|
TextPreferenceWidget(
|
||||||
contentPadding = horizontalPadding,
|
title = stringResource(MR.strings.action_show_manga),
|
||||||
) {
|
icon = Icons.Outlined.Book,
|
||||||
items(
|
onPreferenceClick = {
|
||||||
items = duplicates,
|
onDismissRequest()
|
||||||
key = { it.manga.id },
|
onOpenManga()
|
||||||
) {
|
},
|
||||||
DuplicateMangaListItem(
|
)
|
||||||
duplicate = it,
|
|
||||||
getSource = { sourceManager.getOrStub(it.manga.source) },
|
HorizontalDivider()
|
||||||
onMigrate = { onMigrate(it.manga) },
|
|
||||||
onDismissRequest = onDismissRequest,
|
TextPreferenceWidget(
|
||||||
onOpenManga = { onOpenManga(it.manga) },
|
title = stringResource(MR.strings.action_migrate_duplicate),
|
||||||
)
|
icon = Icons.Outlined.SwapVert,
|
||||||
}
|
onPreferenceClick = {
|
||||||
}
|
onDismissRequest()
|
||||||
|
onMigrate()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
Column(modifier = horizontalPaddingModifier) {
|
|
||||||
HorizontalDivider()
|
HorizontalDivider()
|
||||||
|
|
||||||
TextPreferenceWidget(
|
TextPreferenceWidget(
|
||||||
@ -145,262 +94,33 @@ fun DuplicateMangaDialog(
|
|||||||
onDismissRequest()
|
onDismissRequest()
|
||||||
onConfirm()
|
onConfirm()
|
||||||
},
|
},
|
||||||
modifier = Modifier.clip(CircleShape),
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
OutlinedButton(
|
|
||||||
onClick = onDismissRequest,
|
|
||||||
modifier = Modifier
|
|
||||||
.then(horizontalPaddingModifier)
|
|
||||||
.padding(bottom = MaterialTheme.padding.medium)
|
|
||||||
.heightIn(min = minHeight)
|
|
||||||
.fillMaxWidth(),
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
modifier = Modifier.padding(vertical = MaterialTheme.padding.extraSmall),
|
|
||||||
text = stringResource(MR.strings.action_cancel),
|
|
||||||
color = MaterialTheme.colorScheme.primary,
|
|
||||||
style = MaterialTheme.typography.bodyLarge,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun DuplicateMangaListItem(
|
|
||||||
duplicate: MangaWithChapterCount,
|
|
||||||
getSource: () -> Source,
|
|
||||||
onDismissRequest: () -> Unit,
|
|
||||||
onOpenManga: () -> Unit,
|
|
||||||
onMigrate: () -> Unit,
|
|
||||||
) {
|
|
||||||
val source = getSource()
|
|
||||||
val manga = duplicate.manga
|
|
||||||
Column(
|
|
||||||
modifier = Modifier
|
|
||||||
.width(MangaCardWidth)
|
|
||||||
.clip(MaterialTheme.shapes.medium)
|
|
||||||
.background(MaterialTheme.colorScheme.surface)
|
|
||||||
.combinedClickable(
|
|
||||||
onLongClick = { onOpenManga() },
|
|
||||||
onClick = {
|
|
||||||
onDismissRequest()
|
|
||||||
onMigrate()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.padding(MaterialTheme.padding.small),
|
|
||||||
) {
|
|
||||||
Box {
|
|
||||||
MangaCover.Book(
|
|
||||||
data = ImageRequest.Builder(LocalContext.current)
|
|
||||||
.data(manga)
|
|
||||||
.crossfade(true)
|
|
||||||
.build(),
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
)
|
|
||||||
BadgeGroup(
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(4.dp)
|
|
||||||
.align(Alignment.TopStart),
|
|
||||||
) {
|
|
||||||
Badge(
|
|
||||||
color = MaterialTheme.colorScheme.secondary,
|
|
||||||
textColor = MaterialTheme.colorScheme.onSecondary,
|
|
||||||
text = pluralStringResource(
|
|
||||||
MR.plurals.manga_num_chapters,
|
|
||||||
duplicate.chapterCount.toInt(),
|
|
||||||
duplicate.chapterCount,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(MaterialTheme.padding.extraSmall))
|
|
||||||
|
|
||||||
Text(
|
|
||||||
text = manga.title,
|
|
||||||
style = MaterialTheme.typography.titleSmall,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
maxLines = 2,
|
|
||||||
)
|
|
||||||
|
|
||||||
if (!manga.author.isNullOrBlank()) {
|
|
||||||
MangaDetailRow(
|
|
||||||
text = manga.author!!,
|
|
||||||
iconImageVector = Icons.Filled.PersonOutline,
|
|
||||||
maxLines = 2,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!manga.artist.isNullOrBlank() && manga.author != manga.artist) {
|
|
||||||
MangaDetailRow(
|
|
||||||
text = manga.artist!!,
|
|
||||||
iconImageVector = Icons.Filled.Brush,
|
|
||||||
maxLines = 2,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
MangaDetailRow(
|
|
||||||
text = when (manga.status) {
|
|
||||||
SManga.ONGOING.toLong() -> stringResource(MR.strings.ongoing)
|
|
||||||
SManga.COMPLETED.toLong() -> stringResource(MR.strings.completed)
|
|
||||||
SManga.LICENSED.toLong() -> stringResource(MR.strings.licensed)
|
|
||||||
SManga.PUBLISHING_FINISHED.toLong() -> stringResource(MR.strings.publishing_finished)
|
|
||||||
SManga.CANCELLED.toLong() -> stringResource(MR.strings.cancelled)
|
|
||||||
SManga.ON_HIATUS.toLong() -> stringResource(MR.strings.on_hiatus)
|
|
||||||
else -> stringResource(MR.strings.unknown)
|
|
||||||
},
|
|
||||||
iconImageVector = when (manga.status) {
|
|
||||||
SManga.ONGOING.toLong() -> Icons.Outlined.Schedule
|
|
||||||
SManga.COMPLETED.toLong() -> Icons.Outlined.DoneAll
|
|
||||||
SManga.LICENSED.toLong() -> Icons.Outlined.AttachMoney
|
|
||||||
SManga.PUBLISHING_FINISHED.toLong() -> Icons.Outlined.Done
|
|
||||||
SManga.CANCELLED.toLong() -> Icons.Outlined.Close
|
|
||||||
SManga.ON_HIATUS.toLong() -> Icons.Outlined.Pause
|
|
||||||
else -> Icons.Outlined.Block
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.weight(1f))
|
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier
|
||||||
|
.sizeIn(minHeight = minHeight)
|
||||||
|
.clickable { onDismissRequest.invoke() }
|
||||||
|
.padding(ButtonPadding)
|
||||||
|
.fillMaxWidth(),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.Center,
|
horizontalArrangement = Arrangement.Center,
|
||||||
) {
|
) {
|
||||||
if (source is StubSource) {
|
OutlinedButton(onClick = onDismissRequest, modifier = Modifier.fillMaxWidth()) {
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Filled.Warning,
|
|
||||||
contentDescription = null,
|
|
||||||
modifier = Modifier.size(16.dp),
|
|
||||||
tint = MaterialTheme.colorScheme.error,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Text(
|
Text(
|
||||||
text = source.name,
|
|
||||||
style = MaterialTheme.typography.labelSmall,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
maxLines = 1,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun MangaDetailRow(
|
|
||||||
text: String,
|
|
||||||
iconImageVector: ImageVector,
|
|
||||||
maxLines: Int = 1,
|
|
||||||
) {
|
|
||||||
Row(
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.secondaryItemAlpha()
|
.padding(vertical = 8.dp),
|
||||||
.padding(top = MaterialTheme.padding.extraSmall),
|
text = stringResource(MR.strings.action_cancel),
|
||||||
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.extraSmall),
|
color = MaterialTheme.colorScheme.primary,
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
style = MaterialTheme.typography.titleLarge,
|
||||||
) {
|
fontSize = 16.sp,
|
||||||
Icon(
|
|
||||||
imageVector = iconImageVector,
|
|
||||||
contentDescription = null,
|
|
||||||
modifier = Modifier.size(MangaDetailsIconWidth),
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
text = text,
|
|
||||||
style = MaterialTheme.typography.bodySmall,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
maxLines = maxLines,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun getMaximumMangaCardHeight(duplicates: List<MangaWithChapterCount>): Dp {
|
|
||||||
val density = LocalDensity.current
|
|
||||||
val typography = MaterialTheme.typography
|
|
||||||
val textMeasurer = rememberTextMeasurer()
|
|
||||||
|
|
||||||
val smallPadding = with(density) { MaterialTheme.padding.small.roundToPx() }
|
|
||||||
val extraSmallPadding = with(density) { MaterialTheme.padding.extraSmall.roundToPx() }
|
|
||||||
|
|
||||||
val width = with(density) { MangaCardWidth.roundToPx() - (2 * smallPadding) }
|
|
||||||
val iconWidth = with(density) { MangaDetailsIconWidth.roundToPx() }
|
|
||||||
|
|
||||||
val coverHeight = width / MangaCover.Book.ratio
|
|
||||||
val constraints = Constraints(maxWidth = width)
|
|
||||||
val detailsConstraints = Constraints(maxWidth = width - iconWidth - extraSmallPadding)
|
|
||||||
|
|
||||||
return remember(
|
|
||||||
duplicates,
|
|
||||||
density,
|
|
||||||
typography,
|
|
||||||
textMeasurer,
|
|
||||||
smallPadding,
|
|
||||||
extraSmallPadding,
|
|
||||||
coverHeight,
|
|
||||||
constraints,
|
|
||||||
detailsConstraints,
|
|
||||||
) {
|
|
||||||
duplicates.fastMaxOfOrNull {
|
|
||||||
calculateMangaCardHeight(
|
|
||||||
manga = it.manga,
|
|
||||||
density = density,
|
|
||||||
typography = typography,
|
|
||||||
textMeasurer = textMeasurer,
|
|
||||||
smallPadding = smallPadding,
|
|
||||||
extraSmallPadding = extraSmallPadding,
|
|
||||||
coverHeight = coverHeight,
|
|
||||||
constraints = constraints,
|
|
||||||
detailsConstraints = detailsConstraints,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
?: 0.dp
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun calculateMangaCardHeight(
|
private val PaddingSize = 16.dp
|
||||||
manga: Manga,
|
|
||||||
density: Density,
|
|
||||||
typography: Typography,
|
|
||||||
textMeasurer: TextMeasurer,
|
|
||||||
smallPadding: Int,
|
|
||||||
extraSmallPadding: Int,
|
|
||||||
coverHeight: Float,
|
|
||||||
constraints: Constraints,
|
|
||||||
detailsConstraints: Constraints,
|
|
||||||
): Dp {
|
|
||||||
val titleHeight = textMeasurer.measureHeight(manga.title, typography.titleSmall, 2, constraints)
|
|
||||||
val authorHeight = if (!manga.author.isNullOrBlank()) {
|
|
||||||
textMeasurer.measureHeight(manga.author!!, typography.bodySmall, 2, detailsConstraints)
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
val artistHeight = if (!manga.artist.isNullOrBlank() && manga.author != manga.artist) {
|
|
||||||
textMeasurer.measureHeight(manga.artist!!, typography.bodySmall, 2, detailsConstraints)
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
val statusHeight = textMeasurer.measureHeight("", typography.bodySmall, 2, detailsConstraints)
|
|
||||||
val sourceHeight = textMeasurer.measureHeight("", typography.labelSmall, 1, constraints)
|
|
||||||
|
|
||||||
val totalHeight = coverHeight + titleHeight + authorHeight + artistHeight + statusHeight + sourceHeight
|
private val ButtonPadding = PaddingValues(top = 16.dp, bottom = 16.dp)
|
||||||
return with(density) { ((2 * smallPadding) + totalHeight + (5 * extraSmallPadding)).toDp() }
|
private val TitlePadding = PaddingValues(bottom = 16.dp, top = 8.dp)
|
||||||
}
|
|
||||||
|
|
||||||
private fun TextMeasurer.measureHeight(
|
|
||||||
text: String,
|
|
||||||
style: TextStyle,
|
|
||||||
maxLines: Int,
|
|
||||||
constraints: Constraints,
|
|
||||||
): Int = measure(
|
|
||||||
text = text,
|
|
||||||
style = style,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
maxLines = maxLines,
|
|
||||||
constraints = constraints,
|
|
||||||
)
|
|
||||||
.size
|
|
||||||
.height
|
|
||||||
|
|
||||||
private val MangaCardWidth = 150.dp
|
|
||||||
private val MangaDetailsIconWidth = 16.dp
|
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
package eu.kanade.presentation.manga
|
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.consumeWindowInsets
|
|
||||||
import androidx.compose.foundation.layout.imePadding
|
|
||||||
import androidx.compose.foundation.layout.padding
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import eu.kanade.presentation.components.AppBar
|
|
||||||
import eu.kanade.presentation.components.AppBarTitle
|
|
||||||
import eu.kanade.presentation.manga.components.MangaNotesTextArea
|
|
||||||
import eu.kanade.tachiyomi.ui.manga.notes.MangaNotesScreen
|
|
||||||
import tachiyomi.i18n.MR
|
|
||||||
import tachiyomi.presentation.core.components.material.Scaffold
|
|
||||||
import tachiyomi.presentation.core.i18n.stringResource
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun MangaNotesScreen(
|
|
||||||
state: MangaNotesScreen.State,
|
|
||||||
navigateUp: () -> Unit,
|
|
||||||
onUpdate: (String) -> Unit,
|
|
||||||
) {
|
|
||||||
Scaffold(
|
|
||||||
topBar = { topBarScrollBehavior ->
|
|
||||||
AppBar(
|
|
||||||
titleContent = {
|
|
||||||
AppBarTitle(
|
|
||||||
title = stringResource(MR.strings.action_edit_notes),
|
|
||||||
subtitle = state.manga.title,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
navigateUp = navigateUp,
|
|
||||||
scrollBehavior = topBarScrollBehavior,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
) { contentPadding ->
|
|
||||||
MangaNotesTextArea(
|
|
||||||
state = state,
|
|
||||||
onUpdate = onUpdate,
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(contentPadding)
|
|
||||||
.consumeWindowInsets(contentPadding)
|
|
||||||
.imePadding(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
@ -117,7 +117,7 @@ fun MangaScreen(
|
|||||||
isTabletUi: Boolean,
|
isTabletUi: Boolean,
|
||||||
chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction,
|
chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction,
|
||||||
chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction,
|
chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction,
|
||||||
navigateUp: () -> Unit,
|
onBackClicked: () -> Unit,
|
||||||
onChapterClicked: (Chapter) -> Unit,
|
onChapterClicked: (Chapter) -> Unit,
|
||||||
onDownloadChapter: ((List<ChapterList.Item>, ChapterDownloadAction) -> Unit)?,
|
onDownloadChapter: ((List<ChapterList.Item>, ChapterDownloadAction) -> Unit)?,
|
||||||
onAddToLibraryClicked: () -> Unit,
|
onAddToLibraryClicked: () -> Unit,
|
||||||
@ -142,7 +142,6 @@ fun MangaScreen(
|
|||||||
onEditCategoryClicked: (() -> Unit)?,
|
onEditCategoryClicked: (() -> Unit)?,
|
||||||
onEditFetchIntervalClicked: (() -> Unit)?,
|
onEditFetchIntervalClicked: (() -> Unit)?,
|
||||||
onMigrateClicked: (() -> Unit)?,
|
onMigrateClicked: (() -> Unit)?,
|
||||||
onEditNotesClicked: () -> Unit,
|
|
||||||
// SY -->
|
// SY -->
|
||||||
onMetadataViewerClicked: () -> Unit,
|
onMetadataViewerClicked: () -> Unit,
|
||||||
onEditInfoClicked: () -> Unit,
|
onEditInfoClicked: () -> Unit,
|
||||||
@ -183,7 +182,7 @@ fun MangaScreen(
|
|||||||
nextUpdate = nextUpdate,
|
nextUpdate = nextUpdate,
|
||||||
chapterSwipeStartAction = chapterSwipeStartAction,
|
chapterSwipeStartAction = chapterSwipeStartAction,
|
||||||
chapterSwipeEndAction = chapterSwipeEndAction,
|
chapterSwipeEndAction = chapterSwipeEndAction,
|
||||||
navigateUp = navigateUp,
|
onBackClicked = onBackClicked,
|
||||||
onChapterClicked = onChapterClicked,
|
onChapterClicked = onChapterClicked,
|
||||||
onDownloadChapter = onDownloadChapter,
|
onDownloadChapter = onDownloadChapter,
|
||||||
onAddToLibraryClicked = onAddToLibraryClicked,
|
onAddToLibraryClicked = onAddToLibraryClicked,
|
||||||
@ -202,7 +201,6 @@ fun MangaScreen(
|
|||||||
onEditCategoryClicked = onEditCategoryClicked,
|
onEditCategoryClicked = onEditCategoryClicked,
|
||||||
onEditIntervalClicked = onEditFetchIntervalClicked,
|
onEditIntervalClicked = onEditFetchIntervalClicked,
|
||||||
onMigrateClicked = onMigrateClicked,
|
onMigrateClicked = onMigrateClicked,
|
||||||
onEditNotesClicked = onEditNotesClicked,
|
|
||||||
// SY -->
|
// SY -->
|
||||||
onMetadataViewerClicked = onMetadataViewerClicked,
|
onMetadataViewerClicked = onMetadataViewerClicked,
|
||||||
onEditInfoClicked = onEditInfoClicked,
|
onEditInfoClicked = onEditInfoClicked,
|
||||||
@ -230,7 +228,7 @@ fun MangaScreen(
|
|||||||
chapterSwipeStartAction = chapterSwipeStartAction,
|
chapterSwipeStartAction = chapterSwipeStartAction,
|
||||||
chapterSwipeEndAction = chapterSwipeEndAction,
|
chapterSwipeEndAction = chapterSwipeEndAction,
|
||||||
nextUpdate = nextUpdate,
|
nextUpdate = nextUpdate,
|
||||||
navigateUp = navigateUp,
|
onBackClicked = onBackClicked,
|
||||||
onChapterClicked = onChapterClicked,
|
onChapterClicked = onChapterClicked,
|
||||||
onDownloadChapter = onDownloadChapter,
|
onDownloadChapter = onDownloadChapter,
|
||||||
onAddToLibraryClicked = onAddToLibraryClicked,
|
onAddToLibraryClicked = onAddToLibraryClicked,
|
||||||
@ -249,7 +247,6 @@ fun MangaScreen(
|
|||||||
onEditCategoryClicked = onEditCategoryClicked,
|
onEditCategoryClicked = onEditCategoryClicked,
|
||||||
onEditIntervalClicked = onEditFetchIntervalClicked,
|
onEditIntervalClicked = onEditFetchIntervalClicked,
|
||||||
onMigrateClicked = onMigrateClicked,
|
onMigrateClicked = onMigrateClicked,
|
||||||
onEditNotesClicked = onEditNotesClicked,
|
|
||||||
// SY -->
|
// SY -->
|
||||||
onMetadataViewerClicked = onMetadataViewerClicked,
|
onMetadataViewerClicked = onMetadataViewerClicked,
|
||||||
onEditInfoClicked = onEditInfoClicked,
|
onEditInfoClicked = onEditInfoClicked,
|
||||||
@ -280,7 +277,7 @@ private fun MangaScreenSmallImpl(
|
|||||||
nextUpdate: Instant?,
|
nextUpdate: Instant?,
|
||||||
chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction,
|
chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction,
|
||||||
chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction,
|
chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction,
|
||||||
navigateUp: () -> Unit,
|
onBackClicked: () -> Unit,
|
||||||
onChapterClicked: (Chapter) -> Unit,
|
onChapterClicked: (Chapter) -> Unit,
|
||||||
onDownloadChapter: ((List<ChapterList.Item>, ChapterDownloadAction) -> Unit)?,
|
onDownloadChapter: ((List<ChapterList.Item>, ChapterDownloadAction) -> Unit)?,
|
||||||
onAddToLibraryClicked: () -> Unit,
|
onAddToLibraryClicked: () -> Unit,
|
||||||
@ -306,7 +303,6 @@ private fun MangaScreenSmallImpl(
|
|||||||
onEditCategoryClicked: (() -> Unit)?,
|
onEditCategoryClicked: (() -> Unit)?,
|
||||||
onEditIntervalClicked: (() -> Unit)?,
|
onEditIntervalClicked: (() -> Unit)?,
|
||||||
onMigrateClicked: (() -> Unit)?,
|
onMigrateClicked: (() -> Unit)?,
|
||||||
onEditNotesClicked: () -> Unit,
|
|
||||||
// SY -->
|
// SY -->
|
||||||
onMetadataViewerClicked: () -> Unit,
|
onMetadataViewerClicked: () -> Unit,
|
||||||
onEditInfoClicked: () -> Unit,
|
onEditInfoClicked: () -> Unit,
|
||||||
@ -349,9 +345,14 @@ private fun MangaScreenSmallImpl(
|
|||||||
}
|
}
|
||||||
// SY <--
|
// SY <--
|
||||||
|
|
||||||
BackHandler(enabled = isAnySelected) {
|
val internalOnBackPressed = {
|
||||||
|
if (isAnySelected) {
|
||||||
onAllChapterSelected(false)
|
onAllChapterSelected(false)
|
||||||
|
} else {
|
||||||
|
onBackClicked()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
BackHandler(onBack = internalOnBackPressed)
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
@ -364,25 +365,26 @@ private fun MangaScreenSmallImpl(
|
|||||||
val isFirstItemScrolled by remember {
|
val isFirstItemScrolled by remember {
|
||||||
derivedStateOf { chapterListState.firstVisibleItemScrollOffset > 0 }
|
derivedStateOf { chapterListState.firstVisibleItemScrollOffset > 0 }
|
||||||
}
|
}
|
||||||
val titleAlpha by animateFloatAsState(
|
val animatedTitleAlpha by animateFloatAsState(
|
||||||
if (!isFirstItemVisible) 1f else 0f,
|
if (!isFirstItemVisible) 1f else 0f,
|
||||||
label = "Top Bar Title",
|
label = "Top Bar Title",
|
||||||
)
|
)
|
||||||
val backgroundAlpha by animateFloatAsState(
|
val animatedBgAlpha by animateFloatAsState(
|
||||||
if (!isFirstItemVisible || isFirstItemScrolled) 1f else 0f,
|
if (!isFirstItemVisible || isFirstItemScrolled) 1f else 0f,
|
||||||
label = "Top Bar Background",
|
label = "Top Bar Background",
|
||||||
)
|
)
|
||||||
MangaToolbar(
|
MangaToolbar(
|
||||||
title = state.manga.title,
|
title = state.manga.title,
|
||||||
|
titleAlphaProvider = { animatedTitleAlpha },
|
||||||
|
backgroundAlphaProvider = { animatedBgAlpha },
|
||||||
hasFilters = state.filterActive,
|
hasFilters = state.filterActive,
|
||||||
navigateUp = navigateUp,
|
onBackClicked = internalOnBackPressed,
|
||||||
onClickFilter = onFilterClicked,
|
onClickFilter = onFilterClicked,
|
||||||
onClickShare = onShareClicked,
|
onClickShare = onShareClicked,
|
||||||
onClickDownload = onDownloadActionClicked,
|
onClickDownload = onDownloadActionClicked,
|
||||||
onClickEditCategory = onEditCategoryClicked,
|
onClickEditCategory = onEditCategoryClicked,
|
||||||
onClickRefresh = onRefresh,
|
onClickRefresh = onRefresh,
|
||||||
onClickMigrate = onMigrateClicked,
|
onClickMigrate = onMigrateClicked,
|
||||||
onClickEditNotes = onEditNotesClicked,
|
|
||||||
// SY -->
|
// SY -->
|
||||||
onClickEditInfo = onEditInfoClicked.takeIf { state.manga.favorite },
|
onClickEditInfo = onEditInfoClicked.takeIf { state.manga.favorite },
|
||||||
onClickRecommend = onRecommendClicked.takeIf { state.showRecommendationsInOverflow },
|
onClickRecommend = onRecommendClicked.takeIf { state.showRecommendationsInOverflow },
|
||||||
@ -390,11 +392,8 @@ private fun MangaScreenSmallImpl(
|
|||||||
onClickMerge = onMergeClicked.takeIf { state.showMergeInOverflow },
|
onClickMerge = onMergeClicked.takeIf { state.showMergeInOverflow },
|
||||||
// SY <--
|
// SY <--
|
||||||
actionModeCounter = selectedChapterCount,
|
actionModeCounter = selectedChapterCount,
|
||||||
onCancelActionMode = { onAllChapterSelected(false) },
|
|
||||||
onSelectAll = { onAllChapterSelected(true) },
|
onSelectAll = { onAllChapterSelected(true) },
|
||||||
onInvertSelection = { onInvertSelection() },
|
onInvertSelection = { onInvertSelection() },
|
||||||
titleAlphaProvider = { titleAlpha },
|
|
||||||
backgroundAlphaProvider = { backgroundAlpha },
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
bottomBar = {
|
bottomBar = {
|
||||||
@ -520,10 +519,8 @@ private fun MangaScreenSmallImpl(
|
|||||||
defaultExpandState = state.isFromSource,
|
defaultExpandState = state.isFromSource,
|
||||||
description = state.manga.description,
|
description = state.manga.description,
|
||||||
tagsProvider = { state.manga.genre },
|
tagsProvider = { state.manga.genre },
|
||||||
notes = state.manga.notes,
|
|
||||||
onTagSearch = onTagSearch,
|
onTagSearch = onTagSearch,
|
||||||
onCopyTagToClipboard = onCopyTagToClipboard,
|
onCopyTagToClipboard = onCopyTagToClipboard,
|
||||||
onEditNotes = onEditNotesClicked,
|
|
||||||
// SY -->
|
// SY -->
|
||||||
doSearch = onSearch,
|
doSearch = onSearch,
|
||||||
searchMetadataChips = remember(state.meta, state.source.id, state.manga.genre) {
|
searchMetadataChips = remember(state.meta, state.source.id, state.manga.genre) {
|
||||||
@ -603,7 +600,7 @@ fun MangaScreenLargeImpl(
|
|||||||
nextUpdate: Instant?,
|
nextUpdate: Instant?,
|
||||||
chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction,
|
chapterSwipeStartAction: LibraryPreferences.ChapterSwipeAction,
|
||||||
chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction,
|
chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction,
|
||||||
navigateUp: () -> Unit,
|
onBackClicked: () -> Unit,
|
||||||
onChapterClicked: (Chapter) -> Unit,
|
onChapterClicked: (Chapter) -> Unit,
|
||||||
onDownloadChapter: ((List<ChapterList.Item>, ChapterDownloadAction) -> Unit)?,
|
onDownloadChapter: ((List<ChapterList.Item>, ChapterDownloadAction) -> Unit)?,
|
||||||
onAddToLibraryClicked: () -> Unit,
|
onAddToLibraryClicked: () -> Unit,
|
||||||
@ -629,7 +626,6 @@ fun MangaScreenLargeImpl(
|
|||||||
onEditCategoryClicked: (() -> Unit)?,
|
onEditCategoryClicked: (() -> Unit)?,
|
||||||
onEditIntervalClicked: (() -> Unit)?,
|
onEditIntervalClicked: (() -> Unit)?,
|
||||||
onMigrateClicked: (() -> Unit)?,
|
onMigrateClicked: (() -> Unit)?,
|
||||||
onEditNotesClicked: () -> Unit,
|
|
||||||
// SY -->
|
// SY -->
|
||||||
onMetadataViewerClicked: () -> Unit,
|
onMetadataViewerClicked: () -> Unit,
|
||||||
onEditInfoClicked: () -> Unit,
|
onEditInfoClicked: () -> Unit,
|
||||||
@ -676,9 +672,14 @@ fun MangaScreenLargeImpl(
|
|||||||
|
|
||||||
val chapterListState = rememberLazyListState()
|
val chapterListState = rememberLazyListState()
|
||||||
|
|
||||||
BackHandler(enabled = isAnySelected) {
|
val internalOnBackPressed = {
|
||||||
|
if (isAnySelected) {
|
||||||
onAllChapterSelected(false)
|
onAllChapterSelected(false)
|
||||||
|
} else {
|
||||||
|
onBackClicked()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
BackHandler(onBack = internalOnBackPressed)
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
@ -688,27 +689,25 @@ fun MangaScreenLargeImpl(
|
|||||||
MangaToolbar(
|
MangaToolbar(
|
||||||
modifier = Modifier.onSizeChanged { topBarHeight = it.height },
|
modifier = Modifier.onSizeChanged { topBarHeight = it.height },
|
||||||
title = state.manga.title,
|
title = state.manga.title,
|
||||||
|
titleAlphaProvider = { if (isAnySelected) 1f else 0f },
|
||||||
|
backgroundAlphaProvider = { 1f },
|
||||||
hasFilters = state.filterActive,
|
hasFilters = state.filterActive,
|
||||||
navigateUp = navigateUp,
|
onBackClicked = internalOnBackPressed,
|
||||||
onClickFilter = onFilterButtonClicked,
|
onClickFilter = onFilterButtonClicked,
|
||||||
onClickShare = onShareClicked,
|
onClickShare = onShareClicked,
|
||||||
onClickDownload = onDownloadActionClicked,
|
onClickDownload = onDownloadActionClicked,
|
||||||
onClickEditCategory = onEditCategoryClicked,
|
onClickEditCategory = onEditCategoryClicked,
|
||||||
onClickRefresh = onRefresh,
|
onClickRefresh = onRefresh,
|
||||||
onClickMigrate = onMigrateClicked,
|
onClickMigrate = onMigrateClicked,
|
||||||
onClickEditNotes = onEditNotesClicked,
|
|
||||||
// SY -->
|
// SY -->
|
||||||
onClickEditInfo = onEditInfoClicked.takeIf { state.manga.favorite },
|
onClickEditInfo = onEditInfoClicked.takeIf { state.manga.favorite },
|
||||||
onClickRecommend = onRecommendClicked.takeIf { state.showRecommendationsInOverflow },
|
onClickRecommend = onRecommendClicked.takeIf { state.showRecommendationsInOverflow },
|
||||||
onClickMergedSettings = onMergedSettingsClicked.takeIf { state.manga.source == MERGED_SOURCE_ID },
|
onClickMergedSettings = onMergedSettingsClicked.takeIf { state.manga.source == MERGED_SOURCE_ID },
|
||||||
onClickMerge = onMergeClicked.takeIf { state.showMergeInOverflow },
|
onClickMerge = onMergeClicked.takeIf { state.showMergeInOverflow },
|
||||||
// SY <--
|
// SY <--
|
||||||
onCancelActionMode = { onAllChapterSelected(false) },
|
|
||||||
actionModeCounter = selectedChapterCount,
|
actionModeCounter = selectedChapterCount,
|
||||||
onSelectAll = { onAllChapterSelected(true) },
|
onSelectAll = { onAllChapterSelected(true) },
|
||||||
onInvertSelection = { onInvertSelection() },
|
onInvertSelection = { onInvertSelection() },
|
||||||
titleAlphaProvider = { 1f },
|
|
||||||
backgroundAlphaProvider = { 1f },
|
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
bottomBar = {
|
bottomBar = {
|
||||||
@ -815,10 +814,8 @@ fun MangaScreenLargeImpl(
|
|||||||
defaultExpandState = true,
|
defaultExpandState = true,
|
||||||
description = state.manga.description,
|
description = state.manga.description,
|
||||||
tagsProvider = { state.manga.genre },
|
tagsProvider = { state.manga.genre },
|
||||||
notes = state.manga.notes,
|
|
||||||
onTagSearch = onTagSearch,
|
onTagSearch = onTagSearch,
|
||||||
onCopyTagToClipboard = onCopyTagToClipboard,
|
onCopyTagToClipboard = onCopyTagToClipboard,
|
||||||
onEditNotes = onEditNotesClicked,
|
|
||||||
// SY -->
|
// SY -->
|
||||||
doSearch = onSearch,
|
doSearch = onSearch,
|
||||||
searchMetadataChips = remember(state.meta, state.source.id, state.manga.genre) {
|
searchMetadataChips = remember(state.meta, state.source.id, state.manga.genre) {
|
||||||
|
@ -28,6 +28,7 @@ import androidx.compose.material.icons.outlined.BookmarkRemove
|
|||||||
import androidx.compose.material.icons.outlined.Delete
|
import androidx.compose.material.icons.outlined.Delete
|
||||||
import androidx.compose.material.icons.outlined.DoneAll
|
import androidx.compose.material.icons.outlined.DoneAll
|
||||||
import androidx.compose.material.icons.outlined.Download
|
import androidx.compose.material.icons.outlined.Download
|
||||||
|
import androidx.compose.material.icons.outlined.Label
|
||||||
import androidx.compose.material.icons.outlined.MoreVert
|
import androidx.compose.material.icons.outlined.MoreVert
|
||||||
import androidx.compose.material.icons.outlined.RemoveDone
|
import androidx.compose.material.icons.outlined.RemoveDone
|
||||||
import androidx.compose.material.icons.outlined.SwapCalls
|
import androidx.compose.material.icons.outlined.SwapCalls
|
||||||
@ -236,7 +237,6 @@ fun LibraryBottomActionMenu(
|
|||||||
// SY -->
|
// SY -->
|
||||||
onClickCleanTitles: (() -> Unit)?,
|
onClickCleanTitles: (() -> Unit)?,
|
||||||
onClickMigrate: (() -> Unit)?,
|
onClickMigrate: (() -> Unit)?,
|
||||||
onClickCollectRecommendations: (() -> Unit)?,
|
|
||||||
onClickAddToMangaDex: (() -> Unit)?,
|
onClickAddToMangaDex: (() -> Unit)?,
|
||||||
onClickResetInfo: (() -> Unit)?,
|
onClickResetInfo: (() -> Unit)?,
|
||||||
// SY <--
|
// SY <--
|
||||||
@ -267,10 +267,7 @@ fun LibraryBottomActionMenu(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// SY -->
|
// SY -->
|
||||||
val showOverflow = onClickCleanTitles != null ||
|
val showOverflow = onClickCleanTitles != null || onClickAddToMangaDex != null || onClickResetInfo != null
|
||||||
onClickAddToMangaDex != null ||
|
|
||||||
onClickResetInfo != null ||
|
|
||||||
onClickCollectRecommendations != null
|
|
||||||
val configuration = LocalConfiguration.current
|
val configuration = LocalConfiguration.current
|
||||||
val moveMarkPrev = remember { !configuration.isTabletUi() }
|
val moveMarkPrev = remember { !configuration.isTabletUi() }
|
||||||
var overFlowOpen by remember { mutableStateOf(false) }
|
var overFlowOpen by remember { mutableStateOf(false) }
|
||||||
@ -361,12 +358,6 @@ fun LibraryBottomActionMenu(
|
|||||||
onClick = onClickMigrate,
|
onClick = onClickMigrate,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (onClickCollectRecommendations != null) {
|
|
||||||
DropdownMenuItem(
|
|
||||||
text = { Text(stringResource(SYMR.strings.rec_search_short)) },
|
|
||||||
onClick = onClickCollectRecommendations,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (onClickAddToMangaDex != null) {
|
if (onClickAddToMangaDex != null) {
|
||||||
DropdownMenuItem(
|
DropdownMenuItem(
|
||||||
text = { Text(stringResource(SYMR.strings.mangadex_add_to_follows)) },
|
text = { Text(stringResource(SYMR.strings.mangadex_add_to_follows)) },
|
||||||
|
@ -3,9 +3,6 @@ package eu.kanade.presentation.manga.components
|
|||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.drawable.BitmapDrawable
|
import android.graphics.drawable.BitmapDrawable
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.activity.compose.PredictiveBackHandler
|
|
||||||
import androidx.compose.animation.core.animate
|
|
||||||
import androidx.compose.animation.core.tween
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
@ -28,22 +25,18 @@ import androidx.compose.material3.SnackbarHostState
|
|||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableFloatStateOf
|
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.clip
|
import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.graphicsLayer
|
|
||||||
import androidx.compose.ui.platform.LocalDensity
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
import androidx.compose.ui.unit.DpOffset
|
import androidx.compose.ui.unit.DpOffset
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.util.lerp
|
|
||||||
import androidx.compose.ui.viewinterop.AndroidView
|
import androidx.compose.ui.viewinterop.AndroidView
|
||||||
import androidx.compose.ui.window.Dialog
|
import androidx.compose.ui.window.Dialog
|
||||||
import androidx.compose.ui.window.DialogProperties
|
import androidx.compose.ui.window.DialogProperties
|
||||||
import androidx.core.graphics.drawable.toDrawable
|
|
||||||
import androidx.core.view.updatePadding
|
import androidx.core.view.updatePadding
|
||||||
import coil3.asDrawable
|
import coil3.asDrawable
|
||||||
import coil3.imageLoader
|
import coil3.imageLoader
|
||||||
@ -56,14 +49,11 @@ import eu.kanade.presentation.components.DropdownMenu
|
|||||||
import eu.kanade.presentation.manga.EditCoverAction
|
import eu.kanade.presentation.manga.EditCoverAction
|
||||||
import eu.kanade.tachiyomi.ui.reader.viewer.ReaderPageImageView
|
import eu.kanade.tachiyomi.ui.reader.viewer.ReaderPageImageView
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import soup.compose.material.motion.MotionConstants
|
|
||||||
import tachiyomi.domain.manga.model.Manga
|
import tachiyomi.domain.manga.model.Manga
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import tachiyomi.presentation.core.components.material.Scaffold
|
import tachiyomi.presentation.core.components.material.Scaffold
|
||||||
import tachiyomi.presentation.core.i18n.stringResource
|
import tachiyomi.presentation.core.i18n.stringResource
|
||||||
import tachiyomi.presentation.core.util.PredictiveBack
|
|
||||||
import tachiyomi.presentation.core.util.clickableNoIndication
|
import tachiyomi.presentation.core.util.clickableNoIndication
|
||||||
import kotlin.coroutines.cancellation.CancellationException
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MangaCoverDialog(
|
fun MangaCoverDialog(
|
||||||
@ -162,32 +152,10 @@ fun MangaCoverDialog(
|
|||||||
val statusBarPaddingPx = with(LocalDensity.current) { contentPadding.calculateTopPadding().roundToPx() }
|
val statusBarPaddingPx = with(LocalDensity.current) { contentPadding.calculateTopPadding().roundToPx() }
|
||||||
val bottomPaddingPx = with(LocalDensity.current) { contentPadding.calculateBottomPadding().roundToPx() }
|
val bottomPaddingPx = with(LocalDensity.current) { contentPadding.calculateBottomPadding().roundToPx() }
|
||||||
|
|
||||||
var scale by remember { mutableFloatStateOf(1f) }
|
|
||||||
PredictiveBackHandler { progress ->
|
|
||||||
try {
|
|
||||||
progress.collect { backEvent ->
|
|
||||||
scale = lerp(1f, 0.8f, PredictiveBack.transform(backEvent.progress))
|
|
||||||
}
|
|
||||||
onDismissRequest()
|
|
||||||
} catch (e: CancellationException) {
|
|
||||||
animate(
|
|
||||||
initialValue = scale,
|
|
||||||
targetValue = 1f,
|
|
||||||
animationSpec = tween(durationMillis = MotionConstants.DefaultMotionDuration),
|
|
||||||
) { value, _ ->
|
|
||||||
scale = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.clickableNoIndication(onClick = onDismissRequest)
|
.clickableNoIndication(onClick = onDismissRequest),
|
||||||
.graphicsLayer {
|
|
||||||
scaleX = scale
|
|
||||||
scaleY = scale
|
|
||||||
},
|
|
||||||
) {
|
) {
|
||||||
AndroidView(
|
AndroidView(
|
||||||
factory = {
|
factory = {
|
||||||
@ -204,20 +172,20 @@ fun MangaCoverDialog(
|
|||||||
.memoryCachePolicy(CachePolicy.DISABLED)
|
.memoryCachePolicy(CachePolicy.DISABLED)
|
||||||
.target { image ->
|
.target { image ->
|
||||||
val drawable = image.asDrawable(view.context.resources)
|
val drawable = image.asDrawable(view.context.resources)
|
||||||
|
|
||||||
// Copy bitmap in case it came from memory cache
|
// Copy bitmap in case it came from memory cache
|
||||||
// Because SSIV needs to thoroughly read the image
|
// Because SSIV needs to thoroughly read the image
|
||||||
val copy = (drawable as? BitmapDrawable)
|
val copy = (drawable as? BitmapDrawable)?.let {
|
||||||
?.bitmap
|
val config = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
?.copy(
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
Bitmap.Config.HARDWARE
|
Bitmap.Config.HARDWARE
|
||||||
} else {
|
} else {
|
||||||
Bitmap.Config.ARGB_8888
|
Bitmap.Config.ARGB_8888
|
||||||
},
|
}
|
||||||
false,
|
BitmapDrawable(
|
||||||
|
view.context.resources,
|
||||||
|
it.bitmap.copy(config, false),
|
||||||
)
|
)
|
||||||
?.toDrawable(view.context.resources)
|
} ?: drawable
|
||||||
?: drawable
|
|
||||||
view.setImage(copy, ReaderPageImageView.Config(zoomDuration = 500))
|
view.setImage(copy, ReaderPageImageView.Config(zoomDuration = 500))
|
||||||
}
|
}
|
||||||
.build()
|
.build()
|
||||||
|
@ -77,8 +77,6 @@ import androidx.compose.ui.unit.sp
|
|||||||
import coil3.compose.AsyncImage
|
import coil3.compose.AsyncImage
|
||||||
import coil3.request.ImageRequest
|
import coil3.request.ImageRequest
|
||||||
import coil3.request.crossfade
|
import coil3.request.crossfade
|
||||||
import com.mikepenz.markdown.model.markdownAnnotator
|
|
||||||
import com.mikepenz.markdown.model.markdownAnnotatorConfig
|
|
||||||
import eu.kanade.presentation.components.DropdownMenu
|
import eu.kanade.presentation.components.DropdownMenu
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
@ -97,6 +95,8 @@ import java.time.Instant
|
|||||||
import java.time.temporal.ChronoUnit
|
import java.time.temporal.ChronoUnit
|
||||||
import kotlin.math.roundToInt
|
import kotlin.math.roundToInt
|
||||||
|
|
||||||
|
private val whitespaceLineRegex = Regex("[\\r\\n]{2,}", setOf(RegexOption.MULTILINE))
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun MangaInfoBox(
|
fun MangaInfoBox(
|
||||||
isTabletUi: Boolean,
|
isTabletUi: Boolean,
|
||||||
@ -250,10 +250,8 @@ fun ExpandableMangaDescription(
|
|||||||
defaultExpandState: Boolean,
|
defaultExpandState: Boolean,
|
||||||
description: String?,
|
description: String?,
|
||||||
tagsProvider: () -> List<String>?,
|
tagsProvider: () -> List<String>?,
|
||||||
notes: String,
|
|
||||||
onTagSearch: (String) -> Unit,
|
onTagSearch: (String) -> Unit,
|
||||||
onCopyTagToClipboard: (tag: String) -> Unit,
|
onCopyTagToClipboard: (tag: String) -> Unit,
|
||||||
onEditNotes: () -> Unit,
|
|
||||||
// SY -->
|
// SY -->
|
||||||
searchMetadataChips: SearchMetadataChips?,
|
searchMetadataChips: SearchMetadataChips?,
|
||||||
doSearch: (query: String, global: Boolean) -> Unit,
|
doSearch: (query: String, global: Boolean) -> Unit,
|
||||||
@ -266,12 +264,15 @@ fun ExpandableMangaDescription(
|
|||||||
}
|
}
|
||||||
val desc =
|
val desc =
|
||||||
description.takeIf { !it.isNullOrBlank() } ?: stringResource(MR.strings.description_placeholder)
|
description.takeIf { !it.isNullOrBlank() } ?: stringResource(MR.strings.description_placeholder)
|
||||||
|
val trimmedDescription = remember(desc) {
|
||||||
|
desc
|
||||||
|
.replace(whitespaceLineRegex, "\n")
|
||||||
|
.trimEnd()
|
||||||
|
}
|
||||||
MangaSummary(
|
MangaSummary(
|
||||||
description = desc,
|
expandedDescription = desc,
|
||||||
|
shrunkDescription = trimmedDescription,
|
||||||
expanded = expanded,
|
expanded = expanded,
|
||||||
notes = notes,
|
|
||||||
onEditNotesClicked = onEditNotes,
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(top = 8.dp)
|
.padding(top = 8.dp)
|
||||||
.padding(horizontal = 16.dp)
|
.padding(horizontal = 16.dp)
|
||||||
@ -593,26 +594,11 @@ private fun ColumnScope.MangaContentInfo(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val descriptionAnnotator = markdownAnnotator(
|
|
||||||
annotate = { content, child ->
|
|
||||||
if (child.type in DISALLOWED_MARKDOWN_TYPES) {
|
|
||||||
append(content.substring(child.startOffset, child.endOffset))
|
|
||||||
return@markdownAnnotator true
|
|
||||||
}
|
|
||||||
|
|
||||||
false
|
|
||||||
},
|
|
||||||
config = markdownAnnotatorConfig(
|
|
||||||
eolAsNewLine = true,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun MangaSummary(
|
private fun MangaSummary(
|
||||||
description: String,
|
expandedDescription: String,
|
||||||
notes: String,
|
shrunkDescription: String,
|
||||||
expanded: Boolean,
|
expanded: Boolean,
|
||||||
onEditNotesClicked: () -> Unit,
|
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
val animProgress by animateFloatAsState(
|
val animProgress by animateFloatAsState(
|
||||||
@ -624,41 +610,26 @@ private fun MangaSummary(
|
|||||||
contents = listOf(
|
contents = listOf(
|
||||||
{
|
{
|
||||||
Text(
|
Text(
|
||||||
// Shows at least 3 lines if no notes
|
text = "\n\n", // Shows at least 3 lines
|
||||||
// when there are notes show 6
|
|
||||||
text = if (notes.isBlank()) "\n\n" else "\n\n\n\n\n",
|
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Column {
|
Text(
|
||||||
MangaNotesSection(
|
text = expandedDescription,
|
||||||
content = notes,
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
expanded = true,
|
|
||||||
onEditNotes = onEditNotesClicked,
|
|
||||||
)
|
)
|
||||||
MarkdownRender(
|
|
||||||
content = description,
|
|
||||||
modifier = Modifier.secondaryItemAlpha(),
|
|
||||||
annotator = descriptionAnnotator,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Column {
|
|
||||||
MangaNotesSection(
|
|
||||||
content = notes,
|
|
||||||
expanded = expanded,
|
|
||||||
onEditNotes = onEditNotesClicked,
|
|
||||||
)
|
|
||||||
SelectionContainer {
|
SelectionContainer {
|
||||||
MarkdownRender(
|
Text(
|
||||||
content = description,
|
text = if (expanded) expandedDescription else shrunkDescription,
|
||||||
|
maxLines = Int.MAX_VALUE,
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
color = MaterialTheme.colorScheme.onBackground,
|
||||||
modifier = Modifier.secondaryItemAlpha(),
|
modifier = Modifier.secondaryItemAlpha(),
|
||||||
annotator = descriptionAnnotator,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
val colors = listOf(Color.Transparent, MaterialTheme.colorScheme.background)
|
val colors = listOf(Color.Transparent, MaterialTheme.colorScheme.background)
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
package eu.kanade.presentation.manga.components
|
|
||||||
|
|
||||||
import androidx.compose.animation.animateContentSize
|
|
||||||
import androidx.compose.animation.core.Animatable
|
|
||||||
import androidx.compose.animation.core.tween
|
|
||||||
import androidx.compose.foundation.text.selection.SelectionContainer
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
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
|
|
||||||
import androidx.compose.runtime.setValue
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.compose.ui.draw.alpha
|
|
||||||
import com.mohamedrejeb.richeditor.model.rememberRichTextState
|
|
||||||
import com.mohamedrejeb.richeditor.ui.material3.RichText
|
|
||||||
|
|
||||||
private val FADE_TIME = tween<Float>(500)
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun MangaNotesDisplay(
|
|
||||||
content: String,
|
|
||||||
modifier: Modifier,
|
|
||||||
) {
|
|
||||||
val alpha = remember { Animatable(1f) }
|
|
||||||
var contentUpdatedOnce by remember { mutableStateOf(false) }
|
|
||||||
|
|
||||||
val richTextState = rememberRichTextState()
|
|
||||||
val primaryColor = MaterialTheme.colorScheme.primary
|
|
||||||
LaunchedEffect(content) {
|
|
||||||
richTextState.setMarkdown(content)
|
|
||||||
|
|
||||||
if (!contentUpdatedOnce) {
|
|
||||||
contentUpdatedOnce = true
|
|
||||||
return@LaunchedEffect
|
|
||||||
}
|
|
||||||
|
|
||||||
alpha.snapTo(targetValue = 0f)
|
|
||||||
alpha.animateTo(targetValue = 1f, animationSpec = FADE_TIME)
|
|
||||||
}
|
|
||||||
LaunchedEffect(Unit) {
|
|
||||||
richTextState.config.unorderedListIndent = 4
|
|
||||||
richTextState.config.orderedListIndent = 20
|
|
||||||
}
|
|
||||||
LaunchedEffect(primaryColor) {
|
|
||||||
richTextState.config.linkColor = primaryColor
|
|
||||||
}
|
|
||||||
|
|
||||||
SelectionContainer {
|
|
||||||
RichText(
|
|
||||||
modifier = modifier
|
|
||||||
// Only animate size if the notes changes
|
|
||||||
.then(if (contentUpdatedOnce) Modifier.animateContentSize() else Modifier)
|
|
||||||
.alpha(alpha.value),
|
|
||||||
style = MaterialTheme.typography.bodyMedium,
|
|
||||||
state = richTextState,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
package eu.kanade.presentation.manga.components
|
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.Row
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
import androidx.compose.foundation.layout.padding
|
|
||||||
import androidx.compose.foundation.layout.size
|
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
||||||
import androidx.compose.material.icons.Icons
|
|
||||||
import androidx.compose.material.icons.filled.EditNote
|
|
||||||
import androidx.compose.material3.HorizontalDivider
|
|
||||||
import androidx.compose.material3.Icon
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.Text
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.compose.ui.Alignment
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.tooling.preview.PreviewLightDark
|
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import tachiyomi.i18n.MR
|
|
||||||
import tachiyomi.presentation.core.components.material.Button
|
|
||||||
import tachiyomi.presentation.core.components.material.ButtonDefaults
|
|
||||||
import tachiyomi.presentation.core.components.material.padding
|
|
||||||
import tachiyomi.presentation.core.i18n.stringResource
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun MangaNotesSection(
|
|
||||||
content: String,
|
|
||||||
expanded: Boolean,
|
|
||||||
onEditNotes: () -> Unit,
|
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
) {
|
|
||||||
if (content.isBlank()) return
|
|
||||||
Column(
|
|
||||||
modifier = modifier.fillMaxWidth(),
|
|
||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
|
||||||
) {
|
|
||||||
MangaNotesDisplay(
|
|
||||||
content = content,
|
|
||||||
modifier = modifier.fillMaxWidth(),
|
|
||||||
)
|
|
||||||
if (expanded) {
|
|
||||||
Button(
|
|
||||||
onClick = onEditNotes,
|
|
||||||
colors = ButtonDefaults.buttonColors(
|
|
||||||
containerColor = Color.Transparent,
|
|
||||||
contentColor = MaterialTheme.colorScheme.primary,
|
|
||||||
),
|
|
||||||
shape = RoundedCornerShape(8.dp),
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(horizontal = 16.dp, vertical = 4.dp),
|
|
||||||
) {
|
|
||||||
Row(
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.extraSmall),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Filled.EditNote,
|
|
||||||
contentDescription = null,
|
|
||||||
modifier = Modifier
|
|
||||||
.size(16.dp),
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
stringResource(MR.strings.action_edit_notes),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
HorizontalDivider(
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(
|
|
||||||
top = if (expanded) 0.dp else 12.dp,
|
|
||||||
bottom = if (expanded) 16.dp else 12.dp,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreviewLightDark
|
|
||||||
@Composable
|
|
||||||
private fun MangaNotesSectionPreview() {
|
|
||||||
MangaNotesSection(
|
|
||||||
onEditNotes = {},
|
|
||||||
expanded = true,
|
|
||||||
content = "# Hello world\ntest1234 hi there!",
|
|
||||||
)
|
|
||||||
}
|
|
@ -1,224 +0,0 @@
|
|||||||
package eu.kanade.presentation.manga.components
|
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.clickable
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
|
||||||
import androidx.compose.foundation.layout.Box
|
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
|
||||||
import androidx.compose.foundation.layout.Row
|
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
import androidx.compose.foundation.layout.height
|
|
||||||
import androidx.compose.foundation.layout.padding
|
|
||||||
import androidx.compose.foundation.lazy.LazyRow
|
|
||||||
import androidx.compose.material.icons.Icons
|
|
||||||
import androidx.compose.material.icons.automirrored.outlined.FormatListBulleted
|
|
||||||
import androidx.compose.material.icons.outlined.FormatBold
|
|
||||||
import androidx.compose.material.icons.outlined.FormatItalic
|
|
||||||
import androidx.compose.material.icons.outlined.FormatListNumbered
|
|
||||||
import androidx.compose.material.icons.outlined.FormatUnderlined
|
|
||||||
import androidx.compose.material3.Icon
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.Text
|
|
||||||
import androidx.compose.material3.VerticalDivider
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.compose.runtime.DisposableEffect
|
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
|
||||||
import androidx.compose.runtime.snapshotFlow
|
|
||||||
import androidx.compose.ui.Alignment
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.compose.ui.draw.clip
|
|
||||||
import androidx.compose.ui.focus.FocusRequester
|
|
||||||
import androidx.compose.ui.focus.focusRequester
|
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
|
||||||
import androidx.compose.ui.semantics.Role
|
|
||||||
import androidx.compose.ui.text.SpanStyle
|
|
||||||
import androidx.compose.ui.text.font.FontStyle
|
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
|
||||||
import androidx.compose.ui.text.style.TextDecoration
|
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import com.mohamedrejeb.richeditor.model.rememberRichTextState
|
|
||||||
import com.mohamedrejeb.richeditor.ui.material3.RichTextEditor
|
|
||||||
import com.mohamedrejeb.richeditor.ui.material3.RichTextEditorDefaults.richTextEditorColors
|
|
||||||
import eu.kanade.tachiyomi.ui.manga.notes.MangaNotesScreen
|
|
||||||
import kotlinx.coroutines.flow.debounce
|
|
||||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
|
||||||
import kotlinx.coroutines.flow.launchIn
|
|
||||||
import kotlinx.coroutines.flow.map
|
|
||||||
import kotlinx.coroutines.flow.onEach
|
|
||||||
import tachiyomi.i18n.MR
|
|
||||||
import tachiyomi.presentation.core.components.material.padding
|
|
||||||
import tachiyomi.presentation.core.i18n.stringResource
|
|
||||||
import kotlin.time.Duration.Companion.seconds
|
|
||||||
|
|
||||||
private const val MAX_LENGTH = 250
|
|
||||||
private const val MAX_LENGTH_WARN = MAX_LENGTH * 0.9
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun MangaNotesTextArea(
|
|
||||||
state: MangaNotesScreen.State,
|
|
||||||
onUpdate: (String) -> Unit,
|
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
) {
|
|
||||||
val scope = rememberCoroutineScope()
|
|
||||||
val richTextState = rememberRichTextState()
|
|
||||||
val primaryColor = MaterialTheme.colorScheme.primary
|
|
||||||
|
|
||||||
DisposableEffect(scope, richTextState) {
|
|
||||||
snapshotFlow { richTextState.annotatedString }
|
|
||||||
.debounce(0.25.seconds)
|
|
||||||
.distinctUntilChanged()
|
|
||||||
.map { richTextState.toMarkdown() }
|
|
||||||
.onEach { onUpdate(it) }
|
|
||||||
.launchIn(scope)
|
|
||||||
|
|
||||||
onDispose {
|
|
||||||
onUpdate(richTextState.toMarkdown())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LaunchedEffect(Unit) {
|
|
||||||
richTextState.setMarkdown(state.notes)
|
|
||||||
richTextState.config.unorderedListIndent = 4
|
|
||||||
richTextState.config.orderedListIndent = 20
|
|
||||||
}
|
|
||||||
LaunchedEffect(primaryColor) {
|
|
||||||
richTextState.config.linkColor = primaryColor
|
|
||||||
}
|
|
||||||
val focusRequester = remember { FocusRequester() }
|
|
||||||
LaunchedEffect(focusRequester) {
|
|
||||||
focusRequester.requestFocus()
|
|
||||||
}
|
|
||||||
val textLength = remember(richTextState.annotatedString) { richTextState.toText().length }
|
|
||||||
|
|
||||||
Column(
|
|
||||||
modifier = modifier
|
|
||||||
.padding(horizontal = MaterialTheme.padding.small)
|
|
||||||
.fillMaxSize(),
|
|
||||||
) {
|
|
||||||
RichTextEditor(
|
|
||||||
state = richTextState,
|
|
||||||
textStyle = MaterialTheme.typography.bodyLarge,
|
|
||||||
maxLength = MAX_LENGTH,
|
|
||||||
placeholder = {
|
|
||||||
Text(text = stringResource(MR.strings.notes_placeholder))
|
|
||||||
},
|
|
||||||
colors = richTextEditorColors(
|
|
||||||
containerColor = Color.Transparent,
|
|
||||||
focusedIndicatorColor = Color.Transparent,
|
|
||||||
unfocusedIndicatorColor = Color.Transparent,
|
|
||||||
),
|
|
||||||
contentPadding = PaddingValues(
|
|
||||||
horizontal = MaterialTheme.padding.medium,
|
|
||||||
),
|
|
||||||
modifier = Modifier
|
|
||||||
.weight(1f)
|
|
||||||
.fillMaxWidth()
|
|
||||||
.focusRequester(focusRequester),
|
|
||||||
)
|
|
||||||
Row(
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.SpaceBetween,
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(vertical = MaterialTheme.padding.small)
|
|
||||||
.fillMaxWidth(),
|
|
||||||
) {
|
|
||||||
LazyRow(
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(2.dp),
|
|
||||||
) {
|
|
||||||
item {
|
|
||||||
MangaNotesTextAreaButton(
|
|
||||||
onClick = { richTextState.toggleSpanStyle(SpanStyle(fontWeight = FontWeight.Bold)) },
|
|
||||||
isSelected = richTextState.currentSpanStyle.fontWeight == FontWeight.Bold,
|
|
||||||
icon = Icons.Outlined.FormatBold,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
item {
|
|
||||||
MangaNotesTextAreaButton(
|
|
||||||
onClick = { richTextState.toggleSpanStyle(SpanStyle(fontStyle = FontStyle.Italic)) },
|
|
||||||
isSelected = richTextState.currentSpanStyle.fontStyle == FontStyle.Italic,
|
|
||||||
icon = Icons.Outlined.FormatItalic,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
item {
|
|
||||||
MangaNotesTextAreaButton(
|
|
||||||
onClick = {
|
|
||||||
richTextState.toggleSpanStyle(SpanStyle(textDecoration = TextDecoration.Underline))
|
|
||||||
},
|
|
||||||
isSelected = richTextState.currentSpanStyle.textDecoration
|
|
||||||
?.contains(TextDecoration.Underline)
|
|
||||||
?: false,
|
|
||||||
icon = Icons.Outlined.FormatUnderlined,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
item {
|
|
||||||
VerticalDivider(
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(horizontal = MaterialTheme.padding.extraSmall)
|
|
||||||
.height(MaterialTheme.padding.large),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
item {
|
|
||||||
MangaNotesTextAreaButton(
|
|
||||||
onClick = { richTextState.toggleUnorderedList() },
|
|
||||||
isSelected = richTextState.isUnorderedList,
|
|
||||||
icon = Icons.AutoMirrored.Outlined.FormatListBulleted,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
item {
|
|
||||||
MangaNotesTextAreaButton(
|
|
||||||
onClick = { richTextState.toggleOrderedList() },
|
|
||||||
isSelected = richTextState.isOrderedList,
|
|
||||||
icon = Icons.Outlined.FormatListNumbered,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Box(
|
|
||||||
contentAlignment = Alignment.Center,
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = (MAX_LENGTH - textLength).toString(),
|
|
||||||
color = if (textLength > MAX_LENGTH_WARN) {
|
|
||||||
MaterialTheme.colorScheme.error
|
|
||||||
} else {
|
|
||||||
Color.Unspecified
|
|
||||||
},
|
|
||||||
modifier = Modifier.padding(MaterialTheme.padding.extraSmall),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun MangaNotesTextAreaButton(
|
|
||||||
onClick: () -> Unit,
|
|
||||||
icon: ImageVector,
|
|
||||||
isSelected: Boolean,
|
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
) {
|
|
||||||
Box(
|
|
||||||
modifier = modifier
|
|
||||||
.clip(MaterialTheme.shapes.small)
|
|
||||||
.clickable(
|
|
||||||
onClick = onClick,
|
|
||||||
enabled = true,
|
|
||||||
role = Role.Button,
|
|
||||||
),
|
|
||||||
contentAlignment = Alignment.Center,
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = icon,
|
|
||||||
contentDescription = icon.name,
|
|
||||||
tint = if (isSelected) MaterialTheme.colorScheme.onPrimary else MaterialTheme.colorScheme.primary,
|
|
||||||
modifier = Modifier
|
|
||||||
.background(color = if (isSelected) MaterialTheme.colorScheme.onBackground else Color.Transparent)
|
|
||||||
.padding(MaterialTheme.padding.extraSmall),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +1,18 @@
|
|||||||
package eu.kanade.presentation.manga.components
|
package eu.kanade.presentation.manga.components
|
||||||
|
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.outlined.Close
|
||||||
import androidx.compose.material.icons.outlined.Download
|
import androidx.compose.material.icons.outlined.Download
|
||||||
import androidx.compose.material.icons.outlined.FilterList
|
import androidx.compose.material.icons.outlined.FilterList
|
||||||
import androidx.compose.material.icons.outlined.FlipToBack
|
import androidx.compose.material.icons.outlined.FlipToBack
|
||||||
import androidx.compose.material.icons.outlined.SelectAll
|
import androidx.compose.material.icons.outlined.SelectAll
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.LocalContentColor
|
import androidx.compose.material3.LocalContentColor
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TopAppBar
|
||||||
|
import androidx.compose.material3.TopAppBarDefaults
|
||||||
import androidx.compose.material3.surfaceColorAtElevation
|
import androidx.compose.material3.surfaceColorAtElevation
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
@ -14,12 +20,12 @@ import androidx.compose.runtime.mutableStateOf
|
|||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.draw.alpha
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.kanade.presentation.components.AppBar
|
import eu.kanade.presentation.components.AppBar
|
||||||
import eu.kanade.presentation.components.AppBarActions
|
import eu.kanade.presentation.components.AppBarActions
|
||||||
import eu.kanade.presentation.components.AppBarTitle
|
|
||||||
import eu.kanade.presentation.components.DownloadDropdownMenu
|
import eu.kanade.presentation.components.DownloadDropdownMenu
|
||||||
|
import eu.kanade.presentation.components.UpIcon
|
||||||
import eu.kanade.presentation.manga.DownloadAction
|
import eu.kanade.presentation.manga.DownloadAction
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
@ -30,15 +36,15 @@ import tachiyomi.presentation.core.theme.active
|
|||||||
@Composable
|
@Composable
|
||||||
fun MangaToolbar(
|
fun MangaToolbar(
|
||||||
title: String,
|
title: String,
|
||||||
|
titleAlphaProvider: () -> Float,
|
||||||
hasFilters: Boolean,
|
hasFilters: Boolean,
|
||||||
navigateUp: () -> Unit,
|
onBackClicked: () -> Unit,
|
||||||
onClickFilter: () -> Unit,
|
onClickFilter: () -> Unit,
|
||||||
onClickShare: (() -> Unit)?,
|
onClickShare: (() -> Unit)?,
|
||||||
onClickDownload: ((DownloadAction) -> Unit)?,
|
onClickDownload: ((DownloadAction) -> Unit)?,
|
||||||
onClickEditCategory: (() -> Unit)?,
|
onClickEditCategory: (() -> Unit)?,
|
||||||
onClickRefresh: () -> Unit,
|
onClickRefresh: () -> Unit,
|
||||||
onClickMigrate: (() -> Unit)?,
|
onClickMigrate: (() -> Unit)?,
|
||||||
onClickEditNotes: () -> Unit,
|
|
||||||
// SY -->
|
// SY -->
|
||||||
onClickEditInfo: (() -> Unit)?,
|
onClickEditInfo: (() -> Unit)?,
|
||||||
onClickRecommend: (() -> Unit)?,
|
onClickRecommend: (() -> Unit)?,
|
||||||
@ -48,29 +54,47 @@ fun MangaToolbar(
|
|||||||
|
|
||||||
// For action mode
|
// For action mode
|
||||||
actionModeCounter: Int,
|
actionModeCounter: Int,
|
||||||
onCancelActionMode: () -> Unit,
|
|
||||||
onSelectAll: () -> Unit,
|
onSelectAll: () -> Unit,
|
||||||
onInvertSelection: () -> Unit,
|
onInvertSelection: () -> Unit,
|
||||||
|
|
||||||
titleAlphaProvider: () -> Float,
|
|
||||||
backgroundAlphaProvider: () -> Float,
|
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
backgroundAlphaProvider: () -> Float = titleAlphaProvider,
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = modifier,
|
||||||
) {
|
) {
|
||||||
val isActionMode = actionModeCounter > 0
|
val isActionMode = actionModeCounter > 0
|
||||||
AppBar(
|
TopAppBar(
|
||||||
titleContent = {
|
title = {
|
||||||
if (isActionMode) {
|
Text(
|
||||||
AppBarTitle(actionModeCounter.toString())
|
text = if (isActionMode) actionModeCounter.toString() else title,
|
||||||
} else {
|
maxLines = 1,
|
||||||
AppBarTitle(title, modifier = Modifier.alpha(titleAlphaProvider()))
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
color = LocalContentColor.current.copy(alpha = if (isActionMode) 1f else titleAlphaProvider()),
|
||||||
|
)
|
||||||
|
},
|
||||||
|
navigationIcon = {
|
||||||
|
IconButton(onClick = onBackClicked) {
|
||||||
|
UpIcon(navigationIcon = Icons.Outlined.Close.takeIf { isActionMode })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
modifier = modifier,
|
|
||||||
backgroundColor = MaterialTheme.colorScheme
|
|
||||||
.surfaceColorAtElevation(3.dp)
|
|
||||||
.copy(alpha = if (isActionMode) 1f else backgroundAlphaProvider()),
|
|
||||||
navigateUp = navigateUp,
|
|
||||||
actions = {
|
actions = {
|
||||||
|
if (isActionMode) {
|
||||||
|
AppBarActions(
|
||||||
|
persistentListOf(
|
||||||
|
AppBar.Action(
|
||||||
|
title = stringResource(MR.strings.action_select_all),
|
||||||
|
icon = Icons.Outlined.SelectAll,
|
||||||
|
onClick = onSelectAll,
|
||||||
|
),
|
||||||
|
AppBar.Action(
|
||||||
|
title = stringResource(MR.strings.action_select_inverse),
|
||||||
|
icon = Icons.Outlined.FlipToBack,
|
||||||
|
onClick = onInvertSelection,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
var downloadExpanded by remember { mutableStateOf(false) }
|
var downloadExpanded by remember { mutableStateOf(false) }
|
||||||
if (onClickDownload != null) {
|
if (onClickDownload != null) {
|
||||||
val onDismissRequest = { downloadExpanded = false }
|
val onDismissRequest = { downloadExpanded = false }
|
||||||
@ -83,24 +107,8 @@ fun MangaToolbar(
|
|||||||
|
|
||||||
val filterTint = if (hasFilters) MaterialTheme.colorScheme.active else LocalContentColor.current
|
val filterTint = if (hasFilters) MaterialTheme.colorScheme.active else LocalContentColor.current
|
||||||
AppBarActions(
|
AppBarActions(
|
||||||
actions = persistentListOf<AppBar.AppBarAction>().builder().apply {
|
actions = persistentListOf<AppBar.AppBarAction>().builder()
|
||||||
if (isActionMode) {
|
.apply {
|
||||||
add(
|
|
||||||
AppBar.Action(
|
|
||||||
title = stringResource(MR.strings.action_select_all),
|
|
||||||
icon = Icons.Outlined.SelectAll,
|
|
||||||
onClick = onSelectAll,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
add(
|
|
||||||
AppBar.Action(
|
|
||||||
title = stringResource(MR.strings.action_select_inverse),
|
|
||||||
icon = Icons.Outlined.FlipToBack,
|
|
||||||
onClick = onInvertSelection,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
return@apply
|
|
||||||
}
|
|
||||||
if (onClickDownload != null) {
|
if (onClickDownload != null) {
|
||||||
add(
|
add(
|
||||||
AppBar.Action(
|
AppBar.Action(
|
||||||
@ -148,12 +156,6 @@ fun MangaToolbar(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
add(
|
|
||||||
AppBar.OverflowAction(
|
|
||||||
title = stringResource(MR.strings.action_notes),
|
|
||||||
onClick = onClickEditNotes,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
// SY -->
|
// SY -->
|
||||||
if (onClickMerge != null) {
|
if (onClickMerge != null) {
|
||||||
add(
|
add(
|
||||||
@ -191,8 +193,13 @@ fun MangaToolbar(
|
|||||||
}
|
}
|
||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
isActionMode = isActionMode,
|
colors = TopAppBarDefaults.topAppBarColors(
|
||||||
onCancelActionMode = onCancelActionMode,
|
containerColor = MaterialTheme.colorScheme
|
||||||
|
.surfaceColorAtElevation(3.dp)
|
||||||
|
.copy(alpha = if (isActionMode) 1f else backgroundAlphaProvider()),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -1,253 +0,0 @@
|
|||||||
package eu.kanade.presentation.manga.components
|
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.PaddingValues
|
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
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.ReadOnlyComposable
|
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.layout.FirstBaseline
|
|
||||||
import androidx.compose.ui.text.SpanStyle
|
|
||||||
import androidx.compose.ui.text.TextLinkStyles
|
|
||||||
import androidx.compose.ui.text.font.FontFamily
|
|
||||||
import androidx.compose.ui.text.font.FontStyle
|
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
|
||||||
import androidx.compose.ui.unit.Dp
|
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import com.mikepenz.markdown.coil3.Coil3ImageTransformerImpl
|
|
||||||
import com.mikepenz.markdown.compose.LocalBulletListHandler
|
|
||||||
import com.mikepenz.markdown.compose.Markdown
|
|
||||||
import com.mikepenz.markdown.compose.components.markdownComponents
|
|
||||||
import com.mikepenz.markdown.compose.elements.MarkdownBulletList
|
|
||||||
import com.mikepenz.markdown.compose.elements.MarkdownDivider
|
|
||||||
import com.mikepenz.markdown.compose.elements.MarkdownOrderedList
|
|
||||||
import com.mikepenz.markdown.compose.elements.MarkdownTable
|
|
||||||
import com.mikepenz.markdown.compose.elements.MarkdownTableHeader
|
|
||||||
import com.mikepenz.markdown.compose.elements.MarkdownTableRow
|
|
||||||
import com.mikepenz.markdown.compose.elements.MarkdownText
|
|
||||||
import com.mikepenz.markdown.compose.elements.listDepth
|
|
||||||
import com.mikepenz.markdown.model.DefaultMarkdownColors
|
|
||||||
import com.mikepenz.markdown.model.DefaultMarkdownTypography
|
|
||||||
import com.mikepenz.markdown.model.MarkdownAnnotator
|
|
||||||
import com.mikepenz.markdown.model.MarkdownColors
|
|
||||||
import com.mikepenz.markdown.model.MarkdownPadding
|
|
||||||
import com.mikepenz.markdown.model.MarkdownTypography
|
|
||||||
import com.mikepenz.markdown.model.markdownAnnotator
|
|
||||||
import com.mikepenz.markdown.model.rememberMarkdownState
|
|
||||||
import org.intellij.markdown.MarkdownTokenTypes.Companion.HTML_TAG
|
|
||||||
import org.intellij.markdown.flavours.MarkdownFlavourDescriptor
|
|
||||||
import org.intellij.markdown.flavours.commonmark.CommonMarkFlavourDescriptor
|
|
||||||
import org.intellij.markdown.flavours.commonmark.CommonMarkMarkerProcessor
|
|
||||||
import org.intellij.markdown.flavours.gfm.table.GitHubTableMarkerProvider
|
|
||||||
import org.intellij.markdown.parser.MarkerProcessor
|
|
||||||
import org.intellij.markdown.parser.MarkerProcessorFactory
|
|
||||||
import org.intellij.markdown.parser.ProductionHolder
|
|
||||||
import org.intellij.markdown.parser.constraints.CommonMarkdownConstraints
|
|
||||||
import org.intellij.markdown.parser.constraints.MarkdownConstraints
|
|
||||||
import org.intellij.markdown.parser.markerblocks.MarkerBlockProvider
|
|
||||||
import org.intellij.markdown.parser.markerblocks.providers.AtxHeaderProvider
|
|
||||||
import org.intellij.markdown.parser.markerblocks.providers.BlockQuoteProvider
|
|
||||||
import org.intellij.markdown.parser.markerblocks.providers.CodeBlockProvider
|
|
||||||
import org.intellij.markdown.parser.markerblocks.providers.CodeFenceProvider
|
|
||||||
import org.intellij.markdown.parser.markerblocks.providers.HorizontalRuleProvider
|
|
||||||
import org.intellij.markdown.parser.markerblocks.providers.ListMarkerProvider
|
|
||||||
import org.intellij.markdown.parser.markerblocks.providers.SetextHeaderProvider
|
|
||||||
import tachiyomi.presentation.core.components.material.padding
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun MarkdownRender(
|
|
||||||
content: String,
|
|
||||||
modifier: Modifier = Modifier,
|
|
||||||
flavour: MarkdownFlavourDescriptor = SimpleMarkdownFlavourDescriptor,
|
|
||||||
annotator: MarkdownAnnotator = remember { markdownAnnotator() },
|
|
||||||
) {
|
|
||||||
Markdown(
|
|
||||||
markdownState = rememberMarkdownState(
|
|
||||||
content = content,
|
|
||||||
flavour = flavour,
|
|
||||||
immediate = true,
|
|
||||||
),
|
|
||||||
annotator = annotator,
|
|
||||||
colors = getMarkdownColors(),
|
|
||||||
typography = getMarkdownTypography(),
|
|
||||||
padding = markdownPadding,
|
|
||||||
components = markdownComponents,
|
|
||||||
imageTransformer = Coil3ImageTransformerImpl,
|
|
||||||
modifier = modifier,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
@ReadOnlyComposable
|
|
||||||
private fun getMarkdownColors(): MarkdownColors {
|
|
||||||
val codeBackground = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.1f)
|
|
||||||
return DefaultMarkdownColors(
|
|
||||||
text = MaterialTheme.colorScheme.onSurface,
|
|
||||||
codeText = Color.Unspecified,
|
|
||||||
inlineCodeText = Color.Unspecified,
|
|
||||||
linkText = Color.Unspecified,
|
|
||||||
codeBackground = codeBackground,
|
|
||||||
inlineCodeBackground = codeBackground,
|
|
||||||
dividerColor = MaterialTheme.colorScheme.outlineVariant,
|
|
||||||
tableText = Color.Unspecified,
|
|
||||||
tableBackground = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.05f),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
@ReadOnlyComposable
|
|
||||||
private fun getMarkdownTypography(): MarkdownTypography {
|
|
||||||
val link = MaterialTheme.typography.bodyMedium.copy(
|
|
||||||
color = MaterialTheme.colorScheme.primary,
|
|
||||||
fontWeight = FontWeight.Bold,
|
|
||||||
)
|
|
||||||
return DefaultMarkdownTypography(
|
|
||||||
h1 = MaterialTheme.typography.headlineMedium,
|
|
||||||
h2 = MaterialTheme.typography.headlineSmall,
|
|
||||||
h3 = MaterialTheme.typography.titleLarge,
|
|
||||||
h4 = MaterialTheme.typography.titleMedium,
|
|
||||||
h5 = MaterialTheme.typography.titleSmall,
|
|
||||||
h6 = MaterialTheme.typography.bodyLarge,
|
|
||||||
text = MaterialTheme.typography.bodyMedium,
|
|
||||||
code = MaterialTheme.typography.bodyMedium.copy(fontFamily = FontFamily.Monospace),
|
|
||||||
inlineCode = MaterialTheme.typography.bodyMedium.copy(fontFamily = FontFamily.Monospace),
|
|
||||||
quote = MaterialTheme.typography.bodyMedium.plus(SpanStyle(fontStyle = FontStyle.Italic)),
|
|
||||||
paragraph = MaterialTheme.typography.bodyMedium,
|
|
||||||
ordered = MaterialTheme.typography.bodyMedium,
|
|
||||||
bullet = MaterialTheme.typography.bodyMedium,
|
|
||||||
list = MaterialTheme.typography.bodyMedium,
|
|
||||||
link = link,
|
|
||||||
textLink = TextLinkStyles(style = link.toSpanStyle()),
|
|
||||||
table = MaterialTheme.typography.bodyMedium,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private val markdownPadding = object : MarkdownPadding {
|
|
||||||
override val block: Dp = 2.dp
|
|
||||||
override val blockQuote: PaddingValues = PaddingValues(horizontal = 16.dp, vertical = 0.dp)
|
|
||||||
override val blockQuoteBar: PaddingValues.Absolute = PaddingValues.Absolute(
|
|
||||||
left = 4.dp,
|
|
||||||
top = 2.dp,
|
|
||||||
right = 4.dp,
|
|
||||||
bottom = 2.dp,
|
|
||||||
)
|
|
||||||
override val blockQuoteText: PaddingValues = PaddingValues(vertical = 4.dp)
|
|
||||||
override val codeBlock: PaddingValues = PaddingValues(8.dp)
|
|
||||||
override val list: Dp = 0.dp
|
|
||||||
override val listIndent: Dp = 8.dp
|
|
||||||
override val listItemBottom: Dp = 0.dp
|
|
||||||
override val listItemTop: Dp = 0.dp
|
|
||||||
}
|
|
||||||
|
|
||||||
private val markdownComponents = markdownComponents(
|
|
||||||
horizontalRule = {
|
|
||||||
MarkdownDivider(
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(vertical = MaterialTheme.padding.extraSmall)
|
|
||||||
.fillMaxWidth(),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
orderedList = { ol ->
|
|
||||||
Column(modifier = Modifier.padding(start = MaterialTheme.padding.small)) {
|
|
||||||
MarkdownOrderedList(
|
|
||||||
content = ol.content,
|
|
||||||
node = ol.node,
|
|
||||||
style = ol.typography.ordered,
|
|
||||||
depth = ol.listDepth,
|
|
||||||
markerModifier = { Modifier.alignBy(FirstBaseline) },
|
|
||||||
listModifier = { Modifier.alignBy(FirstBaseline) },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
unorderedList = { ul ->
|
|
||||||
val markers = listOf("•", "◦", "▸", "▹")
|
|
||||||
|
|
||||||
CompositionLocalProvider(
|
|
||||||
LocalBulletListHandler provides { _, _, _, _, _ -> "${markers[ul.listDepth % markers.size]} " },
|
|
||||||
) {
|
|
||||||
Column(modifier = Modifier.padding(start = MaterialTheme.padding.small)) {
|
|
||||||
MarkdownBulletList(
|
|
||||||
content = ul.content,
|
|
||||||
node = ul.node,
|
|
||||||
style = ul.typography.bullet,
|
|
||||||
markerModifier = { Modifier.alignBy(FirstBaseline) },
|
|
||||||
listModifier = { Modifier.alignBy(FirstBaseline) },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
table = { t ->
|
|
||||||
MarkdownTable(
|
|
||||||
content = t.content,
|
|
||||||
node = t.node,
|
|
||||||
style = t.typography.text,
|
|
||||||
headerBlock = { content, header, tableWidth, style ->
|
|
||||||
MarkdownTableHeader(
|
|
||||||
content = content,
|
|
||||||
header = header,
|
|
||||||
tableWidth = tableWidth,
|
|
||||||
style = style,
|
|
||||||
maxLines = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
rowBlock = { content, header, tableWidth, style ->
|
|
||||||
MarkdownTableRow(
|
|
||||||
content = content,
|
|
||||||
header = header,
|
|
||||||
tableWidth = tableWidth,
|
|
||||||
style = style,
|
|
||||||
maxLines = Int.MAX_VALUE,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
},
|
|
||||||
custom = { type, model ->
|
|
||||||
if (type in DISALLOWED_MARKDOWN_TYPES) {
|
|
||||||
MarkdownText(
|
|
||||||
content = model.content.substring(model.node.startOffset, model.node.endOffset),
|
|
||||||
style = model.typography.text,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
private object SimpleMarkdownFlavourDescriptor : CommonMarkFlavourDescriptor() {
|
|
||||||
override val markerProcessorFactory: MarkerProcessorFactory = SimpleMarkdownProcessFactory
|
|
||||||
}
|
|
||||||
|
|
||||||
private object SimpleMarkdownProcessFactory : MarkerProcessorFactory {
|
|
||||||
override fun createMarkerProcessor(productionHolder: ProductionHolder): MarkerProcessor<*> {
|
|
||||||
return SimpleMarkdownMarkerProcessor(productionHolder, CommonMarkdownConstraints.BASE)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Like `CommonMarkFlavour`, but with html blocks and reference links removed and
|
|
||||||
* table support added
|
|
||||||
*/
|
|
||||||
private class SimpleMarkdownMarkerProcessor(
|
|
||||||
productionHolder: ProductionHolder,
|
|
||||||
constraints: MarkdownConstraints,
|
|
||||||
) : CommonMarkMarkerProcessor(productionHolder, constraints) {
|
|
||||||
private val markerBlockProviders = listOf(
|
|
||||||
CodeBlockProvider(),
|
|
||||||
HorizontalRuleProvider(),
|
|
||||||
CodeFenceProvider(),
|
|
||||||
SetextHeaderProvider(),
|
|
||||||
BlockQuoteProvider(),
|
|
||||||
ListMarkerProvider(),
|
|
||||||
AtxHeaderProvider(),
|
|
||||||
GitHubTableMarkerProvider(),
|
|
||||||
)
|
|
||||||
|
|
||||||
override fun getMarkerBlockProviders(): List<MarkerBlockProvider<StateInfo>> {
|
|
||||||
return markerBlockProviders
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val DISALLOWED_MARKDOWN_TYPES = arrayOf(HTML_TAG)
|
|
@ -1,6 +1,13 @@
|
|||||||
package eu.kanade.presentation.more
|
package eu.kanade.presentation.more
|
||||||
|
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
|
import androidx.compose.foundation.layout.WindowInsetsSides
|
||||||
|
import androidx.compose.foundation.layout.only
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.systemBars
|
||||||
|
import androidx.compose.foundation.layout.windowInsetsPadding
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.outlined.HelpOutline
|
import androidx.compose.material.icons.automirrored.outlined.HelpOutline
|
||||||
import androidx.compose.material.icons.automirrored.outlined.Label
|
import androidx.compose.material.icons.automirrored.outlined.Label
|
||||||
@ -22,6 +29,7 @@ import androidx.compose.ui.Modifier
|
|||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.platform.LocalUriHandler
|
import androidx.compose.ui.platform.LocalUriHandler
|
||||||
import androidx.compose.ui.res.vectorResource
|
import androidx.compose.ui.res.vectorResource
|
||||||
|
import eu.kanade.presentation.components.WarningBanner
|
||||||
import eu.kanade.presentation.more.settings.widget.SwitchPreferenceWidget
|
import eu.kanade.presentation.more.settings.widget.SwitchPreferenceWidget
|
||||||
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
|
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
@ -41,6 +49,7 @@ fun MoreScreen(
|
|||||||
onDownloadedOnlyChange: (Boolean) -> Unit,
|
onDownloadedOnlyChange: (Boolean) -> Unit,
|
||||||
incognitoMode: Boolean,
|
incognitoMode: Boolean,
|
||||||
onIncognitoModeChange: (Boolean) -> Unit,
|
onIncognitoModeChange: (Boolean) -> Unit,
|
||||||
|
isFDroid: Boolean,
|
||||||
// SY -->
|
// SY -->
|
||||||
showNavUpdates: Boolean,
|
showNavUpdates: Boolean,
|
||||||
showNavHistory: Boolean,
|
showNavHistory: Boolean,
|
||||||
@ -57,7 +66,26 @@ fun MoreScreen(
|
|||||||
) {
|
) {
|
||||||
val uriHandler = LocalUriHandler.current
|
val uriHandler = LocalUriHandler.current
|
||||||
|
|
||||||
Scaffold { contentPadding ->
|
Scaffold(
|
||||||
|
topBar = {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.windowInsetsPadding(
|
||||||
|
WindowInsets.systemBars.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
|
||||||
|
),
|
||||||
|
) {
|
||||||
|
if (isFDroid) {
|
||||||
|
WarningBanner(
|
||||||
|
textRes = MR.strings.fdroid_warning,
|
||||||
|
modifier = Modifier.clickable {
|
||||||
|
uriHandler.openUri(
|
||||||
|
"https://mihon.app/docs/faq/general#how-do-i-update-from-the-f-droid-builds",
|
||||||
|
)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
) { contentPadding ->
|
||||||
ScrollbarLazyColumn(
|
ScrollbarLazyColumn(
|
||||||
modifier = Modifier.padding(contentPadding),
|
modifier = Modifier.padding(contentPadding),
|
||||||
) {
|
) {
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package eu.kanade.presentation.more
|
package eu.kanade.presentation.more
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
@ -14,10 +13,13 @@ import androidx.compose.material3.Text
|
|||||||
import androidx.compose.material3.TextButton
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.text.SpanStyle
|
||||||
import androidx.compose.ui.tooling.preview.PreviewLightDark
|
import androidx.compose.ui.tooling.preview.PreviewLightDark
|
||||||
import eu.kanade.presentation.manga.components.MarkdownRender
|
import com.halilibo.richtext.markdown.Markdown
|
||||||
|
import com.halilibo.richtext.ui.RichTextStyle
|
||||||
|
import com.halilibo.richtext.ui.material3.RichText
|
||||||
|
import com.halilibo.richtext.ui.string.RichTextStringStyle
|
||||||
import eu.kanade.presentation.theme.TachiyomiPreviewTheme
|
import eu.kanade.presentation.theme.TachiyomiPreviewTheme
|
||||||
import org.intellij.markdown.flavours.gfm.GFMFlavourDescriptor
|
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import tachiyomi.presentation.core.components.material.padding
|
import tachiyomi.presentation.core.components.material.padding
|
||||||
import tachiyomi.presentation.core.i18n.stringResource
|
import tachiyomi.presentation.core.i18n.stringResource
|
||||||
@ -40,15 +42,17 @@ fun NewUpdateScreen(
|
|||||||
rejectText = stringResource(MR.strings.action_not_now),
|
rejectText = stringResource(MR.strings.action_not_now),
|
||||||
onRejectClick = onRejectUpdate,
|
onRejectClick = onRejectUpdate,
|
||||||
) {
|
) {
|
||||||
Column(
|
RichText(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(vertical = MaterialTheme.padding.large),
|
.padding(vertical = MaterialTheme.padding.large),
|
||||||
|
style = RichTextStyle(
|
||||||
|
stringStyle = RichTextStringStyle(
|
||||||
|
linkStyle = SpanStyle(color = MaterialTheme.colorScheme.primary),
|
||||||
|
),
|
||||||
|
),
|
||||||
) {
|
) {
|
||||||
MarkdownRender(
|
Markdown(content = changelogInfo)
|
||||||
content = changelogInfo,
|
|
||||||
flavour = GFMFlavourDescriptor(),
|
|
||||||
)
|
|
||||||
|
|
||||||
TextButton(
|
TextButton(
|
||||||
onClick = onOpenInBrowser,
|
onClick = onOpenInBrowser,
|
||||||
|
@ -42,9 +42,7 @@ fun OnboardingScreen(
|
|||||||
}
|
}
|
||||||
val isLastStep = currentStep == steps.lastIndex
|
val isLastStep = currentStep == steps.lastIndex
|
||||||
|
|
||||||
BackHandler(enabled = currentStep != 0) {
|
BackHandler(enabled = currentStep != 0, onBack = { currentStep-- })
|
||||||
currentStep--
|
|
||||||
}
|
|
||||||
|
|
||||||
InfoScreen(
|
InfoScreen(
|
||||||
icon = Icons.Outlined.RocketLaunch,
|
icon = Icons.Outlined.RocketLaunch,
|
||||||
|
@ -4,6 +4,7 @@ import android.Manifest
|
|||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
@ -31,7 +32,6 @@ import androidx.compose.ui.graphics.Color
|
|||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import androidx.core.net.toUri
|
|
||||||
import androidx.lifecycle.DefaultLifecycleObserver
|
import androidx.lifecycle.DefaultLifecycleObserver
|
||||||
import androidx.lifecycle.LifecycleOwner
|
import androidx.lifecycle.LifecycleOwner
|
||||||
import androidx.lifecycle.compose.LocalLifecycleOwner
|
import androidx.lifecycle.compose.LocalLifecycleOwner
|
||||||
@ -111,7 +111,7 @@ internal class PermissionStep : OnboardingStep {
|
|||||||
onButtonClick = {
|
onButtonClick = {
|
||||||
@SuppressLint("BatteryLife")
|
@SuppressLint("BatteryLife")
|
||||||
val intent = Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS).apply {
|
val intent = Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS).apply {
|
||||||
data = "package:${context.packageName}".toUri()
|
data = Uri.parse("package:${context.packageName}")
|
||||||
}
|
}
|
||||||
context.startActivity(intent)
|
context.startActivity(intent)
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package eu.kanade.presentation.more.settings
|
package eu.kanade.presentation.more.settings
|
||||||
|
|
||||||
import androidx.annotation.IntRange
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
@ -21,7 +20,7 @@ sealed class Preference {
|
|||||||
|
|
||||||
// SY <--
|
// SY <--
|
||||||
abstract val icon: ImageVector?
|
abstract val icon: ImageVector?
|
||||||
abstract val onValueChanged: suspend (value: T) -> Boolean
|
abstract val onValueChanged: suspend (newValue: T) -> Boolean
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A basic [PreferenceItem] that only displays texts.
|
* A basic [PreferenceItem] that only displays texts.
|
||||||
@ -29,58 +28,57 @@ sealed class Preference {
|
|||||||
data class TextPreference(
|
data class TextPreference(
|
||||||
override val title: String,
|
override val title: String,
|
||||||
override val subtitle: CharSequence? = null,
|
override val subtitle: CharSequence? = null,
|
||||||
|
override val icon: ImageVector? = null,
|
||||||
override val enabled: Boolean = true,
|
override val enabled: Boolean = true,
|
||||||
|
override val onValueChanged: suspend (newValue: String) -> Boolean = { true },
|
||||||
|
|
||||||
val onClick: (() -> Unit)? = null,
|
val onClick: (() -> Unit)? = null,
|
||||||
) : PreferenceItem<String>() {
|
) : PreferenceItem<String>()
|
||||||
override val icon: ImageVector? = null
|
|
||||||
override val onValueChanged: suspend (value: String) -> Boolean = { true }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A [PreferenceItem] that provides a two-state toggleable option.
|
* A [PreferenceItem] that provides a two-state toggleable option.
|
||||||
*/
|
*/
|
||||||
data class SwitchPreference(
|
data class SwitchPreference(
|
||||||
val preference: PreferenceData<Boolean>,
|
val pref: PreferenceData<Boolean>,
|
||||||
override val title: String,
|
override val title: String,
|
||||||
override val subtitle: CharSequence? = null,
|
override val subtitle: CharSequence? = null,
|
||||||
|
override val icon: ImageVector? = null,
|
||||||
override val enabled: Boolean = true,
|
override val enabled: Boolean = true,
|
||||||
override val onValueChanged: suspend (value: Boolean) -> Boolean = { true },
|
override val onValueChanged: suspend (newValue: Boolean) -> Boolean = { true },
|
||||||
) : PreferenceItem<Boolean>() {
|
) : PreferenceItem<Boolean>()
|
||||||
override val icon: ImageVector? = null
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A [PreferenceItem] that provides a slider to select an integer number.
|
* A [PreferenceItem] that provides a slider to select an integer number.
|
||||||
*/
|
*/
|
||||||
data class SliderPreference(
|
data class SliderPreference(
|
||||||
val value: Int,
|
val value: Int,
|
||||||
override val title: String,
|
val min: Int = 0,
|
||||||
val valueRange: IntProgression = 0..1,
|
val max: Int,
|
||||||
@IntRange(from = 0) val steps: Int = with(valueRange) { (last - first) - 1 },
|
override val title: String = "",
|
||||||
override val subtitle: String? = null,
|
override val subtitle: String? = null,
|
||||||
|
override val icon: ImageVector? = null,
|
||||||
override val enabled: Boolean = true,
|
override val enabled: Boolean = true,
|
||||||
override val onValueChanged: suspend (value: Int) -> Boolean = { true },
|
override val onValueChanged: suspend (newValue: Int) -> Boolean = { true },
|
||||||
) : PreferenceItem<Int>() {
|
) : PreferenceItem<Int>()
|
||||||
override val icon: ImageVector? = null
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A [PreferenceItem] that displays a list of entries as a dialog.
|
* A [PreferenceItem] that displays a list of entries as a dialog.
|
||||||
*/
|
*/
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
data class ListPreference<T>(
|
data class ListPreference<T>(
|
||||||
val preference: PreferenceData<T>,
|
val pref: PreferenceData<T>,
|
||||||
val entries: ImmutableMap<T, String>,
|
|
||||||
override val title: String,
|
override val title: String,
|
||||||
override val subtitle: String? = "%s",
|
override val subtitle: String? = "%s",
|
||||||
val subtitleProvider: @Composable (value: T, entries: ImmutableMap<T, String>) -> String? =
|
val subtitleProvider: @Composable (value: T, entries: ImmutableMap<T, String>) -> String? =
|
||||||
{ v, e -> subtitle?.format(e[v]) },
|
{ v, e -> subtitle?.format(e[v]) },
|
||||||
override val icon: ImageVector? = null,
|
override val icon: ImageVector? = null,
|
||||||
override val enabled: Boolean = true,
|
override val enabled: Boolean = true,
|
||||||
override val onValueChanged: suspend (value: T) -> Boolean = { true },
|
override val onValueChanged: suspend (newValue: T) -> Boolean = { true },
|
||||||
|
|
||||||
|
val entries: ImmutableMap<T, String>,
|
||||||
) : PreferenceItem<T>() {
|
) : PreferenceItem<T>() {
|
||||||
internal fun internalSet(value: Any) = preference.set(value as T)
|
internal fun internalSet(newValue: Any) = pref.set(newValue as T)
|
||||||
internal suspend fun internalOnValueChanged(value: Any) = onValueChanged(value as T)
|
internal suspend fun internalOnValueChanged(newValue: Any) = onValueChanged(newValue as T)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun internalSubtitleProvider(value: Any?, entries: ImmutableMap<out Any?, String>) =
|
internal fun internalSubtitleProvider(value: Any?, entries: ImmutableMap<out Any?, String>) =
|
||||||
@ -92,14 +90,15 @@ sealed class Preference {
|
|||||||
*/
|
*/
|
||||||
data class BasicListPreference(
|
data class BasicListPreference(
|
||||||
val value: String,
|
val value: String,
|
||||||
val entries: ImmutableMap<String, String>,
|
|
||||||
override val title: String,
|
override val title: String,
|
||||||
override val subtitle: String? = "%s",
|
override val subtitle: String? = "%s",
|
||||||
val subtitleProvider: @Composable (value: String, entries: ImmutableMap<String, String>) -> String? =
|
val subtitleProvider: @Composable (value: String, entries: ImmutableMap<String, String>) -> String? =
|
||||||
{ v, e -> subtitle?.format(e[v]) },
|
{ v, e -> subtitle?.format(e[v]) },
|
||||||
override val icon: ImageVector? = null,
|
override val icon: ImageVector? = null,
|
||||||
override val enabled: Boolean = true,
|
override val enabled: Boolean = true,
|
||||||
override val onValueChanged: suspend (value: String) -> Boolean = { true },
|
override val onValueChanged: suspend (newValue: String) -> Boolean = { true },
|
||||||
|
|
||||||
|
val entries: ImmutableMap<String, String>,
|
||||||
) : PreferenceItem<String>()
|
) : PreferenceItem<String>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,51 +106,52 @@ sealed class Preference {
|
|||||||
* Multiple entries can be selected at the same time.
|
* Multiple entries can be selected at the same time.
|
||||||
*/
|
*/
|
||||||
data class MultiSelectListPreference(
|
data class MultiSelectListPreference(
|
||||||
val preference: PreferenceData<Set<String>>,
|
val pref: PreferenceData<Set<String>>,
|
||||||
val entries: ImmutableMap<String, String>,
|
|
||||||
override val title: String,
|
override val title: String,
|
||||||
override val subtitle: String? = "%s",
|
override val subtitle: String? = "%s",
|
||||||
val subtitleProvider: @Composable (value: Set<String>, entries: ImmutableMap<String, String>) -> String? =
|
val subtitleProvider: @Composable (
|
||||||
{ v, e ->
|
value: Set<String>,
|
||||||
val combined = remember(v, e) {
|
entries: ImmutableMap<String, String>,
|
||||||
v.mapNotNull { e[it] }
|
) -> String? = { v, e ->
|
||||||
.joinToString()
|
val combined = remember(v) {
|
||||||
.takeUnless { it.isBlank() }
|
v.map { e[it] }
|
||||||
}
|
.takeIf { it.isNotEmpty() }
|
||||||
?: stringResource(MR.strings.none)
|
?.joinToString()
|
||||||
|
} ?: stringResource(MR.strings.none)
|
||||||
subtitle?.format(combined)
|
subtitle?.format(combined)
|
||||||
},
|
},
|
||||||
override val icon: ImageVector? = null,
|
override val icon: ImageVector? = null,
|
||||||
override val enabled: Boolean = true,
|
override val enabled: Boolean = true,
|
||||||
override val onValueChanged: suspend (value: Set<String>) -> Boolean = { true },
|
override val onValueChanged: suspend (newValue: Set<String>) -> Boolean = { true },
|
||||||
|
|
||||||
|
val entries: ImmutableMap<String, String>,
|
||||||
) : PreferenceItem<Set<String>>()
|
) : PreferenceItem<Set<String>>()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A [PreferenceItem] that shows a EditText in the dialog.
|
* A [PreferenceItem] that shows a EditText in the dialog.
|
||||||
*/
|
*/
|
||||||
data class EditTextPreference(
|
data class EditTextPreference(
|
||||||
val preference: PreferenceData<String>,
|
val pref: PreferenceData<String>,
|
||||||
override val title: String,
|
override val title: String,
|
||||||
override val subtitle: String? = "%s",
|
override val subtitle: String? = "%s",
|
||||||
|
override val icon: ImageVector? = null,
|
||||||
override val enabled: Boolean = true,
|
override val enabled: Boolean = true,
|
||||||
override val onValueChanged: suspend (value: String) -> Boolean = { true },
|
override val onValueChanged: suspend (newValue: String) -> Boolean = { true },
|
||||||
) : PreferenceItem<String>() {
|
) : PreferenceItem<String>()
|
||||||
override val icon: ImageVector? = null
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A [PreferenceItem] for individual tracker.
|
* A [PreferenceItem] for individual tracker.
|
||||||
*/
|
*/
|
||||||
data class TrackerPreference(
|
data class TrackerPreference(
|
||||||
val tracker: Tracker,
|
val tracker: Tracker,
|
||||||
|
override val title: String,
|
||||||
val login: () -> Unit,
|
val login: () -> Unit,
|
||||||
val logout: () -> Unit,
|
val logout: () -> Unit,
|
||||||
) : PreferenceItem<String>() {
|
) : PreferenceItem<String>() {
|
||||||
override val title: String = ""
|
|
||||||
override val enabled: Boolean = true
|
override val enabled: Boolean = true
|
||||||
override val subtitle: String? = null
|
override val subtitle: String? = null
|
||||||
override val icon: ImageVector? = null
|
override val icon: ImageVector? = null
|
||||||
override val onValueChanged: suspend (value: String) -> Boolean = { true }
|
override val onValueChanged: suspend (newValue: String) -> Boolean = { true }
|
||||||
}
|
}
|
||||||
|
|
||||||
data class InfoPreference(
|
data class InfoPreference(
|
||||||
@ -160,7 +160,7 @@ sealed class Preference {
|
|||||||
override val enabled: Boolean = true
|
override val enabled: Boolean = true
|
||||||
override val subtitle: String? = null
|
override val subtitle: String? = null
|
||||||
override val icon: ImageVector? = null
|
override val icon: ImageVector? = null
|
||||||
override val onValueChanged: suspend (value: String) -> Boolean = { true }
|
override val onValueChanged: suspend (newValue: String) -> Boolean = { true }
|
||||||
}
|
}
|
||||||
|
|
||||||
data class CustomPreference(
|
data class CustomPreference(
|
||||||
@ -170,7 +170,7 @@ sealed class Preference {
|
|||||||
override val enabled: Boolean = true
|
override val enabled: Boolean = true
|
||||||
override val subtitle: String? = null
|
override val subtitle: String? = null
|
||||||
override val icon: ImageVector? = null
|
override val icon: ImageVector? = null
|
||||||
override val onValueChanged: suspend (value: Unit) -> Boolean = { true }
|
override val onValueChanged: suspend (newValue: Unit) -> Boolean = { true }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,8 +5,6 @@ import androidx.compose.animation.expandVertically
|
|||||||
import androidx.compose.animation.fadeIn
|
import androidx.compose.animation.fadeIn
|
||||||
import androidx.compose.animation.fadeOut
|
import androidx.compose.animation.fadeOut
|
||||||
import androidx.compose.animation.shrinkVertically
|
import androidx.compose.animation.shrinkVertically
|
||||||
import androidx.compose.foundation.layout.padding
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.CompositionLocalProvider
|
import androidx.compose.runtime.CompositionLocalProvider
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
@ -14,20 +12,16 @@ import androidx.compose.runtime.compositionLocalOf
|
|||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.structuralEqualityPolicy
|
import androidx.compose.runtime.structuralEqualityPolicy
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import eu.kanade.presentation.more.settings.widget.EditTextPreferenceWidget
|
import eu.kanade.presentation.more.settings.widget.EditTextPreferenceWidget
|
||||||
import eu.kanade.presentation.more.settings.widget.InfoWidget
|
import eu.kanade.presentation.more.settings.widget.InfoWidget
|
||||||
import eu.kanade.presentation.more.settings.widget.ListPreferenceWidget
|
import eu.kanade.presentation.more.settings.widget.ListPreferenceWidget
|
||||||
import eu.kanade.presentation.more.settings.widget.MultiSelectListPreferenceWidget
|
import eu.kanade.presentation.more.settings.widget.MultiSelectListPreferenceWidget
|
||||||
import eu.kanade.presentation.more.settings.widget.PrefsHorizontalPadding
|
|
||||||
import eu.kanade.presentation.more.settings.widget.PrefsVerticalPadding
|
|
||||||
import eu.kanade.presentation.more.settings.widget.SwitchPreferenceWidget
|
import eu.kanade.presentation.more.settings.widget.SwitchPreferenceWidget
|
||||||
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
|
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.presentation.more.settings.widget.TrackingPreferenceWidget
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import tachiyomi.presentation.core.components.BaseSliderItem
|
import tachiyomi.presentation.core.components.SliderItem
|
||||||
import tachiyomi.presentation.core.util.collectAsState
|
import tachiyomi.presentation.core.util.collectAsState
|
||||||
|
|
||||||
val LocalPreferenceHighlighted = compositionLocalOf(structuralEqualityPolicy()) { false }
|
val LocalPreferenceHighlighted = compositionLocalOf(structuralEqualityPolicy()) { false }
|
||||||
@ -66,7 +60,7 @@ internal fun PreferenceItem(
|
|||||||
) {
|
) {
|
||||||
when (item) {
|
when (item) {
|
||||||
is Preference.PreferenceItem.SwitchPreference -> {
|
is Preference.PreferenceItem.SwitchPreference -> {
|
||||||
val value by item.preference.collectAsState()
|
val value by item.pref.collectAsState()
|
||||||
SwitchPreferenceWidget(
|
SwitchPreferenceWidget(
|
||||||
title = item.title,
|
title = item.title,
|
||||||
subtitle = item.subtitle,
|
subtitle = item.subtitle,
|
||||||
@ -75,33 +69,29 @@ internal fun PreferenceItem(
|
|||||||
onCheckedChanged = { newValue ->
|
onCheckedChanged = { newValue ->
|
||||||
scope.launch {
|
scope.launch {
|
||||||
if (item.onValueChanged(newValue)) {
|
if (item.onValueChanged(newValue)) {
|
||||||
item.preference.set(newValue)
|
item.pref.set(newValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is Preference.PreferenceItem.SliderPreference -> {
|
is Preference.PreferenceItem.SliderPreference -> {
|
||||||
BaseSliderItem(
|
// TODO: use different composable?
|
||||||
|
SliderItem(
|
||||||
label = item.title,
|
label = item.title,
|
||||||
|
min = item.min,
|
||||||
|
max = item.max,
|
||||||
value = item.value,
|
value = item.value,
|
||||||
valueRange = item.valueRange,
|
|
||||||
valueText = item.subtitle.takeUnless { it.isNullOrEmpty() } ?: item.value.toString(),
|
valueText = item.subtitle.takeUnless { it.isNullOrEmpty() } ?: item.value.toString(),
|
||||||
steps = item.steps,
|
|
||||||
labelStyle = MaterialTheme.typography.titleLarge.copy(fontSize = TitleFontSize),
|
|
||||||
onChange = {
|
onChange = {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
item.onValueChanged(it)
|
item.onValueChanged(it)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
modifier = Modifier.padding(
|
|
||||||
horizontal = PrefsHorizontalPadding,
|
|
||||||
vertical = PrefsVerticalPadding,
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is Preference.PreferenceItem.ListPreference<*> -> {
|
is Preference.PreferenceItem.ListPreference<*> -> {
|
||||||
val value by item.preference.collectAsState()
|
val value by item.pref.collectAsState()
|
||||||
ListPreferenceWidget(
|
ListPreferenceWidget(
|
||||||
value = value,
|
value = value,
|
||||||
title = item.title,
|
title = item.title,
|
||||||
@ -128,14 +118,14 @@ internal fun PreferenceItem(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
is Preference.PreferenceItem.MultiSelectListPreference -> {
|
is Preference.PreferenceItem.MultiSelectListPreference -> {
|
||||||
val values by item.preference.collectAsState()
|
val values by item.pref.collectAsState()
|
||||||
MultiSelectListPreferenceWidget(
|
MultiSelectListPreferenceWidget(
|
||||||
preference = item,
|
preference = item,
|
||||||
values = values,
|
values = values,
|
||||||
onValuesChange = { newValues ->
|
onValuesChange = { newValues ->
|
||||||
scope.launch {
|
scope.launch {
|
||||||
if (item.onValueChanged(newValues)) {
|
if (item.onValueChanged(newValues)) {
|
||||||
item.preference.set(newValues.toMutableSet())
|
item.pref.set(newValues.toMutableSet())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -150,7 +140,7 @@ internal fun PreferenceItem(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
is Preference.PreferenceItem.EditTextPreference -> {
|
is Preference.PreferenceItem.EditTextPreference -> {
|
||||||
val values by item.preference.collectAsState()
|
val values by item.pref.collectAsState()
|
||||||
EditTextPreferenceWidget(
|
EditTextPreferenceWidget(
|
||||||
title = item.title,
|
title = item.title,
|
||||||
subtitle = item.subtitle,
|
subtitle = item.subtitle,
|
||||||
@ -158,7 +148,7 @@ internal fun PreferenceItem(
|
|||||||
value = values,
|
value = values,
|
||||||
onConfirm = {
|
onConfirm = {
|
||||||
val accepted = item.onValueChanged(it)
|
val accepted = item.onValueChanged(it)
|
||||||
if (accepted) item.preference.set(it)
|
if (accepted) item.pref.set(it)
|
||||||
accepted
|
accepted
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -13,13 +13,13 @@ import androidx.compose.ui.platform.LocalContext
|
|||||||
import androidx.compose.ui.window.DialogProperties
|
import androidx.compose.ui.window.DialogProperties
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import exh.log.xLogE
|
import exh.log.xLogE
|
||||||
import exh.source.ExhPreferences
|
|
||||||
import exh.uconfig.EHConfigurator
|
import exh.uconfig.EHConfigurator
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.NonCancellable
|
import kotlinx.coroutines.NonCancellable
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import tachiyomi.core.common.util.lang.launchUI
|
import tachiyomi.core.common.util.lang.launchUI
|
||||||
|
import tachiyomi.domain.UnsortedPreferences
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import tachiyomi.i18n.sy.SYMR
|
import tachiyomi.i18n.sy.SYMR
|
||||||
import tachiyomi.presentation.core.i18n.stringResource
|
import tachiyomi.presentation.core.i18n.stringResource
|
||||||
@ -29,8 +29,8 @@ import kotlin.time.Duration.Companion.seconds
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ConfigureExhDialog(run: Boolean, onRunning: () -> Unit) {
|
fun ConfigureExhDialog(run: Boolean, onRunning: () -> Unit) {
|
||||||
val exhPreferences = remember {
|
val unsortedPreferences = remember {
|
||||||
Injekt.get<ExhPreferences>()
|
Injekt.get<UnsortedPreferences>()
|
||||||
}
|
}
|
||||||
var warnDialogOpen by remember { mutableStateOf(false) }
|
var warnDialogOpen by remember { mutableStateOf(false) }
|
||||||
var configureDialogOpen by remember { mutableStateOf(false) }
|
var configureDialogOpen by remember { mutableStateOf(false) }
|
||||||
@ -38,7 +38,7 @@ fun ConfigureExhDialog(run: Boolean, onRunning: () -> Unit) {
|
|||||||
|
|
||||||
LaunchedEffect(run) {
|
LaunchedEffect(run) {
|
||||||
if (run) {
|
if (run) {
|
||||||
if (exhPreferences.exhShowSettingsUploadWarning().get()) {
|
if (unsortedPreferences.exhShowSettingsUploadWarning().get()) {
|
||||||
warnDialogOpen = true
|
warnDialogOpen = true
|
||||||
} else {
|
} else {
|
||||||
configureDialogOpen = true
|
configureDialogOpen = true
|
||||||
@ -57,7 +57,7 @@ fun ConfigureExhDialog(run: Boolean, onRunning: () -> Unit) {
|
|||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton(
|
TextButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
exhPreferences.exhShowSettingsUploadWarning().set(false)
|
unsortedPreferences.exhShowSettingsUploadWarning().set(false)
|
||||||
configureDialogOpen = true
|
configureDialogOpen = true
|
||||||
warnDialogOpen = false
|
warnDialogOpen = false
|
||||||
},
|
},
|
||||||
|
@ -72,7 +72,6 @@ import exh.pref.DelegateSourcePreferences
|
|||||||
import exh.source.BlacklistedSources
|
import exh.source.BlacklistedSources
|
||||||
import exh.source.EH_SOURCE_ID
|
import exh.source.EH_SOURCE_ID
|
||||||
import exh.source.EXH_SOURCE_ID
|
import exh.source.EXH_SOURCE_ID
|
||||||
import exh.source.ExhPreferences
|
|
||||||
import exh.util.toAnnotatedString
|
import exh.util.toAnnotatedString
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import kotlinx.collections.immutable.persistentMapOf
|
import kotlinx.collections.immutable.persistentMapOf
|
||||||
@ -87,8 +86,8 @@ import tachiyomi.core.common.util.lang.launchNonCancellable
|
|||||||
import tachiyomi.core.common.util.lang.withUIContext
|
import tachiyomi.core.common.util.lang.withUIContext
|
||||||
import tachiyomi.core.common.util.system.ImageUtil
|
import tachiyomi.core.common.util.system.ImageUtil
|
||||||
import tachiyomi.core.common.util.system.logcat
|
import tachiyomi.core.common.util.system.logcat
|
||||||
|
import tachiyomi.domain.UnsortedPreferences
|
||||||
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
||||||
import tachiyomi.domain.library.service.LibraryPreferences
|
|
||||||
import tachiyomi.domain.manga.interactor.GetAllManga
|
import tachiyomi.domain.manga.interactor.GetAllManga
|
||||||
import tachiyomi.domain.manga.interactor.ResetViewerFlags
|
import tachiyomi.domain.manga.interactor.ResetViewerFlags
|
||||||
import tachiyomi.domain.source.service.SourceManager
|
import tachiyomi.domain.source.service.SourceManager
|
||||||
@ -115,7 +114,6 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
|
|
||||||
val basePreferences = remember { Injekt.get<BasePreferences>() }
|
val basePreferences = remember { Injekt.get<BasePreferences>() }
|
||||||
val networkPreferences = remember { Injekt.get<NetworkPreferences>() }
|
val networkPreferences = remember { Injekt.get<NetworkPreferences>() }
|
||||||
val libraryPreferences = remember { Injekt.get<LibraryPreferences>() }
|
|
||||||
|
|
||||||
return listOf(
|
return listOf(
|
||||||
Preference.PreferenceItem.TextPreference(
|
Preference.PreferenceItem.TextPreference(
|
||||||
@ -128,7 +126,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
/* SY --> Preference.PreferenceItem.SwitchPreference(
|
/* SY --> Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = networkPreferences.verboseLogging(),
|
pref = networkPreferences.verboseLogging(),
|
||||||
title = stringResource(MR.strings.pref_verbose_logging),
|
title = stringResource(MR.strings.pref_verbose_logging),
|
||||||
subtitle = stringResource(MR.strings.pref_verbose_logging_summary),
|
subtitle = stringResource(MR.strings.pref_verbose_logging_summary),
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
@ -156,7 +154,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
getBackgroundActivityGroup(),
|
getBackgroundActivityGroup(),
|
||||||
getDataGroup(),
|
getDataGroup(),
|
||||||
getNetworkGroup(networkPreferences = networkPreferences),
|
getNetworkGroup(networkPreferences = networkPreferences),
|
||||||
getLibraryGroup(libraryPreferences = libraryPreferences),
|
getLibraryGroup(),
|
||||||
getReaderGroup(basePreferences = basePreferences),
|
getReaderGroup(basePreferences = basePreferences),
|
||||||
getExtensionsGroup(basePreferences = basePreferences),
|
getExtensionsGroup(basePreferences = basePreferences),
|
||||||
// SY -->
|
// SY -->
|
||||||
@ -274,7 +272,8 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = networkPreferences.dohProvider(),
|
pref = networkPreferences.dohProvider(),
|
||||||
|
title = stringResource(MR.strings.pref_dns_over_https),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
-1 to stringResource(MR.strings.disabled),
|
-1 to stringResource(MR.strings.disabled),
|
||||||
PREF_DOH_CLOUDFLARE to "Cloudflare",
|
PREF_DOH_CLOUDFLARE to "Cloudflare",
|
||||||
@ -290,14 +289,13 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
PREF_DOH_NJALLA to "Njalla",
|
PREF_DOH_NJALLA to "Njalla",
|
||||||
PREF_DOH_SHECAN to "Shecan",
|
PREF_DOH_SHECAN to "Shecan",
|
||||||
),
|
),
|
||||||
title = stringResource(MR.strings.pref_dns_over_https),
|
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
context.toast(MR.strings.requires_app_restart)
|
context.toast(MR.strings.requires_app_restart)
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.EditTextPreference(
|
Preference.PreferenceItem.EditTextPreference(
|
||||||
preference = userAgentPref,
|
pref = userAgentPref,
|
||||||
title = stringResource(MR.strings.pref_user_agent_string),
|
title = stringResource(MR.strings.pref_user_agent_string),
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
try {
|
try {
|
||||||
@ -324,9 +322,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun getLibraryGroup(
|
private fun getLibraryGroup(): Preference.PreferenceGroup {
|
||||||
libraryPreferences: LibraryPreferences,
|
|
||||||
): Preference.PreferenceGroup {
|
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
@ -354,11 +350,6 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
|
||||||
preference = libraryPreferences.updateMangaTitles(),
|
|
||||||
title = stringResource(MR.strings.pref_update_library_manga_titles),
|
|
||||||
subtitle = stringResource(MR.strings.pref_update_library_manga_titles_summary),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -381,7 +372,13 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
title = stringResource(MR.strings.pref_category_reader),
|
title = stringResource(MR.strings.pref_category_reader),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = basePreferences.hardwareBitmapThreshold(),
|
pref = basePreferences.hardwareBitmapThreshold(),
|
||||||
|
title = stringResource(MR.strings.pref_hardware_bitmap_threshold),
|
||||||
|
subtitleProvider = { value, options ->
|
||||||
|
stringResource(MR.strings.pref_hardware_bitmap_threshold_summary, options[value].orEmpty())
|
||||||
|
},
|
||||||
|
enabled = !ImageUtil.HARDWARE_BITMAP_UNSUPPORTED &&
|
||||||
|
GLUtil.DEVICE_TEXTURE_LIMIT > GLUtil.SAFE_TEXTURE_LIMIT,
|
||||||
entries = GLUtil.CUSTOM_TEXTURE_LIMIT_OPTIONS
|
entries = GLUtil.CUSTOM_TEXTURE_LIMIT_OPTIONS
|
||||||
.mapIndexed { index, option ->
|
.mapIndexed { index, option ->
|
||||||
val display = if (index == 0) {
|
val display = if (index == 0) {
|
||||||
@ -393,16 +390,10 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
}
|
}
|
||||||
.toMap()
|
.toMap()
|
||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
title = stringResource(MR.strings.pref_hardware_bitmap_threshold),
|
|
||||||
subtitleProvider = { value, options ->
|
|
||||||
stringResource(MR.strings.pref_hardware_bitmap_threshold_summary, options[value].orEmpty())
|
|
||||||
},
|
|
||||||
enabled = !ImageUtil.HARDWARE_BITMAP_UNSUPPORTED &&
|
|
||||||
GLUtil.DEVICE_TEXTURE_LIMIT > GLUtil.SAFE_TEXTURE_LIMIT,
|
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = basePreferences.alwaysDecodeLongStripWithSSIV(),
|
pref = basePreferences.alwaysDecodeLongStripWithSSIV(),
|
||||||
title = stringResource(MR.strings.pref_always_decode_long_strip_with_ssiv_2),
|
title = stringResource(MR.strings.pref_always_decode_long_strip_with_ssiv),
|
||||||
subtitle = stringResource(MR.strings.pref_always_decode_long_strip_with_ssiv_summary),
|
subtitle = stringResource(MR.strings.pref_always_decode_long_strip_with_ssiv_summary),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.TextPreference(
|
Preference.PreferenceItem.TextPreference(
|
||||||
@ -453,7 +444,8 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
title = stringResource(MR.strings.label_extensions),
|
title = stringResource(MR.strings.label_extensions),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = extensionInstallerPref,
|
pref = extensionInstallerPref,
|
||||||
|
title = stringResource(MR.strings.ext_installer_pref),
|
||||||
entries = extensionInstallerPref.entries
|
entries = extensionInstallerPref.entries
|
||||||
.filter {
|
.filter {
|
||||||
// TODO: allow private option in stable versions once URL handling is more fleshed out
|
// TODO: allow private option in stable versions once URL handling is more fleshed out
|
||||||
@ -465,7 +457,6 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
}
|
}
|
||||||
.associateWith { stringResource(it.titleRes) }
|
.associateWith { stringResource(it.titleRes) }
|
||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
title = stringResource(MR.strings.ext_installer_pref),
|
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
if (it == BasePreferences.ExtensionInstaller.SHIZUKU &&
|
if (it == BasePreferences.ExtensionInstaller.SHIZUKU &&
|
||||||
!context.isShizukuInstalled
|
!context.isShizukuInstalled
|
||||||
@ -627,7 +618,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
title = stringResource(SYMR.strings.data_saver),
|
title = stringResource(SYMR.strings.data_saver),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = sourcePreferences.dataSaver(),
|
pref = sourcePreferences.dataSaver(),
|
||||||
title = stringResource(SYMR.strings.data_saver),
|
title = stringResource(SYMR.strings.data_saver),
|
||||||
subtitle = stringResource(SYMR.strings.data_saver_summary),
|
subtitle = stringResource(SYMR.strings.data_saver_summary),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
@ -637,28 +628,28 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.EditTextPreference(
|
Preference.PreferenceItem.EditTextPreference(
|
||||||
preference = sourcePreferences.dataSaverServer(),
|
pref = sourcePreferences.dataSaverServer(),
|
||||||
title = stringResource(SYMR.strings.bandwidth_data_saver_server),
|
title = stringResource(SYMR.strings.bandwidth_data_saver_server),
|
||||||
subtitle = stringResource(SYMR.strings.data_saver_server_summary),
|
subtitle = stringResource(SYMR.strings.data_saver_server_summary),
|
||||||
enabled = dataSaver == DataSaver.BANDWIDTH_HERO,
|
enabled = dataSaver == DataSaver.BANDWIDTH_HERO,
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = sourcePreferences.dataSaverDownloader(),
|
pref = sourcePreferences.dataSaverDownloader(),
|
||||||
title = stringResource(SYMR.strings.data_saver_downloader),
|
title = stringResource(SYMR.strings.data_saver_downloader),
|
||||||
enabled = dataSaver != DataSaver.NONE,
|
enabled = dataSaver != DataSaver.NONE,
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = sourcePreferences.dataSaverIgnoreJpeg(),
|
pref = sourcePreferences.dataSaverIgnoreJpeg(),
|
||||||
title = stringResource(SYMR.strings.data_saver_ignore_jpeg),
|
title = stringResource(SYMR.strings.data_saver_ignore_jpeg),
|
||||||
enabled = dataSaver != DataSaver.NONE,
|
enabled = dataSaver != DataSaver.NONE,
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = sourcePreferences.dataSaverIgnoreGif(),
|
pref = sourcePreferences.dataSaverIgnoreGif(),
|
||||||
title = stringResource(SYMR.strings.data_saver_ignore_gif),
|
title = stringResource(SYMR.strings.data_saver_ignore_gif),
|
||||||
enabled = dataSaver != DataSaver.NONE,
|
enabled = dataSaver != DataSaver.NONE,
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = sourcePreferences.dataSaverImageQuality(),
|
pref = sourcePreferences.dataSaverImageQuality(),
|
||||||
title = stringResource(SYMR.strings.data_saver_image_quality),
|
title = stringResource(SYMR.strings.data_saver_image_quality),
|
||||||
subtitle = stringResource(SYMR.strings.data_saver_image_quality_summary),
|
subtitle = stringResource(SYMR.strings.data_saver_image_quality_summary),
|
||||||
entries = listOf(
|
entries = listOf(
|
||||||
@ -677,7 +668,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
val dataSaverImageFormatJpeg by sourcePreferences.dataSaverImageFormatJpeg()
|
val dataSaverImageFormatJpeg by sourcePreferences.dataSaverImageFormatJpeg()
|
||||||
.collectAsState()
|
.collectAsState()
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = sourcePreferences.dataSaverImageFormatJpeg(),
|
pref = sourcePreferences.dataSaverImageFormatJpeg(),
|
||||||
title = stringResource(SYMR.strings.data_saver_image_format),
|
title = stringResource(SYMR.strings.data_saver_image_format),
|
||||||
subtitle = if (dataSaverImageFormatJpeg) {
|
subtitle = if (dataSaverImageFormatJpeg) {
|
||||||
stringResource(SYMR.strings.data_saver_image_format_summary_on)
|
stringResource(SYMR.strings.data_saver_image_format_summary_on)
|
||||||
@ -688,7 +679,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = sourcePreferences.dataSaverColorBW(),
|
pref = sourcePreferences.dataSaverColorBW(),
|
||||||
title = stringResource(SYMR.strings.data_saver_color_bw),
|
title = stringResource(SYMR.strings.data_saver_color_bw),
|
||||||
enabled = dataSaver == DataSaver.BANDWIDTH_HERO,
|
enabled = dataSaver == DataSaver.BANDWIDTH_HERO,
|
||||||
),
|
),
|
||||||
@ -701,14 +692,14 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val navigator = LocalNavigator.currentOrThrow
|
val navigator = LocalNavigator.currentOrThrow
|
||||||
val sourcePreferences = remember { Injekt.get<SourcePreferences>() }
|
val sourcePreferences = remember { Injekt.get<SourcePreferences>() }
|
||||||
val exhPreferences = remember { Injekt.get<ExhPreferences>() }
|
val unsortedPreferences = remember { Injekt.get<UnsortedPreferences>() }
|
||||||
val delegateSourcePreferences = remember { Injekt.get<DelegateSourcePreferences>() }
|
val delegateSourcePreferences = remember { Injekt.get<DelegateSourcePreferences>() }
|
||||||
val securityPreferences = remember { Injekt.get<SecurityPreferences>() }
|
val securityPreferences = remember { Injekt.get<SecurityPreferences>() }
|
||||||
return Preference.PreferenceGroup(
|
return Preference.PreferenceGroup(
|
||||||
title = stringResource(SYMR.strings.developer_tools),
|
title = stringResource(SYMR.strings.developer_tools),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = exhPreferences.isHentaiEnabled(),
|
pref = unsortedPreferences.isHentaiEnabled(),
|
||||||
title = stringResource(SYMR.strings.toggle_hentai_features),
|
title = stringResource(SYMR.strings.toggle_hentai_features),
|
||||||
subtitle = stringResource(SYMR.strings.toggle_hentai_features_summary),
|
subtitle = stringResource(SYMR.strings.toggle_hentai_features_summary),
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
@ -723,7 +714,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = delegateSourcePreferences.delegateSources(),
|
pref = delegateSourcePreferences.delegateSources(),
|
||||||
title = stringResource(SYMR.strings.toggle_delegated_sources),
|
title = stringResource(SYMR.strings.toggle_delegated_sources),
|
||||||
subtitle = stringResource(
|
subtitle = stringResource(
|
||||||
SYMR.strings.toggle_delegated_sources_summary,
|
SYMR.strings.toggle_delegated_sources_summary,
|
||||||
@ -733,7 +724,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = exhPreferences.logLevel(),
|
pref = unsortedPreferences.logLevel(),
|
||||||
title = stringResource(SYMR.strings.log_level),
|
title = stringResource(SYMR.strings.log_level),
|
||||||
subtitle = stringResource(SYMR.strings.log_level_summary),
|
subtitle = stringResource(SYMR.strings.log_level_summary),
|
||||||
entries = EHLogLevel.entries.mapIndexed { index, ehLogLevel ->
|
entries = EHLogLevel.entries.mapIndexed { index, ehLogLevel ->
|
||||||
@ -743,7 +734,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
}.toMap().toImmutableMap(),
|
}.toMap().toImmutableMap(),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = sourcePreferences.enableSourceBlacklist(),
|
pref = sourcePreferences.enableSourceBlacklist(),
|
||||||
title = stringResource(SYMR.strings.enable_source_blacklist),
|
title = stringResource(SYMR.strings.enable_source_blacklist),
|
||||||
subtitle = stringResource(
|
subtitle = stringResource(
|
||||||
SYMR.strings.enable_source_blacklist_summary,
|
SYMR.strings.enable_source_blacklist_summary,
|
||||||
@ -787,7 +778,7 @@ object SettingsAdvancedScreen : SearchableSettings {
|
|||||||
}
|
}
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
title = stringResource(SYMR.strings.encrypt_database),
|
title = stringResource(SYMR.strings.encrypt_database),
|
||||||
preference = securityPreferences.encryptDatabase(),
|
pref = securityPreferences.encryptDatabase(),
|
||||||
subtitle = stringResource(SYMR.strings.encrypt_database_subtitle),
|
subtitle = stringResource(SYMR.strings.encrypt_database_subtitle),
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
if (it) {
|
if (it) {
|
||||||
|
@ -88,7 +88,7 @@ object SettingsAppearanceScreen : SearchableSettings {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = amoledPref,
|
pref = amoledPref,
|
||||||
title = stringResource(MR.strings.pref_dark_theme_pure_black),
|
title = stringResource(MR.strings.pref_dark_theme_pure_black),
|
||||||
enabled = themeMode != ThemeMode.LIGHT,
|
enabled = themeMode != ThemeMode.LIGHT,
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
@ -122,28 +122,28 @@ object SettingsAppearanceScreen : SearchableSettings {
|
|||||||
onClick = { navigator.push(AppLanguageScreen()) },
|
onClick = { navigator.push(AppLanguageScreen()) },
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = uiPreferences.tabletUiMode(),
|
pref = uiPreferences.tabletUiMode(),
|
||||||
|
title = stringResource(MR.strings.pref_tablet_ui_mode),
|
||||||
entries = TabletUiMode.entries
|
entries = TabletUiMode.entries
|
||||||
.associateWith { stringResource(it.titleRes) }
|
.associateWith { stringResource(it.titleRes) }
|
||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
title = stringResource(MR.strings.pref_tablet_ui_mode),
|
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
context.toast(MR.strings.requires_app_restart)
|
context.toast(MR.strings.requires_app_restart)
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = uiPreferences.dateFormat(),
|
pref = uiPreferences.dateFormat(),
|
||||||
|
title = stringResource(MR.strings.pref_date_format),
|
||||||
entries = DateFormats
|
entries = DateFormats
|
||||||
.associateWith {
|
.associateWith {
|
||||||
val formattedDate = UiPreferences.dateFormat(it).format(now)
|
val formattedDate = UiPreferences.dateFormat(it).format(now)
|
||||||
"${it.ifEmpty { stringResource(MR.strings.label_default) }} ($formattedDate)"
|
"${it.ifEmpty { stringResource(MR.strings.label_default) }} ($formattedDate)"
|
||||||
}
|
}
|
||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
title = stringResource(MR.strings.pref_date_format),
|
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = uiPreferences.relativeTime(),
|
pref = uiPreferences.relativeTime(),
|
||||||
title = stringResource(MR.strings.pref_relative_format),
|
title = stringResource(MR.strings.pref_relative_format),
|
||||||
subtitle = stringResource(
|
subtitle = stringResource(
|
||||||
MR.strings.pref_relative_format_summary,
|
MR.strings.pref_relative_format_summary,
|
||||||
@ -164,16 +164,16 @@ object SettingsAppearanceScreen : SearchableSettings {
|
|||||||
stringResource(SYMR.strings.pref_category_fork),
|
stringResource(SYMR.strings.pref_category_fork),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = uiPreferences.expandFilters(),
|
pref = uiPreferences.expandFilters(),
|
||||||
title = stringResource(SYMR.strings.toggle_expand_search_filters),
|
title = stringResource(SYMR.strings.toggle_expand_search_filters),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = uiPreferences.recommendsInOverflow(),
|
pref = uiPreferences.recommendsInOverflow(),
|
||||||
title = stringResource(SYMR.strings.put_recommends_in_overflow),
|
title = stringResource(SYMR.strings.put_recommends_in_overflow),
|
||||||
subtitle = stringResource(SYMR.strings.put_recommends_in_overflow_summary),
|
subtitle = stringResource(SYMR.strings.put_recommends_in_overflow_summary),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = uiPreferences.mergeInOverflow(),
|
pref = uiPreferences.mergeInOverflow(),
|
||||||
title = stringResource(SYMR.strings.put_merge_in_overflow),
|
title = stringResource(SYMR.strings.put_merge_in_overflow),
|
||||||
subtitle = stringResource(SYMR.strings.put_merge_in_overflow_summary),
|
subtitle = stringResource(SYMR.strings.put_merge_in_overflow_summary),
|
||||||
),
|
),
|
||||||
@ -189,7 +189,8 @@ object SettingsAppearanceScreen : SearchableSettings {
|
|||||||
} else {
|
} else {
|
||||||
stringResource(MR.strings.disabled)
|
stringResource(MR.strings.disabled)
|
||||||
},
|
},
|
||||||
valueRange = 0..10,
|
min = 0,
|
||||||
|
max = 10,
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
uiPreferences.previewsRowCount().set(it)
|
uiPreferences.previewsRowCount().set(it)
|
||||||
true
|
true
|
||||||
@ -205,15 +206,15 @@ object SettingsAppearanceScreen : SearchableSettings {
|
|||||||
stringResource(SYMR.strings.pref_category_navbar),
|
stringResource(SYMR.strings.pref_category_navbar),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = uiPreferences.showNavUpdates(),
|
pref = uiPreferences.showNavUpdates(),
|
||||||
title = stringResource(SYMR.strings.pref_hide_updates_button),
|
title = stringResource(SYMR.strings.pref_hide_updates_button),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = uiPreferences.showNavHistory(),
|
pref = uiPreferences.showNavHistory(),
|
||||||
title = stringResource(SYMR.strings.pref_hide_history_button),
|
title = stringResource(SYMR.strings.pref_hide_history_button),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = uiPreferences.bottomBarLabels(),
|
pref = uiPreferences.bottomBarLabels(),
|
||||||
title = stringResource(SYMR.strings.pref_show_bottom_bar_labels),
|
title = stringResource(SYMR.strings.pref_show_bottom_bar_labels),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -20,6 +20,7 @@ import eu.kanade.tachiyomi.util.system.AuthenticatorUtil.authenticate
|
|||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import mihon.domain.extensionrepo.interactor.GetExtensionRepoCount
|
import mihon.domain.extensionrepo.interactor.GetExtensionRepoCount
|
||||||
import tachiyomi.core.common.i18n.stringResource
|
import tachiyomi.core.common.i18n.stringResource
|
||||||
|
import tachiyomi.domain.UnsortedPreferences
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import tachiyomi.i18n.sy.SYMR
|
import tachiyomi.i18n.sy.SYMR
|
||||||
import tachiyomi.presentation.core.i18n.pluralStringResource
|
import tachiyomi.presentation.core.i18n.pluralStringResource
|
||||||
@ -48,6 +49,7 @@ object SettingsBrowseScreen : SearchableSettings {
|
|||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
val hideFeedTab by remember { Injekt.get<UiPreferences>().hideFeedTab().asState(scope) }
|
val hideFeedTab by remember { Injekt.get<UiPreferences>().hideFeedTab().asState(scope) }
|
||||||
val uiPreferences = remember { Injekt.get<UiPreferences>() }
|
val uiPreferences = remember { Injekt.get<UiPreferences>() }
|
||||||
|
val unsortedPreferences = remember { Injekt.get<UnsortedPreferences>() }
|
||||||
// SY <--
|
// SY <--
|
||||||
return listOf(
|
return listOf(
|
||||||
// SY -->
|
// SY -->
|
||||||
@ -65,17 +67,17 @@ object SettingsBrowseScreen : SearchableSettings {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = sourcePreferences.sourcesTabCategoriesFilter(),
|
pref = sourcePreferences.sourcesTabCategoriesFilter(),
|
||||||
title = stringResource(SYMR.strings.pref_source_source_filtering),
|
title = stringResource(SYMR.strings.pref_source_source_filtering),
|
||||||
subtitle = stringResource(SYMR.strings.pref_source_source_filtering_summery),
|
subtitle = stringResource(SYMR.strings.pref_source_source_filtering_summery),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = uiPreferences.useNewSourceNavigation(),
|
pref = uiPreferences.useNewSourceNavigation(),
|
||||||
title = stringResource(SYMR.strings.pref_source_navigation),
|
title = stringResource(SYMR.strings.pref_source_navigation),
|
||||||
subtitle = stringResource(SYMR.strings.pref_source_navigation_summery),
|
subtitle = stringResource(SYMR.strings.pref_source_navigation_summery),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = sourcePreferences.allowLocalSourceHiddenFolders(),
|
pref = unsortedPreferences.allowLocalSourceHiddenFolders(),
|
||||||
title = stringResource(SYMR.strings.pref_local_source_hidden_folders),
|
title = stringResource(SYMR.strings.pref_local_source_hidden_folders),
|
||||||
subtitle = stringResource(SYMR.strings.pref_local_source_hidden_folders_summery),
|
subtitle = stringResource(SYMR.strings.pref_local_source_hidden_folders_summery),
|
||||||
),
|
),
|
||||||
@ -85,11 +87,11 @@ object SettingsBrowseScreen : SearchableSettings {
|
|||||||
title = stringResource(SYMR.strings.feed),
|
title = stringResource(SYMR.strings.feed),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = uiPreferences.hideFeedTab(),
|
pref = uiPreferences.hideFeedTab(),
|
||||||
title = stringResource(SYMR.strings.pref_hide_feed),
|
title = stringResource(SYMR.strings.pref_hide_feed),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = uiPreferences.feedTabInFront(),
|
pref = uiPreferences.feedTabInFront(),
|
||||||
title = stringResource(SYMR.strings.pref_feed_position),
|
title = stringResource(SYMR.strings.pref_feed_position),
|
||||||
subtitle = stringResource(SYMR.strings.pref_feed_position_summery),
|
subtitle = stringResource(SYMR.strings.pref_feed_position_summery),
|
||||||
enabled = hideFeedTab.not(),
|
enabled = hideFeedTab.not(),
|
||||||
@ -101,7 +103,7 @@ object SettingsBrowseScreen : SearchableSettings {
|
|||||||
title = stringResource(MR.strings.label_sources),
|
title = stringResource(MR.strings.label_sources),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = sourcePreferences.hideInLibraryItems(),
|
pref = sourcePreferences.hideInLibraryItems(),
|
||||||
title = stringResource(MR.strings.pref_hide_in_library_items),
|
title = stringResource(MR.strings.pref_hide_in_library_items),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.TextPreference(
|
Preference.PreferenceItem.TextPreference(
|
||||||
@ -117,7 +119,7 @@ object SettingsBrowseScreen : SearchableSettings {
|
|||||||
title = stringResource(MR.strings.pref_category_nsfw_content),
|
title = stringResource(MR.strings.pref_category_nsfw_content),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = sourcePreferences.showNsfwSource(),
|
pref = sourcePreferences.showNsfwSource(),
|
||||||
title = stringResource(MR.strings.pref_show_nsfw_source),
|
title = stringResource(MR.strings.pref_show_nsfw_source),
|
||||||
subtitle = stringResource(MR.strings.requires_app_restart),
|
subtitle = stringResource(MR.strings.requires_app_restart),
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
@ -129,24 +131,6 @@ object SettingsBrowseScreen : SearchableSettings {
|
|||||||
Preference.PreferenceItem.InfoPreference(stringResource(MR.strings.parental_controls_info)),
|
Preference.PreferenceItem.InfoPreference(stringResource(MR.strings.parental_controls_info)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
getMigrationCategory(sourcePreferences),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun getMigrationCategory(sourcePreferences: SourcePreferences): Preference.PreferenceGroup {
|
|
||||||
val skipPreMigration by sourcePreferences.skipPreMigration().collectAsState()
|
|
||||||
val migrationSources by sourcePreferences.migrationSources().collectAsState()
|
|
||||||
return Preference.PreferenceGroup(
|
|
||||||
stringResource(SYMR.strings.migration),
|
|
||||||
enabled = skipPreMigration || migrationSources.isNotEmpty(),
|
|
||||||
preferenceItems = persistentListOf(
|
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
|
||||||
preference = sourcePreferences.skipPreMigration(),
|
|
||||||
title = stringResource(SYMR.strings.skip_pre_migration),
|
|
||||||
subtitle = stringResource(SYMR.strings.pref_skip_pre_migration_summary),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,7 @@ import android.net.Uri
|
|||||||
import androidx.activity.compose.ManagedActivityResultLauncher
|
import androidx.activity.compose.ManagedActivityResultLauncher
|
||||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.compose.foundation.layout.Column
|
|
||||||
import androidx.compose.foundation.layout.IntrinsicSize
|
import androidx.compose.foundation.layout.IntrinsicSize
|
||||||
import androidx.compose.foundation.layout.Row
|
|
||||||
import androidx.compose.foundation.layout.RowScope
|
import androidx.compose.foundation.layout.RowScope
|
||||||
import androidx.compose.foundation.layout.fillMaxHeight
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
@ -17,9 +15,7 @@ import androidx.compose.foundation.layout.height
|
|||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.automirrored.outlined.HelpOutline
|
import androidx.compose.material.icons.automirrored.outlined.HelpOutline
|
||||||
import androidx.compose.material.icons.filled.QrCodeScanner
|
|
||||||
import androidx.compose.material3.AlertDialog
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.Checkbox
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.MultiChoiceSegmentedButtonRow
|
import androidx.compose.material3.MultiChoiceSegmentedButtonRow
|
||||||
@ -28,7 +24,6 @@ import androidx.compose.material3.SegmentedButtonDefaults
|
|||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TextButton
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
|
||||||
import androidx.compose.runtime.ReadOnlyComposable
|
import androidx.compose.runtime.ReadOnlyComposable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableIntStateOf
|
import androidx.compose.runtime.mutableIntStateOf
|
||||||
@ -36,17 +31,13 @@ import androidx.compose.runtime.mutableStateOf
|
|||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
import androidx.compose.runtime.rememberCoroutineScope
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalUriHandler
|
import androidx.compose.ui.platform.LocalUriHandler
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||||
import com.google.zxing.client.android.Intents
|
|
||||||
import com.hippo.unifile.UniFile
|
import com.hippo.unifile.UniFile
|
||||||
import com.journeyapps.barcodescanner.ScanContract
|
|
||||||
import com.journeyapps.barcodescanner.ScanOptions
|
|
||||||
import eu.kanade.domain.sync.SyncPreferences
|
import eu.kanade.domain.sync.SyncPreferences
|
||||||
import eu.kanade.presentation.more.settings.Preference
|
import eu.kanade.presentation.more.settings.Preference
|
||||||
import eu.kanade.presentation.more.settings.screen.data.CreateBackupScreen
|
import eu.kanade.presentation.more.settings.screen.data.CreateBackupScreen
|
||||||
@ -55,16 +46,12 @@ import eu.kanade.presentation.more.settings.screen.data.StorageInfo
|
|||||||
import eu.kanade.presentation.more.settings.screen.data.SyncSettingsSelector
|
import eu.kanade.presentation.more.settings.screen.data.SyncSettingsSelector
|
||||||
import eu.kanade.presentation.more.settings.screen.data.SyncTriggerOptionsScreen
|
import eu.kanade.presentation.more.settings.screen.data.SyncTriggerOptionsScreen
|
||||||
import eu.kanade.presentation.more.settings.widget.BasePreferenceWidget
|
import eu.kanade.presentation.more.settings.widget.BasePreferenceWidget
|
||||||
import eu.kanade.presentation.more.settings.widget.EditTextPreferenceWidget
|
|
||||||
import eu.kanade.presentation.more.settings.widget.PrefsHorizontalPadding
|
import eu.kanade.presentation.more.settings.widget.PrefsHorizontalPadding
|
||||||
import eu.kanade.presentation.more.settings.widget.TrailingWidgetBuffer
|
|
||||||
import eu.kanade.presentation.util.relativeTimeSpanString
|
import eu.kanade.presentation.util.relativeTimeSpanString
|
||||||
import eu.kanade.tachiyomi.data.backup.create.BackupCreateJob
|
import eu.kanade.tachiyomi.data.backup.create.BackupCreateJob
|
||||||
import eu.kanade.tachiyomi.data.backup.restore.BackupRestoreJob
|
import eu.kanade.tachiyomi.data.backup.restore.BackupRestoreJob
|
||||||
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||||
import eu.kanade.tachiyomi.data.cache.PagePreviewCache
|
import eu.kanade.tachiyomi.data.cache.PagePreviewCache
|
||||||
import eu.kanade.tachiyomi.data.export.LibraryExporter
|
|
||||||
import eu.kanade.tachiyomi.data.export.LibraryExporter.ExportOptions
|
|
||||||
import eu.kanade.tachiyomi.data.sync.SyncDataJob
|
import eu.kanade.tachiyomi.data.sync.SyncDataJob
|
||||||
import eu.kanade.tachiyomi.data.sync.SyncManager
|
import eu.kanade.tachiyomi.data.sync.SyncManager
|
||||||
import eu.kanade.tachiyomi.data.sync.service.GoogleDriveService
|
import eu.kanade.tachiyomi.data.sync.service.GoogleDriveService
|
||||||
@ -73,7 +60,6 @@ import eu.kanade.tachiyomi.util.system.DeviceUtil
|
|||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import kotlinx.collections.immutable.persistentMapOf
|
import kotlinx.collections.immutable.persistentMapOf
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import logcat.LogPriority
|
import logcat.LogPriority
|
||||||
import tachiyomi.core.common.i18n.stringResource
|
import tachiyomi.core.common.i18n.stringResource
|
||||||
@ -83,8 +69,6 @@ import tachiyomi.core.common.util.lang.withUIContext
|
|||||||
import tachiyomi.core.common.util.system.logcat
|
import tachiyomi.core.common.util.system.logcat
|
||||||
import tachiyomi.domain.backup.service.BackupPreferences
|
import tachiyomi.domain.backup.service.BackupPreferences
|
||||||
import tachiyomi.domain.library.service.LibraryPreferences
|
import tachiyomi.domain.library.service.LibraryPreferences
|
||||||
import tachiyomi.domain.manga.interactor.GetFavorites
|
|
||||||
import tachiyomi.domain.manga.model.Manga
|
|
||||||
import tachiyomi.domain.storage.service.StoragePreferences
|
import tachiyomi.domain.storage.service.StoragePreferences
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import tachiyomi.i18n.sy.SYMR
|
import tachiyomi.i18n.sy.SYMR
|
||||||
@ -127,7 +111,6 @@ object SettingsDataScreen : SearchableSettings {
|
|||||||
|
|
||||||
getBackupAndRestoreGroup(backupPreferences = backupPreferences),
|
getBackupAndRestoreGroup(backupPreferences = backupPreferences),
|
||||||
getDataGroup(),
|
getDataGroup(),
|
||||||
getExportGroup(),
|
|
||||||
) + getSyncPreferences(syncPreferences = syncPreferences, syncService = syncService)
|
) + getSyncPreferences(syncPreferences = syncPreferences, syncService = syncService)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +255,8 @@ object SettingsDataScreen : SearchableSettings {
|
|||||||
|
|
||||||
// Automatic backups
|
// Automatic backups
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = backupPreferences.backupInterval(),
|
pref = backupPreferences.backupInterval(),
|
||||||
|
title = stringResource(MR.strings.pref_backup_interval),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
0 to stringResource(MR.strings.off),
|
0 to stringResource(MR.strings.off),
|
||||||
6 to stringResource(MR.strings.update_6hour),
|
6 to stringResource(MR.strings.update_6hour),
|
||||||
@ -281,7 +265,6 @@ object SettingsDataScreen : SearchableSettings {
|
|||||||
48 to stringResource(MR.strings.update_48hour),
|
48 to stringResource(MR.strings.update_48hour),
|
||||||
168 to stringResource(MR.strings.update_weekly),
|
168 to stringResource(MR.strings.update_weekly),
|
||||||
),
|
),
|
||||||
title = stringResource(MR.strings.pref_backup_interval),
|
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
BackupCreateJob.setupTask(context, it)
|
BackupCreateJob.setupTask(context, it)
|
||||||
true
|
true
|
||||||
@ -365,151 +348,13 @@ object SettingsDataScreen : SearchableSettings {
|
|||||||
),
|
),
|
||||||
// SY <--
|
// SY <--
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = libraryPreferences.autoClearChapterCache(),
|
pref = libraryPreferences.autoClearChapterCache(),
|
||||||
title = stringResource(MR.strings.pref_auto_clear_chapter_cache),
|
title = stringResource(MR.strings.pref_auto_clear_chapter_cache),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun getExportGroup(): Preference.PreferenceGroup {
|
|
||||||
var showDialog by remember { mutableStateOf(false) }
|
|
||||||
var exportOptions by remember {
|
|
||||||
mutableStateOf(
|
|
||||||
ExportOptions(
|
|
||||||
includeTitle = true,
|
|
||||||
includeAuthor = true,
|
|
||||||
includeArtist = true,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
val context = LocalContext.current
|
|
||||||
val scope = rememberCoroutineScope()
|
|
||||||
val getFavorites = remember { Injekt.get<GetFavorites>() }
|
|
||||||
var favorites by remember { mutableStateOf<List<Manga>>(emptyList()) }
|
|
||||||
LaunchedEffect(Unit) {
|
|
||||||
favorites = getFavorites.await()
|
|
||||||
}
|
|
||||||
|
|
||||||
val saveFileLauncher = rememberLauncherForActivityResult(
|
|
||||||
contract = ActivityResultContracts.CreateDocument("text/csv"),
|
|
||||||
) { uri ->
|
|
||||||
uri?.let {
|
|
||||||
scope.launch {
|
|
||||||
LibraryExporter.exportToCsv(
|
|
||||||
context = context,
|
|
||||||
uri = it,
|
|
||||||
favorites = favorites,
|
|
||||||
options = exportOptions,
|
|
||||||
onExportComplete = {
|
|
||||||
scope.launch(Dispatchers.Main) {
|
|
||||||
context.toast(MR.strings.library_exported)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showDialog) {
|
|
||||||
ColumnSelectionDialog(
|
|
||||||
options = exportOptions,
|
|
||||||
onConfirm = { options ->
|
|
||||||
exportOptions = options
|
|
||||||
saveFileLauncher.launch("mihon_library.csv")
|
|
||||||
},
|
|
||||||
onDismissRequest = { showDialog = false },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return Preference.PreferenceGroup(
|
|
||||||
title = stringResource(MR.strings.export),
|
|
||||||
preferenceItems = persistentListOf(
|
|
||||||
Preference.PreferenceItem.TextPreference(
|
|
||||||
title = stringResource(MR.strings.library_list),
|
|
||||||
onClick = { showDialog = true },
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun ColumnSelectionDialog(
|
|
||||||
options: ExportOptions,
|
|
||||||
onConfirm: (ExportOptions) -> Unit,
|
|
||||||
onDismissRequest: () -> Unit,
|
|
||||||
) {
|
|
||||||
var titleSelected by remember { mutableStateOf(options.includeTitle) }
|
|
||||||
var authorSelected by remember { mutableStateOf(options.includeAuthor) }
|
|
||||||
var artistSelected by remember { mutableStateOf(options.includeArtist) }
|
|
||||||
|
|
||||||
AlertDialog(
|
|
||||||
onDismissRequest = onDismissRequest,
|
|
||||||
title = {
|
|
||||||
Text(text = stringResource(MR.strings.migration_dialog_what_to_include))
|
|
||||||
},
|
|
||||||
text = {
|
|
||||||
Column {
|
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
||||||
Checkbox(
|
|
||||||
checked = titleSelected,
|
|
||||||
onCheckedChange = { checked ->
|
|
||||||
titleSelected = checked
|
|
||||||
if (!checked) {
|
|
||||||
authorSelected = false
|
|
||||||
artistSelected = false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
Text(text = stringResource(MR.strings.title))
|
|
||||||
}
|
|
||||||
|
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
||||||
Checkbox(
|
|
||||||
checked = authorSelected,
|
|
||||||
onCheckedChange = { authorSelected = it },
|
|
||||||
enabled = titleSelected,
|
|
||||||
)
|
|
||||||
Text(text = stringResource(MR.strings.author))
|
|
||||||
}
|
|
||||||
|
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
||||||
Checkbox(
|
|
||||||
checked = artistSelected,
|
|
||||||
onCheckedChange = { artistSelected = it },
|
|
||||||
enabled = titleSelected,
|
|
||||||
)
|
|
||||||
Text(text = stringResource(MR.strings.artist))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
confirmButton = {
|
|
||||||
TextButton(
|
|
||||||
onClick = {
|
|
||||||
onConfirm(
|
|
||||||
ExportOptions(
|
|
||||||
includeTitle = titleSelected,
|
|
||||||
includeAuthor = authorSelected,
|
|
||||||
includeArtist = artistSelected,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
onDismissRequest()
|
|
||||||
},
|
|
||||||
) {
|
|
||||||
Text(text = stringResource(MR.strings.action_save))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
dismissButton = {
|
|
||||||
TextButton(onClick = onDismissRequest) {
|
|
||||||
Text(text = stringResource(MR.strings.action_cancel))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// SY -->
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun getSyncPreferences(syncPreferences: SyncPreferences, syncService: Int): List<Preference> {
|
private fun getSyncPreferences(syncPreferences: SyncPreferences, syncService: Int): List<Preference> {
|
||||||
return listOf(
|
return listOf(
|
||||||
@ -517,7 +362,7 @@ object SettingsDataScreen : SearchableSettings {
|
|||||||
title = stringResource(SYMR.strings.pref_sync_service_category),
|
title = stringResource(SYMR.strings.pref_sync_service_category),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = syncPreferences.syncService(),
|
pref = syncPreferences.syncService(),
|
||||||
title = stringResource(SYMR.strings.pref_sync_service),
|
title = stringResource(SYMR.strings.pref_sync_service),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
SyncManager.SyncService.NONE.value to stringResource(MR.strings.off),
|
SyncManager.SyncService.NONE.value to stringResource(MR.strings.off),
|
||||||
@ -657,27 +502,11 @@ object SettingsDataScreen : SearchableSettings {
|
|||||||
@Composable
|
@Composable
|
||||||
private fun getSelfHostPreferences(syncPreferences: SyncPreferences): List<Preference> {
|
private fun getSelfHostPreferences(syncPreferences: SyncPreferences): List<Preference> {
|
||||||
val scope = rememberCoroutineScope()
|
val scope = rememberCoroutineScope()
|
||||||
|
|
||||||
val qrScanLauncher = rememberLauncherForActivityResult(ScanContract()) {
|
|
||||||
if (it.contents != null && it.contents.isNotEmpty()) {
|
|
||||||
syncPreferences.clientAPIKey().set(it.contents)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val context = LocalContext.current
|
|
||||||
val scanOptions = remember {
|
|
||||||
ScanOptions().apply {
|
|
||||||
setDesiredBarcodeFormats(ScanOptions.QR_CODE)
|
|
||||||
setOrientationLocked(false)
|
|
||||||
setPrompt(SYMR.strings.scan_qr_code.getString(context))
|
|
||||||
addExtra(Intents.Scan.SCAN_TYPE, Intents.Scan.MIXED_SCAN)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return listOf(
|
return listOf(
|
||||||
Preference.PreferenceItem.EditTextPreference(
|
Preference.PreferenceItem.EditTextPreference(
|
||||||
title = stringResource(SYMR.strings.pref_sync_host),
|
title = stringResource(SYMR.strings.pref_sync_host),
|
||||||
subtitle = stringResource(SYMR.strings.pref_sync_host_summ),
|
subtitle = stringResource(SYMR.strings.pref_sync_host_summ),
|
||||||
preference = syncPreferences.clientHost(),
|
pref = syncPreferences.clientHost(),
|
||||||
onValueChanged = { newValue ->
|
onValueChanged = { newValue ->
|
||||||
scope.launch {
|
scope.launch {
|
||||||
// Trim spaces at the beginning and end, then remove trailing slash if present
|
// Trim spaces at the beginning and end, then remove trailing slash if present
|
||||||
@ -688,32 +517,11 @@ object SettingsDataScreen : SearchableSettings {
|
|||||||
true
|
true
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.CustomPreference(
|
Preference.PreferenceItem.EditTextPreference(
|
||||||
title = stringResource(SYMR.strings.pref_sync_api_key),
|
|
||||||
) {
|
|
||||||
val values by syncPreferences.clientAPIKey().collectAsState()
|
|
||||||
EditTextPreferenceWidget(
|
|
||||||
title = stringResource(SYMR.strings.pref_sync_api_key),
|
title = stringResource(SYMR.strings.pref_sync_api_key),
|
||||||
subtitle = stringResource(SYMR.strings.pref_sync_api_key_summ),
|
subtitle = stringResource(SYMR.strings.pref_sync_api_key_summ),
|
||||||
onConfirm = {
|
pref = syncPreferences.clientAPIKey(),
|
||||||
syncPreferences.clientAPIKey().set(it)
|
),
|
||||||
true
|
|
||||||
},
|
|
||||||
icon = null,
|
|
||||||
value = values,
|
|
||||||
widget = {
|
|
||||||
IconButton(
|
|
||||||
onClick = { qrScanLauncher.launch(scanOptions) },
|
|
||||||
modifier = Modifier.padding(start = TrailingWidgetBuffer),
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
Icons.Filled.QrCodeScanner,
|
|
||||||
contentDescription = stringResource(SYMR.strings.scan_qr_code),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -759,7 +567,7 @@ object SettingsDataScreen : SearchableSettings {
|
|||||||
title = stringResource(SYMR.strings.pref_sync_automatic_category),
|
title = stringResource(SYMR.strings.pref_sync_automatic_category),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = syncIntervalPref,
|
pref = syncIntervalPref,
|
||||||
title = stringResource(SYMR.strings.pref_sync_interval),
|
title = stringResource(SYMR.strings.pref_sync_interval),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
0 to stringResource(MR.strings.off),
|
0 to stringResource(MR.strings.off),
|
||||||
@ -783,5 +591,4 @@ object SettingsDataScreen : SearchableSettings {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// SY <--
|
|
||||||
}
|
}
|
||||||
|
@ -39,15 +39,15 @@ object SettingsDownloadScreen : SearchableSettings {
|
|||||||
val downloadPreferences = remember { Injekt.get<DownloadPreferences>() }
|
val downloadPreferences = remember { Injekt.get<DownloadPreferences>() }
|
||||||
return listOf(
|
return listOf(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = downloadPreferences.downloadOnlyOverWifi(),
|
pref = downloadPreferences.downloadOnlyOverWifi(),
|
||||||
title = stringResource(MR.strings.connected_to_wifi),
|
title = stringResource(MR.strings.connected_to_wifi),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = downloadPreferences.saveChaptersAsCBZ(),
|
pref = downloadPreferences.saveChaptersAsCBZ(),
|
||||||
title = stringResource(MR.strings.save_chapter_as_cbz),
|
title = stringResource(MR.strings.save_chapter_as_cbz),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = downloadPreferences.splitTallImages(),
|
pref = downloadPreferences.splitTallImages(),
|
||||||
title = stringResource(MR.strings.split_tall_images),
|
title = stringResource(MR.strings.split_tall_images),
|
||||||
subtitle = stringResource(MR.strings.split_tall_images_summary),
|
subtitle = stringResource(MR.strings.split_tall_images_summary),
|
||||||
),
|
),
|
||||||
@ -72,11 +72,12 @@ object SettingsDownloadScreen : SearchableSettings {
|
|||||||
title = stringResource(MR.strings.pref_category_delete_chapters),
|
title = stringResource(MR.strings.pref_category_delete_chapters),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = downloadPreferences.removeAfterMarkedAsRead(),
|
pref = downloadPreferences.removeAfterMarkedAsRead(),
|
||||||
title = stringResource(MR.strings.pref_remove_after_marked_as_read),
|
title = stringResource(MR.strings.pref_remove_after_marked_as_read),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = downloadPreferences.removeAfterReadSlots(),
|
pref = downloadPreferences.removeAfterReadSlots(),
|
||||||
|
title = stringResource(MR.strings.pref_remove_after_read),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
-1 to stringResource(MR.strings.disabled),
|
-1 to stringResource(MR.strings.disabled),
|
||||||
0 to stringResource(MR.strings.last_read_chapter),
|
0 to stringResource(MR.strings.last_read_chapter),
|
||||||
@ -85,10 +86,9 @@ object SettingsDownloadScreen : SearchableSettings {
|
|||||||
3 to stringResource(MR.strings.fourth_to_last),
|
3 to stringResource(MR.strings.fourth_to_last),
|
||||||
4 to stringResource(MR.strings.fifth_to_last),
|
4 to stringResource(MR.strings.fifth_to_last),
|
||||||
),
|
),
|
||||||
title = stringResource(MR.strings.pref_remove_after_read),
|
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = downloadPreferences.removeBookmarkedChapters(),
|
pref = downloadPreferences.removeBookmarkedChapters(),
|
||||||
title = stringResource(MR.strings.pref_remove_bookmarked_chapters),
|
title = stringResource(MR.strings.pref_remove_bookmarked_chapters),
|
||||||
),
|
),
|
||||||
getExcludedCategoriesPreference(
|
getExcludedCategoriesPreference(
|
||||||
@ -105,11 +105,11 @@ object SettingsDownloadScreen : SearchableSettings {
|
|||||||
categories: () -> List<Category>,
|
categories: () -> List<Category>,
|
||||||
): Preference.PreferenceItem.MultiSelectListPreference {
|
): Preference.PreferenceItem.MultiSelectListPreference {
|
||||||
return Preference.PreferenceItem.MultiSelectListPreference(
|
return Preference.PreferenceItem.MultiSelectListPreference(
|
||||||
preference = downloadPreferences.removeExcludeCategories(),
|
pref = downloadPreferences.removeExcludeCategories(),
|
||||||
|
title = stringResource(MR.strings.pref_remove_exclude_categories),
|
||||||
entries = categories()
|
entries = categories()
|
||||||
.associate { it.id.toString() to it.visualName }
|
.associate { it.id.toString() to it.visualName }
|
||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
title = stringResource(MR.strings.pref_remove_exclude_categories),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,11 +149,11 @@ object SettingsDownloadScreen : SearchableSettings {
|
|||||||
title = stringResource(MR.strings.pref_category_auto_download),
|
title = stringResource(MR.strings.pref_category_auto_download),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = downloadNewChaptersPref,
|
pref = downloadNewChaptersPref,
|
||||||
title = stringResource(MR.strings.pref_download_new),
|
title = stringResource(MR.strings.pref_download_new),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = downloadNewUnreadChaptersOnlyPref,
|
pref = downloadNewUnreadChaptersOnlyPref,
|
||||||
title = stringResource(MR.strings.pref_download_new_unread_chapters_only),
|
title = stringResource(MR.strings.pref_download_new_unread_chapters_only),
|
||||||
enabled = downloadNewChapters,
|
enabled = downloadNewChapters,
|
||||||
),
|
),
|
||||||
@ -164,8 +164,8 @@ object SettingsDownloadScreen : SearchableSettings {
|
|||||||
included = included,
|
included = included,
|
||||||
excluded = excluded,
|
excluded = excluded,
|
||||||
),
|
),
|
||||||
enabled = downloadNewChapters,
|
|
||||||
onClick = { showDialog = true },
|
onClick = { showDialog = true },
|
||||||
|
enabled = downloadNewChapters,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -179,7 +179,8 @@ object SettingsDownloadScreen : SearchableSettings {
|
|||||||
title = stringResource(MR.strings.download_ahead),
|
title = stringResource(MR.strings.download_ahead),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = downloadPreferences.autoDownloadWhileReading(),
|
pref = downloadPreferences.autoDownloadWhileReading(),
|
||||||
|
title = stringResource(MR.strings.auto_download_while_reading),
|
||||||
entries = listOf(0, 2, 3, 5, 10)
|
entries = listOf(0, 2, 3, 5, 10)
|
||||||
.associateWith {
|
.associateWith {
|
||||||
if (it == 0) {
|
if (it == 0) {
|
||||||
@ -189,7 +190,6 @@ object SettingsDownloadScreen : SearchableSettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
title = stringResource(MR.strings.auto_download_while_reading),
|
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.InfoPreference(stringResource(MR.strings.download_ahead_info)),
|
Preference.PreferenceItem.InfoPreference(stringResource(MR.strings.download_ahead_info)),
|
||||||
),
|
),
|
||||||
|
@ -43,6 +43,7 @@ import androidx.compose.ui.platform.LocalContext
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.window.Dialog
|
import androidx.compose.ui.window.Dialog
|
||||||
import androidx.compose.ui.window.DialogProperties
|
import androidx.compose.ui.window.DialogProperties
|
||||||
|
import androidx.core.content.ContextCompat.startActivity
|
||||||
import eu.kanade.presentation.library.components.SyncFavoritesWarningDialog
|
import eu.kanade.presentation.library.components.SyncFavoritesWarningDialog
|
||||||
import eu.kanade.presentation.more.settings.Preference
|
import eu.kanade.presentation.more.settings.Preference
|
||||||
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
|
||||||
@ -51,7 +52,6 @@ import exh.eh.EHentaiUpdateWorker
|
|||||||
import exh.eh.EHentaiUpdateWorkerConstants
|
import exh.eh.EHentaiUpdateWorkerConstants
|
||||||
import exh.eh.EHentaiUpdaterStats
|
import exh.eh.EHentaiUpdaterStats
|
||||||
import exh.metadata.metadata.EHentaiSearchMetadata
|
import exh.metadata.metadata.EHentaiSearchMetadata
|
||||||
import exh.source.ExhPreferences
|
|
||||||
import exh.ui.login.EhLoginActivity
|
import exh.ui.login.EhLoginActivity
|
||||||
import exh.util.nullIfBlank
|
import exh.util.nullIfBlank
|
||||||
import kotlinx.collections.immutable.persistentListOf
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
@ -64,6 +64,7 @@ import tachiyomi.core.common.util.lang.launchNonCancellable
|
|||||||
import tachiyomi.core.common.util.lang.withIOContext
|
import tachiyomi.core.common.util.lang.withIOContext
|
||||||
import tachiyomi.core.common.util.lang.withUIContext
|
import tachiyomi.core.common.util.lang.withUIContext
|
||||||
import tachiyomi.core.common.util.system.logcat
|
import tachiyomi.core.common.util.system.logcat
|
||||||
|
import tachiyomi.domain.UnsortedPreferences
|
||||||
import tachiyomi.domain.library.service.LibraryPreferences.Companion.DEVICE_CHARGING
|
import tachiyomi.domain.library.service.LibraryPreferences.Companion.DEVICE_CHARGING
|
||||||
import tachiyomi.domain.library.service.LibraryPreferences.Companion.DEVICE_ONLY_ON_WIFI
|
import tachiyomi.domain.library.service.LibraryPreferences.Companion.DEVICE_ONLY_ON_WIFI
|
||||||
import tachiyomi.domain.manga.interactor.DeleteFavoriteEntries
|
import tachiyomi.domain.manga.interactor.DeleteFavoriteEntries
|
||||||
@ -88,22 +89,22 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
@Composable
|
@Composable
|
||||||
override fun getTitleRes() = SYMR.strings.pref_category_eh
|
override fun getTitleRes() = SYMR.strings.pref_category_eh
|
||||||
|
|
||||||
override fun isEnabled(): Boolean = Injekt.get<ExhPreferences>().isHentaiEnabled().get()
|
override fun isEnabled(): Boolean = Injekt.get<UnsortedPreferences>().isHentaiEnabled().get()
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun Reconfigure(
|
fun Reconfigure(
|
||||||
exhPreferences: ExhPreferences,
|
unsortedPreferences: UnsortedPreferences,
|
||||||
openWarnConfigureDialogController: () -> Unit,
|
openWarnConfigureDialogController: () -> Unit,
|
||||||
) {
|
) {
|
||||||
var initialLoadGuard by remember { mutableStateOf(false) }
|
var initialLoadGuard by remember { mutableStateOf(false) }
|
||||||
val useHentaiAtHome by exhPreferences.useHentaiAtHome().collectAsState()
|
val useHentaiAtHome by unsortedPreferences.useHentaiAtHome().collectAsState()
|
||||||
val useJapaneseTitle by exhPreferences.useJapaneseTitle().collectAsState()
|
val useJapaneseTitle by unsortedPreferences.useJapaneseTitle().collectAsState()
|
||||||
val useOriginalImages by exhPreferences.exhUseOriginalImages().collectAsState()
|
val useOriginalImages by unsortedPreferences.exhUseOriginalImages().collectAsState()
|
||||||
val ehTagFilterValue by exhPreferences.ehTagFilterValue().collectAsState()
|
val ehTagFilterValue by unsortedPreferences.ehTagFilterValue().collectAsState()
|
||||||
val ehTagWatchingValue by exhPreferences.ehTagWatchingValue().collectAsState()
|
val ehTagWatchingValue by unsortedPreferences.ehTagWatchingValue().collectAsState()
|
||||||
val settingsLanguages by exhPreferences.exhSettingsLanguages().collectAsState()
|
val settingsLanguages by unsortedPreferences.exhSettingsLanguages().collectAsState()
|
||||||
val enabledCategories by exhPreferences.exhEnabledCategories().collectAsState()
|
val enabledCategories by unsortedPreferences.exhEnabledCategories().collectAsState()
|
||||||
val imageQuality by exhPreferences.imageQuality().collectAsState()
|
val imageQuality by unsortedPreferences.imageQuality().collectAsState()
|
||||||
DisposableEffect(
|
DisposableEffect(
|
||||||
useHentaiAtHome,
|
useHentaiAtHome,
|
||||||
useJapaneseTitle,
|
useJapaneseTitle,
|
||||||
@ -124,15 +125,15 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun getPreferences(): List<Preference> {
|
override fun getPreferences(): List<Preference> {
|
||||||
val exhPreferences: ExhPreferences = remember { Injekt.get() }
|
val unsortedPreferences: UnsortedPreferences = remember { Injekt.get() }
|
||||||
val getFlatMetadataById: GetFlatMetadataById = remember { Injekt.get() }
|
val getFlatMetadataById: GetFlatMetadataById = remember { Injekt.get() }
|
||||||
val deleteFavoriteEntries: DeleteFavoriteEntries = remember { Injekt.get() }
|
val deleteFavoriteEntries: DeleteFavoriteEntries = remember { Injekt.get() }
|
||||||
val getExhFavoriteMangaWithMetadata: GetExhFavoriteMangaWithMetadata = remember { Injekt.get() }
|
val getExhFavoriteMangaWithMetadata: GetExhFavoriteMangaWithMetadata = remember { Injekt.get() }
|
||||||
val exhentaiEnabled by exhPreferences.enableExhentai().collectAsState()
|
val exhentaiEnabled by unsortedPreferences.enableExhentai().collectAsState()
|
||||||
var runConfigureDialog by remember { mutableStateOf(false) }
|
var runConfigureDialog by remember { mutableStateOf(false) }
|
||||||
val openWarnConfigureDialogController = { runConfigureDialog = true }
|
val openWarnConfigureDialogController = { runConfigureDialog = true }
|
||||||
|
|
||||||
Reconfigure(exhPreferences, openWarnConfigureDialogController)
|
Reconfigure(unsortedPreferences, openWarnConfigureDialogController)
|
||||||
|
|
||||||
ConfigureExhDialog(run = runConfigureDialog, onRunning = { runConfigureDialog = false })
|
ConfigureExhDialog(run = runConfigureDialog, onRunning = { runConfigureDialog = false })
|
||||||
|
|
||||||
@ -140,36 +141,36 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
Preference.PreferenceGroup(
|
Preference.PreferenceGroup(
|
||||||
stringResource(SYMR.strings.ehentai_prefs_account_settings),
|
stringResource(SYMR.strings.ehentai_prefs_account_settings),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
getLoginPreference(exhPreferences, openWarnConfigureDialogController),
|
getLoginPreference(unsortedPreferences, openWarnConfigureDialogController),
|
||||||
useHentaiAtHome(exhentaiEnabled, exhPreferences),
|
useHentaiAtHome(exhentaiEnabled, unsortedPreferences),
|
||||||
useJapaneseTitle(exhentaiEnabled, exhPreferences),
|
useJapaneseTitle(exhentaiEnabled, unsortedPreferences),
|
||||||
useOriginalImages(exhentaiEnabled, exhPreferences),
|
useOriginalImages(exhentaiEnabled, unsortedPreferences),
|
||||||
watchedTags(exhentaiEnabled),
|
watchedTags(exhentaiEnabled),
|
||||||
tagFilterThreshold(exhentaiEnabled, exhPreferences),
|
tagFilterThreshold(exhentaiEnabled, unsortedPreferences),
|
||||||
tagWatchingThreshold(exhentaiEnabled, exhPreferences),
|
tagWatchingThreshold(exhentaiEnabled, unsortedPreferences),
|
||||||
settingsLanguages(exhentaiEnabled, exhPreferences),
|
settingsLanguages(exhentaiEnabled, unsortedPreferences),
|
||||||
enabledCategories(exhentaiEnabled, exhPreferences),
|
enabledCategories(exhentaiEnabled, unsortedPreferences),
|
||||||
watchedListDefaultState(exhentaiEnabled, exhPreferences),
|
watchedListDefaultState(exhentaiEnabled, unsortedPreferences),
|
||||||
imageQuality(exhentaiEnabled, exhPreferences),
|
imageQuality(exhentaiEnabled, unsortedPreferences),
|
||||||
enhancedEhentaiView(exhPreferences),
|
enhancedEhentaiView(unsortedPreferences),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Preference.PreferenceGroup(
|
Preference.PreferenceGroup(
|
||||||
stringResource(SYMR.strings.favorites_sync),
|
stringResource(SYMR.strings.favorites_sync),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
readOnlySync(exhPreferences),
|
readOnlySync(unsortedPreferences),
|
||||||
syncFavoriteNotes(),
|
syncFavoriteNotes(),
|
||||||
lenientSync(exhPreferences),
|
lenientSync(unsortedPreferences),
|
||||||
forceSyncReset(deleteFavoriteEntries),
|
forceSyncReset(deleteFavoriteEntries),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Preference.PreferenceGroup(
|
Preference.PreferenceGroup(
|
||||||
stringResource(SYMR.strings.gallery_update_checker),
|
stringResource(SYMR.strings.gallery_update_checker),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
updateCheckerFrequency(exhPreferences),
|
updateCheckerFrequency(unsortedPreferences),
|
||||||
autoUpdateRequirements(exhPreferences),
|
autoUpdateRequirements(unsortedPreferences),
|
||||||
updaterStatistics(
|
updaterStatistics(
|
||||||
exhPreferences,
|
unsortedPreferences,
|
||||||
getExhFavoriteMangaWithMetadata,
|
getExhFavoriteMangaWithMetadata,
|
||||||
getFlatMetadataById,
|
getFlatMetadataById,
|
||||||
),
|
),
|
||||||
@ -180,7 +181,7 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun getLoginPreference(
|
fun getLoginPreference(
|
||||||
exhPreferences: ExhPreferences,
|
unsortedPreferences: UnsortedPreferences,
|
||||||
openWarnConfigureDialogController: () -> Unit,
|
openWarnConfigureDialogController: () -> Unit,
|
||||||
): Preference.PreferenceItem.SwitchPreference {
|
): Preference.PreferenceItem.SwitchPreference {
|
||||||
val activityResultContract =
|
val activityResultContract =
|
||||||
@ -191,9 +192,9 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val value by exhPreferences.enableExhentai().collectAsState()
|
val value by unsortedPreferences.enableExhentai().collectAsState()
|
||||||
return Preference.PreferenceItem.SwitchPreference(
|
return Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = exhPreferences.enableExhentai(),
|
pref = unsortedPreferences.enableExhentai(),
|
||||||
title = stringResource(SYMR.strings.enable_exhentai),
|
title = stringResource(SYMR.strings.enable_exhentai),
|
||||||
subtitle = if (!value) {
|
subtitle = if (!value) {
|
||||||
stringResource(SYMR.strings.requires_login)
|
stringResource(SYMR.strings.requires_login)
|
||||||
@ -202,7 +203,7 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
},
|
},
|
||||||
onValueChanged = { newVal ->
|
onValueChanged = { newVal ->
|
||||||
if (!newVal) {
|
if (!newVal) {
|
||||||
exhPreferences.enableExhentai().set(false)
|
unsortedPreferences.enableExhentai().set(false)
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
activityResultContract.launch(EhLoginActivity.newIntent(context))
|
activityResultContract.launch(EhLoginActivity.newIntent(context))
|
||||||
@ -215,10 +216,10 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
@Composable
|
@Composable
|
||||||
fun useHentaiAtHome(
|
fun useHentaiAtHome(
|
||||||
exhentaiEnabled: Boolean,
|
exhentaiEnabled: Boolean,
|
||||||
exhPreferences: ExhPreferences,
|
unsortedPreferences: UnsortedPreferences,
|
||||||
): Preference.PreferenceItem.ListPreference<Int> {
|
): Preference.PreferenceItem.ListPreference<Int> {
|
||||||
return Preference.PreferenceItem.ListPreference(
|
return Preference.PreferenceItem.ListPreference(
|
||||||
preference = exhPreferences.useHentaiAtHome(),
|
pref = unsortedPreferences.useHentaiAtHome(),
|
||||||
title = stringResource(SYMR.strings.use_hentai_at_home),
|
title = stringResource(SYMR.strings.use_hentai_at_home),
|
||||||
subtitle = stringResource(SYMR.strings.use_hentai_at_home_summary),
|
subtitle = stringResource(SYMR.strings.use_hentai_at_home_summary),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
@ -232,11 +233,11 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
@Composable
|
@Composable
|
||||||
fun useJapaneseTitle(
|
fun useJapaneseTitle(
|
||||||
exhentaiEnabled: Boolean,
|
exhentaiEnabled: Boolean,
|
||||||
exhPreferences: ExhPreferences,
|
unsortedPreferences: UnsortedPreferences,
|
||||||
): Preference.PreferenceItem.SwitchPreference {
|
): Preference.PreferenceItem.SwitchPreference {
|
||||||
val value by exhPreferences.useJapaneseTitle().collectAsState()
|
val value by unsortedPreferences.useJapaneseTitle().collectAsState()
|
||||||
return Preference.PreferenceItem.SwitchPreference(
|
return Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = exhPreferences.useJapaneseTitle(),
|
pref = unsortedPreferences.useJapaneseTitle(),
|
||||||
title = stringResource(SYMR.strings.show_japanese_titles),
|
title = stringResource(SYMR.strings.show_japanese_titles),
|
||||||
subtitle = if (value) {
|
subtitle = if (value) {
|
||||||
stringResource(SYMR.strings.show_japanese_titles_option_1)
|
stringResource(SYMR.strings.show_japanese_titles_option_1)
|
||||||
@ -250,11 +251,11 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
@Composable
|
@Composable
|
||||||
fun useOriginalImages(
|
fun useOriginalImages(
|
||||||
exhentaiEnabled: Boolean,
|
exhentaiEnabled: Boolean,
|
||||||
exhPreferences: ExhPreferences,
|
unsortedPreferences: UnsortedPreferences,
|
||||||
): Preference.PreferenceItem.SwitchPreference {
|
): Preference.PreferenceItem.SwitchPreference {
|
||||||
val value by exhPreferences.exhUseOriginalImages().collectAsState()
|
val value by unsortedPreferences.exhUseOriginalImages().collectAsState()
|
||||||
return Preference.PreferenceItem.SwitchPreference(
|
return Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = exhPreferences.exhUseOriginalImages(),
|
pref = unsortedPreferences.exhUseOriginalImages(),
|
||||||
title = stringResource(SYMR.strings.use_original_images),
|
title = stringResource(SYMR.strings.use_original_images),
|
||||||
subtitle = if (value) {
|
subtitle = if (value) {
|
||||||
stringResource(SYMR.strings.use_original_images_on)
|
stringResource(SYMR.strings.use_original_images_on)
|
||||||
@ -272,7 +273,8 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
title = stringResource(SYMR.strings.watched_tags),
|
title = stringResource(SYMR.strings.watched_tags),
|
||||||
subtitle = stringResource(SYMR.strings.watched_tags_summary),
|
subtitle = stringResource(SYMR.strings.watched_tags_summary),
|
||||||
onClick = {
|
onClick = {
|
||||||
context.startActivity(
|
startActivity(
|
||||||
|
context,
|
||||||
WebViewActivity.newIntent(
|
WebViewActivity.newIntent(
|
||||||
context,
|
context,
|
||||||
url = "https://exhentai.org/mytags",
|
url = "https://exhentai.org/mytags",
|
||||||
@ -351,9 +353,9 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
@Composable
|
@Composable
|
||||||
fun tagFilterThreshold(
|
fun tagFilterThreshold(
|
||||||
exhentaiEnabled: Boolean,
|
exhentaiEnabled: Boolean,
|
||||||
exhPreferences: ExhPreferences,
|
unsortedPreferences: UnsortedPreferences,
|
||||||
): Preference.PreferenceItem.TextPreference {
|
): Preference.PreferenceItem.TextPreference {
|
||||||
val value by exhPreferences.ehTagFilterValue().collectAsState()
|
val value by unsortedPreferences.ehTagFilterValue().collectAsState()
|
||||||
var dialogOpen by remember { mutableStateOf(false) }
|
var dialogOpen by remember { mutableStateOf(false) }
|
||||||
if (dialogOpen) {
|
if (dialogOpen) {
|
||||||
TagThresholdDialog(
|
TagThresholdDialog(
|
||||||
@ -364,7 +366,7 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
outsideRangeError = stringResource(SYMR.strings.tag_filtering_threshhold_error),
|
outsideRangeError = stringResource(SYMR.strings.tag_filtering_threshhold_error),
|
||||||
onValueChange = {
|
onValueChange = {
|
||||||
dialogOpen = false
|
dialogOpen = false
|
||||||
exhPreferences.ehTagFilterValue().set(it)
|
unsortedPreferences.ehTagFilterValue().set(it)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -381,9 +383,9 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
@Composable
|
@Composable
|
||||||
fun tagWatchingThreshold(
|
fun tagWatchingThreshold(
|
||||||
exhentaiEnabled: Boolean,
|
exhentaiEnabled: Boolean,
|
||||||
exhPreferences: ExhPreferences,
|
unsortedPreferences: UnsortedPreferences,
|
||||||
): Preference.PreferenceItem.TextPreference {
|
): Preference.PreferenceItem.TextPreference {
|
||||||
val value by exhPreferences.ehTagWatchingValue().collectAsState()
|
val value by unsortedPreferences.ehTagWatchingValue().collectAsState()
|
||||||
var dialogOpen by remember { mutableStateOf(false) }
|
var dialogOpen by remember { mutableStateOf(false) }
|
||||||
if (dialogOpen) {
|
if (dialogOpen) {
|
||||||
TagThresholdDialog(
|
TagThresholdDialog(
|
||||||
@ -394,7 +396,7 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
outsideRangeError = stringResource(SYMR.strings.tag_watching_threshhold_error),
|
outsideRangeError = stringResource(SYMR.strings.tag_watching_threshhold_error),
|
||||||
onValueChange = {
|
onValueChange = {
|
||||||
dialogOpen = false
|
dialogOpen = false
|
||||||
exhPreferences.ehTagWatchingValue().set(it)
|
unsortedPreferences.ehTagWatchingValue().set(it)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -604,9 +606,9 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
@Composable
|
@Composable
|
||||||
fun settingsLanguages(
|
fun settingsLanguages(
|
||||||
exhentaiEnabled: Boolean,
|
exhentaiEnabled: Boolean,
|
||||||
exhPreferences: ExhPreferences,
|
unsortedPreferences: UnsortedPreferences,
|
||||||
): Preference.PreferenceItem.TextPreference {
|
): Preference.PreferenceItem.TextPreference {
|
||||||
val value by exhPreferences.exhSettingsLanguages().collectAsState()
|
val value by unsortedPreferences.exhSettingsLanguages().collectAsState()
|
||||||
var dialogOpen by remember { mutableStateOf(false) }
|
var dialogOpen by remember { mutableStateOf(false) }
|
||||||
if (dialogOpen) {
|
if (dialogOpen) {
|
||||||
LanguagesDialog(
|
LanguagesDialog(
|
||||||
@ -614,7 +616,7 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
initialValue = value,
|
initialValue = value,
|
||||||
onValueChange = {
|
onValueChange = {
|
||||||
dialogOpen = false
|
dialogOpen = false
|
||||||
exhPreferences.exhSettingsLanguages().set(it)
|
unsortedPreferences.exhSettingsLanguages().set(it)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -770,9 +772,9 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
@Composable
|
@Composable
|
||||||
fun enabledCategories(
|
fun enabledCategories(
|
||||||
exhentaiEnabled: Boolean,
|
exhentaiEnabled: Boolean,
|
||||||
exhPreferences: ExhPreferences,
|
unsortedPreferences: UnsortedPreferences,
|
||||||
): Preference.PreferenceItem.TextPreference {
|
): Preference.PreferenceItem.TextPreference {
|
||||||
val value by exhPreferences.exhEnabledCategories().collectAsState()
|
val value by unsortedPreferences.exhEnabledCategories().collectAsState()
|
||||||
var dialogOpen by remember { mutableStateOf(false) }
|
var dialogOpen by remember { mutableStateOf(false) }
|
||||||
if (dialogOpen) {
|
if (dialogOpen) {
|
||||||
FrontPageCategoriesDialog(
|
FrontPageCategoriesDialog(
|
||||||
@ -780,7 +782,7 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
initialValue = value,
|
initialValue = value,
|
||||||
onValueChange = {
|
onValueChange = {
|
||||||
dialogOpen = false
|
dialogOpen = false
|
||||||
exhPreferences.exhEnabledCategories().set(it)
|
unsortedPreferences.exhEnabledCategories().set(it)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -797,10 +799,10 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
@Composable
|
@Composable
|
||||||
fun watchedListDefaultState(
|
fun watchedListDefaultState(
|
||||||
exhentaiEnabled: Boolean,
|
exhentaiEnabled: Boolean,
|
||||||
exhPreferences: ExhPreferences,
|
unsortedPreferences: UnsortedPreferences,
|
||||||
): Preference.PreferenceItem.SwitchPreference {
|
): Preference.PreferenceItem.SwitchPreference {
|
||||||
return Preference.PreferenceItem.SwitchPreference(
|
return Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = exhPreferences.exhWatchedListDefaultState(),
|
pref = unsortedPreferences.exhWatchedListDefaultState(),
|
||||||
title = stringResource(SYMR.strings.watched_list_default),
|
title = stringResource(SYMR.strings.watched_list_default),
|
||||||
subtitle = stringResource(SYMR.strings.watched_list_state_summary),
|
subtitle = stringResource(SYMR.strings.watched_list_state_summary),
|
||||||
enabled = exhentaiEnabled,
|
enabled = exhentaiEnabled,
|
||||||
@ -810,10 +812,10 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
@Composable
|
@Composable
|
||||||
fun imageQuality(
|
fun imageQuality(
|
||||||
exhentaiEnabled: Boolean,
|
exhentaiEnabled: Boolean,
|
||||||
exhPreferences: ExhPreferences,
|
unsortedPreferences: UnsortedPreferences,
|
||||||
): Preference.PreferenceItem.ListPreference<String> {
|
): Preference.PreferenceItem.ListPreference<String> {
|
||||||
return Preference.PreferenceItem.ListPreference(
|
return Preference.PreferenceItem.ListPreference(
|
||||||
preference = exhPreferences.imageQuality(),
|
pref = unsortedPreferences.imageQuality(),
|
||||||
title = stringResource(SYMR.strings.eh_image_quality_summary),
|
title = stringResource(SYMR.strings.eh_image_quality_summary),
|
||||||
subtitle = stringResource(SYMR.strings.eh_image_quality),
|
subtitle = stringResource(SYMR.strings.eh_image_quality),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
@ -829,18 +831,18 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun enhancedEhentaiView(exhPreferences: ExhPreferences): Preference.PreferenceItem.SwitchPreference {
|
fun enhancedEhentaiView(unsortedPreferences: UnsortedPreferences): Preference.PreferenceItem.SwitchPreference {
|
||||||
return Preference.PreferenceItem.SwitchPreference(
|
return Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = exhPreferences.enhancedEHentaiView(),
|
pref = unsortedPreferences.enhancedEHentaiView(),
|
||||||
title = stringResource(SYMR.strings.pref_enhanced_e_hentai_view),
|
title = stringResource(SYMR.strings.pref_enhanced_e_hentai_view),
|
||||||
subtitle = stringResource(SYMR.strings.pref_enhanced_e_hentai_view_summary),
|
subtitle = stringResource(SYMR.strings.pref_enhanced_e_hentai_view_summary),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun readOnlySync(exhPreferences: ExhPreferences): Preference.PreferenceItem.SwitchPreference {
|
fun readOnlySync(unsortedPreferences: UnsortedPreferences): Preference.PreferenceItem.SwitchPreference {
|
||||||
return Preference.PreferenceItem.SwitchPreference(
|
return Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = exhPreferences.exhReadOnlySync(),
|
pref = unsortedPreferences.exhReadOnlySync(),
|
||||||
title = stringResource(SYMR.strings.disable_favorites_uploading),
|
title = stringResource(SYMR.strings.disable_favorites_uploading),
|
||||||
subtitle = stringResource(SYMR.strings.disable_favorites_uploading_summary),
|
subtitle = stringResource(SYMR.strings.disable_favorites_uploading_summary),
|
||||||
)
|
)
|
||||||
@ -863,9 +865,9 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun lenientSync(exhPreferences: ExhPreferences): Preference.PreferenceItem.SwitchPreference {
|
fun lenientSync(unsortedPreferences: UnsortedPreferences): Preference.PreferenceItem.SwitchPreference {
|
||||||
return Preference.PreferenceItem.SwitchPreference(
|
return Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = exhPreferences.exhLenientSync(),
|
pref = unsortedPreferences.exhLenientSync(),
|
||||||
title = stringResource(SYMR.strings.ignore_sync_errors),
|
title = stringResource(SYMR.strings.ignore_sync_errors),
|
||||||
subtitle = stringResource(SYMR.strings.ignore_sync_errors_summary),
|
subtitle = stringResource(SYMR.strings.ignore_sync_errors_summary),
|
||||||
)
|
)
|
||||||
@ -935,12 +937,12 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun updateCheckerFrequency(
|
fun updateCheckerFrequency(
|
||||||
exhPreferences: ExhPreferences,
|
unsortedPreferences: UnsortedPreferences,
|
||||||
): Preference.PreferenceItem.ListPreference<Int> {
|
): Preference.PreferenceItem.ListPreference<Int> {
|
||||||
val value by exhPreferences.exhAutoUpdateFrequency().collectAsState()
|
val value by unsortedPreferences.exhAutoUpdateFrequency().collectAsState()
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
return Preference.PreferenceItem.ListPreference(
|
return Preference.PreferenceItem.ListPreference(
|
||||||
preference = exhPreferences.exhAutoUpdateFrequency(),
|
pref = unsortedPreferences.exhAutoUpdateFrequency(),
|
||||||
title = stringResource(SYMR.strings.time_between_batches),
|
title = stringResource(SYMR.strings.time_between_batches),
|
||||||
subtitle = if (value == 0) {
|
subtitle = if (value == 0) {
|
||||||
stringResource(SYMR.strings.time_between_batches_summary_1, stringResource(MR.strings.app_name))
|
stringResource(SYMR.strings.time_between_batches_summary_1, stringResource(MR.strings.app_name))
|
||||||
@ -971,12 +973,12 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun autoUpdateRequirements(
|
fun autoUpdateRequirements(
|
||||||
exhPreferences: ExhPreferences,
|
unsortedPreferences: UnsortedPreferences,
|
||||||
): Preference.PreferenceItem.MultiSelectListPreference {
|
): Preference.PreferenceItem.MultiSelectListPreference {
|
||||||
val value by exhPreferences.exhAutoUpdateRequirements().collectAsState()
|
val value by unsortedPreferences.exhAutoUpdateRequirements().collectAsState()
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
return Preference.PreferenceItem.MultiSelectListPreference(
|
return Preference.PreferenceItem.MultiSelectListPreference(
|
||||||
preference = exhPreferences.exhAutoUpdateRequirements(),
|
pref = unsortedPreferences.exhAutoUpdateRequirements(),
|
||||||
title = stringResource(SYMR.strings.auto_update_restrictions),
|
title = stringResource(SYMR.strings.auto_update_restrictions),
|
||||||
subtitle = remember(value) {
|
subtitle = remember(value) {
|
||||||
context.stringResource(
|
context.stringResource(
|
||||||
@ -1139,7 +1141,7 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun updaterStatistics(
|
fun updaterStatistics(
|
||||||
exhPreferences: ExhPreferences,
|
unsortedPreferences: UnsortedPreferences,
|
||||||
getExhFavoriteMangaWithMetadata: GetExhFavoriteMangaWithMetadata,
|
getExhFavoriteMangaWithMetadata: GetExhFavoriteMangaWithMetadata,
|
||||||
getFlatMetadataById: GetFlatMetadataById,
|
getFlatMetadataById: GetFlatMetadataById,
|
||||||
): Preference.PreferenceItem.TextPreference {
|
): Preference.PreferenceItem.TextPreference {
|
||||||
@ -1150,7 +1152,7 @@ object SettingsEhScreen : SearchableSettings {
|
|||||||
value = withIOContext {
|
value = withIOContext {
|
||||||
try {
|
try {
|
||||||
val stats =
|
val stats =
|
||||||
exhPreferences.exhAutoUpdateStats().get().nullIfBlank()?.let {
|
unsortedPreferences.exhAutoUpdateStats().get().nullIfBlank()?.let {
|
||||||
Json.decodeFromString<EHentaiUpdaterStats>(it)
|
Json.decodeFromString<EHentaiUpdaterStats>(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import kotlinx.collections.immutable.persistentListOf
|
|||||||
import kotlinx.collections.immutable.persistentMapOf
|
import kotlinx.collections.immutable.persistentMapOf
|
||||||
import kotlinx.collections.immutable.toImmutableMap
|
import kotlinx.collections.immutable.toImmutableMap
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import tachiyomi.domain.UnsortedPreferences
|
||||||
import tachiyomi.domain.category.interactor.GetCategories
|
import tachiyomi.domain.category.interactor.GetCategories
|
||||||
import tachiyomi.domain.category.interactor.ResetCategoryFlags
|
import tachiyomi.domain.category.interactor.ResetCategoryFlags
|
||||||
import tachiyomi.domain.category.model.Category
|
import tachiyomi.domain.category.model.Category
|
||||||
@ -37,8 +38,6 @@ import tachiyomi.domain.library.service.LibraryPreferences.Companion.MANGA_HAS_U
|
|||||||
import tachiyomi.domain.library.service.LibraryPreferences.Companion.MANGA_NON_COMPLETED
|
import tachiyomi.domain.library.service.LibraryPreferences.Companion.MANGA_NON_COMPLETED
|
||||||
import tachiyomi.domain.library.service.LibraryPreferences.Companion.MANGA_NON_READ
|
import tachiyomi.domain.library.service.LibraryPreferences.Companion.MANGA_NON_READ
|
||||||
import tachiyomi.domain.library.service.LibraryPreferences.Companion.MANGA_OUTSIDE_RELEASE_PERIOD
|
import tachiyomi.domain.library.service.LibraryPreferences.Companion.MANGA_OUTSIDE_RELEASE_PERIOD
|
||||||
import tachiyomi.domain.library.service.LibraryPreferences.Companion.MARK_DUPLICATE_CHAPTER_READ_EXISTING
|
|
||||||
import tachiyomi.domain.library.service.LibraryPreferences.Companion.MARK_DUPLICATE_CHAPTER_READ_NEW
|
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import tachiyomi.i18n.sy.SYMR
|
import tachiyomi.i18n.sy.SYMR
|
||||||
import tachiyomi.presentation.core.i18n.pluralStringResource
|
import tachiyomi.presentation.core.i18n.pluralStringResource
|
||||||
@ -58,13 +57,17 @@ object SettingsLibraryScreen : SearchableSettings {
|
|||||||
val getCategories = remember { Injekt.get<GetCategories>() }
|
val getCategories = remember { Injekt.get<GetCategories>() }
|
||||||
val libraryPreferences = remember { Injekt.get<LibraryPreferences>() }
|
val libraryPreferences = remember { Injekt.get<LibraryPreferences>() }
|
||||||
val allCategories by getCategories.subscribe().collectAsState(initial = emptyList())
|
val allCategories by getCategories.subscribe().collectAsState(initial = emptyList())
|
||||||
|
// SY -->
|
||||||
|
val unsortedPreferences = remember { Injekt.get<UnsortedPreferences>() }
|
||||||
|
// SY <--
|
||||||
|
|
||||||
return listOf(
|
return listOf(
|
||||||
getCategoriesGroup(LocalNavigator.currentOrThrow, allCategories, libraryPreferences),
|
getCategoriesGroup(LocalNavigator.currentOrThrow, allCategories, libraryPreferences),
|
||||||
getGlobalUpdateGroup(allCategories, libraryPreferences),
|
getGlobalUpdateGroup(allCategories, libraryPreferences),
|
||||||
getBehaviorGroup(libraryPreferences),
|
getChapterSwipeActionsGroup(libraryPreferences),
|
||||||
// SY -->
|
// SY -->
|
||||||
getSortingCategory(LocalNavigator.currentOrThrow, libraryPreferences),
|
getSortingCategory(LocalNavigator.currentOrThrow, libraryPreferences),
|
||||||
|
getMigrationCategory(unsortedPreferences),
|
||||||
// SY <--
|
// SY <--
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -97,12 +100,12 @@ object SettingsLibraryScreen : SearchableSettings {
|
|||||||
onClick = { navigator.push(CategoryScreen()) },
|
onClick = { navigator.push(CategoryScreen()) },
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = libraryPreferences.defaultCategory(),
|
pref = libraryPreferences.defaultCategory(),
|
||||||
entries = ids.zip(labels).toMap().toImmutableMap(),
|
|
||||||
title = stringResource(MR.strings.default_category),
|
title = stringResource(MR.strings.default_category),
|
||||||
|
entries = ids.zip(labels).toMap().toImmutableMap(),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = libraryPreferences.categorizedDisplaySettings(),
|
pref = libraryPreferences.categorizedDisplaySettings(),
|
||||||
title = stringResource(MR.strings.categorized_display_settings),
|
title = stringResource(MR.strings.categorized_display_settings),
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
if (!it) {
|
if (!it) {
|
||||||
@ -154,7 +157,8 @@ object SettingsLibraryScreen : SearchableSettings {
|
|||||||
title = stringResource(MR.strings.pref_category_library_update),
|
title = stringResource(MR.strings.pref_category_library_update),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = autoUpdateIntervalPref,
|
pref = autoUpdateIntervalPref,
|
||||||
|
title = stringResource(MR.strings.pref_library_update_interval),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
0 to stringResource(MR.strings.update_never),
|
0 to stringResource(MR.strings.update_never),
|
||||||
12 to stringResource(MR.strings.update_12hour),
|
12 to stringResource(MR.strings.update_12hour),
|
||||||
@ -163,22 +167,21 @@ object SettingsLibraryScreen : SearchableSettings {
|
|||||||
72 to stringResource(MR.strings.update_72hour),
|
72 to stringResource(MR.strings.update_72hour),
|
||||||
168 to stringResource(MR.strings.update_weekly),
|
168 to stringResource(MR.strings.update_weekly),
|
||||||
),
|
),
|
||||||
title = stringResource(MR.strings.pref_library_update_interval),
|
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
LibraryUpdateJob.setupTask(context, it)
|
LibraryUpdateJob.setupTask(context, it)
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.MultiSelectListPreference(
|
Preference.PreferenceItem.MultiSelectListPreference(
|
||||||
preference = libraryPreferences.autoUpdateDeviceRestrictions(),
|
pref = libraryPreferences.autoUpdateDeviceRestrictions(),
|
||||||
|
enabled = autoUpdateInterval > 0,
|
||||||
|
title = stringResource(MR.strings.pref_library_update_restriction),
|
||||||
|
subtitle = stringResource(MR.strings.restrictions),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
DEVICE_ONLY_ON_WIFI to stringResource(MR.strings.connected_to_wifi),
|
DEVICE_ONLY_ON_WIFI to stringResource(MR.strings.connected_to_wifi),
|
||||||
DEVICE_NETWORK_NOT_METERED to stringResource(MR.strings.network_not_metered),
|
DEVICE_NETWORK_NOT_METERED to stringResource(MR.strings.network_not_metered),
|
||||||
DEVICE_CHARGING to stringResource(MR.strings.charging),
|
DEVICE_CHARGING to stringResource(MR.strings.charging),
|
||||||
),
|
),
|
||||||
title = stringResource(MR.strings.pref_library_update_restriction),
|
|
||||||
subtitle = stringResource(MR.strings.restrictions),
|
|
||||||
enabled = autoUpdateInterval > 0,
|
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
// Post to event looper to allow the preference to be updated.
|
// Post to event looper to allow the preference to be updated.
|
||||||
ContextCompat.getMainExecutor(context).execute { LibraryUpdateJob.setupTask(context) }
|
ContextCompat.getMainExecutor(context).execute { LibraryUpdateJob.setupTask(context) }
|
||||||
@ -196,7 +199,7 @@ object SettingsLibraryScreen : SearchableSettings {
|
|||||||
),
|
),
|
||||||
// SY -->
|
// SY -->
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = libraryPreferences.groupLibraryUpdateType(),
|
pref = libraryPreferences.groupLibraryUpdateType(),
|
||||||
title = stringResource(SYMR.strings.library_group_updates),
|
title = stringResource(SYMR.strings.library_group_updates),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
GroupLibraryMode.GLOBAL to stringResource(SYMR.strings.library_group_updates_global),
|
GroupLibraryMode.GLOBAL to stringResource(SYMR.strings.library_group_updates_global),
|
||||||
@ -207,37 +210,45 @@ object SettingsLibraryScreen : SearchableSettings {
|
|||||||
),
|
),
|
||||||
// SY <--
|
// SY <--
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = libraryPreferences.autoUpdateMetadata(),
|
pref = libraryPreferences.autoUpdateMetadata(),
|
||||||
title = stringResource(MR.strings.pref_library_update_refresh_metadata),
|
title = stringResource(MR.strings.pref_library_update_refresh_metadata),
|
||||||
subtitle = stringResource(MR.strings.pref_library_update_refresh_metadata_summary),
|
subtitle = stringResource(MR.strings.pref_library_update_refresh_metadata_summary),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.MultiSelectListPreference(
|
Preference.PreferenceItem.MultiSelectListPreference(
|
||||||
preference = libraryPreferences.autoUpdateMangaRestrictions(),
|
pref = libraryPreferences.autoUpdateMangaRestrictions(),
|
||||||
|
title = stringResource(MR.strings.pref_library_update_smart_update),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
MANGA_HAS_UNREAD to stringResource(MR.strings.pref_update_only_completely_read),
|
MANGA_HAS_UNREAD to stringResource(MR.strings.pref_update_only_completely_read),
|
||||||
MANGA_NON_READ to stringResource(MR.strings.pref_update_only_started),
|
MANGA_NON_READ to stringResource(MR.strings.pref_update_only_started),
|
||||||
MANGA_NON_COMPLETED to stringResource(MR.strings.pref_update_only_non_completed),
|
MANGA_NON_COMPLETED to stringResource(MR.strings.pref_update_only_non_completed),
|
||||||
MANGA_OUTSIDE_RELEASE_PERIOD to stringResource(MR.strings.pref_update_only_in_release_period),
|
MANGA_OUTSIDE_RELEASE_PERIOD to stringResource(MR.strings.pref_update_only_in_release_period),
|
||||||
),
|
),
|
||||||
title = stringResource(MR.strings.pref_library_update_smart_update),
|
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = libraryPreferences.newShowUpdatesCount(),
|
pref = libraryPreferences.newShowUpdatesCount(),
|
||||||
title = stringResource(MR.strings.pref_library_update_show_tab_badge),
|
title = stringResource(MR.strings.pref_library_update_show_tab_badge),
|
||||||
),
|
),
|
||||||
|
// SY -->
|
||||||
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
|
pref = libraryPreferences.libraryReadDuplicateChapters(),
|
||||||
|
title = stringResource(SYMR.strings.pref_library_mark_duplicate_chapters),
|
||||||
|
subtitle = stringResource(SYMR.strings.pref_library_mark_duplicate_chapters_summary),
|
||||||
|
),
|
||||||
|
// SY <--
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun getBehaviorGroup(
|
private fun getChapterSwipeActionsGroup(
|
||||||
libraryPreferences: LibraryPreferences,
|
libraryPreferences: LibraryPreferences,
|
||||||
): Preference.PreferenceGroup {
|
): Preference.PreferenceGroup {
|
||||||
return Preference.PreferenceGroup(
|
return Preference.PreferenceGroup(
|
||||||
title = stringResource(MR.strings.pref_behavior),
|
title = stringResource(MR.strings.pref_chapter_swipe),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = libraryPreferences.swipeToStartAction(),
|
pref = libraryPreferences.swipeToStartAction(),
|
||||||
|
title = stringResource(MR.strings.pref_chapter_swipe_start),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
LibraryPreferences.ChapterSwipeAction.Disabled to
|
LibraryPreferences.ChapterSwipeAction.Disabled to
|
||||||
stringResource(MR.strings.disabled),
|
stringResource(MR.strings.disabled),
|
||||||
@ -248,10 +259,10 @@ object SettingsLibraryScreen : SearchableSettings {
|
|||||||
LibraryPreferences.ChapterSwipeAction.Download to
|
LibraryPreferences.ChapterSwipeAction.Download to
|
||||||
stringResource(MR.strings.action_download),
|
stringResource(MR.strings.action_download),
|
||||||
),
|
),
|
||||||
title = stringResource(MR.strings.pref_chapter_swipe_start),
|
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = libraryPreferences.swipeToEndAction(),
|
pref = libraryPreferences.swipeToEndAction(),
|
||||||
|
title = stringResource(MR.strings.pref_chapter_swipe_end),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
LibraryPreferences.ChapterSwipeAction.Disabled to
|
LibraryPreferences.ChapterSwipeAction.Disabled to
|
||||||
stringResource(MR.strings.disabled),
|
stringResource(MR.strings.disabled),
|
||||||
@ -262,17 +273,6 @@ object SettingsLibraryScreen : SearchableSettings {
|
|||||||
LibraryPreferences.ChapterSwipeAction.Download to
|
LibraryPreferences.ChapterSwipeAction.Download to
|
||||||
stringResource(MR.strings.action_download),
|
stringResource(MR.strings.action_download),
|
||||||
),
|
),
|
||||||
title = stringResource(MR.strings.pref_chapter_swipe_end),
|
|
||||||
),
|
|
||||||
Preference.PreferenceItem.MultiSelectListPreference(
|
|
||||||
preference = libraryPreferences.markDuplicateReadChapterAsRead(),
|
|
||||||
entries = persistentMapOf(
|
|
||||||
MARK_DUPLICATE_CHAPTER_READ_EXISTING to
|
|
||||||
stringResource(MR.strings.pref_mark_duplicate_read_chapter_read_existing),
|
|
||||||
MARK_DUPLICATE_CHAPTER_READ_NEW to
|
|
||||||
stringResource(MR.strings.pref_mark_duplicate_read_chapter_read_new),
|
|
||||||
),
|
|
||||||
title = stringResource(MR.strings.pref_mark_duplicate_read_chapter_read),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@ -295,5 +295,22 @@ object SettingsLibraryScreen : SearchableSettings {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun getMigrationCategory(unsortedPreferences: UnsortedPreferences): Preference.PreferenceGroup {
|
||||||
|
val skipPreMigration by unsortedPreferences.skipPreMigration().collectAsState()
|
||||||
|
val migrationSources by unsortedPreferences.migrationSources().collectAsState()
|
||||||
|
return Preference.PreferenceGroup(
|
||||||
|
stringResource(SYMR.strings.migration),
|
||||||
|
enabled = skipPreMigration || migrationSources.isNotEmpty(),
|
||||||
|
preferenceItems = persistentListOf(
|
||||||
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
|
pref = unsortedPreferences.skipPreMigration(),
|
||||||
|
title = stringResource(SYMR.strings.skip_pre_migration),
|
||||||
|
subtitle = stringResource(SYMR.strings.pref_skip_pre_migration_summary),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
// SY <--
|
// SY <--
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ import logcat.LogPriority
|
|||||||
import tachiyomi.core.common.util.lang.launchIO
|
import tachiyomi.core.common.util.lang.launchIO
|
||||||
import tachiyomi.core.common.util.lang.withUIContext
|
import tachiyomi.core.common.util.lang.withUIContext
|
||||||
import tachiyomi.core.common.util.system.logcat
|
import tachiyomi.core.common.util.system.logcat
|
||||||
|
import tachiyomi.domain.UnsortedPreferences
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import tachiyomi.i18n.sy.SYMR
|
import tachiyomi.i18n.sy.SYMR
|
||||||
import tachiyomi.presentation.core.components.material.padding
|
import tachiyomi.presentation.core.components.material.padding
|
||||||
@ -64,13 +65,14 @@ object SettingsMangadexScreen : SearchableSettings {
|
|||||||
@Composable
|
@Composable
|
||||||
override fun getPreferences(): List<Preference> {
|
override fun getPreferences(): List<Preference> {
|
||||||
val sourcePreferences: SourcePreferences = remember { Injekt.get() }
|
val sourcePreferences: SourcePreferences = remember { Injekt.get() }
|
||||||
|
val unsortedPreferences: UnsortedPreferences = remember { Injekt.get() }
|
||||||
val trackPreferences: TrackPreferences = remember { Injekt.get() }
|
val trackPreferences: TrackPreferences = remember { Injekt.get() }
|
||||||
val mdex = remember { MdUtil.getEnabledMangaDex(sourcePreferences) } ?: return emptyList()
|
val mdex = remember { MdUtil.getEnabledMangaDex(unsortedPreferences, sourcePreferences) } ?: return emptyList()
|
||||||
|
|
||||||
return listOf(
|
return listOf(
|
||||||
loginPreference(mdex, trackPreferences),
|
loginPreference(mdex, trackPreferences),
|
||||||
preferredMangaDexId(sourcePreferences),
|
preferredMangaDexId(unsortedPreferences, sourcePreferences),
|
||||||
syncMangaDexIntoThis(sourcePreferences),
|
syncMangaDexIntoThis(unsortedPreferences),
|
||||||
syncLibraryToMangaDex(),
|
syncLibraryToMangaDex(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -172,10 +174,11 @@ object SettingsMangadexScreen : SearchableSettings {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun preferredMangaDexId(
|
fun preferredMangaDexId(
|
||||||
|
unsortedPreferences: UnsortedPreferences,
|
||||||
sourcePreferences: SourcePreferences,
|
sourcePreferences: SourcePreferences,
|
||||||
): Preference.PreferenceItem.ListPreference<String> {
|
): Preference.PreferenceItem.ListPreference<String> {
|
||||||
return Preference.PreferenceItem.ListPreference(
|
return Preference.PreferenceItem.ListPreference(
|
||||||
preference = sourcePreferences.preferredMangaDexId(),
|
pref = unsortedPreferences.preferredMangaDexId(),
|
||||||
title = stringResource(SYMR.strings.mangadex_preffered_source),
|
title = stringResource(SYMR.strings.mangadex_preffered_source),
|
||||||
subtitle = stringResource(SYMR.strings.mangadex_preffered_source_summary),
|
subtitle = stringResource(SYMR.strings.mangadex_preffered_source_summary),
|
||||||
entries = MdUtil.getEnabledMangaDexs(sourcePreferences)
|
entries = MdUtil.getEnabledMangaDexs(sourcePreferences)
|
||||||
@ -247,7 +250,7 @@ object SettingsMangadexScreen : SearchableSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun syncMangaDexIntoThis(sourcePreferences: SourcePreferences): Preference.PreferenceItem.TextPreference {
|
fun syncMangaDexIntoThis(unsortedPreferences: UnsortedPreferences): Preference.PreferenceItem.TextPreference {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
var dialogOpen by remember { mutableStateOf(false) }
|
var dialogOpen by remember { mutableStateOf(false) }
|
||||||
if (dialogOpen) {
|
if (dialogOpen) {
|
||||||
@ -255,7 +258,7 @@ object SettingsMangadexScreen : SearchableSettings {
|
|||||||
onDismissRequest = { dialogOpen = false },
|
onDismissRequest = { dialogOpen = false },
|
||||||
onSelectionConfirmed = { items ->
|
onSelectionConfirmed = { items ->
|
||||||
dialogOpen = false
|
dialogOpen = false
|
||||||
sourcePreferences.mangadexSyncToLibraryIndexes().set(
|
unsortedPreferences.mangadexSyncToLibraryIndexes().set(
|
||||||
List(items.size) { index -> (index + 1).toString() }.toSet(),
|
List(items.size) { index -> (index + 1).toString() }.toSet(),
|
||||||
)
|
)
|
||||||
LibraryUpdateJob.startNow(
|
LibraryUpdateJob.startNow(
|
||||||
|
@ -39,45 +39,45 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
|
|
||||||
return listOf(
|
return listOf(
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = readerPref.defaultReadingMode(),
|
pref = readerPref.defaultReadingMode(),
|
||||||
|
title = stringResource(MR.strings.pref_viewer_type),
|
||||||
entries = ReadingMode.entries.drop(1)
|
entries = ReadingMode.entries.drop(1)
|
||||||
.associate { it.flagValue to stringResource(it.stringRes) }
|
.associate { it.flagValue to stringResource(it.stringRes) }
|
||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
title = stringResource(MR.strings.pref_viewer_type),
|
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = readerPref.doubleTapAnimSpeed(),
|
pref = readerPref.doubleTapAnimSpeed(),
|
||||||
|
title = stringResource(MR.strings.pref_double_tap_anim_speed),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
1 to stringResource(MR.strings.double_tap_anim_speed_0),
|
1 to stringResource(MR.strings.double_tap_anim_speed_0),
|
||||||
500 to stringResource(MR.strings.double_tap_anim_speed_normal),
|
500 to stringResource(MR.strings.double_tap_anim_speed_normal),
|
||||||
250 to stringResource(MR.strings.double_tap_anim_speed_fast),
|
250 to stringResource(MR.strings.double_tap_anim_speed_fast),
|
||||||
),
|
),
|
||||||
title = stringResource(MR.strings.pref_double_tap_anim_speed),
|
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPref.showReadingMode(),
|
pref = readerPref.showReadingMode(),
|
||||||
title = stringResource(MR.strings.pref_show_reading_mode),
|
title = stringResource(MR.strings.pref_show_reading_mode),
|
||||||
subtitle = stringResource(MR.strings.pref_show_reading_mode_summary),
|
subtitle = stringResource(MR.strings.pref_show_reading_mode_summary),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPref.showNavigationOverlayOnStart(),
|
pref = readerPref.showNavigationOverlayOnStart(),
|
||||||
title = stringResource(MR.strings.pref_show_navigation_mode),
|
title = stringResource(MR.strings.pref_show_navigation_mode),
|
||||||
subtitle = stringResource(MR.strings.pref_show_navigation_mode_summary),
|
subtitle = stringResource(MR.strings.pref_show_navigation_mode_summary),
|
||||||
),
|
),
|
||||||
// SY -->
|
// SY -->
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPref.forceHorizontalSeekbar(),
|
pref = readerPref.forceHorizontalSeekbar(),
|
||||||
title = stringResource(SYMR.strings.pref_force_horz_seekbar),
|
title = stringResource(SYMR.strings.pref_force_horz_seekbar),
|
||||||
subtitle = stringResource(SYMR.strings.pref_force_horz_seekbar_summary),
|
subtitle = stringResource(SYMR.strings.pref_force_horz_seekbar_summary),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPref.landscapeVerticalSeekbar(),
|
pref = readerPref.landscapeVerticalSeekbar(),
|
||||||
title = stringResource(SYMR.strings.pref_show_vert_seekbar_landscape),
|
title = stringResource(SYMR.strings.pref_show_vert_seekbar_landscape),
|
||||||
subtitle = stringResource(SYMR.strings.pref_show_vert_seekbar_landscape_summary),
|
subtitle = stringResource(SYMR.strings.pref_show_vert_seekbar_landscape_summary),
|
||||||
enabled = !forceHorizontalSeekbar,
|
enabled = !forceHorizontalSeekbar,
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPref.leftVerticalSeekbar(),
|
pref = readerPref.leftVerticalSeekbar(),
|
||||||
title = stringResource(SYMR.strings.pref_left_handed_vertical_seekbar),
|
title = stringResource(SYMR.strings.pref_left_handed_vertical_seekbar),
|
||||||
subtitle = stringResource(SYMR.strings.pref_left_handed_vertical_seekbar_summary),
|
subtitle = stringResource(SYMR.strings.pref_left_handed_vertical_seekbar_summary),
|
||||||
enabled = !forceHorizontalSeekbar,
|
enabled = !forceHorizontalSeekbar,
|
||||||
@ -85,7 +85,7 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
// SY <--
|
// SY <--
|
||||||
/* SY -->
|
/* SY -->
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPref.pageTransitions(),
|
pref = readerPref.pageTransitions(),
|
||||||
title = stringResource(MR.strings.pref_page_transitions),
|
title = stringResource(MR.strings.pref_page_transitions),
|
||||||
),
|
),
|
||||||
SY <-- */
|
SY <-- */
|
||||||
@ -114,39 +114,39 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
title = stringResource(MR.strings.pref_category_display),
|
title = stringResource(MR.strings.pref_category_display),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = readerPreferences.defaultOrientationType(),
|
pref = readerPreferences.defaultOrientationType(),
|
||||||
|
title = stringResource(MR.strings.pref_rotation_type),
|
||||||
entries = ReaderOrientation.entries.drop(1)
|
entries = ReaderOrientation.entries.drop(1)
|
||||||
.associate { it.flagValue to stringResource(it.stringRes) }
|
.associate { it.flagValue to stringResource(it.stringRes) }
|
||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
title = stringResource(MR.strings.pref_rotation_type),
|
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = readerPreferences.readerTheme(),
|
pref = readerPreferences.readerTheme(),
|
||||||
|
title = stringResource(MR.strings.pref_reader_theme),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
1 to stringResource(MR.strings.black_background),
|
1 to stringResource(MR.strings.black_background),
|
||||||
2 to stringResource(MR.strings.gray_background),
|
2 to stringResource(MR.strings.gray_background),
|
||||||
0 to stringResource(MR.strings.white_background),
|
0 to stringResource(MR.strings.white_background),
|
||||||
3 to stringResource(MR.strings.automatic_background),
|
3 to stringResource(MR.strings.automatic_background),
|
||||||
),
|
),
|
||||||
title = stringResource(MR.strings.pref_reader_theme),
|
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = fullscreenPref,
|
pref = fullscreenPref,
|
||||||
title = stringResource(MR.strings.pref_fullscreen),
|
title = stringResource(MR.strings.pref_fullscreen),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.cutoutShort(),
|
pref = readerPreferences.cutoutShort(),
|
||||||
title = stringResource(MR.strings.pref_cutout_short),
|
title = stringResource(MR.strings.pref_cutout_short),
|
||||||
enabled = fullscreen &&
|
enabled = fullscreen &&
|
||||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.P &&
|
Build.VERSION.SDK_INT >= Build.VERSION_CODES.P &&
|
||||||
LocalView.current.rootWindowInsets?.displayCutout != null, // has cutout
|
LocalView.current.rootWindowInsets?.displayCutout != null, // has cutout
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.keepScreenOn(),
|
pref = readerPreferences.keepScreenOn(),
|
||||||
title = stringResource(MR.strings.pref_keep_screen_on),
|
title = stringResource(MR.strings.pref_keep_screen_on),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.showPageNumber(),
|
pref = readerPreferences.showPageNumber(),
|
||||||
title = stringResource(MR.strings.pref_show_page_number),
|
title = stringResource(MR.strings.pref_show_page_number),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -169,41 +169,43 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
title = "E-Ink",
|
title = "E-Ink",
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.flashOnPageChange(),
|
pref = readerPreferences.flashOnPageChange(),
|
||||||
title = stringResource(MR.strings.pref_flash_page),
|
title = stringResource(MR.strings.pref_flash_page),
|
||||||
subtitle = stringResource(MR.strings.pref_flash_page_summ),
|
subtitle = stringResource(MR.strings.pref_flash_page_summ),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SliderPreference(
|
Preference.PreferenceItem.SliderPreference(
|
||||||
value = flashMillis / ReaderPreferences.MILLI_CONVERSION,
|
value = flashMillis / ReaderPreferences.MILLI_CONVERSION,
|
||||||
valueRange = 1..15,
|
min = 1,
|
||||||
|
max = 15,
|
||||||
title = stringResource(MR.strings.pref_flash_duration),
|
title = stringResource(MR.strings.pref_flash_duration),
|
||||||
subtitle = stringResource(MR.strings.pref_flash_duration_summary, flashMillis),
|
subtitle = stringResource(MR.strings.pref_flash_duration_summary, flashMillis),
|
||||||
enabled = flashPageState,
|
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
flashMillisPref.set(it * ReaderPreferences.MILLI_CONVERSION)
|
flashMillisPref.set(it * ReaderPreferences.MILLI_CONVERSION)
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
|
enabled = flashPageState,
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SliderPreference(
|
Preference.PreferenceItem.SliderPreference(
|
||||||
value = flashInterval,
|
value = flashInterval,
|
||||||
valueRange = 1..10,
|
min = 1,
|
||||||
|
max = 10,
|
||||||
title = stringResource(MR.strings.pref_flash_page_interval),
|
title = stringResource(MR.strings.pref_flash_page_interval),
|
||||||
subtitle = pluralStringResource(MR.plurals.pref_pages, flashInterval, flashInterval),
|
subtitle = pluralStringResource(MR.plurals.pref_pages, flashInterval, flashInterval),
|
||||||
enabled = flashPageState,
|
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
flashIntervalPref.set(it)
|
flashIntervalPref.set(it)
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
|
enabled = flashPageState,
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = flashColorPref,
|
pref = flashColorPref,
|
||||||
|
title = stringResource(MR.strings.pref_flash_with),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
ReaderPreferences.FlashColor.BLACK to stringResource(MR.strings.pref_flash_style_black),
|
ReaderPreferences.FlashColor.BLACK to stringResource(MR.strings.pref_flash_style_black),
|
||||||
ReaderPreferences.FlashColor.WHITE to stringResource(MR.strings.pref_flash_style_white),
|
ReaderPreferences.FlashColor.WHITE to stringResource(MR.strings.pref_flash_style_white),
|
||||||
ReaderPreferences.FlashColor.WHITE_BLACK
|
ReaderPreferences.FlashColor.WHITE_BLACK
|
||||||
to stringResource(MR.strings.pref_flash_style_white_black),
|
to stringResource(MR.strings.pref_flash_style_white_black),
|
||||||
),
|
),
|
||||||
title = stringResource(MR.strings.pref_flash_with),
|
|
||||||
enabled = flashPageState,
|
enabled = flashPageState,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -216,19 +218,26 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
title = stringResource(MR.strings.pref_category_reading),
|
title = stringResource(MR.strings.pref_category_reading),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.skipRead(),
|
pref = readerPreferences.skipRead(),
|
||||||
title = stringResource(MR.strings.pref_skip_read_chapters),
|
title = stringResource(MR.strings.pref_skip_read_chapters),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.skipFiltered(),
|
pref = readerPreferences.skipFiltered(),
|
||||||
title = stringResource(MR.strings.pref_skip_filtered_chapters),
|
title = stringResource(MR.strings.pref_skip_filtered_chapters),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.skipDupe(),
|
pref = readerPreferences.skipDupe(),
|
||||||
title = stringResource(MR.strings.pref_skip_dupe_chapters),
|
title = stringResource(MR.strings.pref_skip_dupe_chapters),
|
||||||
),
|
),
|
||||||
|
// SY -->
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.alwaysShowChapterTransition(),
|
pref = readerPreferences.markReadDupe(),
|
||||||
|
title = stringResource(SYMR.strings.pref_mark_read_dupe_chapters),
|
||||||
|
subtitle = stringResource(SYMR.strings.pref_mark_read_dupe_chapters_summary),
|
||||||
|
),
|
||||||
|
// SY <--
|
||||||
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
|
pref = readerPreferences.alwaysShowChapterTransition(),
|
||||||
title = stringResource(MR.strings.pref_always_show_chapter_transition),
|
title = stringResource(MR.strings.pref_always_show_chapter_transition),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -251,15 +260,16 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
title = stringResource(MR.strings.pager_viewer),
|
title = stringResource(MR.strings.pager_viewer),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = navModePref,
|
pref = navModePref,
|
||||||
|
title = stringResource(MR.strings.pref_viewer_nav),
|
||||||
entries = ReaderPreferences.TapZones
|
entries = ReaderPreferences.TapZones
|
||||||
.mapIndexed { index, it -> index to stringResource(it) }
|
.mapIndexed { index, it -> index to stringResource(it) }
|
||||||
.toMap()
|
.toMap()
|
||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
title = stringResource(MR.strings.pref_viewer_nav),
|
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = readerPreferences.pagerNavInverted(),
|
pref = readerPreferences.pagerNavInverted(),
|
||||||
|
title = stringResource(MR.strings.pref_read_with_tapping_inverted),
|
||||||
entries = persistentListOf(
|
entries = persistentListOf(
|
||||||
ReaderPreferences.TappingInvertMode.NONE,
|
ReaderPreferences.TappingInvertMode.NONE,
|
||||||
ReaderPreferences.TappingInvertMode.HORIZONTAL,
|
ReaderPreferences.TappingInvertMode.HORIZONTAL,
|
||||||
@ -268,47 +278,46 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
)
|
)
|
||||||
.associateWith { stringResource(it.titleRes) }
|
.associateWith { stringResource(it.titleRes) }
|
||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
title = stringResource(MR.strings.pref_read_with_tapping_inverted),
|
|
||||||
enabled = navMode != 5,
|
enabled = navMode != 5,
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = imageScaleTypePref,
|
pref = imageScaleTypePref,
|
||||||
|
title = stringResource(MR.strings.pref_image_scale_type),
|
||||||
entries = ReaderPreferences.ImageScaleType
|
entries = ReaderPreferences.ImageScaleType
|
||||||
.mapIndexed { index, it -> index + 1 to stringResource(it) }
|
.mapIndexed { index, it -> index + 1 to stringResource(it) }
|
||||||
.toMap()
|
.toMap()
|
||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
title = stringResource(MR.strings.pref_image_scale_type),
|
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = readerPreferences.zoomStart(),
|
pref = readerPreferences.zoomStart(),
|
||||||
|
title = stringResource(MR.strings.pref_zoom_start),
|
||||||
entries = ReaderPreferences.ZoomStart
|
entries = ReaderPreferences.ZoomStart
|
||||||
.mapIndexed { index, it -> index + 1 to stringResource(it) }
|
.mapIndexed { index, it -> index + 1 to stringResource(it) }
|
||||||
.toMap()
|
.toMap()
|
||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
title = stringResource(MR.strings.pref_zoom_start),
|
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.cropBorders(),
|
pref = readerPreferences.cropBorders(),
|
||||||
title = stringResource(MR.strings.pref_crop_borders),
|
title = stringResource(MR.strings.pref_crop_borders),
|
||||||
),
|
),
|
||||||
// SY -->
|
// SY -->
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.pageTransitionsPager(),
|
pref = readerPreferences.pageTransitionsPager(),
|
||||||
title = stringResource(MR.strings.pref_page_transitions),
|
title = stringResource(MR.strings.pref_page_transitions),
|
||||||
),
|
),
|
||||||
// SY <--
|
// SY <--
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.landscapeZoom(),
|
pref = readerPreferences.landscapeZoom(),
|
||||||
title = stringResource(MR.strings.pref_landscape_zoom),
|
title = stringResource(MR.strings.pref_landscape_zoom),
|
||||||
enabled = imageScaleType == 1,
|
enabled = imageScaleType == 1,
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.navigateToPan(),
|
pref = readerPreferences.navigateToPan(),
|
||||||
title = stringResource(MR.strings.pref_navigate_pan),
|
title = stringResource(MR.strings.pref_navigate_pan),
|
||||||
enabled = navMode != 5,
|
enabled = navMode != 5,
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = dualPageSplitPref,
|
pref = dualPageSplitPref,
|
||||||
title = stringResource(MR.strings.pref_dual_page_split),
|
title = stringResource(MR.strings.pref_dual_page_split),
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
rotateToFitPref.set(false)
|
rotateToFitPref.set(false)
|
||||||
@ -316,13 +325,13 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.dualPageInvertPaged(),
|
pref = readerPreferences.dualPageInvertPaged(),
|
||||||
title = stringResource(MR.strings.pref_dual_page_invert),
|
title = stringResource(MR.strings.pref_dual_page_invert),
|
||||||
subtitle = stringResource(MR.strings.pref_dual_page_invert_summary),
|
subtitle = stringResource(MR.strings.pref_dual_page_invert_summary),
|
||||||
enabled = dualPageSplit,
|
enabled = dualPageSplit,
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = rotateToFitPref,
|
pref = rotateToFitPref,
|
||||||
title = stringResource(MR.strings.pref_page_rotate),
|
title = stringResource(MR.strings.pref_page_rotate),
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
dualPageSplitPref.set(false)
|
dualPageSplitPref.set(false)
|
||||||
@ -330,7 +339,7 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.dualPageRotateToFitInvert(),
|
pref = readerPreferences.dualPageRotateToFitInvert(),
|
||||||
title = stringResource(MR.strings.pref_page_rotate_invert),
|
title = stringResource(MR.strings.pref_page_rotate_invert),
|
||||||
enabled = rotateToFit,
|
enabled = rotateToFit,
|
||||||
),
|
),
|
||||||
@ -356,15 +365,16 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
title = stringResource(MR.strings.webtoon_viewer),
|
title = stringResource(MR.strings.webtoon_viewer),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = navModePref,
|
pref = navModePref,
|
||||||
|
title = stringResource(MR.strings.pref_viewer_nav),
|
||||||
entries = ReaderPreferences.TapZones
|
entries = ReaderPreferences.TapZones
|
||||||
.mapIndexed { index, it -> index to stringResource(it) }
|
.mapIndexed { index, it -> index to stringResource(it) }
|
||||||
.toMap()
|
.toMap()
|
||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
title = stringResource(MR.strings.pref_viewer_nav),
|
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = readerPreferences.webtoonNavInverted(),
|
pref = readerPreferences.webtoonNavInverted(),
|
||||||
|
title = stringResource(MR.strings.pref_read_with_tapping_inverted),
|
||||||
entries = persistentListOf(
|
entries = persistentListOf(
|
||||||
ReaderPreferences.TappingInvertMode.NONE,
|
ReaderPreferences.TappingInvertMode.NONE,
|
||||||
ReaderPreferences.TappingInvertMode.HORIZONTAL,
|
ReaderPreferences.TappingInvertMode.HORIZONTAL,
|
||||||
@ -373,37 +383,35 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
)
|
)
|
||||||
.associateWith { stringResource(it.titleRes) }
|
.associateWith { stringResource(it.titleRes) }
|
||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
title = stringResource(MR.strings.pref_read_with_tapping_inverted),
|
|
||||||
enabled = navMode != 5,
|
enabled = navMode != 5,
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SliderPreference(
|
Preference.PreferenceItem.SliderPreference(
|
||||||
value = webtoonSidePadding,
|
value = webtoonSidePadding,
|
||||||
valueRange = ReaderPreferences.let {
|
|
||||||
it.WEBTOON_PADDING_MIN..it.WEBTOON_PADDING_MAX
|
|
||||||
},
|
|
||||||
title = stringResource(MR.strings.pref_webtoon_side_padding),
|
title = stringResource(MR.strings.pref_webtoon_side_padding),
|
||||||
subtitle = numberFormat.format(webtoonSidePadding / 100f),
|
subtitle = numberFormat.format(webtoonSidePadding / 100f),
|
||||||
|
min = ReaderPreferences.WEBTOON_PADDING_MIN,
|
||||||
|
max = ReaderPreferences.WEBTOON_PADDING_MAX,
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
webtoonSidePaddingPref.set(it)
|
webtoonSidePaddingPref.set(it)
|
||||||
true
|
true
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = readerPreferences.readerHideThreshold(),
|
pref = readerPreferences.readerHideThreshold(),
|
||||||
|
title = stringResource(MR.strings.pref_hide_threshold),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
ReaderPreferences.ReaderHideThreshold.HIGHEST to stringResource(MR.strings.pref_highest),
|
ReaderPreferences.ReaderHideThreshold.HIGHEST to stringResource(MR.strings.pref_highest),
|
||||||
ReaderPreferences.ReaderHideThreshold.HIGH to stringResource(MR.strings.pref_high),
|
ReaderPreferences.ReaderHideThreshold.HIGH to stringResource(MR.strings.pref_high),
|
||||||
ReaderPreferences.ReaderHideThreshold.LOW to stringResource(MR.strings.pref_low),
|
ReaderPreferences.ReaderHideThreshold.LOW to stringResource(MR.strings.pref_low),
|
||||||
ReaderPreferences.ReaderHideThreshold.LOWEST to stringResource(MR.strings.pref_lowest),
|
ReaderPreferences.ReaderHideThreshold.LOWEST to stringResource(MR.strings.pref_lowest),
|
||||||
),
|
),
|
||||||
title = stringResource(MR.strings.pref_hide_threshold),
|
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.cropBordersWebtoon(),
|
pref = readerPreferences.cropBordersWebtoon(),
|
||||||
title = stringResource(MR.strings.pref_crop_borders),
|
title = stringResource(MR.strings.pref_crop_borders),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = dualPageSplitPref,
|
pref = dualPageSplitPref,
|
||||||
title = stringResource(MR.strings.pref_dual_page_split),
|
title = stringResource(MR.strings.pref_dual_page_split),
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
rotateToFitPref.set(false)
|
rotateToFitPref.set(false)
|
||||||
@ -411,13 +419,13 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.dualPageInvertWebtoon(),
|
pref = readerPreferences.dualPageInvertWebtoon(),
|
||||||
title = stringResource(MR.strings.pref_dual_page_invert),
|
title = stringResource(MR.strings.pref_dual_page_invert),
|
||||||
subtitle = stringResource(MR.strings.pref_dual_page_invert_summary),
|
subtitle = stringResource(MR.strings.pref_dual_page_invert_summary),
|
||||||
enabled = dualPageSplit,
|
enabled = dualPageSplit,
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = rotateToFitPref,
|
pref = rotateToFitPref,
|
||||||
title = stringResource(MR.strings.pref_page_rotate),
|
title = stringResource(MR.strings.pref_page_rotate),
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
dualPageSplitPref.set(false)
|
dualPageSplitPref.set(false)
|
||||||
@ -425,21 +433,21 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.dualPageRotateToFitInvertWebtoon(),
|
pref = readerPreferences.dualPageRotateToFitInvertWebtoon(),
|
||||||
title = stringResource(MR.strings.pref_page_rotate_invert),
|
title = stringResource(MR.strings.pref_page_rotate_invert),
|
||||||
enabled = rotateToFit,
|
enabled = rotateToFit,
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.webtoonDoubleTapZoomEnabled(),
|
pref = readerPreferences.webtoonDoubleTapZoomEnabled(),
|
||||||
title = stringResource(MR.strings.pref_double_tap_zoom),
|
title = stringResource(MR.strings.pref_double_tap_zoom),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.webtoonDisableZoomOut(),
|
pref = readerPreferences.webtoonDisableZoomOut(),
|
||||||
title = stringResource(MR.strings.pref_webtoon_disable_zoom_out),
|
title = stringResource(MR.strings.pref_webtoon_disable_zoom_out),
|
||||||
),
|
),
|
||||||
// SY -->
|
// SY -->
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.pageTransitionsWebtoon(),
|
pref = readerPreferences.pageTransitionsWebtoon(),
|
||||||
title = stringResource(MR.strings.pref_page_transitions),
|
title = stringResource(MR.strings.pref_page_transitions),
|
||||||
),
|
),
|
||||||
// SY <--
|
// SY <--
|
||||||
@ -454,12 +462,12 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
title = stringResource(MR.strings.vertical_plus_viewer),
|
title = stringResource(MR.strings.vertical_plus_viewer),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.continuousVerticalTappingByPage(),
|
pref = readerPreferences.continuousVerticalTappingByPage(),
|
||||||
title = stringResource(SYMR.strings.tap_scroll_page),
|
title = stringResource(SYMR.strings.tap_scroll_page),
|
||||||
subtitle = stringResource(SYMR.strings.tap_scroll_page_summary),
|
subtitle = stringResource(SYMR.strings.tap_scroll_page_summary),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.cropBordersContinuousVertical(),
|
pref = readerPreferences.cropBordersContinuousVertical(),
|
||||||
title = stringResource(MR.strings.pref_crop_borders),
|
title = stringResource(MR.strings.pref_crop_borders),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -475,11 +483,11 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
title = stringResource(MR.strings.pref_reader_navigation),
|
title = stringResource(MR.strings.pref_reader_navigation),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readWithVolumeKeysPref,
|
pref = readWithVolumeKeysPref,
|
||||||
title = stringResource(MR.strings.pref_read_with_volume_keys),
|
title = stringResource(MR.strings.pref_read_with_volume_keys),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.readWithVolumeKeysInverted(),
|
pref = readerPreferences.readWithVolumeKeysInverted(),
|
||||||
title = stringResource(MR.strings.pref_read_with_volume_keys_inverted),
|
title = stringResource(MR.strings.pref_read_with_volume_keys_inverted),
|
||||||
enabled = readWithVolumeKeys,
|
enabled = readWithVolumeKeys,
|
||||||
),
|
),
|
||||||
@ -493,11 +501,11 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
title = stringResource(MR.strings.pref_reader_actions),
|
title = stringResource(MR.strings.pref_reader_actions),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.readWithLongTap(),
|
pref = readerPreferences.readWithLongTap(),
|
||||||
title = stringResource(MR.strings.pref_read_with_long_tap),
|
title = stringResource(MR.strings.pref_read_with_long_tap),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.folderPerManga(),
|
pref = readerPreferences.folderPerManga(),
|
||||||
title = stringResource(MR.strings.pref_create_folder_per_manga),
|
title = stringResource(MR.strings.pref_create_folder_per_manga),
|
||||||
subtitle = stringResource(MR.strings.pref_create_folder_per_manga_summary),
|
subtitle = stringResource(MR.strings.pref_create_folder_per_manga_summary),
|
||||||
),
|
),
|
||||||
@ -512,7 +520,7 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
title = stringResource(SYMR.strings.page_downloading),
|
title = stringResource(SYMR.strings.page_downloading),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = readerPreferences.preloadSize(),
|
pref = readerPreferences.preloadSize(),
|
||||||
title = stringResource(SYMR.strings.reader_preload_amount),
|
title = stringResource(SYMR.strings.reader_preload_amount),
|
||||||
subtitle = stringResource(SYMR.strings.reader_preload_amount_summary),
|
subtitle = stringResource(SYMR.strings.reader_preload_amount_summary),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
@ -527,13 +535,13 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = readerPreferences.readerThreads(),
|
pref = readerPreferences.readerThreads(),
|
||||||
title = stringResource(SYMR.strings.download_threads),
|
title = stringResource(SYMR.strings.download_threads),
|
||||||
subtitle = stringResource(SYMR.strings.download_threads_summary),
|
subtitle = stringResource(SYMR.strings.download_threads_summary),
|
||||||
entries = List(5) { it }.associateWith { it.toString() }.toImmutableMap(),
|
entries = List(5) { it }.associateWith { it.toString() }.toImmutableMap(),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = readerPreferences.cacheSize(),
|
pref = readerPreferences.cacheSize(),
|
||||||
title = stringResource(SYMR.strings.reader_cache_size),
|
title = stringResource(SYMR.strings.reader_cache_size),
|
||||||
subtitle = stringResource(SYMR.strings.reader_cache_size_summary),
|
subtitle = stringResource(SYMR.strings.reader_cache_size_summary),
|
||||||
entries = persistentMapOf(
|
entries = persistentMapOf(
|
||||||
@ -556,7 +564,7 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.aggressivePageLoading(),
|
pref = readerPreferences.aggressivePageLoading(),
|
||||||
title = stringResource(SYMR.strings.aggressively_load_pages),
|
title = stringResource(SYMR.strings.aggressively_load_pages),
|
||||||
subtitle = stringResource(SYMR.strings.aggressively_load_pages_summary),
|
subtitle = stringResource(SYMR.strings.aggressively_load_pages_summary),
|
||||||
),
|
),
|
||||||
@ -571,21 +579,21 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
title = stringResource(SYMR.strings.pref_category_fork),
|
title = stringResource(SYMR.strings.pref_category_fork),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.readerInstantRetry(),
|
pref = readerPreferences.readerInstantRetry(),
|
||||||
title = stringResource(SYMR.strings.skip_queue_on_retry),
|
title = stringResource(SYMR.strings.skip_queue_on_retry),
|
||||||
subtitle = stringResource(SYMR.strings.skip_queue_on_retry_summary),
|
subtitle = stringResource(SYMR.strings.skip_queue_on_retry_summary),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.preserveReadingPosition(),
|
pref = readerPreferences.preserveReadingPosition(),
|
||||||
title = stringResource(SYMR.strings.preserve_reading_position),
|
title = stringResource(SYMR.strings.preserve_reading_position),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.useAutoWebtoon(),
|
pref = readerPreferences.useAutoWebtoon(),
|
||||||
title = stringResource(SYMR.strings.auto_webtoon_mode),
|
title = stringResource(SYMR.strings.auto_webtoon_mode),
|
||||||
subtitle = stringResource(SYMR.strings.auto_webtoon_mode_summary),
|
subtitle = stringResource(SYMR.strings.auto_webtoon_mode_summary),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.MultiSelectListPreference(
|
Preference.PreferenceItem.MultiSelectListPreference(
|
||||||
preference = readerPreferences.readerBottomButtons(),
|
pref = readerPreferences.readerBottomButtons(),
|
||||||
title = stringResource(SYMR.strings.reader_bottom_buttons),
|
title = stringResource(SYMR.strings.reader_bottom_buttons),
|
||||||
subtitle = stringResource(SYMR.strings.reader_bottom_buttons_summary),
|
subtitle = stringResource(SYMR.strings.reader_bottom_buttons_summary),
|
||||||
entries = ReaderBottomButton.entries
|
entries = ReaderBottomButton.entries
|
||||||
@ -593,7 +601,7 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = readerPreferences.pageLayout(),
|
pref = readerPreferences.pageLayout(),
|
||||||
title = stringResource(SYMR.strings.page_layout),
|
title = stringResource(SYMR.strings.page_layout),
|
||||||
subtitle = stringResource(SYMR.strings.automatic_can_still_switch),
|
subtitle = stringResource(SYMR.strings.automatic_can_still_switch),
|
||||||
entries = ReaderPreferences.PageLayouts
|
entries = ReaderPreferences.PageLayouts
|
||||||
@ -602,12 +610,12 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = readerPreferences.invertDoublePages(),
|
pref = readerPreferences.invertDoublePages(),
|
||||||
title = stringResource(SYMR.strings.invert_double_pages),
|
title = stringResource(SYMR.strings.invert_double_pages),
|
||||||
enabled = pageLayout != PagerConfig.PageLayout.SINGLE_PAGE,
|
enabled = pageLayout != PagerConfig.PageLayout.SINGLE_PAGE,
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = readerPreferences.centerMarginType(),
|
pref = readerPreferences.centerMarginType(),
|
||||||
title = stringResource(SYMR.strings.center_margin),
|
title = stringResource(SYMR.strings.center_margin),
|
||||||
subtitle = stringResource(SYMR.strings.pref_center_margin_summary),
|
subtitle = stringResource(SYMR.strings.pref_center_margin_summary),
|
||||||
entries = ReaderPreferences.CenterMarginTypes
|
entries = ReaderPreferences.CenterMarginTypes
|
||||||
@ -616,7 +624,7 @@ object SettingsReaderScreen : SearchableSettings {
|
|||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = readerPreferences.archiveReaderMode(),
|
pref = readerPreferences.archiveReaderMode(),
|
||||||
title = stringResource(SYMR.strings.pref_archive_reader_mode),
|
title = stringResource(SYMR.strings.pref_archive_reader_mode),
|
||||||
subtitle = stringResource(SYMR.strings.pref_archive_reader_mode_summary),
|
subtitle = stringResource(SYMR.strings.pref_archive_reader_mode_summary),
|
||||||
entries = ReaderPreferences.archiveModeTypes
|
entries = ReaderPreferences.archiveModeTypes
|
||||||
|
@ -96,7 +96,7 @@ object SettingsSecurityScreen : SearchableSettings {
|
|||||||
title = stringResource(MR.strings.pref_security),
|
title = stringResource(MR.strings.pref_security),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = useAuthPref,
|
pref = useAuthPref,
|
||||||
title = stringResource(MR.strings.lock_with_biometrics),
|
title = stringResource(MR.strings.lock_with_biometrics),
|
||||||
enabled = authSupported,
|
enabled = authSupported,
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
@ -106,7 +106,9 @@ object SettingsSecurityScreen : SearchableSettings {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = securityPreferences.lockAppAfter(),
|
pref = securityPreferences.lockAppAfter(),
|
||||||
|
title = stringResource(MR.strings.lock_when_idle),
|
||||||
|
enabled = authSupported && useAuth,
|
||||||
entries = LockAfterValues
|
entries = LockAfterValues
|
||||||
.associateWith {
|
.associateWith {
|
||||||
when (it) {
|
when (it) {
|
||||||
@ -116,8 +118,6 @@ object SettingsSecurityScreen : SearchableSettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
title = stringResource(MR.strings.lock_when_idle),
|
|
||||||
enabled = authSupported && useAuth,
|
|
||||||
onValueChanged = {
|
onValueChanged = {
|
||||||
(context as FragmentActivity).authenticate(
|
(context as FragmentActivity).authenticate(
|
||||||
title = context.stringResource(MR.strings.lock_when_idle),
|
title = context.stringResource(MR.strings.lock_when_idle),
|
||||||
@ -125,25 +125,25 @@ object SettingsSecurityScreen : SearchableSettings {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = securityPreferences.hideNotificationContent(),
|
pref = securityPreferences.hideNotificationContent(),
|
||||||
title = stringResource(MR.strings.hide_notification_content),
|
title = stringResource(MR.strings.hide_notification_content),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = securityPreferences.secureScreen(),
|
pref = securityPreferences.secureScreen(),
|
||||||
|
title = stringResource(MR.strings.secure_screen),
|
||||||
entries = SecurityPreferences.SecureScreenMode.entries
|
entries = SecurityPreferences.SecureScreenMode.entries
|
||||||
.associateWith { stringResource(it.titleRes) }
|
.associateWith { stringResource(it.titleRes) }
|
||||||
.toImmutableMap(),
|
.toImmutableMap(),
|
||||||
title = stringResource(MR.strings.secure_screen),
|
|
||||||
),
|
),
|
||||||
// SY -->
|
// SY -->
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = securityPreferences.passwordProtectDownloads(),
|
pref = securityPreferences.passwordProtectDownloads(),
|
||||||
title = stringResource(SYMR.strings.password_protect_downloads),
|
title = stringResource(SYMR.strings.password_protect_downloads),
|
||||||
subtitle = stringResource(SYMR.strings.password_protect_downloads_summary),
|
subtitle = stringResource(SYMR.strings.password_protect_downloads_summary),
|
||||||
enabled = isCbzPasswordSet,
|
enabled = isCbzPasswordSet,
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = securityPreferences.encryptionType(),
|
pref = securityPreferences.encryptionType(),
|
||||||
title = stringResource(SYMR.strings.encryption_type),
|
title = stringResource(SYMR.strings.encryption_type),
|
||||||
entries = SecurityPreferences.EncryptionType.entries
|
entries = SecurityPreferences.EncryptionType.entries
|
||||||
.associateWith { stringResource(it.titleRes) }
|
.associateWith { stringResource(it.titleRes) }
|
||||||
@ -384,12 +384,12 @@ object SettingsSecurityScreen : SearchableSettings {
|
|||||||
title = stringResource(MR.strings.pref_firebase),
|
title = stringResource(MR.strings.pref_firebase),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = privacyPreferences.crashlytics(),
|
pref = privacyPreferences.crashlytics(),
|
||||||
title = stringResource(MR.strings.onboarding_permission_crashlytics),
|
title = stringResource(MR.strings.onboarding_permission_crashlytics),
|
||||||
subtitle = stringResource(MR.strings.onboarding_permission_crashlytics_description),
|
subtitle = stringResource(MR.strings.onboarding_permission_crashlytics_description),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = privacyPreferences.analytics(),
|
pref = privacyPreferences.analytics(),
|
||||||
title = stringResource(MR.strings.onboarding_permission_analytics),
|
title = stringResource(MR.strings.onboarding_permission_analytics),
|
||||||
subtitle = stringResource(MR.strings.onboarding_permission_analytics_description),
|
subtitle = stringResource(MR.strings.onboarding_permission_analytics_description),
|
||||||
),
|
),
|
||||||
|
@ -30,11 +30,8 @@ import androidx.compose.runtime.rememberCoroutineScope
|
|||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.autofill.ContentType
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalUriHandler
|
import androidx.compose.ui.platform.LocalUriHandler
|
||||||
import androidx.compose.ui.semantics.contentType
|
|
||||||
import androidx.compose.ui.semantics.semantics
|
|
||||||
import androidx.compose.ui.text.input.ImeAction
|
import androidx.compose.ui.text.input.ImeAction
|
||||||
import androidx.compose.ui.text.input.KeyboardType
|
import androidx.compose.ui.text.input.KeyboardType
|
||||||
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
import androidx.compose.ui.text.input.PasswordVisualTransformation
|
||||||
@ -62,7 +59,6 @@ import tachiyomi.core.common.util.lang.launchIO
|
|||||||
import tachiyomi.core.common.util.lang.withUIContext
|
import tachiyomi.core.common.util.lang.withUIContext
|
||||||
import tachiyomi.domain.source.service.SourceManager
|
import tachiyomi.domain.source.service.SourceManager
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import tachiyomi.i18n.sy.SYMR
|
|
||||||
import tachiyomi.presentation.core.components.material.padding
|
import tachiyomi.presentation.core.components.material.padding
|
||||||
import tachiyomi.presentation.core.i18n.stringResource
|
import tachiyomi.presentation.core.i18n.stringResource
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
@ -129,52 +125,51 @@ object SettingsTrackingScreen : SearchableSettings {
|
|||||||
|
|
||||||
return listOf(
|
return listOf(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
preference = trackPreferences.autoUpdateTrack(),
|
pref = trackPreferences.autoUpdateTrack(),
|
||||||
title = stringResource(MR.strings.pref_auto_update_manga_sync),
|
title = stringResource(MR.strings.pref_auto_update_manga_sync),
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.ListPreference(
|
Preference.PreferenceItem.ListPreference(
|
||||||
preference = trackPreferences.autoUpdateTrackOnMarkRead(),
|
pref = trackPreferences.autoUpdateTrackOnMarkRead(),
|
||||||
|
title = stringResource(MR.strings.pref_auto_update_manga_on_mark_read),
|
||||||
entries = AutoTrackState.entries
|
entries = AutoTrackState.entries
|
||||||
.associateWith { stringResource(it.titleRes) }
|
.associateWith { stringResource(it.titleRes) }
|
||||||
.toPersistentMap(),
|
.toPersistentMap(),
|
||||||
title = stringResource(MR.strings.pref_auto_update_manga_on_mark_read),
|
|
||||||
),
|
),
|
||||||
// SY -->
|
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
|
||||||
preference = trackPreferences.resolveUsingSourceMetadata(),
|
|
||||||
title = stringResource(SYMR.strings.pref_tracker_resolve_using_source_metadata),
|
|
||||||
subtitle = stringResource(SYMR.strings.pref_tracker_resolve_using_source_metadata_summary),
|
|
||||||
),
|
|
||||||
// SY <--
|
|
||||||
Preference.PreferenceGroup(
|
Preference.PreferenceGroup(
|
||||||
title = stringResource(MR.strings.services),
|
title = stringResource(MR.strings.services),
|
||||||
preferenceItems = persistentListOf(
|
preferenceItems = persistentListOf(
|
||||||
Preference.PreferenceItem.TrackerPreference(
|
Preference.PreferenceItem.TrackerPreference(
|
||||||
|
title = trackerManager.myAnimeList.name,
|
||||||
tracker = trackerManager.myAnimeList,
|
tracker = trackerManager.myAnimeList,
|
||||||
login = { context.openInBrowser(MyAnimeListApi.authUrl(), forceDefaultBrowser = true) },
|
login = { context.openInBrowser(MyAnimeListApi.authUrl(), forceDefaultBrowser = true) },
|
||||||
logout = { dialog = LogoutDialog(trackerManager.myAnimeList) },
|
logout = { dialog = LogoutDialog(trackerManager.myAnimeList) },
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.TrackerPreference(
|
Preference.PreferenceItem.TrackerPreference(
|
||||||
|
title = trackerManager.aniList.name,
|
||||||
tracker = trackerManager.aniList,
|
tracker = trackerManager.aniList,
|
||||||
login = { context.openInBrowser(AnilistApi.authUrl(), forceDefaultBrowser = true) },
|
login = { context.openInBrowser(AnilistApi.authUrl(), forceDefaultBrowser = true) },
|
||||||
logout = { dialog = LogoutDialog(trackerManager.aniList) },
|
logout = { dialog = LogoutDialog(trackerManager.aniList) },
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.TrackerPreference(
|
Preference.PreferenceItem.TrackerPreference(
|
||||||
|
title = trackerManager.kitsu.name,
|
||||||
tracker = trackerManager.kitsu,
|
tracker = trackerManager.kitsu,
|
||||||
login = { dialog = LoginDialog(trackerManager.kitsu, MR.strings.email) },
|
login = { dialog = LoginDialog(trackerManager.kitsu, MR.strings.email) },
|
||||||
logout = { dialog = LogoutDialog(trackerManager.kitsu) },
|
logout = { dialog = LogoutDialog(trackerManager.kitsu) },
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.TrackerPreference(
|
Preference.PreferenceItem.TrackerPreference(
|
||||||
|
title = trackerManager.mangaUpdates.name,
|
||||||
tracker = trackerManager.mangaUpdates,
|
tracker = trackerManager.mangaUpdates,
|
||||||
login = { dialog = LoginDialog(trackerManager.mangaUpdates, MR.strings.username) },
|
login = { dialog = LoginDialog(trackerManager.mangaUpdates, MR.strings.username) },
|
||||||
logout = { dialog = LogoutDialog(trackerManager.mangaUpdates) },
|
logout = { dialog = LogoutDialog(trackerManager.mangaUpdates) },
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.TrackerPreference(
|
Preference.PreferenceItem.TrackerPreference(
|
||||||
|
title = trackerManager.shikimori.name,
|
||||||
tracker = trackerManager.shikimori,
|
tracker = trackerManager.shikimori,
|
||||||
login = { context.openInBrowser(ShikimoriApi.authUrl(), forceDefaultBrowser = true) },
|
login = { context.openInBrowser(ShikimoriApi.authUrl(), forceDefaultBrowser = true) },
|
||||||
logout = { dialog = LogoutDialog(trackerManager.shikimori) },
|
logout = { dialog = LogoutDialog(trackerManager.shikimori) },
|
||||||
),
|
),
|
||||||
Preference.PreferenceItem.TrackerPreference(
|
Preference.PreferenceItem.TrackerPreference(
|
||||||
|
title = trackerManager.bangumi.name,
|
||||||
tracker = trackerManager.bangumi,
|
tracker = trackerManager.bangumi,
|
||||||
login = { context.openInBrowser(BangumiApi.authUrl(), forceDefaultBrowser = true) },
|
login = { context.openInBrowser(BangumiApi.authUrl(), forceDefaultBrowser = true) },
|
||||||
logout = { dialog = LogoutDialog(trackerManager.bangumi) },
|
logout = { dialog = LogoutDialog(trackerManager.bangumi) },
|
||||||
@ -188,6 +183,7 @@ object SettingsTrackingScreen : SearchableSettings {
|
|||||||
enhancedTrackers.first
|
enhancedTrackers.first
|
||||||
.map { service ->
|
.map { service ->
|
||||||
Preference.PreferenceItem.TrackerPreference(
|
Preference.PreferenceItem.TrackerPreference(
|
||||||
|
title = service.name,
|
||||||
tracker = service,
|
tracker = service,
|
||||||
login = { (service as EnhancedTracker).loginNoop() },
|
login = { (service as EnhancedTracker).loginNoop() },
|
||||||
logout = service::logout,
|
logout = service::logout,
|
||||||
@ -231,9 +227,7 @@ object SettingsTrackingScreen : SearchableSettings {
|
|||||||
text = {
|
text = {
|
||||||
Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
|
Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
modifier = Modifier
|
modifier = Modifier.fillMaxWidth(),
|
||||||
.fillMaxWidth()
|
|
||||||
.semantics { contentType = ContentType.Username + ContentType.EmailAddress },
|
|
||||||
value = username,
|
value = username,
|
||||||
onValueChange = { username = it },
|
onValueChange = { username = it },
|
||||||
label = { Text(text = stringResource(uNameStringRes)) },
|
label = { Text(text = stringResource(uNameStringRes)) },
|
||||||
@ -244,9 +238,7 @@ object SettingsTrackingScreen : SearchableSettings {
|
|||||||
|
|
||||||
var hidePassword by remember { mutableStateOf(true) }
|
var hidePassword by remember { mutableStateOf(true) }
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
modifier = Modifier
|
modifier = Modifier.fillMaxWidth(),
|
||||||
.fillMaxWidth()
|
|
||||||
.semantics { contentType = ContentType.Password },
|
|
||||||
value = password,
|
value = password,
|
||||||
onValueChange = { password = it },
|
onValueChange = { password = it },
|
||||||
label = { Text(text = stringResource(MR.strings.password)) },
|
label = { Text(text = stringResource(MR.strings.password)) },
|
||||||
@ -295,7 +287,7 @@ object SettingsTrackingScreen : SearchableSettings {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
val id = if (processing) MR.strings.logging_in else MR.strings.login
|
val id = if (processing) MR.strings.loading else MR.strings.login
|
||||||
Text(text = stringResource(id))
|
Text(text = stringResource(id))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -6,7 +6,7 @@ import androidx.compose.ui.Modifier
|
|||||||
import cafe.adriel.voyager.navigator.LocalNavigator
|
import cafe.adriel.voyager.navigator.LocalNavigator
|
||||||
import cafe.adriel.voyager.navigator.currentOrThrow
|
import cafe.adriel.voyager.navigator.currentOrThrow
|
||||||
import com.mikepenz.aboutlibraries.ui.compose.m3.LibrariesContainer
|
import com.mikepenz.aboutlibraries.ui.compose.m3.LibrariesContainer
|
||||||
import com.mikepenz.aboutlibraries.ui.compose.util.htmlReadyLicenseContent
|
import com.mikepenz.aboutlibraries.ui.compose.m3.util.htmlReadyLicenseContent
|
||||||
import eu.kanade.presentation.components.AppBar
|
import eu.kanade.presentation.components.AppBar
|
||||||
import eu.kanade.presentation.util.Screen
|
import eu.kanade.presentation.util.Screen
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package eu.kanade.presentation.more.settings.screen.advanced
|
package eu.kanade.presentation.more.settings.screen.advanced
|
||||||
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.lazy.items
|
import androidx.compose.foundation.lazy.items
|
||||||
@ -14,7 +12,6 @@ import androidx.compose.material.icons.outlined.SelectAll
|
|||||||
import androidx.compose.material3.AlertDialog
|
import androidx.compose.material3.AlertDialog
|
||||||
import androidx.compose.material3.Checkbox
|
import androidx.compose.material3.Checkbox
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Switch
|
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TextButton
|
import androidx.compose.material3.TextButton
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@ -45,16 +42,16 @@ import kotlinx.coroutines.flow.collectLatest
|
|||||||
import kotlinx.coroutines.flow.update
|
import kotlinx.coroutines.flow.update
|
||||||
import tachiyomi.core.common.util.lang.launchIO
|
import tachiyomi.core.common.util.lang.launchIO
|
||||||
import tachiyomi.core.common.util.lang.launchUI
|
import tachiyomi.core.common.util.lang.launchUI
|
||||||
import tachiyomi.core.common.util.lang.toLong
|
|
||||||
import tachiyomi.core.common.util.lang.withNonCancellableContext
|
import tachiyomi.core.common.util.lang.withNonCancellableContext
|
||||||
import tachiyomi.data.Database
|
import tachiyomi.data.Database
|
||||||
import tachiyomi.domain.source.interactor.GetSourcesWithNonLibraryManga
|
import tachiyomi.domain.source.interactor.GetSourcesWithNonLibraryManga
|
||||||
import tachiyomi.domain.source.model.Source
|
import tachiyomi.domain.source.model.Source
|
||||||
import tachiyomi.domain.source.model.SourceWithCount
|
import tachiyomi.domain.source.model.SourceWithCount
|
||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
|
import tachiyomi.i18n.sy.SYMR
|
||||||
|
import tachiyomi.presentation.core.components.LabeledCheckbox
|
||||||
import tachiyomi.presentation.core.components.LazyColumnWithAction
|
import tachiyomi.presentation.core.components.LazyColumnWithAction
|
||||||
import tachiyomi.presentation.core.components.material.Scaffold
|
import tachiyomi.presentation.core.components.material.Scaffold
|
||||||
import tachiyomi.presentation.core.components.material.padding
|
|
||||||
import tachiyomi.presentation.core.i18n.stringResource
|
import tachiyomi.presentation.core.i18n.stringResource
|
||||||
import tachiyomi.presentation.core.screens.EmptyScreen
|
import tachiyomi.presentation.core.screens.EmptyScreen
|
||||||
import tachiyomi.presentation.core.screens.LoadingScreen
|
import tachiyomi.presentation.core.screens.LoadingScreen
|
||||||
@ -76,45 +73,18 @@ class ClearDatabaseScreen : Screen() {
|
|||||||
is ClearDatabaseScreenModel.State.Loading -> LoadingScreen()
|
is ClearDatabaseScreenModel.State.Loading -> LoadingScreen()
|
||||||
is ClearDatabaseScreenModel.State.Ready -> {
|
is ClearDatabaseScreenModel.State.Ready -> {
|
||||||
if (s.showConfirmation) {
|
if (s.showConfirmation) {
|
||||||
|
// SY -->
|
||||||
var keepReadManga by remember { mutableStateOf(true) }
|
var keepReadManga by remember { mutableStateOf(true) }
|
||||||
|
// SY <--
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
title = {
|
|
||||||
Text(text = stringResource(MR.strings.are_you_sure))
|
|
||||||
},
|
|
||||||
text = {
|
|
||||||
Column(
|
|
||||||
verticalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
|
|
||||||
) {
|
|
||||||
Text(text = stringResource(MR.strings.clear_database_text))
|
|
||||||
Row(
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.extraSmall),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = stringResource(MR.strings.clear_db_exclude_read),
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
)
|
|
||||||
Switch(
|
|
||||||
checked = keepReadManga,
|
|
||||||
onCheckedChange = { keepReadManga = it },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (!keepReadManga) {
|
|
||||||
Text(
|
|
||||||
text = stringResource(MR.strings.clear_database_history_warning),
|
|
||||||
style = MaterialTheme.typography.bodySmall,
|
|
||||||
color = MaterialTheme.colorScheme.error,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onDismissRequest = model::hideConfirmation,
|
onDismissRequest = model::hideConfirmation,
|
||||||
confirmButton = {
|
confirmButton = {
|
||||||
TextButton(
|
TextButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
scope.launchUI {
|
scope.launchUI {
|
||||||
|
// SY -->
|
||||||
model.removeMangaBySourceId(keepReadManga)
|
model.removeMangaBySourceId(keepReadManga)
|
||||||
|
// SY <--
|
||||||
model.clearSelection()
|
model.clearSelection()
|
||||||
model.hideConfirmation()
|
model.hideConfirmation()
|
||||||
context.toast(MR.strings.clear_database_completed)
|
context.toast(MR.strings.clear_database_completed)
|
||||||
@ -129,6 +99,20 @@ class ClearDatabaseScreen : Screen() {
|
|||||||
Text(text = stringResource(MR.strings.action_cancel))
|
Text(text = stringResource(MR.strings.action_cancel))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
text = {
|
||||||
|
// SY -->
|
||||||
|
Column {
|
||||||
|
// SY <--
|
||||||
|
Text(text = stringResource(MR.strings.clear_database_confirmation))
|
||||||
|
// SY -->
|
||||||
|
LabeledCheckbox(
|
||||||
|
label = stringResource(SYMR.strings.clear_db_exclude_read),
|
||||||
|
checked = keepReadManga,
|
||||||
|
onCheckedChange = { keepReadManga = it },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
// SY <--
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,9 +224,15 @@ private class ClearDatabaseScreenModel : StateScreenModel<ClearDatabaseScreenMod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun removeMangaBySourceId(keepReadManga: Boolean) = withNonCancellableContext {
|
suspend fun removeMangaBySourceId(/* SY --> */keepReadManga: Boolean /* SY <-- */) = withNonCancellableContext {
|
||||||
val state = state.value as? State.Ready ?: return@withNonCancellableContext
|
val state = state.value as? State.Ready ?: return@withNonCancellableContext
|
||||||
database.mangasQueries.deleteNonLibraryManga(state.selection, keepReadManga.toLong())
|
// SY -->
|
||||||
|
if (keepReadManga) {
|
||||||
|
database.mangasQueries.deleteMangasNotInLibraryAndNotReadBySourceIds(state.selection)
|
||||||
|
} else {
|
||||||
|
database.mangasQueries.deleteMangasNotInLibraryBySourceIds(state.selection)
|
||||||
|
}
|
||||||
|
// SY <--
|
||||||
database.historyQueries.removeResettedHistory()
|
database.historyQueries.removeResettedHistory()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ import androidx.compose.runtime.remember
|
|||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.composed
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
@ -85,8 +86,7 @@ internal fun BasePreferenceWidget(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
internal fun Modifier.highlightBackground(highlighted: Boolean): Modifier = composed {
|
||||||
internal fun Modifier.highlightBackground(highlighted: Boolean): Modifier {
|
|
||||||
var highlightFlag by remember { mutableStateOf(false) }
|
var highlightFlag by remember { mutableStateOf(false) }
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
if (highlighted) {
|
if (highlighted) {
|
||||||
@ -116,7 +116,7 @@ internal fun Modifier.highlightBackground(highlighted: Boolean): Modifier {
|
|||||||
},
|
},
|
||||||
label = "highlight",
|
label = "highlight",
|
||||||
)
|
)
|
||||||
return this.background(color = highlight)
|
Modifier.background(color = highlight)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val TrailingWidgetBuffer = 16.dp
|
internal val TrailingWidgetBuffer = 16.dp
|
||||||
|
@ -31,7 +31,6 @@ fun EditTextPreferenceWidget(
|
|||||||
subtitle: String?,
|
subtitle: String?,
|
||||||
icon: ImageVector?,
|
icon: ImageVector?,
|
||||||
value: String,
|
value: String,
|
||||||
widget: @Composable (() -> Unit)? = null,
|
|
||||||
onConfirm: suspend (String) -> Boolean,
|
onConfirm: suspend (String) -> Boolean,
|
||||||
) {
|
) {
|
||||||
var isDialogShown by remember { mutableStateOf(false) }
|
var isDialogShown by remember { mutableStateOf(false) }
|
||||||
@ -40,7 +39,6 @@ fun EditTextPreferenceWidget(
|
|||||||
title = title,
|
title = title,
|
||||||
subtitle = subtitle?.format(value),
|
subtitle = subtitle?.format(value),
|
||||||
icon = icon,
|
icon = icon,
|
||||||
widget = widget,
|
|
||||||
onPreferenceClick = { isDialogShown = true },
|
onPreferenceClick = { isDialogShown = true },
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package eu.kanade.presentation.reader.settings
|
|||||||
|
|
||||||
import androidx.compose.foundation.layout.ColumnScope
|
import androidx.compose.foundation.layout.ColumnScope
|
||||||
import androidx.compose.material3.FilterChip
|
import androidx.compose.material3.FilterChip
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
@ -37,12 +36,12 @@ internal fun ColumnScope.ColorFilterPage(screenModel: ReaderSettingsScreenModel)
|
|||||||
if (customBrightness) {
|
if (customBrightness) {
|
||||||
val customBrightnessValue by screenModel.preferences.customBrightnessValue().collectAsState()
|
val customBrightnessValue by screenModel.preferences.customBrightnessValue().collectAsState()
|
||||||
SliderItem(
|
SliderItem(
|
||||||
value = customBrightnessValue,
|
|
||||||
valueRange = -75..100,
|
|
||||||
steps = 0,
|
|
||||||
label = stringResource(MR.strings.pref_custom_brightness),
|
label = stringResource(MR.strings.pref_custom_brightness),
|
||||||
|
min = -75,
|
||||||
|
max = 100,
|
||||||
|
value = customBrightnessValue,
|
||||||
|
valueText = customBrightnessValue.toString(),
|
||||||
onChange = { screenModel.preferences.customBrightnessValue().set(it) },
|
onChange = { screenModel.preferences.customBrightnessValue().set(it) },
|
||||||
pillColor = MaterialTheme.colorScheme.surfaceContainerHighest,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,52 +53,48 @@ internal fun ColumnScope.ColorFilterPage(screenModel: ReaderSettingsScreenModel)
|
|||||||
if (colorFilter) {
|
if (colorFilter) {
|
||||||
val colorFilterValue by screenModel.preferences.colorFilterValue().collectAsState()
|
val colorFilterValue by screenModel.preferences.colorFilterValue().collectAsState()
|
||||||
SliderItem(
|
SliderItem(
|
||||||
value = colorFilterValue.red,
|
|
||||||
valueRange = 0..255,
|
|
||||||
steps = 0,
|
|
||||||
label = stringResource(MR.strings.color_filter_r_value),
|
label = stringResource(MR.strings.color_filter_r_value),
|
||||||
|
max = 255,
|
||||||
|
value = colorFilterValue.red,
|
||||||
|
valueText = colorFilterValue.red.toString(),
|
||||||
onChange = { newRValue ->
|
onChange = { newRValue ->
|
||||||
screenModel.preferences.colorFilterValue().getAndSet {
|
screenModel.preferences.colorFilterValue().getAndSet {
|
||||||
getColorValue(it, newRValue, RED_MASK, 16)
|
getColorValue(it, newRValue, RED_MASK, 16)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pillColor = MaterialTheme.colorScheme.surfaceContainerHighest,
|
|
||||||
)
|
)
|
||||||
SliderItem(
|
SliderItem(
|
||||||
value = colorFilterValue.green,
|
|
||||||
valueRange = 0..255,
|
|
||||||
steps = 0,
|
|
||||||
label = stringResource(MR.strings.color_filter_g_value),
|
label = stringResource(MR.strings.color_filter_g_value),
|
||||||
|
max = 255,
|
||||||
|
value = colorFilterValue.green,
|
||||||
|
valueText = colorFilterValue.green.toString(),
|
||||||
onChange = { newGValue ->
|
onChange = { newGValue ->
|
||||||
screenModel.preferences.colorFilterValue().getAndSet {
|
screenModel.preferences.colorFilterValue().getAndSet {
|
||||||
getColorValue(it, newGValue, GREEN_MASK, 8)
|
getColorValue(it, newGValue, GREEN_MASK, 8)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pillColor = MaterialTheme.colorScheme.surfaceContainerHighest,
|
|
||||||
)
|
)
|
||||||
SliderItem(
|
SliderItem(
|
||||||
value = colorFilterValue.blue,
|
|
||||||
valueRange = 0..255,
|
|
||||||
steps = 0,
|
|
||||||
label = stringResource(MR.strings.color_filter_b_value),
|
label = stringResource(MR.strings.color_filter_b_value),
|
||||||
|
max = 255,
|
||||||
|
value = colorFilterValue.blue,
|
||||||
|
valueText = colorFilterValue.blue.toString(),
|
||||||
onChange = { newBValue ->
|
onChange = { newBValue ->
|
||||||
screenModel.preferences.colorFilterValue().getAndSet {
|
screenModel.preferences.colorFilterValue().getAndSet {
|
||||||
getColorValue(it, newBValue, BLUE_MASK, 0)
|
getColorValue(it, newBValue, BLUE_MASK, 0)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pillColor = MaterialTheme.colorScheme.surfaceContainerHighest,
|
|
||||||
)
|
)
|
||||||
SliderItem(
|
SliderItem(
|
||||||
value = colorFilterValue.alpha,
|
|
||||||
valueRange = 0..255,
|
|
||||||
steps = 0,
|
|
||||||
label = stringResource(MR.strings.color_filter_a_value),
|
label = stringResource(MR.strings.color_filter_a_value),
|
||||||
|
max = 255,
|
||||||
|
value = colorFilterValue.alpha,
|
||||||
|
valueText = colorFilterValue.alpha.toString(),
|
||||||
onChange = { newAValue ->
|
onChange = { newAValue ->
|
||||||
screenModel.preferences.colorFilterValue().getAndSet {
|
screenModel.preferences.colorFilterValue().getAndSet {
|
||||||
getColorValue(it, newAValue, ALPHA_MASK, 24)
|
getColorValue(it, newAValue, ALPHA_MASK, 24)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pillColor = MaterialTheme.colorScheme.surfaceContainerHighest,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
val colorFilterMode by screenModel.preferences.colorFilterMode().collectAsState()
|
val colorFilterMode by screenModel.preferences.colorFilterMode().collectAsState()
|
||||||
|
@ -2,7 +2,6 @@ package eu.kanade.presentation.reader.settings
|
|||||||
|
|
||||||
import androidx.compose.foundation.layout.ColumnScope
|
import androidx.compose.foundation.layout.ColumnScope
|
||||||
import androidx.compose.material3.FilterChip
|
import androidx.compose.material3.FilterChip
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
@ -120,21 +119,21 @@ internal fun ColumnScope.GeneralPage(screenModel: ReaderSettingsScreenModel) {
|
|||||||
if (flashPageState) {
|
if (flashPageState) {
|
||||||
SliderItem(
|
SliderItem(
|
||||||
value = flashMillis / ReaderPreferences.MILLI_CONVERSION,
|
value = flashMillis / ReaderPreferences.MILLI_CONVERSION,
|
||||||
valueRange = 1..15,
|
|
||||||
label = stringResource(MR.strings.pref_flash_duration),
|
label = stringResource(MR.strings.pref_flash_duration),
|
||||||
valueText = stringResource(MR.strings.pref_flash_duration_summary, flashMillis),
|
valueText = stringResource(MR.strings.pref_flash_duration_summary, flashMillis),
|
||||||
onChange = { flashMillisPref.set(it * ReaderPreferences.MILLI_CONVERSION) },
|
onChange = { flashMillisPref.set(it * ReaderPreferences.MILLI_CONVERSION) },
|
||||||
pillColor = MaterialTheme.colorScheme.surfaceContainerHighest,
|
min = 1,
|
||||||
|
max = 15,
|
||||||
)
|
)
|
||||||
SliderItem(
|
SliderItem(
|
||||||
value = flashInterval,
|
value = flashInterval,
|
||||||
valueRange = 1..10,
|
|
||||||
label = stringResource(MR.strings.pref_flash_page_interval),
|
label = stringResource(MR.strings.pref_flash_page_interval),
|
||||||
valueText = pluralStringResource(MR.plurals.pref_pages, flashInterval, flashInterval),
|
valueText = pluralStringResource(MR.plurals.pref_pages, flashInterval, flashInterval),
|
||||||
onChange = {
|
onChange = {
|
||||||
flashIntervalPref.set(it)
|
flashIntervalPref.set(it)
|
||||||
},
|
},
|
||||||
pillColor = MaterialTheme.colorScheme.surfaceContainerHighest,
|
min = 1,
|
||||||
|
max = 10,
|
||||||
)
|
)
|
||||||
SettingsChipRow(MR.strings.pref_flash_with) {
|
SettingsChipRow(MR.strings.pref_flash_with) {
|
||||||
flashColors.map { (labelRes, value) ->
|
flashColors.map { (labelRes, value) ->
|
||||||
|
@ -2,7 +2,6 @@ package eu.kanade.presentation.reader.settings
|
|||||||
|
|
||||||
import androidx.compose.foundation.layout.ColumnScope
|
import androidx.compose.foundation.layout.ColumnScope
|
||||||
import androidx.compose.material3.FilterChip
|
import androidx.compose.material3.FilterChip
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
@ -193,14 +192,14 @@ private fun ColumnScope.WebtoonViewerSettings(screenModel: ReaderSettingsScreenM
|
|||||||
|
|
||||||
val webtoonSidePadding by screenModel.preferences.webtoonSidePadding().collectAsState()
|
val webtoonSidePadding by screenModel.preferences.webtoonSidePadding().collectAsState()
|
||||||
SliderItem(
|
SliderItem(
|
||||||
value = webtoonSidePadding,
|
|
||||||
valueRange = ReaderPreferences.let { it.WEBTOON_PADDING_MIN..it.WEBTOON_PADDING_MAX },
|
|
||||||
label = stringResource(MR.strings.pref_webtoon_side_padding),
|
label = stringResource(MR.strings.pref_webtoon_side_padding),
|
||||||
|
min = ReaderPreferences.WEBTOON_PADDING_MIN,
|
||||||
|
max = ReaderPreferences.WEBTOON_PADDING_MAX,
|
||||||
|
value = webtoonSidePadding,
|
||||||
valueText = numberFormat.format(webtoonSidePadding / 100f),
|
valueText = numberFormat.format(webtoonSidePadding / 100f),
|
||||||
onChange = {
|
onChange = {
|
||||||
screenModel.preferences.webtoonSidePadding().set(it)
|
screenModel.preferences.webtoonSidePadding().set(it)
|
||||||
},
|
},
|
||||||
pillColor = MaterialTheme.colorScheme.surfaceContainerHighest,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
CheckboxItem(
|
CheckboxItem(
|
||||||
|
@ -13,7 +13,6 @@ import eu.kanade.presentation.theme.colorscheme.GreenAppleColorScheme
|
|||||||
import eu.kanade.presentation.theme.colorscheme.LavenderColorScheme
|
import eu.kanade.presentation.theme.colorscheme.LavenderColorScheme
|
||||||
import eu.kanade.presentation.theme.colorscheme.MidnightDuskColorScheme
|
import eu.kanade.presentation.theme.colorscheme.MidnightDuskColorScheme
|
||||||
import eu.kanade.presentation.theme.colorscheme.MonetColorScheme
|
import eu.kanade.presentation.theme.colorscheme.MonetColorScheme
|
||||||
import eu.kanade.presentation.theme.colorscheme.MonochromeColorScheme
|
|
||||||
import eu.kanade.presentation.theme.colorscheme.NordColorScheme
|
import eu.kanade.presentation.theme.colorscheme.NordColorScheme
|
||||||
import eu.kanade.presentation.theme.colorscheme.StrawberryColorScheme
|
import eu.kanade.presentation.theme.colorscheme.StrawberryColorScheme
|
||||||
import eu.kanade.presentation.theme.colorscheme.TachiyomiColorScheme
|
import eu.kanade.presentation.theme.colorscheme.TachiyomiColorScheme
|
||||||
@ -80,7 +79,6 @@ private val colorSchemes: Map<AppTheme, BaseColorScheme> = mapOf(
|
|||||||
AppTheme.GREEN_APPLE to GreenAppleColorScheme,
|
AppTheme.GREEN_APPLE to GreenAppleColorScheme,
|
||||||
AppTheme.LAVENDER to LavenderColorScheme,
|
AppTheme.LAVENDER to LavenderColorScheme,
|
||||||
AppTheme.MIDNIGHT_DUSK to MidnightDuskColorScheme,
|
AppTheme.MIDNIGHT_DUSK to MidnightDuskColorScheme,
|
||||||
AppTheme.MONOCHROME to MonochromeColorScheme,
|
|
||||||
AppTheme.NORD to NordColorScheme,
|
AppTheme.NORD to NordColorScheme,
|
||||||
AppTheme.STRAWBERRY_DAIQUIRI to StrawberryColorScheme,
|
AppTheme.STRAWBERRY_DAIQUIRI to StrawberryColorScheme,
|
||||||
AppTheme.TAKO to TakoColorScheme,
|
AppTheme.TAKO to TakoColorScheme,
|
||||||
|
@ -1,84 +0,0 @@
|
|||||||
package eu.kanade.presentation.theme.colorscheme
|
|
||||||
|
|
||||||
import androidx.compose.material3.darkColorScheme
|
|
||||||
import androidx.compose.material3.lightColorScheme
|
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
|
|
||||||
internal object MonochromeColorScheme : BaseColorScheme() {
|
|
||||||
|
|
||||||
override val darkScheme = darkColorScheme(
|
|
||||||
primary = Color(0xFFFFFFFF),
|
|
||||||
onPrimary = Color(0xFF000000),
|
|
||||||
primaryContainer = Color(0xFFFFFFFF),
|
|
||||||
onPrimaryContainer = Color(0xFF000000),
|
|
||||||
secondary = Color(0xFFFFFFFF),
|
|
||||||
onSecondary = Color(0xFF000000),
|
|
||||||
secondaryContainer = Color(0xFF777777),
|
|
||||||
onSecondaryContainer = Color(0xFF000000),
|
|
||||||
tertiary = Color(0xFF777777),
|
|
||||||
onTertiary = Color(0xFFFFFFFF),
|
|
||||||
tertiaryContainer = Color(0xFFFFFFFF),
|
|
||||||
onTertiaryContainer = Color(0xFF000000),
|
|
||||||
error = Color(0xFFFFFFFF),
|
|
||||||
onError = Color(0xFF000000),
|
|
||||||
errorContainer = Color(0xFFFFFFFF),
|
|
||||||
onErrorContainer = Color(0xFF000000),
|
|
||||||
background = Color(0xFF000000),
|
|
||||||
onBackground = Color(0xFFFFFFFF),
|
|
||||||
surface = Color(0xFF000000),
|
|
||||||
onSurface = Color(0xFFFFFFFF),
|
|
||||||
surfaceVariant = Color(0xFF000000),
|
|
||||||
onSurfaceVariant = Color(0xFFFFFFFF),
|
|
||||||
outline = Color(0xFFFFFFFF),
|
|
||||||
outlineVariant = Color(0xFFFFFFFF),
|
|
||||||
scrim = Color(0xFF000000),
|
|
||||||
inverseSurface = Color(0xFFFFFFFF),
|
|
||||||
inverseOnSurface = Color(0xFF000000),
|
|
||||||
inversePrimary = Color(0xFF000000),
|
|
||||||
surfaceDim = Color(0xFF000000),
|
|
||||||
surfaceBright = Color(0xFFFFFFFF),
|
|
||||||
surfaceContainerLowest = Color(0xFF000000),
|
|
||||||
surfaceContainerLow = Color(0xFF000000),
|
|
||||||
surfaceContainer = Color(0xFF000000),
|
|
||||||
surfaceContainerHigh = Color(0xFF000000),
|
|
||||||
surfaceContainerHighest = Color(0xFF000000),
|
|
||||||
)
|
|
||||||
|
|
||||||
override val lightScheme = lightColorScheme(
|
|
||||||
primary = Color(0xFF000000),
|
|
||||||
onPrimary = Color(0xFFFFFFFF),
|
|
||||||
primaryContainer = Color(0xFF000000),
|
|
||||||
onPrimaryContainer = Color(0xFFFFFFFF),
|
|
||||||
secondary = Color(0xFF000000),
|
|
||||||
onSecondary = Color(0xFFFFFFFF),
|
|
||||||
secondaryContainer = Color(0xFF888888),
|
|
||||||
onSecondaryContainer = Color(0xFFFFFFFF),
|
|
||||||
tertiary = Color(0xFF888888),
|
|
||||||
onTertiary = Color(0xFFFFFFFF),
|
|
||||||
tertiaryContainer = Color(0xFF000000),
|
|
||||||
onTertiaryContainer = Color(0xFFFFFFFF),
|
|
||||||
error = Color(0xFF000000),
|
|
||||||
onError = Color(0xFFFFFFFF),
|
|
||||||
errorContainer = Color(0xFF000000),
|
|
||||||
onErrorContainer = Color(0xFFFFFFFF),
|
|
||||||
background = Color(0xFFFFFFFF),
|
|
||||||
onBackground = Color(0xFF000000),
|
|
||||||
surface = Color(0xFFFFFFFF),
|
|
||||||
onSurface = Color(0xFF000000),
|
|
||||||
surfaceVariant = Color(0xFFFFFFFF),
|
|
||||||
onSurfaceVariant = Color(0xFF000000),
|
|
||||||
outline = Color(0xFF000000),
|
|
||||||
outlineVariant = Color(0xFF000000),
|
|
||||||
scrim = Color(0xFF000000),
|
|
||||||
inverseSurface = Color(0xFF000000),
|
|
||||||
inverseOnSurface = Color(0xFFFFFFFF),
|
|
||||||
inversePrimary = Color(0xFFFFFFFF),
|
|
||||||
surfaceDim = Color(0xFFFFFFFF),
|
|
||||||
surfaceBright = Color(0xFFFFFFFF),
|
|
||||||
surfaceContainerLowest = Color(0xFFFFFFFF),
|
|
||||||
surfaceContainerLow = Color(0xFFFFFFFF),
|
|
||||||
surfaceContainer = Color(0xFFFFFFFF),
|
|
||||||
surfaceContainerHigh = Color(0xFFFFFFFF),
|
|
||||||
surfaceContainerHighest = Color(0xFFFFFFFF),
|
|
||||||
)
|
|
||||||
}
|
|
@ -10,12 +10,10 @@ import androidx.compose.foundation.layout.Column
|
|||||||
import androidx.compose.foundation.layout.IntrinsicSize
|
import androidx.compose.foundation.layout.IntrinsicSize
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
import androidx.compose.foundation.layout.absoluteOffset
|
|
||||||
import androidx.compose.foundation.layout.fillMaxHeight
|
import androidx.compose.foundation.layout.fillMaxHeight
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
|
||||||
import androidx.compose.foundation.layout.systemBars
|
import androidx.compose.foundation.layout.systemBars
|
||||||
import androidx.compose.foundation.layout.windowInsetsPadding
|
import androidx.compose.foundation.layout.windowInsetsPadding
|
||||||
import androidx.compose.foundation.layout.wrapContentSize
|
import androidx.compose.foundation.layout.wrapContentSize
|
||||||
@ -24,9 +22,6 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
|||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.filled.MoreVert
|
import androidx.compose.material.icons.filled.MoreVert
|
||||||
import androidx.compose.material.icons.filled.VisibilityOff
|
|
||||||
import androidx.compose.material3.Badge
|
|
||||||
import androidx.compose.material3.BadgedBox
|
|
||||||
import androidx.compose.material3.DropdownMenuItem
|
import androidx.compose.material3.DropdownMenuItem
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
@ -75,7 +70,6 @@ fun TrackInfoDialogHome(
|
|||||||
onOpenInBrowser: (TrackItem) -> Unit,
|
onOpenInBrowser: (TrackItem) -> Unit,
|
||||||
onRemoved: (TrackItem) -> Unit,
|
onRemoved: (TrackItem) -> Unit,
|
||||||
onCopyLink: (TrackItem) -> Unit,
|
onCopyLink: (TrackItem) -> Unit,
|
||||||
onTogglePrivate: (TrackItem) -> Unit,
|
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@ -90,7 +84,6 @@ fun TrackInfoDialogHome(
|
|||||||
if (item.track != null) {
|
if (item.track != null) {
|
||||||
val supportsScoring = item.tracker.getScoreList().isNotEmpty()
|
val supportsScoring = item.tracker.getScoreList().isNotEmpty()
|
||||||
val supportsReadingDates = item.tracker.supportsReadingDates
|
val supportsReadingDates = item.tracker.supportsReadingDates
|
||||||
val supportsPrivate = item.tracker.supportsPrivateTracking
|
|
||||||
TrackInfoItem(
|
TrackInfoItem(
|
||||||
title = item.track.title,
|
title = item.track.title,
|
||||||
tracker = item.tracker,
|
tracker = item.tracker,
|
||||||
@ -122,9 +115,6 @@ fun TrackInfoDialogHome(
|
|||||||
onOpenInBrowser = { onOpenInBrowser(item) },
|
onOpenInBrowser = { onOpenInBrowser(item) },
|
||||||
onRemoved = { onRemoved(item) },
|
onRemoved = { onRemoved(item) },
|
||||||
onCopyLink = { onCopyLink(item) },
|
onCopyLink = { onCopyLink(item) },
|
||||||
private = item.track.private,
|
|
||||||
onTogglePrivate = { onTogglePrivate(item) }
|
|
||||||
.takeIf { supportsPrivate },
|
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
TrackInfoItemEmpty(
|
TrackInfoItemEmpty(
|
||||||
@ -154,37 +144,17 @@ private fun TrackInfoItem(
|
|||||||
onOpenInBrowser: () -> Unit,
|
onOpenInBrowser: () -> Unit,
|
||||||
onRemoved: () -> Unit,
|
onRemoved: () -> Unit,
|
||||||
onCopyLink: () -> Unit,
|
onCopyLink: () -> Unit,
|
||||||
private: Boolean,
|
|
||||||
onTogglePrivate: (() -> Unit)?,
|
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
Column {
|
Column {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
) {
|
|
||||||
BadgedBox(
|
|
||||||
badge = {
|
|
||||||
if (private) {
|
|
||||||
Badge(
|
|
||||||
containerColor = MaterialTheme.colorScheme.primary,
|
|
||||||
contentColor = MaterialTheme.colorScheme.onPrimary,
|
|
||||||
modifier = Modifier.absoluteOffset(x = (-5).dp),
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Filled.VisibilityOff,
|
|
||||||
contentDescription = stringResource(MR.strings.tracked_privately),
|
|
||||||
modifier = Modifier.size(14.dp),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
) {
|
) {
|
||||||
TrackLogoIcon(
|
TrackLogoIcon(
|
||||||
tracker = tracker,
|
tracker = tracker,
|
||||||
onClick = onOpenInBrowser,
|
onClick = onOpenInBrowser,
|
||||||
onLongClick = onCopyLink,
|
onLongClick = onCopyLink,
|
||||||
)
|
)
|
||||||
}
|
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.height(48.dp)
|
.height(48.dp)
|
||||||
@ -211,8 +181,6 @@ private fun TrackInfoItem(
|
|||||||
onOpenInBrowser = onOpenInBrowser,
|
onOpenInBrowser = onOpenInBrowser,
|
||||||
onRemoved = onRemoved,
|
onRemoved = onRemoved,
|
||||||
onCopyLink = onCopyLink,
|
onCopyLink = onCopyLink,
|
||||||
private = private,
|
|
||||||
onTogglePrivate = onTogglePrivate,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -323,8 +291,6 @@ private fun TrackInfoItemMenu(
|
|||||||
onOpenInBrowser: () -> Unit,
|
onOpenInBrowser: () -> Unit,
|
||||||
onRemoved: () -> Unit,
|
onRemoved: () -> Unit,
|
||||||
onCopyLink: () -> Unit,
|
onCopyLink: () -> Unit,
|
||||||
private: Boolean,
|
|
||||||
onTogglePrivate: (() -> Unit)?,
|
|
||||||
) {
|
) {
|
||||||
var expanded by remember { mutableStateOf(false) }
|
var expanded by remember { mutableStateOf(false) }
|
||||||
Box(modifier = Modifier.wrapContentSize(Alignment.TopStart)) {
|
Box(modifier = Modifier.wrapContentSize(Alignment.TopStart)) {
|
||||||
@ -352,25 +318,6 @@ private fun TrackInfoItemMenu(
|
|||||||
expanded = false
|
expanded = false
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if (onTogglePrivate != null) {
|
|
||||||
DropdownMenuItem(
|
|
||||||
text = {
|
|
||||||
Text(
|
|
||||||
stringResource(
|
|
||||||
if (private) {
|
|
||||||
MR.strings.action_toggle_private_off
|
|
||||||
} else {
|
|
||||||
MR.strings.action_toggle_private_on
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
onClick = {
|
|
||||||
onTogglePrivate()
|
|
||||||
expanded = false
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
DropdownMenuItem(
|
DropdownMenuItem(
|
||||||
text = { Text(stringResource(MR.strings.action_remove)) },
|
text = { Text(stringResource(MR.strings.action_remove)) },
|
||||||
onClick = {
|
onClick = {
|
||||||
|
@ -25,9 +25,7 @@ internal class TrackInfoDialogHomePreviewProvider :
|
|||||||
remoteUrl = "https://example.com",
|
remoteUrl = "https://example.com",
|
||||||
startDate = 0L,
|
startDate = 0L,
|
||||||
finishDate = 0L,
|
finishDate = 0L,
|
||||||
private = false,
|
|
||||||
)
|
)
|
||||||
private val privateTrack = aTrack.copy(private = true)
|
|
||||||
private val trackItemWithoutTrack = TrackItem(
|
private val trackItemWithoutTrack = TrackItem(
|
||||||
track = null,
|
track = null,
|
||||||
tracker = DummyTracker(
|
tracker = DummyTracker(
|
||||||
@ -42,13 +40,6 @@ internal class TrackInfoDialogHomePreviewProvider :
|
|||||||
name = "Example Tracker 2",
|
name = "Example Tracker 2",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
private val trackItemWithPrivateTrack = TrackItem(
|
|
||||||
track = privateTrack,
|
|
||||||
tracker = DummyTracker(
|
|
||||||
id = 2L,
|
|
||||||
name = "Example Tracker 2",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
private val trackersWithAndWithoutTrack = @Composable {
|
private val trackersWithAndWithoutTrack = @Composable {
|
||||||
TrackInfoDialogHome(
|
TrackInfoDialogHome(
|
||||||
@ -66,7 +57,6 @@ internal class TrackInfoDialogHomePreviewProvider :
|
|||||||
onOpenInBrowser = {},
|
onOpenInBrowser = {},
|
||||||
onRemoved = {},
|
onRemoved = {},
|
||||||
onCopyLink = {},
|
onCopyLink = {},
|
||||||
onTogglePrivate = {},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,24 +73,6 @@ internal class TrackInfoDialogHomePreviewProvider :
|
|||||||
onOpenInBrowser = {},
|
onOpenInBrowser = {},
|
||||||
onRemoved = {},
|
onRemoved = {},
|
||||||
onCopyLink = {},
|
onCopyLink = {},
|
||||||
onTogglePrivate = {},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private val trackerWithPrivateTracking = @Composable {
|
|
||||||
TrackInfoDialogHome(
|
|
||||||
trackItems = listOf(trackItemWithPrivateTrack),
|
|
||||||
dateFormat = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM),
|
|
||||||
onStatusClick = {},
|
|
||||||
onChapterClick = {},
|
|
||||||
onScoreClick = {},
|
|
||||||
onStartDateEdit = {},
|
|
||||||
onEndDateEdit = {},
|
|
||||||
onNewSearch = {},
|
|
||||||
onOpenInBrowser = {},
|
|
||||||
onRemoved = {},
|
|
||||||
onCopyLink = {},
|
|
||||||
onTogglePrivate = {},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,6 +80,5 @@ internal class TrackInfoDialogHomePreviewProvider :
|
|||||||
get() = sequenceOf(
|
get() = sequenceOf(
|
||||||
trackersWithAndWithoutTrack,
|
trackersWithAndWithoutTrack,
|
||||||
noTrackers,
|
noTrackers,
|
||||||
trackerWithPrivateTracking,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,6 @@ import androidx.compose.material.icons.Icons
|
|||||||
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
|
import androidx.compose.material.icons.automirrored.outlined.ArrowBack
|
||||||
import androidx.compose.material.icons.filled.CheckCircle
|
import androidx.compose.material.icons.filled.CheckCircle
|
||||||
import androidx.compose.material.icons.filled.Close
|
import androidx.compose.material.icons.filled.Close
|
||||||
import androidx.compose.material.icons.filled.VisibilityOff
|
|
||||||
import androidx.compose.material3.Button
|
import androidx.compose.material3.Button
|
||||||
import androidx.compose.material3.ButtonDefaults
|
import androidx.compose.material3.ButtonDefaults
|
||||||
import androidx.compose.material3.DropdownMenuItem
|
import androidx.compose.material3.DropdownMenuItem
|
||||||
@ -91,9 +90,8 @@ fun TrackerSearch(
|
|||||||
queryResult: Result<List<TrackSearch>>?,
|
queryResult: Result<List<TrackSearch>>?,
|
||||||
selected: TrackSearch?,
|
selected: TrackSearch?,
|
||||||
onSelectedChange: (TrackSearch) -> Unit,
|
onSelectedChange: (TrackSearch) -> Unit,
|
||||||
onConfirmSelection: (private: Boolean) -> Unit,
|
onConfirmSelection: () -> Unit,
|
||||||
onDismissRequest: () -> Unit,
|
onDismissRequest: () -> Unit,
|
||||||
supportsPrivateTracking: Boolean,
|
|
||||||
) {
|
) {
|
||||||
val focusManager = LocalFocusManager.current
|
val focusManager = LocalFocusManager.current
|
||||||
val focusRequester = remember { FocusRequester() }
|
val focusRequester = remember { FocusRequester() }
|
||||||
@ -166,32 +164,16 @@ fun TrackerSearch(
|
|||||||
enter = fadeIn() + slideInVertically { it / 2 },
|
enter = fadeIn() + slideInVertically { it / 2 },
|
||||||
exit = slideOutVertically { it / 2 } + fadeOut(),
|
exit = slideOutVertically { it / 2 } + fadeOut(),
|
||||||
) {
|
) {
|
||||||
Row(
|
Button(
|
||||||
|
onClick = { onConfirmSelection() },
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(MaterialTheme.padding.small)
|
.padding(12.dp)
|
||||||
.windowInsetsPadding(WindowInsets.navigationBars)
|
.windowInsetsPadding(WindowInsets.navigationBars)
|
||||||
.fillMaxWidth(),
|
.fillMaxWidth(),
|
||||||
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
|
|
||||||
) {
|
|
||||||
Button(
|
|
||||||
onClick = { onConfirmSelection(false) },
|
|
||||||
modifier = Modifier.weight(1f),
|
|
||||||
elevation = ButtonDefaults.elevatedButtonElevation(),
|
elevation = ButtonDefaults.elevatedButtonElevation(),
|
||||||
) {
|
) {
|
||||||
Text(text = stringResource(MR.strings.action_track))
|
Text(text = stringResource(MR.strings.action_track))
|
||||||
}
|
}
|
||||||
if (supportsPrivateTracking) {
|
|
||||||
Button(
|
|
||||||
onClick = { onConfirmSelection(true) },
|
|
||||||
elevation = ButtonDefaults.elevatedButtonElevation(),
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Filled.VisibilityOff,
|
|
||||||
contentDescription = stringResource(MR.strings.action_toggle_private_on),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
) { innerPadding ->
|
) { innerPadding ->
|
||||||
@ -304,15 +286,6 @@ private fun SearchResultItem(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if (trackSearch.authors.isNotEmpty() || trackSearch.artists.isNotEmpty()) {
|
|
||||||
Text(
|
|
||||||
text = (trackSearch.authors + trackSearch.artists).distinct().joinToString(),
|
|
||||||
modifier = Modifier.secondaryItemAlpha(),
|
|
||||||
maxLines = 1,
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
style = MaterialTheme.typography.bodySmall,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (type.isNotBlank()) {
|
if (type.isNotBlank()) {
|
||||||
SearchResultItemDetails(
|
SearchResultItemDetails(
|
||||||
title = stringResource(MR.strings.track_type),
|
title = stringResource(MR.strings.track_type),
|
||||||
|
@ -5,11 +5,8 @@ import androidx.compose.runtime.Composable
|
|||||||
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
|
||||||
import androidx.compose.ui.tooling.preview.datasource.LoremIpsum
|
import androidx.compose.ui.tooling.preview.datasource.LoremIpsum
|
||||||
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
import eu.kanade.tachiyomi.data.track.model.TrackSearch
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
import java.time.temporal.ChronoUnit
|
import java.time.temporal.ChronoUnit
|
||||||
import java.util.Date
|
|
||||||
import java.util.Locale
|
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
|
||||||
internal class TrackerSearchPreviewProvider : PreviewParameterProvider<@Composable () -> Unit> {
|
internal class TrackerSearchPreviewProvider : PreviewParameterProvider<@Composable () -> Unit> {
|
||||||
@ -23,7 +20,6 @@ internal class TrackerSearchPreviewProvider : PreviewParameterProvider<@Composab
|
|||||||
onSelectedChange = {},
|
onSelectedChange = {},
|
||||||
onConfirmSelection = {},
|
onConfirmSelection = {},
|
||||||
onDismissRequest = {},
|
onDismissRequest = {},
|
||||||
supportsPrivateTracking = false,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
private val fullPageWithoutSelected = @Composable {
|
private val fullPageWithoutSelected = @Composable {
|
||||||
@ -35,7 +31,6 @@ internal class TrackerSearchPreviewProvider : PreviewParameterProvider<@Composab
|
|||||||
onSelectedChange = {},
|
onSelectedChange = {},
|
||||||
onConfirmSelection = {},
|
onConfirmSelection = {},
|
||||||
onDismissRequest = {},
|
onDismissRequest = {},
|
||||||
supportsPrivateTracking = false,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
private val loading = @Composable {
|
private val loading = @Composable {
|
||||||
@ -47,27 +42,12 @@ internal class TrackerSearchPreviewProvider : PreviewParameterProvider<@Composab
|
|||||||
onSelectedChange = {},
|
onSelectedChange = {},
|
||||||
onConfirmSelection = {},
|
onConfirmSelection = {},
|
||||||
onDismissRequest = {},
|
onDismissRequest = {},
|
||||||
supportsPrivateTracking = false,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
private val fullPageWithPrivateTracking = @Composable {
|
|
||||||
val items = someTrackSearches().take(30).toList()
|
|
||||||
TrackerSearch(
|
|
||||||
state = TextFieldState(initialText = "search text"),
|
|
||||||
onDispatchQuery = {},
|
|
||||||
queryResult = Result.success(items),
|
|
||||||
selected = items[1],
|
|
||||||
onSelectedChange = {},
|
|
||||||
onConfirmSelection = {},
|
|
||||||
onDismissRequest = {},
|
|
||||||
supportsPrivateTracking = true,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
override val values: Sequence<@Composable () -> Unit> = sequenceOf(
|
override val values: Sequence<@Composable () -> Unit> = sequenceOf(
|
||||||
fullPageWithSecondSelected,
|
fullPageWithSecondSelected,
|
||||||
fullPageWithoutSelected,
|
fullPageWithoutSelected,
|
||||||
loading,
|
loading,
|
||||||
fullPageWithPrivateTracking,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun someTrackSearches(): Sequence<TrackSearch> = sequence {
|
private fun someTrackSearches(): Sequence<TrackSearch> = sequence {
|
||||||
@ -76,8 +56,6 @@ internal class TrackerSearchPreviewProvider : PreviewParameterProvider<@Composab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val formatter: SimpleDateFormat = SimpleDateFormat("yyyy-MM-dd", Locale.getDefault())
|
|
||||||
|
|
||||||
private fun randTrackSearch() = TrackSearch().let {
|
private fun randTrackSearch() = TrackSearch().let {
|
||||||
it.id = Random.nextLong()
|
it.id = Random.nextLong()
|
||||||
it.manga_id = Random.nextLong()
|
it.manga_id = Random.nextLong()
|
||||||
@ -93,17 +71,11 @@ internal class TrackerSearchPreviewProvider : PreviewParameterProvider<@Composab
|
|||||||
it.finished_reading_date = 0L
|
it.finished_reading_date = 0L
|
||||||
it.tracking_url = "https://example.com/tracker-example"
|
it.tracking_url = "https://example.com/tracker-example"
|
||||||
it.cover_url = "https://example.com/cover.png"
|
it.cover_url = "https://example.com/cover.png"
|
||||||
it.start_date = formatter.format(Date.from(Instant.now().minus((1L..365).random(), ChronoUnit.DAYS)))
|
it.start_date = Instant.now().minus((1L..365).random(), ChronoUnit.DAYS).toString()
|
||||||
it.summary = lorem((0..40).random()).joinToString()
|
it.summary = lorem((0..40).random()).joinToString()
|
||||||
it.publishing_status = if (Random.nextBoolean()) "Finished" else ""
|
|
||||||
it.publishing_type = if (Random.nextBoolean()) "Oneshot" else ""
|
|
||||||
it.artists = randomNames()
|
|
||||||
it.authors = randomNames()
|
|
||||||
it
|
it
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun randomNames(): List<String> = (0..(0..3).random()).map { lorem((3..5).random()).joinToString() }
|
|
||||||
|
|
||||||
private fun lorem(words: Int): Sequence<String> =
|
private fun lorem(words: Int): Sequence<String> =
|
||||||
LoremIpsum(words).values
|
LoremIpsum(words).values
|
||||||
}
|
}
|
||||||
|
@ -60,9 +60,7 @@ fun UpdateScreen(
|
|||||||
onUpdateSelected: (UpdatesItem, Boolean, Boolean, Boolean) -> Unit,
|
onUpdateSelected: (UpdatesItem, Boolean, Boolean, Boolean) -> Unit,
|
||||||
onOpenChapter: (UpdatesItem) -> Unit,
|
onOpenChapter: (UpdatesItem) -> Unit,
|
||||||
) {
|
) {
|
||||||
BackHandler(enabled = state.selectionMode) {
|
BackHandler(enabled = state.selectionMode, onBack = { onSelectAll(false) })
|
||||||
onSelectAll(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = { scrollBehavior ->
|
topBar = { scrollBehavior ->
|
||||||
|
@ -1,46 +1,12 @@
|
|||||||
package eu.kanade.presentation.util
|
package eu.kanade.presentation.util
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import androidx.activity.BackEventCompat
|
|
||||||
import androidx.activity.compose.PredictiveBackHandler
|
|
||||||
import androidx.compose.animation.AnimatedContent
|
import androidx.compose.animation.AnimatedContent
|
||||||
import androidx.compose.animation.AnimatedContentTransitionScope
|
import androidx.compose.animation.AnimatedContentTransitionScope
|
||||||
import androidx.compose.animation.ContentTransform
|
import androidx.compose.animation.ContentTransform
|
||||||
import androidx.compose.animation.EnterTransition
|
|
||||||
import androidx.compose.animation.ExitTransition
|
|
||||||
import androidx.compose.animation.SizeTransform
|
|
||||||
import androidx.compose.animation.core.AnimationSpec
|
|
||||||
import androidx.compose.animation.core.SeekableTransitionState
|
|
||||||
import androidx.compose.animation.core.Spring
|
|
||||||
import androidx.compose.animation.core.animate
|
|
||||||
import androidx.compose.animation.core.rememberTransition
|
|
||||||
import androidx.compose.animation.core.spring
|
|
||||||
import androidx.compose.animation.fadeIn
|
|
||||||
import androidx.compose.animation.fadeOut
|
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.DisposableEffect
|
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
|
||||||
import androidx.compose.runtime.MutableState
|
|
||||||
import androidx.compose.runtime.ProvidableCompositionLocal
|
import androidx.compose.runtime.ProvidableCompositionLocal
|
||||||
import androidx.compose.runtime.Stable
|
|
||||||
import androidx.compose.runtime.getValue
|
|
||||||
import androidx.compose.runtime.mutableFloatStateOf
|
|
||||||
import androidx.compose.runtime.mutableStateOf
|
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
|
||||||
import androidx.compose.runtime.saveable.Saver
|
|
||||||
import androidx.compose.runtime.saveable.rememberSaveable
|
|
||||||
import androidx.compose.runtime.setValue
|
|
||||||
import androidx.compose.runtime.snapshotFlow
|
|
||||||
import androidx.compose.runtime.staticCompositionLocalOf
|
import androidx.compose.runtime.staticCompositionLocalOf
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.geometry.Offset
|
|
||||||
import androidx.compose.ui.platform.LocalView
|
|
||||||
import androidx.compose.ui.platform.LocalViewConfiguration
|
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import androidx.compose.ui.util.lerp
|
|
||||||
import cafe.adriel.voyager.core.annotation.InternalVoyagerApi
|
|
||||||
import cafe.adriel.voyager.core.model.ScreenModel
|
import cafe.adriel.voyager.core.model.ScreenModel
|
||||||
import cafe.adriel.voyager.core.model.ScreenModelStore
|
import cafe.adriel.voyager.core.model.ScreenModelStore
|
||||||
import cafe.adriel.voyager.core.screen.Screen
|
import cafe.adriel.voyager.core.screen.Screen
|
||||||
@ -49,28 +15,18 @@ import cafe.adriel.voyager.core.screen.uniqueScreenKey
|
|||||||
import cafe.adriel.voyager.core.stack.StackEvent
|
import cafe.adriel.voyager.core.stack.StackEvent
|
||||||
import cafe.adriel.voyager.navigator.Navigator
|
import cafe.adriel.voyager.navigator.Navigator
|
||||||
import cafe.adriel.voyager.transitions.ScreenTransitionContent
|
import cafe.adriel.voyager.transitions.ScreenTransitionContent
|
||||||
import eu.kanade.tachiyomi.util.view.getWindowRadius
|
|
||||||
import kotlinx.coroutines.CoroutineName
|
import kotlinx.coroutines.CoroutineName
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
|
||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
import kotlinx.coroutines.cancel
|
import kotlinx.coroutines.cancel
|
||||||
import kotlinx.coroutines.flow.dropWhile
|
|
||||||
import kotlinx.coroutines.flow.onCompletion
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import kotlinx.coroutines.plus
|
import kotlinx.coroutines.plus
|
||||||
import soup.compose.material.motion.animation.materialSharedAxisXIn
|
import soup.compose.material.motion.animation.materialSharedAxisX
|
||||||
import soup.compose.material.motion.animation.materialSharedAxisXOut
|
|
||||||
import soup.compose.material.motion.animation.rememberSlideDistance
|
import soup.compose.material.motion.animation.rememberSlideDistance
|
||||||
import tachiyomi.presentation.core.util.PredictiveBack
|
|
||||||
import kotlin.coroutines.cancellation.CancellationException
|
|
||||||
import kotlin.math.absoluteValue
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For invoking back press to the parent activity
|
* For invoking back press to the parent activity
|
||||||
*/
|
*/
|
||||||
@SuppressLint("ComposeCompositionLocalUsage")
|
|
||||||
val LocalBackPress: ProvidableCompositionLocal<(() -> Unit)?> = staticCompositionLocalOf { null }
|
val LocalBackPress: ProvidableCompositionLocal<(() -> Unit)?> = staticCompositionLocalOf { null }
|
||||||
|
|
||||||
interface Tab : cafe.adriel.voyager.navigator.tab.Tab {
|
interface Tab : cafe.adriel.voyager.navigator.tab.Tab {
|
||||||
@ -103,278 +59,39 @@ interface AssistContentScreen {
|
|||||||
fun onProvideAssistUrl(): String?
|
fun onProvideAssistUrl(): String?
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(InternalVoyagerApi::class)
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DefaultNavigatorScreenTransition(
|
fun DefaultNavigatorScreenTransition(
|
||||||
navigator: Navigator,
|
navigator: Navigator,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
val screenCandidatesToDispose = rememberSaveable(saver = screenCandidatesToDisposeSaver()) {
|
val slideDistance = rememberSlideDistance()
|
||||||
mutableStateOf(emptySet())
|
|
||||||
}
|
|
||||||
val currentScreens = navigator.items
|
|
||||||
DisposableEffect(currentScreens) {
|
|
||||||
onDispose {
|
|
||||||
val newScreenKeys = navigator.items.map { it.key }
|
|
||||||
screenCandidatesToDispose.value += currentScreens.filter { it.key !in newScreenKeys }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val slideDistance = rememberSlideDistance(slideDistance = 30.dp)
|
|
||||||
ScreenTransition(
|
ScreenTransition(
|
||||||
navigator = navigator,
|
navigator = navigator,
|
||||||
modifier = modifier,
|
transition = {
|
||||||
enterTransition = {
|
materialSharedAxisX(
|
||||||
if (it == SwipeEdge.Right) {
|
forward = navigator.lastEvent != StackEvent.Pop,
|
||||||
materialSharedAxisXIn(forward = false, slideDistance = slideDistance)
|
slideDistance = slideDistance,
|
||||||
} else {
|
)
|
||||||
materialSharedAxisXIn(forward = true, slideDistance = slideDistance)
|
},
|
||||||
}
|
modifier = modifier,
|
||||||
},
|
|
||||||
exitTransition = {
|
|
||||||
if (it == SwipeEdge.Right) {
|
|
||||||
materialSharedAxisXOut(forward = false, slideDistance = slideDistance)
|
|
||||||
} else {
|
|
||||||
materialSharedAxisXOut(forward = true, slideDistance = slideDistance)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
popEnterTransition = {
|
|
||||||
if (it == SwipeEdge.Right) {
|
|
||||||
materialSharedAxisXIn(forward = true, slideDistance = slideDistance)
|
|
||||||
} else {
|
|
||||||
materialSharedAxisXIn(forward = false, slideDistance = slideDistance)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
popExitTransition = {
|
|
||||||
if (it == SwipeEdge.Right) {
|
|
||||||
materialSharedAxisXOut(forward = true, slideDistance = slideDistance)
|
|
||||||
} else {
|
|
||||||
materialSharedAxisXOut(forward = false, slideDistance = slideDistance)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
content = { screen ->
|
|
||||||
if (this.transition.targetState == this.transition.currentState) {
|
|
||||||
LaunchedEffect(Unit) {
|
|
||||||
val newScreens = navigator.items.map { it.key }
|
|
||||||
val screensToDispose = screenCandidatesToDispose.value.filterNot { it.key in newScreens }
|
|
||||||
if (screensToDispose.isNotEmpty()) {
|
|
||||||
screensToDispose.forEach { navigator.dispose(it) }
|
|
||||||
navigator.clearEvent()
|
|
||||||
}
|
|
||||||
screenCandidatesToDispose.value = emptySet()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
screen.Content()
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
enum class SwipeEdge {
|
|
||||||
Unknown,
|
|
||||||
Left,
|
|
||||||
Right,
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum class AnimationType {
|
|
||||||
Pop,
|
|
||||||
Cancel,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun ScreenTransition(
|
fun ScreenTransition(
|
||||||
navigator: Navigator,
|
navigator: Navigator,
|
||||||
|
transition: AnimatedContentTransitionScope<Screen>.() -> ContentTransform,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
enterTransition: AnimatedContentTransitionScope<Screen>.(SwipeEdge) -> EnterTransition = { fadeIn() },
|
|
||||||
exitTransition: AnimatedContentTransitionScope<Screen>.(SwipeEdge) -> ExitTransition = { fadeOut() },
|
|
||||||
popEnterTransition: AnimatedContentTransitionScope<Screen>.(SwipeEdge) -> EnterTransition = enterTransition,
|
|
||||||
popExitTransition: AnimatedContentTransitionScope<Screen>.(SwipeEdge) -> ExitTransition = exitTransition,
|
|
||||||
sizeTransform: (AnimatedContentTransitionScope<Screen>.() -> SizeTransform?)? = null,
|
|
||||||
flingAnimationSpec: () -> AnimationSpec<Float> = { spring(stiffness = Spring.StiffnessLow) },
|
|
||||||
content: ScreenTransitionContent = { it.Content() },
|
content: ScreenTransitionContent = { it.Content() },
|
||||||
) {
|
) {
|
||||||
val view = LocalView.current
|
AnimatedContent(
|
||||||
val viewConfig = LocalViewConfiguration.current
|
targetState = navigator.lastItem,
|
||||||
val scope = rememberCoroutineScope()
|
transitionSpec = transition,
|
||||||
val state = remember {
|
|
||||||
ScreenTransitionState(
|
|
||||||
navigator = navigator,
|
|
||||||
scope = scope,
|
|
||||||
flingAnimationSpec = flingAnimationSpec(),
|
|
||||||
windowCornerRadius = view.getWindowRadius().toFloat(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
val transitionState = remember { SeekableTransitionState(navigator.lastItem) }
|
|
||||||
val transition = rememberTransition(transitionState = transitionState)
|
|
||||||
|
|
||||||
if (state.isPredictiveBack || state.isAnimating) {
|
|
||||||
LaunchedEffect(state.progress) {
|
|
||||||
if (!state.isPredictiveBack) return@LaunchedEffect
|
|
||||||
val previousEntry = navigator.items.getOrNull(navigator.size - 2)
|
|
||||||
if (previousEntry != null) {
|
|
||||||
transitionState.seekTo(fraction = state.progress, targetState = previousEntry)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
LaunchedEffect(navigator) {
|
|
||||||
snapshotFlow { navigator.lastItem }
|
|
||||||
.collect {
|
|
||||||
state.cancelCancelAnimation()
|
|
||||||
if (it != transitionState.currentState) {
|
|
||||||
transitionState.animateTo(it)
|
|
||||||
} else {
|
|
||||||
transitionState.snapTo(it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PredictiveBackHandler(enabled = navigator.canPop) { backEvent ->
|
|
||||||
state.cancelCancelAnimation()
|
|
||||||
var startOffset: Offset? = null
|
|
||||||
backEvent
|
|
||||||
.dropWhile {
|
|
||||||
if (startOffset == null) startOffset = Offset(it.touchX, it.touchY)
|
|
||||||
if (state.isAnimating) return@dropWhile true
|
|
||||||
// Touch slop check
|
|
||||||
val diff = Offset(it.touchX, it.touchY) - startOffset!!
|
|
||||||
diff.x.absoluteValue < viewConfig.touchSlop && diff.y.absoluteValue < viewConfig.touchSlop
|
|
||||||
}
|
|
||||||
.onCompletion {
|
|
||||||
if (it == null) {
|
|
||||||
state.finish()
|
|
||||||
} else {
|
|
||||||
state.cancel()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.collect {
|
|
||||||
state.setPredictiveBackProgress(
|
|
||||||
progress = it.progress,
|
|
||||||
swipeEdge = when (it.swipeEdge) {
|
|
||||||
BackEventCompat.EDGE_LEFT -> SwipeEdge.Left
|
|
||||||
BackEventCompat.EDGE_RIGHT -> SwipeEdge.Right
|
|
||||||
else -> SwipeEdge.Unknown
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
transition.AnimatedContent(
|
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
transitionSpec = {
|
label = "transition",
|
||||||
val pop = navigator.lastEvent == StackEvent.Pop || state.isPredictiveBack
|
) { screen ->
|
||||||
ContentTransform(
|
navigator.saveableState("transition", screen) {
|
||||||
targetContentEnter = if (pop) {
|
content(screen)
|
||||||
popEnterTransition(state.swipeEdge)
|
|
||||||
} else {
|
|
||||||
enterTransition(state.swipeEdge)
|
|
||||||
},
|
|
||||||
initialContentExit = if (pop) {
|
|
||||||
popExitTransition(state.swipeEdge)
|
|
||||||
} else {
|
|
||||||
exitTransition(state.swipeEdge)
|
|
||||||
},
|
|
||||||
targetContentZIndex = if (pop) 0f else 1f,
|
|
||||||
sizeTransform = sizeTransform?.invoke(this),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
contentKey = { it.key },
|
|
||||||
) {
|
|
||||||
navigator.saveableState("transition", it) {
|
|
||||||
content(it)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Stable
|
|
||||||
private class ScreenTransitionState(
|
|
||||||
private val navigator: Navigator,
|
|
||||||
private val scope: CoroutineScope,
|
|
||||||
private val flingAnimationSpec: AnimationSpec<Float>,
|
|
||||||
windowCornerRadius: Float,
|
|
||||||
) {
|
|
||||||
var isPredictiveBack: Boolean by mutableStateOf(false)
|
|
||||||
private set
|
|
||||||
|
|
||||||
var progress: Float by mutableFloatStateOf(0f)
|
|
||||||
private set
|
|
||||||
|
|
||||||
var swipeEdge: SwipeEdge by mutableStateOf(SwipeEdge.Unknown)
|
|
||||||
private set
|
|
||||||
|
|
||||||
private var animationJob: Pair<Job, AnimationType>? by mutableStateOf(null)
|
|
||||||
|
|
||||||
val isAnimating: Boolean
|
|
||||||
get() = animationJob?.first?.isActive == true
|
|
||||||
|
|
||||||
val windowCornerShape = RoundedCornerShape(windowCornerRadius)
|
|
||||||
|
|
||||||
private fun reset() {
|
|
||||||
this.isPredictiveBack = false
|
|
||||||
this.swipeEdge = SwipeEdge.Unknown
|
|
||||||
this.animationJob = null
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setPredictiveBackProgress(progress: Float, swipeEdge: SwipeEdge) {
|
|
||||||
this.progress = lerp(0f, 0.65f, PredictiveBack.transform(progress))
|
|
||||||
this.swipeEdge = swipeEdge
|
|
||||||
this.isPredictiveBack = true
|
|
||||||
}
|
|
||||||
|
|
||||||
fun finish() {
|
|
||||||
if (!isPredictiveBack) {
|
|
||||||
navigator.pop()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
animationJob = scope.launch {
|
|
||||||
try {
|
|
||||||
animate(
|
|
||||||
initialValue = progress,
|
|
||||||
targetValue = 1f,
|
|
||||||
animationSpec = flingAnimationSpec,
|
|
||||||
block = { i, _ -> progress = i },
|
|
||||||
)
|
|
||||||
navigator.pop()
|
|
||||||
} catch (e: CancellationException) {
|
|
||||||
// Cancelled
|
|
||||||
progress = 0f
|
|
||||||
} finally {
|
|
||||||
reset()
|
|
||||||
}
|
|
||||||
} to AnimationType.Pop
|
|
||||||
}
|
|
||||||
|
|
||||||
fun cancel() {
|
|
||||||
if (!isPredictiveBack) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
animationJob = scope.launch {
|
|
||||||
try {
|
|
||||||
animate(
|
|
||||||
initialValue = progress,
|
|
||||||
targetValue = 0f,
|
|
||||||
animationSpec = flingAnimationSpec,
|
|
||||||
block = { i, _ -> progress = i },
|
|
||||||
)
|
|
||||||
} catch (e: CancellationException) {
|
|
||||||
// Cancelled
|
|
||||||
progress = 1f
|
|
||||||
} finally {
|
|
||||||
reset()
|
|
||||||
}
|
|
||||||
} to AnimationType.Cancel
|
|
||||||
}
|
|
||||||
|
|
||||||
fun cancelCancelAnimation() {
|
|
||||||
if (animationJob?.second == AnimationType.Cancel) {
|
|
||||||
animationJob?.first?.cancel()
|
|
||||||
animationJob = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun screenCandidatesToDisposeSaver(): Saver<MutableState<Set<Screen>>, List<Screen>> {
|
|
||||||
return Saver(
|
|
||||||
save = { it.value.toList() },
|
|
||||||
restore = { mutableStateOf(it.toSet()) },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
@ -44,6 +44,7 @@ import kotlinx.coroutines.launch
|
|||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import tachiyomi.presentation.core.components.material.Scaffold
|
import tachiyomi.presentation.core.components.material.Scaffold
|
||||||
import tachiyomi.presentation.core.i18n.stringResource
|
import tachiyomi.presentation.core.i18n.stringResource
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun WebViewScreenContent(
|
fun WebViewScreenContent(
|
||||||
onNavigateUp: () -> Unit,
|
onNavigateUp: () -> Unit,
|
||||||
|
@ -277,16 +277,18 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
|
|||||||
try {
|
try {
|
||||||
// Override the value passed as X-Requested-With in WebView requests
|
// Override the value passed as X-Requested-With in WebView requests
|
||||||
val stackTrace = Looper.getMainLooper().thread.stackTrace
|
val stackTrace = Looper.getMainLooper().thread.stackTrace
|
||||||
val isChromiumCall = stackTrace.any { trace ->
|
val chromiumElement = stackTrace.find {
|
||||||
trace.className.equals("org.chromium.base.BuildInfo", ignoreCase = true) &&
|
it.className.equals(
|
||||||
setOf("getAll", "getPackageName", "<init>").any { trace.methodName.equals(it, ignoreCase = true) }
|
"org.chromium.base.BuildInfo",
|
||||||
|
ignoreCase = true,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (chromiumElement?.methodName.equals("getAll", ignoreCase = true)) {
|
||||||
|
return WebViewUtil.SPOOF_PACKAGE_NAME
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isChromiumCall) return WebViewUtil.spoofedPackageName(applicationContext)
|
|
||||||
} catch (_: Exception) {
|
} catch (_: Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.getPackageName()
|
return super.getPackageName()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,7 +330,7 @@ class App : Application(), DefaultLifecycleObserver, SingletonImageLoader.Factor
|
|||||||
return super.generateFileName(
|
return super.generateFileName(
|
||||||
logLevel,
|
logLevel,
|
||||||
timestamp,
|
timestamp,
|
||||||
) + "-${BuildConfig.BUILD_TYPE}.txt"
|
) + "-${BuildConfig.BUILD_TYPE}.log"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
flattener { timeMillis, level, tag, message ->
|
flattener { timeMillis, level, tag, message ->
|
||||||
|
@ -80,7 +80,7 @@ class BackupNotifier(private val context: Context) {
|
|||||||
addAction(
|
addAction(
|
||||||
R.drawable.ic_share_24dp,
|
R.drawable.ic_share_24dp,
|
||||||
context.stringResource(MR.strings.action_share),
|
context.stringResource(MR.strings.action_share),
|
||||||
NotificationReceiver.shareBackupPendingActivity(context, file.uri),
|
NotificationReceiver.shareBackupPendingBroadcast(context, file.uri),
|
||||||
)
|
)
|
||||||
|
|
||||||
show(Notifications.ID_BACKUP_COMPLETE)
|
show(Notifications.ID_BACKUP_COMPLETE)
|
||||||
|
@ -118,15 +118,13 @@ class MangaBackupCreator(
|
|||||||
private fun Manga.toBackupManga(/* SY --> */customMangaInfo: CustomMangaInfo?/* SY <-- */) =
|
private fun Manga.toBackupManga(/* SY --> */customMangaInfo: CustomMangaInfo?/* SY <-- */) =
|
||||||
BackupManga(
|
BackupManga(
|
||||||
url = this.url,
|
url = this.url,
|
||||||
// SY -->
|
title = this.title,
|
||||||
title = this.ogTitle,
|
artist = this.artist,
|
||||||
artist = this.ogArtist,
|
author = this.author,
|
||||||
author = this.ogAuthor,
|
description = this.description,
|
||||||
description = this.ogDescription,
|
genre = this.genre.orEmpty(),
|
||||||
genre = this.ogGenre.orEmpty(),
|
status = this.status.toInt(),
|
||||||
status = this.ogStatus.toInt(),
|
thumbnailUrl = this.thumbnailUrl,
|
||||||
thumbnailUrl = this.ogThumbnailUrl,
|
|
||||||
// SY <--
|
|
||||||
favorite = this.favorite,
|
favorite = this.favorite,
|
||||||
source = this.source,
|
source = this.source,
|
||||||
dateAdded = this.dateAdded,
|
dateAdded = this.dateAdded,
|
||||||
@ -137,7 +135,6 @@ private fun Manga.toBackupManga(/* SY --> */customMangaInfo: CustomMangaInfo?/*
|
|||||||
lastModifiedAt = this.lastModifiedAt,
|
lastModifiedAt = this.lastModifiedAt,
|
||||||
favoriteModifiedAt = this.favoriteModifiedAt,
|
favoriteModifiedAt = this.favoriteModifiedAt,
|
||||||
version = this.version,
|
version = this.version,
|
||||||
notes = this.notes,
|
|
||||||
// SY -->
|
// SY -->
|
||||||
).also { backupManga ->
|
).also { backupManga ->
|
||||||
customMangaInfo?.let {
|
customMangaInfo?.let {
|
||||||
|
@ -8,7 +8,6 @@ import tachiyomi.domain.category.model.Category
|
|||||||
class BackupCategory(
|
class BackupCategory(
|
||||||
@ProtoNumber(1) var name: String,
|
@ProtoNumber(1) var name: String,
|
||||||
@ProtoNumber(2) var order: Long = 0,
|
@ProtoNumber(2) var order: Long = 0,
|
||||||
@ProtoNumber(3) var id: Long = 0,
|
|
||||||
// @ProtoNumber(3) val updateInterval: Int = 0, 1.x value not used in 0.x
|
// @ProtoNumber(3) val updateInterval: Int = 0, 1.x value not used in 0.x
|
||||||
@ProtoNumber(100) var flags: Long = 0,
|
@ProtoNumber(100) var flags: Long = 0,
|
||||||
// SY specific values
|
// SY specific values
|
||||||
@ -25,7 +24,6 @@ class BackupCategory(
|
|||||||
|
|
||||||
val backupCategoryMapper = { category: Category ->
|
val backupCategoryMapper = { category: Category ->
|
||||||
BackupCategory(
|
BackupCategory(
|
||||||
id = category.id,
|
|
||||||
name = category.name,
|
name = category.name,
|
||||||
order = category.order,
|
order = category.order,
|
||||||
flags = category.flags,
|
flags = category.flags,
|
||||||
|
@ -38,10 +38,8 @@ data class BackupManga(
|
|||||||
@ProtoNumber(105) var updateStrategy: UpdateStrategy = UpdateStrategy.ALWAYS_UPDATE,
|
@ProtoNumber(105) var updateStrategy: UpdateStrategy = UpdateStrategy.ALWAYS_UPDATE,
|
||||||
@ProtoNumber(106) var lastModifiedAt: Long = 0,
|
@ProtoNumber(106) var lastModifiedAt: Long = 0,
|
||||||
@ProtoNumber(107) var favoriteModifiedAt: Long? = null,
|
@ProtoNumber(107) var favoriteModifiedAt: Long? = null,
|
||||||
// Mihon values start here
|
|
||||||
@ProtoNumber(108) var excludedScanlators: List<String> = emptyList(),
|
@ProtoNumber(108) var excludedScanlators: List<String> = emptyList(),
|
||||||
@ProtoNumber(109) var version: Long = 0,
|
@ProtoNumber(109) var version: Long = 0,
|
||||||
@ProtoNumber(110) var notes: String = "",
|
|
||||||
|
|
||||||
// SY specific values
|
// SY specific values
|
||||||
@ProtoNumber(600) var mergedMangaReferences: List<BackupMergedMangaReference> = emptyList(),
|
@ProtoNumber(600) var mergedMangaReferences: List<BackupMergedMangaReference> = emptyList(),
|
||||||
@ -79,7 +77,6 @@ data class BackupManga(
|
|||||||
lastModifiedAt = this@BackupManga.lastModifiedAt,
|
lastModifiedAt = this@BackupManga.lastModifiedAt,
|
||||||
favoriteModifiedAt = this@BackupManga.favoriteModifiedAt,
|
favoriteModifiedAt = this@BackupManga.favoriteModifiedAt,
|
||||||
version = this@BackupManga.version,
|
version = this@BackupManga.version,
|
||||||
notes = this@BackupManga.notes,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ data class BackupTracking(
|
|||||||
@ProtoNumber(10) var startedReadingDate: Long = 0,
|
@ProtoNumber(10) var startedReadingDate: Long = 0,
|
||||||
// finishedReadingDate is called endReadTime in 1.x
|
// finishedReadingDate is called endReadTime in 1.x
|
||||||
@ProtoNumber(11) var finishedReadingDate: Long = 0,
|
@ProtoNumber(11) var finishedReadingDate: Long = 0,
|
||||||
@ProtoNumber(12) var private: Boolean = false,
|
|
||||||
@ProtoNumber(100) var mediaId: Long = 0,
|
@ProtoNumber(100) var mediaId: Long = 0,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@ -49,7 +48,6 @@ data class BackupTracking(
|
|||||||
startDate = this@BackupTracking.startedReadingDate,
|
startDate = this@BackupTracking.startedReadingDate,
|
||||||
finishDate = this@BackupTracking.finishedReadingDate,
|
finishDate = this@BackupTracking.finishedReadingDate,
|
||||||
remoteUrl = this@BackupTracking.trackingUrl,
|
remoteUrl = this@BackupTracking.trackingUrl,
|
||||||
private = this@BackupTracking.private,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,7 +66,6 @@ val backupTrackMapper = {
|
|||||||
remoteUrl: String,
|
remoteUrl: String,
|
||||||
startDate: Long,
|
startDate: Long,
|
||||||
finishDate: Long,
|
finishDate: Long,
|
||||||
private: Boolean,
|
|
||||||
->
|
->
|
||||||
BackupTracking(
|
BackupTracking(
|
||||||
syncId = syncId.toInt(),
|
syncId = syncId.toInt(),
|
||||||
@ -83,6 +80,5 @@ val backupTrackMapper = {
|
|||||||
startedReadingDate = startDate,
|
startedReadingDate = startDate,
|
||||||
finishedReadingDate = finishDate,
|
finishedReadingDate = finishDate,
|
||||||
trackingUrl = remoteUrl,
|
trackingUrl = remoteUrl,
|
||||||
private = private,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ class BackupRestorer(
|
|||||||
}
|
}
|
||||||
// SY <--
|
// SY <--
|
||||||
if (options.appSettings) {
|
if (options.appSettings) {
|
||||||
restoreAppPreferences(backup.backupPreferences, backup.backupCategories.takeIf { options.categories })
|
restoreAppPreferences(backup.backupPreferences)
|
||||||
}
|
}
|
||||||
if (options.sourceSettings) {
|
if (options.sourceSettings) {
|
||||||
restoreSourcePreferences(backup.backupSourcePreferences)
|
restoreSourcePreferences(backup.backupSourcePreferences)
|
||||||
@ -173,15 +173,9 @@ class BackupRestorer(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun CoroutineScope.restoreAppPreferences(
|
private fun CoroutineScope.restoreAppPreferences(preferences: List<BackupPreference>) = launch {
|
||||||
preferences: List<BackupPreference>,
|
|
||||||
categories: List<BackupCategory>?,
|
|
||||||
) = launch {
|
|
||||||
ensureActive()
|
ensureActive()
|
||||||
preferenceRestorer.restoreApp(
|
preferenceRestorer.restoreApp(preferences)
|
||||||
preferences,
|
|
||||||
categories,
|
|
||||||
)
|
|
||||||
|
|
||||||
restoreProgress += 1
|
restoreProgress += 1
|
||||||
notifier.showRestoreProgress(
|
notifier.showRestoreProgress(
|
||||||
|
@ -139,15 +139,13 @@ class MangaRestorer(
|
|||||||
mangasQueries.update(
|
mangasQueries.update(
|
||||||
source = manga.source,
|
source = manga.source,
|
||||||
url = manga.url,
|
url = manga.url,
|
||||||
// SY -->
|
artist = manga.artist,
|
||||||
artist = manga.ogArtist,
|
author = manga.author,
|
||||||
author = manga.ogAuthor,
|
description = manga.description,
|
||||||
description = manga.ogDescription,
|
genre = manga.genre?.joinToString(separator = ", "),
|
||||||
genre = manga.ogGenre?.joinToString(separator = ", "),
|
title = manga.title,
|
||||||
title = manga.ogTitle,
|
status = manga.status,
|
||||||
status = manga.ogStatus,
|
thumbnailUrl = manga.thumbnailUrl,
|
||||||
thumbnailUrl = manga.ogThumbnailUrl,
|
|
||||||
// SY <--
|
|
||||||
favorite = manga.favorite,
|
favorite = manga.favorite,
|
||||||
lastUpdate = manga.lastUpdate,
|
lastUpdate = manga.lastUpdate,
|
||||||
nextUpdate = null,
|
nextUpdate = null,
|
||||||
@ -161,7 +159,6 @@ class MangaRestorer(
|
|||||||
updateStrategy = manga.updateStrategy.let(UpdateStrategyColumnAdapter::encode),
|
updateStrategy = manga.updateStrategy.let(UpdateStrategyColumnAdapter::encode),
|
||||||
version = manga.version,
|
version = manga.version,
|
||||||
isSyncing = 1,
|
isSyncing = 1,
|
||||||
notes = manga.notes,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
return manga
|
return manga
|
||||||
@ -277,15 +274,13 @@ class MangaRestorer(
|
|||||||
mangasQueries.insert(
|
mangasQueries.insert(
|
||||||
source = manga.source,
|
source = manga.source,
|
||||||
url = manga.url,
|
url = manga.url,
|
||||||
// SY -->
|
artist = manga.artist,
|
||||||
artist = manga.ogArtist,
|
author = manga.author,
|
||||||
author = manga.ogAuthor,
|
description = manga.description,
|
||||||
description = manga.ogDescription,
|
genre = manga.genre,
|
||||||
genre = manga.ogGenre,
|
title = manga.title,
|
||||||
title = manga.ogTitle,
|
status = manga.status,
|
||||||
status = manga.ogStatus,
|
thumbnailUrl = manga.thumbnailUrl,
|
||||||
thumbnailUrl = manga.ogThumbnailUrl,
|
|
||||||
// SY <--
|
|
||||||
favorite = manga.favorite,
|
favorite = manga.favorite,
|
||||||
lastUpdate = manga.lastUpdate,
|
lastUpdate = manga.lastUpdate,
|
||||||
nextUpdate = 0L,
|
nextUpdate = 0L,
|
||||||
@ -297,7 +292,6 @@ class MangaRestorer(
|
|||||||
dateAdded = manga.dateAdded,
|
dateAdded = manga.dateAdded,
|
||||||
updateStrategy = manga.updateStrategy,
|
updateStrategy = manga.updateStrategy,
|
||||||
version = manga.version,
|
version = manga.version,
|
||||||
notes = manga.notes,
|
|
||||||
)
|
)
|
||||||
mangasQueries.selectLastInsertedRowId()
|
mangasQueries.selectLastInsertedRowId()
|
||||||
}
|
}
|
||||||
@ -453,7 +447,6 @@ class MangaRestorer(
|
|||||||
track.remoteUrl,
|
track.remoteUrl,
|
||||||
track.startDate,
|
track.startDate,
|
||||||
track.finishDate,
|
track.finishDate,
|
||||||
track.private,
|
|
||||||
track.id,
|
track.id,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -462,7 +455,6 @@ class MangaRestorer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restore the categories from Json
|
* Restore the categories from Json
|
||||||
*
|
*
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package eu.kanade.tachiyomi.data.backup.restore.restorers
|
package eu.kanade.tachiyomi.data.backup.restore.restorers
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.Log
|
|
||||||
import eu.kanade.tachiyomi.data.backup.create.BackupCreateJob
|
import eu.kanade.tachiyomi.data.backup.create.BackupCreateJob
|
||||||
import eu.kanade.tachiyomi.data.backup.models.BackupCategory
|
|
||||||
import eu.kanade.tachiyomi.data.backup.models.BackupPreference
|
import eu.kanade.tachiyomi.data.backup.models.BackupPreference
|
||||||
import eu.kanade.tachiyomi.data.backup.models.BackupSourcePreferences
|
import eu.kanade.tachiyomi.data.backup.models.BackupSourcePreferences
|
||||||
import eu.kanade.tachiyomi.data.backup.models.BooleanPreferenceValue
|
import eu.kanade.tachiyomi.data.backup.models.BooleanPreferenceValue
|
||||||
@ -16,62 +14,38 @@ import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
|||||||
import eu.kanade.tachiyomi.source.sourcePreferences
|
import eu.kanade.tachiyomi.source.sourcePreferences
|
||||||
import tachiyomi.core.common.preference.AndroidPreferenceStore
|
import tachiyomi.core.common.preference.AndroidPreferenceStore
|
||||||
import tachiyomi.core.common.preference.PreferenceStore
|
import tachiyomi.core.common.preference.PreferenceStore
|
||||||
import tachiyomi.core.common.preference.plusAssign
|
|
||||||
import tachiyomi.domain.category.interactor.GetCategories
|
|
||||||
import tachiyomi.domain.category.model.Category
|
|
||||||
import tachiyomi.domain.download.service.DownloadPreferences
|
|
||||||
import tachiyomi.domain.library.service.LibraryPreferences
|
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
class PreferenceRestorer(
|
class PreferenceRestorer(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val getCategories: GetCategories = Injekt.get(),
|
|
||||||
private val preferenceStore: PreferenceStore = Injekt.get(),
|
private val preferenceStore: PreferenceStore = Injekt.get(),
|
||||||
) {
|
) {
|
||||||
suspend fun restoreApp(
|
|
||||||
preferences: List<BackupPreference>,
|
fun restoreApp(preferences: List<BackupPreference>) {
|
||||||
backupCategories: List<BackupCategory>?,
|
restorePreferences(preferences, preferenceStore)
|
||||||
) {
|
|
||||||
restorePreferences(
|
|
||||||
preferences,
|
|
||||||
preferenceStore,
|
|
||||||
backupCategories,
|
|
||||||
)
|
|
||||||
|
|
||||||
LibraryUpdateJob.setupTask(context)
|
LibraryUpdateJob.setupTask(context)
|
||||||
BackupCreateJob.setupTask(context)
|
BackupCreateJob.setupTask(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun restoreSource(preferences: List<BackupSourcePreferences>) {
|
fun restoreSource(preferences: List<BackupSourcePreferences>) {
|
||||||
preferences.forEach {
|
preferences.forEach {
|
||||||
val sourcePrefs = AndroidPreferenceStore(context, sourcePreferences(it.sourceKey))
|
val sourcePrefs = AndroidPreferenceStore(context, sourcePreferences(it.sourceKey))
|
||||||
restorePreferences(it.prefs, sourcePrefs)
|
restorePreferences(it.prefs, sourcePrefs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun restorePreferences(
|
private fun restorePreferences(
|
||||||
toRestore: List<BackupPreference>,
|
toRestore: List<BackupPreference>,
|
||||||
preferenceStore: PreferenceStore,
|
preferenceStore: PreferenceStore,
|
||||||
backupCategories: List<BackupCategory>? = null,
|
|
||||||
) {
|
) {
|
||||||
val allCategories = if (backupCategories != null) getCategories.await() else emptyList()
|
|
||||||
val categoriesByName = allCategories.associateBy { it.name }
|
|
||||||
val backupCategoriesById = backupCategories?.associateBy { it.id.toString() }.orEmpty()
|
|
||||||
val prefs = preferenceStore.getAll()
|
val prefs = preferenceStore.getAll()
|
||||||
toRestore.forEach { (key, value) ->
|
toRestore.forEach { (key, value) ->
|
||||||
try {
|
|
||||||
when (value) {
|
when (value) {
|
||||||
is IntPreferenceValue -> {
|
is IntPreferenceValue -> {
|
||||||
if (prefs[key] is Int?) {
|
if (prefs[key] is Int?) {
|
||||||
val newValue = if (key == LibraryPreferences.DEFAULT_CATEGORY_PREF_KEY) {
|
preferenceStore.getInt(key).set(value.value)
|
||||||
backupCategoriesById[value.value.toString()]
|
|
||||||
?.let { categoriesByName[it.name]?.id?.toInt() }
|
|
||||||
} else {
|
|
||||||
value.value
|
|
||||||
}
|
|
||||||
|
|
||||||
newValue?.let { preferenceStore.getInt(key).set(it) }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
is LongPreferenceValue -> {
|
is LongPreferenceValue -> {
|
||||||
@ -96,42 +70,10 @@ class PreferenceRestorer(
|
|||||||
}
|
}
|
||||||
is StringSetPreferenceValue -> {
|
is StringSetPreferenceValue -> {
|
||||||
if (prefs[key] is Set<*>?) {
|
if (prefs[key] is Set<*>?) {
|
||||||
val restored = restoreCategoriesPreference(
|
preferenceStore.getStringSet(key).set(value.value)
|
||||||
key,
|
|
||||||
value.value,
|
|
||||||
preferenceStore,
|
|
||||||
backupCategoriesById,
|
|
||||||
categoriesByName,
|
|
||||||
)
|
|
||||||
if (!restored) preferenceStore.getStringSet(key).set(value.value)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e("PreferenceRestorer", "Failed to restore preference <$key>", e)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun restoreCategoriesPreference(
|
|
||||||
key: String,
|
|
||||||
value: Set<String>,
|
|
||||||
preferenceStore: PreferenceStore,
|
|
||||||
backupCategoriesById: Map<String, BackupCategory>,
|
|
||||||
categoriesByName: Map<String, Category>,
|
|
||||||
): Boolean {
|
|
||||||
val categoryPreferences = LibraryPreferences.categoryPreferenceKeys + DownloadPreferences.categoryPreferenceKeys
|
|
||||||
if (key !in categoryPreferences) return false
|
|
||||||
|
|
||||||
val ids = value.mapNotNull {
|
|
||||||
backupCategoriesById[it]?.name?.let { name ->
|
|
||||||
categoriesByName[name]?.id?.toString()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ids.isNotEmpty()) {
|
|
||||||
preferenceStore.getStringSet(key) += ids
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -27,9 +27,6 @@ interface Chapter : SChapter, Serializable {
|
|||||||
var version: Long
|
var version: Long
|
||||||
}
|
}
|
||||||
|
|
||||||
val Chapter.isRecognizedNumber: Boolean
|
|
||||||
get() = chapter_number >= 0f
|
|
||||||
|
|
||||||
fun Chapter.toDomainChapter(): DomainChapter? {
|
fun Chapter.toDomainChapter(): DomainChapter? {
|
||||||
if (id == null || manga_id == null) return null
|
if (id == null || manga_id == null) return null
|
||||||
return DomainChapter(
|
return DomainChapter(
|
||||||
|
@ -32,15 +32,12 @@ interface Track : Serializable {
|
|||||||
|
|
||||||
var tracking_url: String
|
var tracking_url: String
|
||||||
|
|
||||||
var private: Boolean
|
fun copyPersonalFrom(other: Track) {
|
||||||
|
|
||||||
fun copyPersonalFrom(other: Track, copyRemotePrivate: Boolean = true) {
|
|
||||||
last_chapter_read = other.last_chapter_read
|
last_chapter_read = other.last_chapter_read
|
||||||
score = other.score
|
score = other.score
|
||||||
status = other.status
|
status = other.status
|
||||||
started_reading_date = other.started_reading_date
|
started_reading_date = other.started_reading_date
|
||||||
finished_reading_date = other.finished_reading_date
|
finished_reading_date = other.finished_reading_date
|
||||||
if (copyRemotePrivate) private = other.private
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -29,6 +29,4 @@ class TrackImpl : Track {
|
|||||||
override var finished_reading_date: Long = 0
|
override var finished_reading_date: Long = 0
|
||||||
|
|
||||||
override var tracking_url: String = ""
|
override var tracking_url: String = ""
|
||||||
|
|
||||||
override var private: Boolean = false
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.data.download
|
|||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.core.net.toUri
|
import android.net.Uri
|
||||||
import com.hippo.unifile.UniFile
|
import com.hippo.unifile.UniFile
|
||||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
@ -307,41 +307,6 @@ class DownloadCache(
|
|||||||
notifyChanges()
|
notifyChanges()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Renames a manga in this cache.
|
|
||||||
*
|
|
||||||
* @param manga the manga being renamed.
|
|
||||||
* @param mangaUniFile the manga's new directory.
|
|
||||||
* @param newTitle the manga's new title.
|
|
||||||
*/
|
|
||||||
suspend fun renameManga(manga: Manga, mangaUniFile: UniFile, newTitle: String) {
|
|
||||||
rootDownloadsDirMutex.withLock {
|
|
||||||
val sourceDir = rootDownloadsDir.sourceDirs[manga.source] ?: return
|
|
||||||
val oldMangaDirName = provider.getMangaDirName(/* SY --> */ manga.ogTitle /* SY <-- */)
|
|
||||||
var oldChapterDirs: MutableSet<String>? = null
|
|
||||||
// Save the old name's cached chapter dirs
|
|
||||||
if (sourceDir.mangaDirs.containsKey(oldMangaDirName)) {
|
|
||||||
oldChapterDirs = sourceDir.mangaDirs[oldMangaDirName]?.chapterDirs
|
|
||||||
sourceDir.mangaDirs -= oldMangaDirName
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retrieve/create the cached manga directory for new name
|
|
||||||
val newMangaDirName = provider.getMangaDirName(newTitle)
|
|
||||||
var mangaDir = sourceDir.mangaDirs[newMangaDirName]
|
|
||||||
if (mangaDir == null) {
|
|
||||||
mangaDir = MangaDirectory(mangaUniFile)
|
|
||||||
sourceDir.mangaDirs += newMangaDirName to mangaDir
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the old chapters to new name's cache
|
|
||||||
if (!oldChapterDirs.isNullOrEmpty()) {
|
|
||||||
mangaDir.chapterDirs += oldChapterDirs
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyChanges()
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun removeSource(source: Source) {
|
suspend fun removeSource(source: Source) {
|
||||||
rootDownloadsDirMutex.withLock {
|
rootDownloadsDirMutex.withLock {
|
||||||
rootDownloadsDir.sourceDirs -= source.id
|
rootDownloadsDir.sourceDirs -= source.id
|
||||||
@ -518,7 +483,7 @@ private object UniFileAsStringSerializer : KSerializer<UniFile?> {
|
|||||||
|
|
||||||
override fun deserialize(decoder: Decoder): UniFile? {
|
override fun deserialize(decoder: Decoder): UniFile? {
|
||||||
return if (decoder.decodeNotNullMark()) {
|
return if (decoder.decodeNotNullMark()) {
|
||||||
UniFile.fromUri(Injekt.get<Application>(), decoder.decodeString().toUri())
|
UniFile.fromUri(Injekt.get<Application>(), Uri.parse(decoder.decodeString()))
|
||||||
} else {
|
} else {
|
||||||
decoder.decodeNull()
|
decoder.decodeNull()
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ class DownloadManager(
|
|||||||
|
|
||||||
return files.sortedBy { it.name }
|
return files.sortedBy { it.name }
|
||||||
.mapIndexed { i, file ->
|
.mapIndexed { i, file ->
|
||||||
Page(i, uri = file.uri).apply { status = Page.State.Ready }
|
Page(i, uri = file.uri).apply { status = Page.State.READY }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,7 +291,6 @@ class DownloadManager(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the list of all manga folders
|
* return the list of all manga folders
|
||||||
*/
|
*/
|
||||||
@ -317,14 +316,11 @@ class DownloadManager(
|
|||||||
|
|
||||||
if (removeNonFavorite && !manga.favorite) {
|
if (removeNonFavorite && !manga.favorite) {
|
||||||
val mangaFolder = provider.getMangaDir(/* SY --> */ manga.ogTitle /* SY <-- */, source)
|
val mangaFolder = provider.getMangaDir(/* SY --> */ manga.ogTitle /* SY <-- */, source)
|
||||||
.getOrNull()
|
|
||||||
if (mangaFolder != null) {
|
|
||||||
cleaned += 1 + mangaFolder.listFiles().orEmpty().size
|
cleaned += 1 + mangaFolder.listFiles().orEmpty().size
|
||||||
mangaFolder.delete()
|
mangaFolder.delete()
|
||||||
cache.removeManga(manga)
|
cache.removeManga(manga)
|
||||||
return cleaned
|
return cleaned
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val filesWithNoChapter = provider.findUnmatchedChapterDirs(allChapters, manga, source)
|
val filesWithNoChapter = provider.findUnmatchedChapterDirs(allChapters, manga, source)
|
||||||
cleaned += filesWithNoChapter.size
|
cleaned += filesWithNoChapter.size
|
||||||
@ -340,8 +336,8 @@ class DownloadManager(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cache.getDownloadCount(manga) == 0) {
|
if (cache.getDownloadCount(manga) == 0) {
|
||||||
val mangaFolder = provider.getMangaDir(/* SY --> */ manga.ogTitle /* SY <-- */, source).getOrNull()
|
val mangaFolder = provider.getMangaDir(/* SY --> */ manga.ogTitle /* SY <-- */, source)
|
||||||
if (mangaFolder != null && !mangaFolder.listFiles().isNullOrEmpty()) {
|
if (!mangaFolder.listFiles().isNullOrEmpty()) {
|
||||||
mangaFolder.delete()
|
mangaFolder.delete()
|
||||||
cache.removeManga(manga)
|
cache.removeManga(manga)
|
||||||
} else {
|
} else {
|
||||||
@ -399,38 +395,6 @@ class DownloadManager(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Renames manga download folder
|
|
||||||
*
|
|
||||||
* @param manga the manga
|
|
||||||
* @param newTitle the new manga title.
|
|
||||||
*/
|
|
||||||
suspend fun renameManga(manga: Manga, newTitle: String) {
|
|
||||||
val source = sourceManager.getOrStub(manga.source)
|
|
||||||
val oldFolder = provider.findMangaDir(/* SY --> */ manga.ogTitle /* SY <-- */, source) ?: return
|
|
||||||
val newName = provider.getMangaDirName(newTitle)
|
|
||||||
|
|
||||||
if (oldFolder.name == newName) return
|
|
||||||
|
|
||||||
// just to be safe, don't allow downloads for this manga while renaming it
|
|
||||||
downloader.removeFromQueue(manga)
|
|
||||||
|
|
||||||
val capitalizationChanged = oldFolder.name.equals(newName, ignoreCase = true)
|
|
||||||
if (capitalizationChanged) {
|
|
||||||
val tempName = newName + Downloader.TMP_DIR_SUFFIX
|
|
||||||
if (!oldFolder.renameTo(tempName)) {
|
|
||||||
logcat(LogPriority.ERROR) { "Failed to rename manga download folder: ${oldFolder.name}" }
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (oldFolder.renameTo(newName)) {
|
|
||||||
cache.renameManga(manga, oldFolder, newTitle)
|
|
||||||
} else {
|
|
||||||
logcat(LogPriority.ERROR) { "Failed to rename manga download folder: ${oldFolder.name}" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renames an already downloaded chapter
|
* Renames an already downloaded chapter
|
||||||
*
|
*
|
||||||
@ -441,10 +405,7 @@ class DownloadManager(
|
|||||||
*/
|
*/
|
||||||
suspend fun renameChapter(source: Source, manga: Manga, oldChapter: Chapter, newChapter: Chapter) {
|
suspend fun renameChapter(source: Source, manga: Manga, oldChapter: Chapter, newChapter: Chapter) {
|
||||||
val oldNames = provider.getValidChapterDirNames(oldChapter.name, oldChapter.scanlator)
|
val oldNames = provider.getValidChapterDirNames(oldChapter.name, oldChapter.scanlator)
|
||||||
val mangaDir = provider.getMangaDir(/* SY --> */ manga.ogTitle /* SY <-- */, source).getOrElse { e ->
|
val mangaDir = provider.getMangaDir(/* SY --> */ manga.ogTitle /* SY <-- */, source)
|
||||||
logcat(LogPriority.ERROR, e) { "Manga download folder doesn't exist. Skipping renaming after source sync" }
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assume there's only 1 version of the chapter name formats present
|
// Assume there's only 1 version of the chapter name formats present
|
||||||
val oldDownload = oldNames.asSequence()
|
val oldDownload = oldNames.asSequence()
|
||||||
|
@ -14,7 +14,6 @@ import tachiyomi.domain.storage.service.StorageManager
|
|||||||
import tachiyomi.i18n.MR
|
import tachiyomi.i18n.MR
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import java.io.IOException
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used to provide the directories where the downloads should be saved.
|
* This class is used to provide the directories where the downloads should be saved.
|
||||||
@ -36,36 +35,20 @@ class DownloadProvider(
|
|||||||
* @param mangaTitle the title of the manga to query.
|
* @param mangaTitle the title of the manga to query.
|
||||||
* @param source the source of the manga.
|
* @param source the source of the manga.
|
||||||
*/
|
*/
|
||||||
internal fun getMangaDir(mangaTitle: String, source: Source): Result<UniFile> {
|
internal fun getMangaDir(mangaTitle: String, source: Source): UniFile {
|
||||||
val downloadsDir = downloadsDir
|
try {
|
||||||
if (downloadsDir == null) {
|
return downloadsDir!!
|
||||||
logcat(LogPriority.ERROR) { "Failed to create download directory" }
|
.createDirectory(getSourceDirName(source))!!
|
||||||
return Result.failure(
|
.createDirectory(getMangaDirName(mangaTitle))!!
|
||||||
IOException(context.stringResource(MR.strings.storage_failed_to_create_download_directory)),
|
} catch (e: Throwable) {
|
||||||
|
logcat(LogPriority.ERROR, e) { "Invalid download directory" }
|
||||||
|
throw Exception(
|
||||||
|
context.stringResource(
|
||||||
|
MR.strings.invalid_location,
|
||||||
|
downloadsDir?.displayablePath ?: "",
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val sourceDirName = getSourceDirName(source)
|
|
||||||
val sourceDir = downloadsDir.createDirectory(sourceDirName)
|
|
||||||
if (sourceDir == null) {
|
|
||||||
val displayablePath = downloadsDir.displayablePath + "/$sourceDirName"
|
|
||||||
logcat(LogPriority.ERROR) { "Failed to create source download directory: $displayablePath" }
|
|
||||||
return Result.failure(
|
|
||||||
IOException(context.stringResource(MR.strings.storage_failed_to_create_directory, displayablePath)),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
val mangaDirName = getMangaDirName(mangaTitle)
|
|
||||||
val mangaDir = sourceDir.createDirectory(mangaDirName)
|
|
||||||
if (mangaDir == null) {
|
|
||||||
val displayablePath = sourceDir.displayablePath + "/$mangaDirName"
|
|
||||||
logcat(LogPriority.ERROR) { "Failed to create manga download directory: $displayablePath" }
|
|
||||||
return Result.failure(
|
|
||||||
IOException(context.stringResource(MR.strings.storage_failed_to_create_directory, displayablePath)),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result.success(mangaDir)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -120,7 +103,6 @@ class DownloadProvider(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of all files in manga directory
|
* Returns a list of all files in manga directory
|
||||||
*
|
*
|
||||||
|
@ -327,11 +327,7 @@ class Downloader(
|
|||||||
* @param download the chapter to be downloaded.
|
* @param download the chapter to be downloaded.
|
||||||
*/
|
*/
|
||||||
private suspend fun downloadChapter(download: Download) {
|
private suspend fun downloadChapter(download: Download) {
|
||||||
val mangaDir = provider.getMangaDir(/* SY --> */ download.manga.ogTitle /* SY <-- */, download.source).getOrElse { e ->
|
val mangaDir = provider.getMangaDir(/* SY --> */ download.manga.ogTitle /* SY <-- */, download.source)
|
||||||
download.status = Download.State.ERROR
|
|
||||||
notifier.onError(e.message, download.chapter.name, download.manga.title, download.manga.id)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
val availSpace = DiskUtil.getAvailableStorageSpace(mangaDir)
|
val availSpace = DiskUtil.getAvailableStorageSpace(mangaDir)
|
||||||
if (availSpace != -1L && availSpace < MIN_DISK_SPACE) {
|
if (availSpace != -1L && availSpace < MIN_DISK_SPACE) {
|
||||||
@ -383,11 +379,11 @@ class Downloader(
|
|||||||
flow {
|
flow {
|
||||||
// Fetch image URL if necessary
|
// Fetch image URL if necessary
|
||||||
if (page.imageUrl.isNullOrEmpty()) {
|
if (page.imageUrl.isNullOrEmpty()) {
|
||||||
page.status = Page.State.LoadPage
|
page.status = Page.State.LOAD_PAGE
|
||||||
try {
|
try {
|
||||||
page.imageUrl = download.source.getImageUrl(page)
|
page.imageUrl = download.source.getImageUrl(page)
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
page.status = Page.State.Error(e)
|
page.status = Page.State.ERROR
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -473,12 +469,12 @@ class Downloader(
|
|||||||
|
|
||||||
page.uri = file.uri
|
page.uri = file.uri
|
||||||
page.progress = 100
|
page.progress = 100
|
||||||
page.status = Page.State.Ready
|
page.status = Page.State.READY
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
if (e is CancellationException) throw e
|
if (e is CancellationException) throw e
|
||||||
// Mark this page as error and allow to download the remaining
|
// Mark this page as error and allow to download the remaining
|
||||||
page.progress = 0
|
page.progress = 0
|
||||||
page.status = Page.State.Error(e)
|
page.status = Page.State.ERROR
|
||||||
notifier.onError(e.message, download.chapter.name, download.manga.title, download.manga.id)
|
notifier.onError(e.message, download.chapter.name, download.manga.title, download.manga.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -498,7 +494,7 @@ class Downloader(
|
|||||||
filename: String,
|
filename: String,
|
||||||
dataSaver: DataSaver,
|
dataSaver: DataSaver,
|
||||||
): UniFile {
|
): UniFile {
|
||||||
page.status = Page.State.DownloadImage
|
page.status = Page.State.DOWNLOAD_IMAGE
|
||||||
page.progress = 0
|
page.progress = 0
|
||||||
return flow {
|
return flow {
|
||||||
val response = source.getImage(page, dataSaver)
|
val response = source.getImage(page, dataSaver)
|
||||||
|
@ -29,7 +29,7 @@ data class Download(
|
|||||||
get() = pages?.sumOf(Page::progress) ?: 0
|
get() = pages?.sumOf(Page::progress) ?: 0
|
||||||
|
|
||||||
val downloadedImages: Int
|
val downloadedImages: Int
|
||||||
get() = pages?.count { it.status == Page.State.Ready } ?: 0
|
get() = pages?.count { it.status == Page.State.READY } ?: 0
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
private val _statusFlow = MutableStateFlow(State.NOT_DOWNLOADED)
|
private val _statusFlow = MutableStateFlow(State.NOT_DOWNLOADED)
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
package eu.kanade.tachiyomi.data.export
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.net.Uri
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
|
||||||
import kotlinx.coroutines.withContext
|
|
||||||
import tachiyomi.domain.manga.model.Manga
|
|
||||||
|
|
||||||
object LibraryExporter {
|
|
||||||
|
|
||||||
data class ExportOptions(
|
|
||||||
val includeTitle: Boolean,
|
|
||||||
val includeAuthor: Boolean,
|
|
||||||
val includeArtist: Boolean,
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun exportToCsv(
|
|
||||||
context: Context,
|
|
||||||
uri: Uri,
|
|
||||||
favorites: List<Manga>,
|
|
||||||
options: ExportOptions,
|
|
||||||
onExportComplete: () -> Unit,
|
|
||||||
) {
|
|
||||||
withContext(Dispatchers.IO) {
|
|
||||||
context.contentResolver.openOutputStream(uri)?.use { outputStream ->
|
|
||||||
val csvData = generateCsvData(favorites, options)
|
|
||||||
outputStream.write(csvData.toByteArray())
|
|
||||||
}
|
|
||||||
onExportComplete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val escapeRequired = listOf("\r", "\n", "\"", ",")
|
|
||||||
|
|
||||||
private fun generateCsvData(favorites: List<Manga>, options: ExportOptions): String {
|
|
||||||
val columnSize = listOf(
|
|
||||||
options.includeTitle,
|
|
||||||
options.includeAuthor,
|
|
||||||
options.includeArtist,
|
|
||||||
)
|
|
||||||
.count { it }
|
|
||||||
|
|
||||||
val rows = buildList(favorites.size) {
|
|
||||||
favorites.forEach { manga ->
|
|
||||||
buildList(columnSize) {
|
|
||||||
if (options.includeTitle) add(manga.title)
|
|
||||||
if (options.includeAuthor) add(manga.author)
|
|
||||||
if (options.includeArtist) add(manga.artist)
|
|
||||||
}
|
|
||||||
.let(::add)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return rows.joinToString("\r\n") { columns ->
|
|
||||||
columns.joinToString(",") columns@{ column ->
|
|
||||||
if (column.isNullOrBlank()) return@columns ""
|
|
||||||
if (escapeRequired.any { column.contains(it) }) {
|
|
||||||
column.replace("\"", "\"\"").let { "\"$it\"" }
|
|
||||||
} else {
|
|
||||||
column
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -23,7 +23,6 @@ import eu.kanade.domain.chapter.interactor.SyncChaptersWithSource
|
|||||||
import eu.kanade.domain.manga.interactor.UpdateManga
|
import eu.kanade.domain.manga.interactor.UpdateManga
|
||||||
import eu.kanade.domain.manga.model.copyFrom
|
import eu.kanade.domain.manga.model.copyFrom
|
||||||
import eu.kanade.domain.manga.model.toSManga
|
import eu.kanade.domain.manga.model.toSManga
|
||||||
import eu.kanade.domain.source.service.SourcePreferences
|
|
||||||
import eu.kanade.domain.sync.SyncPreferences
|
import eu.kanade.domain.sync.SyncPreferences
|
||||||
import eu.kanade.domain.track.model.toDbTrack
|
import eu.kanade.domain.track.model.toDbTrack
|
||||||
import eu.kanade.domain.track.model.toDomainTrack
|
import eu.kanade.domain.track.model.toDomainTrack
|
||||||
@ -65,6 +64,7 @@ import tachiyomi.core.common.i18n.stringResource
|
|||||||
import tachiyomi.core.common.preference.getAndSet
|
import tachiyomi.core.common.preference.getAndSet
|
||||||
import tachiyomi.core.common.util.lang.withIOContext
|
import tachiyomi.core.common.util.lang.withIOContext
|
||||||
import tachiyomi.core.common.util.system.logcat
|
import tachiyomi.core.common.util.system.logcat
|
||||||
|
import tachiyomi.domain.UnsortedPreferences
|
||||||
import tachiyomi.domain.category.model.Category
|
import tachiyomi.domain.category.model.Category
|
||||||
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
|
||||||
import tachiyomi.domain.chapter.model.Chapter
|
import tachiyomi.domain.chapter.model.Chapter
|
||||||
@ -101,12 +101,9 @@ import java.time.Instant
|
|||||||
import java.time.ZonedDateTime
|
import java.time.ZonedDateTime
|
||||||
import java.util.concurrent.CopyOnWriteArrayList
|
import java.util.concurrent.CopyOnWriteArrayList
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import kotlin.concurrent.atomics.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
import kotlin.concurrent.atomics.AtomicInt
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
import kotlin.concurrent.atomics.ExperimentalAtomicApi
|
|
||||||
import kotlin.concurrent.atomics.incrementAndFetch
|
|
||||||
|
|
||||||
@OptIn(ExperimentalAtomicApi::class)
|
|
||||||
class LibraryUpdateJob(private val context: Context, workerParams: WorkerParameters) :
|
class LibraryUpdateJob(private val context: Context, workerParams: WorkerParameters) :
|
||||||
CoroutineWorker(context, workerParams) {
|
CoroutineWorker(context, workerParams) {
|
||||||
|
|
||||||
@ -346,7 +343,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
|||||||
*/
|
*/
|
||||||
private suspend fun updateChapterList() {
|
private suspend fun updateChapterList() {
|
||||||
val semaphore = Semaphore(5)
|
val semaphore = Semaphore(5)
|
||||||
val progressCount = AtomicInt(0)
|
val progressCount = AtomicInteger(0)
|
||||||
val currentlyUpdatingManga = CopyOnWriteArrayList<Manga>()
|
val currentlyUpdatingManga = CopyOnWriteArrayList<Manga>()
|
||||||
val newUpdates = CopyOnWriteArrayList<Pair<Manga, Array<Chapter>>>()
|
val newUpdates = CopyOnWriteArrayList<Pair<Manga, Array<Chapter>>>()
|
||||||
val failedUpdates = CopyOnWriteArrayList<Pair<Manga, String?>>()
|
val failedUpdates = CopyOnWriteArrayList<Pair<Manga, String?>>()
|
||||||
@ -404,14 +401,36 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
|||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
val newChapters = updateManga(manga, fetchWindow)
|
val newChapters = updateManga(manga, fetchWindow)
|
||||||
.sortedByDescending { it.sourceOrder }
|
// SY -->
|
||||||
|
.sortedByDescending { it.sourceOrder }.run {
|
||||||
|
if (libraryPreferences.libraryReadDuplicateChapters().get()) {
|
||||||
|
val readChapters = getChaptersByMangaId.await(manga.id).filter {
|
||||||
|
it.read
|
||||||
|
}
|
||||||
|
val newReadChapters = this.filter { chapter ->
|
||||||
|
chapter.chapterNumber >= 0 &&
|
||||||
|
readChapters.any {
|
||||||
|
it.chapterNumber == chapter.chapterNumber
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newReadChapters.isNotEmpty()) {
|
||||||
|
setReadStatus.await(true, *newReadChapters.toTypedArray())
|
||||||
|
}
|
||||||
|
|
||||||
|
this.filterNot { newReadChapters.contains(it) }
|
||||||
|
} else {
|
||||||
|
this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// SY <--
|
||||||
|
|
||||||
if (newChapters.isNotEmpty()) {
|
if (newChapters.isNotEmpty()) {
|
||||||
val chaptersToDownload = filterChaptersForDownload.await(manga, newChapters)
|
val chaptersToDownload = filterChaptersForDownload.await(manga, newChapters)
|
||||||
|
|
||||||
if (chaptersToDownload.isNotEmpty()) {
|
if (chaptersToDownload.isNotEmpty()) {
|
||||||
downloadChapters(manga, chaptersToDownload)
|
downloadChapters(manga, chaptersToDownload)
|
||||||
hasDownloads.store(true)
|
hasDownloads.set(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
libraryPreferences.newUpdatesCount().getAndSet { it + newChapters.size }
|
libraryPreferences.newUpdatesCount().getAndSet { it + newChapters.size }
|
||||||
@ -444,7 +463,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
|||||||
|
|
||||||
if (newUpdates.isNotEmpty()) {
|
if (newUpdates.isNotEmpty()) {
|
||||||
notifier.showUpdateNotifications(newUpdates)
|
notifier.showUpdateNotifications(newUpdates)
|
||||||
if (hasDownloads.load()) {
|
if (hasDownloads.get()) {
|
||||||
downloadManager.startDownloads()
|
downloadManager.startDownloads()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -510,7 +529,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
|||||||
|
|
||||||
private suspend fun updateCovers() {
|
private suspend fun updateCovers() {
|
||||||
val semaphore = Semaphore(5)
|
val semaphore = Semaphore(5)
|
||||||
val progressCount = AtomicInt(0)
|
val progressCount = AtomicInteger(0)
|
||||||
val currentlyUpdatingManga = CopyOnWriteArrayList<Manga>()
|
val currentlyUpdatingManga = CopyOnWriteArrayList<Manga>()
|
||||||
|
|
||||||
coroutineScope {
|
coroutineScope {
|
||||||
@ -558,12 +577,11 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* filter all follows from Mangadex and only add reading or rereading manga to library
|
* filter all follows from Mangadex and only add reading or rereading manga to library
|
||||||
*/
|
*/
|
||||||
private suspend fun syncFollows() = coroutineScope {
|
private suspend fun syncFollows() = coroutineScope {
|
||||||
val preferences = Injekt.get<SourcePreferences>()
|
val preferences = Injekt.get<UnsortedPreferences>()
|
||||||
var count = 0
|
var count = 0
|
||||||
val mangaDex = MdUtil.getEnabledMangaDex(preferences, sourceManager = sourceManager)
|
val mangaDex = MdUtil.getEnabledMangaDex(preferences, sourceManager = sourceManager)
|
||||||
?: return@coroutineScope
|
?: return@coroutineScope
|
||||||
@ -586,7 +604,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
|||||||
var dbManga = getManga.await(networkManga.url, mangaDex.id)
|
var dbManga = getManga.await(networkManga.url, mangaDex.id)
|
||||||
|
|
||||||
if (dbManga == null) {
|
if (dbManga == null) {
|
||||||
dbManga = networkToLocalManga(
|
dbManga = networkToLocalManga.await(
|
||||||
Manga.create().copy(
|
Manga.create().copy(
|
||||||
url = networkManga.url,
|
url = networkManga.url,
|
||||||
ogTitle = networkManga.title,
|
ogTitle = networkManga.title,
|
||||||
@ -645,7 +663,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
|||||||
|
|
||||||
private suspend fun withUpdateNotification(
|
private suspend fun withUpdateNotification(
|
||||||
updatingManga: CopyOnWriteArrayList<Manga>,
|
updatingManga: CopyOnWriteArrayList<Manga>,
|
||||||
completed: AtomicInt,
|
completed: AtomicInteger,
|
||||||
manga: Manga,
|
manga: Manga,
|
||||||
block: suspend () -> Unit,
|
block: suspend () -> Unit,
|
||||||
) = coroutineScope {
|
) = coroutineScope {
|
||||||
@ -654,7 +672,7 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
|||||||
updatingManga.add(manga)
|
updatingManga.add(manga)
|
||||||
notifier.showProgressNotification(
|
notifier.showProgressNotification(
|
||||||
updatingManga,
|
updatingManga,
|
||||||
completed.load(),
|
completed.get(),
|
||||||
mangaToUpdate.size,
|
mangaToUpdate.size,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -663,10 +681,10 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
|||||||
ensureActive()
|
ensureActive()
|
||||||
|
|
||||||
updatingManga.remove(manga)
|
updatingManga.remove(manga)
|
||||||
completed.incrementAndFetch()
|
completed.getAndIncrement()
|
||||||
notifier.showProgressNotification(
|
notifier.showProgressNotification(
|
||||||
updatingManga,
|
updatingManga,
|
||||||
completed.load(),
|
completed.get(),
|
||||||
mangaToUpdate.size,
|
mangaToUpdate.size,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -735,7 +753,6 @@ class LibraryUpdateJob(private val context: Context, workerParams: WorkerParamet
|
|||||||
private const val KEY_TARGET = "target"
|
private const val KEY_TARGET = "target"
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Key for group to update.
|
* Key for group to update.
|
||||||
*/
|
*/
|
||||||
|
@ -37,11 +37,8 @@ import tachiyomi.domain.source.service.SourceManager
|
|||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import java.util.concurrent.CopyOnWriteArrayList
|
import java.util.concurrent.CopyOnWriteArrayList
|
||||||
import kotlin.concurrent.atomics.AtomicInt
|
import java.util.concurrent.atomic.AtomicInteger
|
||||||
import kotlin.concurrent.atomics.ExperimentalAtomicApi
|
|
||||||
import kotlin.concurrent.atomics.fetchAndIncrement
|
|
||||||
|
|
||||||
@OptIn(ExperimentalAtomicApi::class)
|
|
||||||
class MetadataUpdateJob(private val context: Context, workerParams: WorkerParameters) :
|
class MetadataUpdateJob(private val context: Context, workerParams: WorkerParameters) :
|
||||||
CoroutineWorker(context, workerParams) {
|
CoroutineWorker(context, workerParams) {
|
||||||
|
|
||||||
@ -100,7 +97,7 @@ class MetadataUpdateJob(private val context: Context, workerParams: WorkerParame
|
|||||||
|
|
||||||
private suspend fun updateMetadata() {
|
private suspend fun updateMetadata() {
|
||||||
val semaphore = Semaphore(5)
|
val semaphore = Semaphore(5)
|
||||||
val progressCount = AtomicInt(0)
|
val progressCount = AtomicInteger(0)
|
||||||
val currentlyUpdatingManga = CopyOnWriteArrayList<Manga>()
|
val currentlyUpdatingManga = CopyOnWriteArrayList<Manga>()
|
||||||
|
|
||||||
coroutineScope {
|
coroutineScope {
|
||||||
@ -145,7 +142,7 @@ class MetadataUpdateJob(private val context: Context, workerParams: WorkerParame
|
|||||||
|
|
||||||
private suspend fun withUpdateNotification(
|
private suspend fun withUpdateNotification(
|
||||||
updatingManga: CopyOnWriteArrayList<Manga>,
|
updatingManga: CopyOnWriteArrayList<Manga>,
|
||||||
completed: AtomicInt,
|
completed: AtomicInteger,
|
||||||
manga: Manga,
|
manga: Manga,
|
||||||
block: suspend () -> Unit,
|
block: suspend () -> Unit,
|
||||||
) = coroutineScope {
|
) = coroutineScope {
|
||||||
@ -154,7 +151,7 @@ class MetadataUpdateJob(private val context: Context, workerParams: WorkerParame
|
|||||||
updatingManga.add(manga)
|
updatingManga.add(manga)
|
||||||
notifier.showProgressNotification(
|
notifier.showProgressNotification(
|
||||||
updatingManga,
|
updatingManga,
|
||||||
completed.load(),
|
completed.get(),
|
||||||
mangaToUpdate.size,
|
mangaToUpdate.size,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -163,10 +160,10 @@ class MetadataUpdateJob(private val context: Context, workerParams: WorkerParame
|
|||||||
ensureActive()
|
ensureActive()
|
||||||
|
|
||||||
updatingManga.remove(manga)
|
updatingManga.remove(manga)
|
||||||
completed.fetchAndIncrement()
|
completed.getAndIncrement()
|
||||||
notifier.showProgressNotification(
|
notifier.showProgressNotification(
|
||||||
updatingManga,
|
updatingManga,
|
||||||
completed.load(),
|
completed.get(),
|
||||||
mangaToUpdate.size,
|
mangaToUpdate.size,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -602,17 +602,18 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns [PendingIntent] that directly launches a share activity for a backup file.
|
* Returns [PendingIntent] that starts a share activity for a backup file.
|
||||||
*
|
*
|
||||||
* @param context context of application
|
* @param context context of application
|
||||||
* @param uri uri of backup file
|
* @param uri uri of backup file
|
||||||
* @return [PendingIntent]
|
* @return [PendingIntent]
|
||||||
*/
|
*/
|
||||||
internal fun shareBackupPendingActivity(context: Context, uri: Uri): PendingIntent {
|
internal fun shareBackupPendingBroadcast(context: Context, uri: Uri): PendingIntent {
|
||||||
val intent = uri.toShareIntent(context, "application/x-protobuf+gzip").apply {
|
val intent = Intent(context, NotificationReceiver::class.java).apply {
|
||||||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
action = ACTION_SHARE_BACKUP
|
||||||
|
putExtra(EXTRA_URI, uri)
|
||||||
}
|
}
|
||||||
return PendingIntent.getActivity(
|
return PendingIntent.getBroadcast(
|
||||||
context,
|
context,
|
||||||
0,
|
0,
|
||||||
intent,
|
intent,
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user