diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml
index 4a7d09067acb1..803be6ec7e90c 100644
--- a/packages/SystemUI/res/values/colors.xml
+++ b/packages/SystemUI/res/values/colors.xml
@@ -20,6 +20,10 @@
#ffffffff
#ff1d1d1d
#ff000000
+ #55000000
+ #00000000
+ #7f000000
+ #00000000
#ff000000
#88000000
#ffffffff
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java
new file mode 100644
index 0000000000000..74b14b0ae80bf
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BarTransitions.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2013 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.phone;
+
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.drawable.ColorDrawable;
+import android.graphics.drawable.Drawable;
+import android.view.View;
+
+import com.android.systemui.R;
+
+public class BarTransitions {
+
+ public static final int MODE_NORMAL = 0;
+ public static final int MODE_TRANSIENT = 1;
+ public static final int MODE_TRANSPARENT = 2;
+
+ private final View mTarget;
+ private final Drawable mOpaque;
+ private final Drawable mTransient;
+
+ private Drawable mTransparent;
+ private int mMode;
+
+ public BarTransitions(Context context, View target, Drawable transparent) {
+ mTarget = target;
+ final Resources res = context.getResources();
+ mOpaque = new ColorDrawable(res.getColor(R.drawable.status_bar_background));
+ mTransient = new ColorDrawable(res.getColor(R.color.status_bar_background_transient));
+ mTransparent = transparent;
+ }
+
+ public void setTransparent(Drawable transparent) {
+ mTransparent = transparent;
+ if (mMode == MODE_TRANSPARENT) {
+ transitionTo(MODE_TRANSPARENT);
+ }
+ }
+
+ public void transitionTo(int mode) {
+ mMode = mode;
+ if (!ActivityManager.isHighEndGfx()) return;
+ Drawable background = mode == MODE_TRANSIENT ? mTransient
+ : mode == MODE_TRANSPARENT ? mTransparent
+ : mOpaque;
+ mTarget.setBackground(background);
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
index de33b87379071..131713f676a4a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java
@@ -25,6 +25,8 @@ import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.GradientDrawable;
+import android.graphics.drawable.GradientDrawable.Orientation;
import android.os.Handler;
import android.os.Message;
import android.os.ServiceManager;
@@ -79,6 +81,9 @@ public class NavigationBarView extends LinearLayout {
private DelegateViewHelper mDelegateHelper;
private DeadZone mDeadZone;
+ private final BarTransitions mBarTransitions;
+ private final Drawable mTransparent;
+ private final Drawable mTransparentVertical;
// workaround for LayoutTransitions leaving the nav buttons in a weird state (bug 5549288)
final static boolean WORKAROUND_INVALID_LAYOUT = true;
@@ -107,6 +112,37 @@ public class NavigationBarView extends LinearLayout {
}
}
+ public NavigationBarView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+
+ mHidden = false;
+
+ mDisplay = ((WindowManager)context.getSystemService(
+ Context.WINDOW_SERVICE)).getDefaultDisplay();
+ mBarService = IStatusBarService.Stub.asInterface(
+ ServiceManager.getService(Context.STATUS_BAR_SERVICE));
+
+ final Resources res = mContext.getResources();
+ mBarSize = res.getDimensionPixelSize(R.dimen.navigation_bar_size);
+ mVertical = false;
+ mShowMenu = false;
+ mDelegateHelper = new DelegateViewHelper(this);
+
+ getIcons(res);
+
+ final int[] gradientColors = new int[] {
+ res.getColor(R.color.navigation_bar_background_transparent_start),
+ res.getColor(R.color.navigation_bar_background_transparent_end)
+ };
+ mTransparent = new GradientDrawable(Orientation.BOTTOM_TOP, gradientColors);
+ mTransparentVertical = new GradientDrawable(Orientation.RIGHT_LEFT, gradientColors);
+ mBarTransitions = new BarTransitions(context, this, mTransparent);
+ }
+
+ public BarTransitions getBarTransitions() {
+ return mBarTransitions;
+ }
+
public void setDelegateView(View view) {
mDelegateHelper.setDelegateView(view);
}
@@ -155,25 +191,6 @@ public class NavigationBarView extends LinearLayout {
return mCurrentView.findViewById(R.id.search_light);
}
- public NavigationBarView(Context context, AttributeSet attrs) {
- super(context, attrs);
-
- mHidden = false;
-
- mDisplay = ((WindowManager)context.getSystemService(
- Context.WINDOW_SERVICE)).getDefaultDisplay();
- mBarService = IStatusBarService.Stub.asInterface(
- ServiceManager.getService(Context.STATUS_BAR_SERVICE));
-
- final Resources res = mContext.getResources();
- mBarSize = res.getDimensionPixelSize(R.dimen.navigation_bar_size);
- mVertical = false;
- mShowMenu = false;
- mDelegateHelper = new DelegateViewHelper(this);
-
- getIcons(res);
- }
-
private void getIcons(Resources res) {
mBackIcon = res.getDrawable(R.drawable.ic_sysbar_back);
mBackLandIcon = res.getDrawable(R.drawable.ic_sysbar_back_land);
@@ -406,6 +423,7 @@ public class NavigationBarView extends LinearLayout {
}
setNavigationIconHints(mNavigationIconHints, true);
+ mBarTransitions.setTransparent(mVertical ? mTransparentVertical : mTransparent);
}
@Override
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 0a09a5236fc69..74970873f982b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -16,6 +16,10 @@
package com.android.systemui.statusbar.phone;
+import static com.android.systemui.statusbar.phone.BarTransitions.MODE_NORMAL;
+import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSIENT;
+import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT;
+
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
@@ -129,11 +133,6 @@ public class PhoneStatusBar extends BaseStatusBar {
private static final int STATUS_OR_NAV_TRANSIENT =
View.STATUS_BAR_TRANSIENT | View.NAVIGATION_BAR_TRANSIENT;
private static final long AUTOHIDE_TIMEOUT_MS = 3000;
- private static final float TRANSPARENT_ALPHA = 0.7f;
-
- private static final int BAR_MODE_NORMAL = 0;
- private static final int BAR_MODE_TRANSIENT = 1;
- private static final int BAR_MODE_TRANSPARENT = 2;
// fling gesture tuning parameters, scaled to display density
private float mSelfExpandVelocityPx; // classic value: 2000px/s
@@ -1905,16 +1904,16 @@ public class PhoneStatusBar extends BaseStatusBar {
}
// update status bar mode
- int sbMode = updateBarMode(oldVal, newVal, mStatusBarView,
+ int sbMode = updateBarMode(oldVal, newVal, mStatusBarView.getBarTransitions(),
View.STATUS_BAR_TRANSIENT, View.SYSTEM_UI_FLAG_TRANSPARENT_STATUS);
// update navigation bar mode
- int nbMode = updateBarMode(oldVal, newVal, mNavigationBarView,
+ int nbMode = updateBarMode(oldVal, newVal, mNavigationBarView.getBarTransitions(),
View.NAVIGATION_BAR_TRANSIENT, View.SYSTEM_UI_FLAG_TRANSPARENT_NAVIGATION);
if (sbMode != -1 || nbMode != -1) {
// update transient bar autohide
- if (sbMode == BAR_MODE_TRANSIENT || nbMode == BAR_MODE_TRANSIENT) {
+ if (sbMode == MODE_TRANSIENT || nbMode == MODE_TRANSIENT) {
scheduleAutohide();
} else {
cancelAutohide();
@@ -1926,21 +1925,21 @@ public class PhoneStatusBar extends BaseStatusBar {
}
}
- private int updateBarMode(int oldVis, int newVis, View view,
+ private int updateBarMode(int oldVis, int newVis, BarTransitions transitions,
int transientFlag, int transparentFlag) {
final int oldMode = barMode(oldVis, transientFlag, transparentFlag);
final int newMode = barMode(newVis, transientFlag, transparentFlag);
if (oldMode == newMode) {
return -1; // no mode change
}
- setTransparent(view, newMode != BAR_MODE_NORMAL);
+ transitions.transitionTo(newMode);
return newMode;
}
private int barMode(int vis, int transientFlag, int transparentFlag) {
- return (vis & transientFlag) != 0 ? BAR_MODE_TRANSIENT
- : (vis & transparentFlag) != 0 ? BAR_MODE_TRANSPARENT
- : BAR_MODE_NORMAL;
+ return (vis & transientFlag) != 0 ? MODE_TRANSIENT
+ : (vis & transparentFlag) != 0 ? MODE_TRANSPARENT
+ : MODE_NORMAL;
}
@Override
@@ -1980,13 +1979,6 @@ public class PhoneStatusBar extends BaseStatusBar {
mHandler.postDelayed(mAutohide, 25);
}
- private void setTransparent(View view, boolean transparent) {
- float alpha = transparent ? TRANSPARENT_ALPHA : 1;
- if (DEBUG) Log.d(TAG, "Setting " + (view == mStatusBarView ? "status bar" :
- view == mNavigationBarView ? "navigation bar" : "view") + " alpha to " + alpha);
- view.setAlpha(alpha);
- }
-
private void setStatusBarLowProfile(boolean lightsOut) {
if (mLightsOutAnimation == null) {
final View notifications = mStatusBarView.findViewById(R.id.notification_icon_area);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index 1554e2cf02046..ea84c5cfc12ca 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -17,10 +17,10 @@
package com.android.systemui.statusbar.phone;
import android.app.ActivityManager;
-import android.app.StatusBarManager;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.Resources.NotFoundException;
+import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.EventLog;
import android.util.Log;
@@ -46,6 +46,7 @@ public class PhoneStatusBarView extends PanelBar {
PanelView mLastFullyOpenedPanel = null;
PanelView mNotificationPanel, mSettingsPanel;
private boolean mShouldFade;
+ private final BarTransitions mBarTransitions;
public PhoneStatusBarView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -59,6 +60,12 @@ public class PhoneStatusBarView extends PanelBar {
mSettingsPanelDragzoneFrac = 0f;
}
mFullWidthNotifications = mSettingsPanelDragzoneFrac <= 0f;
+ final Drawable transparent = res.getDrawable(R.color.status_bar_background_transparent);
+ mBarTransitions = new BarTransitions(context, this, transparent);
+ }
+
+ public BarTransitions getBarTransitions() {
+ return mBarTransitions;
}
public void setBar(PhoneStatusBar bar) {