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

Commit 54e01666 authored by Shaowei Shen's avatar Shaowei Shen Committed by Automerger Merge Worker
Browse files

Merge "[Output Switcher] Remove sysui flag for Output Switcher in U" into udc-dev am: 6ba91bb5

parents b91e2b0f 6ba91bb5
Loading
Loading
Loading
Loading
+0 −9
Original line number Original line Diff line number Diff line
@@ -665,15 +665,6 @@ object Flags {
    val WARN_ON_BLOCKING_BINDER_TRANSACTIONS =
    val WARN_ON_BLOCKING_BINDER_TRANSACTIONS =
        unreleasedFlag(2400, "warn_on_blocking_binder_transactions")
        unreleasedFlag(2400, "warn_on_blocking_binder_transactions")


    // 2500 - output switcher
    // TODO(b/261538825): Tracking Bug
    @JvmField
    val OUTPUT_SWITCHER_ADVANCED_LAYOUT = releasedFlag(2500, "output_switcher_advanced_layout")
    @JvmField
    val OUTPUT_SWITCHER_ROUTES_PROCESSING = releasedFlag(2501, "output_switcher_routes_processing")
    @JvmField
    val OUTPUT_SWITCHER_DEVICE_STATUS = releasedFlag(2502, "output_switcher_device_status")

    // 2700 - unfold transitions
    // 2700 - unfold transitions
    // TODO(b/265764985): Tracking Bug
    // TODO(b/265764985): Tracking Bug
    @Keep
    @Keep
+59 −115
Original line number Original line Diff line number Diff line
@@ -72,7 +72,6 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup,
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup,
            int viewType) {
            int viewType) {
        super.onCreateViewHolder(viewGroup, viewType);
        super.onCreateViewHolder(viewGroup, viewType);
        if (mController.isAdvancedLayoutSupported()) {
        switch (viewType) {
        switch (viewType) {
            case MediaItem.MediaItemType.TYPE_GROUP_DIVIDER:
            case MediaItem.MediaItemType.TYPE_GROUP_DIVIDER:
                return new MediaGroupDividerViewHolder(mHolderView);
                return new MediaGroupDividerViewHolder(mHolderView);
@@ -81,14 +80,10 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
            default:
            default:
                return new MediaDeviceViewHolder(mHolderView);
                return new MediaDeviceViewHolder(mHolderView);
        }
        }
        } else {
            return new MediaDeviceViewHolder(mHolderView);
        }
    }
    }


    @Override
    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
        if (mController.isAdvancedLayoutSupported()) {
        if (position >= mMediaItemList.size()) {
        if (position >= mMediaItemList.size()) {
            if (DEBUG) {
            if (DEBUG) {
                Log.d(TAG, "Incorrect position: " + position + " list size: "
                Log.d(TAG, "Incorrect position: " + position + " list size: "
@@ -112,23 +107,10 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
            default:
            default:
                Log.d(TAG, "Incorrect position: " + position);
                Log.d(TAG, "Incorrect position: " + position);
        }
        }
        } else {
            final int size = mController.getMediaDevices().size();
            if (position == size) {
                ((MediaDeviceViewHolder) viewHolder).onBind(CUSTOMIZED_ITEM_PAIR_NEW);
            } else if (position < size) {
                ((MediaDeviceViewHolder) viewHolder).onBind(
                        ((List<MediaDevice>) (mController.getMediaDevices())).get(position),
                        position);
            } else if (DEBUG) {
                Log.d(TAG, "Incorrect position: " + position);
            }
        }
    }
    }


    @Override
    @Override
    public long getItemId(int position) {
    public long getItemId(int position) {
        if (mController.isAdvancedLayoutSupported()) {
        if (position >= mMediaItemList.size()) {
        if (position >= mMediaItemList.size()) {
            Log.d(TAG, "Incorrect position for item id: " + position);
            Log.d(TAG, "Incorrect position for item id: " + position);
            return position;
            return position;
@@ -138,36 +120,19 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
                ? currentMediaItem.getMediaDevice().get().getId().hashCode()
                ? currentMediaItem.getMediaDevice().get().getId().hashCode()
                : position;
                : position;
    }
    }
        final int size = mController.getMediaDevices().size();
        if (position == size) {
            return -1;
        } else if (position < size) {
            return ((List<MediaDevice>) (mController.getMediaDevices()))
                    .get(position).getId().hashCode();
        } else if (DEBUG) {
            Log.d(TAG, "Incorrect position for item id: " + position);
        }
        return position;
    }


    @Override
    @Override
    public int getItemViewType(int position) {
    public int getItemViewType(int position) {
        if (mController.isAdvancedLayoutSupported()
        if (position >= mMediaItemList.size()) {
                && position >= mMediaItemList.size()) {
            Log.d(TAG, "Incorrect position for item type: " + position);
            Log.d(TAG, "Incorrect position for item type: " + position);
            return MediaItem.MediaItemType.TYPE_GROUP_DIVIDER;
            return MediaItem.MediaItemType.TYPE_GROUP_DIVIDER;
        }
        }
        return mController.isAdvancedLayoutSupported()
        return mMediaItemList.get(position).getMediaItemType();
                ? mMediaItemList.get(position).getMediaItemType()
                : super.getItemViewType(position);
    }
    }


    @Override
    @Override
    public int getItemCount() {
    public int getItemCount() {
        // Add extra one for "pair new"
        return mMediaItemList.size();
        return mController.isAdvancedLayoutSupported()
                ? mMediaItemList.size()
                : mController.getMediaDevices().size() + 1;
    }
    }


    class MediaDeviceViewHolder extends MediaDeviceBaseViewHolder {
    class MediaDeviceViewHolder extends MediaDeviceBaseViewHolder {
@@ -203,17 +168,14 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
                // Set different layout for each device
                // Set different layout for each device
                if (device.isMutingExpectedDevice()
                if (device.isMutingExpectedDevice()
                        && !mController.isCurrentConnectedDeviceRemote()) {
                        && !mController.isCurrentConnectedDeviceRemote()) {
                    if (!mController.isAdvancedLayoutSupported()) {
                    updateTitleIcon(R.drawable.media_output_icon_volume,
                    updateTitleIcon(R.drawable.media_output_icon_volume,
                            mController.getColorItemContent());
                            mController.getColorItemContent());
                    }
                    mCurrentActivePosition = position;
                    mCurrentActivePosition = position;
                    updateFullItemClickListener(v -> onItemClick(v, device));
                    updateFullItemClickListener(v -> onItemClick(v, device));
                    setSingleLineLayout(getItemTitle(device));
                    setSingleLineLayout(getItemTitle(device));
                    initMutingExpectedDevice();
                    initMutingExpectedDevice();
                } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
                } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
                        && mController.isSubStatusSupported()
                        && device.hasSubtext()) {
                        && mController.isAdvancedLayoutSupported() && device.hasSubtext()) {
                    boolean isActiveWithOngoingSession =
                    boolean isActiveWithOngoingSession =
                            (device.hasOngoingSession() && (currentlyConnected || isDeviceIncluded(
                            (device.hasOngoingSession() && (currentlyConnected || isDeviceIncluded(
                                    mController.getSelectedMediaDevice(), device)));
                                    mController.getSelectedMediaDevice(), device)));
@@ -284,10 +246,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
                    // selected device in group
                    // selected device in group
                    boolean isDeviceDeselectable = isDeviceIncluded(
                    boolean isDeviceDeselectable = isDeviceIncluded(
                            mController.getDeselectableMediaDevice(), device);
                            mController.getDeselectableMediaDevice(), device);
                    if (!mController.isAdvancedLayoutSupported()) {
                    updateTitleIcon(R.drawable.media_output_icon_volume,
                    updateTitleIcon(R.drawable.media_output_icon_volume,
                            mController.getColorItemContent());
                            mController.getColorItemContent());
                    }
                    updateGroupableCheckBox(true, isDeviceDeselectable, device);
                    updateGroupableCheckBox(true, isDeviceDeselectable, device);
                    updateEndClickArea(device, isDeviceDeselectable);
                    updateEndClickArea(device, isDeviceDeselectable);
                    setUpContentDescriptionForView(mContainerLayout, false, device);
                    setUpContentDescriptionForView(mContainerLayout, false, device);
@@ -305,8 +265,7 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
                        updateFullItemClickListener(v -> cancelMuteAwaitConnection());
                        updateFullItemClickListener(v -> cancelMuteAwaitConnection());
                        setSingleLineLayout(getItemTitle(device));
                        setSingleLineLayout(getItemTitle(device));
                    } else if (mController.isCurrentConnectedDeviceRemote()
                    } else if (mController.isCurrentConnectedDeviceRemote()
                            && !mController.getSelectableMediaDevice().isEmpty()
                            && !mController.getSelectableMediaDevice().isEmpty()) {
                            && mController.isAdvancedLayoutSupported()) {
                        //If device is connected and there's other selectable devices, layout as
                        //If device is connected and there's other selectable devices, layout as
                        // one of selected devices.
                        // one of selected devices.
                        updateTitleIcon(R.drawable.media_output_icon_volume,
                        updateTitleIcon(R.drawable.media_output_icon_volume,
@@ -334,20 +293,14 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
                    //groupable device
                    //groupable device
                    setUpDeviceIcon(device);
                    setUpDeviceIcon(device);
                    updateGroupableCheckBox(false, true, device);
                    updateGroupableCheckBox(false, true, device);
                    if (mController.isAdvancedLayoutSupported()) {
                    updateEndClickArea(device, true);
                    updateEndClickArea(device, true);
                    }
                    updateFullItemClickListener(v -> onItemClick(v, device));
                    updateFullItemClickListener(mController.isAdvancedLayoutSupported()
                            ? v -> onItemClick(v, device)
                            : v -> onGroupActionTriggered(true, device));
                    setSingleLineLayout(getItemTitle(device), false /* showSeekBar */,
                    setSingleLineLayout(getItemTitle(device), false /* showSeekBar */,
                            false /* showProgressBar */, true /* showCheckBox */,
                            false /* showProgressBar */, true /* showCheckBox */,
                            true /* showEndTouchArea */);
                            true /* showEndTouchArea */);
                } else {
                } else {
                    setUpDeviceIcon(device);
                    setUpDeviceIcon(device);
                    setSingleLineLayout(getItemTitle(device));
                    setSingleLineLayout(getItemTitle(device));
                    if (mController.isAdvancedLayoutSupported()
                            && mController.isSubStatusSupported()) {
                    Drawable deviceStatusIcon =
                    Drawable deviceStatusIcon =
                            device.hasOngoingSession() ? mContext.getDrawable(
                            device.hasOngoingSession() ? mContext.getDrawable(
                                    R.drawable.ic_sound_bars_anim)
                                    R.drawable.ic_sound_bars_anim)
@@ -361,9 +314,6 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
                    updateSingleLineLayoutContentAlpha(
                    updateSingleLineLayoutContentAlpha(
                            updateClickActionBasedOnSelectionBehavior(device)
                            updateClickActionBasedOnSelectionBehavior(device)
                                    ? DEVICE_CONNECTED_ALPHA : DEVICE_DISCONNECTED_ALPHA);
                                    ? DEVICE_CONNECTED_ALPHA : DEVICE_DISCONNECTED_ALPHA);
                    } else {
                        updateFullItemClickListener(v -> onItemClick(v, device));
                    }
                }
                }
            }
            }
        }
        }
@@ -400,11 +350,9 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
        }
        }


        public void updateEndClickAreaColor(int color) {
        public void updateEndClickAreaColor(int color) {
            if (mController.isAdvancedLayoutSupported()) {
            mEndTouchArea.setBackgroundTintList(
            mEndTouchArea.setBackgroundTintList(
                    ColorStateList.valueOf(color));
                    ColorStateList.valueOf(color));
        }
        }
        }


        private boolean updateClickActionBasedOnSelectionBehavior(MediaDevice device) {
        private boolean updateClickActionBasedOnSelectionBehavior(MediaDevice device) {
            View.OnClickListener clickListener = Api34Impl.getClickListenerBasedOnSelectionBehavior(
            View.OnClickListener clickListener = Api34Impl.getClickListenerBasedOnSelectionBehavior(
@@ -440,10 +388,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
                    isDeviceDeselectable ? (v) -> mCheckBox.performClick() : null);
                    isDeviceDeselectable ? (v) -> mCheckBox.performClick() : null);
            mEndTouchArea.setImportantForAccessibility(
            mEndTouchArea.setImportantForAccessibility(
                    View.IMPORTANT_FOR_ACCESSIBILITY_YES);
                    View.IMPORTANT_FOR_ACCESSIBILITY_YES);
            if (mController.isAdvancedLayoutSupported()) {
            mEndTouchArea.setBackgroundTintList(
            mEndTouchArea.setBackgroundTintList(
                    ColorStateList.valueOf(mController.getColorItemBackground()));
                    ColorStateList.valueOf(mController.getColorItemBackground()));
            }
            setUpContentDescriptionForView(mEndTouchArea, true, device);
            setUpContentDescriptionForView(mEndTouchArea, true, device);
        }
        }


