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

Commit c1bf01b0 authored by Lucas Dupin's avatar Lucas Dupin Committed by android-build-merger
Browse files

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

am: dd49a8cc

Change-Id: I144652e4ae256ff714e919f040e180aa64081584
parents 6e698428 dd49a8cc
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 {

        /**