From f18437e59fc2e8bc8388e88b4848c871be24faf0 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sun, 1 Jan 2023 12:25:05 +0100 Subject: [PATCH] android: Close soft keyboard on panel close in cheats activity (#6234) This prevents the keyboard from being stuck in an open state if the user slides the panel while focused on a text box. Now it closes gracefully. Co-authored-by: Charles Lombardo --- .../citra/citra_emu/ui/TwoPaneOnBackPressedCallback.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/android/app/src/main/java/org/citra/citra_emu/ui/TwoPaneOnBackPressedCallback.java b/src/android/app/src/main/java/org/citra/citra_emu/ui/TwoPaneOnBackPressedCallback.java index d07fe30d8..84ddf1439 100644 --- a/src/android/app/src/main/java/org/citra/citra_emu/ui/TwoPaneOnBackPressedCallback.java +++ b/src/android/app/src/main/java/org/citra/citra_emu/ui/TwoPaneOnBackPressedCallback.java @@ -1,6 +1,8 @@ package org.citra.citra_emu.ui; +import android.content.Context; import android.view.View; +import android.view.inputmethod.InputMethodManager; import androidx.activity.OnBackPressedCallback; import androidx.annotation.NonNull; @@ -32,6 +34,13 @@ public class TwoPaneOnBackPressedCallback extends OnBackPressedCallback @Override public void onPanelClosed(@NonNull View panel) { + closeKeyboard(); setEnabled(false); } + + private void closeKeyboard() { + InputMethodManager manager = (InputMethodManager) mSlidingPaneLayout.getContext() + .getSystemService(Context.INPUT_METHOD_SERVICE); + manager.hideSoftInputFromWindow(mSlidingPaneLayout.getRootView().getWindowToken(), 0); + } }