@@ -473,10 +419,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
                mTitleIcon.setImageDrawable(addDrawable);
                mTitleIcon.setImageDrawable(addDrawable);
                mTitleIcon.setImageTintList(
                mTitleIcon.setImageTintList(
                        ColorStateList.valueOf(mController.getColorItemContent()));
                        ColorStateList.valueOf(mController.getColorItemContent()));
                if (mController.isAdvancedLayoutSupported()) {
                mIconAreaLayout.setBackgroundTintList(
                mIconAreaLayout.setBackgroundTintList(
                        ColorStateList.valueOf(mController.getColorItemBackground()));
                        ColorStateList.valueOf(mController.getColorItemBackground()));
                }
                mContainerLayout.setOnClickListener(mController::launchBluetoothPairing);
                mContainerLayout.setOnClickListener(mController::launchBluetoothPairing);
            }
            }
        }
        }
+83 −131
Original line number Original line Diff line number Diff line
@@ -89,9 +89,8 @@ public abstract class MediaOutputBaseAdapter extends
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup,
    public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup,
            int viewType) {
            int viewType) {
        mContext = viewGroup.getContext();
        mContext = viewGroup.getContext();
        mHolderView = LayoutInflater.from(mContext).inflate(
        mHolderView = LayoutInflater.from(mContext).inflate(MediaItem.getMediaLayoutId(viewType),
                mController.isAdvancedLayoutSupported() ? MediaItem.getMediaLayoutId(viewType)
                viewGroup, false);
                        : R.layout.media_output_list_item, viewGroup, false);


        return null;
        return null;
    }
    }
