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

Commit a273a70e authored by Siyamed Sinir's avatar Siyamed Sinir
Browse files

Removed unused variables from text layout code

Test: None
Change-Id: I890c3d260edd0570259db5089dcb37f79c2e56e9
parent c51777b9
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -299,7 +299,7 @@ public class DynamicLayout extends Layout

        private final Paint.FontMetricsInt mFontMetricsInt = new Paint.FontMetricsInt();

        private static final SynchronizedPool<Builder> sPool = new SynchronizedPool<Builder>(3);
        private static final SynchronizedPool<Builder> sPool = new SynchronizedPool<>(3);
    }

    /**
@@ -440,7 +440,7 @@ public class DynamicLayout extends Layout
            mEllipsizeAt = null;
        }

        mObjects = new PackedObjectVector<Directions>(1);
        mObjects = new PackedObjectVector<>(1);

        // Initial state is a single line with 0 characters (0 to 0), with top at 0 and bottom at
        // whatever is natural, and undefined ellipsis.
@@ -1050,7 +1050,7 @@ public class DynamicLayout extends Layout

    private static class ChangeWatcher implements TextWatcher, SpanWatcher {
        public ChangeWatcher(DynamicLayout layout) {
            mLayout = new WeakReference<DynamicLayout>(layout);
            mLayout = new WeakReference<>(layout);
        }

        private void reflow(CharSequence s, int where, int before, int after) {
+2 −12
Original line number Diff line number Diff line
@@ -319,8 +319,6 @@ public abstract class Layout {

    private float getJustifyWidth(int lineNum) {
        Alignment paraAlign = mAlignment;
        TabStops tabStops = null;
        boolean tabStopsIsInitialized = false;

        int left = 0;
        int right = mWidth;
@@ -371,10 +369,6 @@ public abstract class Layout {
            }
        }

        if (getLineContainsTab(lineNum)) {
            tabStops = new TabStops(TAB_INCREMENT, spans);
        }

        final Alignment align;
        if (paraAlign == Alignment.ALIGN_LEFT) {
            align = (dir == DIR_LEFT_TO_RIGHT) ?  Alignment.ALIGN_NORMAL : Alignment.ALIGN_OPPOSITE;
@@ -1423,7 +1417,6 @@ public abstract class Layout {
        float dist = Math.abs(getHorizontal(max, primary) - horiz);

        if (dist <= bestdist) {
            bestdist = dist;
            best = max;
        }

@@ -1570,7 +1563,7 @@ public abstract class Layout {
        // XXX: we don't care about tabs
        tl.set(mPaint, mText, lineStart, lineEnd, lineDir, directions, false, null);
        caret = lineStart + tl.getOffsetToLeftRightOf(caret - lineStart, toLeft);
        tl = TextLine.recycle(tl);
        TextLine.recycle(tl);
        return caret;
    }

@@ -1894,10 +1887,7 @@ public abstract class Layout {

        int margin = 0;

        boolean isFirstParaLine = lineStart == 0 ||
            spanned.charAt(lineStart - 1) == '\n';

        boolean useFirstLineMargin = isFirstParaLine;
        boolean useFirstLineMargin = lineStart == 0 || spanned.charAt(lineStart - 1) == '\n';
        for (int i = 0; i < spans.length; i++) {
            if (spans[i] instanceof LeadingMarginSpan2) {
                int spStart = spanned.getSpanStart(spans[i]);
+5 −7
Original line number Diff line number Diff line
@@ -441,8 +441,6 @@ public class StaticLayout extends Layout {

        private Pair<String, long[]> getLocaleAndHyphenatorIfChanged(TextPaint paint) {
            final LocaleList locales = paint.getTextLocales();
            final String languageTags;
            long[] hyphenators;
            if (!locales.equals(mLocales)) {
                mLocales = locales;
                return new Pair(locales.toLanguageTags(), getHyphenators(locales));
@@ -521,7 +519,7 @@ public class StaticLayout extends Layout {

        private LocaleList mLocales;

        private static final SynchronizedPool<Builder> sPool = new SynchronizedPool<Builder>(3);
        private static final SynchronizedPool<Builder> sPool = new SynchronizedPool<>(3);
    }

    public StaticLayout(CharSequence source, TextPaint paint,
@@ -947,10 +945,10 @@ public class StaticLayout extends Layout {
                    boolean moreChars = (endPos < bufEnd);

                    final int ascent = fallbackLineSpacing
                            ? Math.min(fmAscent, (int) Math.round(ascents[breakIndex]))
                            ? Math.min(fmAscent, Math.round(ascents[breakIndex]))
                            : fmAscent;
                    final int descent = fallbackLineSpacing
                            ? Math.max(fmDescent, (int) Math.round(descents[breakIndex]))
                            ? Math.max(fmDescent, Math.round(descents[breakIndex]))
                            : fmDescent;
                    v = out(source, here, endPos,
                            ascent, descent, fmTop, fmBottom,
@@ -1177,7 +1175,7 @@ public class StaticLayout extends Layout {
        mWorkPaint.set(paint);
        do {
            final float ellipsizedWidth = guessEllipsis(text, lineStart, lineEnd, widths,
                    widthStart, tempAvail, where, line, textWidth, mWorkPaint, forceEllipsis, dir);
                    widthStart, tempAvail, where, line, mWorkPaint, forceEllipsis, dir);
            if (ellipsizedWidth <= avail) {
                lineFits = true;
            } else {
@@ -1207,7 +1205,7 @@ public class StaticLayout extends Layout {
    // This method temporarily modifies the TextPaint passed to it, so the TextPaint passed to it
    // should not be accessed while the method is running.
    private float guessEllipsis(CharSequence text, int lineStart, int lineEnd, float[] widths,
            int widthStart, float avail, TextUtils.TruncateAt where, int line, float textWidth,
            int widthStart, float avail, TextUtils.TruncateAt where, int line,
            TextPaint paint, boolean forceEllipsis, int dir) {
        final int savedHyphenEdit = paint.getHyphenEdit();
        paint.setHyphenEdit(0);
+5 −5
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ class TextLine {
            new SpanSet<ReplacementSpan>(ReplacementSpan.class);

    private final DecorationInfo mDecorationInfo = new DecorationInfo();
    private final ArrayList<DecorationInfo> mDecorations = new ArrayList();
    private final ArrayList<DecorationInfo> mDecorations = new ArrayList<>();

    private static final TextLine[] sCached = new TextLine[3];

@@ -340,14 +340,14 @@ class TextLine {

                    boolean advance = (mDir == Layout.DIR_RIGHT_TO_LEFT) == runIsRtl;
                    if (inSegment && advance) {
                        return h += measureRun(segstart, offset, j, runIsRtl, fmi);
                        return h + measureRun(segstart, offset, j, runIsRtl, fmi);
                    }

                    float w = measureRun(segstart, j, j, runIsRtl, fmi);
                    h += advance ? w : -w;

                    if (inSegment) {
                        return h += measureRun(segstart, offset, j, runIsRtl, null);
                        return h + measureRun(segstart, offset, j, runIsRtl, null);
                    }

                    if (codept == '\t') {
@@ -828,14 +828,14 @@ class TextLine {
                    }
                    if (info.isUnderlineText) {
                        final float thickness =
                                Math.max(((Paint) wp).getUnderlineThickness(), 1.0f);
                                Math.max(wp.getUnderlineThickness(), 1.0f);
                        drawStroke(wp, c, wp.getColor(), wp.getUnderlinePosition(), thickness,
                                decorationXLeft, decorationXRight, y);
                    }

                    if (info.isStrikeThruText) {
                        final float thickness =
                                Math.max(((Paint) wp).getStrikeThruThickness(), 1.0f);
                                Math.max(wp.getStrikeThruThickness(), 1.0f);
                        drawStroke(wp, c, wp.getColor(), wp.getStrikeThruPosition(), thickness,
                                decorationXLeft, decorationXRight, y);
                    }