@@ -71,6 +71,11 @@ class StatusView @JvmOverloads constructor(
7171 currentStatusRadius = circleRadius * (1 + value)
7272 }
7373
74+ /* *
75+ * A min margin that there should be between every adjacent status Text
76+ * Note# This only applies if obeyLineLength is set to false
77+ */
78+ var minMarginStatusText: Float by OnLayoutProp (10.0f .pxValue())
7479
7580 /* *
7681 * Set true to obey Status Text i.e alphabets or words belonging to one line would not cross
@@ -335,7 +340,8 @@ class StatusView @JvmOverloads constructor(
335340 * Stores all the drawing data that is used while drawing on canvas
336341 */
337342 private var drawingData = mutableListOf<Item >()
338- private var currentStatusRadius: Float by OnLayoutProp (circleRadius);
343+ private var currentStatusRadius: Float by OnLayoutProp (circleRadius)
344+ private var lineLengthComputed = 0.0f
339345
340346
341347
@@ -376,6 +382,7 @@ class StatusView @JvmOverloads constructor(
376382 drawLabels = a.getBoolean(R .styleable.StatusView_drawCount , drawLabels)
377383 obeyLineLength = a.getBoolean(R .styleable.StatusView_obeyLineLength , obeyLineLength)
378384 lineGap = a.getDimension(R .styleable.StatusView_lineGap , lineGap)
385+ minMarginStatusText = a.getDimension(R .styleable.StatusView_minMarginStatus , minMarginStatusText)
379386 labelTopMargin = a.getDimension(R .styleable.StatusView_labelTopMargin , labelTopMargin)
380387
381388
@@ -518,6 +525,7 @@ class StatusView @JvmOverloads constructor(
518525 override fun getSuggestedMinimumWidth (): Int {
519526
520527
528+ lineLengthComputed = lineLength
521529 var extraWidth = if (obeyLineLength){
522530 setWidthDataForObeyingLineLength()
523531 }else {
@@ -533,7 +541,7 @@ class StatusView @JvmOverloads constructor(
533541 extraWidth * = 2
534542 }
535543
536- return ((statusCount * (2 * (circleRadius + (circleStrokeWidth/ 2 )))) + ((statusCount - 1 ) * ( lineLength + (lineGap * 2 ))) + extraWidth).toInt()
544+ return ((statusCount * (2 * (circleRadius + (circleStrokeWidth/ 2 )))) + ((statusCount - 1 ) * ( lineLengthComputed + (lineGap * 2 ))) + extraWidth).toInt()
537545 }
538546
539547
@@ -686,7 +694,7 @@ class StatusView @JvmOverloads constructor(
686694 }
687695 }else {
688696 lastPoint.x + = lineGap
689- lineItem = LineItem (PointF (lastPoint.x, lastPoint.y), PointF (lastPoint.x + lineLength , lastPoint.y), linePaint)
697+ lineItem = LineItem (PointF (lastPoint.x, lastPoint.y), PointF (lastPoint.x + lineLengthComputed , lastPoint.y), linePaint)
690698 lastPoint.x = lineItem.end.x + lineGap + (circleStrokeWidth / 2 )
691699 }
692700
@@ -771,17 +779,18 @@ class StatusView @JvmOverloads constructor(
771779
772780 val widestLineData: StatusTextWidthInfo = getStatusTextWidthInfo(statusData.map { it.text }, mTextPaintStatus)
773781
774- lineLength + = widestLineData.widestStatus.width - minStatusWidth(widestLineData.widestStatus.pos)
782+ lineLengthComputed + = widestLineData.widestStatus.width - minStatusWidth(widestLineData.widestStatus.pos)
775783
776784 widestLineData.subordinateWidestStatus?.run {
777785 val minStatusWidth = minStatusWidth(pos)
778786
779787 if (width > minStatusWidth) {
780- lineLength + = width - minStatusWidth
788+ lineLengthComputed + = width - minStatusWidth
781789 }
782790 }
783791
784792
793+ var addPadding = false
785794 for (pos in 0 until statusData.size) {
786795 val item = statusData[pos]
787796 when (pos) {
@@ -802,7 +811,15 @@ class StatusView @JvmOverloads constructor(
802811 }
803812 else -> item.width = widestLineData.widestStatus.width
804813 }
814+ if (minMarginStatusText> 0 && ! addPadding && pos in 1 until statusData.size){
815+ if (minStatusWidth(pos)+ minStatusWidth(pos- 1 ) - (item.width+ statusData[pos- 1 ].width)< minMarginStatusText){
816+ addPadding = true
817+ }
805818
819+ }
820+ }
821+ if (addPadding){
822+ lineLengthComputed+ = minMarginStatusText
806823 }
807824 return extraWidth
808825 }
@@ -811,7 +828,7 @@ class StatusView @JvmOverloads constructor(
811828 private fun minStatusWidth (pos : Int ): Float {
812829
813830 var circleRadius = this .circleRadius
814- val lineWidth = (lineLength + lineGap* 2 )
831+ val lineWidth = (lineLengthComputed + lineGap* 2 )
815832
816833 if (isShowingCurrentStatus() && pos== currentCountIndex()){
817834 circleRadius = currentStatusRadius
0 commit comments