@@ -173,15 +172,9 @@ public abstract class MediaOutputBaseAdapter extends
            mStatusIcon = view.requireViewById(R.id.media_output_item_status);
            mStatusIcon = view.requireViewById(R.id.media_output_item_status);
            mCheckBox = view.requireViewById(R.id.check_box);
            mCheckBox = view.requireViewById(R.id.check_box);
            mEndTouchArea = view.requireViewById(R.id.end_action_area);
            mEndTouchArea = view.requireViewById(R.id.end_action_area);
            if (mController.isAdvancedLayoutSupported()) {
            mEndClickIcon = view.requireViewById(R.id.media_output_item_end_click_icon);
            mEndClickIcon = view.requireViewById(R.id.media_output_item_end_click_icon);
            mVolumeValueText = view.requireViewById(R.id.volume_value);
            mVolumeValueText = view.requireViewById(R.id.volume_value);
            mIconAreaLayout = view.requireViewById(R.id.icon_area);
            mIconAreaLayout = view.requireViewById(R.id.icon_area);
            } else {
                mVolumeValueText = null;
                mIconAreaLayout = null;
                mEndClickIcon = null;
            }
            initAnimator();
            initAnimator();
        }
        }


@@ -197,9 +190,7 @@ public abstract class MediaOutputBaseAdapter extends
            mTitleText.setTextColor(mController.getColorItemContent());
            mTitleText.setTextColor(mController.getColorItemContent());
            mSubTitleText.setTextColor(mController.getColorItemContent());
            mSubTitleText.setTextColor(mController.getColorItemContent());
            mTwoLineTitleText.setTextColor(mController.getColorItemContent());
            mTwoLineTitleText.setTextColor(mController.getColorItemContent());
            if (mController.isAdvancedLayoutSupported()) {
            mVolumeValueText.setTextColor(mController.getColorItemContent());
            mVolumeValueText.setTextColor(mController.getColorItemContent());
            }
            mSeekBar.setProgressTintList(
            mSeekBar.setProgressTintList(
                    ColorStateList.valueOf(mController.getColorSeekbarProgress()));
                    ColorStateList.valueOf(mController.getColorSeekbarProgress()));
        }
        }
