这是indexloc提供的服务,不要输入任何密码
Skip to content

Commit 30a58d7

Browse files
Fixed: Fix NullPointerException triggered when trying to show keyboard without dialog view in focus by pressing outside of bottom sheets dialog
`termux-dialog sheet -v 'Item One','Item Two'` ``` java.lang.NullPointerException: Attempt to invoke virtual method 'android.os.IBinder android.view.View.getWindowToken()' on a null object reference at android.view.inputmethod.InputMethodManager.showSoftInput(InputMethodManager.java:1668) at android.view.inputmethod.InputMethodManager.showSoftInput(InputMethodManager.java:1592) at com.termux.api.apis.DialogAPI$DialogActivity$BottomSheetInputMethod.showKeyboard(DialogAPI.java:719) at com.termux.api.apis.DialogAPI$DialogActivity$BottomSheetInputMethod$1.cancel(DialogAPI.java:666) at com.google.android.material.bottomsheet.BottomSheetDialog$2.onClick(BottomSheetDialog.java:327) ``` Closes #486
1 parent ea5c14b commit 30a58d7

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

app/src/main/java/com/termux/api/apis/DialogAPI.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import com.termux.shared.termux.theme.TermuxThemeUtils;
5151
import com.termux.shared.theme.NightMode;
5252
import com.termux.shared.theme.ThemeUtils;
53+
import com.termux.shared.view.KeyboardUtils;
5354

5455
import java.text.SimpleDateFormat;
5556
import java.util.ArrayList;
@@ -712,15 +713,11 @@ public void setupDialog(final Dialog dialog, int style) {
712713
*/
713714

714715
protected void hideKeyboard() {
715-
Objects.requireNonNull(getDialog()).getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
716+
KeyboardUtils.setSoftKeyboardAlwaysHiddenFlags(getActivity());
716717
}
717718

718719
protected void showKeyboard() {
719-
getInputMethodManager().showSoftInput(getView(), InputMethodManager.SHOW_FORCED);
720-
}
721-
722-
protected InputMethodManager getInputMethodManager() {
723-
return (InputMethodManager) requireContext().getSystemService(Context.INPUT_METHOD_SERVICE);
720+
KeyboardUtils.showSoftKeyboard(getActivity(), getView());
724721
}
725722

726723
/**

0 commit comments

Comments
 (0)