Add methods to get manga and chapter url (#8114)
* Add methods to get manga and chapter url Some fork supports directly opening chapters with webview hence `getChapterUrl` * Review Changes * Add since to javadoc (cherry picked from commit de23226591376e998e4ff1ff7b2d4c2a0a805b09) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaController.kt
This commit is contained in:
parent
71076bd56a
commit
41542517f7
@ -19,7 +19,6 @@ import com.bluelinelabs.conductor.ControllerChangeType
|
|||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import eu.kanade.data.chapter.NoChaptersException
|
import eu.kanade.data.chapter.NoChaptersException
|
||||||
import eu.kanade.domain.UnsortedPreferences
|
import eu.kanade.domain.UnsortedPreferences
|
||||||
import eu.kanade.domain.manga.model.toDbManga
|
|
||||||
import eu.kanade.presentation.components.ChangeCategoryDialog
|
import eu.kanade.presentation.components.ChangeCategoryDialog
|
||||||
import eu.kanade.presentation.components.ChapterDownloadAction
|
import eu.kanade.presentation.components.ChapterDownloadAction
|
||||||
import eu.kanade.presentation.components.DuplicateMangaDialog
|
import eu.kanade.presentation.components.DuplicateMangaDialog
|
||||||
@ -312,7 +311,7 @@ class MangaController : FullComposeController<MangaPresenter> {
|
|||||||
source ?: return
|
source ?: return
|
||||||
manga ?: return
|
manga ?: return
|
||||||
val url = try {
|
val url = try {
|
||||||
source.mangaDetailsRequest(manga.toDbManga()).url.toString()
|
source.getMangaUrl(manga.toSManga())
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -322,12 +321,12 @@ class MangaController : FullComposeController<MangaPresenter> {
|
|||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun shareManga() {
|
private fun shareManga() {
|
||||||
val context = view?.context ?: return
|
val context = view?.context ?: return
|
||||||
val manga = presenter.manga ?: return
|
val manga = presenter.manga ?: return
|
||||||
val source = presenter.source as? HttpSource ?: return
|
val source = presenter.source as? HttpSource ?: return
|
||||||
try {
|
try {
|
||||||
val url = source.mangaDetailsRequest(manga.toDbManga()).url.toString()
|
val url = source.getMangaUrl(manga.toSManga())
|
||||||
val intent = Intent(Intent.ACTION_SEND).apply {
|
val intent = Intent(Intent.ACTION_SEND).apply {
|
||||||
type = "text/plain"
|
type = "text/plain"
|
||||||
putExtra(Intent.EXTRA_TEXT, url)
|
putExtra(Intent.EXTRA_TEXT, url)
|
||||||
|
@ -390,6 +390,28 @@ abstract class HttpSource : CatalogueSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the url of the provided manga
|
||||||
|
*
|
||||||
|
* @since extensions-lib 1.4
|
||||||
|
* @param manga the manga
|
||||||
|
* @return url of the manga
|
||||||
|
*/
|
||||||
|
open fun getMangaUrl(manga: SManga): String {
|
||||||
|
return mangaDetailsRequest(manga).url.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the url of the provided chapter
|
||||||
|
*
|
||||||
|
* @since extensions-lib 1.4
|
||||||
|
* @param chapter the chapter
|
||||||
|
* @return url of the chapter
|
||||||
|
*/
|
||||||
|
open fun getChapterUrl(chapter: SChapter): String {
|
||||||
|
return pageListRequest(chapter).url.toString()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before inserting a new chapter into database. Use it if you need to override chapter
|
* Called before inserting a new chapter into database. Use it if you need to override chapter
|
||||||
* fields, like the title or the chapter number. Do not change anything to [manga].
|
* fields, like the title or the chapter number. Do not change anything to [manga].
|
||||||
|
Loading…
x
Reference in New Issue
Block a user