summaryrefslogtreecommitdiffstats
path: root/core/java/android/text/style
diff options
context:
space:
mode:
authorGilles Debunne <debunne@google.com>2011-09-08 18:34:22 -0700
committerGilles Debunne <debunne@google.com>2011-09-08 18:35:54 -0700
commitfa4e2d994bb398b89d08304bb233671ef1a5d5f8 (patch)
tree4b200f0c60beb65385c5a29af040bbb7e6131217 /core/java/android/text/style
parent11e2e5dece7a92f50b73240dc0300343a7b495bf (diff)
downloadframeworks_base-fa4e2d994bb398b89d08304bb233671ef1a5d5f8.zip
frameworks_base-fa4e2d994bb398b89d08304bb233671ef1a5d5f8.tar.gz
frameworks_base-fa4e2d994bb398b89d08304bb233671ef1a5d5f8.tar.bz2
Bug 5278456: text highlight color depends on the type of suggestion spans.
Change-Id: I76ac02b7688a297c0e83d593f446a4cf2ee36015
Diffstat (limited to 'core/java/android/text/style')
-rw-r--r--core/java/android/text/style/SuggestionRangeSpan.java21
-rw-r--r--core/java/android/text/style/SuggestionSpan.java10
2 files changed, 23 insertions, 8 deletions
diff --git a/core/java/android/text/style/SuggestionRangeSpan.java b/core/java/android/text/style/SuggestionRangeSpan.java
index a637b1c..2dbfc72 100644
--- a/core/java/android/text/style/SuggestionRangeSpan.java
+++ b/core/java/android/text/style/SuggestionRangeSpan.java
@@ -28,15 +28,11 @@ import android.text.TextUtils;
* @hide
*/
public class SuggestionRangeSpan extends CharacterStyle implements ParcelableSpan {
- private final int mBackgroundColor;
+ private int mBackgroundColor;
- @Override
- public void updateDrawState(TextPaint tp) {
- tp.bgColor = mBackgroundColor;
- }
-
- public SuggestionRangeSpan(int color) {
- mBackgroundColor = color;
+ public SuggestionRangeSpan() {
+ // 0 is a fully transparent black. Has to be set using #setBackgroundColor
+ mBackgroundColor = 0;
}
public SuggestionRangeSpan(Parcel src) {
@@ -57,4 +53,13 @@ public class SuggestionRangeSpan extends CharacterStyle implements ParcelableSpa
public int getSpanTypeId() {
return TextUtils.SUGGESTION_RANGE_SPAN;
}
+
+ public void setBackgroundColor(int backgroundColor) {
+ mBackgroundColor = backgroundColor;
+ }
+
+ @Override
+ public void updateDrawState(TextPaint tp) {
+ tp.bgColor = mBackgroundColor;
+ }
}
diff --git a/core/java/android/text/style/SuggestionSpan.java b/core/java/android/text/style/SuggestionSpan.java
index 693a7a9..fecf0f7 100644
--- a/core/java/android/text/style/SuggestionSpan.java
+++ b/core/java/android/text/style/SuggestionSpan.java
@@ -264,4 +264,14 @@ public class SuggestionSpan extends CharacterStyle implements ParcelableSpan {
tp.setUnderlineText(mEasyCorrectUnderlineColor, mEasyCorrectUnderlineThickness);
}
}
+
+ /**
+ * @return The color of the underline for that span, or 0 if there is no underline
+ */
+ public int getUnderlineColor() {
+ // The order here should match what is used in updateDrawState
+ if ((mFlags & FLAG_MISSPELLED) != 0) return mMisspelledUnderlineColor;
+ if ((mFlags & FLAG_EASY_CORRECT) != 0) return mEasyCorrectUnderlineColor;
+ return 0;
+ }
}