Skip to content

Commit 9e94695

Browse files
committed
[Display-Cutout] Added missing features due to limitations
1 parent 64ce0f8 commit 9e94695

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy