Repository: florisboard/florisboard
Issue: Keyboard crash when click on PASTE button!

copy some content then open Text Editor suddenly Florisboard is crashing when when goto text editor and press on Paste button!

Android: 10

Device: Realme X2 Pro

FlorisBoard: 3.10.beta05


~~~ 1617590290636.stacktrace ~~~

java.lang.NullPointerException
	at dev.patrickgold.florisboard.ime.core.EditorInstance.performClipboardPaste(EditorInstance.kt:438)
	at dev.patrickgold.florisboard.ime.text.TextInputManager.onInputKeyUp(TextInputManager.kt:708)
	at dev.patrickgold.florisboard.ime.core.InputEventDispatcher$1$3.invokeSuspend(InputEventDispatcher.kt:125)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at android.os.Handler.handleCallback(Handler.java:883)
	at android.os.Handler.dispatchMessage(Handler.java:100)
	at android.os.Looper.loop(Looper.java:227)
	at android.app.ActivityThread.main(ActivityThread.java:7842)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980)


Changed files:
app/src/main/java/dev/patrickgold/florisboard/ime/text/editing/EditingKeyboardView.kt

diff --git a/app/src/main/java/dev/patrickgold/florisboard/ime/text/editing/EditingKeyboardView.kt b/app/src/main/java/dev/patrickgold/florisboard/ime/text/editing/EditingKeyboardView.kt
index 885029a1..83f82a6e 100644
--- a/app/src/main/java/dev/patrickgold/florisboard/ime/text/editing/EditingKeyboardView.kt
+++ b/app/src/main/java/dev/patrickgold/florisboard/ime/text/editing/EditingKeyboardView.kt
@@ -21,6 +21,7 @@ import android.util.AttributeSet
 import android.view.View
 import androidx.constraintlayout.widget.ConstraintLayout
 import dev.patrickgold.florisboard.R
+import dev.patrickgold.florisboard.ime.clip.FlorisClipboardManager
 import dev.patrickgold.florisboard.ime.core.FlorisBoard
 import dev.patrickgold.florisboard.ime.theme.Theme
 import dev.patrickgold.florisboard.ime.theme.ThemeManager
@@ -55,6 +56,9 @@ class EditingKeyboardView : ConstraintLayout, FlorisBoard.EventListener,
         cutKey = findViewById(R.id.clipboard_cut)
         copyKey = findViewById(R.id.clipboard_copy)
         pasteKey = findViewById(R.id.clipboard_paste)
+
+        val clipboardManager = FlorisClipboardManager.getInstance()
+        pasteKey?.isEnabled = clipboardManager.canBePasted(clipboardManager.primaryClip)
     }
 
     override fun onDetachedFromWindow() {
@@ -80,11 +84,8 @@ class EditingKeyboardView : ConstraintLayout, FlorisBoard.EventListener,
             else -> View.GONE
         }
         copyKey?.isEnabled = isSelectionActive
-        pasteKey?.isEnabled =
-            florisboard?.florisClipboardManager?.hasPrimaryClip() == true &&
-                florisboard.activeEditorInstance.contentMimeTypes?.any {
-                    florisboard.florisClipboardManager!!.primaryClip?.mimeTypes?.contains(it) ?: false
-                } == true
+        val clipboardManager = FlorisClipboardManager.getInstance()
+        pasteKey?.isEnabled = clipboardManager.canBePasted(clipboardManager.primaryClip)
     }
 
     override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {