Merge "Disable buttons with no action intent" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
fd10b83c2c
@@ -302,11 +302,14 @@ public class MediaControlPanel {
|
||||
button.setContentDescription(mediaAction.getContentDescription());
|
||||
Runnable action = mediaAction.getAction();
|
||||
|
||||
button.setOnClickListener(v -> {
|
||||
if (action != null) {
|
||||
if (action == null) {
|
||||
button.setEnabled(false);
|
||||
} else {
|
||||
button.setEnabled(true);
|
||||
button.setOnClickListener(v -> {
|
||||
action.run();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
boolean visibleInCompat = actionsWhenCollapsed.contains(i);
|
||||
setVisibleAndAlpha(collapsedSet, actionId, visibleInCompat);
|
||||
setVisibleAndAlpha(expandedSet, actionId, true /*visible */);
|
||||
|
||||
@@ -366,15 +366,20 @@ class MediaDataManager @Inject constructor(
|
||||
actionsToShowCollapsed.remove(index)
|
||||
continue
|
||||
}
|
||||
val runnable = if (action.actionIntent != null) {
|
||||
Runnable {
|
||||
try {
|
||||
action.actionIntent.send()
|
||||
} catch (e: PendingIntent.CanceledException) {
|
||||
Log.d(TAG, "Intent canceled", e)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val mediaAction = MediaAction(
|
||||
action.getIcon().loadDrawable(packageContext),
|
||||
Runnable {
|
||||
try {
|
||||
action.actionIntent.send()
|
||||
} catch (e: PendingIntent.CanceledException) {
|
||||
Log.d(TAG, "Intent canceled", e)
|
||||
}
|
||||
},
|
||||
runnable,
|
||||
action.title)
|
||||
actionIcons.add(mediaAction)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user