Merge "[Output switcher] Fix color issue" into tm-qpr-dev am: d1296d03ae

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

Change-Id: I15706b4e53c6af1ad1672071aa7ad9fbce3ee84c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Shaowei Shen
2022-09-14 08:41:16 +00:00
committed by Automerger Merge Worker
5 changed files with 44 additions and 3 deletions

View File

@@ -0,0 +1,22 @@
<!--
~ Copyright (C) 2021 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.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners
android:radius="28dp"/>
<solid android:color="@color/media_dialog_background" />
</shape>

View File

@@ -20,6 +20,7 @@
android:id="@+id/media_output_dialog" android:id="@+id/media_output_dialog"
android:layout_width="@dimen/large_dialog_width" android:layout_width="@dimen/large_dialog_width"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/media_output_dialog_background"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout

View File

@@ -182,7 +182,7 @@
<color name="media_dialog_item_main_content">@color/material_dynamic_primary20</color> <color name="media_dialog_item_main_content">@color/material_dynamic_primary20</color>
<color name="media_dialog_item_background">@color/material_dynamic_secondary95</color> <color name="media_dialog_item_background">@color/material_dynamic_secondary95</color>
<color name="media_dialog_connected_item_background">@color/material_dynamic_primary90</color> <color name="media_dialog_connected_item_background">@color/material_dynamic_primary90</color>
<color name="media_dialog_seekbar_progress">@color/material_dynamic_secondary40</color> <color name="media_dialog_seekbar_progress">@android:color/system_accent1_200</color>
<color name="media_dialog_button_background">@color/material_dynamic_primary40</color> <color name="media_dialog_button_background">@color/material_dynamic_primary40</color>
<color name="media_dialog_solid_button_text">@color/material_dynamic_neutral95</color> <color name="media_dialog_solid_button_text">@color/material_dynamic_neutral95</color>

View File

