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

Commit e2808789 authored by Chris Göllner's avatar Chris Göllner Committed by Chris Göllner
Browse files

[Status Bar] Implement per-rotation bottom aligned margin configuration

This allows to have bottom aligned status bar content. Will be used when
the content shouldn't be centered vertically within the status bar.

A bottom margin of 0 means that the content will be aligned to the
bottom of the status bar.
A bottom margin of < 0 means that the value will be ignored, and that
the content will be centered vertically.

Change-Id: Ic252d47e3367fe81a833235b0ed05ef535fc9a0e
Test: Manual
Test: Unit tests on this CL
Bug: 309775101
Flag: NONE
parent 5d46b5c6
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -124,6 +124,25 @@
    <dimen name="navigation_edge_cancelled_arrow_height">0dp</dimen>
    <dimen name="navigation_edge_cancelled_edge_corners">6dp</dimen>

    <!--
         NOTICE: STATUS BAR INTERNALS. DO NOT READ THESE OUTSIDE OF STATUS BAR.

         Below are the bottom margin values for each rotation [1].
         Only used when the value is >= 0.
         A value of 0 means that the content has 0 bottom margin, and will be at the bottom of the
         status bar.
         When the value is < 0, the value is ignored, and content will be centered vertically.

         [1] Rotation defined as in android.view.Surface.Rotation.
         Rotation 0 means natural orientation. If a device is naturally portrait (e.g. a phone),
         rotation 0 is portrait. If a device is naturally landscape (e.g a tablet), rotation 0 is
         landscape.
     -->
    <dimen name="status_bar_bottom_aligned_margin_rotation_0">-1px</dimen>
    <dimen name="status_bar_bottom_aligned_margin_rotation_90">-1px</dimen>
    <dimen name="status_bar_bottom_aligned_margin_rotation_180">-1px</dimen>
    <dimen name="status_bar_bottom_aligned_margin_rotation_270">-1px</dimen>

    <!-- Height of the system icons container view in the status bar -->
    <dimen name="status_bar_system_icons_height">@dimen/status_bar_icon_size_sp</dimen>

