[QS] Update landscape UI

Rolling forward the landscape UI changes (To not break taimen with a
notch this time!). OG CL: ag/3717677

Shorten status bar height in landscape and update colors to use
wallpaperTextColor when in landscape mode.

Additionally modified scrim opacity for the QS panel to provide more
contrast/focus on content.

Test: Visually
Bug: 73808887
Change-Id: I249579d2898b9915868bb584661864d10ed88de2
This commit is contained in:
Rohan Shah
2018-03-30 21:24:17 +00:00
parent 1e617f5c20
commit cc3d1d8b96
14 changed files with 303 additions and 35 deletions

View File

@@ -29,7 +29,10 @@
<!-- Height of the status bar -->
<dimen name="status_bar_height">@dimen/status_bar_height_landscape</dimen>
<!-- Height of area above QQS where battery/time go -->
<dimen name="quick_qs_offset_height">@dimen/status_bar_height_landscape</dimen>
<!-- Total height of QQS in landscape, this is effectively status_bar_height_landscape + 128 -->
<dimen name="quick_qs_total_height">152dp</dimen>
<!-- Default height of an action bar. -->
<dimen name="action_bar_default_height">40dip</dimen>
<!-- Vertical padding around action bar icons. -->

View File

@@ -1671,6 +1671,7 @@
<java-symbol type="dimen" name="navigation_bar_height_landscape_car_mode" />
<java-symbol type="dimen" name="navigation_bar_width_car_mode" />
<java-symbol type="dimen" name="status_bar_height" />
<java-symbol type="dimen" name="quick_qs_offset_height" />
<java-symbol type="dimen" name="quick_qs_total_height" />
<java-symbol type="drawable" name="ic_jog_dial_sound_off" />
<java-symbol type="drawable" name="ic_jog_dial_sound_on" />

View File

@@ -31,25 +31,23 @@
<com.android.systemui.statusbar.policy.Clock
android:id="@+id/clock"
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:singleLine="true"
android:gravity="center_vertical|start"
android:paddingStart="@dimen/status_bar_left_clock_starting_padding"
android:paddingEnd="@dimen/status_bar_left_clock_end_padding"
android:gravity="center_vertical|start"
systemui:showDark="false"
/>
android:singleLine="true"
android:textAppearance="@style/TextAppearance.StatusBar.Clock"
systemui:showDark="false" />
<com.android.systemui.statusbar.policy.DateView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="4dp"
android:gravity="center_vertical"
android:singleLine="true"
android:textAppearance="@style/TextAppearance.StatusBar.Expanded.Date"
android:textSize="@dimen/qs_time_collapsed_size"
android:gravity="center_vertical"
systemui:datePattern="@string/abbrev_wday_month_day_no_year_alarm" />
<android.widget.Space
@@ -57,12 +55,11 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
/>
android:gravity="center_vertical|center_horizontal" />
<com.android.systemui.BatteryMeterView android:id="@+id/battery"
<com.android.systemui.BatteryMeterView
android:id="@+id/battery"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:gravity="center_vertical|end"
/>
android:gravity="center_vertical|end" />
</LinearLayout>

View File

