OSDN Git Service

QS: Unavailable cleanup
authorJason Monk <jmonk@google.com>
Thu, 23 Mar 2017 14:45:37 +0000 (10:45 -0400)
committerJason Monk <jmonk@google.com>
Thu, 23 Mar 2017 14:45:37 +0000 (10:45 -0400)
 - Put cellular in unavailable when airplane mode is on
 - Don't show ripples for unavailable tiles.

Test: Click on cell while in airplane mode
Change-Id: I2a20795508801949b90b1b8876e48a0ec4809422
Fixes: 29979349
Fixes: 36302092

packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileBaseView.java
packages/SystemUI/src/com/android/systemui/qs/tiles/CellularTile.java

index 043490c..2d0fe6f 100644 (file)
@@ -20,6 +20,7 @@ import android.graphics.drawable.RippleDrawable;
 import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
+import android.service.quicksettings.Tile;
 import android.text.TextUtils;
 import android.view.Gravity;
 import android.view.View;
@@ -110,7 +111,6 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
 
     public void init(OnClickListener click, OnClickListener secondaryClick,
             OnLongClickListener longClick) {
-        setClickable(true);
         setOnClickListener(click);
         setOnLongClickListener(longClick);
     }
@@ -148,6 +148,7 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
     }
 
     protected void handleStateChanged(QSTile.State state) {
+        setClickable(state.state != Tile.STATE_UNAVAILABLE);
         mIcon.setIcon(state);
         setContentDescription(state.contentDescription);
         mAccessibilityClass = state.expandedAccessibilityClassName;
@@ -157,6 +158,12 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView {
     }
 
     @Override
+    public void setClickable(boolean clickable) {
+        super.setClickable(clickable);
+        setBackground(clickable ? mRipple : null);
+    }
+
+    @Override
     public int getDetailY() {
         return getTop() + getHeight() / 2;
     }
index ca70336..4351b2c 100644 (file)
@@ -137,7 +137,8 @@ public class CellularTile extends QSTileImpl<SignalState> {
         state.expandedAccessibilityClassName = Switch.class.getName();
         state.value = mDataController.isMobileDataSupported()
                 && mDataController.isMobileDataEnabled();
-        state.state = state.value ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
+        state.state = cb.airplaneModeEnabled ? Tile.STATE_UNAVAILABLE
+                : state.value ? Tile.STATE_ACTIVE : Tile.STATE_INACTIVE;
     }
 
     @Override