Skip to content

Commit 3f697d0

Browse files
committed
Release 0.3
1 parent c353c6f commit 3f697d0

File tree

4 files changed

+53
-14
lines changed

4 files changed

+53
-14
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### v0.3
2+
3+
- Add missing spans
4+
- Add link to docs
5+
16
### v0.2
27

38
- New span support: `click`, `url`, `custom`

README.md

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
[![](https://jitpack.io/v/neworld/spanner.svg)](https://jitpack.io/#neworld/spanner)
2+
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Spanner-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/6271)
23

34
This lib provides simple and fluent API for creating [Android Spannable](https://developer.android.com/reference/android/text/Spannable.html).
45
Features:
56
- Simple and fluent API
67
- Helpers to create spans
7-
- Small method footprint (<100 methods, 16kb AAR package)
8+
- Small method footprint (<200 methods, 24kb AAR package)
89

910
This library focuses on building spannable.
1011
If you prefer put full text first and then apply spans, take a look at [another awesome library](https://github.com/jaychang0917/SimpleText)
@@ -14,7 +15,8 @@ If you prefer put full text first and then apply spans, take a look at [another
1415
```java
1516
Spannable spannable = new Spanner()
1617
.append("Original text\n\n")
17-
.append("big\n", Spans.sizePX(100))
18+
.append("Big and blurry\n", Spans.sizePX(100))
19+
.span("blurry", blur(5.0f, BlurMaskFilter.Blur.SOLID))
1820
.append("big in DP\n", sizeDP(30))
1921
.append("50% of original size\n", scaleSize(0.5f))
2022
.append("bold\n", bold())
@@ -35,7 +37,12 @@ Spannable spannable = new Spanner()
3537
.append("http://www.android.com\n", url("http://www.android.com"))
3638
;
3739
```
38-
Here is more methods to work with text:
40+
41+
It looks like:
42+
43+
![preview](https://i.imgur.com/SRnNRdm.png?1)
44+
45+
You can manipulate text in many more ways:
3946
```java
4047
Spannable spannable = new Spanner("The quick brown fox jumps over the lazy dog")
4148
.span("fox", foreground(Color.RED)) // search and span by given text
@@ -44,14 +51,7 @@ Spannable spannable = new Spanner("The quick brown fox jumps over the lazy dog")
4451
.append("bar", underline()); // any number of spans
4552
```
4653

47-
You can use `span` to apply spans on the existing text:
48-
```java
49-
Spannable spannable = new Spanner("The quick brown fox jumps over the lazy dog")
50-
.span("fox", foreground(Color.RED))
51-
.span("dog", foreground(Color.BLUE));
52-
```
53-
54-
If you need custom span, you have to use builder:
54+
If you need custom span, you need span builder:
5555
```
5656
//java 7
5757
Spannable spannable = new Spanner("The quick brown fox jumps over the lazy dog")
@@ -71,6 +71,35 @@ val spannable = Spanner("The quick brown fox jumps over the lazy dog")
7171
.span("fox", custom { StyleSpan(Typeface.ITALIC) })
7272
```
7373

74+
#### Reference
75+
76+
| Main spans |
77+
|------------------------------------|
78+
| sizePx(int) |
79+
| sizeDP(int) |
80+
| scaleSize(float) |
81+
| bold() |
82+
| italic() |
83+
| boldItalic() |
84+
| font(String) |
85+
| strikeThrough() |
86+
| underline() |
87+
| background(int color) |
88+
| foreground(int color) |
89+
| subscript() |
90+
| superscript() |
91+
| image(...) |
92+
| click(listener) |
93+
| url(url) |
94+
| custom(spanBuilder) |
95+
96+
| Modify methods | Description |
97+
| --------------- | --------------------------- |
98+
| append(text, spans...) | appends text |
99+
| replace(search, replace, spans...)| search and replace text |
100+
| span(search, spans...) | search text and apply spans |
101+
| insert(pos, text, spans...) | instert given text in given position |
102+
74103
#### How to use
75104
```
76105
allprojects {
@@ -81,7 +110,7 @@ val spannable = Spanner("The quick brown fox jumps over the lazy dog")
81110
}
82111
83112
dependencies {
84-
compile 'lt.neworld:spanner:v0.2'
113+
compile 'lt.neworld:spanner:v0.3'
85114
}
86115
```
87116

sample/build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ android {
1111
}
1212
}
1313

14+
repositories {
15+
maven { url 'https://jitpack.io' }
16+
}
17+
1418
dependencies {
15-
compile project(":lib")
19+
compile 'lt.neworld:spanner:c353c6fa50'
1620
compile "com.android.support:appcompat-v7:$SUPPORT_LIB_VERSION"
1721
}

sample/src/main/java/lt/neworld/spanner/sample/SampleJavaActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public void onClick(View view) {
4343
// @formatter:off
4444
Spannable spannable = new Spanner()
4545
.append("Original text\n\n")
46-
.append("big\n", Spans.sizePX(100))
46+
.append("Big and blurry\n", Spans.sizePX(100))
47+
.span("blurry", blur(5.0f, BlurMaskFilter.Blur.SOLID))
4748
.append("big in DP\n", sizeDP(30))
4849
.append("50% of original size\n", scaleSize(0.5f))
4950
.append("bold\n", bold())

0 commit comments

Comments
 (0)