@@ -310,6 +310,7 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
if (icon.getType() != Icon.TYPE_BITMAP && icon.getType() != Icon.TYPE_ADAPTIVE_BITMAP) { if (icon.getType() != Icon.TYPE_BITMAP && icon.getType() != Icon.TYPE_ADAPTIVE_BITMAP) {
// icon doesn't support getBitmap, use default value for color scheme // icon doesn't support getBitmap, use default value for color scheme
updateButtonBackgroundColorFilter(); updateButtonBackgroundColorFilter();
updateDialogBackgroundColor();
} else { } else {
Configuration config = mContext.getResources().getConfiguration(); Configuration config = mContext.getResources().getConfiguration();
int currentNightMode = config.uiMode & Configuration.UI_MODE_NIGHT_MASK; int currentNightMode = config.uiMode & Configuration.UI_MODE_NIGHT_MASK;
@@ -319,11 +320,14 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
if (colorSetUpdated) { if (colorSetUpdated) {
mAdapter.updateColorScheme(wallpaperColors, isDarkThemeOn); mAdapter.updateColorScheme(wallpaperColors, isDarkThemeOn);
updateButtonBackgroundColorFilter(); updateButtonBackgroundColorFilter();
updateDialogBackgroundColor();
} }
} }
mHeaderIcon.setVisibility(View.VISIBLE); mHeaderIcon.setVisibility(View.VISIBLE);
mHeaderIcon.setImageIcon(icon); mHeaderIcon.setImageIcon(icon);
} else { } else {
updateButtonBackgroundColorFilter();
updateDialogBackgroundColor();
mHeaderIcon.setVisibility(View.GONE); mHeaderIcon.setVisibility(View.GONE);
} }
if (appSourceIcon != null) { if (appSourceIcon != null) {
@@ -381,11 +385,16 @@ public abstract class MediaOutputBaseDialog extends SystemUIDialog implements
private void updateButtonBackgroundColorFilter() { private void updateButtonBackgroundColorFilter() {
ColorFilter buttonColorFilter = new PorterDuffColorFilter( ColorFilter buttonColorFilter = new PorterDuffColorFilter(
mAdapter.getController().getColorButtonBackground(), mMediaOutputController.getColorButtonBackground(),
PorterDuff.Mode.SRC_IN); PorterDuff.Mode.SRC_IN);
mDoneButton.getBackground().setColorFilter(buttonColorFilter); mDoneButton.getBackground().setColorFilter(buttonColorFilter);
mStopButton.getBackground().setColorFilter(buttonColorFilter); mStopButton.getBackground().setColorFilter(buttonColorFilter);
mDoneButton.setTextColor(mAdapter.getController().getColorPositiveButtonText()); mDoneButton.setTextColor(mMediaOutputController.getColorPositiveButtonText());
}
private void updateDialogBackgroundColor() {
getDialogView().getBackground().setTint(mMediaOutputController.getColorDialogBackground());
mDeviceListLayout.setBackgroundColor(mMediaOutputController.getColorDialogBackground());
} }
private Drawable resizeDrawable(Drawable drawable, int size) { private Drawable resizeDrawable(Drawable drawable, int size) {

View File

@@ -140,6 +140,7 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
private int mColorItemBackground; private int mColorItemBackground;
private int mColorConnectedItemBackground; private int mColorConnectedItemBackground;
private int mColorPositiveButtonText; private int mColorPositiveButtonText;
private int mColorDialogBackground;
private float mInactiveRadius; private float mInactiveRadius;
private float mActiveRadius; private float mActiveRadius;
@@ -188,6 +189,8 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
R.dimen.media_output_dialog_background_radius); R.dimen.media_output_dialog_background_radius);
mActiveRadius = mContext.getResources().getDimension( mActiveRadius = mContext.getResources().getDimension(
R.dimen.media_output_dialog_active_background_radius); R.dimen.media_output_dialog_active_background_radius);
mColorDialogBackground = Utils.getColorStateListDefaultColor(mContext,
R.color.media_dialog_background);
} }
void start(@NonNull Callback cb) { void start(@NonNull Callback cb) {
@@ -471,6 +474,7 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
mColorItemBackground = mCurrentColorScheme.getNeutral2().get(9); // N2-800 mColorItemBackground = mCurrentColorScheme.getNeutral2().get(9); // N2-800
mColorConnectedItemBackground = mCurrentColorScheme.getAccent2().get(9); // A2-800 mColorConnectedItemBackground = mCurrentColorScheme.getAccent2().get(9); // A2-800
mColorPositiveButtonText = mCurrentColorScheme.getAccent2().get(9); // A2-800 mColorPositiveButtonText = mCurrentColorScheme.getAccent2().get(9); // A2-800
mColorDialogBackground = mCurrentColorScheme.getNeutral1().get(10); // N1-900
} else { } else {
mColorItemContent = mCurrentColorScheme.getAccent1().get(9); // A1-800 mColorItemContent = mCurrentColorScheme.getAccent1().get(9); // A1-800
mColorSeekbarProgress = mCurrentColorScheme.getAccent1().get(4); // A1-300 mColorSeekbarProgress = mCurrentColorScheme.getAccent1().get(4); // A1-300
@@ -478,6 +482,7 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
mColorItemBackground = mCurrentColorScheme.getAccent2().get(1); // A2-50 mColorItemBackground = mCurrentColorScheme.getAccent2().get(1); // A2-50
mColorConnectedItemBackground = mCurrentColorScheme.getAccent1().get(2); // A1-100 mColorConnectedItemBackground = mCurrentColorScheme.getAccent1().get(2); // A1-100
mColorPositiveButtonText = mCurrentColorScheme.getNeutral1().get(1); // N1-50 mColorPositiveButtonText = mCurrentColorScheme.getNeutral1().get(1); // N1-50
mColorDialogBackground = mCurrentColorScheme.getBackgroundColor();
} }
} }
@@ -497,6 +502,10 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
return mColorPositiveButtonText; return mColorPositiveButtonText;
} }
public int getColorDialogBackground() {
return mColorDialogBackground;
}
public int getColorItemContent() { public int getColorItemContent() {
return mColorItemContent; return mColorItemContent;
} }