@@ -81,6 +81,14 @@ public class BatteryMeterView extends LinearLayout implements
private float mDarkIntensity;
private int mUser;
/**
* Whether we should use colors that adapt based on wallpaper/the scrim behind quick settings.
*/
private boolean mUseWallpaperTextColors;
private int mNonAdaptedForegroundColor;
private int mNonAdaptedBackgroundColor;
public BatteryMeterView(Context context) {
this(context, null, 0);
}
@@ -140,6 +148,29 @@ public class BatteryMeterView extends LinearLayout implements
updateShowPercent();
}
/**
* Sets whether the battery meter view uses the wallpaperTextColor. If we're not using it, we'll
* revert back to dark-mode-based/tinted colors.
*
* @param shouldUseWallpaperTextColor whether we should use wallpaperTextColor for all
* components
*/
public void useWallpaperTextColor(boolean shouldUseWallpaperTextColor) {
if (shouldUseWallpaperTextColor == mUseWallpaperTextColors) {
return;
}
mUseWallpaperTextColors = shouldUseWallpaperTextColor;
if (mUseWallpaperTextColors) {
updateColors(
Utils.getColorAttr(mContext, R.attr.wallpaperTextColor),
Utils.getColorAttr(mContext, R.attr.wallpaperTextColorSecondary));
} else {
updateColors(mNonAdaptedForegroundColor, mNonAdaptedBackgroundColor);
}
}
public void setColorsFromContext(Context context) {
if (context == null) {
return;
@@ -179,7 +210,8 @@ public class BatteryMeterView extends LinearLayout implements
getContext().getContentResolver().registerContentObserver(
Settings.System.getUriFor(SHOW_BATTERY_PERCENT), false, mSettingObserver, mUser);
updateShowPercent();
Dependency.get(TunerService.class).addTunable(this, StatusBarIconController.ICON_BLACKLIST);
Dependency.get(TunerService.class)
.addTunable(this, StatusBarIconController.ICON_BLACKLIST);
Dependency.get(ConfigurationController.class).addCallback(this);
mUserTracker.startTracking();
}
@@ -273,19 +305,23 @@ public class BatteryMeterView extends LinearLayout implements
@Override
public void onDarkChanged(Rect area, float darkIntensity, int tint) {
mDarkIntensity = darkIntensity;
float intensity = DarkIconDispatcher.isInArea(area, this) ? darkIntensity : 0;
int foreground = getColorForDarkIntensity(intensity, mLightModeFillColor,
mDarkModeFillColor);
int background = getColorForDarkIntensity(intensity, mLightModeBackgroundColor,
mDarkModeBackgroundColor);
mDrawable.setColors(foreground, background);
setTextColor(foreground);
mNonAdaptedForegroundColor = getColorForDarkIntensity(
intensity, mLightModeFillColor, mDarkModeFillColor);
mNonAdaptedBackgroundColor = getColorForDarkIntensity(
intensity, mLightModeBackgroundColor,mDarkModeBackgroundColor);
if (!mUseWallpaperTextColors) {
updateColors(mNonAdaptedForegroundColor, mNonAdaptedBackgroundColor);
}
}
public void setTextColor(int color) {
mTextColor = color;
private void updateColors(int foregroundColor, int backgroundColor) {
mDrawable.setColors(foregroundColor, backgroundColor);
mTextColor = foregroundColor;
if (mBatteryPercentView != null) {
mBatteryPercentView.setTextColor(color);
mBatteryPercentView.setTextColor(foregroundColor);
}
}

View File

@@ -18,17 +18,15 @@ package com.android.systemui.qs;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.Point;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;
import com.android.settingslib.Utils;
import com.android.systemui.R;
import com.android.systemui.qs.customize.QSCustomizer;
import com.android.systemui.statusbar.ExpandableOutlineView;
/**
* Wrapper view with background which contains {@link QSPanel} and {@link BaseStatusBarHeader}
@@ -44,7 +42,11 @@ public class QSContainerImpl extends FrameLayout {
protected float mQsExpansion;
private QSCustomizer mQSCustomizer;
private View mQSFooter;
private View mBackground;
private View mBackgroundGradient;
private View mStatusBarBackground;
private int mSideMargins;
public QSContainerImpl(Context context, AttributeSet attrs) {
@@ -60,6 +62,8 @@ public class QSContainerImpl extends FrameLayout {
mQSCustomizer = findViewById(R.id.qs_customize);
mQSFooter = findViewById(R.id.qs_footer);
mBackground = findViewById(R.id.quick_settings_background);
mStatusBarBackground = findViewById(R.id.quick_settings_status_bar_background);
mBackgroundGradient = findViewById(R.id.quick_settings_gradient_view);
mSideMargins = getResources().getDimensionPixelSize(R.dimen.notification_side_paddings);
setClickable(true);
@@ -67,6 +71,22 @@ public class QSContainerImpl extends FrameLayout {
setMargins();
}
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Hide the backgrounds when in landscape mode.
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
mBackgroundGradient.setVisibility(View.INVISIBLE);
mStatusBarBackground.setVisibility(View.INVISIBLE);
} else {
mBackgroundGradient.setVisibility(View.VISIBLE);
mStatusBarBackground.setVisibility(View.VISIBLE);
}
updateResources();
}
@Override
public boolean performClick() {
// Want to receive clicks so missing QQS tiles doesn't cause collapse, but
@@ -101,6 +121,14 @@ public class QSContainerImpl extends FrameLayout {
updateExpansion();
}
private void updateResources() {
LayoutParams layoutParams = (LayoutParams) mQSPanel.getLayoutParams();
layoutParams.topMargin = mContext.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.quick_qs_offset_height);
mQSPanel.setLayoutParams(layoutParams);
}
/**
* Overrides the height of this view (post-layout), so that the content is clipped to that
* height and the background is set to that height.

View File

@@ -26,6 +26,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.Rect;
import android.media.AudioManager;
@@ -54,8 +55,10 @@ import com.android.systemui.statusbar.CommandQueue;
import com.android.systemui.statusbar.phone.PhoneStatusBarView;
import com.android.systemui.statusbar.phone.StatusBarIconController;
import com.android.systemui.statusbar.phone.StatusBarIconController.TintedIconManager;
import com.android.systemui.statusbar.policy.Clock;
import com.android.systemui.statusbar.policy.DarkIconDispatcher;
import com.android.systemui.statusbar.policy.DarkIconDispatcher.DarkReceiver;
import com.android.systemui.statusbar.policy.DateView;
import com.android.systemui.statusbar.policy.NextAlarmController;
import java.util.Locale;
@@ -90,6 +93,7 @@ public class QuickStatusBarHeader extends RelativeLayout implements CommandQueue
private TouchAnimator mStatusIconsAlphaAnimator;
private TouchAnimator mHeaderTextContainerAlphaAnimator;
private View mSystemIconsView;
private View mQuickQsStatusIcons;
private View mDate;
private View mHeaderTextContainerView;
@@ -107,6 +111,9 @@ public class QuickStatusBarHeader extends RelativeLayout implements CommandQueue
private View mStatusSeparator;
private ImageView mRingerModeIcon;
private TextView mRingerModeTextView;
private BatteryMeterView mBatteryMeterView;
private Clock mClockView;
private DateView mDateView;
private NextAlarmController mAlarmController;
/** Counts how many times the long press tooltip has been shown to the user. */
@@ -138,6 +145,7 @@ public class QuickStatusBarHeader extends RelativeLayout implements CommandQueue
mHeaderQsPanel = findViewById(R.id.quick_qs_panel);
mDate = findViewById(R.id.date);
mDate.setOnClickListener(this);
mSystemIconsView = findViewById(R.id.quick_status_bar_system_icons);
mQuickQsStatusIcons = findViewById(R.id.quick_qs_status_icons);
mIconManager = new TintedIconManager(findViewById(R.id.statusIcons));
@@ -164,8 +172,10 @@ public class QuickStatusBarHeader extends RelativeLayout implements CommandQueue
// Set the correct tint for the status icons so they contrast
mIconManager.setTint(fillColor);
BatteryMeterView battery = findViewById(R.id.battery);
battery.setForceShowPercent(true);
mBatteryMeterView = findViewById(R.id.battery);
mBatteryMeterView.setForceShowPercent(true);
mClockView = findViewById(R.id.clock);
mDateView = findViewById(R.id.date);
}
private void updateStatusText() {
@@ -212,6 +222,13 @@ public class QuickStatusBarHeader extends RelativeLayout implements CommandQueue
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
updateResources();
// Update color schemes in landscape to use wallpaperTextColor
boolean shouldUseWallpaperTextColor =
newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE;
mBatteryMeterView.useWallpaperTextColor(shouldUseWallpaperTextColor);
mClockView.useWallpaperTextColor(shouldUseWallpaperTextColor);
mDateView.useWallpaperTextColor(shouldUseWallpaperTextColor);
}
@Override
@@ -221,11 +238,21 @@ public class QuickStatusBarHeader extends RelativeLayout implements CommandQueue
}
private void updateResources() {
// Update height, especially due to landscape mode restricting space.
Resources resources = mContext.getResources();
// Update height for a few views, especially due to landscape mode restricting space.
mHeaderTextContainerView.getLayoutParams().height =
mContext.getResources().getDimensionPixelSize(R.dimen.qs_header_tooltip_height);
resources.getDimensionPixelSize(R.dimen.qs_header_tooltip_height);
mHeaderTextContainerView.setLayoutParams(mHeaderTextContainerView.getLayoutParams());
mSystemIconsView.getLayoutParams().height = resources.getDimensionPixelSize(
com.android.internal.R.dimen.quick_qs_offset_height);
mSystemIconsView.setLayoutParams(mSystemIconsView.getLayoutParams());
getLayoutParams().height =
resources.getDimensionPixelSize(com.android.internal.R.dimen.quick_qs_total_height);
setLayoutParams(getLayoutParams());
updateStatusIconAlphaAnimator();
updateHeaderTextContainerAlphaAnimator();
}
@@ -497,9 +524,8 @@ public class QuickStatusBarHeader extends RelativeLayout implements CommandQueue
mHeaderQsPanel.setHost(host, null /* No customization in header */);
// Use SystemUI context to get battery meter colors, and let it use the default tint (white)
BatteryMeterView battery = findViewById(R.id.battery);
battery.setColorsFromContext(mHost.getContext());
battery.onDarkChanged(new Rect(), 0, DarkIconDispatcher.DEFAULT_ICON_TINT);
mBatteryMeterView.setColorsFromContext(mHost.getContext());
mBatteryMeterView.onDarkChanged(new Rect(), 0, DarkIconDispatcher.DEFAULT_ICON_TINT);
}
public void setCallback(Callback qsPanelCallback) {

View File

@@ -85,7 +85,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
/**
* Default alpha value for most scrims.
*/
public static final float GRADIENT_SCRIM_ALPHA = 0.45f;
public static final float GRADIENT_SCRIM_ALPHA = 0.70f;
/**
* A scrim varies its opacity based on a busyness factor, for example
* how many notifications are currently visible.

View File

@@ -40,6 +40,7 @@ import android.view.Display;
import android.view.View;
import android.widget.TextView;
import com.android.settingslib.Utils;
import com.android.systemui.DemoMode;
import com.android.systemui.Dependency;
import com.android.systemui.FontSizeUtils;
@@ -84,6 +85,17 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
private boolean mShowSeconds;
private Handler mSecondsHandler;
/**
* Whether we should use colors that adapt based on wallpaper/the scrim behind quick settings
* for text.
*/
private boolean mUseWallpaperTextColor;
/**
* Color to be set on this {@link TextView}, when wallpaperTextColor is <b>not</b> utilized.
*/
private int mNonAdaptedColor;
public Clock(Context context) {
this(context, null);
}
@@ -101,6 +113,7 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
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();
}
@@ -227,7 +240,10 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
@Override
public void onDarkChanged(Rect area, float darkIntensity, int tint) {
setTextColor(DarkIconDispatcher.getTint(area, this, tint));
mNonAdaptedColor = DarkIconDispatcher.getTint(area, this, tint);
if (!mUseWallpaperTextColor) {
setTextColor(mNonAdaptedColor);
}
}
@Override
@@ -242,6 +258,25 @@ public class Clock extends TextView implements DemoMode, Tunable, CommandQueue.C
0);
}
/**
* Sets whether the clock uses the wallpaperTextColor. If we're not using it, we'll revert back
* to dark-mode-based/tinted colors.
*
* @param shouldUseWallpaperTextColor whether we should use wallpaperTextColor for text color
*/
public void useWallpaperTextColor(boolean shouldUseWallpaperTextColor) {
if (shouldUseWallpaperTextColor == mUseWallpaperTextColor) {
return;
}
mUseWallpaperTextColor = shouldUseWallpaperTextColor;
if (mUseWallpaperTextColor) {
setTextColor(Utils.getColorAttr(mContext, R.attr.wallpaperTextColor));
} else {
setTextColor(mNonAdaptedColor);
}
}
private void updateShowSeconds() {
if (mShowSeconds) {
// Wait until we have a display to start trying to show seconds.

View File

@@ -27,6 +27,7 @@ import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.TextView;
import com.android.settingslib.Utils;
import com.android.systemui.Dependency;
import com.android.systemui.R;
@@ -42,6 +43,17 @@ public class DateView extends TextView {
private String mLastText;
private String mDatePattern;
/**
* Whether we should use colors that adapt based on wallpaper/the scrim behind quick settings
* for text.
*/
private boolean mUseWallpaperTextColor;
/**
* Color to be set on this {@link TextView}, when wallpaperTextColor is <b>not</b> utilized.
*/
private int mNonAdaptedTextColor;
private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
@@ -62,6 +74,7 @@ public class DateView extends TextView {
public DateView(Context context, AttributeSet attrs) {
super(context, attrs);
mNonAdaptedTextColor = getCurrentTextColor();
TypedArray a = context.getTheme().obtainStyledAttributes(
attrs,
R.styleable.DateView,
@@ -117,6 +130,25 @@ public class DateView extends TextView {
}
}
/**
* Sets whether the date view uses the wallpaperTextColor. If we're not using it, we'll revert
* back to dark-mode-based/tinted colors.
*
* @param shouldUseWallpaperTextColor whether we should use wallpaperTextColor for text color
*/
public void useWallpaperTextColor(boolean shouldUseWallpaperTextColor) {
if (shouldUseWallpaperTextColor == mUseWallpaperTextColor) {
return;
}
mUseWallpaperTextColor = shouldUseWallpaperTextColor;
if (mUseWallpaperTextColor) {
setTextColor(Utils.getColorAttr(mContext, R.attr.wallpaperTextColor));
} else {
setTextColor(mNonAdaptedTextColor);
}
}
public void setDatePattern(String pattern) {
if (TextUtils.equals(pattern, mDatePattern)) {
return;

View File

@@ -0,0 +1,22 @@
<!--
~ Copyright (C) 2018 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
-->
<resources>
<!-- Can't link to other dimensions here, but this should be status_bar_height_landscape -->
<dimen name="quick_qs_offset_height">28dp</dimen>
<!-- Total height of QQS in landscape; quick_qs_offset_height + 128 -->
<dimen name="quick_qs_total_height">156dp</dimen>
</resources>

View File

@@ -0,0 +1,22 @@
<!--
~ Copyright (C) 2018 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
-->
<resources>
<!-- Can't link to other dimensions here, but this should be status_bar_height_landscape -->
<dimen name="quick_qs_offset_height">28dp</dimen>
<!-- Total height of QQS in landscape; quick_qs_offset_height + 128 -->
<dimen name="quick_qs_total_height">156dp</dimen>
</resources>

View File

@@ -0,0 +1,22 @@
<!--
~ Copyright (C) 2018 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
-->
<resources>
<!-- Can't link to other dimensions here, but this should be status_bar_height_landscape -->
<dimen name="quick_qs_offset_height">28dp</dimen>
<!-- Total height of QQS in landscape; quick_qs_offset_height + 128 -->
<dimen name="quick_qs_total_height">156dp</dimen>
</resources>

View File

@@ -0,0 +1,22 @@
<!--
~ Copyright (C) 2018 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
-->
<resources>
<!-- Can't link to other dimensions here, but this should be status_bar_height_landscape -->
<dimen name="quick_qs_offset_height">28dp</dimen>
<!-- Total height of QQS in landscape; quick_qs_offset_height + 128 -->
<dimen name="quick_qs_total_height">156dp</dimen>
</resources>

View File

@@ -0,0 +1,22 @@
<!--
~ Copyright (C) 2018 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
-->
<resources>
<!-- Can't link to other dimensions here, but this should be status_bar_height_landscape -->
<dimen name="quick_qs_offset_height">28dp</dimen>
<!-- Total height of QQS in landscape; quick_qs_offset_height + 128 -->
<dimen name="quick_qs_total_height">156dp</dimen>
</resources>