Skip to content

Commit 28a8089

Browse files
authored
Merge pull request #4714 from owncloud/feature/show_or_hide_disabled_spaces
[FEATURE REQUEST] Show/hide disabled spaces
2 parents cc2a35a + 9f4e42b commit 28a8089

File tree

9 files changed

+55
-6
lines changed

9 files changed

+55
-6
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ ownCloud admins and users.
5151
* Enhancement - Update space image: [#4691](https://github.com/owncloud/android/issues/4691)
5252
* Enhancement - Show space quota: [#4693](https://github.com/owncloud/android/issues/4693)
5353
* Enhancement - Add user role to spaces: [#4698](https://github.com/owncloud/android/pull/4698)
54+
* Enhancement - New setting to show disabled spaces: [#4711](https://github.com/owncloud/android/issues/4711)
5455
* Enhancement - Cancellation policy for CI workflows: [#4712](https://github.com/owncloud/android/pull/4712)
5556

5657
## Details
@@ -162,6 +163,14 @@ ownCloud admins and users.
162163

163164
https://github.com/owncloud/android/pull/4698
164165

166+
* Enhancement - New setting to show disabled spaces: [#4711](https://github.com/owncloud/android/issues/4711)
167+
168+
A new setting has been added to the advanced section that allows space managers
169+
to show or hide disabled spaces in the spaces list.
170+
171+
https://github.com/owncloud/android/issues/4711
172+
https://github.com/owncloud/android/pull/4714
173+
165174
* Enhancement - Cancellation policy for CI workflows: [#4712](https://github.com/owncloud/android/pull/4712)
166175

167176
A new cancellation policy has been set to CI workflows. Only one concurrent

changelog/unreleased/4714

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Enhancement: New setting to show disabled spaces
2+
3+
A new setting has been added to the advanced section that allows space
4+
managers to show or hide disabled spaces in the spaces list.
5+
6+
https://github.com/owncloud/android/issues/4711
7+
https://github.com/owncloud/android/pull/4714

owncloudApp/src/main/java/com/owncloud/android/dependecyinjection/ViewModelModule.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ val viewModelModule = module {
102102
get()) }
103103
viewModel { ReceiveExternalFilesViewModel(get(), get(), get(), get()) }
104104
viewModel { (accountName: String, showPersonalSpace: Boolean) ->
105-
SpacesListViewModel(get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), accountName,
105+
SpacesListViewModel(get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(), get(),
106+
accountName,
106107
showPersonalSpace)
107108
}
108109
}

owncloudApp/src/main/java/com/owncloud/android/presentation/settings/advanced/SettingsAdvancedFragment.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
*
44
* @author David Crespo Ríos
55
* @author Aitor Ballesteros Pavón
6+
* @author Jorge Aguado Recio
67
*
7-
* Copyright (C) 2024 ownCloud GmbH.
8+
* Copyright (C) 2025 ownCloud GmbH.
89
*
910
* This program is free software: you can redistribute it and/or modify
1011
* it under the terms of the GNU General Public License version 2,
@@ -36,6 +37,7 @@ class SettingsAdvancedFragment : PreferenceFragmentCompat() {
3637
private val advancedViewModel by viewModel<SettingsAdvancedViewModel>()
3738

3839
private var prefShowHiddenFiles: SwitchPreferenceCompat? = null
40+
private var prefShowDisabledSpaces: SwitchPreferenceCompat? = null
3941
private var prefRemoveLocalFiles: ListPreference? = null
4042

4143
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
@@ -59,6 +61,7 @@ class SettingsAdvancedFragment : PreferenceFragmentCompat() {
5961
).toTypedArray()
6062
summary = getString(R.string.prefs_delete_local_files_summary, this.entry)
6163
}
64+
prefShowDisabledSpaces = findPreference(PREF_SHOW_DISABLED_SPACES)
6265
initPreferenceListeners()
6366
}
6467

@@ -74,6 +77,11 @@ class SettingsAdvancedFragment : PreferenceFragmentCompat() {
7477
true
7578
}
7679

80+
prefShowDisabledSpaces?.setOnPreferenceChangeListener { _: Preference?, newValue: Any ->
81+
advancedViewModel.setShowDisabledSpaces(newValue as Boolean)
82+
true
83+
}
84+
7785
prefRemoveLocalFiles?.setOnPreferenceChangeListener { preference: Preference?, newValue: Any ->
7886
val index = (preference as ListPreference).findIndexOfValue(newValue as String)
7987
preference.summary = getString(R.string.prefs_delete_local_files_summary, preference.entries[index])
@@ -84,5 +92,6 @@ class SettingsAdvancedFragment : PreferenceFragmentCompat() {
8492

8593
companion object {
8694
const val PREF_SHOW_HIDDEN_FILES = "show_hidden_files"
95+
const val PREF_SHOW_DISABLED_SPACES = "show_disabled_spaces"
8796
}
8897
}

owncloudApp/src/main/java/com/owncloud/android/presentation/settings/advanced/SettingsAdvancedViewModel.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ package com.owncloud.android.presentation.settings.advanced
2323

2424
import androidx.lifecycle.ViewModel
2525
import com.owncloud.android.data.providers.SharedPreferencesProvider
26+
import com.owncloud.android.presentation.settings.advanced.SettingsAdvancedFragment.Companion.PREF_SHOW_DISABLED_SPACES
2627
import com.owncloud.android.presentation.settings.advanced.SettingsAdvancedFragment.Companion.PREF_SHOW_HIDDEN_FILES
2728
import com.owncloud.android.providers.WorkManagerProvider
2829
import com.owncloud.android.workers.RemoveLocallyFilesWithLastUsageOlderThanGivenTimeWorker.Companion.DELETE_FILES_OLDER_GIVEN_TIME_WORKER
@@ -39,6 +40,10 @@ class SettingsAdvancedViewModel(
3940
preferencesProvider.putBoolean(PREF_SHOW_HIDDEN_FILES, hide)
4041
}
4142

43+
fun setShowDisabledSpaces(showDisabledSpaces: Boolean) {
44+
preferencesProvider.putBoolean(PREF_SHOW_DISABLED_SPACES, showDisabledSpaces)
45+
}
46+
4247
fun scheduleDeleteLocalFiles(newValue: String) {
4348
workManagerProvider.cancelAllWorkByTag(DELETE_FILES_OLDER_GIVEN_TIME_WORKER)
4449
if (newValue != RemoveLocalFiles.NEVER.name) {

owncloudApp/src/main/java/com/owncloud/android/presentation/spaces/SpacesListFragment.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,11 @@ class SpacesListFragment :
171171

172172
private fun subscribeToViewModels() {
173173
collectLatestLifecycleFlow(spacesListViewModel.spacesList) { uiState ->
174+
var spacesToListFiltered: List<OCSpace>
174175
if (uiState.searchFilter != "") {
175-
var spacesToListFiltered =
176-
uiState.spaces.filter { it.name.lowercase().contains(uiState.searchFilter.lowercase()) && !it.isPersonal }
176+
spacesToListFiltered =
177+
uiState.spaces.filter { it.name.lowercase().contains(uiState.searchFilter.lowercase()) && !it.isPersonal &&
178+
shouldShowDisabledSpace(it) }
177179
val personalSpace = uiState.spaces.find { it.isPersonal }
178180
personalSpace?.let {
179181
spacesToListFiltered = spacesToListFiltered.toMutableList().apply {
@@ -183,8 +185,9 @@ class SpacesListFragment :
183185
showOrHideEmptyView(spacesToListFiltered)
184186
spacesListAdapter.setData(spacesToListFiltered, isMultiPersonal)
185187
} else {
186-
showOrHideEmptyView(uiState.spaces)
187-
spacesListAdapter.setData(uiState.spaces, isMultiPersonal)
188+
spacesToListFiltered = uiState.spaces.filter { shouldShowDisabledSpace(it) }
189+
showOrHideEmptyView(spacesToListFiltered)
190+
spacesListAdapter.setData(spacesToListFiltered, isMultiPersonal)
188191
}
189192
binding.swipeRefreshSpacesList.isRefreshing = uiState.refreshing
190193
uiState.error?.let { showErrorInSnackbar(R.string.spaces_sync_failed, it) }
@@ -447,6 +450,8 @@ class SpacesListFragment :
447450
binding.fileOptionsBottomSheetLayout.addView(fileOptionItemView)
448451
}
449452

453+
private fun shouldShowDisabledSpace(space: OCSpace): Boolean = !space.isDisabled || spacesListViewModel.showDisabledSpaces
454+
450455
companion object {
451456
const val REQUEST_KEY_CLICK_SPACE = "REQUEST_KEY_CLICK_SPACE"
452457
const val BUNDLE_KEY_CLICK_SPACE = "BUNDLE_KEY_CLICK_SPACE"

owncloudApp/src/main/java/com/owncloud/android/presentation/spaces/SpacesListViewModel.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ package com.owncloud.android.presentation.spaces
2323

2424
import androidx.lifecycle.ViewModel
2525
import androidx.lifecycle.viewModelScope
26+
import com.owncloud.android.data.providers.SharedPreferencesProvider
2627
import com.owncloud.android.domain.BaseUseCaseWithResult
2728
import com.owncloud.android.domain.UseCaseResult
2829
import com.owncloud.android.domain.capabilities.usecases.GetStoredCapabilitiesUseCase
@@ -47,6 +48,7 @@ import com.owncloud.android.domain.user.usecases.GetUserPermissionsAsyncUseCase
4748
import com.owncloud.android.domain.utils.Event
4849
import com.owncloud.android.extensions.ViewModelExt.runUseCaseWithResult
4950
import com.owncloud.android.presentation.common.UIResult
51+
import com.owncloud.android.presentation.settings.advanced.SettingsAdvancedFragment.Companion.PREF_SHOW_DISABLED_SPACES
5052
import com.owncloud.android.providers.CoroutinesDispatcherProvider
5153
import kotlinx.coroutines.flow.MutableSharedFlow
5254
import kotlinx.coroutines.flow.MutableStateFlow
@@ -71,6 +73,7 @@ class SpacesListViewModel(
7173
private val disableSpaceUseCase: DisableSpaceUseCase,
7274
private val enableSpaceUseCase: EnableSpaceUseCase,
7375
private val coroutinesDispatcherProvider: CoroutinesDispatcherProvider,
76+
private val sharedPreferencesProvider: SharedPreferencesProvider,
7477
private val accountName: String,
7578
private val showPersonalSpace: Boolean,
7679
) : ViewModel() {
@@ -106,6 +109,8 @@ class SpacesListViewModel(
106109
private val _deleteSpaceFlow = MutableSharedFlow<Event<UIResult<Unit>>?>()
107110
val deleteSpaceFlow: SharedFlow<Event<UIResult<Unit>>?> = _deleteSpaceFlow
108111

112+
val showDisabledSpaces = sharedPreferencesProvider.getBoolean(PREF_SHOW_DISABLED_SPACES, false)
113+
109114
init {
110115
viewModelScope.launch(coroutinesDispatcherProvider.io) {
111116
refreshSpacesFromServer()

owncloudApp/src/main/res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@
8383
<string name="prefs_subsection_advanced">Advanced</string>
8484
<string name="prefs_subsection_notifications">Manage notifications</string>
8585
<string name="prefs_show_hidden_files">Show hidden files</string>
86+
<string name="prefs_show_disabled_spaces">Show disabled spaces</string>
87+
<string name="prefs_show_disabled_spaces_summary">Only applying to space managers in Infinite Scale accounts</string>
8688
<string name="prefs_log_open_logs_list_view">Log files</string>
8789
<string name="prefs_log_no_logs_list_view">Empty log folder!</string>
8890
<string name="prefs_log_empty_subtitle">Enable logging and log files will show up here.</string>

owncloudApp/src/main/res/xml/settings_advanced.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
app:key="show_hidden_files"
2323
app:title="@string/prefs_show_hidden_files" />
2424

25+
<SwitchPreferenceCompat
26+
app:iconSpaceReserved="false"
27+
app:key="show_disabled_spaces"
28+
app:title="@string/prefs_show_disabled_spaces"
29+
app:summary="@string/prefs_show_disabled_spaces_summary"/>
30+
2531
<ListPreference
2632
app:defaultValue="NEVER"
2733
app:dialogTitle="@string/prefs_delete_local_files"

0 commit comments

Comments
 (0)