summaryrefslogtreecommitdiffstats
path: root/src/android/app/src/main/java/org/yuzu/yuzu_emu/utils/InsetsHelper.kt
blob: 2eae77a1ddfb120f64e53127ed1c0fba2786e46f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package org.yuzu.yuzu_emu.utils

import android.content.Context
import android.view.ViewGroup.MarginLayoutParams
import androidx.core.graphics.Insets
import com.google.android.material.appbar.AppBarLayout

object InsetsHelper {
    const val THREE_BUTTON_NAVIGATION = 0
    const val TWO_BUTTON_NAVIGATION = 1
    const val GESTURE_NAVIGATION = 2

    fun insetAppBar(insets: Insets, appBarLayout: AppBarLayout) {
        val mlpAppBar = appBarLayout.layoutParams as MarginLayoutParams
        mlpAppBar.leftMargin = insets.left
        mlpAppBar.rightMargin = insets.right
        appBarLayout.layoutParams = mlpAppBar
    }

    fun getSystemGestureType(context: Context): Int {
        val resources = context.resources
        val resourceId =
            resources.getIdentifier("config_navBarInteractionMode", "integer", "android")
        return if (resourceId != 0) {
            resources.getInteger(resourceId)
        } else 0
    }
}