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

Commit fe384078 authored by Tracy Zhou's avatar Tracy Zhou Committed by Android (Google) Code Review
Browse files

Merge "Repostion contextual buttons upon layout changes" into main

parents 8502a7fb a9194c54
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -191,6 +191,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
    private MultiValueAlpha mBackButtonAlpha;
    private MultiValueAlpha mHomeButtonAlpha;
    private FloatingRotationButton mFloatingRotationButton;
    private ImageView mImeSwitcherButton;

    // Variables for moving nav buttons to a separate window above IME
    private boolean mAreNavButtonsInSeparateWindow = false;
@@ -237,10 +238,10 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
                InputMethodService.canImeRenderGesturalNavButtons() && mContext.imeDrawsImeNavBar();
        if (!mIsImeRenderingNavButtons) {
            // IME switcher
            View imeSwitcherButton = addButton(R.drawable.ic_ime_switcher, BUTTON_IME_SWITCH,
            mImeSwitcherButton = addButton(R.drawable.ic_ime_switcher, BUTTON_IME_SWITCH,
                    isThreeButtonNav ? mStartContextualContainer : mEndContextualContainer,
                    mControllers.navButtonController, R.id.ime_switcher);
            mPropertyHolders.add(new StatePropertyHolder(imeSwitcherButton,
            mPropertyHolders.add(new StatePropertyHolder(mImeSwitcherButton,
                    flags -> ((flags & FLAG_SWITCHER_SHOWING) != 0)
                            && ((flags & FLAG_ROTATION_BUTTON_VISIBLE) == 0)));
        }
@@ -736,7 +737,9 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
        if (TaskbarManager.FLAG_HIDE_NAVBAR_WINDOW) {
            NavButtonLayoutter navButtonLayoutter =
                    NavButtonLayoutFactory.Companion.getUiLayoutter(
                            dp, mNavButtonsView, res, isInKidsMode, isInSetup, isThreeButtonNav,
                            dp, mNavButtonsView, mImeSwitcherButton,
                            mControllers.rotationButtonController.getRotationButton(),
                            mA11yButton, res, isInKidsMode, isInSetup, isThreeButtonNav,
                            TaskbarManager.isPhoneMode(dp),
                            mWindowManagerProxy.getRotation(mContext));
            navButtonLayoutter.layoutButtons(dp, isContextualButtonShowing());
+17 −4
Original line number Diff line number Diff line
@@ -18,12 +18,15 @@ package com.android.launcher3.taskbar.navbutton

import android.content.res.Resources
import android.graphics.drawable.RotateDrawable
import android.view.Gravity
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
import com.android.launcher3.R
import com.android.launcher3.Utilities
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.NavButtonLayoutter
import com.android.systemui.shared.rotation.RotationButton

/**
 * Meant to be a simple container for data subclasses will need
@@ -40,7 +43,10 @@ abstract class AbstractNavButtonLayoutter(
        val resources: Resources,
        val navButtonContainer: LinearLayout,
        protected val endContextualContainer: ViewGroup,
    protected val startContextualContainer: ViewGroup
        protected val startContextualContainer: ViewGroup,
        protected val imeSwitcher: ImageView?,
        protected val rotationButton: RotationButton?,
        protected val a11yButton: ImageView
) : NavButtonLayoutter {
    protected val homeButton: ImageView? = navButtonContainer.findViewById(R.id.home)
    protected val recentsButton: ImageView? = navButtonContainer.findViewById(R.id.recent_apps)
@@ -56,4 +62,11 @@ abstract class AbstractNavButtonLayoutter(
            backButton.setImageDrawable(rotateDrawable)
        }
    }

    fun getParamsToCenterView(): FrameLayout.LayoutParams {
        val params = FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)
        params.gravity = Gravity.CENTER
        return params;
    }
}
+38 −8
Original line number Diff line number Diff line
@@ -26,18 +26,25 @@ import android.widget.ImageView
import android.widget.LinearLayout
import com.android.launcher3.DeviceProfile
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.*
import com.android.systemui.shared.rotation.RotationButton

class KidsNavLayoutter(
        resources: Resources,
        navBarContainer: LinearLayout,
        endContextualContainer: ViewGroup,
    startContextualContainer: ViewGroup
        startContextualContainer: ViewGroup,
        imeSwitcher: ImageView?,
        rotationButton: RotationButton?,
        a11yButton: ImageView
) :
    AbstractNavButtonLayoutter(
            resources,
            navBarContainer,
            endContextualContainer,
        startContextualContainer
            startContextualContainer,
            imeSwitcher,
            rotationButton,
            a11yButton
    ) {

    override fun layoutButtons(dp: DeviceProfile, isContextualButtonShowing: Boolean) {
@@ -89,5 +96,28 @@ class KidsNavLayoutter(
        navButtonContainer.requestLayout()

        homeButton.onLongClickListener = null

        endContextualContainer.removeAllViews()
        startContextualContainer.removeAllViews()

        val endContextualContainerParams = FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
        endContextualContainerParams.gravity = Gravity.END or Gravity.CENTER_VERTICAL
        endContextualContainer.layoutParams = endContextualContainerParams

        val startContextualContainerParams = FrameLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)
        startContextualContainerParams.gravity = Gravity.START or Gravity.CENTER_VERTICAL
        startContextualContainer.layoutParams = startContextualContainerParams

        if (imeSwitcher != null) {
            startContextualContainer.addView(imeSwitcher)
            imeSwitcher.layoutParams = getParamsToCenterView()
        }
        endContextualContainer.addView(a11yButton)
        if (rotationButton != null) {
            endContextualContainer.addView(rotationButton.currentView)
            rotationButton.currentView.layoutParams = getParamsToCenterView()
        }
    }
}
+56 −30
Original line number Diff line number Diff line
@@ -21,11 +21,13 @@ import android.view.Surface.ROTATION_90
import android.view.Surface.Rotation
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
import com.android.launcher3.DeviceProfile
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.*
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.Companion
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.NavButtonLayoutter
import com.android.systemui.shared.rotation.RotationButton

/**
 * Select the correct layout for nav buttons
@@ -54,6 +56,9 @@ class NavButtonLayoutFactory {
        fun getUiLayoutter(
                deviceProfile: DeviceProfile,
                navButtonsView: FrameLayout,
                imeSwitcher: ImageView?,
                rotationButton: RotationButton?,
                a11yButton: ImageView,
                resources: Resources,
                isKidsMode: Boolean,
                isInSetup: Boolean,
@@ -76,21 +81,30 @@ class NavButtonLayoutFactory {
                                resources,
                                navButtonContainer,
                                endContextualContainer,
                            startContextualContainer
                                startContextualContainer,
                                imeSwitcher,
                                rotationButton,
                                a11yButton
                        )
                    } else if (surfaceRotation == ROTATION_90) {
                        PhoneLandscapeNavLayoutter(
                                resources,
                                navButtonContainer,
                                endContextualContainer,
                            startContextualContainer
                                startContextualContainer,
                                imeSwitcher,
                                rotationButton,
                                a11yButton
                        )
                    } else {
                        PhoneSeascapeNavLayoutter(
                                resources,
                                navButtonContainer,
                                endContextualContainer,
                                startContextualContainer
                                startContextualContainer,
                                imeSwitcher,
                                rotationButton,
                                a11yButton
                        )
                    }
                }
@@ -99,7 +113,10 @@ class NavButtonLayoutFactory {
                            resources,
                            navButtonContainer,
                            endContextualContainer,
                            startContextualContainer
                            startContextualContainer,
                            imeSwitcher,
                            rotationButton,
                            a11yButton
                    )
                }
                deviceProfile.isTaskbarPresent -> {
@@ -109,7 +126,10 @@ class NavButtonLayoutFactory {
                                    resources,
                                    navButtonContainer,
                                    endContextualContainer,
                                startContextualContainer
                                    startContextualContainer,
                                    imeSwitcher,
                                    rotationButton,
                                    a11yButton
                            )
                        }
                        isKidsMode -> {
@@ -117,7 +137,10 @@ class NavButtonLayoutFactory {
                                    resources,
                                    navButtonContainer,
                                    endContextualContainer,
                                startContextualContainer
                                    startContextualContainer,
                                    imeSwitcher,
                                    rotationButton,
                                    a11yButton
                            )
                        }
                        else ->
@@ -125,7 +148,10 @@ class NavButtonLayoutFactory {
                                    resources,
                                    navButtonContainer,
                                    endContextualContainer,
                                startContextualContainer
                                    startContextualContainer,
                                    imeSwitcher,
                                    rotationButton,
                                    a11yButton
                            )
                    }
                }
+12 −3
Original line number Diff line number Diff line
@@ -18,24 +18,33 @@ package com.android.launcher3.taskbar.navbutton

import android.content.res.Resources
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import com.android.launcher3.DeviceProfile
import com.android.systemui.shared.rotation.RotationButton

/** Layoutter for showing gesture navigation on phone screen. No buttons here, no-op container */
class PhoneGestureLayoutter(
        resources: Resources,
        navBarContainer: LinearLayout,
        endContextualContainer: ViewGroup,
        startContextualContainer: ViewGroup
        startContextualContainer: ViewGroup,
        imeSwitcher: ImageView?,
        rotationButton: RotationButton?,
        a11yButton: ImageView
) :
        AbstractNavButtonLayoutter(
                resources,
                navBarContainer,
                endContextualContainer,
                startContextualContainer
                startContextualContainer,
                imeSwitcher,
                rotationButton,
                a11yButton
        ) {

    override fun layoutButtons(dp: DeviceProfile, isContextualButtonShowing: Boolean) {
        // no-op
        endContextualContainer.removeAllViews()
        startContextualContainer.removeAllViews()
    }
}
Loading