Merge pull request #4718 from tonytamsf/queue-image-button

add an icon to the Android Auto queue
This commit is contained in:
ByteHamster 2020-11-26 18:24:56 +01:00 committed by GitHub
commit 66ee677ebe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View File

@ -7,6 +7,7 @@ import android.app.UiModeManager;
import android.bluetooth.BluetoothA2dp; import android.bluetooth.BluetoothA2dp;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
@ -370,9 +371,26 @@ public class PlaybackService extends MediaBrowserServiceCompat {
} }
private MediaBrowserCompat.MediaItem createBrowsableMediaItemForRoot() { private MediaBrowserCompat.MediaItem createBrowsableMediaItemForRoot() {
Uri uri = new Uri.Builder()
.scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
.authority(getResources().getResourcePackageName(R.drawable.ic_playlist_black))
.appendPath(getResources().getResourceTypeName(R.drawable.ic_playlist_black))
.appendPath(getResources().getResourceEntryName(R.drawable.ic_playlist_black))
.build();
String subtitle = "";
try {
int count = taskManager.getQueue().size();
subtitle = getResources().getQuantityString(R.plurals.num_episodes, count, count);
} catch (InterruptedException e) {
e.printStackTrace();
}
MediaDescriptionCompat description = new MediaDescriptionCompat.Builder() MediaDescriptionCompat description = new MediaDescriptionCompat.Builder()
.setIconUri(uri)
.setMediaId(getResources().getString(R.string.queue_label)) .setMediaId(getResources().getString(R.string.queue_label))
.setTitle(getResources().getString(R.string.queue_label)) .setTitle(getResources().getString(R.string.queue_label))
.setSubtitle(subtitle)
.build(); .build();
return new MediaBrowserCompat.MediaItem(description, return new MediaBrowserCompat.MediaItem(description,
MediaBrowserCompat.MediaItem.FLAG_BROWSABLE); MediaBrowserCompat.MediaItem.FLAG_BROWSABLE);

View File

@ -125,6 +125,11 @@
<item quantity="one">%d selected</item> <item quantity="one">%d selected</item>
<item quantity="other">%d selected</item> <item quantity="other">%d selected</item>
</plurals> </plurals>
<plurals name="num_episodes">
<item quantity="zero">no episodes</item>
<item quantity="one">%d episode</item>
<item quantity="other">%d episodes</item>
</plurals>
<string name="loading_more">Loading more…</string> <string name="loading_more">Loading more…</string>
<!-- Actions on feeds --> <!-- Actions on feeds -->