diff --git a/app/src/main/java/net/gsantner/markor/frontend/textview/HighlightingEditor.java b/app/src/main/java/net/gsantner/markor/frontend/textview/HighlightingEditor.java index b2b58424f6..7b828ffe5d 100644 --- a/app/src/main/java/net/gsantner/markor/frontend/textview/HighlightingEditor.java +++ b/app/src/main/java/net/gsantner/markor/frontend/textview/HighlightingEditor.java @@ -428,7 +428,7 @@ public void insertOrReplaceTextOnCursor(final String newText) { if (newCursorPos >= 0) { setSelection(sel[0] + newCursorPos); - TextViewUtils.showSelection(this); + postDelayed(() -> TextViewUtils.showSelection(this), 500); } } } diff --git a/app/src/main/java/net/gsantner/markor/frontend/textview/TextViewUtils.java b/app/src/main/java/net/gsantner/markor/frontend/textview/TextViewUtils.java index 889d2debf8..1f75c1827b 100644 --- a/app/src/main/java/net/gsantner/markor/frontend/textview/TextViewUtils.java +++ b/app/src/main/java/net/gsantner/markor/frontend/textview/TextViewUtils.java @@ -728,7 +728,10 @@ public static boolean isViewVisible(final View view) { // Check if keyboard open. Only available after android 11 :( public static Boolean isImeOpen(final View view) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { - return view.getRootWindowInsets().isVisible(WindowInsets.Type.ime()); + final WindowInsets insets = view.getRootWindowInsets(); + if (insets != null) { + insets.isVisible(WindowInsets.Type.ime()); + } } return null; // Uncertain }