diff --git a/app/build.gradle b/app/build.gradle
index b1a41250d..665ca1378 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -79,7 +79,7 @@ afterEvaluate {
}
}
dependencies {
- implementation('com.github.nv95:kotatsu-parsers:30071709af') {
+ implementation('com.github.nv95:kotatsu-parsers:6495ddf277') {
exclude group: 'org.json', module: 'json'
}
diff --git a/app/src/main/java/org/koitharu/kotatsu/core/exceptions/MangaNotFoundException.kt b/app/src/main/java/org/koitharu/kotatsu/core/exceptions/MangaNotFoundException.kt
deleted file mode 100644
index 9731f97b1..000000000
--- a/app/src/main/java/org/koitharu/kotatsu/core/exceptions/MangaNotFoundException.kt
+++ /dev/null
@@ -1,3 +0,0 @@
-package org.koitharu.kotatsu.core.exceptions
-
-class MangaNotFoundException(s: String? = null) : RuntimeException(s)
\ No newline at end of file
diff --git a/app/src/main/java/org/koitharu/kotatsu/core/exceptions/resolve/ExceptionResolver.kt b/app/src/main/java/org/koitharu/kotatsu/core/exceptions/resolve/ExceptionResolver.kt
index 50f991b47..d0165c7ca 100644
--- a/app/src/main/java/org/koitharu/kotatsu/core/exceptions/resolve/ExceptionResolver.kt
+++ b/app/src/main/java/org/koitharu/kotatsu/core/exceptions/resolve/ExceptionResolver.kt
@@ -8,9 +8,11 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import kotlinx.coroutines.suspendCancellableCoroutine
import org.koitharu.kotatsu.R
+import org.koitharu.kotatsu.browser.BrowserActivity
import org.koitharu.kotatsu.browser.cloudflare.CloudFlareDialog
import org.koitharu.kotatsu.core.exceptions.CloudFlareProtectedException
import org.koitharu.kotatsu.parsers.exception.AuthRequiredException
+import org.koitharu.kotatsu.parsers.exception.NotFoundException
import org.koitharu.kotatsu.parsers.model.MangaSource
import org.koitharu.kotatsu.settings.sources.auth.SourceAuthActivity
import org.koitharu.kotatsu.utils.TaggedActivityResult
@@ -43,6 +45,10 @@ class ExceptionResolver private constructor(
suspend fun resolve(e: Throwable): Boolean = when (e) {
is CloudFlareProtectedException -> resolveCF(e.url)
is AuthRequiredException -> resolveAuthException(e.source)
+ is NotFoundException -> {
+ openInBrowser(e.url)
+ false
+ }
else -> false
}
@@ -69,6 +75,11 @@ class ExceptionResolver private constructor(
sourceAuthContract.launch(source)
}
+ private fun openInBrowser(url: String) {
+ val context = activity ?: fragment?.activity ?: return
+ context.startActivity(BrowserActivity.newIntent(context, url, null))
+ }
+
private fun getFragmentManager() = checkNotNull(fragment?.childFragmentManager ?: activity?.supportFragmentManager)
companion object {
@@ -77,6 +88,7 @@ class ExceptionResolver private constructor(
fun getResolveStringId(e: Throwable) = when (e) {
is CloudFlareProtectedException -> R.string.captcha_solve
is AuthRequiredException -> R.string.sign_in
+ is NotFoundException -> if (e.url.isNotEmpty()) R.string.open_in_browser else 0
else -> 0
}
diff --git a/app/src/main/java/org/koitharu/kotatsu/details/ui/MangaDetailsDelegate.kt b/app/src/main/java/org/koitharu/kotatsu/details/ui/MangaDetailsDelegate.kt
index 39ad3003b..3a4eca7ca 100644
--- a/app/src/main/java/org/koitharu/kotatsu/details/ui/MangaDetailsDelegate.kt
+++ b/app/src/main/java/org/koitharu/kotatsu/details/ui/MangaDetailsDelegate.kt
@@ -5,7 +5,6 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import org.koitharu.kotatsu.base.domain.MangaDataRepository
import org.koitharu.kotatsu.base.domain.MangaIntent
-import org.koitharu.kotatsu.core.exceptions.MangaNotFoundException
import org.koitharu.kotatsu.core.model.MangaHistory
import org.koitharu.kotatsu.core.parser.MangaRepository
import org.koitharu.kotatsu.core.prefs.AppSettings
@@ -13,6 +12,7 @@ import org.koitharu.kotatsu.details.ui.model.ChapterListItem
import org.koitharu.kotatsu.details.ui.model.toListItem
import org.koitharu.kotatsu.history.domain.HistoryRepository
import org.koitharu.kotatsu.local.domain.LocalMangaRepository
+import org.koitharu.kotatsu.parsers.exception.NotFoundException
import org.koitharu.kotatsu.parsers.model.Manga
import org.koitharu.kotatsu.parsers.model.MangaChapter
import org.koitharu.kotatsu.parsers.model.MangaSource
@@ -40,8 +40,7 @@ class MangaDetailsDelegate(
val mangaId = intent.manga?.id ?: intent.mangaId
suspend fun doLoad() {
- var manga = mangaDataRepository.resolveIntent(intent)
- ?: throw MangaNotFoundException("Cannot find manga")
+ var manga = mangaDataRepository.resolveIntent(intent) ?: throw NotFoundException("Cannot find manga", "")
mangaData.value = manga
manga = MangaRepository(manga.source).getDetails(manga)
// find default branch
diff --git a/app/src/main/java/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt b/app/src/main/java/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt
index 6d8b1f0f6..895bb6628 100644
--- a/app/src/main/java/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt
+++ b/app/src/main/java/org/koitharu/kotatsu/reader/ui/ReaderViewModel.kt
@@ -15,11 +15,11 @@ import org.koitharu.kotatsu.base.domain.MangaUtils
import org.koitharu.kotatsu.base.ui.BaseViewModel
import org.koitharu.kotatsu.bookmarks.domain.Bookmark
import org.koitharu.kotatsu.bookmarks.domain.BookmarksRepository
-import org.koitharu.kotatsu.core.exceptions.MangaNotFoundException
import org.koitharu.kotatsu.core.parser.MangaRepository
import org.koitharu.kotatsu.core.prefs.*
import org.koitharu.kotatsu.history.domain.HistoryRepository
import org.koitharu.kotatsu.history.domain.PROGRESS_NONE
+import org.koitharu.kotatsu.parsers.exception.NotFoundException
import org.koitharu.kotatsu.parsers.model.Manga
import org.koitharu.kotatsu.parsers.model.MangaChapter
import org.koitharu.kotatsu.parsers.model.MangaPage
@@ -259,7 +259,7 @@ class ReaderViewModel(
private fun loadImpl() {
loadingJob = launchLoadingJob(Dispatchers.Default) {
- var manga = dataRepository.resolveIntent(intent) ?: throw MangaNotFoundException("Cannot find manga")
+ var manga = dataRepository.resolveIntent(intent) ?: throw NotFoundException("Cannot find manga", "")
mangaData.value = manga
val repo = MangaRepository(manga.source)
manga = repo.getDetails(manga)
diff --git a/app/src/main/java/org/koitharu/kotatsu/utils/ext/ThrowableExt.kt b/app/src/main/java/org/koitharu/kotatsu/utils/ext/ThrowableExt.kt
index 79ee12775..88d60f45c 100644
--- a/app/src/main/java/org/koitharu/kotatsu/utils/ext/ThrowableExt.kt
+++ b/app/src/main/java/org/koitharu/kotatsu/utils/ext/ThrowableExt.kt
@@ -8,6 +8,7 @@ import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.core.exceptions.*
import org.koitharu.kotatsu.parsers.exception.AuthRequiredException
import org.koitharu.kotatsu.parsers.exception.ContentUnavailableException
+import org.koitharu.kotatsu.parsers.exception.NotFoundException
import org.koitharu.kotatsu.parsers.exception.ParseException
import java.net.SocketTimeoutException
@@ -23,6 +24,7 @@ fun Throwable.getDisplayMessage(resources: Resources): String = when (this) {
is ParseException -> shortMessage
is SocketTimeoutException -> resources.getString(R.string.network_error)
is WrongPasswordException -> resources.getString(R.string.wrong_password)
+ is NotFoundException -> resources.getString(R.string.not_found_404)
else -> localizedMessage
} ?: resources.getString(R.string.error_occurred)
@@ -31,7 +33,7 @@ fun Throwable.isReportable(): Boolean {
return true
}
return this is ParseException || this is IllegalArgumentException ||
- this is IllegalStateException || this is RuntimeException
+ this is IllegalStateException || this.javaClass == RuntimeException::class.java
}
fun Throwable.report(message: String?) {
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 2cac495a1..a34f0fc89 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -322,4 +322,5 @@
Show all
Invalid domain
Select range
+ Content not found or removed
\ No newline at end of file