Skip to content

Commit eff38e1

Browse files
trautamakiGenkzsz11
authored andcommitted
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: Timi Rautamäki <timi.rautamaki@gmail.com> Change-Id: I4320e46a14e671e1176da14f8210604c7c9470d2
1 parent 5a11d07 commit eff38e1

4 files changed

Lines changed: 26 additions & 1 deletion

File tree

packages/SystemUI/res/layout/global_actions_grid_item_v2.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@
3333
android:id="@*android:id/icon"
3434
android:layout_width="20dp"
3535
android:layout_height="20dp"
36-
android:layout_marginBottom="14dp"
3736
android:scaleType="centerInside"
3837
android:tint="@color/control_primary_text" />
3938
<TextView
4039
android:id="@*android:id/message"
4140
android:layout_width="match_parent"
4241
android:layout_height="wrap_content"
42+
android:layout_marginTop="@dimen/global_actions_power_dialog_message_top_margin"
4343
android:ellipsize="end"
4444
android:marqueeRepeatLimit="marquee_forever"
4545
android:maxLines="2"

packages/SystemUI/res/values/dimens.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,9 @@
10551055
<dimen name="global_actions_power_dialog_item_width">135dp</dimen>
10561056
<dimen name="global_actions_power_dialog_item_bottom_margin">14dp</dimen>
10571057

1058+
<dimen name="global_actions_power_dialog_message_top_margin">15dp</dimen>
1059+
<dimen name="global_actions_power_dialog_twoline_message_top_margin">0dp</dimen>
1060+
10581061
<!-- The maximum offset in either direction that elements are moved horizontally to prevent
10591062
burn-in on AOD. -->
10601063
<dimen name="burn_in_prevention_offset_x">8dp</dimen>

packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsFlatLayout.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
9090
if (child instanceof GlobalActionsItem) {
9191
GlobalActionsItem item = (GlobalActionsItem) child;
9292
anyTruncated = anyTruncated || item.isTruncated();
93+
item.setMessageMargin();
9394
}
9495
}
9596
// If any of the items have been truncated, set the all to single-line marquee

packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsItem.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import android.text.TextUtils;
2222
import android.util.AttributeSet;
2323
import android.widget.LinearLayout;
24+
import android.widget.LinearLayout.LayoutParams;
2425
import android.widget.TextView;
2526

2627
import com.android.internal.R;
@@ -54,6 +55,26 @@ public void setMarquee(boolean marquee) {
5455
text.setEllipsize(marquee ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END);
5556
}
5657

58+
/**
59+
* Sets message top margin depending on linecount
60+
*/
61+
public void setMessageMargin() {
62+
TextView message = findViewById(R.id.message);
63+
64+
if (message != null) {
65+
LayoutParams params = (LinearLayout.LayoutParams) message.getLayoutParams();
66+
int marginTop = (int) getResources().getDimension(getTextView().getLineCount() > 1
67+
? com.android.systemui.R.dimen
68+
.global_actions_power_dialog_twoline_message_top_margin
69+
: com.android.systemui.R.dimen
70+
.global_actions_power_dialog_message_top_margin);
71+
72+
params.setMargins(params.leftMargin, marginTop, params.rightMargin,
73+
params.bottomMargin);
74+
message.setLayoutParams(params);
75+
}
76+
}
77+
5778
/**
5879
* Determines whether the message for this item has been truncated.
5980
*/

0 commit comments

Comments
 (0)