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;
announceForAccessibility(announcement);
}
};
- r.tile.setCallback(callback);
+ r.tile.addCallback(callback);
final View.OnClickListener click = new View.OnClickListener() {
@Override
public void onClick(View v) {
}
protected void handleShowDetail(Record r, boolean show) {
+ if (show && !mExpanded) {
+ mHost.animateExpandQS();
+ }
if (r instanceof TileRecord) {
handleShowDetailTile((TileRecord) r, show);
} else {
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;
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;
// 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() {
// call only on tile worker looper
- private void handleSetCallback(Callback callback) {
- mCallback = callback;
+ private void handleAddCallback(Callback callback) {
+ mCallbacks.add(callback);
handleRefreshState(null);
}
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);
}
}
}
}
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);
}
}
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;
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;
void startRunnableDismissingKeyguard(Runnable runnable);
void warn(String message, Throwable t);
void collapsePanels();
+ void animateExpandQS();
void openPanels();
Looper getLooper();
Context getContext();
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;
private final TileServices mServices;
private final List<Callback> mCallbacks = new ArrayList<>();
+ private View mHeader;
public QSTileHost(Context context, PhoneStatusBar statusBar,
BluetoothController bluetooth, LocationController location,
TunerService.get(mContext).addTunable(this, TILES_SETTING);
}
+ public void setHeaderView(View view) {
+ mHeader = view;
+ }
+
public PhoneStatusBar getPhoneStatusBar() {
return mStatusBar;
}
// already logged
}
+ public void animateExpandQS() {
+ // TODO: Better path to animated panel expansion.
+ mHeader.performClick();
+ }
+
@Override
public void collapsePanels() {
mStatusBar.postAnimateCollapsePanels();
}
}
- 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());
}
});
}