From 37342cb83701c741628a7559b288d77489d2dec3 Mon Sep 17 00:00:00 2001 From: Fabian Kozynski Date: Thu, 8 Apr 2021 12:56:15 -0400 Subject: Fix colors and themes in QS Fix in: * QSCustomizer * QSSecurityFooter * PrivacyDialog * BrightnessSlider dialog and mirror Test: manual Fixes: 184862982 Change-Id: Ie2e4a17a72b31215e7294dac1afc0e2d39c4ff91 --- packages/SystemUI/AndroidManifest.xml | 2 +- .../res/drawable/brightness_mirror_background.xml | 2 +- .../res/drawable/brightness_progress_drawable.xml | 2 +- .../drawable/brightness_progress_full_drawable.xml | 3 +- .../SystemUI/res/drawable/privacy_dialog_bg.xml | 22 --------------- .../res/drawable/qs_background_primary.xml | 2 +- .../res/drawable/qs_customize_tile_decoration.xml | 2 +- .../drawable/qs_customizer_background_primary.xml | 2 +- .../res/drawable/qs_customizer_toolbar.xml | 2 +- packages/SystemUI/res/drawable/qs_dialog_bg.xml | 22 +++++++++++++++ packages/SystemUI/res/layout/brightness_mirror.xml | 1 + packages/SystemUI/res/layout/privacy_dialog.xml | 2 +- packages/SystemUI/res/values-night/colors.xml | 3 -- packages/SystemUI/res/values/attrs.xml | 2 ++ packages/SystemUI/res/values/colors.xml | 1 - packages/SystemUI/res/values/dimens.xml | 2 -- packages/SystemUI/res/values/styles.xml | 22 +++++++++++---- .../com/android/systemui/qs/QSSecurityFooter.java | 13 ++++----- .../systemui/qs/customize/QSCustomizer.java | 3 +- .../android/systemui/qs/customize/TileAdapter.java | 11 ++++++-- .../systemui/qs/dagger/QSFragmentModule.java | 21 +++++++++++++- .../systemui/qs/dagger/QSThemedContext.java | 32 ++++++++++++++++++++++ .../systemui/qs/tileimpl/QSTileBaseView.java | 10 +++---- .../settings/brightness/BrightnessDialog.java | 3 +- .../android/systemui/qs/QSSecurityFooterTest.java | 2 +- 25 files changed, 125 insertions(+), 64 deletions(-) delete mode 100644 packages/SystemUI/res/drawable/privacy_dialog_bg.xml create mode 100644 packages/SystemUI/res/drawable/qs_dialog_bg.xml create mode 100644 packages/SystemUI/src/com/android/systemui/qs/dagger/QSThemedContext.java diff --git a/packages/SystemUI/AndroidManifest.xml b/packages/SystemUI/AndroidManifest.xml index 88d7710e56c6..ac88b4590f5f 100644 --- a/packages/SystemUI/AndroidManifest.xml +++ b/packages/SystemUI/AndroidManifest.xml @@ -681,7 +681,7 @@ - + diff --git a/packages/SystemUI/res/drawable/brightness_progress_drawable.xml b/packages/SystemUI/res/drawable/brightness_progress_drawable.xml index 73b02f4fa481..88d8f78fa610 100644 --- a/packages/SystemUI/res/drawable/brightness_progress_drawable.xml +++ b/packages/SystemUI/res/drawable/brightness_progress_drawable.xml @@ -24,7 +24,7 @@ - + diff --git a/packages/SystemUI/res/drawable/brightness_progress_full_drawable.xml b/packages/SystemUI/res/drawable/brightness_progress_full_drawable.xml index f8f455d390c7..ceef9f909c97 100644 --- a/packages/SystemUI/res/drawable/brightness_progress_full_drawable.xml +++ b/packages/SystemUI/res/drawable/brightness_progress_full_drawable.xml @@ -16,12 +16,13 @@ --> - + diff --git a/packages/SystemUI/res/drawable/privacy_dialog_bg.xml b/packages/SystemUI/res/drawable/privacy_dialog_bg.xml deleted file mode 100644 index 96136c4afab8..000000000000 --- a/packages/SystemUI/res/drawable/privacy_dialog_bg.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/packages/SystemUI/res/drawable/qs_background_primary.xml b/packages/SystemUI/res/drawable/qs_background_primary.xml index 0a3afc575c4a..30d026ec2948 100644 --- a/packages/SystemUI/res/drawable/qs_background_primary.xml +++ b/packages/SystemUI/res/drawable/qs_background_primary.xml @@ -16,7 +16,7 @@ --> - + \ No newline at end of file diff --git a/packages/SystemUI/res/drawable/qs_customize_tile_decoration.xml b/packages/SystemUI/res/drawable/qs_customize_tile_decoration.xml index f086cec01234..1124a9220a2c 100644 --- a/packages/SystemUI/res/drawable/qs_customize_tile_decoration.xml +++ b/packages/SystemUI/res/drawable/qs_customize_tile_decoration.xml @@ -14,4 +14,4 @@ limitations under the License. --> \ No newline at end of file + android:color="?android:attr/colorBackground"/> \ No newline at end of file diff --git a/packages/SystemUI/res/drawable/qs_customizer_background_primary.xml b/packages/SystemUI/res/drawable/qs_customizer_background_primary.xml index c2d0841a1b8f..ea0aafd321e1 100644 --- a/packages/SystemUI/res/drawable/qs_customizer_background_primary.xml +++ b/packages/SystemUI/res/drawable/qs_customizer_background_primary.xml @@ -15,7 +15,7 @@ --> - + diff --git a/packages/SystemUI/res/drawable/qs_customizer_toolbar.xml b/packages/SystemUI/res/drawable/qs_customizer_toolbar.xml index 416583013e64..ef950fe67ad2 100644 --- a/packages/SystemUI/res/drawable/qs_customizer_toolbar.xml +++ b/packages/SystemUI/res/drawable/qs_customizer_toolbar.xml @@ -15,6 +15,6 @@ --> - + diff --git a/packages/SystemUI/res/drawable/qs_dialog_bg.xml b/packages/SystemUI/res/drawable/qs_dialog_bg.xml new file mode 100644 index 000000000000..b307781c6ac4 --- /dev/null +++ b/packages/SystemUI/res/drawable/qs_dialog_bg.xml @@ -0,0 +1,22 @@ + + + + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/layout/brightness_mirror.xml b/packages/SystemUI/res/layout/brightness_mirror.xml index 8b47ab915fb4..b714767e7d83 100644 --- a/packages/SystemUI/res/layout/brightness_mirror.xml +++ b/packages/SystemUI/res/layout/brightness_mirror.xml @@ -16,6 +16,7 @@ --> \ No newline at end of file diff --git a/packages/SystemUI/res/values-night/colors.xml b/packages/SystemUI/res/values-night/colors.xml index 471f36b3849e..d7a610300fe8 100644 --- a/packages/SystemUI/res/values-night/colors.xml +++ b/packages/SystemUI/res/values-night/colors.xml @@ -47,9 +47,6 @@ @color/GM2_grey_500 @color/GM2_grey_700 - - @color/GM2_grey_900 - @color/GM2_grey_900 diff --git a/packages/SystemUI/res/values/attrs.xml b/packages/SystemUI/res/values/attrs.xml index 886f98e55d67..e4bdbf3f0727 100644 --- a/packages/SystemUI/res/values/attrs.xml +++ b/packages/SystemUI/res/values/attrs.xml @@ -126,6 +126,8 @@ + + diff --git a/packages/SystemUI/res/values/colors.xml b/packages/SystemUI/res/values/colors.xml index bc7fcde4ae5d..a807d4f95a0d 100644 --- a/packages/SystemUI/res/values/colors.xml +++ b/packages/SystemUI/res/values/colors.xml @@ -35,7 +35,6 @@ #FFFFFFFF #FFFFFFFF #9E9E9E - @color/GM2_grey_300 #2E312C diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 237edf8c973b..b08aa74ffee8 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -1213,8 +1213,6 @@ 16dp - @dimen/notification_corner_radius - @dimen/notification_shade_content_margin_horizontal 32dp diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml index ba07829d02fc..ce8c0c2897b8 100644 --- a/packages/SystemUI/res/values/styles.xml +++ b/packages/SystemUI/res/values/styles.xml @@ -382,6 +382,17 @@ @*android:color/error_color_material_dark true @drawable/ic_arrow_back + @android:color/system_neutral1_800 + @android:color/system_neutral1_1000 + @android:color/system_neutral1_900 + + + + + @@ -588,10 +599,6 @@ 10dp - - - diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java index 2c5dbcd51f21..670475fac5ef 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java +++ b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java @@ -36,7 +36,6 @@ import android.text.SpannableStringBuilder; import android.text.method.LinkMovementMethod; import android.text.style.ClickableSpan; import android.util.Log; -import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; @@ -89,7 +88,7 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen private Drawable mPrimaryFooterIconDrawable; @Inject - QSSecurityFooter(@Named(QS_SECURITY_FOOTER_VIEW) View rootView, Context context, + QSSecurityFooter(@Named(QS_SECURITY_FOOTER_VIEW) View rootView, UserTracker userTracker, @Main Handler mainHandler, ActivityStarter activityStarter, SecurityController securityController, @Background Looper bgLooper) { mRootView = rootView; @@ -98,7 +97,7 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen mFooterIcon = mRootView.findViewById(R.id.footer_icon); mPrimaryFooterIcon = mRootView.findViewById(R.id.primary_footer_icon); mFooterIconId = R.drawable.ic_info_outline; - mContext = context; + mContext = rootView.getContext(); mMainHandler = mainHandler; mActivityStarter = activityStarter; mSecurityController = securityController; @@ -308,7 +307,7 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen } private void createDialog() { - mDialog = new SystemUIDialog(mContext); + mDialog = new SystemUIDialog(mContext, 0); // Use mContext theme mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); mDialog.setButton(DialogInterface.BUTTON_POSITIVE, getPositiveButton(), this); mDialog.setButton(DialogInterface.BUTTON_NEGATIVE, getNegativeButton(), this); @@ -344,8 +343,7 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen final String vpnNameWorkProfile = mSecurityController.getWorkProfileVpnName(); - View dialogView = LayoutInflater.from( - new ContextThemeWrapper(mContext, R.style.Theme_SystemUI_Dialog)) + View dialogView = LayoutInflater.from(mContext) .inflate(R.layout.quick_settings_footer_dialog, null, false); // device management section @@ -420,8 +418,7 @@ class QSSecurityFooter implements OnClickListener, DialogInterface.OnClickListen } private View createParentalControlsDialogView() { - View dialogView = LayoutInflater.from( - new ContextThemeWrapper(mContext, R.style.Theme_SystemUI_Dialog)) + View dialogView = LayoutInflater.from(mContext) .inflate(R.layout.quick_settings_footer_dialog_parental_controls, null, false); DeviceAdminInfo info = mSecurityController.getDeviceAdminInfo(); diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java index 6f789d3c8541..30a08c6f1b66 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java +++ b/packages/SystemUI/src/com/android/systemui/qs/customize/QSCustomizer.java @@ -22,7 +22,6 @@ import android.content.Context; import android.content.res.Configuration; import android.util.AttributeSet; import android.util.TypedValue; -import android.view.ContextThemeWrapper; import android.view.LayoutInflater; import android.view.Menu; import android.view.View; @@ -63,7 +62,7 @@ public class QSCustomizer extends LinearLayout { private boolean mIsShowingNavBackdrop; public QSCustomizer(Context context, AttributeSet attrs) { - super(new ContextThemeWrapper(context, R.style.Theme_SystemUI_QuickSettings_Edit), attrs); + super(context, attrs); LayoutInflater.from(getContext()).inflate(R.layout.qs_customize_panel_content, this); mClipper = new QSDetailClipper(findViewById(R.id.customize_container)); diff --git a/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java b/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java index 08aa599d34b7..006b23098622 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/qs/customize/TileAdapter.java @@ -52,6 +52,7 @@ import com.android.systemui.qs.customize.TileAdapter.Holder; import com.android.systemui.qs.customize.TileQueryHelper.TileInfo; import com.android.systemui.qs.customize.TileQueryHelper.TileStateListener; import com.android.systemui.qs.dagger.QSScope; +import com.android.systemui.qs.dagger.QSThemedContext; import com.android.systemui.qs.external.CustomTile; import com.android.systemui.qs.tileimpl.QSIconViewImpl; import com.android.systemui.qs.tileimpl.QSTileView; @@ -89,7 +90,7 @@ public class TileAdapter extends RecyclerView.Adapter implements TileSta private final Handler mHandler = new Handler(); private final List mTiles = new ArrayList<>(); private final ItemTouchHelper mItemTouchHelper; - private final ItemDecoration mDecoration; + private ItemDecoration mDecoration; private final MarginTileDecoration mMarginDecoration; private final int mMinNumTiles; private final QSTileHost mHost; @@ -112,8 +113,12 @@ public class TileAdapter extends RecyclerView.Adapter implements TileSta private final boolean mUseHorizontalTiles; @Inject - public TileAdapter(Context context, QSTileHost qsHost, UiEventLogger uiEventLogger, - @Named(QS_LABELS_FLAG) boolean useHorizontalTiles) { + public TileAdapter( + @QSThemedContext Context context, + QSTileHost qsHost, + UiEventLogger uiEventLogger, + @Named(QS_LABELS_FLAG) boolean useHorizontalTiles + ) { mContext = context; mHost = qsHost; mUiEventLogger = uiEventLogger; diff --git a/packages/SystemUI/src/com/android/systemui/qs/dagger/QSFragmentModule.java b/packages/SystemUI/src/com/android/systemui/qs/dagger/QSFragmentModule.java index 2363aa455cce..3a5adce51d0d 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/dagger/QSFragmentModule.java +++ b/packages/SystemUI/src/com/android/systemui/qs/dagger/QSFragmentModule.java @@ -49,6 +49,22 @@ public interface QSFragmentModule { String QS_SECURITY_FOOTER_VIEW = "qs_security_footer"; String QS_USING_MEDIA_PLAYER = "qs_using_media_player"; + /** + * Provide a context themed using the QS theme + */ + @Provides + @QSThemedContext + static Context provideThemedContext(@RootView View view) { + return view.getContext(); + } + + /** */ + @Provides + @QSThemedContext + static LayoutInflater provideThemedLayoutInflater(@QSThemedContext Context context) { + return LayoutInflater.from(context); + } + /** */ @Provides @RootView @@ -109,7 +125,10 @@ public interface QSFragmentModule { @Provides @QSScope @Named(QS_SECURITY_FOOTER_VIEW) - static View providesQSSecurityFooterView(LayoutInflater layoutInflater, QSPanel qsPanel) { + static View providesQSSecurityFooterView( + @QSThemedContext LayoutInflater layoutInflater, + QSPanel qsPanel + ) { return layoutInflater.inflate(R.layout.quick_settings_footer, qsPanel, false); } diff --git a/packages/SystemUI/src/com/android/systemui/qs/dagger/QSThemedContext.java b/packages/SystemUI/src/com/android/systemui/qs/dagger/QSThemedContext.java new file mode 100644 index 000000000000..a878d4c60f88 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/qs/dagger/QSThemedContext.java @@ -0,0 +1,32 @@ +/* + * 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. + */ + +package com.android.systemui.qs.dagger; + +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; + +import javax.inject.Qualifier; + +/** + * Annotation for themed context in QS + */ +@Documented +@Retention(RUNTIME) +@Qualifier +public @interface QSThemedContext {} diff --git a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileBaseView.java b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileBaseView.java index abe321979a1a..7e72f1a18e41 100644 --- a/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileBaseView.java +++ b/packages/SystemUI/src/com/android/systemui/qs/tileimpl/QSTileBaseView.java @@ -72,7 +72,6 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView { protected final ImageView mBg; private final int mColorActive; private final int mColorInactive; - private final int mColorDisabled; private int mCircleColor; private int mBgSize; @@ -131,10 +130,9 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView { setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES); setBackground(mTileBackground); - mColorActive = Utils.getColorAttrDefaultColor(context, android.R.attr.colorAccent); - mColorDisabled = Utils.getDisabled(context, - Utils.getColorAttrDefaultColor(context, android.R.attr.colorControlActivated)); - mColorInactive = Utils.getColorAttrDefaultColor(context, android.R.attr.textColorSecondary); + mColorActive = Utils.getColorAttrDefaultColor(context, + com.android.internal.R.attr.colorAccentPrimary); + mColorInactive = Utils.getColorAttrDefaultColor(context, R.attr.offStateColor); setPadding(0, 0, 0, 0); setClipChildren(false); @@ -324,7 +322,7 @@ public class QSTileBaseView extends com.android.systemui.plugins.qs.QSTileView { return mColorActive; case Tile.STATE_INACTIVE: case Tile.STATE_UNAVAILABLE: - return mColorDisabled; + return mColorInactive; default: Log.e(TAG, "Invalid state " + state); return 0; diff --git a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessDialog.java b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessDialog.java index 1961bfc9ee27..3ba46460be43 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessDialog.java +++ b/packages/SystemUI/src/com/android/systemui/settings/brightness/BrightnessDialog.java @@ -25,6 +25,7 @@ import android.view.WindowManager; import com.android.internal.logging.MetricsLogger; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; +import com.android.systemui.R; import com.android.systemui.broadcast.BroadcastDispatcher; import javax.inject.Inject; @@ -61,10 +62,10 @@ public class BrightnessDialog extends Activity { window.setLayout( WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); - BrightnessSlider controller = mToggleSliderFactory.create(this, null); controller.init(); setContentView(controller.getRootView()); + controller.getRootView().setBackgroundResource(R.drawable.brightness_mirror_background); mBrightnessController = new BrightnessController(this, controller, mBroadcastDispatcher); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java index e4b95af1af04..4ee639b6928f 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/qs/QSSecurityFooterTest.java @@ -102,7 +102,7 @@ public class QSSecurityFooterTest extends SysuiTestCase { mRootView = (ViewGroup) new LayoutInflaterBuilder(mContext) .replace("ImageView", TestableImageView.class) .build().inflate(R.layout.quick_settings_footer, null, false); - mFooter = new QSSecurityFooter(mRootView, mContext, mUserTracker, new Handler(looper), + mFooter = new QSSecurityFooter(mRootView, mUserTracker, new Handler(looper), mActivityStarter, mSecurityController, looper); mFooterText = mRootView.findViewById(R.id.footer_text); mFooterIcon = mRootView.findViewById(R.id.footer_icon); -- cgit v1.2.3-59-g8ed1b