From f807447de1da3f2959c7d2f392dd8e1d04ea2d22 Mon Sep 17 00:00:00 2001 From: len Date: Fri, 20 Jan 2017 21:27:53 +0100 Subject: [PATCH] Rename OnlineSource to HttpSource --- .../tachiyomi/data/download/DownloadStore.kt | 4 ++-- .../kanade/tachiyomi/data/download/Downloader.kt | 6 +++--- .../tachiyomi/data/download/model/Download.kt | 4 ++-- .../tachiyomi/data/glide/MangaModelLoader.kt | 4 ++-- .../data/library/LibraryUpdateService.kt | 6 +++--- .../eu/kanade/tachiyomi/source/SourceManager.kt | 16 ++++++++-------- .../online/{OnlineSource.kt => HttpSource.kt} | 4 ++-- ...lineSourceFetcher.kt => HttpSourceFetcher.kt} | 14 +++++++------- ...ParsedOnlineSource.kt => ParsedHttpSource.kt} | 2 +- .../{YamlOnlineSource.kt => YamlHttpSource.kt} | 2 +- ...urceMappings.kt => YamlHttpSourceMappings.kt} | 0 .../tachiyomi/source/online/english/Batoto.kt | 4 ++-- .../tachiyomi/source/online/english/Kissmanga.kt | 4 ++-- .../tachiyomi/source/online/english/Mangafox.kt | 4 ++-- .../tachiyomi/source/online/english/Mangahere.kt | 4 ++-- .../tachiyomi/source/online/english/Mangasee.kt | 4 ++-- .../source/online/english/Readmangatoday.kt | 4 ++-- .../tachiyomi/source/online/german/WieManga.kt | 4 ++-- .../tachiyomi/source/online/russian/Mangachan.kt | 4 ++-- .../tachiyomi/source/online/russian/Mintmanga.kt | 4 ++-- .../tachiyomi/source/online/russian/Readmanga.kt | 4 ++-- .../tachiyomi/ui/manga/info/MangaInfoFragment.kt | 6 +++--- .../kanade/tachiyomi/ui/reader/ChapterLoader.kt | 6 +++--- .../tachiyomi/ui/reader/ReaderPresenter.kt | 6 +++--- .../ui/setting/SettingsSourcesFragment.kt | 4 ++-- .../kanade/tachiyomi/util/ChapterSourceSync.kt | 4 ++-- .../widget/preference/LoginCheckBoxPreference.kt | 4 ++-- .../data/library/LibraryUpdateServiceTest.kt | 6 +++--- 28 files changed, 69 insertions(+), 69 deletions(-) rename app/src/main/java/eu/kanade/tachiyomi/source/online/{OnlineSource.kt => HttpSource.kt} (96%) rename app/src/main/java/eu/kanade/tachiyomi/source/online/{OnlineSourceFetcher.kt => HttpSourceFetcher.kt} (80%) rename app/src/main/java/eu/kanade/tachiyomi/source/online/{ParsedOnlineSource.kt => ParsedHttpSource.kt} (96%) rename app/src/main/java/eu/kanade/tachiyomi/source/online/{YamlOnlineSource.kt => YamlHttpSource.kt} (96%) rename app/src/main/java/eu/kanade/tachiyomi/source/online/{YamlOnlineSourceMappings.kt => YamlHttpSourceMappings.kt} (100%) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadStore.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadStore.kt index adbfe0d331..4edf6b7612 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadStore.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadStore.kt @@ -6,7 +6,7 @@ import eu.kanade.tachiyomi.data.database.DatabaseHelper import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.source.SourceManager -import eu.kanade.tachiyomi.source.online.OnlineSource +import eu.kanade.tachiyomi.source.online.HttpSource import uy.kohesive.injekt.injectLazy /** @@ -93,7 +93,7 @@ class DownloadStore(context: Context) { val manga = cachedManga.getOrPut(mangaId) { db.getManga(mangaId).executeAsBlocking() } ?: continue - val source = sourceManager.get(manga.source) as? OnlineSource ?: continue + val source = sourceManager.get(manga.source) as? HttpSource ?: continue val chapter = db.getChapter(chapterId).executeAsBlocking() ?: continue downloads.add(Download(source, manga, chapter)) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt index 73929709a8..bc48dc95ab 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/Downloader.kt @@ -12,7 +12,7 @@ import eu.kanade.tachiyomi.data.download.model.DownloadQueue import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.model.Page -import eu.kanade.tachiyomi.source.online.OnlineSource +import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.source.online.fetchAllImageUrlsFromPageList import eu.kanade.tachiyomi.util.DynamicConcurrentMergeOperator import eu.kanade.tachiyomi.util.RetryWithDelay @@ -220,7 +220,7 @@ class Downloader(private val context: Context, private val provider: DownloadPro * @param chapters the list of chapters to download. */ fun queueChapters(manga: Manga, chapters: List) { - val source = sourceManager.get(manga.source) as? OnlineSource ?: return + val source = sourceManager.get(manga.source) as? HttpSource ?: return val chaptersToQueue = chapters // Avoid downloading chapters with the same name. @@ -373,7 +373,7 @@ class Downloader(private val context: Context, private val provider: DownloadPro * @param tmpDir the temporary directory of the download. * @param filename the filename of the image. */ - private fun downloadImage(page: Page, source: OnlineSource, tmpDir: UniFile, filename: String): Observable { + private fun downloadImage(page: Page, source: HttpSource, tmpDir: UniFile, filename: String): Observable { page.status = Page.DOWNLOAD_IMAGE page.progress = 0 return source.fetchImage(page) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/model/Download.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/model/Download.kt index bb9821e21c..9c2b503e93 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/model/Download.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/model/Download.kt @@ -3,10 +3,10 @@ package eu.kanade.tachiyomi.data.download.model import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.source.model.Page -import eu.kanade.tachiyomi.source.online.OnlineSource +import eu.kanade.tachiyomi.source.online.HttpSource import rx.subjects.PublishSubject -class Download(val source: OnlineSource, val manga: Manga, val chapter: Chapter) { +class Download(val source: HttpSource, val manga: Manga, val chapter: Chapter) { var pages: List? = null diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/glide/MangaModelLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/data/glide/MangaModelLoader.kt index 273ace468c..663de0c8e0 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/glide/MangaModelLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/glide/MangaModelLoader.kt @@ -9,7 +9,7 @@ import com.bumptech.glide.load.model.stream.StreamModelLoader import eu.kanade.tachiyomi.data.cache.CoverCache import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.source.SourceManager -import eu.kanade.tachiyomi.source.online.OnlineSource +import eu.kanade.tachiyomi.source.online.HttpSource import uy.kohesive.injekt.injectLazy import java.io.File import java.io.InputStream @@ -102,7 +102,7 @@ class MangaModelLoader(context: Context) : StreamModelLoader { * @param manga the model. */ fun getHeaders(manga: Manga): Headers { - val source = sourceManager.get(manga.source) as? OnlineSource ?: return LazyHeaders.DEFAULT + val source = sourceManager.get(manga.source) as? HttpSource ?: return LazyHeaders.DEFAULT return cachedHeaders.getOrPut(manga.source) { LazyHeaders.Builder().apply { val nullStr: String? = null diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt index 26d2ace8c0..766107486d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt @@ -22,7 +22,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.model.SManga -import eu.kanade.tachiyomi.source.online.OnlineSource +import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.util.* import rx.Observable @@ -300,7 +300,7 @@ class LibraryUpdateService : Service() { * @return a pair of the inserted and removed chapters. */ fun updateManga(manga: Manga): Observable, List>> { - val source = sourceManager.get(manga.source) as? OnlineSource ?: return Observable.empty() + val source = sourceManager.get(manga.source) as? HttpSource ?: return Observable.empty() return source.fetchChapterList(manga) .map { syncChaptersWithSource(db, it, manga, source) } } @@ -324,7 +324,7 @@ class LibraryUpdateService : Service() { .doOnNext { showProgressNotification(it, count.andIncrement, mangaToUpdate.size, cancelPendingIntent) } // Update the details of the manga. .concatMap { manga -> - val source = sourceManager.get(manga.source) as? OnlineSource + val source = sourceManager.get(manga.source) as? HttpSource ?: return@concatMap Observable.empty() source.fetchMangaDetails(manga) diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/SourceManager.kt b/app/src/main/java/eu/kanade/tachiyomi/source/SourceManager.kt index 065cfadc0c..3c618d9bfe 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/SourceManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/SourceManager.kt @@ -7,8 +7,8 @@ import android.content.pm.PackageManager import android.os.Environment import dalvik.system.PathClassLoader import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.source.online.OnlineSource -import eu.kanade.tachiyomi.source.online.YamlOnlineSource +import eu.kanade.tachiyomi.source.online.HttpSource +import eu.kanade.tachiyomi.source.online.YamlHttpSource import eu.kanade.tachiyomi.source.online.english.* import eu.kanade.tachiyomi.source.online.german.WieManga import eu.kanade.tachiyomi.source.online.russian.Mangachan @@ -31,7 +31,7 @@ open class SourceManager(private val context: Context) { return sourcesMap[sourceKey] } - fun getOnlineSources() = sourcesMap.values.filterIsInstance() + fun getOnlineSources() = sourcesMap.values.filterIsInstance() fun getCatalogueSources() = sourcesMap.values.filterIsInstance() @@ -71,7 +71,7 @@ open class SourceManager(private val context: Context) { for (file in parsersDir.listFiles().filter { it.extension == "yml" }) { try { val map = file.inputStream().use { yaml.loadAs(it, Map::class.java) } - sources.add(YamlOnlineSource(map)) + sources.add(YamlHttpSource(map)) } catch (e: Exception) { Timber.e("Error loading source from file. Bad format?") } @@ -80,13 +80,13 @@ open class SourceManager(private val context: Context) { return sources } - private fun createExtensionSources(): List { + private fun createExtensionSources(): List { val pkgManager = context.packageManager val flags = PackageManager.GET_CONFIGURATIONS or PackageManager.GET_SIGNATURES val installedPkgs = pkgManager.getInstalledPackages(flags) val extPkgs = installedPkgs.filter { it.reqFeatures.orEmpty().any { it.name == FEATURE } } - val sources = mutableListOf() + val sources = mutableListOf() for (pkgInfo in extPkgs) { val appInfo = pkgManager.getApplicationInfo(pkgInfo.packageName, PackageManager.GET_META_DATA) ?: continue @@ -121,12 +121,12 @@ open class SourceManager(private val context: Context) { return true } - private fun loadExtension(ext: Extension, pkgManager: PackageManager): OnlineSource? { + private fun loadExtension(ext: Extension, pkgManager: PackageManager): HttpSource? { return try { val classLoader = PathClassLoader(ext.appInfo.sourceDir, null, context.classLoader) val resources = pkgManager.getResourcesForApplication(ext.appInfo) - Class.forName(ext.sourceClass, false, classLoader).newInstance() as? OnlineSource + Class.forName(ext.sourceClass, false, classLoader).newInstance() as? HttpSource } catch (e: Exception) { null } catch (e: LinkageError) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/OnlineSource.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt similarity index 96% rename from app/src/main/java/eu/kanade/tachiyomi/source/online/OnlineSource.kt rename to app/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt index 804fdcb7ab..3378509f98 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/OnlineSource.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt @@ -1,10 +1,10 @@ package eu.kanade.tachiyomi.source.online +import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.network.asObservableSuccess import eu.kanade.tachiyomi.network.newCallWithProgress -import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.source.CatalogueSource import eu.kanade.tachiyomi.source.model.* import okhttp3.Headers @@ -20,7 +20,7 @@ import java.security.MessageDigest /** * A simple implementation for sources from a website. */ -abstract class OnlineSource : CatalogueSource { +abstract class HttpSource : CatalogueSource { /** * Network service. diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/OnlineSourceFetcher.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/HttpSourceFetcher.kt similarity index 80% rename from app/src/main/java/eu/kanade/tachiyomi/source/online/OnlineSourceFetcher.kt rename to app/src/main/java/eu/kanade/tachiyomi/source/online/HttpSourceFetcher.kt index b2857b775e..02810c7bde 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/OnlineSourceFetcher.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/HttpSourceFetcher.kt @@ -21,7 +21,7 @@ private val chapterCache: ChapterCache by injectLazy() * * @param chapter the chapter whose page list has to be fetched. */ -fun OnlineSource.fetchPageListFromCacheThenNet(chapter: Chapter): Observable> { +fun HttpSource.fetchPageListFromCacheThenNet(chapter: Chapter): Observable> { return chapterCache .getPageListFromCache(chapter) .onErrorResumeNext { fetchPageList(chapter) } @@ -32,14 +32,14 @@ fun OnlineSource.fetchPageListFromCacheThenNet(chapter: Chapter): Observable { +fun HttpSource.fetchImageFromCacheThenNet(page: Page): Observable { return if (page.imageUrl.isNullOrEmpty()) getImageUrl(page).flatMap { getCachedImage(it) } else getCachedImage(page) } -fun OnlineSource.getImageUrl(page: Page): Observable { +fun HttpSource.getImageUrl(page: Page): Observable { page.status = Page.LOAD_PAGE return fetchImageUrl(page) .doOnError { page.status = Page.ERROR } @@ -54,7 +54,7 @@ fun OnlineSource.getImageUrl(page: Page): Observable { * * @param page the page. */ -fun OnlineSource.getCachedImage(page: Page): Observable { +fun HttpSource.getCachedImage(page: Page): Observable { val imageUrl = page.imageUrl ?: return Observable.just(page) return Observable.just(page) @@ -78,20 +78,20 @@ fun OnlineSource.getCachedImage(page: Page): Observable { * * @param page the page. */ -private fun OnlineSource.cacheImage(page: Page): Observable { +private fun HttpSource.cacheImage(page: Page): Observable { page.status = Page.DOWNLOAD_IMAGE return fetchImage(page) .doOnNext { chapterCache.putImageToCache(page.imageUrl!!, it) } .map { page } } -fun OnlineSource.fetchAllImageUrlsFromPageList(pages: List): Observable { +fun HttpSource.fetchAllImageUrlsFromPageList(pages: List): Observable { return Observable.from(pages) .filter { !it.imageUrl.isNullOrEmpty() } .mergeWith(fetchRemainingImageUrlsFromPageList(pages)) } -fun OnlineSource.fetchRemainingImageUrlsFromPageList(pages: List): Observable { +fun HttpSource.fetchRemainingImageUrlsFromPageList(pages: List): Observable { return Observable.from(pages) .filter { it.imageUrl.isNullOrEmpty() } .concatMap { getImageUrl(it) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/ParsedOnlineSource.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/ParsedHttpSource.kt similarity index 96% rename from app/src/main/java/eu/kanade/tachiyomi/source/online/ParsedOnlineSource.kt rename to app/src/main/java/eu/kanade/tachiyomi/source/online/ParsedHttpSource.kt index 5124a9b57f..6053fc2b69 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/ParsedOnlineSource.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/ParsedHttpSource.kt @@ -12,7 +12,7 @@ import org.jsoup.nodes.Element /** * A simple implementation for sources from a website using Jsoup, an HTML parser. */ -abstract class ParsedOnlineSource : OnlineSource() { +abstract class ParsedHttpSource : HttpSource() { /** * Parses the response from the site and returns a [MangasPage] object. diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/YamlOnlineSource.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/YamlHttpSource.kt similarity index 96% rename from app/src/main/java/eu/kanade/tachiyomi/source/online/YamlOnlineSource.kt rename to app/src/main/java/eu/kanade/tachiyomi/source/online/YamlHttpSource.kt index 5b26c77ba3..2d907a53bf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/YamlOnlineSource.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/YamlHttpSource.kt @@ -12,7 +12,7 @@ import org.jsoup.nodes.Element import java.text.SimpleDateFormat import java.util.* -class YamlOnlineSource(mappings: Map<*, *>) : OnlineSource() { +class YamlHttpSource(mappings: Map<*, *>) : HttpSource() { val map = YamlSourceNode(mappings) diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/YamlOnlineSourceMappings.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/YamlHttpSourceMappings.kt similarity index 100% rename from app/src/main/java/eu/kanade/tachiyomi/source/online/YamlOnlineSourceMappings.kt rename to app/src/main/java/eu/kanade/tachiyomi/source/online/YamlHttpSourceMappings.kt diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Batoto.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Batoto.kt index 043ddff773..d8f35cfb29 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Batoto.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Batoto.kt @@ -6,7 +6,7 @@ import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.network.asObservable import eu.kanade.tachiyomi.source.model.* import eu.kanade.tachiyomi.source.online.LoginSource -import eu.kanade.tachiyomi.source.online.ParsedOnlineSource +import eu.kanade.tachiyomi.source.online.ParsedHttpSource import eu.kanade.tachiyomi.util.asJsoup import eu.kanade.tachiyomi.util.selectText import okhttp3.FormBody @@ -22,7 +22,7 @@ import java.text.SimpleDateFormat import java.util.* import java.util.regex.Pattern -class Batoto : ParsedOnlineSource(), LoginSource { +class Batoto : ParsedHttpSource(), LoginSource { override val id: Long = 1 diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Kissmanga.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Kissmanga.kt index b3845008ed..1ebff79d84 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Kissmanga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Kissmanga.kt @@ -3,7 +3,7 @@ package eu.kanade.tachiyomi.source.online.english import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.source.model.* -import eu.kanade.tachiyomi.source.online.ParsedOnlineSource +import eu.kanade.tachiyomi.source.online.ParsedHttpSource import okhttp3.FormBody import okhttp3.OkHttpClient import okhttp3.Request @@ -13,7 +13,7 @@ import org.jsoup.nodes.Element import java.text.SimpleDateFormat import java.util.regex.Pattern -class Kissmanga : ParsedOnlineSource() { +class Kissmanga : ParsedHttpSource() { override val id: Long = 4 diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangafox.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangafox.kt index 2f547f82ff..5ea36d8e01 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangafox.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangafox.kt @@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.source.online.english import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.source.model.* -import eu.kanade.tachiyomi.source.online.ParsedOnlineSource +import eu.kanade.tachiyomi.source.online.ParsedHttpSource import okhttp3.HttpUrl import okhttp3.Request import org.jsoup.nodes.Document @@ -11,7 +11,7 @@ import java.text.ParseException import java.text.SimpleDateFormat import java.util.* -class Mangafox : ParsedOnlineSource() { +class Mangafox : ParsedHttpSource() { override val id: Long = 3 diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangahere.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangahere.kt index 880e234432..74b4411e3c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangahere.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangahere.kt @@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.source.online.english import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.source.model.* -import eu.kanade.tachiyomi.source.online.ParsedOnlineSource +import eu.kanade.tachiyomi.source.online.ParsedHttpSource import okhttp3.HttpUrl import okhttp3.Request import org.jsoup.nodes.Document @@ -11,7 +11,7 @@ import java.text.ParseException import java.text.SimpleDateFormat import java.util.* -class Mangahere : ParsedOnlineSource() { +class Mangahere : ParsedHttpSource() { override val id: Long = 2 diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangasee.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangasee.kt index f82bcf5c1f..abac69d584 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangasee.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Mangasee.kt @@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.source.online.english import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.source.model.* -import eu.kanade.tachiyomi.source.online.ParsedOnlineSource +import eu.kanade.tachiyomi.source.online.ParsedHttpSource import okhttp3.FormBody import okhttp3.HttpUrl import okhttp3.Request @@ -11,7 +11,7 @@ import org.jsoup.nodes.Element import java.text.SimpleDateFormat import java.util.regex.Pattern -class Mangasee : ParsedOnlineSource() { +class Mangasee : ParsedHttpSource() { override val id: Long = 9 diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Readmangatoday.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Readmangatoday.kt index 06f2d8b999..c4c476a048 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Readmangatoday.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/english/Readmangatoday.kt @@ -3,7 +3,7 @@ package eu.kanade.tachiyomi.source.online.english import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.network.POST import eu.kanade.tachiyomi.source.model.* -import eu.kanade.tachiyomi.source.online.ParsedOnlineSource +import eu.kanade.tachiyomi.source.online.ParsedHttpSource import okhttp3.Headers import okhttp3.OkHttpClient import okhttp3.Request @@ -11,7 +11,7 @@ import org.jsoup.nodes.Document import org.jsoup.nodes.Element import java.util.* -class Readmangatoday : ParsedOnlineSource() { +class Readmangatoday : ParsedHttpSource() { override val id: Long = 8 diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/german/WieManga.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/german/WieManga.kt index e6699d538c..b680ae9056 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/german/WieManga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/german/WieManga.kt @@ -5,13 +5,13 @@ import eu.kanade.tachiyomi.source.model.FilterList import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga -import eu.kanade.tachiyomi.source.online.ParsedOnlineSource +import eu.kanade.tachiyomi.source.online.ParsedHttpSource import okhttp3.Request import org.jsoup.nodes.Document import org.jsoup.nodes.Element import java.text.SimpleDateFormat -class WieManga : ParsedOnlineSource() { +class WieManga : ParsedHttpSource() { override val id: Long = 10 diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mangachan.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mangachan.kt index 0e2fc993a6..3444418acc 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mangachan.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mangachan.kt @@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.source.online.russian import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.source.model.* -import eu.kanade.tachiyomi.source.online.ParsedOnlineSource +import eu.kanade.tachiyomi.source.online.ParsedHttpSource import eu.kanade.tachiyomi.util.asJsoup import okhttp3.Request import okhttp3.Response @@ -11,7 +11,7 @@ import org.jsoup.nodes.Element import java.text.SimpleDateFormat import java.util.* -class Mangachan : ParsedOnlineSource() { +class Mangachan : ParsedHttpSource() { override val id: Long = 7 diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mintmanga.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mintmanga.kt index d4466de687..1ea8269917 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mintmanga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Mintmanga.kt @@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.source.online.russian import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.source.model.* -import eu.kanade.tachiyomi.source.online.ParsedOnlineSource +import eu.kanade.tachiyomi.source.online.ParsedHttpSource import okhttp3.Request import okhttp3.Response import org.jsoup.nodes.Document @@ -11,7 +11,7 @@ import java.text.SimpleDateFormat import java.util.* import java.util.regex.Pattern -class Mintmanga : ParsedOnlineSource() { +class Mintmanga : ParsedHttpSource() { override val id: Long = 6 diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Readmanga.kt b/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Readmanga.kt index 5c19ac62a4..d8ec69e56c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Readmanga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/online/russian/Readmanga.kt @@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.source.online.russian import eu.kanade.tachiyomi.network.GET import eu.kanade.tachiyomi.source.model.* -import eu.kanade.tachiyomi.source.online.ParsedOnlineSource +import eu.kanade.tachiyomi.source.online.ParsedHttpSource import okhttp3.Request import okhttp3.Response import org.jsoup.nodes.Document @@ -11,7 +11,7 @@ import java.text.SimpleDateFormat import java.util.* import java.util.regex.Pattern -class Readmanga : ParsedOnlineSource() { +class Readmanga : ParsedHttpSource() { override val id: Long = 5 diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoFragment.kt index c33097e7a1..5b808ff73f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/info/MangaInfoFragment.kt @@ -16,7 +16,7 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.model.SManga -import eu.kanade.tachiyomi.source.online.OnlineSource +import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.ui.base.fragment.BaseRxFragment import eu.kanade.tachiyomi.ui.manga.MangaActivity import eu.kanade.tachiyomi.util.getResourceColor @@ -164,7 +164,7 @@ class MangaInfoFragment : BaseRxFragment() { * Open the manga in browser. */ fun openInBrowser() { - val source = presenter.source as? OnlineSource ?: return + val source = presenter.source as? HttpSource ?: return try { val url = Uri.parse(source.baseUrl + presenter.manga.url) val intent = CustomTabsIntent.Builder() @@ -180,7 +180,7 @@ class MangaInfoFragment : BaseRxFragment() { * Called to run Intent with [Intent.ACTION_SEND], which show share dialog. */ private fun shareManga() { - val source = presenter.source as? OnlineSource ?: return + val source = presenter.source as? HttpSource ?: return try { val url = source.mangaDetailsRequest(presenter.manga).url().toString() val sharingIntent = Intent(Intent.ACTION_SEND).apply { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ChapterLoader.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ChapterLoader.kt index 3258c220e1..88b2b184f2 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ChapterLoader.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ChapterLoader.kt @@ -4,7 +4,7 @@ import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.model.Page -import eu.kanade.tachiyomi.source.online.OnlineSource +import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.source.online.fetchImageFromCacheThenNet import eu.kanade.tachiyomi.source.online.fetchPageListFromCacheThenNet import eu.kanade.tachiyomi.util.plusAssign @@ -39,7 +39,7 @@ class ChapterLoader( } private fun prepareOnlineReading() { - if (source !is OnlineSource) return + if (source !is HttpSource) return subscriptions += Observable.defer { Observable.just(queue.take().page) } .filter { it.status == Page.QUEUE } @@ -85,7 +85,7 @@ class ChapterLoader( // Fetch the page list from disk. downloadManager.buildPageList(source, manga, chapter) } else { - (source as? OnlineSource)?.fetchPageListFromCacheThenNet(chapter) + (source as? HttpSource)?.fetchPageListFromCacheThenNet(chapter) ?: source.fetchPageList(chapter) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index 7881623631..82fd55f078 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -15,7 +15,7 @@ import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.model.Page -import eu.kanade.tachiyomi.source.online.OnlineSource +import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.TrackUpdateService import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter @@ -348,7 +348,7 @@ class ReaderPresenter : BasePresenter() { * @param page the page that failed. */ fun retryPage(page: Page?) { - if (page != null && source is OnlineSource) { + if (page != null && source is HttpSource) { page.status = Page.QUEUE val uri = page.uri if (uri != null && !page.chapter.isDownloaded) { @@ -372,7 +372,7 @@ class ReaderPresenter : BasePresenter() { // Cache current page list progress for online chapters to allow a faster reopen if (!chapter.isDownloaded) { source.let { - if (it is OnlineSource) chapterCache.putPageListToCache(chapter, pages) + if (it is HttpSource) chapterCache.putPageListToCache(chapter, pages) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSourcesFragment.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSourcesFragment.kt index 20a4f82acc..6f9349a5db 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSourcesFragment.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsSourcesFragment.kt @@ -8,7 +8,7 @@ import android.view.View import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.source.SourceManager -import eu.kanade.tachiyomi.source.online.OnlineSource +import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.widget.preference.LoginCheckBoxPreference import eu.kanade.tachiyomi.widget.preference.SourceLoginDialog import eu.kanade.tachiyomi.widget.preference.SwitchPreferenceCategory @@ -87,7 +87,7 @@ class SettingsSourcesFragment : SettingsFragment() { * * @param group the language category. */ - private fun addLanguageSources(group: SwitchPreferenceCategory, sources: List) { + private fun addLanguageSources(group: SwitchPreferenceCategory, sources: List) { val hiddenCatalogues = preferences.hiddenCatalogues().getOrDefault() sources.forEach { source -> diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/ChapterSourceSync.kt b/app/src/main/java/eu/kanade/tachiyomi/util/ChapterSourceSync.kt index abb681c52e..7a705fe66e 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/ChapterSourceSync.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/ChapterSourceSync.kt @@ -5,7 +5,7 @@ import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.source.Source import eu.kanade.tachiyomi.source.model.SChapter -import eu.kanade.tachiyomi.source.online.OnlineSource +import eu.kanade.tachiyomi.source.online.HttpSource import java.util.* /** @@ -42,7 +42,7 @@ fun syncChaptersWithSource(db: DatabaseHelper, // Recognize number for new chapters. toAdd.forEach { - if (source is OnlineSource) { + if (source is HttpSource) { source.prepareNewChapter(it, manga) } ChapterRecognition.parseChapterNumber(it, manga) diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginCheckBoxPreference.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginCheckBoxPreference.kt index 7a3d76caca..c120358d5c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginCheckBoxPreference.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginCheckBoxPreference.kt @@ -7,7 +7,7 @@ import android.util.AttributeSet import android.view.View import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.source.online.LoginSource -import eu.kanade.tachiyomi.source.online.OnlineSource +import eu.kanade.tachiyomi.source.online.HttpSource import eu.kanade.tachiyomi.util.getResourceColor import eu.kanade.tachiyomi.util.setVectorCompat import kotlinx.android.synthetic.main.pref_item_source.view.* @@ -15,7 +15,7 @@ import net.xpece.android.support.preference.CheckBoxPreference class LoginCheckBoxPreference @JvmOverloads constructor( context: Context, - val source: OnlineSource, + val source: HttpSource, attrs: AttributeSet? = null ) : CheckBoxPreference(context, attrs) { diff --git a/app/src/test/java/eu/kanade/tachiyomi/data/library/LibraryUpdateServiceTest.kt b/app/src/test/java/eu/kanade/tachiyomi/data/library/LibraryUpdateServiceTest.kt index 4da9011efa..069d1ce36d 100644 --- a/app/src/test/java/eu/kanade/tachiyomi/data/library/LibraryUpdateServiceTest.kt +++ b/app/src/test/java/eu/kanade/tachiyomi/data/library/LibraryUpdateServiceTest.kt @@ -10,7 +10,7 @@ import eu.kanade.tachiyomi.data.database.models.Chapter import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.model.SChapter -import eu.kanade.tachiyomi.source.online.OnlineSource +import eu.kanade.tachiyomi.source.online.HttpSource import org.assertj.core.api.Assertions.assertThat import org.junit.Before import org.junit.Test @@ -35,7 +35,7 @@ class LibraryUpdateServiceTest { lateinit var app: Application lateinit var context: Context lateinit var service: LibraryUpdateService - lateinit var source: OnlineSource + lateinit var source: HttpSource @Before fun setup() { @@ -51,7 +51,7 @@ class LibraryUpdateServiceTest { Injekt.importModule(module) service = Robolectric.setupService(LibraryUpdateService::class.java) - source = mock(OnlineSource::class.java) + source = mock(HttpSource::class.java) `when`(service.sourceManager.get(anyLong())).thenReturn(source) }