diff options
7 files changed, 45 insertions, 79 deletions
diff --git a/packages/SystemUI/res/layout/media_output_list_group_divider.xml b/packages/SystemUI/res/layout/media_output_list_group_divider.xml index 5e96866c0a9a..c351912de295 100644 --- a/packages/SystemUI/res/layout/media_output_list_group_divider.xml +++ b/packages/SystemUI/res/layout/media_output_list_group_divider.xml @@ -26,7 +26,7 @@ android:layout_width="wrap_content" android:layout_height="36dp" android:layout_gravity="center_vertical|start" - android:layout_marginStart="16dp" + android:layout_marginStart="@dimen/media_output_dialog_margin_horizontal" android:layout_marginEnd="56dp" android:ellipsize="end" android:maxLines="1" diff --git a/packages/SystemUI/res/layout/media_output_list_item_advanced.xml b/packages/SystemUI/res/layout/media_output_list_item_advanced.xml index 69117cf7cf5d..d297ec46e1e1 100644 --- a/packages/SystemUI/res/layout/media_output_list_item_advanced.xml +++ b/packages/SystemUI/res/layout/media_output_list_item_advanced.xml @@ -15,18 +15,19 @@ ~ limitations under the License. --> -<FrameLayout +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/device_container" android:layout_width="match_parent" - android:layout_height="wrap_content"> + android:layout_height="wrap_content" + android:paddingHorizontal="@dimen/media_output_dialog_margin_horizontal" + android:baselineAligned="false"> <FrameLayout - android:layout_width="match_parent" - android:layout_height="64dp" + android:layout_weight="1" + android:layout_width="0dp" + android:layout_height="@dimen/media_output_dialog_item_height" android:id="@+id/item_layout" android:background="@drawable/media_output_item_background" - android:layout_marginStart="16dp" - android:layout_marginEnd="80dp" android:layout_marginBottom="12dp"> <FrameLayout android:layout_width="match_parent" @@ -36,7 +37,7 @@ android:id="@+id/volume_seekbar" android:splitTrack="false" android:visibility="gone" - android:paddingStart="64dp" + android:paddingStart="@dimen/media_output_dialog_item_height" android:paddingEnd="0dp" android:background="@null" android:contentDescription="@string/media_output_dialog_accessibility_seekbar" @@ -48,8 +49,8 @@ <FrameLayout android:id="@+id/icon_area" - android:layout_width="64dp" - android:layout_height="64dp" + android:layout_width="@dimen/media_output_dialog_item_height" + android:layout_height="@dimen/media_output_dialog_item_height" android:focusable="false" android:importantForAccessibility="no" android:layout_gravity="center_vertical|start"> @@ -131,11 +132,11 @@ </FrameLayout> <FrameLayout android:id="@+id/end_action_area" - android:layout_width="64dp" - android:layout_height="64dp" + android:layout_width="@dimen/media_output_dialog_item_height" + android:layout_height="@dimen/media_output_dialog_item_height" android:visibility="gone" android:layout_marginBottom="6dp" - android:layout_marginEnd="8dp" + android:layout_marginStart="7dp" android:layout_gravity="end|center" android:gravity="center" android:background="@drawable/media_output_item_background_active"> @@ -160,4 +161,4 @@ android:indeterminateOnly="true" android:visibility="gone"/> </FrameLayout> -</FrameLayout>
\ No newline at end of file +</LinearLayout>
\ No newline at end of file diff --git a/packages/SystemUI/res/values-ldrtl/dimens.xml b/packages/SystemUI/res/values-ldrtl/dimens.xml index 0d99b617819b..345f0414e637 100644 --- a/packages/SystemUI/res/values-ldrtl/dimens.xml +++ b/packages/SystemUI/res/values-ldrtl/dimens.xml @@ -16,5 +16,5 @@ --> <resources> <dimen name="media_output_dialog_icon_left_radius">0dp</dimen> - <dimen name="media_output_dialog_icon_right_radius">28dp</dimen> + <dimen name="media_output_dialog_icon_right_radius">@dimen/media_output_dialog_active_background_radius</dimen> </resources>
\ No newline at end of file diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 57748add5d8a..d93716b03685 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -1525,11 +1525,11 @@ <dimen name="media_output_dialog_icon_corner_radius">16dp</dimen> <dimen name="media_output_dialog_title_anim_y_delta">12.5dp</dimen> <dimen name="media_output_dialog_background_radius">16dp</dimen> - <dimen name="media_output_dialog_active_background_radius">30dp</dimen> - <dimen name="media_output_dialog_default_margin_end">16dp</dimen> - <dimen name="media_output_dialog_selectable_margin_end">80dp</dimen> + <dimen name="media_output_dialog_active_background_radius">32dp</dimen> + <dimen name="media_output_dialog_item_height">64dp</dimen> + <dimen name="media_output_dialog_margin_horizontal">16dp</dimen> <dimen name="media_output_dialog_list_padding_top">8dp</dimen> - <dimen name="media_output_dialog_icon_left_radius">28dp</dimen> + <dimen name="media_output_dialog_icon_left_radius">@dimen/media_output_dialog_active_background_radius</dimen> <dimen name="media_output_dialog_icon_right_radius">0dp</dimen> <!-- Distance that the full shade transition takes in order to complete by tapping on a button diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java index b391cb079ec5..bc6b2beb2ddb 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java @@ -298,8 +298,7 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { boolean showEndArea = !Flags.enableOutputSwitcherSessionGrouping() || isDeselectable; updateUnmutedVolumeIcon(device); - updateGroupableCheckBox(true, isDeselectable, device); - updateEndClickArea(device, isDeselectable); + updateEndAreaForGroupCheckbox(device, true /* isSelected */, isDeselectable); disableFocusPropertyForView(mContainerLayout); setUpContentDescriptionForView(mSeekBar, device); setSingleLineLayout(device.getName(), true /* showSeekBar */, @@ -331,8 +330,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { //If device is connected and there's other selectable devices, layout as // one of selected devices. updateUnmutedVolumeIcon(device); - updateGroupableCheckBox(true, isDeselectable, device); - updateEndClickArea(device, isDeselectable); + updateEndAreaForGroupCheckbox(device, true /* isSelected */, + isDeselectable); disableFocusPropertyForView(mContainerLayout); setUpContentDescriptionForView(mSeekBar, device); setSingleLineLayout(device.getName(), true /* showSeekBar */, @@ -352,8 +351,8 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { } else if (isSelectable) { //groupable device setUpDeviceIcon(device); - updateGroupableCheckBox(false, true, device); - updateEndClickArea(device, true); + updateEndAreaForGroupCheckbox(device, false /* isSelected */, + true /* isDeselectable */); if (!Flags.disableTransferWhenAppsDoNotSupport() || isTransferable || hasRouteListingPreferenceItem) { @@ -406,7 +405,7 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { private void updateEndClickAreaWithIcon(View.OnClickListener clickListener, @DrawableRes int iconDrawableId, @StringRes int accessibilityStringId) { - updateEndClickAreaColor(mController.getColorSeekbarProgress()); + updateEndAreaColor(mController.getColorSeekbarProgress()); mEndClickIcon.setImageTintList( ColorStateList.valueOf(mController.getColorItemContent())); mEndClickIcon.setOnClickListener(clickListener); @@ -422,7 +421,7 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { } } - public void updateEndClickAreaColor(int color) { + public void updateEndAreaColor(int color) { mEndTouchArea.setBackgroundTintList( ColorStateList.valueOf(color)); } @@ -455,25 +454,22 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { ColorStateList.valueOf(mController.getColorItemContent())); } - public void updateEndClickArea(MediaDevice device, boolean isDeviceDeselectable) { + public void updateEndAreaForGroupCheckbox(MediaDevice device, boolean isSelected, + boolean isDeselectable) { mEndTouchArea.setOnClickListener(null); mEndTouchArea.setOnClickListener( - isDeviceDeselectable ? (v) -> mCheckBox.performClick() : null); + isDeselectable ? (v) -> mCheckBox.performClick() : null); mEndTouchArea.setImportantForAccessibility( View.IMPORTANT_FOR_ACCESSIBILITY_YES); - mEndTouchArea.setBackgroundTintList( - ColorStateList.valueOf(mController.getColorItemBackground())); + updateEndAreaColor(isSelected ? mController.getColorSeekbarProgress() + : mController.getColorItemBackground()); setUpContentDescriptionForView(mEndTouchArea, device); - } - - private void updateGroupableCheckBox(boolean isSelected, boolean isGroupable, - MediaDevice device) { mCheckBox.setOnCheckedChangeListener(null); mCheckBox.setChecked(isSelected); mCheckBox.setOnCheckedChangeListener( - isGroupable ? (buttonView, isChecked) -> onGroupActionTriggered(!isSelected, + isDeselectable ? (buttonView, isChecked) -> onGroupActionTriggered(!isSelected, device) : null); - mCheckBox.setEnabled(isGroupable); + mCheckBox.setEnabled(isDeselectable); setCheckBoxColor(mCheckBox, mController.getColorItemContent()); } diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java index ee2d8aa46264..a7786c8f0b57 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java @@ -141,6 +141,8 @@ public abstract class MediaOutputBaseAdapter extends final ImageView mEndClickIcon; @VisibleForTesting MediaOutputSeekbar mSeekBar; + private final float mInactiveRadius; + private final float mActiveRadius; private String mDeviceId; private ValueAnimator mCornerAnimator; private ValueAnimator mVolumeAnimator; @@ -161,6 +163,10 @@ public abstract class MediaOutputBaseAdapter extends mEndClickIcon = view.requireViewById(R.id.media_output_item_end_click_icon); mVolumeValueText = view.requireViewById(R.id.volume_value); mIconAreaLayout = view.requireViewById(R.id.icon_area); + mInactiveRadius = mContext.getResources().getDimension( + R.dimen.media_output_dialog_background_radius); + mActiveRadius = mContext.getResources().getDimension( + R.dimen.media_output_dialog_active_background_radius); initAnimator(); } @@ -216,10 +222,6 @@ public abstract class MediaOutputBaseAdapter extends mEndClickIcon.setVisibility( !showCheckBox && showEndTouchArea ? View.VISIBLE : View.GONE); } - ViewGroup.MarginLayoutParams params = - (ViewGroup.MarginLayoutParams) mItemLayout.getLayoutParams(); - params.rightMargin = showEndTouchArea ? mController.getItemMarginEndSelectable() - : mController.getItemMarginEndDefault(); } void setTwoLineLayout(CharSequence title, boolean showSeekBar, @@ -247,10 +249,6 @@ public abstract class MediaOutputBaseAdapter extends //update end click area by isActive mEndTouchArea.setVisibility(showEndTouchArea ? View.VISIBLE : View.GONE); mEndClickIcon.setVisibility(showEndTouchArea ? View.VISIBLE : View.GONE); - ViewGroup.MarginLayoutParams params = - (ViewGroup.MarginLayoutParams) mItemLayout.getLayoutParams(); - params.rightMargin = showEndTouchArea ? mController.getItemMarginEndSelectable() - : mController.getItemMarginEndDefault(); mItemLayout.setBackground(backgroundDrawable); mProgressBar.setVisibility(showProgressBar ? View.VISIBLE : View.GONE); mSubTitleText.setVisibility(showSubtitle ? View.VISIBLE : View.GONE); @@ -264,10 +262,10 @@ public abstract class MediaOutputBaseAdapter extends final GradientDrawable progressDrawable = (GradientDrawable) clipDrawable.getDrawable(); progressDrawable.setCornerRadii( - new float[]{0, 0, mController.getActiveRadius(), - mController.getActiveRadius(), - mController.getActiveRadius(), - mController.getActiveRadius(), 0, 0}); + new float[]{0, 0, mActiveRadius, + mActiveRadius, + mActiveRadius, + mActiveRadius, 0, 0}); } private void initializeSeekbarVolume( @@ -431,8 +429,7 @@ public abstract class MediaOutputBaseAdapter extends } private void initAnimator() { - mCornerAnimator = ValueAnimator.ofFloat(mController.getInactiveRadius(), - mController.getActiveRadius()); + mCornerAnimator = ValueAnimator.ofFloat(mInactiveRadius, mActiveRadius); mCornerAnimator.setDuration(ANIM_DURATION); mCornerAnimator.setInterpolator(new LinearInterpolator()); diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaSwitchingController.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaSwitchingController.java index 02a2befe44e5..19409b32a2f6 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaSwitchingController.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaSwitchingController.java @@ -171,10 +171,6 @@ public class MediaSwitchingController private int mColorConnectedItemBackground; private int mColorPositiveButtonText; private int mColorDialogBackground; - private int mItemMarginEndDefault; - private int mItemMarginEndSelectable; - private float mInactiveRadius; - private float mActiveRadius; private FeatureFlags mFeatureFlags; private UserTracker mUserTracker; private VolumePanelGlobalStateInteractor mVolumePanelGlobalStateInteractor; @@ -246,16 +242,8 @@ public class MediaSwitchingController R.color.media_dialog_connected_item_background); mColorPositiveButtonText = Utils.getColorStateListDefaultColor(mContext, R.color.media_dialog_solid_button_text); - mInactiveRadius = mContext.getResources().getDimension( - R.dimen.media_output_dialog_background_radius); - mActiveRadius = mContext.getResources().getDimension( - R.dimen.media_output_dialog_active_background_radius); mColorDialogBackground = Utils.getColorStateListDefaultColor(mContext, R.color.media_dialog_background); - mItemMarginEndDefault = (int) mContext.getResources().getDimension( - R.dimen.media_output_dialog_default_margin_end); - mItemMarginEndSelectable = (int) mContext.getResources().getDimension( - R.dimen.media_output_dialog_selectable_margin_end); if (enableInputRouting()) { mInputRouteManager = new InputRouteManager(mContext, audioManager); @@ -638,22 +626,6 @@ public class MediaSwitchingController return mColorItemBackground; } - public float getInactiveRadius() { - return mInactiveRadius; - } - - public float getActiveRadius() { - return mActiveRadius; - } - - public int getItemMarginEndDefault() { - return mItemMarginEndDefault; - } - - public int getItemMarginEndSelectable() { - return mItemMarginEndSelectable; - } - private void buildMediaItems(List<MediaDevice> devices) { synchronized (mMediaDevicesLock) { List<MediaItem> updatedMediaItems = buildMediaItems(mOutputMediaItemList, devices); |