[Android] Use time for the default bookmark naming

Nicolas Pomepuy git at videolan.org
Wed Nov 10 08:29:17 UTC 2021


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Nov  9 08:56:03 2021 +0100| [a61d3c76636383a2ef27aabb57e7e580f724271b] | committer: Nicolas Pomepuy

Use time for the default bookmark naming

Fixes #2242

> https://code.videolan.org/videolan/vlc-android/commit/a61d3c76636383a2ef27aabb57e7e580f724271b
---

 application/resources/src/main/res/values/strings.xml                  | 1 +
 application/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt   | 3 ++-
 .../vlc-android/src/org/videolan/vlc/viewmodels/BookmarkModel.kt       | 3 ++-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/application/resources/src/main/res/values/strings.xml b/application/resources/src/main/res/values/strings.xml
index 22f556a55..7fafdbe03 100644
--- a/application/resources/src/main/res/values/strings.xml
+++ b/application/resources/src/main/res/values/strings.xml
@@ -849,6 +849,7 @@
     <string name="add_to_existing_playlist">Add to existing playlist</string>
     <string name="bookmarks_title">Bookmarks</string>
     <string name="no_bookmark">No bookmark yet</string>
+    <string name="bookmark_default_name">Bookmark at %s</string>
     <string name="bookmark_name">Bookmark %s</string>
     <string name="add_bookmark">Add bookmark</string>
     <string name="optional_features">Optional features</string>
diff --git a/application/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt b/application/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt
index e643e1af2..d4404d7f4 100644
--- a/application/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt
+++ b/application/vlc-android/src/org/videolan/vlc/MediaSessionCallback.kt
@@ -12,6 +12,7 @@ import android.view.KeyEvent
 import androidx.core.net.toUri
 import androidx.lifecycle.lifecycleScope
 import kotlinx.coroutines.*
+import org.videolan.medialibrary.Tools
 import org.videolan.medialibrary.interfaces.Medialibrary
 import org.videolan.medialibrary.interfaces.media.MediaWrapper
 import org.videolan.medialibrary.media.MediaLibraryItem
@@ -119,7 +120,7 @@ internal class MediaSessionCallback(private val playbackService: PlaybackService
                     val context = playbackService.applicationContext
                     playbackService.currentMediaWrapper?.let {
                         val bookmark = it.addBookmark(playbackService.getTime())
-                        val bookmarkName = context.getString(R.string.bookmark_name, it.bookmarks.size.toString())
+                        val bookmarkName = context.getString(R.string.bookmark_default_name, Tools.millisToString(playbackService.getTime()))
                         bookmark?.setName(bookmarkName)
                         playbackService.displayPlaybackMessage(R.string.saved, bookmarkName)
                     }
diff --git a/application/vlc-android/src/org/videolan/vlc/viewmodels/BookmarkModel.kt b/application/vlc-android/src/org/videolan/vlc/viewmodels/BookmarkModel.kt
index ca8d85cd9..e88ba6c9c 100644
--- a/application/vlc-android/src/org/videolan/vlc/viewmodels/BookmarkModel.kt
+++ b/application/vlc-android/src/org/videolan/vlc/viewmodels/BookmarkModel.kt
@@ -34,6 +34,7 @@ import kotlinx.coroutines.flow.onCompletion
 import kotlinx.coroutines.flow.onEach
 import org.videolan.libvlc.MediaPlayer
 import org.videolan.libvlc.interfaces.IMedia
+import org.videolan.medialibrary.Tools
 import org.videolan.medialibrary.interfaces.media.Bookmark
 import org.videolan.tools.livedata.LiveDataset
 import org.videolan.vlc.BuildConfig
@@ -114,7 +115,7 @@ class BookmarkModel : ViewModel(), PlaybackService.Callback {
             viewModelScope.launch {
                 withContext(Dispatchers.IO) {
                     val bookmark = it.addBookmark(service!!.getTime())
-                    bookmark?.setName(context.getString(R.string.bookmark_name, it.bookmarks.size.toString()))
+                    bookmark?.setName(context.getString(R.string.bookmark_default_name, Tools.millisToString(service!!.getTime())))
                 }
                 refresh()
             }



More information about the Android mailing list