Loading res/values/strings.xml +3 −0 Original line number Original line Diff line number Diff line Loading @@ -8828,6 +8828,9 @@ <!-- Sound: Title for the option managing notification volume. [CHAR LIMIT=30] --> <!-- Sound: Title for the option managing notification volume. [CHAR LIMIT=30] --> <string name="notification_volume_option_title">Notification volume</string> <string name="notification_volume_option_title">Notification volume</string> <!-- Sound: Summary for when notification volume is disabled. [CHAR LIMIT=100] --> <string name="notification_volume_disabled_summary">Unavailable because ring is muted</string> <!-- Sound: Title for the option defining the phone ringtone. [CHAR LIMIT=30] --> <!-- Sound: Title for the option defining the phone ringtone. [CHAR LIMIT=30] --> <string name="ringtone_title">Phone ringtone</string> <string name="ringtone_title">Phone ringtone</string> res/xml/sound_settings.xml +2 −2 Original line number Original line Diff line number Diff line Loading @@ -86,8 +86,8 @@ android:icon="@drawable/ic_notifications" android:icon="@drawable/ic_notifications" android:title="@string/notification_volume_option_title" android:title="@string/notification_volume_option_title" android:order="-150" android:order="-150" settings:controller= settings:controller="com.android.settings.notification.NotificationVolumePreferenceController" "com.android.settings.notification.NotificationVolumePreferenceController"/> settings:unavailableSliceSubtitle="@string/notification_volume_disabled_summary"/> <!-- Alarm volume --> <!-- Alarm volume --> <com.android.settings.notification.VolumeSeekBarPreference <com.android.settings.notification.VolumeSeekBarPreference Loading src/com/android/settings/notification/NotificationVolumePreferenceController.java +25 −14 Original line number Original line Diff line number Diff line Loading @@ -51,7 +51,6 @@ public class NotificationVolumePreferenceController extends private final RingReceiver mReceiver = new RingReceiver(); private final RingReceiver mReceiver = new RingReceiver(); private final H mHandler = new H(); private final H mHandler = new H(); public NotificationVolumePreferenceController(Context context) { public NotificationVolumePreferenceController(Context context) { this(context, KEY_NOTIFICATION_VOLUME); this(context, KEY_NOTIFICATION_VOLUME); } } Loading @@ -63,7 +62,9 @@ public class NotificationVolumePreferenceController extends mVibrateIconId = R.drawable.ic_volume_ringer_vibrate; mVibrateIconId = R.drawable.ic_volume_ringer_vibrate; mSilentIconId = R.drawable.ic_notifications_off_24dp; mSilentIconId = R.drawable.ic_notifications_off_24dp; updateRingerMode(); if (updateRingerMode()) { updateEnabledState(); } } } /** /** Loading @@ -77,12 +78,10 @@ public class NotificationVolumePreferenceController extends if (mPreference == null) { if (mPreference == null) { setupVolPreference(screen); setupVolPreference(screen); } } mSeparateNotification = isSeparateNotificationConfigEnabled(); if (mPreference != null) { mPreference.setVisible(getAvailabilityStatus() == AVAILABLE); } updateEffectsSuppressor(); updateEffectsSuppressor(); selectPreferenceIconState(); selectPreferenceIconState(); updateEnabledState(); } } /** /** Loading @@ -95,14 +94,18 @@ public class NotificationVolumePreferenceController extends boolean newVal = isSeparateNotificationConfigEnabled(); boolean newVal = isSeparateNotificationConfigEnabled(); if (newVal != mSeparateNotification) { if (newVal != mSeparateNotification) { mSeparateNotification = newVal; mSeparateNotification = newVal; // manually hiding the preference because being unavailable does not do the job // Update UI if config change happens when Sound Settings page is on the foreground if (mPreference != null) { if (mPreference != null) { mPreference.setVisible(getAvailabilityStatus() == AVAILABLE); int status = getAvailabilityStatus(); mPreference.setVisible(status == AVAILABLE || status == DISABLED_DEPENDENT_SETTING); if (status == DISABLED_DEPENDENT_SETTING) { mPreference.setEnabled(false); } } } } } } } } } @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) @Override @Override Loading @@ -126,10 +129,11 @@ public class NotificationVolumePreferenceController extends @Override @Override public int getAvailabilityStatus() { public int getAvailabilityStatus() { boolean separateNotification = isSeparateNotificationConfigEnabled(); boolean separateNotification = isSeparateNotificationConfigEnabled(); return mContext.getResources().getBoolean(R.bool.config_show_notification_volume) return mContext.getResources().getBoolean(R.bool.config_show_notification_volume) && !mHelper.isSingleVolume() && separateNotification && !mHelper.isSingleVolume() && separateNotification ? AVAILABLE : UNSUPPORTED_ON_DEVICE; ? (mRingerMode == AudioManager.RINGER_MODE_NORMAL ? AVAILABLE : DISABLED_DEPENDENT_SETTING) : UNSUPPORTED_ON_DEVICE; } } @Override @Override Loading Loading @@ -158,7 +162,6 @@ public class NotificationVolumePreferenceController extends if (mVibrator != null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) { if (mVibrator != null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) { mMuteIcon = mVibrateIconId; mMuteIcon = mVibrateIconId; mPreference.showIcon(mVibrateIconId); mPreference.showIcon(mVibrateIconId); } else if (mRingerMode == AudioManager.RINGER_MODE_SILENT } else if (mRingerMode == AudioManager.RINGER_MODE_SILENT || mVibrator == null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) { || mVibrator == null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) { mMuteIcon = mSilentIconId; mMuteIcon = mSilentIconId; Loading @@ -175,6 +178,12 @@ public class NotificationVolumePreferenceController extends } } } } private void updateEnabledState() { if (mPreference != null) { mPreference.setEnabled(mRingerMode == AudioManager.RINGER_MODE_NORMAL); } } private final class H extends Handler { private final class H extends Handler { private static final int UPDATE_EFFECTS_SUPPRESSOR = 1; private static final int UPDATE_EFFECTS_SUPPRESSOR = 1; private static final int UPDATE_RINGER_MODE = 2; private static final int UPDATE_RINGER_MODE = 2; Loading @@ -191,10 +200,13 @@ public class NotificationVolumePreferenceController extends updateEffectsSuppressor(); updateEffectsSuppressor(); break; break; case UPDATE_RINGER_MODE: case UPDATE_RINGER_MODE: updateRingerMode(); if (updateRingerMode()) { updateEnabledState(); } break; break; case NOTIFICATION_VOLUME_CHANGED: case NOTIFICATION_VOLUME_CHANGED: selectPreferenceIconState(); selectPreferenceIconState(); updateEnabledState(); break; break; } } } } Loading Loading @@ -239,5 +251,4 @@ public class NotificationVolumePreferenceController extends } } } } } } } } src/com/android/settings/notification/RingerModeAffectedVolumePreferenceController.java +9 −2 Original line number Original line Diff line number Diff line Loading @@ -140,11 +140,18 @@ public abstract class RingerModeAffectedVolumePreferenceController extends return valueUpdated; return valueUpdated; } } protected void updateRingerMode() { /** * Updates UI Icon in response to ringer mode changes. * @return whether the ringer mode has changed. */ protected boolean updateRingerMode() { final int ringerMode = mHelper.getRingerModeInternal(); final int ringerMode = mHelper.getRingerModeInternal(); if (mRingerMode == ringerMode) return; if (mRingerMode == ringerMode) { return false; } mRingerMode = ringerMode; mRingerMode = ringerMode; selectPreferenceIconState(); selectPreferenceIconState(); return true; } } /** /** Loading src/com/android/settings/slices/VolumeSliceHelper.java +24 −2 Original line number Original line Diff line number Diff line Loading @@ -93,8 +93,9 @@ public class VolumeSliceHelper { if (AudioManager.VOLUME_CHANGED_ACTION.equals(action)) { if (AudioManager.VOLUME_CHANGED_ACTION.equals(action)) { handleVolumeChanged(context, intent); handleVolumeChanged(context, intent); } else if (AudioManager.STREAM_MUTE_CHANGED_ACTION.equals(action) } else if (AudioManager.STREAM_MUTE_CHANGED_ACTION.equals(action)) { || AudioManager.STREAM_DEVICES_CHANGED_ACTION.equals(action)) { handleMuteChanged(context, intent); } else if (AudioManager.STREAM_DEVICES_CHANGED_ACTION.equals(action)) { handleStreamChanged(context, intent); handleStreamChanged(context, intent); } else { } else { notifyAllStreamsChanged(context); notifyAllStreamsChanged(context); Loading @@ -109,8 +110,29 @@ public class VolumeSliceHelper { } } } } /** * When mute is changed, notifyChange on relevant Volume Slice ContentResolvers to mark them * as needing update. * * In addition to the matching stream, we always notifyChange for the Notification stream * when Ring events are issued. This is to make sure that Notification always gets updated * for RingerMode changes, even if Notification's volume is zero and therefore it would not * get its own AudioManager.VOLUME_CHANGED_ACTION. */ private static void handleMuteChanged(Context context, Intent intent) { final int inputType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1); handleStreamChanged(context, inputType); if (inputType == AudioManager.STREAM_RING) { handleStreamChanged(context, AudioManager.STREAM_NOTIFICATION); } } private static void handleStreamChanged(Context context, Intent intent) { private static void handleStreamChanged(Context context, Intent intent) { final int inputType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1); final int inputType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1); handleStreamChanged(context, inputType); } private static void handleStreamChanged(Context context, int inputType) { synchronized (sRegisteredUri) { synchronized (sRegisteredUri) { for (Map.Entry<Uri, Integer> entry : sRegisteredUri.entrySet()) { for (Map.Entry<Uri, Integer> entry : sRegisteredUri.entrySet()) { if (entry.getValue() == inputType) { if (entry.getValue() == inputType) { Loading Loading
res/values/strings.xml +3 −0 Original line number Original line Diff line number Diff line Loading @@ -8828,6 +8828,9 @@ <!-- Sound: Title for the option managing notification volume. [CHAR LIMIT=30] --> <!-- Sound: Title for the option managing notification volume. [CHAR LIMIT=30] --> <string name="notification_volume_option_title">Notification volume</string> <string name="notification_volume_option_title">Notification volume</string> <!-- Sound: Summary for when notification volume is disabled. [CHAR LIMIT=100] --> <string name="notification_volume_disabled_summary">Unavailable because ring is muted</string> <!-- Sound: Title for the option defining the phone ringtone. [CHAR LIMIT=30] --> <!-- Sound: Title for the option defining the phone ringtone. [CHAR LIMIT=30] --> <string name="ringtone_title">Phone ringtone</string> <string name="ringtone_title">Phone ringtone</string>
res/xml/sound_settings.xml +2 −2 Original line number Original line Diff line number Diff line Loading @@ -86,8 +86,8 @@ android:icon="@drawable/ic_notifications" android:icon="@drawable/ic_notifications" android:title="@string/notification_volume_option_title" android:title="@string/notification_volume_option_title" android:order="-150" android:order="-150" settings:controller= settings:controller="com.android.settings.notification.NotificationVolumePreferenceController" "com.android.settings.notification.NotificationVolumePreferenceController"/> settings:unavailableSliceSubtitle="@string/notification_volume_disabled_summary"/> <!-- Alarm volume --> <!-- Alarm volume --> <com.android.settings.notification.VolumeSeekBarPreference <com.android.settings.notification.VolumeSeekBarPreference Loading
src/com/android/settings/notification/NotificationVolumePreferenceController.java +25 −14 Original line number Original line Diff line number Diff line Loading @@ -51,7 +51,6 @@ public class NotificationVolumePreferenceController extends private final RingReceiver mReceiver = new RingReceiver(); private final RingReceiver mReceiver = new RingReceiver(); private final H mHandler = new H(); private final H mHandler = new H(); public NotificationVolumePreferenceController(Context context) { public NotificationVolumePreferenceController(Context context) { this(context, KEY_NOTIFICATION_VOLUME); this(context, KEY_NOTIFICATION_VOLUME); } } Loading @@ -63,7 +62,9 @@ public class NotificationVolumePreferenceController extends mVibrateIconId = R.drawable.ic_volume_ringer_vibrate; mVibrateIconId = R.drawable.ic_volume_ringer_vibrate; mSilentIconId = R.drawable.ic_notifications_off_24dp; mSilentIconId = R.drawable.ic_notifications_off_24dp; updateRingerMode(); if (updateRingerMode()) { updateEnabledState(); } } } /** /** Loading @@ -77,12 +78,10 @@ public class NotificationVolumePreferenceController extends if (mPreference == null) { if (mPreference == null) { setupVolPreference(screen); setupVolPreference(screen); } } mSeparateNotification = isSeparateNotificationConfigEnabled(); if (mPreference != null) { mPreference.setVisible(getAvailabilityStatus() == AVAILABLE); } updateEffectsSuppressor(); updateEffectsSuppressor(); selectPreferenceIconState(); selectPreferenceIconState(); updateEnabledState(); } } /** /** Loading @@ -95,14 +94,18 @@ public class NotificationVolumePreferenceController extends boolean newVal = isSeparateNotificationConfigEnabled(); boolean newVal = isSeparateNotificationConfigEnabled(); if (newVal != mSeparateNotification) { if (newVal != mSeparateNotification) { mSeparateNotification = newVal; mSeparateNotification = newVal; // manually hiding the preference because being unavailable does not do the job // Update UI if config change happens when Sound Settings page is on the foreground if (mPreference != null) { if (mPreference != null) { mPreference.setVisible(getAvailabilityStatus() == AVAILABLE); int status = getAvailabilityStatus(); mPreference.setVisible(status == AVAILABLE || status == DISABLED_DEPENDENT_SETTING); if (status == DISABLED_DEPENDENT_SETTING) { mPreference.setEnabled(false); } } } } } } } } } @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) @OnLifecycleEvent(Lifecycle.Event.ON_RESUME) @Override @Override Loading @@ -126,10 +129,11 @@ public class NotificationVolumePreferenceController extends @Override @Override public int getAvailabilityStatus() { public int getAvailabilityStatus() { boolean separateNotification = isSeparateNotificationConfigEnabled(); boolean separateNotification = isSeparateNotificationConfigEnabled(); return mContext.getResources().getBoolean(R.bool.config_show_notification_volume) return mContext.getResources().getBoolean(R.bool.config_show_notification_volume) && !mHelper.isSingleVolume() && separateNotification && !mHelper.isSingleVolume() && separateNotification ? AVAILABLE : UNSUPPORTED_ON_DEVICE; ? (mRingerMode == AudioManager.RINGER_MODE_NORMAL ? AVAILABLE : DISABLED_DEPENDENT_SETTING) : UNSUPPORTED_ON_DEVICE; } } @Override @Override Loading Loading @@ -158,7 +162,6 @@ public class NotificationVolumePreferenceController extends if (mVibrator != null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) { if (mVibrator != null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) { mMuteIcon = mVibrateIconId; mMuteIcon = mVibrateIconId; mPreference.showIcon(mVibrateIconId); mPreference.showIcon(mVibrateIconId); } else if (mRingerMode == AudioManager.RINGER_MODE_SILENT } else if (mRingerMode == AudioManager.RINGER_MODE_SILENT || mVibrator == null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) { || mVibrator == null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) { mMuteIcon = mSilentIconId; mMuteIcon = mSilentIconId; Loading @@ -175,6 +178,12 @@ public class NotificationVolumePreferenceController extends } } } } private void updateEnabledState() { if (mPreference != null) { mPreference.setEnabled(mRingerMode == AudioManager.RINGER_MODE_NORMAL); } } private final class H extends Handler { private final class H extends Handler { private static final int UPDATE_EFFECTS_SUPPRESSOR = 1; private static final int UPDATE_EFFECTS_SUPPRESSOR = 1; private static final int UPDATE_RINGER_MODE = 2; private static final int UPDATE_RINGER_MODE = 2; Loading @@ -191,10 +200,13 @@ public class NotificationVolumePreferenceController extends updateEffectsSuppressor(); updateEffectsSuppressor(); break; break; case UPDATE_RINGER_MODE: case UPDATE_RINGER_MODE: updateRingerMode(); if (updateRingerMode()) { updateEnabledState(); } break; break; case NOTIFICATION_VOLUME_CHANGED: case NOTIFICATION_VOLUME_CHANGED: selectPreferenceIconState(); selectPreferenceIconState(); updateEnabledState(); break; break; } } } } Loading Loading @@ -239,5 +251,4 @@ public class NotificationVolumePreferenceController extends } } } } } } } }
src/com/android/settings/notification/RingerModeAffectedVolumePreferenceController.java +9 −2 Original line number Original line Diff line number Diff line Loading @@ -140,11 +140,18 @@ public abstract class RingerModeAffectedVolumePreferenceController extends return valueUpdated; return valueUpdated; } } protected void updateRingerMode() { /** * Updates UI Icon in response to ringer mode changes. * @return whether the ringer mode has changed. */ protected boolean updateRingerMode() { final int ringerMode = mHelper.getRingerModeInternal(); final int ringerMode = mHelper.getRingerModeInternal(); if (mRingerMode == ringerMode) return; if (mRingerMode == ringerMode) { return false; } mRingerMode = ringerMode; mRingerMode = ringerMode; selectPreferenceIconState(); selectPreferenceIconState(); return true; } } /** /** Loading
src/com/android/settings/slices/VolumeSliceHelper.java +24 −2 Original line number Original line Diff line number Diff line Loading @@ -93,8 +93,9 @@ public class VolumeSliceHelper { if (AudioManager.VOLUME_CHANGED_ACTION.equals(action)) { if (AudioManager.VOLUME_CHANGED_ACTION.equals(action)) { handleVolumeChanged(context, intent); handleVolumeChanged(context, intent); } else if (AudioManager.STREAM_MUTE_CHANGED_ACTION.equals(action) } else if (AudioManager.STREAM_MUTE_CHANGED_ACTION.equals(action)) { || AudioManager.STREAM_DEVICES_CHANGED_ACTION.equals(action)) { handleMuteChanged(context, intent); } else if (AudioManager.STREAM_DEVICES_CHANGED_ACTION.equals(action)) { handleStreamChanged(context, intent); handleStreamChanged(context, intent); } else { } else { notifyAllStreamsChanged(context); notifyAllStreamsChanged(context); Loading @@ -109,8 +110,29 @@ public class VolumeSliceHelper { } } } } /** * When mute is changed, notifyChange on relevant Volume Slice ContentResolvers to mark them * as needing update. * * In addition to the matching stream, we always notifyChange for the Notification stream * when Ring events are issued. This is to make sure that Notification always gets updated * for RingerMode changes, even if Notification's volume is zero and therefore it would not * get its own AudioManager.VOLUME_CHANGED_ACTION. */ private static void handleMuteChanged(Context context, Intent intent) { final int inputType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1); handleStreamChanged(context, inputType); if (inputType == AudioManager.STREAM_RING) { handleStreamChanged(context, AudioManager.STREAM_NOTIFICATION); } } private static void handleStreamChanged(Context context, Intent intent) { private static void handleStreamChanged(Context context, Intent intent) { final int inputType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1); final int inputType = intent.getIntExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, -1); handleStreamChanged(context, inputType); } private static void handleStreamChanged(Context context, int inputType) { synchronized (sRegisteredUri) { synchronized (sRegisteredUri) { for (Map.Entry<Uri, Integer> entry : sRegisteredUri.entrySet()) { for (Map.Entry<Uri, Integer> entry : sRegisteredUri.entrySet()) { if (entry.getValue() == inputType) { if (entry.getValue() == inputType) { Loading