@@ -55,6 +55,7 @@ import android.view.WindowManager
5555import android.view.inputmethod.BaseInputConnection
5656import android.widget.CheckBox
5757import android.widget.EditText
58+ import android.widget.Toast
5859import kotlinx.coroutines.Dispatchers
5960import kotlinx.coroutines.runBlocking
6061import kotlinx.coroutines.withContext
@@ -1384,6 +1385,8 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
13841385 max = Math .max(0 , Math .max(selectionStart, selectionEnd))
13851386 }
13861387
1388+ var clipboardIdentifier = resources.getIdentifier(" android:id/clipboard" , " id" , context.packageName)
1389+
13871390 when (id) {
13881391 android.R .id.paste -> paste(text, min, max)
13891392 android.R .id.pasteAsPlainText -> paste(text, min, max, true )
@@ -1400,7 +1403,17 @@ open class AztecText : AppCompatEditText, TextWatcher, UnknownHtmlSpan.OnUnknown
14001403 deleteInlineStyleFromTheBeginning()
14011404 }
14021405 }
1403- else -> return super .onTextContextMenuItem(id)
1406+ // Fix for crash when pasting text on Samsung Devices running Android 8.
1407+ // Ref: https://github.com/wordpress-mobile/WordPress-Android/issues/8827
1408+ clipboardIdentifier -> {
1409+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O && Build .VERSION .SDK_INT < 28
1410+ && Build .MANUFACTURER .toLowerCase().equals(" samsung" )) {
1411+ // Nope return true
1412+ Toast .makeText(context, R .string.samsung_disabled_custom_clipboard, Toast .LENGTH_LONG ).show()
1413+ } else {
1414+ return super .onTextContextMenuItem(id)
1415+ }
1416+ } else -> return super .onTextContextMenuItem(id)
14041417 }
14051418
14061419 return true
0 commit comments