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

Commit 72fbb775 authored by Shaowei Shen's avatar Shaowei Shen Committed by Android (Google) Code Review
Browse files

Merge "DO NOT MERGE: Downbranch merge conflict [Output Switcher] Make either...

Merge "DO NOT MERGE: Downbranch merge conflict [Output Switcher] Make either transfer or expansion on a single route" into tm-dev
parents a729b09f 6da04ce0
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -33,7 +33,7 @@
            android:layout_height="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/media_output_item_background"
            android:background="@drawable/media_output_item_background"
            android:layout_gravity="center_vertical|start">
            android:layout_gravity="center_vertical|start">
            <SeekBar
            <com.android.systemui.media.dialog.MediaOutputSeekbar
                android:id="@+id/volume_seekbar"
                android:id="@+id/volume_seekbar"
                android:splitTrack="false"
                android:splitTrack="false"
                android:visibility="gone"
                android:visibility="gone"
@@ -127,6 +127,7 @@
            android:layout_gravity="right|center"
            android:layout_gravity="right|center"
            android:button="@drawable/ic_circle_check_box"
            android:button="@drawable/ic_circle_check_box"
            android:visibility="gone"
            android:visibility="gone"
            android:clickable="false"
        />
        />
    </FrameLayout>
    </FrameLayout>
</LinearLayout>
</LinearLayout>
 No newline at end of file
+4 −10
Original line number Original line Diff line number Diff line
@@ -169,12 +169,10 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
                    setSingleLineLayout(getItemTitle(device), true /* bFocused */,
                    setSingleLineLayout(getItemTitle(device), true /* bFocused */,
                            true /* showSeekBar */,
                            true /* showSeekBar */,
                            false /* showProgressBar */, false /* showStatus */);
                            false /* showProgressBar */, false /* showStatus */);
                    mCheckBox.setOnCheckedChangeListener(null);
                    mCheckBox.setVisibility(View.VISIBLE);
                    mCheckBox.setVisibility(View.VISIBLE);
                    mCheckBox.setChecked(true);
                    mCheckBox.setChecked(true);
                    mCheckBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
                    mSeekBar.setOnClickListener(null);
                        onCheckBoxClicked(false, device);
                    mSeekBar.setOnClickListener(v -> onGroupActionTriggered(false, device));
                    });
                    setCheckBoxColor(mCheckBox, mController.getColorItemContent());
                    setCheckBoxColor(mCheckBox, mController.getColorItemContent());
                    initSeekbar(device);
                    initSeekbar(device);
                } else if (!mController.hasAdjustVolumeUserRestriction() && currentlyConnected) {
                } else if (!mController.hasAdjustVolumeUserRestriction() && currentlyConnected) {
@@ -188,17 +186,13 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
                    initSeekbar(device);
                    initSeekbar(device);
                    mCurrentActivePosition = position;
                    mCurrentActivePosition = position;
                } else if (isDeviceIncluded(mController.getSelectableMediaDevice(), device)) {
                } else if (isDeviceIncluded(mController.getSelectableMediaDevice(), device)) {
                    mCheckBox.setOnCheckedChangeListener(null);
                    mCheckBox.setVisibility(View.VISIBLE);
                    mCheckBox.setVisibility(View.VISIBLE);
                    mCheckBox.setChecked(false);
                    mCheckBox.setChecked(false);
                    mCheckBox.setOnCheckedChangeListener((buttonView, isChecked) -> {
                    mContainerLayout.setOnClickListener(v -> onGroupActionTriggered(true, device));
                        onCheckBoxClicked(true, device);
                    });
                    setCheckBoxColor(mCheckBox, mController.getColorItemContent());
                    setCheckBoxColor(mCheckBox, mController.getColorItemContent());
                    setSingleLineLayout(getItemTitle(device), false /* bFocused */,
                    setSingleLineLayout(getItemTitle(device), false /* bFocused */,
                            false /* showSeekBar */,
                            false /* showSeekBar */,
                            false /* showProgressBar */, false /* showStatus */);
                            false /* showProgressBar */, false /* showStatus */);
                    mContainerLayout.setOnClickListener(v -> onItemClick(v, device));
                } else {
                } else {
                    setSingleLineLayout(getItemTitle(device), false /* bFocused */);
                    setSingleLineLayout(getItemTitle(device), false /* bFocused */);
                    mContainerLayout.setOnClickListener(v -> onItemClick(v, device));
                    mContainerLayout.setOnClickListener(v -> onItemClick(v, device));
@@ -228,7 +222,7 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
            }
            }
        }
        }


        private void onCheckBoxClicked(boolean isChecked, MediaDevice device) {
        private void onGroupActionTriggered(boolean isChecked, MediaDevice device) {
            if (isChecked && isDeviceIncluded(mController.getSelectableMediaDevice(), device)) {
            if (isChecked && isDeviceIncluded(mController.getSelectableMediaDevice(), device)) {
                mController.addDeviceToPlayMedia(device);
                mController.addDeviceToPlayMedia(device);
            } else if (!isChecked && isDeviceIncluded(mController.getDeselectableMediaDevice(),
            } else if (!isChecked && isDeviceIncluded(mController.getDeselectableMediaDevice(),
+68 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.media.dialog;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.SeekBar;

/**
 * Customized seekbar used by MediaOutputDialog, which only changes progress when dragging,
 * otherwise performs click.
 */
public class MediaOutputSeekbar extends SeekBar {
    private static final int DRAGGING_THRESHOLD = 20;
    private boolean mIsDragging = false;

    public MediaOutputSeekbar(Context context) {
        super(context);
    }

    public MediaOutputSeekbar(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        int width = getWidth()
                - getPaddingLeft()
                - getPaddingRight();
        int thumbPos = getPaddingLeft()
                + width
                * getProgress()
                / getMax();
        if (event.getAction() == MotionEvent.ACTION_DOWN
                && Math.abs(event.getX() - thumbPos) < DRAGGING_THRESHOLD) {
            mIsDragging = true;
            super.onTouchEvent(event);
        } else if (event.getAction() == MotionEvent.ACTION_MOVE && mIsDragging) {
            super.onTouchEvent(event);
        } else if (event.getAction() == MotionEvent.ACTION_UP && mIsDragging) {
            mIsDragging = false;
            super.onTouchEvent(event);
        } else if (event.getAction() == MotionEvent.ACTION_UP && !mIsDragging) {
            performClick();
        }
        return true;
    }

    @Override
    public boolean performClick() {
        return super.performClick();
    }
}