commit 6034cca6365fad5f8fcad1463bd7a5b2c5756bd4
parent b27a3fd39b5dc554136b6d8bca050b780811a159
Author: Makoto Kato <m_kato@ga2.so-net.ne.jp>
Date: Thu, 13 Nov 2025 05:00:56 +0000
Bug 1999648 - Don't use reflection to get underline color if Android API 29+. r=geckoview-reviewers,ohall
Android API 29+ has an API to get underline color, so we should use it
on 29+.
Differential Revision: https://phabricator.services.mozilla.com/D272219
Diffstat:
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoEditable.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoEditable.java
@@ -1033,12 +1033,18 @@ import org.mozilla.geckoview.SessionTextInput.EditableListener.IMEState;
for (final CharacterStyle span : styleSpans) {
span.updateDrawState(tp);
}
- int tpUnderlineColor = 0;
- float tpUnderlineThickness = 0.0f;
- // These TextPaint fields only exist on Android ICS+ and are not in the SDK.
- tpUnderlineColor = (Integer) getField(tp, "underlineColor", 0);
- tpUnderlineThickness = (Float) getField(tp, "underlineThickness", 0.0f);
+ final int tpUnderlineColor;
+ final float tpUnderlineThickness;
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
+ tpUnderlineColor = tp.underlineColor;
+ tpUnderlineThickness = tp.underlineThickness;
+ } else {
+ // These TextPaint fields only exist on Android ICS+ and are not in the SDK.
+ tpUnderlineColor = (Integer) getField(tp, "underlineColor", 0);
+ tpUnderlineThickness = (Float) getField(tp, "underlineThickness", 0.0f);
+ }
if (tpUnderlineColor != 0) {
rangeStyles |= IME_RANGE_UNDERLINE | IME_RANGE_LINECOLOR;
rangeLineColor = tpUnderlineColor;