diff options
| author | 2016-06-20 12:39:38 -0400 | |
|---|---|---|
| committer | 2016-06-20 12:40:37 -0400 | |
| commit | ab17c984169d225964541db7baf5e5494b05a033 (patch) | |
| tree | 2a6d4cef158e5dd53aa78894fdfb9ccfefe2e037 | |
| parent | bd04ec31bdc247489241c448d6298e9b074d253b (diff) | |
QS: Don't disable hotspot animation when leaving airplane mode
Change-Id: I80750e3c4d63e4d590b43e3ed595100e054e5b1e
Fixes: 29374561
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/QSTile.java | 12 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java | 30 |
2 files changed, 24 insertions, 18 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java index 8a7a7fb7273e..27b079a06c99 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java @@ -634,6 +634,18 @@ public abstract class QSTile<TState extends State> { } } + public static class AirplaneBooleanState extends BooleanState { + public boolean isAirplaneMode; + + @Override + public boolean copyTo(State other) { + final AirplaneBooleanState o = (AirplaneBooleanState) other; + final boolean changed = super.copyTo(other) || o.isAirplaneMode != isAirplaneMode; + o.isAirplaneMode = isAirplaneMode; + return changed; + } + } + public static final class SignalState extends BooleanState { public boolean connected; public boolean activityIn; 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 1c134c1e1424..d3434e5aa812 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/HotspotTile.java @@ -36,15 +36,16 @@ import com.android.systemui.qs.QSTile; import com.android.systemui.statusbar.policy.HotspotController; /** Quick settings tile: Hotspot **/ -public class HotspotTile extends QSTile<QSTile.BooleanState> { +public class HotspotTile extends QSTile<QSTile.AirplaneBooleanState> { private final AnimationIcon mEnable = new AnimationIcon(R.drawable.ic_hotspot_enable_animation, R.drawable.ic_hotspot_disable); private final AnimationIcon mDisable = new AnimationIcon(R.drawable.ic_hotspot_disable_animation, R.drawable.ic_hotspot_enable); - private final Icon mUnavailable = - ResourceIcon.get(R.drawable.ic_hotspot_unavailable); + private final Icon mDisableNoAnimation = ResourceIcon.get(R.drawable.ic_hotspot_enable); + private final Icon mUnavailable = ResourceIcon.get(R.drawable.ic_hotspot_unavailable); + private final HotspotController mController; private final Callback mCallback = new Callback(); private final GlobalSetting mAirplaneMode; @@ -72,8 +73,8 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> { } @Override - public BooleanState newTileState() { - return new BooleanState(); + public AirplaneBooleanState newTileState() { + return new AirplaneBooleanState(); } @Override @@ -84,10 +85,8 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> { mController.addCallback(mCallback); final IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_AIRPLANE_MODE_CHANGED); - mContext.registerReceiver(mReceiver, filter); } else { mController.removeCallback(mCallback); - mContext.unregisterReceiver(mReceiver); } mAirplaneMode.setListening(listening); } @@ -113,7 +112,7 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> { } @Override - protected void handleUpdateState(BooleanState state, Object arg) { + protected void handleUpdateState(AirplaneBooleanState state, Object arg) { state.label = mContext.getString(R.string.quick_settings_hotspot_label); checkIfRestrictionEnforcedByAdminOnly(state, UserManager.DISALLOW_CONFIG_TETHERING); @@ -123,12 +122,16 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> { state.value = mController.isHotspotEnabled(); } state.icon = state.value ? mEnable : mDisable; - if (mAirplaneMode.getValue() != 0) { + boolean wasAirplane = state.isAirplaneMode; + state.isAirplaneMode = mAirplaneMode.getValue() != 0; + if (state.isAirplaneMode) { final int disabledColor = mHost.getContext().getColor(R.color.qs_tile_tint_unavailable); state.label = new SpannableStringBuilder().append(state.label, new ForegroundColorSpan(disabledColor), SpannableStringBuilder.SPAN_INCLUSIVE_INCLUSIVE); state.icon = mUnavailable; + } else if (wasAirplane) { + state.icon = mDisableNoAnimation; } state.minimalAccessibilityClassName = state.expandedAccessibilityClassName = Switch.class.getName(); @@ -155,13 +158,4 @@ public class HotspotTile extends QSTile<QSTile.BooleanState> { refreshState(enabled); } }; - - private final BroadcastReceiver mReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(intent.getAction())) { - refreshState(); - } - } - }; } |