From Android 30 onwards we can get system insets to check whether gesture navigation is enabled or not.
If gesture navigation is enabled, then WindowInsets.Type.systemGestures() will have values for inset.left and inset.right greater than 0.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
binding.root.apply {
var hasGesture = false
doOnAttach {
val inset = it.rootWindowInsets?.getInsets(WindowInsets.Type.systemGestures())
println("inset: left: ${inset?.left} right: ${inset?.right} top:${inset?.top} bottom: ${inset?.bottom}")
val margin = it.rootWindowInsets?.getInsets(WindowInsets.Type.systemGestures())?.left ?: 0
hasGesture = margin > 0
}
}
}