Java Code Examples for android.media.AudioManager#STREAM_ACCESSIBILITY

The following examples show how to use android.media.AudioManager#STREAM_ACCESSIBILITY . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GroupedMenuItemForVolumeAction.java    From talkback with Apache License 2.0 6 votes vote down vote up
@Override
public int getIconResource() {
  switch (volumeStreamType) {
    case AudioManager.STREAM_MUSIC:
      return R.drawable.quantum_ic_music_note_white_24;
    case AudioManager.STREAM_VOICE_CALL:
      return R.drawable.quantum_ic_phone_white_24;
    case AudioManager.STREAM_RING:
      return R.drawable.quantum_ic_vibration_white_24;
    case AudioManager.STREAM_ALARM:
      return R.drawable.quantum_ic_alarm_white_24;
    case AudioManager.STREAM_ACCESSIBILITY:
      return R.drawable.quantum_ic_accessibility_new_white_24;
  }
  return 0;
}
 
Example 2
Source File: GroupedMenuItemForVolumeAction.java    From talkback with Apache License 2.0 6 votes vote down vote up
@Override
public String getText() {
  switch (volumeStreamType) {
    case AudioManager.STREAM_MUSIC:
      return context.getString(R.string.volume_menu_media);
    case AudioManager.STREAM_VOICE_CALL:
      return context.getString(R.string.volume_menu_call);
    case AudioManager.STREAM_RING:
      return context.getString(R.string.volume_menu_ring);
    case AudioManager.STREAM_ALARM:
      return context.getString(R.string.volume_menu_alarm);
    case AudioManager.STREAM_ACCESSIBILITY:
      return context.getString(R.string.volume_menu_accessibility);
  }
  return "";
}
 
Example 3
Source File: GroupedMenuItemForVolumeAction.java    From talkback with Apache License 2.0 5 votes vote down vote up
private static SwitchAccessMenuItemEnum.MenuItem getMenuItemEnumFromVolumeType(int volumeType) {
  switch (volumeType) {
    case AudioManager.STREAM_MUSIC:
      return SwitchAccessMenuItemEnum.MenuItem.VOLUME_SUBMENU_MEDIA;
    case AudioManager.STREAM_VOICE_CALL:
      return SwitchAccessMenuItemEnum.MenuItem.VOLUME_SUBMENU_CALL;
    case AudioManager.STREAM_RING:
      return SwitchAccessMenuItemEnum.MenuItem.VOLUME_SUBMENU_RING;
    case AudioManager.STREAM_ALARM:
      return SwitchAccessMenuItemEnum.MenuItem.VOLUME_SUBMENU_ALARM;
    case AudioManager.STREAM_ACCESSIBILITY:
      return SwitchAccessMenuItemEnum.MenuItem.VOLUME_SUBMENU_ACCESSIBILITY;
  }
  return SwitchAccessMenuItemEnum.MenuItem.ITEM_UNSPECIFIED;
}
 
Example 4
Source File: GroupedMenuItemForVolumeAction.java    From talkback with Apache License 2.0 5 votes vote down vote up
private boolean canStreamBeMuted() {
  // TODO: Instead of hiding the mute button for alarm and accessibility, investigate
  // a more elegant way of determining is a volume stream can be muted and/or manually setting
  // the volume to 0 instead of using ADJUST_STREAM_MUTE. There's a bug in AudioManager that
  // causes some volume types on certain versions to not be muteable. Alarm and accessibility
  // volume are generally not considered "muteable" volume types, so manually hiding the mute
  // button for these streams doesn't significantly impact user experience.
  boolean isValidStreamType =
      (volumeStreamType != AudioManager.STREAM_ALARM)
          && (volumeStreamType != AudioManager.STREAM_ACCESSIBILITY);
  return isValidStreamType
      && ((audioManager != null) && (audioManager.getStreamMinVolume(volumeStreamType) == 0));
}
 
Example 5
Source File: VolumeMonitor.java    From talkback with Apache License 2.0 5 votes vote down vote up
/**
 * Called after volume changes. Handles acquiring control of the current stream and providing
 * feedback.
 *
 * @param streamType The stream type constant.
 * @param volume The current volume.
 * @param prevVolume The previous volume.
 */
private void internalOnVolumeChanged(int streamType, int volume, int prevVolume) {
  if (isSelfAdjusted(streamType, volume)) {
    // Ignore self-adjustments.
    return;
  }

  if (FeatureSupport.hasAcessibilityAudioStream(context)
      && streamType == AudioManager.STREAM_ACCESSIBILITY) {
    cacheAccessibilityStreamVolume();
  }

  if (currentStream < 0) {
    // If the current stream hasn't been set, acquire control.
    currentStream = streamType;
    AudioManagerCompatUtils.forceVolumeControlStream(audioManager, currentStream);
    handler.onControlAcquired(streamType);
    return;
  }

  if (volume == prevVolume) {
    // Ignore ADJUST_SAME if we've already acquired control.
    return;
  }

  handler.releaseControlDelayed();
}