Merge "Clear quick settings backgrounds, update clock text color"

This commit is contained in:
TreeHugger Robot
2020-11-14 02:31:28 +00:00
committed by Android (Google) Code Review
8 changed files with 41 additions and 60 deletions

View File

@@ -29,25 +29,6 @@
android:elevation="4dp"
android:background="@drawable/qs_background_primary" />
<!-- Black part behind the status bar -->
<View
android:id="@+id/quick_settings_status_bar_background"
android:layout_width="match_parent"
android:layout_height="@*android:dimen/quick_qs_offset_height"
android:clipToPadding="false"
android:clipChildren="false"
android:background="#ff000000" />
<!-- Gradient view behind QS -->
<View
android:id="@+id/quick_settings_gradient_view"
android:layout_width="match_parent"
android:layout_height="126dp"
android:layout_marginTop="@*android:dimen/quick_qs_offset_height"
android:clipToPadding="false"
android:clipChildren="false"
android:background="@drawable/qs_bg_gradient" />
<com.android.systemui.qs.NonInterceptingScrollView
android:id="@+id/expanded_qs_scroll_view"
android:layout_width="match_parent"

View File

@@ -43,8 +43,7 @@
android:paddingStart="@dimen/status_bar_left_clock_starting_padding"
android:paddingEnd="@dimen/status_bar_left_clock_end_padding"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
systemui:showDark="false" />
android:textAppearance="@style/TextAppearance.StatusBar.Clock" />
</LinearLayout>
<android.widget.Space

View File

