Skip to content

Commit

Permalink
Merge pull request #954 from tchapgouv/953-probleme-de-copie-du-code-…
Browse files Browse the repository at this point in the history
…de-recuperation-apres-generation

Problème de copie du code de récupération après génération
  • Loading branch information
NicolasBuquet authored Jul 26, 2023
2 parents 9c56064 + 7bed83c commit 02c5558
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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

0 comments on commit 02c5558

Please sign in to comment.