Remove Microsoft integration
This commit is contained in:
parent
44e029e4af
commit
ff61165a34
@ -16,7 +16,6 @@ class BuildInfoSettingsScreenVM : ViewModel(), KoinComponent {
|
|||||||
|
|
||||||
val buildFeatures = mapOf(
|
val buildFeatures = mapOf(
|
||||||
"Accounts: Google" to accountsRepository.isSupported(AccountType.Google),
|
"Accounts: Google" to accountsRepository.isSupported(AccountType.Google),
|
||||||
"Accounts: Microsoft" to accountsRepository.isSupported(AccountType.Microsoft),
|
|
||||||
"Weather providers: HERE" to availableWeatherProviders.contains(WeatherProvider.Here),
|
"Weather providers: HERE" to availableWeatherProviders.contains(WeatherProvider.Here),
|
||||||
"Weather providers: Met No" to availableWeatherProviders.contains(WeatherProvider.MetNo),
|
"Weather providers: Met No" to availableWeatherProviders.contains(WeatherProvider.MetNo),
|
||||||
"Weather providers: OpenWeatherMap" to availableWeatherProviders.contains(WeatherProvider.OpenWeatherMap),
|
"Weather providers: OpenWeatherMap" to availableWeatherProviders.contains(WeatherProvider.OpenWeatherMap),
|
||||||
|
|||||||
@ -140,41 +140,6 @@ fun FileSearchSettingsScreen() {
|
|||||||
enabled = owncloudAccount != null
|
enabled = owncloudAccount != null
|
||||||
)
|
)
|
||||||
|
|
||||||
if (viewModel.microsoftAvailable) {
|
|
||||||
val onedrive by viewModel.onedrive.collectAsState()
|
|
||||||
val microsoftAccount by viewModel.microsoftAccount
|
|
||||||
AnimatedVisibility(microsoftAccount == null) {
|
|
||||||
Banner(
|
|
||||||
text = stringResource(R.string.no_account_microsoft),
|
|
||||||
icon = Icons.Rounded.AccountBox,
|
|
||||||
primaryAction = {
|
|
||||||
TextButton(onClick = {
|
|
||||||
viewModel.login(
|
|
||||||
context as AppCompatActivity,
|
|
||||||
AccountType.Microsoft
|
|
||||||
)
|
|
||||||
}) {
|
|
||||||
Text(
|
|
||||||
stringResource(R.string.connect_account),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
modifier = Modifier.padding(16.dp)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
SwitchPreference(
|
|
||||||
title = stringResource(R.string.preference_search_onedrive),
|
|
||||||
summary = microsoftAccount?.let {
|
|
||||||
stringResource(R.string.preference_search_onedrive_summary, it.userName)
|
|
||||||
} ?: stringResource(R.string.preference_summary_not_logged_in),
|
|
||||||
value = onedrive == true && microsoftAccount != null,
|
|
||||||
onValueChanged = {
|
|
||||||
viewModel.setOneDrive(it)
|
|
||||||
},
|
|
||||||
enabled = microsoftAccount != null
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (viewModel.googleAvailable) {
|
if (viewModel.googleAvailable) {
|
||||||
val gdrive by viewModel.gdrive.collectAsState()
|
val gdrive by viewModel.gdrive.collectAsState()
|
||||||
val googleAccount by viewModel.googleAccount
|
val googleAccount by viewModel.googleAccount
|
||||||
|
|||||||
@ -28,10 +28,8 @@ class FileSearchSettingsScreenVM : ViewModel(), KoinComponent {
|
|||||||
val loading = mutableStateOf(true)
|
val loading = mutableStateOf(true)
|
||||||
val nextcloudAccount = mutableStateOf<Account?>(null)
|
val nextcloudAccount = mutableStateOf<Account?>(null)
|
||||||
val owncloudAccount = mutableStateOf<Account?>(null)
|
val owncloudAccount = mutableStateOf<Account?>(null)
|
||||||
val microsoftAccount = mutableStateOf<Account?>(null)
|
|
||||||
val googleAccount = mutableStateOf<Account?>(null)
|
val googleAccount = mutableStateOf<Account?>(null)
|
||||||
|
|
||||||
val microsoftAvailable = accountsRepository.isSupported(AccountType.Microsoft)
|
|
||||||
val googleAvailable = accountsRepository.isSupported(AccountType.Google)
|
val googleAvailable = accountsRepository.isSupported(AccountType.Google)
|
||||||
|
|
||||||
fun onResume() {
|
fun onResume() {
|
||||||
@ -40,8 +38,6 @@ class FileSearchSettingsScreenVM : ViewModel(), KoinComponent {
|
|||||||
accountsRepository.getCurrentlySignedInAccount(AccountType.Nextcloud)
|
accountsRepository.getCurrentlySignedInAccount(AccountType.Nextcloud)
|
||||||
owncloudAccount.value =
|
owncloudAccount.value =
|
||||||
accountsRepository.getCurrentlySignedInAccount(AccountType.Owncloud)
|
accountsRepository.getCurrentlySignedInAccount(AccountType.Owncloud)
|
||||||
microsoftAccount.value =
|
|
||||||
accountsRepository.getCurrentlySignedInAccount(AccountType.Microsoft)
|
|
||||||
googleAccount.value = accountsRepository.getCurrentlySignedInAccount(AccountType.Google)
|
googleAccount.value = accountsRepository.getCurrentlySignedInAccount(AccountType.Google)
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -126,29 +126,7 @@ fun IntegrationsSettingsScreen() {
|
|||||||
},
|
},
|
||||||
enabled = !loading,
|
enabled = !loading,
|
||||||
)
|
)
|
||||||
if (viewModel.isMicrosoftAvailable) {
|
|
||||||
Preference(
|
|
||||||
title = if (msUser != null) {
|
|
||||||
stringResource(R.string.preference_microsoft)
|
|
||||||
} else {
|
|
||||||
stringResource(R.string.preference_ms_signin)
|
|
||||||
},
|
|
||||||
summary = msUser?.let {
|
|
||||||
stringResource(R.string.preference_signin_user, it.userName)
|
|
||||||
} ?: stringResource(R.string.preference_ms_signin_summary),
|
|
||||||
onClick = {
|
|
||||||
if (msUser != null) {
|
|
||||||
viewModel.signOut(AccountType.Microsoft)
|
|
||||||
} else {
|
|
||||||
viewModel.signIn(
|
|
||||||
context as AppCompatActivity,
|
|
||||||
AccountType.Microsoft
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
enabled = !loading,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (viewModel.isGoogleAvailable) {
|
if (viewModel.isGoogleAvailable) {
|
||||||
Preference(
|
Preference(
|
||||||
title = if (googleUser != null) {
|
title = if (googleUser != null) {
|
||||||
|
|||||||
@ -15,7 +15,6 @@ class IntegrationsSettingsScreenVM : ViewModel(), KoinComponent {
|
|||||||
private val accountsRepository: AccountsRepository by inject()
|
private val accountsRepository: AccountsRepository by inject()
|
||||||
|
|
||||||
val isGoogleAvailable = accountsRepository.isSupported(AccountType.Google)
|
val isGoogleAvailable = accountsRepository.isSupported(AccountType.Google)
|
||||||
val isMicrosoftAvailable = accountsRepository.isSupported(AccountType.Microsoft)
|
|
||||||
|
|
||||||
val googleUser = mutableStateOf<Account?>(null)
|
val googleUser = mutableStateOf<Account?>(null)
|
||||||
val msUser= mutableStateOf<Account?>(null)
|
val msUser= mutableStateOf<Account?>(null)
|
||||||
@ -29,7 +28,6 @@ class IntegrationsSettingsScreenVM : ViewModel(), KoinComponent {
|
|||||||
loading.value = true
|
loading.value = true
|
||||||
googleUser.value = accountsRepository.getCurrentlySignedInAccount(AccountType.Google)
|
googleUser.value = accountsRepository.getCurrentlySignedInAccount(AccountType.Google)
|
||||||
nextcloudUser.value = accountsRepository.getCurrentlySignedInAccount(AccountType.Nextcloud)
|
nextcloudUser.value = accountsRepository.getCurrentlySignedInAccount(AccountType.Nextcloud)
|
||||||
msUser.value = accountsRepository.getCurrentlySignedInAccount(AccountType.Microsoft)
|
|
||||||
owncloudUser.value = accountsRepository.getCurrentlySignedInAccount(AccountType.Owncloud)
|
owncloudUser.value = accountsRepository.getCurrentlySignedInAccount(AccountType.Owncloud)
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
@ -43,7 +41,6 @@ class IntegrationsSettingsScreenVM : ViewModel(), KoinComponent {
|
|||||||
accountsRepository.signout(accountType)
|
accountsRepository.signout(accountType)
|
||||||
when(accountType){
|
when(accountType){
|
||||||
AccountType.Google -> googleUser.value = null
|
AccountType.Google -> googleUser.value = null
|
||||||
AccountType.Microsoft -> msUser.value = null
|
|
||||||
AccountType.Nextcloud -> nextcloudUser.value = null
|
AccountType.Nextcloud -> nextcloudUser.value = null
|
||||||
AccountType.Owncloud -> owncloudUser.value = null
|
AccountType.Owncloud -> owncloudUser.value = null
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import de.mm20.launcher2.files.providers.FileProvider
|
|||||||
import de.mm20.launcher2.files.providers.GDriveFileProvider
|
import de.mm20.launcher2.files.providers.GDriveFileProvider
|
||||||
import de.mm20.launcher2.files.providers.LocalFileProvider
|
import de.mm20.launcher2.files.providers.LocalFileProvider
|
||||||
import de.mm20.launcher2.files.providers.NextcloudFileProvider
|
import de.mm20.launcher2.files.providers.NextcloudFileProvider
|
||||||
import de.mm20.launcher2.files.providers.OneDriveFileProvider
|
|
||||||
import de.mm20.launcher2.files.providers.OwncloudFileProvider
|
import de.mm20.launcher2.files.providers.OwncloudFileProvider
|
||||||
import de.mm20.launcher2.nextcloud.NextcloudApiHelper
|
import de.mm20.launcher2.nextcloud.NextcloudApiHelper
|
||||||
import de.mm20.launcher2.owncloud.OwncloudClient
|
import de.mm20.launcher2.owncloud.OwncloudClient
|
||||||
@ -65,7 +64,6 @@ internal class FileRepositoryImpl(
|
|||||||
|
|
||||||
if (local) providers.add(LocalFileProvider(context, permissionsManager))
|
if (local) providers.add(LocalFileProvider(context, permissionsManager))
|
||||||
if (gdrive) providers.add(GDriveFileProvider(context))
|
if (gdrive) providers.add(GDriveFileProvider(context))
|
||||||
//if (onedrive) providers.add(OneDriveFileProvider(context))
|
|
||||||
if (nextcloud) providers.add(NextcloudFileProvider(nextcloudClient))
|
if (nextcloud) providers.add(NextcloudFileProvider(nextcloudClient))
|
||||||
if (owncloud) providers.add(OwncloudFileProvider(owncloudClient))
|
if (owncloud) providers.add(OwncloudFileProvider(owncloudClient))
|
||||||
|
|
||||||
|
|||||||
@ -1,48 +0,0 @@
|
|||||||
package de.mm20.launcher2.files.providers
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import de.mm20.launcher2.files.R
|
|
||||||
import de.mm20.launcher2.msservices.DriveItem
|
|
||||||
import de.mm20.launcher2.msservices.MicrosoftGraphApiHelper
|
|
||||||
import de.mm20.launcher2.search.data.File
|
|
||||||
import de.mm20.launcher2.search.data.OneDriveFile
|
|
||||||
|
|
||||||
internal class OneDriveFileProvider(
|
|
||||||
private val context: Context
|
|
||||||
) : FileProvider {
|
|
||||||
override suspend fun search(query: String): List<File> {
|
|
||||||
if (query.length < 4) return emptyList()
|
|
||||||
val driveItems = MicrosoftGraphApiHelper.getInstance(context).queryOneDriveFiles(query)
|
|
||||||
?: return emptyList()
|
|
||||||
val files = mutableListOf<OneDriveFile>()
|
|
||||||
for (driveItem in driveItems) {
|
|
||||||
files += OneDriveFile(
|
|
||||||
fileId = driveItem.id,
|
|
||||||
label = driveItem.label,
|
|
||||||
path = "",
|
|
||||||
mimeType = driveItem.mimeType,
|
|
||||||
size = driveItem.size,
|
|
||||||
isDirectory = driveItem.isDirectory,
|
|
||||||
metaData = getMetaData(driveItem),
|
|
||||||
webUrl = driveItem.webUrl
|
|
||||||
)
|
|
||||||
}
|
|
||||||
return files
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getMetaData(driveItem: DriveItem): List<Pair<Int, String>> {
|
|
||||||
val metaData = mutableListOf<Pair<Int, String>>()
|
|
||||||
driveItem.meta.owner?.let {
|
|
||||||
metaData.add(R.string.file_meta_owner to it)
|
|
||||||
} ?: driveItem.meta.createdBy?.let {
|
|
||||||
metaData.add(R.string.file_meta_owner to it)
|
|
||||||
}
|
|
||||||
val width = driveItem.meta.width
|
|
||||||
val height = driveItem.meta.height
|
|
||||||
|
|
||||||
if (width != null && height != null) {
|
|
||||||
metaData.add(R.string.file_meta_dimensions to "${width}x${height}")
|
|
||||||
}
|
|
||||||
return metaData
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -2,7 +2,6 @@ package de.mm20.launcher2.accounts
|
|||||||
|
|
||||||
enum class AccountType {
|
enum class AccountType {
|
||||||
Google,
|
Google,
|
||||||
Microsoft,
|
|
||||||
Nextcloud,
|
Nextcloud,
|
||||||
Owncloud,
|
Owncloud,
|
||||||
}
|
}
|
||||||
@ -3,7 +3,6 @@ package de.mm20.launcher2.accounts
|
|||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import de.mm20.launcher2.gservices.GoogleApiHelper
|
import de.mm20.launcher2.gservices.GoogleApiHelper
|
||||||
import de.mm20.launcher2.msservices.MicrosoftGraphApiHelper
|
|
||||||
import de.mm20.launcher2.nextcloud.NextcloudApiHelper
|
import de.mm20.launcher2.nextcloud.NextcloudApiHelper
|
||||||
import de.mm20.launcher2.owncloud.OwncloudClient
|
import de.mm20.launcher2.owncloud.OwncloudClient
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
@ -29,7 +28,6 @@ internal class AccountsRepositoryImpl(
|
|||||||
private val scope = CoroutineScope(Job() + Dispatchers.Default)
|
private val scope = CoroutineScope(Job() + Dispatchers.Default)
|
||||||
|
|
||||||
private val googleApiHelper = GoogleApiHelper.getInstance(context)
|
private val googleApiHelper = GoogleApiHelper.getInstance(context)
|
||||||
private val msGraphApiHelper = MicrosoftGraphApiHelper.getInstance(context)
|
|
||||||
private val nextcloudApiHelper = NextcloudApiHelper(context)
|
private val nextcloudApiHelper = NextcloudApiHelper(context)
|
||||||
private val owncloudApiHelper = OwncloudClient(context)
|
private val owncloudApiHelper = OwncloudClient(context)
|
||||||
|
|
||||||
@ -40,11 +38,6 @@ internal class AccountsRepositoryImpl(
|
|||||||
googleApiHelper.login(context)
|
googleApiHelper.login(context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AccountType.Microsoft -> {
|
|
||||||
scope.launch {
|
|
||||||
msGraphApiHelper.login(context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AccountType.Nextcloud ->
|
AccountType.Nextcloud ->
|
||||||
scope.launch {
|
scope.launch {
|
||||||
nextcloudApiHelper.login(context)
|
nextcloudApiHelper.login(context)
|
||||||
@ -61,11 +54,6 @@ internal class AccountsRepositoryImpl(
|
|||||||
AccountType.Google -> {
|
AccountType.Google -> {
|
||||||
googleApiHelper.logout()
|
googleApiHelper.logout()
|
||||||
}
|
}
|
||||||
AccountType.Microsoft -> {
|
|
||||||
scope.launch {
|
|
||||||
msGraphApiHelper.logout()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AccountType.Nextcloud -> {
|
AccountType.Nextcloud -> {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
nextcloudApiHelper.logout()
|
nextcloudApiHelper.logout()
|
||||||
@ -80,7 +68,6 @@ internal class AccountsRepositoryImpl(
|
|||||||
override fun isSupported(accountType: AccountType): Boolean {
|
override fun isSupported(accountType: AccountType): Boolean {
|
||||||
return when (accountType) {
|
return when (accountType) {
|
||||||
AccountType.Google -> googleApiHelper.isAvailable()
|
AccountType.Google -> googleApiHelper.isAvailable()
|
||||||
AccountType.Microsoft -> false
|
|
||||||
AccountType.Nextcloud -> true
|
AccountType.Nextcloud -> true
|
||||||
AccountType.Owncloud -> true
|
AccountType.Owncloud -> true
|
||||||
}
|
}
|
||||||
@ -91,9 +78,6 @@ internal class AccountsRepositoryImpl(
|
|||||||
AccountType.Google -> {
|
AccountType.Google -> {
|
||||||
getGoogleAccount()
|
getGoogleAccount()
|
||||||
}
|
}
|
||||||
AccountType.Microsoft -> {
|
|
||||||
getMicrosoftAccount()
|
|
||||||
}
|
|
||||||
AccountType.Nextcloud -> {
|
AccountType.Nextcloud -> {
|
||||||
getNextcloudAccount()
|
getNextcloudAccount()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user