Skip to content

Commit

Permalink
refactor: removed run method, changed spacesListViewModel initializat…
Browse files Browse the repository at this point in the history
…ion and added license from GetUserQuotasAsStreamUseCae
  • Loading branch information
joragua committed Nov 14, 2024
1 parent 571c132 commit 812812e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ package com.owncloud.android.presentation.accounts

import android.accounts.Account
import android.accounts.AccountManager
import android.accounts.AccountManagerCallback
import android.accounts.AccountManagerFuture
import android.accounts.OperationCanceledException
import android.app.AlertDialog
Expand Down Expand Up @@ -54,7 +53,7 @@ import com.owncloud.android.utils.PreferenceUtils
import org.koin.androidx.viewmodel.ext.android.viewModel
import timber.log.Timber

class ManageAccountsDialogFragment : DialogFragment(), ManageAccountsAdapter.AccountAdapterListener, AccountManagerCallback<Boolean> {
class ManageAccountsDialogFragment : DialogFragment(), ManageAccountsAdapter.AccountAdapterListener {

private lateinit var accountListAdapter: ManageAccountsAdapter
private var currentAccount: Account? = null
Expand Down Expand Up @@ -109,7 +108,7 @@ class ManageAccountsDialogFragment : DialogFragment(), ManageAccountsAdapter.Acc
)
.setPositiveButton(getString(R.string.common_yes)) { _, _ ->
val accountManager = AccountManager.get(MainApp.appContext)
accountManager.removeAccount(account, this, null)
accountManager.removeAccount(account, null, null)
if (manageAccountsViewModel.getLoggedAccounts().size > 1) {
dialogView.isVisible = true
}
Expand Down Expand Up @@ -190,13 +189,6 @@ class ManageAccountsDialogFragment : DialogFragment(), ManageAccountsAdapter.Acc
}
}

/**
* What happens when an account is removed
*/
override fun run(future: AccountManagerFuture<Boolean>) {
// Nothing to do
}

private fun changeToAccountContext(account: Account) {
AccountUtils.setCurrentOwnCloudAccount(
parentActivity.applicationContext,
Expand Down Expand Up @@ -252,7 +244,6 @@ class ManageAccountsDialogFragment : DialogFragment(), ManageAccountsAdapter.Acc

accountListAdapter.submitAccountList(accountList = getAccountListItems(listUserQuotas))

recyclerView = dialogView.findViewById(R.id.account_list_recycler_view)
recyclerView.adapter = accountListAdapter
} else {
createAccount()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import org.koin.android.ext.android.inject
import org.koin.androidx.viewmodel.ext.android.getViewModel
import org.koin.androidx.viewmodel.ext.android.viewModel
import org.koin.core.parameter.parametersOf
import timber.log.Timber
Expand Down Expand Up @@ -183,9 +184,7 @@ class FileDisplayActivity : FileActivity(),

private val fileOperationsViewModel: FileOperationsViewModel by viewModel()
private val transfersViewModel: TransfersViewModel by viewModel()

private val spacesListViewModelLazy: Lazy<SpacesListViewModel> = inject { parametersOf(account.name, false) }
private val spacesListViewModel: SpacesListViewModel get() = spacesListViewModelLazy.value
private lateinit var spacesListViewModel: SpacesListViewModel

private val sharedPreferences: SharedPreferencesProvider by inject()

Expand Down Expand Up @@ -382,6 +381,7 @@ class FileDisplayActivity : FileActivity(),
}
}

spacesListViewModel = getViewModel { parametersOf(account.name, false) }
spacesListViewModel.refreshSpacesFromServer()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/**
* ownCloud Android client application
*
* @author Jorge Aguado Recio
*
* Copyright (C) 2024 ownCloud GmbH.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/


package com.owncloud.android.domain.user.usecases

import com.owncloud.android.domain.BaseUseCase
Expand Down

0 comments on commit 812812e

Please sign in to comment.