Merge Mihon 0.21.2 updates and use BookOasis updater
Build & Test / Build & Test App (push) Has been cancelled
Release / Extract tag name (push) Has been cancelled
Update website / update_website (release) Has been cancelled
Release / Build (push) Has been cancelled
Release / Build (FOSS) (push) Has been cancelled
Release / Create GitHub Release (push) Has been cancelled

This commit is contained in:
BookOasis Reader
2026-10-13 14:26:36 +09:00
583 changed files with 52681 additions and 30246 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ body:
required: true
- label: I have written a short but informative title.
required: true
- label: I have updated the app to version **[0.20.4](https://github.com/mihonapp/mihon/releases/latest)**.
- label: I have updated the app to version **[0.21.2](https://github.com/mihonapp/mihon/releases/latest)**.
required: true
- label: I will fill out all of the requested information in this form.
required: true
+2 -2
View File
@@ -52,7 +52,7 @@ body:
label: Mihon version
description: You can find your Mihon version in **More → About**.
placeholder: |
Example: "0.20.4"
Example: "0.21.2"
validations:
required: true
@@ -95,7 +95,7 @@ body:
required: true
- label: I have gone through the [FAQ](https://mihon.app/docs/faq/general) and [troubleshooting guide](https://mihon.app/docs/guides/troubleshooting/).
required: true
- label: I have updated the app to version **[0.20.4](https://github.com/mihonapp/mihon/releases/latest)**.
- label: I have updated the app to version **[0.21.2](https://github.com/mihonapp/mihon/releases/latest)**.
required: true
- label: I have filled out all of the requested information in this form, including specific version numbers.
required: true
+8 -6
View File
@@ -23,7 +23,7 @@ permissions:
jobs:
build:
name: Build & Test App
runs-on: 'ubuntu-24.04'
runs-on: 'ubuntu-26.04'
steps:
- name: Checkout
@@ -40,7 +40,9 @@ jobs:
distribution: temurin
- name: Set up Gradle
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- name: Check code format
run: ./gradlew spotlessCheck
@@ -54,22 +56,22 @@ jobs:
- name: Upload test report
if: steps.unit_tests.outcome == 'failure'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: test-report-${{ github.sha }}
path: app/build/reports/tests/testDebugUnitTest
- name: Build app
run: ./gradlew assembleRelease -Pinclude-telemetry -Penable-updater
run: ./gradlew assembleRelease -Pdist=ci
- name: Upload APK
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: arm64-v8a-${{ github.sha }}
path: app/build/outputs/apk/release/app-arm64-v8a-release.apk
- name: Upload mapping
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: mapping-${{ github.sha }}
path: app/build/outputs/mapping/release
+26 -14
View File
@@ -15,7 +15,7 @@ jobs:
get_tag:
if: github.repository == 'mihonapp/mihon'
name: Extract tag name
runs-on: 'ubuntu-24.04'
runs-on: 'ubuntu-26.04'
outputs:
tag: ${{ steps.extract.outputs.tag }}
@@ -27,7 +27,7 @@ jobs:
build:
if: github.repository == 'mihonapp/mihon'
name: Build
runs-on: 'ubuntu-24.04'
runs-on: 'ubuntu-26.04'
needs: get_tag
steps:
@@ -41,12 +41,19 @@ jobs:
distribution: temurin
- name: Set up Gradle
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
with:
cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }}
- name: Decode signing keystore
run: echo "$SIGNING_KEY" | base64 -d > "${{ runner.temp }}/antsy.keystore"
env:
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
- name: Build
run: ./gradlew assembleRelease -Pinclude-telemetry -Penable-updater
run: ./gradlew assembleRelease -Pdist=github
env:
storeFileBase64: ${{ secrets.SIGNING_KEY }}
storeFile: ${{ runner.temp }}/antsy.keystore
storePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyAlias: ${{ secrets.ALIAS }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
@@ -62,7 +69,7 @@ jobs:
mv app/build/outputs/apk/release/app-x86_64-release.apk mihon-x86_64-${{ needs.get_tag.outputs.tag }}.apk
- name: Upload APK
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: mihon
path: |
@@ -75,7 +82,7 @@ jobs:
build_foss:
if: github.repository == 'mihonapp/mihon'
name: Build (FOSS)
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04
needs: get_tag
steps:
@@ -89,14 +96,19 @@ jobs:
distribution: temurin
- name: Set up Gradle
uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0
uses: gradle/actions/setup-gradle@3f5f9adaf7d9fecd50b5935e54106014257a94e6 # v6.4.0
with:
cache-disabled: true
- name: Build
run: ./gradlew assembleFoss -Penable-updater
- name: Decode signing keystore
run: echo "$SIGNING_KEY" | base64 -d > "${{ runner.temp }}/antsy.keystore"
env:
storeFileBase64: ${{ secrets.SIGNING_KEY }}
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
- name: Build
run: ./gradlew assembleFoss -Pdist=foss
env:
storeFile: ${{ runner.temp }}/antsy.keystore
storePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyAlias: ${{ secrets.ALIAS }}
keyPassword: ${{ secrets.KEY_PASSWORD }}
@@ -108,7 +120,7 @@ jobs:
mv app/build/outputs/apk/foss/app-universal-foss.apk mihon-${{ needs.get_tag.outputs.tag }}-foss.apk
- name: Upload APK
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: mihon-foss
path: mihon-${{ needs.get_tag.outputs.tag }}-foss.apk
@@ -116,12 +128,12 @@ jobs:
release:
if: github.repository == 'mihonapp/mihon'
name: Create GitHub Release
runs-on: ubuntu-24.04
runs-on: ubuntu-26.04
needs: [get_tag, build, build_foss]
steps:
- name: Download all artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
merge-multiple: true
+1 -1
View File
@@ -9,7 +9,7 @@ on:
jobs:
update_website:
runs-on: 'ubuntu-24.04'
runs-on: 'ubuntu-26.04'
steps:
- name: Update website
+183 -8
View File
@@ -12,23 +12,195 @@ The format is a modified version of [Keep a Changelog](https://keepachangelog.co
## [Unreleased]
### Added
- Add `id:` prefix search to remaining trackers (AniList, Bangumi, Kitsu, MangaUpdates, Shikimori, and Hikka) ([@MajorTanya](https://github.com/MajorTanya)) ([#3776](https://github.com/mihonapp/mihon/pull/3776))
- Allow `id:` to search for slugs on Kitsu ([@MajorTanya](https://github.com/MajorTanya)) ([#3792](https://github.com/mihonapp/mihon/pull/3792))
- Add support for using the user's chosen rating system for Kitsu ([@MajorTanya](https://github.com/MajorTanya)) ([#3818](https://github.com/mihonapp/mihon/pull/3818))
- Add support for the Year, Month, and Day fields in ComicInfo.xml files for chapter dating ([@MajorTanya](https://github.com/MajorTanya)) ([#3967](https://github.com/mihonapp/mihon/pull/3967))
- Add experimental high quality reader renderer (Settings → Advanced → Use high quality renderer) with better image scaling, page transition animations, dual page view and display cutout handling ([@wwww-wwww](https://github.com/wwww-wwww)) ([#3388](https://github.com/mihonapp/mihon/pull/3388))
- Match background and transition page colors to the old reader ([@AntsyLich](https://github.com/AntsyLich)) ([#3765](https://github.com/mihonapp/mihon/pull/3765))
- Support the Fit width, Fit height and Original size scale types and the zoom start position ([@wwww-wwww](https://github.com/wwww-wwww)) ([#3801](https://github.com/mihonapp/mihon/pull/3801))
- Fix preloading and navigation across chapters, and right-to-left navigation ([@wwww-wwww](https://github.com/wwww-wwww)) ([#3823](https://github.com/mihonapp/mihon/pull/3823))
- Add a "None" page transition and fix the background color of animated images ([@wwww-wwww](https://github.com/wwww-wwww)) ([#3843](https://github.com/mihonapp/mihon/pull/3843))
- Improve transition and error pages, dual page animations and border cropping ([@wwww-wwww](https://github.com/wwww-wwww)) ([#3852](https://github.com/mihonapp/mihon/pull/3852))
- Fix navigation directions and long strip bounds, and fade in loaded pages ([@wwww-wwww](https://github.com/wwww-wwww)) ([#3870](https://github.com/mihonapp/mihon/pull/3870))
- Add a "Page flip" transition, a long strip minimum width setting and separate dual page settings, and show wide pages on their own in dual page view ([@wwww-wwww](https://github.com/wwww-wwww)) ([#3886](https://github.com/mihonapp/mihon/pull/3886))
- Fix freezes and running out of memory when jumping between pages with the slider ([@Danidukiyu](https://github.com/Danidukiyu)) ([#3872](https://github.com/mihonapp/mihon/pull/3872))
- Add HDR, ICC color profile and EXIF orientation support ([@wwww-wwww](https://github.com/wwww-wwww)) ([#3933](https://github.com/mihonapp/mihon/pull/3933))
- Add a page gap setting for long strip with gaps and a "Disable zoom out" setting for long strip modes ([@wwww-wwww](https://github.com/wwww-wwww)) ([#3933](https://github.com/mihonapp/mihon/pull/3933))
- Fix a crash on Android 15 and long strip progress and background color ([@wwww-wwww](https://github.com/wwww-wwww)) ([#3949](https://github.com/mihonapp/mihon/pull/3949))
- Keep the reader menu open while moving through pages with the slider ([@wwww-wwww](https://github.com/wwww-wwww)) ([#3956](https://github.com/mihonapp/mihon/pull/3956))
- Show pages progressively while they download ([@wwww-wwww](https://github.com/wwww-wwww)) ([#4023](https://github.com/mihonapp/mihon/pull/4023))
- Lower memory use for animated images and support cropping borders in long strip ([@wwww-wwww](https://github.com/wwww-wwww)) ([#4029](https://github.com/mihonapp/mihon/pull/4029))
- Pair more wide pages in dual page view by comparing them with neighbouring pages ([@wwww-wwww](https://github.com/wwww-wwww)) ([#4051](https://github.com/mihonapp/mihon/pull/4051))
### Changed
- Use a new decoder for images Android can't decode itself, like AVIF, JPEG XL and HEIF, and support JPEG 2000 images ([@wwww-wwww](https://github.com/wwww-wwww)) ([#3786](https://github.com/mihonapp/mihon/pull/3786))
### Improved
- Show updates and upcoming filter icon as active for categories ([@Secozzi](https://github.com/Secozzi)) ([#3772](https://github.com/mihonapp/mihon/pull/3772))
- Create and restore backups faster and with less memory ([@NGB-Was-Taken](https://github.com/NGB-Was-Taken), [@AntsyLich](https://github.com/AntsyLich))
### Removed
- Remove "Custom hardware bitmap threshold" and "Custom display profile" advanced settings ([@wwww-wwww](https://github.com/wwww-wwww)) ([#3786](https://github.com/mihonapp/mihon/pull/3786))
## [v0.21.2] - 2026-10-13
### Fixed
- Fix long floating point numbers showing up in Comick progress ([@MajorTanya](https://github.com/MajorTanya)) ([#4090](https://github.com/mihonapp/mihon/pull/4090))
- Fixed updating from v0.20.x failing when the database had duplicate history or tracking entries, or damaged indexes ([@AntsyLich](https://github.com/AntsyLich)) ([`ea2b73a`](https://github.com/mihonapp/mihon/commit/ea2b73a))
- Fixed a crash when a back gesture was still in progress as the reader or a dialog closed ([@AntsyLich](https://github.com/AntsyLich)) ([`43de88c`](https://github.com/mihonapp/mihon/commit/43de88c))
- Fixed Kitsu login and other requests that send data failing with "Failed to bypass Cloudflare" ([@AntsyLich](https://github.com/AntsyLich)) ([`7ae858e`](https://github.com/mihonapp/mihon/commit/7ae858e))
- Fixed tracker start date being off by a day when adding tracking to an entry with read history in some timezones ([@hazptr](https://github.com/hazptr)) ([#4049](https://github.com/mihonapp/mihon/pull/4049))
- Fixed the paged reader crashing when moving to another chapter after a wide page of a neighbouring chapter was split ([@AntsyLich](https://github.com/AntsyLich)) ([`3156b4a`](https://github.com/mihonapp/mihon/commit/3156b4a))
- Fixed a crash when opening the filters of a source with an invalid filter ([@AntsyLich](https://github.com/AntsyLich)) ([`c9e1b6e`](https://github.com/mihonapp/mihon/commit/c9e1b6e))
- Fixed a crash when installing an extension on a device where the system installer can't ask for confirmation ([@AntsyLich](https://github.com/AntsyLich)) ([`2df48e1`](https://github.com/mihonapp/mihon/commit/2df48e1))
- Fixed a crash when tapping in the long strip reader as it closed ([@AntsyLich](https://github.com/AntsyLich)) ([`c371d63`](https://github.com/mihonapp/mihon/commit/c371d63))
- Fixed chapters downloaded before v0.21.0 showing as not downloaded when their name started with a space or dot, was long, or had a non-ASCII scanlator ([@AntsyLich](https://github.com/AntsyLich)) ([`f0f1e4d`](https://github.com/mihonapp/mihon/commit/f0f1e4d))
- Fixed slowdowns and running out of memory when many requests to a site hit a Cloudflare challenge at once ([@tigeryu8900](https://github.com/tigeryu8900), [@AntsyLich](https://github.com/AntsyLich)) ([`5a5ff22`](https://github.com/mihonapp/mihon/commit/5a5ff22))
## [v0.21.1] - 2026-10-12
### Fixed
- Fixed refreshing chapters failing with the app language set to Arabic or another language with its own digits ([@AntsyLich](https://github.com/AntsyLich)) ([`8457fb9`](https://github.com/mihonapp/mihon/commit/8457fb9))
- Fixed a crash on launch on some Samsung devices running Android 9 to 11 ([@AntsyLich](https://github.com/AntsyLich)) ([`abb126a`](https://github.com/mihonapp/mihon/commit/abb126a))
- Fixed the start and resume button going under the taskbar on tablets ([@AntsyLich](https://github.com/AntsyLich)) ([`c279291`](https://github.com/mihonapp/mihon/commit/c279291))
- Fixed a crash when updating an extension while others were installing ([@AntsyLich](https://github.com/AntsyLich)) ([`07b9fb6`](https://github.com/mihonapp/mihon/commit/07b9fb6))
- Fixed library entries without a date added getting their last update time as date added when updating from v0.20.x ([@AntsyLich](https://github.com/AntsyLich)) ([`6dffca1`](https://github.com/mihonapp/mihon/commit/6dffca1))
- Fixed the app closing when WebView's page process crashed ([@AntsyLich](https://github.com/AntsyLich)) ([`649fc83`](https://github.com/mihonapp/mihon/commit/649fc83))
- Fixed installing or updating an extension sometimes cancelling the install of another one ([@AntsyLich](https://github.com/AntsyLich)) ([`ae749bb`](https://github.com/mihonapp/mihon/commit/ae749bb))
- Fixed updating from v0.20.x taking up to hours on libraries with many duplicate entries ([@AntsyLich](https://github.com/AntsyLich)) ([`a999e49`](https://github.com/mihonapp/mihon/commit/a999e49))
- Fixed the app staying on the updating screen for good when updating its data failed, it now shows what went wrong, and updating failing on leftover data of deleted entries ([@AntsyLich](https://github.com/AntsyLich)) ([`9dbb714`](https://github.com/mihonapp/mihon/commit/9dbb714))
- Fixed library updates ignoring the smart update restrictions for entries whose details were never fetched ([@AntsyLich](https://github.com/AntsyLich)) ([`010ac71`](https://github.com/mihonapp/mihon/commit/010ac71))
- Fixed resuming a chapter sometimes opening the next chapter partway through, and saving progress to it, in the right to left reader ([@AntsyLich](https://github.com/AntsyLich)) ([`51b61a3`](https://github.com/mihonapp/mihon/commit/51b61a3))
## [v0.21.0] - 2026-10-12
### Added
- Add `id:` prefix search to remaining trackers (AniList, Bangumi, Kitsu, MangaUpdates, Shikimori, and Hikka) ([@MajorTanya](https://github.com/MajorTanya), [@BrutuZ](https://github.com/BrutuZ)) ([#3776](https://github.com/mihonapp/mihon/pull/3776))
- Allow `id:` to search for slugs on Kitsu ([@MajorTanya](https://github.com/MajorTanya)) ([#3792](https://github.com/mihonapp/mihon/pull/3792))
- Add support for using the user's chosen rating system for Kitsu ([@MajorTanya](https://github.com/MajorTanya)) ([#3818](https://github.com/mihonapp/mihon/pull/3818))
- Fix a crash after logging in to Kitsu caused by the rating system's letter case ([@Secozzi](https://github.com/Secozzi)) ([#3887](https://github.com/mihonapp/mihon/pull/3887))
- Add option to keep loading installed extensions regardless of the allowed content warnings ([@AntsyLich](https://github.com/AntsyLich)) ([#3952](https://github.com/mihonapp/mihon/pull/3952))
- Read chapter dates from the Year, Month, and Day fields of ComicInfo.xml in local source, and write them when downloading chapters ([@MajorTanya](https://github.com/MajorTanya)) ([#3967](https://github.com/mihonapp/mihon/pull/3967))
- Fix wrongly padded years and months above 12 in local source dates ([@MajorTanya](https://github.com/MajorTanya)) ([#3970](https://github.com/mihonapp/mihon/pull/3970))
- Add refresh buttons to trackers in Settings to update displayed usernames & rating systems (where supported) ([@MajorTanya](https://github.com/MajorTanya)) ([#3828](https://github.com/mihonapp/mihon/pull/3828))
- Add option to turn off the hash suffix in downloaded chapter folder names (Settings → Advanced). It stays on for existing installs ([@choppeh](https://github.com/choppeh), [@AntsyLich](https://github.com/AntsyLich)) ([#3966](https://github.com/mihonapp/mihon/pull/3966))
- Fixed downloads not being found when the scanlator name contains a "/" ([@AntsyLich](https://github.com/AntsyLich)) ([`a5d584e`](https://github.com/mihonapp/mihon/commit/a5d584e))
- Show a screen while the app migrates its data after an update ([@AntsyLich](https://github.com/AntsyLich)) ([`fd4f73c`](https://github.com/mihonapp/mihon/commit/fd4f73c))
- Keep the screen up for at least a second so it doesn't just flash by ([@AntsyLich](https://github.com/AntsyLich)) ([`b454c1b`](https://github.com/mihonapp/mihon/commit/b454c1b))
- Add option to skip an app update version ([@AntsyLich](https://github.com/AntsyLich)) ([`fc20410`](https://github.com/mihonapp/mihon/commit/fc20410))
- Add support for [Comick](https://comick.dev) tracker ([@MajorTanya](https://github.com/MajorTanya)) ([#4056](https://github.com/mihonapp/mihon/pull/4056))
### Changed
- Download app updates from the update screen instead of a background job, and remove the "App updates" notification channel ([@AntsyLich](https://github.com/AntsyLich)) ([#3707](https://github.com/mihonapp/mihon/pull/3707))
- Switch app icons to Material Symbols ([@AntsyLich](https://github.com/AntsyLich)) ([#3873](https://github.com/mihonapp/mihon/pull/3873))
- Use the filled icon for the library continue reading button ([@AntsyLich](https://github.com/AntsyLich)) ([`34a33ed`](https://github.com/mihonapp/mihon/commit/34a33ed))
- Move notification, launcher shortcut, bottom navigation and reading mode icons to Material Symbols, bring back filled icons where the switch dropped them, and show a compact grid icon for the compact display modes ([@AntsyLich](https://github.com/AntsyLich)) ([#4057](https://github.com/mihonapp/mihon/pull/4057))
- Replace the NSFW sources toggle with allowed content warnings (Safe, Mixed, 18+) for extensions ([@AntsyLich](https://github.com/AntsyLich)) ([#3951](https://github.com/mihonapp/mihon/pull/3951))
- Restoring a backup over an existing library now keeps existing entry details, the furthest read progress and the earliest date added ([@AntsyLich](https://github.com/AntsyLich)) ([`c67a33f`](https://github.com/mihonapp/mihon/commit/c67a33f))
- Install and update extensions only from a repo whose signing key matches the extension, and reject downloaded extensions not signed with their repo's key ([@AntsyLich](https://github.com/AntsyLich)) ([`0938411`](https://github.com/mihonapp/mihon/commit/0938411))
- Keep the repo shown for an installed extension current when repos are renamed or removed ([@AntsyLich](https://github.com/AntsyLich)) ([`09edf7d`](https://github.com/mihonapp/mihon/commit/09edf7d))
- Show the repo name in extension details, opening the repo's website, instead of the "Open source repo" button ([@AntsyLich](https://github.com/AntsyLich)) ([#3955](https://github.com/mihonapp/mihon/pull/3955))
- Rework the database schema, merging duplicate entries and chapters left by older versions. The merge can't be undone, so create a backup before updating ([@AntsyLich](https://github.com/AntsyLich)) ([#3805](https://github.com/mihonapp/mihon/pull/3805))
- Fixed restoring a backup failing on entries that list a category or excluded scanlator twice ([@AntsyLich](https://github.com/AntsyLich)) ([#4022](https://github.com/mihonapp/mihon/pull/4022))
- List MangaBaka first among trackers ([@AntsyLich](https://github.com/AntsyLich)) ([`dd46413`](https://github.com/mihonapp/mihon/commit/dd46413))
- Show a wavy progress ring while a chapter downloads ([@AntsyLich](https://github.com/AntsyLich)) ([`e562a9b`](https://github.com/mihonapp/mihon/commit/e562a9b))
- Show a confirmation dialog when unfavoriting manga from the manga screen ([@WizaHX](https://github.com/WizaHX)) ([#4073](https://github.com/mihonapp/mihon/pull/4073))
### Improved
- Show the updates and upcoming filter icon as active when filtering by category, or by hidden excluded scanlators in updates ([@Secozzi](https://github.com/Secozzi)) ([#3772](https://github.com/mihonapp/mihon/pull/3772))
- Load extensions in the background to speed up app startup ([@AntsyLich](https://github.com/AntsyLich)) ([#3788](https://github.com/mihonapp/mihon/pull/3788))
- Wait for extensions to load before listing sources, so lists and global search aren't empty right after launch ([@AntsyLich](https://github.com/AntsyLich)) ([#3841](https://github.com/mihonapp/mihon/pull/3841))
- Show scores in MangaUpdates search results (and authors for `id:` prefix searches) ([@MajorTanya](https://github.com/MajorTanya)) ([#3795](https://github.com/mihonapp/mihon/pull/3795))
- Remove whitespace from MAL and MB `id:` prefix search inputs before searching ([@MajorTanya](https://github.com/MajorTanya)) ([#3793](https://github.com/mihonapp/mihon/pull/3793))
- Detect Cloudflare challenges with Cloudflare's `cf-mitigated` header, and fail sooner when a challenge needs user interaction instead of waiting for the timeout ([@tigeryu8900](https://github.com/tigeryu8900)) ([#3842](https://github.com/mihonapp/mihon/pull/3842))
- Show a helpful error message for expired AniList credentials ([@MajorTanya](https://github.com/MajorTanya)) ([#3888](https://github.com/mihonapp/mihon/pull/3888))
- Show installed extensions that couldn't be loaded, with the reason and a copyable stack trace ([@AntsyLich](https://github.com/AntsyLich)) ([#3953](https://github.com/mihonapp/mihon/pull/3953))
- Apply extension trust, repo and content warning changes without restarting the app ([@AntsyLich](https://github.com/AntsyLich)) ([#3954](https://github.com/mihonapp/mihon/pull/3954))
- Use the system document picker when selecting a backup to restore ([@MajorTanya](https://github.com/MajorTanya)) ([#3948](https://github.com/mihonapp/mihon/pull/3948))
- Offer updates for installed extensions that aren't loaded ([@AntsyLich](https://github.com/AntsyLich)) ([`2d86a70`](https://github.com/mihonapp/mihon/commit/2d86a70))
- Show available extension updates on the Browse badge and in the Extensions tab right after launch ([@AntsyLich](https://github.com/AntsyLich)) ([`4f33486`](https://github.com/mihonapp/mihon/commit/4f33486))
- Show which repo an extension comes from in the extensions list, and list an extension once for each repo signing key offering it ([@AntsyLich](https://github.com/AntsyLich)) ([#3955](https://github.com/mihonapp/mihon/pull/3955))
- Speed up loading the library on large libraries ([@AntsyLich](https://github.com/AntsyLich)) ([#3805](https://github.com/mihonapp/mihon/pull/3805))
- Speed up history, updates, the updates widget and browse on large libraries ([@AntsyLich](https://github.com/AntsyLich)) ([#4022](https://github.com/mihonapp/mihon/pull/4022))
- Reduce lag when dragging sliders in settings ([@AntsyLich](https://github.com/AntsyLich)) ([`9409740`](https://github.com/mihonapp/mihon/commit/9409740))
- Speed up refreshing the library when returning to it ([@AntsyLich](https://github.com/AntsyLich)) ([`f027de8`](https://github.com/mihonapp/mihon/commit/f027de8))
- Download a source's chapters faster by starting the next one while the current one finishes ([@AntsyLich](https://github.com/AntsyLich)) ([`730e43f`](https://github.com/mihonapp/mihon/commit/730e43f))
- Load an entry's cover once when several updates show it ([@AntsyLich](https://github.com/AntsyLich)) ([`1f85a5a`](https://github.com/mihonapp/mihon/commit/1f85a5a))
- Speed up the entry details chapter list on entries with many chapters, and the updates list when many chapters are queued for download ([@AntsyLich](https://github.com/AntsyLich)) ([`fb8e640`](https://github.com/mihonapp/mihon/commit/fb8e640))
- Speed up checking which chapters are downloaded ([@AntsyLich](https://github.com/AntsyLich)) ([`6a32938`](https://github.com/mihonapp/mihon/commit/6a32938))
- Stop the entry details screen from refreshing its chapter list in the background while reading ([@AntsyLich](https://github.com/AntsyLich)) ([`7ff9776`](https://github.com/mihonapp/mihon/commit/7ff9776))
- Speed up opening the library on large libraries by loading tracker entries only for tracker filters and sorting ([@AntsyLich](https://github.com/AntsyLich)) ([`940272f`](https://github.com/mihonapp/mihon/commit/940272f))
- Speed up the library query on large libraries ([@AntsyLich](https://github.com/AntsyLich)) ([`5df78e3`](https://github.com/mihonapp/mihon/commit/5df78e3))
- Speed up the statistics screen on large libraries ([@AntsyLich](https://github.com/AntsyLich)) ([`179bfac`](https://github.com/mihonapp/mihon/commit/179bfac))
- Find settings by their group heading in settings search ([@kaosjammo](https://github.com/kaosjammo), [@AntsyLich](https://github.com/AntsyLich)) ([#4044](https://github.com/mihonapp/mihon/pull/4044))
- Predict the next library update from release patterns such as fixed weekdays or a day of the month, ignore chapters dated in the future, and include the predicted date in backups ([@AntsyLich](https://github.com/AntsyLich)) ([`2923816`](https://github.com/mihonapp/mihon/commit/2923816))
- Also follow two days of the month, a weekday of the month, releases in batches and breaks between seasons, and never wait more than 28 days between checks ([@AntsyLich](https://github.com/AntsyLich)) ([`ba44815`](https://github.com/mihonapp/mihon/commit/ba44815))
- Recognize chapter numbers more accurately by looking at neighbouring chapters, and stop taking volume numbers or numbers every chapter name shares as the chapter number ([@AntsyLich](https://github.com/AntsyLich)) ([`e42e010`](https://github.com/mihonapp/mihon/commit/e42e010))
- Move blocking work off the main thread across the app for fewer freezes and stutters ([@AntsyLich](https://github.com/AntsyLich)) ([#4068](https://github.com/mihonapp/mihon/pull/4068))
- Load reader pages in parallel and preload the rest of the chapter and the next chapter, with a "Load ahead only on Wi-Fi" setting to save mobile data ([@AntsyLich](https://github.com/AntsyLich)) ([#2986](https://github.com/mihonapp/mihon/pull/2986))
- Cache extension and source icons so lists show them faster ([@AntsyLich](https://github.com/AntsyLich)) ([`b15af71`](https://github.com/mihonapp/mihon/commit/b15af71))
- Keep screens loaded while they're hidden so switching back to them is faster ([@AntsyLich](https://github.com/AntsyLich)) ([#4071](https://github.com/mihonapp/mihon/pull/4071))
- Speed up the migration list, the extensions list and settings search ([@AntsyLich](https://github.com/AntsyLich)) ([#4071](https://github.com/mihonapp/mihon/pull/4071))
- Cancel the previous tracker search when searching again ([@AntsyLich](https://github.com/AntsyLich)) ([#4071](https://github.com/mihonapp/mihon/pull/4071))
- Do less background work while reading, downloading and updating the library, and when no updates widget is placed ([@AntsyLich](https://github.com/AntsyLich)) ([#4071](https://github.com/mihonapp/mihon/pull/4071))
- Speed up loading extension repos at startup ([@AntsyLich](https://github.com/AntsyLich)) ([`8066b8d`](https://github.com/mihonapp/mihon/commit/8066b8d))
- Speed up opening the entry details screen and showing download progress there and in updates ([@AntsyLich](https://github.com/AntsyLich)) ([`ba16158`](https://github.com/mihonapp/mihon/commit/ba16158))
- Speed up queueing many chapters for download at once ([@AntsyLich](https://github.com/AntsyLich)) ([`f02bf5b`](https://github.com/mihonapp/mihon/commit/f02bf5b))
### Removed
- Remove "Use legacy decoder for long strip reader" advanced setting, since long strip pages no longer load as one big image ([@AntsyLich](https://github.com/AntsyLich))
### Fixed
- Fixed app and extension update check running again on configuration change ([@AntsyLich](https://github.com/AntsyLich)) ([#3708](https://github.com/mihonapp/mihon/pull/3708))
- Fixed MangaBaka user start/finish dates drifting in negative offset timezones ([@MajorTanya](https://github.com/MajorTanya)) ([#3711](https://github.com/mihonapp/mihon/pull/3711))
- Fixed MangaBaka scores being wrong when score step size was set to > 1 ([@MajorTanya](https://github.com/MajorTanya)) ([#3740](https://github.com/mihonapp/mihon/pull/3740))
- Fixed MangaBaka scores being wrong when score step size was set to > 1, and being counted 10 times too high in library sorting by tracker score and in statistics ([@MajorTanya](https://github.com/MajorTanya)) ([#3740](https://github.com/mihonapp/mihon/pull/3740))
- Fixed tracking an entry on Shikimori failing with "Unknown status: 0" when it isn't in your Shikimori list ([@MajorTanya](https://github.com/MajorTanya)) ([#3810](https://github.com/mihonapp/mihon/pull/3810))
- Fixed default category and manga sometimes not getting their category set when restoring a backup ([@Secozzi](https://github.com/Secozzi)) ([#3891](https://github.com/mihonapp/mihon/pull/3891))
- Fixed AniList rate limit ([@MajorTanya](https://github.com/MajorTanya)) ([#3942](https://github.com/mihonapp/mihon/pull/3942))
- Fixed text between dollar signs disappearing from descriptions and notes ([@renovate](https://github.com/apps/renovate)) ([#3806](https://github.com/mihonapp/mihon/pull/3806))
- Fixed AniList requests failing with rate limit errors by lowering the request rate to AniList's current limit ([@MajorTanya](https://github.com/MajorTanya)) ([#3942](https://github.com/mihonapp/mihon/pull/3942))
- Fixed library search when clicking source name in manga info screen ([@choppeh](https://github.com/choppeh)) ([#4002](https://github.com/mihonapp/mihon/pull/4002))
- Fixed entries being incorrectly marked as duplicates when tracked with some trackers ([@Secozzi](https://github.com/Secozzi)) ([#4008](https://github.com/mihonapp/mihon/pull/4008))
- Fixed the default chapter settings not being applied to entries added to the library from a source by long pressing them ([@AntsyLich](https://github.com/AntsyLich)) ([`f8fff31`](https://github.com/mihonapp/mihon/commit/f8fff31))
- Fixed chapter list updates being partially applied when a refresh fails, and sources that list a chapter twice adding it twice ([@AntsyLich](https://github.com/AntsyLich)) ([`6ee529c`](https://github.com/mihonapp/mihon/commit/6ee529c))
- Fixed downloads of entries from uninstalled extensions sometimes not being recognized ([@AntsyLich](https://github.com/AntsyLich)) ([`0044cc7`](https://github.com/mihonapp/mihon/commit/0044cc7))
- Fixed a removed extension repo coming back when it was removed while repos were refreshing ([@AntsyLich](https://github.com/AntsyLich)) ([`fc5592f`](https://github.com/mihonapp/mihon/commit/fc5592f))
- Fixed being able to rename a category to an empty name ([@AntsyLich](https://github.com/AntsyLich)) ([`8bfa495`](https://github.com/mihonapp/mihon/commit/8bfa495))
- Fixed reading time sometimes being counted twice, and tracker start dates being set to 1970 after removing history ([@AntsyLich](https://github.com/AntsyLich)) ([`553762f`](https://github.com/mihonapp/mihon/commit/553762f))
- Fixed chapters from excluded scanlators failing to open from notifications or links ([@AntsyLich](https://github.com/AntsyLich)) ([`2b4b847`](https://github.com/mihonapp/mihon/commit/2b4b847))
- Fixed queued offline tracker updates being lost when the track was refreshed ([@AntsyLich](https://github.com/AntsyLich)) ([`9a77bae`](https://github.com/mihonapp/mihon/commit/9a77bae))
- Fixed restoring a backup mixing up tracker entries of an entry that was already tracked ([@AntsyLich](https://github.com/AntsyLich)) ([`4b48a84`](https://github.com/mihonapp/mihon/commit/4b48a84))
- Fixed crashes from APIs extensions use being removed from release builds ([@AntsyLich](https://github.com/AntsyLich)) ([`6dfa10f`](https://github.com/mihonapp/mihon/commit/6dfa10f))
- Fixed the download service staying alive after downloads stopped for a network change ([@AntsyLich](https://github.com/AntsyLich)) ([`01d302f`](https://github.com/mihonapp/mihon/commit/01d302f))
- Fixed "database is locked" crashes ([@AntsyLich](https://github.com/AntsyLich)) ([`38e9308`](https://github.com/mihonapp/mihon/commit/38e9308))
- Use WAL journaling on every device ([@AntsyLich](https://github.com/AntsyLich)) ([`61cd786`](https://github.com/mihonapp/mihon/commit/61cd786))
- Fixed global search leaking threads each time it was opened ([@choppeh](https://github.com/choppeh)) ([#4036](https://github.com/mihonapp/mihon/pull/4036))
- Fixed sources getting stuck loading in global and migration search ([@choppeh](https://github.com/choppeh)) ([#4037](https://github.com/mihonapp/mihon/pull/4037))
- Fixed webtoon reader leaving a gap after zooming in split screen or a resized window ([@AntsyLich](https://github.com/AntsyLich)) ([`d1c5c12`](https://github.com/mihonapp/mihon/commit/d1c5c12))
- Fixed download error notifications showing an old time and the previous warning's text ([@AntsyLich](https://github.com/AntsyLich)) ([`f82a7a6`](https://github.com/mihonapp/mihon/commit/f82a7a6))
- Fixed the paused downloads notification not appearing ([@AntsyLich](https://github.com/AntsyLich)) ([`7aacaa3`](https://github.com/mihonapp/mihon/commit/7aacaa3))
- Fixed duplicate page files and failed downloads after pausing and resuming downloads ([@AntsyLich](https://github.com/AntsyLich)) ([`6490c41`](https://github.com/mihonapp/mihon/commit/6490c41))
- Fixed high CPU use on the entry details and updates screens while many chapters are queued for download ([@AntsyLich](https://github.com/AntsyLich)) ([`9a6dea8`](https://github.com/mihonapp/mihon/commit/9a6dea8))
- Fixed backups dropping the names of sources whose extension isn't installed, which left them blank under missing sources when restoring ([@AntsyLich](https://github.com/AntsyLich)) ([`5910a51`](https://github.com/mihonapp/mihon/commit/5910a51))
- Fixed the updates widget showing "Can't show content" when there are no recent updates or app lock is on ([@AntsyLich](https://github.com/AntsyLich)) ([`76b146f`](https://github.com/mihonapp/mihon/commit/76b146f))
- Fixed a crash when range selecting library entries across categories ([@AntsyLich](https://github.com/AntsyLich)) ([`a6ee4bc`](https://github.com/mihonapp/mihon/commit/a6ee4bc))
- Fixed reader tap navigation not responding after a button press turned into a scroll ([@mujina3](https://github.com/mujina3)) ([#3655](https://github.com/mihonapp/mihon/pull/3655))
- Fixed editing the cover of an entry that isn't in the library saying the cover was updated without changing it, and say to add it to the library first instead ([@quickdesh](https://github.com/quickdesh), [@AntsyLich](https://github.com/AntsyLich)) ([#2265](https://github.com/mihonapp/mihon/pull/2265))
- Fixed downloads of duplicate chapters not being deleted when they were marked as read along with a chapter ([@leodyversemilla07](https://github.com/leodyversemilla07), [@AntsyLich](https://github.com/AntsyLich)) ([#3030](https://github.com/mihonapp/mihon/pull/3030))
- Fixed library updates skipping entries whose details were never fetched ([@NarwhalHorns](https://github.com/NarwhalHorns), [@AntsyLich](https://github.com/AntsyLich)) ([#3179](https://github.com/mihonapp/mihon/pull/3179))
- Fixed every library entry being matched as a duplicate of an entry with a blank title ([@NarwhalHorns](https://github.com/NarwhalHorns), [@AntsyLich](https://github.com/AntsyLich)) ([#3308](https://github.com/mihonapp/mihon/pull/3308))
- Fixed marking chapters as read deleting their downloads in categories excluded from "Delete after reading" ([@mliem2k](https://github.com/mliem2k)) ([#3558](https://github.com/mihonapp/mihon/pull/3558))
- Fixed local source entries missing from global search ([@mugetau](https://github.com/mugetau)) ([#3784](https://github.com/mihonapp/mihon/pull/3784))
- Fixed the Updates screen hiding the last update time and pull to refresh when it has no chapters, and saying there are no recent updates when filters hide them all ([@AMendoza180890](https://github.com/AMendoza180890), [@AntsyLich](https://github.com/AntsyLich)) ([#3790](https://github.com/mihonapp/mihon/pull/3790))
- Fixed downloads of chapters removed by the source getting stuck in the download queue ([@JoJoKorok](https://github.com/JoJoKorok), [@AntsyLich](https://github.com/AntsyLich)) ([#3845](https://github.com/mihonapp/mihon/pull/3845))
- Fixed the stored download index overwriting the startup rescan, which could show downloaded chapters as not downloaded ([@choppeh](https://github.com/choppeh), [@AntsyLich](https://github.com/AntsyLich)) ([#3968](https://github.com/mihonapp/mihon/pull/3968))
- Fixed local chapters no longer being listed after one archive couldn't be read ([@a-biad](https://github.com/a-biad), [@AntsyLich](https://github.com/AntsyLich)) ([#3997](https://github.com/mihonapp/mihon/pull/3997))
- Fixed "Hide missing chapter indicators" not hiding the indicator in chapter headers ([@kaosjammo](https://github.com/kaosjammo)) ([#4039](https://github.com/mihonapp/mihon/pull/4039))
- Fixed a chapter being downloaded a second time when downloads were stopped right as it finished ([@AntsyLich](https://github.com/AntsyLich)) ([`6115783`](https://github.com/mihonapp/mihon/commit/6115783))
- Fixed the chapter selection being cleared when new chapters were downloaded automatically after a refresh ([@AntsyLich](https://github.com/AntsyLich)) ([`a82d27c`](https://github.com/mihonapp/mihon/commit/a82d27c))
- Fixed actions started from a dialog sometimes not running when the dialog closed right away, Kitsu, Shikimori, MangaBaka, Bangumi and Hikka sometimes refreshing their login twice at once, adding an extension repo served over HTTP failing, and cancelling an extension install not stopping its download ([@AntsyLich](https://github.com/AntsyLich)) ([#4068](https://github.com/mihonapp/mihon/pull/4068))
- Fixed the next library update staying "Soon" after new chapters were found, and chapters that came out early, late or were dated earlier by the source pushing the next check back ([@AntsyLich](https://github.com/AntsyLich)) ([`ba44815`](https://github.com/mihonapp/mihon/commit/ba44815))
- Fixed long strip side padding being counted in zoom bounds ([@WizaHX](https://github.com/WizaHX)) ([#4072](https://github.com/mihonapp/mihon/pull/4072))
- Fixed long strip stuttering between pages and using a lot of memory with very tall pages ([@AntsyLich](https://github.com/AntsyLich), [@matheuswr89](https://github.com/matheuswr89))
### Other
- Show "Nightly" instead of "Beta" for preview builds and "FOSS" for FOSS builds in About ([@AntsyLich](https://github.com/AntsyLich)) ([#3760](https://github.com/mihonapp/mihon/pull/3760))
- Migrate Kitsu tracker to Kitsu's GraphQL API ([@MajorTanya](https://github.com/MajorTanya)) ([#3792](https://github.com/mihonapp/mihon/pull/3792))
- Fixed Kitsu search showing novel results ([@MajorTanya](https://github.com/MajorTanya)) ([#4069](https://github.com/mihonapp/mihon/pull/4069))
- Extensions can only get Application, Context, Json, ProtoBuf, XML, NetworkHelper and JavaScriptEngine from Injekt ([@AntsyLich](https://github.com/AntsyLich)) ([#3965](https://github.com/mihonapp/mihon/pull/3965))
- Use Apollo GraphQL for AniList, Kitsu, Shikimori and Suwayomi tracker APIs ([@MajorTanya](https://github.com/MajorTanya), [@Syer10](https://github.com/Syer10)) ([#3827](https://github.com/mihonapp/mihon/pull/3827))
## [v0.20.4] - 2026-08-05
### Fixed
@@ -640,7 +812,10 @@ Same as v0.19.6
- Branding to Mihon ([@AntsyLich](https://github.com/AntsyLich))
- Minimum supported Android version to 8 ([@AntsyLich](https://github.com/AntsyLich)) ([`dfb3091`](https://github.com/mihonapp/mihon/commit/dfb3091e380dda3e9bfb64bf5c9a685cf3a03d0e))
[unreleased]: https://github.com/mihonapp/mihon/compare/v0.20.4...main
[unreleased]: https://github.com/mihonapp/mihon/compare/v0.21.2...main
[v0.21.2]: https://github.com/mihonapp/mihon/compare/v0.21.1...v0.21.2
[v0.21.1]: https://github.com/mihonapp/mihon/compare/v0.21.0...v0.21.1
[v0.21.0]: https://github.com/mihonapp/mihon/compare/v0.20.4...v0.21.0
[v0.20.4]: https://github.com/mihonapp/mihon/compare/v0.20.3...v0.20.4
[v0.20.3]: https://github.com/mihonapp/mihon/compare/v0.20.2...v0.20.3
[v0.20.2]: https://github.com/mihonapp/mihon/compare/v0.20.1...v0.20.2
+119 -26
View File
@@ -1,11 +1,14 @@
import com.android.build.api.variant.ApplicationVariant
import com.android.build.api.variant.BuildConfigField
import com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension
import mihon.gradle.Config
import mihon.gradle.getBuildTime
import mihon.gradle.getCurrentTime
import mihon.gradle.getLatestCommitCount
import mihon.gradle.getLatestCommitSha
import mihon.gradle.getLatestCommitTime
import mihon.gradle.tasks.ReplaceShortcutsPlaceholderTask
import java.io.FileInputStream
import java.util.Properties
import kotlin.io.encoding.Base64
plugins {
alias(mihonx.plugins.android.application)
@@ -16,6 +19,7 @@ plugins {
alias(libs.plugins.aboutLibraries)
alias(libs.plugins.androidx.baselineProfile)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.apollo)
}
if (Config.includeTelemetry) {
@@ -25,7 +29,7 @@ if (Config.includeTelemetry) {
}
}
val keystorePropertiesFile = rootProject.file("keystore.properties")
val keystorePropertiesFile = layout.settingsDirectory.file("keystore.properties").asFile
android {
namespace = "eu.kanade.tachiyomi"
@@ -33,12 +37,9 @@ android {
defaultConfig {
applicationId = "app.mihon"
versionCode = 31
versionName = "0.20.5"
versionCode = 38
versionName = "0.21.2-bookoasis-r15"
buildConfigField("String", "COMMIT_COUNT", "\"${getLatestCommitCount()}\"")
buildConfigField("String", "COMMIT_SHA", "\"${getLatestCommitSha()}\"")
buildConfigField("String", "BUILD_TIME", "\"${getBuildTime(useLatestCommitTime = false)}\"")
buildConfigField("boolean", "TELEMETRY_INCLUDED", "${Config.includeTelemetry}")
buildConfigField("boolean", "UPDATER_ENABLED", "${Config.enableUpdater}")
@@ -46,14 +47,9 @@ android {
}
if (System.getenv("MIHON_GITHUB_RELEASE").toBoolean()) {
val tempStoreFile = file(System.getenv("RUNNER_TEMP")).resolve("antsy.keystore")
val storeFileBytes = System.getenv("storeFileBase64").let(Base64::decode)
tempStoreFile.outputStream().use { it.write(storeFileBytes) }
signingConfigs {
named("debug") {
storeFile = tempStoreFile
storeFile = file(System.getenv("storeFile"))
storePassword = System.getenv("storePassword")
keyAlias = System.getenv("keyAlias")
keyPassword = System.getenv("keyPassword")
@@ -75,7 +71,6 @@ android {
buildTypes {
val debug = getByName("debug") {
applicationIdSuffix = ".dev"
versionNameSuffix = "-${getLatestCommitCount()}"
isPseudoLocalesEnabled = true
}
val release = getByName("release") {
@@ -87,8 +82,6 @@ android {
isProfileable = true
proguardFiles("proguard-android-optimize.txt", "proguard-rules.pro")
buildConfigField("String", "BUILD_TIME", "\"${getBuildTime(useLatestCommitTime = true)}\"")
}
val commonMatchingFallbacks = listOf(release.name)
@@ -105,11 +98,7 @@ android {
applicationIdSuffix = ".debug"
versionNameSuffix = debug.versionNameSuffix
matchingFallbacks.addAll(commonMatchingFallbacks)
buildConfigField("String", "BUILD_TIME", "\"${getBuildTime(useLatestCommitTime = false)}\"")
}
create("benchmark") {
initWith(release)
@@ -119,6 +108,14 @@ android {
matchingFallbacks.addAll(commonMatchingFallbacks)
}
if (Config.includeTelemetry) {
configureEach {
configure<CrashlyticsExtension> {
mappingFileUploadEnabled = Config.uploadCrashlyticsMapping
}
}
}
}
sourceSets {
@@ -208,6 +205,7 @@ dependencies {
baselineProfile(projects.baselineProfile)
implementation(projects.i18n)
implementation(projects.icons.customMaterialSymbols)
implementation(projects.icons.materialSymbols)
implementation(projects.icons.simpleIcons)
implementation(projects.core.archive)
@@ -216,7 +214,6 @@ dependencies {
implementation(projects.coreMetadata)
implementation(projects.sourceApi)
implementation(projects.sourceLocal)
implementation(libs.jsoup)
implementation(projects.data)
implementation(projects.domain)
implementation(projects.presentationCore)
@@ -232,20 +229,17 @@ dependencies {
debugImplementation(libs.androidx.compose.uiTooling)
implementation(libs.androidx.compose.uiToolingPreview)
implementation(libs.androidx.compose.uiUtil)
implementation(libs.androidx.navigationEvent)
implementation(libs.androidx.interpolator)
implementation(libs.androidx.paging.runtime)
implementation(libs.androidx.paging.compose)
implementation(libs.androidx.sqlite.bundled)
implementation(libs.kotlin.reflect)
implementation(libs.bundles.kotlinx.coroutines)
implementation(libs.sqldelight.async)
implementation(libs.kotlinx.datetime)
// AndroidX libraries
@@ -327,6 +321,10 @@ dependencies {
// String similarity
implementation(libs.stringSimilarity)
// GraphQL generation
implementation(libs.apollo)
implementation(libs.apollo.adapters)
// Tests
testImplementation(libs.bundles.test)
testRuntimeOnly(libs.junit.platform.launcher)
@@ -338,7 +336,102 @@ dependencies {
testImplementation(libs.kotlinx.coroutines.test)
}
apollo {
val schemaBasePath = "src/main/graphql/mihon/graphql"
service("anilist") {
packageName.set("mihon.graphql.anilist")
val srcDir = "$schemaBasePath/anilist"
srcDir(file(srcDir))
introspection {
endpointUrl.set("https://graphql.anilist.co")
schemaFile.set(file("$srcDir/anilist.graphqls"))
}
// ISO 3166-1 alpha-2 country code
mapScalarToKotlinString("CountryCode")
}
service("kitsu") {
packageName.set("mihon.graphql.kitsu")
val srcDir = "$schemaBasePath/kitsu"
srcDir(file(srcDir))
android.defaultConfig.versionCode
introspection {
// Kitsu doesn't like requests without a UA
headers.put(
"User-Agent",
"Mihon v${android.defaultConfig.versionName} (${android.defaultConfig.applicationId})",
)
endpointUrl.set("https://kitsu.app/api/graphql")
schemaFile.set(file("$srcDir/kitsu.graphqls"))
}
// A date, expressed as an ISO8601 string
mapScalarToKotlinString("Date")
// An ISO 8601-encoded datetime
mapScalar("ISO8601DateTime", "kotlin.time.Instant", "com.apollographql.adapter.core.KotlinInstantAdapter")
// A loose key-value map in GraphQL
mapScalar(
"Map",
"kotlin.collections.Map<String, Any?>",
"mihon.graphql.kitsu.adapter.KitsuMapAdapter",
)
}
service("shikimori") {
packageName.set("mihon.graphql.shikimori")
val srcDir = "$schemaBasePath/shikimori"
srcDir(file(srcDir))
introspection {
endpointUrl.set("https://shikimori.io/api/graphql")
schemaFile.set(file("$srcDir/shikimori.graphqls"))
}
// An ISO 8601-encoded date
mapScalarToKotlinString("ISO8601Date")
}
service("suwayomi") {
packageName.set("mihon.graphql.suwayomi")
val srcDir = "$schemaBasePath/suwayomi"
srcDir(file(srcDir))
introspection {
endpointUrl.set("http://localhost:4567/api/graphql")
schemaFile.set(file("$srcDir/suwayomi.graphqls"))
}
}
}
val latestCommitCount = getLatestCommitCount()
val latestCommitSha = getLatestCommitSha()
val latestCommitTime = getLatestCommitTime()
val currentTime = getCurrentTime()
fun ApplicationVariant.buildConfigField(type: String, name: String, value: Provider<String>) {
buildConfigFields?.put(name, value.map { BuildConfigField(type, it, null) })
}
androidComponents {
onVariants { variant ->
val isUnstableBuild = variant.buildType == "debug" || variant.buildType == "nightly"
val buildTime = if (isUnstableBuild) currentTime else latestCommitTime
variant.buildConfigField("String", "COMMIT_COUNT", latestCommitCount.map { "\"$it\"" })
variant.buildConfigField("String", "COMMIT_SHA", latestCommitSha.map { "\"$it\"" })
variant.buildConfigField("String", "BUILD_TIME", buildTime.map { "\"$it\"" })
if (isUnstableBuild) {
variant.outputs.forEach { output ->
val versionName = output.versionName.get()
output.versionName.set(latestCommitCount.map { "$versionName-$it" })
}
}
}
onVariants { variant ->
val resSource = variant.sources.res ?: return@onVariants
+3 -11
View File
@@ -1,8 +1,8 @@
-dontobfuscate
-keep,allowoptimization class eu.kanade.**
-keep,allowoptimization class tachiyomi.**
-keep,allowoptimization class mihon.**
# Injekt reads the injected type from the generic superclass of its type tokens
-keepattributes Signature
-keep,allowshrinking class * extends uy.kohesive.injekt.api.FullTypeReference
# Keep common dependencies used in extensions
-keep,allowoptimization class androidx.preference.** { public protected *; }
@@ -18,14 +18,6 @@
-keep,allowoptimization class uy.kohesive.injekt.** { public protected *; }
-keep,allowoptimization class com.squareup.zstd.** { public protected *; }
# From extensions-lib
-keep,allowoptimization class eu.kanade.tachiyomi.network.interceptor.RateLimitInterceptorKt { public protected *; }
-keep,allowoptimization class eu.kanade.tachiyomi.network.interceptor.SpecificHostRateLimitInterceptorKt { public protected *; }
-keep,allowoptimization class eu.kanade.tachiyomi.network.NetworkHelper { public protected *; }
-keep,allowoptimization class eu.kanade.tachiyomi.network.OkHttpExtensionsKt { public protected *; }
-keep,allowoptimization class eu.kanade.tachiyomi.network.RequestsKt { public protected *; }
-keep,allowoptimization class eu.kanade.tachiyomi.AppInfo { public protected *; }
-keepclassmembers class * implements java.io.Serializable {
java.lang.Object writeReplace();
java.lang.Object readResolve();
+11
View File
@@ -199,6 +199,17 @@
<data android:host="shikimori-auth" />
<data android:host="hikka-auth" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Comick requires native reverse-domain schemes -->
<data android:scheme="app.mihon" />
<data android:host="comick-auth" />
</intent-filter>
</activity>
<receiver
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,15 @@
mutation AniListAddManga(
$manga_id: Int!,
$progress: Int!,
$status: MediaListStatus!,
$private: Boolean!,
) {
SaveMediaListEntry (
mediaId: $manga_id,
progress: $progress,
status: $status,
private: $private,
) {
id
}
}
@@ -0,0 +1,9 @@
mutation AniListDeleteManga(
$library_id: Int!,
) {
DeleteMediaListEntry(
id: $library_id,
) {
deleted
}
}
@@ -0,0 +1,9 @@
query AniListGetCurrentUser {
Viewer {
id
name
mediaListOptions {
scoreFormat
}
}
}
@@ -0,0 +1,31 @@
query AniListGetLibManga(
$user_id: Int!,
$manga_id: Int!,
) {
Page {
mediaList(
userId: $user_id,
type: MANGA,
mediaId: $manga_id,
) {
id
status
scoreRaw: score(format: POINT_100)
progress
private
startedAt {
year
month
day
}
completedAt {
year
month
day
}
media {
...MangaFragment
}
}
}
}
@@ -0,0 +1,13 @@
query AniListGetMangaDetails(
$manga_id: Int!,
) {
Page (perPage: 1) {
media(
id: $manga_id,
type: MANGA,
format_not_in: [NOVEL],
) {
...MangaFragment
}
}
}
@@ -0,0 +1,13 @@
query AniListSearchManga(
$search: String!,
) {
Page (perPage: 50) {
media(
search: $search,
type: MANGA,
format_not_in: [NOVEL],
) {
...MangaFragment
}
}
}
@@ -0,0 +1,21 @@
mutation AniListUpdateManga(
$library_id: Int!,
$progress: Int!,
$status: MediaListStatus!,
$private: Boolean!,
$score: Int!,
$startedAt: FuzzyDateInput!,
$completedAt: FuzzyDateInput!,
) {
SaveMediaListEntry(
id: $library_id,
progress: $progress,
status: $status,
private: $private,
scoreRaw: $score,
startedAt: $startedAt,
completedAt: $completedAt,
) {
id
}
}
@@ -0,0 +1,30 @@
fragment MangaFragment on Media {
id
staff {
edges {
role
node {
name {
userPreferred
}
}
}
}
title {
userPreferred
}
coverImage {
large
}
format
countryOfOrigin
status
chapters
description
startDate {
year
month
day
}
averageScore
}
File diff suppressed because one or more lines are too long
@@ -0,0 +1,27 @@
mutation KitsuAddLibManga(
$media_id: ID!,
$status: LibraryEntryStatusEnum!,
$progress: Int!,
$private: Boolean!,
$rating: Int,
) {
libraryEntry {
create(
input: {
mediaId: $media_id,
mediaType: MANGA,
status: $status,
progress: $progress,
private: $private,
rating: $rating,
}
) {
errors {
message
}
libraryEntry {
id
}
}
}
}
@@ -0,0 +1,18 @@
mutation KitsuDeleteLibEntry(
$library_id: ID!,
) {
libraryEntry {
delete(
input: {
id: $library_id,
}
) {
errors {
message
}
libraryEntry {
id
}
}
}
}
@@ -0,0 +1,18 @@
query KitsuFindLibManga(
$remote_id: ID!,
) {
findMangaById(
id: $remote_id,
) {
...MangaFragment
myLibraryEntry {
id
private
progress
rating
status
startedAt
finishedAt
}
}
}
@@ -0,0 +1,9 @@
query KitsuGetCurrentAccount {
currentAccount {
id
ratingSystem
profile {
name
}
}
}
@@ -0,0 +1,9 @@
query KitsuGetMangaDetailsById(
$id: ID!,
) {
findMangaById(
id: $id,
) {
...MangaFragment
}
}
@@ -0,0 +1,9 @@
query KitsuGetMangaDetailsBySlug(
$slug: String!,
) {
findMangaBySlug(
slug: $slug,
) {
...MangaFragment
}
}
@@ -0,0 +1,12 @@
query KitsuSearchMangaByTitle(
$query: String!,
) {
searchMangaByTitle(
title: $query,
first: 20,
) {
nodes {
...MangaFragment
}
}
}
@@ -0,0 +1,30 @@
mutation KitsuUpdateLibManga(
$library_id: ID!,
$status: LibraryEntryStatusEnum!,
$progress: Int!,
$private: Boolean!,
$rating: Int,
$startedAt: ISO8601DateTime,
$finishedAt: ISO8601DateTime,
) {
libraryEntry {
update(
input: {
id: $library_id,
status: $status,
progress: $progress,
private: $private,
rating: $rating,
startedAt: $startedAt,
finishedAt: $finishedAt,
}
) {
errors {
message
}
libraryEntry {
id
}
}
}
}
@@ -0,0 +1,31 @@
fragment MangaFragment on Manga {
id
titles {
preferred
}
chapterCount
staff(first: 5) {
nodes {
role
person {
name
}
}
}
posterImage {
views(names: "small") {
name
url
}
original {
name
url
}
}
description(locales: "en")
status
subtype
startDate
slug
averageRating
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,22 @@
fragment MangaFragment on Manga {
id
name
chapters
kind
poster {
mainUrl
}
score
url
status
airedOn {
date
}
description
personRoles {
person {
name
}
rolesEn
}
}
@@ -0,0 +1,6 @@
query ShikimoriGetCurrentUser {
currentUser {
id
nickname
}
}
@@ -0,0 +1,19 @@
query ShikimoriGetLibManga(
$remote_id: String!,
) {
mangas(
ids: $remote_id,
limit: 1,
) {
id
url
name
chapters
userRate {
id
chapters
status
score
}
}
}
@@ -0,0 +1,11 @@
query ShikimoriGetMangaDetails(
$query: String!,
) {
mangas(
ids: $query,
limit: 1,
kind: "!light_novel,!novel",
) {
...MangaFragment
}
}
@@ -0,0 +1,11 @@
query ShikimoriSearchManga(
$search: String!
) {
mangas(
search: $search,
limit: 20,
kind: "!light_novel,!novel",
) {
...MangaFragment
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,15 @@
fragment MangaFragment on MangaType {
description
id
status
thumbnailUrl
title
url
chapters {
totalCount
}
latestReadChapter {
chapterNumber
}
unreadCount
}
@@ -0,0 +1,9 @@
query SuwayomiGetManga(
$mangaId: Int!,
) {
manga(
id: $mangaId,
) {
...MangaFragment
}
}
@@ -0,0 +1,30 @@
query SuwayomiGetMangaUnreadChapters(
$mangaId: Int!,
$chapterNumber: Float!,
) {
chapters(
condition: {
mangaId: $mangaId,
isRead: false,
},
filter: {
and: [
{
chapterNumber: {
lessThanOrEqualTo: $chapterNumber
}
},
{
chapterNumber: {
greaterThan: 0
}
},
]
},
){
nodes {
id
chapterNumber
}
}
}
@@ -0,0 +1,14 @@
mutation SuwayomiMarkChaptersRead(
$chapters: [Int!]!,
) {
updateChapters(
input: {
ids: $chapters,
patch: {
isRead: true,
},
},
) {
__typename
}
}
@@ -0,0 +1,22 @@
mutation SuwayomiMarkAndDeleteChapters(
$chapters: [Int!]!,
) {
updateChapters(
input: {
ids: $chapters,
patch: {
isRead: true,
},
},
) {
__typename
}
deleteDownloadedChapters(
input: {
ids: $chapters,
},
) {
__typename
}
}
@@ -0,0 +1,11 @@
mutation SuwayomiUpdateMangaProgress(
$mangaId: Int!,
) {
trackProgress(
input: {
mangaId: $mangaId,
},
) {
__typename
}
}
File diff suppressed because it is too large Load Diff
@@ -45,4 +45,9 @@ class BasePreferences(
Preference.appStateKey("donation_campaign_shown"),
false,
)
val skippedAppUpdate: Preference<String> = preferenceStore.getString(
Preference.appStateKey("skipped_app_update"),
"",
)
}
@@ -3,7 +3,6 @@ package eu.kanade.domain.chapter.interactor
import dev.zacsweers.metro.Inject
import eu.kanade.domain.download.interactor.DeleteDownload
import logcat.LogPriority
import tachiyomi.core.common.util.lang.withNonCancellableContext
import tachiyomi.core.common.util.system.logcat
import tachiyomi.domain.chapter.model.Chapter
import tachiyomi.domain.chapter.model.ChapterUpdate
@@ -21,14 +20,13 @@ class SetReadStatus(
) {
private val mapper = { chapter: Chapter, read: Boolean ->
ChapterUpdate(
read = read,
lastPageRead = if (!read) 0 else null,
id = chapter.id,
)
ChapterUpdate(chapter.id) {
this.read = read
if (!read) lastPageRead = 0
}
}
suspend fun await(read: Boolean, vararg chapters: Chapter): Result = withNonCancellableContext {
suspend fun await(read: Boolean, vararg chapters: Chapter): Result {
val chaptersToUpdate = chapters.filter {
when (read) {
true -> !it.read
@@ -36,7 +34,7 @@ class SetReadStatus(
}
}
if (chaptersToUpdate.isEmpty()) {
return@withNonCancellableContext Result.NoChapters
return Result.NoChapters
}
try {
@@ -45,11 +43,14 @@ class SetReadStatus(
)
} catch (e: Exception) {
logcat(LogPriority.ERROR, e)
return@withNonCancellableContext Result.InternalError(e)
return Result.InternalError(e)
}
if (read && downloadPreferences.removeAfterMarkedAsRead.get()) {
chaptersToUpdate
// Chapters here still carry their pre-update read state; downstream
// deletion filtering (excluded categories) relies on the new state.
.map { it.copy(read = true) }
.groupBy { it.mangaId }
.forEach { (mangaId, chapters) ->
deleteDownload.awaitAll(
@@ -59,17 +60,16 @@ class SetReadStatus(
}
}
Result.Success
return Result.Success
}
suspend fun await(mangaId: Long, read: Boolean): Result = withNonCancellableContext {
suspend fun await(mangaId: Long, read: Boolean): Result =
await(
read = read,
chapters = chapterRepository
.getChapterByMangaId(mangaId)
.toTypedArray(),
)
}
suspend fun await(manga: Manga, read: Boolean) =
await(manga.id, read)
@@ -15,12 +15,10 @@ import kotlinx.datetime.TimeZone
import kotlinx.datetime.toInstant
import kotlinx.datetime.toLocalDateTime
import tachiyomi.data.chapter.ChapterSanitizer
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
import tachiyomi.domain.chapter.interactor.ShouldUpdateDbChapter
import tachiyomi.domain.chapter.interactor.UpdateChapter
import tachiyomi.domain.chapter.model.Chapter
import tachiyomi.domain.chapter.model.ChapterRemoteUpdate
import tachiyomi.domain.chapter.model.NoChaptersException
import tachiyomi.domain.chapter.model.toChapterUpdate
import tachiyomi.domain.chapter.repository.ChapterRepository
import tachiyomi.domain.chapter.service.ChapterRecognition
import tachiyomi.domain.library.service.LibraryPreferences
@@ -29,6 +27,8 @@ import tachiyomi.source.local.isLocal
import java.lang.Long.max
import java.util.TreeSet
import kotlin.time.Clock
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.Instant
@Inject
class SyncChaptersWithSource(
@@ -37,8 +37,6 @@ class SyncChaptersWithSource(
private val chapterRepository: ChapterRepository,
private val shouldUpdateDbChapter: ShouldUpdateDbChapter,
private val updateManga: UpdateManga,
private val updateChapter: UpdateChapter,
private val getChaptersByMangaId: GetChaptersByMangaId,
private val getExcludedScanlators: GetExcludedScanlators,
private val libraryPreferences: LibraryPreferences,
) {
@@ -56,7 +54,7 @@ class SyncChaptersWithSource(
manga: Manga,
source: Source,
manualFetch: Boolean = false,
fetchWindow: Pair<Long, Long> = Pair(0, 0),
fetchWindow: ClosedRange<Instant>? = null,
): List<Chapter> {
if (rawSourceChapters.isEmpty() && !source.isLocal()) {
throw NoChaptersException()
@@ -64,7 +62,7 @@ class SyncChaptersWithSource(
val timeZone = TimeZone.currentSystemDefault()
val now = Clock.System.now().toLocalDateTime(timeZone)
val nowMillis = now.toInstant(timeZone).toEpochMilliseconds()
val nowInstant = now.toInstant(timeZone)
val sourceChapters = rawSourceChapters
.distinctBy { it.url }
@@ -75,43 +73,46 @@ class SyncChaptersWithSource(
.copy(mangaId = manga.id, sourceOrder = i.toLong())
}
val dbChapters = getChaptersByMangaId.await(manga.id)
val dbChapters = chapterRepository.getChapterByMangaId(manga.id)
val dbChaptersByUrl = dbChapters.associateBy { it.url }
val newChapters = mutableListOf<Chapter>()
val updatedChapters = mutableListOf<Chapter>()
val removedChapters = dbChapters.filterNot { dbChapter ->
sourceChapters.any { sourceChapter ->
dbChapter.url == sourceChapter.url
}
}
val updatedChapters = mutableListOf<ChapterRemoteUpdate>()
val sourceUrls = mutableSetOf<String>()
// Used to not set upload date of older chapters
// to a higher value than newer chapters
var maxSeenUploadDate = 0L
for (sourceChapter in sourceChapters) {
var chapter = sourceChapter
var maxSeenUploadDate: Instant? = null
// Update metadata from source if necessary.
if (source is HttpSource) {
val preparedChapters = if (source is HttpSource) {
val sManga = manga.toSManga()
sourceChapters.map { chapter ->
val sChapter = chapter.toSChapter()
@Suppress("DEPRECATION")
source.prepareNewChapter(sChapter, manga.toSManga())
chapter = chapter.copyFromSChapter(sChapter)
source.prepareNewChapter(sChapter, sManga)
chapter.copyFromSChapter(sChapter)
}
} else {
sourceChapters
}
// Recognize chapter number for the chapter.
val chapterNumber = ChapterRecognition.parseChapterNumber(manga.title, chapter.name, chapter.chapterNumber)
chapter = chapter.copy(chapterNumber = chapterNumber)
// Recognize chapter numbers, from the whole list since names alone don't always tell.
val recognizedChapters = preparedChapters
.zip(ChapterRecognition.parseChapterNumbers(manga.title, preparedChapters)) { chapter, numbering ->
chapter.copy(chapterNumber = numbering.chapter?.let(ChapterRecognition::toDouble) ?: -1.0)
}
val dbChapter = dbChapters.find { it.url == chapter.url }
for (chapter in recognizedChapters) {
if (!sourceUrls.add(chapter.url)) continue
val dbChapter = dbChaptersByUrl[chapter.url]
if (dbChapter == null) {
val toAddChapter = if (chapter.dateUpload == 0L) {
val altDateUpload = if (maxSeenUploadDate == 0L) nowMillis else maxSeenUploadDate
chapter.copy(dateUpload = altDateUpload)
val toAddChapter = if (chapter.dateUpload == null) {
chapter.copy(dateUpload = maxSeenUploadDate ?: nowInstant)
} else {
maxSeenUploadDate = max(maxSeenUploadDate, sourceChapter.dateUpload)
maxSeenUploadDate = listOfNotNull(maxSeenUploadDate, chapter.dateUpload).maxOrNull()
chapter
}
newChapters.add(toAddChapter)
@@ -130,25 +131,33 @@ class SyncChaptersWithSource(
downloadManager.renameChapter(source, manga, dbChapter, chapter)
}
var toChangeChapter = dbChapter.copy(
updatedChapters.add(
ChapterRemoteUpdate(
id = dbChapter.id,
name = chapter.name,
chapterNumber = chapter.chapterNumber,
scanlator = chapter.scanlator,
sourceOrder = chapter.sourceOrder,
dateUpload = chapter.dateUpload,
memo = chapter.memo,
),
)
}
}
}
if (chapter.dateUpload != 0L) {
toChangeChapter = toChangeChapter.copy(dateUpload = chapter.dateUpload)
}
updatedChapters.add(toChangeChapter)
}
}
}
val removedChapters = dbChapters.filterNot { it.url in sourceUrls }
// The source no longer lists these, so their queued downloads could only fail
removedChapters.mapNotNull { downloadManager.getQueuedDownloadOrNull(it.id) }
.takeIf { it.isNotEmpty() }
?.let { downloadManager.cancelQueuedDownloads(it) }
// Return if there's nothing to add, delete, or update to avoid unnecessary db transactions.
if (newChapters.isEmpty() && removedChapters.isEmpty() && updatedChapters.isEmpty()) {
if (manualFetch || manga.fetchInterval == 0 || manga.nextUpdate < fetchWindow.first) {
val isNextUpdateBeforeWindow = fetchWindow != null &&
manga.nextUpdate.let { it == null || it < fetchWindow.start }
if (manualFetch || manga.fetchInterval == 0 || isNextUpdateBeforeWindow) {
updateManga.awaitUpdateFetchInterval(
manga,
timeZone,
@@ -186,8 +195,8 @@ class SyncChaptersWithSource(
// Date fetch is set in such a way that the upper ones will have bigger value than the lower ones
// Sources MUST return the chapters from most to less recent, which is common.
var itemCount = newChapters.size
var updatedToAdd = newChapters.map { toAddItem ->
var chapter = toAddItem.copy(dateFetch = nowMillis + itemCount--)
val toAdd = newChapters.map { toAddItem ->
var chapter = toAddItem.copy(dateFetch = nowInstant + (itemCount--).milliseconds)
if (chapter.chapterNumber in readChapterNumbers && markDuplicateAsRead) {
changedOrDuplicateReadUrls.add(chapter.url)
@@ -211,27 +220,25 @@ class SyncChaptersWithSource(
chapter
}
if (removedChapters.isNotEmpty()) {
val toDeleteIds = removedChapters.map { it.id }
chapterRepository.removeChaptersWithIds(toDeleteIds)
}
if (updatedToAdd.isNotEmpty()) {
updatedToAdd = chapterRepository.addAll(updatedToAdd)
}
if (updatedChapters.isNotEmpty()) {
val chapterUpdates = updatedChapters.map { it.toChapterUpdate() }
updateChapter.awaitAll(chapterUpdates)
}
updateManga.awaitUpdateFetchInterval(manga, timeZone, now, fetchWindow)
// Set this manga as updated since chapters were changed
// Note that last_update actually represents last time the chapter list changed at all
updateManga.awaitUpdateLastUpdate(manga.id)
val added = chapterRepository.updateFromRemote(
removedIds = removedChapters.map { it.id },
added = toAdd,
updated = updatedChapters,
)
val excludedScanlators = getExcludedScanlators.await(manga.id).toHashSet()
return updatedToAdd.filterNot { it.url in changedOrDuplicateReadUrls || it.scanlator in excludedScanlators }
// A first fetch lists the back catalogue, and chapters coming back under a deleted number were out already
val foundRelease = dbChapters.isNotEmpty() &&
toAdd.any { chapter ->
chapter.scanlator !in excludedScanlators &&
!(chapter.isRecognizedNumber && chapter.chapterNumber in deletedChapterNumbers)
}
// Set this manga as updated since chapters were changed
// Note that last_update actually represents last time the chapter list changed at all
updateManga.awaitUpdateFetchIntervalAndLastUpdate(manga, timeZone, now, fetchWindow, foundRelease)
return added.filterNot { it.url in changedOrDuplicateReadUrls || it.scanlator in excludedScanlators }
}
}
@@ -1,16 +1,15 @@
package eu.kanade.domain.chapter.model
import eu.kanade.tachiyomi.data.database.models.ChapterImpl
import eu.kanade.tachiyomi.source.model.SChapter
import mihon.core.common.extensions.toEpochMillisOrZero
import mihon.core.common.extensions.toInstantOrNull
import tachiyomi.domain.chapter.model.Chapter
import eu.kanade.tachiyomi.data.database.models.Chapter as DbChapter
// TODO: Remove when all deps are migrated
fun Chapter.toSChapter(): SChapter {
return SChapter.create().also {
it.url = url
it.name = name
it.date_upload = dateUpload
it.date_upload = dateUpload.toEpochMillisOrZero()
it.chapter_number = chapterNumber.toFloat()
it.scanlator = scanlator
it.memo = memo
@@ -21,25 +20,9 @@ fun Chapter.copyFromSChapter(sChapter: SChapter): Chapter {
return this.copy(
name = sChapter.name,
url = sChapter.url,
dateUpload = sChapter.date_upload,
dateUpload = sChapter.date_upload.toInstantOrNull(),
chapterNumber = sChapter.chapter_number.toDouble(),
scanlator = sChapter.scanlator?.ifBlank { null }?.trim(),
memo = sChapter.memo,
)
}
fun Chapter.toDbChapter(): DbChapter = ChapterImpl().also {
it.id = id
it.manga_id = mangaId
it.url = url
it.name = name
it.scanlator = scanlator
it.read = read
it.bookmark = bookmark
it.last_page_read = lastPageRead.toInt()
it.date_fetch = dateFetch
it.date_upload = dateUpload
it.chapter_number = chapterNumber.toFloat()
it.source_order = sourceOrder.toInt()
it.memo = memo
}
@@ -2,7 +2,6 @@ package eu.kanade.domain.download.interactor
import dev.zacsweers.metro.Inject
import eu.kanade.tachiyomi.data.download.DownloadManager
import tachiyomi.core.common.util.lang.withNonCancellableContext
import tachiyomi.domain.chapter.model.Chapter
import tachiyomi.domain.manga.model.Manga
import tachiyomi.domain.source.service.SourceManager
@@ -13,7 +12,7 @@ class DeleteDownload(
private val downloadManager: DownloadManager,
) {
suspend fun awaitAll(manga: Manga, vararg chapters: Chapter) = withNonCancellableContext {
suspend fun awaitAll(manga: Manga, vararg chapters: Chapter) {
sourceManager.get(manga.source)?.let { source ->
downloadManager.deleteChapters(chapters.toList(), manga, source)
}
@@ -23,20 +23,17 @@ class GetExtensionsByType(
extensionManager.notLoadedExtensionsFlow,
extensionManager.availableExtensionsFlow,
) { enabledLanguages, _loaded, _notLoaded, _available ->
val (updates, loaded) = _loaded
.sortedWith(
compareBy<Extension.Loaded> { !it.isObsolete }
.thenBy(String.CASE_INSENSITIVE_ORDER) { it.name },
)
.partition { it.hasUpdate }
val byName = compareBy<Extension, String>(String.CASE_INSENSITIVE_ORDER) { it.name }
val notLoaded = _notLoaded
.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name })
val (loadedUpdates, loaded) = _loaded.partition { it.hasUpdate }
val (notLoadedUpdates, notLoaded) = _notLoaded.partition { it.hasUpdate }
val updates = (loadedUpdates + notLoadedUpdates).sortedWith(byName)
val installedSignatures = (_loaded + _notLoaded).groupBy({ it.pkgName }, { it.signatures })
val available = _available
.filter { extension ->
_loaded.none { it.pkgName == extension.pkgName } &&
_notLoaded.none { it.pkgName == extension.pkgName } &&
installedSignatures[extension.pkgName].orEmpty().none { extension.store.signingKey in it } &&
extension.contentWarning in enabledContentWarnings
}
.flatMap { ext ->
@@ -50,9 +47,17 @@ class GetExtensionsByType(
)
}
}
.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name })
.sortedWith(
compareBy<Extension.Available, String>(String.CASE_INSENSITIVE_ORDER) { it.name }
.thenBy { it.store.signingKey },
)
Extensions(updates, loaded, available, notLoaded)
Extensions(
updates = updates,
loaded = loaded.sortedWith(compareBy<Extension.Loaded> { !it.isObsolete }.then(byName)),
available = available,
notLoaded = notLoaded.sortedWith(byName),
)
}
}
}
@@ -9,6 +9,7 @@ import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.drop
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
import mihon.domain.extension.model.ExtensionStore
import mihon.domain.extension.repository.ExtensionStoreRepository
import tachiyomi.core.common.preference.getAndSet
@@ -18,8 +19,8 @@ class TrustExtension(
private val preferences: SourcePreferences,
) {
suspend fun isTrusted(pkgInfo: PackageInfo, fingerprints: List<String>): Boolean {
val trustedFingerprints = repository.getAll().map { it.signingKey }.toHashSet()
fun isTrusted(pkgInfo: PackageInfo, fingerprints: List<String>, stores: List<ExtensionStore>): Boolean {
val trustedFingerprints = stores.mapTo(HashSet()) { it.signingKey }
val key = "${pkgInfo.packageName}:${PackageInfoCompat.getLongVersionCode(pkgInfo)}:${fingerprints.last()}"
return trustedFingerprints.any { fingerprints.contains(it) } || key in preferences.trustedExtensions.get()
}
@@ -3,7 +3,7 @@ package eu.kanade.domain.extension.model
import eu.kanade.tachiyomi.extension.model.Extension
data class Extensions(
val updates: List<Extension.Loaded>,
val updates: List<Extension.Installed>,
val loaded: List<Extension.Loaded>,
val available: List<Extension.Available>,
val notLoaded: List<Extension.NotLoaded>,
@@ -1,28 +1,19 @@
package eu.kanade.domain.manga.interactor
import app.cash.sqldelight.async.coroutines.awaitAsList
import dev.zacsweers.metro.Inject
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import tachiyomi.data.Database
import tachiyomi.data.subscribeToList
import tachiyomi.domain.manga.repository.MangaRepository
@Inject
class GetExcludedScanlators(
private val database: Database,
private val mangaRepository: MangaRepository,
) {
suspend fun await(mangaId: Long): Set<String> {
return database.excluded_scanlatorsQueries
.getExcludedScanlatorsByMangaId(mangaId)
.awaitAsList()
.toSet()
return mangaRepository.getExcludedScanlators(mangaId)
}
fun subscribe(mangaId: Long): Flow<Set<String>> {
return database.excluded_scanlatorsQueries
.getExcludedScanlatorsByMangaId(mangaId)
.subscribeToList()
.map { it.toSet() }
return mangaRepository.getExcludedScanlatorsAsFlow(mangaId)
}
}
@@ -1,26 +1,14 @@
package eu.kanade.domain.manga.interactor
import app.cash.sqldelight.async.coroutines.awaitAsList
import dev.zacsweers.metro.Inject
import tachiyomi.data.Database
import tachiyomi.domain.manga.repository.MangaRepository
@Inject
class SetExcludedScanlators(
private val database: Database,
private val mangaRepository: MangaRepository,
) {
suspend fun await(mangaId: Long, excludedScanlators: Set<String>) {
database.transaction {
val currentExcluded = database.excluded_scanlatorsQueries
.getExcludedScanlatorsByMangaId(mangaId)
.awaitAsList()
.toSet()
val toAdd = excludedScanlators.minus(currentExcluded)
for (scanlator in toAdd) {
database.excluded_scanlatorsQueries.insert(mangaId, scanlator)
}
val toRemove = currentExcluded.minus(excludedScanlators)
database.excluded_scanlatorsQueries.remove(mangaId, toRemove)
}
mangaRepository.setExcludedScanlators(mangaId, excludedScanlators)
}
}
@@ -14,20 +14,18 @@ class SetMangaViewerFlags(
suspend fun awaitSetReadingMode(id: Long, flag: Long) {
val manga = mangaRepository.getMangaById(id)
mangaRepository.update(
MangaUpdate(
id = id,
viewerFlags = manga.viewerFlags.setFlag(flag, ReadingMode.MASK.toLong()),
),
MangaUpdate(id) {
viewerFlags = manga.viewerFlags.setFlag(flag, ReadingMode.MASK.toLong())
},
)
}
suspend fun awaitSetOrientation(id: Long, flag: Long) {
val manga = mangaRepository.getMangaById(id)
mangaRepository.update(
MangaUpdate(
id = id,
viewerFlags = manga.viewerFlags.setFlag(flag, ReaderOrientation.MASK.toLong()),
),
MangaUpdate(id) {
viewerFlags = manga.viewerFlags.setFlag(flag, ReaderOrientation.MASK.toLong())
},
)
}
@@ -9,6 +9,7 @@ import tachiyomi.domain.manga.model.Manga
import tachiyomi.domain.manga.model.MangaUpdate
import tachiyomi.domain.manga.repository.MangaRepository
import kotlin.time.Clock
import kotlin.time.Instant
@Inject
class UpdateManga(
@@ -28,33 +29,43 @@ class UpdateManga(
manga: Manga,
timeZone: TimeZone = TimeZone.currentSystemDefault(),
dateTime: LocalDateTime = Clock.System.now().toLocalDateTime(timeZone),
window: Pair<Long, Long> = fetchInterval.getWindow(dateTime.date, timeZone),
window: ClosedRange<Instant>? = fetchInterval.getWindow(dateTime.date, timeZone),
): Boolean {
return mangaRepository.update(
fetchInterval.toMangaUpdate(manga, dateTime, timeZone, window),
fetchInterval.withFetchInterval(manga, dateTime, timeZone, window),
)
}
suspend fun awaitUpdateLastUpdate(mangaId: Long): Boolean {
return mangaRepository.update(MangaUpdate(id = mangaId, lastUpdate = Clock.System.now().toEpochMilliseconds()))
/**
* Updates the fetch interval and marks the chapter list as changed in a single write.
*/
suspend fun awaitUpdateFetchIntervalAndLastUpdate(
manga: Manga,
timeZone: TimeZone,
dateTime: LocalDateTime,
window: ClosedRange<Instant>?,
foundRelease: Boolean,
): Boolean {
return mangaRepository.update(
fetchInterval.withFetchInterval(manga, dateTime, timeZone, window, foundRelease).apply {
lastUpdate = Clock.System.now()
},
)
}
suspend fun awaitUpdateCoverLastModified(mangaId: Long): Boolean {
return mangaRepository.update(
MangaUpdate(
id = mangaId,
coverLastModified = Clock.System.now().toEpochMilliseconds(),
),
MangaUpdate(mangaId) {
coverLastModified = Clock.System.now()
},
)
}
suspend fun awaitUpdateFavorite(mangaId: Long, favorite: Boolean): Boolean {
val dateAdded = when (favorite) {
true -> Clock.System.now().toEpochMilliseconds()
false -> 0
val update = when (favorite) {
true -> MangaUpdate(mangaId) { favoriteAt = Clock.System.now() }
false -> MangaUpdate(mangaId) { favoriteAt = null }
}
return mangaRepository.update(
MangaUpdate(id = mangaId, favorite = favorite, dateAdded = dateAdded),
)
return mangaRepository.update(update)
}
}
@@ -16,7 +16,6 @@ import tachiyomi.domain.chapter.model.Chapter
import tachiyomi.domain.manga.model.Manga
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import kotlin.time.Instant
// TODO: move these into the domain model
val Manga.readingMode: Long
@@ -77,7 +76,7 @@ fun Manga.copyFrom(other: SManga): Manga {
}
fun Manga.hasCustomCover(coverCache: CoverCache = Injekt.get<Context>().appGraph.coverCache): Boolean {
return coverCache.getCustomCoverFile(id).exists()
return coverCache.hasCustomCover(id)
}
/**
@@ -90,11 +89,7 @@ fun getComicInfo(
categories: List<String>?,
sourceName: String,
): ComicInfo {
val date = chapter.dateUpload
.takeIf { it != 0L }
?.let {
Instant.fromEpochMilliseconds(it).toLocalDateTime(TimeZone.currentSystemDefault())
}
val date = chapter.dateUpload?.toLocalDateTime(TimeZone.currentSystemDefault())
return ComicInfo(
title = ComicInfo.Title(chapter.name),
@@ -1,17 +0,0 @@
package eu.kanade.domain.source.model
import android.content.Context
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asImageBitmap
import androidx.core.graphics.drawable.toBitmap
import mihon.app.di.appGraph
import tachiyomi.core.common.util.lang.withIOContext
import tachiyomi.domain.source.model.Source
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
suspend fun Source.icon(): ImageBitmap? = withIOContext {
Injekt.get<Context>().appGraph.extensionManager.getAppIconForSource(id)
?.toBitmap()
?.asImageBitmap()
}
@@ -8,20 +8,19 @@ import eu.kanade.tachiyomi.data.track.EnhancedTracker
import eu.kanade.tachiyomi.data.track.Tracker
import eu.kanade.tachiyomi.data.track.TrackerManager
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.util.lang.convertEpochMillisZone
import kotlinx.datetime.TimeZone
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import logcat.LogPriority
import tachiyomi.core.common.util.lang.withIOContext
import tachiyomi.core.common.util.lang.withNonCancellableContext
import tachiyomi.core.common.util.system.logcat
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
import tachiyomi.domain.history.interactor.GetHistory
import tachiyomi.domain.manga.model.Manga
import tachiyomi.domain.track.interactor.InsertTrack
import tachiyomi.domain.track.interactor.UpsertTrack
import kotlin.time.Instant
@Inject
class AddTracks(
private val insertTrack: InsertTrack,
private val upsertTrack: UpsertTrack,
private val syncChapterProgressWithTrack: SyncChapterProgressWithTrack,
private val getChaptersByMangaId: GetChaptersByMangaId,
private val trackerManager: TrackerManager,
@@ -29,15 +28,14 @@ class AddTracks(
) {
// TODO: update all trackers based on common data
suspend fun bind(tracker: Tracker, item: Track, mangaId: Long) = withNonCancellableContext {
withIOContext {
suspend fun bind(tracker: Tracker, item: Track, mangaId: Long) = withContext(Dispatchers.IO) {
val allChapters = getChaptersByMangaId.await(mangaId)
val hasReadChapters = allChapters.any { it.read }
tracker.bind(item, hasReadChapters)
var track = item.toDomainTrack(idRequired = false) ?: return@withIOContext
var track = item.toDomainTrack(idRequired = false) ?: return@withContext
insertTrack.await(track)
upsertTrack.await(track)
// TODO: merge into [SyncChapterProgressWithTrack]?
// Update chapter progress if newer chapters marked read locally
@@ -55,19 +53,15 @@ class AddTracks(
tracker.setRemoteLastChapterRead(track.toDbTrack(), latestLocalReadChapterNumber.toInt())
}
if (track.startDate <= 0) {
if (track.startDate == null) {
val firstReadChapterDate = getHistory.await(mangaId)
.sortedBy { it.readAt }
.firstOrNull()
?.readAt
.mapNotNull { it.readAt }
.minOrNull()
firstReadChapterDate?.let {
val startDate = firstReadChapterDate.time.convertEpochMillisZone(
TimeZone.currentSystemDefault(),
TimeZone.UTC,
)
val startDate = firstReadChapterDate.toEpochMilliseconds()
track = track.copy(
startDate = startDate,
startDate = Instant.fromEpochMilliseconds(startDate),
)
tracker.setRemoteStartDate(track.toDbTrack(), startDate)
}
@@ -76,10 +70,8 @@ class AddTracks(
syncChapterProgressWithTrack.await(mangaId, track, tracker)
}
}
suspend fun bindEnhancedTrackers(manga: Manga, source: Source) = withNonCancellableContext {
withIOContext {
suspend fun bindEnhancedTrackers(manga: Manga, source: Source) = withContext(Dispatchers.IO) {
trackerManager.loggedInTrackers()
.filterIsInstance<EnhancedTracker>()
.filter { it.accept(source) }
@@ -88,7 +80,7 @@ class AddTracks(
service.match(manga)?.let { track ->
track.manga_id = manga.id
(service as Tracker).bind(track)
insertTrack.await(track.toDomainTrack(idRequired = false)!!)
upsertTrack.await(track.toDomainTrack(idRequired = false)!!)
syncChapterProgressWithTrack.await(
manga.id,
@@ -105,4 +97,3 @@ class AddTracks(
}
}
}
}
@@ -5,17 +5,18 @@ import eu.kanade.domain.track.model.toDbTrack
import eu.kanade.domain.track.model.toDomainTrack
import eu.kanade.tachiyomi.data.track.Tracker
import eu.kanade.tachiyomi.data.track.TrackerManager
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.supervisorScope
import tachiyomi.domain.track.interactor.GetTracks
import tachiyomi.domain.track.interactor.InsertTrack
import tachiyomi.domain.track.interactor.UpsertTrack
@Inject
class RefreshTracks(
private val getTracks: GetTracks,
private val trackerManager: TrackerManager,
private val insertTrack: InsertTrack,
private val upsertTrack: UpsertTrack,
private val syncChapterProgressWithTrack: SyncChapterProgressWithTrack,
) {
@@ -30,10 +31,10 @@ class RefreshTracks(
.map { it to trackerManager.get(it.trackerId) }
.filter { (_, service) -> service?.isLoggedIn == true }
.map { (track, service) ->
async {
async(Dispatchers.IO) {
return@async try {
val updatedTrack = service!!.refresh(track.toDbTrack()).toDomainTrack()!!
insertTrack.await(updatedTrack)
upsertTrack.await(updatedTrack)
syncChapterProgressWithTrack.await(mangaId, updatedTrack, service)
null
} catch (e: Throwable) {
@@ -8,15 +8,15 @@ import logcat.LogPriority
import tachiyomi.core.common.util.system.logcat
import tachiyomi.domain.chapter.interactor.GetChaptersByMangaId
import tachiyomi.domain.chapter.interactor.UpdateChapter
import tachiyomi.domain.chapter.model.toChapterUpdate
import tachiyomi.domain.track.interactor.InsertTrack
import tachiyomi.domain.chapter.model.ChapterUpdate
import tachiyomi.domain.track.interactor.UpsertTrack
import tachiyomi.domain.track.model.Track
import kotlin.math.max
@Inject
class SyncChapterProgressWithTrack(
private val updateChapter: UpdateChapter,
private val insertTrack: InsertTrack,
private val upsertTrack: UpsertTrack,
private val getChaptersByMangaId: GetChaptersByMangaId,
) {
@@ -35,7 +35,7 @@ class SyncChapterProgressWithTrack(
val chapterUpdates = sortedChapters
.filter { chapter -> chapter.chapterNumber <= remoteTrack.lastChapterRead && !chapter.read }
.map { it.copy(read = true).toChapterUpdate() }
.map { ChapterUpdate(it.id) { read = true } }
// only take into account continuous reading
val localLastRead = sortedChapters.takeWhile { it.read }.lastOrNull()?.chapterNumber ?: 0F
@@ -45,7 +45,7 @@ class SyncChapterProgressWithTrack(
try {
tracker.update(updatedTrack.toDbTrack())
updateChapter.awaitAll(chapterUpdates)
insertTrack.await(updatedTrack)
upsertTrack.await(updatedTrack)
} catch (e: Throwable) {
logcat(LogPriority.WARN, e)
}
@@ -4,29 +4,29 @@ import android.content.Context
import dev.zacsweers.metro.Inject
import eu.kanade.domain.track.model.toDbTrack
import eu.kanade.domain.track.model.toDomainTrack
import eu.kanade.domain.track.service.DelayedTrackingUpdateJob
import eu.kanade.domain.track.service.DelayedTrackingUpdateWorker
import eu.kanade.domain.track.store.DelayedTrackingStore
import eu.kanade.tachiyomi.data.track.TrackerManager
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.coroutineScope
import logcat.LogPriority
import tachiyomi.core.common.util.lang.withNonCancellableContext
import tachiyomi.core.common.util.system.logcat
import tachiyomi.domain.track.interactor.GetTracks
import tachiyomi.domain.track.interactor.InsertTrack
import tachiyomi.domain.track.interactor.UpsertTrack
@Inject
class TrackChapter(
private val getTracks: GetTracks,
private val trackerManager: TrackerManager,
private val insertTrack: InsertTrack,
private val upsertTrack: UpsertTrack,
private val delayedTrackingStore: DelayedTrackingStore,
) {
suspend fun await(context: Context, mangaId: Long, chapterNumber: Double, setupJobOnFailure: Boolean = true) {
withNonCancellableContext {
coroutineScope {
val tracks = getTracks.await(mangaId)
if (tracks.isEmpty()) return@withNonCancellableContext
if (tracks.isEmpty()) return@coroutineScope
tracks.mapNotNull { track ->
val service = trackerManager.get(track.trackerId)
@@ -41,12 +41,12 @@ class TrackChapter(
.toDomainTrack(idRequired = true)!!
.copy(lastChapterRead = chapterNumber)
service.update(updatedTrack.toDbTrack(), true)
insertTrack.await(updatedTrack)
upsertTrack.await(updatedTrack)
delayedTrackingStore.remove(track.id)
} catch (e: Exception) {
delayedTrackingStore.add(track.id, chapterNumber)
if (setupJobOnFailure) {
DelayedTrackingUpdateJob.setupTask(context)
DelayedTrackingUpdateWorker.setupTask(context)
}
throw e
}
@@ -1,5 +1,7 @@
package eu.kanade.domain.track.model
import mihon.core.common.extensions.toEpochMillisOrZero
import mihon.core.common.extensions.toInstantOrNull
import tachiyomi.domain.track.model.Track
import eu.kanade.tachiyomi.data.database.models.Track as DbTrack
@@ -25,8 +27,8 @@ fun Track.toDbTrack(): DbTrack = DbTrack.create(trackerId).also {
it.status = status
it.score = score
it.tracking_url = remoteUrl
it.started_reading_date = startDate
it.finished_reading_date = finishDate
it.started_reading_date = startDate.toEpochMillisOrZero()
it.finished_reading_date = finishDate.toEpochMillisOrZero()
it.private = private
}
@@ -44,8 +46,8 @@ fun DbTrack.toDomainTrack(idRequired: Boolean = true): Track? {
status = status,
score = score,
remoteUrl = tracking_url,
startDate = started_reading_date,
finishDate = finished_reading_date,
startDate = started_reading_date.toInstantOrNull(),
finishDate = finished_reading_date.toInstantOrNull(),
private = private,
)
}
@@ -12,15 +12,16 @@ import dev.zacsweers.metro.Inject
import eu.kanade.domain.track.interactor.TrackChapter
import eu.kanade.domain.track.store.DelayedTrackingStore
import eu.kanade.tachiyomi.util.system.workManager
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import logcat.LogPriority
import mihon.app.di.AppGraph
import mihon.core.metro.metroGraph
import tachiyomi.core.common.util.lang.withIOContext
import tachiyomi.core.common.util.system.logcat
import tachiyomi.domain.track.interactor.GetTracks
import java.util.concurrent.TimeUnit
class DelayedTrackingUpdateJob(private val context: Context, workerParams: WorkerParameters) :
class DelayedTrackingUpdateWorker(private val context: Context, workerParams: WorkerParameters) :
CoroutineWorker(context, workerParams) {
private val graph: AppGraph = context.metroGraph()
@@ -38,7 +39,7 @@ class DelayedTrackingUpdateJob(private val context: Context, workerParams: Worke
return Result.failure()
}
withIOContext {
withContext(Dispatchers.IO) {
delayedTrackingStore.getItems()
.mapNotNull {
val track = getTracks.awaitOne(it.trackId)
@@ -66,7 +67,7 @@ class DelayedTrackingUpdateJob(private val context: Context, workerParams: Worke
requiredNetworkType = NetworkType.CONNECTED,
)
val request = OneTimeWorkRequestBuilder<DelayedTrackingUpdateJob>()
val request = OneTimeWorkRequestBuilder<DelayedTrackingUpdateWorker>()
.setConstraints(constraints)
.setBackoffCriteria(BackoffPolicy.EXPONENTIAL, 5, TimeUnit.MINUTES)
.addTag(TAG)
@@ -15,7 +15,7 @@ class DelayedTrackingStore(context: Context) {
/**
* Preference file where queued tracking updates are stored.
*/
private val preferences = context.getSharedPreferences("tracking_queue", Context.MODE_PRIVATE)
private val preferences by lazy { context.getSharedPreferences("tracking_queue", Context.MODE_PRIVATE) }
fun add(trackId: Long, lastChapterRead: Double) {
val previousLastChapterRead = preferences.getFloat(trackId.toString(), 0f)
@@ -32,31 +32,30 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import dev.icerock.moko.resources.StringResource
import eu.kanade.domain.extension.interactor.ExtensionSourceItem
import eu.kanade.presentation.browse.components.ExtensionIcon
import eu.kanade.presentation.browse.components.ExtensionPill
import eu.kanade.presentation.browse.components.label
import eu.kanade.presentation.components.AppBar
import eu.kanade.presentation.components.AppBarActions
import eu.kanade.presentation.components.WarningBanner
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
import eu.kanade.presentation.more.settings.widget.TrailingWidgetBuffer
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.extension.model.Extension
import eu.kanade.tachiyomi.source.ConfigurableSource
import eu.kanade.tachiyomi.ui.browse.extension.details.ExtensionDetailsViewModel
import eu.kanade.tachiyomi.util.system.LocaleHelper
import eu.kanade.tachiyomi.util.system.copyToClipboard
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.automirroredrounded.OpenInNew
import mihon.icons.materialsymbols.rounded.Eyeglasses2
import mihon.icons.materialsymbols.rounded.Settings
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.ScrollbarLazyColumn
@@ -77,15 +76,6 @@ fun ExtensionDetailsScreen(
onClickIncognito: (Boolean) -> Unit,
) {
val uriHandler = LocalUriHandler.current
val url = remember(state.extension) {
val regex = """https://raw.githubusercontent.com/(.+?)/(.+?)/.+""".toRegex()
regex.find(state.extension.store?.indexUrl.orEmpty())
?.let {
val (user, repo) = it.destructured
"https://github.com/$user/$repo"
}
?: state.extension.store?.indexUrl
}
Scaffold(
topBar = { scrollBehavior ->
@@ -94,20 +84,7 @@ fun ExtensionDetailsScreen(
navigateUp = navigateUp,
actions = {
AppBarActions(
actions = buildList {
if (url != null) {
add(
AppBar.Action(
title = stringResource(MR.strings.action_open_repo),
icon = MaterialSymbols.AutoMirroredRounded.OpenInNew,
onClick = {
uriHandler.openUri(url)
},
),
)
}
addAll(
listOf(
actions = listOf(
AppBar.OverflowAction(
title = stringResource(MR.strings.action_enable_all),
onClick = onClickEnableAll,
@@ -123,8 +100,6 @@ fun ExtensionDetailsScreen(
),
)
},
)
},
scrollBehavior = scrollBehavior,
)
},
@@ -132,6 +107,11 @@ fun ExtensionDetailsScreen(
ExtensionDetails(
contentPadding = paddingValues,
extension = state.extension,
onClickStore = state.extension.store
?.contact
?.website
?.takeIf { it.isNotBlank() }
?.let { website -> { uriHandler.openUri(website) } },
sources = state.sources,
incognitoMode = state.isIncognito,
onClickSourcePreferences = onClickSourcePreferences,
@@ -146,6 +126,7 @@ fun ExtensionDetailsScreen(
private fun ExtensionDetails(
contentPadding: PaddingValues,
extension: Extension.Loaded,
onClickStore: (() -> Unit)?,
sources: List<ExtensionSourceItem>,
incognitoMode: Boolean,
onClickSourcePreferences: (sourceId: Long) -> Unit,
@@ -178,6 +159,7 @@ private fun ExtensionDetails(
}
Unit
}.takeIf { extension.isShared },
onClickStore = onClickStore,
onClickContentWarning = {
showContentWarning = true
},
@@ -210,8 +192,9 @@ private fun ExtensionDetails(
@Composable
private fun DetailsHeader(
extension: Extension,
extension: Extension.Installed,
extIncognitoMode: Boolean,
onClickStore: (() -> Unit)?,
onClickContentWarning: () -> Unit,
onClickUninstall: () -> Unit,
onClickAppInfo: (() -> Unit)?,
@@ -271,12 +254,35 @@ private fun DetailsHeader(
textAlign = TextAlign.Center,
)
val strippedPkgName = extension.pkgName.substringAfter("eu.kanade.tachiyomi.extension.")
Text(
text = strippedPkgName,
text = extension.pkgName,
textAlign = TextAlign.Center,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
extension.store?.let { store ->
Text(
text = store.name,
modifier = Modifier
.clip(MaterialTheme.shapes.small)
.clickable(enabled = onClickStore != null) { onClickStore?.invoke() }
.padding(
horizontal = MaterialTheme.padding.extraSmall,
vertical = MaterialTheme.padding.extraSmall / 2,
),
textAlign = TextAlign.Center,
style = MaterialTheme.typography.labelLarge,
color = MaterialTheme.colorScheme.primary,
)
}
if ((extension as? Extension.Loaded)?.isShared == false) {
ExtensionPill(
text = stringResource(MR.strings.ext_installer_private),
modifier = Modifier.padding(top = MaterialTheme.padding.small),
)
}
}
Row(
@@ -334,10 +340,7 @@ private fun DetailsHeader(
modifier = Modifier.weight(1f),
onClick = onClickAppInfo,
) {
Text(
text = stringResource(MR.strings.ext_app_info),
color = MaterialTheme.colorScheme.onPrimary,
)
Text(stringResource(MR.strings.ext_app_info))
}
}
}
@@ -346,7 +349,7 @@ private fun DetailsHeader(
modifier = Modifier.padding(horizontal = MaterialTheme.padding.small),
title = stringResource(MR.strings.pref_incognito_mode),
subtitle = stringResource(MR.strings.pref_incognito_mode_extension_summary),
icon = ImageVector.vectorResource(R.drawable.ic_glasses_24dp),
icon = MaterialSymbols.Rounded.Eyeglasses2,
widget = {
Row(
verticalAlignment = Alignment.CenterVertically,
@@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.CircularProgressIndicator
@@ -20,7 +21,6 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ProvideTextStyle
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
@@ -30,6 +30,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.style.TextOverflow
@@ -39,9 +40,9 @@ import cafe.adriel.voyager.navigator.currentOrThrow
import dev.icerock.moko.resources.StringResource
import eu.kanade.presentation.browse.components.BaseBrowseItem
import eu.kanade.presentation.browse.components.ExtensionIcon
import eu.kanade.presentation.browse.components.ExtensionPill
import eu.kanade.presentation.browse.components.label
import eu.kanade.presentation.components.WarningBanner
import eu.kanade.presentation.manga.components.DotSeparatorNoSpaceText
import eu.kanade.presentation.more.settings.screen.browse.ExtensionStoresScreen
import eu.kanade.presentation.util.rememberRequestPackageInstallsPermissionState
import eu.kanade.tachiyomi.extension.model.Extension
@@ -51,6 +52,7 @@ import eu.kanade.tachiyomi.ui.browse.extension.ExtensionsViewModel
import eu.kanade.tachiyomi.util.system.LocaleHelper
import eu.kanade.tachiyomi.util.system.copyToClipboard
import eu.kanade.tachiyomi.util.system.launchRequestPackageInstallsPermission
import mihon.domain.extension.model.ExtensionStore
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.rounded.Close
import mihon.icons.materialsymbols.rounded.Download
@@ -71,7 +73,6 @@ import tachiyomi.presentation.core.screens.EmptyScreenAction
import tachiyomi.presentation.core.screens.LoadingScreen
import tachiyomi.presentation.core.theme.header
import tachiyomi.presentation.core.util.plus
import tachiyomi.presentation.core.util.secondaryItemAlpha
@Composable
fun ExtensionScreen(
@@ -83,7 +84,7 @@ fun ExtensionScreen(
onOpenWebView: (Extension.Available) -> Unit,
onInstallExtension: (Extension.Available) -> Unit,
onUninstallExtension: (Extension.Installed) -> Unit,
onUpdateExtension: (Extension.Loaded) -> Unit,
onUpdateExtension: (Extension.Installed) -> Unit,
onTrustExtension: (Extension.NotLoaded) -> Unit,
onOpenExtension: (Extension.Loaded) -> Unit,
onClickUpdateAll: () -> Unit,
@@ -144,7 +145,7 @@ private fun ExtensionContent(
onOpenWebView: (Extension.Available) -> Unit,
onInstallExtension: (Extension.Available) -> Unit,
onUninstallExtension: (Extension.Installed) -> Unit,
onUpdateExtension: (Extension.Loaded) -> Unit,
onUpdateExtension: (Extension.Installed) -> Unit,
onTrustExtension: (Extension.NotLoaded) -> Unit,
onOpenExtension: (Extension.Loaded) -> Unit,
onClickUpdateAll: () -> Unit,
@@ -232,7 +233,9 @@ private fun ExtensionContent(
when (it) {
is Extension.Available -> onOpenWebView(it)
is Extension.Loaded -> onOpenExtension(it)
else -> {}
is Extension.NotLoaded -> {
notLoadedState = it
}
}
},
onClickItemCancel = onClickItemCancel,
@@ -247,9 +250,13 @@ private fun ExtensionContent(
}
}
is Extension.NotLoaded -> {
if (it.hasUpdate) {
onUpdateExtension(it)
} else {
notLoadedState = it
}
}
}
},
)
}
@@ -293,24 +300,82 @@ private fun ExtensionItem(
modifier: Modifier = Modifier,
) {
val (extension, installStep) = item
val store = when (extension) {
is Extension.Available -> extension.store
is Extension.Installed -> extension.store
}
BaseBrowseItem(
modifier = modifier
.combinedClickable(
onClick = { onClickItem(extension) },
onLongClick = { onLongClickItem(extension) },
),
modifier = modifier,
onClickItem = { onClickItem(extension) },
onLongClickItem = { onLongClickItem(extension) },
icon = {
ExtensionItemIcon(extension = extension, installStep = installStep)
},
action = {
ExtensionItemActions(
extension = extension,
installStep = installStep,
onClickItemCancel = onClickItemCancel,
onClickItemAction = onClickItemAction,
onClickItemSecondaryAction = onClickItemSecondaryAction,
)
},
) {
ExtensionItemContent(
extension = extension,
installStep = installStep,
store = store,
modifier = Modifier.weight(1f),
)
}
}
@Composable
private fun ExtensionItemContent(
extension: Extension,
installStep: InstallStep,
store: ExtensionStore?,
modifier: Modifier = Modifier,
) {
Column(
modifier = modifier.padding(start = MaterialTheme.padding.medium),
) {
Text(
text = extension.name,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.bodyMedium,
)
if (store != null) {
Text(
text = store.name,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
ExtensionItemMetadata(extension = extension, installStep = installStep)
}
}
@Composable
private fun ExtensionItemIcon(
extension: Extension,
installStep: InstallStep,
modifier: Modifier = Modifier,
) {
Box(
modifier = Modifier
.size(40.dp),
modifier = modifier.size(48.dp),
contentAlignment = Alignment.Center,
) {
val idle = installStep.isCompleted()
if (!idle) {
CircularProgressIndicator(
modifier = Modifier.size(40.dp),
modifier = Modifier.size(48.dp),
strokeWidth = 2.dp,
)
}
@@ -326,63 +391,48 @@ private fun ExtensionItem(
.padding(padding),
)
}
},
action = {
ExtensionItemActions(
extension = extension,
installStep = installStep,
onClickItemCancel = onClickItemCancel,
onClickItemAction = onClickItemAction,
onClickItemSecondaryAction = onClickItemSecondaryAction,
)
},
) {
ExtensionItemContent(
extension = extension,
installStep = installStep,
modifier = Modifier.weight(1f),
)
}
}
/**
* Plain text for what an extension simply is, pills for the few things worth noticing about it.
* Won't look good when it wraps, but it's not like overflowing content can be ellipsized.
*/
@Composable
private fun ExtensionItemContent(
private fun ExtensionItemMetadata(
extension: Extension,
installStep: InstallStep,
modifier: Modifier = Modifier,
) {
Column(
modifier = modifier.padding(start = MaterialTheme.padding.medium),
FlowRow(
modifier = modifier,
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.extraSmall),
verticalArrangement = Arrangement.spacedBy(MaterialTheme.padding.extraSmall / 2),
itemVerticalAlignment = Alignment.CenterVertically,
) {
val facts = listOfNotNull(
(extension as? Extension.Loaded)
?.lang
?.takeIf { it.isNotEmpty() }
?.let { LocaleHelper.getSourceDisplayName(it, LocalContext.current) },
extension.versionName.takeIf { it.isNotEmpty() },
)
if (facts.isNotEmpty()) {
Text(
text = extension.name,
text = facts.joinToString(" \u2022 "),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.bodyMedium,
)
// Won't look good but it's not like we can ellipsize overflowing content
FlowRow(
modifier = Modifier.secondaryItemAlpha(),
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.extraSmall),
) {
ProvideTextStyle(value = MaterialTheme.typography.bodySmall) {
var hasAlreadyShownAnElement by remember { mutableStateOf(false) }
if (extension is Extension.Loaded && extension.lang.isNotEmpty()) {
hasAlreadyShownAnElement = true
Text(
text = LocaleHelper.getSourceDisplayName(extension.lang, LocalContext.current),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}
if (extension.versionName.isNotEmpty()) {
if (hasAlreadyShownAnElement) DotSeparatorNoSpaceText()
hasAlreadyShownAnElement = true
Text(
text = extension.versionName,
)
}
val warnings = listOfNotNull(
val notable = listOfNotNull(
when (installStep) {
InstallStep.Pending -> MR.strings.ext_pending
InstallStep.Downloading -> MR.strings.ext_downloading
InstallStep.Installing -> MR.strings.ext_installing
else -> null
}?.let { it to MaterialTheme.colorScheme.primary },
when {
extension is Extension.NotLoaded ->
extension.reason.labelRes?.let { it to MaterialTheme.colorScheme.error }
@@ -391,37 +441,12 @@ private fun ExtensionItemContent(
else -> null
},
extension.contentWarning.label?.let { it.title to it.color },
(extension as? Extension.Loaded)
?.takeIf { !it.isShared }
?.let { MR.strings.ext_installer_private to MaterialTheme.colorScheme.onSurfaceVariant },
)
warnings.forEach { (label, color) ->
if (hasAlreadyShownAnElement) DotSeparatorNoSpaceText()
hasAlreadyShownAnElement = true
Text(
text = stringResource(label).uppercase(),
color = color,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
)
}
if (extension is Extension.Loaded && !extension.isShared) {
if (hasAlreadyShownAnElement) DotSeparatorNoSpaceText()
Text(
text = stringResource(MR.strings.ext_installer_private),
)
}
if (!installStep.isCompleted()) {
DotSeparatorNoSpaceText()
Text(
text = when (installStep) {
InstallStep.Pending -> stringResource(MR.strings.ext_pending)
InstallStep.Downloading -> stringResource(MR.strings.ext_downloading)
InstallStep.Installing -> stringResource(MR.strings.ext_installing)
else -> error("Must not show non-install process text")
},
)
}
}
notable.forEach { (label, color) ->
ExtensionPill(text = stringResource(label), color = color)
}
}
}
@@ -435,85 +460,50 @@ private fun ExtensionItemActions(
onClickItemAction: (Extension) -> Unit = {},
onClickItemSecondaryAction: (Extension) -> Unit = {},
) {
val isIdle = installStep.isCompleted()
Row(
modifier = modifier,
horizontalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
verticalAlignment = Alignment.CenterVertically,
) {
when {
!isIdle -> {
if (!installStep.isCompleted()) {
IconButton(onClick = { onClickItemCancel(extension) }) {
Icon(
imageVector = MaterialSymbols.Rounded.Close,
contentDescription = stringResource(MR.strings.action_cancel),
)
}
}
installStep == InstallStep.Error -> {
IconButton(onClick = { onClickItemAction(extension) }) {
Icon(
imageVector = MaterialSymbols.Rounded.Refresh,
contentDescription = stringResource(MR.strings.action_retry),
)
}
}
installStep == InstallStep.Idle -> {
when (extension) {
is Extension.Loaded -> {
IconButton(onClick = { onClickItemSecondaryAction(extension) }) {
Icon(
imageVector = MaterialSymbols.Rounded.Settings,
contentDescription = stringResource(MR.strings.action_settings),
)
return@Row
}
if (extension.hasUpdate) {
IconButton(onClick = { onClickItemAction(extension) }) {
Icon(
imageVector = MaterialSymbols.Rounded.Download,
contentDescription = stringResource(MR.strings.ext_update),
)
}
}
}
is Extension.NotLoaded -> {
val isUntrusted = extension.reason is Extension.NotLoaded.Reason.Untrusted
IconButton(onClick = { onClickItemAction(extension) }) {
Icon(
imageVector = if (isUntrusted) {
MaterialSymbols.Rounded.VerifiedUser
} else {
MaterialSymbols.Rounded.Info
},
contentDescription = if (isUntrusted) {
stringResource(MR.strings.ext_trust)
} else {
stringResource(MR.strings.ext_not_loaded)
},
)
}
}
val secondaryAction = when (extension) {
is Extension.Available -> {
if (extension.sources.isNotEmpty()) {
IconButton(
onClick = { onClickItemSecondaryAction(extension) },
) {
Icon(
imageVector = MaterialSymbols.Rounded.Public,
contentDescription = stringResource(MR.strings.action_open_in_web_view),
)
(MaterialSymbols.Rounded.Public to MR.strings.action_open_in_web_view)
.takeIf { extension.sources.isNotEmpty() }
}
is Extension.Loaded -> MaterialSymbols.Rounded.Settings to MR.strings.action_settings
is Extension.NotLoaded -> if (extension.reason is Extension.NotLoaded.Reason.Untrusted) {
MaterialSymbols.Rounded.VerifiedUser to MR.strings.ext_trust
} else {
MaterialSymbols.Rounded.Info to MR.strings.ext_not_loaded_details
}
}
secondaryAction?.let { (icon, label) ->
IconButton(onClick = { onClickItemSecondaryAction(extension) }) {
Icon(imageVector = icon, contentDescription = stringResource(label))
}
}
val action = when {
installStep == InstallStep.Error -> MaterialSymbols.Rounded.Refresh to MR.strings.action_retry
extension is Extension.Available -> MaterialSymbols.Rounded.Download to MR.strings.ext_install
extension is Extension.Installed && extension.hasUpdate -> {
MaterialSymbols.Rounded.Download to MR.strings.ext_update
}
else -> null
}
action?.let { (icon, label) ->
IconButton(onClick = { onClickItemAction(extension) }) {
Icon(
imageVector = MaterialSymbols.Rounded.Download,
contentDescription = stringResource(MR.strings.ext_install),
)
}
}
}
Icon(imageVector = icon, contentDescription = stringResource(label))
}
}
}
@@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
@@ -16,6 +17,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import eu.kanade.domain.source.interactor.SetMigrateSorting
import eu.kanade.presentation.browse.components.BaseSourceItem
import eu.kanade.presentation.browse.components.SourceIcon
@@ -156,7 +158,7 @@ private fun MigrateSourceItem(
showLanguageInContent = source.lang != "",
onClickItem = onClickItem,
onLongClickItem = onLongClickItem,
icon = { SourceIcon(source = source) },
icon = { SourceIcon(source = source, modifier = Modifier.size(48.dp)) },
action = {
BadgeGroup {
Badge(text = "$count")
@@ -22,8 +22,8 @@ import eu.kanade.tachiyomi.ui.browse.source.SourcesViewModel
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceViewModel.Listing
import eu.kanade.tachiyomi.util.system.LocaleHelper
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.rounded.PushPin
import mihon.icons.materialsymbols.roundedfilled.PushPin
import mihon.icons.materialsymbols.rounded.Keep
import mihon.icons.materialsymbols.roundedfilled.Keep
import tachiyomi.domain.source.model.Pin
import tachiyomi.domain.source.model.Source
import tachiyomi.i18n.MR
@@ -143,7 +143,7 @@ private fun SourcePinButton(
isPinned: Boolean,
onClick: () -> Unit,
) {
val icon = if (isPinned) MaterialSymbols.RoundedFilled.PushPin else MaterialSymbols.Rounded.PushPin
val icon = if (isPinned) MaterialSymbols.RoundedFilled.Keep else MaterialSymbols.Rounded.Keep
val tint = if (isPinned) {
MaterialTheme.colorScheme.primary
} else {
@@ -3,12 +3,14 @@ package eu.kanade.presentation.browse.components
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import eu.kanade.tachiyomi.util.system.LocaleHelper
import tachiyomi.domain.source.model.Source
import tachiyomi.presentation.core.components.material.padding
@@ -39,7 +41,7 @@ fun BaseSourceItem(
}
private val defaultIcon: @Composable RowScope.(Source) -> Unit = { source ->
SourceIcon(source = source)
SourceIcon(source = source, modifier = Modifier.size(48.dp))
}
private val defaultContent: @Composable RowScope.(Source, String?) -> Unit = { source, sourceLangString ->
@@ -2,36 +2,26 @@ package eu.kanade.presentation.browse.components
import android.util.DisplayMetrics
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.height
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.getValue
import androidx.compose.runtime.produceState
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.graphics.painter.ColorPainter
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.imageResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.core.graphics.drawable.toBitmap
import coil3.compose.AsyncImage
import eu.kanade.domain.source.model.icon
import eu.kanade.presentation.util.rememberResourceBitmapPainter
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.coil.InstalledExtensionIcon
import eu.kanade.tachiyomi.data.coil.InstalledSourceIcon
import eu.kanade.tachiyomi.extension.model.Extension
import eu.kanade.tachiyomi.extension.util.ExtensionLoader
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.rounded.Dangerous
import mihon.icons.materialsymbols.rounded.Warning
import tachiyomi.core.common.util.lang.withIOContext
import mihon.icons.materialsymbols.roundedfilled.Dangerous
import mihon.icons.materialsymbols.roundedfilled.Warning
import tachiyomi.domain.source.model.Source
import tachiyomi.source.local.isLocal
@@ -44,24 +34,15 @@ fun SourceIcon(
source: Source,
modifier: Modifier = Modifier,
) {
val icon = produceState<ImageBitmap?>(initialValue = null, source.id) { value = source.icon() }.value
when {
source.isStub && icon == null -> {
source.isStub -> {
Image(
imageVector = MaterialSymbols.Rounded.Warning,
imageVector = MaterialSymbols.RoundedFilled.Warning,
contentDescription = null,
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.error),
modifier = modifier.then(defaultModifier),
)
}
icon != null -> {
Image(
bitmap = icon,
contentDescription = null,
modifier = modifier.then(defaultModifier),
)
}
source.isLocal() -> {
Image(
painter = painterResource(R.mipmap.ic_local_source),
@@ -70,9 +51,12 @@ fun SourceIcon(
)
}
else -> {
Image(
painter = painterResource(R.mipmap.ic_default_source),
val defaultIcon = painterResource(R.mipmap.ic_default_source)
AsyncImage(
model = InstalledSourceIcon(source.id),
contentDescription = null,
placeholder = defaultIcon,
error = defaultIcon,
modifier = modifier.then(defaultModifier),
)
}
@@ -97,52 +81,20 @@ fun ExtensionIcon(
)
}
is Extension.Loaded -> {
val icon by extension.getIcon(density)
when (icon) {
Result.Loading -> Box(modifier = modifier)
is Result.Success -> Image(
bitmap = (icon as Result.Success<ImageBitmap>).value,
val defaultIcon = painterResource(R.mipmap.ic_default_source)
AsyncImage(
model = InstalledExtensionIcon(extension.pkgName, extension.versionCode, density),
contentDescription = null,
placeholder = defaultIcon,
error = defaultIcon,
modifier = modifier,
)
Result.Error -> Image(
bitmap = ImageBitmap.imageResource(id = R.mipmap.ic_default_source),
contentDescription = null,
modifier = modifier,
)
}
}
is Extension.NotLoaded -> Image(
imageVector = MaterialSymbols.Rounded.Dangerous,
imageVector = MaterialSymbols.RoundedFilled.Dangerous,
contentDescription = null,
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.error),
modifier = modifier.then(defaultModifier),
)
}
}
@Composable
private fun Extension.getIcon(density: Int = DisplayMetrics.DENSITY_DEFAULT): State<Result<ImageBitmap>> {
val context = LocalContext.current
return produceState<Result<ImageBitmap>>(initialValue = Result.Loading, this) {
withIOContext {
value = try {
val appInfo = ExtensionLoader.getExtensionPackageInfoFromPkgName(context, pkgName)!!.applicationInfo!!
val appResources = context.packageManager.getResourcesForApplication(appInfo)
Result.Success(
appResources.getDrawableForDensity(appInfo.icon, density, null)!!
.toBitmap()
.asImageBitmap(),
)
} catch (e: Exception) {
Result.Error
}
}
}
}
sealed class Result<out T> {
data object Loading : Result<Nothing>()
data object Error : Result<Nothing>()
data class Success<out T>(val value: T) : Result<T>()
}
@@ -16,8 +16,9 @@ import eu.kanade.presentation.components.SearchToolbar
import eu.kanade.tachiyomi.source.ConfigurableSource
import eu.kanade.tachiyomi.source.Source
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.automirroredrounded.ViewList
import mihon.icons.materialsymbols.rounded.ViewModule
import mihon.icons.materialsymbols.automirroredroundedfilled.ViewList
import mihon.icons.materialsymbols.roundedfilled.ViewCompact
import mihon.icons.materialsymbols.roundedfilled.ViewModule
import tachiyomi.domain.library.model.LibraryDisplayMode
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource
@@ -57,10 +58,12 @@ fun BrowseSourceToolbar(
add(
AppBar.Action(
title = stringResource(MR.strings.action_display_mode),
icon = if (displayMode == LibraryDisplayMode.List) {
MaterialSymbols.AutoMirroredRounded.ViewList
} else {
MaterialSymbols.Rounded.ViewModule
icon = when (displayMode) {
LibraryDisplayMode.List -> MaterialSymbols.AutoMirroredRoundedFilled.ViewList
LibraryDisplayMode.ComfortableGrid -> MaterialSymbols.RoundedFilled.ViewModule
LibraryDisplayMode.CompactGrid,
LibraryDisplayMode.CoverOnlyGrid,
-> MaterialSymbols.RoundedFilled.ViewCompact
},
onClick = { selectingDisplayMode = true },
),
@@ -0,0 +1,32 @@
package eu.kanade.presentation.browse.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import tachiyomi.presentation.core.components.material.padding
@Composable
internal fun ExtensionPill(
text: String,
modifier: Modifier = Modifier,
color: Color = MaterialTheme.colorScheme.onSurfaceVariant,
) {
Text(
text = text,
modifier = modifier
.background(color = color.copy(alpha = PILL_BACKGROUND_ALPHA), shape = MaterialTheme.shapes.small)
.padding(horizontal = MaterialTheme.padding.small, vertical = 2.dp),
color = color,
maxLines = 1,
overflow = TextOverflow.Ellipsis,
style = MaterialTheme.typography.labelSmall,
)
}
private const val PILL_BACKGROUND_ALPHA = 0.12f
@@ -22,7 +22,7 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.automirroredrounded.ArrowForward
import mihon.icons.materialsymbols.rounded.Error
import mihon.icons.materialsymbols.roundedfilled.Error
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.material.padding
import tachiyomi.presentation.core.i18n.stringResource
@@ -90,7 +90,7 @@ fun GlobalSearchErrorResultItem(message: String?) {
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center,
) {
Icon(imageVector = MaterialSymbols.Rounded.Error, contentDescription = null)
Icon(imageVector = MaterialSymbols.RoundedFilled.Error, contentDescription = null)
Spacer(Modifier.height(4.dp))
Text(
text = message ?: stringResource(MR.strings.unknown_error),
@@ -28,7 +28,7 @@ import eu.kanade.tachiyomi.ui.browse.source.globalsearch.SourceFilter
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.rounded.DoneAll
import mihon.icons.materialsymbols.rounded.FilterList
import mihon.icons.materialsymbols.rounded.PushPin
import mihon.icons.materialsymbols.rounded.Keep
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.material.padding
import tachiyomi.presentation.core.i18n.stringResource
@@ -82,7 +82,7 @@ fun GlobalSearchToolbar(
onClick = { onChangeSearchFilter(SourceFilter.PinnedOnly) },
leadingIcon = {
Icon(
imageVector = MaterialSymbols.Rounded.PushPin,
imageVector = MaterialSymbols.Rounded.Keep,
contentDescription = null,
modifier = Modifier
.size(FilterChipDefaults.IconSize),
@@ -110,7 +110,7 @@ fun CategoryRenameDialog(
onDismissRequest = onDismissRequest,
confirmButton = {
TextButton(
enabled = valueHasChanged && !nameAlreadyExists,
enabled = valueHasChanged && name.isNotEmpty() && !nameAlreadyExists,
onClick = {
onRename(name)
onDismissRequest()
@@ -15,13 +15,10 @@ import kotlin.time.Instant
@Composable
fun relativeDateText(
dateEpochMillis: Long,
date: Instant?,
): String {
return relativeDateText(
localDate = Instant.fromEpochMilliseconds(dateEpochMillis)
.toLocalDateTime(TimeZone.currentSystemDefault())
.date
.takeIf { dateEpochMillis != 0L },
localDate = date?.toLocalDateTime(TimeZone.currentSystemDefault())?.date,
)
}
@@ -6,12 +6,10 @@ import kotlinx.datetime.TimeZone
import kotlinx.datetime.toLocalDateTime
import tachiyomi.domain.history.model.HistoryWithRelations
import tachiyomi.domain.manga.model.MangaCover
import java.util.Date
import kotlin.random.Random
import kotlin.time.Clock
import kotlin.time.Duration.Companion.days
import kotlin.time.Instant
import kotlin.time.toJavaInstant
class HistoryviewModelStateProvider : PreviewParameterProvider<HistoryViewModel.State> {
@@ -99,14 +97,14 @@ class HistoryviewModelStateProvider : PreviewParameterProvider<HistoryViewModel.
mangaId = Random.nextLong(),
title = "Test Title",
chapterNumber = Random.nextDouble(),
readAt = Date.from(Clock.System.now().toJavaInstant()),
readAt = Clock.System.now(),
readDuration = Random.nextLong(),
coverData = MangaCover(
mangaId = Random.nextLong(),
sourceId = Random.nextLong(),
isMangaFavorite = Random.nextBoolean(),
url = "https://example.com/cover.png",
lastModified = Random.nextLong(),
lastModified = Instant.fromEpochMilliseconds(Random.nextLong()),
),
),
),
@@ -2,7 +2,7 @@ package eu.kanade.presentation.history.components
import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import tachiyomi.domain.history.model.HistoryWithRelations
import java.util.Date
import kotlin.time.Instant
internal class HistoryWithRelationsProvider : PreviewParameterProvider<HistoryWithRelations> {
@@ -12,14 +12,14 @@ internal class HistoryWithRelationsProvider : PreviewParameterProvider<HistoryWi
mangaId = 3L,
title = "Test Title",
chapterNumber = 10.2,
readAt = Date(1697247357L),
readAt = Instant.fromEpochMilliseconds(1697247357L),
readDuration = 123L,
coverData = tachiyomi.domain.manga.model.MangaCover(
mangaId = 3L,
sourceId = 4L,
isMangaFavorite = false,
url = "https://example.com/cover.png",
lastModified = 5L,
lastModified = Instant.fromEpochMilliseconds(5L),
),
)
@@ -36,7 +36,7 @@ internal class HistoryWithRelationsProvider : PreviewParameterProvider<HistoryWi
sourceId = 4L,
isMangaFavorite = false,
url = "https://example.com/cover.png",
lastModified = 5L,
lastModified = Instant.fromEpochMilliseconds(5L),
),
)
@@ -46,14 +46,14 @@ internal class HistoryWithRelationsProvider : PreviewParameterProvider<HistoryWi
mangaId = 3L,
title = "Test Title",
chapterNumber = -2.0,
readAt = Date(1697247357L),
readAt = Instant.fromEpochMilliseconds(1697247357L),
readDuration = 123L,
coverData = tachiyomi.domain.manga.model.MangaCover(
mangaId = 3L,
sourceId = 4L,
isMangaFavorite = false,
url = "https://example.com/cover.png",
lastModified = 5L,
lastModified = Instant.fromEpochMilliseconds(5L),
),
)
@@ -39,7 +39,7 @@ fun LibraryContent(
onContinueReadingClicked: ((LibraryManga) -> Unit)?,
onToggleSelection: (Category, LibraryManga) -> Unit,
onToggleRangeSelection: (Category, LibraryManga) -> Unit,
onRefresh: () -> Boolean,
onRefresh: suspend () -> Boolean,
onGlobalSearchClicked: () -> Unit,
getItemCountForCategory: (Category) -> Int?,
getDisplayMode: (Int) -> PreferenceMutableState<LibraryDisplayMode>,
@@ -80,9 +80,8 @@ fun LibraryContent(
refreshing = isRefreshing,
enabled = selection.isEmpty(),
onRefresh = {
val started = onRefresh()
if (!started) return@PullRefresh
scope.launch {
if (!onRefresh()) return@launch
// Fake refresh status but hide it after a second as it's a long running task
isRefreshing = true
delay(1.seconds)
@@ -31,7 +31,7 @@ import eu.kanade.presentation.components.TabbedDialog
import eu.kanade.presentation.components.TabbedDialogPaddings
import mihon.app.di.appGraph
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.rounded.PeopleAlt
import mihon.icons.materialsymbols.rounded.Group
import tachiyomi.core.common.preference.TriState
import tachiyomi.domain.manga.model.Manga
import tachiyomi.i18n.MR
@@ -174,7 +174,7 @@ fun ScanlatorFilterItem(
horizontalArrangement = Arrangement.spacedBy(24.dp),
) {
Icon(
imageVector = MaterialSymbols.Rounded.PeopleAlt,
imageVector = MaterialSymbols.Rounded.Group,
contentDescription = null,
tint = if (active) {
MaterialTheme.colorScheme.active
@@ -58,14 +58,14 @@ import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.rounded.Add
import mihon.icons.materialsymbols.rounded.AttachMoney
import mihon.icons.materialsymbols.rounded.Block
import mihon.icons.materialsymbols.rounded.Brush
import mihon.icons.materialsymbols.rounded.Check
import mihon.icons.materialsymbols.rounded.Close
import mihon.icons.materialsymbols.rounded.Done
import mihon.icons.materialsymbols.rounded.DoneAll
import mihon.icons.materialsymbols.rounded.Pause
import mihon.icons.materialsymbols.rounded.Person
import mihon.icons.materialsymbols.rounded.Schedule
import mihon.icons.materialsymbols.rounded.Warning
import mihon.icons.materialsymbols.roundedfilled.Brush
import mihon.icons.materialsymbols.roundedfilled.Pause
import mihon.icons.materialsymbols.roundedfilled.Warning
import tachiyomi.domain.manga.model.Manga
import tachiyomi.domain.manga.model.MangaWithChapterCount
import tachiyomi.domain.source.model.StubSource
@@ -238,7 +238,7 @@ private fun DuplicateMangaListItem(
if (!manga.artist.isNullOrBlank() && manga.author != manga.artist) {
MangaDetailRow(
text = manga.artist!!,
iconImageVector = MaterialSymbols.Rounded.Brush,
iconImageVector = MaterialSymbols.RoundedFilled.Brush,
maxLines = 2,
)
}
@@ -257,9 +257,9 @@ private fun DuplicateMangaListItem(
SManga.ONGOING.toLong() -> MaterialSymbols.Rounded.Schedule
SManga.COMPLETED.toLong() -> MaterialSymbols.Rounded.DoneAll
SManga.LICENSED.toLong() -> MaterialSymbols.Rounded.AttachMoney
SManga.PUBLISHING_FINISHED.toLong() -> MaterialSymbols.Rounded.Done
SManga.PUBLISHING_FINISHED.toLong() -> MaterialSymbols.Rounded.Check
SManga.CANCELLED.toLong() -> MaterialSymbols.Rounded.Close
SManga.ON_HIATUS.toLong() -> MaterialSymbols.Rounded.Pause
SManga.ON_HIATUS.toLong() -> MaterialSymbols.RoundedFilled.Pause
else -> MaterialSymbols.Rounded.Block
},
)
@@ -272,7 +272,7 @@ private fun DuplicateMangaListItem(
) {
if (source is StubSource) {
Icon(
imageVector = MaterialSymbols.Rounded.Warning,
imageVector = MaterialSymbols.RoundedFilled.Warning,
contentDescription = null,
modifier = Modifier.size(16.dp),
tint = MaterialTheme.colorScheme.error,
@@ -15,6 +15,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListScope
import androidx.compose.foundation.lazy.items
@@ -63,7 +64,6 @@ import eu.kanade.tachiyomi.util.system.copyToClipboard
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.roundedfilled.PlayArrow
import tachiyomi.domain.chapter.model.Chapter
import tachiyomi.domain.chapter.service.missingChaptersCount
import tachiyomi.domain.library.service.LibraryPreferences
import tachiyomi.domain.manga.model.Manga
import tachiyomi.domain.source.model.StubSource
@@ -88,6 +88,7 @@ fun MangaScreen(
navigateUp: () -> Unit,
onChapterClicked: (Chapter) -> Unit,
onDownloadChapter: ((List<ChapterList.Item>, ChapterDownloadAction) -> Unit)?,
downloadProgressProvider: (chapterId: Long) -> Int,
onAddToLibraryClicked: () -> Unit,
onWebViewClicked: (() -> Unit)?,
onWebViewLongClicked: (() -> Unit)?,
@@ -143,6 +144,7 @@ fun MangaScreen(
navigateUp = navigateUp,
onChapterClicked = onChapterClicked,
onDownloadChapter = onDownloadChapter,
downloadProgressProvider = downloadProgressProvider,
onAddToLibraryClicked = onAddToLibraryClicked,
onWebViewClicked = onWebViewClicked,
onWebViewLongClicked = onWebViewLongClicked,
@@ -179,6 +181,7 @@ fun MangaScreen(
navigateUp = navigateUp,
onChapterClicked = onChapterClicked,
onDownloadChapter = onDownloadChapter,
downloadProgressProvider = downloadProgressProvider,
onAddToLibraryClicked = onAddToLibraryClicked,
onWebViewClicked = onWebViewClicked,
onWebViewLongClicked = onWebViewLongClicked,
@@ -218,6 +221,7 @@ private fun MangaScreenSmallImpl(
navigateUp: () -> Unit,
onChapterClicked: (Chapter) -> Unit,
onDownloadChapter: ((List<ChapterList.Item>, ChapterDownloadAction) -> Unit)?,
downloadProgressProvider: (chapterId: Long) -> Int,
onAddToLibraryClicked: () -> Unit,
onWebViewClicked: (() -> Unit)?,
onWebViewLongClicked: (() -> Unit)?,
@@ -273,9 +277,6 @@ private fun MangaScreenSmallImpl(
Scaffold(
topBar = {
val selectedChapterCount: Int = remember(chapters) {
chapters.count { it.selected }
}
val isFirstItemVisible by remember {
derivedStateOf { chapterListState.firstVisibleItemIndex == 0 }
}
@@ -301,7 +302,7 @@ private fun MangaScreenSmallImpl(
onClickRefresh = onRefresh,
onClickMigrate = onMigrateClicked,
onClickEditNotes = onEditNotesClicked,
actionModeCounter = selectedChapterCount,
actionModeCounter = state.selectedChapters.size,
onCancelActionMode = { onAllChapterSelected(false) },
onSelectAll = { onAllChapterSelected(true) },
onInvertSelection = { onInvertSelection() },
@@ -310,11 +311,8 @@ private fun MangaScreenSmallImpl(
)
},
bottomBar = {
val selectedChapters = remember(chapters) {
chapters.filter { it.selected }
}
SharedMangaBottomActionMenu(
selected = selectedChapters,
selected = state.selectedChapters,
onMultiBookmarkClicked = onMultiBookmarkClicked,
onMultiMarkAsReadClicked = onMultiMarkAsReadClicked,
onMarkPreviousAsReadClicked = onMarkPreviousAsReadClicked,
@@ -325,16 +323,13 @@ private fun MangaScreenSmallImpl(
},
snackbarHost = { SnackbarHost(hostState = snackbarHostState) },
floatingActionButton = {
val isFABVisible = remember(chapters) {
chapters.fastAny { !it.chapter.read } && !isAnySelected
}
val isFABVisible = state.hasUnreadChapters && !isAnySelected
SmallExtendedFloatingActionButton(
text = {
val isReading = remember(state.chapters) {
state.chapters.fastAny { it.chapter.read }
}
Text(
text = stringResource(if (isReading) MR.strings.action_resume else MR.strings.action_start),
text = stringResource(
if (state.hasReadChapters) MR.strings.action_resume else MR.strings.action_start,
),
)
},
icon = { Icon(imageVector = MaterialSymbols.RoundedFilled.PlayArrow, contentDescription = null) },
@@ -378,7 +373,7 @@ private fun MangaScreenSmallImpl(
isTabletUi = false,
appBarPadding = topPadding,
manga = state.manga,
sourceName = remember { state.source.getNameForMangaInfo() },
source = remember { state.source },
isStubSource = remember { state.source is StubSource },
onCoverClick = onCoverClicked,
doSearch = onSearch,
@@ -422,13 +417,10 @@ private fun MangaScreenSmallImpl(
key = MangaScreenItem.CHAPTER_HEADER,
contentType = MangaScreenItem.CHAPTER_HEADER,
) {
val missingChapterCount = remember(chapters) {
chapters.map { it.chapter.chapterNumber }.missingChaptersCount()
}
ChapterHeader(
enabled = !isAnySelected,
chapterCount = chapters.size,
missingChapterCount = missingChapterCount,
missingChapterCount = state.missingChapterCount,
onClick = onFilterClicked,
)
}
@@ -436,11 +428,12 @@ private fun MangaScreenSmallImpl(
sharedChapterItems(
manga = state.manga,
chapters = listItem,
isAnyChapterSelected = chapters.fastAny { it.selected },
isAnyChapterSelected = state.selectedChapters.isNotEmpty(),
chapterSwipeStartAction = chapterSwipeStartAction,
chapterSwipeEndAction = chapterSwipeEndAction,
onChapterClicked = onChapterClicked,
onDownloadChapter = onDownloadChapter,
downloadProgressProvider = downloadProgressProvider,
onChapterSelected = onChapterSelected,
onChapterSwipe = onChapterSwipe,
)
@@ -460,6 +453,7 @@ fun MangaScreenLargeImpl(
navigateUp: () -> Unit,
onChapterClicked: (Chapter) -> Unit,
onDownloadChapter: ((List<ChapterList.Item>, ChapterDownloadAction) -> Unit)?,
downloadProgressProvider: (chapterId: Long) -> Int,
onAddToLibraryClicked: () -> Unit,
onWebViewClicked: (() -> Unit)?,
onWebViewLongClicked: (() -> Unit)?,
@@ -521,9 +515,6 @@ fun MangaScreenLargeImpl(
Scaffold(
topBar = {
val selectedChapterCount = remember(chapters) {
chapters.count { it.selected }
}
MangaToolbar(
modifier = Modifier.onSizeChanged { topBarHeight = it.height },
title = state.manga.title,
@@ -537,7 +528,7 @@ fun MangaScreenLargeImpl(
onClickMigrate = onMigrateClicked,
onClickEditNotes = onEditNotesClicked,
onCancelActionMode = { onAllChapterSelected(false) },
actionModeCounter = selectedChapterCount,
actionModeCounter = state.selectedChapters.size,
onSelectAll = { onAllChapterSelected(true) },
onInvertSelection = { onInvertSelection() },
titleAlphaProvider = { 1f },
@@ -545,37 +536,29 @@ fun MangaScreenLargeImpl(
)
},
bottomBar = {
Box(
modifier = Modifier.fillMaxWidth(),
contentAlignment = Alignment.BottomEnd,
) {
val selectedChapters = remember(chapters) {
chapters.filter { it.selected }
}
// Aligned by its own modifier: a wrapper would always be laid out, and the scaffold then drops the
// navigation bar inset under the FAB
SharedMangaBottomActionMenu(
selected = selectedChapters,
selected = state.selectedChapters,
onMultiBookmarkClicked = onMultiBookmarkClicked,
onMultiMarkAsReadClicked = onMultiMarkAsReadClicked,
onMarkPreviousAsReadClicked = onMarkPreviousAsReadClicked,
onDownloadChapter = onDownloadChapter,
onMultiDeleteClicked = onMultiDeleteClicked,
fillFraction = 0.5f,
modifier = Modifier
.fillMaxWidth()
.wrapContentWidth(Alignment.End),
)
}
},
snackbarHost = { SnackbarHost(hostState = snackbarHostState) },
floatingActionButton = {
val isFABVisible = remember(chapters) {
chapters.fastAny { !it.chapter.read } && !isAnySelected
}
val isFABVisible = state.hasUnreadChapters && !isAnySelected
SmallExtendedFloatingActionButton(
text = {
val isReading = remember(state.chapters) {
state.chapters.fastAny { it.chapter.read }
}
Text(
text = stringResource(
if (isReading) MR.strings.action_resume else MR.strings.action_start,
if (state.hasReadChapters) MR.strings.action_resume else MR.strings.action_start,
),
)
},
@@ -614,7 +597,7 @@ fun MangaScreenLargeImpl(
isTabletUi = true,
appBarPadding = contentPadding.calculateTopPadding(),
manga = state.manga,
sourceName = remember { state.source.getNameForMangaInfo() },
source = remember { state.source },
isStubSource = remember { state.source is StubSource },
onCoverClick = onCoverClicked,
doSearch = onSearch,
@@ -659,13 +642,10 @@ fun MangaScreenLargeImpl(
key = MangaScreenItem.CHAPTER_HEADER,
contentType = MangaScreenItem.CHAPTER_HEADER,
) {
val missingChapterCount = remember(chapters) {
chapters.map { it.chapter.chapterNumber }.missingChaptersCount()
}
ChapterHeader(
enabled = !isAnySelected,
chapterCount = chapters.size,
missingChapterCount = missingChapterCount,
missingChapterCount = state.missingChapterCount,
onClick = onFilterButtonClicked,
)
}
@@ -673,11 +653,12 @@ fun MangaScreenLargeImpl(
sharedChapterItems(
manga = state.manga,
chapters = listItem,
isAnyChapterSelected = chapters.fastAny { it.selected },
isAnyChapterSelected = state.selectedChapters.isNotEmpty(),
chapterSwipeStartAction = chapterSwipeStartAction,
chapterSwipeEndAction = chapterSwipeEndAction,
onChapterClicked = onChapterClicked,
onDownloadChapter = onDownloadChapter,
downloadProgressProvider = downloadProgressProvider,
onChapterSelected = onChapterSelected,
onChapterSwipe = onChapterSwipe,
)
@@ -714,7 +695,7 @@ private fun SharedMangaBottomActionMenu(
}.takeIf { selected.fastAny { !it.chapter.read } },
onMarkAsUnreadClicked = {
onMultiMarkAsReadClicked(selected.fastMap { it.chapter }, false)
}.takeIf { selected.fastAny { it.chapter.read || it.chapter.lastPageRead > 0L } },
}.takeIf { selected.fastAny { it.chapter.read || it.chapter.lastPageRead > 0 } },
onMarkPreviousAsReadClicked = {
onMarkPreviousAsReadClicked(selected[0].chapter)
}.takeIf { selected.size == 1 },
@@ -739,6 +720,7 @@ private fun LazyListScope.sharedChapterItems(
chapterSwipeEndAction: LibraryPreferences.ChapterSwipeAction,
onChapterClicked: (Chapter) -> Unit,
onDownloadChapter: ((List<ChapterList.Item>, ChapterDownloadAction) -> Unit)?,
downloadProgressProvider: (chapterId: Long) -> Int,
onChapterSelected: (ChapterList.Item, Boolean, Boolean) -> Unit,
onChapterSwipe: (ChapterList.Item, LibraryPreferences.ChapterSwipeAction) -> Unit,
) {
@@ -783,7 +765,7 @@ private fun LazyListScope.sharedChapterItems(
selected = item.selected,
downloadIndicatorEnabled = !isAnyChapterSelected && !manga.isLocal(),
downloadStateProvider = { item.downloadState },
downloadProgressProvider = { item.downloadProgress },
downloadProgressProvider = { downloadProgressProvider(item.id) },
chapterSwipeStartAction = chapterSwipeStartAction,
chapterSwipeEndAction = chapterSwipeEndAction,
onLongClick = {
@@ -12,6 +12,7 @@ enum class DownloadAction {
enum class EditCoverAction {
EDIT,
DELETE,
ADD_TO_LIBRARY,
}
enum class MangaScreenItem {
@@ -5,12 +5,12 @@ import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.CircularWavyProgressIndicator
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ProgressIndicatorDefaults
import androidx.compose.material3.Text
import androidx.compose.material3.WavyProgressIndicatorDefaults
import androidx.compose.material3.ripple
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
@@ -21,17 +21,19 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.StrokeCap
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.hapticfeedback.HapticFeedback
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.unit.dp
import eu.kanade.presentation.components.DropdownMenu
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.download.model.Download
import mihon.icons.custommaterialsymbols.CustomMaterialSymbols
import mihon.icons.custommaterialsymbols.rounded.DownloadArrow
import mihon.icons.custommaterialsymbols.rounded.DownloadCircle
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.rounded.ArrowDownward
import mihon.icons.materialsymbols.rounded.Error
import mihon.icons.materialsymbols.roundedfilled.CheckCircle
import tachiyomi.i18n.MR
@@ -99,7 +101,7 @@ private fun NotDownloadedIndicator(
contentAlignment = Alignment.Center,
) {
Icon(
painter = painterResource(R.drawable.ic_download_chapter_24dp),
imageVector = CustomMaterialSymbols.Rounded.DownloadCircle,
contentDescription = stringResource(MR.strings.manga_download),
modifier = Modifier.size(IndicatorSize),
tint = MaterialTheme.colorScheme.onSurfaceVariant,
@@ -127,39 +129,38 @@ private fun DownloadingIndicator(
),
contentAlignment = Alignment.Center,
) {
val arrowColor: Color
val strokeColor = MaterialTheme.colorScheme.onSurfaceVariant
val color = MaterialTheme.colorScheme.onSurfaceVariant
val trackColor = color.copy(alpha = TRACK_ALPHA)
val stroke = Stroke(width = with(LocalDensity.current) { IndicatorStrokeWidth.toPx() }, cap = StrokeCap.Round)
val downloadProgress = downloadProgressProvider()
val indeterminate = downloadState == Download.State.QUEUE ||
(downloadState == Download.State.DOWNLOADING && downloadProgress == 0)
if (indeterminate) {
arrowColor = strokeColor
CircularProgressIndicator(
CircularWavyProgressIndicator(
modifier = IndicatorModifier,
color = strokeColor,
strokeWidth = IndicatorStrokeWidth,
color = color,
trackColor = Color.Transparent,
strokeCap = StrokeCap.Butt,
stroke = stroke,
trackStroke = stroke,
// Only an active download waves, so a queued one reads as waiting
amplitude = if (downloadState == Download.State.DOWNLOADING) INDICATOR_AMPLITUDE else 0f,
wavelength = IndicatorWavelength,
)
} else {
val animatedProgress by animateFloatAsState(
targetValue = downloadProgress / 100f,
animationSpec = ProgressIndicatorDefaults.ProgressAnimationSpec,
animationSpec = WavyProgressIndicatorDefaults.ProgressAnimationSpec,
label = "progress",
)
arrowColor = if (animatedProgress < 0.5f) {
strokeColor
} else {
MaterialTheme.colorScheme.background
}
CircularProgressIndicator(
CircularWavyProgressIndicator(
progress = { animatedProgress },
modifier = IndicatorModifier,
color = strokeColor,
strokeWidth = IndicatorSize / 2,
trackColor = Color.Transparent,
strokeCap = StrokeCap.Butt,
gapSize = 0.dp,
color = color,
trackColor = trackColor,
stroke = stroke,
trackStroke = stroke,
amplitude = { WavyProgressIndicatorDefaults.indicatorAmplitude(it) * INDICATOR_AMPLITUDE },
wavelength = IndicatorWavelength,
)
}
DropdownMenu(expanded = isMenuExpanded, onDismissRequest = { isMenuExpanded = false }) {
@@ -179,10 +180,10 @@ private fun DownloadingIndicator(
)
}
Icon(
imageVector = MaterialSymbols.Rounded.ArrowDownward,
imageVector = CustomMaterialSymbols.Rounded.DownloadArrow,
contentDescription = null,
modifier = ArrowModifier,
tint = arrowColor,
tint = color,
)
}
}
@@ -270,13 +271,15 @@ private fun Modifier.commonClickable(
)
private val IndicatorSize = 26.dp
private val IndicatorPadding = 2.dp
private val IndicatorPadding = 1.dp
private val IndicatorWavelength = 7.dp
private const val INDICATOR_AMPLITUDE = 0.6f
private const val TRACK_ALPHA = 0.25f
// To match composable parameter name when used later
private val IndicatorStrokeWidth = IndicatorPadding
private val IndicatorStrokeWidth = 2.dp
private val IndicatorModifier = Modifier
.size(IndicatorSize)
.padding(IndicatorPadding)
private val ArrowModifier = Modifier
.size(IndicatorSize - 7.dp)
.size(IndicatorSize)
@@ -40,18 +40,18 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.hapticfeedback.HapticFeedbackType
import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.DpOffset
import androidx.compose.ui.unit.dp
import eu.kanade.presentation.components.DownloadDropdownMenu
import eu.kanade.presentation.components.DropdownMenu
import eu.kanade.presentation.manga.DownloadAction
import eu.kanade.tachiyomi.R
import kotlinx.coroutines.Job
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import mihon.icons.custommaterialsymbols.CustomMaterialSymbols
import mihon.icons.custommaterialsymbols.rounded.DonePrevious
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.automirroredrounded.Label
import mihon.icons.materialsymbols.rounded.BookmarkAdd
@@ -149,7 +149,7 @@ fun MangaBottomActionMenu(
if (onMarkPreviousAsReadClicked != null) {
Button(
title = stringResource(MR.strings.action_mark_previous_as_read),
icon = ImageVector.vectorResource(R.drawable.ic_done_prev_24dp),
icon = CustomMaterialSymbols.Rounded.DonePrevious,
toConfirm = confirm[4],
onLongClick = { onLongClickItem(4) },
onClick = onMarkPreviousAsReadClicked,
@@ -31,8 +31,8 @@ import me.saket.swipe.SwipeableActionsBox
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.rounded.BookmarkAdd
import mihon.icons.materialsymbols.rounded.BookmarkRemove
import mihon.icons.materialsymbols.rounded.Check
import mihon.icons.materialsymbols.rounded.Delete
import mihon.icons.materialsymbols.rounded.Done
import mihon.icons.materialsymbols.rounded.Download
import mihon.icons.materialsymbols.rounded.FileDownloadOff
import mihon.icons.materialsymbols.rounded.RemoveDone
@@ -192,7 +192,7 @@ private fun getSwipeAction(
): me.saket.swipe.SwipeAction? {
return when (action) {
LibraryPreferences.ChapterSwipeAction.ToggleRead -> swipeAction(
icon = if (!read) MaterialSymbols.Rounded.Done else MaterialSymbols.Rounded.RemoveDone,
icon = if (!read) MaterialSymbols.Rounded.Check else MaterialSymbols.Rounded.RemoveDone,
background = background,
isUndo = read,
onSwipe = onSwipe,
@@ -18,6 +18,7 @@ import androidx.compose.material3.SnackbarHost
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
@@ -44,6 +45,7 @@ import coil3.asDrawable
import coil3.imageLoader
import coil3.request.CachePolicy
import coil3.request.ImageRequest
import coil3.request.SuccessResult
import coil3.size.Size
import eu.kanade.presentation.components.AppBar
import eu.kanade.presentation.components.AppBarActions
@@ -53,7 +55,7 @@ import eu.kanade.tachiyomi.data.coil.ImageDecoder
import eu.kanade.tachiyomi.data.coil.newDecoder
import eu.kanade.tachiyomi.ui.reader.viewer.ReaderPageImageView
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import mihon.app.di.appGraph
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.rounded.Close
@@ -65,6 +67,7 @@ import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.material.Scaffold
import tachiyomi.presentation.core.i18n.stringResource
import tachiyomi.presentation.core.util.clickableNoIndication
import tachiyomi.source.local.isLocal
@Composable
fun MangaCoverDialog(
@@ -125,10 +128,12 @@ fun MangaCoverDialog(
var expanded by remember { mutableStateOf(false) }
IconButton(
onClick = {
if (isCustomCover) {
expanded = true
} else {
onEditClick(EditCoverAction.EDIT)
when {
!manga.favorite && !manga.isLocal() -> {
onEditClick(EditCoverAction.ADD_TO_LIBRARY)
}
isCustomCover -> expanded = true
else -> onEditClick(EditCoverAction.EDIT)
}
},
) {
@@ -164,16 +169,20 @@ fun MangaCoverDialog(
},
) { contentPadding ->
if (useNewRenderer) {
val state = ImageViewerState()
ImageRequest.Builder(view.context)
val state = remember(manga) { ImageViewerState() }
LaunchedEffect(manga) {
val request = ImageRequest.Builder(view.context)
.data(manga)
.size(Size.ORIGINAL)
.memoryCachePolicy(CachePolicy.DISABLED)
.newDecoder(true)
.target { result ->
val res = (result as ImageDecoder.DecodeResultImage).res
val page = runBlocking(Dispatchers.Default) {
.build()
val result = view.context.imageLoader.execute(request) as? SuccessResult ?: return@LaunchedEffect
val res = result.image as? ImageDecoder.DecodeResultImage ?: return@LaunchedEffect
// Held, then freed, around the upload: its buffer alone doesn't keep
// the frame's native pixels alive.
val page = res.frame.use {
withContext(Dispatchers.Default) {
ImagePage.ImageSingle(
Image(
res.image,
@@ -199,6 +208,7 @@ fun MangaCoverDialog(
),
)
}
}
state.apply {
fetchPage = { index ->
if (index == 0) page else null
@@ -206,8 +216,6 @@ fun MangaCoverDialog(
invalidate()
}
}
.build()
.let(view.context.imageLoader::enqueue)
ImageViewer(state = state)
return@Scaffold
@@ -72,6 +72,8 @@ import com.mikepenz.markdown.model.markdownAnnotatorConfig
import com.mikepenz.markdown.utils.getUnescapedTextInNode
import eu.kanade.presentation.components.DropdownMenu
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.getNameForMangaInfo
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.util.system.copyToClipboard
import kotlinx.datetime.TimeZone
@@ -80,19 +82,19 @@ import mihon.app.di.appGraph
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.rounded.AttachMoney
import mihon.icons.materialsymbols.rounded.Block
import mihon.icons.materialsymbols.rounded.Brush
import mihon.icons.materialsymbols.rounded.Check
import mihon.icons.materialsymbols.rounded.Close
import mihon.icons.materialsymbols.rounded.Done
import mihon.icons.materialsymbols.rounded.DoneAll
import mihon.icons.materialsymbols.rounded.Favorite
import mihon.icons.materialsymbols.rounded.HourglassEmpty
import mihon.icons.materialsymbols.rounded.Pause
import mihon.icons.materialsymbols.rounded.Person
import mihon.icons.materialsymbols.rounded.Public
import mihon.icons.materialsymbols.rounded.Schedule
import mihon.icons.materialsymbols.rounded.Sync
import mihon.icons.materialsymbols.rounded.Warning
import mihon.icons.materialsymbols.roundedfilled.Brush
import mihon.icons.materialsymbols.roundedfilled.Favorite
import mihon.icons.materialsymbols.roundedfilled.Pause
import mihon.icons.materialsymbols.roundedfilled.Warning
import org.intellij.markdown.MarkdownElementTypes
import org.intellij.markdown.MarkdownTokenTypes
import org.intellij.markdown.ast.findChildOfType
@@ -114,7 +116,7 @@ fun MangaInfoBox(
isTabletUi: Boolean,
appBarPadding: Dp,
manga: Manga,
sourceName: String,
source: Source,
isStubSource: Boolean,
onCoverClick: () -> Unit,
doSearch: (query: String, global: Boolean) -> Unit,
@@ -151,7 +153,7 @@ fun MangaInfoBox(
MangaAndSourceTitlesSmall(
appBarPadding = appBarPadding,
manga = manga,
sourceName = sourceName,
source = source,
isStubSource = isStubSource,
onCoverClick = onCoverClick,
doSearch = doSearch,
@@ -160,7 +162,7 @@ fun MangaInfoBox(
MangaAndSourceTitlesLarge(
appBarPadding = appBarPadding,
manga = manga,
sourceName = sourceName,
source = source,
isStubSource = isStubSource,
onCoverClick = onCoverClick,
doSearch = doSearch,
@@ -228,7 +230,7 @@ fun MangaActionRow(
} else {
pluralStringResource(MR.plurals.num_trackers, count = trackingCount, trackingCount)
},
icon = if (trackingCount == 0) MaterialSymbols.Rounded.Sync else MaterialSymbols.Rounded.Done,
icon = if (trackingCount == 0) MaterialSymbols.Rounded.Sync else MaterialSymbols.Rounded.Check,
color = if (trackingCount == 0) defaultActionButtonColor else MaterialTheme.colorScheme.primary,
onClick = onTrackingClicked,
)
@@ -344,7 +346,7 @@ fun ExpandableMangaDescription(
private fun MangaAndSourceTitlesLarge(
appBarPadding: Dp,
manga: Manga,
sourceName: String,
source: Source,
isStubSource: Boolean,
onCoverClick: () -> Unit,
doSearch: (query: String, global: Boolean) -> Unit,
@@ -370,7 +372,7 @@ private fun MangaAndSourceTitlesLarge(
author = manga.author,
artist = manga.artist,
status = manga.status,
sourceName = sourceName,
source = source,
isStubSource = isStubSource,
doSearch = doSearch,
textAlign = TextAlign.Center,
@@ -382,7 +384,7 @@ private fun MangaAndSourceTitlesLarge(
private fun MangaAndSourceTitlesSmall(
appBarPadding: Dp,
manga: Manga,
sourceName: String,
source: Source,
isStubSource: Boolean,
onCoverClick: () -> Unit,
doSearch: (query: String, global: Boolean) -> Unit,
@@ -413,7 +415,7 @@ private fun MangaAndSourceTitlesSmall(
author = manga.author,
artist = manga.artist,
status = manga.status,
sourceName = sourceName,
source = source,
isStubSource = isStubSource,
doSearch = doSearch,
)
@@ -427,7 +429,7 @@ private fun ColumnScope.MangaContentInfo(
author: String?,
artist: String?,
status: Long,
sourceName: String,
source: Source,
isStubSource: Boolean,
doSearch: (query: String, global: Boolean) -> Unit,
textAlign: TextAlign? = LocalTextStyle.current.textAlign,
@@ -489,7 +491,7 @@ private fun ColumnScope.MangaContentInfo(
verticalAlignment = Alignment.CenterVertically,
) {
Icon(
imageVector = MaterialSymbols.Rounded.Brush,
imageVector = MaterialSymbols.RoundedFilled.Brush,
contentDescription = null,
modifier = Modifier.size(16.dp),
)
@@ -517,9 +519,9 @@ private fun ColumnScope.MangaContentInfo(
SManga.ONGOING.toLong() -> MaterialSymbols.Rounded.Schedule
SManga.COMPLETED.toLong() -> MaterialSymbols.Rounded.DoneAll
SManga.LICENSED.toLong() -> MaterialSymbols.Rounded.AttachMoney
SManga.PUBLISHING_FINISHED.toLong() -> MaterialSymbols.Rounded.Done
SManga.PUBLISHING_FINISHED.toLong() -> MaterialSymbols.Rounded.Check
SManga.CANCELLED.toLong() -> MaterialSymbols.Rounded.Close
SManga.ON_HIATUS.toLong() -> MaterialSymbols.Rounded.Pause
SManga.ON_HIATUS.toLong() -> MaterialSymbols.RoundedFilled.Pause
else -> MaterialSymbols.Rounded.Block
},
contentDescription = null,
@@ -544,7 +546,7 @@ private fun ColumnScope.MangaContentInfo(
DotSeparatorText()
if (isStubSource) {
Icon(
imageVector = MaterialSymbols.Rounded.Warning,
imageVector = MaterialSymbols.RoundedFilled.Warning,
contentDescription = null,
modifier = Modifier
.padding(end = 4.dp)
@@ -553,12 +555,9 @@ private fun ColumnScope.MangaContentInfo(
)
}
Text(
text = sourceName,
text = source.getNameForMangaInfo(),
modifier = Modifier.clickableNoIndication {
doSearch(
sourceName,
false,
)
doSearch(source.query(), false)
},
overflow = TextOverflow.Ellipsis,
maxLines = 1,
@@ -567,6 +566,8 @@ private fun ColumnScope.MangaContentInfo(
}
}
private fun Source.query(): String = """src:"$name" lang:$lang""".takeIf { name.isNotBlank() } ?: "srcid:$id"
@Composable
private fun descriptionAnnotator(loadImages: Boolean, linkStyle: SpanStyle) = remember(loadImages, linkStyle) {
markdownAnnotator(
@@ -666,7 +667,7 @@ private fun MangaSummary(
modifier = Modifier.background(Brush.verticalGradient(colors = colors)),
contentAlignment = Alignment.Center,
) {
val image = AnimatedImageVector.animatedVectorResource(R.drawable.anim_caret_down)
val image = AnimatedImageVector.animatedVectorResource(R.drawable.animated_caret_flip)
Icon(
painter = rememberAnimatedVectorPainter(image, !expanded),
contentDescription = stringResource(
@@ -45,7 +45,7 @@ import com.mikepenz.markdown.model.MarkdownTypography
import com.mikepenz.markdown.model.NoOpImageTransformerImpl
import com.mikepenz.markdown.model.markdownAlertPadding
import com.mikepenz.markdown.model.markdownAnnotator
import com.mikepenz.markdown.model.rememberMarkdownState
import com.mikepenz.markdown.model.parseMarkdown
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.rounded.Image
import org.intellij.markdown.MarkdownTokenTypes.Companion.HTML_TAG
@@ -79,11 +79,9 @@ fun MarkdownRender(
loadImages: Boolean = true,
) {
Markdown(
markdownState = rememberMarkdownState(
content = content,
flavour = flavour,
immediate = true,
),
// rememberMarkdownState parses again in the background even when it already parsed immediately, and its
// new result recomposes the whole content a second time
state = remember(content, flavour) { parseMarkdown(content = content, flavour = flavour) },
annotator = annotator,
colors = getMarkdownColors(),
typography = getMarkdownTypography(),
@@ -0,0 +1,48 @@
package eu.kanade.presentation.more
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawingPadding
import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.i18n.stringResource
/**
* Shown instead of the app while migrations from the previous version run, so a slow first launch
* after an update doesn't look like the app hanging.
*/
@Composable
fun AppMigratingScreen() {
Surface(modifier = Modifier.fillMaxSize()) {
Column(
modifier = Modifier
.safeDrawingPadding()
.padding(horizontal = 32.dp),
verticalArrangement = Arrangement.spacedBy(16.dp, Alignment.CenterVertically),
horizontalAlignment = Alignment.CenterHorizontally,
) {
CircularProgressIndicator()
Text(
text = stringResource(MR.strings.app_migrating_title),
style = MaterialTheme.typography.titleLarge,
textAlign = TextAlign.Center,
)
Text(
text = stringResource(MR.strings.app_migrating_summary),
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
textAlign = TextAlign.Center,
)
}
}
}
@@ -3,24 +3,22 @@ package eu.kanade.presentation.more
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.material3.HorizontalDivider
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.unit.dp
import eu.kanade.presentation.more.settings.widget.SwitchPreferenceWidget
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.more.DownloadQueueState
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.automirroredrounded.Help
import mihon.icons.materialsymbols.automirroredrounded.Label
import mihon.icons.materialsymbols.rounded.CloudOff
import mihon.icons.materialsymbols.rounded.Download
import mihon.icons.materialsymbols.rounded.Eyeglasses2
import mihon.icons.materialsymbols.rounded.Info
import mihon.icons.materialsymbols.rounded.QueryStats
import mihon.icons.materialsymbols.rounded.Settings
import mihon.icons.materialsymbols.rounded.Storage
import mihon.icons.materialsymbols.rounded.VolunteerActivism
import mihon.icons.materialsymbols.roundedfilled.VolunteerActivism
import tachiyomi.core.common.Constants
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.ScrollbarLazyColumn
@@ -65,7 +63,7 @@ fun MoreScreen(
SwitchPreferenceWidget(
title = stringResource(MR.strings.pref_incognito_mode),
subtitle = stringResource(MR.strings.pref_incognito_mode_summary),
icon = ImageVector.vectorResource(R.drawable.ic_glasses_24dp),
icon = MaterialSymbols.Rounded.Eyeglasses2,
checked = incognitoMode,
onCheckedChanged = onIncognitoModeChange,
)
@@ -136,7 +134,7 @@ fun MoreScreen(
item {
TextPreferenceWidget(
title = stringResource(MR.strings.label_support_us),
icon = MaterialSymbols.Rounded.VolunteerActivism,
icon = MaterialSymbols.RoundedFilled.VolunteerActivism,
onPreferenceClick = onClickSupport,
)
}
@@ -5,12 +5,17 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.PreviewLightDark
import eu.kanade.presentation.manga.components.MarkdownRender
@@ -18,7 +23,8 @@ import eu.kanade.presentation.theme.TachiyomiPreviewTheme
import eu.kanade.tachiyomi.ui.more.NewUpdateScreenModel
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.automirroredrounded.OpenInNew
import mihon.icons.materialsymbols.rounded.NewReleases
import mihon.icons.materialsymbols.rounded.UpdateDisabled
import mihon.icons.materialsymbols.rounded.Verified
import org.intellij.markdown.flavours.gfm.GFMFlavourDescriptor
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.material.padding
@@ -34,9 +40,35 @@ fun NewUpdateScreen(
onOpenInBrowser: () -> Unit,
onAcceptUpdate: () -> Unit,
onRejectUpdate: () -> Unit,
onSkipUpdate: () -> Unit,
) {
var showSkipDialog by remember { mutableStateOf(false) }
if (showSkipDialog) {
val dismiss = { showSkipDialog = false }
AlertDialog(
onDismissRequest = dismiss,
title = { Text(text = stringResource(MR.strings.update_check_skip_title, versionName)) },
text = { Text(text = stringResource(MR.strings.update_check_skip_message)) },
dismissButton = {
TextButton(onClick = dismiss) {
Text(text = stringResource(MR.strings.action_cancel))
}
},
confirmButton = {
TextButton(
onClick = {
dismiss()
onSkipUpdate()
},
) {
Text(text = stringResource(MR.strings.action_ok))
}
},
)
}
InfoScreen(
icon = MaterialSymbols.Rounded.NewReleases,
icon = MaterialSymbols.Rounded.Verified,
headingText = stringResource(MR.strings.update_check_notification_update_available),
subtitleText = versionName,
acceptText = when (stage) {
@@ -52,6 +84,14 @@ fun NewUpdateScreen(
canAccept = stage != NewUpdateScreenModel.Stage.Downloading,
rejectText = stringResource(MR.strings.action_not_now),
onRejectClick = onRejectUpdate,
rejectAction = {
OutlinedButton(onClick = { showSkipDialog = true }) {
Icon(
imageVector = MaterialSymbols.Rounded.UpdateDisabled,
contentDescription = stringResource(MR.strings.update_check_skip),
)
}
},
) {
Column(
modifier = Modifier
@@ -94,6 +134,7 @@ private fun NewUpdateScreenPreview() {
onOpenInBrowser = {},
onAcceptUpdate = {},
onRejectUpdate = {},
onSkipUpdate = {},
)
}
}
@@ -11,7 +11,7 @@ import tachiyomi.core.common.preference.Preference as PreferenceData
sealed class Preference {
abstract val title: String
abstract val enabled: Boolean
abstract val visible: Boolean
sealed class PreferenceItem<T, R> : Preference() {
abstract val subtitle: String?
@@ -24,7 +24,7 @@ sealed class Preference {
data class TextPreference(
override val title: String,
override val subtitle: String? = null,
override val enabled: Boolean = true,
override val visible: Boolean = true,
val widget: @Composable (() -> Unit)? = null,
val onClick: (() -> Unit)? = null,
) : PreferenceItem<String, Unit>() {
@@ -39,7 +39,7 @@ sealed class Preference {
val preference: PreferenceData<Boolean>,
override val title: String,
override val subtitle: String? = null,
override val enabled: Boolean = true,
override val visible: Boolean = true,
override val onValueChanged: suspend (value: Boolean) -> Boolean = { true },
) : PreferenceItem<Boolean, Boolean>() {
override val icon: ImageVector? = null
@@ -49,15 +49,15 @@ sealed class Preference {
* A [PreferenceItem] that provides a slider to select an integer number.
*/
data class SliderPreference(
val value: Int,
val preference: PreferenceData<Int>,
override val title: String,
override val subtitle: String? = null,
val valueString: String? = null,
val valueText: @Composable (Int) -> String = { it.toString() },
val valueRange: IntProgression = 0..1,
@IntRange(from = 0) val steps: Int = with(valueRange) { (last - first) - 1 },
override val enabled: Boolean = true,
override val onValueChanged: suspend (value: Int) -> Unit = {},
) : PreferenceItem<Int, Unit>() {
@IntRange(from = 0) val steps: Int = with(valueRange) { ((last - first) / step) - 1 },
override val visible: Boolean = true,
override val onValueChanged: suspend (value: Int) -> Boolean = { true },
) : PreferenceItem<Int, Boolean>() {
override val icon: ImageVector? = null
}
@@ -73,7 +73,7 @@ sealed class Preference {
val subtitleProvider: @Composable (value: T, entries: Map<T, String>) -> String? =
{ v, e -> subtitle?.format(e[v]) },
override val icon: ImageVector? = null,
override val enabled: Boolean = true,
override val visible: Boolean = true,
override val onValueChanged: suspend (value: T) -> Boolean = { true },
) : PreferenceItem<T, Boolean>() {
internal fun internalSet(value: Any) = preference.set(value as T)
@@ -95,7 +95,7 @@ sealed class Preference {
val subtitleProvider: @Composable (value: String, entries: Map<String, String>) -> String? =
{ v, e -> subtitle?.format(e[v]) },
override val icon: ImageVector? = null,
override val enabled: Boolean = true,
override val visible: Boolean = true,
override val onValueChanged: suspend (value: String) -> Unit = {},
) : PreferenceItem<String, Unit>()
@@ -120,7 +120,7 @@ sealed class Preference {
subtitle?.format(combined)
},
override val icon: ImageVector? = null,
override val enabled: Boolean = true,
override val visible: Boolean = true,
override val onValueChanged: suspend (value: Set<T>) -> Boolean = { true },
) : PreferenceItem<Set<T>, Boolean>() {
internal fun internalSet(value: Set<Any?>) = preference.set(value as Set<T>)
@@ -138,7 +138,7 @@ sealed class Preference {
val preference: PreferenceData<String>,
override val title: String,
override val subtitle: String? = "%s",
override val enabled: Boolean = true,
override val visible: Boolean = true,
override val onValueChanged: suspend (value: String) -> Boolean = { true },
) : PreferenceItem<String, Boolean>() {
override val icon: ImageVector? = null
@@ -153,7 +153,7 @@ sealed class Preference {
val logout: () -> Unit,
) : PreferenceItem<String, Unit>() {
override val title: String = ""
override val enabled: Boolean = true
override val visible: Boolean = true
override val subtitle: String? = null
override val icon: ImageVector? = null
override val onValueChanged: suspend (value: String) -> Unit = {}
@@ -162,7 +162,7 @@ sealed class Preference {
data class InfoPreference(
override val title: String,
) : PreferenceItem<String, Unit>() {
override val enabled: Boolean = true
override val visible: Boolean = true
override val subtitle: String? = null
override val icon: ImageVector? = null
override val onValueChanged: suspend (value: String) -> Unit = {}
@@ -172,7 +172,7 @@ sealed class Preference {
override val title: String,
val content: @Composable () -> Unit,
) : PreferenceItem<Unit, Unit>() {
override val enabled: Boolean = true
override val visible: Boolean = true
override val subtitle: String? = null
override val icon: ImageVector? = null
override val onValueChanged: suspend (value: Unit) -> Unit = {}
@@ -181,7 +181,7 @@ sealed class Preference {
data class PreferenceGroup(
override val title: String,
override val enabled: Boolean = true,
override val visible: Boolean = true,
val preferenceItems: List<PreferenceItem<out Any, out Any>>,
) : Preference()
@@ -9,12 +9,14 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.structuralEqualityPolicy
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import eu.kanade.presentation.more.settings.widget.EditTextPreferenceWidget
import eu.kanade.presentation.more.settings.widget.InfoWidget
@@ -26,7 +28,11 @@ import eu.kanade.presentation.more.settings.widget.SwitchPreferenceWidget
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
import eu.kanade.presentation.more.settings.widget.TitleFontSize
import eu.kanade.presentation.more.settings.widget.TrackingPreferenceWidget
import eu.kanade.tachiyomi.data.track.RefreshResult
import eu.kanade.tachiyomi.util.system.toast
import kotlinx.coroutines.launch
import tachiyomi.core.common.i18n.stringResource
import tachiyomi.i18n.MR
import tachiyomi.presentation.core.components.BaseSliderItem
import tachiyomi.presentation.core.util.collectAsState
@@ -39,7 +45,7 @@ fun StatusWrapper(
highlightKey: String?,
content: @Composable () -> Unit,
) {
val enabled = item.enabled
val enabled = item.visible
val highlighted = item.title == highlightKey
AnimatedVisibility(
visible = enabled,
@@ -82,16 +88,19 @@ internal fun PreferenceItem(
)
}
is Preference.PreferenceItem.SliderPreference -> {
val value by item.preference.collectAsState()
BaseSliderItem(
value = item.value,
value = value,
valueRange = item.valueRange,
steps = item.steps,
title = item.title,
subtitle = item.subtitle,
valueString = item.valueString.takeUnless { it.isNullOrEmpty() } ?: item.value.toString(),
onChange = {
valueString = item.valueText(value),
onChange = { newValue ->
scope.launch {
item.onValueChanged(it)
if (item.onValueChanged(newValue)) {
item.preference.set(newValue)
}
}
},
titleStyle = MaterialTheme.typography.titleLarge.copy(fontSize = TitleFontSize),
@@ -169,12 +178,28 @@ internal fun PreferenceItem(
)
}
is Preference.PreferenceItem.TrackerPreference -> {
val context = LocalContext.current
LaunchedEffect(item.tracker) {
item.tracker.refreshResultFlow.collect {
when (it) {
RefreshResult.Success -> context.toast(
context.stringResource(MR.strings.refresh_tracker_success, item.tracker.name),
)
is RefreshResult.Error -> context.toast(
context.stringResource(MR.strings.refresh_tracker_error, item.tracker.name, it.msg),
)
}
}
}
val isLoggedIn by item.tracker.let { tracker ->
tracker.isLoggedInFlow.collectAsState(tracker.isLoggedIn)
}
val isRefreshing by item.tracker.isRefreshingFlow.collectAsState()
TrackingPreferenceWidget(
tracker = item.tracker,
isLoggedIn = isLoggedIn,
isRefreshing = isRefreshing,
onClick = { if (isLoggedIn) item.logout() else item.login() },
)
}
@@ -50,11 +50,14 @@ fun PreferenceScreen(
when (preference) {
// Create Preference Group
is Preference.PreferenceGroup -> {
if (!preference.enabled) return@fastForEachIndexed
if (!preference.visible) return@fastForEachIndexed
item {
Column {
PreferenceGroupHeader(title = preference.title)
PreferenceGroupHeader(
title = preference.title,
highlighted = preference.title == highlightKey,
)
}
}
items(preference.preferenceItems) { item ->
@@ -86,7 +89,7 @@ private fun List<Preference>.findHighlightedIndex(highlightKey: String): Int {
return flatMap {
if (it is Preference.PreferenceGroup) {
buildList<String?> {
add(null) // Header
add(it.title) // Header
addAll(it.preferenceItems.map { groupItem -> groupItem.title })
add(null) // Spacer
}
@@ -26,7 +26,7 @@ import eu.kanade.domain.base.BasePreferences
import eu.kanade.presentation.more.settings.Preference
import eu.kanade.presentation.more.settings.screen.advanced.ClearDatabaseScreen
import eu.kanade.presentation.more.settings.screen.debug.DebugInfoScreen
import eu.kanade.tachiyomi.data.library.MetadataUpdateJob
import eu.kanade.tachiyomi.data.library.MetadataUpdateWorker
import eu.kanade.tachiyomi.network.NetworkPreferences
import eu.kanade.tachiyomi.network.PREF_DOH_360
import eu.kanade.tachiyomi.network.PREF_DOH_ADGUARD
@@ -47,12 +47,12 @@ import eu.kanade.tachiyomi.util.system.powerManager
import eu.kanade.tachiyomi.util.system.setDefaultSettings
import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.system.workManager
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import logcat.LogPriority
import mihon.app.di.appGraph
import okhttp3.Headers
import tachiyomi.core.common.util.lang.launchNonCancellable
import tachiyomi.core.common.util.lang.withUIContext
import tachiyomi.core.common.util.system.logcat
import tachiyomi.domain.library.service.LibraryPreferences
import tachiyomi.i18n.MR
@@ -193,6 +193,7 @@ object SettingsAdvancedScreen : SearchableSettings {
): Preference.PreferenceGroup {
val context = LocalContext.current
val networkHelper = remember { context.appGraph.networkHelper }
val scope = rememberCoroutineScope()
val userAgentPref = networkPreferences.defaultUserAgent
val userAgent by userAgentPref.collectAsState()
@@ -219,8 +220,10 @@ object SettingsAdvancedScreen : SearchableSettings {
clearSslPreferences()
}
WebStorage.getInstance().deleteAllData()
scope.launch(Dispatchers.IO) {
context.applicationInfo?.dataDir?.let { File("$it/app_webview/").deleteRecursively() }
context.toast(MR.strings.webview_data_deleted)
withContext(Dispatchers.Main) { context.toast(MR.strings.webview_data_deleted) }
}
} catch (e: Throwable) {
logcat(LogPriority.ERROR, e)
context.toast(MR.strings.cache_delete_error)
@@ -267,7 +270,7 @@ object SettingsAdvancedScreen : SearchableSettings {
),
Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.pref_reset_user_agent_string),
enabled = remember(userAgent) { userAgent != userAgentPref.defaultValue() },
visible = remember(userAgent) { userAgent != userAgentPref.defaultValue() },
onClick = {
userAgentPref.delete()
context.toast(MR.strings.requires_app_restart)
@@ -289,15 +292,14 @@ object SettingsAdvancedScreen : SearchableSettings {
preferenceItems = listOf(
Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.pref_refresh_library_covers),
onClick = { MetadataUpdateJob.startNow(context.workManager) },
onClick = { scope.launch { MetadataUpdateWorker.startNow(context.workManager) } },
),
Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.pref_reset_viewer_flags),
subtitle = stringResource(MR.strings.pref_reset_viewer_flags_summary),
onClick = {
scope.launchNonCancellable {
scope.launch {
val success = context.appGraph.resetViewerFlags.await()
withUIContext {
val message = if (success) {
MR.strings.pref_reset_viewer_flags_success
} else {
@@ -305,7 +307,6 @@ object SettingsAdvancedScreen : SearchableSettings {
}
context.toast(message)
}
}
},
),
Preference.PreferenceItem.SwitchPreference(
@@ -318,6 +319,11 @@ object SettingsAdvancedScreen : SearchableSettings {
title = stringResource(MR.strings.pref_disallow_non_ascii_filenames),
subtitle = stringResource(MR.strings.pref_disallow_non_ascii_filenames_details),
),
Preference.PreferenceItem.SwitchPreference(
preference = libraryPreferences.enableChapterNameHash,
title = stringResource(MR.strings.pref_enable_chapter_name_hash),
subtitle = stringResource(MR.strings.pref_enable_chapter_name_hash_details),
),
),
)
}
@@ -85,7 +85,7 @@ object SettingsAppearanceScreen : SearchableSettings {
Preference.PreferenceItem.SwitchPreference(
preference = amoledPref,
title = stringResource(MR.strings.pref_dark_theme_pure_black),
enabled = themeMode != ThemeMode.LIGHT,
visible = themeMode != ThemeMode.LIGHT,
onValueChanged = {
(context as? Activity)?.let { ActivityCompat.recreate(it) }
true
@@ -28,6 +28,7 @@ import androidx.compose.runtime.ReadOnlyComposable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.produceState
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue
@@ -46,23 +47,23 @@ import eu.kanade.presentation.more.settings.screen.data.StorageInfo
import eu.kanade.presentation.more.settings.widget.BasePreferenceWidget
import eu.kanade.presentation.more.settings.widget.PrefsHorizontalPadding
import eu.kanade.presentation.util.relativeTimeSpanString
import eu.kanade.tachiyomi.data.backup.create.BackupCreateJob
import eu.kanade.tachiyomi.data.backup.restore.BackupRestoreJob
import eu.kanade.tachiyomi.data.backup.create.BackupCreateWorker
import eu.kanade.tachiyomi.data.backup.restore.BackupRestoreWorker
import eu.kanade.tachiyomi.data.export.LibraryExporter
import eu.kanade.tachiyomi.data.export.LibraryExporter.ExportOptions
import eu.kanade.tachiyomi.util.system.DeviceUtil
import eu.kanade.tachiyomi.util.system.toast
import eu.kanade.tachiyomi.util.system.workManager
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import logcat.LogPriority
import mihon.app.di.appGraph
import mihon.icons.materialsymbols.MaterialSymbols
import mihon.icons.materialsymbols.automirroredrounded.Help
import tachiyomi.core.common.i18n.stringResource
import tachiyomi.core.common.storage.displayablePath
import tachiyomi.core.common.util.lang.launchNonCancellable
import tachiyomi.core.common.util.lang.withUIContext
import tachiyomi.core.common.util.system.logcat
import tachiyomi.domain.backup.service.BackupPreferences
import tachiyomi.domain.manga.model.Manga
@@ -181,6 +182,7 @@ object SettingsDataScreen : SearchableSettings {
private fun getBackupAndRestoreGroup(backupPreferences: BackupPreferences): Preference.PreferenceGroup {
val context = LocalContext.current
val navigator = LocalNavigator.currentOrThrow
val scope = rememberCoroutineScope()
val lastAutoBackup by backupPreferences.lastAutoBackupTimestamp.collectAsState()
@@ -231,7 +233,8 @@ object SettingsDataScreen : SearchableSettings {
modifier = Modifier.fillMaxHeight(),
checked = false,
onCheckedChange = {
if (!BackupRestoreJob.isRunning(context.workManager)) {
scope.launch {
if (!BackupRestoreWorker.isRunning(context.workManager)) {
if (DeviceUtil.isMiui && DeviceUtil.isMiuiOptimizationDisabled()) {
context.toast(MR.strings.restore_miui_warning)
}
@@ -239,6 +242,7 @@ object SettingsDataScreen : SearchableSettings {
} else {
context.toast(MR.strings.restore_in_progress)
}
}
},
shape = SegmentedButtonDefaults.itemShape(1, 2),
) {
@@ -262,7 +266,7 @@ object SettingsDataScreen : SearchableSettings {
),
title = stringResource(MR.strings.pref_backup_interval),
onValueChanged = {
BackupCreateJob.setupTask(context, it)
BackupCreateWorker.setupTask(context, it)
true
},
),
@@ -282,7 +286,9 @@ object SettingsDataScreen : SearchableSettings {
val chapterCache = remember { context.appGraph.chapterCache }
var cacheReadableSizeSema by remember { mutableIntStateOf(0) }
val cacheReadableSize = remember(cacheReadableSizeSema) { chapterCache.readableSize }
val cacheReadableSize by produceState("", cacheReadableSizeSema) {
value = withContext(Dispatchers.IO) { chapterCache.readableSize }
}
return Preference.PreferenceGroup(
title = stringResource(MR.strings.pref_storage_usage),
@@ -303,16 +309,15 @@ object SettingsDataScreen : SearchableSettings {
title = stringResource(MR.strings.pref_clear_chapter_cache),
subtitle = stringResource(MR.strings.used_cache, cacheReadableSize),
onClick = {
scope.launchNonCancellable {
scope.launch {
try {
val deletedFiles = chapterCache.clear()
withUIContext {
val deletedFiles = withContext(Dispatchers.IO) { chapterCache.clear() }
context.toast(context.stringResource(MR.strings.cache_deleted, deletedFiles))
cacheReadableSizeSema++
}
} catch (e: Throwable) {
} catch (e: Exception) {
if (e is CancellationException) throw e
logcat(LogPriority.ERROR, e)
withUIContext { context.toast(MR.strings.cache_delete_error) }
context.toast(MR.strings.cache_delete_error)
}
}
},
@@ -34,8 +34,6 @@ object SettingsDownloadScreen : SearchableSettings {
val allCategories by getCategories.subscribe().collectAsState(initial = emptyList())
val downloadPreferences = remember { context.appGraph.downloadPreferences }
val parallelSourceLimit by downloadPreferences.parallelSourceLimit.collectAsState()
val parallelPageLimit by downloadPreferences.parallelPageLimit.collectAsState()
return listOf(
Preference.PreferenceItem.SwitchPreference(
preference = downloadPreferences.downloadOnlyOverWifi,
@@ -51,17 +49,15 @@ object SettingsDownloadScreen : SearchableSettings {
subtitle = stringResource(MR.strings.split_tall_images_summary),
),
Preference.PreferenceItem.SliderPreference(
value = parallelSourceLimit,
preference = downloadPreferences.parallelSourceLimit,
valueRange = 1..10,
title = stringResource(MR.strings.pref_download_concurrent_sources),
onValueChanged = { downloadPreferences.parallelSourceLimit.set(it) },
),
Preference.PreferenceItem.SliderPreference(
value = parallelPageLimit,
preference = downloadPreferences.parallelPageLimit,
valueRange = 1..15,
title = stringResource(MR.strings.pref_download_concurrent_pages),
subtitle = stringResource(MR.strings.pref_download_concurrent_pages_summary),
onValueChanged = { downloadPreferences.parallelPageLimit.set(it) },
),
getDeleteChaptersGroup(
downloadPreferences = downloadPreferences,
@@ -166,7 +162,7 @@ object SettingsDownloadScreen : SearchableSettings {
Preference.PreferenceItem.SwitchPreference(
preference = downloadNewUnreadChaptersOnlyPref,
title = stringResource(MR.strings.pref_download_new_unread_chapters_only),
enabled = downloadNewChapters,
visible = downloadNewChapters,
),
Preference.PreferenceItem.TextPreference(
title = stringResource(MR.strings.categories),
@@ -175,7 +171,7 @@ object SettingsDownloadScreen : SearchableSettings {
included = included,
excluded = excluded,
),
enabled = downloadNewChapters,
visible = downloadNewChapters,
onClick = { showDialog = true },
),
),
@@ -18,7 +18,7 @@ import cafe.adriel.voyager.navigator.currentOrThrow
import eu.kanade.presentation.category.visualName
import eu.kanade.presentation.more.settings.Preference
import eu.kanade.presentation.more.settings.widget.TriStateListDialog
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
import eu.kanade.tachiyomi.data.library.LibraryUpdateWorker
import eu.kanade.tachiyomi.ui.category.CategoryScreen
import kotlinx.coroutines.launch
import mihon.app.di.appGraph
@@ -155,7 +155,7 @@ object SettingsLibraryScreen : SearchableSettings {
),
title = stringResource(MR.strings.pref_library_update_interval),
onValueChanged = {
LibraryUpdateJob.setupTask(context, it)
LibraryUpdateWorker.setupTask(context, it)
true
},
),
@@ -168,11 +168,11 @@ object SettingsLibraryScreen : SearchableSettings {
),
title = stringResource(MR.strings.pref_library_update_restriction),
subtitle = stringResource(MR.strings.restrictions),
enabled = autoUpdateInterval > 0,
visible = autoUpdateInterval > 0,
onValueChanged = {
// Post to event looper to allow the preference to be updated.
ContextCompat.getMainExecutor(context).execute {
LibraryUpdateJob.setupTask(context)
LibraryUpdateWorker.setupTask(context)
}
true
},

Some files were not shown because too many files have changed in this diff Show More