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

Commit da26e19d authored by Saumya Prakash's avatar Saumya Prakash
Browse files

Adjust where the back button is rendered for new SUW requirements.

Large screen devices in landscape mode and devices that have mostly a
square aspect ratio are undergoing a redesign in Setup wizard that makes
most screens two-pane. As part of this redesign, the back button is
aligned in this change. This change doesn't use a flag because the Setup
Wizard change is not flagged.

Fixes: 323778778
Fixes: 328017929
Test: Run Setup Wizard and see if the back button aligns with the Skip
button in two pane screens.
Flag: N/A

Change-Id: I22680f40c0ddf7cd03ab1da69406eb14184b0174
parent 1bc33421
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -78,7 +78,8 @@
    <!--  Taskbar 3 button spacing  -->
    <dimen name="taskbar_button_margin_split">88dp</dimen>
    <dimen name="taskbar_button_margin_6_5">219.6dp</dimen>
    <dimen name="taskbar_contextual_button_margin">48dp</dimen>
    <dimen name="taskbar_contextual_button_suw_margin">48dp</dimen>
    <dimen name="taskbar_contextual_button_suw_height">48dp</dimen>
    <dimen name="taskbar_suw_frame">96dp</dimen>
    <dimen name="taskbar_suw_insets">24dp</dimen>

+6 −2
Original line number Diff line number Diff line
@@ -325,10 +325,9 @@
    <dimen name="taskbar_contextual_padding_top">8dp</dimen>
    <dimen name="taskbar_nav_buttons_size">44dp</dimen>
    <dimen name="taskbar_split_instructions_margin">48dp</dimen>
    <dimen name="taskbar_contextual_button_margin">120dp</dimen>
    <dimen name="taskbar_ime_switcher_button_margin_start">40dp</dimen>
    <dimen name="taskbar_suw_insets">48dp</dimen>
    <dimen name="taskbar_suw_frame">48dp</dimen>
    <dimen name="taskbar_suw_frame">96dp</dimen>
    <dimen name="taskbar_hotseat_nav_spacing">24dp</dimen>
    <dimen name="taskbar_contextual_buttons_size">35dp</dimen>
    <dimen name="taskbar_stashed_size">24dp</dimen>
@@ -347,6 +346,11 @@
    <dimen name="taskbar_icon_size_kids">32dp</dimen>
    <dimen name="taskbar_all_apps_button_translation_x_offset">6dp</dimen>
    <dimen name="taskbar_all_apps_search_button_translation_x_offset">6dp</dimen>
    <dimen name="taskbar_contextual_button_suw_margin">64dp</dimen>
    <dimen name="taskbar_contextual_button_suw_height">64dp</dimen>
    <dimen name="taskbar_back_button_suw_start_margin">48dp</dimen>
    <dimen name="taskbar_back_button_suw_bottom_margin">1dp</dimen>
    <dimen name="taskbar_back_button_suw_height">72dp</dimen>

    <!-- Transient taskbar -->
    <dimen name="transient_taskbar_padding">12dp</dimen>
+32 −8
Original line number Diff line number Diff line
@@ -142,6 +142,9 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT

    private static final String NAV_BUTTONS_SEPARATE_WINDOW_TITLE = "Taskbar Nav Buttons";

    private static final double SQUARE_ASPECT_RATIO_BOTTOM_BOUND = 0.95;
    private static final double SQUARE_ASPECT_RATIO_UPPER_BOUND = 1.05;

    public static final int ALPHA_INDEX_IMMERSIVE_MODE = 0;
    public static final int ALPHA_INDEX_KEYGUARD_OR_DISABLE = 1;
    public static final int ALPHA_INDEX_SUW = 2;
