Fix issue #2544466: Car Home brightness icon comes and goes while phone is in car dock in FRE83
There was a really dumb bug that was causing us to not always apply the new configuration. As a result of fixing this, there were new glithes in the transition between car and regular mode, so further work here to fix that. And since I was actually working during the night and seeing night mode, I noticed how obnoxiously bright the status bar is compared to the car home at night, so it now nicely dims itself when we switch to the night config. Oh and in doing that I also found and fixed a bug in dispatching config changes to a window (where they wouldn't get dispatched if the window didn't resize). FINALLY... tweak the wallpaper enter/exit animations a bit to make them a little smoother. Change-Id: I234458f6081ec021311ee04c247931eabcf0447c
This commit is contained in:
@@ -17,9 +17,10 @@
|
||||
package com.android.server.status;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Canvas;
|
||||
import android.os.SystemClock;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Slog;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -31,6 +32,8 @@ import com.android.internal.R;
|
||||
public class StatusBarView extends FrameLayout {
|
||||
private static final String TAG = "StatusBarView";
|
||||
|
||||
static final int DIM_ANIM_TIME = 400;
|
||||
|
||||
StatusBarService mService;
|
||||
boolean mTracking;
|
||||
int mStartX, mStartY;
|
||||
@@ -38,6 +41,10 @@ public class StatusBarView extends FrameLayout {
|
||||
ViewGroup mStatusIcons;
|
||||
View mDate;
|
||||
FixedSizeDrawable mBackground;
|
||||
|
||||
boolean mNightMode = false;
|
||||
int mStartAlpha = 0, mEndAlpha = 0;
|
||||
long mEndTime = 0;
|
||||
|
||||
public StatusBarView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@@ -60,7 +67,30 @@ public class StatusBarView extends FrameLayout {
|
||||
super.onAttachedToWindow();
|
||||
mService.onBarViewAttached();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
boolean nightMode = (newConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK)
|
||||
== Configuration.UI_MODE_NIGHT_YES;
|
||||
if (mNightMode != nightMode) {
|
||||
mNightMode = nightMode;
|
||||
mStartAlpha = getCurAlpha();
|
||||
mEndAlpha = mNightMode ? 0x80 : 0x00;
|
||||
mEndTime = SystemClock.uptimeMillis() + DIM_ANIM_TIME;
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
int getCurAlpha() {
|
||||
long time = SystemClock.uptimeMillis();
|
||||
if (time > mEndTime) {
|
||||
return mEndAlpha;
|
||||
}
|
||||
return mEndAlpha
|
||||
- (int)(((mEndAlpha-mStartAlpha) * (mEndTime-time) / DIM_ANIM_TIME));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
@@ -97,6 +127,18 @@ public class StatusBarView extends FrameLayout {
|
||||
mBackground.setFixedBounds(-mDate.getLeft(), -mDate.getTop(), (r-l), (b-t));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
super.dispatchDraw(canvas);
|
||||
int alpha = getCurAlpha();
|
||||
if (alpha != 0) {
|
||||
canvas.drawARGB(alpha, 0, 0, 0);
|
||||
}
|
||||
if (alpha != mEndAlpha) {
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the left position of v in this view. Throws if v is not
|
||||
* a child of this.
|
||||
|
||||
Reference in New Issue
Block a user