Merge "Add content description for seekbar" into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
c91778d2e5
@@ -2830,6 +2830,8 @@
|
|||||||
<string name="controls_media_settings_button">Settings</string>
|
<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]-->
|
<!-- 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>
|
<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] -->
|
<!-- 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>
|
<string name="controls_media_smartspace_rec_title">Play</string>
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class SeekBarObserver(private val holder: PlayerViewHolder) : Observer<SeekBarVi
|
|||||||
holder.seekBar.setProgress(0)
|
holder.seekBar.setProgress(0)
|
||||||
holder.elapsedTimeView.setText("")
|
holder.elapsedTimeView.setText("")
|
||||||
holder.totalTimeView.setText("")
|
holder.totalTimeView.setText("")
|
||||||
|
holder.seekBar.contentDescription = ""
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -61,16 +62,22 @@ class SeekBarObserver(private val holder: PlayerViewHolder) : Observer<SeekBarVi
|
|||||||
setVerticalPadding(seekBarEnabledVerticalPadding)
|
setVerticalPadding(seekBarEnabledVerticalPadding)
|
||||||
}
|
}
|
||||||
|
|
||||||
data.duration?.let {
|
holder.seekBar.setMax(data.duration)
|
||||||
holder.seekBar.setMax(it)
|
val totalTimeString = DateUtils.formatElapsedTime(
|
||||||
holder.totalTimeView.setText(DateUtils.formatElapsedTime(
|
data.duration / DateUtils.SECOND_IN_MILLIS)
|
||||||
it / DateUtils.SECOND_IN_MILLIS))
|
holder.totalTimeView.setText(totalTimeString)
|
||||||
}
|
|
||||||
|
|
||||||
data.elapsedTime?.let {
|
data.elapsedTime?.let {
|
||||||
holder.seekBar.setProgress(it)
|
holder.seekBar.setProgress(it)
|
||||||
holder.elapsedTimeView.setText(DateUtils.formatElapsedTime(
|
val elapsedTimeString = DateUtils.formatElapsedTime(
|
||||||
it / DateUtils.SECOND_IN_MILLIS))
|
it / DateUtils.SECOND_IN_MILLIS)
|
||||||
|
holder.elapsedTimeView.setText(elapsedTimeString)
|
||||||
|
|
||||||
|
holder.seekBar.contentDescription = holder.seekBar.context.getString(
|
||||||
|
R.string.controls_media_seekbar_description,
|
||||||
|
elapsedTimeString,
|
||||||
|
totalTimeString
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ public class SeekBarObserverTest : SysuiTestCase() {
|
|||||||
assertThat(seekBarView.getThumb().getAlpha()).isEqualTo(0)
|
assertThat(seekBarView.getThumb().getAlpha()).isEqualTo(0)
|
||||||
assertThat(elapsedTimeView.getText()).isEqualTo("")
|
assertThat(elapsedTimeView.getText()).isEqualTo("")
|
||||||
assertThat(totalTimeView.getText()).isEqualTo("")
|
assertThat(totalTimeView.getText()).isEqualTo("")
|
||||||
|
assertThat(seekBarView.contentDescription).isEqualTo("")
|
||||||
assertThat(seekBarView.maxHeight).isEqualTo(disabledHeight)
|
assertThat(seekBarView.maxHeight).isEqualTo(disabledHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,6 +103,9 @@ public class SeekBarObserverTest : SysuiTestCase() {
|
|||||||
assertThat(seekBarView.max).isEqualTo(120000)
|
assertThat(seekBarView.max).isEqualTo(120000)
|
||||||
assertThat(elapsedTimeView.getText()).isEqualTo("00:03")
|
assertThat(elapsedTimeView.getText()).isEqualTo("00:03")
|
||||||
assertThat(totalTimeView.getText()).isEqualTo("02:00")
|
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
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user