FileDocCategorySizeDatePackage
QSTile.javaAPI DocAndroid 5.1 API17221Thu Mar 12 22:22:42 GMT 2015com.android.systemui.qs

QSTile

public abstract class QSTile extends Object implements com.android.systemui.statusbar.policy.Listenable
Base quick-settings tile, extend this to create a new tile. State management done on a looper provided by the host. Tiles should update state in handleUpdateState. Callbacks affecting state should use refreshState to trigger another state update pass on tile looper.

Fields Summary
protected final String
TAG
protected static final boolean
DEBUG
protected final Host
mHost
protected final android.content.Context
mContext
protected final H
mHandler
protected final android.os.Handler
mUiHandler
private Callback
mCallback
protected final TState
mState
private final TState
mTmpState
private boolean
mAnnounceNextStateChange
Constructors Summary
protected QSTile(Host host)


       
       
          

       
        mHost = host;
        mContext = host.getContext();
        mHandler = new H(host.getLooper());
    
Methods Summary
public voidclick()

        mHandler.sendEmptyMessage(H.CLICK);
    
protected java.lang.StringcomposeChangeAnnouncement()

        return null;
    
public QSTileViewcreateTileView(android.content.Context context)

        return new QSTileView(context);
    
public voiddestroy()

        mHandler.sendEmptyMessage(H.DESTROY);
    
public voidfireScanStateChanged(boolean state)

        mHandler.obtainMessage(H.SCAN_STATE_CHANGED, state ? 1 : 0, 0).sendToTarget();
    
public voidfireToggleStateChanged(boolean state)

        mHandler.obtainMessage(H.TOGGLE_STATE_CHANGED, state ? 1 : 0, 0).sendToTarget();
    
public com.android.systemui.qs.QSTile$DetailAdaptergetDetailAdapter()

        return null; // optional
    
public com.android.systemui.qs.QSTile$HostgetHost()

        return mHost;
    
public TStategetState()

        return mState;
    
protected abstract voidhandleClick()

protected voidhandleDestroy()

        setListening(false);
        mCallback = null;
    
protected voidhandleLongClick()

        // optional
    
protected voidhandleRefreshState(java.lang.Object arg)

        handleUpdateState(mTmpState, arg);
        final boolean changed = mTmpState.copyTo(mState);
        if (changed) {
            handleStateChanged();
        }
    
private voidhandleScanStateChanged(boolean state)

        if (mCallback != null) {
            mCallback.onScanStateChanged(state);
        }
    
protected voidhandleSecondaryClick()

        // optional
    
private voidhandleSetCallback(com.android.systemui.qs.QSTile$Callback callback)

        mCallback = callback;
        handleRefreshState(null);
    
private voidhandleShowDetail(boolean show)

        if (mCallback != null) {
            mCallback.onShowDetail(show);
        }
    
private voidhandleStateChanged()

        boolean delayAnnouncement = shouldAnnouncementBeDelayed();
        if (mCallback != null) {
            mCallback.onStateChanged(mState);
            if (mAnnounceNextStateChange && !delayAnnouncement) {
                String announcement = composeChangeAnnouncement();
                if (announcement != null) {
                    mCallback.onAnnouncementRequested(announcement);
                }
            }
        }
        mAnnounceNextStateChange = mAnnounceNextStateChange && delayAnnouncement;
    
private voidhandleToggleStateChanged(boolean state)

        if (mCallback != null) {
            mCallback.onToggleStateChanged(state);
        }
    
protected abstract voidhandleUpdateState(TState state, java.lang.Object arg)

protected voidhandleUserSwitch(int newUserId)

        handleRefreshState(null);
    
public voidlongClick()

        mHandler.sendEmptyMessage(H.LONG_CLICK);
    
protected abstract TStatenewTileState()

protected final voidrefreshState()

        refreshState(null);
    
protected final voidrefreshState(java.lang.Object arg)

        mHandler.obtainMessage(H.REFRESH_STATE, arg).sendToTarget();
    
public voidsecondaryClick()

        mHandler.sendEmptyMessage(H.SECONDARY_CLICK);
    
public voidsetCallback(com.android.systemui.qs.QSTile$Callback callback)

        mHandler.obtainMessage(H.SET_CALLBACK, callback).sendToTarget();
    
protected booleanshouldAnnouncementBeDelayed()

        return false;
    
public voidshowDetail(boolean show)

        mHandler.obtainMessage(H.SHOW_DETAIL, show ? 1 : 0, 0).sendToTarget();
    
public booleansupportsDualTargets()

        return false;
    
public voiduserSwitch(int newUserId)

        mHandler.obtainMessage(H.USER_SWITCH, newUserId, 0).sendToTarget();