Skip to content

Commit 90f79bd

Browse files
author
roman_tcaregorodtcev
committed
Merge branch 'develop' of https://github.com/Omega-R/OmegaViews into feature/text_appearance
# Conflicts: # omegaviwslibs/src/main/java/com/omega_r/libs/views/OmegaTextView.kt
2 parents 2959452 + e528177 commit 90f79bd

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

omegaviwslibs/src/main/java/com/omega_r/libs/views/OmegaTextView.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ open class OmegaTextView @JvmOverloads constructor(
5858
}
5959

6060
private val startTextStyle = Style()
61+
private val middleTextStyle = Style()
6162
private val endTextStyle = Style()
6263

6364
private var initData: Boolean = true
@@ -85,24 +86,36 @@ open class OmegaTextView @JvmOverloads constructor(
8586
R.styleable.OmegaTextView_startTextSize -> {
8687
startTextStyle.textSize = Size.from(a.getDimension(attr, 0f), Size.Unit.PX)
8788
}
89+
R.styleable.OmegaTextView_middleTextSize -> {
90+
middleTextStyle.textSize = Size.from(a.getDimension(attr, 0f), Size.Unit.PX)
91+
}
8892
R.styleable.OmegaTextView_endTextSize -> {
8993
endTextStyle.textSize = Size.from(a.getDimension(attr, 0f), Size.Unit.PX)
9094
}
9195
R.styleable.OmegaTextView_startTextStyle -> {
9296
startTextStyle.style = a.getInt(attr, STYLE_NONE)
9397
}
98+
R.styleable.OmegaTextView_middleTextStyle -> {
99+
middleTextStyle.style = a.getInt(attr, STYLE_NONE)
100+
}
94101
R.styleable.OmegaTextView_endTextStyle -> {
95102
endTextStyle.style = a.getInt(attr, STYLE_NONE)
96103
}
97104
R.styleable.OmegaTextView_startTextColor -> {
98105
startTextStyle.textColor = a.getColor(attr, startTextStyle.textColor)
99106
}
107+
R.styleable.OmegaTextView_middleTextColor -> {
108+
middleTextStyle.textColor = a.getColor(attr, middleTextStyle.textColor)
109+
}
100110
R.styleable.OmegaTextView_endTextColor -> {
101111
endTextStyle.textColor = a.getColor(attr, endTextStyle.textColor)
102112
}
103113
R.styleable.OmegaTextView_startTextFontFamily -> {
104114
obtainFont(intoStyle = startTextStyle, typedArray = a, attr = attr)
105115
}
116+
R.styleable.OmegaTextView_middleTextFontFamily -> {
117+
obtainFont(intoStyle = middleTextStyle, typedArray = a, attr = attr)
118+
}
106119
R.styleable.OmegaTextView_endTextFontFamily -> {
107120
obtainFont(intoStyle = endTextStyle, typedArray = a, attr = attr)
108121
}
@@ -166,7 +179,11 @@ open class OmegaTextView @JvmOverloads constructor(
166179

167180
private fun updateAllText(force: Boolean = false) {
168181
if (initData || force) {
169-
val allText = (startText + startTextStyle) + startSpaceText + text + endSpaceText + (endText + endTextStyle)
182+
val allText = (startText + startTextStyle) +
183+
startSpaceText +
184+
(text + middleTextStyle) +
185+
endSpaceText +
186+
(endText + endTextStyle)
170187
super.setText(allText?.getCharSequence(context), BufferType.NORMAL)
171188
}
172189
}

omegaviwslibs/src/main/res/values/attrs.xml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,40 @@
44
<declare-styleable name="OmegaTextView">
55
<attr name="startText" format="string" localization="suggested"/>
66
<attr name="endText" format="string" localization="suggested"/>
7-
<attr name="startTextSize" format="dimension" />
8-
<attr name="endTextSize" format="dimension" />
7+
<attr name="startTextSize" format="dimension"/>
8+
<attr name="middleTextSize" format="dimension"/>
9+
<attr name="endTextSize" format="dimension"/>
910

10-
<attr name="startTextStyle" format="flags" >
11+
<attr name="startTextStyle" format="flags">
1112
<flag name="bold" value="1"/>
1213
<flag name="italic" value="2"/>
1314
<flag name="underline" value="4"/>
1415
<flag name="strikethrough" value="8"/>
1516
</attr>
1617

17-
<attr name="endTextStyle" format="flags" >
18-
<flag name="none" value="0"/>
18+
<attr name="middleTextStyle" format="flags">
19+
<flag name="bold" value="1"/>
20+
<flag name="italic" value="2"/>
21+
<flag name="underline" value="4"/>
22+
<flag name="strikethrough" value="8"/>
23+
</attr>
24+
25+
<attr name="endTextStyle" format="flags">
1926
<flag name="bold" value="1"/>
2027
<flag name="italic" value="2"/>
2128
<flag name="underline" value="4"/>
2229
<flag name="strikethrough" value="8"/>
2330
</attr>
2431

2532
<attr name="startTextColor" format="color"/>
33+
<attr name="middleTextColor" format="color"/>
2634
<attr name="endTextColor" format="color"/>
27-
<attr name="startTextFontFamily" />
28-
<attr name="endTextFontFamily" />
35+
<attr name="startTextFontFamily"/>
36+
<attr name="middleTextFontFamily"/>
37+
<attr name="endTextFontFamily"/>
2938

30-
<attr name="startDelimiter" format="string" />
31-
<attr name="endDelimiter" format="string" />
39+
<attr name="startDelimiter" format="string"/>
40+
<attr name="endDelimiter" format="string"/>
3241

3342
</declare-styleable>
3443

0 commit comments

Comments
 (0)