Add 'create a pin' button to backups sub pin entry sheet.
This commit is contained in:
parent
b9da045f79
commit
16a732171a
4 changed files with 38 additions and 9 deletions
|
@ -1105,6 +1105,7 @@
|
||||||
|
|
||||||
<activity android:name=".components.settings.app.subscription.donate.CheckoutFlowActivity"
|
<activity android:name=".components.settings.app.subscription.donate.CheckoutFlowActivity"
|
||||||
android:theme="@style/Theme.Signal.DayNight.NoActionBar"
|
android:theme="@style/Theme.Signal.DayNight.NoActionBar"
|
||||||
|
android:windowSoftInputMode="adjustResize"
|
||||||
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
|
android:configChanges="touchscreen|keyboard|keyboardHidden|orientation|screenLayout|screenSize"
|
||||||
android:exported="false"/>
|
android:exported="false"/>
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.lifecycle.compose.LocalLifecycleOwner
|
||||||
import androidx.navigation.compose.composable
|
import androidx.navigation.compose.composable
|
||||||
import androidx.navigation.compose.rememberNavController
|
import androidx.navigation.compose.rememberNavController
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
|
@ -23,6 +24,7 @@ import org.thoughtcrime.securesms.components.settings.app.subscription.donate.In
|
||||||
import org.thoughtcrime.securesms.compose.ComposeFragment
|
import org.thoughtcrime.securesms.compose.ComposeFragment
|
||||||
import org.thoughtcrime.securesms.compose.Nav
|
import org.thoughtcrime.securesms.compose.Nav
|
||||||
import org.thoughtcrime.securesms.database.InAppPaymentTable
|
import org.thoughtcrime.securesms.database.InAppPaymentTable
|
||||||
|
import org.thoughtcrime.securesms.lock.v2.CreateSvrPinActivity
|
||||||
import org.thoughtcrime.securesms.util.navigation.safeNavigate
|
import org.thoughtcrime.securesms.util.navigation.safeNavigate
|
||||||
import org.thoughtcrime.securesms.util.viewModel
|
import org.thoughtcrime.securesms.util.viewModel
|
||||||
|
|
||||||
|
@ -57,14 +59,19 @@ class MessageBackupsFlowFragment : ComposeFragment(), InAppPaymentCheckoutDelega
|
||||||
skipPartiallyExpanded = true
|
skipPartiallyExpanded = true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val lifecycleOwner = LocalLifecycleOwner.current
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
navController.setLifecycleOwner(this@MessageBackupsFlowFragment)
|
navController.setLifecycleOwner(this@MessageBackupsFlowFragment)
|
||||||
|
|
||||||
requireActivity().onBackPressedDispatcher.addCallback(object : OnBackPressedCallback(true) {
|
requireActivity().onBackPressedDispatcher.addCallback(
|
||||||
|
lifecycleOwner,
|
||||||
|
object : OnBackPressedCallback(true) {
|
||||||
override fun handleOnBackPressed() {
|
override fun handleOnBackPressed() {
|
||||||
viewModel.goToPreviousScreen()
|
viewModel.goToPreviousScreen()
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
Nav.Host(
|
Nav.Host(
|
||||||
|
@ -95,7 +102,8 @@ class MessageBackupsFlowFragment : ComposeFragment(), InAppPaymentCheckoutDelega
|
||||||
onPinChanged = viewModel::onPinEntryUpdated,
|
onPinChanged = viewModel::onPinEntryUpdated,
|
||||||
pinKeyboardType = state.pinKeyboardType,
|
pinKeyboardType = state.pinKeyboardType,
|
||||||
onPinKeyboardTypeSelected = viewModel::onPinKeyboardTypeUpdated,
|
onPinKeyboardTypeSelected = viewModel::onPinKeyboardTypeUpdated,
|
||||||
onNextClick = viewModel::goToNextScreen
|
onNextClick = viewModel::goToNextScreen,
|
||||||
|
onCreateNewPinClick = this@MessageBackupsFlowFragment::createANewPin
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,6 +196,11 @@ class MessageBackupsFlowFragment : ComposeFragment(), InAppPaymentCheckoutDelega
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun createANewPin() {
|
||||||
|
viewModel.onPinEntryUpdated("")
|
||||||
|
startActivity(CreateSvrPinActivity.getIntentForPinChangeFromSettings(requireContext()))
|
||||||
|
}
|
||||||
|
|
||||||
private fun cancelSubscription() {
|
private fun cancelSubscription() {
|
||||||
findNavController().safeNavigate(
|
findNavController().safeNavigate(
|
||||||
MessageBackupsFlowFragmentDirections.actionDonateToSignalFragmentToStripePaymentInProgressFragment(
|
MessageBackupsFlowFragmentDirections.actionDonateToSignalFragmentToStripePaymentInProgressFragment(
|
||||||
|
|
|
@ -7,6 +7,8 @@ package org.thoughtcrime.securesms.backup.v2.ui.subscription
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
|
@ -54,7 +56,8 @@ fun MessageBackupsPinConfirmationScreen(
|
||||||
onPinChanged: (String) -> Unit,
|
onPinChanged: (String) -> Unit,
|
||||||
pinKeyboardType: PinKeyboardType,
|
pinKeyboardType: PinKeyboardType,
|
||||||
onPinKeyboardTypeSelected: (PinKeyboardType) -> Unit,
|
onPinKeyboardTypeSelected: (PinKeyboardType) -> Unit,
|
||||||
onNextClick: () -> Unit
|
onNextClick: () -> Unit,
|
||||||
|
onCreateNewPinClick: () -> Unit
|
||||||
) {
|
) {
|
||||||
val focusRequester = remember { FocusRequester() }
|
val focusRequester = remember { FocusRequester() }
|
||||||
Surface {
|
Surface {
|
||||||
|
@ -139,12 +142,21 @@ fun MessageBackupsPinConfirmationScreen(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Box(
|
Row(
|
||||||
contentAlignment = Alignment.BottomEnd,
|
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.padding(vertical = 16.dp)
|
.padding(vertical = 16.dp)
|
||||||
) {
|
) {
|
||||||
|
if (isPinIncorrect) {
|
||||||
|
TextButton(onClick = onCreateNewPinClick) {
|
||||||
|
Text(
|
||||||
|
text = stringResource(id = R.string.MessageBackupsPinConfirmationScreen__create_new_pin)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.weight(1f))
|
||||||
|
|
||||||
Buttons.LargeTonal(
|
Buttons.LargeTonal(
|
||||||
onClick = onNextClick
|
onClick = onNextClick
|
||||||
) {
|
) {
|
||||||
|
@ -171,7 +183,8 @@ private fun MessageBackupsPinConfirmationScreenPreview() {
|
||||||
onPinChanged = {},
|
onPinChanged = {},
|
||||||
pinKeyboardType = PinKeyboardType.ALPHA_NUMERIC,
|
pinKeyboardType = PinKeyboardType.ALPHA_NUMERIC,
|
||||||
onPinKeyboardTypeSelected = {},
|
onPinKeyboardTypeSelected = {},
|
||||||
onNextClick = {}
|
onNextClick = {},
|
||||||
|
onCreateNewPinClick = {}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7346,6 +7346,8 @@
|
||||||
<string name="MessageBackupsPinConfirmationScreen__next">Next</string>
|
<string name="MessageBackupsPinConfirmationScreen__next">Next</string>
|
||||||
<!-- Action button to switch keyboard type -->
|
<!-- Action button to switch keyboard type -->
|
||||||
<string name="MessageBackupsPinConfirmationScreen__switch_keyboard">Switch keyboard</string>
|
<string name="MessageBackupsPinConfirmationScreen__switch_keyboard">Switch keyboard</string>
|
||||||
|
<!-- Action button to create a new pin if we type the incorrect one -->
|
||||||
|
<string name="MessageBackupsPinConfirmationScreen__create_new_pin">Create new pin</string>
|
||||||
|
|
||||||
<!-- MessageBackupsPinEducationScreen -->
|
<!-- MessageBackupsPinEducationScreen -->
|
||||||
<!-- Screen headline -->
|
<!-- Screen headline -->
|
||||||
|
|
Loading…
Add table
Reference in a new issue