From 963e125d64a13d43a64ebaca213104c1b4082c43 Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 7 Apr 2020 00:34:23 -0400 Subject: [PATCH] Fixing #178 and adding #171 --- .../main/java/eu/kanade/tachiyomi/data/track/TrackService.kt | 2 ++ .../java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt | 2 ++ .../java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt | 2 ++ .../main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt | 2 ++ .../kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt | 5 ++++- .../eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt | 2 ++ .../eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt | 2 ++ 7 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt index e8a2930ff7..8306b849f6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt @@ -27,6 +27,8 @@ abstract class TrackService(val id: Int) { abstract fun getStatusList(): List + abstract fun isCompletedStatus(index: Int): Boolean + abstract fun getStatus(status: Int): String abstract fun getScoreList(): List diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt index 12ba91ed65..e5849ce7b3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/anilist/Anilist.kt @@ -38,6 +38,8 @@ class Anilist(private val context: Context, id: Int) : TrackService(id) { override fun getStatusList() = listOf(READING, PLANNING, COMPLETED, REPEATING, PAUSED, DROPPED) + override fun isCompletedStatus(index: Int) = getStatusList()[index] == COMPLETED + override fun getStatus(status: Int): String = with(context) { when (status) { READING -> getString(R.string.reading) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt index 72e69bf80b..3bc3231ec5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/bangumi/Bangumi.kt @@ -76,6 +76,8 @@ class Bangumi(private val context: Context, id: Int) : TrackService(id) { return listOf(READING, COMPLETED, ON_HOLD, DROPPED, PLANNING) } + override fun isCompletedStatus(index: Int) = getStatusList()[index] == COMPLETED + override fun getStatus(status: Int): String = with(context) { when (status) { READING -> getString(R.string.reading) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt index 5a055380ff..c73999fe96 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/kitsu/Kitsu.kt @@ -44,6 +44,8 @@ class Kitsu(private val context: Context, id: Int) : TrackService(id) { return listOf(READING, PLAN_TO_READ, COMPLETED, ON_HOLD, DROPPED) } + override fun isCompletedStatus(index: Int) = getStatusList()[index] == COMPLETED + override fun getStatus(status: Int): String = with(context) { when (status) { READING -> getString(R.string.currently_reading) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt index 9e235a2780..0fe9b2484a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt @@ -36,6 +36,8 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) { return listOf(READING, COMPLETED, ON_HOLD, DROPPED, PLAN_TO_READ) } + override fun isCompletedStatus(index: Int) = getStatusList()[index] == COMPLETED + override fun getScoreList(): List { return IntRange(0, 10).map(Int::toString) } @@ -121,7 +123,8 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) { networkService.cookieManager.remove(BASE_URL.toHttpUrlOrNull()!!) } - private val isAuthorized = super.isLogged && getCSRF().isNotEmpty() && checkCookies() + private val isAuthorized: Boolean + get() = super.isLogged && getCSRF().isNotEmpty() && checkCookies() fun getCSRF(): String = preferences.trackToken(this).getOrDefault() diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt index 1c6b3e5cdf..0896f22801 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/shikimori/Shikimori.kt @@ -27,6 +27,8 @@ class Shikimori(private val context: Context, id: Int) : TrackService(id) { return listOf(READING, COMPLETED, ON_HOLD, DROPPED, PLANNING, REPEATING) } + override fun isCompletedStatus(index: Int) = getStatusList()[index] == COMPLETED + override fun getStatus(status: Int): String = with(context) { when (status) { READING -> getString(R.string.reading) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt index e0054247e7..ed70804b3e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaDetailsPresenter.kt @@ -821,6 +821,8 @@ class MangaDetailsPresenter( fun setStatus(item: TrackItem, index: Int) { val track = item.track!! track.status = item.service.getStatusList()[index] + if (item.service.isCompletedStatus(index) && track.total_chapters > 0) + track.last_chapter_read = track.total_chapters updateRemote(track, item.service) }