From 38dfd19611160e8f182d42040f6821f151353716 Mon Sep 17 00:00:00 2001 From: Shu Chen Date: Fri, 17 Jul 2020 19:43:18 +0800 Subject: Ensures the slop value is fixed cross lines. In Q, the slop is a fixed value calculated based on TextView.getLineHeight(). In R+ (before this cl), the slop is a dynamic value based on the height of the current line. It's been confirmed as the root cause of the regression bug b/159528374. This cl changes the slop value back to the fixed value. Bug: 159528374 Test: Verified locally. Change-Id: I182d22779f1c1155ae2e0b0deb0455bd270b2fd9 --- core/java/android/widget/Editor.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java index 346bbb6fd409..c4eb39626d8b 100644 --- a/core/java/android/widget/Editor.java +++ b/core/java/android/widget/Editor.java @@ -6053,9 +6053,8 @@ public class Editor { return trueLine; } - final int lineHeight = layout.getLineBottom(prevLine) - layout.getLineTop(prevLine); - int slop = (int)(mLineSlopRatio - * (layout.getLineBottom(trueLine) - layout.getLineTop(trueLine))); + final int lineHeight = mTextView.getLineHeight(); + int slop = (int)(mLineSlopRatio * lineHeight); slop = Math.max(mLineChangeSlopMin, Math.min(mLineChangeSlopMax, lineHeight + slop)) - lineHeight; slop = Math.max(0, slop); -- cgit v1.2.3-59-g8ed1b