Distinguish transient + transparent bar styles.

Transient bars = 30% black scrim per spec (formerly view alpha).
Transparent nav bar = Simple gradient drawable from 50% to 0% black.
Transparent status bar = Fully transparent.

Smoother transitions between bar modes will be tricky due to
coordination with window manager, and thus deferred to a separate
future change.

Pre-baked assets instead of the gradient drawable will also be
part of a separate future change, this change is simply meant to
move closer to the final look and feel to minimize confusion for
those kicking the tires on the new flags.

Bug:10012887
Change-Id: I8c35a660187903224a6bfe604b5313e9115c4a73
This commit is contained in:
John Spurlock
2013-08-12 10:16:29 -04:00
parent 34e13d90ed
commit e932e30ead
5 changed files with 125 additions and 40 deletions

View File

@@ -20,6 +20,10 @@
<drawable name="notification_number_text_color">#ffffffff</drawable>
<drawable name="ticker_background_color">#ff1d1d1d</drawable>
<drawable name="status_bar_background">#ff000000</drawable>
<color name="status_bar_background_transient">#55000000</color>
<color name="status_bar_background_transparent">#00000000</color>
<color name="navigation_bar_background_transparent_start">#7f000000</color>
<color name="navigation_bar_background_transparent_end">#00000000</color>
<color name="notification_panel_solid_background">#ff000000</color>
<drawable name="status_bar_recents_app_thumbnail_background">#88000000</drawable>
<color name="status_bar_recents_app_label_color">#ffffffff</color>

View File

@@ -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);
}
}

View File

@@ -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

View File

@@ -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);

View File

@@ -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) {