Merge "Save space in small width screens" into sc-dev

This commit is contained in:
Fabian Kozynski
2021-07-28 13:23:49 +00:00
committed by Android (Google) Code Review
4 changed files with 45 additions and 3 deletions

View File

@@ -0,0 +1,19 @@
<!--
~ 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.
-->
<resources>
<bool name="config_showBatteryEstimateQSBH">true</bool>
</resources>

View File

@@ -539,6 +539,11 @@
<item>@*android:string/status_bar_headset</item>
</string-array>
<!-- Whether to show estimate in QS header. Default to false in case there's not enough
space -->
<bool name="config_showBatteryEstimateQSBH">false</bool>
<!-- A path similar to frameworks/base/core/res/res/values/config.xml
config_mainBuiltInDisplayCutout that describes a path larger than the exact path of a display
cutout. If present as well as config_enableDisplayCutoutProtection is set to true, then

View File

@@ -195,6 +195,7 @@ public class BatteryMeterView extends LinearLayout implements
* @param mode desired mode (none, on, off)
*/
public void setPercentShowMode(@BatteryPercentMode int mode) {
if (mode == mShowPercentMode) return;
mShowPercentMode = mode;
updateShowPercent();
}
@@ -330,7 +331,7 @@ public class BatteryMeterView extends LinearLayout implements
if (mBatteryPercentView == null) {
return;
}
if (estimate != null) {
if (estimate != null && mShowPercentMode == MODE_ESTIMATE) {
mBatteryPercentView.setText(estimate);
setContentDescription(getContext().getString(
R.string.accessibility_battery_level_with_estimate,
@@ -485,6 +486,7 @@ public class BatteryMeterView extends LinearLayout implements
pw.println(" mTextColor: #" + Integer.toHexString(mTextColor));
pw.println(" mBatteryStateUnknown: " + mBatteryStateUnknown);
pw.println(" mLevel: " + mLevel);
pw.println(" mMode: " + mShowPercentMode);
}
private final class SettingObserver extends ContentObserver {

View File

@@ -95,6 +95,9 @@ public class QuickStatusBarHeader extends FrameLayout {
private List<String> mRssiIgnoredSlots;
private boolean mIsSingleCarrier;
private boolean mHasCenterCutout;
private boolean mConfigShowBatteryEstimate;
public QuickStatusBarHeader(Context context, AttributeSet attrs) {
super(context, attrs);
}
@@ -203,9 +206,19 @@ public class QuickStatusBarHeader extends FrameLayout {
mPrivacyContainer.setLayoutParams(lp);
}
private void updateBatteryMode() {
if (mConfigShowBatteryEstimate && !mHasCenterCutout) {
mBatteryRemainingIcon.setPercentShowMode(BatteryMeterView.MODE_ESTIMATE);
} else {
mBatteryRemainingIcon.setPercentShowMode(BatteryMeterView.MODE_ON);
}
}
void updateResources() {
Resources resources = mContext.getResources();
mConfigShowBatteryEstimate = resources.getBoolean(R.bool.config_showBatteryEstimateQSBH);
mRoundedCornerPadding = resources.getDimensionPixelSize(
R.dimen.rounded_corner_content_padding);
@@ -246,6 +259,7 @@ public class QuickStatusBarHeader extends FrameLayout {
.getDimensionPixelSize(R.dimen.qqs_layout_margin_top);
mHeaderQsPanel.setLayoutParams(qqsLP);
updateBatteryMode();
updateHeadersPadding();
updateAnimators();
}
@@ -384,14 +398,14 @@ public class QuickStatusBarHeader extends FrameLayout {
mClockIconsSeparatorLayoutParams.width = 0;
setSeparatorVisibility(false);
mShowClockIconsSeparator = false;
mBatteryRemainingIcon.setPercentShowMode(BatteryMeterView.MODE_ESTIMATE);
mHasCenterCutout = false;
} else {
datePrivacySeparatorLayoutParams.width = topCutout.width();
mDatePrivacySeparator.setVisibility(View.VISIBLE);
mClockIconsSeparatorLayoutParams.width = topCutout.width();
mShowClockIconsSeparator = true;
setSeparatorVisibility(mKeyguardExpansionFraction == 0f);
mBatteryRemainingIcon.setPercentShowMode(BatteryMeterView.MODE_ON);
mHasCenterCutout = true;
}
}
mDatePrivacySeparator.setLayoutParams(datePrivacySeparatorLayoutParams);
@@ -399,6 +413,8 @@ public class QuickStatusBarHeader extends FrameLayout {
mCutOutPaddingLeft = padding.first;
mCutOutPaddingRight = padding.second;
mWaterfallTopInset = cutout == null ? 0 : cutout.getWaterfallInsets().top;
updateBatteryMode();
updateHeadersPadding();
return super.onApplyWindowInsets(insets);
}