Skip to content

Commit 78d591e

Browse files
author
Parminder
committed
dev: obeyLineLength param added
1 parent fad779d commit 78d591e

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,16 @@ class StatusView @JvmOverloads constructor(
7272
}
7373

7474

75+
/**
76+
* Set true to obey Status Text i.e alphabets or words belonging to one line would not cross
77+
* to the other line so the line length between circles would be increased as per if needed.
78+
*
79+
* Set false to strictly obey line length.
80+
*
81+
*
82+
*/
83+
var obeyLineLength: Boolean by OnLayoutProp(false)
84+
7585

7686
/**
7787
* The total number of statuses to be displayed
@@ -286,6 +296,7 @@ class StatusView @JvmOverloads constructor(
286296
if((oldHadStrokeFlagSet && !newHasStrokeFlagSet) || (!oldHadStrokeFlagSet && newHasStrokeFlagSet))
287297
{
288298
requestLayout()
299+
289300
}else{
290301
setDrawingDimensions()
291302
invalidate()
@@ -363,6 +374,7 @@ class StatusView @JvmOverloads constructor(
363374
incompleteDrawable = a.getDrawable(R.styleable.StatusView_incomplete_drawable)
364375
currentDrawable = a.getDrawable(R.styleable.StatusView_current_drawable)
365376
drawLabels = a.getBoolean(R.styleable.StatusView_drawCount, drawLabels)
377+
obeyLineLength = a.getBoolean(R.styleable.StatusView_obeyLineLength, obeyLineLength)
366378
lineGap = a.getDimension(R.styleable.StatusView_lineGap, lineGap)
367379
labelTopMargin = a.getDimension(R.styleable.StatusView_labelTopMargin, labelTopMargin)
368380

@@ -506,10 +518,10 @@ class StatusView @JvmOverloads constructor(
506518
override fun getSuggestedMinimumWidth(): Int {
507519

508520

509-
var extraWidth = if(true){
510-
setWidthDataForObeyingStatusText()
511-
}else{
521+
var extraWidth = if(obeyLineLength){
512522
setWidthDataForObeyingLineLength()
523+
}else{
524+
setWidthDataForObeyingStatusText()
513525
}
514526

515527
if(isShowingCurrentStatus()){

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
app:circleColorType="fillStroke"
2525
app:statusCount="3"
2626
app:currentCount="1"
27+
app:circleRadius="30dp"
2728
app:lineLength="50dp"
29+
app:obeyLineLength="true"
2830
app:currentStatusZoom="0.0"
2931
app:drawCount="true"
3032
app:textSize="20sp"

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<attr name="current_drawable" format="reference"/>
3535
<attr name="incomplete_drawable" format="reference"/>
3636
<attr name="drawCount" format="boolean"/>
37+
<attr name="obeyLineLength" format="boolean"/>
3738
<attr name="lineGap" format="dimension"/>
3839
<attr name="labelTopMargin" format="dimension"/>
3940
<attr name="currentStatusZoom" format="float"/>

0 commit comments

Comments
 (0)