Merge branch 'master' into protobuf

This commit is contained in:
Aria Moradi
2021-08-18 00:28:42 +04:30
19 changed files with 63 additions and 43 deletions
@@ -1,5 +0,0 @@
package kotlinx.coroutines.experimental.android
import kotlinx.coroutines.GlobalScope
val UI = GlobalScope.coroutineContext
@@ -4,11 +4,21 @@ import java.io.InputStream
import java.io.Reader
import java.math.BigDecimal
import java.net.URL
import java.sql.*
import java.sql.Array
import java.sql.Blob
import java.sql.Clob
import java.sql.Date
import java.util.*
import java.sql.NClob
import java.sql.Ref
import java.sql.ResultSet
import java.sql.ResultSetMetaData
import java.sql.RowId
import java.sql.SQLXML
import java.sql.Time
import java.sql.Timestamp
import java.util.Calendar
@Suppress("UNCHECKED_CAST")
class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
private val cachedContent = mutableListOf<ResultSetEntry>()
@@ -18,7 +18,7 @@ class ServiceSupport {
private val logger = KotlinLogging.logger {}
fun startService(context: Context, intent: Intent) {
fun startService(@Suppress("UNUSED_PARAMETER") context: Context, intent: Intent) {
val name = intentToClassName(intent)
logger.debug { "Starting service: $name" }
@@ -35,7 +35,7 @@ class ServiceSupport {
}
}
fun stopService(context: Context, intent: Intent) {
fun stopService(@Suppress("UNUSED_PARAMETER") context: Context, intent: Intent) {
val name = intentToClassName(intent)
stopService(name)
}
@@ -25,6 +25,7 @@ object KodeinGlobalHelper {
* Get a dependency
*/
@JvmStatic
@Suppress("UNCHECKED_CAST")
fun <T : Any> instance(type: Class<T>, kodein: DI? = null): T {
return when(type) {
AndroidFiles::class.java -> {
+7 -4
View File
@@ -1,8 +1,10 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.4.32"
kotlin("plugin.serialization") version "1.4.32" apply false
val kotlinVersion = "1.5.21"
kotlin("jvm") version kotlinVersion
kotlin("plugin.serialization") version kotlinVersion
}
allprojects {
@@ -46,12 +48,12 @@ configure(projects) {
testImplementation(kotlin("test-junit5"))
// coroutines
val coroutinesVersion = "1.4.3"
val coroutinesVersion = "1.5.0"
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$coroutinesVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion")
val kotlinSerializationVersion = "1.1.0"
val kotlinSerializationVersion = "1.2.1"
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlinSerializationVersion")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-protobuf:$kotlinSerializationVersion")
@@ -80,6 +82,7 @@ configure(projects) {
implementation("net.harawata:appdirs:1.2.1")
// dex2jar: https://github.com/DexPatcher/dex2jar/releases/tag/v2.1-20190905-lanchon
// note: watch https://github.com/ThexXTURBOXx/dex2jar for future development
implementation("com.github.DexPatcher.dex2jar:dex-tools:v2.1-20190905-lanchon")
// APK parser
+17 -11
View File
@@ -9,7 +9,7 @@ plugins {
application
id("com.github.johnrengelman.shadow") version "7.0.0"
id("org.jmailen.kotlinter") version "3.4.3"
id("de.fuerstenau.buildconfig") version "1.1.8"
id("com.github.gmazzo.buildconfig") version "3.0.2"
}
buildscript {
@@ -128,23 +128,29 @@ val tachideskRevision = runCatching {
}.getOrDefault("r0")
buildConfig {
clsName = "BuildConfig"
packageName = "suwayomi.tachidesk.server"
className("BuildConfig")
packageName("suwayomi.tachidesk.server")
useKotlinOutput()
buildConfigField("String", "NAME", rootProject.name)
buildConfigField("String", "VERSION", tachideskVersion)
buildConfigField("String", "REVISION", tachideskRevision)
buildConfigField("String", "BUILD_TYPE", if (System.getenv("ProductBuildType") == "Stable") "Stable" else "Preview")
fun str(obj: Any): String {
return "\"${obj}\""
}
buildConfigField("String", "NAME", str(rootProject.name))
buildConfigField("String", "VERSION", str(tachideskVersion))
buildConfigField("String", "REVISION", str(tachideskRevision))
buildConfigField("String", "BUILD_TYPE", str(if (System.getenv("ProductBuildType") == "Stable") "Stable" else "Preview"))
buildConfigField("long", "BUILD_TIME", Instant.now().epochSecond.toString())
buildConfigField("String", "WEBUI_REPO", "https://github.com/Suwayomi/Tachidesk-WebUI-preview")
buildConfigField("String", "WEBUI_TAG", webUIRevisionTag)
buildConfigField("String", "WEBUI_REPO", str("https://github.com/Suwayomi/Tachidesk-WebUI-preview"))
buildConfigField("String", "WEBUI_TAG", str(webUIRevisionTag))
buildConfigField("String", "GITHUB", "https://github.com/Suwayomi/Tachidesk")
buildConfigField("String", "DISCORD", "https://discord.gg/DDZdqZWaHA")
buildConfigField("String", "GITHUB", str("https://github.com/Suwayomi/Tachidesk"))
buildConfigField("String", "DISCORD", str("https://discord.gg/DDZdqZWaHA"))
}
tasks {
@@ -54,7 +54,7 @@ abstract class AnimeHttpSource : AnimeCatalogueSource {
* Note the generated id sets the sign bit to 0.
*/
override val id by lazy {
val key = "${name.toLowerCase()}/$lang/$versionId"
val key = "${name.lowercase()}/$lang/$versionId"
val bytes = MessageDigest.getInstance("MD5").digest(key.toByteArray())
(0..7).map { bytes[it].toLong() and 0xff shl 8 * (7 - it) }.reduce(Long::or) and Long.MAX_VALUE
}
@@ -80,7 +80,7 @@ abstract class AnimeHttpSource : AnimeCatalogueSource {
/**
* Visible name of the source.
*/
override fun toString() = "$name (${lang.toUpperCase()})"
override fun toString() = "$name (${lang.uppercase()})"
/**
* Returns an observable containing a page with a list of anime. Normally it's not needed to
@@ -18,6 +18,7 @@ import okhttp3.OkHttpClient
// import uy.kohesive.injekt.injectLazy
import java.util.concurrent.TimeUnit
@Suppress("UNUSED_PARAMETER")
class NetworkHelper(context: Context) {
// private val preferences: PreferencesHelper by injectLazy()
@@ -110,6 +110,7 @@ fun Call.asObservableSuccess(): Observable<Response> {
// return progressClient.newCall(request)
// }
@Suppress("UNUSED_PARAMETER")
fun OkHttpClient.newCallWithProgress(request: Request, listener: ProgressListener): Call {
val progressClient = newBuilder()
// .cache(null)
@@ -55,7 +55,7 @@ abstract class HttpSource : CatalogueSource {
* Note the generated id sets the sign bit to 0.
*/
override val id by lazy {
val key = "${name.toLowerCase()}/$lang/$versionId"
val key = "${name.lowercase()}/$lang/$versionId"
val bytes = MessageDigest.getInstance("MD5").digest(key.toByteArray())
(0..7).map { bytes[it].toLong() and 0xff shl 8 * (7 - it) }.reduce(Long::or) and Long.MAX_VALUE
}
@@ -81,7 +81,7 @@ abstract class HttpSource : CatalogueSource {
/**
* Visible name of the source.
*/
override fun toString() = "$name (${lang.toUpperCase()})"
override fun toString() = "$name (${lang.uppercase()})"
/**
* Returns an observable containing a page with a list of manga. Normally it's not needed to
@@ -7,7 +7,6 @@ package suwayomi.tachidesk.manga
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import io.javalin.Javalin
import io.javalin.apibuilder.ApiBuilder.delete
import io.javalin.apibuilder.ApiBuilder.get
import io.javalin.apibuilder.ApiBuilder.patch
@@ -22,7 +21,7 @@ import suwayomi.tachidesk.manga.controller.MangaController
import suwayomi.tachidesk.manga.controller.SourceController
object MangaAPI {
fun defineEndpoints(app: Javalin) {
fun defineEndpoints() {
path("extension") {
get("list", ExtensionController::list)
@@ -82,7 +81,7 @@ object MangaAPI {
patch(":categoryId", LibraryController::categoryModify)
delete(":categoryId", LibraryController::categoryDelete)
patch(":categoryId/reorder", LibraryController::categoryReorder)
patch(":categoryId/reorder", LibraryController::categoryReorder) // TODO: the underlying code doesn't need `:categoryId`, remove it
}
}
@@ -54,10 +54,9 @@ object LibraryController {
/** category re-ordering */
fun categoryReorder(ctx: Context) {
val categoryId = ctx.pathParam("categoryId").toInt()
val from = ctx.formParam("from")!!.toInt()
val to = ctx.formParam("to")!!.toInt()
Category.reorderCategory(categoryId, from, to)
Category.reorderCategory(from, to)
ctx.status(200)
}
}
@@ -47,7 +47,7 @@ object Category {
/**
* Move the category from position `from` to `to`
*/
fun reorderCategory(categoryId: Int, from: Int, to: Int) {
fun reorderCategory(from: Int, to: Int) {
transaction {
val categories = CategoryTable.selectAll().orderBy(CategoryTable.order to SortOrder.ASC).toMutableList()
categories.add(to - 1, categories.removeAt(from - 1))
@@ -20,15 +20,18 @@ object Search {
}
// TODO
@Suppress("UNUSED_PARAMETER", "UNUSED_VARIABLE")
fun sourceFilters(sourceId: Long) {
val source = getHttpSource(sourceId)
// source.getFilterList().toItems()
}
@Suppress("UNUSED_PARAMETER")
fun sourceGlobalSearch(searchTerm: String) {
// TODO
}
@Suppress("unused")
data class FilterWrapper(
val type: String,
val filter: Any
@@ -141,6 +141,7 @@ object LegacyBackupImport : LegacyBackupBase() {
* @param history history data from json
* @param tracks tracking data from json
*/
@Suppress("UNUSED_PARAMETER")
private suspend fun restoreMangaData(
manga: Manga,
source: Source,
@@ -204,6 +205,7 @@ object LegacyBackupImport : LegacyBackupBase() {
return fetchedManga
}
@Suppress("UNUSED_PARAMETER") // TODO: remove this suppress when update Chapters is written
private fun updateChapters(source: Source, fetchedManga: SManga, chapters: List<Chapter>) {
// TODO("Not yet implemented")
}
@@ -42,11 +42,11 @@ object LegacyBackupValidator {
.sorted()
}
val trackers = mangas
.filter { it.asJsonObject.has("track") }
.flatMap { it.asJsonObject["track"].asJsonArray }
.map { it.asJsonObject["s"].asInt }
.distinct()
// val trackers = mangas
// .filter { it.asJsonObject.has("track") }
// .flatMap { it.asJsonObject["track"].asJsonArray }
// .map { it.asJsonObject["s"].asInt }
// .distinct()
val missingTrackers = listOf("")
// val missingTrackers = trackers
@@ -85,7 +85,7 @@ object BytecodeEditor {
bytes[2],
bytes[3]
)
if (cafebabe.toLowerCase() != "cafebabe") {
if (cafebabe.lowercase() != "cafebabe") {
// Corrupted class
return@use null
}
@@ -81,7 +81,7 @@ object JavalinSetup {
app.routes {
path("api/v1/") {
GlobalAPI.defineEndpoints()
MangaAPI.defineEndpoints(app)
MangaAPI.defineEndpoints()
AnimeAPI.defineEndpoints(app) // TODO: migrate Anime endpoints
}
}
@@ -72,7 +72,7 @@ class TestExtensions {
sources = getSourceList().map { getHttpSource(it.id.toLong()) }
}
setLoggingEnabled(true)
File("tmp/TestDesk/sources.txt").writeText(sources.joinToString("\n") { "${it.name} - ${it.lang.toUpperCase()} - ${it.id}" })
File("tmp/TestDesk/sources.txt").writeText(sources.joinToString("\n") { "${it.name} - ${it.lang.uppercase()} - ${it.id}" })
}
@Test
@@ -99,7 +99,7 @@ class TestExtensions {
}.awaitAll()
File("tmp/TestDesk/failedToFetch.txt").writeText(
failedToFetch.joinToString("\n") { (source, exception) ->
"${source.name} (${source.lang.toUpperCase()}, ${source.id}):" +
"${source.name} (${source.lang.uppercase()}, ${source.id}):" +
" ${exception.message}"
}
)