44from android import mActivity
55
66__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' )
89
910
1011def _core_cutout ():
@@ -20,7 +21,7 @@ def get_cutout_pos():
2021 """
2122 try :
2223 cutout = _core_cutout ()
23- return int (cutout .left ), Window .height - int ( cutout .height ())
24+ return int (cutout .left ), int ( Window .height - cutout .height ())
2425 except Exception :
2526 # Doesn't have a camera builtin with the display
2627 return 0 , 0
@@ -70,3 +71,32 @@ def get_size_of_bar(bar_target=None):
7071 bar_target = status or navigation and defaults to status
7172 """
7273 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+ 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
0 commit comments