summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--java/org/gnu/emacs/EmacsService.java10
-rw-r--r--lisp/subr.el6
-rw-r--r--src/android.c16
-rw-r--r--src/android.h2
-rw-r--r--src/androidfns.c20
5 files changed, 53 insertions, 1 deletions
diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java
index 5cb1ceca0aa..93e34e6e694 100644
--- a/java/org/gnu/emacs/EmacsService.java
+++ b/java/org/gnu/emacs/EmacsService.java
@@ -60,6 +60,7 @@ import android.content.UriPermission;
import android.content.pm.PackageManager;
import android.content.res.AssetManager;
+import android.content.res.Configuration;
import android.hardware.input.InputManager;
@@ -581,6 +582,15 @@ public final class EmacsService extends Service
return false;
}
+ public boolean
+ detectKeyboard ()
+ {
+ Configuration configuration;
+
+ configuration = getResources ().getConfiguration ();
+ return configuration.keyboard != Configuration.KEYBOARD_NOKEYS;
+ }
+
public String
nameKeysym (int keysym)
{
diff --git a/lisp/subr.el b/lisp/subr.el
index 582415a9761..e53ef505522 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -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))
diff --git a/src/android.c b/src/android.c
index 4a74f5b2af4..2c0e4f845f4 100644
--- a/src/android.c
+++ b/src/android.c
@@ -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)
diff --git a/src/android.h b/src/android.h
index 2f5f32037c5..bd19c4d9ac8 100644
--- a/src/android.h
+++ b/src/android.h
@@ -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;
diff --git a/src/androidfns.c b/src/androidfns.c
index eaecb78338b..48c3f3046d6 100644
--- a/src/androidfns.c
+++ b/src/androidfns.c
@@ -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);