mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-06 22:29:09 +00:00
Migrate server selection from requery to room
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
749e0dbf1c
commit
fe8c7d468a
@ -3,8 +3,8 @@
|
|||||||
*
|
*
|
||||||
* @author Andy Scherzinger
|
* @author Andy Scherzinger
|
||||||
* @author Mario Danic
|
* @author Mario Danic
|
||||||
* Copyright (C) 2021 Andy Scherzinger (info@andy-scherzinger.de)
|
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
|
||||||
* Copyright (C) 2017 Mario Danic (mario@lovelyhq.com)
|
* Copyright (C) 2017 Mario Danic <mario@lovelyhq.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -44,15 +44,14 @@ import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedA
|
|||||||
import com.nextcloud.talk.controllers.base.NewBaseController
|
import com.nextcloud.talk.controllers.base.NewBaseController
|
||||||
import com.nextcloud.talk.controllers.util.viewBinding
|
import com.nextcloud.talk.controllers.util.viewBinding
|
||||||
import com.nextcloud.talk.databinding.ControllerServerSelectionBinding
|
import com.nextcloud.talk.databinding.ControllerServerSelectionBinding
|
||||||
import com.nextcloud.talk.models.database.UserEntity
|
|
||||||
import com.nextcloud.talk.models.json.generic.Status
|
import com.nextcloud.talk.models.json.generic.Status
|
||||||
import com.nextcloud.talk.utils.AccountUtils.findAccounts
|
import com.nextcloud.talk.users.UserManager
|
||||||
|
import com.nextcloud.talk.utils.AccountUtils.findAccountsForUsers
|
||||||
import com.nextcloud.talk.utils.AccountUtils.getAppNameBasedOnPackage
|
import com.nextcloud.talk.utils.AccountUtils.getAppNameBasedOnPackage
|
||||||
import com.nextcloud.talk.utils.ApiUtils
|
import com.nextcloud.talk.utils.ApiUtils
|
||||||
import com.nextcloud.talk.utils.DisplayUtils
|
import com.nextcloud.talk.utils.DisplayUtils
|
||||||
import com.nextcloud.talk.utils.UriUtils
|
import com.nextcloud.talk.utils.UriUtils
|
||||||
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_IS_ACCOUNT_IMPORT
|
import com.nextcloud.talk.utils.bundle.BundleKeys.KEY_IS_ACCOUNT_IMPORT
|
||||||
import com.nextcloud.talk.utils.database.user.UserUtils
|
|
||||||
import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder
|
import com.nextcloud.talk.utils.singletons.ApplicationWideMessageHolder
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||||
import io.reactivex.disposables.Disposable
|
import io.reactivex.disposables.Disposable
|
||||||
@ -70,7 +69,7 @@ class ServerSelectionController :
|
|||||||
lateinit var ncApi: NcApi
|
lateinit var ncApi: NcApi
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
lateinit var userUtils: UserUtils
|
lateinit var userManager: UserManager
|
||||||
|
|
||||||
private var statusQueryDisposable: Disposable? = null
|
private var statusQueryDisposable: Disposable? = null
|
||||||
|
|
||||||
@ -119,9 +118,9 @@ class ServerSelectionController :
|
|||||||
if (
|
if (
|
||||||
(
|
(
|
||||||
TextUtils.isEmpty(resources!!.getString(R.string.nc_import_account_type)) ||
|
TextUtils.isEmpty(resources!!.getString(R.string.nc_import_account_type)) ||
|
||||||
findAccounts(userUtils.users as List<UserEntity>).isEmpty()
|
findAccountsForUsers(userManager.users.blockingGet()).isEmpty()
|
||||||
) &&
|
) &&
|
||||||
userUtils.users.size == 0
|
userManager.users.blockingGet().isEmpty()
|
||||||
) {
|
) {
|
||||||
binding.helperTextView.setText(R.string.nc_get_from_provider)
|
binding.helperTextView.setText(R.string.nc_get_from_provider)
|
||||||
binding.helperTextView.setOnClickListener {
|
binding.helperTextView.setOnClickListener {
|
||||||
@ -134,12 +133,12 @@ class ServerSelectionController :
|
|||||||
)
|
)
|
||||||
startActivity(browserIntent)
|
startActivity(browserIntent)
|
||||||
}
|
}
|
||||||
} else if (findAccounts(userUtils.users as List<UserEntity>).size > 0) {
|
} else if (findAccountsForUsers(userManager.users.blockingGet()).isNotEmpty()) {
|
||||||
if (!TextUtils.isEmpty(
|
if (!TextUtils.isEmpty(
|
||||||
getAppNameBasedOnPackage(resources!!.getString(R.string.nc_import_accounts_from))
|
getAppNameBasedOnPackage(resources!!.getString(R.string.nc_import_accounts_from))
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
if (findAccounts(userUtils.users as List<UserEntity>).size > 1) {
|
if (findAccountsForUsers(userManager.users.blockingGet()).size > 1) {
|
||||||
binding.helperTextView.setText(
|
binding.helperTextView.setText(
|
||||||
String.format(
|
String.format(
|
||||||
resources!!.getString(R.string.nc_server_import_accounts),
|
resources!!.getString(R.string.nc_server_import_accounts),
|
||||||
@ -155,7 +154,7 @@ class ServerSelectionController :
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (findAccounts(userUtils.users as List<UserEntity>).size > 1) {
|
if (findAccountsForUsers(userManager.users.blockingGet()).size > 1) {
|
||||||
binding.helperTextView.text = resources!!.getString(R.string.nc_server_import_accounts_plain)
|
binding.helperTextView.text = resources!!.getString(R.string.nc_server_import_accounts_plain)
|
||||||
} else {
|
} else {
|
||||||
binding.helperTextView.text = resources!!.getString(R.string.nc_server_import_account_plain)
|
binding.helperTextView.text = resources!!.getString(R.string.nc_server_import_account_plain)
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Nextcloud Talk application
|
* Nextcloud Talk application
|
||||||
*
|
*
|
||||||
|
* @author Andy Scherzinger
|
||||||
* @author Mario Danic
|
* @author Mario Danic
|
||||||
|
* Copyright (C) 2021 Andy Scherzinger <info@andy-scherzinger.de>
|
||||||
* Copyright (C) 2017 Mario Danic <mario@lovelyhq.com>
|
* Copyright (C) 2017 Mario Danic <mario@lovelyhq.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
@ -32,7 +34,6 @@ import com.nextcloud.talk.R
|
|||||||
import com.nextcloud.talk.application.NextcloudTalkApplication
|
import com.nextcloud.talk.application.NextcloudTalkApplication
|
||||||
import com.nextcloud.talk.data.user.model.User
|
import com.nextcloud.talk.data.user.model.User
|
||||||
import com.nextcloud.talk.models.ImportAccount
|
import com.nextcloud.talk.models.ImportAccount
|
||||||
import com.nextcloud.talk.models.database.UserEntity
|
|
||||||
import java.util.Arrays
|
import java.util.Arrays
|
||||||
|
|
||||||
object AccountUtils {
|
object AccountUtils {
|
||||||
@ -40,11 +41,6 @@ object AccountUtils {
|
|||||||
private const val TAG = "AccountUtils"
|
private const val TAG = "AccountUtils"
|
||||||
private const val MIN_SUPPORTED_FILES_APP_VERSION = 30060151
|
private const val MIN_SUPPORTED_FILES_APP_VERSION = 30060151
|
||||||
|
|
||||||
@Deprecated("Migrate to findAccountsForUsers")
|
|
||||||
fun findAccounts(userEntitiesList: List<UserEntity>): List<Account> {
|
|
||||||
return findAccountsForUsers(LegacyUserEntityMapper.toModel(userEntitiesList))
|
|
||||||
}
|
|
||||||
|
|
||||||
fun findAccountsForUsers(users: List<User>): List<Account> {
|
fun findAccountsForUsers(users: List<User>): List<Account> {
|
||||||
val context = NextcloudTalkApplication.sharedApplication!!.applicationContext
|
val context = NextcloudTalkApplication.sharedApplication!!.applicationContext
|
||||||
val accMgr = AccountManager.get(context)
|
val accMgr = AccountManager.get(context)
|
||||||
|
Loading…
Reference in New Issue
Block a user