Merge branch 'devel' into feature/nextgen

# Conflicts:
#	app/src/main/java/org/koitharu/kotatsu/reader/ui/ReaderActivity.kt
#	app/src/main/res/values/strings.xml
pull/189/head
Zakhar Timoshenko 4 years ago
commit 3b5a305122

@ -14,8 +14,8 @@ android {
applicationId 'org.koitharu.kotatsu' applicationId 'org.koitharu.kotatsu'
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 32 targetSdkVersion 32
versionCode 417 versionCode 418
versionName '3.4.5' versionName '3.4.6'
generatedDensities = [] generatedDensities = []
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@ -83,7 +83,7 @@ afterEvaluate {
} }
} }
dependencies { dependencies {
implementation('com.github.nv95:kotatsu-parsers:30071709af') { implementation('com.github.nv95:kotatsu-parsers:fadb06aabb') {
exclude group: 'org.json', module: 'json' exclude group: 'org.json', module: 'json'
} }
@ -127,7 +127,6 @@ dependencies {
implementation 'ch.acra:acra-mail:5.9.5' implementation 'ch.acra:acra-mail:5.9.5'
implementation 'ch.acra:acra-dialog:5.9.5' implementation 'ch.acra:acra-dialog:5.9.5'
debugImplementation 'org.jsoup:jsoup:1.15.2'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1' debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'

@ -1,3 +0,0 @@
package org.koitharu.kotatsu.core.exceptions
class MangaNotFoundException(s: String? = null) : RuntimeException(s)

@ -8,9 +8,11 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity import androidx.fragment.app.FragmentActivity
import kotlinx.coroutines.suspendCancellableCoroutine import kotlinx.coroutines.suspendCancellableCoroutine
import org.koitharu.kotatsu.R import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.browser.BrowserActivity
import org.koitharu.kotatsu.browser.cloudflare.CloudFlareDialog import org.koitharu.kotatsu.browser.cloudflare.CloudFlareDialog
import org.koitharu.kotatsu.core.exceptions.CloudFlareProtectedException import org.koitharu.kotatsu.core.exceptions.CloudFlareProtectedException
import org.koitharu.kotatsu.parsers.exception.AuthRequiredException 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.parsers.model.MangaSource
import org.koitharu.kotatsu.settings.sources.auth.SourceAuthActivity import org.koitharu.kotatsu.settings.sources.auth.SourceAuthActivity
import org.koitharu.kotatsu.utils.TaggedActivityResult import org.koitharu.kotatsu.utils.TaggedActivityResult
@ -43,6 +45,10 @@ class ExceptionResolver private constructor(
suspend fun resolve(e: Throwable): Boolean = when (e) { suspend fun resolve(e: Throwable): Boolean = when (e) {
is CloudFlareProtectedException -> resolveCF(e.url) is CloudFlareProtectedException -> resolveCF(e.url)
is AuthRequiredException -> resolveAuthException(e.source) is AuthRequiredException -> resolveAuthException(e.source)
is NotFoundException -> {
openInBrowser(e.url)
false
}
else -> false else -> false
} }
@ -69,6 +75,11 @@ class ExceptionResolver private constructor(
sourceAuthContract.launch(source) 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) private fun getFragmentManager() = checkNotNull(fragment?.childFragmentManager ?: activity?.supportFragmentManager)
companion object { companion object {
@ -77,6 +88,7 @@ class ExceptionResolver private constructor(
fun getResolveStringId(e: Throwable) = when (e) { fun getResolveStringId(e: Throwable) = when (e) {
is CloudFlareProtectedException -> R.string.captcha_solve is CloudFlareProtectedException -> R.string.captcha_solve
is AuthRequiredException -> R.string.sign_in is AuthRequiredException -> R.string.sign_in
is NotFoundException -> if (e.url.isNotEmpty()) R.string.open_in_browser else 0
else -> 0 else -> 0
} }

@ -5,7 +5,6 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.StateFlow
import org.koitharu.kotatsu.base.domain.MangaDataRepository import org.koitharu.kotatsu.base.domain.MangaDataRepository
import org.koitharu.kotatsu.base.domain.MangaIntent 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.model.MangaHistory
import org.koitharu.kotatsu.core.parser.MangaRepository import org.koitharu.kotatsu.core.parser.MangaRepository
import org.koitharu.kotatsu.core.prefs.AppSettings 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.details.ui.model.toListItem
import org.koitharu.kotatsu.history.domain.HistoryRepository import org.koitharu.kotatsu.history.domain.HistoryRepository
import org.koitharu.kotatsu.local.domain.LocalMangaRepository 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.Manga
import org.koitharu.kotatsu.parsers.model.MangaChapter import org.koitharu.kotatsu.parsers.model.MangaChapter
import org.koitharu.kotatsu.parsers.model.MangaSource import org.koitharu.kotatsu.parsers.model.MangaSource
@ -40,8 +40,7 @@ class MangaDetailsDelegate(
val mangaId = intent.manga?.id ?: intent.mangaId val mangaId = intent.manga?.id ?: intent.mangaId
suspend fun doLoad() { suspend fun doLoad() {
var manga = mangaDataRepository.resolveIntent(intent) var manga = mangaDataRepository.resolveIntent(intent) ?: throw NotFoundException("Cannot find manga", "")
?: throw MangaNotFoundException("Cannot find manga")
mangaData.value = manga mangaData.value = manga
manga = MangaRepository(manga.source).getDetails(manga) manga = MangaRepository(manga.source).getDetails(manga)
// find default branch // find default branch

@ -137,6 +137,11 @@ class ReaderActivity :
return false return false
} }
} }
R.id.action_save_page -> {
viewModel.saveCurrentState(readerManager.currentReader?.getCurrentState())
val page = viewModel.getCurrentPage() ?: return false
viewModel.saveCurrentPage(page, savePageRequest)
}
R.id.action_bookmark -> { R.id.action_bookmark -> {
if (viewModel.isBookmarkAdded.value == true) { if (viewModel.isBookmarkAdded.value == true) {
viewModel.removeBookmark() viewModel.removeBookmark()

@ -16,11 +16,11 @@ import org.koitharu.kotatsu.base.domain.MangaUtils
import org.koitharu.kotatsu.base.ui.BaseViewModel import org.koitharu.kotatsu.base.ui.BaseViewModel
import org.koitharu.kotatsu.bookmarks.domain.Bookmark import org.koitharu.kotatsu.bookmarks.domain.Bookmark
import org.koitharu.kotatsu.bookmarks.domain.BookmarksRepository 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.parser.MangaRepository
import org.koitharu.kotatsu.core.prefs.* import org.koitharu.kotatsu.core.prefs.*
import org.koitharu.kotatsu.history.domain.HistoryRepository import org.koitharu.kotatsu.history.domain.HistoryRepository
import org.koitharu.kotatsu.history.domain.PROGRESS_NONE 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.Manga
import org.koitharu.kotatsu.parsers.model.MangaChapter import org.koitharu.kotatsu.parsers.model.MangaChapter
import org.koitharu.kotatsu.parsers.model.MangaPage import org.koitharu.kotatsu.parsers.model.MangaPage
@ -251,7 +251,7 @@ class ReaderViewModel(
private fun loadImpl() { private fun loadImpl() {
loadingJob = launchLoadingJob(Dispatchers.Default) { 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 mangaData.value = manga
val repo = MangaRepository(manga.source) val repo = MangaRepository(manga.source)
manga = repo.getDetails(manga) manga = repo.getDetails(manga)

@ -8,6 +8,7 @@ import org.koitharu.kotatsu.R
import org.koitharu.kotatsu.core.exceptions.* import org.koitharu.kotatsu.core.exceptions.*
import org.koitharu.kotatsu.parsers.exception.AuthRequiredException import org.koitharu.kotatsu.parsers.exception.AuthRequiredException
import org.koitharu.kotatsu.parsers.exception.ContentUnavailableException 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.ParseException
import java.net.SocketTimeoutException import java.net.SocketTimeoutException
@ -24,6 +25,7 @@ fun Throwable.getDisplayMessage(resources: Resources): String = when (this) {
is ParseException -> shortMessage is ParseException -> shortMessage
is SocketTimeoutException -> resources.getString(R.string.network_error) is SocketTimeoutException -> resources.getString(R.string.network_error)
is WrongPasswordException -> resources.getString(R.string.wrong_password) is WrongPasswordException -> resources.getString(R.string.wrong_password)
is NotFoundException -> resources.getString(R.string.not_found_404)
else -> localizedMessage else -> localizedMessage
} ?: resources.getString(R.string.error_occurred) } ?: resources.getString(R.string.error_occurred)
@ -32,7 +34,7 @@ fun Throwable.isReportable(): Boolean {
return true return true
} }
return this is ParseException || this is IllegalArgumentException || 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?) { fun Throwable.report(message: String?) {

@ -314,4 +314,7 @@
<string name="status_completed">Abgeschlossen</string> <string name="status_completed">Abgeschlossen</string>
<string name="exclude_nsfw_from_history_summary">Manga, die als NSFW markiert sind, werden nicht in den Verlauf aufgenommen und Ihr Fortschritt wird nicht gespeichert.</string> <string name="exclude_nsfw_from_history_summary">Manga, die als NSFW markiert sind, werden nicht in den Verlauf aufgenommen und Ihr Fortschritt wird nicht gespeichert.</string>
<string name="data_deletion">Datenlöschung</string> <string name="data_deletion">Datenlöschung</string>
<string name="invalid_domain_message">Ungültige Domäne</string>
<string name="status_reading">Lesen</string>
<string name="select_range">Bereich auswählen</string>
</resources> </resources>

@ -317,4 +317,5 @@
<string name="exclude_nsfw_from_history_summary">El manga marcado como NSFW nunca se añadirá al historial y no se guardará tu progreso</string> <string name="exclude_nsfw_from_history_summary">El manga marcado como NSFW nunca se añadirá al historial y no se guardará tu progreso</string>
<string name="clear_cookies_summary">Puede ayudar en caso de algunos problemas. Todas las autorizaciones serán invalidadas</string> <string name="clear_cookies_summary">Puede ayudar en caso de algunos problemas. Todas las autorizaciones serán invalidadas</string>
<string name="show_all">Mostrar todo</string> <string name="show_all">Mostrar todo</string>
<string name="invalid_domain_message">Dominio no válido</string>
</resources> </resources>

@ -308,4 +308,5 @@
<string name="status_re_reading">Lukemassa uudelleen</string> <string name="status_re_reading">Lukemassa uudelleen</string>
<string name="data_deletion">Tietojen poistaminen</string> <string name="data_deletion">Tietojen poistaminen</string>
<string name="show_all">Näytä kaikki</string> <string name="show_all">Näytä kaikki</string>
<string name="select_range">Valitse alue</string>
</resources> </resources>

@ -317,4 +317,6 @@
<string name="logout">Se déconnecter</string> <string name="logout">Se déconnecter</string>
<string name="status_completed">Terminé</string> <string name="status_completed">Terminé</string>
<string name="status_re_reading">Relecture</string> <string name="status_re_reading">Relecture</string>
<string name="invalid_domain_message">Domaine invalide</string>
<string name="select_range">Sélectionner une plage</string>
</resources> </resources>

@ -317,4 +317,6 @@
<string name="status_planned">Pianificato</string> <string name="status_planned">Pianificato</string>
<string name="status_completed">Finito</string> <string name="status_completed">Finito</string>
<string name="status_dropped">Abbandonato</string> <string name="status_dropped">Abbandonato</string>
<string name="invalid_domain_message">Dominio non valido</string>
<string name="select_range">Seleziona l\'intervallo</string>
</resources> </resources>

@ -317,4 +317,5 @@
<string name="show_reading_indicators">読書の進行状況インジケーターを表示</string> <string name="show_reading_indicators">読書の進行状況インジケーターを表示</string>
<string name="exclude_nsfw_from_history_summary">NSFWとマークされたマンガは履歴に追加されず、進行状況も保存されない</string> <string name="exclude_nsfw_from_history_summary">NSFWとマークされたマンガは履歴に追加されず、進行状況も保存されない</string>
<string name="show_all">すべて表示</string> <string name="show_all">すべて表示</string>
<string name="invalid_domain_message">無効なドメイン</string>
</resources> </resources>

@ -317,4 +317,6 @@
<string name="status_planned">Planlandı</string> <string name="status_planned">Planlandı</string>
<string name="status_re_reading">Yeniden okunuyor</string> <string name="status_re_reading">Yeniden okunuyor</string>
<string name="show_all">Tümünü göster</string> <string name="show_all">Tümünü göster</string>
<string name="invalid_domain_message">Geçersiz etki alanı</string>
<string name="select_range">Aralık seç</string>
</resources> </resources>

@ -302,4 +302,20 @@
<string name="use_fingerprint">Використовувати відбиток пальця, якщо доступно</string> <string name="use_fingerprint">Використовувати відбиток пальця, якщо доступно</string>
<string name="appwidget_shelf_description">Манга з Вашого улюбленого</string> <string name="appwidget_shelf_description">Манга з Вашого улюбленого</string>
<string name="appwidget_recent_description">Манга, яку Ви нещодавно читали</string> <string name="appwidget_recent_description">Манга, яку Ви нещодавно читали</string>
<string name="invalid_domain_message">Недійсний домен</string>
<string name="report">Звіт</string>
<string name="tracking">Відстеження</string>
<string name="logout">Вийти</string>
<string name="status_planned">Заплановано</string>
<string name="status_reading">Читаю</string>
<string name="status_re_reading">Перечитую</string>
<string name="status_completed">Завершено</string>
<string name="status_on_hold">Відкладено</string>
<string name="status_dropped">Занедбано</string>
<string name="show_reading_indicators">Показувати індикатори прогресу читання</string>
<string name="data_deletion">Видалення даних</string>
<string name="show_reading_indicators_summary">Показати відсоток прочитаного в історії та обраному</string>
<string name="exclude_nsfw_from_history_summary">Манґа, позначена як NSFW, ніколи не буде додана до історії і ваш прогрес не буде збережений</string>
<string name="clear_cookies_summary">Може допомогти в разі виникнення проблем. Усі авторизації будуть анульовані</string>
<string name="show_all">Показати всі</string>
</resources> </resources>

@ -357,4 +357,5 @@
<string name="removed_from_favourites">Removed from favourites</string> <string name="removed_from_favourites">Removed from favourites</string>
<string name="removed_from_s">Removed from \"%s\"</string> <string name="removed_from_s">Removed from \"%s\"</string>
<string name="options">Options</string> <string name="options">Options</string>
<string name="not_found_404">Content not found or removed</string>
</resources> </resources>

@ -1,15 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<paths> <paths>
<external-files-path <!-- https://issuetracker.google.com/issues/37125252 -->
name="manga-ext" <!--suppress AndroidElementNotAllowed -->
path="/manga" /> <root-path
<files-path name="root"
name="manga" path="." />
path="/manga" />
<external-files-path
name="backups-ext"
path="/backups" />
<files-path
name="backups"
path="/backups" />
</paths> </paths>
Loading…
Cancel
Save