mirror of
https://github.com/Suwayomi/Tachidesk.git
synced 2025-12-10 06:42:07 +01:00
aftermath of adding kotlinter to all modules
This commit is contained in:
@@ -6,7 +6,7 @@ import org.kodein.di.singleton
|
||||
|
||||
class ConfigKodeinModule {
|
||||
fun create() = DI.Module("ConfigManager") {
|
||||
//Config module
|
||||
// Config module
|
||||
bind<ConfigManager>() with singleton { GlobalConfigManager }
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ open class ConfigManager {
|
||||
private val generatedModules = mutableMapOf<Class<out ConfigModule>, ConfigModule>()
|
||||
val config by lazy { loadConfigs() }
|
||||
|
||||
//Public read-only view of modules
|
||||
// Public read-only view of modules
|
||||
val loadedModules: Map<Class<out ConfigModule>, ConfigModule>
|
||||
get() = generatedModules
|
||||
|
||||
@@ -42,7 +42,7 @@ open class ConfigManager {
|
||||
* Load configs
|
||||
*/
|
||||
fun loadConfigs(): Config {
|
||||
//Load reference configs
|
||||
// Load reference configs
|
||||
val compatConfig = ConfigFactory.parseResources("compat-reference.conf")
|
||||
val serverConfig = ConfigFactory.parseResources("server-reference.conf")
|
||||
val baseConfig =
|
||||
@@ -52,13 +52,12 @@ open class ConfigManager {
|
||||
)
|
||||
)
|
||||
|
||||
//Load user config
|
||||
// Load user config
|
||||
val userConfig =
|
||||
File(ApplicationRootDir, "server.conf").let {
|
||||
ConfigFactory.parseFile(it)
|
||||
}
|
||||
|
||||
|
||||
val config = ConfigFactory.empty()
|
||||
.withFallback(baseConfig)
|
||||
.withFallback(userConfig)
|
||||
|
||||
@@ -20,7 +20,7 @@ abstract class ConfigModule(config: Config)
|
||||
/**
|
||||
* Abstract jvm-commandline-argument-overridable config module.
|
||||
*/
|
||||
abstract class SystemPropertyOverridableConfigModule(config: Config, moduleName: String): ConfigModule(config) {
|
||||
abstract class SystemPropertyOverridableConfigModule(config: Config, moduleName: String) : ConfigModule(config) {
|
||||
val overridableConfig = SystemPropertyOverrideDelegate(config, moduleName)
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class SystemPropertyOverrideDelegate(val config: Config, val moduleName: String)
|
||||
configValue.toString()
|
||||
)
|
||||
|
||||
return when(T::class.simpleName) {
|
||||
return when (T::class.simpleName) {
|
||||
"Int" -> combined.toInt()
|
||||
"Boolean" -> combined.toBoolean()
|
||||
// add more types as needed
|
||||
|
||||
@@ -16,5 +16,5 @@ fun setLogLevel(level: Level) {
|
||||
(KotlinLogging.logger(Logger.ROOT_LOGGER_NAME).underlyingLogger as ch.qos.logback.classic.Logger).level = level
|
||||
}
|
||||
|
||||
fun debugLogsEnabled(config: Config)
|
||||
= System.getProperty("suwayomi.tachidesk.config.server.debugLogsEnabled", config.getString("server.debugLogsEnabled")).toBoolean()
|
||||
fun debugLogsEnabled(config: Config) =
|
||||
System.getProperty("suwayomi.tachidesk.config.server.debugLogsEnabled", config.getString("server.debugLogsEnabled")).toBoolean()
|
||||
|
||||
@@ -9,8 +9,10 @@ import android.content.Context
|
||||
class PreferenceManager {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun getDefaultSharedPreferences(context: Context)
|
||||
= context.getSharedPreferences(context.applicationInfo.packageName,
|
||||
Context.MODE_PRIVATE)!!
|
||||
fun getDefaultSharedPreferences(context: Context) =
|
||||
context.getSharedPreferences(
|
||||
context.applicationInfo.packageName,
|
||||
Context.MODE_PRIVATE
|
||||
)!!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class AndroidCompatInitializer {
|
||||
fun init() {
|
||||
DI.global.addImport(AndroidCompatModule().create())
|
||||
|
||||
//Register config modules
|
||||
// Register config modules
|
||||
GlobalConfigManager.registerModules(
|
||||
FilesConfigModule.register(GlobalConfigManager.config),
|
||||
ApplicationInfoConfigModule.register(GlobalConfigManager.config),
|
||||
|
||||
@@ -29,7 +29,7 @@ class AndroidCompatModule {
|
||||
|
||||
bind<PackageController>() with singleton { PackageController() }
|
||||
|
||||
//Context
|
||||
// Context
|
||||
bind<CustomContext>() with singleton { CustomContext() }
|
||||
bind<Context>() with singleton {
|
||||
val context: Context by DI.global.instance<CustomContext>()
|
||||
|
||||
@@ -13,7 +13,7 @@ class ApplicationInfoConfigModule(config: Config) : ConfigModule(config) {
|
||||
val debug: Boolean by config
|
||||
|
||||
companion object {
|
||||
fun register(config: Config)
|
||||
= ApplicationInfoConfigModule(config.getConfig("android.app"))
|
||||
fun register(config: Config) =
|
||||
ApplicationInfoConfigModule(config.getConfig("android.app"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,26 +9,26 @@ import xyz.nulldev.ts.config.ConfigModule
|
||||
*/
|
||||
|
||||
class FilesConfigModule(config: Config) : ConfigModule(config) {
|
||||
val dataDir:String by config
|
||||
val filesDir:String by config
|
||||
val noBackupFilesDir:String by config
|
||||
val dataDir: String by config
|
||||
val filesDir: String by config
|
||||
val noBackupFilesDir: String by config
|
||||
val externalFilesDirs: MutableList<String> by config
|
||||
val obbDirs: MutableList<String> by config
|
||||
val cacheDir:String by config
|
||||
val codeCacheDir:String by config
|
||||
val cacheDir: String by config
|
||||
val codeCacheDir: String by config
|
||||
val externalCacheDirs: MutableList<String> by config
|
||||
val externalMediaDirs: MutableList<String> by config
|
||||
val rootDir:String by config
|
||||
val externalStorageDir:String by config
|
||||
val downloadCacheDir:String by config
|
||||
val databasesDir:String by config
|
||||
val rootDir: String by config
|
||||
val externalStorageDir: String by config
|
||||
val downloadCacheDir: String by config
|
||||
val databasesDir: String by config
|
||||
|
||||
val prefsDir:String by config
|
||||
val prefsDir: String by config
|
||||
|
||||
val packageDir:String by config
|
||||
val packageDir: String by config
|
||||
|
||||
companion object {
|
||||
fun register(config: Config)
|
||||
= FilesConfigModule(config.getConfig("android.files"))
|
||||
fun register(config: Config) =
|
||||
FilesConfigModule(config.getConfig("android.files"))
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package xyz.nulldev.androidcompat.config
|
||||
|
||||
import com.typesafe.config.Config
|
||||
import xyz.nulldev.ts.config.ConfigModule
|
||||
import io.github.config4k.getValue
|
||||
import xyz.nulldev.ts.config.ConfigModule
|
||||
|
||||
class SystemConfigModule(val config: Config) : ConfigModule(config) {
|
||||
val isDebuggable: Boolean by config
|
||||
@@ -16,7 +16,7 @@ class SystemConfigModule(val config: Config) : ConfigModule(config) {
|
||||
fun hasProperty(property: String) = config.hasPath("$propertyPrefix$property")
|
||||
|
||||
companion object {
|
||||
fun register(config: Config)
|
||||
= SystemConfigModule(config.getConfig("android.system"))
|
||||
fun register(config: Config) =
|
||||
SystemConfigModule(config.getConfig("android.system"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
|
||||
val parentMetadata = parent.metaData
|
||||
val columnCount = parentMetadata.columnCount
|
||||
val columnLabels = (1 .. columnCount).map {
|
||||
val columnLabels = (1..columnCount).map {
|
||||
parentMetadata.getColumnLabel(it)
|
||||
}.toTypedArray()
|
||||
|
||||
@@ -41,10 +41,10 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
// How can we optimize this?
|
||||
// We need to fill the cache as the set is loaded
|
||||
|
||||
//Fill cache
|
||||
while(parent.next()) {
|
||||
// Fill cache
|
||||
while (parent.next()) {
|
||||
cachedContent += ResultSetEntry().apply {
|
||||
for(i in 1 .. columnCount)
|
||||
for (i in 1..columnCount)
|
||||
data += parent.getObject(i)
|
||||
}
|
||||
resultSetLength++
|
||||
@@ -60,8 +60,8 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
}
|
||||
|
||||
private fun internalMove(row: Int) {
|
||||
if(cursor < 0) cursor = 0
|
||||
else if(cursor > resultSetLength + 1) cursor = resultSetLength + 1
|
||||
if (cursor < 0) cursor = 0
|
||||
else if (cursor > resultSetLength + 1) cursor = resultSetLength + 1
|
||||
else cursor = row
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return obj(cachedFindColumn(column))
|
||||
}
|
||||
|
||||
private fun cachedFindColumn(column: String?)
|
||||
= columnCache.getOrPut(column!!, {
|
||||
private fun cachedFindColumn(column: String?) =
|
||||
columnCache.getOrPut(column!!, {
|
||||
findColumn(column)
|
||||
})
|
||||
|
||||
@@ -157,27 +157,27 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
}
|
||||
|
||||
override fun getDate(columnIndex: Int): Date {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getDate(columnLabel: String?): Date {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getDate(columnIndex: Int, cal: Calendar?): Date {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getDate(columnLabel: String?, cal: Calendar?): Date {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun beforeFirst() {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -202,12 +202,12 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
}
|
||||
|
||||
override fun getBigDecimal(columnIndex: Int, scale: Int): BigDecimal {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getBigDecimal(columnLabel: String?, scale: Int): BigDecimal {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -236,22 +236,22 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
}
|
||||
|
||||
override fun getTime(columnIndex: Int): Time {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getTime(columnLabel: String?): Time {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getTime(columnIndex: Int, cal: Calendar?): Time {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getTime(columnLabel: String?, cal: Calendar?): Time {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -272,28 +272,28 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
}
|
||||
|
||||
override fun absolute(row: Int): Boolean {
|
||||
if(row > 0) {
|
||||
if (row > 0) {
|
||||
internalMove(row)
|
||||
} else {
|
||||
last()
|
||||
for(i in 1 .. row)
|
||||
for (i in 1..row)
|
||||
previous()
|
||||
}
|
||||
return cursorValid()
|
||||
}
|
||||
|
||||
override fun getSQLXML(columnIndex: Int): SQLXML? {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getSQLXML(columnLabel: String?): SQLXML? {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun <T : Any?> unwrap(iface: Class<T>?): T {
|
||||
if(thisIsWrapperFor(iface))
|
||||
if (thisIsWrapperFor(iface))
|
||||
return this as T
|
||||
else
|
||||
return parent.unwrap(iface)
|
||||
@@ -426,12 +426,12 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
}
|
||||
|
||||
override fun getBlob(columnIndex: Int): Blob {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getBlob(columnLabel: String?): Blob {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -500,12 +500,12 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
}
|
||||
|
||||
override fun getObject(columnIndex: Int, map: MutableMap<String, Class<*>>?): Any {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getObject(columnLabel: String?, map: MutableMap<String, Class<*>>?): Any {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -531,9 +531,9 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
}
|
||||
|
||||
private fun castToLong(obj: Any?): Long {
|
||||
if(obj == null) return 0
|
||||
else if(obj is Long) return obj
|
||||
else if(obj is Number) return obj.toLong()
|
||||
if (obj == null) return 0
|
||||
else if (obj is Long) return obj
|
||||
else if (obj is Number) return obj.toLong()
|
||||
else throw IllegalStateException("Object is not a long!")
|
||||
}
|
||||
|
||||
@@ -546,12 +546,12 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
}
|
||||
|
||||
override fun getClob(columnIndex: Int): Clob {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getClob(columnLabel: String?): Clob {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -604,12 +604,12 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
}
|
||||
|
||||
override fun getArray(columnIndex: Int): Array {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getArray(columnLabel: String?): Array {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -688,32 +688,32 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
}
|
||||
|
||||
override fun getTimestamp(columnIndex: Int): Timestamp {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getTimestamp(columnLabel: String?): Timestamp {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getTimestamp(columnIndex: Int, cal: Calendar?): Timestamp {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getTimestamp(columnLabel: String?, cal: Calendar?): Timestamp {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getRef(columnIndex: Int): Ref {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getRef(columnLabel: String?): Ref {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -792,12 +792,12 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
}
|
||||
|
||||
override fun getRowId(columnIndex: Int): RowId {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getRowId(columnLabel: String?): RowId {
|
||||
//TODO Maybe?
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@ import java.io.File
|
||||
import javax.imageio.ImageIO
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
|
||||
|
||||
|
||||
data class InstalledPackage(val root: File) {
|
||||
val apk = File(root, "package.apk")
|
||||
val jar = File(root, "translated.jar")
|
||||
@@ -40,13 +38,17 @@ data class InstalledPackage(val root: File) {
|
||||
}?.filter {
|
||||
it.tagName == "meta-data"
|
||||
}?.map {
|
||||
putString(it.attributes.getNamedItem("android:name").nodeValue,
|
||||
it.attributes.getNamedItem("android:value").nodeValue)
|
||||
putString(
|
||||
it.attributes.getNamedItem("android:name").nodeValue,
|
||||
it.attributes.getNamedItem("android:value").nodeValue
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
it.signatures = (parsed.apkSingers.flatMap { it.certificateMetas }
|
||||
/*+ parsed.apkV2Singers.flatMap { it.certificateMetas }*/) // Blocked by: https://github.com/hsiafan/apk-parser/issues/72
|
||||
it.signatures = (
|
||||
parsed.apkSingers.flatMap { it.certificateMetas }
|
||||
/*+ parsed.apkV2Singers.flatMap { it.certificateMetas }*/
|
||||
) // Blocked by: https://github.com/hsiafan/apk-parser/issues/72
|
||||
.map { Signature(it.data) }.toTypedArray()
|
||||
}
|
||||
|
||||
@@ -69,7 +71,7 @@ data class InstalledPackage(val root: File) {
|
||||
}.sortedByDescending { it.width * it.height }.firstOrNull() ?: return
|
||||
|
||||
ImageIO.write(read, "png", icon)
|
||||
} catch(e: Exception) {
|
||||
} catch (e: Exception) {
|
||||
icon.delete()
|
||||
}
|
||||
}
|
||||
@@ -77,7 +79,7 @@ data class InstalledPackage(val root: File) {
|
||||
fun writeJar() {
|
||||
try {
|
||||
Dex2jar.from(apk).to(jar.toPath())
|
||||
} catch(e: Exception) {
|
||||
} catch (e: Exception) {
|
||||
jar.delete()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class PackageController {
|
||||
if (!installed.jar.exists()) {
|
||||
throw IllegalStateException("Failed to translate APK dex!")
|
||||
}
|
||||
} catch(t: Throwable) {
|
||||
} catch (t: Throwable) {
|
||||
root.deleteRecursively()
|
||||
throw t
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class PackageController {
|
||||
}
|
||||
|
||||
fun deletePackage(pack: InstalledPackage) {
|
||||
if(!pack.root.exists()) error("Package was never installed!")
|
||||
if (!pack.root.exists()) error("Package was never installed!")
|
||||
|
||||
val packageName = pack.info.packageName
|
||||
pack.root.deleteRecursively()
|
||||
@@ -74,7 +74,7 @@ class PackageController {
|
||||
|
||||
fun findPackage(packageName: String): InstalledPackage? {
|
||||
val file = File(androidFiles.packagesDir, packageName)
|
||||
return if(file.exists())
|
||||
return if (file.exists())
|
||||
InstalledPackage(file)
|
||||
else
|
||||
null
|
||||
|
||||
@@ -27,10 +27,10 @@ class ServiceSupport {
|
||||
|
||||
runningServices[name] = service
|
||||
|
||||
//Setup service
|
||||
// Setup service
|
||||
thread {
|
||||
callOnCreate(service)
|
||||
//TODO Handle more complex cases
|
||||
// TODO Handle more complex cases
|
||||
service.onStartCommand(intent, 0, 0)
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,7 @@ class ServiceSupport {
|
||||
fun stopService(name: String) {
|
||||
logger.debug { "Stopping service: $name" }
|
||||
val service = runningServices.remove(name)
|
||||
if(service == null) {
|
||||
if (service == null) {
|
||||
logger.warn { "An attempt was made to stop a service that is not running: $name" }
|
||||
} else {
|
||||
thread {
|
||||
|
||||
@@ -27,7 +27,7 @@ object KodeinGlobalHelper {
|
||||
@JvmStatic
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T : Any> instance(type: Class<T>, kodein: DI? = null): T {
|
||||
return when(type) {
|
||||
return when (type) {
|
||||
AndroidFiles::class.java -> {
|
||||
val instance: AndroidFiles by (kodein ?: kodein()).instance()
|
||||
instance as T
|
||||
@@ -64,5 +64,4 @@ object KodeinGlobalHelper {
|
||||
fun <T : Any> instance(type: Class<T>): T {
|
||||
return instance(type, null)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -440,7 +440,6 @@ class LocalSource : HttpSource() {
|
||||
private object FileSystemInterceptor : Interceptor {
|
||||
fun fakeUrlFrom(path: String): String = "http://$path"
|
||||
|
||||
|
||||
private fun restoreFilePath(url: String): String {
|
||||
val path = URLDecoder.decode(url.replaceFirst("http://", ""), "UTF-8")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user