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

Commit a0e9961d authored by Jeff DeCew's avatar Jeff DeCew
Browse files

Notifications in landscape should line up with the QS tiles.

Fixes: 190701466
Test: manual
Change-Id: I74e800d95066031f37b5643ebf4a8abb7558b7ee
parent 6c9c6cb6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -449,6 +449,9 @@
    <!-- Adjust the theme on fully custom and decorated custom view notifications -->
    <bool name="config_adjustThemeOnNotificationCustomViews">false</bool>

    <!-- Notifications are sized to match the width of two (of 4) qs tiles in landscape. -->
    <bool name="config_skinnyNotifsInLandscape">true</bool>

    <!-- If true, enable the advance anti-falsing classifier on the lockscreen. On some devices it
         does not work well, particularly with noisy touchscreens. Note that disabling it may
         increase the rate of unintentional unlocks. -->
+25 −2
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ import com.android.systemui.statusbar.phone.StatusBar;
import com.android.systemui.statusbar.policy.HeadsUpUtil;
import com.android.systemui.statusbar.policy.ScrollAdapter;
import com.android.systemui.util.Assert;
import com.android.systemui.util.leak.RotationUtils;

import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -419,6 +420,9 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        animateScroll();
    };
    private int mCornerRadius;
    private int mMinimumPaddings;
    private int mQsTilePadding;
    private boolean mSkinnyNotifsInLandscape;
    private int mSidePaddings;
    private final Rect mBackgroundAnimationRect = new Rect();
    private ArrayList<BiConsumer<Float, Float>> mExpandedHeightListeners = new ArrayList<>();
@@ -851,7 +855,10 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
                R.dimen.min_top_overscroll_to_qs);
        mStatusBarHeight = res.getDimensionPixelSize(R.dimen.status_bar_height);
        mBottomMargin = res.getDimensionPixelSize(R.dimen.notification_panel_margin_bottom);
        mSidePaddings = res.getDimensionPixelSize(R.dimen.notification_side_paddings);
        mMinimumPaddings = res.getDimensionPixelSize(R.dimen.notification_side_paddings);
        mQsTilePadding = res.getDimensionPixelOffset(R.dimen.qs_tile_margin_horizontal);
        mSkinnyNotifsInLandscape = res.getBoolean(R.bool.config_skinnyNotifsInLandscape);
        mSidePaddings = mMinimumPaddings;  // Updated in onMeasure by updateSidePadding()
        mMinInteractionHeight = res.getDimensionPixelSize(
                R.dimen.notification_min_interaction_height);
        mCornerRadius = res.getDimensionPixelSize(R.dimen.notification_corner_radius);
@@ -859,6 +866,21 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
                R.dimen.heads_up_status_bar_padding);
    }

    void updateSidePadding(int viewWidth) {
        if (viewWidth == 0 || !mSkinnyNotifsInLandscape) {
            mSidePaddings = mMinimumPaddings;
            return;
        }
        // Portrait is easy, just use the dimen for paddings
        if (RotationUtils.getRotation(mContext) == RotationUtils.ROTATION_NONE) {
            mSidePaddings = mMinimumPaddings;
            return;
        }
        final int innerWidth = viewWidth - mMinimumPaddings * 2;
        final int qsTileWidth = (innerWidth - mQsTilePadding * 3) / 4;
        mSidePaddings = mMinimumPaddings + qsTileWidth + mQsTilePadding;
    }

    void updateCornerRadius() {
        int newRadius = getResources().getDimensionPixelSize(R.dimen.notification_corner_radius);
        if (mCornerRadius != newRadius) {
@@ -919,6 +941,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        int width = MeasureSpec.getSize(widthMeasureSpec);
        updateSidePadding(width);
        int childWidthSpec = MeasureSpec.makeMeasureSpec(width - mSidePaddings * 2,
                MeasureSpec.getMode(widthMeasureSpec));
        // Don't constrain the height of the children so we know how big they'd like to be
@@ -2069,7 +2092,7 @@ public class NotificationStackScrollLayout extends ViewGroup implements Dumpable

    @ShadeViewRefactor(RefactorComponent.STATE_RESOLVER)
    private void updateContentHeight() {
        final float scrimTopPadding = mAmbientState.isOnKeyguard() ? 0 : mSidePaddings;
        final float scrimTopPadding = mAmbientState.isOnKeyguard() ? 0 : mMinimumPaddings;
        int height = (int) scrimTopPadding;
        float previousPaddingRequest = mPaddingBetweenElements;
        int numShownItems = 0;