Merge "Fix colors and themes in QS" into sc-dev

This commit is contained in:
Fabian Kozynski
2021-04-12 13:04:39 +00:00
committed by Android (Google) Code Review
24 changed files with 104 additions and 43 deletions

View File

@@ -682,7 +682,7 @@
<activity
android:name=".settings.brightness.BrightnessDialog"
android:label="@string/quick_settings_brightness_dialog_title"
android:theme="@*android:style/Theme.DeviceDefault.SystemUI.Dialog"
android:theme="@style/Theme.SystemUI.QuickSettings.BrightnessDialog"
android:finishOnCloseSystemDialogs="true"
android:launchMode="singleInstance"
android:excludeFromRecents="true"

View File

@@ -15,6 +15,6 @@
~ limitations under the License
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="?android:attr/colorBackgroundFloating" />
<solid android:color="?attr/underSurfaceColor" />
<corners android:radius="8dp" />
</shape>

View File

@@ -24,7 +24,7 @@
<shape>
<size android:height="@dimen/rounded_slider_track_width" />
<corners android:radius="@dimen/rounded_slider_track_corner_radius" />
<solid android:color="?android:attr/textColorPrimary" />
<solid android:color="?attr/offStateColor" />
</shape>
</inset>
</item>

View File

@@ -16,12 +16,13 @@
-->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:priv-android="http://schemas.android.com/apk/prv/res/android"
android:autoMirrored="true">
<item android:id="@+id/slider_foreground"
android:height="@dimen/rounded_slider_height">
<shape>
<size android:height="@dimen/rounded_slider_height" />
<solid android:color="?android:attr/colorControlActivated" />
<solid android:color="?priv-android:attr/colorAccentPrimary" />
<corners android:radius="@dimen/rounded_slider_corner_radius"/>
</shape>
</item>

View File

@@ -16,7 +16,7 @@
-->
<inset xmlns:android="http://schemas.android.com/apk/res/android">
<shape>
<solid android:color="?android:attr/colorBackground"/>
<solid android:color="?attr/underSurfaceColor"/>
<corners android:radius="@dimen/notification_corner_radius" />
</shape>
</inset>

View File

@@ -14,4 +14,4 @@
limitations under the License.
-->
<color xmlns:android="http://schemas.android.com/apk/res/android"
android:color="@color/qs_customize_decoration"/>
android:color="?android:attr/colorBackground"/>

View File

@@ -15,7 +15,7 @@
-->
<inset xmlns:android="http://schemas.android.com/apk/res/android">
<shape>
<solid android:color="?android:attr/colorBackgroundFloating"/>
<solid android:color="?attr/underSurfaceColor"/>
<corners android:radius="?android:attr/dialogCornerRadius" />
</shape>
</inset>

View File

@@ -15,6 +15,6 @@
-->
<inset xmlns:android="http://schemas.android.com/apk/res/android">
<shape>
<solid android:color="?android:attr/colorBackgroundFloating"/>
<solid android:color="?attr/underSurfaceColor"/>
</shape>
</inset>

View File

@@ -18,5 +18,5 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="?android:attr/colorBackground" />
<corners android:radius="@dimen/ongoing_appops_dialog_bg_corner_radius" />
<corners android:radius="?android:attr/dialogCornerRadius" />
</shape>

View File

@@ -16,6 +16,7 @@
-->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:theme="@style/Theme.SystemUI.QuickSettings"
android:id="@+id/brightness_mirror"
android:layout_width="@dimen/qs_panel_width"
android:layout_height="@dimen/brightness_mirror_height"

View File

@@ -28,7 +28,7 @@
android:paddingRight="@dimen/ongoing_appops_dialog_side_padding"
android:paddingBottom="12dp"
android:paddingTop="8dp"
android:background="@drawable/privacy_dialog_bg"
android:background="@drawable/qs_dialog_bg"
/>
<!-- 12dp padding bottom so there's 20dp total under the icon -->
<!-- 8dp padding top, as there's 4dp margin in each row -->

