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

Commit 45f3c97c authored by Alex Shabalin's avatar Alex Shabalin
Browse files

Extract legacy UI logic and place it outside of shared components.

Move the logic to show the ongoing session indicator in the status icon
position from MediaOutputAdapterBase to MediaOutputAdapterLegacy
since it doesn't apply to the refreshed UI.

Bug: 386411078
Fix: 386411078
Flag: EXEMPT refactor
Test: atest SystemUiRoboTests:com.android.systemui.media.dialog,
atest SystemUIGoogleRoboRNGTests:com.android.systemui.media.dialog

Change-Id: I9e67e8d3fe9f0748ab0b931dd457ab2482e599e9
parent 8ef4bffe
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -237,8 +237,7 @@ public abstract class MediaOutputAdapterBase extends RecyclerView.Adapter<Recycl
                                clickListener = v -> onItemClick(v, device);
                            }
                        } else {
                            deviceStatusIcon = getDeviceStatusIcon(device,
                                    device.hasOngoingSession());
                            deviceStatusIcon = getDeviceStatusIcon(device);
                            clickListener = getClickListenerBasedOnSelectionBehavior(device);
                        }
                        deviceDisabled = clickListener == null;
@@ -302,13 +301,9 @@ public abstract class MediaOutputAdapterBase extends RecyclerView.Adapter<Recycl
        }

        @Nullable
        private Drawable getDeviceStatusIcon(MediaDevice device, boolean hasOngoingSession) {
            if (hasOngoingSession) {
                return mContext.getDrawable(R.drawable.ic_sound_bars_anim);
            } else {
        private Drawable getDeviceStatusIcon(MediaDevice device) {
            return Api34Impl.getDeviceStatusIconBasedOnSelectionBehavior(device, mContext);
        }
        }

        protected void onExpandGroupButtonClicked() {
            mShouldGroupSelectedMediaItems = false;
+13 −4
Original line number Diff line number Diff line
@@ -231,7 +231,7 @@ public class MediaOutputAdapterLegacy extends MediaOutputAdapterBase {
            updateFullItemClickListener(clickListener);
            updateContentAlpha(deviceDisabled);
            updateSubtitle(subtitle);
            updateDeviceStatusIcon(deviceStatusIcon);
            updateDeviceStatusIcon(deviceStatusIcon, ongoingSessionStatus, connectionState);
            updateItemBackground(connectionState);
        }

@@ -523,11 +523,20 @@ public class MediaOutputAdapterLegacy extends MediaOutputAdapterBase {
            mStatusIcon.setAlpha(alphaValue);
        }

        private void updateDeviceStatusIcon(@Nullable Drawable deviceStatusIcon) {
            if (deviceStatusIcon == null) {
        private void updateDeviceStatusIcon(@Nullable Drawable deviceStatusIcon,
                @Nullable OngoingSessionStatus ongoingSessionStatus,
                ConnectionState connectionState) {
            boolean showOngoingSession =
                    ongoingSessionStatus != null && connectionState == ConnectionState.DISCONNECTED;
            if (deviceStatusIcon == null && !showOngoingSession) {
                mStatusIcon.setVisibility(View.GONE);
            } else {
                if (showOngoingSession) {
                    mStatusIcon.setImageDrawable(
                            mContext.getDrawable(R.drawable.ic_sound_bars_anim));
                } else {
                    mStatusIcon.setImageDrawable(deviceStatusIcon);
                }
                mStatusIcon.setImageTintList(ColorStateList.valueOf(
                        mController.getColorSchemeLegacy().getColorItemContent()));
                if (deviceStatusIcon instanceof AnimatedVectorDrawable) {