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

Commit 5c6dd95c authored by felkachang's avatar felkachang Committed by android-build-merger
Browse files

Fix fullscreen notification to support RTL am: 3d00f35c

am: 50e37e53

Change-Id: I464bc95f21d847788570d23aba2c368dac8fd566
parents 8afa50f9 50e37e53
Loading
Loading
Loading
Loading
+35 −13
Original line number Original line Diff line number Diff line
@@ -19,8 +19,10 @@ package com.android.systemui.statusbar;
import android.content.Context;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.view.DisplayCutout;
import android.view.View;
import android.view.View;
import android.widget.TextView;
import android.widget.TextView;


@@ -44,9 +46,10 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout {
    private boolean mPublicMode;
    private boolean mPublicMode;
    private int mMaxWidth;
    private int mMaxWidth;
    private View mRootView;
    private View mRootView;
    private int mLeftCutOutInset;
    private int mSysWinInset;
    private int mLeftInset;
    private int mCutOutInset;
    private Rect mIconDrawingRect = new Rect();
    private Rect mIconDrawingRect = new Rect();
    private Point mPoint;
    private Runnable mOnDrawingRectChangedListener;
    private Runnable mOnDrawingRectChangedListener;


    public HeadsUpStatusBarView(Context context) {
    public HeadsUpStatusBarView(Context context) {
@@ -137,9 +140,20 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout {
        int bottom = top + mIconPlaceholder.getHeight();
        int bottom = top + mIconPlaceholder.getHeight();
        mLayoutedIconRect.set(left, top, right, bottom);
        mLayoutedIconRect.set(left, top, right, bottom);
        updateDrawingRect();
        updateDrawingRect();
        int targetPadding = mAbsoluteStartPadding + mLeftInset + mLeftCutOutInset;
        int targetPadding = mAbsoluteStartPadding + mSysWinInset + mCutOutInset;
        if (left != targetPadding) {
        if (left != targetPadding) {
            int newPadding = targetPadding - left + getPaddingStart();
            int start;
            if (isLayoutRtl()) {
                if (mPoint == null) {
                    mPoint = new Point();
                }
                getDisplay().getRealSize(mPoint);
                start = (mPoint.x - right);
            } else {
                start = left;
            }

            int newPadding = targetPadding - start + getPaddingStart();
            setPaddingRelative(newPadding, 0, mEndMargin, 0);
            setPaddingRelative(newPadding, 0, mEndMargin, 0);
        }
        }
        if (mFirstLayout) {
        if (mFirstLayout) {
@@ -152,7 +166,11 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout {
    }
    }


    public void setPanelTranslation(float translationX) {
    public void setPanelTranslation(float translationX) {
        setTranslationX(translationX - mLeftCutOutInset);
        if (isLayoutRtl()) {
            setTranslationX(translationX + mCutOutInset);
        } else {
            setTranslationX(translationX - mCutOutInset);
        }
        updateDrawingRect();
        updateDrawingRect();
    }
    }


@@ -167,15 +185,19 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout {


    @Override
    @Override
    protected boolean fitSystemWindows(Rect insets) {
    protected boolean fitSystemWindows(Rect insets) {
        mLeftInset = insets.left;
        boolean isRtl = isLayoutRtl();
        mLeftCutOutInset = (getRootWindowInsets().getDisplayCutout() != null)
        mSysWinInset = isRtl ? insets.right : insets.left;
                ? getRootWindowInsets().getDisplayCutout().getSafeInsetLeft() : 0;
        DisplayCutout displayCutout = getRootWindowInsets().getDisplayCutout();

        mCutOutInset = (displayCutout != null)
                ? (isRtl ? displayCutout.getSafeInsetRight() : displayCutout.getSafeInsetLeft())
                : 0;
        // For Double Cut Out mode, the System window navigation bar is at the right
        // For Double Cut Out mode, the System window navigation bar is at the right
        // hand side of the left cut out. In this condition, mLeftInset include the left cut
        // side of the left cut out. In this condition, mSysWinInset include the left cut
        // out width so we set mLeftCutOutInset to be 0.
        // out width so we set mCutOutInset to be 0. For RTL, the condition is the same.
        if (mLeftInset != 0) {
        // The navigation bar is at the left side of the right cut out and include the
            mLeftCutOutInset = 0;
        // right cut out width.
        if (mSysWinInset != 0) {
            mCutOutInset = 0;
        }
        }


        return super.fitSystemWindows(insets);
        return super.fitSystemWindows(insets);
+50 −1
Original line number Original line Diff line number Diff line
@@ -16,8 +16,10 @@


package com.android.systemui.statusbar.phone;
package com.android.systemui.statusbar.phone;


import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Rect;
import android.view.View;
import android.view.View;
import android.view.WindowInsets;


import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.Dependency;
import com.android.systemui.Dependency;
@@ -59,6 +61,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
    private final View.OnLayoutChangeListener mStackScrollLayoutChangeListener =
    private final View.OnLayoutChangeListener mStackScrollLayoutChangeListener =
            (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom)
            (v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom)
                    -> updatePanelTranslation();
                    -> updatePanelTranslation();
    Point mPoint;


    public HeadsUpAppearanceController(
    public HeadsUpAppearanceController(
            NotificationIconAreaController notificationIconAreaController,
            NotificationIconAreaController notificationIconAreaController,
@@ -121,8 +124,54 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
        updateHeader(headsUp.getEntry());
        updateHeader(headsUp.getEntry());
    }
    }


    /** To count the distance from the window right boundary to scroller right boundary. The
     * distance formula is the following:
     *     Y = screenSize - (SystemWindow's width + Scroller.getRight())
     * There are four modes MUST to be considered in Cut Out of RTL.
     * No Cut Out:
     *   Scroller + NB
     *   NB + Scroller
     *     => SystemWindow = NavigationBar's width
     *     => Y = screenSize - (SystemWindow's width + Scroller.getRight())
     * Corner Cut Out or Tall Cut Out:
     *   cut out + Scroller + NB
     *   NB + Scroller + cut out
     *     => SystemWindow = NavigationBar's width
     *     => Y = screenSize - (SystemWindow's width + Scroller.getRight())
     * Double Cut Out:
     *   cut out left + Scroller + (NB + cut out right)
     *     SystemWindow = NavigationBar's width + cut out right width
     *     => Y = screenSize - (SystemWindow's width + Scroller.getRight())
     *   (cut out left + NB) + Scroller + cut out right
     *     SystemWindow = NavigationBar's width + cut out left width
     *     => Y = screenSize - (SystemWindow's width + Scroller.getRight())
     * @return the translation X value for RTL. In theory, it should be negative. i.e. -Y
     */
    private int getRtlTranslation() {
        // TODO: Corner Cut Out still need to handle.
        if (mPoint == null) {
            mPoint = new Point();
        }

        int realDisplaySize = 0;
        if (mStackScroller.getDisplay() != null) {
            mStackScroller.getDisplay().getRealSize(mPoint);
            realDisplaySize = mPoint.x;
        }

        WindowInsets windowInset = mStackScroller.getRootWindowInsets();
        return windowInset.getSystemWindowInsetLeft() + mStackScroller.getRight()
                + windowInset.getSystemWindowInsetRight() - realDisplaySize;
    }

    public void updatePanelTranslation() {
    public void updatePanelTranslation() {
        float newTranslation = mStackScroller.getLeft() + mStackScroller.getTranslationX();
        float newTranslation;
        if (mStackScroller.isLayoutRtl()) {
            newTranslation = getRtlTranslation();
        } else {
            newTranslation = mStackScroller.getLeft();
        }
        newTranslation += mStackScroller.getTranslationX();
        mHeadsUpStatusBarView.setPanelTranslation(newTranslation);
        mHeadsUpStatusBarView.setPanelTranslation(newTranslation);
    }
    }