Play downloads in Android Auto
Offline, the car showed "Sign in" and nothing to play. It now lists the downloads, by track and by album or playlist, searches them and plays them by voice; online they sit under Collection. Their covers come from the copies kept with them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
250e721fea
commit
05c90c03df
5 files changed
+106
-20
No files matched your search
@@ -86,7 +86,7 @@ class Downloads(
|
||||
private val coverSizes: List<Int> = emptyList(),
|
||||
) {
|
||||
private val dir = File(context.filesDir, "offline")
|
||||
private val coverDir = File(dir, "covers")
|
||||
private val coverDir = coverDir(context)
|
||||
private val indexFile = File(dir, "index.json")
|
||||
|
||||
/** Writes the index one at a time, in the order asked. */
|
||||
@@ -502,6 +502,11 @@ class Downloads(
|
||||
|
||||
internal fun coverName(url: String): String = sha1(url).take(24) + ".img"
|
||||
|
||||
private fun coverDir(context: Context) = File(context.filesDir, "offline/covers")
|
||||
|
||||
/** The kept copy of a cover, found without reading the downloads, e.g. for the car. */
|
||||
fun coverFile(context: Context, url: String): File? = File(coverDir(context), coverName(url)).takeIf { it.isFile }
|
||||
|
||||
private fun sha1(s: String): String =
|
||||
MessageDigest.getInstance("SHA-1").digest(s.toByteArray()).joinToString("") { "%02x".format(it) }
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user