mirror of
https://github.com/videolan/vlc-android
synced 2024-11-23 09:56:36 +08:00
Use common string separator for title/album/artist. Add range separator for Android Auto pagination.
This commit is contained in:
parent
27bff6827a
commit
239ae771e1
@ -556,7 +556,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
|
||||
R.string.audio_queue_progress,
|
||||
if (totalTimeText.isNullOrEmpty()) progressTimeDescription else getString(R.string.talkback_out_of, progressTimeDescription, totalTimeDescription)
|
||||
)
|
||||
Pair("$textTrack ${TextUtils.separator} $textProgress", "$textTrackDescription. $textDescription")
|
||||
Pair("$textTrack ${TextUtils.SEPARATOR} $textProgress", "$textTrackDescription. $textDescription")
|
||||
}
|
||||
binding.audioPlayProgress.text = text.first
|
||||
binding.audioPlayProgress.contentDescription = text.second
|
||||
|
@ -85,9 +85,9 @@ object NotificationHelper {
|
||||
builder.setSmallIcon(if (video) R.drawable.ic_notif_video else R.drawable.ic_notif_audio)
|
||||
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
|
||||
.setContentTitle(title)
|
||||
.setContentText(TextUtils.separatedString('-', artist, album))
|
||||
.setContentText(TextUtils.separatedString(artist, album))
|
||||
.setLargeIcon(cover)
|
||||
.setTicker(TextUtils.separatedString('-', title, artist))
|
||||
.setTicker(TextUtils.separatedString(title, artist))
|
||||
.setAutoCancel(!playing)
|
||||
.setOngoing(playing)
|
||||
.setCategory(NotificationCompat.CATEGORY_TRANSPORT)
|
||||
|
@ -267,12 +267,12 @@ class PlayerOptionsDelegate(val activity: FragmentActivity, val service: Playbac
|
||||
started = true
|
||||
}
|
||||
if (media.albumName.isNotBlank()) {
|
||||
if (started) append(" ${TextUtils.separator} ")
|
||||
if (started) append(" ${TextUtils.SEPARATOR} ")
|
||||
started = true
|
||||
append(media.albumName)
|
||||
}
|
||||
if (media.artistName.isNotBlank()) {
|
||||
if (started) append(" ${TextUtils.separator} ")
|
||||
if (started) append(" ${TextUtils.SEPARATOR} ")
|
||||
append(media.artistName)
|
||||
}
|
||||
}
|
||||
|
@ -483,7 +483,7 @@ class MediaSessionBrowser {
|
||||
when {
|
||||
media.type == MediaWrapper.TYPE_STREAM -> media.uri.toString()
|
||||
parentId.startsWith(ID_ALBUM) -> getMediaSubtitle(media)
|
||||
else -> TextUtils.separatedString('-', getMediaArtist(context, media), getMediaAlbum(context, media))
|
||||
else -> TextUtils.separatedString(getMediaArtist(context, media), getMediaAlbum(context, media))
|
||||
}
|
||||
}
|
||||
MediaLibraryItem.TYPE_PLAYLIST -> res.getString(R.string.track_number, libraryItem.tracksCount)
|
||||
@ -670,7 +670,7 @@ class MediaSessionBrowser {
|
||||
} else if (endTitleSize > halfLabelSize) {
|
||||
endTitleSize = (maxLabelSize - beginTitleSize).coerceAtMost(endTitleSize)
|
||||
}
|
||||
return TextUtils.separatedString(beginTitle.abbreviate(beginTitleSize).markBidi(), endTitle.abbreviate(endTitleSize).markBidi())
|
||||
return TextUtils.separatedString(TextUtils.EN_DASH, beginTitle.abbreviate(beginTitleSize).markBidi(), endTitle.abbreviate(endTitleSize).markBidi())
|
||||
}
|
||||
|
||||
private fun getPlayAllBuilder(ctx: Context, mediaId: String, @StringRes title: Int, trackCount: Int, uri: Uri? = null): MediaDescriptionCompat.Builder {
|
||||
|
@ -341,7 +341,7 @@ object MediaUtils {
|
||||
val artist = getMediaArtist(ctx, media)
|
||||
val isAlbumUnknown = album == getMediaString(ctx, R.string.unknown_album)
|
||||
val isArtistUnknown = artist == getMediaString(ctx, R.string.unknown_artist)
|
||||
return if (!isArtistUnknown && !isAlbumUnknown) TextUtils.separatedString('-', artist.markBidi(), album.markBidi()) else null
|
||||
return if (!isArtistUnknown && !isAlbumUnknown) TextUtils.separatedString(artist.markBidi(), album.markBidi()) else null
|
||||
}
|
||||
|
||||
fun getQueuePosition(mediaPosition: Int, mediaSize: Int, shortQueue: Boolean = false): String? {
|
||||
|
@ -32,24 +32,29 @@ object TextUtils {
|
||||
/**
|
||||
* Common string separator used in the whole app
|
||||
*/
|
||||
const val separator = '·'
|
||||
const val SEPARATOR = '·'
|
||||
|
||||
/**
|
||||
* Create a string separated by the common [separator]
|
||||
* En-dash separator used for ranges
|
||||
*/
|
||||
const val EN_DASH = '–'
|
||||
|
||||
/**
|
||||
* Create a string separated by the common [SEPARATOR]
|
||||
*
|
||||
* @param pieces the strings to join
|
||||
* @return a string containing all the [pieces] if they are not blanked, separated by the [separator]
|
||||
* @return a string containing all the [pieces] if they are not blanked, separated by the [SEPARATOR]
|
||||
*/
|
||||
@JvmName("separatedStringArgs")
|
||||
fun separatedString(vararg pieces: String?) = separatedString(this.separator, arrayOf(*pieces))
|
||||
fun separatedString(vararg pieces: String?) = separatedString(this.SEPARATOR, arrayOf(*pieces))
|
||||
|
||||
/**
|
||||
* Create a string separated by the common [separator]
|
||||
* Create a string separated by the common [SEPARATOR]
|
||||
*
|
||||
* @param pieces the strings to join in an [Array]
|
||||
* @return a string containing all the [pieces] if they are not blanked, separated by the [separator]
|
||||
* @return a string containing all the [pieces] if they are not blanked, separated by the [SEPARATOR]
|
||||
*/
|
||||
fun separatedString(pieces: Array<String?>) = separatedString(this.separator, pieces)
|
||||
fun separatedString(pieces: Array<String?>) = separatedString(this.SEPARATOR, pieces)
|
||||
|
||||
/**
|
||||
* Create a string separated by a custom [separator]
|
||||
|
@ -471,7 +471,7 @@ class MiniPlayerAppWidgetProvider : AppWidgetProvider() {
|
||||
private fun setupTexts(context: Context, views: RemoteViews, widgetType: WidgetType, title: String?, artist: String?) {
|
||||
log(-1, WidgetLogType.INFO, "setupTexts: $title /// $artist")
|
||||
views.setTextViewText(R.id.songName, title)
|
||||
views.setTextViewText(R.id.artist, if (!artist.isNullOrBlank()) "${if (widgetType == WidgetType.MACRO) "" else " ${TextUtils.separator} "}$artist" else artist)
|
||||
views.setTextViewText(R.id.artist, if (!artist.isNullOrBlank()) "${if (widgetType == WidgetType.MACRO) "" else " ${TextUtils.SEPARATOR} "}$artist" else artist)
|
||||
if (title == context.getString(R.string.widget_default_text)) {
|
||||
views.setViewVisibility(R.id.app_name, View.VISIBLE)
|
||||
views.setViewVisibility(R.id.songName, View.GONE)
|
||||
|
@ -1433,7 +1433,7 @@ private fun getProviderDescriptions(context: Context, scope: CoroutineScope, pro
|
||||
val unparsedDescription = pair.second
|
||||
val folders = unparsedDescription.getFolderNumber()
|
||||
val files = unparsedDescription.getFilesNumber()
|
||||
"${context.resources.getQuantityString(org.videolan.vlc.R.plurals.subfolders_quantity, folders, folders)} ${TextUtils.separator} ${context.resources.getQuantityString(org.videolan.vlc.R.plurals.mediafiles_quantity, files, files)}"
|
||||
"${context.resources.getQuantityString(org.videolan.vlc.R.plurals.subfolders_quantity, folders, folders)} ${TextUtils.SEPARATOR} ${context.resources.getQuantityString(org.videolan.vlc.R.plurals.mediafiles_quantity, files, files)}"
|
||||
}
|
||||
if (desc.isNotEmpty()) scope.launch(Dispatchers.IO) {
|
||||
RemoteAccessWebSockets.sendToAll(RemoteAccessServer.BrowserDescription(datasetEntry.uri.toString(), desc))
|
||||
@ -1444,7 +1444,7 @@ private fun getProviderDescriptions(context: Context, scope: CoroutineScope, pro
|
||||
val unparsedDescription = pair.second
|
||||
val folders = unparsedDescription.getFolderNumber()
|
||||
val files = unparsedDescription.getFilesNumber()
|
||||
val desc = "${context.resources.getQuantityString(org.videolan.vlc.R.plurals.subfolders_quantity, folders, folders)} ${TextUtils.separator} ${context.resources.getQuantityString(org.videolan.vlc.R.plurals.mediafiles_quantity, files, files)}"
|
||||
val desc = "${context.resources.getQuantityString(org.videolan.vlc.R.plurals.subfolders_quantity, folders, folders)} ${TextUtils.SEPARATOR} ${context.resources.getQuantityString(org.videolan.vlc.R.plurals.mediafiles_quantity, files, files)}"
|
||||
if (desc.isNotEmpty()) scope.launch(Dispatchers.IO) {
|
||||
RemoteAccessWebSockets.sendToAll(RemoteAccessServer.BrowserDescription(datasetEntry.uri.toString(), desc))
|
||||
}
|
||||
@ -1487,7 +1487,7 @@ private suspend fun getProviderContent(context:Context, provider: BrowserProvide
|
||||
val folders = unparsedDescription.getFolderNumber()
|
||||
val files = unparsedDescription.getFilesNumber()
|
||||
if (folders > 0 && files > 0) {
|
||||
"${context.resources.getQuantityString(org.videolan.vlc.R.plurals.subfolders_quantity, folders, folders)} ${TextUtils.separator} ${context.resources.getQuantityString(org.videolan.vlc.R.plurals.mediafiles_quantity, files, files)}"
|
||||
"${context.resources.getQuantityString(org.videolan.vlc.R.plurals.subfolders_quantity, folders, folders)} ${TextUtils.SEPARATOR} ${context.resources.getQuantityString(org.videolan.vlc.R.plurals.mediafiles_quantity, files, files)}"
|
||||
} else if (files > 0) {
|
||||
context.resources.getQuantityString(org.videolan.vlc.R.plurals.mediafiles_quantity, files, files)
|
||||
} else if (folders > 0) {
|
||||
|
@ -96,7 +96,7 @@ public class Tools {
|
||||
final String artist = mw.getReferenceArtist(), album = mw.getAlbumName();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
boolean hasArtist = !TextUtils.isEmpty(artist), hasAlbum = !TextUtils.isEmpty(album);
|
||||
if (hasArtist && hasAlbum) sb.append(artist).append(" - ").append(album);
|
||||
if (hasArtist && hasAlbum) sb.append(artist).append(" · ").append(album);
|
||||
else if (hasArtist) sb.append(artist);
|
||||
else sb.append(album);
|
||||
item.setDescription(sb.toString());
|
||||
|
@ -183,7 +183,7 @@ public abstract class MediaWrapper extends MediaLibraryItem implements Parcelabl
|
||||
if (hasArtistMeta) {
|
||||
sb.append(artist);
|
||||
if (hasAlbumMeta)
|
||||
sb.append(" - ");
|
||||
sb.append(" · ");
|
||||
}
|
||||
if (hasAlbumMeta)
|
||||
sb.append(album);
|
||||
|
@ -31,7 +31,7 @@ public class StubMediaWrapper extends MediaWrapper {
|
||||
if (hasArtistMeta) {
|
||||
sb.append(artist);
|
||||
if (hasAlbumMeta)
|
||||
sb.append(" - ");
|
||||
sb.append(" · ");
|
||||
}
|
||||
if (hasAlbumMeta)
|
||||
sb.append(album);
|
||||
|
Loading…
Reference in New Issue
Block a user