4
4
from android import mActivity
5
5
6
6
__all__ = ('get_cutout_pos' , 'get_cutout_size' , 'get_width_of_bar' ,
7
- 'get_height_of_bar' , 'get_size_of_bar' )
7
+ 'get_height_of_bar' , 'get_size_of_bar' , 'get_width_of_bar' ,
8
+ 'get_cutout_mode' )
8
9
9
10
10
11
def _core_cutout ():
@@ -15,20 +16,20 @@ def _core_cutout():
15
16
16
17
17
18
def get_cutout_pos ():
18
- """ Get position of the display-cutout.
19
- Returns integer for each positions (xy)
19
+ """Get position of the display-cutout.
20
+ Returns integer for each positions (xy)
20
21
"""
21
22
try :
22
23
cutout = _core_cutout ()
23
- return int (cutout .left ), Window .height - int ( cutout .height ())
24
+ return int (cutout .left ), int ( Window .height - cutout .height ())
24
25
except Exception :
25
26
# Doesn't have a camera builtin with the display
26
27
return 0 , 0
27
28
28
29
29
30
def get_cutout_size ():
30
- """ Get the size (xy) of the front camera.
31
- Returns size with float values
31
+ """Get the size (xy) of the front camera.
32
+ Returns size with float values
32
33
"""
33
34
try :
34
35
cutout = _core_cutout ()
@@ -39,8 +40,8 @@ def get_cutout_size():
39
40
40
41
41
42
def get_height_of_bar (bar_target = None ):
42
- """ Get the height of either statusbar or navigationbar
43
- bar_target = status or navigation and defaults to status
43
+ """Get the height of either statusbar or navigationbar
44
+ bar_target = status or navigation and defaults to status
44
45
"""
45
46
bar_target = bar_target or 'status'
46
47
@@ -61,12 +62,30 @@ def get_height_of_bar(bar_target=None):
61
62
62
63
63
64
def get_width_of_bar (bar_target = None ):
64
- " Get the width of the bar "
65
+ """ Get the width of the bar"" "
65
66
return Window .width
66
67
67
68
68
69
def get_size_of_bar (bar_target = None ):
69
- """ Get the size of either statusbar or navigationbar
70
- bar_target = status or navigation and defaults to status
70
+ """Get the size of either statusbar or navigationbar
71
+ bar_target = status or navigation and defaults to status
71
72
"""
72
73
return get_width_of_bar (), get_height_of_bar (bar_target )
74
+
75
+
76
+ def get_heights_of_both_bars ():
77
+ """Return heights of both bars"""
78
+ return get_height_of_bar ('status' ), get_height_of_bar ('navigation' )
79
+
80
+
81
+ def get_cutout_mode ():
82
+ """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' )
0 commit comments