Make LineBreaker public
This CL includes:
- Move NativeLineBreaker/NativeMeasuredParagraph to android.graphics.text
package since these two uses the shaping result of the text which is a
part of graphics responsibility. At the same time, by this moving,
minikin is only used by android.graphics package.
- Rename NativeLineBreaker/NativeMeasuredParagraph to
LineBreaker/MeasuredText.
- Updated comments of the break strategy and hyphenation frequency.
Bug: 112327179
Test: atest CtsTextTestCases CtsGraphicsTestCases CtsWidgetTestCases
Change-Id: Id69c328e7c9097b9fc11b5c0bd04d1c2e0939c6a
diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java
index d2f0853..ac7e574 100644
--- a/core/java/android/text/StaticLayout.java
+++ b/core/java/android/text/StaticLayout.java
@@ -22,6 +22,7 @@
import android.annotation.Nullable;
import android.annotation.UnsupportedAppUsage;
import android.graphics.Paint;
+import android.graphics.text.LineBreaker;
import android.os.Build;
import android.text.style.LeadingMarginSpan;
import android.text.style.LeadingMarginSpan.LeadingMarginSpan2;
@@ -55,7 +56,7 @@
*
* - Create MeasuredParagraph by MeasuredParagraph.buildForStaticLayout which measures in
* native.
- * - Run NativeLineBreaker.computeLineBreaks() to obtain line breaks for the paragraph.
+ * - Run LineBreaker.computeLineBreaks() to obtain line breaks for the paragraph.
*
* After all paragraphs, call finish() to release expensive buffers.
*/
@@ -634,7 +635,7 @@
indents = null;
}
- final NativeLineBreaker lineBreaker = new NativeLineBreaker.Builder()
+ final LineBreaker lineBreaker = new LineBreaker.Builder()
.setBreakStrategy(b.mBreakStrategy)
.setHyphenationFrequency(b.mHyphenationFrequency)
// TODO: Support more justification mode, e.g. letter spacing, stretching.
@@ -642,8 +643,8 @@
.setIndents(indents)
.build();
- NativeLineBreaker.ParagraphConstraints constraints =
- new NativeLineBreaker.ParagraphConstraints();
+ LineBreaker.ParagraphConstraints constraints =
+ new LineBreaker.ParagraphConstraints();
PrecomputedText.ParagraphInfo[] paragraphInfo = null;
final Spanned spanned = (source instanceof Spanned) ? (Spanned) source : null;
@@ -739,8 +740,8 @@
constraints.setIndent(firstWidth, firstWidthLineCount);
constraints.setTabStops(variableTabStops, TAB_INCREMENT);
- NativeLineBreaker.Result res = lineBreaker.computeLineBreaks(
- measuredPara.getNativeMeasuredParagraph(), constraints, mLineCount);
+ LineBreaker.Result res = lineBreaker.computeLineBreaks(
+ measuredPara.getMeasuredText(), constraints, mLineCount);
int breakCount = res.getLineCount();
if (lineBreakCapacity < breakCount) {
lineBreakCapacity = breakCount;