From fbf9bbeeebcff37c378419ced24efe610a77d3a5 Mon Sep 17 00:00:00 2001 From: jvsena42 Date: Thu, 26 Nov 2026 10:33:21 -0300 Subject: [PATCH 1/4] fix: apply screen gutter to profile cleanup recovery Co-Authored-By: Claude Opus 5.5 --- .../profile/ProfileRecoveryContentTest.kt | 47 ++++++++++ .../ui/screens/profile/ProfileScreen.kt | 91 ++++++++++++++----- changelog.d/next/1749.fixed.md | 1 + 3 files changed, 115 insertions(+), 24 deletions(-) create mode 100644 changelog.d/next/1749.fixed.md diff --git a/app/src/androidTest/java/to/bitkit/ui/screens/profile/ProfileRecoveryContentTest.kt b/app/src/androidTest/java/to/bitkit/ui/screens/profile/ProfileRecoveryContentTest.kt index 506ee64ee1..7ec8892497 100644 --- a/app/src/androidTest/java/to/bitkit/ui/screens/profile/ProfileRecoveryContentTest.kt +++ b/app/src/androidTest/java/to/bitkit/ui/screens/profile/ProfileRecoveryContentTest.kt @@ -7,18 +7,24 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.platform.LocalInspectionMode import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertIsNotEnabled +import androidx.compose.ui.test.assertLeftPositionInRootIsEqualTo +import androidx.compose.ui.test.getUnclippedBoundsInRoot import androidx.compose.ui.test.junit4.v2.createComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText +import androidx.compose.ui.test.onRoot import androidx.compose.ui.test.performClick import androidx.test.espresso.Espresso.pressBackUnconditionally +import androidx.compose.ui.unit.dp import androidx.test.platform.app.InstrumentationRegistry import org.junit.Rule import org.junit.Test import to.bitkit.R import to.bitkit.test.annotations.ComposeUi import to.bitkit.ui.theme.AppThemeSurface +import kotlin.math.abs import kotlin.test.assertEquals +import kotlin.test.assertTrue @ComposeUi class ProfileRecoveryContentTest { @@ -81,6 +87,47 @@ class ProfileRecoveryContentTest { compose.runOnIdle { assertEquals(0, back) } } + @Test + fun cleanupRecoveryContentKeepsStandardGutter() { + compose.setContent { + AppThemeSurface { + CompositionLocalProvider(LocalInspectionMode provides true) { + ProfileContent( + uiState = ProfileUiState( + recoveryPending = true, + recoveryCanDisconnect = true, + recoveryCanRetry = true, + isSigningOut = true, + ), + onBackClick = {}, + onClickEdit = {}, + onClickCopy = {}, + onClickShare = {}, + onClickSignOut = {}, + onDismissSignOutDialog = {}, + onConfirmSignOut = {}, + onClickRetry = {}, + onClickAddTag = {}, + onRemoveTag = {}, + onDismissAddTagSheet = {}, + onSaveTag = {}, + onDismissCopiedPopup = {}, + ) + } + } + } + val rootRight = compose.onRoot().getUnclippedBoundsInRoot().right + compose.onNodeWithText(context.getString(R.string.profile__cleanup_pending)) + .assertLeftPositionInRootIsEqualTo(16.dp) + listOf("ProfileRecoveryRetry", "ProfileRecoveryDisconnect").forEach { + val node = compose.onNodeWithTag(it).assertLeftPositionInRootIsEqualTo(16.dp) + val right = node.getUnclippedBoundsInRoot().right + assertTrue(abs((rootRight - 16.dp - right).value) < 0.5f, "'$it' right edge '$right' is off the gutter") + } + val progress = compose.onNodeWithTag("ProfileRecoveryProgress").assertIsDisplayed().getUnclippedBoundsInRoot() + assertTrue(progress.left >= 16.dp && progress.right <= rootRight - 16.dp, "progress '$progress' crosses the gutter") + } + @Test fun uncertainDeletionOffersReviewThenSeparateConfirmation() { var state by mutableStateOf(EditProfileUiState(showDeleteFailureDialog = true, canReviewRemoval = true)) diff --git a/app/src/main/java/to/bitkit/ui/screens/profile/ProfileScreen.kt b/app/src/main/java/to/bitkit/ui/screens/profile/ProfileScreen.kt index 177aa2a4a2..080670ad43 100644 --- a/app/src/main/java/to/bitkit/ui/screens/profile/ProfileScreen.kt +++ b/app/src/main/java/to/bitkit/ui/screens/profile/ProfileScreen.kt @@ -146,35 +146,50 @@ internal fun ProfileContent( when { uiState.recoveryPending -> ScreenColumn { topBar(Modifier) - VerticalSpacer(32.dp) - BodyM( - text = stringResource( - if (uiState.recoveryCanDisconnect) { - R.string.profile__cleanup_pending - } else { - R.string.profile__wallet_recovery_pending - }, - ), - ) - if (uiState.recoveryCanDisconnect) { - VerticalSpacer(24.dp) - if (uiState.recoveryCanRetry) { + Column( + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 16.dp) + .testTag("ProfileRecoveryContent") + ) { + VerticalSpacer(32.dp) + BodyM( + text = stringResource( + if (uiState.recoveryCanDisconnect) { + R.string.profile__cleanup_pending + } else { + R.string.profile__wallet_recovery_pending + }, + ), + ) + if (uiState.recoveryCanDisconnect) { + VerticalSpacer(24.dp) + if (uiState.recoveryCanRetry) { + PrimaryButton( + text = stringResource(R.string.common__retry), + onClick = onClickRemoteRetry, + enabled = !uiState.isSigningOut, + modifier = Modifier.testTag("ProfileRecoveryRetry"), + ) + VerticalSpacer(16.dp) + } PrimaryButton( - text = stringResource(R.string.common__retry), - onClick = onClickRemoteRetry, + text = stringResource(R.string.profile__sign_out), + onClick = onClickSignOut, enabled = !uiState.isSigningOut, - modifier = Modifier.testTag("ProfileRecoveryRetry"), + modifier = Modifier.testTag("ProfileRecoveryDisconnect"), + ) + } + if (uiState.isSigningOut) { + VerticalSpacer(24.dp) + GradientCircularProgressIndicator( + modifier = Modifier + .size(32.dp) + .align(Alignment.CenterHorizontally) + .testTag("ProfileRecoveryProgress") ) - VerticalSpacer(16.dp) } - PrimaryButton( - text = stringResource(R.string.profile__sign_out), - onClick = onClickSignOut, - enabled = !uiState.isSigningOut, - modifier = Modifier.testTag("ProfileRecoveryDisconnect"), - ) } - if (uiState.isSigningOut) GradientCircularProgressIndicator(Modifier.size(32.dp)) } currentProfile != null -> Box(modifier = Modifier.screen()) { @@ -583,3 +598,31 @@ private fun Preview() { ) } } + +@Preview(showSystemUi = true, widthDp = 320) +@Composable +private fun PreviewRecoveryPending() { + AppThemeSurface { + ProfileContent( + uiState = ProfileUiState( + recoveryPending = true, + recoveryCanDisconnect = true, + recoveryCanRetry = true, + isSigningOut = true, + ), + onBackClick = {}, + onClickEdit = {}, + onClickCopy = {}, + onClickShare = {}, + onClickSignOut = {}, + onDismissSignOutDialog = {}, + onConfirmSignOut = {}, + onClickRetry = {}, + onClickAddTag = {}, + onRemoveTag = {}, + onDismissAddTagSheet = {}, + onSaveTag = {}, + onDismissCopiedPopup = {}, + ) + } +} diff --git a/changelog.d/next/1749.fixed.md b/changelog.d/next/1749.fixed.md new file mode 100644 index 0000000000..b272def915 --- /dev/null +++ b/changelog.d/next/1749.fixed.md @@ -0,0 +1 @@ +The profile cleanup recovery screen now keeps its text, buttons and progress indicator inside the standard screen margins. From ab231fa615d1b72de7ae576d7a1d498ff4930e92 Mon Sep 17 00:00:00 2001 From: jvsena42 Date: Thu, 26 Nov 2026 12:00:13 -0300 Subject: [PATCH 2/4] fix: scroll profile cleanup recovery content Co-Authored-By: Claude Opus 5.5 --- .../profile/ProfileRecoveryContentTest.kt | 110 ++++++++++++------ .../ui/screens/profile/ProfileScreen.kt | 3 +- 2 files changed, 79 insertions(+), 34 deletions(-) diff --git a/app/src/androidTest/java/to/bitkit/ui/screens/profile/ProfileRecoveryContentTest.kt b/app/src/androidTest/java/to/bitkit/ui/screens/profile/ProfileRecoveryContentTest.kt index 7ec8892497..2d3e658189 100644 --- a/app/src/androidTest/java/to/bitkit/ui/screens/profile/ProfileRecoveryContentTest.kt +++ b/app/src/androidTest/java/to/bitkit/ui/screens/profile/ProfileRecoveryContentTest.kt @@ -1,10 +1,21 @@ package to.bitkit.ui.screens.profile +import android.content.res.Configuration +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.width import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue +import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalConfiguration +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalInspectionMode +import androidx.compose.ui.platform.testTag import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.assertLeftPositionInRootIsEqualTo @@ -12,16 +23,18 @@ import androidx.compose.ui.test.getUnclippedBoundsInRoot import androidx.compose.ui.test.junit4.v2.createComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText -import androidx.compose.ui.test.onRoot import androidx.compose.ui.test.performClick -import androidx.test.espresso.Espresso.pressBackUnconditionally +import androidx.compose.ui.unit.Density +import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp +import androidx.test.espresso.Espresso.pressBackUnconditionally import androidx.test.platform.app.InstrumentationRegistry import org.junit.Rule import org.junit.Test import to.bitkit.R import to.bitkit.test.annotations.ComposeUi import to.bitkit.ui.theme.AppThemeSurface +import java.util.Locale import kotlin.math.abs import kotlin.test.assertEquals import kotlin.test.assertTrue @@ -89,43 +102,74 @@ class ProfileRecoveryContentTest { @Test fun cleanupRecoveryContentKeepsStandardGutter() { + var locale by mutableStateOf(Locale.ENGLISH) + var width by mutableStateOf(null) + var fontScale by mutableFloatStateOf(1f) compose.setContent { - AppThemeSurface { - CompositionLocalProvider(LocalInspectionMode provides true) { - ProfileContent( - uiState = ProfileUiState( - recoveryPending = true, - recoveryCanDisconnect = true, - recoveryCanRetry = true, - isSigningOut = true, - ), - onBackClick = {}, - onClickEdit = {}, - onClickCopy = {}, - onClickShare = {}, - onClickSignOut = {}, - onDismissSignOutDialog = {}, - onConfirmSignOut = {}, - onClickRetry = {}, - onClickAddTag = {}, - onRemoveTag = {}, - onDismissAddTagSheet = {}, - onSaveTag = {}, - onDismissCopiedPopup = {}, - ) + val configuration = Configuration(LocalConfiguration.current).apply { setLocale(locale) } + val localized = LocalContext.current.createConfigurationContext(configuration) + CompositionLocalProvider( + LocalContext provides localized, + LocalConfiguration provides configuration, + LocalDensity provides Density(LocalDensity.current.density, fontScale), + LocalInspectionMode provides true, + ) { + AppThemeSurface { + Box(modifier = Modifier.fillMaxSize()) { + Box( + modifier = Modifier + .then(width?.let { Modifier.width(it) } ?: Modifier.fillMaxWidth()) + .testTag("RecoveryFrame") + ) { + ProfileContent( + uiState = ProfileUiState( + recoveryPending = true, + recoveryCanDisconnect = true, + recoveryCanRetry = true, + isSigningOut = true, + ), + onBackClick = {}, + onClickEdit = {}, + onClickCopy = {}, + onClickShare = {}, + onClickSignOut = {}, + onDismissSignOutDialog = {}, + onConfirmSignOut = {}, + onClickRetry = {}, + onClickAddTag = {}, + onRemoveTag = {}, + onDismissAddTagSheet = {}, + onSaveTag = {}, + onDismissCopiedPopup = {}, + ) + } + } } } } - val rootRight = compose.onRoot().getUnclippedBoundsInRoot().right - compose.onNodeWithText(context.getString(R.string.profile__cleanup_pending)) - .assertLeftPositionInRootIsEqualTo(16.dp) + assertGutter(context.getString(R.string.profile__cleanup_pending)) + compose.runOnIdle { + locale = Locale.forLanguageTag("el") + width = 320.dp + fontScale = 1.3f + } + val greek = context.createConfigurationContext( + Configuration(context.resources.configuration).apply { setLocale(Locale.forLanguageTag("el")) }, + ) + assertGutter(greek.getString(R.string.profile__cleanup_pending)) + } + + private fun assertGutter(text: String) { + val frame = compose.onNodeWithTag("RecoveryFrame").getUnclippedBoundsInRoot() + val left = frame.left + 16.dp + val right = frame.right - 16.dp + compose.onNodeWithText(text).assertExists().assertLeftPositionInRootIsEqualTo(left) listOf("ProfileRecoveryRetry", "ProfileRecoveryDisconnect").forEach { - val node = compose.onNodeWithTag(it).assertLeftPositionInRootIsEqualTo(16.dp) - val right = node.getUnclippedBoundsInRoot().right - assertTrue(abs((rootRight - 16.dp - right).value) < 0.5f, "'$it' right edge '$right' is off the gutter") + val bounds = compose.onNodeWithTag(it).assertLeftPositionInRootIsEqualTo(left).getUnclippedBoundsInRoot() + assertTrue(abs((right - bounds.right).value) < 0.5f, "'$it' right edge '${bounds.right}' is off the gutter") } - val progress = compose.onNodeWithTag("ProfileRecoveryProgress").assertIsDisplayed().getUnclippedBoundsInRoot() - assertTrue(progress.left >= 16.dp && progress.right <= rootRight - 16.dp, "progress '$progress' crosses the gutter") + val progress = compose.onNodeWithTag("ProfileRecoveryProgress").assertExists().getUnclippedBoundsInRoot() + assertTrue(progress.left >= left && progress.right <= right, "progress '$progress' crosses the gutter") } @Test diff --git a/app/src/main/java/to/bitkit/ui/screens/profile/ProfileScreen.kt b/app/src/main/java/to/bitkit/ui/screens/profile/ProfileScreen.kt index 080670ad43..a44921b05d 100644 --- a/app/src/main/java/to/bitkit/ui/screens/profile/ProfileScreen.kt +++ b/app/src/main/java/to/bitkit/ui/screens/profile/ProfileScreen.kt @@ -149,7 +149,8 @@ internal fun ProfileContent( Column( modifier = Modifier .fillMaxWidth() - .padding(horizontal = 16.dp) + .verticalScroll(rememberScrollState()) + .padding(start = 16.dp, end = 16.dp, bottom = 16.dp) .testTag("ProfileRecoveryContent") ) { VerticalSpacer(32.dp) From 3cc80605c9982141d525990e6b7137d24b8dcf87 Mon Sep 17 00:00:00 2001 From: jvsena42 Date: Thu, 26 Nov 2026 16:56:11 -0300 Subject: [PATCH 3/4] test: resolve cleanup text in the forced locale Co-Authored-By: Claude Opus 5.5 --- .../profile/ProfileRecoveryContentTest.kt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/androidTest/java/to/bitkit/ui/screens/profile/ProfileRecoveryContentTest.kt b/app/src/androidTest/java/to/bitkit/ui/screens/profile/ProfileRecoveryContentTest.kt index 2d3e658189..74c068e3ef 100644 --- a/app/src/androidTest/java/to/bitkit/ui/screens/profile/ProfileRecoveryContentTest.kt +++ b/app/src/androidTest/java/to/bitkit/ui/screens/profile/ProfileRecoveryContentTest.kt @@ -41,6 +41,10 @@ import kotlin.test.assertTrue @ComposeUi class ProfileRecoveryContentTest { + private companion object { + val GREEK: Locale = Locale.forLanguageTag("el") + } + @get:Rule val compose = createComposeRule() @@ -147,16 +151,18 @@ class ProfileRecoveryContentTest { } } } - assertGutter(context.getString(R.string.profile__cleanup_pending)) + assertGutter(cleanupText(Locale.ENGLISH)) compose.runOnIdle { - locale = Locale.forLanguageTag("el") + locale = GREEK width = 320.dp fontScale = 1.3f } - val greek = context.createConfigurationContext( - Configuration(context.resources.configuration).apply { setLocale(Locale.forLanguageTag("el")) }, - ) - assertGutter(greek.getString(R.string.profile__cleanup_pending)) + assertGutter(cleanupText(GREEK)) + } + + private fun cleanupText(locale: Locale): String { + val configuration = Configuration(context.resources.configuration).apply { setLocale(locale) } + return context.createConfigurationContext(configuration).getString(R.string.profile__cleanup_pending) } private fun assertGutter(text: String) { From 9ccca3e679a4a68ef5b5e53cbb28209a518a911b Mon Sep 17 00:00:00 2001 From: jvsena42 Date: Thu, 26 Nov 2026 16:56:17 -0300 Subject: [PATCH 4/4] test: prove cleanup recovery content scrolls on short screens Co-Authored-By: Claude Opus 5.5 --- .../ui/screens/profile/ProfileRecoveryContentTest.kt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/src/androidTest/java/to/bitkit/ui/screens/profile/ProfileRecoveryContentTest.kt b/app/src/androidTest/java/to/bitkit/ui/screens/profile/ProfileRecoveryContentTest.kt index 74c068e3ef..0241fddb0e 100644 --- a/app/src/androidTest/java/to/bitkit/ui/screens/profile/ProfileRecoveryContentTest.kt +++ b/app/src/androidTest/java/to/bitkit/ui/screens/profile/ProfileRecoveryContentTest.kt @@ -4,6 +4,7 @@ import android.content.res.Configuration import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.width import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.getValue @@ -17,6 +18,7 @@ import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalInspectionMode import androidx.compose.ui.platform.testTag import androidx.compose.ui.test.assertIsDisplayed +import androidx.compose.ui.test.assertIsNotDisplayed import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.assertLeftPositionInRootIsEqualTo import androidx.compose.ui.test.getUnclippedBoundsInRoot @@ -24,6 +26,7 @@ import androidx.compose.ui.test.junit4.v2.createComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick +import androidx.compose.ui.test.performScrollTo import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp @@ -108,6 +111,7 @@ class ProfileRecoveryContentTest { fun cleanupRecoveryContentKeepsStandardGutter() { var locale by mutableStateOf(Locale.ENGLISH) var width by mutableStateOf(null) + var height by mutableStateOf(null) var fontScale by mutableFloatStateOf(1f) compose.setContent { val configuration = Configuration(LocalConfiguration.current).apply { setLocale(locale) } @@ -123,6 +127,7 @@ class ProfileRecoveryContentTest { Box( modifier = Modifier .then(width?.let { Modifier.width(it) } ?: Modifier.fillMaxWidth()) + .then(height?.let { Modifier.height(it) } ?: Modifier) .testTag("RecoveryFrame") ) { ProfileContent( @@ -158,6 +163,12 @@ class ProfileRecoveryContentTest { fontScale = 1.3f } assertGutter(cleanupText(GREEK)) + compose.runOnIdle { + height = 400.dp + fontScale = 1.5f + } + compose.onNodeWithTag("ProfileRecoveryDisconnect").assertIsNotDisplayed() + compose.onNodeWithTag("ProfileRecoveryDisconnect").performScrollTo().assertIsDisplayed() } private fun cleanupText(locale: Locale): String {