Skip to content

Commit b130e22

Browse files
feat(heightCalculation) calculate height with getRealSize (paufau#68)
1 parent 40de424 commit b130e22

1 file changed

Lines changed: 4 additions & 26 deletions

File tree

android/src/main/java/com/multiplemodals/library/ModalHostHelper.kt

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,9 @@ internal object ModalHostHelper {
1616
fun getModalHostSize(context: Context, includeStatusBar: Boolean): Point {
1717
val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
1818
val display = Assertions.assertNotNull(wm).defaultDisplay
19-
// getCurrentSizeRange will return the min and max width and height that the window can be
20-
display.getCurrentSizeRange(MIN_POINT, MAX_POINT)
21-
// getSize will return the dimensions of the screen in its current orientation
22-
display.getSize(SIZE_POINT)
23-
24-
val attrs = intArrayOf(R.attr.windowFullscreen)
25-
val theme = context.theme
26-
val ta = theme.obtainStyledAttributes(attrs)
27-
val windowFullscreen = ta.getBoolean(0, false)
28-
29-
// We need to add the status bar height to the height if we have a fullscreen window,
30-
// because Display.getCurrentSizeRange doesn't include it.
31-
val resources = context.resources
32-
val statusBarId = resources.getIdentifier("status_bar_height", "dimen", "android")
33-
var statusBarHeight = 0
34-
if ((windowFullscreen || includeStatusBar) && statusBarId > 0) {
35-
statusBarHeight = resources.getDimension(statusBarId).toInt()
36-
}
37-
38-
return if (SIZE_POINT.x < SIZE_POINT.y) {
39-
// If we are vertical the width value comes from min width and height comes from max height
40-
Point(MIN_POINT.x, MAX_POINT.y + statusBarHeight)
41-
} else {
42-
// If we are horizontal the width value comes from max width and height comes from min height
43-
Point(MAX_POINT.x, MIN_POINT.y + statusBarHeight)
44-
}
19+
20+
display.getRealSize(SIZE_POINT)
21+
22+
return SIZE_POINT
4523
}
4624
}

0 commit comments

Comments
 (0)