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

Commit 3e744915 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Status Bar - Wrap visible content in containers"

parents 30e8b42e 248cb1e9
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -60,9 +60,8 @@
        </com.android.systemui.statusbar.phone.userswitcher.StatusBarUserSwitcherContainer>

        <FrameLayout android:id="@+id/system_icons_container"
            android:layout_width="0dp"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:layout_marginEnd="@dimen/status_bar_padding_end"
            android:gravity="center_vertical|end">
            <include layout="@layout/system_icons" />
+4 −13
Original line number Diff line number Diff line
@@ -14,18 +14,9 @@
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License
  -->
<com.android.keyguard.AlphaOptimizedLinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/notification_icon_area_inner"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipChildren="false">
<com.android.systemui.statusbar.phone.NotificationIconContainer
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/notificationIcons"
        android:layout_width="match_parent"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
        android:layout_alignParentStart="true"
        android:gravity="center_vertical"
        android:orientation="horizontal"
    android:clipChildren="false"/>
 No newline at end of file
</com.android.keyguard.AlphaOptimizedLinearLayout>
 No newline at end of file
+91 −65
Original line number Diff line number Diff line
@@ -47,24 +47,35 @@
        android:paddingStart="@dimen/status_bar_padding_start"
        android:paddingEnd="@dimen/status_bar_padding_end"
        android:paddingTop="@dimen/status_bar_padding_top"
        android:orientation="horizontal"
        >
        android:orientation="horizontal">

        <!-- Container for the entire start half of the status bar. It will always use the same
             width, independent of the number of visible children and sub-children. -->
        <FrameLayout
            android:id="@+id/status_bar_start_side_container"
            android:layout_height="match_parent"
            android:layout_width="0dp"
            android:layout_weight="1">

            <!-- Container that is wrapped around the views on the start half of the status bar.
                 Its width will change with the number of visible children and sub-children.
                 It is useful when we want to know the visible bounds of the content. -->
            <FrameLayout
                android:id="@+id/status_bar_start_side_content"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:clipChildren="false">

                <include layout="@layout/heads_up_status_bar_layout" />

            <!-- The alpha of the left side is controlled by PhoneStatusBarTransitions, and the
             individual views are controlled by StatusBarManager disable flags DISABLE_CLOCK and
             DISABLE_NOTIFICATION_ICONS, respectively -->
                <!-- The alpha of the start side is controlled by PhoneStatusBarTransitions, and the
                     individual views are controlled by StatusBarManager disable flags DISABLE_CLOCK
                     and DISABLE_NOTIFICATION_ICONS, respectively -->
                <LinearLayout
                android:id="@+id/status_bar_left_side"
                android:layout_height="match_parent"
                    android:id="@+id/status_bar_start_side_except_heads_up"
                    android:layout_height="wrap_content"
                    android:layout_width="match_parent"
                android:clipChildren="false"
            >
                    android:clipChildren="false">
                    <ViewStub
                        android:id="@+id/operator_name"
                        android:layout_width="wrap_content"
@@ -86,14 +97,14 @@

                    <com.android.systemui.statusbar.AlphaOptimizedFrameLayout
                        android:id="@+id/notification_icon_area"
                    android:layout_width="0dp"
                        android:layout_width="wrap_content"
                        android:layout_height="match_parent"
                    android:layout_weight="1"
                        android:orientation="horizontal"
                        android:clipChildren="false"/>

                </LinearLayout>
            </FrameLayout>
        </FrameLayout>

        <!-- Space should cover the notch (if it exists) and let other views lay out around it -->
        <android.widget.Space
@@ -103,13 +114,27 @@
            android:gravity="center_horizontal|center_vertical"
        />

        <com.android.keyguard.AlphaOptimizedLinearLayout android:id="@+id/system_icon_area"
        <!-- Container for the entire end half of the status bar. It will always use the same
             width, independent of the number of visible children and sub-children. -->
        <FrameLayout
            android:id="@+id/status_bar_end_side_container"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:clipChildren="false">

            <!-- Container that is wrapped around the views on the end half of the
                 status bar. Its width will change with the number of visible children and
                 sub-children.
                 It is useful when we want know the visible bounds of the content.-->
            <com.android.keyguard.AlphaOptimizedLinearLayout
                android:id="@+id/status_bar_end_side_content"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_gravity="end"
                android:orientation="horizontal"
                android:gravity="center_vertical|end"
            >
                android:clipChildren="false">

                <com.android.systemui.statusbar.phone.userswitcher.StatusBarUserSwitcherContainer
                    android:id="@+id/user_switcher_container"
@@ -139,6 +164,7 @@

                <include layout="@layout/system_icons" />
            </com.android.keyguard.AlphaOptimizedLinearLayout>
        </FrameLayout>
    </LinearLayout>

</com.android.systemui.statusbar.phone.PhoneStatusBarView>
+33 −5
Original line number Diff line number Diff line
@@ -13,7 +13,6 @@
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.systemui.statusbar.phone;

import static com.android.systemui.statusbar.phone.HeadsUpAppearanceController.CONTENT_FADE_DELAY;
@@ -31,6 +30,7 @@ import android.util.MathUtils;
import android.util.Property;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Interpolator;

