Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions changelog/unreleased/4714
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -36,6 +37,7 @@ class SettingsAdvancedFragment : PreferenceFragmentCompat() {
private val advancedViewModel by viewModel<SettingsAdvancedViewModel>()

private var prefShowHiddenFiles: SwitchPreferenceCompat? = null
private var prefShowDisabledSpaces: SwitchPreferenceCompat? = null
private var prefRemoveLocalFiles: ListPreference? = null

override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
Expand All @@ -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()
}

Expand All @@ -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])
Expand All @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,11 @@ class SpacesListFragment :

private fun subscribeToViewModels() {
collectLatestLifecycleFlow(spacesListViewModel.spacesList) { uiState ->
var spacesToListFiltered: List<OCSpace>
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 {
Expand All @@ -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) }
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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() {
Expand Down Expand Up @@ -106,6 +109,8 @@ class SpacesListViewModel(
private val _deleteSpaceFlow = MutableSharedFlow<Event<UIResult<Unit>>?>()
val deleteSpaceFlow: SharedFlow<Event<UIResult<Unit>>?> = _deleteSpaceFlow

val showDisabledSpaces = sharedPreferencesProvider.getBoolean(PREF_SHOW_DISABLED_SPACES, false)

init {
viewModelScope.launch(coroutinesDispatcherProvider.io) {
refreshSpacesFromServer()
Expand Down
2 changes: 2 additions & 0 deletions owncloudApp/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
<string name="prefs_subsection_advanced">Advanced</string>
<string name="prefs_subsection_notifications">Manage notifications</string>
<string name="prefs_show_hidden_files">Show hidden files</string>
<string name="prefs_show_disabled_spaces">Show disabled spaces</string>
<string name="prefs_show_disabled_spaces_summary">Only applying to space managers in Infinite Scale accounts</string>
<string name="prefs_log_open_logs_list_view">Log files</string>
<string name="prefs_log_no_logs_list_view">Empty log folder!</string>
<string name="prefs_log_empty_subtitle">Enable logging and log files will show up here.</string>
Expand Down
6 changes: 6 additions & 0 deletions owncloudApp/src/main/res/xml/settings_advanced.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
app:key="show_hidden_files"
app:title="@string/prefs_show_hidden_files" />

<SwitchPreferenceCompat
app:iconSpaceReserved="false"
app:key="show_disabled_spaces"
app:title="@string/prefs_show_disabled_spaces"
app:summary="@string/prefs_show_disabled_spaces_summary"/>

<ListPreference
app:defaultValue="NEVER"
app:dialogTitle="@string/prefs_delete_local_files"
Expand Down
Loading