From d55fe64075a3de7b3b6f69c73dcd1d3ffb589f74 Mon Sep 17 00:00:00 2001 From: MM20 <15646950+MM2-0@users.noreply.github.com> Date: Sat, 15 Jun 2024 23:07:01 +0200 Subject: [PATCH] Clean up integration settings screen --- .../IntegrationsSettingsScreen.kt | 21 ------------ .../IntegrationsSettingsScreenVM.kt | 34 ------------------- 2 files changed, 55 deletions(-) diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/integrations/IntegrationsSettingsScreen.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/integrations/IntegrationsSettingsScreen.kt index 801b3978..373e1475 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/integrations/IntegrationsSettingsScreen.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/integrations/IntegrationsSettingsScreen.kt @@ -46,30 +46,9 @@ import de.mm20.launcher2.ui.locals.LocalNavController @Composable fun IntegrationsSettingsScreen() { val viewModel: IntegrationsSettingsScreenVM = viewModel() - val context = LocalContext.current - val lifecycleOwner = LocalLifecycleOwner.current val navController = LocalNavController.current - LaunchedEffect(null) { - lifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) { - viewModel.onResume() - } - } - - val owncloudUser by viewModel.owncloudUser - val nextcloudUser by viewModel.nextcloudUser - val googleUser by viewModel.googleUser - - val loading by viewModel.loading - PreferenceScreen(title = stringResource(R.string.preference_screen_integrations)) { - if (loading) { - item { - LinearProgressIndicator( - modifier = Modifier.fillMaxWidth() - ) - } - } item { Preference( title = stringResource(R.string.preference_weather_integration), diff --git a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/integrations/IntegrationsSettingsScreenVM.kt b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/integrations/IntegrationsSettingsScreenVM.kt index 57d3e1e7..851f3f92 100644 --- a/app/ui/src/main/java/de/mm20/launcher2/ui/settings/integrations/IntegrationsSettingsScreenVM.kt +++ b/app/ui/src/main/java/de/mm20/launcher2/ui/settings/integrations/IntegrationsSettingsScreenVM.kt @@ -1,13 +1,8 @@ package de.mm20.launcher2.ui.settings.integrations -import androidx.appcompat.app.AppCompatActivity -import androidx.compose.runtime.mutableStateOf import androidx.lifecycle.ViewModel -import androidx.lifecycle.viewModelScope -import de.mm20.launcher2.accounts.Account import de.mm20.launcher2.accounts.AccountType import de.mm20.launcher2.accounts.AccountsRepository -import kotlinx.coroutines.launch import org.koin.core.component.KoinComponent import org.koin.core.component.inject @@ -15,33 +10,4 @@ class IntegrationsSettingsScreenVM : ViewModel(), KoinComponent { private val accountsRepository: AccountsRepository by inject() val isGoogleAvailable = accountsRepository.isSupported(AccountType.Google) - - val googleUser = mutableStateOf(null) - val nextcloudUser = mutableStateOf(null) - val owncloudUser = mutableStateOf(null) - - val loading = mutableStateOf(true) - - fun onResume() { - viewModelScope.launch { - loading.value = true - googleUser.value = accountsRepository.getCurrentlySignedInAccount(AccountType.Google) - nextcloudUser.value = accountsRepository.getCurrentlySignedInAccount(AccountType.Nextcloud) - owncloudUser.value = accountsRepository.getCurrentlySignedInAccount(AccountType.Owncloud) - loading.value = false - } - } - - fun signIn(activity: AppCompatActivity, accountType: AccountType) { - accountsRepository.signin(activity, accountType) - } - - fun signOut(accountType: AccountType) { - accountsRepository.signout(accountType) - when(accountType){ - AccountType.Google -> googleUser.value = null - AccountType.Nextcloud -> nextcloudUser.value = null - AccountType.Owncloud -> owncloudUser.value = null - } - } } \ No newline at end of file