Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
QuasselDroid-ng
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Janne Mareike Koschinski
QuasselDroid-ng
Commits
d1642750
Commit
d1642750
authored
7 years ago
by
Janne Mareike Koschinski
Browse files
Options
Downloads
Patches
Plain Diff
Fixed minor bug
parent
a5116c7d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/de/kuschku/quasseldroid/util/ui/SpanFormatter.kt
+2
-17
2 additions, 17 deletions
...ain/java/de/kuschku/quasseldroid/util/ui/SpanFormatter.kt
with
2 additions
and
17 deletions
app/src/main/java/de/kuschku/quasseldroid/util/ui/SpanFormatter.kt
+
2
−
17
View file @
d1642750
...
...
@@ -30,22 +30,6 @@ import java.util.regex.Pattern
object
SpanFormatter
{
private
val
FORMAT_SEQUENCE
=
Pattern
.
compile
(
"%([0-9]+\\$|<?)([^a-zA-z%]*)([[a-zA-Z%]&&[^tT]]|[tT][a-zA-Z])"
)
/**
* Version of [String.format] that works on [Spanned] strings to preserve rich text formatting.
* Both the `format` as well as any `%s args` can be Spanned and will have their formatting preserved.
* Due to the way [Spannable]s work, any argument's spans will can only be included **once** in the result.
* Any duplicates will appear as text only.
*
* @param format the format string (see [java.util.Formatter.format])
* @param args the list of arguments passed to the formatter. If there are
* more arguments than required by `format`,
* additional arguments are ignored.
* @return the formatted string (with spans).
*/
fun
format
(
format
:
CharSequence
,
vararg
args
:
Any
):
SpannedString
{
return
format
(
Locale
.
getDefault
(),
format
,
*
args
)
}
/**
* Version of [String.format] that works on [Spanned] strings to preserve rich text formatting.
* Both the `format` as well as any `%s args` can be Spanned and will have their formatting preserved.
...
...
@@ -58,7 +42,8 @@ object SpanFormatter {
* @return the formatted string (with spans).
* @see String.format
*/
fun
format
(
locale
:
Locale
,
format
:
CharSequence
,
vararg
args
:
Any
):
SpannedString
{
fun
format
(
format
:
CharSequence
,
vararg
args
:
Any
?,
locale
:
Locale
=
Locale
.
getDefault
()):
SpannedString
{
val
out
=
SpannableStringBuilder
(
format
)
var
i
=
0
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment