android support! thanks to TachiWeb devs.
This commit is contained in:
+5
-10
@@ -1,18 +1,9 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
val compileKotlin: KotlinCompile by tasks
|
||||
|
||||
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.jvm") version "1.4.21"
|
||||
// id("org.jetbrains.kotlin.jvm") version "1.4.21"
|
||||
application
|
||||
}
|
||||
|
||||
|
||||
compileKotlin.kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
@@ -83,6 +74,10 @@ dependencies {
|
||||
implementation ("org.jetbrains.exposed:exposed-jdbc:$exposed_version")
|
||||
implementation ("org.xerial:sqlite-jdbc:3.30.1")
|
||||
|
||||
// AndroidCompat
|
||||
implementation(project(":AndroidCompat"))
|
||||
implementation(project(":AndroidCompat:Config"))
|
||||
|
||||
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test")
|
||||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package eu.kanade.tachiyomi
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
//import android.content.res.Configuration
|
||||
//import android.support.multidex.MultiDex
|
||||
//import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.InjektScope
|
||||
import uy.kohesive.injekt.registry.default.DefaultRegistrar
|
||||
|
||||
open class App : Application() {
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
Injekt = InjektScope(DefaultRegistrar())
|
||||
Injekt.importModule(AppModule(this))
|
||||
|
||||
// if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree())
|
||||
}
|
||||
|
||||
override fun attachBaseContext(base: Context) {
|
||||
super.attachBaseContext(base)
|
||||
// if (BuildConfig.DEBUG) {
|
||||
// MultiDex.install(this)
|
||||
// }
|
||||
}
|
||||
|
||||
// override fun onConfigurationChanged(newConfig: Configuration) {
|
||||
// super.onConfigurationChanged(newConfig)
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package eu.kanade.tachiyomi
|
||||
|
||||
import android.app.Application
|
||||
import com.google.gson.Gson
|
||||
//import eu.kanade.tachiyomi.data.cache.ChapterCache
|
||||
//import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||
//import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||
//import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||
//import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
//import eu.kanade.tachiyomi.data.sync.LibrarySyncManager
|
||||
//import eu.kanade.tachiyomi.data.track.TrackManager
|
||||
//import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import rx.Observable
|
||||
import rx.schedulers.Schedulers
|
||||
import uy.kohesive.injekt.api.*
|
||||
|
||||
class AppModule(val app: Application) : InjektModule {
|
||||
|
||||
override fun InjektRegistrar.registerInjectables() {
|
||||
|
||||
addSingleton(app)
|
||||
|
||||
// addSingletonFactory { PreferencesHelper(app) }
|
||||
//
|
||||
// addSingletonFactory { DatabaseHelper(app) }
|
||||
//
|
||||
// addSingletonFactory { ChapterCache(app) }
|
||||
//
|
||||
// addSingletonFactory { CoverCache(app) }
|
||||
|
||||
addSingletonFactory { NetworkHelper(app) }
|
||||
|
||||
// addSingletonFactory { SourceManager(app).also { get<ExtensionManager>().init(it) } }
|
||||
//
|
||||
// addSingletonFactory { ExtensionManager(app) }
|
||||
//
|
||||
// addSingletonFactory { DownloadManager(app) }
|
||||
//
|
||||
// addSingletonFactory { TrackManager(app) }
|
||||
//
|
||||
// addSingletonFactory { LibrarySyncManager(app) }
|
||||
|
||||
addSingletonFactory { Gson() }
|
||||
|
||||
// Asynchronously init expensive components for a faster cold start
|
||||
|
||||
// rxAsync { get<PreferencesHelper>() }
|
||||
|
||||
rxAsync { get<NetworkHelper>() }
|
||||
|
||||
rxAsync {
|
||||
// get<SourceManager>()
|
||||
// get<DownloadManager>()
|
||||
}
|
||||
|
||||
// rxAsync { get<DatabaseHelper>() }
|
||||
|
||||
}
|
||||
|
||||
private fun rxAsync(block: () -> Unit) {
|
||||
Observable.fromCallable { block() }.subscribeOn(Schedulers.computation()).subscribe()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,6 +7,8 @@ import kotlinx.serialization.json.JsonArray
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.http.GET
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
//import uy.kohesive.injekt.injectLazy
|
||||
|
||||
/**
|
||||
@@ -16,7 +18,7 @@ interface ExtensionGithubService {
|
||||
|
||||
companion object {
|
||||
private val client by lazy {
|
||||
val network: NetworkHelper = NetworkHelper()
|
||||
val network: NetworkHelper by injectLazy()
|
||||
network.client.newBuilder()
|
||||
.addNetworkInterceptor { chain ->
|
||||
val originalResponse = chain.proceed(chain.request())
|
||||
|
||||
@@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.network
|
||||
//import android.content.Context
|
||||
//import eu.kanade.tachiyomi.BuildConfig
|
||||
//import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import android.content.Context
|
||||
import okhttp3.Cache
|
||||
//import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.OkHttpClient
|
||||
@@ -13,7 +14,7 @@ import java.io.File
|
||||
import java.net.InetAddress
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class NetworkHelper() {
|
||||
class NetworkHelper(context: Context) {
|
||||
|
||||
// private val preferences: PreferencesHelper by injectLazy()
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import rx.Observable
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
//import uy.kohesive.injekt.injectLazy
|
||||
import java.net.URI
|
||||
import java.net.URISyntaxException
|
||||
@@ -28,7 +29,7 @@ abstract class HttpSource : CatalogueSource {
|
||||
/**
|
||||
* Network service.
|
||||
*/
|
||||
protected val network = NetworkHelper()
|
||||
protected val network: NetworkHelper by injectLazy()
|
||||
|
||||
// /**
|
||||
// * Preferences that a source may need.
|
||||
|
||||
@@ -1,16 +1,43 @@
|
||||
package ir.armor.tachidesk
|
||||
|
||||
import eu.kanade.tachiyomi.App
|
||||
import io.javalin.Javalin
|
||||
import ir.armor.tachidesk.util.*
|
||||
import org.kodein.di.DI
|
||||
import org.kodein.di.conf.global
|
||||
import xyz.nulldev.androidcompat.AndroidCompat
|
||||
import xyz.nulldev.androidcompat.AndroidCompatInitializer
|
||||
import xyz.nulldev.ts.config.ConfigKodeinModule
|
||||
import xyz.nulldev.ts.config.GlobalConfigManager
|
||||
import xyz.nulldev.ts.config.ServerConfig
|
||||
import java.util.*
|
||||
|
||||
class Main {
|
||||
companion object {
|
||||
val androidCompat by lazy { AndroidCompat() }
|
||||
|
||||
fun registerConfigModules() {
|
||||
GlobalConfigManager.registerModules(
|
||||
// ServerConfig.register(GlobalConfigManager.config),
|
||||
// SyncConfigModule.register(GlobalConfigManager.config)
|
||||
)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
// make sure everything we need exists
|
||||
applicationSetup()
|
||||
|
||||
registerConfigModules()
|
||||
|
||||
//Load config API
|
||||
DI.global.addImport(ConfigKodeinModule().create())
|
||||
//Load Android compatibility dependencies
|
||||
AndroidCompatInitializer().init()
|
||||
// start app
|
||||
androidCompat.startApp(App())
|
||||
|
||||
|
||||
|
||||
val app = Javalin.create().start(4567)
|
||||
|
||||
@@ -40,6 +67,8 @@ class Main {
|
||||
ctx.json(getPopularManga(sourceId))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@ import org.jetbrains.exposed.sql.insert
|
||||
import org.jetbrains.exposed.sql.select
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
import org.jetbrains.exposed.sql.update
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import java.net.URLClassLoader
|
||||
@@ -118,9 +121,11 @@ fun installAPK(apkName: String): Int {
|
||||
}
|
||||
}
|
||||
|
||||
val networkHelper: NetworkHelper by injectLazy()
|
||||
|
||||
private fun downloadAPKFile(url: String, apkPath: String) {
|
||||
val request = Request.Builder().url(url).build()
|
||||
val response = NetworkHelper().client.newCall(request).execute();
|
||||
val response = networkHelper.client.newCall(request).execute()
|
||||
|
||||
val downloadedFile = File(apkPath)
|
||||
val sink = downloadedFile.sink().buffer()
|
||||
|
||||
Reference in New Issue
Block a user