diff options
| author | 2016-01-04 19:55:41 +0000 | |
|---|---|---|
| committer | 2016-01-04 19:55:41 +0000 | |
| commit | 154a01ec81e595c178a4a56eb019c3af2b43a3f2 (patch) | |
| tree | 8107edbbf9becf21124c710f215e92fa7879fdc8 | |
| parent | 931c51f54599a227422b2a1c71e922e1458e0291 (diff) | |
| parent | 66239fbdfce1586555b339854b8a21f8187e805f (diff) | |
Merge "Remove UserBoolean"
10 files changed, 32 insertions, 82 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java b/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java index b56ad76ec2b4..01eb5f941fee 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSIconView.java @@ -75,7 +75,8 @@ public class QSIconView extends ViewGroup { iv.setTag(R.id.qs_icon_tag, state.icon); if (d instanceof Animatable) { Animatable a = (Animatable) d; - if (state.icon instanceof QSTile.AnimationIcon && !iv.isShown()) { + a.start(); + if (!iv.isShown()) { a.stop(); // skip directly to end state } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java index 39f0c5578e8e..1a36abd3f1c3 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java @@ -19,8 +19,6 @@ package com.android.systemui.qs; import android.app.PendingIntent; import android.content.Context; import android.content.Intent; -import android.graphics.drawable.Animatable; -import android.graphics.drawable.AnimatedVectorDrawable; import android.graphics.drawable.Drawable; import android.os.Handler; import android.os.Looper; @@ -29,9 +27,20 @@ import android.util.Log; import android.util.SparseArray; import android.view.View; import android.view.ViewGroup; - import com.android.systemui.qs.QSTile.State; -import com.android.systemui.statusbar.policy.*; +import com.android.systemui.statusbar.policy.BatteryController; +import com.android.systemui.statusbar.policy.BluetoothController; +import com.android.systemui.statusbar.policy.CastController; +import com.android.systemui.statusbar.policy.FlashlightController; +import com.android.systemui.statusbar.policy.HotspotController; +import com.android.systemui.statusbar.policy.KeyguardMonitor; +import com.android.systemui.statusbar.policy.Listenable; +import com.android.systemui.statusbar.policy.LocationController; +import com.android.systemui.statusbar.policy.NetworkController; +import com.android.systemui.statusbar.policy.RotationLockController; +import com.android.systemui.statusbar.policy.UserInfoController; +import com.android.systemui.statusbar.policy.UserSwitcherController; +import com.android.systemui.statusbar.policy.ZenModeController; import java.util.Collection; import java.util.Objects; @@ -389,11 +398,7 @@ public abstract class QSTile<TState extends State> implements Listenable { @Override public Drawable getDrawable(Context context) { - Drawable d = context.getDrawable(mResId); - if (d instanceof Animatable) { - ((Animatable) d).start(); - } - return d; + return context.getDrawable(mResId); } @Override @@ -408,41 +413,14 @@ public abstract class QSTile<TState extends State> implements Listenable { } protected class AnimationIcon extends ResourceIcon { - private boolean mAllowAnimation; - public AnimationIcon(int resId) { super(resId); } - public void setAllowAnimation(boolean allowAnimation) { - mAllowAnimation = allowAnimation; - } - @Override public Drawable getDrawable(Context context) { // workaround: get a clean state for every new AVD - final AnimatedVectorDrawable d = (AnimatedVectorDrawable) context.getDrawable(mResId) - .getConstantState().newDrawable(); - d.start(); - if (mAllowAnimation) { - mAllowAnimation = false; - } else { - d.stop(); // skip directly to end state - } - return d; - } - } - - protected enum UserBoolean { - USER_TRUE(true, true), - USER_FALSE(true, false), - BACKGROUND_TRUE(false, true), - BACKGROUND_FALSE(false, false); - public final boolean value; - public final boolean userInitiated; - private UserBoolean(boolean userInitiated, boolean value) { - this.value = value; - this.userInitiated = userInitiated; + return context.getDrawable(mResId).getConstantState().newDrawable(); } } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java index fc802dde9797..c696f886e33f 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/AirplaneModeTile.java @@ -58,8 +58,6 @@ public class AirplaneModeTile extends QSTile<QSTile.BooleanState> { public void handleClick() { MetricsLogger.action(mContext, getMetricsCategory(), !mState.value); setEnabled(!mState.value); - mEnable.setAllowAnimation(true); - mDisable.setAllowAnimation(true); } private void setEnabled(boolean enabled) { diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java index f73ee354443d..23a15b9d68ab 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/ColorInversionTile.java @@ -71,8 +71,6 @@ public class ColorInversionTile extends QSTile<QSTile.BooleanState> { protected void handleClick() { MetricsLogger.action(mContext, getMetricsCategory(), !mState.value); mSetting.setValue(mState.value ? 0 : 1); - mEnable.setAllowAnimation(true); - mDisable.setAllowAnimation(true); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java index d96f735301e5..4f9f46df7d26 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/DndTile.java @@ -107,8 +107,6 @@ public class DndTile extends QSTile<QSTile.BooleanState> { Toast.LENGTH_LONG).show(); return; } - mDisable.setAllowAnimation(true); - mDisableTotalSilence.setAllowAnimation(true); MetricsLogger.action(mContext, getMetricsCategory(), !mState.value); if (mState.value) { mController.setZen(Global.ZEN_MODE_OFF, null, TAG); diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java index 12c12980b065..39d9da12d4a1 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/FlashlightTile.java @@ -64,7 +64,7 @@ public class FlashlightTile extends QSTile<QSTile.BooleanState> implements } MetricsLogger.action(mContext, getMetricsCategory(), !mState.value); boolean newState = !mState.value; - refreshState(newState ? UserBoolean.USER_TRUE : UserBoolean.USER_FALSE); + refreshState(newState); mFlashlightController.setFlashlight(newState); } @@ -73,8 +73,8 @@ public class FlashlightTile extends QSTile<QSTile.BooleanState> implements // TODO: Flashlight available handling... // state.visible = mFlashlightController.isAvailable(); state.label = mHost.getContext().getString(R.string.quick_settings_flashlight_label); - if (arg instanceof UserBoolean) { - boolean value = ((UserBoolean) arg).value; + if (arg instanceof Boolean) { + boolean value = (Boolean) arg; if (value == state.value) { return; } @@ -83,7 +83,6 @@ public class FlashlightTile extends QSTile<QSTile.BooleanState> implements state.value = mFlashlightController.isEnabled(); } final AnimationIcon icon = state.value ? mEnable : mDisable; - icon.setAllowAnimation(arg instanceof UserBoolean && ((UserBoolean) arg).userInitiated); state.icon = icon; int onOrOffId = state.value ? R.string.accessibility_quick_settings_flashlight_on @@ -107,12 +106,12 @@ public class FlashlightTile extends QSTile<QSTile.BooleanState> implements @Override public void onFlashlightChanged(boolean enabled) { - refreshState(enabled ? UserBoolean.BACKGROUND_TRUE : UserBoolean.BACKGROUND_FALSE); + refreshState(enabled); } @Override public void onFlashlightError() { - refreshState(UserBoolean.BACKGROUND_FALSE); + refreshState(false); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java index 250d5674bb6e..55aa32bb0db9 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java @@ -59,8 +59,6 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> { final boolean isEnabled = (Boolean) mState.value; MetricsLogger.action(mContext, getMetricsCategory(), !isEnabled); mController.setHotspotEnabled(!isEnabled); - mEnable.setAllowAnimation(true); - mDisable.setAllowAnimation(true); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java index 08540f69ff6e..e79aabfb8bf8 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/LocationTile.java @@ -67,8 +67,6 @@ public class LocationTile extends QSTile<QSTile.BooleanState> { mHost.openPanels(); MetricsLogger.action(mContext, getMetricsCategory(), !wasEnabled); mController.setLocationEnabled(!wasEnabled); - mEnable.setAllowAnimation(true); - mDisable.setAllowAnimation(true); } }); return; @@ -76,8 +74,6 @@ public class LocationTile extends QSTile<QSTile.BooleanState> { final boolean wasEnabled = (Boolean) mState.value; MetricsLogger.action(mContext, getMetricsCategory(), !wasEnabled); mController.setLocationEnabled(!wasEnabled); - mEnable.setAllowAnimation(true); - mDisable.setAllowAnimation(true); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java index d85cf605c851..7bce54b33d7a 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/RotationLockTile.java @@ -63,15 +63,14 @@ public class RotationLockTile extends QSTile<QSTile.BooleanState> { MetricsLogger.action(mContext, getMetricsCategory(), !mState.value); final boolean newState = !mState.value; mController.setRotationLocked(newState); - refreshState(newState ? UserBoolean.USER_TRUE : UserBoolean.USER_FALSE); + refreshState(newState); } @Override protected void handleUpdateState(BooleanState state, Object arg) { if (mController == null) return; - final boolean rotationLocked = arg != null ? ((UserBoolean) arg).value + final boolean rotationLocked = arg != null ? (Boolean) arg : mController.isRotationLocked(); - final boolean userInitiated = arg != null ? ((UserBoolean) arg).userInitiated : false; // TODO: Handle accessibility rotation lock and whatnot. // state.visible = mController.isRotationLockAffordanceVisible(); if (state.value == rotationLocked && state.contentDescription != null) { @@ -80,18 +79,15 @@ public class RotationLockTile extends QSTile<QSTile.BooleanState> { } state.value = rotationLocked; final boolean portrait = isCurrentOrientationLockPortrait(); - final AnimationIcon icon; if (rotationLocked) { final int label = portrait ? R.string.quick_settings_rotation_locked_portrait_label : R.string.quick_settings_rotation_locked_landscape_label; state.label = mContext.getString(label); - icon = portrait ? mAutoToPortrait : mAutoToLandscape; + state.icon = portrait ? mAutoToPortrait : mAutoToLandscape; } else { state.label = mContext.getString(R.string.quick_settings_rotation_unlocked_label); - icon = portrait ? mPortraitToAuto : mLandscapeToAuto; + state.icon = portrait ? mPortraitToAuto : mLandscapeToAuto; } - icon.setAllowAnimation(userInitiated); - state.icon = icon; state.contentDescription = getAccessibilityString(rotationLocked, R.string.accessibility_rotation_lock_on_portrait, R.string.accessibility_rotation_lock_on_landscape, @@ -145,8 +141,7 @@ public class RotationLockTile extends QSTile<QSTile.BooleanState> { private final RotationLockControllerCallback mCallback = new RotationLockControllerCallback() { @Override public void onRotationLockStateChanged(boolean rotationLocked, boolean affordanceVisible) { - refreshState(rotationLocked ? UserBoolean.BACKGROUND_TRUE - : UserBoolean.BACKGROUND_FALSE); + refreshState(rotationLocked); } }; } diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java index 07915f8dc56e..255f29f285c4 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/WorkModeTile.java @@ -93,12 +93,7 @@ public class WorkModeTile extends QSTile<QSTile.BooleanState> { } private void refreshQuietModeState(boolean backgroundRefresh) { - if (backgroundRefresh) { - refreshState(isWorkModeEnabled() ? UserBoolean.BACKGROUND_TRUE - : UserBoolean.BACKGROUND_FALSE); - } else { - refreshState(isWorkModeEnabled() ? UserBoolean.USER_TRUE : UserBoolean.USER_FALSE); - } + refreshState(isWorkModeEnabled()); } @Override @@ -108,28 +103,22 @@ public class WorkModeTile extends QSTile<QSTile.BooleanState> { return; } - final boolean userInitialized; - if (arg instanceof UserBoolean) { - state.value = ((UserBoolean) arg).value; - userInitialized = ((UserBoolean) arg).userInitiated; + if (arg instanceof Boolean) { + state.value = (Boolean) arg; } else { state.value = isWorkModeEnabled(); - userInitialized = false; } - final AnimationIcon icon; state.label = mContext.getString(R.string.quick_settings_work_mode_label); if (state.value) { - icon = mEnable; + state.icon = mEnable; state.contentDescription = mContext.getString( R.string.accessibility_quick_settings_work_mode_on); } else { - icon = mDisable; + state.icon = mDisable; state.contentDescription = mContext.getString( R.string.accessibility_quick_settings_work_mode_off); } - icon.setAllowAnimation(userInitialized); - state.icon = icon; } @Override |