Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd10b83c authored by Beth Thibodeau's avatar Beth Thibodeau Committed by Android (Google) Code Review
Browse files

Merge "Disable buttons with no action intent" into rvc-dev

parents b55bc82d f96f4fbf
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -302,11 +302,14 @@ public class MediaControlPanel {
            button.setContentDescription(mediaAction.getContentDescription());
            Runnable action = mediaAction.getAction();

            if (action == null) {
                button.setEnabled(false);
            } else {
                button.setEnabled(true);
                button.setOnClickListener(v -> {
                if (action != null) {
                    action.run();
                }
                });
            }
            boolean visibleInCompat = actionsWhenCollapsed.contains(i);
            setVisibleAndAlpha(collapsedSet, actionId, visibleInCompat);
            setVisibleAndAlpha(expandedSet, actionId, true /*visible */);
+12 −7
Original line number Diff line number Diff line
@@ -366,15 +366,20 @@ class MediaDataManager @Inject constructor(
                    actionsToShowCollapsed.remove(index)
                    continue
                }
                val mediaAction = MediaAction(
                        action.getIcon().loadDrawable(packageContext),
                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,
                        action.title)
                actionIcons.add(mediaAction)
            }