Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package com.buzbuz.smartautoclicker.core.base.extensions

import android.graphics.Rect
import android.view.View
import android.view.ViewGroup
import android.view.ViewTreeObserver
Expand Down Expand Up @@ -51,14 +52,14 @@ fun View.delayDrawUntil(timeOutMs: Long = DEFAULT_DRAW_DELAY_TIMEOUT_MS, closure
)
}

fun View.applySystemBarInsets() {
fun View.applySystemBarInsets(margin: Rect) {
ViewCompat.setOnApplyWindowInsetsListener(this) { view, windowInsets ->
// Apply the system bar insets as a margin to the view.
windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()).let { insets ->
view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
leftMargin += insets.left
bottomMargin += insets.bottom
rightMargin += insets.right
leftMargin = margin.left + insets.left
bottomMargin = margin.bottom + insets.bottom
rightMargin = margin.right + insets.right
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package com.buzbuz.smartautoclicker.scenarios.list

import android.content.DialogInterface
import android.content.Intent
import android.graphics.Rect
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
Expand Down Expand Up @@ -106,7 +107,9 @@ class ScenarioListFragment : Fragment() {
appBarLayout.statusBarForeground = MaterialShapeDrawable.createWithElevationOverlay(context)
topAppBar.setOnMenuItemClickListener { onMenuItemSelected(it) }

add.applySystemBarInsets()
val fabEndMargin = resources.getDimensionPixelSize(R.dimen.margin_horizontal_default)
val fabBottomMargin = resources.getDimensionPixelSize(R.dimen.margin_vertical_default)
add.applySystemBarInsets(Rect(0, 0, fabEndMargin, fabBottomMargin))
}

lifecycleScope.launch {
Expand Down