Adds up navigation from spaces
This commit is contained in:
parent
15366f8d2a
commit
e706c5a3c8
|
@ -199,43 +199,13 @@ class HomeActivity :
|
||||||
when (sharedAction) {
|
when (sharedAction) {
|
||||||
is HomeActivitySharedAction.OpenDrawer -> views.drawerLayout.openDrawer(GravityCompat.START)
|
is HomeActivitySharedAction.OpenDrawer -> views.drawerLayout.openDrawer(GravityCompat.START)
|
||||||
is HomeActivitySharedAction.CloseDrawer -> views.drawerLayout.closeDrawer(GravityCompat.START)
|
is HomeActivitySharedAction.CloseDrawer -> views.drawerLayout.closeDrawer(GravityCompat.START)
|
||||||
is HomeActivitySharedAction.OpenGroup -> {
|
is HomeActivitySharedAction.OpenGroup -> openGroup(sharedAction.shouldClearFragment)
|
||||||
views.drawerLayout.closeDrawer(GravityCompat.START)
|
is HomeActivitySharedAction.OpenSpacePreview -> startActivity(SpacePreviewActivity.newIntent(this, sharedAction.spaceId))
|
||||||
|
is HomeActivitySharedAction.AddSpace -> createSpaceResultLauncher.launch(SpaceCreationActivity.newIntent(this))
|
||||||
// Temporary
|
is HomeActivitySharedAction.ShowSpaceSettings -> showSpaceSettings(sharedAction.spaceId)
|
||||||
// When switching from space to group or group to space, we need to reload the fragment
|
is HomeActivitySharedAction.OpenSpaceInvite -> openSpaceInvite(sharedAction.spaceId)
|
||||||
// To be removed when dropping legacy groups
|
HomeActivitySharedAction.SendSpaceFeedBack -> bugReporter.openBugReportScreen(this, ReportType.SPACE_BETA_FEEDBACK)
|
||||||
if (sharedAction.clearFragment) {
|
HomeActivitySharedAction.CloseGroup -> closeGroup()
|
||||||
replaceFragment(views.homeDetailFragmentContainer, HomeDetailFragment::class.java, allowStateLoss = true)
|
|
||||||
} else {
|
|
||||||
// nop
|
|
||||||
}
|
|
||||||
// we might want to delay that to avoid having the drawer animation lagging
|
|
||||||
// would be probably better to let the drawer do that? in the on closed callback?
|
|
||||||
}
|
|
||||||
is HomeActivitySharedAction.OpenSpacePreview -> {
|
|
||||||
startActivity(SpacePreviewActivity.newIntent(this, sharedAction.spaceId))
|
|
||||||
}
|
|
||||||
is HomeActivitySharedAction.AddSpace -> {
|
|
||||||
createSpaceResultLauncher.launch(SpaceCreationActivity.newIntent(this))
|
|
||||||
}
|
|
||||||
is HomeActivitySharedAction.ShowSpaceSettings -> {
|
|
||||||
// open bottom sheet
|
|
||||||
SpaceSettingsMenuBottomSheet
|
|
||||||
.newInstance(sharedAction.spaceId, object : SpaceSettingsMenuBottomSheet.InteractionListener {
|
|
||||||
override fun onShareSpaceSelected(spaceId: String) {
|
|
||||||
ShareSpaceBottomSheet.show(supportFragmentManager, spaceId)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.show(supportFragmentManager, "SPACE_SETTINGS")
|
|
||||||
}
|
|
||||||
is HomeActivitySharedAction.OpenSpaceInvite -> {
|
|
||||||
SpaceInviteBottomSheet.newInstance(sharedAction.spaceId)
|
|
||||||
.show(supportFragmentManager, "SPACE_INVITE")
|
|
||||||
}
|
|
||||||
HomeActivitySharedAction.SendSpaceFeedBack -> {
|
|
||||||
bugReporter.openBugReportScreen(this, ReportType.SPACE_BETA_FEEDBACK)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.launchIn(lifecycleScope)
|
.launchIn(lifecycleScope)
|
||||||
|
@ -272,6 +242,37 @@ class HomeActivity :
|
||||||
homeActivityViewModel.handle(HomeActivityViewActions.ViewStarted)
|
homeActivityViewModel.handle(HomeActivityViewActions.ViewStarted)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun openGroup(shouldClearFragment: Boolean) {
|
||||||
|
views.drawerLayout.closeDrawer(GravityCompat.START)
|
||||||
|
|
||||||
|
// When switching from space to group or group to space, we need to reload the fragment
|
||||||
|
if (shouldClearFragment) {
|
||||||
|
replaceFragment(views.homeDetailFragmentContainer, HomeDetailFragment::class.java, allowStateLoss = true)
|
||||||
|
} else {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showSpaceSettings(spaceId: String) {
|
||||||
|
// open bottom sheet
|
||||||
|
SpaceSettingsMenuBottomSheet
|
||||||
|
.newInstance(spaceId, object : SpaceSettingsMenuBottomSheet.InteractionListener {
|
||||||
|
override fun onShareSpaceSelected(spaceId: String) {
|
||||||
|
ShareSpaceBottomSheet.show(supportFragmentManager, spaceId)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.show(supportFragmentManager, "SPACE_SETTINGS")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun openSpaceInvite(spaceId: String) {
|
||||||
|
SpaceInviteBottomSheet.newInstance(spaceId)
|
||||||
|
.show(supportFragmentManager, "SPACE_INVITE")
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun closeGroup() {
|
||||||
|
views.drawerLayout.openDrawer(GravityCompat.START)
|
||||||
|
}
|
||||||
|
|
||||||
private fun handleShowAnalyticsOptIn() {
|
private fun handleShowAnalyticsOptIn() {
|
||||||
navigator.openAnalyticsOptIn(this)
|
navigator.openAnalyticsOptIn(this)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,8 @@ import im.vector.app.core.platform.VectorSharedAction
|
||||||
sealed class HomeActivitySharedAction : VectorSharedAction {
|
sealed class HomeActivitySharedAction : VectorSharedAction {
|
||||||
object OpenDrawer : HomeActivitySharedAction()
|
object OpenDrawer : HomeActivitySharedAction()
|
||||||
object CloseDrawer : HomeActivitySharedAction()
|
object CloseDrawer : HomeActivitySharedAction()
|
||||||
data class OpenGroup(val clearFragment: Boolean) : HomeActivitySharedAction()
|
data class OpenGroup(val shouldClearFragment: Boolean) : HomeActivitySharedAction()
|
||||||
|
object CloseGroup : HomeActivitySharedAction()
|
||||||
object AddSpace : HomeActivitySharedAction()
|
object AddSpace : HomeActivitySharedAction()
|
||||||
data class OpenSpacePreview(val spaceId: String) : HomeActivitySharedAction()
|
data class OpenSpacePreview(val spaceId: String) : HomeActivitySharedAction()
|
||||||
data class OpenSpaceInvite(val spaceId: String) : HomeActivitySharedAction()
|
data class OpenSpaceInvite(val spaceId: String) : HomeActivitySharedAction()
|
||||||
|
|
|
@ -60,6 +60,11 @@ import org.matrix.android.sdk.api.session.group.model.GroupSummary
|
||||||
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
import org.matrix.android.sdk.api.session.room.model.RoomSummary
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO:
|
||||||
|
* 1) Change the hamburger menu to a back button when in a space
|
||||||
|
* 2) Make the back navigation button follow the same behaviour
|
||||||
|
*/
|
||||||
class HomeDetailFragment @Inject constructor(
|
class HomeDetailFragment @Inject constructor(
|
||||||
private val avatarRenderer: AvatarRenderer,
|
private val avatarRenderer: AvatarRenderer,
|
||||||
private val colorProvider: ColorProvider,
|
private val colorProvider: ColorProvider,
|
||||||
|
@ -130,12 +135,8 @@ class HomeDetailFragment @Inject constructor(
|
||||||
|
|
||||||
viewModel.onEach(HomeDetailViewState::roomGroupingMethod) { roomGroupingMethod ->
|
viewModel.onEach(HomeDetailViewState::roomGroupingMethod) { roomGroupingMethod ->
|
||||||
when (roomGroupingMethod) {
|
when (roomGroupingMethod) {
|
||||||
is RoomGroupingMethod.ByLegacyGroup -> {
|
is RoomGroupingMethod.ByLegacyGroup -> onGroupChange(roomGroupingMethod.groupSummary)
|
||||||
onGroupChange(roomGroupingMethod.groupSummary)
|
is RoomGroupingMethod.BySpace -> onSpaceChange(roomGroupingMethod.spaceSummary)
|
||||||
}
|
|
||||||
is RoomGroupingMethod.BySpace -> {
|
|
||||||
onSpaceChange(roomGroupingMethod.spaceSummary)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,6 +148,10 @@ class HomeDetailFragment @Inject constructor(
|
||||||
updateTabVisibilitySafely(R.id.bottom_action_dial_pad, showDialPadTab)
|
updateTabVisibilitySafely(R.id.bottom_action_dial_pad, showDialPadTab)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
views.groupToolbarNavigateUp.setOnClickListener {
|
||||||
|
navigateUpOneParentSpace()
|
||||||
|
}
|
||||||
|
|
||||||
viewModel.observeViewEvents { viewEvent ->
|
viewModel.observeViewEvents { viewEvent ->
|
||||||
when (viewEvent) {
|
when (viewEvent) {
|
||||||
HomeDetailViewEvents.CallStarted -> handleCallStarted()
|
HomeDetailViewEvents.CallStarted -> handleCallStarted()
|
||||||
|
@ -157,7 +162,6 @@ class HomeDetailFragment @Inject constructor(
|
||||||
|
|
||||||
unknownDeviceDetectorSharedViewModel.onEach { state ->
|
unknownDeviceDetectorSharedViewModel.onEach { state ->
|
||||||
state.unknownSessions.invoke()?.let { unknownDevices ->
|
state.unknownSessions.invoke()?.let { unknownDevices ->
|
||||||
// Timber.v("## Detector Triggerred in fragment - ${unknownDevices.firstOrNull()}")
|
|
||||||
if (unknownDevices.firstOrNull()?.currentSessionTrust == true) {
|
if (unknownDevices.firstOrNull()?.currentSessionTrust == true) {
|
||||||
val uid = "review_login"
|
val uid = "review_login"
|
||||||
alertManager.cancelAlert(uid)
|
alertManager.cancelAlert(uid)
|
||||||
|
@ -190,6 +194,15 @@ class HomeDetailFragment @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun navigateUpOneParentSpace() = with(appStateHandler) {
|
||||||
|
val parentId = when (val roomGroupingMethod = getCurrentRoomGroupingMethod()) {
|
||||||
|
is RoomGroupingMethod.BySpace -> roomGroupingMethod.spaceSummary?.flattenParentIds?.firstOrNull { it.isNotBlank() }
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
setCurrentSpace(parentId)
|
||||||
|
sharedActionViewModel.post(HomeActivitySharedAction.CloseGroup)
|
||||||
|
}
|
||||||
|
|
||||||
private fun handleCallStarted() {
|
private fun handleCallStarted() {
|
||||||
dismissLoadingDialog()
|
dismissLoadingDialog()
|
||||||
val fragmentTag = HomeTab.DialPad.toFragmentTag()
|
val fragmentTag = HomeTab.DialPad.toFragmentTag()
|
||||||
|
@ -203,20 +216,16 @@ class HomeDetailFragment @Inject constructor(
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
// update notification tab if needed
|
|
||||||
updateTabVisibilitySafely(R.id.bottom_action_notification, vectorPreferences.labAddNotificationTab())
|
updateTabVisibilitySafely(R.id.bottom_action_notification, vectorPreferences.labAddNotificationTab())
|
||||||
callManager.checkForProtocolsSupportIfNeeded()
|
callManager.checkForProtocolsSupportIfNeeded()
|
||||||
|
refreshSpaceState()
|
||||||
|
}
|
||||||
|
|
||||||
// Current space/group is not live so at least refresh toolbar on resume
|
private fun refreshSpaceState() {
|
||||||
appStateHandler.getCurrentRoomGroupingMethod()?.let { roomGroupingMethod ->
|
when (val roomGroupingMethod = appStateHandler.getCurrentRoomGroupingMethod()) {
|
||||||
when (roomGroupingMethod) {
|
is RoomGroupingMethod.ByLegacyGroup -> onGroupChange(roomGroupingMethod.groupSummary)
|
||||||
is RoomGroupingMethod.ByLegacyGroup -> {
|
is RoomGroupingMethod.BySpace -> onSpaceChange(roomGroupingMethod.spaceSummary)
|
||||||
onGroupChange(roomGroupingMethod.groupSummary)
|
else -> Unit
|
||||||
}
|
|
||||||
is RoomGroupingMethod.BySpace -> {
|
|
||||||
onSpaceChange(roomGroupingMethod.spaceSummary)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,12 +269,12 @@ class HomeDetailFragment @Inject constructor(
|
||||||
viewBinder = VerificationVectorAlert.ViewBinder(user, avatarRenderer)
|
viewBinder = VerificationVectorAlert.ViewBinder(user, avatarRenderer)
|
||||||
colorInt = colorProvider.getColorFromAttribute(R.attr.colorPrimary)
|
colorInt = colorProvider.getColorFromAttribute(R.attr.colorPrimary)
|
||||||
contentAction = Runnable {
|
contentAction = Runnable {
|
||||||
(weakCurrentActivity?.get() as? VectorBaseActivity<*>)?.let {
|
(weakCurrentActivity?.get() as? VectorBaseActivity<*>)?.let { activity ->
|
||||||
// mark as ignored to avoid showing it again
|
// mark as ignored to avoid showing it again
|
||||||
unknownDeviceDetectorSharedViewModel.handle(
|
unknownDeviceDetectorSharedViewModel.handle(
|
||||||
UnknownDeviceDetectorSharedViewModel.Action.IgnoreDevice(oldUnverified.mapNotNull { it.deviceId })
|
UnknownDeviceDetectorSharedViewModel.Action.IgnoreDevice(oldUnverified.mapNotNull { it.deviceId })
|
||||||
)
|
)
|
||||||
it.navigator.openSettings(it, EXTRA_DIRECT_ACCESS_SECURITY_PRIVACY_MANAGE_SESSIONS)
|
activity.navigator.openSettings(activity, EXTRA_DIRECT_ACCESS_SECURITY_PRIVACY_MANAGE_SESSIONS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dismissedAction = Runnable {
|
dismissedAction = Runnable {
|
||||||
|
@ -289,9 +298,13 @@ class HomeDetailFragment @Inject constructor(
|
||||||
private fun onSpaceChange(spaceSummary: RoomSummary?) {
|
private fun onSpaceChange(spaceSummary: RoomSummary?) {
|
||||||
if (spaceSummary == null) {
|
if (spaceSummary == null) {
|
||||||
views.groupToolbarSpaceTitleView.isVisible = false
|
views.groupToolbarSpaceTitleView.isVisible = false
|
||||||
|
views.groupToolbarAvatarImageView.isVisible = true
|
||||||
|
views.groupToolbarNavigateUp.isVisible = false
|
||||||
} else {
|
} else {
|
||||||
views.groupToolbarSpaceTitleView.isVisible = true
|
views.groupToolbarSpaceTitleView.isVisible = true
|
||||||
views.groupToolbarSpaceTitleView.text = spaceSummary.displayName
|
views.groupToolbarSpaceTitleView.text = spaceSummary.displayName
|
||||||
|
views.groupToolbarAvatarImageView.isVisible = false
|
||||||
|
views.groupToolbarNavigateUp.isVisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,11 +337,11 @@ class HomeDetailFragment @Inject constructor(
|
||||||
withState(viewModel) {
|
withState(viewModel) {
|
||||||
when (it.roomGroupingMethod) {
|
when (it.roomGroupingMethod) {
|
||||||
is RoomGroupingMethod.ByLegacyGroup -> {
|
is RoomGroupingMethod.ByLegacyGroup -> {
|
||||||
// nothing do far
|
// do nothing
|
||||||
}
|
}
|
||||||
is RoomGroupingMethod.BySpace -> {
|
is RoomGroupingMethod.BySpace -> {
|
||||||
it.roomGroupingMethod.spaceSummary?.let {
|
it.roomGroupingMethod.spaceSummary?.let { spaceSummary ->
|
||||||
sharedActionViewModel.post(HomeActivitySharedAction.ShowSpaceSettings(it.roomId))
|
sharedActionViewModel.post(HomeActivitySharedAction.ShowSpaceSettings(spaceSummary.roomId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -348,17 +361,6 @@ class HomeDetailFragment @Inject constructor(
|
||||||
viewModel.handle(HomeDetailAction.SwitchTab(tab))
|
viewModel.handle(HomeDetailAction.SwitchTab(tab))
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
// val menuView = bottomNavigationView.getChildAt(0) as BottomNavigationMenuView
|
|
||||||
|
|
||||||
// bottomNavigationView.getOrCreateBadge()
|
|
||||||
// menuView.forEachIndexed { index, view ->
|
|
||||||
// val itemView = view as BottomNavigationItemView
|
|
||||||
// val badgeLayout = LayoutInflater.from(requireContext()).inflate(R.layout.vector_home_badge_unread_layout, menuView, false)
|
|
||||||
// val unreadCounterBadgeView: UnreadCounterBadgeView = badgeLayout.findViewById(R.id.actionUnreadCounterBadgeView)
|
|
||||||
// itemView.addView(badgeLayout)
|
|
||||||
// unreadCounterBadgeViews.add(index, unreadCounterBadgeView)
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateUIForTab(tab: HomeTab) {
|
private fun updateUIForTab(tab: HomeTab) {
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
<vector android:autoMirrored="true" android:height="24dp"
|
||||||
|
android:tint="#000000" android:viewportHeight="24"
|
||||||
|
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
|
||||||
|
</vector>
|
|
@ -38,6 +38,7 @@
|
||||||
android:layout_height="40dp"
|
android:layout_height="40dp"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_marginBottom="8dp"
|
android:layout_marginBottom="8dp"
|
||||||
|
android:visibility="gone"
|
||||||
android:contentDescription="@string/a11y_open_drawer"
|
android:contentDescription="@string/a11y_open_drawer"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
@ -74,6 +75,20 @@
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/groupToolbarNavigateUp"
|
||||||
|
android:layout_width="28dp"
|
||||||
|
android:layout_height="28dp"
|
||||||
|
android:src="@drawable/ic_arrow_back"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:contentDescription="@string/a11y_navigate_up_space"
|
||||||
|
android:visibility="visible"
|
||||||
|
app:tint="?vctr_content_secondary"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:ignore="MissingPrefix" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/homeToolbarContent"
|
android:id="@+id/homeToolbarContent"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
|
|
|
@ -1777,6 +1777,7 @@
|
||||||
<string name="send_attachment">Send attachment</string>
|
<string name="send_attachment">Send attachment</string>
|
||||||
|
|
||||||
<string name="a11y_open_drawer">Open the navigation drawer</string>
|
<string name="a11y_open_drawer">Open the navigation drawer</string>
|
||||||
|
<string name="a11y_navigate_up_space">Navigate up one space</string>
|
||||||
<string name="a11y_create_menu_open">Open the create room menu</string>
|
<string name="a11y_create_menu_open">Open the create room menu</string>
|
||||||
<string name="a11y_create_menu_close">Close the create room menu…</string>
|
<string name="a11y_create_menu_close">Close the create room menu…</string>
|
||||||
<string name="a11y_create_direct_message">Create a new direct conversation</string>
|
<string name="a11y_create_direct_message">Create a new direct conversation</string>
|
||||||
|
|
Loading…
Reference in New Issue