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

Commit b3f164de authored by Anton Potapov's avatar Anton Potapov Committed by Android (Google) Code Review
Browse files

Merge changes from topic "volume_panel_sliders_improvements" into main

* changes:
  Add a11y descriptions for the new panel
  Improve volume sliders behaviour:
parents 6de35cc4 ddd434c6
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -161,11 +161,11 @@ class AudioRepositoryImpl(

    override suspend fun setMuted(audioStream: AudioStream, isMuted: Boolean) =
        withContext(backgroundCoroutineContext) {
            if (isMuted) {
                audioManager.adjustStreamVolume(audioStream.value, 0, AudioManager.ADJUST_MUTE)
            } else {
                audioManager.adjustStreamVolume(audioStream.value, 0, AudioManager.ADJUST_UNMUTE)
            }
            audioManager.adjustStreamVolume(
                audioStream.value,
                if (isMuted) AudioManager.ADJUST_MUTE else AudioManager.ADJUST_UNMUTE,
                0,
            )
        }

    private fun getMinVolume(stream: AudioStream): Int =
+2 −2
Original line number Diff line number Diff line
@@ -84,10 +84,10 @@ class AudioVolumeInteractor(
                    (audioStreamModel.audioStream.value == AudioManager.STREAM_NOTIFICATION &&
                        audioStreamModel.isMuted)
            ) {
                return 0
                return audioStreamModel.minVolume
            }
        } else if (audioStreamModel.isMuted) {
            return 0
            return audioStreamModel.minVolume
        }
        return audioStreamModel.volume
    }
+3 −3
Original line number Diff line number Diff line
@@ -77,13 +77,13 @@ class AudioRepositoryTest {
        `when`(audioManager.getStreamMaxVolume(anyInt())).thenReturn(MAX_VOLUME)
        `when`(audioManager.ringerModeInternal).thenReturn(AudioManager.RINGER_MODE_NORMAL)
        `when`(audioManager.setStreamVolume(anyInt(), anyInt(), anyInt())).then {
            val streamType = it.arguments[1] as Int
            volumeByStream[it.arguments[0] as Int] = streamType
            val streamType = it.arguments[0] as Int
            volumeByStream[it.arguments[0] as Int] = it.arguments[1] as Int
            triggerEvent(AudioManagerEvent.StreamVolumeChanged(AudioStream(streamType)))
        }
        `when`(audioManager.adjustStreamVolume(anyInt(), anyInt(), anyInt())).then {
            val streamType = it.arguments[0] as Int
            isMuteByStream[streamType] = it.arguments[2] == AudioManager.ADJUST_MUTE
            isMuteByStream[streamType] = it.arguments[1] == AudioManager.ADJUST_MUTE
            triggerEvent(AudioManagerEvent.StreamMuteChanged(AudioStream(streamType)))
        }
        `when`(audioManager.getStreamVolume(anyInt())).thenAnswer {
+1 −1
Original line number Diff line number Diff line
@@ -911,7 +911,7 @@

        <activity
            android:name=".volume.panel.ui.activity.VolumePanelActivity"
            android:label="@string/sound_settings"
            android:label="@string/accessibility_volume_settings"
            android:excludeFromRecents="true"
            android:exported="false"
            android:launchMode="singleInstance"
+13 −2
Original line number Diff line number Diff line
@@ -32,6 +32,11 @@ import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.semantics.Role
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.role
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import com.android.compose.animation.Expandable
@@ -52,6 +57,7 @@ class ButtonComponent(
    override fun VolumePanelComposeScope.Content(modifier: Modifier) {
        val viewModelByState by viewModelFlow.collectAsState()
        val viewModel = viewModelByState ?: return
        val label = viewModel.label.toString()

        Column(
            modifier = modifier,
@@ -59,7 +65,11 @@ class ButtonComponent(
            horizontalAlignment = Alignment.CenterHorizontally,
        ) {
            Expandable(
                modifier = Modifier.height(64.dp).fillMaxWidth(),
                modifier =
                    Modifier.height(64.dp).fillMaxWidth().semantics {
                        role = Role.Button
                        contentDescription = label
                    },
                color = MaterialTheme.colorScheme.primaryContainer,
                shape = RoundedCornerShape(28.dp),
                contentColor = MaterialTheme.colorScheme.onPrimaryContainer,
@@ -71,7 +81,8 @@ class ButtonComponent(
                }
            }
            Text(
                text = viewModel.label.toString(),
                modifier = Modifier.clearAndSetSemantics {},
                text = label,
                style = MaterialTheme.typography.labelMedium,
                maxLines = 1,
                overflow = TextOverflow.Ellipsis,
Loading