mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-20 11:08:31 +00:00
Display back button when the conversation pane is expanded.
This commit is contained in:
committed by
Greyson Parrelli
parent
f38262c0ab
commit
43bb32e64b
@@ -415,6 +415,26 @@ class MainActivity : PassphraseRequiredActivity(), VoiceNoteMediaControllerOwner
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val scope = rememberCoroutineScope()
|
||||||
|
BackHandler(paneExpansionState.currentAnchor == detailOnlyAnchor) {
|
||||||
|
scope.launch {
|
||||||
|
paneExpansionState.animateTo(listOnlyAnchor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LaunchedEffect(paneExpansionState.currentAnchor, detailOnlyAnchor, listOnlyAnchor, detailAndListAnchor) {
|
||||||
|
val isFullScreenPane = when (paneExpansionState.currentAnchor) {
|
||||||
|
listOnlyAnchor, detailOnlyAnchor -> {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mainNavigationViewModel.onPaneAnchorChanged(isFullScreenPane)
|
||||||
|
}
|
||||||
|
|
||||||
LaunchedEffect(paneExpansionState, detailOnlyAnchor, listOnlyAnchor, wrappedNavigator) {
|
LaunchedEffect(paneExpansionState, detailOnlyAnchor, listOnlyAnchor, wrappedNavigator) {
|
||||||
mainNavigationViewModel.detailLocation.collect {
|
mainNavigationViewModel.detailLocation.collect {
|
||||||
if (paneExpansionState.currentAnchor == listOnlyAnchor) {
|
if (paneExpansionState.currentAnchor == listOnlyAnchor) {
|
||||||
|
|||||||
@@ -261,6 +261,7 @@ import org.thoughtcrime.securesms.linkpreview.LinkPreview
|
|||||||
import org.thoughtcrime.securesms.linkpreview.LinkPreviewViewModelV2
|
import org.thoughtcrime.securesms.linkpreview.LinkPreviewViewModelV2
|
||||||
import org.thoughtcrime.securesms.longmessage.LongMessageFragment
|
import org.thoughtcrime.securesms.longmessage.LongMessageFragment
|
||||||
import org.thoughtcrime.securesms.main.MainNavigationListLocation
|
import org.thoughtcrime.securesms.main.MainNavigationListLocation
|
||||||
|
import org.thoughtcrime.securesms.main.MainNavigationViewModel
|
||||||
import org.thoughtcrime.securesms.main.VerticalInsets
|
import org.thoughtcrime.securesms.main.VerticalInsets
|
||||||
import org.thoughtcrime.securesms.mediaoverview.MediaOverviewActivity
|
import org.thoughtcrime.securesms.mediaoverview.MediaOverviewActivity
|
||||||
import org.thoughtcrime.securesms.mediapreview.MediaIntentFactory
|
import org.thoughtcrime.securesms.mediapreview.MediaIntentFactory
|
||||||
@@ -491,6 +492,8 @@ class ConversationFragment :
|
|||||||
|
|
||||||
private val shareDataTimestampViewModel: ShareDataTimestampViewModel by activityViewModels()
|
private val shareDataTimestampViewModel: ShareDataTimestampViewModel by activityViewModels()
|
||||||
|
|
||||||
|
private val mainNavigationViewModel: MainNavigationViewModel by activityViewModels()
|
||||||
|
|
||||||
private val inlineQueryController: InlineQueryResultsControllerV2 by lazy {
|
private val inlineQueryController: InlineQueryResultsControllerV2 by lazy {
|
||||||
InlineQueryResultsControllerV2(
|
InlineQueryResultsControllerV2(
|
||||||
this,
|
this,
|
||||||
@@ -1401,16 +1404,37 @@ class ConversationFragment :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun presentNavigationIconForNormal() {
|
private fun presentNavigationIconForNormal() {
|
||||||
if (!resources.getWindowSizeClass().isSplitPane()) {
|
if (WindowSizeClass.isLargeScreenSupportEnabled()) {
|
||||||
|
lifecycleScope.launch {
|
||||||
|
repeatOnLifecycle(Lifecycle.State.RESUMED) {
|
||||||
|
mainNavigationViewModel.isFullScreenPane.collect { isFullScreenPane ->
|
||||||
|
updateNavigationIconForNormal(isFullScreenPane)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
updateNavigationIconForNormal(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun updateNavigationIconForNormal(isFullScreenPane: Boolean) {
|
||||||
|
if (!resources.getWindowSizeClass().isSplitPane() || isFullScreenPane) {
|
||||||
binding.toolbar.setNavigationIcon(R.drawable.symbol_arrow_start_24)
|
binding.toolbar.setNavigationIcon(R.drawable.symbol_arrow_start_24)
|
||||||
binding.toolbar.setNavigationContentDescription(R.string.ConversationFragment__content_description_back_button)
|
binding.toolbar.setNavigationContentDescription(R.string.ConversationFragment__content_description_back_button)
|
||||||
binding.toolbar.setNavigationOnClickListener {
|
binding.toolbar.setNavigationOnClickListener {
|
||||||
binding.root.hideKeyboard(composeText)
|
binding.root.hideKeyboard(composeText)
|
||||||
requireActivity().onBackPressedDispatcher.onBackPressed()
|
requireActivity().onBackPressedDispatcher.onBackPressed()
|
||||||
}
|
}
|
||||||
|
binding.toolbar.setContentInsetsRelative(
|
||||||
|
46.dp,
|
||||||
|
binding.toolbar.contentInsetEnd
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
binding.toolbar.navigationIcon = null
|
binding.toolbar.navigationIcon = null
|
||||||
binding.toolbar.contentInsetStartWithNavigation = 0
|
binding.toolbar.setContentInsetsRelative(
|
||||||
|
24.dp,
|
||||||
|
binding.toolbar.contentInsetEnd
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ class MainNavigationViewModel(
|
|||||||
private val internalMainNavigationState = MutableStateFlow(MainNavigationState(currentListLocation = initialListLocation))
|
private val internalMainNavigationState = MutableStateFlow(MainNavigationState(currentListLocation = initialListLocation))
|
||||||
val mainNavigationState: StateFlow<MainNavigationState> = internalMainNavigationState
|
val mainNavigationState: StateFlow<MainNavigationState> = internalMainNavigationState
|
||||||
|
|
||||||
|
private val internalIsFullScreenPane = MutableStateFlow(false)
|
||||||
|
val isFullScreenPane: StateFlow<Boolean> = internalIsFullScreenPane
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is Rx because these are still accessed from Java.
|
* This is Rx because these are still accessed from Java.
|
||||||
*/
|
*/
|
||||||
@@ -121,6 +124,10 @@ class MainNavigationViewModel(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun onPaneAnchorChanged(isFullScreenPane: Boolean) {
|
||||||
|
internalIsFullScreenPane.update { isFullScreenPane }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the navigator on the view-model. This wraps the given navigator in our own delegating implementation
|
* Sets the navigator on the view-model. This wraps the given navigator in our own delegating implementation
|
||||||
* such that we can react to navigateTo/Back signals and maintain proper state for internalDetailLocation.
|
* such that we can react to navigateTo/Back signals and maintain proper state for internalDetailLocation.
|
||||||
|
|||||||
Reference in New Issue
Block a user