Loading core/java/com/android/internal/widget/ImageFloatingTextView.java +7 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.text.BoringLayout; import android.text.Layout; import android.text.StaticLayout; import android.text.TextUtils; import android.text.method.TransformationMethod; import android.util.AttributeSet; import android.view.RemotableViewMethod; import android.widget.RemoteViews; Loading Loading @@ -68,7 +69,12 @@ public class ImageFloatingTextView extends TextView { protected Layout makeSingleLayout(int wantWidth, BoringLayout.Metrics boring, int ellipsisWidth, Layout.Alignment alignment, boolean shouldEllipsize, TextUtils.TruncateAt effectiveEllipsize, boolean useSaved) { CharSequence text = getText() == null ? "" : getText(); TransformationMethod transformationMethod = getTransformationMethod(); CharSequence text = getText(); if (transformationMethod != null) { text = transformationMethod.getTransformation(text, this); } text = text == null ? "" : text; StaticLayout.Builder builder = StaticLayout.Builder.obtain(text, 0, text.length(), getPaint(), wantWidth) .setAlignment(alignment) Loading core/tests/coretests/src/com/android/internal/widget/ImageFloatingTextViewTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -21,9 +21,11 @@ import static org.junit.Assert.assertTrue; import android.content.Context; import android.support.test.InstrumentationRegistry; import android.support.test.filters.SmallTest; import android.text.Layout; import android.view.View.MeasureSpec; import android.widget.TextView; import org.junit.Assert; import org.junit.Before; import org.junit.Test; Loading Loading @@ -102,6 +104,16 @@ public class ImageFloatingTextViewTest { + "Yada yada, yada yada. Lorem ipsum dolor sit amet."); } @Test public void usesTransformationMethod() { mView.setSingleLine(); String text = "Test \n Test"; parametrizedTest(text); Layout layout = mView.getLayout(); Assert.assertFalse("The transformation method wasn't used, string is still the same", text.equals(layout.getText())); } private void parametrizedTest(CharSequence text) { int heightMeasureSpec = MeasureSpec.makeMeasureSpec(500, MeasureSpec.AT_MOST); int widthMeasureSpec = MeasureSpec.makeMeasureSpec(500, MeasureSpec.EXACTLY); Loading Loading
core/java/com/android/internal/widget/ImageFloatingTextView.java +7 −1 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import android.text.BoringLayout; import android.text.Layout; import android.text.StaticLayout; import android.text.TextUtils; import android.text.method.TransformationMethod; import android.util.AttributeSet; import android.view.RemotableViewMethod; import android.widget.RemoteViews; Loading Loading @@ -68,7 +69,12 @@ public class ImageFloatingTextView extends TextView { protected Layout makeSingleLayout(int wantWidth, BoringLayout.Metrics boring, int ellipsisWidth, Layout.Alignment alignment, boolean shouldEllipsize, TextUtils.TruncateAt effectiveEllipsize, boolean useSaved) { CharSequence text = getText() == null ? "" : getText(); TransformationMethod transformationMethod = getTransformationMethod(); CharSequence text = getText(); if (transformationMethod != null) { text = transformationMethod.getTransformation(text, this); } text = text == null ? "" : text; StaticLayout.Builder builder = StaticLayout.Builder.obtain(text, 0, text.length(), getPaint(), wantWidth) .setAlignment(alignment) Loading
core/tests/coretests/src/com/android/internal/widget/ImageFloatingTextViewTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -21,9 +21,11 @@ import static org.junit.Assert.assertTrue; import android.content.Context; import android.support.test.InstrumentationRegistry; import android.support.test.filters.SmallTest; import android.text.Layout; import android.view.View.MeasureSpec; import android.widget.TextView; import org.junit.Assert; import org.junit.Before; import org.junit.Test; Loading Loading @@ -102,6 +104,16 @@ public class ImageFloatingTextViewTest { + "Yada yada, yada yada. Lorem ipsum dolor sit amet."); } @Test public void usesTransformationMethod() { mView.setSingleLine(); String text = "Test \n Test"; parametrizedTest(text); Layout layout = mView.getLayout(); Assert.assertFalse("The transformation method wasn't used, string is still the same", text.equals(layout.getText())); } private void parametrizedTest(CharSequence text) { int heightMeasureSpec = MeasureSpec.makeMeasureSpec(500, MeasureSpec.AT_MOST); int widthMeasureSpec = MeasureSpec.makeMeasureSpec(500, MeasureSpec.EXACTLY); Loading