Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 83c13d65 authored by Michael Mikhail's avatar Michael Mikhail Committed by Android (Google) Code Review
Browse files

Merge changes I4bd65bdb,Ibe80b4b1 into udc-dev

* changes:
  Trigger talkback for notification volume change
  Add content description to volume title in settings.
parents e0b92493 6308e3fb
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -7151,6 +7151,18 @@
    <!-- Sound: Title for the option managing notification volume. [CHAR LIMIT=30] -->
    <string name="notification_volume_option_title">Notification volume</string>
    <!-- Sound: Content description of ring volume title in silent mode. [CHAR LIMIT=NONE BACKUP_MESSAGE_ID=8994620163934249882] -->
    <string name="ringer_content_description_silent_mode">Ringer silent</string>
    <!-- Sound: Content description of ring volume title in vibrate mode. [CHAR LIMIT=NONE BACKUP_MESSAGE_ID=6261841170896561364] -->
    <string name="ringer_content_description_vibrate_mode">Ringer vibrate</string>
    <!-- Sound: Content description of notification volume title in vibrate mode. [CHAR LIMIT=NONE] -->
    <string name="notification_volume_content_description_vibrate_mode">Notification volume muted, notifications will vibrate</string>
    <!-- Sound: Content description of volume title in silent mode [CHAR LIMIT=NONE] -->
    <string name="volume_content_description_silent_mode"> <xliff:g id="volume type" example="notification volume">%1$s</xliff:g> muted</string>
    <!-- Sound: Summary for when notification volume is disabled. [CHAR LIMIT=100] -->
    <string name="notification_volume_disabled_summary">Unavailable because ring is muted</string>
+13 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ public class MediaVolumePreferenceController extends VolumeSeekBarPreferenceCont

    public MediaVolumePreferenceController(Context context) {
        super(context, KEY_MEDIA_VOLUME);
        mVolumePreferenceListener = this::updateContentDescription;
    }

    @Override
@@ -109,6 +110,18 @@ public class MediaVolumePreferenceController extends VolumeSeekBarPreferenceCont
        return false;
    }

    private void updateContentDescription() {
        if (mPreference != null) {
            if (mPreference.isMuted()) {
                mPreference.updateContentDescription(
                        mContext.getString(R.string.volume_content_description_silent_mode,
                        mPreference.getTitle()));
            } else {
                mPreference.updateContentDescription(mPreference.getTitle());
            }
        }
    }

    @Override
    public SliceAction getSliceEndItem(Context context) {
        if (!isSupportEndItem()) {
+33 −16
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.service.notification.NotificationListenerService;
import android.view.View;

import androidx.lifecycle.OnLifecycleEvent;
import androidx.preference.PreferenceScreen;
@@ -75,6 +76,7 @@ public class NotificationVolumePreferenceController extends

        updateEffectsSuppressor();
        selectPreferenceIconState();
        updateContentDescription();
        updateEnabledState();
    }

@@ -120,23 +122,37 @@ public class NotificationVolumePreferenceController extends
    }

    @Override
    protected void selectPreferenceIconState() {
        if (mPreference != null) {
            if (mVibrator != null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
                mMuteIcon = mVibrateIconId;
                mPreference.showIcon(mVibrateIconId);
            } else if (mRingerMode == AudioManager.RINGER_MODE_SILENT
                    || mVibrator == null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
                mMuteIcon = mSilentIconId;
                mPreference.showIcon(mSilentIconId);
            } else { // ringmode normal: could be that we are still silent
    protected int getEffectiveRingerMode() {
        if (mVibrator == null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
            return AudioManager.RINGER_MODE_SILENT;
        } else if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
            if (mHelper.getStreamVolume(AudioManager.STREAM_NOTIFICATION) == 0) {
                    // ring is in normal, but notification is in silent
                    mMuteIcon = mSilentIconId;
                    mPreference.showIcon(mSilentIconId);
                } else {
                    mPreference.showIcon(mNormalIconId);
                // Ring is in normal, but notification is in silent.
                return AudioManager.RINGER_MODE_SILENT;
            }
        }
        return mRingerMode;
    }

    @Override
    protected void updateContentDescription() {
        if (mPreference != null) {
            int ringerMode = getEffectiveRingerMode();
            if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
                mPreference.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_POLITE);
                mPreference.updateContentDescription(
                        mContext.getString(
                                R.string.notification_volume_content_description_vibrate_mode));
            } else if (ringerMode == AudioManager.RINGER_MODE_SILENT) {
                mPreference.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_POLITE);
                mPreference.updateContentDescription(
                        mContext.getString(R.string.volume_content_description_silent_mode,
                                mPreference.getTitle()));
            } else {
                // Set a11y mode to none in order not to trigger talkback while changing
                // notification volume in normal mode.
                mPreference.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_NONE);
                mPreference.updateContentDescription(mPreference.getTitle());
            }
        }
    }
@@ -169,6 +185,7 @@ public class NotificationVolumePreferenceController extends
                    break;
                case NOTIFICATION_VOLUME_CHANGED:
                    selectPreferenceIconState();
                    updateContentDescription();
                    updateEnabledState();
                    break;
            }
+28 −2
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.os.Vibrator;
import android.util.Log;

import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.R;

import java.util.Objects;

@@ -54,6 +55,7 @@ public abstract class RingerModeAffectedVolumePreferenceController extends
        if (mVibrator != null && !mVibrator.hasVibrator()) {
            mVibrator = null;
        }
        mVolumePreferenceListener = this::updateContentDescription;
    }

    protected void updateEffectsSuppressor() {
@@ -123,6 +125,7 @@ public abstract class RingerModeAffectedVolumePreferenceController extends
        }
        mRingerMode = ringerMode;
        selectPreferenceIconState();
        updateContentDescription();
        return true;
    }

@@ -131,10 +134,11 @@ public abstract class RingerModeAffectedVolumePreferenceController extends
     */
    protected void selectPreferenceIconState() {
        if (mPreference != null) {
            if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
            int ringerMode = getEffectiveRingerMode();
            if (ringerMode == AudioManager.RINGER_MODE_NORMAL) {
                mPreference.showIcon(mNormalIconId);
            } else {
                if (mRingerMode == AudioManager.RINGER_MODE_VIBRATE && mVibrator != null) {
                if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
                    mMuteIcon = mVibrateIconId;
                } else {
                    mMuteIcon = mSilentIconId;
@@ -144,6 +148,28 @@ public abstract class RingerModeAffectedVolumePreferenceController extends
        }
    }

    protected int getEffectiveRingerMode() {
        if (mVibrator == null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
            return AudioManager.RINGER_MODE_SILENT;
        }
        return mRingerMode;
    }

    protected void updateContentDescription() {
        if (mPreference != null) {
            int ringerMode = getEffectiveRingerMode();
            if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
                mPreference.updateContentDescription(
                        mContext.getString(R.string.ringer_content_description_vibrate_mode));
            } else if (ringerMode == AudioManager.RINGER_MODE_SILENT) {
                mPreference.updateContentDescription(
                        mContext.getString(R.string.ringer_content_description_silent_mode));
            } else {
                mPreference.updateContentDescription(mPreference.getTitle());
            }
        }
    }

    protected abstract boolean hintsMatch(int hints);

}
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ public class SeparateRingVolumePreferenceController extends
        mReceiver.register(true);
        updateEffectsSuppressor();
        selectPreferenceIconState();
        updateContentDescription();

        if (mPreference != null) {
            mPreference.setVisible(getAvailabilityStatus() == AVAILABLE);
Loading