From af9f831a6cd09eb76cb9e05270a8b8f986e07f75 Mon Sep 17 00:00:00 2001 From: Seigo Nonaka Date: Mon, 20 May 2024 15:03:50 +0900 Subject: Add getter methods to the line breaker Flag: com.android.text.flags.missing_getter_apis Bug: 340875345 Test: m checkapi Change-Id: Ifc51bbfc0ab36d76321efaa5beb74992b0a7c246 --- .../java/android/graphics/text/LineBreaker.java | 69 ++++++++++++++++++++++ 1 file changed, 69 insertions(+) (limited to 'graphics/java') diff --git a/graphics/java/android/graphics/text/LineBreaker.java b/graphics/java/android/graphics/text/LineBreaker.java index d8cf21e72441..94de066c9182 100644 --- a/graphics/java/android/graphics/text/LineBreaker.java +++ b/graphics/java/android/graphics/text/LineBreaker.java @@ -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; } /** -- cgit v1.2.3-59-g8ed1b