summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Haoyu Zhang <haoyuchang@google.com> 2023-04-06 14:57:55 -0700
committer Haoyu Zhang <haoyuchang@google.com> 2023-04-06 19:23:31 -0700
commit5a7bf6e00a51f15e25d218e15deb30458316abab (patch)
tree9f815e48cd624daa9f3f3bdeec15aeb59d23956c
parent7b888dcc01e43d21f3297fb2abea354e9e209064 (diff)
Fix insert mode draws extra rectangle at the end of the first line
Bug: 276784691 Test: manually tested Change-Id: If0433c9bb3744d4bd0385c11b6d5c37d299af196
-rw-r--r--core/java/android/widget/Editor.java8
1 files changed, 4 insertions, 4 deletions
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index 088065d2f77d..7931d1a06d39 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -8095,12 +8095,14 @@ public class Editor {
private boolean mIsInsertModeActive;
private InsertModeTransformationMethod mInsertModeTransformationMethod;
private final Paint mHighlightPaint;
+ private final Path mHighlightPath;
InsertModeController(@NonNull TextView textView) {
mTextView = Objects.requireNonNull(textView);
mIsInsertModeActive = false;
mInsertModeTransformationMethod = null;
mHighlightPaint = new Paint();
+ mHighlightPath = new Path();
// The highlight color is supposed to be 12% of the color primary40. We can't
// directly access Material 3 theme. But because Material 3 sets the colorPrimary to
@@ -8168,10 +8170,8 @@ public class Editor {
((InsertModeTransformationMethod.TransformedText) transformedText);
final int highlightStart = insertModeTransformedText.getHighlightStart();
final int highlightEnd = insertModeTransformedText.getHighlightEnd();
- final Layout.SelectionRectangleConsumer consumer =
- (left, top, right, bottom, textSelectionLayout) ->
- canvas.drawRect(left, top, right, bottom, mHighlightPaint);
- layout.getSelection(highlightStart, highlightEnd, consumer);
+ layout.getSelectionPath(highlightStart, highlightEnd, mHighlightPath);
+ canvas.drawPath(mHighlightPath, mHighlightPaint);
}
}