Commit 14144dc9 authored by Valere's avatar Valere
Browse files

Default all in home + lab flag

parent 24a32f2b
...@@ -69,12 +69,12 @@ class RoomListViewModel @Inject constructor( ...@@ -69,12 +69,12 @@ class RoomListViewModel @Inject constructor(
* Filter the rooms if they are part of the current space (children and grand children). * Filter the rooms if they are part of the current space (children and grand children).
* If current space is null, will return orphan rooms only * If current space is null, will return orphan rooms only
*/ */
NORMAL, ORPHANS_IF_SPACE_NULL,
/** /**
* Special case when we don't want to discriminate rooms when current space is null. * Special case when we don't want to discriminate rooms when current space is null.
* In this case return all. * In this case return all.
*/ */
NOT_IF_ALL, ALL_IF_SPACE_NULL,
/** Do not filter based on space*/ /** Do not filter based on space*/
NONE NONE
} }
...@@ -131,7 +131,8 @@ class RoomListViewModel @Inject constructor( ...@@ -131,7 +131,8 @@ class RoomListViewModel @Inject constructor(
}, },
{ {
updatableQuery = it updatableQuery = it
} },
vectorPreferences.labsSpacesOnlyOrphansInHome()
).buildSections(initialState.displayMode) ).buildSections(initialState.displayMode)
} else { } else {
GroupRoomListSectionBuilder( GroupRoomListSectionBuilder(
......
...@@ -50,7 +50,8 @@ class SpaceRoomListSectionBuilder( ...@@ -50,7 +50,8 @@ class SpaceRoomListSectionBuilder(
val viewModelScope: CoroutineScope, val viewModelScope: CoroutineScope,
private val suggestedRoomJoiningState: LiveData<Map<String, Async<Unit>>>, private val suggestedRoomJoiningState: LiveData<Map<String, Async<Unit>>>,
val onDisposable: (Disposable) -> Unit, val onDisposable: (Disposable) -> Unit,
val onUdpatable: (UpdatableLivePageResult) -> Unit val onUdpatable: (UpdatableLivePageResult) -> Unit,
val onlyOrphansInHome: Boolean = false
) : RoomListSectionBuilder { ) : RoomListSectionBuilder {
val pagedListConfig = PagedList.Config.Builder() val pagedListConfig = PagedList.Config.Builder()
...@@ -91,7 +92,8 @@ class SpaceRoomListSectionBuilder( ...@@ -91,7 +92,8 @@ class SpaceRoomListSectionBuilder(
activeSpaceAwareQueries, activeSpaceAwareQueries,
R.string.invitations_header, R.string.invitations_header,
true, true,
RoomListViewModel.SpaceFilterStrategy.NORMAL RoomListViewModel.SpaceFilterStrategy.ORPHANS_IF_SPACE_NULL.takeIf { onlyOrphansInHome }
?: RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL
) { ) {
it.memberships = listOf(Membership.INVITE) it.memberships = listOf(Membership.INVITE)
it.roomCategoryFilter = RoomCategoryFilter.ALL it.roomCategoryFilter = RoomCategoryFilter.ALL
...@@ -102,7 +104,8 @@ class SpaceRoomListSectionBuilder( ...@@ -102,7 +104,8 @@ class SpaceRoomListSectionBuilder(
activeSpaceAwareQueries, activeSpaceAwareQueries,
R.string.bottom_action_rooms, R.string.bottom_action_rooms,
false, false,
RoomListViewModel.SpaceFilterStrategy.NORMAL RoomListViewModel.SpaceFilterStrategy.ORPHANS_IF_SPACE_NULL.takeIf { onlyOrphansInHome }
?: RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL
) { ) {
it.memberships = listOf(Membership.JOIN) it.memberships = listOf(Membership.JOIN)
it.roomCategoryFilter = RoomCategoryFilter.ONLY_WITH_NOTIFICATIONS it.roomCategoryFilter = RoomCategoryFilter.ONLY_WITH_NOTIFICATIONS
...@@ -129,7 +132,7 @@ class SpaceRoomListSectionBuilder( ...@@ -129,7 +132,7 @@ class SpaceRoomListSectionBuilder(
sections, activeSpaceAwareQueries, sections, activeSpaceAwareQueries,
R.string.invitations_header, R.string.invitations_header,
true, true,
RoomListViewModel.SpaceFilterStrategy.NOT_IF_ALL RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL
) { ) {
it.memberships = listOf(Membership.INVITE) it.memberships = listOf(Membership.INVITE)
it.roomCategoryFilter = RoomCategoryFilter.ONLY_ROOMS it.roomCategoryFilter = RoomCategoryFilter.ONLY_ROOMS
...@@ -140,7 +143,7 @@ class SpaceRoomListSectionBuilder( ...@@ -140,7 +143,7 @@ class SpaceRoomListSectionBuilder(
activeSpaceAwareQueries, activeSpaceAwareQueries,
R.string.bottom_action_favourites, R.string.bottom_action_favourites,
false, false,
RoomListViewModel.SpaceFilterStrategy.NOT_IF_ALL RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL
) { ) {
it.memberships = listOf(Membership.JOIN) it.memberships = listOf(Membership.JOIN)
it.roomCategoryFilter = RoomCategoryFilter.ONLY_ROOMS it.roomCategoryFilter = RoomCategoryFilter.ONLY_ROOMS
...@@ -152,7 +155,8 @@ class SpaceRoomListSectionBuilder( ...@@ -152,7 +155,8 @@ class SpaceRoomListSectionBuilder(
activeSpaceAwareQueries, activeSpaceAwareQueries,
R.string.bottom_action_rooms, R.string.bottom_action_rooms,
false, false,
RoomListViewModel.SpaceFilterStrategy.NORMAL RoomListViewModel.SpaceFilterStrategy.ORPHANS_IF_SPACE_NULL.takeIf { onlyOrphansInHome }
?: RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL
) { ) {
it.memberships = listOf(Membership.JOIN) it.memberships = listOf(Membership.JOIN)
it.roomCategoryFilter = RoomCategoryFilter.ONLY_ROOMS it.roomCategoryFilter = RoomCategoryFilter.ONLY_ROOMS
...@@ -164,7 +168,8 @@ class SpaceRoomListSectionBuilder( ...@@ -164,7 +168,8 @@ class SpaceRoomListSectionBuilder(
activeSpaceAwareQueries, activeSpaceAwareQueries,
R.string.low_priority_header, R.string.low_priority_header,
false, false,
RoomListViewModel.SpaceFilterStrategy.NORMAL RoomListViewModel.SpaceFilterStrategy.ORPHANS_IF_SPACE_NULL.takeIf { onlyOrphansInHome }
?: RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL
) { ) {
it.memberships = listOf(Membership.JOIN) it.memberships = listOf(Membership.JOIN)
it.roomCategoryFilter = RoomCategoryFilter.ONLY_ROOMS it.roomCategoryFilter = RoomCategoryFilter.ONLY_ROOMS
...@@ -176,7 +181,8 @@ class SpaceRoomListSectionBuilder( ...@@ -176,7 +181,8 @@ class SpaceRoomListSectionBuilder(
activeSpaceAwareQueries, activeSpaceAwareQueries,
R.string.system_alerts_header, R.string.system_alerts_header,
false, false,
RoomListViewModel.SpaceFilterStrategy.NORMAL RoomListViewModel.SpaceFilterStrategy.ORPHANS_IF_SPACE_NULL.takeIf { onlyOrphansInHome }
?: RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL
) { ) {
it.memberships = listOf(Membership.JOIN) it.memberships = listOf(Membership.JOIN)
it.roomCategoryFilter = RoomCategoryFilter.ONLY_ROOMS it.roomCategoryFilter = RoomCategoryFilter.ONLY_ROOMS
...@@ -232,7 +238,7 @@ class SpaceRoomListSectionBuilder( ...@@ -232,7 +238,7 @@ class SpaceRoomListSectionBuilder(
activeSpaceAwareQueries, activeSpaceAwareQueries,
R.string.invitations_header, R.string.invitations_header,
true, true,
RoomListViewModel.SpaceFilterStrategy.NOT_IF_ALL RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL
) { ) {
it.memberships = listOf(Membership.INVITE) it.memberships = listOf(Membership.INVITE)
it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
...@@ -242,7 +248,7 @@ class SpaceRoomListSectionBuilder( ...@@ -242,7 +248,7 @@ class SpaceRoomListSectionBuilder(
activeSpaceAwareQueries, activeSpaceAwareQueries,
R.string.bottom_action_favourites, R.string.bottom_action_favourites,
false, false,
RoomListViewModel.SpaceFilterStrategy.NOT_IF_ALL RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL
) { ) {
it.memberships = listOf(Membership.JOIN) it.memberships = listOf(Membership.JOIN)
it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
...@@ -253,7 +259,7 @@ class SpaceRoomListSectionBuilder( ...@@ -253,7 +259,7 @@ class SpaceRoomListSectionBuilder(
activeSpaceAwareQueries, activeSpaceAwareQueries,
R.string.bottom_action_people_x, R.string.bottom_action_people_x,
false, false,
RoomListViewModel.SpaceFilterStrategy.NOT_IF_ALL RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL
) { ) {
it.memberships = listOf(Membership.JOIN) it.memberships = listOf(Membership.JOIN)
it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM it.roomCategoryFilter = RoomCategoryFilter.ONLY_DM
...@@ -277,7 +283,7 @@ class SpaceRoomListSectionBuilder( ...@@ -277,7 +283,7 @@ class SpaceRoomListSectionBuilder(
pagedListConfig pagedListConfig
).also { ).also {
when (spaceFilterStrategy) { when (spaceFilterStrategy) {
RoomListViewModel.SpaceFilterStrategy.NORMAL -> { RoomListViewModel.SpaceFilterStrategy.ORPHANS_IF_SPACE_NULL -> {
activeSpaceUpdaters.add(object : RoomListViewModel.ActiveSpaceQueryUpdater { activeSpaceUpdaters.add(object : RoomListViewModel.ActiveSpaceQueryUpdater {
override fun updateForSpaceId(roomId: String?) { override fun updateForSpaceId(roomId: String?) {
it.updateQuery { it.updateQuery {
...@@ -288,7 +294,7 @@ class SpaceRoomListSectionBuilder( ...@@ -288,7 +294,7 @@ class SpaceRoomListSectionBuilder(
} }
}) })
} }
RoomListViewModel.SpaceFilterStrategy.NOT_IF_ALL -> { RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL -> {
activeSpaceUpdaters.add(object : RoomListViewModel.ActiveSpaceQueryUpdater { activeSpaceUpdaters.add(object : RoomListViewModel.ActiveSpaceQueryUpdater {
override fun updateForSpaceId(roomId: String?) { override fun updateForSpaceId(roomId: String?) {
if (roomId != null) { if (roomId != null) {
...@@ -349,21 +355,23 @@ class SpaceRoomListSectionBuilder( ...@@ -349,21 +355,23 @@ class SpaceRoomListSectionBuilder(
internal fun RoomSummaryQueryParams.process(spaceFilter: RoomListViewModel.SpaceFilterStrategy, currentSpace: String?): RoomSummaryQueryParams { internal fun RoomSummaryQueryParams.process(spaceFilter: RoomListViewModel.SpaceFilterStrategy, currentSpace: String?): RoomSummaryQueryParams {
return when (spaceFilter) { return when (spaceFilter) {
RoomListViewModel.SpaceFilterStrategy.NORMAL -> { RoomListViewModel.SpaceFilterStrategy.ORPHANS_IF_SPACE_NULL -> {
copy( copy(
activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(currentSpace) activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(currentSpace)
) )
} }
RoomListViewModel.SpaceFilterStrategy.NOT_IF_ALL -> { RoomListViewModel.SpaceFilterStrategy.ALL_IF_SPACE_NULL -> {
if (currentSpace == null) { if (currentSpace == null) {
this copy(
activeSpaceFilter = ActiveSpaceFilter.None
)
} else { } else {
copy( copy(
activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(currentSpace) activeSpaceFilter = ActiveSpaceFilter.ActiveSpace(currentSpace)
) )
} }
} }
RoomListViewModel.SpaceFilterStrategy.NONE -> this RoomListViewModel.SpaceFilterStrategy.NONE -> this
} }
} }
} }
...@@ -151,6 +151,7 @@ class VectorPreferences @Inject constructor(private val context: Context) { ...@@ -151,6 +151,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_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_USE_RESTRICTED_JOIN_RULE = "SETTINGS_LABS_USE_RESTRICTED_JOIN_RULE"
const val SETTINGS_LABS_SPACES_HOME_AS_ORPHAN = "SETTINGS_LABS_SPACES_HOME_AS_ORPHAN"
private const val SETTINGS_DEVELOPER_MODE_PREFERENCE_KEY = "SETTINGS_DEVELOPER_MODE_PREFERENCE_KEY" private const val SETTINGS_DEVELOPER_MODE_PREFERENCE_KEY = "SETTINGS_DEVELOPER_MODE_PREFERENCE_KEY"
private const val SETTINGS_LABS_SHOW_HIDDEN_EVENTS_PREFERENCE_KEY = "SETTINGS_LABS_SHOW_HIDDEN_EVENTS_PREFERENCE_KEY" private const val SETTINGS_LABS_SHOW_HIDDEN_EVENTS_PREFERENCE_KEY = "SETTINGS_LABS_SHOW_HIDDEN_EVENTS_PREFERENCE_KEY"
...@@ -956,6 +957,10 @@ class VectorPreferences @Inject constructor(private val context: Context) { ...@@ -956,6 +957,10 @@ class VectorPreferences @Inject constructor(private val context: Context) {
return defaultPrefs.getBoolean(SETTINGS_LABS_USE_RESTRICTED_JOIN_RULE, false) return defaultPrefs.getBoolean(SETTINGS_LABS_USE_RESTRICTED_JOIN_RULE, false)
} }
fun labsSpacesOnlyOrphansInHome(): Boolean {
return defaultPrefs.getBoolean(SETTINGS_LABS_SPACES_HOME_AS_ORPHAN, false)
}
/* /*
* Photo / video picker * Photo / video picker
*/ */
......
...@@ -17,6 +17,9 @@ ...@@ -17,6 +17,9 @@
package im.vector.app.features.settings package im.vector.app.features.settings
import im.vector.app.R 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 import javax.inject.Inject
class VectorSettingsLabsFragment @Inject constructor( class VectorSettingsLabsFragment @Inject constructor(
...@@ -27,6 +30,11 @@ class VectorSettingsLabsFragment @Inject constructor( ...@@ -27,6 +30,11 @@ class VectorSettingsLabsFragment @Inject constructor(
override val preferenceXmlRes = R.xml.vector_settings_labs override val preferenceXmlRes = R.xml.vector_settings_labs
override fun bindPref() { override fun bindPref() {
// Nothing to do findPreference<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_SPACES_HOME_AS_ORPHAN)!!.let { pref ->
pref.setOnPreferenceChangeListener { _, _ ->
MainActivity.restartApp(requireActivity(), MainActivityArgs(clearCache = false))
true
}
}
} }
} }
...@@ -3362,4 +3362,7 @@ ...@@ -3362,4 +3362,7 @@
<string name="space_mark_as_suggested">Mark as suggested</string> <string name="space_mark_as_suggested">Mark as suggested</string>
<string name="space_mark_as_not_suggested">Mark as not suggested</string> <string name="space_mark_as_not_suggested">Mark as not suggested</string>
<string name="space_manage_rooms_and_spaces">Manage rooms and spaces</string> <string name="space_manage_rooms_and_spaces">Manage rooms and spaces</string>
<string name="labs_space_show_orphan_in_home">Experimental Space - Only show orphans in Home</string>
</resources> </resources>
...@@ -52,4 +52,9 @@ ...@@ -52,4 +52,9 @@
android:summary="@string/labs_use_restricted_join_rule_desc"/> android:summary="@string/labs_use_restricted_join_rule_desc"/>
<!--</im.vector.app.core.preference.VectorPreferenceCategory>--> <!--</im.vector.app.core.preference.VectorPreferenceCategory>-->
<im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="false"
android:key="SETTINGS_LABS_SPACES_HOME_AS_ORPHAN"
android:title="@string/labs_space_show_orphan_in_home"/>
</androidx.preference.PreferenceScreen> </androidx.preference.PreferenceScreen>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment