Skip to content

Commit 6c0991b

Browse files
authored
Merge pull request #18 from Irineu333/release/v1.0.4
Release/v1.0.4
2 parents d4db1c5 + c53fd48 commit 6c0991b

31 files changed

+679
-582
lines changed

.idea/deploymentTargetDropDown.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 52 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ highlight.addScheme(
1414
new ColorScheme(
1515
Pattern.compile("\\b([Jj])ava\\b"),
1616
Color.parseColor("#FC0400")
17-
)
18-
);
19-
20-
highlight.addScheme(
17+
),
2118
new ColorScheme(
2219
Pattern.compile("\\b([Kk])otlin\\b"),
2320
Color.parseColor("#FC8500")
@@ -41,10 +38,7 @@ highlightTextWatcher.addScheme(
4138
new StyleScheme(
4239
Pattern.compile("\\b([Jj])ava\\b"),
4340
StyleScheme.STYLE.BOLD_ITALIC
44-
).setClearOldSpan(true)
45-
);
46-
47-
highlightTextWatcher.addScheme(
41+
).setClearOldSpan(true),
4842
new StyleScheme(
4943
Pattern.compile("\\b([Kk])otlin\\b"),
5044
StyleScheme.STYLE.BOLD_ITALIC
@@ -55,34 +49,31 @@ highlightTextWatcher.addScheme(
5549
binding.edittext.addTextChangedListener(highlightTextWatcher);
5650
```
5751
## Schemes
58-
Use the default schemes; `ColorScheme`, `StyleScheme`, `LinkScheme` and `OnClickScheme`, or implement the `Scheme` interface to create a custom scheme.
52+
Use the default schemes; `ColorScheme`, `OnBackgroundScheme`, `StyleScheme`, `FontScheme`, `LinkScheme` and `OnClickScheme`, or implement the `Scheme` interface to create a custom scheme.
5953

6054
``` java
6155
...
6256

6357
highlight.addScheme(
64-
//modify the style
6558
new StyleScheme(
6659
Pattern.compile("Highlight"),
6760
StyleScheme.STYLE.BOLD_ITALIC
61+
).addScopeScheme(
62+
//scheme in scope of other schemes
63+
new ColorScheme(
64+
Pattern.compile("light"),
65+
Color.parseColor("#FF03DAC5")
66+
)
6867
)
6968
);
7069

7170
highlight.addScheme(
72-
//modify the text color
73-
new ColorScheme(
74-
Pattern.compile("light"),
75-
Color.parseColor("#FF03DAC5")
76-
)
77-
);
78-
79-
highlight.addScheme(
80-
//make the links clickable
71+
//clickable links
8172
new LinkScheme().setPainTextUnderline(false)
8273
);
8374

8475
highlight.addScheme(
85-
//make a clickable text
76+
//clickable text
8677
new OnClickScheme(
8778
Pattern.compile("Highlight"),
8879
new OnClickScheme.OnClickListener() {
@@ -95,30 +86,50 @@ highlight.addScheme(
9586
);
9687

9788
highlight.addScheme(
98-
//create the custom scheme
99-
new Scheme() {
100-
@Override
101-
public Pattern getRegex() {
102-
return Pattern.compile("Highlight");
103-
}
104-
105-
@Override
106-
public Object getSpan(@NonNull CharSequence text) {
107-
return new BackgroundColorSpan(Color.GRAY);
108-
}
109-
110-
@Override
111-
public boolean getClearOldSpan() {
112-
return false;
113-
}
114-
});
115-
116-
//for the library to know how to remove span
117-
highlight.addSpanType(BackgroundColorSpan.class);
89+
new ColorScheme(
90+
Pattern.compile("Project"),
91+
Color.BLACK
92+
).addScopeScheme(
93+
//font scheme
94+
new FontScheme(
95+
FontScheme.getFont(this, R.font.pacifico_regular)
96+
)
97+
)
98+
);
99+
118100
...
119101
```
120102

121-
## Performance
103+
## SchemeScope
104+
105+
Every schema has a scope to which other schemas can be added via the `addScopeScheme (...)` method. Schemes added to a scope will run only within that scope, saving processing and creating possibilities for smarter highlights.
106+
107+
``` java
108+
Highlight highlight = new Highlight();
109+
110+
highlight.addScheme(
111+
new StyleScheme(
112+
Pattern.compile("Highlight"),
113+
StyleScheme.STYLE.BOLD_ITALIC
114+
).addScopeScheme(
115+
//add scheme scope in any scheme
116+
new ColorScheme(
117+
Pattern.compile("light"),
118+
Color.parseColor("#FF03DAC5")
119+
)
120+
)
121+
);
122+
123+
highlight.addScheme(
124+
//use scope to group schemes
125+
new Scope(Pattern.compile("Project"),
126+
new ColorScheme(Color.BLACK),
127+
new FontScheme(FontScheme.getFont(this, R.font.pacifico_regular))
128+
)
129+
);
130+
131+
highlight.setSpan(binding.toolbarTitle);
132+
```
122133

123134
## Add to project
124135

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ android {
2727
}
2828

2929
compileOptions {
30-
sourceCompatibility JavaVersion.VERSION_11
31-
targetCompatibility JavaVersion.VERSION_11
30+
sourceCompatibility JavaVersion.VERSION_1_8
31+
targetCompatibility JavaVersion.VERSION_1_8
3232
}
3333
}
3434

0 commit comments

Comments
 (0)