Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions pythonforandroid/recipes/android/src/android/display_cutout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading