Merge "Fix incorrect colors for CustomTile in QS" into oc-mr1-dev
am: 859f8c4a21
Change-Id: Id96f0a18c77628d63069ed434f5904936cb41359
This commit is contained in:
@@ -26,6 +26,7 @@ import com.android.systemui.plugins.qs.QSTile.Icon;
|
|||||||
import com.android.systemui.plugins.qs.QSTile.State;
|
import com.android.systemui.plugins.qs.QSTile.State;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@ProvidesInterface(version = QSTile.VERSION)
|
@ProvidesInterface(version = QSTile.VERSION)
|
||||||
@DependsOn(target = QSIconView.class)
|
@DependsOn(target = QSIconView.class)
|
||||||
@@ -104,6 +105,7 @@ public interface QSTile {
|
|||||||
public static class State {
|
public static class State {
|
||||||
public static final int VERSION = 1;
|
public static final int VERSION = 1;
|
||||||
public Icon icon;
|
public Icon icon;
|
||||||
|
public Supplier<Icon> iconSupplier;
|
||||||
public int state = Tile.STATE_ACTIVE;
|
public int state = Tile.STATE_ACTIVE;
|
||||||
public CharSequence label;
|
public CharSequence label;
|
||||||
public CharSequence contentDescription;
|
public CharSequence contentDescription;
|
||||||
@@ -118,6 +120,7 @@ public interface QSTile {
|
|||||||
if (other == null) throw new IllegalArgumentException();
|
if (other == null) throw new IllegalArgumentException();
|
||||||
if (!other.getClass().equals(getClass())) throw new IllegalArgumentException();
|
if (!other.getClass().equals(getClass())) throw new IllegalArgumentException();
|
||||||
final boolean changed = !Objects.equals(other.icon, icon)
|
final boolean changed = !Objects.equals(other.icon, icon)
|
||||||
|
|| !Objects.equals(other.iconSupplier, iconSupplier)
|
||||||
|| !Objects.equals(other.label, label)
|
|| !Objects.equals(other.label, label)
|
||||||
|| !Objects.equals(other.contentDescription, contentDescription)
|
|| !Objects.equals(other.contentDescription, contentDescription)
|
||||||
|| !Objects.equals(other.dualLabelContentDescription,
|
|| !Objects.equals(other.dualLabelContentDescription,
|
||||||
@@ -130,6 +133,7 @@ public interface QSTile {
|
|||||||
|| !Objects.equals(other.dualTarget, dualTarget)
|
|| !Objects.equals(other.dualTarget, dualTarget)
|
||||||
|| !Objects.equals(other.slash, slash);
|
|| !Objects.equals(other.slash, slash);
|
||||||
other.icon = icon;
|
other.icon = icon;
|
||||||
|
other.iconSupplier = iconSupplier;
|
||||||
other.label = label;
|
other.label = label;
|
||||||
other.contentDescription = contentDescription;
|
other.contentDescription = contentDescription;
|
||||||
other.dualLabelContentDescription = dualLabelContentDescription;
|
other.dualLabelContentDescription = dualLabelContentDescription;
|
||||||
@@ -150,6 +154,7 @@ public interface QSTile {
|
|||||||
protected StringBuilder toStringBuilder() {
|
protected StringBuilder toStringBuilder() {
|
||||||
final StringBuilder sb = new StringBuilder(getClass().getSimpleName()).append('[');
|
final StringBuilder sb = new StringBuilder(getClass().getSimpleName()).append('[');
|
||||||
sb.append(",icon=").append(icon);
|
sb.append(",icon=").append(icon);
|
||||||
|
sb.append(",iconSupplier=").append(iconSupplier);
|
||||||
sb.append(",label=").append(label);
|
sb.append(",label=").append(label);
|
||||||
sb.append(",contentDescription=").append(contentDescription);
|
sb.append(",contentDescription=").append(contentDescription);
|
||||||
sb.append(",dualLabelContentDescription=").append(dualLabelContentDescription);
|
sb.append(",dualLabelContentDescription=").append(dualLabelContentDescription);
|
||||||
|
|||||||
@@ -305,7 +305,15 @@ public class CustomTile extends QSTileImpl<State> implements TileChangeListener
|
|||||||
state.state = Tile.STATE_UNAVAILABLE;
|
state.state = Tile.STATE_UNAVAILABLE;
|
||||||
drawable = mDefaultIcon.loadDrawable(mContext);
|
drawable = mDefaultIcon.loadDrawable(mContext);
|
||||||
}
|
}
|
||||||
state.icon = new DrawableIcon(drawable);
|
|
||||||
|
final Drawable drawableF = drawable;
|
||||||
|
state.iconSupplier = () -> {
|
||||||
|
Drawable.ConstantState cs = drawableF.getConstantState();
|
||||||
|
if (cs != null) {
|
||||||
|
return new DrawableIcon(cs.newDrawable());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
state.label = mTile.getLabel();
|
state.label = mTile.getLabel();
|
||||||
if (mTile.getContentDescription() != null) {
|
if (mTile.getContentDescription() != null) {
|
||||||
state.contentDescription = mTile.getContentDescription();
|
state.contentDescription = mTile.getContentDescription();
|
||||||
|
|||||||
@@ -87,14 +87,15 @@ public class QSIconViewImpl extends QSIconView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void updateIcon(ImageView iv, State state) {
|
protected void updateIcon(ImageView iv, State state) {
|
||||||
if (!Objects.equals(state.icon, iv.getTag(R.id.qs_icon_tag))
|
final QSTile.Icon icon = state.iconSupplier != null ? state.iconSupplier.get() : state.icon;
|
||||||
|
if (!Objects.equals(icon, iv.getTag(R.id.qs_icon_tag))
|
||||||
|| !Objects.equals(state.slash, iv.getTag(R.id.qs_slash_tag))) {
|
|| !Objects.equals(state.slash, iv.getTag(R.id.qs_slash_tag))) {
|
||||||
boolean shouldAnimate = iv.isShown() && mAnimationEnabled
|
boolean shouldAnimate = iv.isShown() && mAnimationEnabled
|
||||||
&& iv.getDrawable() != null;
|
&& iv.getDrawable() != null;
|
||||||
Drawable d = state.icon != null
|
Drawable d = icon != null
|
||||||
? shouldAnimate ? state.icon.getDrawable(mContext)
|
? shouldAnimate ? icon.getDrawable(mContext)
|
||||||
: state.icon.getInvisibleDrawable(mContext) : null;
|
: icon.getInvisibleDrawable(mContext) : null;
|
||||||
int padding = state.icon != null ? state.icon.getPadding() : 0;
|
int padding = icon != null ? icon.getPadding() : 0;
|
||||||
if (d != null) {
|
if (d != null) {
|
||||||
d.setAutoMirrored(false);
|
d.setAutoMirrored(false);
|
||||||
d.setLayoutDirection(getLayoutDirection());
|
d.setLayoutDirection(getLayoutDirection());
|
||||||
@@ -107,7 +108,7 @@ public class QSIconViewImpl extends QSIconView {
|
|||||||
iv.setImageDrawable(d);
|
iv.setImageDrawable(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
iv.setTag(R.id.qs_icon_tag, state.icon);
|
iv.setTag(R.id.qs_icon_tag, icon);
|
||||||
iv.setTag(R.id.qs_slash_tag, state.slash);
|
iv.setTag(R.id.qs_slash_tag, state.slash);
|
||||||
iv.setPadding(0, padding, 0, padding);
|
iv.setPadding(0, padding, 0, padding);
|
||||||
if (d instanceof Animatable2) {
|
if (d instanceof Animatable2) {
|
||||||
|
|||||||
Reference in New Issue
Block a user