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

Commit 15f6ca2e authored by Beth Thibodeau's avatar Beth Thibodeau
Browse files

Add content description for seekbar

With the standard talkback info, this will result in a description like
"20%, 1:02 of 5:16, Slider" when the user taps on the seekbar

Fixes: 192346227
Test: manual; atest SeekBarObserverTest
Change-Id: I906d1f11d986e956508e00df269e09bbd150105a
parent 8d80e7ae
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2830,6 +2830,8 @@
    <string name="controls_media_settings_button">Settings</string>
    <!-- Description for media control's playing media item, including information for the media's title, the artist, and source app [CHAR LIMIT=NONE]-->
    <string name="controls_media_playing_item_description"><xliff:g id="song_name" example="Daily mix">%1$s</xliff:g> by <xliff:g id="artist_name" example="Various artists">%2$s</xliff:g> is playing from <xliff:g id="app_label" example="Spotify">%3$s</xliff:g></string>
    <!-- Content description for media cotnrols progress bar [CHAR_LIMIT=NONE] -->
    <string name="controls_media_seekbar_description"><xliff:g id="elapsed_time" example="1:30">%1$s</xliff:g> of <xliff:g id="total_time" example="3:00">%2$s</xliff:g></string>

    <!-- Title for Smartspace recommendation card within media controls. The "Play" means the action to play a media [CHAR_LIMIT=10] -->
    <string name="controls_media_smartspace_rec_title">Play</string>
+14 −7
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ class SeekBarObserver(private val holder: PlayerViewHolder) : Observer<SeekBarVi
            holder.seekBar.setProgress(0)
            holder.elapsedTimeView.setText("")
            holder.totalTimeView.setText("")
            holder.seekBar.contentDescription = ""
            return
        }

@@ -61,16 +62,22 @@ class SeekBarObserver(private val holder: PlayerViewHolder) : Observer<SeekBarVi
            setVerticalPadding(seekBarEnabledVerticalPadding)
        }

        data.duration?.let {
            holder.seekBar.setMax(it)
            holder.totalTimeView.setText(DateUtils.formatElapsedTime(
                    it / DateUtils.SECOND_IN_MILLIS))
        }
        holder.seekBar.setMax(data.duration)
        val totalTimeString = DateUtils.formatElapsedTime(
            data.duration / DateUtils.SECOND_IN_MILLIS)
        holder.totalTimeView.setText(totalTimeString)

        data.elapsedTime?.let {
            holder.seekBar.setProgress(it)
            holder.elapsedTimeView.setText(DateUtils.formatElapsedTime(
                    it / DateUtils.SECOND_IN_MILLIS))
            val elapsedTimeString = DateUtils.formatElapsedTime(
                it / DateUtils.SECOND_IN_MILLIS)
            holder.elapsedTimeView.setText(elapsedTimeString)

            holder.seekBar.contentDescription = holder.seekBar.context.getString(
                R.string.controls_media_seekbar_description,
                elapsedTimeString,
                totalTimeString
            )
        }
    }

+4 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ public class SeekBarObserverTest : SysuiTestCase() {
        assertThat(seekBarView.getThumb().getAlpha()).isEqualTo(0)
        assertThat(elapsedTimeView.getText()).isEqualTo("")
        assertThat(totalTimeView.getText()).isEqualTo("")
        assertThat(seekBarView.contentDescription).isEqualTo("")
        assertThat(seekBarView.maxHeight).isEqualTo(disabledHeight)
    }

@@ -102,6 +103,9 @@ public class SeekBarObserverTest : SysuiTestCase() {
        assertThat(seekBarView.max).isEqualTo(120000)
        assertThat(elapsedTimeView.getText()).isEqualTo("00:03")
        assertThat(totalTimeView.getText()).isEqualTo("02:00")

        val desc = context.getString(R.string.controls_media_seekbar_description, "00:03", "02:00")
        assertThat(seekBarView.contentDescription).isEqualTo(desc)
    }

    @Test