QS tile transition fixes.
- Don't change QS tile icons until state color transition animations are
complete.
- Wait up to 350ms for wifi to turn from on -> off before handling
updated state in anticipation of wifi turning off.
Change-Id: Id4a761b88d4f499acd6d00a97f4f5980f2e4b206
Fixes: 77026682
Test: visual
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java
index 0f83078..862a6a4 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSIconViewImpl.java
@@ -16,6 +16,8 @@
import static com.android.systemui.qs.tileimpl.QSTileImpl.getColorForState;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
@@ -127,7 +129,6 @@
}
protected void setIcon(ImageView iv, QSTile.State state) {
- updateIcon(iv, state);
if (state.disabledByPolicy) {
iv.setColorFilter(getContext().getColor(R.color.qs_tile_disabled_color));
} else {
@@ -137,7 +138,7 @@
int color = getColor(state.state);
mState = state.state;
if (iv.isShown() && mTint != 0) {
- animateGrayScale(mTint, color, iv);
+ animateGrayScale(mTint, color, iv, () -> updateIcon(iv, state));
mTint = color;
} else {
if (iv instanceof AlphaControlledSlashImageView) {
@@ -147,7 +148,10 @@
setTint(iv, color);
}
mTint = color;
+ updateIcon(iv, state);
}
+ } else {
+ updateIcon(iv, state);
}
}
@@ -155,7 +159,8 @@
return getColorForState(getContext(), state);
}
- public static void animateGrayScale(int fromColor, int toColor, ImageView iv) {
+ public static void animateGrayScale(int fromColor, int toColor, ImageView iv,
+ final Runnable endRunnable) {
if (iv instanceof AlphaControlledSlashImageView) {
((AlphaControlledSlashImageView)iv)
.setFinalImageTintList(ColorStateList.valueOf(toColor));
@@ -175,10 +180,16 @@
setTint(iv, Color.argb(alpha, channel, channel, channel));
});
-
+ anim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ endRunnable.run();
+ }
+ });
anim.start();
} else {
setTint(iv, toColor);
+ endRunnable.run();
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
index 8a1e4da..d8f7b71 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WifiTile.java
@@ -41,6 +41,7 @@
import com.android.systemui.qs.QSDetailItems;
import com.android.systemui.qs.QSDetailItems.Item;
import com.android.systemui.qs.QSHost;
+import com.android.systemui.qs.tileimpl.QSIconViewImpl;
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.NetworkController.AccessPointController;
@@ -60,6 +61,7 @@
protected final WifiSignalCallback mSignalCallback = new WifiSignalCallback();
private final ActivityStarter mActivityStarter;
+ private boolean mExpectDisabled;
public WifiTile(QSHost host) {
super(host);
@@ -120,6 +122,15 @@
// Immediately enter transient state when turning on wifi.
refreshState(wifiEnabled ? null : ARG_SHOW_TRANSIENT_ENABLING);
mController.setWifiEnabled(!wifiEnabled);
+ mExpectDisabled = wifiEnabled;
+ if (mExpectDisabled) {
+ mHandler.postDelayed(() -> {
+ if (mExpectDisabled) {
+ mExpectDisabled = false;
+ refreshState();
+ }
+ }, QSIconViewImpl.QS_ANIM_LENGTH);
+ }
}
@Override
@@ -143,11 +154,13 @@
@Override
protected void handleUpdateState(SignalState state, Object arg) {
if (DEBUG) Log.d(TAG, "handleUpdateState arg=" + arg);
- final CallbackInfo cb;
- if (arg != null && arg instanceof CallbackInfo) {
- cb = (CallbackInfo) arg;
- } else {
- cb = mSignalCallback.mInfo;
+ final CallbackInfo cb = mSignalCallback.mInfo;
+ if (mExpectDisabled) {
+ if (cb.enabled) {
+ return; // Ignore updates until disabled event occurs.
+ } else {
+ mExpectDisabled = false;
+ }
}
boolean transientEnabling = arg == ARG_SHOW_TRANSIENT_ENABLING;
boolean wifiConnected = cb.enabled && (cb.wifiSignalIconId > 0) && (cb.ssid != null);
@@ -288,7 +301,7 @@
if (isShowingDetail()) {
mDetailAdapter.updateItems();
}
- refreshState(mInfo);
+ refreshState();
}
}