Enable split pane UI for new conversation screen.

This commit is contained in:
jeffrey-signal
2025-10-17 11:23:36 -04:00
committed by Cody Henthorne
parent 4fd4792dd8
commit 9d0422a898
10 changed files with 24 additions and 477 deletions

View File

@@ -68,13 +68,16 @@ import org.thoughtcrime.securesms.window.rememberAppScaffoldNavigator
/**
* Allows the user to start a new conversation by selecting a recipient.
*
* A modernized compose-based replacement for [org.thoughtcrime.securesms.NewConversationActivity].
*/
class NewConversationActivityV2 : PassphraseRequiredActivity() {
class NewConversationActivity : PassphraseRequiredActivity() {
companion object {
@JvmOverloads
@JvmStatic
fun createIntent(context: Context): Intent = Intent(context, NewConversationActivityV2::class.java)
fun createIntent(context: Context, draftMessage: String? = null): Intent {
return Intent(context, NewConversationActivity::class.java).apply {
putExtra(Intent.EXTRA_TEXT, draftMessage)
}
}
}
override fun onCreate(savedInstanceState: Bundle?, ready: Boolean) {
@@ -121,7 +124,7 @@ private fun NewConversationScreen(
val coroutineScope = rememberCoroutineScope()
val callbacks = remember {
object : Callbacks {
object : UiCallbacks {
override fun onCreateNewGroup() = createGroupLauncher.launch(CreateGroupActivity.newIntent(context))
override fun onFindByUsername() = findByLauncher.launch(FindByMode.USERNAME)
override fun onFindByPhoneNumber() = findByLauncher.launch(FindByMode.PHONE_NUMBER)
@@ -191,7 +194,7 @@ private suspend fun openConversation(
@Composable
private fun NewConversationScreenUi(
uiState: NewConversationUiState,
callbacks: Callbacks
callbacks: UiCallbacks
) {
val windowSizeClass = WindowSizeClass.rememberWindowSizeClass()
val isSplitPane = windowSizeClass.isSplitPane(forceSplitPaneOnCompactLandscape = uiState.forceSplitPaneOnCompactLandscape)
@@ -259,7 +262,7 @@ private fun NewConversationScreenUi(
}
@Composable
private fun TopAppBarActions(callbacks: Callbacks) {
private fun TopAppBarActions(callbacks: UiCallbacks) {
val menuController = remember { DropdownMenus.MenuController() }
IconButton(
onClick = { menuController.show() },
@@ -303,13 +306,13 @@ private fun TopAppBarActions(callbacks: Callbacks) {
}
}
private interface Callbacks : RecipientPickerCallbacks {
private interface UiCallbacks : RecipientPickerCallbacks {
fun onRemoveConfirmed(recipient: Recipient)
fun onBlockConfirmed(recipient: Recipient)
fun onUserMessageDismissed(userMessage: UserMessage)
fun onBackPressed()
object Empty : Callbacks {
object Empty : UiCallbacks {
override fun onCreateNewGroup() = Unit
override fun onFindByUsername() = Unit
override fun onFindByPhoneNumber() = Unit
@@ -333,7 +336,7 @@ private interface Callbacks : RecipientPickerCallbacks {
@Composable
private fun NewConversationRecipientPicker(
uiState: NewConversationUiState,
callbacks: Callbacks,
callbacks: UiCallbacks,
modifier: Modifier = Modifier
) {
RecipientPicker(
@@ -423,7 +426,7 @@ private fun NewConversationScreenPreview() {
uiState = NewConversationUiState(
forceSplitPaneOnCompactLandscape = false
),
callbacks = Callbacks.Empty
callbacks = UiCallbacks.Empty
)
}
}

View File

@@ -113,7 +113,7 @@ private fun RecipientSearchField(
}
}
// TODO(jeff) This causes the keyboard to re-open on rotation, which doesn't match the existing behavior of ContactFilterView. To fix this,
// TODO [jeff] This causes the keyboard to re-open on rotation, which doesn't match the existing behavior of ContactFilterView. To fix this,
// RecipientSearchField needs to be converted to compose so we can use FocusRequestor.
LaunchedEffect(focusAndShowKeyboard) {
if (focusAndShowKeyboard) {
@@ -298,7 +298,7 @@ private suspend fun showItemContextMenu(anchorView: View, contactSearchKey: Cont
if (!recipient.isSelf && !recipient.isGroup) {
val removeItem = ActionItem(
iconRes = R.drawable.ic_minus_circle_20, // TODO [alex] -- correct asset
iconRes = R.drawable.ic_minus_circle_20,
title = context.getString(R.string.NewConversationActivity__remove),
tintRes = R.color.signal_colorOnSurface,
action = { callbacks.onRemove(recipient) }