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

Commit 2515eb25 authored by Roy Chou's avatar Roy Chou
Browse files

fix(non linear font scaling): clock & battery textviews might be cutoff in...

fix(non linear font scaling): clock & battery textviews might be cutoff in status bar when larger font size

Originally the clock and battery textviews contain inner padding. With larger font scaling and limited status bar height, the space would not be enough for the text and the padding in textview, then the top padding would cause the text to not be able to display center vertically, so it might look shifted down or even cutoff. Therefore, we adjust the textview line height and layout param height to only contain the font height, then the inner padding should be elimitated and the text should display center vertically.

Besides, when density (display size) is changed, the status bar view and the internal clock are not notified, then the clock height could not update in time. Therefore, we fix the notify-path so that the PhoneStatusBarViewController can detect the config changed then notify the status bar view and the clock.

Bug: 298064328
Bug: 291168760
Test: manually - attached videos in bug
      atest packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/
      atest SystemUIGoogleScreenshotTests
      atest ClockTest
Change-Id: I653584d5963b38ce2ef2ba05ca9df63280aac128
Merged-In: I653584d5963b38ce2ef2ba05ca9df63280aac128
parent cd15fed5
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -27,4 +27,5 @@
        android:gravity="center_vertical|start"
        android:gravity="center_vertical|start"
        android:paddingStart="@dimen/battery_level_padding_start"
        android:paddingStart="@dimen/battery_level_padding_start"
        android:importantForAccessibility="no"
        android:importantForAccessibility="no"
        android:includeFontPadding="false"
        />
        />
+3 −2
Original line number Original line Diff line number Diff line
@@ -25,7 +25,8 @@
    <LinearLayout
    <LinearLayout
        android:id="@+id/rounded_container"
        android:id="@+id/rounded_container"
        android:layout_width="wrap_content"
        android:layout_width="wrap_content"
        android:layout_height="@dimen/ongoing_appops_chip_height"
        android:layout_height="wrap_content"
        android:minHeight="@dimen/ongoing_appops_chip_height"
        android:layout_gravity="center"
        android:layout_gravity="center"
        android:background="@drawable/statusbar_chip_bg"
        android:background="@drawable/statusbar_chip_bg"
        android:clipToOutline="true"
        android:clipToOutline="true"
@@ -36,7 +37,7 @@
        <com.android.systemui.battery.BatteryMeterView
        <com.android.systemui.battery.BatteryMeterView
            android:id="@+id/battery_meter_view"
            android:id="@+id/battery_meter_view"
            android:layout_width="wrap_content"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginHorizontal="10dp" />
            android:layout_marginHorizontal="10dp" />


    </LinearLayout>
    </LinearLayout>
+1 −0
Original line number Original line Diff line number Diff line
@@ -79,6 +79,7 @@
                    android:id="@+id/status_bar_start_side_except_heads_up"
                    android:id="@+id/status_bar_start_side_except_heads_up"
                    android:layout_height="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_width="match_parent"
                    android:layout_width="match_parent"
                    android:layout_gravity="center_vertical|start"
                    android:clipChildren="false">
                    android:clipChildren="false">
                    <ViewStub
                    <ViewStub
                        android:id="@+id/operator_name"
                        android:id="@+id/operator_name"
+3 −1
Original line number Original line Diff line number Diff line
@@ -354,11 +354,13 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver {
                if (mPercentageStyleId != 0) { // Only set if specified as attribute
                if (mPercentageStyleId != 0) { // Only set if specified as attribute
                    mBatteryPercentView.setTextAppearance(mPercentageStyleId);
                    mBatteryPercentView.setTextAppearance(mPercentageStyleId);
                }
                }
                float fontHeight = mBatteryPercentView.getPaint().getFontMetricsInt(null);
                mBatteryPercentView.setLineHeight(TypedValue.COMPLEX_UNIT_PX, fontHeight);
                if (mTextColor != 0) mBatteryPercentView.setTextColor(mTextColor);
                if (mTextColor != 0) mBatteryPercentView.setTextColor(mTextColor);
                updatePercentText();
                updatePercentText();
                addView(mBatteryPercentView, new LayoutParams(
                addView(mBatteryPercentView, new LayoutParams(
                        LayoutParams.WRAP_CONTENT,
                        LayoutParams.WRAP_CONTENT,
                        LayoutParams.WRAP_CONTENT));
                        (int) Math.ceil(fontHeight)));
            }
            }
        } else {
        } else {
            if (showing) {
            if (showing) {
+6 −1
Original line number Original line Diff line number Diff line
@@ -40,6 +40,7 @@ import com.android.systemui.R;
import com.android.systemui.plugins.DarkIconDispatcher;
import com.android.systemui.plugins.DarkIconDispatcher;
import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
import com.android.systemui.plugins.DarkIconDispatcher.DarkReceiver;
import com.android.systemui.statusbar.phone.userswitcher.StatusBarUserSwitcherContainer;
import com.android.systemui.statusbar.phone.userswitcher.StatusBarUserSwitcherContainer;
import com.android.systemui.statusbar.policy.Clock;
import com.android.systemui.user.ui.binder.StatusBarUserChipViewBinder;
import com.android.systemui.user.ui.binder.StatusBarUserChipViewBinder;
import com.android.systemui.user.ui.viewmodel.StatusBarUserChipViewModel;
import com.android.systemui.user.ui.viewmodel.StatusBarUserChipViewModel;
import com.android.systemui.util.leak.RotationUtils;
import com.android.systemui.util.leak.RotationUtils;
@@ -51,7 +52,7 @@ public class PhoneStatusBarView extends FrameLayout {
    private final StatusBarContentInsetsProvider mContentInsetsProvider;
    private final StatusBarContentInsetsProvider mContentInsetsProvider;


    private DarkReceiver mBattery;
    private DarkReceiver mBattery;
    private DarkReceiver mClock;
    private Clock mClock;
    private int mRotationOrientation = -1;
    private int mRotationOrientation = -1;
    @Nullable
    @Nullable
    private View mCutoutSpace;
    private View mCutoutSpace;
@@ -123,6 +124,10 @@ public class PhoneStatusBarView extends FrameLayout {
        }
        }
    }
    }


    void onDensityOrFontScaleChanged() {
        mClock.onDensityOrFontScaleChanged();
    }

    @Override
    @Override
    public WindowInsets onApplyWindowInsets(WindowInsets insets) {
    public WindowInsets onApplyWindowInsets(WindowInsets insets) {
        if (updateDisplayParameters()) {
        if (updateDisplayParameters()) {
Loading