@@ -230,12 +221,10 @@ public abstract class MediaOutputBaseAdapter extends
            mItemLayout.setBackgroundTintList(
            mItemLayout.setBackgroundTintList(
                    ColorStateList.valueOf(isActive ? mController.getColorConnectedItemBackground()
                    ColorStateList.valueOf(isActive ? mController.getColorConnectedItemBackground()
                            : mController.getColorItemBackground()));
                            : mController.getColorItemBackground()));
            if (mController.isAdvancedLayoutSupported()) {
            mIconAreaLayout.setBackgroundTintList(
            mIconAreaLayout.setBackgroundTintList(
                    ColorStateList.valueOf(showSeekBar ? mController.getColorSeekbarProgress()
                    ColorStateList.valueOf(showSeekBar ? mController.getColorSeekbarProgress()
                            : showProgressBar ? mController.getColorConnectedItemBackground()
                            : showProgressBar ? mController.getColorConnectedItemBackground()
                                    : mController.getColorItemBackground()));
                                    : mController.getColorItemBackground()));
            }
            mProgressBar.setVisibility(showProgressBar ? View.VISIBLE : View.GONE);
            mProgressBar.setVisibility(showProgressBar ? View.VISIBLE : View.GONE);
            mSeekBar.setAlpha(1);
            mSeekBar.setAlpha(1);
            mSeekBar.setVisibility(showSeekBar ? View.VISIBLE : View.GONE);
            mSeekBar.setVisibility(showSeekBar ? View.VISIBLE : View.GONE);
