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 Original line Diff line number Diff line
@@ -191,6 +191,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
    private MultiValueAlpha mBackButtonAlpha;
    private MultiValueAlpha mBackButtonAlpha;
    private MultiValueAlpha mHomeButtonAlpha;
    private MultiValueAlpha mHomeButtonAlpha;
    private FloatingRotationButton mFloatingRotationButton;
    private FloatingRotationButton mFloatingRotationButton;
    private ImageView mImeSwitcherButton;


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


import android.content.res.Resources
import android.content.res.Resources
import android.graphics.drawable.RotateDrawable
import android.graphics.drawable.RotateDrawable
import android.view.Gravity
import android.view.ViewGroup
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.LinearLayout
import com.android.launcher3.R
import com.android.launcher3.R
import com.android.launcher3.Utilities
import com.android.launcher3.Utilities
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.NavButtonLayoutter
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
 * Meant to be a simple container for data subclasses will need
@@ -40,7 +43,10 @@ abstract class AbstractNavButtonLayoutter(
        val resources: Resources,
        val resources: Resources,
        val navButtonContainer: LinearLayout,
        val navButtonContainer: LinearLayout,
        protected val endContextualContainer: ViewGroup,
        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 {
) : NavButtonLayoutter {
    protected val homeButton: ImageView? = navButtonContainer.findViewById(R.id.home)
    protected val homeButton: ImageView? = navButtonContainer.findViewById(R.id.home)
    protected val recentsButton: ImageView? = navButtonContainer.findViewById(R.id.recent_apps)
    protected val recentsButton: ImageView? = navButtonContainer.findViewById(R.id.recent_apps)
@@ -56,4 +62,11 @@ abstract class AbstractNavButtonLayoutter(
            backButton.setImageDrawable(rotateDrawable)
            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 Original line Diff line number Diff line
@@ -26,18 +26,25 @@ import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.LinearLayout
import com.android.launcher3.DeviceProfile
import com.android.launcher3.DeviceProfile
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.*
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.*
import com.android.systemui.shared.rotation.RotationButton


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


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


        homeButton.onLongClickListener = null
        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 Original line Diff line number Diff line
@@ -21,11 +21,13 @@ import android.view.Surface.ROTATION_90
import android.view.Surface.Rotation
import android.view.Surface.Rotation
import android.view.ViewGroup
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.LinearLayout
import com.android.launcher3.DeviceProfile
import com.android.launcher3.DeviceProfile
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.*
import com.android.launcher3.taskbar.navbutton.LayoutResourceHelper.*
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.Companion
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.Companion
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.NavButtonLayoutter
import com.android.launcher3.taskbar.navbutton.NavButtonLayoutFactory.NavButtonLayoutter
import com.android.systemui.shared.rotation.RotationButton


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


import android.content.res.Resources
import android.content.res.Resources
import android.view.ViewGroup
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.LinearLayout
import com.android.launcher3.DeviceProfile
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 */
/** Layoutter for showing gesture navigation on phone screen. No buttons here, no-op container */
class PhoneGestureLayoutter(
class PhoneGestureLayoutter(
        resources: Resources,
        resources: Resources,
        navBarContainer: LinearLayout,
        navBarContainer: LinearLayout,
        endContextualContainer: ViewGroup,
        endContextualContainer: ViewGroup,
        startContextualContainer: ViewGroup
        startContextualContainer: ViewGroup,
        imeSwitcher: ImageView?,
        rotationButton: RotationButton?,
        a11yButton: ImageView
) :
) :
        AbstractNavButtonLayoutter(
        AbstractNavButtonLayoutter(
                resources,
                resources,
                navBarContainer,
                navBarContainer,
                endContextualContainer,
                endContextualContainer,
                startContextualContainer
                startContextualContainer,
                imeSwitcher,
                rotationButton,
                a11yButton
        ) {
        ) {


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