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

Commit 2269a328 authored by Timi's avatar Timi Committed by Rashed Abdel-Tawab
Browse files

SystemUI: global actions: fix icon position on multi-line action



Some languages (such as Finnish) have reboot text over 2 lines.
Set the top margin of the message to 0dp when there is more than
1 line of text and to 14dp when there is only 1 line.
Fixes issue where icon is not inline  with other icons on a tile
with multi-line message.

Test: verify icons are aligned on different dpi's in power menu.

Signed-off-by: default avatarTimi Rautamäki <timi.rautamaki@gmail.com>
Change-Id: I4320e46a14e671e1176da14f8210604c7c9470d2
parent 1f0ac7f7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -33,13 +33,13 @@
            android:id="@*android:id/icon"
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:layout_marginBottom="14dp"
            android:scaleType="centerInside"
            android:tint="@color/control_primary_text" />
        <TextView
            android:id="@*android:id/message"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="@dimen/global_actions_power_dialog_message_top_margin"
            android:ellipsize="end"
            android:marqueeRepeatLimit="marquee_forever"
            android:maxLines="2"
+3 −0
Original line number Diff line number Diff line
@@ -1072,6 +1072,9 @@
    <dimen name="global_actions_power_dialog_item_width">128dp</dimen>
    <dimen name="global_actions_power_dialog_item_bottom_margin">22dp</dimen>

    <dimen name="global_actions_power_dialog_message_top_margin">15dp</dimen>
    <dimen name="global_actions_power_dialog_twoline_message_top_margin">0dp</dimen>

    <!-- The maximum offset in either direction that elements are moved horizontally to prevent
         burn-in on AOD. -->
    <dimen name="burn_in_prevention_offset_x">8dp</dimen>
+1 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ public class GlobalActionsFlatLayout extends GlobalActionsLayout {
            if (child instanceof GlobalActionsItem) {
                GlobalActionsItem item = (GlobalActionsItem) child;
                anyTruncated = anyTruncated || item.isTruncated();
                item.setMessageMargin();
            }
        }
        // If any of the items have been truncated, set the all to single-line marquee
+21 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.text.Layout;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;

import com.android.internal.R;
@@ -54,6 +55,26 @@ public class GlobalActionsItem extends LinearLayout {
        text.setEllipsize(marquee ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END);
    }

    /**
     * Sets message top margin depending on linecount
     */
    public void setMessageMargin() {
        TextView message = findViewById(R.id.message);

        if (message != null) {
            LayoutParams params = (LinearLayout.LayoutParams) message.getLayoutParams();
            int marginTop = (int) getResources().getDimension(getTextView().getLineCount() > 1
                    ? com.android.systemui.R.dimen
                            .global_actions_power_dialog_twoline_message_top_margin
                    : com.android.systemui.R.dimen
                            .global_actions_power_dialog_message_top_margin);

            params.setMargins(params.leftMargin, marginTop, params.rightMargin,
                    params.bottomMargin);
            message.setLayoutParams(params);
        }
    }

    /**
     * Determines whether the message for this item has been truncated.
     */