View File

@@ -47,9 +47,6 @@
<color name="notification_section_clear_all_btn_color">@color/GM2_grey_500</color>
<color name="notification_channel_dialog_separator">@color/GM2_grey_700</color>
<!-- The color of the background in the bottom part of QSCustomizer -->
<color name="qs_customize_decoration">@color/GM2_grey_900</color>
<!-- The color of the background in the separated list of the Global Actions menu -->
<color name="global_actions_separated_background">@color/GM2_grey_900</color>

View File

@@ -126,6 +126,8 @@
<attr name="wallpaperTextColorSecondary" format="reference|color" />
<attr name="wallpaperTextColorAccent" format="reference|color" />
<attr name="backgroundProtectedStyle" format="reference" />
<attr name="offStateColor" format="reference|color" />
<attr name="underSurfaceColor" format="reference|color" />
<declare-styleable name="SmartReplyView">
<attr name="spacing" format="dimension" />

View File

@@ -35,7 +35,6 @@
<color name="status_bar_clock_color">#FFFFFFFF</color>
<color name="qs_user_detail_icon_muted">#FFFFFFFF</color> <!-- not so muted after all -->
<color name="qs_tile_disabled_color">#9E9E9E</color> <!-- 38% black -->
<color name="qs_customize_decoration">@color/GM2_grey_300</color>
<color name="qs_footer_action_border">#2E312C</color>
<!-- The color of the background in the separated list of the Global Actions menu -->

View File

@@ -1219,8 +1219,6 @@
<!-- Radius of Ongoing App Ops chip corners -->
<dimen name="ongoing_appops_chip_bg_corner_radius">16dp</dimen>
<dimen name="ongoing_appops_dialog_bg_corner_radius">@dimen/notification_corner_radius</dimen>
<dimen name="ongoing_appops_dialog_side_margins">@dimen/notification_shade_content_margin_horizontal</dimen>
<dimen name="ongoing_appops_dialog_circle_size">32dp</dimen>

View File

@@ -382,6 +382,17 @@
<item name="android:colorError">@*android:color/error_color_material_dark</item>
<item name="android:windowIsFloating">true</item>
<item name="android:homeAsUpIndicator">@drawable/ic_arrow_back</item>
<item name="offStateColor">@android:color/system_neutral1_800</item>
<item name="underSurfaceColor">@android:color/system_neutral1_1000</item>
<item name="android:colorBackground">@android:color/system_neutral1_900</item>
</style>
<style name="Theme.SystemUI.QuickSettings.BrightnessDialog" parent="@android:style/Theme.DeviceDefault.Dialog">
<item name="android:dialogCornerRadius">8dp</item>
</style>
<style name="Theme.SystemUI.QuickSettings.Dialog" parent="@android:style/Theme.DeviceDefault.Dialog">
<item name="android:dialogCornerRadius">@dimen/notification_corner_radius</item>
</style>
<!-- Overridden by values-television/styles.xml with tv-specific settings -->
@@ -588,10 +599,6 @@
<item name="android:elevation">10dp</item>
</style>
<style name="Theme.SystemUI.QuickSettings.Edit">
<item name="android:colorBackground">?android:attr/colorSecondary</item>
</style>
<style name="MediaPlayer.Button" parent="@android:style/Widget.Material.Button.Borderless.Small">
<item name="android:background">@drawable/qs_media_light_source</item>
<item name="android:tint">?android:attr/textColorPrimary</item>
@@ -628,7 +635,12 @@
</style>
<!-- Privacy dialog -->
<style name="PrivacyDialog" parent="ScreenRecord">
<style name="PrivacyDialog" parent="Theme.SystemUI.QuickSettings.Dialog">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowCloseOnTouchOutside">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
</style>

View File

@@ -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();

View File

@@ -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));

View File

@@ -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<Holder> implements TileSta
private final Handler mHandler = new Handler();
private final List<TileInfo> 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<Holder> 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;

View File

@@ -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);
}

View File

@@ -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 {}

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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);