[go: nahoru, domu]

Reorganize ellipsis APIs

Here is the problems with existing APIs.
- getLinEllipsisCount stops counting at the LF character.
  This is came from framework implementation but not a good
  behavior to expose to public API. It is good to return the
  end of text instead of LF offset.
- getLineVisibleEnd in framework does not respect ellipsis.
  From the naming of API, it should return the visible end
  offset for the ellipsized line.

To address above problems, propose following changes:
- add getLineVisibleEnd which returns ellipsize start offset
  if ellipsis happens. If not, returns line end without
  trailing whitespaces.
- To get whether ellipsis happens or not, add isLineEllipsized.
- Remove getLineEllipsisOffset since this is equivalent to
  getLineVisibleEnd.
- Remove getLineEllipsisCount since this is equivalent to
  getLineEnd() - getLineVisibleEnd().

Relnote: "Remove getLineEllipsisOffset/getLineEllipsisCount. Use
getLineVisibleEnd/getLineEnd/isLineEllipsized instead."

Bug: 162029805
Test: ./gradlew :compose:ui:ui-text:cAT
Change-Id: I85aa258d57056cbdae2816b14ce1af313023020c
diff --git a/ui/ui-text-core/api/current.txt b/ui/ui-text-core/api/current.txt
index 1eae8c4..e8bd76b 100644
--- a/ui/ui-text-core/api/current.txt
+++ b/ui/ui-text-core/api/current.txt
@@ -85,8 +85,6 @@
     method public float getLastBaseline();
     method public float getLineBottom(int lineIndex);
     method public int getLineCount();
-    method public int getLineEllipsisCount(int lineIndex);
-    method public int getLineEllipsisOffset(int lineIndex);
     method public int getLineEnd(int lineIndex);
     method public int getLineForOffset(int offset);
     method public int getLineForVerticalPosition(float vertical);
@@ -95,6 +93,7 @@
     method public float getLineRight(int lineIndex);
     method public int getLineStart(int lineIndex);
     method public float getLineTop(int lineIndex);
+    method public int getLineVisibleEnd(int lineIndex);
     method public float getLineWidth(int lineIndex);
     method public float getMaxIntrinsicWidth();
     method public int getMaxLines();
@@ -105,6 +104,7 @@
     method public java.util.List<androidx.compose.ui.geometry.Rect> getPlaceholderRects();
     method public float getWidth();
     method public androidx.compose.ui.text.TextRange getWordBoundary(int offset);
+    method public boolean isLineEllipsized(int lineIndex);
     method public void paint(androidx.compose.ui.graphics.Canvas canvas);
     property public final boolean didExceedMaxLines;
     property public final float firstBaseline;
@@ -144,8 +144,6 @@
     method public float getLastBaseline();
     method public float getLineBottom(int lineIndex);
     method public int getLineCount();
-    method public int getLineEllipsisCount(int lineIndex);
-    method public int getLineEllipsisOffset(int lineIndex);
     method public int getLineEnd(int lineIndex);
     method public int getLineForOffset(int offset);
     method public int getLineForVerticalPosition(float vertical);
@@ -154,6 +152,7 @@
     method public float getLineRight(int lineIndex);
     method public int getLineStart(int lineIndex);
     method public float getLineTop(int lineIndex);
+    method public int getLineVisibleEnd(int lineIndex);
     method public float getLineWidth(int lineIndex);
     method public float getMaxIntrinsicWidth();
     method public float getMinIntrinsicWidth();
@@ -163,6 +162,7 @@
     method public java.util.List<androidx.compose.ui.geometry.Rect> getPlaceholderRects();
     method public float getWidth();
     method public androidx.compose.ui.text.TextRange getWordBoundary(int offset);
+    method public boolean isLineEllipsized(int lineIndex);
     method public void paint(androidx.compose.ui.graphics.Canvas canvas);
     property public abstract boolean didExceedMaxLines;
     property public abstract float firstBaseline;
@@ -345,12 +345,14 @@
     method public float getLineRight(int lineIndex);
     method public int getLineStart(int lineIndex);
     method public float getLineTop(int lineIndex);
+    method public int getLineVisibleEnd(int lineIndex);
     method public int getOffsetForPosition(androidx.compose.ui.geometry.Offset position);
     method public androidx.compose.ui.text.style.ResolvedTextDirection getParagraphDirection(int offset);
     method public androidx.compose.ui.graphics.Path getPathForRange(int start, int end);
     method public java.util.List<androidx.compose.ui.geometry.Rect> getPlaceholderRects();
     method public androidx.compose.ui.unit.IntSize getSize();
     method public androidx.compose.ui.text.TextRange getWordBoundary(int offset);
+    method public boolean isLineEllipsized(int lineIndex);
     property public final boolean didOverflowHeight;
     property public final boolean didOverflowWidth;
     property public final float firstBaseline;