mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-10 06:42:05 +01:00
Use CommonMain in data module, use multiplatform locale library
This commit is contained in:
@@ -84,6 +84,7 @@ dependencies {
|
||||
// Localization
|
||||
implementation(libs.moko.core)
|
||||
implementation(libs.moko.compose)
|
||||
implementation(libs.locale)
|
||||
|
||||
// Testing
|
||||
testImplementation(kotlin("test-junit"))
|
||||
|
||||
@@ -47,6 +47,7 @@ kotlin {
|
||||
api(libs.multiplatformSettings.core)
|
||||
api(libs.multiplatformSettings.coroutines)
|
||||
api(libs.multiplatformSettings.serialization)
|
||||
api(libs.locale)
|
||||
}
|
||||
}
|
||||
val commonTest by getting {
|
||||
|
||||
11
core/src/commonMain/kotlin/ca/gosyer/core/lang/Locale.kt
Normal file
11
core/src/commonMain/kotlin/ca/gosyer/core/lang/Locale.kt
Normal file
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
package ca.gosyer.core.lang
|
||||
|
||||
import io.fluidsonic.locale.Locale
|
||||
|
||||
expect fun Locale.Companion.getDefault(): Locale
|
||||
13
core/src/jvmMain/kotlin/ca/gosyer/core/lang/JvmLocale.kt
Normal file
13
core/src/jvmMain/kotlin/ca/gosyer/core/lang/JvmLocale.kt
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/.
|
||||
*/
|
||||
|
||||
package ca.gosyer.core.lang
|
||||
|
||||
import io.fluidsonic.locale.Locale
|
||||
import io.fluidsonic.locale.toCommon
|
||||
import java.util.Locale as PlatformLocale
|
||||
|
||||
actual fun Locale.Companion.getDefault(): Locale = PlatformLocale.getDefault().toCommon()
|
||||
@@ -45,6 +45,7 @@ kotlin {
|
||||
api(libs.okio)
|
||||
api(projects.core)
|
||||
api(projects.i18n)
|
||||
api(libs.locale)
|
||||
}
|
||||
}
|
||||
val commonTest by getting {
|
||||
|
||||
@@ -51,7 +51,7 @@ abstract class WebsocketService(
|
||||
while (true) {
|
||||
if (errorConnectionCount > 3) {
|
||||
_status.value = Status.STOPPED
|
||||
throw CancellationException()
|
||||
throw CancellationException("Finish")
|
||||
}
|
||||
runCatching {
|
||||
client.ws(
|
||||
@@ -6,14 +6,15 @@
|
||||
|
||||
package ca.gosyer.data.catalog
|
||||
|
||||
import ca.gosyer.core.lang.getDefault
|
||||
import ca.gosyer.core.prefs.Preference
|
||||
import ca.gosyer.core.prefs.PreferenceStore
|
||||
import ca.gosyer.data.library.model.DisplayMode
|
||||
import java.util.Locale
|
||||
import io.fluidsonic.locale.Locale
|
||||
|
||||
class CatalogPreferences(private val preferenceStore: PreferenceStore) {
|
||||
fun languages(): Preference<Set<String>> {
|
||||
return preferenceStore.getStringSet("enabled_langs", setOf("en", Locale.getDefault().language))
|
||||
return preferenceStore.getStringSet("enabled_langs", setOfNotNull("en", Locale.getDefault().language))
|
||||
}
|
||||
|
||||
fun displayMode(): Preference<DisplayMode> {
|
||||
@@ -6,12 +6,13 @@
|
||||
|
||||
package ca.gosyer.data.extension
|
||||
|
||||
import ca.gosyer.core.lang.getDefault
|
||||
import ca.gosyer.core.prefs.Preference
|
||||
import ca.gosyer.core.prefs.PreferenceStore
|
||||
import java.util.Locale
|
||||
import io.fluidsonic.locale.Locale
|
||||
|
||||
class ExtensionPreferences(private val preferenceStore: PreferenceStore) {
|
||||
fun languages(): Preference<Set<String>> {
|
||||
return preferenceStore.getStringSet("enabled_langs", setOf("all", "en", Locale.getDefault().language))
|
||||
return preferenceStore.getStringSet("enabled_langs", setOfNotNull("all", "en", Locale.getDefault().language))
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,6 @@ import ca.gosyer.data.server.model.Auth
|
||||
import ca.gosyer.data.server.model.Proxy
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.engine.ProxyBuilder
|
||||
import io.ktor.client.engine.ProxyConfig
|
||||
import io.ktor.client.engine.okhttp.OkHttp
|
||||
import io.ktor.client.features.auth.providers.BasicAuthCredentials
|
||||
import io.ktor.client.features.auth.providers.DigestAuthCredentials
|
||||
import io.ktor.client.features.auth.providers.basic
|
||||
@@ -31,10 +29,10 @@ typealias Http = HttpClient
|
||||
|
||||
class HttpProvider @Inject constructor() {
|
||||
fun get(serverPreferences: ServerPreferences): Http {
|
||||
return HttpClient(OkHttp) {
|
||||
return HttpClient {
|
||||
engine {
|
||||
proxy = when (serverPreferences.proxy().get()) {
|
||||
Proxy.NO_PROXY -> ProxyConfig.NO_PROXY
|
||||
Proxy.NO_PROXY -> null
|
||||
Proxy.HTTP_PROXY -> ProxyBuilder.http(
|
||||
URLBuilder(
|
||||
host = serverPreferences.proxyHttpHost().get(),
|
||||
@@ -6,6 +6,8 @@
|
||||
|
||||
package ca.gosyer.data.server.interactions
|
||||
|
||||
import ca.gosyer.core.io.SYSTEM
|
||||
import ca.gosyer.core.lang.IO
|
||||
import ca.gosyer.data.models.BackupValidationResult
|
||||
import ca.gosyer.data.server.Http
|
||||
import ca.gosyer.data.server.ServerPreferences
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
package ca.gosyer.data.server.interactions
|
||||
|
||||
import ca.gosyer.core.lang.IO
|
||||
import ca.gosyer.data.models.Category
|
||||
import ca.gosyer.data.models.Manga
|
||||
import ca.gosyer.data.server.Http
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
package ca.gosyer.data.server.interactions
|
||||
|
||||
import ca.gosyer.core.lang.IO
|
||||
import ca.gosyer.data.models.Chapter
|
||||
import ca.gosyer.data.models.Manga
|
||||
import ca.gosyer.data.server.Http
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
package ca.gosyer.data.server.interactions
|
||||
|
||||
import ca.gosyer.core.lang.IO
|
||||
import ca.gosyer.data.server.Http
|
||||
import ca.gosyer.data.server.ServerPreferences
|
||||
import ca.gosyer.data.server.requests.downloadsClearRequest
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
package ca.gosyer.data.server.interactions
|
||||
|
||||
import ca.gosyer.core.lang.IO
|
||||
import ca.gosyer.data.models.Extension
|
||||
import ca.gosyer.data.server.Http
|
||||
import ca.gosyer.data.server.ServerPreferences
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
package ca.gosyer.data.server.interactions
|
||||
|
||||
import ca.gosyer.core.lang.IO
|
||||
import ca.gosyer.data.models.Manga
|
||||
import ca.gosyer.data.server.Http
|
||||
import ca.gosyer.data.server.ServerPreferences
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
package ca.gosyer.data.server.interactions
|
||||
|
||||
import ca.gosyer.core.lang.IO
|
||||
import ca.gosyer.data.models.Manga
|
||||
import ca.gosyer.data.server.Http
|
||||
import ca.gosyer.data.server.ServerPreferences
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
package ca.gosyer.data.server.interactions
|
||||
|
||||
import ca.gosyer.core.lang.IO
|
||||
import ca.gosyer.data.models.MangaPage
|
||||
import ca.gosyer.data.models.Source
|
||||
import ca.gosyer.data.models.sourcefilters.SourceFilter
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
package ca.gosyer.data.server.interactions
|
||||
|
||||
import ca.gosyer.core.lang.IO
|
||||
import ca.gosyer.data.models.Category
|
||||
import ca.gosyer.data.models.Updates
|
||||
import ca.gosyer.data.server.Http
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
package ca.gosyer.data.update
|
||||
|
||||
import ca.gosyer.core.lang.IO
|
||||
import ca.gosyer.data.build.BuildKonfig
|
||||
import ca.gosyer.data.server.Http
|
||||
import ca.gosyer.data.update.model.GithubRelease
|
||||
@@ -85,6 +85,7 @@ dependencies {
|
||||
// Localization
|
||||
implementation(libs.moko.core)
|
||||
implementation(libs.moko.compose)
|
||||
implementation(libs.locale)
|
||||
|
||||
// Testing
|
||||
testImplementation(kotlin("test-junit"))
|
||||
|
||||
@@ -52,6 +52,7 @@ kroki = "1.22"
|
||||
desugarJdkLibs = "1.1.5"
|
||||
|
||||
# Localization
|
||||
locale = "0.11.0"
|
||||
moko = "0.18.0"
|
||||
|
||||
# BuildConfigs
|
||||
@@ -140,6 +141,7 @@ desugarJdkLibs = { module = "com.android.tools:desugar_jdk_libs", version.ref =
|
||||
# Localization
|
||||
moko-core = { module = "dev.icerock.moko:resources", version.ref = "moko" }
|
||||
moko-compose = { module = "dev.icerock.moko:resources-compose", version.ref = "moko" }
|
||||
locale = { module = "io.fluidsonic.locale:fluid-locale", version.ref = "locale" }
|
||||
|
||||
# Optimizer
|
||||
proguard = { module = "com.guardsquare:proguard-gradle", version.ref = "proguard" }
|
||||
|
||||
@@ -50,6 +50,7 @@ kotlin {
|
||||
api(libs.accompanist.pagerIndicators)
|
||||
api(libs.accompanist.flowLayout)
|
||||
api(libs.krokiCoroutines)
|
||||
api(libs.locale)
|
||||
api(projects.core)
|
||||
api(projects.i18n)
|
||||
api(projects.data)
|
||||
|
||||
@@ -39,6 +39,7 @@ kotlin {
|
||||
api(libs.coroutines.core)
|
||||
api(libs.kamel)
|
||||
api(libs.voyager.core)
|
||||
api(libs.locale)
|
||||
api(projects.core)
|
||||
api(projects.i18n)
|
||||
api(compose.desktop.currentOs)
|
||||
|
||||
Reference in New Issue
Block a user