mirror of
https://github.com/vector-im/riotX-android
synced 2025-10-06 00:02:48 +02:00
Compare commits
20 Commits
v1.5.16
...
community-
Author | SHA1 | Date | |
---|---|---|---|
|
7b6ab601a7 | ||
|
70e2157ed0 | ||
|
6ff80d29dc | ||
|
2249a4debf | ||
|
86382d04c6 | ||
|
46c68fca7a | ||
|
e4a8158a41 | ||
|
fc301c8a2e | ||
|
06baae04ed | ||
|
82d9a4a531 | ||
|
894d4f700e | ||
|
5012f37e6f | ||
|
7ee58ccc88 | ||
|
d8115a79a4 | ||
|
989471a409 | ||
|
7a50e25bea | ||
|
4f4d7f111d | ||
|
527bcf2e6f | ||
|
c0c0f90b04 | ||
|
9505d196e4 |
1
changelog.d/6506.wip
Normal file
1
changelog.d/6506.wip
Normal file
@@ -0,0 +1 @@
|
||||
[App Layout] added dialog to configure app layout
|
1
changelog.d/6795.wip
Normal file
1
changelog.d/6795.wip
Normal file
@@ -0,0 +1 @@
|
||||
Makes toolbar switch title based on space in New App Layout
|
1
changelog.d/6801.wip
Normal file
1
changelog.d/6801.wip
Normal file
@@ -0,0 +1 @@
|
||||
Adds new chat bottom sheet as the click action of the main FAB in the new app layout
|
@@ -51,11 +51,13 @@ interface SpaceStateHandler : DefaultLifecycleObserver {
|
||||
)
|
||||
|
||||
/**
|
||||
* Gets the current backstack of spaces (via their id).
|
||||
* Gets the Space ID of the space on top of the backstack
|
||||
*
|
||||
* null may be an entry in the ArrayDeque to indicate the root space (All Chats)
|
||||
* May return null to indicate the All Chats space
|
||||
*/
|
||||
fun getSpaceBackstack(): ArrayDeque<String?>
|
||||
fun popSpaceBackstack(): String?
|
||||
|
||||
fun getPersistedSpaceBackstack(): List<String?>
|
||||
|
||||
/**
|
||||
* Gets a flow of the selected space for clients to react immediately to space changes.
|
||||
|
@@ -23,6 +23,7 @@ import im.vector.app.core.utils.BehaviorDataSource
|
||||
import im.vector.app.features.analytics.AnalyticsTracker
|
||||
import im.vector.app.features.analytics.plan.UserProperties
|
||||
import im.vector.app.features.session.coroutineScope
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import im.vector.app.features.ui.UiStateRepository
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -52,13 +53,13 @@ class SpaceStateHandlerImpl @Inject constructor(
|
||||
private val sessionDataSource: ActiveSessionDataSource,
|
||||
private val uiStateRepository: UiStateRepository,
|
||||
private val activeSessionHolder: ActiveSessionHolder,
|
||||
private val analyticsTracker: AnalyticsTracker
|
||||
private val analyticsTracker: AnalyticsTracker,
|
||||
private val vectorPreferences: VectorPreferences,
|
||||
) : SpaceStateHandler {
|
||||
|
||||
private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
|
||||
private val selectedSpaceDataSource = BehaviorDataSource<Option<RoomSummary>>(Option.empty())
|
||||
private val selectedSpaceFlow = selectedSpaceDataSource.stream()
|
||||
private val spaceBackstack = ArrayDeque<String?>()
|
||||
|
||||
override fun getCurrentSpace(): RoomSummary? {
|
||||
return selectedSpaceDataSource.currentValue?.orNull()?.let { spaceSummary ->
|
||||
@@ -73,26 +74,26 @@ class SpaceStateHandlerImpl @Inject constructor(
|
||||
isForwardNavigation: Boolean,
|
||||
) {
|
||||
val activeSession = session ?: activeSessionHolder.getSafeActiveSession() ?: return
|
||||
val currentSpace = selectedSpaceDataSource.currentValue?.orNull()
|
||||
val spaceSummary = spaceId?.let { activeSession.getRoomSummary(spaceId) }
|
||||
val sameSpaceSelected = currentSpace != null && spaceId == currentSpace.roomId
|
||||
val spaceToLeave = selectedSpaceDataSource.currentValue?.orNull()
|
||||
val spaceToSet = spaceId?.let { activeSession.getRoomSummary(spaceId) }
|
||||
val sameSpaceSelected = spaceId == spaceToLeave?.roomId
|
||||
|
||||
if (sameSpaceSelected) {
|
||||
return
|
||||
}
|
||||
|
||||
if (isForwardNavigation) {
|
||||
spaceBackstack.addLast(currentSpace?.roomId)
|
||||
addToBackstack(spaceToLeave, spaceToSet)
|
||||
}
|
||||
|
||||
if (persistNow) {
|
||||
uiStateRepository.storeSelectedSpace(spaceSummary?.roomId, activeSession.sessionId)
|
||||
uiStateRepository.storeSelectedSpace(spaceToSet?.roomId, activeSession.sessionId)
|
||||
}
|
||||
|
||||
if (spaceSummary == null) {
|
||||
if (spaceToSet == null) {
|
||||
selectedSpaceDataSource.post(Option.empty())
|
||||
} else {
|
||||
selectedSpaceDataSource.post(Option.just(spaceSummary))
|
||||
selectedSpaceDataSource.post(Option.just(spaceToSet))
|
||||
}
|
||||
|
||||
if (spaceId != null) {
|
||||
@@ -104,6 +105,17 @@ class SpaceStateHandlerImpl @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun addToBackstack(spaceToLeave: RoomSummary?, spaceToSet: RoomSummary?) {
|
||||
// Only add to the persisted backstack if the space to set is not All Chats, else reset the persisted stack
|
||||
if (spaceToSet != null) {
|
||||
val currentPersistedBackstack = vectorPreferences.getPersistedSpaceBackstack().toMutableList()
|
||||
currentPersistedBackstack.add(spaceToLeave?.roomId)
|
||||
vectorPreferences.setPersistedSpaceBackstack(currentPersistedBackstack)
|
||||
} else {
|
||||
vectorPreferences.setPersistedSpaceBackstack(emptyList())
|
||||
}
|
||||
}
|
||||
|
||||
private fun observeActiveSession() {
|
||||
sessionDataSource.stream()
|
||||
.distinctUntilChanged()
|
||||
@@ -127,7 +139,15 @@ class SpaceStateHandlerImpl @Inject constructor(
|
||||
}.launchIn(session.coroutineScope)
|
||||
}
|
||||
|
||||
override fun getSpaceBackstack() = spaceBackstack
|
||||
override fun popSpaceBackstack(): String? {
|
||||
vectorPreferences.getPersistedSpaceBackstack().toMutableList().apply {
|
||||
val poppedSpaceId = removeLast()
|
||||
vectorPreferences.setPersistedSpaceBackstack(this)
|
||||
return poppedSpaceId
|
||||
}
|
||||
}
|
||||
|
||||
override fun getPersistedSpaceBackstack() = vectorPreferences.getPersistedSpaceBackstack()
|
||||
|
||||
override fun getSelectedSpaceFlow() = selectedSpaceFlow
|
||||
|
||||
|
@@ -63,6 +63,7 @@ import im.vector.app.features.home.room.detail.TimelineFragment
|
||||
import im.vector.app.features.home.room.detail.search.SearchFragment
|
||||
import im.vector.app.features.home.room.list.RoomListFragment
|
||||
import im.vector.app.features.home.room.list.home.HomeRoomListFragment
|
||||
import im.vector.app.features.home.room.list.home.NewChatBottomSheet
|
||||
import im.vector.app.features.home.room.threads.list.views.ThreadListFragment
|
||||
import im.vector.app.features.location.LocationSharingFragment
|
||||
import im.vector.app.features.location.preview.LocationPreviewFragment
|
||||
@@ -209,6 +210,11 @@ interface FragmentModule {
|
||||
@FragmentKey(RoomListFragment::class)
|
||||
fun bindRoomListFragment(fragment: RoomListFragment): Fragment
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@FragmentKey(NewChatBottomSheet::class)
|
||||
fun bindNewChatBottomSheetFragment(fragment: NewChatBottomSheet): Fragment
|
||||
|
||||
@Binds
|
||||
@IntoMap
|
||||
@FragmentKey(LocalePickerFragment::class)
|
||||
|
@@ -56,6 +56,7 @@ import im.vector.app.features.analytics.plan.MobileScreen
|
||||
import im.vector.app.features.analytics.plan.ViewRoom
|
||||
import im.vector.app.features.crypto.recover.SetupMode
|
||||
import im.vector.app.features.disclaimer.showDisclaimerDialog
|
||||
import im.vector.app.features.home.room.list.home.layout.HomeLayoutSettingBottomDialogFragment
|
||||
import im.vector.app.features.matrixto.MatrixToBottomSheet
|
||||
import im.vector.app.features.matrixto.OriginOfMatrixTo
|
||||
import im.vector.app.features.navigation.Navigator
|
||||
@@ -283,6 +284,11 @@ class HomeActivity :
|
||||
.show(supportFragmentManager, "SPACE_SETTINGS")
|
||||
}
|
||||
|
||||
private fun showLayoutSettings() {
|
||||
HomeLayoutSettingBottomDialogFragment()
|
||||
.show(supportFragmentManager, "LAYOUT_SETTINGS")
|
||||
}
|
||||
|
||||
private fun openSpaceInvite(spaceId: String) {
|
||||
SpaceInviteBottomSheet.newInstance(spaceId)
|
||||
.show(supportFragmentManager, "SPACE_INVITE")
|
||||
@@ -596,6 +602,10 @@ class HomeActivity :
|
||||
navigator.openSettings(this)
|
||||
true
|
||||
}
|
||||
R.id.menu_home_layout_settings -> {
|
||||
showLayoutSettings()
|
||||
true
|
||||
}
|
||||
R.id.menu_home_invite_friends -> {
|
||||
launchInviteFriends()
|
||||
true
|
||||
|
@@ -183,7 +183,7 @@ class HomeDetailFragment @Inject constructor(
|
||||
}
|
||||
|
||||
private fun navigateBack() {
|
||||
val previousSpaceId = spaceStateHandler.getSpaceBackstack().removeLastOrNull()
|
||||
val previousSpaceId = spaceStateHandler.popSpaceBackstack()
|
||||
val parentSpaceId = spaceStateHandler.getCurrentSpace()?.flattenParentIds?.lastOrNull()
|
||||
setCurrentSpace(previousSpaceId ?: parentSpaceId)
|
||||
}
|
||||
|
@@ -44,16 +44,22 @@ import im.vector.app.features.call.SharedKnownCallsViewModel
|
||||
import im.vector.app.features.call.VectorCallActivity
|
||||
import im.vector.app.features.call.dialpad.DialPadFragment
|
||||
import im.vector.app.features.call.webrtc.WebRtcCallManager
|
||||
import im.vector.app.features.home.room.list.actions.RoomListSharedAction
|
||||
import im.vector.app.features.home.room.list.actions.RoomListSharedActionViewModel
|
||||
import im.vector.app.features.home.room.list.home.HomeRoomListFragment
|
||||
import im.vector.app.features.home.room.list.home.NewChatBottomSheet
|
||||
import im.vector.app.features.popup.PopupAlertManager
|
||||
import im.vector.app.features.popup.VerificationVectorAlert
|
||||
import im.vector.app.features.settings.VectorLocale
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import im.vector.app.features.settings.VectorSettingsActivity.Companion.EXTRA_DIRECT_ACCESS_SECURITY_PRIVACY_MANAGE_SESSIONS
|
||||
import im.vector.app.features.spaces.SpaceListBottomSheet
|
||||
import im.vector.app.features.themes.ThemeUtils
|
||||
import im.vector.app.features.workers.signout.BannerState
|
||||
import im.vector.app.features.workers.signout.ServerBackupStatusViewModel
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo
|
||||
@@ -77,12 +83,15 @@ class NewHomeDetailFragment @Inject constructor(
|
||||
|
||||
private val viewModel: HomeDetailViewModel by fragmentViewModel()
|
||||
private val unknownDeviceDetectorSharedViewModel: UnknownDeviceDetectorSharedViewModel by activityViewModel()
|
||||
private val unreadMessagesSharedViewModel: UnreadMessagesSharedViewModel by activityViewModel()
|
||||
private val serverBackupStatusViewModel: ServerBackupStatusViewModel by activityViewModel()
|
||||
|
||||
private lateinit var sharedActionViewModel: HomeSharedActionViewModel
|
||||
private lateinit var homeSharedActionViewModel: HomeSharedActionViewModel
|
||||
private lateinit var sharedActionViewModel: RoomListSharedActionViewModel
|
||||
private lateinit var sharedCallActionViewModel: SharedKnownCallsViewModel
|
||||
|
||||
private val newChatBottomSheet = NewChatBottomSheet()
|
||||
private val spaceListBottomSheet = SpaceListBottomSheet()
|
||||
|
||||
private var hasUnreadRooms = false
|
||||
set(value) {
|
||||
if (value != field) {
|
||||
@@ -118,17 +127,18 @@ class NewHomeDetailFragment @Inject constructor(
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
sharedActionViewModel = activityViewModelProvider.get(HomeSharedActionViewModel::class.java)
|
||||
homeSharedActionViewModel = activityViewModelProvider.get(HomeSharedActionViewModel::class.java)
|
||||
sharedActionViewModel = activityViewModelProvider[RoomListSharedActionViewModel::class.java]
|
||||
sharedCallActionViewModel = activityViewModelProvider.get(SharedKnownCallsViewModel::class.java)
|
||||
setupBottomNavigationView()
|
||||
setupToolbar()
|
||||
setupKeysBackupBanner()
|
||||
setupActiveCallView()
|
||||
setupFabs()
|
||||
|
||||
withState(viewModel) {
|
||||
// Update the navigation view if needed (for when we restore the tabs)
|
||||
views.bottomNavigationView.selectedItemId = it.currentTab.toMenuId()
|
||||
}
|
||||
sharedActionViewModel
|
||||
.stream()
|
||||
.onEach(::handleSharedAction)
|
||||
.launchIn(viewLifecycleOwner.lifecycleScope)
|
||||
|
||||
viewModel.onEach(HomeDetailViewState::selectedSpace) { selectedSpace ->
|
||||
onSpaceChange(selectedSpace)
|
||||
@@ -138,10 +148,6 @@ class NewHomeDetailFragment @Inject constructor(
|
||||
updateUIForTab(currentTab)
|
||||
}
|
||||
|
||||
viewModel.onEach(HomeDetailViewState::showDialPadTab) { showDialPadTab ->
|
||||
updateTabVisibilitySafely(R.id.bottom_action_dial_pad, showDialPadTab)
|
||||
}
|
||||
|
||||
viewModel.observeViewEvents { viewEvent ->
|
||||
when (viewEvent) {
|
||||
HomeDetailViewEvents.CallStarted -> handleCallStarted()
|
||||
@@ -175,15 +181,26 @@ class NewHomeDetailFragment @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun navigateBack() {
|
||||
val previousSpaceId = spaceStateHandler.getSpaceBackstack().removeLastOrNull()
|
||||
val parentSpaceId = spaceStateHandler.getCurrentSpace()?.flattenParentIds?.lastOrNull()
|
||||
setCurrentSpace(previousSpaceId ?: parentSpaceId)
|
||||
private fun setupFabs() {
|
||||
views.newLayoutCreateChatButton.setOnClickListener {
|
||||
newChatBottomSheet.show(requireActivity().supportFragmentManager, NewChatBottomSheet.TAG)
|
||||
}
|
||||
|
||||
views.newLayoutOpenSpacesButton.setOnClickListener {
|
||||
// Click action for open spaces modal goes here
|
||||
spaceListBottomSheet.show(requireActivity().supportFragmentManager, SpaceListBottomSheet.TAG)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleSharedAction(action: RoomListSharedAction) {
|
||||
when (action) {
|
||||
RoomListSharedAction.CloseBottomSheet -> spaceListBottomSheet.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
private fun setCurrentSpace(spaceId: String?) {
|
||||
spaceStateHandler.setCurrentSpace(spaceId, isForwardNavigation = false)
|
||||
sharedActionViewModel.post(HomeActivitySharedAction.OnCloseSpace)
|
||||
homeSharedActionViewModel.post(HomeActivitySharedAction.OnCloseSpace)
|
||||
}
|
||||
|
||||
private fun handleCallStarted() {
|
||||
@@ -199,7 +216,6 @@ class NewHomeDetailFragment @Inject constructor(
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
updateTabVisibilitySafely(R.id.bottom_action_notification, vectorPreferences.labAddNotificationTab())
|
||||
callManager.checkForProtocolsSupportIfNeeded()
|
||||
refreshSpaceState()
|
||||
}
|
||||
@@ -268,8 +284,7 @@ class NewHomeDetailFragment @Inject constructor(
|
||||
}
|
||||
|
||||
private fun onSpaceChange(spaceSummary: RoomSummary?) {
|
||||
// Reimplement in next PR
|
||||
println(spaceSummary)
|
||||
views.collapsingToolbar.title = (spaceSummary?.displayName ?: getString(R.string.all_chats))
|
||||
}
|
||||
|
||||
private fun setupKeysBackupBanner() {
|
||||
@@ -303,22 +318,7 @@ class NewHomeDetailFragment @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupBottomNavigationView() {
|
||||
views.bottomNavigationView.menu.findItem(R.id.bottom_action_notification).isVisible = vectorPreferences.labAddNotificationTab()
|
||||
views.bottomNavigationView.setOnItemSelectedListener {
|
||||
val tab = when (it.itemId) {
|
||||
R.id.bottom_action_people -> HomeTab.RoomList(RoomListDisplayMode.PEOPLE)
|
||||
R.id.bottom_action_rooms -> HomeTab.RoomList(RoomListDisplayMode.ROOMS)
|
||||
R.id.bottom_action_notification -> HomeTab.RoomList(RoomListDisplayMode.NOTIFICATIONS)
|
||||
else -> HomeTab.DialPad
|
||||
}
|
||||
viewModel.handle(HomeDetailAction.SwitchTab(tab))
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateUIForTab(tab: HomeTab) {
|
||||
views.bottomNavigationView.menu.findItem(tab.toMenuId()).isChecked = true
|
||||
updateSelectedFragment(tab)
|
||||
invalidateOptionsMenu()
|
||||
}
|
||||
@@ -364,19 +364,6 @@ class NewHomeDetailFragment @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateTabVisibilitySafely(tabId: Int, isVisible: Boolean) {
|
||||
val wasVisible = views.bottomNavigationView.menu.findItem(tabId).isVisible
|
||||
views.bottomNavigationView.menu.findItem(tabId).isVisible = isVisible
|
||||
if (wasVisible && !isVisible) {
|
||||
// As we hide it check if it's not the current item!
|
||||
withState(viewModel) {
|
||||
if (it.currentTab.toMenuId() == tabId) {
|
||||
viewModel.handle(HomeDetailAction.SwitchTab(HomeTab.RoomList(RoomListDisplayMode.PEOPLE)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ==========================================================================================
|
||||
* KeysBackupBanner Listener
|
||||
* ========================================================================================== */
|
||||
@@ -390,9 +377,6 @@ class NewHomeDetailFragment @Inject constructor(
|
||||
}
|
||||
|
||||
override fun invalidate() = withState(viewModel) {
|
||||
views.bottomNavigationView.getOrCreateBadge(R.id.bottom_action_people).render(it.notificationCountPeople, it.notificationHighlightPeople)
|
||||
views.bottomNavigationView.getOrCreateBadge(R.id.bottom_action_rooms).render(it.notificationCountRooms, it.notificationHighlightRooms)
|
||||
views.bottomNavigationView.getOrCreateBadge(R.id.bottom_action_notification).render(it.notificationCountCatchup, it.notificationHighlightCatchup)
|
||||
views.syncStateView.render(
|
||||
it.syncState,
|
||||
it.incrementalSyncRequestState,
|
||||
@@ -450,10 +434,11 @@ class NewHomeDetailFragment @Inject constructor(
|
||||
return this
|
||||
}
|
||||
|
||||
override fun onBackPressed(toolbarButton: Boolean) = if (spaceStateHandler.getCurrentSpace() != null) {
|
||||
navigateBack()
|
||||
override fun onBackPressed(toolbarButton: Boolean) = try {
|
||||
val lastSpace = spaceStateHandler.popSpaceBackstack()
|
||||
spaceStateHandler.setCurrentSpace(lastSpace, isForwardNavigation = false)
|
||||
true
|
||||
} else {
|
||||
} catch (e: NoSuchElementException) {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2022 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.features.home.room.list.home
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import androidx.core.content.edit
|
||||
import im.vector.app.core.di.DefaultPreferences
|
||||
import javax.inject.Inject
|
||||
|
||||
class HomeLayoutPreferences @Inject constructor(
|
||||
@DefaultPreferences private val preferences: SharedPreferences
|
||||
) {
|
||||
|
||||
// We need to keep references, because it's kept as a Weak reference and so will be gathered by GC
|
||||
private var filtersListener: SharedPreferences.OnSharedPreferenceChangeListener? = null
|
||||
private var recentsListener: SharedPreferences.OnSharedPreferenceChangeListener? = null
|
||||
private var orderListener: SharedPreferences.OnSharedPreferenceChangeListener? = null
|
||||
|
||||
fun areRecentsEnabled() = preferences.getBoolean(SETTINGS_PREFERENCES_HOME_RECENTS, false)
|
||||
fun areFiltersEnabled() = preferences.getBoolean(SETTINGS_PREFERENCES_HOME_FILTERS, false)
|
||||
fun isAZOrderingEnabled() = preferences.getBoolean(SETTINGS_PREFERENCES_USE_AZ_ORDER, false)
|
||||
|
||||
fun setRecentsEnabled(isEnabled: Boolean) {
|
||||
preferences.edit { putBoolean(SETTINGS_PREFERENCES_HOME_RECENTS, isEnabled) }
|
||||
}
|
||||
|
||||
fun setFiltersEnabled(isEnabled: Boolean) {
|
||||
preferences.edit {
|
||||
putBoolean(SETTINGS_PREFERENCES_HOME_FILTERS, isEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
fun setAZOrderingEnabled(isEnabled: Boolean) {
|
||||
preferences.edit {
|
||||
putBoolean(SETTINGS_PREFERENCES_USE_AZ_ORDER, isEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
fun registerFiltersListener(callBack: (Boolean) -> Unit) {
|
||||
filtersListener = SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
|
||||
when (key) {
|
||||
SETTINGS_PREFERENCES_HOME_FILTERS -> {
|
||||
callBack.invoke(areFiltersEnabled())
|
||||
}
|
||||
}
|
||||
}
|
||||
preferences.registerOnSharedPreferenceChangeListener(filtersListener)
|
||||
}
|
||||
|
||||
fun registerRecentsListener(callBack: (Boolean) -> Unit) {
|
||||
recentsListener = SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
|
||||
when (key) {
|
||||
SETTINGS_PREFERENCES_HOME_RECENTS -> {
|
||||
callBack.invoke(areRecentsEnabled())
|
||||
}
|
||||
}
|
||||
}
|
||||
preferences.registerOnSharedPreferenceChangeListener(recentsListener)
|
||||
}
|
||||
|
||||
fun registerOrderingListener(callBack: (Boolean) -> Unit) {
|
||||
orderListener = SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
|
||||
when (key) {
|
||||
SETTINGS_PREFERENCES_USE_AZ_ORDER -> {
|
||||
callBack.invoke(isAZOrderingEnabled())
|
||||
}
|
||||
}
|
||||
}
|
||||
preferences.registerOnSharedPreferenceChangeListener(orderListener)
|
||||
}
|
||||
|
||||
fun unregisterListeners() {
|
||||
preferences.unregisterOnSharedPreferenceChangeListener(filtersListener)
|
||||
preferences.unregisterOnSharedPreferenceChangeListener(recentsListener)
|
||||
preferences.unregisterOnSharedPreferenceChangeListener(orderListener)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val SETTINGS_PREFERENCES_HOME_RECENTS = "SETTINGS_PREFERENCES_HOME_RECENTS"
|
||||
const val SETTINGS_PREFERENCES_HOME_FILTERS = "SETTINGS_PREFERENCES_HOME_FILTERS"
|
||||
const val SETTINGS_PREFERENCES_USE_AZ_ORDER = "SETTINGS_PREFERENCES_USE_AZ_ORDER"
|
||||
}
|
||||
}
|
@@ -66,12 +66,9 @@ class HomeRoomListFragment @Inject constructor(
|
||||
|
||||
private val roomListViewModel: HomeRoomListViewModel by fragmentViewModel()
|
||||
private lateinit var sharedQuickActionsViewModel: RoomListQuickActionsSharedActionViewModel
|
||||
private lateinit var sharedActionViewModel: RoomListSharedActionViewModel
|
||||
private var concatAdapter = ConcatAdapter()
|
||||
private var modelBuildListener: OnModelBuildFinishedListener? = null
|
||||
|
||||
private val spaceListBottomSheet = SpaceListBottomSheet()
|
||||
|
||||
private lateinit var stateRestorer: LayoutManagerStateRestorer
|
||||
|
||||
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): FragmentRoomListBinding {
|
||||
@@ -84,17 +81,11 @@ class HomeRoomListFragment @Inject constructor(
|
||||
views.stateView.state = StateView.State.Loading
|
||||
setupObservers()
|
||||
setupRecyclerView()
|
||||
setupFabs()
|
||||
}
|
||||
|
||||
private fun setupObservers() {
|
||||
sharedQuickActionsViewModel = activityViewModelProvider[RoomListQuickActionsSharedActionViewModel::class.java]
|
||||
sharedActionViewModel = activityViewModelProvider[RoomListSharedActionViewModel::class.java]
|
||||
|
||||
sharedActionViewModel
|
||||
.stream()
|
||||
.onEach(::handleSharedAction)
|
||||
.launchIn(viewLifecycleOwner.lifecycleScope)
|
||||
sharedQuickActionsViewModel
|
||||
.stream()
|
||||
.onEach(::handleQuickActions)
|
||||
@@ -110,12 +101,6 @@ class HomeRoomListFragment @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleSharedAction(action: RoomListSharedAction) {
|
||||
when (action) {
|
||||
RoomListSharedAction.CloseBottomSheet -> spaceListBottomSheet.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleQuickActions(quickAction: RoomListQuickActionsSharedAction) {
|
||||
when (quickAction) {
|
||||
is RoomListQuickActionsSharedAction.NotificationsAllNoisy -> {
|
||||
@@ -160,49 +145,25 @@ class HomeRoomListFragment @Inject constructor(
|
||||
}.launchIn(lifecycleScope)
|
||||
|
||||
views.roomListView.adapter = concatAdapter
|
||||
}
|
||||
|
||||
private fun setupFabs() {
|
||||
showFABs()
|
||||
|
||||
views.newLayoutCreateChatButton.setOnClickListener {
|
||||
// Click action for create chat modal goes here (Issue #6717)
|
||||
}
|
||||
|
||||
views.newLayoutOpenSpacesButton.setOnClickListener {
|
||||
// Click action for open spaces modal goes here
|
||||
spaceListBottomSheet.show(requireActivity().supportFragmentManager, SpaceListBottomSheet.TAG)
|
||||
}
|
||||
|
||||
// Hide FABs when list is scrolling
|
||||
views.roomListView.addOnScrollListener(object : RecyclerView.OnScrollListener() {
|
||||
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
||||
views.createChatFabMenu.handler.removeCallbacksAndMessages(null)
|
||||
|
||||
when (newState) {
|
||||
RecyclerView.SCROLL_STATE_IDLE -> views.createChatFabMenu.postDelayed(::showFABs, 250)
|
||||
RecyclerView.SCROLL_STATE_DRAGGING,
|
||||
RecyclerView.SCROLL_STATE_SETTLING -> hideFABs()
|
||||
// we need to force scroll when recents/filter tabs are added to make them visible
|
||||
concatAdapter.registerAdapterDataObserver(object : RecyclerView.AdapterDataObserver() {
|
||||
override fun onItemRangeInserted(positionStart: Int, itemCount: Int) {
|
||||
if (positionStart == 0) {
|
||||
layoutManager.scrollToPosition(0)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun showFABs() {
|
||||
views.newLayoutCreateChatButton.show()
|
||||
views.newLayoutOpenSpacesButton.show()
|
||||
}
|
||||
|
||||
private fun hideFABs() {
|
||||
views.newLayoutCreateChatButton.hide()
|
||||
views.newLayoutOpenSpacesButton.hide()
|
||||
}
|
||||
|
||||
override fun invalidate() = withState(roomListViewModel) { state ->
|
||||
views.stateView.state = state.state
|
||||
}
|
||||
|
||||
private fun setUpAdapters(sections: Set<HomeRoomSection>) {
|
||||
concatAdapter.adapters.forEach {
|
||||
concatAdapter.removeAdapter(it)
|
||||
}
|
||||
sections.forEach {
|
||||
concatAdapter.addAdapter(getAdapterForData(it))
|
||||
}
|
||||
@@ -232,12 +193,11 @@ class HomeRoomListFragment @Inject constructor(
|
||||
is HomeRoomSection.RoomSummaryData -> {
|
||||
HomeFilteredRoomsController(
|
||||
roomSummaryItemFactory,
|
||||
showFilters = section.showFilters,
|
||||
).also { controller ->
|
||||
controller.listener = this
|
||||
controller.onFilterChanged = ::onRoomFilterChanged
|
||||
section.filtersData.onEach {
|
||||
controller.submitFiltersData(it)
|
||||
controller.submitFiltersData(it.getOrNull())
|
||||
}.launchIn(lifecycleScope)
|
||||
section.list.observe(viewLifecycleOwner) { list ->
|
||||
controller.submitList(list)
|
||||
|
@@ -53,12 +53,14 @@ import org.matrix.android.sdk.api.session.room.model.Membership
|
||||
import org.matrix.android.sdk.api.session.room.model.tag.RoomTag
|
||||
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
|
||||
import org.matrix.android.sdk.api.session.room.state.isPublic
|
||||
import org.matrix.android.sdk.api.util.Optional
|
||||
import org.matrix.android.sdk.flow.flow
|
||||
|
||||
class HomeRoomListViewModel @AssistedInject constructor(
|
||||
@Assisted initialState: HomeRoomListViewState,
|
||||
private val session: Session,
|
||||
private val spaceStateHandler: SpaceStateHandler,
|
||||
private val preferences: HomeLayoutPreferences,
|
||||
) : VectorViewModel<HomeRoomListViewState, HomeRoomListAction, HomeRoomListViewEvents>(initialState) {
|
||||
|
||||
@AssistedFactory
|
||||
@@ -78,16 +80,45 @@ class HomeRoomListViewModel @AssistedInject constructor(
|
||||
private val _sections = MutableSharedFlow<Set<HomeRoomSection>>(replay = 1)
|
||||
val sections = _sections.asSharedFlow()
|
||||
|
||||
private val filtersPreferencesFlow = MutableSharedFlow<Boolean>(replay = 1)
|
||||
|
||||
private var filteredPagedRoomSummariesLive: UpdatableLivePageResult? = null
|
||||
|
||||
init {
|
||||
configureSections()
|
||||
observePreferences()
|
||||
}
|
||||
|
||||
private fun observePreferences() {
|
||||
preferences.registerFiltersListener { areFiltersEnabled ->
|
||||
viewModelScope.launch {
|
||||
filtersPreferencesFlow.emit(areFiltersEnabled)
|
||||
}
|
||||
}
|
||||
viewModelScope.launch {
|
||||
filtersPreferencesFlow.emit(preferences.areFiltersEnabled())
|
||||
}
|
||||
|
||||
preferences.registerRecentsListener { _ ->
|
||||
configureSections()
|
||||
}
|
||||
|
||||
preferences.registerOrderingListener { _ ->
|
||||
configureSections()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
preferences.unregisterListeners()
|
||||
super.onCleared()
|
||||
}
|
||||
|
||||
private fun configureSections() {
|
||||
val newSections = mutableSetOf<HomeRoomSection>()
|
||||
|
||||
newSections.add(getRecentRoomsSection())
|
||||
if (preferences.areRecentsEnabled()) {
|
||||
newSections.add(getRecentRoomsSection())
|
||||
}
|
||||
newSections.add(getFilteredRoomsSection())
|
||||
|
||||
viewModelScope.launch {
|
||||
@@ -117,7 +148,11 @@ class HomeRoomListViewModel @AssistedInject constructor(
|
||||
}
|
||||
|
||||
val params = getFilteredQueryParams(HomeRoomFilter.ALL, builder.build())
|
||||
val sortOrder = RoomSortOrder.ACTIVITY // #6506
|
||||
val sortOrder = if (preferences.isAZOrderingEnabled()) {
|
||||
RoomSortOrder.NAME
|
||||
} else {
|
||||
RoomSortOrder.ACTIVITY
|
||||
}
|
||||
|
||||
val liveResults = session.roomService().getFilteredPagedRoomSummariesLive(
|
||||
params,
|
||||
@@ -135,19 +170,18 @@ class HomeRoomListViewModel @AssistedInject constructor(
|
||||
.onEach { selectedSpaceOption ->
|
||||
val selectedSpace = selectedSpaceOption.orNull()
|
||||
liveResults.queryParams = liveResults.queryParams.copy(
|
||||
spaceFilter = selectedSpace?.roomId.toActiveSpaceOrNoFilter()
|
||||
spaceFilter = selectedSpace?.roomId.toActiveSpaceOrNoFilter()
|
||||
)
|
||||
}.launchIn(viewModelScope)
|
||||
|
||||
return HomeRoomSection.RoomSummaryData(
|
||||
list = liveResults.livePagedList,
|
||||
showFilters = true, // #6506
|
||||
filtersData = getFiltersDataFlow()
|
||||
)
|
||||
}
|
||||
|
||||
private fun getFiltersDataFlow(): SharedFlow<List<HomeRoomFilter>> {
|
||||
val flow = MutableSharedFlow<List<HomeRoomFilter>>(replay = 1)
|
||||
private fun getFiltersDataFlow(): SharedFlow<Optional<List<HomeRoomFilter>>> {
|
||||
val flow = MutableSharedFlow<Optional<List<HomeRoomFilter>>>(replay = 1)
|
||||
|
||||
val favouritesFlow = session.flow()
|
||||
.liveRoomSummaries(
|
||||
@@ -168,25 +202,28 @@ class HomeRoomListViewModel @AssistedInject constructor(
|
||||
.map { it.isNotEmpty() }
|
||||
.distinctUntilChanged()
|
||||
|
||||
favouritesFlow.combine(dmsFLow) { hasFavourite, hasDm ->
|
||||
hasFavourite to hasDm
|
||||
}.onEach { (hasFavourite, hasDm) ->
|
||||
val filtersData = mutableListOf(
|
||||
HomeRoomFilter.ALL,
|
||||
HomeRoomFilter.UNREADS
|
||||
)
|
||||
if (hasFavourite) {
|
||||
filtersData.add(
|
||||
HomeRoomFilter.FAVOURITES
|
||||
combine(favouritesFlow, dmsFLow, filtersPreferencesFlow) { hasFavourite, hasDm, areFiltersEnabled ->
|
||||
Triple(hasFavourite, hasDm, areFiltersEnabled)
|
||||
}.onEach { (hasFavourite, hasDm, areFiltersEnabled) ->
|
||||
if (areFiltersEnabled) {
|
||||
val filtersData = mutableListOf(
|
||||
HomeRoomFilter.ALL,
|
||||
HomeRoomFilter.UNREADS
|
||||
)
|
||||
if (hasFavourite) {
|
||||
filtersData.add(
|
||||
HomeRoomFilter.FAVOURITES
|
||||
)
|
||||
}
|
||||
if (hasDm) {
|
||||
filtersData.add(
|
||||
HomeRoomFilter.PEOPlE
|
||||
)
|
||||
}
|
||||
flow.emit(Optional.from(filtersData))
|
||||
} else {
|
||||
flow.emit(Optional.empty())
|
||||
}
|
||||
if (hasDm) {
|
||||
filtersData.add(
|
||||
HomeRoomFilter.PEOPlE
|
||||
)
|
||||
}
|
||||
|
||||
flow.emit(filtersData)
|
||||
}.launchIn(viewModelScope)
|
||||
|
||||
return flow
|
||||
|
@@ -21,12 +21,12 @@ import androidx.paging.PagedList
|
||||
import im.vector.app.features.home.room.list.home.filter.HomeRoomFilter
|
||||
import kotlinx.coroutines.flow.SharedFlow
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||
import org.matrix.android.sdk.api.util.Optional
|
||||
|
||||
sealed class HomeRoomSection {
|
||||
data class RoomSummaryData(
|
||||
val list: LiveData<PagedList<RoomSummary>>,
|
||||
val showFilters: Boolean,
|
||||
val filtersData: SharedFlow<List<HomeRoomFilter>>
|
||||
val filtersData: SharedFlow<Optional<List<HomeRoomFilter>>>,
|
||||
) : HomeRoomSection()
|
||||
|
||||
data class RecentRoomsData(
|
||||
|
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2022 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.features.home.room.list.home
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.databinding.FragmentNewChatBottomSheetBinding
|
||||
import im.vector.app.features.navigation.Navigator
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class NewChatBottomSheet @Inject constructor() : BottomSheetDialogFragment() {
|
||||
|
||||
@Inject lateinit var navigator: Navigator
|
||||
|
||||
private lateinit var binding: FragmentNewChatBottomSheetBinding
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
binding = FragmentNewChatBottomSheetBinding.inflate(inflater, container, false)
|
||||
initFABs()
|
||||
return binding.root
|
||||
}
|
||||
|
||||
private fun initFABs() {
|
||||
binding.startChat.setOnClickListener {
|
||||
navigator.openCreateDirectRoom(requireActivity())
|
||||
}
|
||||
|
||||
binding.createRoom.setOnClickListener {
|
||||
navigator.openCreateRoom(requireActivity(), "")
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TAG = "NewChatBottomSheet"
|
||||
}
|
||||
}
|
@@ -28,7 +28,6 @@ import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||
|
||||
class HomeFilteredRoomsController(
|
||||
private val roomSummaryItemFactory: RoomSummaryItemFactory,
|
||||
private val showFilters: Boolean,
|
||||
) : PagedListEpoxyController<RoomSummary>(
|
||||
// Important it must match the PageList builder notify Looper
|
||||
modelBuildingHandler = createUIHandler()
|
||||
@@ -48,7 +47,7 @@ class HomeFilteredRoomsController(
|
||||
|
||||
override fun addModels(models: List<EpoxyModel<*>>) {
|
||||
val host = this
|
||||
if (showFilters) {
|
||||
if (host.filtersData != null) {
|
||||
roomFilterHeaderItem {
|
||||
id("filter_header")
|
||||
filtersData(host.filtersData)
|
||||
@@ -58,7 +57,7 @@ class HomeFilteredRoomsController(
|
||||
super.addModels(models)
|
||||
}
|
||||
|
||||
fun submitFiltersData(data: List<HomeRoomFilter>) {
|
||||
fun submitFiltersData(data: List<HomeRoomFilter>?) {
|
||||
this.filtersData = data
|
||||
requestForcedModelBuild()
|
||||
}
|
||||
|
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2022 New Vector Ltd
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.features.home.room.list.home.layout
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment
|
||||
import im.vector.app.databinding.BottomSheetHomeLayoutSettingsBinding
|
||||
import im.vector.app.features.home.room.list.home.HomeLayoutPreferences
|
||||
import javax.inject.Inject
|
||||
|
||||
@AndroidEntryPoint
|
||||
class HomeLayoutSettingBottomDialogFragment : VectorBaseBottomSheetDialogFragment<BottomSheetHomeLayoutSettingsBinding>() {
|
||||
|
||||
@Inject lateinit var preferences: HomeLayoutPreferences
|
||||
|
||||
override fun getBinding(inflater: LayoutInflater, container: ViewGroup?): BottomSheetHomeLayoutSettingsBinding {
|
||||
return BottomSheetHomeLayoutSettingsBinding.inflate(inflater, container, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
views.homeLayoutSettingsRecents.isChecked = preferences.areRecentsEnabled()
|
||||
views.homeLayoutSettingsFilters.isChecked = preferences.areFiltersEnabled()
|
||||
|
||||
if (preferences.isAZOrderingEnabled()) {
|
||||
views.homeLayoutSettingsSortName.isChecked = true
|
||||
} else {
|
||||
views.homeLayoutSettingsSortActivity.isChecked = true
|
||||
}
|
||||
|
||||
views.homeLayoutSettingsDone.setOnClickListener {
|
||||
preferences.setRecentsEnabled(views.homeLayoutSettingsRecents.isChecked)
|
||||
preferences.setFiltersEnabled(views.homeLayoutSettingsFilters.isChecked)
|
||||
preferences.setAZOrderingEnabled(views.homeLayoutSettingsSortGroup.checkedRadioButtonId == R.id.home_layout_settings_sort_name)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
@@ -59,7 +59,13 @@ class RecentRoomCarouselController @Inject constructor(
|
||||
data?.let { data ->
|
||||
carousel {
|
||||
id("recents_carousel")
|
||||
padding(Carousel.Padding(host.hPadding, host.itemSpacing))
|
||||
padding(Carousel.Padding(
|
||||
host.hPadding,
|
||||
0,
|
||||
host.hPadding,
|
||||
0,
|
||||
host.itemSpacing)
|
||||
)
|
||||
withModelsFrom(data) { roomSummary ->
|
||||
val onClick = host.listener?.let { it::onRoomClicked }
|
||||
val onLongClick = host.listener?.let { it::onRoomLongClicked }
|
||||
|
@@ -78,6 +78,7 @@ class VectorPreferences @Inject constructor(
|
||||
const val SETTINGS_ALLOW_INTEGRATIONS_KEY = "SETTINGS_ALLOW_INTEGRATIONS_KEY"
|
||||
const val SETTINGS_INTEGRATION_MANAGER_UI_URL_KEY = "SETTINGS_INTEGRATION_MANAGER_UI_URL_KEY"
|
||||
const val SETTINGS_SECURE_MESSAGE_RECOVERY_PREFERENCE_KEY = "SETTINGS_SECURE_MESSAGE_RECOVERY_PREFERENCE_KEY"
|
||||
const val SETTINGS_PERSISTED_SPACE_BACKSTACK = "SETTINGS_PERSISTED_SPACE_BACKSTACK"
|
||||
|
||||
const val SETTINGS_CRYPTOGRAPHY_HS_ADMIN_DISABLED_E2E_DEFAULT = "SETTINGS_CRYPTOGRAPHY_HS_ADMIN_DISABLED_E2E_DEFAULT"
|
||||
// const val SETTINGS_SECURE_BACKUP_RESET_PREFERENCE_KEY = "SETTINGS_SECURE_BACKUP_RESET_PREFERENCE_KEY"
|
||||
@@ -1126,6 +1127,25 @@ class VectorPreferences @Inject constructor(
|
||||
.apply()
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the space backstack that is used for up navigation
|
||||
* This needs to be persisted because navigating up through spaces should work across sessions
|
||||
*
|
||||
* Only the IDs of the spaces are stored
|
||||
*/
|
||||
fun setPersistedSpaceBackstack(spaceBackstack: List<String?>) {
|
||||
val spaceIdsJoined = spaceBackstack.takeIf { it.isNotEmpty() }?.joinToString(",")
|
||||
defaultPrefs.edit().putString(SETTINGS_PERSISTED_SPACE_BACKSTACK, spaceIdsJoined).apply()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the space backstack used for up navigation
|
||||
*/
|
||||
fun getPersistedSpaceBackstack(): List<String?> {
|
||||
val spaceIdsJoined = defaultPrefs.getString(SETTINGS_PERSISTED_SPACE_BACKSTACK, null)
|
||||
return spaceIdsJoined?.takeIf { it.isNotEmpty() }?.split(",").orEmpty()
|
||||
}
|
||||
|
||||
fun showLiveSenderInfo(): Boolean {
|
||||
return defaultPrefs.getBoolean(SETTINGS_TIMELINE_SHOW_LIVE_SENDER_INFO, getDefault(R.bool.settings_timeline_show_live_sender_info_default))
|
||||
}
|
||||
|
@@ -16,6 +16,9 @@
|
||||
|
||||
package im.vector.app.features.spaces
|
||||
|
||||
import android.content.Context
|
||||
import android.widget.TextView
|
||||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.epoxy.VectorEpoxyHolder
|
||||
@@ -23,5 +26,31 @@ import im.vector.app.core.epoxy.VectorEpoxyModel
|
||||
|
||||
@EpoxyModelClass
|
||||
abstract class NewSpaceListHeaderItem : VectorEpoxyModel<NewSpaceListHeaderItem.Holder>(R.layout.item_new_space_list_header) {
|
||||
class Holder : VectorEpoxyHolder()
|
||||
|
||||
@EpoxyAttribute var currentSpace: String? = null
|
||||
@EpoxyAttribute var spaceHistory: List<Pair<String?, String>> = emptyList()
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
holder.spaceHeader.text = buildSpaceHeaderText(holder.spaceHeader.context)
|
||||
}
|
||||
|
||||
private fun buildSpaceHeaderText(context: Context): String {
|
||||
val allChats = context.getString(R.string.all_chats)
|
||||
var spaceHeaderText = allChats
|
||||
|
||||
val nonRootSpaceHistory = spaceHistory.filter { it.second.isNotEmpty() }
|
||||
|
||||
if (nonRootSpaceHistory.isNotEmpty()) {
|
||||
spaceHeaderText += " > ${nonRootSpaceHistory.joinToString(" > ") { it.second }}"
|
||||
}
|
||||
if (currentSpace != null) {
|
||||
spaceHeaderText += " > $currentSpace"
|
||||
}
|
||||
return spaceHeaderText
|
||||
}
|
||||
|
||||
class Holder : VectorEpoxyHolder() {
|
||||
val spaceHeader by bind<TextView>(R.id.space_header)
|
||||
}
|
||||
}
|
||||
|
@@ -50,7 +50,8 @@ class NewSpaceSummaryController @Inject constructor(
|
||||
nonNullViewState.spaces,
|
||||
nonNullViewState.selectedSpace,
|
||||
nonNullViewState.rootSpacesOrdered,
|
||||
nonNullViewState.homeAggregateCount
|
||||
nonNullViewState.homeAggregateCount,
|
||||
nonNullViewState.spaceHistory,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -58,11 +59,15 @@ class NewSpaceSummaryController @Inject constructor(
|
||||
spaceSummaries: List<RoomSummary>?,
|
||||
selectedSpace: RoomSummary?,
|
||||
rootSpaces: List<RoomSummary>?,
|
||||
homeCount: RoomAggregateNotificationCount
|
||||
homeCount: RoomAggregateNotificationCount,
|
||||
spaceHistory: List<Pair<String?, String>>,
|
||||
) {
|
||||
val host = this
|
||||
|
||||
newSpaceListHeaderItem {
|
||||
id("space_list_header")
|
||||
currentSpace(selectedSpace?.displayName)
|
||||
spaceHistory(spaceHistory)
|
||||
}
|
||||
|
||||
if (selectedSpace != null) {
|
||||
|
@@ -65,7 +65,7 @@ class SpaceListViewModel @AssistedInject constructor(
|
||||
private val session: Session,
|
||||
private val vectorPreferences: VectorPreferences,
|
||||
private val autoAcceptInvites: AutoAcceptInvites,
|
||||
private val analyticsTracker: AnalyticsTracker
|
||||
private val analyticsTracker: AnalyticsTracker,
|
||||
) : VectorViewModel<SpaceListViewState, SpaceListAction, SpaceListViewEvents>(initialState) {
|
||||
|
||||
@AssistedFactory
|
||||
@@ -85,11 +85,14 @@ class SpaceListViewModel @AssistedInject constructor(
|
||||
}
|
||||
|
||||
observeSpaceSummaries()
|
||||
val spaceHistory = spaceStateHandler.getPersistedSpaceBackstack()
|
||||
.map { it to it?.let { session.roomService().getRoomSummary(it)?.displayName }.orEmpty() }
|
||||
spaceStateHandler.getSelectedSpaceFlow()
|
||||
.distinctUntilChanged()
|
||||
.setOnEach { selectedSpaceOption ->
|
||||
copy(
|
||||
selectedSpace = selectedSpaceOption.orNull()
|
||||
selectedSpace = selectedSpaceOption.orNull(),
|
||||
spaceHistory = spaceHistory,
|
||||
)
|
||||
}
|
||||
|
||||
|
@@ -32,5 +32,6 @@ data class SpaceListViewState(
|
||||
val spaceOrderInfo: Map<String, String?>? = null,
|
||||
val spaceOrderLocalEchos: Map<String, String?>? = null,
|
||||
val expandedStates: Map<String, Boolean> = emptyMap(),
|
||||
val spaceHistory: List<Pair<String?, String>> = emptyList(), // List of space id to display name
|
||||
val homeAggregateCount: RoomAggregateNotificationCount = RoomAggregateNotificationCount(0, 0)
|
||||
) : MavericksState
|
||||
|
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/rootLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?colorSurface"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
style="@style/Widget.Vector.TextView.Subtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:text="@string/home_layout_preferences"
|
||||
android:textAllCaps="true" />
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/home_layout_settings_recents"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:checked="true"
|
||||
android:text="@string/home_layout_preferences_recents" />
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/home_layout_settings_filters"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="64dp"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:checked="true"
|
||||
android:text="@string/home_layout_preferences_filters" />
|
||||
|
||||
<TextView
|
||||
style="@style/Widget.Vector.TextView.Subtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:layout_marginVertical="8dp"
|
||||
android:text="@string/home_layout_preferences_sort_by"
|
||||
android:textAllCaps="true" />
|
||||
|
||||
<RadioGroup
|
||||
android:id="@+id/home_layout_settings_sort_group"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="16dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/home_layout_settings_sort_activity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:checked="true"
|
||||
android:text="@string/home_layout_preferences_sort_activity"
|
||||
android:textColor="?vctr_content_primary" />
|
||||
|
||||
<RadioButton
|
||||
android:id="@+id/home_layout_settings_sort_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/home_layout_preferences_sort_name"
|
||||
android:textColor="?vctr_content_primary" />
|
||||
</RadioGroup>
|
||||
|
||||
<Button
|
||||
android:id="@+id/home_layout_settings_done"
|
||||
style="@style/Widget.Vector.Button.Login"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginHorizontal="18dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:text="@string/done" />
|
||||
|
||||
|
||||
</LinearLayout>
|
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/start_chat"
|
||||
style="@style/Widget.Vector.TextView.Subtitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?selectableItemBackground"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="16dp"
|
||||
android:text="@string/start_chat"
|
||||
android:textAppearance="@style/TextAppearance.Vector.Body"
|
||||
android:textColor="?vctr_content_primary" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/create_room"
|
||||
style="@style/Widget.Vector.TextView.Subtitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?selectableItemBackground"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="16dp"
|
||||
android:text="@string/create_room"
|
||||
android:textAppearance="@style/TextAppearance.Vector.Body"
|
||||
android:textColor="?vctr_content_primary" />
|
||||
|
||||
</LinearLayout>
|
@@ -49,6 +49,7 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/syncStateView">
|
||||
|
||||
<com.google.android.material.appbar.CollapsingToolbarLayout
|
||||
android:id="@+id/collapsing_toolbar"
|
||||
style="@style/Widget.Vector.Material3.CollapsingToolbar.Medium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/collapsingToolbarLayoutMediumSize"
|
||||
@@ -61,7 +62,7 @@
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:elevation="0dp"
|
||||
app:layout_collapseMode="pin"
|
||||
app:title="@string/all_chats">
|
||||
tools:title="@string/all_chats">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/avatar"
|
||||
@@ -77,24 +78,52 @@
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/roomListContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||
android:layout_gravity="bottom|end">
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/roomListContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/bottomNavigationView"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/bottomNavigationView"
|
||||
android:layout_width="match_parent"
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/newLayoutOpenSpacesButton"
|
||||
style="@style/Widget.Vector.FloatingActionButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:accessibilityTraversalAfter="@id/newLayoutCreateChatButton"
|
||||
android:contentDescription="@string/a11y_open_spaces"
|
||||
android:src="@drawable/ic_open_spaces"
|
||||
android:visibility="visible"
|
||||
app:backgroundTint="?attr/vctr_toolbar_background"
|
||||
app:fabSize="mini"
|
||||
app:layout_constraintBottom_toTopOf="@id/newLayoutCreateChatButton"
|
||||
app:layout_constraintEnd_toEndOf="@id/newLayoutCreateChatButton"
|
||||
app:layout_constraintStart_toStartOf="@id/newLayoutCreateChatButton"
|
||||
app:tint="?attr/colorPrimary"
|
||||
tools:targetApi="lollipop_mr1"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/newLayoutCreateChatButton"
|
||||
style="@style/Widget.Vector.FloatingActionButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:accessibilityTraversalBefore="@id/roomListView"
|
||||
android:contentDescription="@string/a11y_create_message"
|
||||
android:src="@drawable/ic_new_chat"
|
||||
android:visibility="visible"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:menu="@menu/home_bottom_navigation" />
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:targetApi="lollipop_mr1"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
@@ -59,49 +59,6 @@
|
||||
tools:layout_marginEnd="144dp"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="bottom|end">
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/newLayoutOpenSpacesButton"
|
||||
style="@style/Widget.Vector.FloatingActionButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:accessibilityTraversalAfter="@id/newLayoutCreateChatButton"
|
||||
android:contentDescription="@string/a11y_open_spaces"
|
||||
android:src="@drawable/ic_open_spaces"
|
||||
android:visibility="gone"
|
||||
app:backgroundTint="?attr/vctr_toolbar_background"
|
||||
app:fabSize="mini"
|
||||
app:layout_constraintBottom_toTopOf="@id/newLayoutCreateChatButton"
|
||||
app:layout_constraintEnd_toEndOf="@id/newLayoutCreateChatButton"
|
||||
app:layout_constraintStart_toStartOf="@id/newLayoutCreateChatButton"
|
||||
app:tint="?attr/colorPrimary"
|
||||
tools:targetApi="lollipop_mr1"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:id="@+id/newLayoutCreateChatButton"
|
||||
style="@style/Widget.Vector.FloatingActionButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:accessibilityTraversalBefore="@id/roomListView"
|
||||
android:contentDescription="@string/a11y_create_message"
|
||||
android:src="@drawable/ic_new_chat"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
tools:targetApi="lollipop_mr1"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</im.vector.app.core.platform.StateView>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
|
@@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/space_header"
|
||||
style="@style/TextAppearance.Vector.Body.Medium"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
@@ -3,6 +3,10 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_home_layout_settings"
|
||||
android:title="@string/home_layout_preferences"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_home_invite_friends"
|
||||
android:title="@string/invite_friends"
|
||||
@@ -37,6 +41,6 @@
|
||||
android:icon="@drawable/ic_home_search"
|
||||
android:title="@string/home_filter_placeholder_home"
|
||||
app:iconTint="?vctr_content_secondary"
|
||||
app:showAsAction="always" />
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
</menu>
|
||||
|
@@ -138,6 +138,8 @@
|
||||
<!-- Home Screen -->
|
||||
<string name="all_chats">All Chats</string>
|
||||
<string name="change_space">Change Space</string>
|
||||
<string name="start_chat">Start chat</string>
|
||||
<string name="create_room">Create room</string>
|
||||
|
||||
<!-- Last seen time -->
|
||||
|
||||
@@ -424,6 +426,15 @@
|
||||
|
||||
<!-- Home screen -->
|
||||
<string name="home_filter_placeholder_home">Filter room names</string>
|
||||
<string name="home_layout_preferences">Layout preferences</string>
|
||||
|
||||
|
||||
<!-- Home screen layout settings -->
|
||||
<string name="home_layout_preferences_filters">Show filters</string>
|
||||
<string name="home_layout_preferences_recents">Show recents</string>
|
||||
<string name="home_layout_preferences_sort_by">Sort by</string>
|
||||
<string name="home_layout_preferences_sort_activity">Activity</string>
|
||||
<string name="home_layout_preferences_sort_name">A - Z</string>
|
||||
|
||||
<!-- Home fragment -->
|
||||
<string name="invitations_header">Invites</string>
|
||||
|
Reference in New Issue
Block a user