Remove Google integration
This commit is contained in:
@@ -48,7 +48,6 @@ import de.mm20.launcher2.ui.settings.favorites.FavoritesSettingsScreen
|
||||
import de.mm20.launcher2.ui.settings.filesearch.FileSearchSettingsScreen
|
||||
import de.mm20.launcher2.ui.settings.filterbar.FilterBarSettingsScreen
|
||||
import de.mm20.launcher2.ui.settings.gestures.GestureSettingsScreen
|
||||
import de.mm20.launcher2.ui.settings.google.GoogleSettingsScreen
|
||||
import de.mm20.launcher2.ui.settings.hiddenitems.HiddenItemsSettingsScreen
|
||||
import de.mm20.launcher2.ui.settings.homescreen.HomescreenSettingsScreen
|
||||
import de.mm20.launcher2.ui.settings.icons.IconsSettingsScreen
|
||||
@@ -226,9 +225,6 @@ class SettingsActivity : BaseActivity() {
|
||||
composable("settings/integrations/owncloud") {
|
||||
OwncloudSettingsScreen()
|
||||
}
|
||||
composable("settings/integrations/google") {
|
||||
GoogleSettingsScreen()
|
||||
}
|
||||
composable("settings/plugins") {
|
||||
PluginsSettingsScreen()
|
||||
}
|
||||
|
||||
-4
@@ -1,22 +1,18 @@
|
||||
package de.mm20.launcher2.ui.settings.buildinfo
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import de.mm20.launcher2.accounts.AccountType
|
||||
import de.mm20.launcher2.accounts.AccountsRepository
|
||||
import de.mm20.launcher2.weather.WeatherRepository
|
||||
import kotlinx.coroutines.flow.map
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
|
||||
class BuildInfoSettingsScreenVM : ViewModel(), KoinComponent {
|
||||
private val accountsRepository: AccountsRepository by inject()
|
||||
private val weatherRepository: WeatherRepository by inject()
|
||||
|
||||
private val availableWeatherProviders = weatherRepository.getProviders()
|
||||
|
||||
val buildFeatures = availableWeatherProviders.map {
|
||||
mapOf(
|
||||
"Accounts: Google" to accountsRepository.isSupported(AccountType.Google),
|
||||
"Weather providers: HERE" to it.any { it.id == "here" },
|
||||
"Weather providers: Met No" to it.any { it.id == "metno" },
|
||||
"Weather providers: OpenWeatherMap" to it.any { it.id == "owm" },
|
||||
|
||||
-34
@@ -153,40 +153,6 @@ fun FileSearchSettingsScreen() {
|
||||
enabled = owncloudAccount != null
|
||||
)
|
||||
|
||||
if (viewModel.googleAvailable) {
|
||||
val gdrive by viewModel.gdrive.collectAsState()
|
||||
val googleAccount by viewModel.googleAccount
|
||||
AnimatedVisibility(googleAccount == null) {
|
||||
Banner(
|
||||
text = stringResource(R.string.no_account_google),
|
||||
icon = Icons.Rounded.AccountBox,
|
||||
primaryAction = {
|
||||
TextButton(onClick = {
|
||||
viewModel.login(
|
||||
context as AppCompatActivity,
|
||||
AccountType.Google
|
||||
)
|
||||
}) {
|
||||
Text(
|
||||
stringResource(R.string.connect_account),
|
||||
)
|
||||
}
|
||||
},
|
||||
modifier = Modifier.padding(16.dp)
|
||||
)
|
||||
}
|
||||
SwitchPreference(
|
||||
title = stringResource(R.string.preference_search_gdrive),
|
||||
summary = googleAccount?.let {
|
||||
stringResource(R.string.preference_search_gdrive_summary, it.userName)
|
||||
} ?: stringResource(R.string.preference_summary_not_logged_in),
|
||||
value = gdrive == true && googleAccount != null,
|
||||
onValueChanged = {
|
||||
viewModel.setGdrive(it)
|
||||
},
|
||||
enabled = googleAccount != null
|
||||
)
|
||||
}
|
||||
for (plugin in plugins) {
|
||||
val state = plugin.state
|
||||
if (state is PluginState.SetupRequired) {
|
||||
|
||||
-4
@@ -30,9 +30,6 @@ class FileSearchSettingsScreenVM : ViewModel(), KoinComponent {
|
||||
val loading = mutableStateOf(true)
|
||||
val nextcloudAccount = mutableStateOf<Account?>(null)
|
||||
val owncloudAccount = mutableStateOf<Account?>(null)
|
||||
val googleAccount = mutableStateOf<Account?>(null)
|
||||
|
||||
val googleAvailable = accountsRepository.isSupported(AccountType.Google)
|
||||
|
||||
val availablePlugins = pluginService.getPluginsWithState(
|
||||
type = PluginType.FileSearch,
|
||||
@@ -48,7 +45,6 @@ class FileSearchSettingsScreenVM : ViewModel(), KoinComponent {
|
||||
accountsRepository.getCurrentlySignedInAccount(AccountType.Nextcloud)
|
||||
owncloudAccount.value =
|
||||
accountsRepository.getCurrentlySignedInAccount(AccountType.Owncloud)
|
||||
googleAccount.value = accountsRepository.getCurrentlySignedInAccount(AccountType.Google)
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
package de.mm20.launcher2.ui.settings.google
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.rounded.Logout
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.compose.LocalLifecycleOwner
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import de.mm20.launcher2.ui.R
|
||||
import de.mm20.launcher2.ui.component.preferences.PreferenceScreen
|
||||
import de.mm20.launcher2.ui.component.preferences.SwitchPreference
|
||||
import de.mm20.launcher2.ui.locals.LocalNavController
|
||||
import de.mm20.launcher2.ui.settings.integrations.GoogleSigninButton
|
||||
|
||||
@Composable
|
||||
fun GoogleSettingsScreen() {
|
||||
|
||||
val viewModel: GoogleSettingsScreenVM = viewModel()
|
||||
val lifecycleOwner = LocalLifecycleOwner.current
|
||||
val navController = LocalNavController.current
|
||||
|
||||
val googleUser by viewModel.googleUser
|
||||
val loading by viewModel.loading
|
||||
val searchFiles by viewModel.searchFiles.collectAsState(null)
|
||||
|
||||
LaunchedEffect(null) {
|
||||
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.RESUMED) {
|
||||
viewModel.onResume()
|
||||
}
|
||||
}
|
||||
PreferenceScreen(title = stringResource(R.string.preference_google)) {
|
||||
if (loading) return@PreferenceScreen
|
||||
|
||||
if (googleUser != null) {
|
||||
item {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.background(MaterialTheme.colorScheme.secondaryContainer)
|
||||
.fillParentMaxWidth()
|
||||
.padding(vertical = 64.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier
|
||||
.size(72.dp)
|
||||
.background(MaterialTheme.colorScheme.secondary, CircleShape)
|
||||
.border(
|
||||
2.dp,
|
||||
MaterialTheme.colorScheme.onSecondaryContainer,
|
||||
CircleShape
|
||||
),
|
||||
) {
|
||||
Text(
|
||||
text = googleUser!!.userName.split(" ")
|
||||
.map { it.first() }
|
||||
.joinToString("").let {
|
||||
if (it.length >= 2) it.first().toString() + it.last().toString()
|
||||
else it.first().toString()
|
||||
},
|
||||
color = MaterialTheme.colorScheme.onSecondary,
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
)
|
||||
}
|
||||
Text(
|
||||
modifier = Modifier.padding(top = 24.dp),
|
||||
text = stringResource(
|
||||
R.string.preference_signin_user,
|
||||
googleUser!!.userName
|
||||
),
|
||||
color = MaterialTheme.colorScheme.onSecondaryContainer,
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
)
|
||||
Button(
|
||||
modifier = Modifier.padding(top = 32.dp),
|
||||
onClick = {
|
||||
viewModel.signOut()
|
||||
},
|
||||
contentPadding = ButtonDefaults.ButtonWithIconContentPadding,
|
||||
) {
|
||||
Icon(
|
||||
Icons.AutoMirrored.Rounded.Logout,
|
||||
modifier = Modifier
|
||||
.padding(end = ButtonDefaults.IconSpacing)
|
||||
.size(ButtonDefaults.IconSize),
|
||||
contentDescription = null
|
||||
)
|
||||
Text(text = stringResource(R.string.preference_signout))
|
||||
}
|
||||
}
|
||||
}
|
||||
item {
|
||||
HorizontalDivider()
|
||||
}
|
||||
|
||||
item {
|
||||
SwitchPreference(
|
||||
title = stringResource(R.string.plugin_type_filesearch),
|
||||
summary = stringResource(
|
||||
R.string.preference_search_cloud_summary,
|
||||
googleUser!!.userName
|
||||
),
|
||||
value = searchFiles == true,
|
||||
onValueChanged = {
|
||||
viewModel.setSearchFiles(it)
|
||||
},
|
||||
iconPadding = false,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
item {
|
||||
val activity = LocalContext.current as AppCompatActivity
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillParentMaxWidth()
|
||||
.padding(vertical = 64.dp, horizontal = 24.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
GoogleSigninButton(
|
||||
onClick = {
|
||||
viewModel.signIn(activity)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
item {
|
||||
HorizontalDivider()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package de.mm20.launcher2.ui.settings.google
|
||||
|
||||
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 de.mm20.launcher2.preferences.search.FileSearchSettings
|
||||
import kotlinx.coroutines.launch
|
||||
import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
|
||||
class GoogleSettingsScreenVM: ViewModel(), KoinComponent {
|
||||
private val accountsRepository: AccountsRepository by inject()
|
||||
private val fileSearchSettings: FileSearchSettings by inject()
|
||||
|
||||
val googleUser = mutableStateOf<Account?>(null)
|
||||
val loading = mutableStateOf(true)
|
||||
|
||||
fun onResume() {
|
||||
viewModelScope.launch {
|
||||
loading.value = true
|
||||
googleUser.value = accountsRepository.getCurrentlySignedInAccount(AccountType.Google)
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
fun signIn(activity: AppCompatActivity) {
|
||||
accountsRepository.signin(activity, AccountType.Google)
|
||||
}
|
||||
|
||||
fun signOut() {
|
||||
accountsRepository.signout(AccountType.Google)
|
||||
googleUser.value = null
|
||||
}
|
||||
|
||||
val searchFiles = fileSearchSettings.gdriveFiles
|
||||
|
||||
fun setSearchFiles(value: Boolean) {
|
||||
fileSearchSettings.setGdriveFiles(value)
|
||||
}
|
||||
}
|
||||
-76
@@ -1,45 +1,16 @@
|
||||
package de.mm20.launcher2.ui.settings.integrations
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.rounded.LightMode
|
||||
import androidx.compose.material.icons.rounded.PlayCircleOutline
|
||||
import androidx.compose.material3.LinearProgressIndicator
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalLifecycleOwner
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import de.mm20.launcher2.accounts.AccountType
|
||||
import de.mm20.launcher2.icons.Google
|
||||
import de.mm20.launcher2.icons.Nextcloud
|
||||
import de.mm20.launcher2.icons.Owncloud
|
||||
import de.mm20.launcher2.ui.R
|
||||
import de.mm20.launcher2.ui.component.preferences.Preference
|
||||
import de.mm20.launcher2.ui.component.preferences.PreferenceCategory
|
||||
import de.mm20.launcher2.ui.component.preferences.PreferenceScreen
|
||||
import de.mm20.launcher2.ui.locals.LocalNavController
|
||||
|
||||
@@ -78,53 +49,6 @@ fun IntegrationsSettingsScreen() {
|
||||
navController?.navigate("settings/integrations/owncloud")
|
||||
}
|
||||
)
|
||||
if (viewModel.isGoogleAvailable) {
|
||||
Preference(
|
||||
title = stringResource(R.string.preference_google),
|
||||
icon = Icons.Rounded.Google,
|
||||
onClick = {
|
||||
navController?.navigate("settings/integrations/google")
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun GoogleSigninButton(
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
Surface(
|
||||
modifier = Modifier.height(40.dp),
|
||||
shadowElevation = 1.dp,
|
||||
color = Color.White,
|
||||
shape = RoundedCornerShape(2.dp),
|
||||
onClick = onClick
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(40.dp)
|
||||
.background(Color.White),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Image(
|
||||
modifier = Modifier.size(18.dp),
|
||||
painter = painterResource(id = R.drawable.ic_google_g),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
Text(
|
||||
modifier = Modifier.padding(start = 13.dp, end = 8.dp),
|
||||
text = stringResource(id = R.string.preference_google_signin),
|
||||
fontFamily = FontFamily.SansSerif,
|
||||
color = Color(0f, 0f, 0f, 0.54f),
|
||||
fontSize = 14.sp,
|
||||
fontWeight = FontWeight.Medium
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
-3
@@ -7,7 +7,4 @@ import org.koin.core.component.KoinComponent
|
||||
import org.koin.core.component.inject
|
||||
|
||||
class IntegrationsSettingsScreenVM : ViewModel(), KoinComponent {
|
||||
private val accountsRepository: AccountsRepository by inject()
|
||||
|
||||
val isGoogleAvailable = accountsRepository.isSupported(AccountType.Google)
|
||||
}
|
||||
Reference in New Issue
Block a user