Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 650000f6 authored by Tracy Zhou's avatar Tracy Zhou
Browse files

Correct contextual button width, height and touch area

Side note: this is unrelated to NearestTouchFrame

Bug: 313371759
Bug: 230395757
Test: https://screenshot.googleplex.com/6mF4ZPSob6z55Nh
Change-Id: I7e5217bef4b2cfb6d14d62d107e75b1267ffd2f4
parent 6ab98924
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -65,18 +65,19 @@ abstract class AbstractNavButtonLayoutter(

    fun getParamsToCenterView(): FrameLayout.LayoutParams {
        val params = FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)
        params.gravity = Gravity.CENTER
        return params;
    }

    open fun repositionContextualContainer(contextualContainer: ViewGroup, barAxisMargin: Int,
    open fun repositionContextualContainer(contextualContainer: ViewGroup, buttonSize: Int,
                                           barAxisMarginStart: Int, barAxisMarginEnd: Int,
                                           gravity: Int) {
        val contextualContainerParams = FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
                buttonSize, ViewGroup.LayoutParams.MATCH_PARENT)
        contextualContainerParams.apply {
            marginStart = barAxisMargin
            marginEnd = barAxisMargin
            marginStart = barAxisMarginStart
            marginEnd = barAxisMarginEnd
            topMargin = 0
            bottomMargin = 0
        }
+4 −2
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.graphics.Color
import android.graphics.drawable.PaintDrawable
import android.view.Gravity
import android.view.ViewGroup
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
@@ -103,8 +104,9 @@ class KidsNavLayoutter(

        val contextualMargin = resources.getDimensionPixelSize(
                R.dimen.taskbar_contextual_button_padding)
        repositionContextualContainer(endContextualContainer, 0, Gravity.END)
        repositionContextualContainer(startContextualContainer, contextualMargin, Gravity.START)
        repositionContextualContainer(endContextualContainer, WRAP_CONTENT, 0, 0, Gravity.END)
        repositionContextualContainer(startContextualContainer, WRAP_CONTENT, contextualMargin,
                contextualMargin, Gravity.START)

        if (imeSwitcher != null) {
            startContextualContainer.addView(imeSwitcher)
+12 −9
Original line number Diff line number Diff line
@@ -106,7 +106,7 @@ open class PhoneLandscapeNavLayoutter(
            }
        }

        repositionContextualButtons()
        repositionContextualButtons(contextualButtonHeight.toInt())
    }

    open fun addThreeButtons() {
@@ -116,13 +116,15 @@ open class PhoneLandscapeNavLayoutter(
        navButtonContainer.addView(backButton)
    }

    open fun repositionContextualButtons() {
    open fun repositionContextualButtons(buttonSize: Int) {
        endContextualContainer.removeAllViews()
        startContextualContainer.removeAllViews()

        val contextualMargin = resources.getDimensionPixelSize(
                R.dimen.taskbar_contextual_button_padding)
        repositionContextualContainer(startContextualContainer, contextualMargin, Gravity.TOP)
        val roundedCornerContentMargin = resources.getDimensionPixelSize(
                R.dimen.taskbar_phone_rounded_corner_content_margin)
        val contentPadding = resources.getDimensionPixelSize(R.dimen.taskbar_phone_content_padding)
        repositionContextualContainer(startContextualContainer, buttonSize,
                roundedCornerContentMargin + contentPadding, 0, Gravity.TOP)

        if (imeSwitcher != null) {
            startContextualContainer.addView(imeSwitcher)
@@ -137,15 +139,16 @@ open class PhoneLandscapeNavLayoutter(
        }
    }

    override fun repositionContextualContainer(contextualContainer: ViewGroup, barAxisMargin: Int,
    override fun repositionContextualContainer(contextualContainer: ViewGroup, buttonSize: Int,
                                               barAxisMarginTop: Int, barAxisMarginBottom: Int,
                                               gravity: Int) {
        val contextualContainerParams = FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)
                ViewGroup.LayoutParams.MATCH_PARENT, buttonSize)
        contextualContainerParams.apply {
            marginStart = 0
            marginEnd = 0
            topMargin = barAxisMargin
            bottomMargin = barAxisMargin
            topMargin = barAxisMarginTop
            bottomMargin = barAxisMarginBottom
        }
        contextualContainerParams.gravity = gravity or Gravity.CENTER_HORIZONTAL
        contextualContainer.layoutParams = contextualContainerParams
+2 −3
Original line number Diff line number Diff line
@@ -110,9 +110,8 @@ class PhonePortraitNavLayoutter(
        endContextualContainer.removeAllViews()
        startContextualContainer.removeAllViews()

        val contextualMargin = resources.getDimensionPixelSize(
                R.dimen.taskbar_contextual_button_padding)
        repositionContextualContainer(endContextualContainer, contextualMargin, Gravity.END)
        repositionContextualContainer(endContextualContainer, contextualButtonWidth.toInt(), 0,
                roundedCornerContentMargin + contentPadding, Gravity.END)

        if (imeSwitcher != null) {
            endContextualContainer.addView(imeSwitcher)
+6 −4
Original line number Diff line number Diff line
@@ -50,13 +50,15 @@ class PhoneSeascapeNavLayoutter(
        navButtonContainer.addView(recentsButton)
    }

    override fun repositionContextualButtons() {
    override fun repositionContextualButtons(buttonSize: Int) {
        endContextualContainer.removeAllViews()
        startContextualContainer.removeAllViews()

        val contextualMargin = resources.getDimensionPixelSize(
                R.dimen.taskbar_contextual_button_padding)
        repositionContextualContainer(endContextualContainer, contextualMargin, Gravity.BOTTOM)
        val roundedCornerContentMargin = resources.getDimensionPixelSize(
                R.dimen.taskbar_phone_rounded_corner_content_margin)
        val contentPadding = resources.getDimensionPixelSize(R.dimen.taskbar_phone_content_padding)
        repositionContextualContainer(endContextualContainer, buttonSize, 0,
                roundedCornerContentMargin + contentPadding,  Gravity.BOTTOM)

        if (imeSwitcher != null) {
            endContextualContainer.addView(imeSwitcher)
Loading