@@ -246,12 +235,10 @@ public abstract class MediaOutputBaseAdapter extends
            mTitleText.setVisibility(View.VISIBLE);
            mTitleText.setVisibility(View.VISIBLE);
            mCheckBox.setVisibility(showCheckBox ? View.VISIBLE : View.GONE);
            mCheckBox.setVisibility(showCheckBox ? View.VISIBLE : View.GONE);
            mEndTouchArea.setVisibility(showEndTouchArea ? View.VISIBLE : View.GONE);
            mEndTouchArea.setVisibility(showEndTouchArea ? View.VISIBLE : View.GONE);
            if (mController.isAdvancedLayoutSupported()) {
            ViewGroup.MarginLayoutParams params =
            ViewGroup.MarginLayoutParams params =
                    (ViewGroup.MarginLayoutParams) mItemLayout.getLayoutParams();
                    (ViewGroup.MarginLayoutParams) mItemLayout.getLayoutParams();
            params.rightMargin = showEndTouchArea ? mController.getItemMarginEndSelectable()
            params.rightMargin = showEndTouchArea ? mController.getItemMarginEndSelectable()
                    : mController.getItemMarginEndDefault();
                    : mController.getItemMarginEndDefault();
            }
            mTitleIcon.setBackgroundTintList(
            mTitleIcon.setBackgroundTintList(
                    ColorStateList.valueOf(mController.getColorItemContent()));
                    ColorStateList.valueOf(mController.getColorItemContent()));
        }
        }
