From 46672dfed8a3c7b784bf561b0d8a62009b388946 Mon Sep 17 00:00:00 2001 From: Alex Hart Date: Fri, 14 Nov 2025 09:48:04 -0400 Subject: [PATCH] Remember and restore last pane selection. --- .../java/org/thoughtcrime/securesms/MainActivity.kt | 11 +++++++++-- .../securesms/keyvalue/MiscellaneousValues.kt | 3 +++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/MainActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/MainActivity.kt index ae06517629..7088a44c76 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/MainActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/MainActivity.kt @@ -376,14 +376,21 @@ class MainActivity : PassphraseRequiredActivity(), VoiceNoteMediaControllerOwner val (detailOnlyAnchor, detailAndListAnchor, listOnlyAnchor) = anchors + val initialAnchorIndex = remember { + val index = SignalStore.misc.preferredMainActivityAnchorIndex + if (index >= 0) index else 1 + } + val paneExpansionState = rememberPaneExpansionState( key = wrappedNavigator.scaffoldValue.paneExpansionStateKey, anchors = anchors, - initialAnchoredIndex = 1 + initialAnchoredIndex = initialAnchorIndex ) val paneAnchorIndex = rememberSaveable(paneExpansionState.currentAnchor) { - anchors.indexOf(paneExpansionState.currentAnchor) + val index = anchors.indexOf(paneExpansionState.currentAnchor) + SignalStore.misc.preferredMainActivityAnchorIndex = index + index } LaunchedEffect(windowSizeClass) { diff --git a/app/src/main/java/org/thoughtcrime/securesms/keyvalue/MiscellaneousValues.kt b/app/src/main/java/org/thoughtcrime/securesms/keyvalue/MiscellaneousValues.kt index 02706ca9f2..77d6fc24cc 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/keyvalue/MiscellaneousValues.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/keyvalue/MiscellaneousValues.kt @@ -42,6 +42,7 @@ class MiscellaneousValues internal constructor(store: KeyValueStore) : SignalSto private const val NEW_LINKED_DEVICE_ID = "misc.new_linked_device_id" private const val NEW_LINKED_DEVICE_CREATED_TIME = "misc.new_linked_device_created_time" private const val STARTED_QUOTE_THUMBNAIL_MIGRATION = "misc.started_quote_thumbnail_migration" + private const val PREFERRED_MAIN_ACTIVITY_ANCHOR_INDEX = "misc.preferred_main_activity_anchor_index" } public override fun onFirstEverAppLaunch() { @@ -95,6 +96,8 @@ class MiscellaneousValues internal constructor(store: KeyValueStore) : SignalSto val isChangeNumberLocked: Boolean by booleanValue(CHANGE_NUMBER_LOCK, false) + var preferredMainActivityAnchorIndex: Int by integerValue(PREFERRED_MAIN_ACTIVITY_ANCHOR_INDEX, -1) + fun lockChangeNumber() { putBoolean(CHANGE_NUMBER_LOCK, true) ChangeNumberConstraintObserver.onChange()