Merge "Support multiple dark tint areas in status bar"
This commit is contained in:
committed by
Android (Google) Code Review
commit
0bf4f64503
@@ -25,6 +25,8 @@ import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
|
||||
import com.android.systemui.plugins.annotations.DependsOn;
|
||||
import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Dispatches events to {@link DarkReceiver}s about changes in darkness, tint area and dark
|
||||
* intensity. Accessible through {@link PluginDependency}
|
||||
@@ -32,15 +34,15 @@ import com.android.systemui.plugins.annotations.ProvidesInterface;
|
||||
@ProvidesInterface(version = DarkIconDispatcher.VERSION)
|
||||
@DependsOn(target = DarkReceiver.class)
|
||||
public interface DarkIconDispatcher {
|
||||
int VERSION = 1;
|
||||
int VERSION = 2;
|
||||
|
||||
/**
|
||||
* Sets the dark area so {@link #applyDark} only affects the icons in the specified area.
|
||||
*
|
||||
* @param r the area in which icons should change its tint, in logical screen
|
||||
* @param r the areas in which icons should change its tint, in logical screen
|
||||
* coordinates
|
||||
*/
|
||||
void setIconsDarkArea(Rect r);
|
||||
void setIconsDarkArea(ArrayList<Rect> r);
|
||||
|
||||
/**
|
||||
* Adds a receiver to receive callbacks onDarkChanged
|
||||
@@ -76,8 +78,8 @@ public interface DarkIconDispatcher {
|
||||
* @return the tint to apply to view depending on the desired tint color and
|
||||
* the screen tintArea in which to apply that tint
|
||||
*/
|
||||
static int getTint(Rect tintArea, View view, int color) {
|
||||
if (isInArea(tintArea, view)) {
|
||||
static int getTint(ArrayList<Rect> tintAreas, View view, int color) {
|
||||
if (isInAreas(tintAreas, view)) {
|
||||
return color;
|
||||
} else {
|
||||
return DEFAULT_ICON_TINT;
|
||||
@@ -85,15 +87,16 @@ public interface DarkIconDispatcher {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the dark intensity to apply to view depending on the desired dark
|
||||
* intensity and the screen tintArea in which to apply that intensity
|
||||
* @return true if more than half of the view area are in any of the given
|
||||
* areas, false otherwise
|
||||
*/
|
||||
static float getDarkIntensity(Rect tintArea, View view, float intensity) {
|
||||
if (isInArea(tintArea, view)) {
|
||||
return intensity;
|
||||
} else {
|
||||
return 0f;
|
||||
static boolean isInAreas(ArrayList<Rect> areas, View view) {
|
||||
for (Rect area : areas) {
|
||||
if (isInArea(area, view)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,7 +125,7 @@ public interface DarkIconDispatcher {
|
||||
*/
|
||||
@ProvidesInterface(version = DarkReceiver.VERSION)
|
||||
interface DarkReceiver {
|
||||
int VERSION = 1;
|
||||
void onDarkChanged(Rect area, float darkIntensity, int tint);
|
||||
int VERSION = 2;
|
||||
void onDarkChanged(ArrayList<Rect> areas, float darkIntensity, int tint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,11 +32,11 @@ class DarkReceiverImpl @JvmOverloads constructor(
|
||||
private val dualToneHandler = DualToneHandler(context)
|
||||
|
||||
init {
|
||||
onDarkChanged(Rect(), 1f, DarkIconDispatcher.DEFAULT_ICON_TINT)
|
||||
onDarkChanged(ArrayList<Rect>(), 1f, DarkIconDispatcher.DEFAULT_ICON_TINT)
|
||||
}
|
||||
|
||||
override fun onDarkChanged(area: Rect?, darkIntensity: Float, tint: Int) {
|
||||
val intensity = if (DarkIconDispatcher.isInArea(area, this)) darkIntensity else 0f
|
||||
override fun onDarkChanged(areas: ArrayList<Rect>?, darkIntensity: Float, tint: Int) {
|
||||
val intensity = if (DarkIconDispatcher.isInAreas(areas, this)) darkIntensity else 0f
|
||||
setBackgroundColor(dualToneHandler.getSingleColor(intensity))
|
||||
}
|
||||
}
|
||||
@@ -56,6 +56,7 @@ import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class BatteryMeterView extends LinearLayout implements DarkReceiver {
|
||||
|
||||
@@ -125,7 +126,7 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver {
|
||||
updateShowPercent();
|
||||
mDualToneHandler = new DualToneHandler(context);
|
||||
// Init to not dark at all.
|
||||
onDarkChanged(new Rect(), 0, DarkIconDispatcher.DEFAULT_ICON_TINT);
|
||||
onDarkChanged(new ArrayList<Rect>(), 0, DarkIconDispatcher.DEFAULT_ICON_TINT);
|
||||
|
||||
setClipChildren(false);
|
||||
setClipToPadding(false);
|
||||
@@ -353,8 +354,8 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDarkChanged(Rect area, float darkIntensity, int tint) {
|
||||
float intensity = DarkIconDispatcher.isInArea(area, this) ? darkIntensity : 0;
|
||||
public void onDarkChanged(ArrayList<Rect> areas, float darkIntensity, int tint) {
|
||||
float intensity = DarkIconDispatcher.isInAreas(areas, this) ? darkIntensity : 0;
|
||||
mNonAdaptedSingleToneColor = mDualToneHandler.getSingleColor(intensity);
|
||||
mNonAdaptedForegroundColor = mDualToneHandler.getFillColor(intensity);
|
||||
mNonAdaptedBackgroundColor = mDualToneHandler.getBackgroundColor(intensity);
|
||||
|
||||
@@ -31,6 +31,8 @@ import com.android.systemui.plugins.DarkIconDispatcher;
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry;
|
||||
import com.android.systemui.statusbar.notification.collection.NotificationEntry.OnSensitivityChangedListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
/**
|
||||
* The view in the statusBar that contains part of the heads-up information
|
||||
@@ -161,8 +163,8 @@ public class HeadsUpStatusBarView extends AlphaOptimizedLinearLayout {
|
||||
return mIconDrawingRect;
|
||||
}
|
||||
|
||||
public void onDarkChanged(Rect area, float darkIntensity, int tint) {
|
||||
mTextView.setTextColor(DarkIconDispatcher.getTint(area, this, tint));
|
||||
public void onDarkChanged(ArrayList<Rect> areas, float darkIntensity, int tint) {
|
||||
mTextView.setTextColor(DarkIconDispatcher.getTint(areas, this, tint));
|
||||
}
|
||||
|
||||
public void setOnDrawingRectChangedListener(Runnable onDrawingRectChangedListener) {
|
||||
|
||||
@@ -60,6 +60,7 @@ import com.android.systemui.statusbar.notification.NotificationUtils;
|
||||
import com.android.systemui.util.drawable.DrawableSize;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class StatusBarIconView extends AnimatedImageView implements StatusIconDisplayable {
|
||||
@@ -961,8 +962,8 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDarkChanged(Rect area, float darkIntensity, int tint) {
|
||||
int areaTint = getTint(area, this, tint);
|
||||
public void onDarkChanged(ArrayList<Rect> areas, float darkIntensity, int tint) {
|
||||
int areaTint = getTint(areas, this, tint);
|
||||
ColorStateList color = ColorStateList.valueOf(areaTint);
|
||||
setImageTintList(color);
|
||||
setDecorColor(areaTint);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package com.android.systemui.statusbar;
|
||||
|
||||
import static com.android.systemui.plugins.DarkIconDispatcher.getTint;
|
||||
import static com.android.systemui.plugins.DarkIconDispatcher.isInArea;
|
||||
import static com.android.systemui.plugins.DarkIconDispatcher.isInAreas;
|
||||
import static com.android.systemui.statusbar.StatusBarIconView.STATE_DOT;
|
||||
import static com.android.systemui.statusbar.StatusBarIconView.STATE_HIDDEN;
|
||||
import static com.android.systemui.statusbar.StatusBarIconView.STATE_ICON;
|
||||
@@ -40,6 +40,8 @@ import com.android.systemui.R;
|
||||
import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.MobileIconState;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class StatusBarMobileView extends FrameLayout implements DarkReceiver,
|
||||
StatusIconDisplayable {
|
||||
private static final String TAG = "StatusBarMobileView";
|
||||
@@ -222,11 +224,11 @@ public class StatusBarMobileView extends FrameLayout implements DarkReceiver,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDarkChanged(Rect area, float darkIntensity, int tint) {
|
||||
float intensity = isInArea(area, this) ? darkIntensity : 0;
|
||||
public void onDarkChanged(ArrayList<Rect> areas, float darkIntensity, int tint) {
|
||||
float intensity = isInAreas(areas, this) ? darkIntensity : 0;
|
||||
mMobileDrawable.setTintList(
|
||||
ColorStateList.valueOf(mDualToneHandler.getSingleColor(intensity)));
|
||||
ColorStateList color = ColorStateList.valueOf(getTint(area, this, tint));
|
||||
ColorStateList color = ColorStateList.valueOf(getTint(areas, this, tint));
|
||||
mIn.setImageTintList(color);
|
||||
mOut.setImageTintList(color);
|
||||
mMobileType.setImageTintList(color);
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.android.systemui.statusbar;
|
||||
|
||||
import static com.android.systemui.plugins.DarkIconDispatcher.getTint;
|
||||
import static com.android.systemui.plugins.DarkIconDispatcher.isInArea;
|
||||
import static com.android.systemui.statusbar.StatusBarIconView.STATE_DOT;
|
||||
import static com.android.systemui.statusbar.StatusBarIconView.STATE_HIDDEN;
|
||||
import static com.android.systemui.statusbar.StatusBarIconView.STATE_ICON;
|
||||
@@ -37,6 +36,8 @@ import com.android.systemui.R;
|
||||
import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
|
||||
import com.android.systemui.statusbar.phone.StatusBarSignalPolicy.WifiIconState;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Start small: StatusBarWifiView will be able to layout from a WifiIconState
|
||||
*/
|
||||
@@ -235,8 +236,8 @@ public class StatusBarWifiView extends FrameLayout implements DarkReceiver,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDarkChanged(Rect area, float darkIntensity, int tint) {
|
||||
int areaTint = getTint(area, this, tint);
|
||||
public void onDarkChanged(ArrayList<Rect> areas, float darkIntensity, int tint) {
|
||||
int areaTint = getTint(areas, this, tint);
|
||||
ColorStateList color = ColorStateList.valueOf(areaTint);
|
||||
mWifiIcon.setImageTintList(color);
|
||||
mIn.setImageTintList(color);
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.android.systemui.statusbar.CommandQueue;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -40,7 +41,7 @@ public class DarkIconDispatcherImpl implements SysuiDarkIconDispatcher,
|
||||
LightBarTransitionsController.DarkIntensityApplier {
|
||||
|
||||
private final LightBarTransitionsController mTransitionsController;
|
||||
private final Rect mTintArea = new Rect();
|
||||
private final ArrayList<Rect> mTintAreas = new ArrayList<>();
|
||||
private final ArrayMap<Object, DarkReceiver> mReceivers = new ArrayMap<>();
|
||||
|
||||
private int mIconTint = DEFAULT_ICON_TINT;
|
||||
@@ -69,14 +70,14 @@ public class DarkIconDispatcherImpl implements SysuiDarkIconDispatcher,
|
||||
|
||||
public void addDarkReceiver(DarkReceiver receiver) {
|
||||
mReceivers.put(receiver, receiver);
|
||||
receiver.onDarkChanged(mTintArea, mDarkIntensity, mIconTint);
|
||||
receiver.onDarkChanged(mTintAreas, mDarkIntensity, mIconTint);
|
||||
}
|
||||
|
||||
public void addDarkReceiver(ImageView imageView) {
|
||||
DarkReceiver receiver = (area, darkIntensity, tint) -> imageView.setImageTintList(
|
||||
ColorStateList.valueOf(getTint(mTintArea, imageView, mIconTint)));
|
||||
ColorStateList.valueOf(getTint(mTintAreas, imageView, mIconTint)));
|
||||
mReceivers.put(imageView, receiver);
|
||||
receiver.onDarkChanged(mTintArea, mDarkIntensity, mIconTint);
|
||||
receiver.onDarkChanged(mTintAreas, mDarkIntensity, mIconTint);
|
||||
}
|
||||
|
||||
public void removeDarkReceiver(DarkReceiver object) {
|
||||
@@ -88,23 +89,23 @@ public class DarkIconDispatcherImpl implements SysuiDarkIconDispatcher,
|
||||
}
|
||||
|
||||
public void applyDark(DarkReceiver object) {
|
||||
mReceivers.get(object).onDarkChanged(mTintArea, mDarkIntensity, mIconTint);
|
||||
mReceivers.get(object).onDarkChanged(mTintAreas, mDarkIntensity, mIconTint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the dark area so {@link #applyDark} only affects the icons in the specified area.
|
||||
*
|
||||
* @param darkArea the area in which icons should change it's tint, in logical screen
|
||||
* coordinates
|
||||
* @param darkAreas the areas in which icons should change it's tint, in logical screen
|
||||
* coordinates
|
||||
*/
|
||||
public void setIconsDarkArea(Rect darkArea) {
|
||||
if (darkArea == null && mTintArea.isEmpty()) {
|
||||
public void setIconsDarkArea(ArrayList<Rect> darkAreas) {
|
||||
if (darkAreas == null && mTintAreas.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (darkArea == null) {
|
||||
mTintArea.setEmpty();
|
||||
} else {
|
||||
mTintArea.set(darkArea);
|
||||
|
||||
mTintAreas.clear();
|
||||
if (darkAreas != null) {
|
||||
mTintAreas.addAll(darkAreas);
|
||||
}
|
||||
applyIconTint();
|
||||
}
|
||||
@@ -124,7 +125,7 @@ public class DarkIconDispatcherImpl implements SysuiDarkIconDispatcher,
|
||||
|
||||
private void applyIconTint() {
|
||||
for (int i = 0; i < mReceivers.size(); i++) {
|
||||
mReceivers.valueAt(i).onDarkChanged(mTintArea, mDarkIntensity, mIconTint);
|
||||
mReceivers.valueAt(i).onDarkChanged(mTintAreas, mDarkIntensity, mIconTint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,6 +134,6 @@ public class DarkIconDispatcherImpl implements SysuiDarkIconDispatcher,
|
||||
pw.println("DarkIconDispatcher: ");
|
||||
pw.println(" mIconTint: 0x" + Integer.toHexString(mIconTint));
|
||||
pw.println(" mDarkIntensity: " + mDarkIntensity + "f");
|
||||
pw.println(" mTintArea: " + mTintArea);
|
||||
pw.println(" mTintAreas: " + mTintAreas);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -315,14 +315,14 @@ public class DemoStatusIcons extends StatusIconContainer implements DemoMode, Da
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDarkChanged(Rect area, float darkIntensity, int tint) {
|
||||
setColor(DarkIconDispatcher.getTint(area, mStatusIcons, tint));
|
||||
public void onDarkChanged(ArrayList<Rect> areas, float darkIntensity, int tint) {
|
||||
setColor(DarkIconDispatcher.getTint(areas, mStatusIcons, tint));
|
||||
|
||||
if (mWifiView != null) {
|
||||
mWifiView.onDarkChanged(area, darkIntensity, tint);
|
||||
mWifiView.onDarkChanged(areas, darkIntensity, tint);
|
||||
}
|
||||
for (StatusBarMobileView view : mMobileViews) {
|
||||
view.onDarkChanged(area, darkIntensity, tint);
|
||||
view.onDarkChanged(areas, darkIntensity, tint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
|
||||
import com.android.systemui.util.ViewController;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.ArrayList;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@@ -369,8 +370,8 @@ public class HeadsUpAppearanceController extends ViewController<HeadsUpStatusBar
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDarkChanged(Rect area, float darkIntensity, int tint) {
|
||||
mView.onDarkChanged(area, darkIntensity, tint);
|
||||
public void onDarkChanged(ArrayList<Rect> areas, float darkIntensity, int tint) {
|
||||
mView.onDarkChanged(areas, darkIntensity, tint);
|
||||
}
|
||||
|
||||
public void onStateChanged() {
|
||||
|
||||
@@ -50,6 +50,7 @@ import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* The header group on Keyguard.
|
||||
@@ -60,7 +61,7 @@ public class KeyguardStatusBarView extends RelativeLayout {
|
||||
private static final int LAYOUT_CUTOUT = 1;
|
||||
private static final int LAYOUT_NO_CUTOUT = 2;
|
||||
|
||||
private final Rect mEmptyRect = new Rect(0, 0, 0, 0);
|
||||
private final ArrayList<Rect> mEmptyTintRect = new ArrayList<>();
|
||||
|
||||
private boolean mShowPercentAvailable;
|
||||
private boolean mBatteryCharging;
|
||||
@@ -476,14 +477,14 @@ public class KeyguardStatusBarView extends RelativeLayout {
|
||||
iconManager.setTint(iconColor);
|
||||
}
|
||||
|
||||
applyDarkness(R.id.battery, mEmptyRect, intensity, iconColor);
|
||||
applyDarkness(R.id.clock, mEmptyRect, intensity, iconColor);
|
||||
applyDarkness(R.id.battery, mEmptyTintRect, intensity, iconColor);
|
||||
applyDarkness(R.id.clock, mEmptyTintRect, intensity, iconColor);
|
||||
}
|
||||
|
||||
private void applyDarkness(int id, Rect tintArea, float intensity, int color) {
|
||||
private void applyDarkness(int id, ArrayList<Rect> tintAreas, float intensity, int color) {
|
||||
View v = findViewById(id);
|
||||
if (v instanceof DarkReceiver) {
|
||||
((DarkReceiver) v).onDarkChanged(tintArea, intensity, color);
|
||||
((DarkReceiver) v).onDarkChanged(tintAreas, intensity, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARE
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Rect;
|
||||
import android.view.InsetsFlags;
|
||||
import android.view.ViewDebug;
|
||||
import android.view.WindowInsetsController.Appearance;
|
||||
@@ -41,6 +42,7 @@ import com.android.systemui.statusbar.policy.BatteryController;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -214,27 +216,23 @@ public class LightBarController implements BatteryController.BatteryStateChangeC
|
||||
|
||||
private void updateStatus() {
|
||||
final int numStacks = mAppearanceRegions.length;
|
||||
int numLightStacks = 0;
|
||||
|
||||
// We can only have maximum one light stack.
|
||||
int indexLightStack = -1;
|
||||
final ArrayList<Rect> lightBarBounds = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < numStacks; i++) {
|
||||
if (isLight(mAppearanceRegions[i].getAppearance(), mStatusBarMode,
|
||||
APPEARANCE_LIGHT_STATUS_BARS)) {
|
||||
numLightStacks++;
|
||||
indexLightStack = i;
|
||||
final AppearanceRegion ar = mAppearanceRegions[i];
|
||||
if (isLight(ar.getAppearance(), mStatusBarMode, APPEARANCE_LIGHT_STATUS_BARS)) {
|
||||
lightBarBounds.add(ar.getBounds());
|
||||
}
|
||||
}
|
||||
|
||||
// If no one is light, all icons become white.
|
||||
if (numLightStacks == 0) {
|
||||
if (lightBarBounds.isEmpty()) {
|
||||
mStatusBarIconController.getTransitionsController().setIconsDark(
|
||||
false, animateChange());
|
||||
}
|
||||
|
||||
// If all stacks are light, all icons get dark.
|
||||
else if (numLightStacks == numStacks) {
|
||||
else if (lightBarBounds.size() == numStacks) {
|
||||
mStatusBarIconController.setIconsDarkArea(null);
|
||||
mStatusBarIconController.getTransitionsController().setIconsDark(true, animateChange());
|
||||
|
||||
@@ -242,8 +240,7 @@ public class LightBarController implements BatteryController.BatteryStateChangeC
|
||||
|
||||
// Not the same for every stack, magic!
|
||||
else {
|
||||
mStatusBarIconController.setIconsDarkArea(
|
||||
mAppearanceRegions[indexLightStack].getBounds());
|
||||
mStatusBarIconController.setIconsDarkArea(lightBarBounds);
|
||||
mStatusBarIconController.getTransitionsController().setIconsDark(true, animateChange());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ public class NotificationIconAreaController implements
|
||||
private NotificationIconContainer mNotificationIcons;
|
||||
private NotificationIconContainer mShelfIcons;
|
||||
private NotificationIconContainer mAodIcons;
|
||||
private final Rect mTintArea = new Rect();
|
||||
private final ArrayList<Rect> mTintAreas = new ArrayList<>();
|
||||
private Context mContext;
|
||||
|
||||
private final DemoModeController mDemoModeController;
|
||||
@@ -240,17 +240,14 @@ public class NotificationIconAreaController implements
|
||||
* See {@link com.android.systemui.statusbar.policy.DarkIconDispatcher#setIconsDarkArea}.
|
||||
* Sets the color that should be used to tint any icons in the notification area.
|
||||
*
|
||||
* @param tintArea the area in which to tint the icons, specified in screen coordinates
|
||||
* @param tintAreas the areas in which to tint the icons, specified in screen coordinates
|
||||
* @param darkIntensity
|
||||
*/
|
||||
public void onDarkChanged(Rect tintArea, float darkIntensity, int iconTint) {
|
||||
if (tintArea == null) {
|
||||
mTintArea.setEmpty();
|
||||
} else {
|
||||
mTintArea.set(tintArea);
|
||||
}
|
||||
public void onDarkChanged(ArrayList<Rect> tintAreas, float darkIntensity, int iconTint) {
|
||||
mTintAreas.clear();
|
||||
mTintAreas.addAll(tintAreas);
|
||||
|
||||
if (DarkIconDispatcher.isInArea(tintArea, mNotificationIconArea)) {
|
||||
if (DarkIconDispatcher.isInAreas(tintAreas, mNotificationIconArea)) {
|
||||
mIconTint = iconTint;
|
||||
}
|
||||
|
||||
@@ -489,7 +486,7 @@ public class NotificationIconAreaController implements
|
||||
int color = StatusBarIconView.NO_COLOR;
|
||||
boolean colorize = !isPreL || NotificationUtils.isGrayscale(v, mContrastColorUtil);
|
||||
if (colorize) {
|
||||
color = DarkIconDispatcher.getTint(mTintArea, v, tint);
|
||||
color = DarkIconDispatcher.getTint(mTintAreas, v, tint);
|
||||
}
|
||||
v.setStaticDrawableColor(color);
|
||||
v.setDecorColor(tint);
|
||||
|
||||
@@ -56,6 +56,7 @@ import com.android.systemui.tuner.TunerService;
|
||||
import com.android.systemui.tuner.TunerService.Tunable;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
@@ -314,8 +315,8 @@ public class Clock extends TextView implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDarkChanged(Rect area, float darkIntensity, int tint) {
|
||||
mNonAdaptedColor = DarkIconDispatcher.getTint(area, this, tint);
|
||||
public void onDarkChanged(ArrayList<Rect> areas, float darkIntensity, int tint) {
|
||||
mNonAdaptedColor = DarkIconDispatcher.getTint(areas, this, tint);
|
||||
setTextColor(mNonAdaptedColor);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ import static android.view.WindowInsetsController.APPEARANCE_LIGHT_STATUS_BARS;
|
||||
|
||||
import static com.android.systemui.statusbar.phone.BarTransitions.MODE_TRANSPARENT;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -41,6 +43,9 @@ import com.android.systemui.statusbar.policy.BatteryController;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@SmallTest
|
||||
@RunWith(AndroidTestingRunner.class)
|
||||
@@ -91,7 +96,9 @@ public class LightBarControllerTest extends SysuiTestCase {
|
||||
mLightBarController.onStatusBarAppearanceChanged(
|
||||
appearanceRegions, true /* sbModeChanged */, MODE_TRANSPARENT,
|
||||
false /* navbarColorManagedByIme */);
|
||||
verify(mStatusBarIconController).setIconsDarkArea(eq(firstBounds));
|
||||
ArgumentCaptor<ArrayList<Rect>> captor = ArgumentCaptor.forClass(ArrayList.class);
|
||||
verify(mStatusBarIconController).setIconsDarkArea(captor.capture());
|
||||
assertTrue(captor.getValue().contains(firstBounds));
|
||||
verify(mLightBarTransitionsController).setIconsDark(eq(true), anyBoolean());
|
||||
}
|
||||
|
||||
@@ -106,7 +113,29 @@ public class LightBarControllerTest extends SysuiTestCase {
|
||||
mLightBarController.onStatusBarAppearanceChanged(
|
||||
appearanceRegions, true /* sbModeChanged */, MODE_TRANSPARENT,
|
||||
false /* navbarColorManagedByIme */);
|
||||
verify(mStatusBarIconController).setIconsDarkArea(eq(secondBounds));
|
||||
ArgumentCaptor<ArrayList<Rect>> captor = ArgumentCaptor.forClass(ArrayList.class);
|
||||
verify(mStatusBarIconController).setIconsDarkArea(captor.capture());
|
||||
assertTrue(captor.getValue().contains(secondBounds));
|
||||
verify(mLightBarTransitionsController).setIconsDark(eq(true), anyBoolean());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnStatusBarAppearanceChanged_multipleStacks_oneStackLightMultipleStackDark() {
|
||||
final Rect firstBounds = new Rect(0, 0, 1, 1);
|
||||
final Rect secondBounds = new Rect(1, 0, 2, 1);
|
||||
final Rect thirdBounds = new Rect(2, 0, 3, 1);
|
||||
final AppearanceRegion[] appearanceRegions = new AppearanceRegion[]{
|
||||
new AppearanceRegion(APPEARANCE_LIGHT_STATUS_BARS, firstBounds),
|
||||
new AppearanceRegion(0 /* appearance */, secondBounds),
|
||||
new AppearanceRegion(APPEARANCE_LIGHT_STATUS_BARS, thirdBounds)
|
||||
};
|
||||
mLightBarController.onStatusBarAppearanceChanged(
|
||||
appearanceRegions, true /* sbModeChanged */, MODE_TRANSPARENT,
|
||||
false /* navbarColorManagedByIme */);
|
||||
ArgumentCaptor<ArrayList<Rect>> captor = ArgumentCaptor.forClass(ArrayList.class);
|
||||
verify(mStatusBarIconController).setIconsDarkArea(captor.capture());
|
||||
assertTrue(captor.getValue().contains(firstBounds));
|
||||
assertTrue(captor.getValue().contains(thirdBounds));
|
||||
verify(mLightBarTransitionsController).setIconsDark(eq(true), anyBoolean());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user