From e736b18ae76a698ff1b2aea28c85eabe0d26ba02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abel=20Garci=CC=81a=20de=20Prada?= Date: Wed, 27 Oct 2021 12:57:06 +0200 Subject: [PATCH] Use a more appropriated function to retrieve the accounts --- .../android/dependecyinjection/RemoteDataSourceModule.kt | 3 ++- .../main/java/com/owncloud/android/data/ClientManager.kt | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/owncloudApp/src/main/java/com/owncloud/android/dependecyinjection/RemoteDataSourceModule.kt b/owncloudApp/src/main/java/com/owncloud/android/dependecyinjection/RemoteDataSourceModule.kt index a6be33477a1..0627097748d 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/dependecyinjection/RemoteDataSourceModule.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/dependecyinjection/RemoteDataSourceModule.kt @@ -19,6 +19,7 @@ package com.owncloud.android.dependecyinjection +import com.owncloud.android.MainApp import com.owncloud.android.R import com.owncloud.android.authentication.AccountUtils import com.owncloud.android.data.ClientManager @@ -63,7 +64,7 @@ val remoteDataSourceModule = module { single { OwnCloudAccount(get(), androidContext()) } single { SingleSessionManager.getDefaultSingleton().getClientFor(get(), androidContext()) } - single { ClientManager(get(), get(), get()) } + single { ClientManager(get(), get(), get(), MainApp.accountType) } single { OCCapabilityService(get()) } single { OCFileService(get()) } diff --git a/owncloudData/src/main/java/com/owncloud/android/data/ClientManager.kt b/owncloudData/src/main/java/com/owncloud/android/data/ClientManager.kt index d2de459161c..788df716cd2 100644 --- a/owncloudData/src/main/java/com/owncloud/android/data/ClientManager.kt +++ b/owncloudData/src/main/java/com/owncloud/android/data/ClientManager.kt @@ -35,7 +35,8 @@ import com.owncloud.android.lib.resources.users.services.implementation.OCUserSe class ClientManager( private val accountManager: AccountManager, private val preferencesProvider: SharedPreferencesProvider, - val context: Context + val context: Context, + val accountType: String, ) { // This client will maintain cookies across the whole login process. private var ownCloudClient: OwnCloudClient? = null @@ -69,14 +70,14 @@ class ClientManager( val account: Account? = if (accountName.isNullOrBlank()) { getCurrentAccount() } else { - accountManager.accounts.firstOrNull { it.name == accountName } + accountManager.getAccountsByType(accountType).firstOrNull { it.name == accountName } } val ownCloudAccount = OwnCloudAccount(account, context) return SingleSessionManager.getDefaultSingleton().getClientFor(ownCloudAccount, context) } private fun getCurrentAccount(): Account? { - val ocAccounts = accountManager.accounts + val ocAccounts = accountManager.getAccountsByType(accountType) val accountName = preferencesProvider.getString(SELECTED_ACCOUNT, null)