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