diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/internal/InternalSettingsFragment.kt b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/internal/InternalSettingsFragment.kt index 2ae038dec1..8d09293967 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/internal/InternalSettingsFragment.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/components/settings/app/internal/InternalSettingsFragment.kt @@ -245,6 +245,14 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter ) } + clickPref( + title = DSLSettingsText.from("Copy service password"), + summary = DSLSettingsText.from("Copy the password used to authenticate with the service."), + onClick = { + onCopyServicePasswordClicked() + } + ) + clickPref( title = DSLSettingsText.from("Unregister"), summary = DSLSettingsText.from("This will unregister your account without deleting it."), @@ -1147,6 +1155,24 @@ class InternalSettingsFragment : DSLSettingsFragment(R.string.preferences__inter .show() } + private fun onCopyServicePasswordClicked() { + val servicePassword = SignalStore.account.servicePassword + if (servicePassword == null) { + Toast.makeText(requireContext(), "No service password set!", Toast.LENGTH_SHORT).show() + return + } + + MaterialAlertDialogBuilder(requireContext()) + .setTitle("Copy service password?") + .setMessage("Your service password lets anyone who has it send messages as you on the service. Treat it like a password: don't paste it anywhere you don't fully trust. It will be cleared from the clipboard after ${Util.SENSITIVE_CLIPBOARD_TIMEOUT_SECONDS} seconds.") + .setPositiveButton("Copy") { _, _ -> + Util.copyToClipboardSensitive(requireContext(), servicePassword) + Toast.makeText(requireContext(), "Copied service password", Toast.LENGTH_SHORT).show() + } + .setNegativeButton(android.R.string.cancel, null) + .show() + } + private fun copyPaymentsDataToClipboard() { MaterialAlertDialogBuilder(requireContext()) .setMessage(