summaryrefslogtreecommitdiff
path: root/core/java/android/widget/TextView.java
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-08-17 01:12:06 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2021-08-17 01:12:06 +0000
commitfee0bc79657d3bae1446c974a5ec757c54a98443 (patch)
tree5d233d0d602da4a0dc612fac2a0ff1be9ca9b777 /core/java/android/widget/TextView.java
parentd42e8928647aa183aa06564329dbfc08e0f1acff (diff)
parent991fe9a310898868e671cb758f4b0fbea77c5a7c (diff)
Merge cherrypicks of [15589380, 15589521, 15589522, 15589273, 15589503, 15589504, 15589505, 15589506, 15589507, 15589508, 15589509, 15589510, 15589511, 15589274, 15589562, 15589523, 15589405, 15589406, 15589581, 15589524, 15589525, 15589526, 15589276, 15589277, 15589565, 15589566, 15589528, 15589407, 15589255, 15589516, 15589530, 15589531, 15589569, 15589258] into sc-release
Change-Id: Ie51dfebad33c817c1df839f5e364f751e25976c0
Diffstat (limited to 'core/java/android/widget/TextView.java')
-rw-r--r--core/java/android/widget/TextView.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index ca6e735f86b4..f5c1bcf2de42 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -11857,6 +11857,15 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
if (text != null) {
if (expandedTopChar > 0 || expandedBottomChar < text.length()) {
+ // Cap the offsets to avoid an OOB exception. That can happen if the
+ // displayed/layout text, on which these offsets are calculated, is longer
+ // than the original text (such as when the view is translated by the
+ // platform intelligence).
+ // TODO(b/196433694): Figure out how to better handle the offset
+ // calculations for this case (so we don't unnecessarily cutoff the original
+ // text, for example).
+ expandedTopChar = Math.min(expandedTopChar, text.length());
+ expandedBottomChar = Math.min(expandedBottomChar, text.length());
text = text.subSequence(expandedTopChar, expandedBottomChar);
}