diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinPresenter.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinPresenter.kt index e72e636ed4..957594c0f7 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinPresenter.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinPresenter.kt @@ -25,12 +25,14 @@ import io.element.android.features.lockscreen.impl.create.model.PinEntry import io.element.android.features.lockscreen.impl.create.validation.CreatePinFailure import io.element.android.features.lockscreen.impl.create.validation.PinValidator import io.element.android.libraries.architecture.Presenter +import io.element.android.libraries.core.meta.BuildMeta import javax.inject.Inject private const val PIN_SIZE = 4 class CreatePinPresenter @Inject constructor( private val pinValidator: PinValidator, + private val buildMeta: BuildMeta, ) : Presenter { @Composable @@ -94,6 +96,7 @@ class CreatePinPresenter @Inject constructor( confirmPinEntry = confirmPinEntry, isConfirmationStep = isConfirmationStep, createPinFailure = createPinFailure, + appName = buildMeta.applicationName, eventSink = ::handleEvents ) } diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinState.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinState.kt index 5bb632f04e..020076a2ab 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinState.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinState.kt @@ -24,6 +24,7 @@ data class CreatePinState( val confirmPinEntry: PinEntry, val isConfirmationStep: Boolean, val createPinFailure: CreatePinFailure?, + val appName: String, val eventSink: (CreatePinEvents) -> Unit ) { val pinSize = choosePinEntry.size diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinStateProvider.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinStateProvider.kt index 543360f91e..c9dcce018d 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinStateProvider.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinStateProvider.kt @@ -55,6 +55,7 @@ fun aCreatePinState( confirmPinEntry = confirmPinEntry, isConfirmationStep = isConfirmationStep, createPinFailure = creationFailure, + appName = "Element", eventSink = {} ) diff --git a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinView.kt b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinView.kt index cddadbbae9..063d65f41f 100644 --- a/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinView.kt +++ b/features/lockscreen/impl/src/main/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinView.kt @@ -25,7 +25,6 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.consumeWindowInsets -import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.padding @@ -38,14 +37,12 @@ import androidx.compose.foundation.verticalScroll import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Lock import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.text.input.TextFieldValue -import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.unit.dp import io.element.android.features.lockscreen.impl.R @@ -89,7 +86,7 @@ fun CreatePinView( .verticalScroll(state = scrollState) .padding(vertical = 16.dp, horizontal = 20.dp), ) { - CreatePinHeader(state.isConfirmationStep, state.pinSize) + CreatePinHeader(state.isConfirmationStep, state.appName) CreatePinContent(state) } } @@ -99,7 +96,7 @@ fun CreatePinView( @Composable private fun CreatePinHeader( isValidationStep: Boolean, - pinSize: Int, + appName: String, modifier: Modifier = Modifier, ) { Column( @@ -110,18 +107,11 @@ private fun CreatePinHeader( title = if (isValidationStep) { stringResource(id = R.string.screen_app_lock_setup_confirm_pin) } else { - stringResource(id = R.string.screen_app_lock_setup_choose_pin, pinSize) + stringResource(id = R.string.screen_app_lock_setup_choose_pin) }, - subTitle = stringResource(id = R.string.screen_app_lock_setup_pin_context), + subTitle = stringResource(id = R.string.screen_app_lock_setup_pin_context, appName), iconImageVector = Icons.Filled.Lock, ) - Text( - text = stringResource(id = R.string.screen_app_lock_setup_pin_context_warning), - modifier = Modifier.padding(top = 24.dp), - textAlign = TextAlign.Center, - style = ElementTheme.typography.fontBodyMdRegular, - color = MaterialTheme.colorScheme.secondary, - ) } } diff --git a/features/lockscreen/impl/src/main/res/values/localazy.xml b/features/lockscreen/impl/src/main/res/values/localazy.xml index fb5c2be73c..6b12eac427 100644 --- a/features/lockscreen/impl/src/main/res/values/localazy.xml +++ b/features/lockscreen/impl/src/main/res/values/localazy.xml @@ -10,12 +10,13 @@ "Remove PIN" "Are you sure you want to remove PIN?" "Remove PIN?" - "Choose %1$d digit PIN" + "Choose PIN" "Confirm PIN" "You cannot choose this as your PIN code for security reasons" "Choose a different PIN" - "Lock Element to add extra security to your chats." - "Choose something memorable. If you forget this PIN, you will be logged out of the app." + "Lock %1$s to add extra security to your chats. + +Choose something memorable. If you forget this PIN, you will be logged out of the app." "Please enter the same PIN twice" "PINs don\'t match" "You’ll need to re-login and create a new PIN to proceed" diff --git a/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinPresenterTest.kt b/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinPresenterTest.kt index c1af14f519..78536bb693 100644 --- a/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinPresenterTest.kt +++ b/features/lockscreen/impl/src/test/kotlin/io/element/android/features/lockscreen/impl/create/CreatePinPresenterTest.kt @@ -24,6 +24,7 @@ import io.element.android.features.lockscreen.impl.create.model.PinDigit import io.element.android.features.lockscreen.impl.create.model.PinEntry import io.element.android.features.lockscreen.impl.create.validation.CreatePinFailure import io.element.android.features.lockscreen.impl.create.validation.PinValidator +import io.element.android.libraries.matrix.test.core.aBuildMeta import io.element.android.tests.testutils.awaitLastSequentialItem import kotlinx.coroutines.test.runTest import org.junit.Test @@ -108,6 +109,6 @@ class CreatePinPresenterTest { } private fun createCreatePinPresenter(): CreatePinPresenter { - return CreatePinPresenter(PinValidator()) + return CreatePinPresenter(PinValidator(), aBuildMeta()) } }