From 88c0f46748abe85de4155841a0e3abbb9c68c1e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Font=C3=A1n?= Date: Wed, 31 Jul 2024 16:21:08 +0200 Subject: [PATCH] refactor: Removed App.context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed the unnecessary `App.context` and used `LocalContext` instead. Simplified dynamic color scheme condition. Signed-off-by: Gabriel Fontán --- app/src/main/java/com/bobbyesp/metadator/App.kt | 5 ----- .../metadator/presentation/common/CompositionLocals.kt | 4 +++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/bobbyesp/metadator/App.kt b/app/src/main/java/com/bobbyesp/metadator/App.kt index c537c70..0a52bc1 100644 --- a/app/src/main/java/com/bobbyesp/metadator/App.kt +++ b/app/src/main/java/com/bobbyesp/metadator/App.kt @@ -2,7 +2,6 @@ package com.bobbyesp.metadator import android.app.Application import android.content.ClipboardManager -import android.content.Context import android.content.pm.PackageInfo import android.content.pm.PackageManager import android.net.ConnectivityManager @@ -12,7 +11,6 @@ import com.bobbyesp.crashhandler.CrashHandler.setupCrashHandler import com.bobbyesp.crashhandler.ReportInfo import com.tencent.mmkv.MMKV import dagger.hilt.android.HiltAndroidApp -import dagger.hilt.android.qualifiers.ApplicationContext import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.SupervisorJob import kotlin.properties.Delegates @@ -27,7 +25,6 @@ class App : Application() { ) else getPackageInfo(packageName, 0) } - context = applicationContext applicationScope = CoroutineScope(SupervisorJob()) clipboard = getSystemService()!! connectivityManager = getSystemService()!! @@ -44,8 +41,6 @@ class App : Application() { } companion object { - @ApplicationContext - lateinit var context: Context lateinit var clipboard: ClipboardManager lateinit var applicationScope: CoroutineScope lateinit var connectivityManager: ConnectivityManager diff --git a/app/src/main/java/com/bobbyesp/metadator/presentation/common/CompositionLocals.kt b/app/src/main/java/com/bobbyesp/metadator/presentation/common/CompositionLocals.kt index a8a38fa..6236e00 100644 --- a/app/src/main/java/com/bobbyesp/metadator/presentation/common/CompositionLocals.kt +++ b/app/src/main/java/com/bobbyesp/metadator/presentation/common/CompositionLocals.kt @@ -13,6 +13,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.staticCompositionLocalOf import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalConfiguration +import androidx.compose.ui.platform.LocalContext import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.navigation.NavHostController import androidx.navigation.compose.rememberNavController @@ -20,7 +21,6 @@ import coil.ImageLoader import coil.disk.DiskCache import coil.memory.MemoryCache import com.bobbyesp.mediaplayer.service.ConnectionHandler -import com.bobbyesp.metadator.App.Companion.context import com.bobbyesp.utilities.preferences.Preferences.AppMainSettingsStateFlow import com.bobbyesp.utilities.theme.DarkThemePreference import com.bobbyesp.utilities.ui.DEFAULT_SEED_COLOR @@ -57,6 +57,8 @@ fun AppLocalSettingsProvider( playerConnectionHandler: ConnectionHandler, content: @Composable () -> Unit ) { + val context = LocalContext.current + val appSettingsState = AppMainSettingsStateFlow.collectAsStateWithLifecycle().value val bottomSheetNavigator = rememberBottomSheetNavigator() val navController = rememberNavController(bottomSheetNavigator)