Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 10fc0e66 authored by Fabian Kozynski's avatar Fabian Kozynski Committed by Automerger Merge Worker
Browse files

Merge "Save space in small width screens" into sc-dev am: 842ebcdb

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15377398

Change-Id: Ic453ae258ce0889005182a225ef82fc8231e0a5f
parents 569f1109 842ebcdb
Loading
Loading
Loading
Loading
+19 −0
Original line number Original line Diff line number Diff line
<!--
  ~ 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>
 No newline at end of file
+5 −0
Original line number Original line Diff line number Diff line
@@ -542,6 +542,11 @@
        <item>@*android:string/status_bar_headset</item>
        <item>@*android:string/status_bar_headset</item>
    </string-array>
    </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
    <!-- 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
      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
      cutout. If present as well as config_enableDisplayCutoutProtection is set to true, then
+3 −1
Original line number Original line Diff line number Diff line
@@ -196,6 +196,7 @@ public class BatteryMeterView extends LinearLayout implements
     * @param mode desired mode (none, on, off)
     * @param mode desired mode (none, on, off)
     */
     */
    public void setPercentShowMode(@BatteryPercentMode int mode) {
    public void setPercentShowMode(@BatteryPercentMode int mode) {
        if (mode == mShowPercentMode) return;
        mShowPercentMode = mode;
        mShowPercentMode = mode;
        updateShowPercent();
        updateShowPercent();
    }
    }
