diff --git a/feature/registration/src/main/java/org/signal/registration/screens/signallogincredentials/SignalLoginCredentialEntryScreen.kt b/feature/registration/src/main/java/org/signal/registration/screens/signallogincredentials/SignalLoginCredentialEntryScreen.kt index 882531f3db..b2e68a4477 100644 --- a/feature/registration/src/main/java/org/signal/registration/screens/signallogincredentials/SignalLoginCredentialEntryScreen.kt +++ b/feature/registration/src/main/java/org/signal/registration/screens/signallogincredentials/SignalLoginCredentialEntryScreen.kt @@ -41,6 +41,8 @@ import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.autofill.ContentType +import androidx.compose.ui.autofill.contentType import androidx.compose.ui.focus.onFocusChanged import androidx.compose.ui.input.nestedscroll.nestedScroll import androidx.compose.ui.platform.LocalContext @@ -315,6 +317,7 @@ private fun AccountIdTextField( visualTransformation = AccountIdVisualTransformation, modifier = modifier .fillMaxWidth() + .contentType(ContentType.Username) .testTag(TestTags.SIGNAL_LOGIN_CREDENTIAL_ACCOUNT_ID_FIELD) ) } @@ -377,6 +380,7 @@ private fun RecoveryKeyTextField( visualTransformation = visualTransformation, modifier = modifier .fillMaxWidth() + .contentType(ContentType.Password) .testTag(TestTags.SIGNAL_LOGIN_CREDENTIAL_RECOVERY_KEY_FIELD) .attachPasswordAutoFillHelper(autoFillHelper) ) diff --git a/feature/registration/src/test/java/org/signal/registration/screens/signallogincredentials/SignalLoginCredentialEntryScreenTest.kt b/feature/registration/src/test/java/org/signal/registration/screens/signallogincredentials/SignalLoginCredentialEntryScreenTest.kt index 567205dc43..676ca782eb 100644 --- a/feature/registration/src/test/java/org/signal/registration/screens/signallogincredentials/SignalLoginCredentialEntryScreenTest.kt +++ b/feature/registration/src/test/java/org/signal/registration/screens/signallogincredentials/SignalLoginCredentialEntryScreenTest.kt @@ -6,6 +6,9 @@ package org.signal.registration.screens.signallogincredentials import android.app.Application +import androidx.compose.ui.autofill.ContentType +import androidx.compose.ui.semantics.SemanticsProperties +import androidx.compose.ui.semantics.getOrNull import androidx.compose.ui.test.assertIsEnabled import androidx.compose.ui.test.assertIsNotEnabled import androidx.compose.ui.test.junit4.createComposeRule @@ -16,6 +19,7 @@ import androidx.compose.ui.test.performTextInput import androidx.test.core.app.ApplicationProvider import assertk.assertThat import assertk.assertions.contains +import assertk.assertions.isEqualTo import io.mockk.coEvery import io.mockk.coVerify import io.mockk.every @@ -78,6 +82,20 @@ class SignalLoginCredentialEntryScreenTest { coVerify(exactly = 0) { SignalCredentialManager.getCredential(any()) } } + @Test + fun `the account ID field is tagged for autofill as the username`() { + setContent(SignalLoginCredentialEntryState()) + + assertThat(contentTypeOf(TestTags.SIGNAL_LOGIN_CREDENTIAL_ACCOUNT_ID_FIELD)).isEqualTo(ContentType.Username) + } + + @Test + fun `the recovery key field is tagged for autofill as the password`() { + setContent(SignalLoginCredentialEntryState()) + + assertThat(contentTypeOf(TestTags.SIGNAL_LOGIN_CREDENTIAL_RECOVERY_KEY_FIELD)).isEqualTo(ContentType.Password) + } + @Test fun `when text is typed into the account ID field, AccountIdChanged is emitted`() { setContent(SignalLoginCredentialEntryState()) @@ -165,6 +183,10 @@ class SignalLoginCredentialEntryScreenTest { composeTestRule.onNodeWithTag(TestTags.SIGNAL_LOGIN_CREDENTIAL_NEXT_BUTTON).assertIsNotEnabled() } + private fun contentTypeOf(tag: String): ContentType? { + return composeTestRule.onNodeWithTag(tag).fetchSemanticsNode().config.getOrNull(SemanticsProperties.ContentType) + } + private fun stubPasswordManager() { mockkObject(SignalCredentialManager) every { SignalCredentialManager.isSupported(any()) } returns true