@Override
 protected void handleUpdateState(BooleanState state, Object arg) {
   state.visible = true;
   if (gestureEnabled()) {
     state.icon = ResourceIcon.get(R.drawable.ic_qs_gestures_on);
     state.label = mContext.getString(R.string.quick_settings_gesture_on);
   } else {
     state.icon = ResourceIcon.get(R.drawable.ic_qs_gestures_off);
     state.label = mContext.getString(R.string.quick_settings_gesture_off);
   }
 }
Пример #2
0
 @Override
 protected void handleUpdateState(BooleanState state, Object arg) {
   state.value = ContentResolver.getMasterSyncAutomatically();
   state.visible = true;
   state.label = mContext.getString(R.string.quick_settings_sync_label);
   if (state.value) {
     state.icon = ResourceIcon.get(R.drawable.ic_qs_sync_on);
     state.contentDescription = mContext.getString(R.string.accessibility_quick_settings_sync_on);
   } else {
     state.icon = ResourceIcon.get(R.drawable.ic_qs_sync_off);
     state.contentDescription = mContext.getString(R.string.accessibility_quick_settings_sync_off);
   }
 }
  @Override
  protected void handleUpdateState(SignalState state, Object arg) {
    state.visible = true;
    if (DEBUG) Log.d(TAG, "handleUpdateState arg=" + arg);
    CallbackInfo cb = (CallbackInfo) arg;
    if (cb == null) {
      cb = mSignalCallback.mInfo;
    }

    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_full_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;
  }
  @Override
  protected void handleUpdateState(BooleanState state, Object arg) {
    final boolean supported = mController.isBluetoothSupported();
    final boolean enabled = mController.isBluetoothEnabled();
    final boolean connected = mController.isBluetoothConnected();
    final boolean connecting = mController.isBluetoothConnecting();
    state.visible = supported;
    state.value = enabled;
    state.autoMirrorDrawable = false;
    if (enabled) {
      state.label = null;
      if (connected) {
        state.icon = ResourceIcon.get(R.drawable.ic_qs_bluetooth_connected);
        state.contentDescription =
            mContext.getString(R.string.accessibility_quick_settings_bluetooth_connected);
        state.label = mController.getLastDeviceName();
      } else if (connecting) {
        state.icon = ResourceIcon.get(R.drawable.ic_qs_bluetooth_connecting);
        state.contentDescription =
            mContext.getString(R.string.accessibility_quick_settings_bluetooth_connecting);
        state.label = mContext.getString(R.string.quick_settings_bluetooth_label);
      } else {
        state.icon = ResourceIcon.get(R.drawable.ic_qs_bluetooth_on);
        state.contentDescription =
            mContext.getString(R.string.accessibility_quick_settings_bluetooth_on);
      }
      if (TextUtils.isEmpty(state.label)) {
        state.label = mContext.getString(R.string.quick_settings_bluetooth_label);
      }
    } else {
      state.icon = ResourceIcon.get(R.drawable.ic_qs_bluetooth_off);
      state.label = mContext.getString(R.string.quick_settings_bluetooth_label);
      state.contentDescription =
          mContext.getString(R.string.accessibility_quick_settings_bluetooth_off);
    }

    String bluetoothName = state.label;
    if (connected) {
      bluetoothName =
          state.dualLabelContentDescription =
              mContext.getString(R.string.accessibility_bluetooth_name, state.label);
    }
    state.dualLabelContentDescription = bluetoothName;
  }