Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problème de copie du code de récupération après génération #954

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/953.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Problème de copie du code de récupération après génération
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand All @@ -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,
Expand Down
Loading