FileDocCategorySizeDatePackage
CastTile.javaAPI DocAndroid 5.1 API9046Thu Mar 12 22:22:42 GMT 2015com.android.systemui.qs.tiles

CastTile

public class CastTile extends com.android.systemui.qs.QSTile
Quick settings tile: Cast

Fields Summary
private static final android.content.Intent
CAST_SETTINGS
private final com.android.systemui.statusbar.policy.CastController
mController
private final CastDetailAdapter
mDetailAdapter
private final com.android.systemui.statusbar.policy.KeyguardMonitor
mKeyguard
private final Callback
mCallback
Constructors Summary
public CastTile(Host host)


       
        super(host);
        mController = host.getCastController();
        mDetailAdapter = new CastDetailAdapter();
        mKeyguard = host.getKeyguardMonitor();
    
Methods Summary
protected java.lang.StringcomposeChangeAnnouncement()

        if (!mState.value) {
            // We only announce when it's turned off to avoid vocal overflow.
            return mContext.getString(R.string.accessibility_casting_turned_off);
        }
        return null;
    
public DetailAdaptergetDetailAdapter()

        return mDetailAdapter;
    
private java.lang.StringgetDeviceName(com.android.systemui.statusbar.policy.CastController.CastDevice device)

        return device.name != null ? device.name
                : mContext.getString(R.string.quick_settings_cast_device_default_name);
    
protected voidhandleClick()

        showDetail(true);
    
protected voidhandleUpdateState(BooleanState state, java.lang.Object arg)

        state.visible = !(mKeyguard.isSecure() && mKeyguard.isShowing());
        state.label = mContext.getString(R.string.quick_settings_cast_title);
        state.value = false;
        state.autoMirrorDrawable = false;
        final Set<CastDevice> devices = mController.getCastDevices();
        boolean connecting = false;
        for (CastDevice device : devices) {
            if (device.state == CastDevice.STATE_CONNECTED) {
                state.value = true;
                state.label = getDeviceName(device);
            } else if (device.state == CastDevice.STATE_CONNECTING) {
                connecting = true;
            }
        }
        if (!state.value && connecting) {
            state.label = mContext.getString(R.string.quick_settings_connecting);
        }
        state.icon = ResourceIcon.get(state.value ? R.drawable.ic_qs_cast_on
                : R.drawable.ic_qs_cast_off);
        mDetailAdapter.updateItems(devices);
    
protected voidhandleUserSwitch(int newUserId)

        super.handleUserSwitch(newUserId);
        if (mController == null) return;
        mController.setCurrentUserId(newUserId);
    
protected BooleanStatenewTileState()

        return new BooleanState();
    
public voidsetListening(boolean listening)

        if (mController == null) return;
        if (DEBUG) Log.d(TAG, "setListening " + listening);
        if (listening) {
            mController.addCallback(mCallback);
            mKeyguard.addCallback(mCallback);
        } else {
            mController.setDiscovering(false);
            mController.removeCallback(mCallback);
            mKeyguard.removeCallback(mCallback);
        }