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

Commit a7e48fa6 authored by Tracy Zhou's avatar Tracy Zhou
Browse files

Fix nav buttons in task bar disppearing when unfolding from landscape small screen

Previously we reuse layout params when we switch to a new layout, but not all of the fields we reuse are reset. Due to the variety of fields we update in different layouts and the fact that it's relatively cheap to instantiate a new layout params object, let's start fresh every time.

Fixes: 295057715
Bug: 288311605
Test: put the device to landscape in small screen and then unfold, make sure that the nav buttons show in the task bar
Change-Id: I8e600c2553436f563dd4509a83cc46ce47c0114d
parent 6682d58d
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -42,16 +42,15 @@ open class PhoneLandscapeNavLayoutter(

    override fun layoutButtons(dp: DeviceProfile, isContextualButtonShowing: Boolean) {
        // TODO(b/230395757): Polish pending, this is just to make it usable
        val navContainerParams = navButtonContainer.layoutParams as FrameLayout.LayoutParams
        val endStartMargins = resources.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size)
        val taskbarDimensions = DimensionUtils.getTaskbarPhoneDimensions(dp, resources,
                TaskbarManager.isPhoneMode(dp))
        navButtonContainer.removeAllViews()
        navButtonContainer.orientation = LinearLayout.VERTICAL

        val navContainerParams = FrameLayout.LayoutParams(
                taskbarDimensions.x, ViewGroup.LayoutParams.MATCH_PARENT)
        navContainerParams.apply {
            width = taskbarDimensions.x
            height = ViewGroup.LayoutParams.MATCH_PARENT
            topMargin = endStartMargins
            bottomMargin = endStartMargins
            marginEnd = 0
@@ -64,7 +63,7 @@ open class PhoneLandscapeNavLayoutter(
        navButtonContainer.addView(backButton)

        navButtonContainer.layoutParams = navContainerParams
        navButtonContainer.gravity = Gravity.CENTER_HORIZONTAL
        navButtonContainer.gravity = Gravity.CENTER

        // Add the spaces in between the nav buttons
        val spaceInBetween: Int =
+3 −4
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ class PhonePortraitNavLayoutter(

    override fun layoutButtons(dp: DeviceProfile, isContextualButtonShowing: Boolean) {
        // TODO(b/230395757): Polish pending, this is just to make it usable
        val navContainerParams = navButtonContainer.layoutParams as FrameLayout.LayoutParams
        val taskbarDimensions =
            DimensionUtils.getTaskbarPhoneDimensions(dp, resources,
                    TaskbarManager.isPhoneMode(dp))
@@ -51,9 +50,9 @@ class PhonePortraitNavLayoutter(
        navButtonContainer.removeAllViews()
        navButtonContainer.orientation = LinearLayout.HORIZONTAL

        val navContainerParams = FrameLayout.LayoutParams(
                taskbarDimensions.x, ViewGroup.LayoutParams.MATCH_PARENT)
        navContainerParams.apply {
            width = taskbarDimensions.x
            height = ViewGroup.LayoutParams.MATCH_PARENT
            topMargin = 0
            bottomMargin = 0
            marginEnd = endStartMargins
@@ -66,7 +65,7 @@ class PhonePortraitNavLayoutter(
        navButtonContainer.addView(recentsButton)

        navButtonContainer.layoutParams = navContainerParams
        navButtonContainer.gravity = Gravity.CENTER_VERTICAL
        navButtonContainer.gravity = Gravity.CENTER

        // Add the spaces in between the nav buttons
        val spaceInBetween =
+3 −4
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ class TaskbarNavLayoutter(

    override fun layoutButtons(dp: DeviceProfile, isContextualButtonShowing: Boolean) {
        // Add spacing after the end of the last nav button
        val navButtonParams = navButtonContainer.layoutParams as FrameLayout.LayoutParams
        var navMarginEnd = resources.getDimension(dp.inv.inlineNavButtonsEndSpacing).toInt()
        val contextualWidth = endContextualContainer.width
        // If contextual buttons are showing, we check if the end margin is enough for the
@@ -50,10 +49,10 @@ class TaskbarNavLayoutter(
            navMarginEnd += resources.getDimensionPixelSize(R.dimen.taskbar_hotseat_nav_spacing) / 2
        }

        val navButtonParams = FrameLayout.LayoutParams(
                FrameLayout.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
        navButtonParams.apply {
            gravity = Gravity.END
            width = FrameLayout.LayoutParams.WRAP_CONTENT
            height = ViewGroup.LayoutParams.MATCH_PARENT
            gravity = Gravity.END or Gravity.CENTER_VERTICAL
            marginEnd = navMarginEnd
        }
        navButtonContainer.orientation = LinearLayout.HORIZONTAL