Tapadoo / Alerter

An Android Alerting Library
MIT License
5.52k stars 633 forks source link

Alert may has extra bottom margin when displayed with Gravity.BOTTOM #267

Closed vshkl closed 3 years ago

vshkl commented 3 years ago

On some devices where it is possible to switch between the system navigation bar and the physical buttons, the notification, when shown at the bottom, will have an additional margin of the height of the navigation bar, even if it is hidden.

  1. Library version: 7.1.0
  2. Android version: 10
  3. Device: OnePlus 5

The issue must be here:

private val navigationBarHeight by lazy {
    val dimenId = resources.getIdentifier("navigation_bar_height", "dimen", "android")
    resources.getDimensionPixelSize(dimenId)
}

apparently, this code will give the default value for the given device, but doesn't take into account whether it's been actually shown or not.

kpmmmurphy commented 3 years ago

Hey vshkl, thanks for flagging this issue, and for referencing the code which is causing it. I'd be delighted to review your pull request with a fix.

vshkl commented 3 years ago

Hey @kpmmmurphy, I've made a PR that should address this issue. Tested on several devices I have and a couple of emulators to check certain edge-cases like screens with cutouts. Will be happy to hear the feedback.