コード例 #1
0
 @Override
 public void setListening(boolean listening) {
   if (listening) {
     mController.addStateChangedCallback(mCallback);
   } else {
     mController.removeStateChangedCallback(mCallback);
   }
 }
コード例 #2
0
 @Override
 protected void handleSecondaryClick() {
   if (!mState.value) {
     mState.value = true;
     mController.setBluetoothEnabled(true);
   }
   showDetail(true);
 }
コード例 #3
0
  @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;
  }
コード例 #4
0
 @Override
 protected void handleClick() {
   final boolean isEnabled = (Boolean) mState.value;
   MetricsLogger.action(mContext, getMetricsCategory(), !isEnabled);
   mController.setBluetoothEnabled(!isEnabled);
 }