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

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

Merge "[Output Switcher] Refactor MediaOutputAdapter" into tm-qpr-dev am: 7b431244

parents 4fe9eab8 7b431244
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -1182,7 +1182,6 @@
    <item name="shutdown_scrim_behind_alpha" format="float" type="dimen">0.95</item>
    <item name="shutdown_scrim_behind_alpha" format="float" type="dimen">0.95</item>


    <!-- Output switcher panel related dimensions -->
    <!-- Output switcher panel related dimensions -->
    <dimen name="media_output_dialog_list_margin">12dp</dimen>
    <dimen name="media_output_dialog_list_max_height">355dp</dimen>
    <dimen name="media_output_dialog_list_max_height">355dp</dimen>
    <dimen name="media_output_dialog_header_album_icon_size">72dp</dimen>
    <dimen name="media_output_dialog_header_album_icon_size">72dp</dimen>
    <dimen name="media_output_dialog_header_back_icon_size">32dp</dimen>
    <dimen name="media_output_dialog_header_back_icon_size">32dp</dimen>
+89 −101
Original line number Original line Diff line number Diff line
@@ -16,6 +16,7 @@


package com.android.systemui.media.dialog;
package com.android.systemui.media.dialog;


import android.annotation.DrawableRes;
import android.content.res.ColorStateList;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.PorterDuffColorFilter;
@@ -42,9 +43,6 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
    private static final String TAG = "MediaOutputAdapter";
    private static final String TAG = "MediaOutputAdapter";
    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
    private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);


    private ViewGroup mConnectedItem;
    private boolean mIncludeDynamicGroup;

    public MediaOutputAdapter(MediaOutputController controller) {
    public MediaOutputAdapter(MediaOutputController controller) {
        super(controller);
        super(controller);
        setHasStableIds(true);
        setHasStableIds(true);
@@ -102,141 +100,90 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
        void onBind(MediaDevice device, boolean topMargin, boolean bottomMargin, int position) {
        void onBind(MediaDevice device, boolean topMargin, boolean bottomMargin, int position) {
            super.onBind(device, topMargin, bottomMargin, position);
            super.onBind(device, topMargin, bottomMargin, position);
            boolean isMutingExpectedDeviceExist = mController.hasMutingExpectedDevice();
            boolean isMutingExpectedDeviceExist = mController.hasMutingExpectedDevice();
            final boolean currentlyConnected = !mIncludeDynamicGroup
            final boolean currentlyConnected = isCurrentlyConnected(device);
                    && isCurrentlyConnected(device);
            boolean isCurrentSeekbarInvisible = mSeekBar.getVisibility() == View.GONE;
            boolean isCurrentSeekbarInvisible = mSeekBar.getVisibility() == View.GONE;
            if (currentlyConnected) {
                mConnectedItem = mContainerLayout;
            }
            mCheckBox.setVisibility(View.GONE);
            mStatusIcon.setVisibility(View.GONE);
            mEndTouchArea.setVisibility(View.GONE);
            mEndTouchArea.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
            mContainerLayout.setOnClickListener(null);
            mContainerLayout.setContentDescription(null);
            mTitleText.setTextColor(mController.getColorItemContent());
            mSubTitleText.setTextColor(mController.getColorItemContent());
            mTwoLineTitleText.setTextColor(mController.getColorItemContent());
            mSeekBar.getProgressDrawable().setColorFilter(
                    new PorterDuffColorFilter(mController.getColorSeekbarProgress(),
                            PorterDuff.Mode.SRC_IN));
            if (mCurrentActivePosition == position) {
            if (mCurrentActivePosition == position) {
                mCurrentActivePosition = -1;
                mCurrentActivePosition = -1;
            }
            }


            if (mController.isTransferring()) {
            if (mController.isAnyDeviceTransferring()) {
                if (device.getState() == MediaDeviceState.STATE_CONNECTING
                if (device.getState() == MediaDeviceState.STATE_CONNECTING
                        && !mController.hasAdjustVolumeUserRestriction()) {
                        && !mController.hasAdjustVolumeUserRestriction()) {
                    setUpDeviceIcon(device);
                    setUpDeviceIcon(device);
                    mProgressBar.getIndeterminateDrawable().setColorFilter(
                    updateProgressBarColor();
                            new PorterDuffColorFilter(
                    setSingleLineLayout(getItemTitle(device), false /* showSeekBar*/,
                                    mController.getColorItemContent(),
                            true /* showProgressBar */, false /* showCheckBox */,
                                    PorterDuff.Mode.SRC_IN));
                            false /* showEndTouchArea */);
                    setSingleLineLayout(getItemTitle(device), true /* bFocused */,
                            false /* showSeekBar*/,
                            true /* showProgressBar */, false /* showStatus */);
                } else {
                } else {
                    setUpDeviceIcon(device);
                    setUpDeviceIcon(device);
                    setSingleLineLayout(getItemTitle(device), false /* bFocused */);
                    setSingleLineLayout(getItemTitle(device));
                }
                }
            } else {
            } else {
                // Set different layout for each device
                // Set different layout for each device
                if (device.isMutingExpectedDevice()
                if (device.isMutingExpectedDevice()
                        && !mController.isCurrentConnectedDeviceRemote()) {
                        && !mController.isCurrentConnectedDeviceRemote()) {
                    mTitleIcon.setImageDrawable(
                    updateTitleIcon(R.drawable.media_output_icon_volume,
                            mContext.getDrawable(R.drawable.media_output_icon_volume));
                            mController.getColorItemContent());
                    mTitleIcon.setColorFilter(mController.getColorItemContent());
                    mTitleText.setTextColor(mController.getColorItemContent());
                    setSingleLineLayout(getItemTitle(device), true /* bFocused */,
                            false /* showSeekBar */,
                            false /* showProgressBar */, false /* showStatus */);
                    initMutingExpectedDevice();
                    initMutingExpectedDevice();
                    mCurrentActivePosition = position;
                    mCurrentActivePosition = position;
                    mContainerLayout.setOnClickListener(v -> onItemClick(v, device));
                    updateContainerClickListener(v -> onItemClick(v, device));
                    setSingleLineLayout(getItemTitle(device));
                } else if (device.getState() == MediaDeviceState.STATE_CONNECTING_FAILED) {
                } else if (device.getState() == MediaDeviceState.STATE_CONNECTING_FAILED) {
                    setUpDeviceIcon(device);
                    setUpDeviceIcon(device);
                    mStatusIcon.setImageDrawable(
                    updateConnectionFailedStatusIcon();
                            mContext.getDrawable(R.drawable.media_output_status_failed));
                    mStatusIcon.setColorFilter(mController.getColorItemContent());
                    setTwoLineLayout(device, false /* bFocused */,
                            false /* showSeekBar */, false /* showProgressBar */,
                            true /* showSubtitle */, true /* showStatus */);
                    mSubTitleText.setText(R.string.media_output_dialog_connect_failed);
                    mSubTitleText.setText(R.string.media_output_dialog_connect_failed);
                    mContainerLayout.setOnClickListener(v -> onItemClick(v, device));
                    updateContainerClickListener(v -> onItemClick(v, device));
                    setTwoLineLayout(device, false /* bFocused */, false /* showSeekBar */,
                            false /* showProgressBar */, true /* showSubtitle */,
                            true /* showStatus */);
                } else if (device.getState() == MediaDeviceState.STATE_GROUPING) {
                } else if (device.getState() == MediaDeviceState.STATE_GROUPING) {
                    setUpDeviceIcon(device);
                    setUpDeviceIcon(device);
                    mProgressBar.getIndeterminateDrawable().setColorFilter(
                    updateProgressBarColor();
                            new PorterDuffColorFilter(
                    setSingleLineLayout(getItemTitle(device), false /* showSeekBar*/,
                                    mController.getColorItemContent(),
                            true /* showProgressBar */, false /* showCheckBox */,
                                    PorterDuff.Mode.SRC_IN));
                            false /* showEndTouchArea */);
                    setSingleLineLayout(getItemTitle(device), true /* bFocused */,
                            false /* showSeekBar*/,
                            true /* showProgressBar */, false /* showStatus */);
                } else if (mController.getSelectedMediaDevice().size() > 1
                } else if (mController.getSelectedMediaDevice().size() > 1
                        && isDeviceIncluded(mController.getSelectedMediaDevice(), device)) {
                        && isDeviceIncluded(mController.getSelectedMediaDevice(), device)) {
                    boolean isDeviceDeselectable = isDeviceIncluded(
                    boolean isDeviceDeselectable = isDeviceIncluded(
                            mController.getDeselectableMediaDevice(), device);
                            mController.getDeselectableMediaDevice(), device);
                    mTitleText.setTextColor(mController.getColorItemContent());
                    updateTitleIcon(R.drawable.media_output_icon_volume,
                    mTitleIcon.setImageDrawable(
                            mController.getColorItemContent());
                            mContext.getDrawable(R.drawable.media_output_icon_volume));
                    updateGroupableCheckBox(true, isDeviceDeselectable, device);
                    mTitleIcon.setColorFilter(mController.getColorItemContent());
                    updateEndClickArea(device, isDeviceDeselectable);
                    setSingleLineLayout(getItemTitle(device), true /* bFocused */,
                            true /* showSeekBar */,
                            false /* showProgressBar */, false /* showStatus */);
                    setUpContentDescriptionForView(mContainerLayout, false, device);
                    setUpContentDescriptionForView(mContainerLayout, false, device);
                    mCheckBox.setOnCheckedChangeListener(null);
                    setSingleLineLayout(getItemTitle(device), true /* showSeekBar */,
                    mCheckBox.setVisibility(View.VISIBLE);
                            false /* showProgressBar */, true /* showCheckBox */,
                    mCheckBox.setChecked(true);
                            true /* showEndTouchArea */);
                    mCheckBox.setOnCheckedChangeListener(isDeviceDeselectable
                            ? (buttonView, isChecked) -> onGroupActionTriggered(false, device)
                            : null);
                    mCheckBox.setEnabled(isDeviceDeselectable);
                    setCheckBoxColor(mCheckBox, mController.getColorItemContent());
                    initSeekbar(device, isCurrentSeekbarInvisible);
                    initSeekbar(device, isCurrentSeekbarInvisible);
                    mEndTouchArea.setVisibility(View.VISIBLE);
                    mEndTouchArea.setOnClickListener(null);
                    mEndTouchArea.setOnClickListener(
                            isDeviceDeselectable ? (v) -> mCheckBox.performClick() : null);
                    mEndTouchArea.setImportantForAccessibility(
                            View.IMPORTANT_FOR_ACCESSIBILITY_YES);
                    setUpContentDescriptionForView(mEndTouchArea, true, device);
                } else if (!mController.hasAdjustVolumeUserRestriction()
                } else if (!mController.hasAdjustVolumeUserRestriction()
                        && currentlyConnected) {
                        && currentlyConnected) {
                    if (isMutingExpectedDeviceExist
                    if (isMutingExpectedDeviceExist
                            && !mController.isCurrentConnectedDeviceRemote()) {
                            && !mController.isCurrentConnectedDeviceRemote()) {
                        // mark as disconnected and set special click listener
                        // mark as disconnected and set special click listener
                        setUpDeviceIcon(device);
                        setUpDeviceIcon(device);
                        setSingleLineLayout(getItemTitle(device), false /* bFocused */);
                        updateContainerClickListener(v -> cancelMuteAwaitConnection());
                        mContainerLayout.setOnClickListener(v -> cancelMuteAwaitConnection());
                        setSingleLineLayout(getItemTitle(device));
                    } else {
                    } else {
                        mTitleIcon.setImageDrawable(
                        updateTitleIcon(R.drawable.media_output_icon_volume,
                                mContext.getDrawable(R.drawable.media_output_icon_volume));
                                mController.getColorItemContent());
                        mTitleIcon.setColorFilter(mController.getColorItemContent());
                        mTitleText.setTextColor(mController.getColorItemContent());
                        setSingleLineLayout(getItemTitle(device), true /* bFocused */,
                                true /* showSeekBar */,
                                false /* showProgressBar */, false /* showStatus */);
                        initSeekbar(device, isCurrentSeekbarInvisible);
                        setUpContentDescriptionForView(mContainerLayout, false, device);
                        setUpContentDescriptionForView(mContainerLayout, false, device);
                        mCurrentActivePosition = position;
                        mCurrentActivePosition = position;
                        setSingleLineLayout(getItemTitle(device), true /* showSeekBar */,
                                false /* showProgressBar */, false /* showCheckBox */,
                                false /* showEndTouchArea */);
                        initSeekbar(device, isCurrentSeekbarInvisible);
                    }
                    }
                } else if (isDeviceIncluded(mController.getSelectableMediaDevice(), device)) {
                } else if (isDeviceIncluded(mController.getSelectableMediaDevice(), device)) {
                    setUpDeviceIcon(device);
                    setUpDeviceIcon(device);
                    mCheckBox.setOnCheckedChangeListener(null);
                    updateGroupableCheckBox(false, true, device);
                    mCheckBox.setVisibility(View.VISIBLE);
                    updateContainerClickListener(v -> onGroupActionTriggered(true, device));
                    mCheckBox.setChecked(false);
                    setSingleLineLayout(getItemTitle(device), false /* showSeekBar */,
                    mCheckBox.setOnCheckedChangeListener(
                            false /* showProgressBar */, true /* showCheckBox */,
                            (buttonView, isChecked) -> onGroupActionTriggered(true, device));
                            true /* showEndTouchArea */);
                    mEndTouchArea.setVisibility(View.VISIBLE);
                    mContainerLayout.setOnClickListener(v -> onGroupActionTriggered(true, device));
                    setCheckBoxColor(mCheckBox, mController.getColorItemContent());
                    setSingleLineLayout(getItemTitle(device), false /* bFocused */,
                            false /* showSeekBar */,
                            false /* showProgressBar */, false /* showStatus */);
                } else {
                } else {
                    setUpDeviceIcon(device);
                    setUpDeviceIcon(device);
                    setSingleLineLayout(getItemTitle(device), false /* bFocused */);
                    setSingleLineLayout(getItemTitle(device));
                    mContainerLayout.setOnClickListener(v -> onItemClick(v, device));
                    updateContainerClickListener(v -> onItemClick(v, device));
                }
                }
            }
            }
        }
        }
@@ -248,15 +195,56 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
                    ColorStateList(states, colors));
                    ColorStateList(states, colors));
        }
        }


        private void updateConnectionFailedStatusIcon() {
            mStatusIcon.setImageDrawable(
                    mContext.getDrawable(R.drawable.media_output_status_failed));
            mStatusIcon.setColorFilter(mController.getColorItemContent());
        }

        private void updateProgressBarColor() {
            mProgressBar.getIndeterminateDrawable().setColorFilter(
                    new PorterDuffColorFilter(
                            mController.getColorItemContent(),
                            PorterDuff.Mode.SRC_IN));
        }

        public void updateEndClickArea(MediaDevice device, boolean isDeviceDeselectable) {
            mEndTouchArea.setOnClickListener(null);
            mEndTouchArea.setOnClickListener(
                    isDeviceDeselectable ? (v) -> mCheckBox.performClick() : null);
            mEndTouchArea.setImportantForAccessibility(
                    View.IMPORTANT_FOR_ACCESSIBILITY_YES);
            setUpContentDescriptionForView(mEndTouchArea, true, device);
        }

        private void updateGroupableCheckBox(boolean isSelected, boolean isGroupable,
                MediaDevice device) {
            mCheckBox.setOnCheckedChangeListener(null);
            mCheckBox.setChecked(isSelected);
            mCheckBox.setOnCheckedChangeListener(
                    isGroupable ? (buttonView, isChecked) -> onGroupActionTriggered(!isSelected,
                            device) : null);
            mCheckBox.setEnabled(isGroupable);
            setCheckBoxColor(mCheckBox, mController.getColorItemContent());
        }

        private void updateTitleIcon(@DrawableRes int id, int color) {
            mTitleIcon.setImageDrawable(mContext.getDrawable(id));
            mTitleIcon.setColorFilter(color);
        }

        private void updateContainerClickListener(View.OnClickListener listener) {
            mContainerLayout.setOnClickListener(listener);
        }

        @Override
        @Override
        void onBind(int customizedItem, boolean topMargin, boolean bottomMargin) {
        void onBind(int customizedItem, boolean topMargin, boolean bottomMargin) {
            if (customizedItem == CUSTOMIZED_ITEM_PAIR_NEW) {
            if (customizedItem == CUSTOMIZED_ITEM_PAIR_NEW) {
                mTitleText.setTextColor(mController.getColorItemContent());
                mTitleText.setTextColor(mController.getColorItemContent());
                mCheckBox.setVisibility(View.GONE);
                mCheckBox.setVisibility(View.GONE);
                setSingleLineLayout(mContext.getText(R.string.media_output_dialog_pairing_new),
                setSingleLineLayout(mContext.getText(R.string.media_output_dialog_pairing_new));
                        false /* bFocused */);
                final Drawable addDrawable = mContext.getDrawable(R.drawable.ic_add);
                final Drawable d = mContext.getDrawable(R.drawable.ic_add);
                mTitleIcon.setImageDrawable(addDrawable);
                mTitleIcon.setImageDrawable(d);
                mTitleIcon.setColorFilter(mController.getColorItemContent());
                mTitleIcon.setColorFilter(mController.getColorItemContent());
                mContainerLayout.setOnClickListener(mController::launchBluetoothPairing);
                mContainerLayout.setOnClickListener(mController::launchBluetoothPairing);
            }
            }
@@ -273,7 +261,7 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
        }
        }


        private void onItemClick(View view, MediaDevice device) {
        private void onItemClick(View view, MediaDevice device) {
            if (mController.isTransferring()) {
            if (mController.isAnyDeviceTransferring()) {
                return;
                return;
            }
            }
            if (isCurrentlyConnected(device)) {
            if (isCurrentlyConnected(device)) {
+27 −73
Original line number Original line Diff line number Diff line
@@ -63,8 +63,6 @@ public abstract class MediaOutputBaseAdapter extends


    protected final MediaOutputController mController;
    protected final MediaOutputController mController;


    private int mMargin;

    Context mContext;
    Context mContext;
    View mHolderView;
    View mHolderView;
    boolean mIsDragging;
    boolean mIsDragging;
@@ -82,8 +80,6 @@ public abstract class MediaOutputBaseAdapter extends
    public MediaDeviceBaseViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup,
    public MediaDeviceBaseViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup,
            int viewType) {
            int viewType) {
        mContext = viewGroup.getContext();
        mContext = viewGroup.getContext();
        mMargin = mContext.getResources().getDimensionPixelSize(
                R.dimen.media_output_dialog_list_margin);
        mHolderView = LayoutInflater.from(mContext).inflate(R.layout.media_output_list_item,
        mHolderView = LayoutInflater.from(mContext).inflate(R.layout.media_output_list_item,
                viewGroup, false);
                viewGroup, false);


@@ -168,16 +164,28 @@ public abstract class MediaOutputBaseAdapter extends


        void onBind(MediaDevice device, boolean topMargin, boolean bottomMargin, int position) {
        void onBind(MediaDevice device, boolean topMargin, boolean bottomMargin, int position) {
            mDeviceId = device.getId();
            mDeviceId = device.getId();
            mCheckBox.setVisibility(View.GONE);
            mStatusIcon.setVisibility(View.GONE);
            mEndTouchArea.setVisibility(View.GONE);
            mEndTouchArea.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
            mContainerLayout.setOnClickListener(null);
            mContainerLayout.setContentDescription(null);
            mTitleText.setTextColor(mController.getColorItemContent());
            mSubTitleText.setTextColor(mController.getColorItemContent());
            mTwoLineTitleText.setTextColor(mController.getColorItemContent());
            mSeekBar.getProgressDrawable().setColorFilter(
                    new PorterDuffColorFilter(mController.getColorSeekbarProgress(),
                            PorterDuff.Mode.SRC_IN));
        }
        }


        abstract void onBind(int customizedItem, boolean topMargin, boolean bottomMargin);
        abstract void onBind(int customizedItem, boolean topMargin, boolean bottomMargin);


        void setSingleLineLayout(CharSequence title, boolean bFocused) {
        void setSingleLineLayout(CharSequence title) {
            setSingleLineLayout(title, bFocused, false, false, false);
            setSingleLineLayout(title, false, false, false, false);
        }
        }


        void setSingleLineLayout(CharSequence title, boolean bFocused, boolean showSeekBar,
        void setSingleLineLayout(CharSequence title, boolean showSeekBar,
                boolean showProgressBar, boolean showStatus) {
                boolean showProgressBar, boolean showCheckBox, boolean showEndTouchArea) {
            mTwoLineLayout.setVisibility(View.GONE);
            mTwoLineLayout.setVisibility(View.GONE);
            boolean isActive = showSeekBar || showProgressBar;
            boolean isActive = showSeekBar || showProgressBar;
            if (!mCornerAnimator.isRunning()) {
            if (!mCornerAnimator.isRunning()) {
@@ -188,10 +196,6 @@ public abstract class MediaOutputBaseAdapter extends
                                .mutate() : mContext.getDrawable(
                                .mutate() : mContext.getDrawable(
                                        R.drawable.media_output_item_background)
                                        R.drawable.media_output_item_background)
                                .mutate();
                                .mutate();
                backgroundDrawable.setColorFilter(new PorterDuffColorFilter(
                        isActive ? mController.getColorConnectedItemBackground()
                                : mController.getColorItemBackground(),
                        PorterDuff.Mode.SRC_IN));
                mItemLayout.setBackground(backgroundDrawable);
                mItemLayout.setBackground(backgroundDrawable);
                if (showSeekBar) {
                if (showSeekBar) {
                    final ClipDrawable clipDrawable =
                    final ClipDrawable clipDrawable =
@@ -201,27 +205,21 @@ public abstract class MediaOutputBaseAdapter extends
                            (GradientDrawable) clipDrawable.getDrawable();
                            (GradientDrawable) clipDrawable.getDrawable();
                    progressDrawable.setCornerRadius(mController.getActiveRadius());
                    progressDrawable.setCornerRadius(mController.getActiveRadius());
                }
                }
            } else {
            }
            mItemLayout.getBackground().setColorFilter(new PorterDuffColorFilter(
            mItemLayout.getBackground().setColorFilter(new PorterDuffColorFilter(
                    isActive ? mController.getColorConnectedItemBackground()
                    isActive ? mController.getColorConnectedItemBackground()
                            : mController.getColorItemBackground(),
                            : mController.getColorItemBackground(),
                    PorterDuff.Mode.SRC_IN));
                    PorterDuff.Mode.SRC_IN));
            }
            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);
            if (!showSeekBar) {
            if (!showSeekBar) {
                mSeekBar.resetVolume();
                mSeekBar.resetVolume();
            }
            }
            mStatusIcon.setVisibility(showStatus ? View.VISIBLE : View.GONE);
            mTitleText.setText(title);
            mTitleText.setText(title);
            mTitleText.setVisibility(View.VISIBLE);
            mTitleText.setVisibility(View.VISIBLE);
        }
            mCheckBox.setVisibility(showCheckBox ? View.VISIBLE : View.GONE);

            mEndTouchArea.setVisibility(showEndTouchArea ? View.VISIBLE : View.GONE);
        void setTwoLineLayout(MediaDevice device, boolean bFocused, boolean showSeekBar,
                boolean showProgressBar, boolean showSubtitle) {
            setTwoLineLayout(device, null, bFocused, showSeekBar, showProgressBar, showSubtitle,
                    false);
        }
        }


        void setTwoLineLayout(MediaDevice device, boolean bFocused, boolean showSeekBar,
        void setTwoLineLayout(MediaDevice device, boolean bFocused, boolean showSeekBar,
@@ -230,12 +228,6 @@ public abstract class MediaOutputBaseAdapter extends
                    showStatus);
                    showStatus);
        }
        }


        void setTwoLineLayout(CharSequence title, boolean bFocused, boolean showSeekBar,
                boolean showProgressBar, boolean showSubtitle) {
            setTwoLineLayout(null, title, bFocused, showSeekBar, showProgressBar, showSubtitle,
                    false);
        }

        private void setTwoLineLayout(MediaDevice device, CharSequence title, boolean bFocused,
        private void setTwoLineLayout(MediaDevice device, CharSequence title, boolean bFocused,
                boolean showSeekBar, boolean showProgressBar, boolean showSubtitle,
                boolean showSeekBar, boolean showProgressBar, boolean showSubtitle,
                boolean showStatus) {
                boolean showStatus) {
@@ -254,20 +246,11 @@ public abstract class MediaOutputBaseAdapter extends
            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);
            mTwoLineTitleText.setTranslationY(0);
            mTwoLineTitleText.setTranslationY(0);
            if (device == null) {
            mTwoLineTitleText.setText(device == null ? title : getItemTitle(device));
                mTwoLineTitleText.setText(title);
            } else {
                mTwoLineTitleText.setText(getItemTitle(device));
            }

            if (bFocused) {
            mTwoLineTitleText.setTypeface(Typeface.create(mContext.getString(
            mTwoLineTitleText.setTypeface(Typeface.create(mContext.getString(
                        com.android.internal.R.string.config_headlineFontFamilyMedium),
                            bFocused ? com.android.internal.R.string.config_headlineFontFamilyMedium
                                    : com.android.internal.R.string.config_headlineFontFamily),
                    Typeface.NORMAL));
                    Typeface.NORMAL));
            } else {
                mTwoLineTitleText.setTypeface(Typeface.create(mContext.getString(
                        com.android.internal.R.string.config_headlineFontFamily), Typeface.NORMAL));
            }
        }
        }


        void initSeekbar(MediaDevice device, boolean isCurrentSeekbarInvisible) {
        void initSeekbar(MediaDevice device, boolean isCurrentSeekbarInvisible) {
@@ -327,35 +310,6 @@ public abstract class MediaOutputBaseAdapter extends
            mItemLayout.setBackground(backgroundDrawable);
            mItemLayout.setBackground(backgroundDrawable);
        }
        }


        void initSessionSeekbar() {
            disableSeekBar();
            mSeekBar.setMax(mController.getSessionVolumeMax());
            mSeekBar.setMin(0);
            final int currentVolume = mController.getSessionVolume();
            if (mSeekBar.getProgress() != currentVolume) {
                mSeekBar.setProgress(currentVolume, true);
            }
            mSeekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
                @Override
                public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                    if (!fromUser) {
                        return;
                    }
                    mController.adjustSessionVolume(progress);
                }

                @Override
                public void onStartTrackingTouch(SeekBar seekBar) {
                    mIsDragging = true;
                }

                @Override
                public void onStopTrackingTouch(SeekBar seekBar) {
                    mIsDragging = false;
                }
            });
        }

        private void animateCornerAndVolume(int fromProgress, int toProgress) {
        private void animateCornerAndVolume(int fromProgress, int toProgress) {
            final GradientDrawable layoutBackgroundDrawable =
            final GradientDrawable layoutBackgroundDrawable =
                    (GradientDrawable) mItemLayout.getBackground();
                    (GradientDrawable) mItemLayout.getBackground();
+2 −2
Original line number Original line Diff line number Diff line
@@ -421,7 +421,7 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
                device.getId());
                device.getId());
        boolean isSelectedDeviceInGroup = getSelectedMediaDevice().size() > 1
        boolean isSelectedDeviceInGroup = getSelectedMediaDevice().size() > 1
                && getSelectedMediaDevice().contains(device);
                && getSelectedMediaDevice().contains(device);
        return (!hasAdjustVolumeUserRestriction() && isConnected && !isTransferring())
        return (!hasAdjustVolumeUserRestriction() && isConnected && !isAnyDeviceTransferring())
                || isSelectedDeviceInGroup;
                || isSelectedDeviceInGroup;
    }
    }


@@ -726,7 +726,7 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
                UserHandle.of(UserHandle.myUserId()));
                UserHandle.of(UserHandle.myUserId()));
    }
    }


    boolean isTransferring() {
    boolean isAnyDeviceTransferring() {
        synchronized (mMediaDevicesLock) {
        synchronized (mMediaDevicesLock) {
            for (MediaDevice device : mMediaDevices) {
            for (MediaDevice device : mMediaDevices) {
                if (device.getState() == LocalMediaManager.MediaDeviceState.STATE_CONNECTING) {
                if (device.getState() == LocalMediaManager.MediaDeviceState.STATE_CONNECTING) {
+3 −3

File changed.

Preview size limit exceeded, changes collapsed.