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

Commit 5e32ddef authored by Alex Florescu's avatar Alex Florescu Committed by Automerger Merge Worker
Browse files

Merge "Ensure ConstraintLayout children have ids" into sc-dev am: cbdc7ee5

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13436542

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I96e12ceb2b630128f3698f1d6096aeceeb8ec9d4
parents ec7bd545 cbdc7ee5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -19,4 +19,7 @@

    <!-- Max number of columns for quick controls area -->
    <integer name="controls_max_columns">2</integer>

    <!-- Whether to use the split 2-column notification shade -->
    <bool name="config_use_split_notification_shade">true</bool>
</resources>
+3 −0
Original line number Diff line number Diff line
@@ -565,4 +565,7 @@

    <!-- Whether wallet view is shown in landscape / seascape orientations -->
    <bool name="global_actions_show_landscape_wallet_view">false</bool>

    <!-- Whether to use the split 2-column notification shade -->
    <bool name="config_use_split_notification_shade">false</bool>
</resources>
+26 −1
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.plugins.statusbar.StatusBarStateController.StateListener;
import com.android.systemui.qs.QSDetailDisplayer;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.GestureRecorder;
import com.android.systemui.statusbar.KeyguardAffordanceView;
import com.android.systemui.statusbar.KeyguardIndicationController;
@@ -292,6 +293,7 @@ public class NotificationPanelViewController extends PanelViewController {
    private final StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
    private final KeyguardStatusViewComponent.Factory mKeyguardStatusViewComponentFactory;
    private final QSDetailDisplayer mQSDetailDisplayer;
    private final FeatureFlags mFeatureFlags;
    private final ScrimController mScrimController;
    // Maximum # notifications to show on Keyguard; extras will be collapsed in an overflow card.
    // If there are exactly 1 + mMaxKeyguardNotifications, then still shows all notifications
@@ -554,7 +556,9 @@ public class NotificationPanelViewController extends PanelViewController {
            QSDetailDisplayer qsDetailDisplayer,
            ScrimController scrimController,
            MediaDataManager mediaDataManager,
            AmbientState ambientState) {
            AmbientState ambientState,
            FeatureFlags featureFlags
    ) {
        super(view, falsingManager, dozeLog, keyguardStateController,
                (SysuiStatusBarStateController) statusBarStateController, vibratorHelper,
                latencyTracker, flingAnimationUtilsBuilder.get(), statusBarTouchableRegionManager,
@@ -571,6 +575,7 @@ public class NotificationPanelViewController extends PanelViewController {
        mNotificationIconAreaController = notificationIconAreaController;
        mKeyguardStatusViewComponentFactory = keyguardStatusViewComponentFactory;
        mQSDetailDisplayer = qsDetailDisplayer;
        mFeatureFlags = featureFlags;
        mView.setWillNotDraw(!DEBUG);
        mLayoutInflater = layoutInflater;
        mFalsingManager = falsingManager;
@@ -768,6 +773,26 @@ public class NotificationPanelViewController extends PanelViewController {
            lp.width = panelWidth;
            mNotificationStackScrollLayoutController.setLayoutParams(lp);
        }

        if (shouldUseSplitNotificationShade()) {
            // In order to change the constraints at runtime, all children of the Constraint Layout
            // must have ids.
            ensureAllViewsHaveIds(mNotificationContainerParent);
        }
    }

    private boolean shouldUseSplitNotificationShade() {
        return mFeatureFlags.isTwoColumnNotificationShadeEnabled()
                && mResources.getBoolean(R.bool.config_use_split_notification_shade);
    }

    private static void ensureAllViewsHaveIds(ViewGroup parentView) {
        for (int i = 0; i < parentView.getChildCount(); i++) {
            View childView = parentView.getChildAt(i);
            if (childView.getId() == View.NO_ID) {
                childView.setId(View.generateViewId());
            }
        }
    }

    private void reInflateViews() {
+35 −1
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ import com.android.systemui.media.MediaDataManager;
import com.android.systemui.media.MediaHierarchyManager;
import com.android.systemui.qs.QSDetailDisplayer;
import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.FeatureFlags;
import com.android.systemui.statusbar.KeyguardAffordanceView;
import com.android.systemui.statusbar.NotificationLockscreenUserManager;
import com.android.systemui.statusbar.NotificationShelfController;
@@ -204,6 +205,10 @@ public class NotificationPanelViewTest extends SysuiTestCase {
    @Mock
    private MediaDataManager mMediaDataManager;
    @Mock
    private FeatureFlags mFeatureFlags;
    @Mock
    private NotificationsQuickSettingsContainer mNotificationContainerParent;
    @Mock
    private AmbientState mAmbientState;
    private NotificationPanelViewController mNotificationPanelViewController;
    private View.AccessibilityDelegate mAccessibiltyDelegate;
@@ -219,6 +224,8 @@ public class NotificationPanelViewTest extends SysuiTestCase {
        when(mResources.getDisplayMetrics()).thenReturn(mDisplayMetrics);
        mDisplayMetrics.density = 100;
        when(mResources.getBoolean(R.bool.config_enableNotificationShadeDrag)).thenReturn(true);
        when(mResources.getDimensionPixelSize(R.dimen.qs_panel_width)).thenReturn(400);
        when(mResources.getDimensionPixelSize(R.dimen.notification_panel_width)).thenReturn(400);
        when(mView.getContext()).thenReturn(getContext());
        when(mView.findViewById(R.id.keyguard_header)).thenReturn(mKeyguardStatusBar);
        when(mView.findViewById(R.id.keyguard_clock_container)).thenReturn(mKeyguardClockSwitch);
@@ -237,6 +244,8 @@ public class NotificationPanelViewTest extends SysuiTestCase {
        when(mView.findViewById(R.id.keyguard_status_view))
                .thenReturn(mock(KeyguardStatusView.class));
        when(mView.findViewById(R.id.keyguard_header)).thenReturn(mKeyguardStatusBar);
        when(mView.findViewById(R.id.notification_container_parent))
                .thenReturn(mNotificationContainerParent);
        FlingAnimationUtils.Builder flingAnimationUtilsBuilder = new FlingAnimationUtils.Builder(
                mDisplayMetrics);

@@ -264,6 +273,11 @@ 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,
                mLayoutInflater,
@@ -285,7 +299,8 @@ public class NotificationPanelViewTest extends SysuiTestCase {
                new QSDetailDisplayer(),
                mScrimController,
                mMediaDataManager,
                mAmbientState);
                mAmbientState,
                mFeatureFlags);
        mNotificationPanelViewController.initDependencies(
                mStatusBar,
                mNotificationShelfController);
@@ -400,6 +415,25 @@ public class NotificationPanelViewTest extends SysuiTestCase {
        verify(mStatusBarKeyguardViewManager).showBouncer(true);
    }

    @Test
    public void testAllChildrenOfNotificationContainer_haveIds() {
        when(mNotificationContainerParent.getChildCount()).thenReturn(2);
        when(mResources.getBoolean(R.bool.config_use_split_notification_shade)).thenReturn(true);
        when(mFeatureFlags.isTwoColumnNotificationShadeEnabled()).thenReturn(true);

        View view1 = new View(mContext);
        view1.setId(1);
        when(mNotificationContainerParent.getChildAt(0)).thenReturn(view1);

        View view2 = mock(View.class);
        when(mNotificationContainerParent.getChildAt(1)).thenReturn(view2);

        mNotificationPanelViewController.updateResources();

        assertThat(mNotificationContainerParent.getChildAt(0).getId()).isEqualTo(1);
        assertThat(mNotificationContainerParent.getChildAt(1).getId()).isNotEqualTo(View.NO_ID);
    }

    private void onTouchEvent(MotionEvent ev) {
        mTouchHandler.onTouch(mView, ev);
    }