Hide Google Drive / OneDrive file settings if unavailable

This commit is contained in:
MM20 2023-04-17 18:07:22 +02:00
parent e0515b4432
commit 168ab729a1
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
2 changed files with 65 additions and 58 deletions

View File

@ -140,6 +140,7 @@ fun FileSearchSettingsScreen() {
enabled = owncloudAccount != null enabled = owncloudAccount != null
) )
if (viewModel.microsoftAvailable) {
val onedrive by viewModel.onedrive.observeAsState() val onedrive by viewModel.onedrive.observeAsState()
val microsoftAccount by viewModel.microsoftAccount.observeAsState() val microsoftAccount by viewModel.microsoftAccount.observeAsState()
AnimatedVisibility(microsoftAccount == null) { AnimatedVisibility(microsoftAccount == null) {
@ -172,7 +173,9 @@ fun FileSearchSettingsScreen() {
}, },
enabled = microsoftAccount != null enabled = microsoftAccount != null
) )
}
if (viewModel.googleAvailable) {
val gdrive by viewModel.gdrive.observeAsState() val gdrive by viewModel.gdrive.observeAsState()
val googleAccount by viewModel.googleAccount.observeAsState() val googleAccount by viewModel.googleAccount.observeAsState()
AnimatedVisibility(googleAccount == null) { AnimatedVisibility(googleAccount == null) {
@ -209,3 +212,4 @@ fun FileSearchSettingsScreen() {
} }
} }
} }
}

View File

@ -30,6 +30,9 @@ class FileSearchSettingsScreenVM : ViewModel(), KoinComponent {
val microsoftAccount = MutableLiveData<Account?>(null) val microsoftAccount = MutableLiveData<Account?>(null)
val googleAccount = MutableLiveData<Account?>(null) val googleAccount = MutableLiveData<Account?>(null)
val microsoftAvailable = accountsRepository.isSupported(AccountType.Microsoft)
val googleAvailable = accountsRepository.isSupported(AccountType.Google)
fun onResume() { fun onResume() {
viewModelScope.launch { viewModelScope.launch {
nextcloudAccount.value = nextcloudAccount.value =