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

Commit 90097016 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add getter methods to the line breaker" into main

parents 0e05178d af9f831a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -18087,6 +18087,11 @@ package android.graphics.text {
  public class LineBreaker {
    method @NonNull public android.graphics.text.LineBreaker.Result computeLineBreaks(@NonNull android.graphics.text.MeasuredText, @NonNull android.graphics.text.LineBreaker.ParagraphConstraints, @IntRange(from=0) int);
    method @FlaggedApi("com.android.text.flags.missing_getter_apis") public int getBreakStrategy();
    method @FlaggedApi("com.android.text.flags.missing_getter_apis") public int getHyphenationFrequency();
    method @FlaggedApi("com.android.text.flags.missing_getter_apis") @Nullable public int[] getIndents();
    method @FlaggedApi("com.android.text.flags.missing_getter_apis") public int getJustificationMode();
    method @FlaggedApi("com.android.text.flags.missing_getter_apis") public boolean getUseBoundsForWidth();
    field public static final int BREAK_STRATEGY_BALANCED = 2; // 0x2
    field public static final int BREAK_STRATEGY_HIGH_QUALITY = 1; // 0x1
    field public static final int BREAK_STRATEGY_SIMPLE = 0; // 0x0
+10 −0
Original line number Diff line number Diff line
@@ -181,3 +181,13 @@ flag {
    purpose: PURPOSE_BUGFIX
  }
}

flag {
  name: "missing_getter_apis"
  namespace: "text"
  description: "Fix the lint warning about missing getters."
  bug: "340875345"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}
+69 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package android.graphics.text;

import static com.android.text.flags.Flags.FLAG_USE_BOUNDS_FOR_WIDTH;
import static com.android.text.flags.Flags.FLAG_LETTER_SPACING_JUSTIFICATION;
import static com.android.text.flags.Flags.FLAG_MISSING_GETTER_APIS;


import android.annotation.FlaggedApi;
import android.annotation.FloatRange;
@@ -488,6 +490,12 @@ public class LineBreaker {

    private final long mNativePtr;

    private final @BreakStrategy int mBreakStrategy;
    private final @HyphenationFrequency int mHyphenationFrequency;
    private final @JustificationMode int mJustificationMode;
    private final int[] mIndents;
    private final boolean mUseBoundsForWidth;

    /**
     * Use Builder instead.
     */
@@ -497,6 +505,67 @@ public class LineBreaker {
        mNativePtr = nInit(breakStrategy, hyphenationFrequency,
                justify == JUSTIFICATION_MODE_INTER_WORD, indents, useBoundsForWidth);
        NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, mNativePtr);

        mBreakStrategy = breakStrategy;
        mHyphenationFrequency = hyphenationFrequency;
        mJustificationMode = justify;
        mIndents = indents;
        mUseBoundsForWidth = useBoundsForWidth;
    }

    /**
     * Returns the break strategy used for this line breaker.
     *
     * @return the break strategy used for this line breaker.
     * @see Builder#setBreakStrategy(int)
     */
    @FlaggedApi(FLAG_MISSING_GETTER_APIS)
    public @BreakStrategy int getBreakStrategy() {
        return mBreakStrategy;
    }

    /**
     * Returns the hyphenation frequency used for this line breaker.
     *
     * @return the hyphenation frequency used for this line breaker.
     * @see Builder#setHyphenationFrequency(int)
     */
    @FlaggedApi(FLAG_MISSING_GETTER_APIS)
    public @HyphenationFrequency int getHyphenationFrequency() {
        return mHyphenationFrequency;
    }

    /**
     * Returns the justification mode used for this line breaker.
     *
     * @return the justification mode used for this line breaker.
     * @see Builder#setJustificationMode(int)
     */
    @FlaggedApi(FLAG_MISSING_GETTER_APIS)
    public @JustificationMode int getJustificationMode() {
        return mJustificationMode;
    }

    /**
     * Returns the indents used for this line breaker.
     *
     * @return the indents used for this line breaker.
     * @see Builder#setIndents(int[])
     */
    @FlaggedApi(FLAG_MISSING_GETTER_APIS)
    public @Nullable int[] getIndents() {
        return mIndents;
    }

    /**
     * Returns true if this line breaker uses bounds as width for line breaking.
     *
     * @return true if this line breaker uses bounds as width for line breaking.
     * @see Builder#setUseBoundsForWidth(boolean)
     */
    @FlaggedApi(FLAG_MISSING_GETTER_APIS)
    public boolean getUseBoundsForWidth() {
        return mUseBoundsForWidth;
    }

    /**