@@ -272,7 +259,6 @@ public abstract class MediaOutputBaseAdapter extends
            mSeekBar.setAlpha(1);
            mSeekBar.setAlpha(1);
            mSeekBar.setVisibility(showSeekBar ? View.VISIBLE : View.GONE);
            mSeekBar.setVisibility(showSeekBar ? View.VISIBLE : View.GONE);
            final Drawable backgroundDrawable;
            final Drawable backgroundDrawable;
            if (mController.isAdvancedLayoutSupported() && mController.isSubStatusSupported()) {
            backgroundDrawable = mContext.getDrawable(
            backgroundDrawable = mContext.getDrawable(
                    showSeekBar || isFakeActive ? R.drawable.media_output_item_background_active
                    showSeekBar || isFakeActive ? R.drawable.media_output_item_background_active
                            : R.drawable.media_output_item_background).mutate();
                            : R.drawable.media_output_item_background).mutate();
@@ -295,13 +281,6 @@ public abstract class MediaOutputBaseAdapter extends
                    (ViewGroup.MarginLayoutParams) mItemLayout.getLayoutParams();
                    (ViewGroup.MarginLayoutParams) mItemLayout.getLayoutParams();
            params.rightMargin = showEndTouchArea ? mController.getItemMarginEndSelectable()
            params.rightMargin = showEndTouchArea ? mController.getItemMarginEndSelectable()
                    : mController.getItemMarginEndDefault();
                    : mController.getItemMarginEndDefault();
            } else {
                backgroundDrawable = mContext.getDrawable(
                                R.drawable.media_output_item_background)
                        .mutate();
                mItemLayout.setBackgroundTintList(
                        ColorStateList.valueOf(mController.getColorItemBackground()));
            }
            mItemLayout.setBackground(backgroundDrawable);
            mItemLayout.setBackground(backgroundDrawable);
            mProgressBar.setVisibility(showProgressBar ? View.VISIBLE : View.GONE);
            mProgressBar.setVisibility(showProgressBar ? View.VISIBLE : View.GONE);
            mSubTitleText.setVisibility(showSubtitle ? View.VISIBLE : View.GONE);
            mSubTitleText.setVisibility(showSubtitle ? View.VISIBLE : View.GONE);
@@ -319,15 +298,11 @@ public abstract class MediaOutputBaseAdapter extends
                            .findDrawableByLayerId(android.R.id.progress);
                            .findDrawableByLayerId(android.R.id.progress);
            final GradientDrawable progressDrawable =
            final GradientDrawable progressDrawable =
                    (GradientDrawable) clipDrawable.getDrawable();
                    (GradientDrawable) clipDrawable.getDrawable();
            if (mController.isAdvancedLayoutSupported()) {
            progressDrawable.setCornerRadii(
            progressDrawable.setCornerRadii(
                    new float[]{0, 0, mController.getActiveRadius(),
                    new float[]{0, 0, mController.getActiveRadius(),
                            mController.getActiveRadius(),
                            mController.getActiveRadius(),
                            mController.getActiveRadius(),
                            mController.getActiveRadius(),
                            mController.getActiveRadius(), 0, 0});
                            mController.getActiveRadius(), 0, 0});
            } else {
                progressDrawable.setCornerRadius(mController.getActiveRadius());
            }
        }
        }


        void initSeekbar(MediaDevice device, boolean isCurrentSeekbarInvisible) {
        void initSeekbar(MediaDevice device, boolean isCurrentSeekbarInvisible) {
@@ -340,17 +315,11 @@ public abstract class MediaOutputBaseAdapter extends
            final int currentVolume = device.getCurrentVolume();
            final int currentVolume = device.getCurrentVolume();
            if (mSeekBar.getVolume() != currentVolume) {
            if (mSeekBar.getVolume() != currentVolume) {
                if (isCurrentSeekbarInvisible && !mIsInitVolumeFirstTime) {
                if (isCurrentSeekbarInvisible && !mIsInitVolumeFirstTime) {
                    if (mController.isAdvancedLayoutSupported()) {
                    updateTitleIcon(currentVolume == 0 ? R.drawable.media_output_icon_volume_off
                    updateTitleIcon(currentVolume == 0 ? R.drawable.media_output_icon_volume_off
                                    : R.drawable.media_output_icon_volume,
                                    : R.drawable.media_output_icon_volume,
                            mController.getColorItemContent());
                            mController.getColorItemContent());
                    } else {
                        animateCornerAndVolume(mSeekBar.getProgress(),
                                MediaOutputSeekbar.scaleVolumeToProgress(currentVolume));
                    }
                } else {
                } else {
                    if (!mVolumeAnimator.isStarted()) {
                    if (!mVolumeAnimator.isStarted()) {
                        if (mController.isAdvancedLayoutSupported()) {
                        int percentage =
                        int percentage =
                                (int) ((double) currentVolume * VOLUME_PERCENTAGE_SCALE_SIZE
                                (int) ((double) currentVolume * VOLUME_PERCENTAGE_SCALE_SIZE
                                        / (double) mSeekBar.getMax());
                                        / (double) mSeekBar.getMax());
@@ -359,11 +328,10 @@ public abstract class MediaOutputBaseAdapter extends
                        } else {
                        } else {
                            updateUnmutedVolumeIcon();
                            updateUnmutedVolumeIcon();
                        }
                        }
                        }
                        mSeekBar.setVolume(currentVolume);
                        mSeekBar.setVolume(currentVolume);
                    }
                    }
                }
                }
            } else if (mController.isAdvancedLayoutSupported() && currentVolume == 0) {
            } else if (currentVolume == 0) {
                mSeekBar.resetVolume();
                mSeekBar.resetVolume();
                updateMutedVolumeIcon();
                updateMutedVolumeIcon();
            }
            }
