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

Commit 51547aa0 authored by shaoweishen's avatar shaoweishen Committed by Automerger Merge Worker
Browse files

DO NOT MERGE: Downbranch merge conflict [Output Switcher] Update volume...

DO NOT MERGE: Downbranch merge conflict [Output Switcher] Update volume control behavior am: ca9a784d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17741624



Change-Id: If0f8d450df81ba9652a7ded12a660a45fe8f76dc
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 0d94c6a1 ca9a784d
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@
            android:layout_height="match_parent"
            android:background="@drawable/media_output_item_background"
            android:layout_gravity="center_vertical|start">
            <com.android.systemui.media.dialog.MediaOutputSeekbar
            <SeekBar
                android:id="@+id/volume_seekbar"
                android:splitTrack="false"
                android:visibility="gone"
@@ -119,15 +119,24 @@
            android:importantForAccessibility="no"
            android:visibility="gone"/>

        <LinearLayout
            android:id="@+id/end_action_area"
            android:visibility="gone"
            android:orientation="vertical"
            android:layout_width="48dp"
            android:layout_height="64dp"
            android:layout_gravity="right|center"
            android:gravity="center_vertical">
        <CheckBox
            android:id="@+id/check_box"
            android:layout_width="24dp"
            android:layout_height="24dp"
            android:layout_marginEnd="16dp"
            android:layout_gravity="right|center"
            android:layout_gravity="right"
            android:button="@drawable/ic_circle_check_box"
            android:visibility="gone"
            android:clickable="false"
        />

        </LinearLayout>
    </FrameLayout>
</LinearLayout>
 No newline at end of file
+10 −2
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
            }
            mCheckBox.setVisibility(View.GONE);
            mStatusIcon.setVisibility(View.GONE);
            mEndTouchArea.setVisibility(View.GONE);
            mContainerLayout.setOnClickListener(null);
            mTitleText.setTextColor(mController.getColorItemContent());
            mSubTitleText.setTextColor(mController.getColorItemContent());
@@ -168,12 +169,16 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
                    setSingleLineLayout(getItemTitle(device), true /* bFocused */,
                            true /* showSeekBar */,
                            false /* showProgressBar */, false /* showStatus */);
                    mCheckBox.setOnCheckedChangeListener(null);
                    mCheckBox.setVisibility(View.VISIBLE);
                    mCheckBox.setChecked(true);
                    mSeekBar.setOnClickListener(null);
                    mSeekBar.setOnClickListener(v -> onGroupActionTriggered(false, device));
                    mCheckBox.setOnCheckedChangeListener(
                            (buttonView, isChecked) -> onGroupActionTriggered(false, device));
                    setCheckBoxColor(mCheckBox, mController.getColorItemContent());
                    initSeekbar(device);
                    mEndTouchArea.setVisibility(View.VISIBLE);
                    mEndTouchArea.setOnClickListener(null);
                    mEndTouchArea.setOnClickListener((v) -> mCheckBox.performClick());
                } else if (!mController.hasAdjustVolumeUserRestriction() && currentlyConnected) {
                    mStatusIcon.setImageDrawable(
                            mContext.getDrawable(R.drawable.media_output_status_check));
@@ -185,8 +190,11 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter {
                    initSeekbar(device);
                    mCurrentActivePosition = position;
                } else if (isDeviceIncluded(mController.getSelectableMediaDevice(), device)) {
                    mCheckBox.setOnCheckedChangeListener(null);
                    mCheckBox.setVisibility(View.VISIBLE);
                    mCheckBox.setChecked(false);
                    mCheckBox.setOnCheckedChangeListener(
                            (buttonView, isChecked) -> onGroupActionTriggered(true, device));
                    mContainerLayout.setOnClickListener(v -> onGroupActionTriggered(true, device));
                    setCheckBoxColor(mCheckBox, mController.getColorItemContent());
                    setSingleLineLayout(getItemTitle(device), false /* bFocused */,
+2 −0
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@ public abstract class MediaOutputBaseAdapter extends
        final LinearLayout mTwoLineLayout;
        final ImageView mStatusIcon;
        final CheckBox mCheckBox;
        final LinearLayout mEndTouchArea;
        private String mDeviceId;

        MediaDeviceBaseViewHolder(View view) {
@@ -159,6 +160,7 @@ public abstract class MediaOutputBaseAdapter extends
            mSeekBar = view.requireViewById(R.id.volume_seekbar);
            mStatusIcon = view.requireViewById(R.id.media_output_item_status);
            mCheckBox = view.requireViewById(R.id.check_box);
            mEndTouchArea = view.requireViewById(R.id.end_action_area);
        }

        void onBind(MediaDevice device, boolean topMargin, boolean bottomMargin, int position) {
+0 −57
Original line number 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 int mLastDownPosition = -1;

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

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

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {
            mLastDownPosition = Math.round(event.getX());
        } else if (event.getAction() == MotionEvent.ACTION_UP) {
            if (mLastDownPosition == event.getX()) {
                performClick();
                return true;
            }
            mLastDownPosition = -1;
        }
        return super.onTouchEvent(event);
    }

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