-
-
Save bmsleight/9f7da2360f856f8ca45c392be7e652ab to your computer and use it in GitHub Desktop.
Kivy App - Sticky hiding of navigation on Android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.app import App | |
from kivy.logger import Logger | |
try: | |
from jnius import autoclass | |
from android.runnable import run_on_ui_thread | |
android_api_version = autoclass('android.os.Build$VERSION') | |
AndroidView = autoclass('android.view.View') | |
AndroidPythonActivity = autoclass('org.renpy.android.PythonActivity') | |
Logger.debug( | |
'Application runs on Android, API level {0}'.format( | |
android_api_version.SDK_INT | |
) | |
) | |
except ImportError: | |
def run_on_ui_thread(func): | |
def wrapper(*args): | |
Logger.debug('{0} called on non android platform'.format( | |
func.__name__ | |
)) | |
return wrapper | |
class MyApp(App): | |
def on_start(self): | |
self.android_set_hide_menu() | |
def on_resume(self): | |
self.android_set_hide_menu() | |
@run_on_ui_thread | |
def android_set_hide_menu(self): | |
if android_api_version.SDK_INT >= 19: | |
Logger.debug('API >= 19. Set hide menu') | |
view = AndroidPythonActivity.mActivity.getWindow().getDecorView() | |
view.setSystemUiVisibility( | |
AndroidView.SYSTEM_UI_FLAG_LAYOUT_STABLE | | |
AndroidView.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | | |
AndroidView.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | | |
AndroidView.SYSTEM_UI_FLAG_HIDE_NAVIGATION | | |
AndroidView.SYSTEM_UI_FLAG_FULLSCREEN | | |
AndroidView.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment