Skip to content

Commit 6f3ab80

Browse files
authored
Merge pull request #3171 from kuzeyron/more_cutout_tools
[Display-Cutout] Added missing features due to limitations
2 parents 64ce0f8 + 9e94695 commit 6f3ab80

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

pythonforandroid/recipes/android/src/android/display_cutout.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,20 @@ def get_heights_of_both_bars():
8080

8181
def get_cutout_mode():
8282
"""Return mode for cutout supported applications"""
83-
LayoutParams = autoclass('android.view.WindowManager$LayoutParams')
84-
window = mActivity.getWindow()
85-
layout_params = window.getAttributes()
86-
cutout_mode = layout_params.layoutInDisplayCutoutMode
87-
cutout_modes = {LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS: 'always',
88-
LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT: 'default',
89-
LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES: 'shortEdges'}
90-
91-
return cutout_modes.get(cutout_mode, 'never')
83+
BuildVersion = autoclass('android.os.Build$VERSION')
84+
cutout_modes = {}
85+
86+
if BuildVersion.SDK_INT >= 28:
87+
LayoutParams = autoclass('android.view.WindowManager$LayoutParams')
88+
window = mActivity.getWindow()
89+
layout_params = window.getAttributes()
90+
cutout_mode = layout_params.layoutInDisplayCutoutMode
91+
cutout_modes.update({LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT: 'default',
92+
LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES: 'shortEdges'})
93+
94+
if BuildVersion.SDK_INT >= 30:
95+
cutout_modes[LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS] = 'always'
96+
97+
return cutout_modes.get(cutout_mode, 'never')
98+
99+
return None

0 commit comments

Comments
 (0)