summaryrefslogtreecommitdiffstats
path: root/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
diff options
context:
space:
mode:
authorJohn Spurlock <jspurlock@google.com>2014-08-10 18:04:16 -0400
committerJohn Spurlock <jspurlock@google.com>2014-08-11 10:19:21 -0400
commitbceed060f0090a4f86418c4515128d5ec8ebdd4a (patch)
treee772b34120b40d046a370aa9fb9c3e253011c131 /packages/SystemUI/src/com/android/systemui/qs/QSTile.java
parent88992bc90c874eb0eb159b3ea37659a8b83bbee0 (diff)
downloadframeworks_base-bceed060f0090a4f86418c4515128d5ec8ebdd4a.zip
frameworks_base-bceed060f0090a4f86418c4515128d5ec8ebdd4a.tar.gz
frameworks_base-bceed060f0090a4f86418c4515128d5ec8ebdd4a.tar.bz2
QS: Fix some QS layout issues.
- Make the tile list configurable for testing. - Support an external tile backed by a sticky broadcast intent. - Ensure tiles clean up properly when no longer needed. Bug:16818269 Bug:16822505 Change-Id: Ie24f878aae0d19c7f1feca4c519d10667023bef3
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/qs/QSTile.java')
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSTile.java29
1 files changed, 26 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
index 93766af..6975541 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTile.java
@@ -37,9 +37,8 @@ import com.android.systemui.statusbar.policy.NetworkController;
import com.android.systemui.statusbar.policy.RotationLockController;
import com.android.systemui.statusbar.policy.HotspotController;
import com.android.systemui.statusbar.policy.ZenModeController;
-import com.android.systemui.volume.VolumeComponent;
-import java.util.List;
+import java.util.Collection;
import java.util.Objects;
/**
@@ -134,6 +133,14 @@ public abstract class QSTile<TState extends State> implements Listenable {
mHandler.obtainMessage(H.SCAN_STATE_CHANGED, state ? 1 : 0, 0).sendToTarget();
}
+ public void destroy() {
+ mHandler.sendEmptyMessage(H.DESTROY);
+ }
+
+ public TState getState() {
+ return mState;
+ }
+
// call only on tile worker looper
private void handleSetCallback(Callback callback) {
@@ -181,6 +188,11 @@ public abstract class QSTile<TState extends State> implements Listenable {
handleRefreshState(null);
}
+ protected void handleDestroy() {
+ setListening(false);
+ mCallback = null;
+ }
+
protected final class H extends Handler {
private static final int SET_CALLBACK = 1;
private static final int CLICK = 2;
@@ -190,6 +202,7 @@ public abstract class QSTile<TState extends State> implements Listenable {
private static final int USER_SWITCH = 6;
private static final int TOGGLE_STATE_CHANGED = 7;
private static final int SCAN_STATE_CHANGED = 8;
+ private static final int DESTROY = 9;
private H(Looper looper) {
super(looper);
@@ -223,6 +236,11 @@ public abstract class QSTile<TState extends State> implements Listenable {
} else if (msg.what == SCAN_STATE_CHANGED) {
name = "handleScanStateChanged";
handleScanStateChanged(msg.arg1 != 0);
+ } else if (msg.what == DESTROY) {
+ name = "handleDestroy";
+ handleDestroy();
+ } else {
+ throw new IllegalArgumentException("Unknown msg: " + msg.what);
}
} catch (Throwable t) {
final String error = "Error in " + name;
@@ -245,7 +263,8 @@ public abstract class QSTile<TState extends State> implements Listenable {
void collapsePanels();
Looper getLooper();
Context getContext();
- List<QSTile<?>> getTiles();
+ Collection<QSTile<?>> getTiles();
+ void setCallback(Callback callback);
BluetoothController getBluetoothController();
LocationController getLocationController();
RotationLockController getRotationLockController();
@@ -255,6 +274,10 @@ public abstract class QSTile<TState extends State> implements Listenable {
CastController getCastController();
FlashlightController getFlashlightController();
KeyguardMonitor getKeyguardMonitor();
+
+ public interface Callback {
+ void onTilesChanged();
+ }
}
public static class State {