@@ -378,17 +346,15 @@ public abstract class MediaOutputBaseAdapter extends
                    }
                    }
                    int progressToVolume = MediaOutputSeekbar.scaleProgressToVolume(progress);
                    int progressToVolume = MediaOutputSeekbar.scaleProgressToVolume(progress);
                    int deviceVolume = device.getCurrentVolume();
                    int deviceVolume = device.getCurrentVolume();
                    if (mController.isAdvancedLayoutSupported()) {
                    int percentage =
                    int percentage =
                            (int) ((double) progressToVolume * VOLUME_PERCENTAGE_SCALE_SIZE
                            (int) ((double) progressToVolume * VOLUME_PERCENTAGE_SCALE_SIZE
                                    / (double) seekBar.getMax());
                                    / (double) seekBar.getMax());
                    mVolumeValueText.setText(mContext.getResources().getString(
                    mVolumeValueText.setText(mContext.getResources().getString(
                            R.string.media_output_dialog_volume_percentage, percentage));
                            R.string.media_output_dialog_volume_percentage, percentage));
                    mVolumeValueText.setVisibility(View.VISIBLE);
                    mVolumeValueText.setVisibility(View.VISIBLE);
                    }
                    if (progressToVolume != deviceVolume) {
                    if (progressToVolume != deviceVolume) {
                        mController.adjustVolume(device, progressToVolume);
                        mController.adjustVolume(device, progressToVolume);
                        if (mController.isAdvancedLayoutSupported() && deviceVolume == 0) {
                        if (deviceVolume == 0) {
                            updateUnmutedVolumeIcon();
                            updateUnmutedVolumeIcon();
                        }
                        }
                    }
                    }
@@ -396,16 +362,13 @@ public abstract class MediaOutputBaseAdapter extends


                @Override
                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {
                public void onStartTrackingTouch(SeekBar seekBar) {
                    if (mController.isAdvancedLayoutSupported()) {
                    mTitleIcon.setVisibility(View.INVISIBLE);
                    mTitleIcon.setVisibility(View.INVISIBLE);
                    mVolumeValueText.setVisibility(View.VISIBLE);
                    mVolumeValueText.setVisibility(View.VISIBLE);
                    }
                    mIsDragging = true;
                    mIsDragging = true;
                }
                }


                @Override
                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {
                public void onStopTrackingTouch(SeekBar seekBar) {
                    if (mController.isAdvancedLayoutSupported()) {
                    int currentVolume = MediaOutputSeekbar.scaleProgressToVolume(
                    int currentVolume = MediaOutputSeekbar.scaleProgressToVolume(
                            seekBar.getProgress());
                            seekBar.getProgress());
                    int percentage =
                    int percentage =
@@ -419,7 +382,6 @@ public abstract class MediaOutputBaseAdapter extends
                    }
                    }
                    mTitleIcon.setVisibility(View.VISIBLE);
                    mTitleIcon.setVisibility(View.VISIBLE);
                    mVolumeValueText.setVisibility(View.GONE);
                    mVolumeValueText.setVisibility(View.GONE);
                    }
                    mController.logInteractionAdjustVolume(device);
                    mController.logInteractionAdjustVolume(device);
                    mIsDragging = false;
                    mIsDragging = false;
                }
                }
