From 02cadd5d33cdf4eb40ee8b0ae7771509705fe25f Mon Sep 17 00:00:00 2001 From: Nik Clayton Date: Fri, 30 Dec 2022 11:41:48 +0100 Subject: [PATCH] Ensure text content is always pasted as plain text (#3083) Fixes https://github.com/tuskyapp/Tusky/issues/3082. --- .../tusky/components/compose/view/EditTextTyped.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/EditTextTyped.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/EditTextTyped.kt index 2a1c7446..087a7035 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/view/EditTextTyped.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/view/EditTextTyped.kt @@ -63,4 +63,16 @@ class EditTextTyped @JvmOverloads constructor( editorInfo )!! } + + /** + * Override pasting to ensure that formatted content is always pasted as + * plain text. + */ + override fun onTextContextMenuItem(id: Int): Boolean { + if (id == android.R.id.paste) { + return super.onTextContextMenuItem(android.R.id.pasteAsPlainText) + } + + return super.onTextContextMenuItem(id) + } }