Kivy working on ChromeOS and detetcting hardware keyboard on Android

159 views
Skip to first unread message

ZenCODE

unread,
Oct 18, 2017, 5:41:10 AM10/18/17
to Kivy users support
Hi all

To anyone with that question, yes, Kivy apps work very nicely on ChromeOS.

One consideration is that Chromebooks have a hardware keyboard. If you want to detect whether you android OS has a hardware keyboard, you can use the following. The ChromeBook keyboard will be detected.

Cheers


from jnius import autoclass, cast
# https://developer.android.com/reference/android/content/res/Configuration.html#keyboard
python_activity
= autoclass('org.renpy.android.PythonActivity')
current_activity
= cast('android.app.Activity',
                        python_activity
.mActivity)
config
= current_activity.getResources().getConfiguration()

if config.keyboard == 1:
   
Logger.info("Android - no hardware keyboard")
else:
   
Logger.info('Android hardware keyboard {0}. Hooking..'.format(
                config
.keyboard))



Dave McCormick

unread,
Oct 18, 2017, 7:14:11 AM10/18/17
to kivy-...@googlegroups.com
Thank you !  This will be handy. 

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ZenCODE

unread,
Oct 23, 2017, 3:47:06 AM10/23/17
to Kivy users support
Turns out you also need to consider whether the keyboard has been folded back, so the Chromebook acts as a tablet. If you request the keyboard then, it pops up the software keybaord. Here is a more complete example considering that.

    def _android_has_keyboard():
       
""" Return True if Android has a keyboard, False otherwise. """

       
from jnius import autoclass, cast
       
# https://developer.android.com/reference/android/content/res/Configuration.html#keyboard
        python_activity
= autoclass('org.renpy.android.PythonActivity')
        current_activity
= cast('android.app.Activity',
                                python_activity
.mActivity)
        config
= current_activity.getResources().getConfiguration()


       
if config.keyboard != 1 and config.hardKeyboardHidden != 2:
           
# For .keyboard:
           
#     KEYBOARD_UNDEFINED = 0
           
#     KEYBOARD_NOKEYS = 1
           
#     KEYBOARD_QWERTY = 2
           
# For .hardKeyboardHidden
           
#     HARDKEYBOARDHIDDEN_UNDEFINED = 0
           
#     HARDKEYBOARDHIDDEN_NO = 1
           
#     HARDKEYBOARDHIDDEN_YES = 2
           
#
           
# They have a keyboard and it's not hidden/folded back
           
return True
       
else:
           
return False


Damien Moore

unread,
Oct 24, 2017, 5:29:10 PM10/24/17
to Kivy users support
>To anyone with that question, yes, Kivy apps work very nicely on ChromeOS.

Interesting. How does one do this? I didn't think there was any way to get python, let alone kivy, in ChromeOS.

ZenCODE

unread,
Oct 25, 2017, 2:16:55 AM10/25/17
to Kivy users support
ChromeOS installs Android apps from the play store, so installing it is the same as installing on an Android device.

Damien Moore

unread,
Oct 27, 2017, 3:15:33 PM10/27/17
to Kivy users support
Ah, I have one of the older Chromebooks that didn't make the cut (Acer C720) despite quite clearly being capable of running android. (I have used Crouton and have run steam stuff.)

Is editing scripts and then running them on kivy launcher on an android-compatible chromebook a viable workflow? If so, I may eventually spring for a new model.

ZenCODE

unread,
Oct 27, 2017, 4:49:15 PM10/27/17
to Kivy users support
Maybe some simple things, but I don't think that is ideal for anything serious or long term. You really want to be able to run stuff immediately, and don't know of any decent mobile IDE's? Well, that's my feeling anyway. Nice hardware though, just wish they made it easier to run a proper linux distro....
Reply all
Reply to author
Forward
0 new messages