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

Commit e4b11be6 authored by Michał Brzeziński's avatar Michał Brzeziński Committed by Android (Google) Code Review
Browse files

Merge "Making notifications wider in split shade mode" into sc-dev

parents 0622a76d a804b7f9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@
            android:id="@+id/qs_edge_guideline"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            systemui:layout_constraintGuide_percent="0.5"
            systemui:layout_constraintGuide_percent="0.4"
            android:orientation="vertical"/>

        <com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout
+6 −13
Original line number Diff line number Diff line
@@ -868,25 +868,16 @@ public class NotificationPanelViewController extends PanelViewController {

    public void updateResources() {
        int qsWidth = mResources.getDimensionPixelSize(R.dimen.qs_panel_width);
        ViewGroup.LayoutParams lp = mQsFrame.getLayoutParams();
        if (lp.width != qsWidth) {
            lp.width = qsWidth;
            mQsFrame.setLayoutParams(lp);
        }

        int panelWidth = mResources.getDimensionPixelSize(R.dimen.notification_panel_width);
        lp = mNotificationStackScrollLayoutController.getLayoutParams();
        if (lp.width != panelWidth) {
            lp.width = panelWidth;
            mNotificationStackScrollLayoutController.setLayoutParams(lp);
        }

        // In order to change the constraints at runtime, all children of the Constraint Layout
        // must have ids.
        // To change the constraints at runtime, all children of the ConstraintLayout must have ids
        ensureAllViewsHaveIds(mNotificationContainerParent);
        ConstraintSet constraintSet = new ConstraintSet();
        constraintSet.clone(mNotificationContainerParent);
        if (Utils.shouldUseSplitNotificationShade(mFeatureFlags, mResources)) {
            // width = 0 to take up all available space within constraints
            qsWidth = 0;
            panelWidth = 0;
            constraintSet.connect(R.id.qs_frame, END, R.id.qs_edge_guideline, END);
            constraintSet.connect(
                    R.id.notification_stack_scroller, START,
@@ -895,6 +886,8 @@ public class NotificationPanelViewController extends PanelViewController {
            constraintSet.connect(R.id.qs_frame, END, PARENT_ID, END);
            constraintSet.connect(R.id.notification_stack_scroller, START, PARENT_ID, START);
        }
        constraintSet.getConstraint(R.id.notification_stack_scroller).layout.mWidth = panelWidth;
        constraintSet.getConstraint(R.id.qs_frame).layout.mWidth = qsWidth;
        constraintSet.applyTo(mNotificationContainerParent);
    }

+0 −18
Original line number Diff line number Diff line
@@ -18,14 +18,12 @@ package com.android.systemui.statusbar.phone;

import android.app.Fragment;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.View;
import android.view.WindowInsets;
import android.widget.FrameLayout;

import androidx.annotation.DimenRes;
import androidx.constraintlayout.widget.ConstraintLayout;

import com.android.systemui.R;
@@ -82,22 +80,6 @@ public class NotificationsQuickSettingsContainer extends ConstraintLayout
        FragmentHostManager.get(this).removeTagListener(QS.TAG, this);
    }

    @Override
    protected void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        reloadWidth(mQsFrame, R.dimen.qs_panel_width);
        reloadWidth(mStackScroller, R.dimen.notification_panel_width);
    }

    /**
     * Loads the given width resource and sets it on the given View.
     */
    private void reloadWidth(View view, @DimenRes int width) {
        LayoutParams params = (LayoutParams) view.getLayoutParams();
        params.width = getResources().getDimensionPixelSize(width);
        view.setLayoutParams(params);
    }

    @Override
    public WindowInsets onApplyWindowInsets(WindowInsets insets) {
        mBottomPadding = insets.getStableInsetBottom();
+53 −36
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.annotation.IdRes;
import android.app.ActivityManager;
import android.app.StatusBarManager;
import android.content.res.Configuration;
@@ -269,8 +270,9 @@ public class NotificationPanelViewTest extends SysuiTestCase {
        when(mView.findViewById(R.id.qs_frame)).thenReturn(mQsFrame);
        when(mView.findViewById(R.id.keyguard_status_view))
                .thenReturn(mock(KeyguardStatusView.class));
        when(mView.findViewById(R.id.keyguard_header)).thenReturn(mKeyguardStatusBar);
        mNotificationContainerParent = new NotificationsQuickSettingsContainer(getContext(), null);
        mNotificationContainerParent.addView(newViewWithId(R.id.qs_frame));
        mNotificationContainerParent.addView(newViewWithId(R.id.notification_stack_scroller));
        when(mView.findViewById(R.id.notification_container_parent))
                .thenReturn(mNotificationContainerParent);
        FlingAnimationUtils.Builder flingAnimationUtilsBuilder = new FlingAnimationUtils.Builder(
@@ -300,10 +302,6 @@ public class NotificationPanelViewTest extends SysuiTestCase {
                .thenReturn(mKeyguardClockSwitchController);
        when(mKeyguardStatusViewComponent.getKeyguardStatusViewController())
                .thenReturn(mKeyguardStatusViewController);
        when(mQsFrame.getLayoutParams()).thenReturn(
                new ViewGroup.LayoutParams(600, 400));
        when(mNotificationStackScrollLayoutController.getLayoutParams()).thenReturn(
                new ViewGroup.LayoutParams(600, 400));

        mNotificationPanelViewController = new NotificationPanelViewController(mView,
                mResources,
@@ -451,7 +449,8 @@ public class NotificationPanelViewTest extends SysuiTestCase {

    @Test
    public void testAllChildrenOfNotificationContainer_haveIds() {
        enableDualPaneShade();
        enableSplitShade();
        mNotificationContainerParent.removeAllViews();
        mNotificationContainerParent.addView(newViewWithId(1));
        mNotificationContainerParent.addView(newViewWithId(View.NO_ID));

@@ -464,35 +463,59 @@ public class NotificationPanelViewTest extends SysuiTestCase {
    @Test
    public void testSinglePaneShadeLayout_isAlignedToParent() {
        when(mFeatureFlags.isTwoColumnNotificationShadeEnabled()).thenReturn(false);
        mNotificationContainerParent.addView(newViewWithId(R.id.qs_frame));
        mNotificationContainerParent.addView(newViewWithId(R.id.notification_stack_scroller));

        mNotificationPanelViewController.updateResources();

        ConstraintSet constraintSet = new ConstraintSet();
        constraintSet.clone(mNotificationContainerParent);
        ConstraintSet.Layout qsFrameLayout = constraintSet.getConstraint(R.id.qs_frame).layout;
        ConstraintSet.Layout stackScrollerLayout = constraintSet.getConstraint(
                R.id.notification_stack_scroller).layout;
        assertThat(qsFrameLayout.endToEnd).isEqualTo(ConstraintSet.PARENT_ID);
        assertThat(stackScrollerLayout.startToStart).isEqualTo(ConstraintSet.PARENT_ID);
        assertThat(getConstraintSetLayout(R.id.qs_frame).endToEnd)
                .isEqualTo(ConstraintSet.PARENT_ID);
        assertThat(getConstraintSetLayout(R.id.notification_stack_scroller).startToStart)
                .isEqualTo(ConstraintSet.PARENT_ID);
    }

    @Test
    public void testSplitShadeLayout_isAlignedToGuideline() {
        enableDualPaneShade();
        mNotificationContainerParent.addView(newViewWithId(R.id.qs_frame));
        mNotificationContainerParent.addView(newViewWithId(R.id.notification_stack_scroller));
        enableSplitShade();

        mNotificationPanelViewController.updateResources();

        ConstraintSet constraintSet = new ConstraintSet();
        constraintSet.clone(mNotificationContainerParent);
        ConstraintSet.Layout qsFrameLayout = constraintSet.getConstraint(R.id.qs_frame).layout;
        ConstraintSet.Layout stackScrollerLayout = constraintSet.getConstraint(
                R.id.notification_stack_scroller).layout;
        assertThat(qsFrameLayout.endToEnd).isEqualTo(R.id.qs_edge_guideline);
        assertThat(stackScrollerLayout.startToStart).isEqualTo(R.id.qs_edge_guideline);
        assertThat(getConstraintSetLayout(R.id.qs_frame).endToEnd)
                .isEqualTo(R.id.qs_edge_guideline);
        assertThat(getConstraintSetLayout(R.id.notification_stack_scroller).startToStart)
                .isEqualTo(R.id.qs_edge_guideline);
    }

    @Test
    public void testSinglePaneShadeLayout_childrenHaveConstantWidth() {
        when(mFeatureFlags.isTwoColumnNotificationShadeEnabled()).thenReturn(false);

        mNotificationPanelViewController.updateResources();

        assertThat(getConstraintSetLayout(R.id.qs_frame).mWidth)
                .isEqualTo(mResources.getDimensionPixelSize(R.dimen.qs_panel_width));
        assertThat(getConstraintSetLayout(R.id.notification_stack_scroller).mWidth)
                .isEqualTo(mResources.getDimensionPixelSize(R.dimen.notification_panel_width));
    }

    @Test
    public void testSplitShadeLayout_childrenHaveZeroWidth() {
        enableSplitShade();

        mNotificationPanelViewController.updateResources();

        assertThat(getConstraintSetLayout(R.id.qs_frame).mWidth).isEqualTo(0);
        assertThat(getConstraintSetLayout(R.id.notification_stack_scroller).mWidth).isEqualTo(0);
    }

    @Test
    public void testOnDragDownEvent_horizontalTranslationIsZeroForSplitShade() {
        when(mNotificationStackScrollLayoutController.getWidth()).thenReturn(350f);
        when(mView.getWidth()).thenReturn(800);
        enableSplitShade();

        onTouchEvent(MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN,
                200f /* x position */, 0f, 0));

        verify(mQsFrame).setTranslationX(0);
    }

    @Test
@@ -538,19 +561,13 @@ public class NotificationPanelViewTest extends SysuiTestCase {
        return view;
    }

    @Test
    public void testOnDragDownEvent_horizontalTranslationIsZeroForDualPaneShade() {
        when(mNotificationStackScrollLayoutController.getWidth()).thenReturn(350f);
        when(mView.getWidth()).thenReturn(800);
        enableDualPaneShade();

        onTouchEvent(MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN,
                200f /* x position */, 0f, 0));

        verify(mQsFrame).setTranslationX(0);
    private ConstraintSet.Layout getConstraintSetLayout(@IdRes int id) {
        ConstraintSet constraintSet = new ConstraintSet();
        constraintSet.clone(mNotificationContainerParent);
        return constraintSet.getConstraint(id).layout;
    }

    private void enableDualPaneShade() {
    private void enableSplitShade() {
        when(mResources.getBoolean(R.bool.config_use_split_notification_shade)).thenReturn(true);
        when(mFeatureFlags.isTwoColumnNotificationShadeEnabled()).thenReturn(true);
    }