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 Original line Diff line number Diff line
@@ -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 */);
+12 −7
Original line number Original line Diff line number Diff line
@@ -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)
            }
            }