+4 −4
Original line number Diff line number Diff line
@@ -23,11 +23,11 @@ import android.app.PendingIntent
import android.app.StatusBarManager
import android.content.Intent
import android.content.res.Configuration
import android.graphics.Insets
import android.os.Bundle
import android.os.Trace
import android.os.Trace.TRACE_TAG_APP
import android.provider.AlarmClock
import android.util.Pair
import android.view.DisplayCutout
import android.view.View
import android.view.WindowInsets
@@ -402,9 +402,9 @@ constructor(
    private fun updateConstraintsForInsets(view: MotionLayout, insets: WindowInsets) {
        val cutout = insets.displayCutout.also { this.cutout = it }

        val sbInsets: Pair<Int, Int> = insetsProvider.getStatusBarContentInsetsForCurrentRotation()
        val cutoutLeft = sbInsets.first
        val cutoutRight = sbInsets.second
        val sbInsets: Insets = insetsProvider.getStatusBarContentInsetsForCurrentRotation()
        val cutoutLeft = sbInsets.left
        val cutoutRight = sbInsets.right
        val hasCornerCutout: Boolean = insetsProvider.currentRotationHasCornerCutout()
        updateQQSPaddings()
        // Set these guides as the left/right limits for content that lives in the top row, using
+4 −0
Original line number Diff line number Diff line
@@ -278,6 +278,7 @@ open class PrivacyDotViewController @Inject constructor(
        var contentInsets = state.contentRectForRotation(rot)
        tl.setPadding(0, state.paddingTop, 0, 0)
        (tl.layoutParams as FrameLayout.LayoutParams).apply {
            topMargin = contentInsets.top
            height = contentInsets.height()
            if (rtl) {
                width = contentInsets.left
@@ -290,6 +291,7 @@ open class PrivacyDotViewController @Inject constructor(
        contentInsets = state.contentRectForRotation(rot)
        tr.setPadding(0, state.paddingTop, 0, 0)
        (tr.layoutParams as FrameLayout.LayoutParams).apply {
            topMargin = contentInsets.top
            height = contentInsets.height()
            if (rtl) {
                width = contentInsets.left
@@ -302,6 +304,7 @@ open class PrivacyDotViewController @Inject constructor(
        contentInsets = state.contentRectForRotation(rot)
        br.setPadding(0, state.paddingTop, 0, 0)
        (br.layoutParams as FrameLayout.LayoutParams).apply {
            topMargin = contentInsets.top
            height = contentInsets.height()
            if (rtl) {
                width = contentInsets.left
@@ -314,6 +317,7 @@ open class PrivacyDotViewController @Inject constructor(
        contentInsets = state.contentRectForRotation(rot)
        bl.setPadding(0, state.paddingTop, 0, 0)
        (bl.layoutParams as FrameLayout.LayoutParams).apply {
            topMargin = contentInsets.top
            height = contentInsets.height()
            if (rtl) {
                width = contentInsets.left
+3 −3
Original line number Diff line number Diff line
@@ -87,8 +87,8 @@ class SystemEventChipAnimationController @Inject constructor(
            animationWindowView.addView(
                    it.view,
                    layoutParamsDefault(
                            if (animationWindowView.isLayoutRtl) insets.first
                            else insets.second))
                            if (animationWindowView.isLayoutRtl) insets.left
                            else insets.right))
            it.view.alpha = 0f
            // For some reason, the window view's measured width is always 0 here, so use the
            // parent (status bar)
@@ -289,7 +289,7 @@ class SystemEventChipAnimationController @Inject constructor(
     */
    private fun updateChipBounds(chip: BackgroundAnimatableView, contentArea: Rect) {
        // decide which direction we're animating from, and then set some screen coordinates
        val chipTop = (contentArea.bottom - chip.view.measuredHeight) / 2
        val chipTop = contentArea.top + (contentArea.height() - chip.view.measuredHeight) / 2
        val chipBottom = chipTop + chip.view.measuredHeight
        val chipRight: Int
        val chipLeft: Int
+5 −5
Original line number Diff line number Diff line
@@ -24,11 +24,11 @@ import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Insets;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Trace;
import android.util.AttributeSet;
import android.util.Pair;
import android.util.TypedValue;
import android.view.DisplayCutout;
import android.view.Gravity;
@@ -103,7 +103,7 @@ public class KeyguardStatusBarView extends RelativeLayout {
    private DisplayCutout mDisplayCutout;
    private int mRoundedCornerPadding = 0;
    // right and left padding applied to this view to account for cutouts and rounded corners
    private Pair<Integer, Integer> mPadding = new Pair(0, 0);
    private Insets mPadding = Insets.of(0, 0, 0, 0);

    /**
     * The clipping on the top
@@ -184,7 +184,7 @@ public class KeyguardStatusBarView extends RelativeLayout {

        int marginStart = calculateMargin(
                getResources().getDimensionPixelSize(R.dimen.keyguard_carrier_text_margin),
                mPadding.first);
                mPadding.left);
        lp.setMarginStart(marginStart);

        mCarrierLabel.setLayoutParams(lp);
@@ -303,9 +303,9 @@ public class KeyguardStatusBarView extends RelativeLayout {

        // consider privacy dot space
        final int minLeft = (isLayoutRtl() && mIsPrivacyDotEnabled)
                ? Math.max(mMinDotWidth, mPadding.first) : mPadding.first;
                ? Math.max(mMinDotWidth, mPadding.left) : mPadding.left;
        final int minRight = (!isLayoutRtl() && mIsPrivacyDotEnabled)
                ? Math.max(mMinDotWidth, mPadding.second) : mPadding.second;
                ? Math.max(mMinDotWidth, mPadding.right) : mPadding.right;

        setPadding(minLeft, waterfallTop, minRight, 0);
    }
Loading