diff --git a/changelog.d/3754.feature b/changelog.d/3754.feature new file mode 100644 index 00000000000..e997ac370dc --- /dev/null +++ b/changelog.d/3754.feature @@ -0,0 +1 @@ +M11.12 Spaces | Default to 'Home' in settings \ No newline at end of file diff --git a/vector/src/main/java/im/vector/app/features/home/UnreadMessagesSharedViewModel.kt b/vector/src/main/java/im/vector/app/features/home/UnreadMessagesSharedViewModel.kt index e9e2447b398..f02711690a8 100644 --- a/vector/src/main/java/im/vector/app/features/home/UnreadMessagesSharedViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/UnreadMessagesSharedViewModel.kt @@ -147,7 +147,7 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia roomSummaryQueryParams { this.memberships = listOf(Membership.JOIN) this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null).takeIf { - vectorPreferences.labsSpacesOnlyOrphansInHome() + !vectorPreferences.prefSpacesShowAllRoomInHome() } ?: ActiveSpaceFilter.None } ) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt index 845be0b18b9..11f92284a6c 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt @@ -131,7 +131,7 @@ class RoomListViewModel @Inject constructor( updatableQuery = it }, suggestedRoomJoiningState, - vectorPreferences.labsSpacesOnlyOrphansInHome() + !vectorPreferences.prefSpacesShowAllRoomInHome() ) } else { RoomListSectionBuilderGroup( diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index fbc9f5836e3..bd09709e956 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -153,6 +153,7 @@ class VectorPreferences @Inject constructor(private val context: Context) { const val SETTINGS_LABS_ALLOW_EXTENDED_LOGS = "SETTINGS_LABS_ALLOW_EXTENDED_LOGS" const val SETTINGS_LABS_USE_RESTRICTED_JOIN_RULE = "SETTINGS_LABS_USE_RESTRICTED_JOIN_RULE" const val SETTINGS_LABS_SPACES_HOME_AS_ORPHAN = "SETTINGS_LABS_SPACES_HOME_AS_ORPHAN" + const val SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME = "SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME" const val SETTINGS_LABS_VOICE_MESSAGE = "SETTINGS_LABS_VOICE_MESSAGE" @@ -973,10 +974,16 @@ class VectorPreferences @Inject constructor(private val context: Context) { return defaultPrefs.getBoolean(SETTINGS_LABS_USE_RESTRICTED_JOIN_RULE, false) } - fun labsSpacesOnlyOrphansInHome(): Boolean { + private fun labsSpacesOnlyOrphansInHome(): Boolean { return defaultPrefs.getBoolean(SETTINGS_LABS_SPACES_HOME_AS_ORPHAN, false) } + fun prefSpacesShowAllRoomInHome(): Boolean { + return defaultPrefs.getBoolean(SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME, + // migration of old property + !labsSpacesOnlyOrphansInHome()) + } + /* * Photo / video picker */ diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt index ae6b24e4e49..f4579804035 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsLabsFragment.kt @@ -17,24 +17,12 @@ package im.vector.app.features.settings import im.vector.app.R -import im.vector.app.core.preference.VectorSwitchPreference -import im.vector.app.features.MainActivity -import im.vector.app.features.MainActivityArgs import javax.inject.Inject -class VectorSettingsLabsFragment @Inject constructor( - private val vectorPreferences: VectorPreferences -) : VectorSettingsBaseFragment() { +class VectorSettingsLabsFragment @Inject constructor() : VectorSettingsBaseFragment() { override var titleRes = R.string.room_settings_labs_pref_title override val preferenceXmlRes = R.xml.vector_settings_labs - override fun bindPref() { - findPreference(VectorPreferences.SETTINGS_LABS_SPACES_HOME_AS_ORPHAN)!!.let { pref -> - pref.setOnPreferenceChangeListener { _, _ -> - MainActivity.restartApp(requireActivity(), MainActivityArgs(clearCache = false)) - true - } - } - } + override fun bindPref() {} } diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt index 83780f362cb..212147e628b 100644 --- a/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorSettingsPreferencesFragment.kt @@ -27,7 +27,10 @@ import im.vector.app.core.dialogs.PhotoOrVideoDialog import im.vector.app.core.extensions.restart import im.vector.app.core.preference.VectorListPreference import im.vector.app.core.preference.VectorPreference +import im.vector.app.core.preference.VectorSwitchPreference import im.vector.app.databinding.DialogSelectTextSizeBinding +import im.vector.app.features.MainActivity +import im.vector.app.features.MainActivityArgs import im.vector.app.features.configuration.VectorConfiguration import im.vector.app.features.themes.ThemeUtils import javax.inject.Inject @@ -67,6 +70,14 @@ class VectorSettingsPreferencesFragment @Inject constructor( } } + findPreference(VectorPreferences.SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME)!!.let { pref -> + pref.isChecked = vectorPreferences.prefSpacesShowAllRoomInHome() + pref.setOnPreferenceChangeListener { _, _ -> + MainActivity.restartApp(requireActivity(), MainActivityArgs(clearCache = false)) + true + } + } + // Url preview /* TODO Note: we keep the setting client side for now diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpacesListViewModel.kt b/vector/src/main/java/im/vector/app/features/spaces/SpacesListViewModel.kt index 400a658d1b0..12c4ddbfc47 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpacesListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpacesListViewModel.kt @@ -121,7 +121,7 @@ class SpacesListViewModel @AssistedInject constructor(@Assisted initialState: Sp roomSummaryQueryParams { this.memberships = listOf(Membership.JOIN) this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null).takeIf { - vectorPreferences.labsSpacesOnlyOrphansInHome() + !vectorPreferences.prefSpacesShowAllRoomInHome() } ?: ActiveSpaceFilter.None }, sortOrder = RoomSortOrder.NONE ).asObservable() @@ -139,7 +139,7 @@ class SpacesListViewModel @AssistedInject constructor(@Assisted initialState: Sp roomSummaryQueryParams { this.memberships = listOf(Membership.JOIN) this.activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(null).takeIf { - vectorPreferences.labsSpacesOnlyOrphansInHome() + !vectorPreferences.prefSpacesShowAllRoomInHome() } ?: ActiveSpaceFilter.None } ) diff --git a/vector/src/main/res/values/strings.xml b/vector/src/main/res/values/strings.xml index f421e451a96..c798276e8a2 100644 --- a/vector/src/main/res/values/strings.xml +++ b/vector/src/main/res/values/strings.xml @@ -3417,7 +3417,10 @@ Manage rooms and spaces - Experimental Space - Only show orphans in Home + + Show all rooms in Home + All rooms you’re in will be shown in Home. + Feeling experimental?\nYou can add existing spaces to a space. It looks like your homeserver does not support Spaces yet Please contact your homeserver admin for further information diff --git a/vector/src/main/res/xml/vector_settings_labs.xml b/vector/src/main/res/xml/vector_settings_labs.xml index 50227590be2..a1a1a555bed 100644 --- a/vector/src/main/res/xml/vector_settings_labs.xml +++ b/vector/src/main/res/xml/vector_settings_labs.xml @@ -52,10 +52,6 @@ android:summary="@string/labs_use_restricted_join_rule_desc"/> - + + + + + +