[Android] Accessibility: improve talkback for the sleep timer
Nicolas Pomepuy
git at videolan.org
Fri Jun 3 11:30:21 UTC 2022
vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue May 24 11:42:25 2022 +0200| [182eac84d4fe683eb4bbaaf4de702eb8966da7d2] | committer: Nicolas Pomepuy
Accessibility: improve talkback for the sleep timer
> https://code.videolan.org/videolan/vlc-android/commit/182eac84d4fe683eb4bbaaf4de702eb8966da7d2
---
.../src/org/videolan/vlc/gui/dialogs/JumpToTimeDialog.kt | 5 +----
.../src/org/videolan/vlc/gui/dialogs/PickTimeFragment.kt | 9 +++++++++
.../src/org/videolan/vlc/gui/dialogs/SleepTimerDialog.kt | 10 ++++------
.../src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt | 2 +-
.../org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt | 6 ++----
5 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/JumpToTimeDialog.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/JumpToTimeDialog.kt
index 56e253d3f..3f59e05df 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/JumpToTimeDialog.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/JumpToTimeDialog.kt
@@ -30,10 +30,7 @@ class JumpToTimeDialog : PickTimeFragment() {
override fun executeAction() {
if (playbackService == null)
return
- val hours = if (hours != "") java.lang.Long.parseLong(hours) * HOURS_IN_MICROS else 0L
- val minutes = if (minutes != "") java.lang.Long.parseLong(minutes) * MINUTES_IN_MICROS else 0L
- val seconds = if (seconds != "") java.lang.Long.parseLong(seconds) * SECONDS_IN_MICROS else 0L
- val newTime = (hours + minutes + seconds) / 1000L //Time in ms
+ val newTime = getTimeInMillis() //Time in ms
playbackService.setTime(newTime)
playbackService.playlistManager.player.updateProgress(newTime)
dismiss()
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.kt
index 1d3f8bc43..a266d83dc 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/PickTimeFragment.kt
@@ -34,6 +34,7 @@ import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.onEach
import org.videolan.vlc.PlaybackService
import org.videolan.vlc.R
+import org.videolan.vlc.gui.helpers.TalkbackUtil
import org.videolan.vlc.util.launchWhenStarted
abstract class PickTimeFragment : VLCBottomSheetDialogFragment(), View.OnClickListener, View.OnFocusChangeListener {
@@ -185,6 +186,14 @@ abstract class PickTimeFragment : VLCBottomSheetDialogFragment(), View.OnClickLi
formatTime = hours + "h " + formatTime
tvTimeToJump.text = formatTime
+ tvTimeToJump.announceForAccessibility(TalkbackUtil.millisToString(requireActivity(), getTimeInMillis() ))
+ }
+
+ fun getTimeInMillis(): Long {
+ val hours = if (hours != "") java.lang.Long.parseLong(hours) * HOURS_IN_MICROS else 0L
+ val minutes = if (minutes != "") java.lang.Long.parseLong(minutes) * MINUTES_IN_MICROS else 0L
+ val seconds = if (seconds != "") java.lang.Long.parseLong(seconds) * SECONDS_IN_MICROS else 0L
+ return (hours + minutes + seconds) / 1000L
}
protected abstract fun executeAction()
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SleepTimerDialog.kt b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SleepTimerDialog.kt
index 193a6fda9..095abb436 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SleepTimerDialog.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/dialogs/SleepTimerDialog.kt
@@ -47,12 +47,10 @@ class SleepTimerDialog : PickTimeFragment() {
val minutes = if (minutes != "") java.lang.Long.parseLong(minutes) * MINUTES_IN_MICROS else 0L
val interval = (hours + minutes) / MILLIS_IN_MICROS //Interval in ms
- if (interval < ONE_DAY_IN_MILLIS) {
- val sleepTime = Calendar.getInstance()
- sleepTime.timeInMillis = sleepTime.timeInMillis + interval
- sleepTime.set(Calendar.SECOND, 0)
- playlistModel.service?.setSleepTimer(sleepTime)
- }
+ val sleepTime = Calendar.getInstance()
+ sleepTime.timeInMillis = sleepTime.timeInMillis + interval
+ sleepTime.set(Calendar.SECOND, 0)
+ playlistModel.service?.setSleepTimer(sleepTime)
dismiss()
}
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
index 9a6f78371..b59dc1794 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.kt
@@ -1219,7 +1219,7 @@ open class VideoPlayerActivity : AppCompatActivity(), PlaybackService.Callback,
}
}
optionsDelegate?.show()
- overlayDelegate.hideOverlay(false)
+ overlayDelegate.hideOverlay(fromUser = false, forceTalkback = true)
}
private fun volumeUp() {
diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
index abb3fca6c..209806837 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerOverlayDelegate.kt
@@ -71,10 +71,7 @@ import org.videolan.vlc.gui.audio.PlaylistAdapter
import org.videolan.vlc.gui.browser.FilePickerActivity
import org.videolan.vlc.gui.browser.KEY_MEDIA
import org.videolan.vlc.gui.dialogs.VideoTracksDialog
-import org.videolan.vlc.gui.helpers.BookmarkListDelegate
-import org.videolan.vlc.gui.helpers.OnRepeatListenerKey
-import org.videolan.vlc.gui.helpers.SwipeDragItemTouchHelperCallback
-import org.videolan.vlc.gui.helpers.UiTools
+import org.videolan.vlc.gui.helpers.*
import org.videolan.vlc.gui.helpers.UiTools.showVideoTrack
import org.videolan.vlc.gui.view.PlayerProgress
import org.videolan.vlc.manageAbRepeatStep
@@ -832,6 +829,7 @@ class VideoPlayerOverlayDelegate (private val player: VideoPlayerActivity) {
val format = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.getDefault())
PlaybackService.playerSleepTime.value?.let {
hudRightBinding.sleepQuickAction.text = format.format(it.time)
+ hudRightBinding.sleepQuickAction.contentDescription = player.getString(R.string.sleep_in) + TalkbackUtil.millisToString(player, System.currentTimeMillis() - it.time.time)
}
hudRightBinding.spuDelayQuickAction.text = "${(player.service?.spuDelay ?: 0L) / 1000L} ms"
hudRightBinding.audioDelayQuickAction.text = "${(player.service?.audioDelay ?: 0L) / 1000L} ms"
More information about the Android
mailing list