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

Commit 7c53d299 authored by Michael Mikhail's avatar Michael Mikhail Committed by Automerger Merge Worker
Browse files

Merge changes I4bd65bdb,Ibe80b4b1 into udc-dev am: 83c13d65

parents d42cc8e5 83c13d65
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -7155,6 +7155,18 @@
    <!-- 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: 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] -->
    <!-- Sound: Summary for when notification volume is disabled. [CHAR LIMIT=100] -->
    <string name="notification_volume_disabled_summary">Unavailable because ring is muted</string>
    <string name="notification_volume_disabled_summary">Unavailable because ring is muted</string>
+13 −0
Original line number Original line Diff line number Diff line
@@ -52,6 +52,7 @@ public class MediaVolumePreferenceController extends VolumeSeekBarPreferenceCont


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


    @Override
    @Override
@@ -109,6 +110,18 @@ public class MediaVolumePreferenceController extends VolumeSeekBarPreferenceCont
        return false;
        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
    @Override
    public SliceAction getSliceEndItem(Context context) {
    public SliceAction getSliceEndItem(Context context) {
        if (!isSupportEndItem()) {
        if (!isSupportEndItem()) {
+33 −16
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Looper;
import android.os.Message;
import android.os.Message;
import android.service.notification.NotificationListenerService;
import android.service.notification.NotificationListenerService;
import android.view.View;


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


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


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


    @Override
    @Override
    protected void selectPreferenceIconState() {
    protected int getEffectiveRingerMode() {
        if (mPreference != null) {
        if (mVibrator == null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
            if (mVibrator != null && mRingerMode == AudioManager.RINGER_MODE_VIBRATE) {
            return AudioManager.RINGER_MODE_SILENT;
                mMuteIcon = mVibrateIconId;
        } else if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
                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
            if (mHelper.getStreamVolume(AudioManager.STREAM_NOTIFICATION) == 0) {
            if (mHelper.getStreamVolume(AudioManager.STREAM_NOTIFICATION) == 0) {
                    // ring is in normal, but notification is in silent
                // Ring is in normal, but notification is in silent.
                    mMuteIcon = mSilentIconId;
                return AudioManager.RINGER_MODE_SILENT;
                    mPreference.showIcon(mSilentIconId);
            }
                } else {
        }
                    mPreference.showIcon(mNormalIconId);
        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;
                    break;
                case NOTIFICATION_VOLUME_CHANGED:
                case NOTIFICATION_VOLUME_CHANGED:
                    selectPreferenceIconState();
                    selectPreferenceIconState();
                    updateContentDescription();
                    updateEnabledState();
                    updateEnabledState();
                    break;
                    break;
            }
            }
+28 −2
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@ import android.os.Vibrator;
import android.util.Log;
import android.util.Log;


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


import java.util.Objects;
import java.util.Objects;


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


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


@@ -131,10 +134,11 @@ public abstract class RingerModeAffectedVolumePreferenceController extends
     */
     */
    protected void selectPreferenceIconState() {
    protected void selectPreferenceIconState() {
        if (mPreference != null) {
        if (mPreference != null) {
            if (mRingerMode == AudioManager.RINGER_MODE_NORMAL) {
            int ringerMode = getEffectiveRingerMode();
            if (ringerMode == AudioManager.RINGER_MODE_NORMAL) {
                mPreference.showIcon(mNormalIconId);
                mPreference.showIcon(mNormalIconId);
            } else {
            } else {
                if (mRingerMode == AudioManager.RINGER_MODE_VIBRATE && mVibrator != null) {
                if (ringerMode == AudioManager.RINGER_MODE_VIBRATE) {
                    mMuteIcon = mVibrateIconId;
                    mMuteIcon = mVibrateIconId;
                } else {
                } else {
                    mMuteIcon = mSilentIconId;
                    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);
    protected abstract boolean hintsMatch(int hints);


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


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