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

Commit 5d699587 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Keep a mirror of the system icons while expanding the panel"

parents f866e1e0 605f1902
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -69,19 +69,24 @@
        android:src="@drawable/ic_settings_24dp"
        android:contentDescription="@string/accessibility_desc_quick_settings"/>

    <FrameLayout android:id="@+id/system_icons_container"
    <FrameLayout android:id="@+id/system_icons_super_container"
        android:layout_width="wrap_content"
        android:layout_height="@dimen/status_bar_header_height"
        android:layout_toStartOf="@id/multi_user_switch"
        android:layout_alignWithParentIfMissing="true"
        android:layout_marginStart="16dp"
        android:paddingEnd="2dp" />
        android:paddingEnd="2dp">
        <FrameLayout android:id="@+id/system_icons_container"
            android:layout_width="wrap_content"
            android:layout_height="@dimen/status_bar_height"
            android:layout_gravity="center_vertical"/>
    </FrameLayout>

    <TextView
        android:id="@+id/header_charging_info"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toEndOf="@id/system_icons_container"
        android:layout_toEndOf="@id/system_icons_super_container"
        android:layout_below="@id/header_spacer"
        android:paddingTop="12dp"
        android:paddingEnd="16dp"
+60 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License
 */

package com.android.systemui.statusbar;

import android.content.Context;
import android.graphics.Canvas;
import android.view.View;

/**
 * A view that mirrors the visual contents of another one. Should be used for animation purposes
 * only, as this view doesn't have any input handling.
 */
public class MirrorView extends View {

    private View mView;
    private int mFixedWidth;
    private int mFixedHeight;

    public MirrorView(Context context) {
        super(context);
    }

    public void setMirroredView(View v, int width, int height) {
        mView = v;
        mFixedWidth = width;
        mFixedHeight = height;
        requestLayout();
        invalidate();
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (mView != null) {
            setMeasuredDimension(mFixedWidth, mFixedHeight);
        } else {
            setMeasuredDimension(0, 0);
        }
    }

    @Override
    protected void onDraw(Canvas canvas) {
        if (mView != null) {
            mView.draw(canvas);
        }
    }
}
+16 −4
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import com.android.systemui.R;
import com.android.systemui.statusbar.ExpandableView;
import com.android.systemui.statusbar.FlingAnimationUtils;
import com.android.systemui.statusbar.GestureRecorder;
import com.android.systemui.statusbar.MirrorView;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.stack.StackStateAnimator;
@@ -64,6 +65,8 @@ public class NotificationPanelView extends PanelView implements
    private ObservableScrollView mScrollView;
    private TextView mClockView;

    private MirrorView mSystemIconsCopy;

    private NotificationStackScrollLayout mNotificationStackScroller;
    private int mNotificationTopPadding;
    private boolean mAnimateNextTopPaddingChange;
@@ -118,6 +121,7 @@ public class NotificationPanelView extends PanelView implements

    public NotificationPanelView(Context context, AttributeSet attrs) {
        super(context, attrs);
        mSystemIconsCopy = new MirrorView(context);
    }

    public void setStatusBar(PhoneStatusBar bar) {
@@ -692,14 +696,22 @@ public class NotificationPanelView extends PanelView implements
            return;
        }
        LinearLayout systemIcons = mStatusBar.getSystemIcons();
        if (systemIcons.getParent() != null) {
            ((ViewGroup) systemIcons.getParent()).removeView(systemIcons);
        }
        ViewGroup parent = ((ViewGroup) systemIcons.getParent());
        if (toHeader) {
            int index = parent.indexOfChild(systemIcons);
            parent.removeView(systemIcons);
            mSystemIconsCopy.setMirroredView(
                    systemIcons, systemIcons.getWidth(), systemIcons.getHeight());
            parent.addView(mSystemIconsCopy, index);
            mHeader.attachSystemIcons(systemIcons);
        } else {
            ViewGroup newParent = mStatusBar.getSystemIconArea();
            int index = newParent.indexOfChild(mSystemIconsCopy);
            parent.removeView(systemIcons);
            mHeader.onSystemIconsDetached();
            mStatusBar.reattachSystemIcons();
            mSystemIconsCopy.setMirroredView(null, 0, 0);
            newParent.removeView(mSystemIconsCopy);
            newParent.addView(systemIcons, index);
        }
    }

+2 −5
Original line number Diff line number Diff line
@@ -3086,11 +3086,8 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
        return mSystemIcons;
    }

    /**
     * Reattaches the system icons to its normal parent in collapsed status bar.
     */
    public void reattachSystemIcons() {
        mSystemIconArea.addView(mSystemIcons, 0);
    public LinearLayout getSystemIconArea() {
        return mSystemIconArea;
    }

    @Override
+6 −4
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL

    private View mBackground;
    private ViewGroup mSystemIconsContainer;
    private View mSystemIconsSuperContainer;
    private View mDateTime;
    private View mKeyguardCarrierText;
    private MultiUserSwitch mMultiUserSwitch;
@@ -90,6 +91,7 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
    protected void onFinishInflate() {
        super.onFinishInflate();
        mBackground = findViewById(R.id.background);
        mSystemIconsSuperContainer = findViewById(R.id.system_icons_super_container);
        mSystemIconsContainer = (ViewGroup) findViewById(R.id.system_icons_container);
        mDateTime = findViewById(R.id.datetime);
        mKeyguardCarrierText = findViewById(R.id.keyguard_carrier_text);
@@ -180,10 +182,10 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
            setLayoutParams(lp);
        }
        int systemIconsContainerHeight = onKeyguardAndCollapsed ? mKeyguardHeight : mCollapsedHeight;
        lp = mSystemIconsContainer.getLayoutParams();
        lp = mSystemIconsSuperContainer.getLayoutParams();
        if (lp.height != systemIconsContainerHeight) {
            lp.height = systemIconsContainerHeight;
            mSystemIconsContainer.setLayoutParams(lp);
            mSystemIconsSuperContainer.setLayoutParams(lp);
        }
        lp = mMultiUserSwitch.getLayoutParams();
        if (lp.height != systemIconsContainerHeight) {
@@ -224,7 +226,7 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
    }

    private void updateSystemIconsLayoutParams() {
        RelativeLayout.LayoutParams lp = (LayoutParams) mSystemIconsContainer.getLayoutParams();
        RelativeLayout.LayoutParams lp = (LayoutParams) mSystemIconsSuperContainer.getLayoutParams();
        boolean systemIconsAboveClock = mExpanded && !mOverscrolled
                && mShowChargingInfo && !mShowEmergencyCallsOnly;
        lp.setMarginEnd(0);
@@ -240,7 +242,7 @@ public class StatusBarHeaderView extends RelativeLayout implements View.OnClickL
                lp.setMarginEnd(mSystemIconsSwitcherHiddenExpandedMargin);
            }
        }
        mSystemIconsContainer.setLayoutParams(lp);
        mSystemIconsSuperContainer.setLayoutParams(lp);

        RelativeLayout.LayoutParams clockLp = (LayoutParams) mDateTime.getLayoutParams();
        if (systemIconsAboveClock) {