Skip to content

Commit 5d27bc1

Browse files
committed
More tools for the developer + minor changes
1 parent eaa1f79 commit 5d27bc1

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

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

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

8181
def get_cutout_mode():
8282
" Return mode for cutout supported applications "
83-
mode = 'never'
84-
85-
try:
86-
LayoutParams = autoclass('android.view.WindowManager$LayoutParams')
87-
window = mActivity.getWindow()
88-
layout_params = window.getAttributes()
89-
cutout_mode = layout_params.layoutInDisplayCutoutMode
90-
91-
if cutout_mode == LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS:
92-
mode = 'always'
93-
elif cutout_mode == LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_DEFAULT:
94-
mode = 'default'
95-
elif cutout_mode == LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES:
96-
mode = 'shortEdges'
97-
98-
except Exception:
99-
# Something went wrong
100-
pass
101-
102-
return mode
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')

0 commit comments

Comments
 (0)