@@ -735,18 +738,39 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
        // end-aligned, so start-align instead.
        FrameLayout.LayoutParams navButtonsLayoutParams = (FrameLayout.LayoutParams)
                mNavButtonContainer.getLayoutParams();
        FrameLayout.LayoutParams navButtonsViewLayoutParams = (FrameLayout.LayoutParams)
                mNavButtonsView.getLayoutParams();
        Resources resources = mContext.getResources();
        DeviceProfile deviceProfile = mContext.getDeviceProfile();
        int setupMargin = resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_margin);
        navButtonsLayoutParams.setMarginStart(setupMargin);
        navButtonsLayoutParams.bottomMargin = !deviceProfile.isLandscape
                ? 0
                : setupMargin -
                        (resources.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size) / 2);

        navButtonsLayoutParams.setMarginEnd(0);
        navButtonsLayoutParams.gravity = Gravity.START;
        mNavButtonsView.getLayoutParams().height =
                mControllers.taskbarActivityContext.getSetupWindowSize();
        mControllers.taskbarActivityContext.setTaskbarWindowSize(
                mControllers.taskbarActivityContext.getSetupWindowSize());

        // If SUW is on a large screen device that is landscape (or has a square aspect
        // ratio) the back button has to be placed accordingly
        if ((deviceProfile.isTablet && deviceProfile.isLandscape)
                || (deviceProfile.aspectRatio > SQUARE_ASPECT_RATIO_BOTTOM_BOUND
                && deviceProfile.aspectRatio < SQUARE_ASPECT_RATIO_UPPER_BOUND)) {
            navButtonsLayoutParams.setMarginStart(
                    resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_start_margin));
            navButtonsViewLayoutParams.bottomMargin = resources.getDimensionPixelSize(
                    R.dimen.taskbar_back_button_suw_bottom_margin);
            navButtonsLayoutParams.height = resources.getDimensionPixelSize(
                    R.dimen.taskbar_back_button_suw_height);
        } else {
            int phoneOrPortraitSetupMargin = resources.getDimensionPixelSize(
                    R.dimen.taskbar_contextual_button_suw_margin);
            navButtonsLayoutParams.setMarginStart(phoneOrPortraitSetupMargin);
            navButtonsLayoutParams.bottomMargin = !deviceProfile.isLandscape
                    ? 0
                    : phoneOrPortraitSetupMargin - (resources.getDimensionPixelSize(
                            R.dimen.taskbar_nav_buttons_size) / 2);
            navButtonsViewLayoutParams.height = resources.getDimensionPixelSize(
                    R.dimen.taskbar_contextual_button_suw_height);
        }
        mNavButtonsView.setLayoutParams(navButtonsViewLayoutParams);
        mNavButtonContainer.setLayoutParams(navButtonsLayoutParams);
    }

+66 −66
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.content.res.Resources
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 android.widget.Space
@@ -134,6 +133,7 @@ class NavButtonLayoutFactory {
                        isInSetup -> {
                            SetupNavLayoutter(
                                resources,
                                navButtonsView,
                                navButtonContainer,
                                endContextualContainer,
                                startContextualContainer,
+64 −25
Original line number Diff line number Diff line
@@ -24,12 +24,17 @@ import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.Space
import com.android.launcher3.DeviceProfile
import com.android.launcher3.R
import com.android.launcher3.taskbar.TaskbarActivityContext
import com.android.systemui.shared.rotation.RotationButton

const val SQUARE_ASPECT_RATIO_BOTTOM_BOUND = 0.95
const val SQUARE_ASPECT_RATIO_UPPER_BOUND = 1.05

class SetupNavLayoutter(
    resources: Resources,
    navButtonsView: NearestTouchFrame,
    navButtonContainer: LinearLayout,
    endContextualContainer: ViewGroup,
    startContextualContainer: ViewGroup,
@@ -48,26 +53,60 @@ class SetupNavLayoutter(
        a11yButton,
        space
    ) {
    private val mNavButtonsView = navButtonsView

    override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) {
        // Since setup wizard only has back button enabled, it looks strange to be
        // end-aligned, so start-align instead.
        val navButtonsLayoutParams = navButtonContainer.layoutParams as FrameLayout.LayoutParams
        navButtonsLayoutParams.apply {
            marginStart = navButtonsLayoutParams.marginEnd
            marginEnd = 0
            gravity = Gravity.START
        val navButtonsViewLayoutParams = mNavButtonsView.layoutParams as FrameLayout.LayoutParams
        val deviceProfile: DeviceProfile = context.deviceProfile

        navButtonsLayoutParams.marginEnd = 0
        navButtonsLayoutParams.gravity = Gravity.START
        context.setTaskbarWindowSize(context.setupWindowSize)

        // If SUW is on a large screen device that is landscape (or has a square aspect
        // ratio) the back button has to be placed accordingly
        if (
            deviceProfile.isTablet && deviceProfile.isLandscape ||
                (deviceProfile.aspectRatio > SQUARE_ASPECT_RATIO_BOTTOM_BOUND &&
                    deviceProfile.aspectRatio < SQUARE_ASPECT_RATIO_UPPER_BOUND)
        ) {
            navButtonsLayoutParams.marginStart =
                resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_start_margin)
            navButtonsViewLayoutParams.bottomMargin =
                resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_bottom_margin)
            navButtonsLayoutParams.height =
                resources.getDimensionPixelSize(R.dimen.taskbar_back_button_suw_height)
        } else {
            val phoneOrPortraitSetupMargin =
                resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_suw_margin)
            navButtonsLayoutParams.marginStart = phoneOrPortraitSetupMargin
            navButtonsLayoutParams.bottomMargin =
                if (!deviceProfile.isLandscape) 0
                else
                    phoneOrPortraitSetupMargin -
                        resources.getDimensionPixelSize(R.dimen.taskbar_nav_buttons_size) / 2
            navButtonsViewLayoutParams.height =
                resources.getDimensionPixelSize(R.dimen.taskbar_contextual_button_suw_height)
        }
        navButtonContainer.requestLayout()
        mNavButtonsView.layoutParams = navButtonsViewLayoutParams
        navButtonContainer.layoutParams = navButtonsLayoutParams

        endContextualContainer.removeAllViews()
        startContextualContainer.removeAllViews()

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

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