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

Commit dd49a8cc authored by Lucas Dupin's avatar Lucas Dupin Committed by Android (Google) Code Review
Browse files

Merge "Fix issue where line breaks would be wrong" into pi-dev

parents 96dc1ca7 bc1827ae
Loading
Loading
Loading
Loading
+21 −12
Original line number Diff line number Diff line
@@ -166,18 +166,6 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
            SliceItem mainTitle = header.getTitleItem();
            CharSequence title = mainTitle != null ? mainTitle.getText() : null;
            mTitle.setText(title);

            // Check if we're already ellipsizing the text.
            // We're going to figure out the best possible line break if not.
            Layout layout = mTitle.getLayout();
            if (layout != null){
                final int lineCount = layout.getLineCount();
                if (lineCount > 0) {
                    if (layout.getEllipsisCount(lineCount - 1) == 0) {
                        mTitle.setText(findBestLineBreak(title));
                    }
                }
            }
        }

        mClickActions.clear();
@@ -381,6 +369,27 @@ public class KeyguardSliceView extends LinearLayout implements View.OnClickListe
        mIconSize = mContext.getResources().getDimensionPixelSize(R.dimen.widget_icon_size);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        // Find best ellipsis strategy for the title.
        // Done on onMeasure since TextView#getLayout needs a measure pass to calculate its bounds.
        Layout layout = mTitle.getLayout();
        if (layout != null) {
            final int lineCount = layout.getLineCount();
            if (lineCount > 0) {
                if (layout.getEllipsisCount(lineCount - 1) == 0) {
                    CharSequence title = mTitle.getText();
                    CharSequence bestLineBreak = findBestLineBreak(title);
                    if (!TextUtils.equals(title, bestLineBreak)) {
                        mTitle.setText(bestLineBreak);
                    }
                }
            }
        }
    }

    public static class Row extends LinearLayout {

        /**