Update nav bar background size to match handle
- Also disable sampling when opaque nav bar background is showing Bug: 128939962 Test: Manual Change-Id: Iee6b92a3dcff304c9bd58fc97dfb49ebd0d67557
This commit is contained in:
@@ -70,7 +70,7 @@ public class BarTransitions {
|
||||
|
||||
private final String mTag;
|
||||
private final View mView;
|
||||
private final BarBackgroundDrawable mBarBackground;
|
||||
protected final BarBackgroundDrawable mBarBackground;
|
||||
|
||||
private int mMode;
|
||||
private boolean mAlwaysOpaque = false;
|
||||
@@ -152,7 +152,7 @@ public class BarTransitions {
|
||||
return mode == MODE_LIGHTS_OUT || mode == MODE_LIGHTS_OUT_TRANSPARENT;
|
||||
}
|
||||
|
||||
private static class BarBackgroundDrawable extends Drawable {
|
||||
protected static class BarBackgroundDrawable extends Drawable {
|
||||
private final int mOpaque;
|
||||
private final int mSemiTransparent;
|
||||
private final int mTransparent;
|
||||
@@ -171,6 +171,7 @@ public class BarTransitions {
|
||||
|
||||
private int mGradientAlphaStart;
|
||||
private int mColorStart;
|
||||
private Rect mFrame;
|
||||
|
||||
|
||||
public BarBackgroundDrawable(Context context, int gradientResourceId) {
|
||||
@@ -190,6 +191,10 @@ public class BarTransitions {
|
||||
mGradient = context.getDrawable(gradientResourceId);
|
||||
}
|
||||
|
||||
public void setFrame(Rect frame) {
|
||||
mFrame = frame;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
// noop
|
||||
@@ -296,7 +301,11 @@ public class BarTransitions {
|
||||
if (mTintFilter != null) {
|
||||
mPaint.setColorFilter(mTintFilter);
|
||||
}
|
||||
canvas.drawPaint(mPaint);
|
||||
if (mFrame != null) {
|
||||
canvas.drawRect(mFrame, mPaint);
|
||||
} else {
|
||||
canvas.drawPaint(mPaint);
|
||||
}
|
||||
}
|
||||
if (mAnimating) {
|
||||
invalidateSelf(); // keep going
|
||||
|
||||
@@ -988,11 +988,11 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback
|
||||
if (Intent.ACTION_SCREEN_ON.equals(action)) {
|
||||
// Enabled and screen is on, start it again if enabled
|
||||
if (NavBarTintController.isEnabled(getContext())) {
|
||||
mNavigationBarView.getColorAdaptionController().start();
|
||||
mNavigationBarView.getTintController().start();
|
||||
}
|
||||
} else {
|
||||
// Screen off disable it
|
||||
mNavigationBarView.getColorAdaptionController().stop();
|
||||
mNavigationBarView.getTintController().stop();
|
||||
}
|
||||
}
|
||||
if (Intent.ACTION_USER_SWITCHED.equals(action)) {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.android.systemui.statusbar.phone;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Handler;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
@@ -105,6 +106,10 @@ public final class NavigationBarTransitions extends BarTransitions {
|
||||
applyLightsOut(true, false);
|
||||
}
|
||||
|
||||
void setBackgroundFrame(Rect frame) {
|
||||
mBarBackground.setFrame(frame);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isLightsOut(int mode) {
|
||||
return super.isLightsOut(mode) || (mAllowAutoDimWallpaperNotVisible && mAutoDim
|
||||
@@ -119,6 +124,7 @@ public final class NavigationBarTransitions extends BarTransitions {
|
||||
protected void onTransition(int oldMode, int newMode, boolean animate) {
|
||||
super.onTransition(oldMode, newMode, animate);
|
||||
applyLightsOut(animate, false /*force*/);
|
||||
mView.onBarTransition(newMode);
|
||||
}
|
||||
|
||||
private void applyLightsOut(boolean animate, boolean force) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_
|
||||
import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_NONE;
|
||||
import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_OVERVIEW;
|
||||
import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_ROTATION;
|
||||
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_OPAQUE;
|
||||
import static com.android.systemui.statusbar.phone.NavigationBarInflaterView.NAV_BAR_VIEWS;
|
||||
|
||||
import android.animation.LayoutTransition;
|
||||
@@ -172,7 +173,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
private RecentsOnboarding mRecentsOnboarding;
|
||||
private NotificationPanelView mPanelView;
|
||||
|
||||
private NavBarTintController mColorAdaptionController;
|
||||
private NavBarTintController mTintController;
|
||||
private boolean mAssistantAvailable;
|
||||
private NavigationPrototypeController mPrototypeController;
|
||||
private NavigationGestureAction[] mDefaultGestureMap;
|
||||
@@ -309,9 +310,9 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
@Override
|
||||
public void onColorAdaptChanged(boolean enabled) {
|
||||
if (enabled) {
|
||||
mColorAdaptionController.start();
|
||||
mTintController.start();
|
||||
} else {
|
||||
mColorAdaptionController.stop();
|
||||
mTintController.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,15 +443,15 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
mPrototypeController = new NavigationPrototypeController(context);
|
||||
mPrototypeController.register();
|
||||
mPrototypeController.setOnPrototypeChangedListener(mPrototypeListener);
|
||||
mColorAdaptionController = new NavBarTintController(this, getLightTransitionsController());
|
||||
mTintController = new NavBarTintController(this, getLightTransitionsController());
|
||||
|
||||
IntentFilter filter = new IntentFilter(ACTION_OVERLAY_CHANGED);
|
||||
filter.addDataScheme("package");
|
||||
context.registerReceiver(mOverlaysChangedReceiver, filter);
|
||||
}
|
||||
|
||||
public NavBarTintController getColorAdaptionController() {
|
||||
return mColorAdaptionController;
|
||||
public NavBarTintController getTintController() {
|
||||
return mTintController;
|
||||
}
|
||||
|
||||
public BarTransitions getBarTransitions() {
|
||||
@@ -476,7 +477,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
@Override
|
||||
protected void dispatchDraw(Canvas canvas) {
|
||||
super.dispatchDraw(canvas);
|
||||
mColorAdaptionController.onDraw();
|
||||
mTintController.onDraw();
|
||||
}
|
||||
|
||||
private void updateNavigationGestures() {
|
||||
@@ -557,6 +558,17 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
void onBarTransition(int newMode) {
|
||||
if (newMode == MODE_OPAQUE) {
|
||||
// If the nav bar background is opaque, stop auto tinting since we know the icons are
|
||||
// showing over a dark background
|
||||
mTintController.stop();
|
||||
getLightTransitionsController().setIconsDark(false /* dark */, true /* animate */);
|
||||
} else {
|
||||
mTintController.start();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean shouldDeadZoneConsumeTouchEvents(MotionEvent event) {
|
||||
if (mDeadZone.onTouchEvent(event) || mDeadZoneConsuming) {
|
||||
switch (event.getActionMasked()) {
|
||||
@@ -978,9 +990,9 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
|
||||
// Color adaption is tied with showing home handle, only avaliable if visible
|
||||
if (visible) {
|
||||
mColorAdaptionController.start();
|
||||
mTintController.start();
|
||||
} else {
|
||||
mColorAdaptionController.stop();
|
||||
mTintController.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1205,6 +1217,19 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
reorient();
|
||||
notifyVerticalChangedListener(newVertical);
|
||||
}
|
||||
|
||||
if (QuickStepContract.isGesturalMode(getContext())) {
|
||||
// Update the nav bar background to match the height of the visible nav bar
|
||||
int height = mIsVertical
|
||||
? getResources().getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.navigation_bar_height_landscape)
|
||||
: getResources().getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.navigation_bar_height);
|
||||
int frameHeight = getResources().getDimensionPixelSize(
|
||||
com.android.internal.R.dimen.navigation_bar_frame_height);
|
||||
mBarTransitions.setBackgroundFrame(new Rect(0, frameHeight - height, w, h));
|
||||
}
|
||||
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
}
|
||||
|
||||
@@ -1231,9 +1256,9 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
}
|
||||
|
||||
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
|
||||
mColorAdaptionController.start();
|
||||
mTintController.start();
|
||||
} else {
|
||||
mColorAdaptionController.stop();
|
||||
mTintController.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1416,7 +1441,7 @@ public class NavigationBarView extends FrameLayout implements PluginListener<Nav
|
||||
mGestureHelper.dump(pw);
|
||||
}
|
||||
mRecentsOnboarding.dump(pw);
|
||||
mColorAdaptionController.dump(pw);
|
||||
mTintController.dump(pw);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user