@@ -444,11 +406,9 @@ public abstract class MediaOutputBaseAdapter extends
        void updateTitleIcon(@DrawableRes int id, int color) {
        void updateTitleIcon(@DrawableRes int id, int color) {
            mTitleIcon.setImageDrawable(mContext.getDrawable(id));
            mTitleIcon.setImageDrawable(mContext.getDrawable(id));
            mTitleIcon.setImageTintList(ColorStateList.valueOf(color));
            mTitleIcon.setImageTintList(ColorStateList.valueOf(color));
            if (mController.isAdvancedLayoutSupported()) {
            mIconAreaLayout.setBackgroundTintList(
            mIconAreaLayout.setBackgroundTintList(
                    ColorStateList.valueOf(mController.getColorSeekbarProgress()));
                    ColorStateList.valueOf(mController.getColorSeekbarProgress()));
        }
        }
        }


        void updateIconAreaClickListener(View.OnClickListener listener) {
        void updateIconAreaClickListener(View.OnClickListener listener) {
            mTitleIcon.setOnClickListener(listener);
            mTitleIcon.setOnClickListener(listener);
@@ -475,13 +435,10 @@ public abstract class MediaOutputBaseAdapter extends
                    (ClipDrawable) ((LayerDrawable) mSeekBar.getProgressDrawable())
                    (ClipDrawable) ((LayerDrawable) mSeekBar.getProgressDrawable())
                            .findDrawableByLayerId(android.R.id.progress);
                            .findDrawableByLayerId(android.R.id.progress);
            final GradientDrawable targetBackgroundDrawable =
            final GradientDrawable targetBackgroundDrawable =
                    (GradientDrawable) (mController.isAdvancedLayoutSupported()
                    (GradientDrawable) (mIconAreaLayout.getBackground());
                            ? mIconAreaLayout.getBackground()
                            : clipDrawable.getDrawable());
            mCornerAnimator.addUpdateListener(animation -> {
            mCornerAnimator.addUpdateListener(animation -> {
                float value = (float) animation.getAnimatedValue();
                float value = (float) animation.getAnimatedValue();
                layoutBackgroundDrawable.setCornerRadius(value);
                layoutBackgroundDrawable.setCornerRadius(value);
                if (mController.isAdvancedLayoutSupported()) {
                if (toProgress == 0) {
                if (toProgress == 0) {
                    targetBackgroundDrawable.setCornerRadius(value);
                    targetBackgroundDrawable.setCornerRadius(value);
                } else {
                } else {
@@ -491,9 +448,6 @@ public abstract class MediaOutputBaseAdapter extends
                            0, 0, 0, 0, value, value
                            0, 0, 0, 0, value, value
                    });
                    });
                }
                }
                } else {
                    targetBackgroundDrawable.setCornerRadius(value);
                }
            });
            });
            mVolumeAnimator.setIntValues(fromProgress, toProgress);
            mVolumeAnimator.setIntValues(fromProgress, toProgress);
            mVolumeAnimator.start();
            mVolumeAnimator.start();
@@ -539,10 +493,8 @@ public abstract class MediaOutputBaseAdapter extends
        protected void disableSeekBar() {
        protected void disableSeekBar() {
            mSeekBar.setEnabled(false);
            mSeekBar.setEnabled(false);
            mSeekBar.setOnTouchListener((v, event) -> true);
            mSeekBar.setOnTouchListener((v, event) -> true);
            if (mController.isAdvancedLayoutSupported()) {
            updateIconAreaClickListener(null);
            updateIconAreaClickListener(null);
        }
        }
        }


        private void enableSeekBar(MediaDevice device) {
        private void enableSeekBar(MediaDevice device) {
            mSeekBar.setEnabled(true);
            mSeekBar.setEnabled(true);
+2 −4
Original line number Original line Diff line number Diff line
@@ -270,11 +270,9 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
            dismiss();
            dismiss();
        });
        });
        mAppButton.setOnClickListener(mMediaOutputController::tryToLaunchMediaApplication);
        mAppButton.setOnClickListener(mMediaOutputController::tryToLaunchMediaApplication);
        if (mMediaOutputController.isAdvancedLayoutSupported()) {
        mMediaMetadataSectionLayout.setOnClickListener(
        mMediaMetadataSectionLayout.setOnClickListener(
                mMediaOutputController::tryToLaunchMediaApplication);
                mMediaOutputController::tryToLaunchMediaApplication);
    }
    }
    }


    @Override
    @Override
    public void start() {
    public void start() {
+11 −116

File changed.

Preview size limit exceeded, changes collapsed.

Loading