<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_semi_transparent">#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>
private static final boolean DEBUG = false;
public static final int MODE_NORMAL = 0;
- public static final int MODE_TRANSIENT = 1;
+ public static final int MODE_SEMI_TRANSPARENT = 1;
public static final int MODE_TRANSPARENT = 2;
private final String mTag;
private final View mTarget;
private final Drawable mOpaque;
- private final Drawable mTransient;
+ private final Drawable mSemiTransparent;
- private Drawable mTransparent;
+ protected Drawable mTransparent;
private int mMode;
- public BarTransitions(Context context, View target, Drawable transparent) {
+ public BarTransitions(Context context, View target) {
mTag = "BarTransitions." + target.getClass().getSimpleName();
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;
+ mSemiTransparent =
+ new ColorDrawable(res.getColor(R.color.status_bar_background_semi_transparent));
}
public void setTransparent(Drawable transparent) {
}
public void transitionTo(int mode) {
+ if (mMode == mode) return;
+ int oldMode = mMode;
mMode = mode;
if (!ActivityManager.isHighEndGfx()) return;
- if (DEBUG) Log.d(mTag, "transitionTo " + modeToString(mode));
- Drawable background = mode == MODE_TRANSIENT ? mTransient
- : mode == MODE_TRANSPARENT ? mTransparent
+ if (DEBUG) Log.d(mTag, String.format("transition from %s to %s",
+ modeToString(oldMode), modeToString(mode)));
+ onTransition(oldMode, mMode);
+ }
+
+ protected void onTransition(int oldMode, int newMode) {
+ Drawable background = newMode == MODE_SEMI_TRANSPARENT ? mSemiTransparent
+ : newMode == MODE_TRANSPARENT ? mTransparent
: mOpaque;
mTarget.setBackground(background);
}
public static String modeToString(int mode) {
if (mode == MODE_NORMAL) return "MODE_NORMAL";
- if (mode == MODE_TRANSIENT) return "MODE_TRANSIENT";
+ if (mode == MODE_SEMI_TRANSPARENT) return "MODE_SEMI_TRANSPARENT";
if (mode == MODE_TRANSPARENT) return "MODE_TRANSPARENT";
throw new IllegalArgumentException("Unknown mode " + mode);
}
import com.android.systemui.statusbar.BaseStatusBar;
import com.android.systemui.statusbar.DelegateViewHelper;
import com.android.systemui.statusbar.policy.DeadZone;
+import com.android.systemui.statusbar.policy.KeyButtonView;
import java.io.FileDescriptor;
import java.io.PrintWriter;
private DelegateViewHelper mDelegateHelper;
private DeadZone mDeadZone;
- private final BarTransitions mBarTransitions;
- private final Drawable mTransparent;
- private final Drawable mTransparentVertical;
+ private final NavigationBarTransitions mBarTransitions;
// workaround for LayoutTransitions leaving the nav buttons in a weird state (bug 5549288)
final static boolean WORKAROUND_INVALID_LAYOUT = true;
}
}
+ private final class NavigationBarTransitions extends BarTransitions {
+
+ private final Drawable mTransparentBottom;
+ private final Drawable mTransparentRight;
+
+ public NavigationBarTransitions(Context context) {
+ super(context, NavigationBarView.this);
+ final Resources res = mContext.getResources();
+ final int[] gradientColors = new int[] {
+ res.getColor(R.color.navigation_bar_background_transparent_start),
+ res.getColor(R.color.navigation_bar_background_transparent_end)
+ };
+ mTransparentBottom = new GradientDrawable(Orientation.BOTTOM_TOP, gradientColors);
+ mTransparentRight = new GradientDrawable(Orientation.RIGHT_LEFT, gradientColors);
+ }
+
+ public void setVertical(boolean isVertical) {
+ mTransparent = isVertical ? mTransparentRight : mTransparentBottom;
+ }
+
+ @Override
+ protected void onTransition(int oldMode, int newMode) {
+ super.onTransition(oldMode, newMode);
+ final float alpha = newMode == MODE_NORMAL ? KeyButtonView.DEFAULT_QUIESCENT_ALPHA : 1f;
+ setKeyButtonViewQuiescentAlpha(getBackButton(), alpha);
+ setKeyButtonViewQuiescentAlpha(getHomeButton(), alpha);
+ setKeyButtonViewQuiescentAlpha(getRecentsButton(), alpha);
+ setKeyButtonViewQuiescentAlpha(getMenuButton(), alpha);
+ }
+
+ private void setKeyButtonViewQuiescentAlpha(View button, float alpha) {
+ if (button instanceof KeyButtonView) {
+ ((KeyButtonView) button).setQuiescentAlpha(alpha);
+ }
+ }
+ }
+
public NavigationBarView(Context context, AttributeSet attrs) {
super(context, attrs);
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);
+ mBarTransitions = new NavigationBarTransitions(context);
}
public BarTransitions getBarTransitions() {
}
setNavigationIconHints(mNavigationIconHints, true);
- mBarTransitions.setTransparent(mVertical ? mTransparentVertical : mTransparent);
+ mBarTransitions.setVertical(mVertical);
}
@Override
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_SEMI_TRANSPARENT;
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT;
import android.animation.Animator;
if (sbMode != -1 || nbMode != -1) {
// update transient bar autohide
- if (sbMode == MODE_TRANSIENT || nbMode == MODE_TRANSIENT) {
+ if (sbMode == MODE_SEMI_TRANSPARENT || nbMode == MODE_SEMI_TRANSPARENT) {
scheduleAutohide();
} else {
cancelAutohide();
}
private int barMode(int vis, int transientFlag, int transparentFlag) {
- return (vis & transientFlag) != 0 ? MODE_TRANSIENT
+ return (vis & transientFlag) != 0 ? MODE_SEMI_TRANSPARENT
: (vis & transparentFlag) != 0 ? MODE_TRANSPARENT
: MODE_NORMAL;
}
PanelView mLastFullyOpenedPanel = null;
PanelView mNotificationPanel, mSettingsPanel;
private boolean mShouldFade;
- private final BarTransitions mBarTransitions;
+ private final StatusBarTransitions mBarTransitions;
+
+ private final class StatusBarTransitions extends BarTransitions {
+ public StatusBarTransitions(Context context) {
+ super(context, PhoneStatusBarView.this);
+ final Resources res = context.getResources();
+ mTransparent = res.getDrawable(R.color.status_bar_background_transparent);
+ }
+ }
public PhoneStatusBarView(Context context, AttributeSet attrs) {
super(context, attrs);
mSettingsPanelDragzoneFrac = 0f;
}
mFullWidthNotifications = mSettingsPanelDragzoneFrac <= 0f;
- final Drawable transparent = res.getDrawable(R.color.status_bar_background_transparent);
- mBarTransitions = new BarTransitions(context, this, transparent);
+ mBarTransitions = new StatusBarTransitions(context);
}
public BarTransitions getBarTransitions() {
package com.android.systemui.statusbar.policy;
+import android.animation.Animator;
+import android.animation.Animator.AnimatorListener;
+import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.hardware.input.InputManager;
import android.os.SystemClock;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.HapticFeedbackConstants;
import android.view.InputDevice;
import android.view.KeyCharacterMap;
public class KeyButtonView extends ImageView {
private static final String TAG = "StatusBar.KeyButtonView";
+ private static final boolean DEBUG = false;
final float GLOW_MAX_SCALE_FACTOR = 1.8f;
- final float BUTTON_QUIESCENT_ALPHA = 0.70f;
+ public static final float DEFAULT_QUIESCENT_ALPHA = 0.70f;
long mDownTime;
int mCode;
Drawable mGlowBG;
int mGlowWidth, mGlowHeight;
float mGlowAlpha = 0f, mGlowScale = 1f, mDrawingAlpha = 1f;
+ float mQuiescentAlpha = DEFAULT_QUIESCENT_ALPHA;
boolean mSupportsLongpress = true;
RectF mRect = new RectF(0f,0f,0f,0f);
AnimatorSet mPressedAnim;
}
};
+ private final AnimatorListener mRecoverToQuiescentListener = new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ if (mQuiescentAlpha != mDrawingAlpha) {
+ animateToQuiescent().setDuration(200).start();
+ }
+ }
+ };
+
public KeyButtonView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
mGlowBG = a.getDrawable(R.styleable.KeyButtonView_glowBackground);
if (mGlowBG != null) {
- setDrawingAlpha(BUTTON_QUIESCENT_ALPHA);
+ setDrawingAlpha(mQuiescentAlpha);
mGlowWidth = mGlowBG.getIntrinsicWidth();
mGlowHeight = mGlowBG.getIntrinsicHeight();
}
super.onDraw(canvas);
}
+ public void setQuiescentAlpha(float alpha) {
+ alpha = Math.min(Math.max(alpha, 0), 1);
+ if (alpha == mQuiescentAlpha) return;
+ mQuiescentAlpha = alpha;
+ if (DEBUG) Log.d(TAG, "New quiescent alpha = " + mQuiescentAlpha);
+ if (mGlowBG != null) {
+ setDrawingAlpha(mQuiescentAlpha);
+ }
+ }
+
public float getDrawingAlpha() {
if (mGlowBG == null) return 0;
return mDrawingAlpha;
}
}
+ private ObjectAnimator animateToQuiescent() {
+ ObjectAnimator anim = ObjectAnimator.ofFloat(this, "drawingAlpha", mQuiescentAlpha);
+ anim.addListener(mRecoverToQuiescentListener); // mQuiescentAlpha may change mid-animation
+ return anim;
+ }
+
public void setPressed(boolean pressed) {
if (mGlowBG != null) {
if (pressed != isPressed()) {
if (pressed) {
if (mGlowScale < GLOW_MAX_SCALE_FACTOR)
mGlowScale = GLOW_MAX_SCALE_FACTOR;
- if (mGlowAlpha < BUTTON_QUIESCENT_ALPHA)
- mGlowAlpha = BUTTON_QUIESCENT_ALPHA;
+ if (mGlowAlpha < mQuiescentAlpha)
+ mGlowAlpha = mQuiescentAlpha;
setDrawingAlpha(1f);
as.playTogether(
ObjectAnimator.ofFloat(this, "glowAlpha", 1f),
as.playTogether(
ObjectAnimator.ofFloat(this, "glowAlpha", 0f),
ObjectAnimator.ofFloat(this, "glowScale", 1f),
- ObjectAnimator.ofFloat(this, "drawingAlpha", BUTTON_QUIESCENT_ALPHA)
+ animateToQuiescent()
);
as.setDuration(500);
}