@@ -65,8 +65,6 @@ public class QSContainerImpl extends FrameLayout {
private View mQSPanelContainer;
private View mBackground;
private View mBackgroundGradient;
private View mStatusBarBackground;
private int mSideMargins;
private boolean mQsDisabled;
@@ -86,8 +84,6 @@ public class QSContainerImpl extends FrameLayout {
mQSCustomizer = findViewById(R.id.qs_customize);
mDragHandle = findViewById(R.id.qs_drag_handle_view);
mBackground = findViewById(R.id.quick_settings_background);
mStatusBarBackground = findViewById(R.id.quick_settings_status_bar_background);
mBackgroundGradient = findViewById(R.id.quick_settings_gradient_view);
mHeader.getHeaderQsPanel().setMediaVisibilityChangedListener((visible) -> {
if (mHeader.getHeaderQsPanel().isShown()) {
mAnimateBottomOnNextLayout = true;
@@ -117,7 +113,6 @@ public class QSContainerImpl extends FrameLayout {
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
setBackgroundGradientVisibility(newConfig);
mSizePoint.set(0, 0); // Will be retrieved on next measure pass.
}
@@ -186,7 +181,6 @@ public class QSContainerImpl extends FrameLayout {
final boolean disabled = (state2 & DISABLE2_QUICK_SETTINGS) != 0;
if (disabled == mQsDisabled) return;
mQsDisabled = disabled;
setBackgroundGradientVisibility(getResources().getConfiguration());
mBackground.setVisibility(mQsDisabled ? View.GONE : View.VISIBLE);
}
@@ -252,16 +246,6 @@ public class QSContainerImpl extends FrameLayout {
+ mHeader.getHeight();
}
private void setBackgroundGradientVisibility(Configuration newConfig) {
if (newConfig.orientation == ORIENTATION_LANDSCAPE) {
mBackgroundGradient.setVisibility(View.INVISIBLE);
mStatusBarBackground.setVisibility(View.INVISIBLE);
} else {
mBackgroundGradient.setVisibility(mQsDisabled ? View.INVISIBLE : View.VISIBLE);
mStatusBarBackground.setVisibility(View.VISIBLE);
}
}
public void setExpansion(float expansion) {
mQsExpansion = expansion;
mDragHandle.setAlpha(1.0f - expansion);
@@ -271,8 +255,7 @@ public class QSContainerImpl extends FrameLayout {
private void updatePaddingsAndMargins(QSPanelController qsPanelController) {
for (int i = 0; i < getChildCount(); i++) {
View view = getChildAt(i);
if (view == mStatusBarBackground || view == mBackgroundGradient
|| view == mQSCustomizer) {
if (view == mQSCustomizer) {
// Some views are always full width or have dependent padding
continue;
}

View File

@@ -137,10 +137,6 @@ public class QuickStatusBarHeader extends RelativeLayout implements LifecycleOwn
updateResources();
Rect tintArea = new Rect(0, 0, 0, 0);
// Set light text on the header icons because they will always be on a black background
applyDarkness(R.id.clock, tintArea, 0, DarkIconDispatcher.DEFAULT_ICON_TINT);
mClockView = findViewById(R.id.clock);
mSpace = findViewById(R.id.space);
@@ -158,7 +154,14 @@ public class QuickStatusBarHeader extends RelativeLayout implements LifecycleOwn
android.R.attr.colorForeground);
float intensity = getColorIntensity(colorForeground);
int fillColor = mDualToneHandler.getSingleColor(intensity);
Rect tintArea = new Rect(0, 0, 0, 0);
mBatteryRemainingIcon.onDarkChanged(tintArea, intensity, fillColor);
// The quick settings status bar clock depends on the color of the background scrim and
// can be different from the status bar clock color.
mClockView.setTextColor(
Utils.getColorAttrDefaultColor(mContext, R.attr.wallpaperTextColor));
}
void onAttach(TintedIconManager iconManager) {
@@ -231,13 +234,6 @@ public class QuickStatusBarHeader extends RelativeLayout implements LifecycleOwn
!Objects.equals(originalAlarmText, mNextAlarmTextView.getText());
}
private void applyDarkness(int id, Rect tintArea, float intensity, int color) {
View v = findViewById(id);
if (v instanceof DarkReceiver) {
((DarkReceiver) v).onDarkChanged(tintArea, intensity, color);
}
}
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);

View File

@@ -34,8 +34,10 @@ import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleRegistry;
import com.android.internal.colorextraction.ColorExtractor;
import com.android.internal.logging.UiEventLogger;
import com.android.systemui.R;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.demomode.DemoMode;
import com.android.systemui.demomode.DemoModeController;
import com.android.systemui.plugins.ActivityStarter;
@@ -99,6 +101,9 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
private boolean mMicCameraIndicatorsEnabled;
private boolean mLocationIndicatorsEnabled;
private boolean mPrivacyChipLogged;
private SysuiColorExtractor mColorExtractor;
private ColorExtractor.OnColorsChangedListener mOnColorsChangedListener;
private int mRingerMode = AudioManager.RINGER_MODE_NORMAL;
private final ZenModeController.Callback mZenModeControllerCallback = new Callback() {
@@ -216,7 +221,8 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
CommandQueue commandQueue, DemoModeController demoModeController,
UserTracker userTracker, QuickQSPanelController quickQSPanelController,
QSCarrierGroupController.Builder qsCarrierGroupControllerBuilder,
PrivacyLogger privacyLogger) {
PrivacyLogger privacyLogger,
SysuiColorExtractor colorExtractor) {
super(view);
mZenModeController = zenModeController;
mNextAlarmController = nextAlarmController;
@@ -246,6 +252,12 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
mIconManager = new StatusBarIconController.TintedIconManager(mIconContainer, mCommandQueue);
mDemoModeReceiver = new ClockDemoModeReceiver(mClockView);
mColorExtractor = colorExtractor;
mOnColorsChangedListener = (extractor, which) -> {
final boolean lightTheme = mColorExtractor.getNeutralColors().supportsDarkText();
mClockView.onColorsChanged(lightTheme);
};
mColorExtractor.addOnColorsChangedListener(mOnColorsChangedListener);
}
@Override
@@ -281,6 +293,7 @@ class QuickStatusBarHeaderController extends ViewController<QuickStatusBarHeader
protected void onViewDetached() {
mRingerModeTracker.getRingerModeInternal().removeObservers(mLifecycleOwner);
mClockView.setOnClickListener(null);
mColorExtractor.removeOnColorsChangedListener(mOnColorsChangedListener);
mNextAlarmContainer.setOnClickListener(null);
mRingerContainer.setOnClickListener(null);
mPrivacyChip.setOnClickListener(null);

View File

@@ -66,6 +66,7 @@ public class PhoneStatusBarView extends PanelBar {
}
};
private DarkReceiver mBattery;
private DarkReceiver mClock;
private int mRotationOrientation = -1;
@Nullable
private View mCenterIconSpace;
@@ -99,6 +100,7 @@ public class PhoneStatusBarView extends PanelBar {
@Override
public void onFinishInflate() {
mBattery = findViewById(R.id.battery);
mClock = findViewById(R.id.clock);
mCutoutSpace = findViewById(R.id.cutout_space_view);
mCenterIconSpace = findViewById(R.id.centered_icon_area);
@@ -110,6 +112,7 @@ public class PhoneStatusBarView extends PanelBar {
super.onAttachedToWindow();
// Always have Battery meters in the status bar observe the dark/light modes.
Dependency.get(DarkIconDispatcher.class).addDarkReceiver(mBattery);
Dependency.get(DarkIconDispatcher.class).addDarkReceiver(mClock);
if (updateOrientationAndCutout()) {
updateLayoutForCutout();
}
@@ -119,6 +122,7 @@ public class PhoneStatusBarView extends PanelBar {
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
Dependency.get(DarkIconDispatcher.class).removeDarkReceiver(mBattery);
Dependency.get(DarkIconDispatcher.class).removeDarkReceiver(mClock);
mDisplayCutout = null;
}

View File

@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.policy;
import android.annotation.ColorInt;
import android.app.StatusBarManager;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -35,6 +36,7 @@ import android.text.format.DateFormat;
import android.text.style.CharacterStyle;
import android.text.style.RelativeSizeSpan;
import android.util.AttributeSet;
import android.view.ContextThemeWrapper;
import android.view.Display;
import android.view.View;
import android.widget.TextView;
@@ -96,7 +98,6 @@ public class Clock extends TextView implements
private static final int AM_PM_STYLE_GONE = 2;
private final int mAmPmStyle;
private final boolean mShowDark;
private boolean mShowSeconds;
private Handler mSecondsHandler;
@@ -126,7 +127,6 @@ public class Clock extends TextView implements
0, 0);
try {
mAmPmStyle = a.getInt(R.styleable.Clock_amPmStyle, AM_PM_STYLE_GONE);
mShowDark = a.getBoolean(R.styleable.Clock_showDark, true);
mNonAdaptedColor = getCurrentTextColor();
} finally {
a.recycle();
@@ -196,9 +196,6 @@ public class Clock extends TextView implements
Dependency.get(TunerService.class).addTunable(this, CLOCK_SECONDS,
StatusBarIconController.ICON_HIDE_LIST);
mCommandQueue.addCallback(this);
if (mShowDark) {
Dependency.get(DarkIconDispatcher.class).addDarkReceiver(this);
}
mCurrentUserTracker.startTracking();
mCurrentUserId = mCurrentUserTracker.getCurrentUserId();
}
@@ -229,9 +226,6 @@ public class Clock extends TextView implements
mAttached = false;
Dependency.get(TunerService.class).removeTunable(this);
mCommandQueue.removeCallback(this);
if (mShowDark) {
Dependency.get(DarkIconDispatcher.class).removeDarkReceiver(this);
}
mCurrentUserTracker.stopTracking();
}
}
@@ -334,6 +328,13 @@ public class Clock extends TextView implements
}
}
// Update text color based when shade scrim changes color.
public void onColorsChanged(boolean lightTheme) {
final Context context = new ContextThemeWrapper(mContext,
lightTheme ? R.style.Theme_SystemUI_Light : R.style.Theme_SystemUI);
setTextColor(Utils.getColorAttrDefaultColor(context, R.attr.wallpaperTextColor));
}
@Override
public void onDensityOrFontScaleChanged() {
FontSizeUtils.updateFontSize(this, R.dimen.status_bar_clock_size);

View File

@@ -21,6 +21,7 @@ import android.testing.AndroidTestingRunner
import android.view.View
import androidx.test.filters.SmallTest
import com.android.internal.logging.UiEventLogger
import com.android.systemui.colorextraction.SysuiColorExtractor
import com.android.systemui.R
import com.android.systemui.SysuiTestCase
import com.android.systemui.demomode.DemoModeController
@@ -89,6 +90,8 @@ class QuickStatusBarHeaderControllerTest : SysuiTestCase() {
@Mock
private lateinit var privacyLogger: PrivacyLogger
@Mock
private lateinit var colorExtractor: SysuiColorExtractor
@Mock
private lateinit var iconContainer: StatusIconContainer
@Mock
private lateinit var qsCarrierGroup: QSCarrierGroup
@@ -127,7 +130,8 @@ class QuickStatusBarHeaderControllerTest : SysuiTestCase() {
userTracker,
quickQSPanelController,
qsCarrierGroupControllerBuilder,
privacyLogger
privacyLogger,
colorExtractor
)
}