mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-11 07:12:03 +01:00
Implement Android ContextWrapper
This commit is contained in:
@@ -21,7 +21,7 @@ class AppMigrations @Inject constructor(
|
||||
if (oldVersion < BuildConfig.VERSION_CODE) {
|
||||
migrationPreferences.appVersion().set(BuildConfig.VERSION_CODE)
|
||||
|
||||
UpdateCheckWorker.setupTask(contextWrapper.context)
|
||||
UpdateCheckWorker.setupTask(contextWrapper)
|
||||
|
||||
// Fresh install
|
||||
if (oldVersion == 0) {
|
||||
|
||||
@@ -12,6 +12,6 @@ import io.kamel.image.config.resourcesFetcher
|
||||
import io.kamel.image.config.resourcesIdMapper
|
||||
|
||||
actual fun KamelConfigBuilder.kamelPlatformHandler(contextWrapper: ContextWrapper) {
|
||||
resourcesIdMapper(contextWrapper.context)
|
||||
resourcesFetcher(contextWrapper.context)
|
||||
resourcesIdMapper(contextWrapper)
|
||||
resourcesFetcher(contextWrapper)
|
||||
}
|
||||
|
||||
@@ -17,12 +17,11 @@ internal actual fun startDownloadService(
|
||||
downloadService: DownloadService,
|
||||
actions: WebsocketService.Actions
|
||||
) {
|
||||
val context = contextWrapper.context
|
||||
val intent = Intent(
|
||||
context,
|
||||
contextWrapper,
|
||||
Class.forName("ca.gosyer.jui.android.data.download.AndroidDownloadService")
|
||||
).apply {
|
||||
action = actions.name
|
||||
}
|
||||
ContextCompat.startForegroundService(context, intent)
|
||||
ContextCompat.startForegroundService(contextWrapper, intent)
|
||||
}
|
||||
|
||||
@@ -7,24 +7,25 @@
|
||||
package ca.gosyer.jui.uicore.vm
|
||||
|
||||
import android.content.Context
|
||||
import android.content.ContextWrapper
|
||||
import android.widget.Toast
|
||||
import dev.icerock.moko.resources.StringResource
|
||||
import dev.icerock.moko.resources.desc.desc
|
||||
import dev.icerock.moko.resources.format
|
||||
import me.tatarka.inject.annotations.Inject
|
||||
|
||||
actual class ContextWrapper @Inject constructor(val context: Context) {
|
||||
actual class ContextWrapper @Inject constructor(context: Context) : ContextWrapper(context) {
|
||||
actual fun toPlatformString(stringResource: StringResource): String {
|
||||
return stringResource.desc().toString(context)
|
||||
return stringResource.desc().toString(this)
|
||||
}
|
||||
|
||||
actual fun toPlatformString(stringResource: StringResource, vararg args: Any): String {
|
||||
return stringResource.format(*args).toString(context)
|
||||
return stringResource.format(*args).toString(this)
|
||||
}
|
||||
|
||||
actual fun toast(string: String, length: Length) {
|
||||
Toast.makeText(
|
||||
context,
|
||||
this,
|
||||
string,
|
||||
when (length) {
|
||||
Length.SHORT -> Toast.LENGTH_SHORT
|
||||
|
||||
Reference in New Issue
Block a user