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 <clombardo169@gmail.com>
This commit is contained in:
JosJuice 2023-01-01 12:25:05 +01:00 committed by GitHub
parent b588d6181b
commit f18437e59f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -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);
}
}