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

Commit e816dcd7 authored by Alexandr Shabalin's avatar Alexandr Shabalin Committed by Android (Google) Code Review
Browse files

Merge "Extract legacy UI logic and place it outside of shared components." into main

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


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


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


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


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