diff options
author | Luca Zanolin <zano@google.com> | 2011-08-30 18:04:34 +0100 |
---|---|---|
committer | Luca Zanolin <zano@google.com> | 2011-08-30 18:04:34 +0100 |
commit | e6d368218918f911b1954296dab25bf84147b4c6 (patch) | |
tree | ced516f25e2cba3dd742f1b322460c9cbf10d206 /core/java/android/text/TextLine.java | |
parent | c5d0fac081c4c496b29586bff79dfff05755b716 (diff) | |
download | frameworks_base-e6d368218918f911b1954296dab25bf84147b4c6.zip frameworks_base-e6d368218918f911b1954296dab25bf84147b4c6.tar.gz frameworks_base-e6d368218918f911b1954296dab25bf84147b4c6.tar.bz2 |
Add EditTextShortcutSpan to provide edit short cut in the text view.
At the moment, EditTextShortcutSpan allows only the deletion of the text. In the future, we may decide to add extra functionality,
like "retry" where all the text is removed and a specific IME is triggered.
Fix the underline. The underline is not defined in thickness, and not as a multiplier of the default underline thickness.
Change the behaviour of SuggestionRangeSpan to match the specification.
Change-Id: I80437d9887c7a2ff8f62c38afbb0cb7add7ee9c8
Diffstat (limited to 'core/java/android/text/TextLine.java')
-rw-r--r-- | core/java/android/text/TextLine.java | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java index fcc372e..68a6b3e 100644 --- a/core/java/android/text/TextLine.java +++ b/core/java/android/text/TextLine.java @@ -723,7 +723,7 @@ class TextLine { float ret = 0; int contextLen = contextEnd - contextStart; - if (needWidth || (c != null && (wp.bgColor != 0 || wp.underlineColor !=0 || runIsRtl))) { + if (needWidth || (c != null && (wp.bgColor != 0 || wp.underlineCount != 0 || runIsRtl))) { int flags = runIsRtl ? Paint.DIRECTION_RTL : Paint.DIRECTION_LTR; if (mCharsValid) { ret = wp.getTextRunAdvances(mChars, start, runLen, @@ -753,21 +753,26 @@ class TextLine { wp.setColor(previousColor); } - if (wp.underlineColor != 0) { + if (wp.underlineCount != 0) { // kStdUnderline_Offset = 1/9, defined in SkTextFormatParams.h - float middle = y + wp.baselineShift + (1.0f / 9.0f) * wp.getTextSize(); - // kStdUnderline_Thickness = 1/18, defined in SkTextFormatParams.h - float halfHeight = wp.underlineThickness * (1.0f / 18.0f / 2.0f) * wp.getTextSize(); + float underlineTop = y + wp.baselineShift + (1.0f / 9.0f) * wp.getTextSize(); int previousColor = wp.getColor(); Paint.Style previousStyle = wp.getStyle(); + boolean previousAntiAlias = wp.isAntiAlias(); - wp.setColor(wp.underlineColor); wp.setStyle(Paint.Style.FILL); - c.drawRect(x, middle - halfHeight, x + ret, middle + halfHeight, wp); + wp.setAntiAlias(true); + + for (int i = 0; i < wp.underlineCount; i++) { + wp.setColor(wp.underlineColors[i]); + c.drawRect(x, underlineTop, x + ret, underlineTop + wp.underlineThicknesses[i], + wp); + } wp.setStyle(previousStyle); wp.setColor(previousColor); + wp.setAntiAlias(previousAntiAlias); } drawTextRun(c, wp, start, end, contextStart, contextEnd, runIsRtl, |