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 "org.jetbrains.kotlin:kotlin-gradle-plugin:$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 {
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.Request
import okhttp3.Response
import okhttp3.ResponseBody
import okhttp3.ResponseBody.Companion.toResponseBody
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.io.IOException
@ -72,9 +72,7 @@ class RemoteStorageUtils {
webview.webViewClient = object : WebViewClient() {
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) {
latch.countDown()
}
@ -94,7 +92,7 @@ class RemoteStorageUtils {
return if (transparent) {
response
} 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.TimeUnit
// TODO: remove after new stable release
class CloudflareWafInterceptor(private val cookieDomain: String) : Interceptor {
private val context = Injekt.get<Application>()
private val handler by lazy { Handler(Looper.getMainLooper()) }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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