diff --git a/changelog.d/953.bugfix b/changelog.d/953.bugfix new file mode 100644 index 0000000000..1eeaba5fdb --- /dev/null +++ b/changelog.d/953.bugfix @@ -0,0 +1 @@ +Problème de copie du code de récupération après génération diff --git a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSaveRecoveryKeyFragment.kt b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSaveRecoveryKeyFragment.kt index bed4d58b1e..f8750710e0 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSaveRecoveryKeyFragment.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSaveRecoveryKeyFragment.kt @@ -18,6 +18,9 @@ package im.vector.app.features.crypto.recover import android.app.Activity import android.content.ActivityNotFoundException +import android.content.ClipData +import android.content.ClipboardManager +import android.content.Context import android.content.Intent import android.os.Bundle import android.view.LayoutInflater @@ -93,7 +96,8 @@ class BootstrapSaveRecoveryKeyFragment : } private val copyStartForActivityResult = registerStartForActivityResult { activityResult -> - if (activityResult.resultCode == Activity.RESULT_OK) { + // Tchap : accept to close sheet even if result is RESULT_CANCELED. The Recovery code is in the clipboard. + if (activityResult.resultCode == Activity.RESULT_OK || activityResult.resultCode == Activity.RESULT_CANCELED) { // Tchap : Close the dialog without having to tap "Continue" sharedViewModel.handle(BootstrapActions.Completed) } @@ -103,6 +107,11 @@ class BootstrapSaveRecoveryKeyFragment : val recoveryKey = state.recoveryKeyCreationInfo?.recoveryKey?.formatRecoveryKey() ?: return@withState + // Tchap : copy recovery key to clipboard right now after "Copy" button is tapped. + val clipboard = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + val clip = ClipData.newPlainText("", recoveryKey) + clipboard.setPrimaryClip(clip) + startSharePlainTextIntent( requireContext(), copyStartForActivityResult,