import androidx.annotation.VisibleForTesting;
@@ -40,7 +40,6 @@ import com.android.internal.statusbar.StatusBarIcon;
import com.android.settingslib.Utils;
import com.android.systemui.R;
import com.android.systemui.animation.Interpolators;
import com.android.systemui.statusbar.AlphaOptimizedFrameLayout;
import com.android.systemui.statusbar.StatusBarIconView;
import com.android.systemui.statusbar.notification.stack.AnimationFilter;
import com.android.systemui.statusbar.notification.stack.AnimationProperties;
@@ -54,7 +53,7 @@ import java.util.function.Consumer;
 * A container for notification icons. It handles overflowing icons properly and positions them
 * correctly on the screen.
 */
public class NotificationIconContainer extends AlphaOptimizedFrameLayout {
public class NotificationIconContainer extends ViewGroup {
    /**
     * A float value indicating how much before the overflow start the icons should transform into
     * a dot. A value of 0 means that they are exactly at the end and a value of 1 means it starts
@@ -231,6 +230,31 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout {
        initDimens();
    }

    @Override
    public boolean hasOverlappingRendering() {
        // Does the same as "AlphaOptimizedFrameLayout".
        return false;
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        final int childCount = getChildCount();
        final int maxVisibleIcons = getMaxVisibleIcons(childCount);
        final int width = MeasureSpec.getSize(widthMeasureSpec);
        final int childWidthSpec = MeasureSpec.makeMeasureSpec(width, MeasureSpec.UNSPECIFIED);
        int totalWidth = (int) (getActualPaddingStart() + getActualPaddingEnd());
        for (int i = 0; i < childCount; i++) {
            View child = getChildAt(i);
            measureChild(child, childWidthSpec, heightMeasureSpec);
            if (i <= maxVisibleIcons) {
                totalWidth += child.getMeasuredWidth();
            }
        }
        final int measuredWidth = resolveSize(totalWidth, widthMeasureSpec);
        final int measuredHeight = MeasureSpec.getSize(heightMeasureSpec);
        setMeasuredDimension(measuredWidth, measuredHeight);
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        float centerY = getHeight() / 2.0f;
@@ -408,8 +432,7 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout {
        float translationX = getActualPaddingStart();
        int firstOverflowIndex = -1;
        int childCount = getChildCount();
        int maxVisibleIcons = mOnLockScreen ? MAX_ICONS_ON_AOD :
                mIsStaticLayout ? MAX_STATIC_ICONS : childCount;
        int maxVisibleIcons = getMaxVisibleIcons(childCount);
        float layoutEnd = getLayoutEnd();
        mVisualOverflowStart = 0;
        mFirstVisibleIconState = null;
@@ -493,6 +516,11 @@ public class NotificationIconContainer extends AlphaOptimizedFrameLayout {
        }
    }

    private int getMaxVisibleIcons(int childCount) {
        return mOnLockScreen ? MAX_ICONS_ON_AOD :
                mIsStaticLayout ? MAX_STATIC_ICONS : childCount;
    }

    private float getLayoutEnd() {
        return getActualWidth() - getActualPaddingEnd();
    }
+5 −5
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ public final class PhoneStatusBarTransitions extends BarTransitions {

    private final float mIconAlphaWhenOpaque;

    private View mLeftSide, mStatusIcons, mBattery;
    private View mStartSide, mStatusIcons, mBattery;
    private Animator mCurrentAnimation;

    /**
@@ -41,7 +41,7 @@ public final class PhoneStatusBarTransitions extends BarTransitions {
        super(backgroundView, R.drawable.status_background);
        final Resources res = statusBarView.getContext().getResources();
        mIconAlphaWhenOpaque = res.getFraction(R.dimen.status_bar_icon_drawing_alpha, 1, 1);
        mLeftSide = statusBarView.findViewById(R.id.status_bar_left_side);
        mStartSide = statusBarView.findViewById(R.id.status_bar_start_side_except_heads_up);
        mStatusIcons = statusBarView.findViewById(R.id.statusIcons);
        mBattery = statusBarView.findViewById(R.id.battery);
        applyModeBackground(-1, getMode(), false /*animate*/);
@@ -75,7 +75,7 @@ public final class PhoneStatusBarTransitions extends BarTransitions {
    }

    private void applyMode(int mode, boolean animate) {
        if (mLeftSide == null) return; // pre-init
        if (mStartSide == null) return; // pre-init
        float newAlpha = getNonBatteryClockAlphaFor(mode);
        float newAlphaBC = getBatteryClockAlpha(mode);
        if (mCurrentAnimation != null) {
@@ -84,7 +84,7 @@ public final class PhoneStatusBarTransitions extends BarTransitions {
        if (animate) {
            AnimatorSet anims = new AnimatorSet();
            anims.playTogether(
                    animateTransitionTo(mLeftSide, newAlpha),
                    animateTransitionTo(mStartSide, newAlpha),
                    animateTransitionTo(mStatusIcons, newAlpha),
                    animateTransitionTo(mBattery, newAlphaBC)
                    );
@@ -94,7 +94,7 @@ public final class PhoneStatusBarTransitions extends BarTransitions {
            anims.start();
            mCurrentAnimation = anims;
        } else {
            mLeftSide.setAlpha(newAlpha);
            mStartSide.setAlpha(newAlpha);
            mStatusIcons.setAlpha(newAlpha);
            mBattery.setAlpha(newAlphaBC);
        }
Loading