From 9e9469588b90c3087d3840c23adfa3332d5a4de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20Lindstr=C3=B6m?= Date: Sat, 12 Jul 2025 13:08:39 +0300 Subject: [PATCH] [Display-Cutout] Added missing features due to limitations --- .../android/src/android/display_cutout.py | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/pythonforandroid/recipes/android/src/android/display_cutout.py b/pythonforandroid/recipes/android/src/android/display_cutout.py index 09f89672da..a52868502d 100644 --- a/pythonforandroid/recipes/android/src/android/display_cutout.py +++ b/pythonforandroid/recipes/android/src/android/display_cutout.py @@ -80,12 +80,20 @@ def get_heights_of_both_bars(): def get_cutout_mode(): """Return mode for cutout supported applications""" - LayoutParams = autoclass('android.view.WindowManager$LayoutParams') - window = mActivity.getWindow() - layout_params = window.getAttributes() - cutout_mode = layout_params.layoutInDisplayCutoutMode - cutout_modes = {LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS: 'always', - LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT: 'default', - LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES: 'shortEdges'} - - return cutout_modes.get(cutout_mode, 'never') + BuildVersion = autoclass('android.os.Build$VERSION') + cutout_modes = {} + + if BuildVersion.SDK_INT >= 28: + LayoutParams = autoclass('android.view.WindowManager$LayoutParams') + window = mActivity.getWindow() + layout_params = window.getAttributes() + cutout_mode = layout_params.layoutInDisplayCutoutMode + cutout_modes.update({LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT: 'default', + LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES: 'shortEdges'}) + + if BuildVersion.SDK_INT >= 30: + cutout_modes[LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS] = 'always' + + return cutout_modes.get(cutout_mode, 'never') + + return None