From c6a51d4d083ae734eee92128f4bb6f691e27b232 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sun, 19 Jan 2025 11:56:26 +0200 Subject: [PATCH 1/8] Increase version --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 83f5400a7..64d1ab304 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,8 +18,8 @@ android { applicationId 'org.koitharu.kotatsu' minSdk = 21 targetSdk = 35 - versionCode = 699 - versionName = '7.7.7' + versionCode = 700 + versionName = '7.7.8' generatedDensities = [] testInstrumentationRunner 'org.koitharu.kotatsu.HiltTestRunner' ksp { From b425f3e779e5683c2f579c7dd3a8e3b651bd65a6 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sun, 19 Jan 2025 11:55:13 +0200 Subject: [PATCH 2/8] Fix nullability for ParcelableManga (cherry picked from commit b8b601821a57deff04ed2301989b9dfcc9c91325) --- .../kotatsu/core/model/parcelable/ParcelableManga.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/model/parcelable/ParcelableManga.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/model/parcelable/ParcelableManga.kt index 08f644280..58b28adde 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/model/parcelable/ParcelableManga.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/model/parcelable/ParcelableManga.kt @@ -2,7 +2,6 @@ package org.koitharu.kotatsu.core.model.parcelable import android.os.Parcel import android.os.Parcelable -import androidx.core.os.ParcelCompat import kotlinx.parcelize.Parceler import kotlinx.parcelize.Parcelize import org.koitharu.kotatsu.core.model.MangaSource @@ -25,7 +24,7 @@ data class ParcelableManga( parcel.writeString(url) parcel.writeString(publicUrl) parcel.writeFloat(rating) - ParcelCompat.writeBoolean(parcel, isNsfw) + parcel.writeSerializable(contentRating) parcel.writeString(coverUrl) parcel.writeString(largeCoverUrl) parcel.writeString(description.takeIf { withDescription }) @@ -43,8 +42,8 @@ data class ParcelableManga( url = requireNotNull(parcel.readString()), publicUrl = requireNotNull(parcel.readString()), rating = parcel.readFloat(), - isNsfw = ParcelCompat.readBoolean(parcel), - coverUrl = requireNotNull(parcel.readString()), + contentRating = parcel.readSerializableCompat(), + coverUrl = parcel.readString(), largeCoverUrl = parcel.readString(), description = parcel.readString(), tags = requireNotNull(parcel.readParcelableCompat()).tags, From 15e99c03a902c3d27cb61adf97fc1bf47a98a997 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sun, 19 Jan 2025 11:53:38 +0200 Subject: [PATCH 3/8] Update parsers and adjust imports (cherry picked from commit 5e8aa4cec720839fc64001e8b7b97693b38abecc) --- .../domain/AlternativesUseCase.kt | 2 +- .../kotatsu/core/db/entity/EntityMapping.kt | 2 +- .../koitharu/kotatsu/core/github/VersionId.kt | 2 +- .../core/network/cookies/AndroidCookieJar.kt | 2 +- .../imageproxy/BaseImageProxyInterceptor.kt | 2 +- .../kotatsu/core/parser/MangaLinkResolver.kt | 2 +- .../external/ExternalPluginContentSource.kt | 3 +- .../kotatsu/core/prefs/SourceSettings.kt | 2 +- .../kotatsu/core/util/ext/Collections.kt | 22 ------- .../koitharu/kotatsu/core/util/ext/Http.kt | 28 --------- .../kotatsu/core/util/ext/LocaleList.kt | 1 + .../kotatsu/core/util/ext/Primitive.kt | 5 -- .../koitharu/kotatsu/core/util/ext/String.kt | 59 ++++++++++--------- .../kotatsu/core/util/ext/Throwable.kt | 1 + .../kotatsu/details/ui/DetailsActivity.kt | 2 +- .../ui/dialog/DownloadDialogFragment.kt | 2 +- .../ui/dialog/DownloadDialogViewModel.kt | 2 +- .../download/ui/worker/DownloadWorker.kt | 2 +- .../explore/domain/ExploreRepository.kt | 4 +- .../explore/ui/model/MangaSourceItem.kt | 2 +- .../list/ui/preview/PreviewFragment.kt | 2 +- .../koitharu/kotatsu/local/data/PagesCache.kt | 3 +- .../local/data/input/LocalMangaParser.kt | 4 +- .../local/data/output/LocalMangaDirOutput.kt | 6 +- .../local/data/output/LocalMangaOutput.kt | 2 +- .../main/domain/CoverRestoreInterceptor.kt | 2 +- .../kotatsu/reader/ui/PageSaveHelper.kt | 2 +- .../kotatsu/reader/ui/ReaderViewModel.kt | 4 +- .../reader/ui/config/ImageServerDelegate.kt | 2 +- .../remotelist/ui/RemoteListViewModel.kt | 2 +- .../suggestion/SearchSuggestionViewModel.kt | 2 +- .../settings/about/AboutSettingsFragment.kt | 12 ++-- .../settings/about/AboutSettingsViewModel.kt | 9 ++- .../settings/sources/SourceSettingsExt.kt | 26 ++++---- .../utils/EditTextDefaultSummaryProvider.kt | 2 +- .../suggestions/domain/TagsBlacklist.kt | 2 +- .../suggestions/ui/SuggestionsWorker.kt | 4 +- .../kotatsu/sync/data/SyncSettings.kt | 2 +- .../kotatsu/sync/ui/SyncHostDialogFragment.kt | 2 +- .../tracker/domain/TrackingRepository.kt | 2 +- .../tracker/domain/model/MangaUpdates.kt | 2 +- gradle/libs.versions.toml | 2 +- 42 files changed, 99 insertions(+), 144 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/alternatives/domain/AlternativesUseCase.kt b/app/src/main/kotlin/org/koitharu/kotatsu/alternatives/domain/AlternativesUseCase.kt index e822efbbd..969e61c4c 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/alternatives/domain/AlternativesUseCase.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/alternatives/domain/AlternativesUseCase.kt @@ -8,13 +8,13 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.sync.Semaphore import kotlinx.coroutines.sync.withPermit import org.koitharu.kotatsu.core.parser.MangaRepository -import org.koitharu.kotatsu.core.util.ext.almostEquals import org.koitharu.kotatsu.explore.data.MangaSourcesRepository import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.model.MangaListFilter import org.koitharu.kotatsu.parsers.model.MangaParserSource import org.koitharu.kotatsu.parsers.model.MangaSource import org.koitharu.kotatsu.parsers.model.SortOrder +import org.koitharu.kotatsu.parsers.util.almostEquals import org.koitharu.kotatsu.parsers.util.runCatchingCancellable import javax.inject.Inject diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/db/entity/EntityMapping.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/db/entity/EntityMapping.kt index 55a5cf020..eda091c30 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/db/entity/EntityMapping.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/db/entity/EntityMapping.kt @@ -1,11 +1,11 @@ package org.koitharu.kotatsu.core.db.entity import org.koitharu.kotatsu.core.model.MangaSource -import org.koitharu.kotatsu.core.util.ext.longHashCode import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.model.MangaState import org.koitharu.kotatsu.parsers.model.MangaTag import org.koitharu.kotatsu.parsers.model.SortOrder +import org.koitharu.kotatsu.parsers.util.longHashCode import org.koitharu.kotatsu.parsers.util.mapToSet import org.koitharu.kotatsu.parsers.util.toTitleCase diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/github/VersionId.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/github/VersionId.kt index 9426401ae..bca961ea6 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/github/VersionId.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/github/VersionId.kt @@ -1,6 +1,6 @@ package org.koitharu.kotatsu.core.github -import org.koitharu.kotatsu.core.util.ext.digits +import org.koitharu.kotatsu.parsers.util.digits import java.util.Locale data class VersionId( diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/network/cookies/AndroidCookieJar.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/network/cookies/AndroidCookieJar.kt index 9c1d2afe2..773c63c2d 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/network/cookies/AndroidCookieJar.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/network/cookies/AndroidCookieJar.kt @@ -5,7 +5,7 @@ import androidx.annotation.WorkerThread import androidx.core.util.Predicate import okhttp3.Cookie import okhttp3.HttpUrl -import org.koitharu.kotatsu.core.util.ext.newBuilder +import org.koitharu.kotatsu.parsers.util.newBuilder import kotlin.coroutines.resume import kotlin.coroutines.suspendCoroutine diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/network/imageproxy/BaseImageProxyInterceptor.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/network/imageproxy/BaseImageProxyInterceptor.kt index ce7451008..40eb78385 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/network/imageproxy/BaseImageProxyInterceptor.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/network/imageproxy/BaseImageProxyInterceptor.kt @@ -17,8 +17,8 @@ import org.jsoup.HttpStatusException import org.koitharu.kotatsu.BuildConfig import org.koitharu.kotatsu.core.exceptions.CloudFlareBlockedException import org.koitharu.kotatsu.core.util.ext.ensureSuccess -import org.koitharu.kotatsu.core.util.ext.isHttpOrHttps import org.koitharu.kotatsu.parsers.util.await +import org.koitharu.kotatsu.parsers.util.isHttpOrHttps import org.koitharu.kotatsu.parsers.util.runCatchingCancellable import java.net.HttpURLConnection import java.util.Collections diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/parser/MangaLinkResolver.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/parser/MangaLinkResolver.kt index c831b1623..7a94fcf2f 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/parser/MangaLinkResolver.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/parser/MangaLinkResolver.kt @@ -6,13 +6,13 @@ import dagger.Reusable import org.koitharu.kotatsu.core.model.MangaSource import org.koitharu.kotatsu.core.model.UnknownMangaSource import org.koitharu.kotatsu.core.model.isNsfw -import org.koitharu.kotatsu.core.util.ext.ifNullOrEmpty import org.koitharu.kotatsu.parsers.MangaLoaderContext import org.koitharu.kotatsu.parsers.exception.NotFoundException import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.model.MangaListFilter import org.koitharu.kotatsu.parsers.model.MangaSource import org.koitharu.kotatsu.parsers.util.almostEquals +import org.koitharu.kotatsu.parsers.util.ifNullOrEmpty import org.koitharu.kotatsu.parsers.util.levenshteinDistance import org.koitharu.kotatsu.parsers.util.runCatchingCancellable import javax.inject.Inject diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/parser/external/ExternalPluginContentSource.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/parser/external/ExternalPluginContentSource.kt index f59514e90..743a96401 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/parser/external/ExternalPluginContentSource.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/parser/external/ExternalPluginContentSource.kt @@ -7,8 +7,6 @@ import androidx.collection.ArraySet import androidx.core.net.toUri import org.jetbrains.annotations.Blocking import org.koitharu.kotatsu.core.exceptions.IncompatiblePluginException -import org.koitharu.kotatsu.core.util.ext.ifNullOrEmpty -import org.koitharu.kotatsu.parsers.exception.NotFoundException import org.koitharu.kotatsu.parsers.model.ContentRating import org.koitharu.kotatsu.parsers.model.ContentType import org.koitharu.kotatsu.parsers.model.Demographic @@ -22,6 +20,7 @@ import org.koitharu.kotatsu.parsers.model.MangaState import org.koitharu.kotatsu.parsers.model.MangaTag import org.koitharu.kotatsu.parsers.model.SortOrder import org.koitharu.kotatsu.parsers.util.find +import org.koitharu.kotatsu.parsers.util.ifNullOrEmpty import org.koitharu.kotatsu.parsers.util.mapNotNullToSet import org.koitharu.kotatsu.parsers.util.splitTwoParts import java.util.EnumSet diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/SourceSettings.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/SourceSettings.kt index 0f491099d..6e3425ffa 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/SourceSettings.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/prefs/SourceSettings.kt @@ -4,13 +4,13 @@ import android.content.Context import android.content.SharedPreferences.OnSharedPreferenceChangeListener import androidx.core.content.edit import org.koitharu.kotatsu.core.util.ext.getEnumValue -import org.koitharu.kotatsu.core.util.ext.ifNullOrEmpty import org.koitharu.kotatsu.core.util.ext.putEnumValue import org.koitharu.kotatsu.core.util.ext.sanitizeHeaderValue import org.koitharu.kotatsu.parsers.config.ConfigKey import org.koitharu.kotatsu.parsers.config.MangaSourceConfig import org.koitharu.kotatsu.parsers.model.MangaSource import org.koitharu.kotatsu.parsers.model.SortOrder +import org.koitharu.kotatsu.parsers.util.ifNullOrEmpty import org.koitharu.kotatsu.parsers.util.nullIfEmpty import org.koitharu.kotatsu.settings.utils.validation.DomainValidator diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Collections.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Collections.kt index a7455af10..a677c9409 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Collections.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Collections.kt @@ -4,21 +4,8 @@ import androidx.collection.ArrayMap import androidx.collection.ArraySet import androidx.collection.LongSet import org.koitharu.kotatsu.BuildConfig -import java.util.Collections import java.util.EnumSet -inline fun MutableSet(size: Int, init: (index: Int) -> T): MutableSet { - val set = ArraySet(size) - repeat(size) { index -> set.add(init(index)) } - return set -} - -inline fun Set(size: Int, init: (index: Int) -> T): Set = when (size) { - 0 -> emptySet() - 1 -> Collections.singleton(init(0)) - else -> MutableSet(size, init) -} - fun Collection.asArrayList(): ArrayList = if (this is ArrayList<*>) { this as ArrayList } else { @@ -76,15 +63,6 @@ fun Iterable.sortedWithSafe(comparator: Comparator): List = try } } -fun Collection<*>?.sizeOrZero() = this?.size ?: 0 - -@Suppress("UNCHECKED_CAST") -inline fun Collection.mapToArray(transform: (T) -> R): Array { - val result = arrayOfNulls(size) - forEachIndexed { index, t -> result[index] = transform(t) } - return result as Array -} - fun LongSet.toLongArray(): LongArray { val result = LongArray(size) var i = 0 diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Http.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Http.kt index 5d384ba88..1c7151e17 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Http.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Http.kt @@ -1,7 +1,5 @@ package org.koitharu.kotatsu.core.util.ext -import okhttp3.Cookie -import okhttp3.HttpUrl import okhttp3.MediaType.Companion.toMediaType import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.Response @@ -27,12 +25,6 @@ fun Response.parseJsonOrNull(): JSONObject? { } } -val HttpUrl.isHttpOrHttps: Boolean - get() { - val s = scheme.lowercase() - return s == "https" || s == "http" - } - fun Response.ensureSuccess() = apply { if (!isSuccessful || code == HttpURLConnection.HTTP_NO_CONTENT) { closeQuietly() @@ -40,26 +32,6 @@ fun Response.ensureSuccess() = apply { } } -fun Cookie.newBuilder(): Cookie.Builder = Cookie.Builder().also { c -> - c.name(name) - c.value(value) - if (persistent) { - c.expiresAt(expiresAt) - } - if (hostOnly) { - c.hostOnlyDomain(domain) - } else { - c.domain(domain) - } - c.path(path) - if (secure) { - c.secure() - } - if (httpOnly) { - c.httpOnly() - } -} - fun String.sanitizeHeaderValue(): String { return if (all(Char::isValidForHeaderValue)) { this // fast path diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/LocaleList.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/LocaleList.kt index e9b69a6c7..8a500b026 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/LocaleList.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/LocaleList.kt @@ -3,6 +3,7 @@ package org.koitharu.kotatsu.core.util.ext import android.content.Context import androidx.core.os.LocaleListCompat import org.koitharu.kotatsu.R +import org.koitharu.kotatsu.parsers.util.Set import org.koitharu.kotatsu.parsers.util.toTitleCase import java.util.Locale diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Primitive.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Primitive.kt index 78ba499fc..5b99e0d86 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Primitive.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Primitive.kt @@ -1,7 +1,2 @@ package org.koitharu.kotatsu.core.util.ext -inline fun Long.ifZero(defaultValue: () -> Long): Long = if (this == 0L) defaultValue() else this - -fun longOf(a: Int, b: Int): Long { - return a.toLong() shl 32 or (b.toLong() and 0xffffffffL) -} diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/String.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/String.kt index dfc16562e..8e3acc264 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/String.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/String.kt @@ -2,25 +2,11 @@ package org.koitharu.kotatsu.core.util.ext import android.content.Context import android.database.DatabaseUtils -import androidx.annotation.FloatRange +import androidx.collection.arraySetOf import org.koitharu.kotatsu.R import org.koitharu.kotatsu.parsers.util.ellipsize -import org.koitharu.kotatsu.parsers.util.levenshteinDistance import java.util.UUID -inline fun C?.ifNullOrEmpty(defaultValue: () -> R): R { - return if (this.isNullOrEmpty()) defaultValue() else this -} - -fun String.longHashCode(): Long { - var h = 1125899906842597L - val len: Int = this.length - for (i in 0 until len) { - h = 31 * h + this[i].code - } - return h -} - fun String.toUUIDOrNull(): UUID? = try { UUID.fromString(this) } catch (e: IllegalArgumentException) { @@ -28,19 +14,35 @@ fun String.toUUIDOrNull(): UUID? = try { null } -fun String.digits() = filter { it.isDigit() } - -/** - * @param threshold 0 = exact match - */ -fun String.almostEquals(other: String, @FloatRange(from = 0.0) threshold: Float): Boolean { - if (threshold == 0f) { - return equals(other, ignoreCase = true) +fun String.transliterate(skipMissing: Boolean): String { + val cyr = charArrayOf( + 'а', 'б', 'в', 'г', 'д', 'е', 'ж', 'з', 'и', 'й', 'к', 'л', 'м', 'н', 'о', 'п', + 'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'щ', 'ъ', 'ы', 'ь', 'э', 'ю', 'я', 'ё', 'ў', + ) + val lat = arrayOf( + "a", "b", "v", "g", "d", "e", "zh", "z", "i", "y", "k", "l", "m", "n", "o", "p", + "r", "s", "t", "u", "f", "h", "ts", "ch", "sh", "sch", "", "i", "", "e", "ju", "ja", "jo", "w", + ) + return buildString(length + 5) { + for (c in this@transliterate) { + val p = cyr.binarySearch(c.lowercaseChar()) + if (p in lat.indices) { + if (c.isUpperCase()) { + append(lat[p].uppercase()) + } else { + append(lat[p]) + } + } else if (!skipMissing) { + append(c) + } + } } - val diff = lowercase().levenshteinDistance(other.lowercase()) / ((length + other.length) / 2f) - return diff < threshold } +fun String.toFileNameSafe(): String = this.transliterate(false) + .replace(Regex("[^a-z0-9_\\-]", arraySetOf(RegexOption.IGNORE_CASE)), " ") + .replace(Regex("\\s+"), "_") + fun CharSequence.sanitize(): CharSequence { return filterNot { c -> c.isReplacement() } } @@ -68,10 +70,11 @@ fun Collection.joinToStringWithLimit(context: Context, limit: Int, transf } } -@Deprecated("", +@Deprecated( + "", ReplaceWith( "sqlEscapeString(this)", - "android.database.DatabaseUtils.sqlEscapeString" - ) + "android.database.DatabaseUtils.sqlEscapeString", + ), ) fun String.sqlEscape(): String = DatabaseUtils.sqlEscapeString(this) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Throwable.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Throwable.kt index c201853cf..826d6d94d 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Throwable.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/ext/Throwable.kt @@ -38,6 +38,7 @@ import org.koitharu.kotatsu.parsers.exception.ContentUnavailableException import org.koitharu.kotatsu.parsers.exception.NotFoundException import org.koitharu.kotatsu.parsers.exception.ParseException import org.koitharu.kotatsu.parsers.exception.TooManyRequestExceptions +import org.koitharu.kotatsu.parsers.util.ifNullOrEmpty import org.koitharu.kotatsu.scrobbling.common.domain.ScrobblerAuthRequiredException import java.io.ObjectOutputStream import java.net.ConnectException diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt index 5da9cba05..4578a164a 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/details/ui/DetailsActivity.kt @@ -77,7 +77,6 @@ import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.drawable import org.koitharu.kotatsu.core.util.ext.enqueueWith import org.koitharu.kotatsu.core.util.ext.getThemeColor -import org.koitharu.kotatsu.core.util.ext.ifNullOrEmpty import org.koitharu.kotatsu.core.util.ext.isTextTruncated import org.koitharu.kotatsu.core.util.ext.joinToStringWithLimit import org.koitharu.kotatsu.core.util.ext.mangaSourceExtra @@ -113,6 +112,7 @@ import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.model.MangaListFilter import org.koitharu.kotatsu.parsers.model.MangaTag import org.koitharu.kotatsu.parsers.util.ellipsize +import org.koitharu.kotatsu.parsers.util.ifNullOrEmpty import org.koitharu.kotatsu.reader.ui.ReaderActivity import org.koitharu.kotatsu.scrobbling.common.domain.model.ScrobblingInfo import org.koitharu.kotatsu.scrobbling.common.ui.selector.ScrobblingSelectorSheet diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/dialog/DownloadDialogFragment.kt b/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/dialog/DownloadDialogFragment.kt index e0f6cee7c..76ce31f9a 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/dialog/DownloadDialogFragment.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/dialog/DownloadDialogFragment.kt @@ -27,7 +27,6 @@ import org.koitharu.kotatsu.core.ui.widgets.TwoLinesItemView import org.koitharu.kotatsu.core.util.ext.findActivity import org.koitharu.kotatsu.core.util.ext.getDisplayMessage import org.koitharu.kotatsu.core.util.ext.joinToStringWithLimit -import org.koitharu.kotatsu.core.util.ext.mapToArray import org.koitharu.kotatsu.core.util.ext.observe import org.koitharu.kotatsu.core.util.ext.observeEvent import org.koitharu.kotatsu.core.util.ext.parentView @@ -39,6 +38,7 @@ import org.koitharu.kotatsu.download.ui.list.DownloadsActivity import org.koitharu.kotatsu.main.ui.owners.BottomNavOwner import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.util.format +import org.koitharu.kotatsu.parsers.util.mapToArray import org.koitharu.kotatsu.settings.storage.DirectoryModel import javax.inject.Inject diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/dialog/DownloadDialogViewModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/dialog/DownloadDialogViewModel.kt index 6dd2ebf06..97a69844a 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/dialog/DownloadDialogViewModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/dialog/DownloadDialogViewModel.kt @@ -21,7 +21,6 @@ import org.koitharu.kotatsu.core.util.ext.MutableEventFlow import org.koitharu.kotatsu.core.util.ext.call import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug import org.koitharu.kotatsu.core.util.ext.require -import org.koitharu.kotatsu.core.util.ext.sizeOrZero import org.koitharu.kotatsu.download.ui.worker.DownloadTask import org.koitharu.kotatsu.download.ui.worker.DownloadWorker import org.koitharu.kotatsu.history.data.HistoryRepository @@ -30,6 +29,7 @@ import org.koitharu.kotatsu.local.data.LocalStorageManager import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.util.mapToSet import org.koitharu.kotatsu.parsers.util.runCatchingCancellable +import org.koitharu.kotatsu.parsers.util.sizeOrZero import org.koitharu.kotatsu.parsers.util.suspendlazy.suspendLazy import org.koitharu.kotatsu.settings.storage.DirectoryModel import javax.inject.Inject diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/worker/DownloadWorker.kt b/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/worker/DownloadWorker.kt index a52c1c343..45d6c2438 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/worker/DownloadWorker.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/worker/DownloadWorker.kt @@ -60,7 +60,6 @@ import org.koitharu.kotatsu.core.util.ext.ensureSuccess import org.koitharu.kotatsu.core.util.ext.getDisplayMessage import org.koitharu.kotatsu.core.util.ext.getWorkInputData import org.koitharu.kotatsu.core.util.ext.getWorkSpec -import org.koitharu.kotatsu.core.util.ext.ifNullOrEmpty import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug import org.koitharu.kotatsu.core.util.ext.withTicker import org.koitharu.kotatsu.core.util.ext.writeAllCancellable @@ -79,6 +78,7 @@ import org.koitharu.kotatsu.parsers.exception.TooManyRequestExceptions import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.model.MangaChapter import org.koitharu.kotatsu.parsers.model.MangaSource +import org.koitharu.kotatsu.parsers.util.ifNullOrEmpty import org.koitharu.kotatsu.parsers.util.mapToSet import org.koitharu.kotatsu.parsers.util.requireBody import org.koitharu.kotatsu.parsers.util.runCatchingCancellable diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/explore/domain/ExploreRepository.kt b/app/src/main/kotlin/org/koitharu/kotatsu/explore/domain/ExploreRepository.kt index f09f89f72..76a0d46d8 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/explore/domain/ExploreRepository.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/explore/domain/ExploreRepository.kt @@ -3,7 +3,6 @@ package org.koitharu.kotatsu.explore.domain import org.koitharu.kotatsu.core.model.isNsfw import org.koitharu.kotatsu.core.parser.MangaRepository import org.koitharu.kotatsu.core.prefs.AppSettings -import org.koitharu.kotatsu.core.util.ext.almostEquals import org.koitharu.kotatsu.core.util.ext.asArrayList import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug import org.koitharu.kotatsu.explore.data.MangaSourcesRepository @@ -11,6 +10,7 @@ import org.koitharu.kotatsu.history.data.HistoryRepository import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.model.MangaListFilter import org.koitharu.kotatsu.parsers.model.MangaSource +import org.koitharu.kotatsu.parsers.util.almostEquals import org.koitharu.kotatsu.parsers.util.runCatchingCancellable import org.koitharu.kotatsu.suggestions.domain.TagsBlacklist import javax.inject.Inject @@ -77,7 +77,7 @@ class ExploreRepository @Inject constructor( val list = repository.getList( offset = 0, order = order, - filter = MangaListFilter(tags = setOfNotNull(tag)) + filter = MangaListFilter(tags = setOfNotNull(tag)), ).asArrayList() if (settings.isSuggestionsExcludeNsfw) { list.removeAll { it.isNsfw } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/model/MangaSourceItem.kt b/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/model/MangaSourceItem.kt index 9c084c80a..53eff4c00 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/model/MangaSourceItem.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/explore/ui/model/MangaSourceItem.kt @@ -1,8 +1,8 @@ package org.koitharu.kotatsu.explore.ui.model import org.koitharu.kotatsu.core.model.MangaSourceInfo -import org.koitharu.kotatsu.core.util.ext.longHashCode import org.koitharu.kotatsu.list.ui.model.ListModel +import org.koitharu.kotatsu.parsers.util.longHashCode data class MangaSourceItem( val source: MangaSourceInfo, diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/preview/PreviewFragment.kt b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/preview/PreviewFragment.kt index cee84e64c..2010c045c 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/preview/PreviewFragment.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/list/ui/preview/PreviewFragment.kt @@ -28,7 +28,6 @@ import org.koitharu.kotatsu.core.util.ext.crossfade import org.koitharu.kotatsu.core.util.ext.defaultPlaceholders import org.koitharu.kotatsu.core.util.ext.drawable import org.koitharu.kotatsu.core.util.ext.enqueueWith -import org.koitharu.kotatsu.core.util.ext.ifNullOrEmpty import org.koitharu.kotatsu.core.util.ext.mangaSourceExtra import org.koitharu.kotatsu.core.util.ext.observe import org.koitharu.kotatsu.core.util.ext.scaleUpActivityOptionsOf @@ -40,6 +39,7 @@ import org.koitharu.kotatsu.image.ui.ImageActivity import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.model.MangaListFilter import org.koitharu.kotatsu.parsers.model.MangaTag +import org.koitharu.kotatsu.parsers.util.ifNullOrEmpty import org.koitharu.kotatsu.reader.ui.ReaderActivity import org.koitharu.kotatsu.search.ui.MangaListActivity import javax.inject.Inject diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/local/data/PagesCache.kt b/app/src/main/kotlin/org/koitharu/kotatsu/local/data/PagesCache.kt index b4a414dfa..013aa9275 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/local/data/PagesCache.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/local/data/PagesCache.kt @@ -16,13 +16,12 @@ import okio.use import org.koitharu.kotatsu.core.exceptions.NoDataReceivedException import org.koitharu.kotatsu.core.util.FileSize import org.koitharu.kotatsu.core.util.ext.compressToPNG -import org.koitharu.kotatsu.core.util.ext.ifNullOrEmpty import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug import org.koitharu.kotatsu.core.util.ext.subdir import org.koitharu.kotatsu.core.util.ext.takeIfReadable import org.koitharu.kotatsu.core.util.ext.takeIfWriteable import org.koitharu.kotatsu.core.util.ext.writeAllCancellable -import org.koitharu.kotatsu.parsers.model.MangaPage +import org.koitharu.kotatsu.parsers.util.ifNullOrEmpty import org.koitharu.kotatsu.parsers.util.runCatchingCancellable import org.koitharu.kotatsu.parsers.util.suspendlazy.suspendLazy import java.io.File diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/local/data/input/LocalMangaParser.kt b/app/src/main/kotlin/org/koitharu/kotatsu/local/data/input/LocalMangaParser.kt index 83d697a42..a8506d1ac 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/local/data/input/LocalMangaParser.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/local/data/input/LocalMangaParser.kt @@ -22,8 +22,8 @@ import org.koitharu.kotatsu.core.util.ext.URI_SCHEME_ZIP import org.koitharu.kotatsu.core.util.ext.isFileUri import org.koitharu.kotatsu.core.util.ext.isRegularFile import org.koitharu.kotatsu.core.util.ext.isZipUri -import org.koitharu.kotatsu.core.util.ext.longHashCode import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug +import org.koitharu.kotatsu.core.util.ext.toFileNameSafe import org.koitharu.kotatsu.core.util.ext.toListSorted import org.koitharu.kotatsu.local.data.MangaIndex import org.koitharu.kotatsu.local.data.hasZipExtension @@ -33,8 +33,8 @@ import org.koitharu.kotatsu.local.domain.model.LocalManga import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.model.MangaChapter import org.koitharu.kotatsu.parsers.model.MangaPage +import org.koitharu.kotatsu.parsers.util.longHashCode import org.koitharu.kotatsu.parsers.util.runCatchingCancellable -import org.koitharu.kotatsu.parsers.util.toFileNameSafe import java.io.File /** diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/local/data/output/LocalMangaDirOutput.kt b/app/src/main/kotlin/org/koitharu/kotatsu/local/data/output/LocalMangaDirOutput.kt index 4c1cbff62..edf715610 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/local/data/output/LocalMangaDirOutput.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/local/data/output/LocalMangaDirOutput.kt @@ -10,12 +10,12 @@ import okhttp3.internal.closeQuietly import org.koitharu.kotatsu.core.model.isLocal import org.koitharu.kotatsu.core.util.ext.deleteAwait import org.koitharu.kotatsu.core.util.ext.takeIfReadable +import org.koitharu.kotatsu.core.util.ext.toFileNameSafe import org.koitharu.kotatsu.core.zip.ZipOutput import org.koitharu.kotatsu.local.data.MangaIndex import org.koitharu.kotatsu.local.data.input.LocalMangaParser import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.model.MangaChapter -import org.koitharu.kotatsu.parsers.util.toFileNameSafe import java.io.File class LocalMangaDirOutput( @@ -96,7 +96,9 @@ class LocalMangaDirOutput( } suspend fun deleteChapters(ids: Set) = mutex.withLock { - val chapters = checkNotNull((index.getMangaInfo() ?: LocalMangaParser(rootFile).getManga(withDetails = true).manga).chapters) { + val chapters = checkNotNull( + (index.getMangaInfo() ?: LocalMangaParser(rootFile).getManga(withDetails = true).manga).chapters, + ) { "No chapters found" }.withIndex() val victimsIds = ids.toMutableSet() diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/local/data/output/LocalMangaOutput.kt b/app/src/main/kotlin/org/koitharu/kotatsu/local/data/output/LocalMangaOutput.kt index 6db94d18d..f8ffd8362 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/local/data/output/LocalMangaOutput.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/local/data/output/LocalMangaOutput.kt @@ -7,11 +7,11 @@ import kotlinx.coroutines.withContext import okio.Closeable import org.koitharu.kotatsu.core.prefs.DownloadFormat import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug +import org.koitharu.kotatsu.core.util.ext.toFileNameSafe import org.koitharu.kotatsu.local.data.input.LocalMangaParser import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.model.MangaChapter import org.koitharu.kotatsu.parsers.util.runCatchingCancellable -import org.koitharu.kotatsu.parsers.util.toFileNameSafe import java.io.File sealed class LocalMangaOutput( diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/main/domain/CoverRestoreInterceptor.kt b/app/src/main/kotlin/org/koitharu/kotatsu/main/domain/CoverRestoreInterceptor.kt index 733105cea..5ca72a833 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/main/domain/CoverRestoreInterceptor.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/main/domain/CoverRestoreInterceptor.kt @@ -10,11 +10,11 @@ import org.koitharu.kotatsu.core.model.isLocal import org.koitharu.kotatsu.core.parser.MangaDataRepository import org.koitharu.kotatsu.core.parser.MangaRepository import org.koitharu.kotatsu.core.util.ext.bookmarkKey -import org.koitharu.kotatsu.core.util.ext.ifNullOrEmpty import org.koitharu.kotatsu.core.util.ext.mangaKey import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.util.findById +import org.koitharu.kotatsu.parsers.util.ifNullOrEmpty import org.koitharu.kotatsu.parsers.util.runCatchingCancellable import java.util.Collections import javax.inject.Inject diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/PageSaveHelper.kt b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/PageSaveHelper.kt index d44c258ca..a6b1d2d3e 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/PageSaveHelper.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/PageSaveHelper.kt @@ -31,12 +31,12 @@ import okio.source import org.koitharu.kotatsu.core.prefs.AppSettings import org.koitharu.kotatsu.core.util.ext.isFileUri import org.koitharu.kotatsu.core.util.ext.isZipUri +import org.koitharu.kotatsu.core.util.ext.toFileNameSafe import org.koitharu.kotatsu.core.util.ext.toFileOrNull import org.koitharu.kotatsu.core.util.ext.writeAllCancellable import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.model.MangaChapter import org.koitharu.kotatsu.parsers.model.MangaPage -import org.koitharu.kotatsu.parsers.util.toFileNameSafe import org.koitharu.kotatsu.reader.domain.PageLoader import java.io.File import java.text.SimpleDateFormat diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt index f7649b4b7..dd08b07d6 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt @@ -40,9 +40,7 @@ import org.koitharu.kotatsu.core.prefs.observeAsFlow import org.koitharu.kotatsu.core.prefs.observeAsStateFlow import org.koitharu.kotatsu.core.util.ext.MutableEventFlow import org.koitharu.kotatsu.core.util.ext.call -import org.koitharu.kotatsu.core.util.ext.ifNullOrEmpty import org.koitharu.kotatsu.core.util.ext.requireValue -import org.koitharu.kotatsu.core.util.ext.sizeOrZero import org.koitharu.kotatsu.details.data.MangaDetails import org.koitharu.kotatsu.details.domain.DetailsInteractor import org.koitharu.kotatsu.details.domain.DetailsLoadUseCase @@ -57,6 +55,8 @@ import org.koitharu.kotatsu.local.domain.DeleteLocalMangaUseCase import org.koitharu.kotatsu.local.domain.model.LocalManga import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.model.MangaPage +import org.koitharu.kotatsu.parsers.util.ifNullOrEmpty +import org.koitharu.kotatsu.parsers.util.sizeOrZero import org.koitharu.kotatsu.reader.domain.ChaptersLoader import org.koitharu.kotatsu.reader.domain.DetectReaderModeUseCase import org.koitharu.kotatsu.reader.domain.PageLoader diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/config/ImageServerDelegate.kt b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/config/ImageServerDelegate.kt index 7e498e8e4..47b1f9d5a 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/config/ImageServerDelegate.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/reader/ui/config/ImageServerDelegate.kt @@ -8,9 +8,9 @@ import kotlinx.coroutines.withContext import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.parser.MangaRepository import org.koitharu.kotatsu.core.parser.ParserMangaRepository -import org.koitharu.kotatsu.core.util.ext.mapToArray import org.koitharu.kotatsu.parsers.config.ConfigKey import org.koitharu.kotatsu.parsers.model.MangaSource +import org.koitharu.kotatsu.parsers.util.mapToArray import org.koitharu.kotatsu.parsers.util.suspendlazy.getOrNull import org.koitharu.kotatsu.parsers.util.suspendlazy.suspendLazy import kotlin.coroutines.resume diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/remotelist/ui/RemoteListViewModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/remotelist/ui/RemoteListViewModel.kt index 6ee783c4c..55f08c9b4 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/remotelist/ui/RemoteListViewModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/remotelist/ui/RemoteListViewModel.kt @@ -26,7 +26,6 @@ import org.koitharu.kotatsu.core.util.ext.MutableEventFlow import org.koitharu.kotatsu.core.util.ext.call import org.koitharu.kotatsu.core.util.ext.getCauseUrl import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug -import org.koitharu.kotatsu.core.util.ext.sizeOrZero import org.koitharu.kotatsu.download.ui.worker.DownloadWorker import org.koitharu.kotatsu.explore.data.MangaSourcesRepository import org.koitharu.kotatsu.explore.domain.ExploreRepository @@ -40,6 +39,7 @@ import org.koitharu.kotatsu.list.ui.model.LoadingState import org.koitharu.kotatsu.list.ui.model.toErrorFooter import org.koitharu.kotatsu.list.ui.model.toErrorState import org.koitharu.kotatsu.parsers.model.Manga +import org.koitharu.kotatsu.parsers.util.sizeOrZero import javax.inject.Inject private const val FILTER_MIN_INTERVAL = 250L diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/suggestion/SearchSuggestionViewModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/suggestion/SearchSuggestionViewModel.kt index 507d15734..28b1f4125 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/suggestion/SearchSuggestionViewModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/search/ui/suggestion/SearchSuggestionViewModel.kt @@ -21,11 +21,11 @@ import org.koitharu.kotatsu.core.prefs.observeAsFlow import org.koitharu.kotatsu.core.prefs.observeAsStateFlow import org.koitharu.kotatsu.core.ui.BaseViewModel import org.koitharu.kotatsu.core.ui.widgets.ChipsView -import org.koitharu.kotatsu.core.util.ext.sizeOrZero import org.koitharu.kotatsu.explore.data.MangaSourcesRepository import org.koitharu.kotatsu.parsers.model.MangaSource import org.koitharu.kotatsu.parsers.model.MangaTag import org.koitharu.kotatsu.parsers.util.mapToSet +import org.koitharu.kotatsu.parsers.util.sizeOrZero import org.koitharu.kotatsu.search.domain.MangaSearchRepository import org.koitharu.kotatsu.search.ui.suggestion.model.SearchSuggestionItem import javax.inject.Inject diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/settings/about/AboutSettingsFragment.kt b/app/src/main/kotlin/org/koitharu/kotatsu/settings/about/AboutSettingsFragment.kt index 5419fed7a..bbc9ee88b 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/settings/about/AboutSettingsFragment.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/settings/about/AboutSettingsFragment.kt @@ -10,6 +10,7 @@ import androidx.preference.Preference import androidx.preference.SwitchPreferenceCompat import com.google.android.material.snackbar.Snackbar import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.flow.combine import org.koitharu.kotatsu.BuildConfig import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.github.AppVersion @@ -29,10 +30,8 @@ class AboutSettingsFragment : BasePreferenceFragment(R.string.about) { addPreferencesFromResource(R.xml.pref_about) findPreference(AppSettings.KEY_APP_VERSION)?.run { title = getString(R.string.app_version, BuildConfig.VERSION_NAME) - isEnabled = viewModel.isUpdateSupported } findPreference(AppSettings.KEY_UPDATES_UNSTABLE)?.run { - isVisible = viewModel.isUpdateSupported isEnabled = VersionId(BuildConfig.VERSION_NAME).isStable if (!isEnabled) isChecked = true } @@ -40,9 +39,12 @@ class AboutSettingsFragment : BasePreferenceFragment(R.string.about) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - viewModel.isLoading.observe(viewLifecycleOwner) { - findPreference(AppSettings.KEY_APP_UPDATE)?.isEnabled = !it - } + combine(viewModel.isUpdateSupported, viewModel.isLoading, ::Pair) + .observe(viewLifecycleOwner) { (isUpdateSupported, isLoading) -> + findPreference(AppSettings.KEY_UPDATES_UNSTABLE)?.isVisible = isUpdateSupported + findPreference(AppSettings.KEY_APP_VERSION)?.isEnabled = isUpdateSupported && !isLoading + + } viewModel.onUpdateAvailable.observeEvent(viewLifecycleOwner, ::onUpdateAvailable) } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/settings/about/AboutSettingsViewModel.kt b/app/src/main/kotlin/org/koitharu/kotatsu/settings/about/AboutSettingsViewModel.kt index 638ce1e8e..ead988beb 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/settings/about/AboutSettingsViewModel.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/settings/about/AboutSettingsViewModel.kt @@ -1,6 +1,10 @@ package org.koitharu.kotatsu.settings.about +import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel +import kotlinx.coroutines.flow.SharingStarted +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.flow.stateIn import org.koitharu.kotatsu.core.github.AppUpdateRepository import org.koitharu.kotatsu.core.github.AppVersion import org.koitharu.kotatsu.core.ui.BaseViewModel @@ -13,7 +17,10 @@ class AboutSettingsViewModel @Inject constructor( private val appUpdateRepository: AppUpdateRepository, ) : BaseViewModel() { - val isUpdateSupported = appUpdateRepository.isUpdateSupported() + val isUpdateSupported = flow { + emit(appUpdateRepository.isUpdateSupported()) + }.stateIn(viewModelScope, SharingStarted.Eagerly, false) + val onUpdateAvailable = MutableEventFlow() fun checkForUpdates() { diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/settings/sources/SourceSettingsExt.kt b/app/src/main/kotlin/org/koitharu/kotatsu/settings/sources/SourceSettingsExt.kt index dbd2f23bd..158003971 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/settings/sources/SourceSettingsExt.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/settings/sources/SourceSettingsExt.kt @@ -10,9 +10,9 @@ import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.parser.EmptyMangaRepository import org.koitharu.kotatsu.core.parser.MangaRepository import org.koitharu.kotatsu.core.parser.ParserMangaRepository -import org.koitharu.kotatsu.core.util.ext.mapToArray import org.koitharu.kotatsu.parsers.config.ConfigKey import org.koitharu.kotatsu.parsers.network.UserAgents +import org.koitharu.kotatsu.parsers.util.mapToArray import org.koitharu.kotatsu.settings.utils.AutoCompleteTextViewPreference import org.koitharu.kotatsu.settings.utils.EditTextBindListener import org.koitharu.kotatsu.settings.utils.EditTextDefaultSummaryProvider @@ -41,12 +41,10 @@ private fun PreferenceFragmentCompat.addPreferencesFromParserRepository(reposito } }.apply { summaryProvider = EditTextDefaultSummaryProvider(key.defaultValue) - setOnBindEditTextListener( - EditTextBindListener( - inputType = EditorInfo.TYPE_CLASS_TEXT or EditorInfo.TYPE_TEXT_VARIATION_URI, - hint = key.defaultValue, - validator = DomainValidator(), - ), + onBindEditTextListener = EditTextBindListener( + inputType = EditorInfo.TYPE_CLASS_TEXT or EditorInfo.TYPE_TEXT_VARIATION_URI, + hint = key.defaultValue, + validator = DomainValidator(), ) setTitle(R.string.domain) setDialogTitle(R.string.domain) @@ -62,12 +60,10 @@ private fun PreferenceFragmentCompat.addPreferencesFromParserRepository(reposito UserAgents.CHROME_DESKTOP, ) summaryProvider = EditTextDefaultSummaryProvider(key.defaultValue) - setOnBindEditTextListener( - EditTextBindListener( - inputType = EditorInfo.TYPE_CLASS_TEXT, - hint = key.defaultValue, - validator = HeaderValidator(), - ), + onBindEditTextListener = EditTextBindListener( + inputType = EditorInfo.TYPE_CLASS_TEXT, + hint = key.defaultValue, + validator = HeaderValidator(), ) setTitle(R.string.user_agent) setDialogTitle(R.string.user_agent) @@ -119,6 +115,6 @@ private fun PreferenceFragmentCompat.addPreferencesFromEmptyRepository() { preferenceScreen.addPreference(preference) } -private fun Array.toStringArray(): Array { - return Array(size) { i -> this[i] as? String ?: "" } +private fun Array.toStringArray(): Array { + return Array(size) { i -> this[i].orEmpty() } } diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/settings/utils/EditTextDefaultSummaryProvider.kt b/app/src/main/kotlin/org/koitharu/kotatsu/settings/utils/EditTextDefaultSummaryProvider.kt index b2f448b1b..851ede594 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/settings/utils/EditTextDefaultSummaryProvider.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/settings/utils/EditTextDefaultSummaryProvider.kt @@ -16,4 +16,4 @@ class EditTextDefaultSummaryProvider( text } } -} \ No newline at end of file +} diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/suggestions/domain/TagsBlacklist.kt b/app/src/main/kotlin/org/koitharu/kotatsu/suggestions/domain/TagsBlacklist.kt index a408dd722..d05b3ad1d 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/suggestions/domain/TagsBlacklist.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/suggestions/domain/TagsBlacklist.kt @@ -1,8 +1,8 @@ package org.koitharu.kotatsu.suggestions.domain -import org.koitharu.kotatsu.core.util.ext.almostEquals import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.model.MangaTag +import org.koitharu.kotatsu.parsers.util.almostEquals class TagsBlacklist( private val tags: Set, diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/suggestions/ui/SuggestionsWorker.kt b/app/src/main/kotlin/org/koitharu/kotatsu/suggestions/ui/SuggestionsWorker.kt index d7bfd3b67..8f0110f54 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/suggestions/ui/SuggestionsWorker.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/suggestions/ui/SuggestionsWorker.kt @@ -51,7 +51,6 @@ import org.koitharu.kotatsu.core.model.distinctById import org.koitharu.kotatsu.core.model.isNsfw import org.koitharu.kotatsu.core.parser.MangaRepository import org.koitharu.kotatsu.core.prefs.AppSettings -import org.koitharu.kotatsu.core.util.ext.almostEquals import org.koitharu.kotatsu.core.util.ext.asArrayList import org.koitharu.kotatsu.core.util.ext.awaitUniqueWorkInfoByName import org.koitharu.kotatsu.core.util.ext.awaitWorkInfosByTag @@ -60,7 +59,6 @@ import org.koitharu.kotatsu.core.util.ext.flatten import org.koitharu.kotatsu.core.util.ext.mangaSourceExtra import org.koitharu.kotatsu.core.util.ext.printStackTraceDebug import org.koitharu.kotatsu.core.util.ext.sanitize -import org.koitharu.kotatsu.core.util.ext.sizeOrZero import org.koitharu.kotatsu.core.util.ext.takeMostFrequent import org.koitharu.kotatsu.core.util.ext.toBitmapOrNull import org.koitharu.kotatsu.core.util.ext.trySetForeground @@ -73,7 +71,9 @@ import org.koitharu.kotatsu.parsers.model.MangaListFilter import org.koitharu.kotatsu.parsers.model.MangaSource import org.koitharu.kotatsu.parsers.model.MangaTag import org.koitharu.kotatsu.parsers.model.SortOrder +import org.koitharu.kotatsu.parsers.util.almostEquals import org.koitharu.kotatsu.parsers.util.runCatchingCancellable +import org.koitharu.kotatsu.parsers.util.sizeOrZero import org.koitharu.kotatsu.reader.ui.ReaderActivity.IntentBuilder import org.koitharu.kotatsu.settings.SettingsActivity import org.koitharu.kotatsu.settings.work.PeriodicWorkScheduler diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/sync/data/SyncSettings.kt b/app/src/main/kotlin/org/koitharu/kotatsu/sync/data/SyncSettings.kt index b08aca06e..0c3fe09cb 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/sync/data/SyncSettings.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/sync/data/SyncSettings.kt @@ -6,7 +6,7 @@ import android.content.Context import androidx.annotation.WorkerThread import dagger.hilt.android.qualifiers.ApplicationContext import org.koitharu.kotatsu.R -import org.koitharu.kotatsu.core.util.ext.ifNullOrEmpty +import org.koitharu.kotatsu.parsers.util.ifNullOrEmpty import javax.inject.Inject class SyncSettings( diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/sync/ui/SyncHostDialogFragment.kt b/app/src/main/kotlin/org/koitharu/kotatsu/sync/ui/SyncHostDialogFragment.kt index f2821b5e1..1b04e6877 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/sync/ui/SyncHostDialogFragment.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/sync/ui/SyncHostDialogFragment.kt @@ -13,9 +13,9 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder import dagger.hilt.android.AndroidEntryPoint import org.koitharu.kotatsu.R import org.koitharu.kotatsu.core.ui.AlertDialogFragment -import org.koitharu.kotatsu.core.util.ext.ifNullOrEmpty import org.koitharu.kotatsu.core.util.ext.withArgs import org.koitharu.kotatsu.databinding.PreferenceDialogAutocompletetextviewBinding +import org.koitharu.kotatsu.parsers.util.ifNullOrEmpty import org.koitharu.kotatsu.settings.utils.validation.UrlValidator import org.koitharu.kotatsu.sync.data.SyncSettings import javax.inject.Inject diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/tracker/domain/TrackingRepository.kt b/app/src/main/kotlin/org/koitharu/kotatsu/tracker/domain/TrackingRepository.kt index 569a4e1e8..5aabf2f51 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/tracker/domain/TrackingRepository.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/tracker/domain/TrackingRepository.kt @@ -11,12 +11,12 @@ import org.koitharu.kotatsu.core.db.MangaDatabase import org.koitharu.kotatsu.core.db.entity.toManga import org.koitharu.kotatsu.core.db.entity.toMangaTags import org.koitharu.kotatsu.core.prefs.AppSettings -import org.koitharu.kotatsu.core.util.ext.ifZero import org.koitharu.kotatsu.core.util.ext.mapItems import org.koitharu.kotatsu.core.util.ext.toInstantOrNull import org.koitharu.kotatsu.details.domain.ProgressUpdateUseCase import org.koitharu.kotatsu.list.domain.ListFilterOption import org.koitharu.kotatsu.parsers.model.Manga +import org.koitharu.kotatsu.parsers.util.ifZero import org.koitharu.kotatsu.tracker.data.TrackEntity import org.koitharu.kotatsu.tracker.data.TrackLogEntity import org.koitharu.kotatsu.tracker.data.toTrackingLogItem diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/tracker/domain/model/MangaUpdates.kt b/app/src/main/kotlin/org/koitharu/kotatsu/tracker/domain/model/MangaUpdates.kt index e59011199..6bde152ce 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/tracker/domain/model/MangaUpdates.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/tracker/domain/model/MangaUpdates.kt @@ -1,9 +1,9 @@ package org.koitharu.kotatsu.tracker.domain.model -import org.koitharu.kotatsu.core.util.ext.ifZero import org.koitharu.kotatsu.parsers.exception.TooManyRequestExceptions import org.koitharu.kotatsu.parsers.model.Manga import org.koitharu.kotatsu.parsers.model.MangaChapter +import org.koitharu.kotatsu.parsers.util.ifZero sealed interface MangaUpdates { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ccd9e79f6..9e4acac50 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -31,7 +31,7 @@ material = "1.12.0" moshi = "1.15.2" okhttp = "4.12.0" okio = "3.9.1" -parsers = "8481fadbd0" +parsers = "51ed1b2db8" preference = "1.2.1" recyclerview = "1.3.2" room = "2.6.1" From 8713faa48787305c6cd9ed405cd3c1b0a0a9e21f Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sat, 25 Jan 2025 12:14:01 +0200 Subject: [PATCH 4/8] Update parsers --- app/build.gradle | 4 ++-- .../koitharu/kotatsu/local/data/input/LocalMangaParser.kt | 6 ++---- gradle/libs.versions.toml | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 64d1ab304..17ec347e8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,8 +18,8 @@ android { applicationId 'org.koitharu.kotatsu' minSdk = 21 targetSdk = 35 - versionCode = 700 - versionName = '7.7.8' + versionCode = 701 + versionName = '7.7.9' generatedDensities = [] testInstrumentationRunner 'org.koitharu.kotatsu.HiltTestRunner' ksp { diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/local/data/input/LocalMangaParser.kt b/app/src/main/kotlin/org/koitharu/kotatsu/local/data/input/LocalMangaParser.kt index a8506d1ac..6941c2409 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/local/data/input/LocalMangaParser.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/local/data/input/LocalMangaParser.kt @@ -62,7 +62,7 @@ class LocalMangaParser(private val uri: Uri) { mangaInfo.copy( source = LocalMangaSource, url = rootFile.toUri().toString(), - coverUrl = coverEntry?.let { uri.child(it, resolve = true).toString() }.orEmpty(), + coverUrl = coverEntry?.let { uri.child(it, resolve = true).toString() }, largeCoverUrl = null, chapters = if (withDetails) { mangaInfo.chapters?.mapNotNull { c -> @@ -92,9 +92,7 @@ class LocalMangaParser(private val uri: Uri) { url = rootFile.toUri().toString(), publicUrl = rootFile.toUri().toString(), source = LocalMangaSource, - coverUrl = coverEntry?.let { - uri.child(it, resolve = true).toString() - }.orEmpty(), + coverUrl = coverEntry?.let { uri.child(it, resolve = true).toString() }, chapters = if (withDetails) { val chapters = fileSystem.listRecursively(rootPath) .mapNotNullTo(HashSet()) { path -> diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9e4acac50..60460a3cc 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -31,7 +31,7 @@ material = "1.12.0" moshi = "1.15.2" okhttp = "4.12.0" okio = "3.9.1" -parsers = "51ed1b2db8" +parsers = "58e09bdaba" preference = "1.2.1" recyclerview = "1.3.2" room = "2.6.1" From e03a200c328b8efe151119bf427c7a5363896168 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sat, 25 Jan 2025 12:51:13 +0200 Subject: [PATCH 5/8] Fix build --- .../settings/sources/SourceSettingsExt.kt | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/settings/sources/SourceSettingsExt.kt b/app/src/main/kotlin/org/koitharu/kotatsu/settings/sources/SourceSettingsExt.kt index 158003971..fd700e97e 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/settings/sources/SourceSettingsExt.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/settings/sources/SourceSettingsExt.kt @@ -41,10 +41,12 @@ private fun PreferenceFragmentCompat.addPreferencesFromParserRepository(reposito } }.apply { summaryProvider = EditTextDefaultSummaryProvider(key.defaultValue) - onBindEditTextListener = EditTextBindListener( - inputType = EditorInfo.TYPE_CLASS_TEXT or EditorInfo.TYPE_TEXT_VARIATION_URI, - hint = key.defaultValue, - validator = DomainValidator(), + setOnBindEditTextListener( + EditTextBindListener( + inputType = EditorInfo.TYPE_CLASS_TEXT or EditorInfo.TYPE_TEXT_VARIATION_URI, + hint = key.defaultValue, + validator = DomainValidator(), + ), ) setTitle(R.string.domain) setDialogTitle(R.string.domain) @@ -60,10 +62,12 @@ private fun PreferenceFragmentCompat.addPreferencesFromParserRepository(reposito UserAgents.CHROME_DESKTOP, ) summaryProvider = EditTextDefaultSummaryProvider(key.defaultValue) - onBindEditTextListener = EditTextBindListener( - inputType = EditorInfo.TYPE_CLASS_TEXT, - hint = key.defaultValue, - validator = HeaderValidator(), + setOnBindEditTextListener( + EditTextBindListener( + inputType = EditorInfo.TYPE_CLASS_TEXT, + hint = key.defaultValue, + validator = HeaderValidator(), + ), ) setTitle(R.string.user_agent) setDialogTitle(R.string.user_agent) From e60ca7115a73d29938dee2610266037b32ceccdb Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sun, 9 Feb 2025 10:01:15 +0200 Subject: [PATCH 6/8] Update parsers --- app/build.gradle | 4 ++-- gradle/libs.versions.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 17ec347e8..a1d638eaf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,8 +18,8 @@ android { applicationId 'org.koitharu.kotatsu' minSdk = 21 targetSdk = 35 - versionCode = 701 - versionName = '7.7.9' + versionCode = 702 + versionName = '7.7.10' generatedDensities = [] testInstrumentationRunner 'org.koitharu.kotatsu.HiltTestRunner' ksp { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 60460a3cc..12a78285c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -31,7 +31,7 @@ material = "1.12.0" moshi = "1.15.2" okhttp = "4.12.0" okio = "3.9.1" -parsers = "58e09bdaba" +parsers = "794a737b6d" preference = "1.2.1" recyclerview = "1.3.2" room = "2.6.1" From bb68869fe118f3b2fc7ca88c4165cbcf13f8c7a3 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sun, 9 Feb 2025 10:11:24 +0200 Subject: [PATCH 7/8] Fix crashes --- .../koitharu/kotatsu/bookmarks/ui/adapter/BookmarksAdapter.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/adapter/BookmarksAdapter.kt b/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/adapter/BookmarksAdapter.kt index 6bdee400c..8854b8a78 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/adapter/BookmarksAdapter.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/bookmarks/ui/adapter/BookmarksAdapter.kt @@ -10,6 +10,7 @@ import org.koitharu.kotatsu.core.ui.list.fastscroll.FastScroller import org.koitharu.kotatsu.list.ui.adapter.ListHeaderClickListener import org.koitharu.kotatsu.list.ui.adapter.ListItemType import org.koitharu.kotatsu.list.ui.adapter.emptyStateListAD +import org.koitharu.kotatsu.list.ui.adapter.errorStateListAD import org.koitharu.kotatsu.list.ui.adapter.listHeaderAD import org.koitharu.kotatsu.list.ui.adapter.loadingFooterAD import org.koitharu.kotatsu.list.ui.adapter.loadingStateAD @@ -25,6 +26,7 @@ class BookmarksAdapter( init { addDelegate(ListItemType.PAGE_THUMB, bookmarkLargeAD(coil, lifecycleOwner, clickListener)) addDelegate(ListItemType.HEADER, listHeaderAD(headerClickListener)) + addDelegate(ListItemType.STATE_ERROR, errorStateListAD(null)) addDelegate(ListItemType.FOOTER_LOADING, loadingFooterAD()) addDelegate(ListItemType.STATE_LOADING, loadingStateAD()) addDelegate(ListItemType.STATE_EMPTY, emptyStateListAD(coil, lifecycleOwner, null)) From 8a26587250b1ec533ced50f08f9860c6a1b22dec Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sun, 9 Feb 2025 10:15:24 +0200 Subject: [PATCH 8/8] Database migration for downgrade from 24 to 23 (#1269, #1270) --- .../org/koitharu/kotatsu/core/db/MangaDatabase.kt | 2 ++ .../kotatsu/core/db/migrations/Migration24To23.kt | 11 +++++++++++ 2 files changed, 13 insertions(+) create mode 100644 app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration24To23.kt diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/db/MangaDatabase.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/db/MangaDatabase.kt index 60f1abb02..f87bc5b0a 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/db/MangaDatabase.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/db/MangaDatabase.kt @@ -36,6 +36,7 @@ import org.koitharu.kotatsu.core.db.migrations.Migration1To2 import org.koitharu.kotatsu.core.db.migrations.Migration20To21 import org.koitharu.kotatsu.core.db.migrations.Migration21To22 import org.koitharu.kotatsu.core.db.migrations.Migration22To23 +import org.koitharu.kotatsu.core.db.migrations.Migration24To23 import org.koitharu.kotatsu.core.db.migrations.Migration2To3 import org.koitharu.kotatsu.core.db.migrations.Migration3To4 import org.koitharu.kotatsu.core.db.migrations.Migration4To5 @@ -128,6 +129,7 @@ fun getDatabaseMigrations(context: Context): Array = arrayOf( Migration20To21(), Migration21To22(), Migration22To23(), + Migration24To23(), ) fun MangaDatabase(context: Context): MangaDatabase = Room diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration24To23.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration24To23.kt new file mode 100644 index 000000000..bf466d273 --- /dev/null +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/db/migrations/Migration24To23.kt @@ -0,0 +1,11 @@ +package org.koitharu.kotatsu.core.db.migrations + +import androidx.room.migration.Migration +import androidx.sqlite.db.SupportSQLiteDatabase + +class Migration24To23 : Migration(24, 23) { + + override fun migrate(db: SupportSQLiteDatabase) { + db.execSQL("DROP TABLE IF EXISTS `chapters`") + } +}