Don't forcibly display dialogs on Android if a keyboard is present
* java/org/gnu/emacs/EmacsService.java (detectKeyboard): New function. * lisp/subr.el (use-dialog-box-p): Don't always return t if a keyboard is present on Android. * src/android.c (android_init_emacs_service): Link to new function. (android_detect_keyboard): New function. * src/android.h: Update prototypes. * src/androidfns.c (Fandroid_detect_keyboard) (syms_of_androidfns): New function.
This commit is contained in:
parent
cebd26b2e1
commit
0d2b712078
5 changed files with 53 additions and 1 deletions
|
@ -60,6 +60,7 @@
|
|||
import android.content.pm.PackageManager;
|
||||
|
||||
import android.content.res.AssetManager;
|
||||
import android.content.res.Configuration;
|
||||
|
||||
import android.hardware.input.InputManager;
|
||||
|
||||
|
@ -581,6 +582,15 @@ invocation of app_process (through android-emacs) can
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean
|
||||
detectKeyboard ()
|
||||
{
|
||||
Configuration configuration;
|
||||
|
||||
configuration = getResources ().getConfiguration ();
|
||||
return configuration.keyboard != Configuration.KEYBOARD_NOKEYS;
|
||||
}
|
||||
|
||||
public String
|
||||
nameKeysym (int keysym)
|
||||
{
|
||||
|
|
|
@ -3829,13 +3829,17 @@ confusing to some users.")
|
|||
|
||||
(defvar from--tty-menu-p nil
|
||||
"Non-nil means the current command was invoked from a TTY menu.")
|
||||
|
||||
(declare-function android-detect-keyboard "androidfns.c")
|
||||
|
||||
(defun use-dialog-box-p ()
|
||||
"Return non-nil if the current command should prompt the user via a dialog box."
|
||||
(and last-input-event ; not during startup
|
||||
(or (consp last-nonmenu-event) ; invoked by a mouse event
|
||||
(and (null last-nonmenu-event)
|
||||
(consp last-input-event))
|
||||
(featurep 'android) ; Prefer dialog boxes on Android.
|
||||
(and (featurep 'android) ; Prefer dialog boxes on Android.
|
||||
(not (android-detect-keyboard))) ; If no keyboard is connected.
|
||||
from--tty-menu-p) ; invoked via TTY menu
|
||||
use-dialog-box))
|
||||
|
||||
|
|
|
@ -1593,6 +1593,7 @@ android_init_emacs_service (void)
|
|||
FIND_METHOD (get_screen_width, "getScreenWidth", "(Z)I");
|
||||
FIND_METHOD (get_screen_height, "getScreenHeight", "(Z)I");
|
||||
FIND_METHOD (detect_mouse, "detectMouse", "()Z");
|
||||
FIND_METHOD (detect_keyboard, "detectKeyboard", "()Z");
|
||||
FIND_METHOD (name_keysym, "nameKeysym", "(I)Ljava/lang/String;");
|
||||
FIND_METHOD (browse_url, "browseUrl", "(Ljava/lang/String;Z)"
|
||||
"Ljava/lang/String;");
|
||||
|
@ -5626,6 +5627,21 @@ android_detect_mouse (void)
|
|||
return rc;
|
||||
}
|
||||
|
||||
bool
|
||||
android_detect_keyboard (void)
|
||||
{
|
||||
bool rc;
|
||||
jmethodID method;
|
||||
|
||||
method = service_class.detect_keyboard;
|
||||
rc = (*android_java_env)->CallNonvirtualBooleanMethod (android_java_env,
|
||||
emacs_service,
|
||||
service_class.class,
|
||||
method);
|
||||
android_exception_check ();
|
||||
return rc;
|
||||
}
|
||||
|
||||
void
|
||||
android_set_dont_focus_on_map (android_window handle,
|
||||
bool no_focus_on_map)
|
||||
|
|
|
@ -103,6 +103,7 @@ extern int android_get_screen_height (void);
|
|||
extern int android_get_mm_width (void);
|
||||
extern int android_get_mm_height (void);
|
||||
extern bool android_detect_mouse (void);
|
||||
extern bool android_detect_keyboard (void);
|
||||
|
||||
extern void android_set_dont_focus_on_map (android_window, bool);
|
||||
extern void android_set_dont_accept_focus (android_window, bool);
|
||||
|
@ -265,6 +266,7 @@ struct android_emacs_service
|
|||
jmethodID get_screen_width;
|
||||
jmethodID get_screen_height;
|
||||
jmethodID detect_mouse;
|
||||
jmethodID detect_keyboard;
|
||||
jmethodID name_keysym;
|
||||
jmethodID browse_url;
|
||||
jmethodID restart_emacs;
|
||||
|
|
|
@ -2476,6 +2476,25 @@ there is no mouse. */)
|
|||
#endif
|
||||
}
|
||||
|
||||
DEFUN ("android-detect-keyboard", Fandroid_detect_keyboard,
|
||||
Sandroid_detect_keyboard, 0, 0, 0,
|
||||
doc: /* Return whether a keyboard is connected.
|
||||
Return non-nil if a key is connected to this computer, or nil
|
||||
if there is no keyboard. */)
|
||||
(void)
|
||||
{
|
||||
#ifndef ANDROID_STUBIFY
|
||||
/* If no display connection is present, just return nil. */
|
||||
|
||||
if (!android_init_gui)
|
||||
return Qnil;
|
||||
|
||||
return android_detect_keyboard () ? Qt : Qnil;
|
||||
#else /* ANDROID_STUBIFY */
|
||||
return Qt;
|
||||
#endif /* ANDROID_STUBIFY */
|
||||
}
|
||||
|
||||
DEFUN ("android-toggle-on-screen-keyboard",
|
||||
Fandroid_toggle_on_screen_keyboard,
|
||||
Sandroid_toggle_on_screen_keyboard, 2, 2, 0,
|
||||
|
@ -3560,6 +3579,7 @@ language to be US English if LANGUAGE is empty. */);
|
|||
defsubr (&Sx_show_tip);
|
||||
defsubr (&Sx_hide_tip);
|
||||
defsubr (&Sandroid_detect_mouse);
|
||||
defsubr (&Sandroid_detect_keyboard);
|
||||
defsubr (&Sandroid_toggle_on_screen_keyboard);
|
||||
defsubr (&Sx_server_vendor);
|
||||
defsubr (&Sx_server_version);
|
||||
|
|
Loading…
Add table
Reference in a new issue