Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
6438e1cd
authored
Apr 02, 2020
by
ibaker
Committed by
Oliver Woodman
Apr 06, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add support for tate-chu-yoko to SpannedToHtmlConverter
PiperOrigin-RevId: 304386857
parent
fe013979
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
library/ui/src/main/java/com/google/android/exoplayer2/ui/SpannedToHtmlConverter.java
library/ui/src/test/java/com/google/android/exoplayer2/ui/SpannedToHtmlConverterTest.java
library/ui/src/main/java/com/google/android/exoplayer2/ui/SpannedToHtmlConverter.java
View file @
6438e1cd
...
...
@@ -26,6 +26,7 @@ import android.text.style.UnderlineSpan;
import
android.util.SparseArray
;
import
androidx.annotation.ColorInt
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.text.span.HorizontalTextInVerticalContextSpan
;
import
com.google.android.exoplayer2.text.span.RubySpan
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Util
;
...
...
@@ -124,6 +125,8 @@ import java.util.regex.Pattern;
ForegroundColorSpan
colorSpan
=
(
ForegroundColorSpan
)
span
;
return
Util
.
formatInvariant
(
"<span style='color:%s;'>"
,
toCssColor
(
colorSpan
.
getForegroundColor
()));
}
else
if
(
span
instanceof
HorizontalTextInVerticalContextSpan
)
{
return
"<span style='text-combine-upright:all;'>"
;
}
else
if
(
span
instanceof
StyleSpan
)
{
switch
(((
StyleSpan
)
span
).
getStyle
())
{
case
Typeface
.
BOLD
:
...
...
@@ -158,6 +161,8 @@ import java.util.regex.Pattern;
private
static
String
getClosingTag
(
Object
span
)
{
if
(
span
instanceof
ForegroundColorSpan
)
{
return
"</span>"
;
}
else
if
(
span
instanceof
HorizontalTextInVerticalContextSpan
)
{
return
"</span>"
;
}
else
if
(
span
instanceof
StyleSpan
)
{
switch
(((
StyleSpan
)
span
).
getStyle
())
{
case
Typeface
.
BOLD
:
...
...
library/ui/src/test/java/com/google/android/exoplayer2/ui/SpannedToHtmlConverterTest.java
View file @
6438e1cd
...
...
@@ -26,6 +26,7 @@ import android.text.style.ForegroundColorSpan;
import
android.text.style.StyleSpan
;
import
android.text.style.UnderlineSpan
;
import
androidx.test.ext.junit.runners.AndroidJUnit4
;
import
com.google.android.exoplayer2.text.span.HorizontalTextInVerticalContextSpan
;
import
com.google.android.exoplayer2.text.span.RubySpan
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
...
...
@@ -50,6 +51,23 @@ public class SpannedToHtmlConverterTest {
}
@Test
public
void
convert_supportsHorizontalTextInVerticalContextSpan
()
{
SpannableString
spanned
=
new
SpannableString
(
"Vertical text with 123 horizontal numbers"
);
spanned
.
setSpan
(
new
HorizontalTextInVerticalContextSpan
(),
"Vertical text with "
.
length
(),
"Vertical text with 123"
.
length
(),
Spanned
.
SPAN_EXCLUSIVE_EXCLUSIVE
);
String
html
=
SpannedToHtmlConverter
.
convert
(
spanned
);
assertThat
(
html
)
.
isEqualTo
(
"Vertical text with <span style='text-combine-upright:all;'>123</span> "
+
"horizontal numbers"
);
}
@Test
public
void
convert_supportsStyleSpan
()
{
SpannableString
spanned
=
new
SpannableString
(
"String with bold, italic and bold-italic sections."
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment