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

WifiTile

public class WifiTile extends com.android.systemui.qs.QSTile
Quick settings tile: Wifi

Fields Summary
private static final android.content.Intent
WIFI_SETTINGS
private final com.android.systemui.statusbar.policy.NetworkController
mController
private final com.android.systemui.statusbar.policy.NetworkController.AccessPointController
mWifiController
private final WifiDetailAdapter
mDetailAdapter
private final QSTile.SignalState
mStateBeforeClick
private final com.android.systemui.statusbar.policy.NetworkController.NetworkSignalChangedCallback
mCallback
Constructors Summary
public WifiTile(Host host)


       
        super(host);
        mController = host.getNetworkController();
        mWifiController = mController.getAccessPointController();
        mDetailAdapter = new WifiDetailAdapter();
    
Methods Summary
protected java.lang.StringcomposeChangeAnnouncement()

        if (mState.enabled) {
            return mContext.getString(R.string.accessibility_quick_settings_wifi_changed_on);
        } else {
            return mContext.getString(R.string.accessibility_quick_settings_wifi_changed_off);
        }
    
public com.android.systemui.qs.QSTileViewcreateTileView(android.content.Context context)

        return new SignalTileView(context);
    
public DetailAdaptergetDetailAdapter()

        return mDetailAdapter;
    
protected voidhandleClick()

        mState.copyTo(mStateBeforeClick);
        mController.setWifiEnabled(!mState.enabled);
    
protected voidhandleSecondaryClick()

        if (!mWifiController.canConfigWifi()) {
            mHost.startSettingsActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
            return;
        }
        if (!mState.enabled) {
            mController.setWifiEnabled(true);
            mState.enabled = true;
        }
        showDetail(true);
    
protected voidhandleUpdateState(SignalState state, java.lang.Object arg)

        state.visible = true;
        if (DEBUG) Log.d(TAG, "handleUpdateState arg=" + arg);
        if (arg == null) return;
        CallbackInfo cb = (CallbackInfo) arg;

        boolean wifiConnected = cb.enabled && (cb.wifiSignalIconId > 0) && (cb.enabledDesc != null);
        boolean wifiNotConnected = (cb.wifiSignalIconId > 0) && (cb.enabledDesc == null);
        boolean enabledChanging = state.enabled != cb.enabled;
        if (enabledChanging) {
            mDetailAdapter.setItemsVisible(cb.enabled);
            fireToggleStateChanged(cb.enabled);
        }
        state.enabled = cb.enabled;
        state.connected = wifiConnected;
        state.activityIn = cb.enabled && cb.activityIn;
        state.activityOut = cb.enabled && cb.activityOut;
        state.filter = true;
        final String signalContentDescription;
        final Resources r = mContext.getResources();
        if (!state.enabled) {
            state.icon = ResourceIcon.get(R.drawable.ic_qs_wifi_disabled);
            state.label = r.getString(R.string.quick_settings_wifi_label);
            signalContentDescription = r.getString(R.string.accessibility_wifi_off);
        } else if (wifiConnected) {
            state.icon = ResourceIcon.get(cb.wifiSignalIconId);
            state.label = removeDoubleQuotes(cb.enabledDesc);
            signalContentDescription = cb.wifiSignalContentDescription;
        } else if (wifiNotConnected) {
            state.icon = ResourceIcon.get(R.drawable.ic_qs_wifi_0);
            state.label = r.getString(R.string.quick_settings_wifi_label);
            signalContentDescription = r.getString(R.string.accessibility_no_wifi);
        } else {
            state.icon = ResourceIcon.get(R.drawable.ic_qs_wifi_no_network);
            state.label = r.getString(R.string.quick_settings_wifi_label);
            signalContentDescription = r.getString(R.string.accessibility_wifi_off);
        }
        state.contentDescription = mContext.getString(
                R.string.accessibility_quick_settings_wifi,
                signalContentDescription);
        String wifiName = state.label;
        if (state.connected) {
            wifiName = r.getString(R.string.accessibility_wifi_name, state.label);
        }
        state.dualLabelContentDescription = wifiName;
    
protected SignalStatenewTileState()

        return new SignalState();
    
private static java.lang.StringremoveDoubleQuotes(java.lang.String string)

        if (string == null) return null;
        final int length = string.length();
        if ((length > 1) && (string.charAt(0) == '"") && (string.charAt(length - 1) == '"")) {
            return string.substring(1, length - 1);
        }
        return string;
    
public voidsetListening(boolean listening)

        if (listening) {
            mController.addNetworkSignalChangedCallback(mCallback);
            mWifiController.addAccessPointCallback(mDetailAdapter);
        } else {
            mController.removeNetworkSignalChangedCallback(mCallback);
            mWifiController.removeAccessPointCallback(mDetailAdapter);
        }
    
protected booleanshouldAnnouncementBeDelayed()

        return mStateBeforeClick.enabled == mState.enabled;
    
public booleansupportsDualTargets()

        return true;