mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Accept resource URIs for command buttons
PiperOrigin-RevId: 687239119 (cherry picked from commit 3e556a4b53a4b5ae6feebe302b7b3c2813281943)
This commit is contained in:
parent
ed6b822ff5
commit
88a78ade04
@ -571,11 +571,12 @@ public final class CommandButton {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a content {@link Uri} for the icon of this button.
|
||||
* Sets a {@linkplain ContentResolver#SCHEME_CONTENT content} or {@linkplain
|
||||
* ContentResolver#SCHEME_ANDROID_RESOURCE resource} {@link Uri} for the icon of this button.
|
||||
*
|
||||
* <p>Note that this {@link Uri} may be used when the predefined {@link Icon} is not available
|
||||
* or set to {@link #ICON_UNDEFINED}. It can be used in addition to {@link #setCustomIconResId}
|
||||
* for consumers that are capable of loading the content {@link Uri}.
|
||||
* for consumers that are capable of loading the content or resource {@link Uri}.
|
||||
*
|
||||
* @param uri The uri to an icon.
|
||||
* @return This builder for chaining.
|
||||
@ -584,8 +585,9 @@ public final class CommandButton {
|
||||
@CanIgnoreReturnValue
|
||||
public Builder setIconUri(Uri uri) {
|
||||
checkArgument(
|
||||
Objects.equal(uri.getScheme(), ContentResolver.SCHEME_CONTENT),
|
||||
"Only content Uris are supported for CommandButton");
|
||||
Objects.equal(uri.getScheme(), ContentResolver.SCHEME_CONTENT)
|
||||
|| Objects.equal(uri.getScheme(), ContentResolver.SCHEME_ANDROID_RESOURCE),
|
||||
"Only content or resource Uris are supported for CommandButton");
|
||||
this.iconUri = uri;
|
||||
return this;
|
||||
}
|
||||
@ -711,11 +713,13 @@ public final class CommandButton {
|
||||
@DrawableRes public final int iconResId;
|
||||
|
||||
/**
|
||||
* The content {@link Uri} for the icon of the button that is used when the predefined {@link
|
||||
* #icon} is not available or set to {@link #ICON_UNDEFINED}. Can be {@code null}.
|
||||
* The {@linkplain ContentResolver#SCHEME_CONTENT content} or {@linkplain
|
||||
* ContentResolver#SCHEME_ANDROID_RESOURCE resource} {@link Uri} for the icon of the button that
|
||||
* is used when the predefined {@link #icon} is not available or set to {@link #ICON_UNDEFINED}.
|
||||
* Can be {@code null}.
|
||||
*
|
||||
* <p>Note that this value can be used in addition to {@link #iconResId} for consumers that are
|
||||
* capable of loading the content {@link Uri}.
|
||||
* capable of loading the content or resource {@link Uri}.
|
||||
*/
|
||||
@UnstableApi @Nullable public final Uri iconUri;
|
||||
|
||||
@ -938,7 +942,9 @@ public final class CommandButton {
|
||||
if (playerCommand != Player.COMMAND_INVALID) {
|
||||
builder.setPlayerCommand(playerCommand);
|
||||
}
|
||||
if (iconUri != null && Objects.equal(iconUri.getScheme(), ContentResolver.SCHEME_CONTENT)) {
|
||||
if (iconUri != null
|
||||
&& (Objects.equal(iconUri.getScheme(), ContentResolver.SCHEME_CONTENT)
|
||||
|| Objects.equal(iconUri.getScheme(), ContentResolver.SCHEME_ANDROID_RESOURCE))) {
|
||||
builder.setIconUri(iconUri);
|
||||
}
|
||||
return builder
|
||||
|
Loading…
x
Reference in New Issue
Block a user