Skip to content

Commit

Permalink
Spaces | Default to 'Home' in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
BillCarsonFr committed Jul 30, 2021
1 parent c7c5893 commit edf0f6e
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 24 deletions.
1 change: 1 addition & 0 deletions changelog.d/3754.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
M11.12 Spaces | Default to 'Home' in settings
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class RoomListViewModel @Inject constructor(
updatableQuery = it
},
suggestedRoomJoiningState,
vectorPreferences.labsSpacesOnlyOrphansInHome()
!vectorPreferences.prefSpacesShowAllRoomInHome()
)
} else {
RoomListSectionBuilderGroup(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<VectorSwitchPreference>(VectorPreferences.SETTINGS_LABS_SPACES_HOME_AS_ORPHAN)!!.let { pref ->
pref.setOnPreferenceChangeListener { _, _ ->
MainActivity.restartApp(requireActivity(), MainActivityArgs(clearCache = false))
true
}
}
}
override fun bindPref() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -67,6 +70,14 @@ class VectorSettingsPreferencesFragment @Inject constructor(
}
}

findPreference<VectorSwitchPreference>(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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
}
)
Expand Down
5 changes: 4 additions & 1 deletion vector/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3417,7 +3417,10 @@
<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>

<string name="preference_show_all_rooms_in_home">Show all rooms in Home</string>
<string name="all_rooms_youre_in_will_be_shown_in_home">All rooms you’re in will be shown in Home.</string>

<string name="spaces_feeling_experimental_subspace">Feeling experimental?\nYou can add existing spaces to a space.</string>
<string name="spaces_no_server_support_title">It looks like your homeserver does not support Spaces yet</string>
<string name="spaces_no_server_support_description">Please contact your homeserver admin for further information</string>
Expand Down
4 changes: 0 additions & 4 deletions vector/src/main/res/xml/vector_settings_labs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@
android:summary="@string/labs_use_restricted_join_rule_desc"/>
<!--</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"/>

<im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="false"
Expand Down
10 changes: 10 additions & 0 deletions vector/src/main/res/xml/vector_settings_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@

</im.vector.app.core.preference.VectorPreferenceCategory>

<im.vector.app.core.preference.VectorPreferenceCategory android:title="@string/spaces_header">

<im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="false"
android:key="SETTINGS_PREF_SPACE_SHOW_ALL_ROOM_IN_HOME"
android:title="@string/preference_show_all_rooms_in_home"
android:summary="@string/all_rooms_youre_in_will_be_shown_in_home" />

</im.vector.app.core.preference.VectorPreferenceCategory>

<im.vector.app.core.preference.VectorPreferenceCategory android:title="@string/settings_category_composer">

<im.vector.app.core.preference.VectorSwitchPreference
Expand Down

0 comments on commit edf0f6e

Please sign in to comment.