diff --git a/CHANGELOG.md b/CHANGELOG.md index d851e519b21..54c918695f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ ownCloud admins and users. * Enhancement - Update space image: [#4691](https://github.com/owncloud/android/issues/4691) * Enhancement - Show space quota: [#4693](https://github.com/owncloud/android/issues/4693) * Enhancement - Add user role to spaces: [#4698](https://github.com/owncloud/android/pull/4698) +* Enhancement - New setting to show disabled spaces: [#4711](https://github.com/owncloud/android/issues/4711) * Enhancement - Cancellation policy for CI workflows: [#4712](https://github.com/owncloud/android/pull/4712) ## Details @@ -162,6 +163,14 @@ ownCloud admins and users. https://github.com/owncloud/android/pull/4698 +* Enhancement - New setting to show disabled spaces: [#4711](https://github.com/owncloud/android/issues/4711) + + A new setting has been added to the advanced section that allows space managers + to show or hide disabled spaces in the spaces list. + + https://github.com/owncloud/android/issues/4711 + https://github.com/owncloud/android/pull/4714 + * Enhancement - Cancellation policy for CI workflows: [#4712](https://github.com/owncloud/android/pull/4712) A new cancellation policy has been set to CI workflows. Only one concurrent diff --git a/changelog/unreleased/4714 b/changelog/unreleased/4714 new file mode 100644 index 00000000000..cfcf01a0bdf --- /dev/null +++ b/changelog/unreleased/4714 @@ -0,0 +1,7 @@ +Enhancement: New setting to show disabled spaces + +A new setting has been added to the advanced section that allows space +managers to show or hide disabled spaces in the spaces list. + +https://github.com/owncloud/android/issues/4711 +https://github.com/owncloud/android/pull/4714 diff --git a/owncloudApp/src/main/java/com/owncloud/android/dependecyinjection/ViewModelModule.kt b/owncloudApp/src/main/java/com/owncloud/android/dependecyinjection/ViewModelModule.kt index 1da2679251c..537d47f5d8e 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/dependecyinjection/ViewModelModule.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/dependecyinjection/ViewModelModule.kt @@ -102,7 +102,8 @@ val viewModelModule = module { get()) } viewModel { ReceiveExternalFilesViewModel(get(), get(), get(), get()) } viewModel { (accountName: String, showPersonalSpace: Boolean) -> - SpacesListViewModel(get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), accountName, + SpacesListViewModel(get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), + accountName, showPersonalSpace) } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/presentation/settings/advanced/SettingsAdvancedFragment.kt b/owncloudApp/src/main/java/com/owncloud/android/presentation/settings/advanced/SettingsAdvancedFragment.kt index 2e0a649b494..b4e2c62da92 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/presentation/settings/advanced/SettingsAdvancedFragment.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/presentation/settings/advanced/SettingsAdvancedFragment.kt @@ -3,8 +3,9 @@ * * @author David Crespo Ríos * @author Aitor Ballesteros Pavón + * @author Jorge Aguado Recio * - * Copyright (C) 2024 ownCloud GmbH. + * Copyright (C) 2025 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, @@ -36,6 +37,7 @@ class SettingsAdvancedFragment : PreferenceFragmentCompat() { private val advancedViewModel by viewModel() private var prefShowHiddenFiles: SwitchPreferenceCompat? = null + private var prefShowDisabledSpaces: SwitchPreferenceCompat? = null private var prefRemoveLocalFiles: ListPreference? = null override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { @@ -59,6 +61,7 @@ class SettingsAdvancedFragment : PreferenceFragmentCompat() { ).toTypedArray() summary = getString(R.string.prefs_delete_local_files_summary, this.entry) } + prefShowDisabledSpaces = findPreference(PREF_SHOW_DISABLED_SPACES) initPreferenceListeners() } @@ -74,6 +77,11 @@ class SettingsAdvancedFragment : PreferenceFragmentCompat() { true } + prefShowDisabledSpaces?.setOnPreferenceChangeListener { _: Preference?, newValue: Any -> + advancedViewModel.setShowDisabledSpaces(newValue as Boolean) + true + } + prefRemoveLocalFiles?.setOnPreferenceChangeListener { preference: Preference?, newValue: Any -> val index = (preference as ListPreference).findIndexOfValue(newValue as String) preference.summary = getString(R.string.prefs_delete_local_files_summary, preference.entries[index]) @@ -84,5 +92,6 @@ class SettingsAdvancedFragment : PreferenceFragmentCompat() { companion object { const val PREF_SHOW_HIDDEN_FILES = "show_hidden_files" + const val PREF_SHOW_DISABLED_SPACES = "show_disabled_spaces" } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/presentation/settings/advanced/SettingsAdvancedViewModel.kt b/owncloudApp/src/main/java/com/owncloud/android/presentation/settings/advanced/SettingsAdvancedViewModel.kt index 10f0a320f61..1cc2aa3edc2 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/presentation/settings/advanced/SettingsAdvancedViewModel.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/presentation/settings/advanced/SettingsAdvancedViewModel.kt @@ -23,6 +23,7 @@ package com.owncloud.android.presentation.settings.advanced import androidx.lifecycle.ViewModel import com.owncloud.android.data.providers.SharedPreferencesProvider +import com.owncloud.android.presentation.settings.advanced.SettingsAdvancedFragment.Companion.PREF_SHOW_DISABLED_SPACES import com.owncloud.android.presentation.settings.advanced.SettingsAdvancedFragment.Companion.PREF_SHOW_HIDDEN_FILES import com.owncloud.android.providers.WorkManagerProvider import com.owncloud.android.workers.RemoveLocallyFilesWithLastUsageOlderThanGivenTimeWorker.Companion.DELETE_FILES_OLDER_GIVEN_TIME_WORKER @@ -39,6 +40,10 @@ class SettingsAdvancedViewModel( preferencesProvider.putBoolean(PREF_SHOW_HIDDEN_FILES, hide) } + fun setShowDisabledSpaces(showDisabledSpaces: Boolean) { + preferencesProvider.putBoolean(PREF_SHOW_DISABLED_SPACES, showDisabledSpaces) + } + fun scheduleDeleteLocalFiles(newValue: String) { workManagerProvider.cancelAllWorkByTag(DELETE_FILES_OLDER_GIVEN_TIME_WORKER) if (newValue != RemoveLocalFiles.NEVER.name) { diff --git a/owncloudApp/src/main/java/com/owncloud/android/presentation/spaces/SpacesListFragment.kt b/owncloudApp/src/main/java/com/owncloud/android/presentation/spaces/SpacesListFragment.kt index 3030155cfad..510401cdbb9 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/presentation/spaces/SpacesListFragment.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/presentation/spaces/SpacesListFragment.kt @@ -171,9 +171,11 @@ class SpacesListFragment : private fun subscribeToViewModels() { collectLatestLifecycleFlow(spacesListViewModel.spacesList) { uiState -> + var spacesToListFiltered: List if (uiState.searchFilter != "") { - var spacesToListFiltered = - uiState.spaces.filter { it.name.lowercase().contains(uiState.searchFilter.lowercase()) && !it.isPersonal } + spacesToListFiltered = + uiState.spaces.filter { it.name.lowercase().contains(uiState.searchFilter.lowercase()) && !it.isPersonal && + shouldShowDisabledSpace(it) } val personalSpace = uiState.spaces.find { it.isPersonal } personalSpace?.let { spacesToListFiltered = spacesToListFiltered.toMutableList().apply { @@ -183,8 +185,9 @@ class SpacesListFragment : showOrHideEmptyView(spacesToListFiltered) spacesListAdapter.setData(spacesToListFiltered, isMultiPersonal) } else { - showOrHideEmptyView(uiState.spaces) - spacesListAdapter.setData(uiState.spaces, isMultiPersonal) + spacesToListFiltered = uiState.spaces.filter { shouldShowDisabledSpace(it) } + showOrHideEmptyView(spacesToListFiltered) + spacesListAdapter.setData(spacesToListFiltered, isMultiPersonal) } binding.swipeRefreshSpacesList.isRefreshing = uiState.refreshing uiState.error?.let { showErrorInSnackbar(R.string.spaces_sync_failed, it) } @@ -447,6 +450,8 @@ class SpacesListFragment : binding.fileOptionsBottomSheetLayout.addView(fileOptionItemView) } + private fun shouldShowDisabledSpace(space: OCSpace): Boolean = !space.isDisabled || spacesListViewModel.showDisabledSpaces + companion object { const val REQUEST_KEY_CLICK_SPACE = "REQUEST_KEY_CLICK_SPACE" const val BUNDLE_KEY_CLICK_SPACE = "BUNDLE_KEY_CLICK_SPACE" diff --git a/owncloudApp/src/main/java/com/owncloud/android/presentation/spaces/SpacesListViewModel.kt b/owncloudApp/src/main/java/com/owncloud/android/presentation/spaces/SpacesListViewModel.kt index 2fecf8f24e6..70d24f6f625 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/presentation/spaces/SpacesListViewModel.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/presentation/spaces/SpacesListViewModel.kt @@ -23,6 +23,7 @@ package com.owncloud.android.presentation.spaces import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope +import com.owncloud.android.data.providers.SharedPreferencesProvider import com.owncloud.android.domain.BaseUseCaseWithResult import com.owncloud.android.domain.UseCaseResult import com.owncloud.android.domain.capabilities.usecases.GetStoredCapabilitiesUseCase @@ -47,6 +48,7 @@ import com.owncloud.android.domain.user.usecases.GetUserPermissionsAsyncUseCase import com.owncloud.android.domain.utils.Event import com.owncloud.android.extensions.ViewModelExt.runUseCaseWithResult import com.owncloud.android.presentation.common.UIResult +import com.owncloud.android.presentation.settings.advanced.SettingsAdvancedFragment.Companion.PREF_SHOW_DISABLED_SPACES import com.owncloud.android.providers.CoroutinesDispatcherProvider import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.MutableStateFlow @@ -71,6 +73,7 @@ class SpacesListViewModel( private val disableSpaceUseCase: DisableSpaceUseCase, private val enableSpaceUseCase: EnableSpaceUseCase, private val coroutinesDispatcherProvider: CoroutinesDispatcherProvider, + private val sharedPreferencesProvider: SharedPreferencesProvider, private val accountName: String, private val showPersonalSpace: Boolean, ) : ViewModel() { @@ -106,6 +109,8 @@ class SpacesListViewModel( private val _deleteSpaceFlow = MutableSharedFlow>?>() val deleteSpaceFlow: SharedFlow>?> = _deleteSpaceFlow + val showDisabledSpaces = sharedPreferencesProvider.getBoolean(PREF_SHOW_DISABLED_SPACES, false) + init { viewModelScope.launch(coroutinesDispatcherProvider.io) { refreshSpacesFromServer() diff --git a/owncloudApp/src/main/res/values/strings.xml b/owncloudApp/src/main/res/values/strings.xml index ca7a59e2a71..8ef97390ba8 100644 --- a/owncloudApp/src/main/res/values/strings.xml +++ b/owncloudApp/src/main/res/values/strings.xml @@ -83,6 +83,8 @@ Advanced Manage notifications Show hidden files + Show disabled spaces + Only applying to space managers in Infinite Scale accounts Log files Empty log folder! Enable logging and log files will show up here. diff --git a/owncloudApp/src/main/res/xml/settings_advanced.xml b/owncloudApp/src/main/res/xml/settings_advanced.xml index 57be59069c7..1cd0478e895 100644 --- a/owncloudApp/src/main/res/xml/settings_advanced.xml +++ b/owncloudApp/src/main/res/xml/settings_advanced.xml @@ -22,6 +22,12 @@ app:key="show_hidden_files" app:title="@string/prefs_show_hidden_files" /> + +