From c27264761dbb7d905f9768ae483f9815322eff83 Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 2 Apr 2020 18:11:22 +0200 Subject: [PATCH] Back /Skip navigation --- .../crypto/recover/BootstrapBottomSheet.kt | 16 ++++++++++++++++ .../recover/BootstrapSaveRecoveryKeyFragment.kt | 4 ++-- .../crypto/recover/BootstrapSharedViewModel.kt | 13 +++++++++++++ .../crypto/recover/BootstrapViewEvents.kt | 12 +----------- .../res/layout/fragment_bootstrap_conclusion.xml | 2 +- vector/src/main/res/values/strings_riotX.xml | 4 +++- 6 files changed, 36 insertions(+), 15 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapBottomSheet.kt b/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapBottomSheet.kt index d9ca97a830..6812997ffa 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapBottomSheet.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapBottomSheet.kt @@ -66,10 +66,26 @@ class BootstrapBottomSheet : VectorBaseBottomSheetDialogFragment() { BootstrapViewEvents.RecoveryKeySaved -> { KeepItSafeDialog().show(requireActivity()) } + BootstrapViewEvents.SkipBootstrap -> { + promptSkip() + } } } } + private fun promptSkip() { + AlertDialog.Builder(requireActivity()) + .setTitle(R.string.are_you_sure) + .setMessage(R.string.bootstrap_skip_text) + .setPositiveButton(R.string._continue, null) + .setNeutralButton(R.string.generate_message_key) { _, _ -> + } + .setNegativeButton(R.string.skip) { _, _ -> + dismiss() + } + .show() + } + override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { val rootView = super.onCreateView(inflater, container, savedInstanceState) dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE) diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapSaveRecoveryKeyFragment.kt b/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapSaveRecoveryKeyFragment.kt index ccd6017613..05c6f7a53f 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapSaveRecoveryKeyFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapSaveRecoveryKeyFragment.kt @@ -57,7 +57,7 @@ class BootstrapSaveRecoveryKeyFragment @Inject constructor( .colorizeMatchingText(getString(R.string.message_key), colorProvider.getColorFromAttribute(android.R.attr.textColorLink)) recoverySave.clickableView.clicks() - .debounce(300, TimeUnit.MILLISECONDS) + .debounce(600, TimeUnit.MILLISECONDS) .observeOn(AndroidSchedulers.mainThread()) .subscribe { downloadRecoveryKey() @@ -65,7 +65,7 @@ class BootstrapSaveRecoveryKeyFragment @Inject constructor( .disposeOnDestroyView() recoveryCopy.clickableView.clicks() - .debounce(300, TimeUnit.MILLISECONDS) + .debounce(600, TimeUnit.MILLISECONDS) .observeOn(AndroidSchedulers.mainThread()) .subscribe { shareRecoveryKey() diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapSharedViewModel.kt b/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapSharedViewModel.kt index db714ba2f0..0e9395468f 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapSharedViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapSharedViewModel.kt @@ -296,6 +296,8 @@ class BootstrapSharedViewModel @AssistedInject constructor( private fun queryBack() = withState { state -> when (state.step) { is BootstrapStep.SetupPassphrase -> { + // do we let you cancel from here? + _viewEvents.post(BootstrapViewEvents.SkipBootstrap) } is BootstrapStep.ConfirmPassphrase -> { setState { @@ -306,6 +308,17 @@ class BootstrapSharedViewModel @AssistedInject constructor( ) } } + is BootstrapStep.AccountPassword -> { + _viewEvents.post(BootstrapViewEvents.SkipBootstrap) + } + BootstrapStep.Initializing -> { + // do we let you cancel from here? + _viewEvents.post(BootstrapViewEvents.SkipBootstrap) + } + is BootstrapStep.SaveRecoveryKey, + BootstrapStep.DoneSuccess -> { + // nop + } } } diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapViewEvents.kt b/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapViewEvents.kt index 524112f8bb..efac9c9e34 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapViewEvents.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/recover/BootstrapViewEvents.kt @@ -20,17 +20,7 @@ import im.vector.riotx.core.platform.VectorViewEvents sealed class BootstrapViewEvents : VectorViewEvents { object Dismiss : BootstrapViewEvents() -// data class RequestPassword(val sessionId: String, val userId: String) : BootstrapViewEvents() data class ModalError(val error: String) : BootstrapViewEvents() object RecoveryKeySaved: BootstrapViewEvents() -// data class Failure(val throwable: Throwable) : DevicesViewEvents() -// -// object RequestPassword : DevicesViewEvents() -// -// data class PromptRenameDevice(val deviceInfo: DeviceInfo) : DevicesViewEvents() -// -// data class ShowVerifyDevice( -// val userId: String, -// val transactionId: String? -// ) : DevicesViewEvents() + object SkipBootstrap: BootstrapViewEvents() } diff --git a/vector/src/main/res/layout/fragment_bootstrap_conclusion.xml b/vector/src/main/res/layout/fragment_bootstrap_conclusion.xml index f78289da7f..37e7292366 100644 --- a/vector/src/main/res/layout/fragment_bootstrap_conclusion.xml +++ b/vector/src/main/res/layout/fragment_bootstrap_conclusion.xml @@ -37,7 +37,7 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="50dp" - app:actionTitle="@string/_continue" + app:actionTitle="@string/finish" app:forceStartPadding="false" app:rightIcon="@drawable/ic_arrow_right" app:tint="?colorAccent" /> diff --git a/vector/src/main/res/values/strings_riotX.xml b/vector/src/main/res/values/strings_riotX.xml index 6a33492e8b..c875cb9ea9 100644 --- a/vector/src/main/res/values/strings_riotX.xml +++ b/vector/src/main/res/values/strings_riotX.xml @@ -39,6 +39,7 @@ Set a %s + Generate a Message Key Confirm %s @@ -59,6 +60,7 @@ Your recovery key You‘re done! Keep it safe + Finish Use this %1$s as a safety net in case you forget your %2$s. @@ -81,7 +83,7 @@ You cannot do that from mobile - + Setting a Message Password lets you secure & unlock encrypted messages and trust.\n\nIf you don’t want to set a Message Password, generate a Message Key instead.