From ecae90faab31bd135ddc2934419317a367169137 Mon Sep 17 00:00:00 2001 From: Michal Tajchert Date: Fri, 6 Mar 2015 14:28:31 +0100 Subject: [PATCH 1/2] Fix for issue 110 in Android Lollipop. --- .../java/com/andrewgiang/textspritzer/lib/Spritzer.java | 7 ++++--- lib/src/main/res/values/styles.xml | 7 ------- 2 files changed, 4 insertions(+), 10 deletions(-) delete mode 100644 lib/src/main/res/values/styles.xml diff --git a/lib/src/main/java/com/andrewgiang/textspritzer/lib/Spritzer.java b/lib/src/main/java/com/andrewgiang/textspritzer/lib/Spritzer.java index e5aca6b..2f28f0c 100644 --- a/lib/src/main/java/com/andrewgiang/textspritzer/lib/Spritzer.java +++ b/lib/src/main/java/com/andrewgiang/textspritzer/lib/Spritzer.java @@ -33,6 +33,7 @@ public class Spritzer { protected TextView mTarget; protected int mWPM; + protected static final ForegroundColorSpan spanRed = new ForegroundColorSpan(Color.RED); protected Handler mSpritzHandler; protected Object mPlayingSync = new Object(); @@ -61,6 +62,7 @@ public void setOnCompletionListener(OnCompletionListener onCompletionListener) { public Spritzer(TextView target) { init(); mTarget = target; + mTarget.setTypeface(Typeface.MONOSPACE); mSpritzHandler = new SpritzHandler(this); } @@ -317,9 +319,8 @@ private void printWord(String word) { } Spannable spanRange = new SpannableString(word); - TextAppearanceSpan tas = new TextAppearanceSpan(mTarget.getContext(), R.style.PivotLetter); - spanRange.setSpan(tas, startSpan, endSpan, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); - mTarget.setText(spanRange); + spanRange.setSpan(spanRed, startSpan, endSpan , 0); + mTarget.setText(spanRange, TextView.BufferType.SPANNABLE); } public void pause() { diff --git a/lib/src/main/res/values/styles.xml b/lib/src/main/res/values/styles.xml deleted file mode 100644 index bd0123a..0000000 --- a/lib/src/main/res/values/styles.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - \ No newline at end of file From b199df6681c21bc4a3f7a6601d551bb528cca9d2 Mon Sep 17 00:00:00 2001 From: Michal Tajchert Date: Fri, 6 Mar 2015 14:37:22 +0100 Subject: [PATCH 2/2] Fix for imports. --- .../main/java/com/andrewgiang/textspritzer/lib/Spritzer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/src/main/java/com/andrewgiang/textspritzer/lib/Spritzer.java b/lib/src/main/java/com/andrewgiang/textspritzer/lib/Spritzer.java index 2f28f0c..5220ecd 100644 --- a/lib/src/main/java/com/andrewgiang/textspritzer/lib/Spritzer.java +++ b/lib/src/main/java/com/andrewgiang/textspritzer/lib/Spritzer.java @@ -1,10 +1,12 @@ package com.andrewgiang.textspritzer.lib; +import android.graphics.Color; +import android.graphics.Typeface; import android.os.Handler; import android.os.Message; import android.text.Spannable; import android.text.SpannableString; -import android.text.style.TextAppearanceSpan; +import android.text.style.ForegroundColorSpan; import android.util.Log; import android.widget.ProgressBar; import android.widget.TextView;