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

Commit 7d779b68 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[Dock Defend] Ensure the bottom of the battery icon is always aligned

with the bottom of the other icons, even if the shield is displayed.

Bug: 255625888
Test: manual: Verify battery icon bottom stays aligned with other icon
bottoms both with and without the shield. See video attached to bug.
Change-Id: Ib203e8ce27d515a177e8371958fa43ecf8b20e74

Change-Id: I1d8c53cc2beae90f6dca14cf339733bfb085a56e
parent 1b65e523
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -105,6 +105,12 @@
    so the width of the icon should be 13.0dp * (12.0 / 20.0) -->
    <dimen name="status_bar_battery_icon_width">7.8dp</dimen>

    <!-- The battery icon is 13dp tall, but the other system icons are 15dp tall (see
         @*android:dimen/status_bar_system_icon_size) with some top and bottom padding embedded in
         the drawables themselves. So, the battery icon may need an extra 1dp of spacing so that its
         bottom still aligns with the bottom of all the other system icons. See b/258672854. -->
    <dimen name="status_bar_battery_extra_vertical_spacing">1dp</dimen>

    <!-- The font size for the clock in the status bar. -->
    <dimen name="status_bar_clock_size">14sp</dimen>

+15 −3
Original line number Diff line number Diff line
@@ -378,14 +378,26 @@ public class BatteryMeterView extends LinearLayout implements DarkReceiver {
        float fullBatteryIconWidth =
                BatterySpecs.getFullBatteryWidth(mainBatteryWidth, displayShield);

        // TODO(b/255625888): Add some marginTop so that, even when the battery icon has the shield,
        //   the bottom of the main icon is still aligned with the bottom of all the other icons.
        int marginTop;
        if (displayShield) {
            // If the shield is displayed, we need some extra marginTop so that the bottom of the
            // main icon is still aligned with the bottom of all the other system icons.
            int shieldHeightAddition = Math.round(fullBatteryIconHeight - mainBatteryHeight);
            // However, the other system icons have some embedded bottom padding that the battery
            // doesn't have, so we shouldn't move the battery icon down by the full amount.
            // See b/258672854.
            marginTop = shieldHeightAddition
                    - res.getDimensionPixelSize(R.dimen.status_bar_battery_extra_vertical_spacing);
        } else {
            marginTop = 0;
        }

        int marginBottom = res.getDimensionPixelSize(R.dimen.battery_margin_bottom);

        LinearLayout.LayoutParams scaledLayoutParams = new LinearLayout.LayoutParams(
                Math.round(fullBatteryIconWidth),
                Math.round(fullBatteryIconHeight));
        scaledLayoutParams.setMargins(0, 0, 0, marginBottom);
        scaledLayoutParams.setMargins(0, marginTop, 0, marginBottom);

        mDrawable.setDisplayShield(displayShield);
        mBatteryIconView.setLayoutParams(scaledLayoutParams);