Skip to content

Commit

Permalink
Merge pull request #57 from anoop44/statusbar-height-better-api
Browse files Browse the repository at this point in the history
Statusbar height calculation using a better api
  • Loading branch information
yshrsmz committed Feb 25, 2020
2 parents 023a3ce + f97fe81 commit 709d48e
Showing 1 changed file with 5 additions and 8 deletions.
Expand Up @@ -100,17 +100,11 @@ object KeyboardVisibilityEvent {

val layoutListener = object : ViewTreeObserver.OnGlobalLayoutListener {

private val r = Rect()

private var wasOpened = false

override fun onGlobalLayout() {
activityRoot.getWindowVisibleDisplayFrame(r)

val screenHeight = activityRoot.rootView.height
val heightDiff = screenHeight - r.height()

val isOpen = heightDiff > screenHeight * KEYBOARD_MIN_HEIGHT_RATIO
val isOpen = isKeyboardVisible(activity)

if (isOpen == wasOpened) {
// keyboard state has not changed
Expand Down Expand Up @@ -140,8 +134,11 @@ object KeyboardVisibilityEvent {

activityRoot.getWindowVisibleDisplayFrame(r)

val location = IntArray(2)
getContentRoot(activity).getLocationOnScreen(location)

val screenHeight = activityRoot.rootView.height
val heightDiff = screenHeight - r.height() - getContentRoot(activity).top
val heightDiff = screenHeight - r.height() - location[1]

return heightDiff > screenHeight * KEYBOARD_MIN_HEIGHT_RATIO
}
Expand Down

0 comments on commit 709d48e

Please sign in to comment.