Loading packages/SystemUI/res/layout/global_actions_grid_item_v2.xml +3 −5 Original line number Diff line number Diff line Loading @@ -14,9 +14,7 @@ limitations under the License. --> <!-- RelativeLayouts have an issue enforcing minimum heights, so just work around this for now with LinearLayouts. --> <LinearLayout <com.android.systemui.globalactions.GlobalActionsItem xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="0dp" android:layout_weight="1" Loading @@ -42,7 +40,7 @@ android:id="@*android:id/message" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="marquee" android:ellipsize="end" android:marqueeRepeatLimit="marquee_forever" android:maxLines="2" android:textSize="12sp" Loading @@ -51,4 +49,4 @@ android:breakStrategy="high_quality" android:hyphenationFrequency="full" android:textAppearance="?android:attr/textAppearanceSmall" /> </LinearLayout> </com.android.systemui.globalactions.GlobalActionsItem> packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsFlatLayout.java +26 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static com.android.systemui.util.leak.RotationUtils.ROTATION_SEASCAPE; import android.content.Context; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.HardwareBgDrawable; Loading Loading @@ -78,6 +79,31 @@ public class GlobalActionsFlatLayout extends GlobalActionsLayout { } } @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); boolean anyTruncated = false; ViewGroup listView = getListView(); // Check to see if any of the GlobalActionsItems have had their messages truncated for (int i = 0; i < listView.getChildCount(); i++) { View child = listView.getChildAt(i); if (child instanceof GlobalActionsItem) { GlobalActionsItem item = (GlobalActionsItem) child; anyTruncated = anyTruncated || item.isTruncated(); } } // If any of the items have been truncated, set the all to single-line marquee if (anyTruncated) { for (int i = 0; i < listView.getChildCount(); i++) { View child = listView.getChildAt(i); if (child instanceof GlobalActionsItem) { GlobalActionsItem item = (GlobalActionsItem) child; item.setMarquee(true); } } } } @VisibleForTesting protected float getGridItemSize() { return getContext().getResources().getDimension(R.dimen.global_actions_grid_item_height); Loading packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsItem.java 0 → 100644 +76 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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. */ package com.android.systemui.globalactions; import android.content.Context; import android.text.Layout; import android.text.TextUtils; import android.util.AttributeSet; import android.widget.LinearLayout; import android.widget.TextView; import com.android.internal.R; /** * Layout for GlobalActions items. */ public class GlobalActionsItem extends LinearLayout { public GlobalActionsItem(Context context) { super(context); } public GlobalActionsItem(Context context, AttributeSet attrs) { super(context, attrs); } public GlobalActionsItem(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } private TextView getTextView() { return (TextView) findViewById(R.id.message); } /** * Sets this item to marquee or not. */ public void setMarquee(boolean marquee) { TextView text = getTextView(); text.setSingleLine(marquee); text.setEllipsize(marquee ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END); } /** * Determines whether the message for this item has been truncated. */ public boolean isTruncated() { TextView message = getTextView(); if (message != null) { Layout messageLayout = message.getLayout(); if (messageLayout != null) { if (messageLayout.getLineCount() > 0) { // count the number of ellipses in the last line. int ellipses = messageLayout.getEllipsisCount( messageLayout.getLineCount() - 1); // If ellipses are present, the line was forced to truncate. return ellipses > 0; } } } return false; } } Loading
packages/SystemUI/res/layout/global_actions_grid_item_v2.xml +3 −5 Original line number Diff line number Diff line Loading @@ -14,9 +14,7 @@ limitations under the License. --> <!-- RelativeLayouts have an issue enforcing minimum heights, so just work around this for now with LinearLayouts. --> <LinearLayout <com.android.systemui.globalactions.GlobalActionsItem xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="0dp" android:layout_weight="1" Loading @@ -42,7 +40,7 @@ android:id="@*android:id/message" android:layout_width="match_parent" android:layout_height="wrap_content" android:ellipsize="marquee" android:ellipsize="end" android:marqueeRepeatLimit="marquee_forever" android:maxLines="2" android:textSize="12sp" Loading @@ -51,4 +49,4 @@ android:breakStrategy="high_quality" android:hyphenationFrequency="full" android:textAppearance="?android:attr/textAppearanceSmall" /> </LinearLayout> </com.android.systemui.globalactions.GlobalActionsItem>
packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsFlatLayout.java +26 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static com.android.systemui.util.leak.RotationUtils.ROTATION_SEASCAPE; import android.content.Context; import android.util.AttributeSet; import android.view.View; import android.view.ViewGroup; import com.android.internal.annotations.VisibleForTesting; import com.android.systemui.HardwareBgDrawable; Loading Loading @@ -78,6 +79,31 @@ public class GlobalActionsFlatLayout extends GlobalActionsLayout { } } @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { super.onLayout(changed, left, top, right, bottom); boolean anyTruncated = false; ViewGroup listView = getListView(); // Check to see if any of the GlobalActionsItems have had their messages truncated for (int i = 0; i < listView.getChildCount(); i++) { View child = listView.getChildAt(i); if (child instanceof GlobalActionsItem) { GlobalActionsItem item = (GlobalActionsItem) child; anyTruncated = anyTruncated || item.isTruncated(); } } // If any of the items have been truncated, set the all to single-line marquee if (anyTruncated) { for (int i = 0; i < listView.getChildCount(); i++) { View child = listView.getChildAt(i); if (child instanceof GlobalActionsItem) { GlobalActionsItem item = (GlobalActionsItem) child; item.setMarquee(true); } } } } @VisibleForTesting protected float getGridItemSize() { return getContext().getResources().getDimension(R.dimen.global_actions_grid_item_height); Loading
packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsItem.java 0 → 100644 +76 −0 Original line number Diff line number Diff line /* * Copyright (C) 2020 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. */ package com.android.systemui.globalactions; import android.content.Context; import android.text.Layout; import android.text.TextUtils; import android.util.AttributeSet; import android.widget.LinearLayout; import android.widget.TextView; import com.android.internal.R; /** * Layout for GlobalActions items. */ public class GlobalActionsItem extends LinearLayout { public GlobalActionsItem(Context context) { super(context); } public GlobalActionsItem(Context context, AttributeSet attrs) { super(context, attrs); } public GlobalActionsItem(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } private TextView getTextView() { return (TextView) findViewById(R.id.message); } /** * Sets this item to marquee or not. */ public void setMarquee(boolean marquee) { TextView text = getTextView(); text.setSingleLine(marquee); text.setEllipsize(marquee ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END); } /** * Determines whether the message for this item has been truncated. */ public boolean isTruncated() { TextView message = getTextView(); if (message != null) { Layout messageLayout = message.getLayout(); if (messageLayout != null) { if (messageLayout.getLineCount() > 0) { // count the number of ellipses in the last line. int ellipses = messageLayout.getEllipsisCount( messageLayout.getLineCount() - 1); // If ellipses are present, the line was forced to truncate. return ellipses > 0; } } } return false; } }