Skip to content

Commit cc1e326

Browse files
author
Parminder
committed
dev: line length fix
1 parent 3429483 commit cc1e326

5 files changed

Lines changed: 15 additions & 11 deletions

File tree

.idea/misc.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.

app/src/main/java/jugnoo/com/learningcustomvviews/StatusView.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class StatusView @JvmOverloads constructor(
7575
* A min margin that there should be between every adjacent status Text
7676
* Note# This only applies if obeyLineLength is set to false
7777
*/
78-
var minMarginStatusText: Float by OnLayoutProp(10.0f.pxValue())
78+
var minMarginStatusText: Float by OnLayoutProp(5.0f.pxValue())
7979

8080
/**
8181
* Set true to obey Status Text i.e alphabets or words belonging to one line would not cross
@@ -111,7 +111,7 @@ class StatusView @JvmOverloads constructor(
111111
* Length of line to be drawn between circles
112112
* #Note: This does not include line gap
113113
*/
114-
var lineLength: Float = 30.0f.pxValue()/* by OnLayoutProp(30.0f.pxValue())*/ //dp
114+
var lineLength: Float by OnLayoutProp(30.0f.pxValue()) //dp
115115

116116
/**
117117
* Stroke width of each circle to be drawn
@@ -382,7 +382,7 @@ class StatusView @JvmOverloads constructor(
382382
drawLabels = a.getBoolean(R.styleable.StatusView_drawCount, drawLabels)
383383
obeyLineLength = a.getBoolean(R.styleable.StatusView_obeyLineLength, obeyLineLength)
384384
lineGap = a.getDimension(R.styleable.StatusView_lineGap, lineGap)
385-
minMarginStatusText = a.getDimension(R.styleable.StatusView_minMarginStatus, minMarginStatusText)
385+
minMarginStatusText = a.getDimension(R.styleable.StatusView_minStatusMargin, minMarginStatusText)
386386
labelTopMargin = a.getDimension(R.styleable.StatusView_labelTopMargin, labelTopMargin)
387387

388388

@@ -779,7 +779,11 @@ class StatusView @JvmOverloads constructor(
779779

780780
val widestLineData: StatusTextWidthInfo = getStatusTextWidthInfo(statusData.map { it.text }, mTextPaintStatus)
781781

782-
lineLengthComputed += widestLineData.widestStatus.width - minStatusWidth(widestLineData.widestStatus.pos)
782+
val minStatusWidthWidestPos = minStatusWidth(widestLineData.widestStatus.pos)
783+
if(widestLineData.widestStatus.width>minStatusWidthWidestPos){
784+
lineLengthComputed += widestLineData.widestStatus.width - minStatusWidthWidestPos
785+
786+
}
783787

784788
widestLineData.subordinateWidestStatus?.run {
785789
val minStatusWidth = minStatusWidth(pos)

app/src/main/res/layout/activity_main.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
app:circleColorType="fillStroke"
2525
app:statusCount="3"
2626
app:currentCount="1"
27+
app:lineLength="5dp"
2728
app:circleRadius="30dp"
28-
app:minMarginStatus="20dp"
29-
app:lineLength="50dp"
29+
app:minStatusMargin="20dp"
3030
app:obeyLineLength="false"
3131
app:currentStatusZoom="0.0"
3232
app:drawCount="true"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<attr name="drawCount" format="boolean"/>
3737
<attr name="obeyLineLength" format="boolean"/>
3838
<attr name="lineGap" format="dimension"/>
39-
<attr name="minMarginStatus" format="dimension"/>
39+
<attr name="minStatusMargin" format="dimension"/>
4040
<attr name="labelTopMargin" format="dimension"/>
4141
<attr name="currentStatusZoom" format="float"/>
4242
<attr name="android:entries" />

app/src/main/res/values/strings.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<string name="customViewLabel">Fan Control</string>
44

55
<string-array name="statuses">
6-
<item>pamDreeeeeee</item>
7-
<item>pamDreeeeeee</item>
8-
<item>pamDrqww</item>
6+
<item>pamewqeqwe</item>
7+
<item>pamewqeqwe</item>
8+
<item>pamDewqe</item>
99
</string-array>
1010
</resources>

0 commit comments

Comments
 (0)