Minor project updates

- Update kotlinter
- Opt in to serialization API to avoid IDE warnings
- Replace some deprecated OkHttp function usages
- Remove some unnecessary Android version checks/targets
This commit is contained in:
arkon 2022-01-02 18:47:56 -05:00
parent 27d26f2814
commit 542c28875d
10 changed files with 127 additions and 131 deletions

View File

@ -10,7 +10,7 @@ buildscript {
classpath 'com.android.tools.build:gradle:4.2.1' classpath 'com.android.tools.build:gradle:4.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
classpath 'org.jmailen.gradle:kotlinter-gradle:3.3.0' classpath 'org.jmailen.gradle:kotlinter-gradle:3.4.0'
} }
} }

View File

@ -57,6 +57,7 @@ android {
kotlinOptions { kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString() jvmTarget = JavaVersion.VERSION_1_8.toString()
freeCompilerArgs += "-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi"
} }
} }

View File

@ -10,7 +10,7 @@ import android.webkit.WebViewClient
import okhttp3.Interceptor import okhttp3.Interceptor
import okhttp3.Request import okhttp3.Request
import okhttp3.Response import okhttp3.Response
import okhttp3.ResponseBody import okhttp3.ResponseBody.Companion.toResponseBody
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get import uy.kohesive.injekt.api.get
import java.io.IOException import java.io.IOException
@ -72,9 +72,7 @@ class RemoteStorageUtils {
webview.webViewClient = object : WebViewClient() { webview.webViewClient = object : WebViewClient() {
override fun onPageFinished(view: WebView, url: String) { override fun onPageFinished(view: WebView, url: String) {
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) { view.evaluateJavascript(jsScript) {}
view.evaluateJavascript(jsScript) {}
}
if (transparent) { if (transparent) {
latch.countDown() latch.countDown()
} }
@ -94,7 +92,7 @@ class RemoteStorageUtils {
return if (transparent) { return if (transparent) {
response response
} else { } else {
response.newBuilder().body(ResponseBody.create(response.body?.contentType(), jsInterface.payload)).build() response.newBuilder().body(jsInterface.payload.toResponseBody(response.body?.contentType())).build()
} }
} }
} }

View File

@ -19,6 +19,7 @@ import java.io.IOException
import java.util.concurrent.CountDownLatch import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
// TODO: remove after new stable release
class CloudflareWafInterceptor(private val cookieDomain: String) : Interceptor { class CloudflareWafInterceptor(private val cookieDomain: String) : Interceptor {
private val context = Injekt.get<Application>() private val context = Injekt.get<Application>()
private val handler by lazy { Handler(Looper.getMainLooper()) } private val handler by lazy { Handler(Looper.getMainLooper()) }

View File

@ -28,7 +28,6 @@ import okhttp3.Headers
import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import okhttp3.Request import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.RequestBody.Companion.toRequestBody
import okhttp3.Response import okhttp3.Response
import uy.kohesive.injekt.injectLazy import uy.kohesive.injekt.injectLazy

View File

@ -499,15 +499,15 @@ class MangaDoom : HttpSource() {
private fun generateFilterContent(): List<Pair<String, String>>? { private fun generateFilterContent(): List<Pair<String, String>>? {
fun responseToGenreFilterContentPair(genreResponse: Response): fun responseToGenreFilterContentPair(genreResponse: Response):
List<Pair<String, String>> { List<Pair<String, String>> {
val document = genreResponse.asJsoup() val document = genreResponse.asJsoup()
return document.select("ul.manga-cat > li").map { return document.select("ul.manga-cat > li").map {
Pair( Pair(
it.select("span.fa").first().attr("data-id"), it.select("span.fa").first().attr("data-id"),
it.ownText() it.ownText()
) )
}
} }
}
val genreResponse = client val genreResponse = client
.newCall( .newCall(

View File

@ -9,7 +9,7 @@ import com.drew.metadata.exif.ExifSubIFDDirectory
import okhttp3.Interceptor import okhttp3.Interceptor
import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.Response import okhttp3.Response
import okhttp3.ResponseBody import okhttp3.ResponseBody.Companion.toResponseBody
import java.io.ByteArrayInputStream import java.io.ByteArrayInputStream
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.io.InputStream import java.io.InputStream
@ -23,7 +23,7 @@ class VizImageInterceptor : Interceptor {
return response return response
val image = decodeImage(response.body!!.byteStream()) val image = decodeImage(response.body!!.byteStream())
val body = ResponseBody.create(MEDIA_TYPE, image) val body = image.toResponseBody(MEDIA_TYPE)
return response.newBuilder() return response.newBuilder()
.body(body) .body(body)
.build() .build()

View File

@ -1,13 +1,11 @@
package eu.kanade.tachiyomi.extension.fr.japscan package eu.kanade.tachiyomi.extension.fr.japscan
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.annotation.TargetApi
import android.app.Application import android.app.Application
import android.content.SharedPreferences import android.content.SharedPreferences
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.Canvas import android.graphics.Canvas
import android.net.Uri import android.net.Uri
import android.os.Build
import android.os.Handler import android.os.Handler
import android.os.Looper import android.os.Looper
import android.util.Log import android.util.Log
@ -377,7 +375,6 @@ class Japscan : ConfigurableSource, ParsedHttpSource() {
webview.settings.domStorageEnabled = true webview.settings.domStorageEnabled = true
webview.settings.userAgentString = webview.settings.userAgentString.replace("Mobile", "eliboM").replace("Android", "diordnA") webview.settings.userAgentString = webview.settings.userAgentString.replace("Mobile", "eliboM").replace("Android", "diordnA")
webview.webViewClient = object : WebViewClient() { webview.webViewClient = object : WebViewClient() {
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
override fun shouldInterceptRequest( override fun shouldInterceptRequest(
view: WebView, view: WebView,
request: WebResourceRequest request: WebResourceRequest

View File

@ -122,25 +122,25 @@ class ComX : ParsedHttpSource() {
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request { override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
/** val url = "$baseUrl/index.php?do=xsearch&searchCat=comix-read&page=$page".toHttpUrlOrNull()!!.newBuilder() /** val url = "$baseUrl/index.php?do=xsearch&searchCat=comix-read&page=$page".toHttpUrlOrNull()!!.newBuilder()
(if (filters.isEmpty()) getFilterList() else filters).forEach { filter -> (if (filters.isEmpty()) getFilterList() else filters).forEach { filter ->
when (filter) { when (filter) {
is TypeList -> filter.state.forEach { type -> is TypeList -> filter.state.forEach { type ->
if (type.state) { if (type.state) {
url.addQueryParameter("field[type][${type.id}]", 1.toString()) url.addQueryParameter("field[type][${type.id}]", 1.toString())
} }
} }
is PubList -> filter.state.forEach { publisher -> is PubList -> filter.state.forEach { publisher ->
if (publisher.state) { if (publisher.state) {
url.addQueryParameter("subCat[]", publisher.id) url.addQueryParameter("subCat[]", publisher.id)
} }
} }
is GenreList -> filter.state.forEach { genre -> is GenreList -> filter.state.forEach { genre ->
if (genre.state) { if (genre.state) {
url.addQueryParameter("field[genre][${genre.id}]", 1.toString()) url.addQueryParameter("field[genre][${genre.id}]", 1.toString())
} }
} }
} }
}**/ }**/
if (query.isNotEmpty()) { if (query.isNotEmpty()) {
return POST( return POST(
"$baseUrl/index.php?do=search&search_start=$page", "$baseUrl/index.php?do=search&search_start=$page",
@ -259,102 +259,102 @@ class ComX : ParsedHttpSource() {
return GET(page.imageUrl!!, headers) return GET(page.imageUrl!!, headers)
} }
/** /**
private class CheckFilter(name: String, val id: String) : Filter.CheckBox(name) private class CheckFilter(name: String, val id: String) : Filter.CheckBox(name)
private class TypeList(types: List<CheckFilter>) : Filter.Group<CheckFilter>("Тип выпуска", types) private class TypeList(types: List<CheckFilter>) : Filter.Group<CheckFilter>("Тип выпуска", types)
private class PubList(publishers: List<CheckFilter>) : Filter.Group<CheckFilter>("Разделы", publishers) private class PubList(publishers: List<CheckFilter>) : Filter.Group<CheckFilter>("Разделы", publishers)
private class GenreList(genres: List<CheckFilter>) : Filter.Group<CheckFilter>("Жанры", genres) private class GenreList(genres: List<CheckFilter>) : Filter.Group<CheckFilter>("Жанры", genres)
override fun getFilterList() = FilterList( override fun getFilterList() = FilterList(
TypeList(getTypeList()), TypeList(getTypeList()),
PubList(getPubList()), PubList(getPubList()),
GenreList(getGenreList()), GenreList(getGenreList()),
) )
private fun getTypeList() = listOf( private fun getTypeList() = listOf(
CheckFilter("Лимитка", "1"), CheckFilter("Лимитка", "1"),
CheckFilter("Ван шот", "2"), CheckFilter("Ван шот", "2"),
CheckFilter("Графический Роман", "3"), CheckFilter("Графический Роман", "3"),
CheckFilter("Онгоинг", "4"), CheckFilter("Онгоинг", "4"),
) )
private fun getPubList() = listOf( private fun getPubList() = listOf(
CheckFilter("Marvel", "2"), CheckFilter("Marvel", "2"),
CheckFilter("DC Comics", "14"), CheckFilter("DC Comics", "14"),
CheckFilter("Dark Horse", "7"), CheckFilter("Dark Horse", "7"),
CheckFilter("IDW Publishing", "6"), CheckFilter("IDW Publishing", "6"),
CheckFilter("Image", "4"), CheckFilter("Image", "4"),
CheckFilter("Vertigo", "8"), CheckFilter("Vertigo", "8"),
CheckFilter("Dynamite Entertainment", "10"), CheckFilter("Dynamite Entertainment", "10"),
CheckFilter("Wildstorm", "5"), CheckFilter("Wildstorm", "5"),
CheckFilter("Avatar Press", "11"), CheckFilter("Avatar Press", "11"),
CheckFilter("Boom! Studios", "12"), CheckFilter("Boom! Studios", "12"),
CheckFilter("Top Cow", "9"), CheckFilter("Top Cow", "9"),
CheckFilter("Oni Press", "13"), CheckFilter("Oni Press", "13"),
CheckFilter("Valiant", "15"), CheckFilter("Valiant", "15"),
CheckFilter("Icon Comics", "16"), CheckFilter("Icon Comics", "16"),
CheckFilter("Manga", "3"), CheckFilter("Manga", "3"),
CheckFilter("Manhua", "45"), CheckFilter("Manhua", "45"),
CheckFilter("Manhwa", "44"), CheckFilter("Manhwa", "44"),
CheckFilter("Разные комиксы", "18") CheckFilter("Разные комиксы", "18")
) )
private fun getGenreList() = listOf( private fun getGenreList() = listOf(
CheckFilter("Sci-Fi", "2"), CheckFilter("Sci-Fi", "2"),
CheckFilter("Антиутопия", "3"), CheckFilter("Антиутопия", "3"),
CheckFilter("Апокалипсис", "4"), CheckFilter("Апокалипсис", "4"),
CheckFilter("Боевик", "5"), CheckFilter("Боевик", "5"),
CheckFilter("Боевые искусства", "6"), CheckFilter("Боевые искусства", "6"),
CheckFilter("Вампиры", "7"), CheckFilter("Вампиры", "7"),
CheckFilter("Вестерн", "8"), CheckFilter("Вестерн", "8"),
CheckFilter("Военный", "9"), CheckFilter("Военный", "9"),
CheckFilter("Детектив", "10"), CheckFilter("Детектив", "10"),
CheckFilter("Драма", "11"), CheckFilter("Драма", "11"),
CheckFilter("Зомби", "12"), CheckFilter("Зомби", "12"),
CheckFilter("Игры", "13"), CheckFilter("Игры", "13"),
CheckFilter("Исекай", "14"), CheckFilter("Исекай", "14"),
CheckFilter("Исторический", "15"), CheckFilter("Исторический", "15"),
CheckFilter("Киберпанк", "16"), CheckFilter("Киберпанк", "16"),
CheckFilter("Комедия", "17"), CheckFilter("Комедия", "17"),
CheckFilter("Космоопера", "18"), CheckFilter("Космоопера", "18"),
CheckFilter("Космос", "19"), CheckFilter("Космос", "19"),
CheckFilter("Криминал", "20"), CheckFilter("Криминал", "20"),
CheckFilter("МелоДрама", "21"), CheckFilter("МелоДрама", "21"),
CheckFilter("Мистика", "22"), CheckFilter("Мистика", "22"),
CheckFilter("Научная Фантастика", "23"), CheckFilter("Научная Фантастика", "23"),
CheckFilter("Неотвратимость", "24"), CheckFilter("Неотвратимость", "24"),
CheckFilter("Нуар", "25"), CheckFilter("Нуар", "25"),
CheckFilter("Паника", "26"), CheckFilter("Паника", "26"),
CheckFilter("Пародия", "27"), CheckFilter("Пародия", "27"),
CheckFilter("Повседневность", "28"), CheckFilter("Повседневность", "28"),
CheckFilter("Постапокалиптика", "29"), CheckFilter("Постапокалиптика", "29"),
CheckFilter("ПредательСредиНас", "30"), CheckFilter("ПредательСредиНас", "30"),
CheckFilter("Приключения", "31"), CheckFilter("Приключения", "31"),
CheckFilter("Путешествия во времени", "32"), CheckFilter("Путешествия во времени", "32"),
CheckFilter("Сверхъестественное", "33"), CheckFilter("Сверхъестественное", "33"),
CheckFilter("Слэшер", "34"), CheckFilter("Слэшер", "34"),
CheckFilter("Смерть", "35"), CheckFilter("Смерть", "35"),
CheckFilter("Супергерои", "36"), CheckFilter("Супергерои", "36"),
CheckFilter("Супергероика", "37"), CheckFilter("Супергероика", "37"),
CheckFilter("Сёнен", "38"), CheckFilter("Сёнен", "38"),
CheckFilter("Тревога", "39"), CheckFilter("Тревога", "39"),
CheckFilter("Триллер", "40"), CheckFilter("Триллер", "40"),
CheckFilter("Ужасы", "41"), CheckFilter("Ужасы", "41"),
CheckFilter("Фантасмагория", "42"), CheckFilter("Фантасмагория", "42"),
CheckFilter("Фантастика", "43"), CheckFilter("Фантастика", "43"),
CheckFilter("Фэнтези", "44"), CheckFilter("Фэнтези", "44"),
CheckFilter("Экшен", "45"), CheckFilter("Экшен", "45"),
CheckFilter("Экшн", "46"), CheckFilter("Экшн", "46"),
CheckFilter("Эротика", "47"), CheckFilter("Эротика", "47"),
CheckFilter("сэйнэн", "66"), CheckFilter("сэйнэн", "66"),
CheckFilter("сёдзё", "67"), CheckFilter("сёдзё", "67"),
CheckFilter("сёнэн", "68"), CheckFilter("сёнэн", "68"),
CheckFilter("сёнэн-ай", "69"), CheckFilter("сёнэн-ай", "69"),
CheckFilter("трагедия", "70"), CheckFilter("трагедия", "70"),
CheckFilter("фэнтези", "73"), CheckFilter("фэнтези", "73"),
CheckFilter("школа", "74"), CheckFilter("школа", "74"),
CheckFilter("этти", "76"), CheckFilter("этти", "76"),
CheckFilter("яой", "77"), CheckFilter("яой", "77"),
)**/ )**/
} }

View File

@ -37,7 +37,7 @@ class TencentComics : ParsedHttpSource() {
override val lang = "zh" override val lang = "zh"
override val supportsLatest = true override val supportsLatest = true
override val id: Long = 6353436350537369479 override val id: Long = 6353436350537369479
override val client: OkHttpClient = network.cloudflareClient override val client: OkHttpClient = network.cloudflareClient