Merge "Make QS only have one Host and Tiles"
This commit is contained in:
@@ -329,16 +329,19 @@ public class QSPanel extends FrameLayout implements Tunable {
|
||||
drawTile(r, state);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShowDetail(boolean show) {
|
||||
QSPanel.this.showDetail(show, r);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onToggleStateChanged(boolean state) {
|
||||
if (mDetailRecord == r) {
|
||||
fireToggleStateChanged(state);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScanStateChanged(boolean state) {
|
||||
r.scanState = state;
|
||||
@@ -352,7 +355,7 @@ public class QSPanel extends FrameLayout implements Tunable {
|
||||
announceForAccessibility(announcement);
|
||||
}
|
||||
};
|
||||
r.tile.setCallback(callback);
|
||||
r.tile.addCallback(callback);
|
||||
final View.OnClickListener click = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -415,6 +418,9 @@ public class QSPanel extends FrameLayout implements Tunable {
|
||||
}
|
||||
|
||||
protected void handleShowDetail(Record r, boolean show) {
|
||||
if (show && !mExpanded) {
|
||||
mHost.animateExpandQS();
|
||||
}
|
||||
if (r instanceof TileRecord) {
|
||||
handleShowDetailTile((TileRecord) r, show);
|
||||
} else {
|
||||
|
||||
@@ -43,6 +43,7 @@ import com.android.systemui.statusbar.policy.UserInfoController;
|
||||
import com.android.systemui.statusbar.policy.UserSwitcherController;
|
||||
import com.android.systemui.statusbar.policy.ZenModeController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -62,7 +63,7 @@ public abstract class QSTile<TState extends State> implements Listenable {
|
||||
protected final H mHandler;
|
||||
protected final Handler mUiHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
private Callback mCallback;
|
||||
private final ArrayList<Callback> mCallbacks = new ArrayList<>();
|
||||
protected TState mState = newTileState();
|
||||
private TState mTmpState = newTileState();
|
||||
private boolean mAnnounceNextStateChange;
|
||||
@@ -119,8 +120,8 @@ public abstract class QSTile<TState extends State> implements Listenable {
|
||||
|
||||
// safe to call from any thread
|
||||
|
||||
public void setCallback(Callback callback) {
|
||||
mHandler.obtainMessage(H.SET_CALLBACK, callback).sendToTarget();
|
||||
public void addCallback(Callback callback) {
|
||||
mHandler.obtainMessage(H.ADD_CALLBACK, callback).sendToTarget();
|
||||
}
|
||||
|
||||
public void click() {
|
||||
@@ -177,8 +178,8 @@ public abstract class QSTile<TState extends State> implements Listenable {
|
||||
|
||||
// call only on tile worker looper
|
||||
|
||||
private void handleSetCallback(Callback callback) {
|
||||
mCallback = callback;
|
||||
private void handleAddCallback(Callback callback) {
|
||||
mCallbacks.add(callback);
|
||||
handleRefreshState(null);
|
||||
}
|
||||
|
||||
@@ -206,12 +207,14 @@ public abstract class QSTile<TState extends State> implements Listenable {
|
||||
|
||||
private void handleStateChanged() {
|
||||
boolean delayAnnouncement = shouldAnnouncementBeDelayed();
|
||||
if (mCallback != null) {
|
||||
mCallback.onStateChanged(mState);
|
||||
if (mCallbacks.size() != 0) {
|
||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||
mCallbacks.get(i).onStateChanged(mState);
|
||||
}
|
||||
if (mAnnounceNextStateChange && !delayAnnouncement) {
|
||||
String announcement = composeChangeAnnouncement();
|
||||
if (announcement != null) {
|
||||
mCallback.onAnnouncementRequested(announcement);
|
||||
mCallbacks.get(0).onAnnouncementRequested(announcement);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -227,20 +230,20 @@ public abstract class QSTile<TState extends State> implements Listenable {
|
||||
}
|
||||
|
||||
private void handleShowDetail(boolean show) {
|
||||
if (mCallback != null) {
|
||||
mCallback.onShowDetail(show);
|
||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||
mCallbacks.get(i).onShowDetail(show);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleToggleStateChanged(boolean state) {
|
||||
if (mCallback != null) {
|
||||
mCallback.onToggleStateChanged(state);
|
||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||
mCallbacks.get(i).onToggleStateChanged(state);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleScanStateChanged(boolean state) {
|
||||
if (mCallback != null) {
|
||||
mCallback.onScanStateChanged(state);
|
||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||
mCallbacks.get(i).onScanStateChanged(state);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,11 +253,11 @@ public abstract class QSTile<TState extends State> implements Listenable {
|
||||
|
||||
protected void handleDestroy() {
|
||||
setListening(false);
|
||||
mCallback = null;
|
||||
mCallbacks.clear();
|
||||
}
|
||||
|
||||
protected final class H extends Handler {
|
||||
private static final int SET_CALLBACK = 1;
|
||||
private static final int ADD_CALLBACK = 1;
|
||||
private static final int CLICK = 2;
|
||||
private static final int SECONDARY_CLICK = 3;
|
||||
private static final int LONG_CLICK = 4;
|
||||
@@ -274,9 +277,9 @@ public abstract class QSTile<TState extends State> implements Listenable {
|
||||
public void handleMessage(Message msg) {
|
||||
String name = null;
|
||||
try {
|
||||
if (msg.what == SET_CALLBACK) {
|
||||
name = "handleSetCallback";
|
||||
handleSetCallback((QSTile.Callback)msg.obj);
|
||||
if (msg.what == ADD_CALLBACK) {
|
||||
name = "handleAddCallback";
|
||||
handleAddCallback((QSTile.Callback)msg.obj);
|
||||
} else if (msg.what == CLICK) {
|
||||
name = "handleClick";
|
||||
mAnnounceNextStateChange = true;
|
||||
@@ -333,6 +336,7 @@ public abstract class QSTile<TState extends State> implements Listenable {
|
||||
void startRunnableDismissingKeyguard(Runnable runnable);
|
||||
void warn(String message, Throwable t);
|
||||
void collapsePanels();
|
||||
void animateExpandQS();
|
||||
void openPanels();
|
||||
Looper getLooper();
|
||||
Context getContext();
|
||||
|
||||
@@ -60,14 +60,8 @@ public class QuickQSPanel extends QSPanel {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleShowDetail(QSPanel.Record r, boolean show) {
|
||||
if (show) {
|
||||
mHeader.performClick();
|
||||
mFullPanel.showDetail(show, r);
|
||||
} else {
|
||||
// Not sure how we would end up here...
|
||||
super.handleShowDetail(r, show);
|
||||
}
|
||||
protected void showDetail(boolean show, Record r) {
|
||||
// Do nothing, will be handled by the QSPanel.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -68,6 +68,11 @@ public class CustomQSPanel extends QSPanel {
|
||||
TunerService.get(mContext).addTunable(this, QSTileHost.TILES_SETTING);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void showDetail(boolean show, Record r) {
|
||||
// No detail here.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
// Don't allow the super to unregister the tunable.
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.os.Process;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.qs.QSTile;
|
||||
import com.android.systemui.qs.external.CustomTile;
|
||||
@@ -99,6 +100,7 @@ public final class QSTileHost implements QSTile.Host, Tunable {
|
||||
private final TileServices mServices;
|
||||
|
||||
private final List<Callback> mCallbacks = new ArrayList<>();
|
||||
private View mHeader;
|
||||
|
||||
public QSTileHost(Context context, PhoneStatusBar statusBar,
|
||||
BluetoothController bluetooth, LocationController location,
|
||||
@@ -135,6 +137,10 @@ public final class QSTileHost implements QSTile.Host, Tunable {
|
||||
TunerService.get(mContext).addTunable(this, TILES_SETTING);
|
||||
}
|
||||
|
||||
public void setHeaderView(View view) {
|
||||
mHeader = view;
|
||||
}
|
||||
|
||||
public PhoneStatusBar getPhoneStatusBar() {
|
||||
return mStatusBar;
|
||||
}
|
||||
@@ -173,6 +179,11 @@ public final class QSTileHost implements QSTile.Host, Tunable {
|
||||
// already logged
|
||||
}
|
||||
|
||||
public void animateExpandQS() {
|
||||
// TODO: Better path to animated panel expansion.
|
||||
mHeader.performClick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collapsePanels() {
|
||||
mStatusBar.postAnimateCollapsePanels();
|
||||
|
||||
@@ -197,23 +197,16 @@ public class QuickStatusBarHeader extends BaseStatusBarHeader implements
|
||||
}
|
||||
}
|
||||
|
||||
public void setupHost(QSTileHost host) {
|
||||
final QSTileHost myHost = new QSTileHost(host.getContext(), host.getPhoneStatusBar(),
|
||||
host.getBluetoothController(), host.getLocationController(),
|
||||
host.getRotationLockController(), host.getNetworkController(),
|
||||
host.getZenModeController(), host.getHotspotController(),
|
||||
host.getCastController(), host.getFlashlightController(),
|
||||
host.getUserSwitcherController(), host.getUserInfoController(),
|
||||
host.getKeyguardMonitor(), host.getSecurityController(),
|
||||
host.getBatteryController(), host.getIconController());
|
||||
public void setupHost(final QSTileHost host) {
|
||||
host.setHeaderView(this);
|
||||
mHeaderQsPanel.setQSPanelAndHeader(mQsPanel, this);
|
||||
mHeaderQsPanel.setHost(myHost);
|
||||
mHeaderQsPanel.setHost(host);
|
||||
mHeaderQsPanel.setMaxTiles(5);
|
||||
mHeaderQsPanel.setTiles(myHost.getTiles());
|
||||
myHost.addCallback(new QSTile.Host.Callback() {
|
||||
mHeaderQsPanel.setTiles(host.getTiles());
|
||||
host.addCallback(new QSTile.Host.Callback() {
|
||||
@Override
|
||||
public void onTilesChanged() {
|
||||
mHeaderQsPanel.setTiles(myHost.getTiles());
|
||||
mHeaderQsPanel.setTiles(host.getTiles());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user