mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Move user status next to the current account header.
Also make the other account section collapsable
This commit is contained in:
+1
@@ -82,6 +82,7 @@ enum class AvatarSize(val dp: Dp) {
|
||||
LeaveSpaceRoom(32.dp),
|
||||
SelectParentSpace(32.dp),
|
||||
AccountItem(32.dp),
|
||||
OtherAccountItem(20.dp),
|
||||
LocationPin(32.dp),
|
||||
ActiveCallItem(20.dp)
|
||||
}
|
||||
|
||||
+8
@@ -44,6 +44,14 @@ interface AppPreferencesStore {
|
||||
/** The name of the chosen theme, or `null` when the user has not picked one and the system setting should be followed. */
|
||||
fun getThemeFlow(): Flow<String?>
|
||||
|
||||
/**
|
||||
* @param expanded true to expand the other accounts section.
|
||||
*/
|
||||
suspend fun setOtherAccountsExpanded(expanded: Boolean)
|
||||
|
||||
/** Whether the other accounts section is expanded; defaults to `true`. */
|
||||
fun isOtherAccountsExpandedFlow(): Flow<Boolean>
|
||||
|
||||
/**
|
||||
* @param value the distance in metres the user must move before a new live location is published.
|
||||
*/
|
||||
|
||||
+13
@@ -33,6 +33,7 @@ private val developerModeKey = booleanPreferencesKey("developerMode")
|
||||
private val customElementCallBaseUrlKey = stringPreferencesKey("elementCallBaseUrl")
|
||||
private val themeKey = stringPreferencesKey("theme")
|
||||
private val hideInviteAvatarsKey = booleanPreferencesKey("hideInviteAvatars")
|
||||
private val otherAccountsExpandedKey = booleanPreferencesKey("otherAccountsExpanded")
|
||||
private val timelineMediaPreviewValueKey = stringPreferencesKey("timelineMediaPreviewValue")
|
||||
private val liveLocationMinimumDistanceUpdateKey = intPreferencesKey("liveLocationMinimumDistanceUpdate")
|
||||
private val logLevelKey = stringPreferencesKey("logLevel")
|
||||
@@ -97,6 +98,18 @@ class DefaultAppPreferencesStore(
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun setOtherAccountsExpanded(expanded: Boolean) {
|
||||
store.edit { prefs ->
|
||||
prefs[otherAccountsExpandedKey] = expanded
|
||||
}
|
||||
}
|
||||
|
||||
override fun isOtherAccountsExpandedFlow(): Flow<Boolean> {
|
||||
return store.data.map { prefs ->
|
||||
prefs[otherAccountsExpandedKey] ?: true
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun setLiveLocationMinimumDistanceInMetersUpdate(value: Int) {
|
||||
store.edit { prefs ->
|
||||
prefs[liveLocationMinimumDistanceUpdateKey] = value
|
||||
|
||||
+18
@@ -120,6 +120,24 @@ class DefaultAppPreferencesStoreTest {
|
||||
assertThat(history.last()).isEqualTo("https://server5.org")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `other accounts section is expanded by default`() = runTest {
|
||||
val store = createStore()
|
||||
|
||||
assertThat(store.isOtherAccountsExpandedFlow().first()).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `other accounts expanded state persists updates`() = runTest {
|
||||
val store = createStore()
|
||||
|
||||
store.setOtherAccountsExpanded(false)
|
||||
assertThat(store.isOtherAccountsExpandedFlow().first()).isFalse()
|
||||
|
||||
store.setOtherAccountsExpanded(true)
|
||||
assertThat(store.isOtherAccountsExpandedFlow().first()).isTrue()
|
||||
}
|
||||
|
||||
private fun createStore() = DefaultAppPreferencesStore(
|
||||
buildMeta = buildMeta,
|
||||
preferenceDataStoreFactory = FakePreferenceDataStoreFactory(),
|
||||
|
||||
+10
@@ -21,6 +21,7 @@ import kotlinx.coroutines.flow.updateAndGet
|
||||
|
||||
class InMemoryAppPreferencesStore(
|
||||
isDeveloperModeEnabled: Boolean = false,
|
||||
isOtherAccountsExpanded: Boolean = true,
|
||||
customElementCallBaseUrl: String? = null,
|
||||
hideInviteAvatars: Boolean? = null,
|
||||
timelineMediaPreviewValue: MediaPreviewValue? = null,
|
||||
@@ -37,6 +38,7 @@ class InMemoryAppPreferencesStore(
|
||||
callRingtoneDisplayName: String? = null,
|
||||
) : AppPreferencesStore {
|
||||
private val isDeveloperModeEnabled = MutableStateFlow(isDeveloperModeEnabled)
|
||||
private val isOtherAccountsExpanded = MutableStateFlow(isOtherAccountsExpanded)
|
||||
private val customElementCallBaseUrl = MutableStateFlow(customElementCallBaseUrl)
|
||||
private val theme = MutableStateFlow(theme)
|
||||
private val liveLocationMinimumDistanceUpdate = MutableStateFlow(liveLocationMinimumDistanceUpdate)
|
||||
@@ -60,6 +62,14 @@ class InMemoryAppPreferencesStore(
|
||||
return isDeveloperModeEnabled
|
||||
}
|
||||
|
||||
override suspend fun setOtherAccountsExpanded(expanded: Boolean) {
|
||||
isOtherAccountsExpanded.value = expanded
|
||||
}
|
||||
|
||||
override fun isOtherAccountsExpandedFlow(): Flow<Boolean> {
|
||||
return isOtherAccountsExpanded
|
||||
}
|
||||
|
||||
override suspend fun setCustomElementCallBaseUrl(string: String?) {
|
||||
customElementCallBaseUrl.tryEmit(string)
|
||||
}
|
||||
|
||||
@@ -10,4 +10,5 @@
|
||||
<string name="a11y_state_collapsed">"Collapsed"</string>
|
||||
<string name="a11y_active">Active</string>
|
||||
<string name="a11y_inactive">Inactive</string>
|
||||
<string name="common_switch_account">Switch accounts</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user