From cd40dab8a409f38923ac878bb720b30dc0864e66 Mon Sep 17 00:00:00 2001 From: Koitharu Date: Tue, 10 Dec 2024 14:29:55 +0200 Subject: [PATCH 1/2] Error handling fixes --- .../org/koitharu/kotatsu/core/util/ext/Throwable.kt | 8 ++++++-- app/src/main/res/values-ar/strings.xml | 4 ++-- app/src/main/res/values/strings.xml | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) 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 bc40df0fb..a7bae7f51 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 @@ -41,11 +41,13 @@ import org.koitharu.kotatsu.scrobbling.common.domain.ScrobblerAuthRequiredExcept import java.io.ObjectOutputStream import java.net.ConnectException import java.net.NoRouteToHostException +import java.net.SocketException import java.net.SocketTimeoutException import java.net.UnknownHostException import java.util.Locale private const val MSG_NO_SPACE_LEFT = "No space left on device" +private const val MSG_CONNECTION_RESET = "Connection reset" private const val IMAGE_FORMAT_NOT_SUPPORTED = "Image format not supported" fun Throwable.getDisplayMessage(resources: Resources): String = getDisplayMessageOrNull(resources) @@ -117,7 +119,7 @@ private fun Throwable.getDisplayMessageOrNull(resources: Resources): String? = w is HttpException -> getHttpDisplayMessage(response.code, resources) is HttpStatusException -> getHttpDisplayMessage(statusCode, resources) - else -> getDisplayMessage(message, resources) ?: message + else -> mapDisplayMessage(message, resources) ?: message }.takeUnless { it.isNullOrBlank() } @DrawableRes @@ -154,10 +156,11 @@ private fun getHttpDisplayMessage(statusCode: Int, resources: Resources): String else -> null } -private fun getDisplayMessage(msg: String?, resources: Resources): String? = when { +private fun mapDisplayMessage(msg: String?, resources: Resources): String? = when { msg.isNullOrEmpty() -> null msg.contains(MSG_NO_SPACE_LEFT) -> resources.getString(R.string.error_no_space_left) msg.contains(IMAGE_FORMAT_NOT_SUPPORTED) -> resources.getString(R.string.error_corrupted_file) + msg == MSG_CONNECTION_RESET -> resources.getString(R.string.error_connection_reset) msg == FILTER_MULTIPLE_GENRES_NOT_SUPPORTED -> resources.getString(R.string.error_multiple_genres_not_supported) msg == FILTER_MULTIPLE_STATES_NOT_SUPPORTED -> resources.getString(R.string.error_multiple_states_not_supported) msg == SEARCH_NOT_SUPPORTED -> resources.getString(R.string.error_search_not_supported) @@ -184,6 +187,7 @@ fun Throwable.isReportable(): Boolean { || this is WrongPasswordException || this is TooManyRequestExceptions || this is HttpStatusException + || this is SocketException ) { return false } diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 8771de2f4..57a074cc5 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -661,5 +661,5 @@ mangatime.org حاول مجدداً الصفحات المحفوظة - هنالك الكثير من الطلبات. حاول مرة أخرى بعد% s - \ No newline at end of file + هنالك الكثير من الطلبات. حاول مرة أخرى بعد%s + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c11b27342..172fbbc50 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -769,4 +769,5 @@ Handle manga links from external applications (e.g. web browser). You may also need to enable it manually in the application\'s system settings Email This source requires solving a captcha to continue + Connection reset by remote host From 1bd916371a3a576cb9f8a2746e8dba7dce30c4be Mon Sep 17 00:00:00 2001 From: Koitharu Date: Sat, 14 Dec 2024 09:36:50 +0200 Subject: [PATCH 2/2] Update parsers --- .gitignore | 1 + app/build.gradle | 4 ++-- gradle/libs.versions.toml | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 6155175a9..13c83266d 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ .cxx /.idea/deviceManager.xml /.kotlin/ +/.idea/AndroidProjectSystem.xml diff --git a/app/build.gradle b/app/build.gradle index c2d668f03..e64fde895 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -18,8 +18,8 @@ android { applicationId 'org.koitharu.kotatsu' minSdk = 21 targetSdk = 35 - versionCode = 693 - versionName = '7.7.1' + versionCode = 694 + versionName = '7.7.2' generatedDensities = [] testInstrumentationRunner 'org.koitharu.kotatsu.HiltTestRunner' ksp { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 741d2801d..07308cc66 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,6 +7,7 @@ avifDecoder = "1.1.1.14d8e3c4" biometric = "1.2.0-alpha05" coil = "3.0.4" collections = "1.4.5" +#noinspection GradleDependency - 2.5.3 cause crashes conscrypt = "2.5.2" constraintlayout = "2.2.0" coreKtx = "1.15.0" @@ -30,7 +31,7 @@ material = "1.12.0" moshi = "1.15.1" okhttp = "4.12.0" okio = "3.9.1" -parsers = "883886bc32" +parsers = "fece09b781" preference = "1.2.1" recyclerview = "1.3.2" room = "2.6.1"