Use separate icon group for signal/battery in QS header
This reverts the terrible hack that reattaches the system icons when
expanding QS. This primarily fixes that the alpha of the icons was
wrong when closing the shade, but also fixes flickering when expanding
the shade.
Bug: 17338013
Change-Id: Ifcbe03eca43ed7639059734e23d740c1b8a7a9de
diff --git a/packages/SystemUI/res/layout/status_bar_expanded_header.xml b/packages/SystemUI/res/layout/status_bar_expanded_header.xml
index f9e7852..7ad3a89 100644
--- a/packages/SystemUI/res/layout/status_bar_expanded_header.xml
+++ b/packages/SystemUI/res/layout/status_bar_expanded_header.xml
@@ -64,7 +64,10 @@
<FrameLayout android:id="@+id/system_icons_container"
android:layout_width="wrap_content"
android:layout_height="@dimen/status_bar_height"
- android:layout_gravity="center_vertical" />
+ android:layout_gravity="center_vertical"
+ >
+ <include layout="@layout/system_icons" />
+ </FrameLayout>
<TextView android:id="@+id/battery_level"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/MirrorView.java b/packages/SystemUI/src/com/android/systemui/statusbar/MirrorView.java
deleted file mode 100644
index 8b0df06..0000000
--- a/packages/SystemUI/src/com/android/systemui/statusbar/MirrorView.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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);
- }
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index d3c3f56..5a94395 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -28,21 +28,19 @@
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
-import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
import android.widget.FrameLayout;
-import android.widget.LinearLayout;
import android.widget.TextView;
+
import com.android.systemui.R;
import com.android.systemui.qs.QSPanel;
import com.android.systemui.statusbar.ExpandableView;
import com.android.systemui.statusbar.FlingAnimationUtils;
import com.android.systemui.statusbar.GestureRecorder;
import com.android.systemui.statusbar.KeyguardAffordanceView;
-import com.android.systemui.statusbar.MirrorView;
import com.android.systemui.statusbar.StatusBarState;
import com.android.systemui.statusbar.policy.KeyguardUserSwitcher;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
@@ -71,7 +69,6 @@
private ObservableScrollView mScrollView;
private TextView mClockView;
private View mReserveNotificationSpace;
- private MirrorView mSystemIconsCopy;
private View mQsNavbarScrim;
private View mNotificationContainerParent;
private NotificationStackScrollLayout mNotificationStackScroller;
@@ -165,7 +162,6 @@
public NotificationPanelView(Context context, AttributeSet attrs) {
super(context, attrs);
- mSystemIconsCopy = new MirrorView(context);
}
public void setStatusBar(PhoneStatusBar bar) {
@@ -1168,43 +1164,6 @@
}
@Override
- public void setVisibility(int visibility) {
- int oldVisibility = getVisibility();
- super.setVisibility(visibility);
- if (visibility != oldVisibility) {
- reparentStatusIcons(visibility == VISIBLE);
- }
- }
-
- /**
- * When the notification panel gets expanded, we need to move the status icons in the header
- * card.
- */
- private void reparentStatusIcons(boolean toHeader) {
- if (mStatusBar == null) {
- return;
- }
- LinearLayout systemIcons = mStatusBar.getSystemIcons();
- 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();
- mSystemIconsCopy.setMirroredView(null, 0, 0);
- newParent.removeView(mSystemIconsCopy);
- newParent.addView(systemIcons, index);
- }
- }
-
- @Override
protected boolean isScrolledToBottom() {
if (mStatusBar.getBarState() == StatusBarState.KEYGUARD) {
return true;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 8c7dad9..3b24bfd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -779,10 +779,14 @@
(SignalClusterView) mStatusBarView.findViewById(R.id.signal_cluster);
final SignalClusterView signalClusterKeyguard =
(SignalClusterView) mKeyguardStatusBar.findViewById(R.id.signal_cluster);
+ final SignalClusterView signalClusterQs =
+ (SignalClusterView) mHeader.findViewById(R.id.signal_cluster);
mNetworkController.addSignalCluster(signalCluster);
mNetworkController.addSignalCluster(signalClusterKeyguard);
+ mNetworkController.addSignalCluster(signalClusterQs);
signalCluster.setNetworkController(mNetworkController);
signalClusterKeyguard.setNetworkController(mNetworkController);
+ signalClusterQs.setNetworkController(mNetworkController);
final boolean isAPhone = mNetworkController.hasVoiceCallingFeature();
if (isAPhone) {
mNetworkController.addEmergencyLabelView(mHeader);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
index b6792f5..eeb97e3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarHeaderView.java
@@ -39,6 +39,7 @@
import android.widget.TextView;
import com.android.keyguard.KeyguardStatusView;
+import com.android.systemui.BatteryMeterView;
import com.android.systemui.FontSizeUtils;
import com.android.systemui.R;
import com.android.systemui.qs.QSPanel;
@@ -67,7 +68,6 @@
private TextView mDateCollapsed;
private TextView mDateExpanded;
private LinearLayout mSystemIcons;
- private View mStatusIcons;
private View mSignalCluster;
private View mSettingsButton;
private View mQsDetailHeader;
@@ -149,6 +149,8 @@
mBatteryLevel = (TextView) findViewById(R.id.battery_level);
mAlarmStatus = (TextView) findViewById(R.id.alarm_status);
mAlarmStatus.setOnClickListener(this);
+ mSignalCluster = findViewById(R.id.signal_cluster);
+ mSystemIcons = (LinearLayout) findViewById(R.id.system_icons);
loadDimens();
updateVisibilities();
updateClockScale();
@@ -259,6 +261,7 @@
public void setBatteryController(BatteryController batteryController) {
mBatteryController = batteryController;
+ ((BatteryMeterView) findViewById(R.id.battery)).setBatteryController(batteryController);
}
public void setNextAlarmController(NextAlarmController nextAlarmController) {
@@ -476,36 +479,6 @@
invalidateOutline();
}
- public void attachSystemIcons(LinearLayout systemIcons) {
- mSystemIconsContainer.addView(systemIcons);
- mStatusIcons = systemIcons.findViewById(R.id.statusIcons);
- mSignalCluster = systemIcons.findViewById(R.id.signal_cluster);
- mSystemIcons = systemIcons;
- updateVisibilities();
- if (mStatusIcons != null) {
- mStatusIcons.setVisibility(View.GONE);
- }
- }
-
- public void onSystemIconsDetached() {
- if (mSignalClusterDetached) {
- reattachSignalCluster();
- mSignalClusterDetached = false;
- }
- if (mStatusIcons != null) {
- mStatusIcons.setVisibility(View.VISIBLE);
- }
- if (mSignalCluster != null) {
- mSignalCluster.setVisibility(View.VISIBLE);
- mSignalCluster.setAlpha(1f);
- mSignalCluster.setTranslationX(0f);
- mSignalCluster.setTranslationY(0f);
- }
- mStatusIcons = null;
- mSignalCluster = null;
- mSystemIcons = null;
- }
-
public void setUserInfoController(UserInfoController userInfoController) {
userInfoController.addListener(new UserInfoController.OnUserInfoChangedListener() {
@Override