@@ -331,7 +332,7 @@ public class BatteryMeterView extends LinearLayout implements
                    if (mBatteryPercentView == null) {
                    if (mBatteryPercentView == null) {
                        return;
                        return;
                    }
                    }
                    if (estimate != null) {
                    if (estimate != null && mShowPercentMode == MODE_ESTIMATE) {
                        mBatteryPercentView.setText(estimate);
                        mBatteryPercentView.setText(estimate);
                        setContentDescription(getContext().getString(
                        setContentDescription(getContext().getString(
                                R.string.accessibility_battery_level_with_estimate,
                                R.string.accessibility_battery_level_with_estimate,
@@ -486,6 +487,7 @@ public class BatteryMeterView extends LinearLayout implements
        pw.println("    mTextColor: #" + Integer.toHexString(mTextColor));
        pw.println("    mTextColor: #" + Integer.toHexString(mTextColor));
        pw.println("    mBatteryStateUnknown: " + mBatteryStateUnknown);
        pw.println("    mBatteryStateUnknown: " + mBatteryStateUnknown);
        pw.println("    mLevel: " + mLevel);
        pw.println("    mLevel: " + mLevel);
        pw.println("    mMode: " + mShowPercentMode);
    }
    }


    private final class SettingObserver extends ContentObserver {
    private final class SettingObserver extends ContentObserver {
+18 −2
Original line number Original line Diff line number Diff line
@@ -93,6 +93,9 @@ public class QuickStatusBarHeader extends FrameLayout {
    private List<String> mRssiIgnoredSlots;
    private List<String> mRssiIgnoredSlots;
    private boolean mIsSingleCarrier;
    private boolean mIsSingleCarrier;


    private boolean mHasCenterCutout;
    private boolean mConfigShowBatteryEstimate;

    public QuickStatusBarHeader(Context context, AttributeSet attrs) {
    public QuickStatusBarHeader(Context context, AttributeSet attrs) {
        super(context, attrs);
        super(context, attrs);
    }
    }
@@ -200,6 +203,14 @@ public class QuickStatusBarHeader extends FrameLayout {
        mPrivacyContainer.setLayoutParams(lp);
        mPrivacyContainer.setLayoutParams(lp);
    }
    }


    private void updateBatteryMode() {
        if (mConfigShowBatteryEstimate && !mHasCenterCutout) {
            mBatteryRemainingIcon.setPercentShowMode(BatteryMeterView.MODE_ESTIMATE);
        } else {
            mBatteryRemainingIcon.setPercentShowMode(BatteryMeterView.MODE_ON);
        }
    }

    void updateResources() {
    void updateResources() {
        Resources resources = mContext.getResources();
        Resources resources = mContext.getResources();
        // status bar is already displayed out of QS in split shade
        // status bar is already displayed out of QS in split shade
@@ -208,6 +219,8 @@ public class QuickStatusBarHeader extends FrameLayout {
        mStatusIconsView.setVisibility(shouldUseSplitShade ? View.GONE : View.VISIBLE);
        mStatusIconsView.setVisibility(shouldUseSplitShade ? View.GONE : View.VISIBLE);
        mDatePrivacyView.setVisibility(shouldUseSplitShade ? View.GONE : View.VISIBLE);
        mDatePrivacyView.setVisibility(shouldUseSplitShade ? View.GONE : View.VISIBLE);


        mConfigShowBatteryEstimate = resources.getBoolean(R.bool.config_showBatteryEstimateQSBH);

        mRoundedCornerPadding = resources.getDimensionPixelSize(
        mRoundedCornerPadding = resources.getDimensionPixelSize(
                R.dimen.rounded_corner_content_padding);
                R.dimen.rounded_corner_content_padding);


@@ -248,6 +261,7 @@ public class QuickStatusBarHeader extends FrameLayout {
                .getDimensionPixelSize(R.dimen.qqs_layout_margin_top);
                .getDimensionPixelSize(R.dimen.qqs_layout_margin_top);
        mHeaderQsPanel.setLayoutParams(qqsLP);
        mHeaderQsPanel.setLayoutParams(qqsLP);


        updateBatteryMode();
        updateHeadersPadding();
        updateHeadersPadding();
        updateAnimators();
        updateAnimators();
    }
    }
@@ -386,14 +400,14 @@ public class QuickStatusBarHeader extends FrameLayout {
                mClockIconsSeparatorLayoutParams.width = 0;
                mClockIconsSeparatorLayoutParams.width = 0;
                setSeparatorVisibility(false);
                setSeparatorVisibility(false);
                mShowClockIconsSeparator = false;
                mShowClockIconsSeparator = false;
                mBatteryRemainingIcon.setPercentShowMode(BatteryMeterView.MODE_ESTIMATE);
                mHasCenterCutout = false;
            } else {
            } else {
                datePrivacySeparatorLayoutParams.width = topCutout.width();
                datePrivacySeparatorLayoutParams.width = topCutout.width();
                mDatePrivacySeparator.setVisibility(View.VISIBLE);
                mDatePrivacySeparator.setVisibility(View.VISIBLE);
                mClockIconsSeparatorLayoutParams.width = topCutout.width();
                mClockIconsSeparatorLayoutParams.width = topCutout.width();
                mShowClockIconsSeparator = true;
                mShowClockIconsSeparator = true;
                setSeparatorVisibility(mKeyguardExpansionFraction == 0f);
                setSeparatorVisibility(mKeyguardExpansionFraction == 0f);
                mBatteryRemainingIcon.setPercentShowMode(BatteryMeterView.MODE_ON);
                mHasCenterCutout = true;
            }
            }
        }
        }
        mDatePrivacySeparator.setLayoutParams(datePrivacySeparatorLayoutParams);
        mDatePrivacySeparator.setLayoutParams(datePrivacySeparatorLayoutParams);
@@ -401,6 +415,8 @@ public class QuickStatusBarHeader extends FrameLayout {
        mCutOutPaddingLeft = padding.first;
        mCutOutPaddingLeft = padding.first;
        mCutOutPaddingRight = padding.second;
        mCutOutPaddingRight = padding.second;
        mWaterfallTopInset = cutout == null ? 0 : cutout.getWaterfallInsets().top;
        mWaterfallTopInset = cutout == null ? 0 : cutout.getWaterfallInsets().top;

        updateBatteryMode();
        updateHeadersPadding();
        updateHeadersPadding();
        return super.onApplyWindowInsets(insets);
        return super.onApplyWindowInsets(insets);
    }
    }