Skip to content

Commit 95a1878

Browse files
committed
attrs, vars renamed
1 parent 276fe66 commit 95a1878

5 files changed

Lines changed: 96 additions & 79 deletions

File tree

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
# StepViewAndroid
2-
An android library written in kotlin to display steps (without any max-min limits) along with the status/description. It also supports some really cool features.
2+
An Android library written in kotlin to display steps (without any max-min limits) along with the status/description. It also supports some really cool features.
33

44
## Usage
55

66
### A customised StepView
77

88
![Downloading..](https://github.com/params-ing/StepViewAndroid/blob/dev/screenshots/colors_stepview.png)
99

10-
* Set total step count and current count.
10+
* Set step count and current count.
1111

12-
* Set different dimensions for stroke width, line width, text size of label (step count) & line Gap.
12+
* Set different dimensions for circle radius, line length, line gap, stroke width, line width, text size of label (step count).
13+
14+
* Set status data using ```android:entries```
15+
16+
* Chose a color mode i.e fill, stroke or both using ```circleColorType```
1317

1418
* Stroke color (circle), fill color (circle), line color & label text color can be set differently for completed, current & incomplete states.
1519

@@ -19,7 +23,7 @@ An android library written in kotlin to display steps (without any max-min limit
1923
android:layout_height="wrap_content"
2024
app:stepCount="5"
2125
app:currentCount="4"
22-
app:drawCount="true"
26+
app:drawLabels="true"
2327
android:entries="@array/status"
2428
app:circleColorType="fillStroke"
2529
app:lineGap="5dp"
@@ -36,7 +40,7 @@ An android library written in kotlin to display steps (without any max-min limit
3640
app:circleStrokeWidth="4dp"
3741
app:circleStrokeColorCurrent="#91A8D0"
3842
app:textSizeLabels="15sp"
39-
app:complete_drawable="@drawable/ic_done_black_24dp" />
43+
app:completeDrawable="@drawable/ic_done_black_24dp" />
4044
```
4145

4246
### Some more customisations
@@ -48,12 +52,12 @@ An android library written in kotlin to display steps (without any max-min limit
4852

4953
```XML
5054
app:currentStepZoom="0.5"
51-
app:complete_drawable="@drawable/ic_satisfied_black_24dp"
52-
app:current_drawable="@drawable/ic_dissatisfied_black_24dp"
53-
app:incomplete_drawable="@drawable/ic_very_dissatisfied_black_24dp"
55+
app:completeDrawable="@drawable/ic_satisfied_black_24dp"
56+
app:currentDrawable="@drawable/ic_dissatisfied_black_24dp"
57+
app:incompleteDrawable="@drawable/ic_very_dissatisfied_black_24dp"
5458
```
5559

56-
### Step Status customisations
60+
### Step status customisations
5761

5862
![Downloading..](https://github.com/params-ing/StepViewAndroid/blob/dev/screenshots/android_stepview.png)
5963

@@ -79,4 +83,4 @@ An android library written in kotlin to display steps (without any max-min limit
7983
![Downloading..](https://github.com/params-ing/StepViewAndroid/blob/dev/screenshots/fragment_scroll_stepview.gif)
8084

8185
* The view can be scrolled if the content exceeds the available width.
82-
* You can also scroll to a particular step by calling ```statusViewScroller.scrollToPos(stepCount)```
86+
* You can also scroll to a particular step by calling ```statusViewScroller.scrollToStep(stepCount)```

app/src/main/java/params/com/statusView/StatusView.kt

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ class StatusViewScroller @JvmOverloads constructor(
2626
addView(statusView)
2727
}
2828

29-
fun scrollToPos(count:Int){
30-
scrollTo(statusView.getScrollPosForStatus(count).toInt(),scrollY)
29+
fun scrollToStep(stepCount:Int){
30+
scrollTo(statusView.getScrollPosForStep(stepCount),scrollY)
3131
}
32-
fun smoothScrollToPos(count:Int){
33-
smoothScrollTo(statusView.getScrollPosForStatus(count).toInt(),scrollY)
32+
fun smoothScrollToStep(stepCount:Int){
33+
smoothScrollTo(statusView.getScrollPosForStep(stepCount),scrollY)
3434
}
3535
}
3636

@@ -82,9 +82,9 @@ class StatusView @JvmOverloads constructor(
8282

8383
/**
8484
* A min margin that there should be between every adjacent status Text
85-
* Note# This only applies if obeyLineLength is set to false
85+
* Note# This only applies if strictObeyLineLength is set to false
8686
*/
87-
var minMarginStatusText: Float by OnLayoutProp(5.0f.pxValue())
87+
var minStatusAdjacentMargin: Float by OnLayoutProp(5.0f.pxValue())
8888

8989
/**
9090
* Set true to obey Status Text i.e alphabets or words belonging to one line would not cross
@@ -94,13 +94,13 @@ class StatusView @JvmOverloads constructor(
9494
*
9595
*
9696
*/
97-
var obeyLineLength: Boolean by OnLayoutProp(false)
97+
var strictObeyLineLength: Boolean by OnLayoutProp(false)
9898

9999

100100
/**
101101
* The total number of statuses to be displayed
102102
*/
103-
var statusCount: Int by OnLayoutProp(4)
103+
var stepCount: Int by OnLayoutProp(4)
104104

105105
/*
106106
The count up to which status has been completed
@@ -136,9 +136,9 @@ class StatusView @JvmOverloads constructor(
136136

137137

138138
/**
139-
* Top Margin of Labels from circle
139+
* Top Margin of Status from circle
140140
*/
141-
var labelTopMargin by OnLayoutProp( 4.0f.pxValue())
141+
var statusTopMargin by OnLayoutProp( 4.0f.pxValue())
142142

143143
/**
144144
* set true to align all status to align same as current Status y-pos
@@ -151,10 +151,10 @@ class StatusView @JvmOverloads constructor(
151151
/**
152152
* Stroke width of the line between circles (dp)
153153
*/
154-
var lineStrokeWidth: Float by OnValidateProp(1.5f.pxValue()) {
155-
mLinePaint.strokeWidth = lineStrokeWidth
156-
mLinePaintIncomplete.strokeWidth = lineStrokeWidth
157-
mLinePaintCurrent.strokeWidth = lineStrokeWidth
154+
var lineWidth: Float by OnValidateProp(1.5f.pxValue()) {
155+
mLinePaint.strokeWidth = lineWidth
156+
mLinePaintIncomplete.strokeWidth = lineWidth
157+
mLinePaintCurrent.strokeWidth = lineWidth
158158
}
159159

160160
/**
@@ -366,11 +366,11 @@ class StatusView @JvmOverloads constructor(
366366

367367
/**
368368
* Creates List<LabelInfo> from List<String> by passing default values.
369-
* #Note: It trims any extra statuses (if size is greater than statusCount)
369+
* #Note: It trims any extra statuses (if size is greater than stepCount)
370370
*/
371371
fun setStatusList(list: List<String>) {
372372
//to make sure original list is not modified convert to mutableList
373-
val input = list.toMutableList().dropLast(statusCount)
373+
val input = list.toMutableList().dropLast(stepCount)
374374

375375
statusData = (input.map{StatusInfo(it)}).toMutableList()
376376

@@ -419,26 +419,26 @@ class StatusView @JvmOverloads constructor(
419419

420420
try {
421421

422-
statusCount = a.getInt(R.styleable.StatusViewScroller_statusCount, statusCount)
422+
stepCount = a.getInt(R.styleable.StatusViewScroller_stepCount, stepCount)
423423
currentCount = a.getInt(R.styleable.StatusViewScroller_currentCount, INVALID_STATUS_COUNT)
424424
circleRadius = a.getDimension(R.styleable.StatusViewScroller_circleRadius, circleRadius)
425425
lineLength = a.getDimension(R.styleable.StatusViewScroller_lineLength, lineLength)
426426
circleStrokeWidth = a.getDimension(R.styleable.StatusViewScroller_circleStrokeWidth, circleStrokeWidth)
427-
lineStrokeWidth = a.getDimension(R.styleable.StatusViewScroller_lineWidth, lineStrokeWidth)
428-
completeDrawable = a.getDrawable(R.styleable.StatusViewScroller_complete_drawable)
429-
incompleteDrawable = a.getDrawable(R.styleable.StatusViewScroller_incomplete_drawable)
430-
currentDrawable = a.getDrawable(R.styleable.StatusViewScroller_current_drawable)
431-
drawLabels = a.getBoolean(R.styleable.StatusViewScroller_drawCount, drawLabels)
432-
obeyLineLength = a.getBoolean(R.styleable.StatusViewScroller_obeyLineLength, obeyLineLength)
427+
lineWidth = a.getDimension(R.styleable.StatusViewScroller_lineWidth, lineWidth)
428+
completeDrawable = a.getDrawable(R.styleable.StatusViewScroller_completeDrawable)
429+
incompleteDrawable = a.getDrawable(R.styleable.StatusViewScroller_incompleteDrawable)
430+
currentDrawable = a.getDrawable(R.styleable.StatusViewScroller_currentDrawable)
431+
drawLabels = a.getBoolean(R.styleable.StatusViewScroller_drawLabels, drawLabels)
432+
strictObeyLineLength = a.getBoolean(R.styleable.StatusViewScroller_strictObeyLineLength, strictObeyLineLength)
433433
lineGap = a.getDimension(R.styleable.StatusViewScroller_lineGap, lineGap)
434-
minMarginStatusText = a.getDimension(R.styleable.StatusViewScroller_minStatusMargin, minMarginStatusText)
435-
labelTopMargin = a.getDimension(R.styleable.StatusViewScroller_labelTopMargin, labelTopMargin)
434+
minStatusAdjacentMargin = a.getDimension(R.styleable.StatusViewScroller_minStatusAdjacentMargin, minStatusAdjacentMargin)
435+
statusTopMargin = a.getDimension(R.styleable.StatusViewScroller_statusTopMargin, statusTopMargin)
436436
lineColor = a.getColor(R.styleable.StatusViewScroller_lineColor, lineColor)
437437
circleFillColor = a.getColor(R.styleable.StatusViewScroller_circleColor, circleFillColor)
438438
circleStrokeColor = a.getColor(R.styleable.StatusViewScroller_circleStrokeColor, circleStrokeColor)
439-
textColorStatus = a.getColor(R.styleable.StatusViewScroller_textColor, textColorStatus)
439+
textColorStatus = a.getColor(R.styleable.StatusViewScroller_textColorStatus, textColorStatus)
440440
textColorLabels = a.getColor(R.styleable.StatusViewScroller_textColorLabels, textColorLabels)
441-
textSizeStatus = a.getDimension(R.styleable.StatusViewScroller_textSize, textSizeStatus)
441+
textSizeStatus = a.getDimension(R.styleable.StatusViewScroller_textSizeStatus, textSizeStatus)
442442
textSizeLabels = a.getDimension(R.styleable.StatusViewScroller_textSizeLabels, textSizeLabels)
443443
circleColorType = a.getInteger(R.styleable.StatusViewScroller_circleColorType, circleColorType)
444444
textColorLabelsIncomplete = a.getColor(R.styleable.StatusViewScroller_textColorLabelsIncomplete, textColorLabels)
@@ -449,7 +449,7 @@ class StatusView @JvmOverloads constructor(
449449
circleStrokeColorIncomplete = a.getColor(R.styleable.StatusViewScroller_circleStrokeColorIncomplete, circleStrokeColor)
450450
circleStrokeColorCurrent = a.getColor(R.styleable.StatusViewScroller_circleStrokeColorCurrent, circleStrokeColorIncomplete)
451451
circleFillColorCurrent = a.getColor(R.styleable.StatusViewScroller_circleColorCurrent, circleFillColorIncomplete)
452-
currentStatusZoom = a.getFloat(R.styleable.StatusViewScroller_currentStatusZoom, currentStatusZoom)
452+
currentStatusZoom = a.getFloat(R.styleable.StatusViewScroller_currentStepZoom, currentStatusZoom)
453453
alignStatusWithCurrent = a.getBoolean(R.styleable.StatusViewScroller_alignStatusWithCurrent, alignStatusWithCurrent)
454454

455455
val entries = a.getTextArray(R.styleable.StatusViewScroller_android_entries)
@@ -490,7 +490,7 @@ class StatusView @JvmOverloads constructor(
490490

491491
mLinePaint = Paint(Paint.ANTI_ALIAS_FLAG)
492492
mLinePaint.style = Paint.Style.STROKE
493-
mLinePaint.strokeWidth = lineStrokeWidth
493+
mLinePaint.strokeWidth = lineWidth
494494
mLinePaint.color = lineColor
495495

496496

@@ -591,17 +591,17 @@ class StatusView @JvmOverloads constructor(
591591

592592

593593
private fun isShowingIncompleteStatus() =
594-
currentCount > INVALID_STATUS_COUNT && currentCount < statusCount
594+
currentCount > INVALID_STATUS_COUNT && currentCount < stepCount
595595

596596
private fun isShowingCurrentStatus()=
597-
currentCount in 1..statusCount
597+
currentCount in 1..stepCount
598598

599599

600600
override fun getSuggestedMinimumWidth(): Int {
601601

602602

603603
lineLengthComputed = lineLength
604-
var extraWidth = if(obeyLineLength){// extra width required by status at extreme positions
604+
var extraWidth = if(strictObeyLineLength){// extra width required by status at extreme positions
605605
setWidthDataForObeyingLineLength()
606606
}else{
607607
setWidthDataForObeyingStatusText()
@@ -612,12 +612,12 @@ class StatusView @JvmOverloads constructor(
612612
}
613613

614614

615-
if(statusCount==1) {
615+
if(stepCount==1) {
616616
extraWidth *= 2
617617
}
618618

619-
return ((statusCount * (2 * (circleRadius + (circleStrokeWidth/2)))) +
620-
((statusCount - 1) * ( lineLengthComputed + (lineGap * 2))) + extraWidth).toInt()
619+
return ((stepCount * (2 * (circleRadius + (circleStrokeWidth/2)))) +
620+
((stepCount - 1) * ( lineLengthComputed + (lineGap * 2))) + extraWidth).toInt()
621621
}
622622

623623

@@ -630,7 +630,7 @@ class StatusView @JvmOverloads constructor(
630630
labelHeight = Math.max(labelHeight,setLabelsHeight(mTextPaintStatus,item))
631631
}
632632
if(statusData.size>0){
633-
labelHeight+=labelTopMargin
633+
labelHeight+=statusTopMargin
634634
}
635635

636636
val circleRadius = if(isShowingCurrentStatus()) currentStatusRadius else circleRadius
@@ -716,7 +716,7 @@ class StatusView @JvmOverloads constructor(
716716
lastPoint.x = paddingLeft.toFloat() + (circleStrokeWidth / 2)
717717
lastPoint.y = paddingTop.toFloat() + (circleRadius + (circleStrokeWidth / 2))
718718
if(isShowingCurrentStatus()) lastPoint.y += currentStatusRadius-circleRadius
719-
for (pos in 0 until statusCount) {
719+
for (pos in 0 until stepCount) {
720720

721721
var circleStrokePaint: Paint?
722722
var circleFillPaint : Paint?
@@ -732,7 +732,7 @@ class StatusView @JvmOverloads constructor(
732732
textPaintLabel = mTextPaintLabelCurrent
733733
linePaint = mLinePaintCurrent
734734
itemDrawable = currentDrawable
735-
}else if (isShowingIncompleteStatus() && pos in (currentCount)..statusCount) {
735+
}else if (isShowingIncompleteStatus() && pos in (currentCount)..stepCount) {
736736
circleStrokePaint = mCircleStrokePaintIncomplete
737737
circleFillPaint = mCircleFillPaintIncomplete
738738
textPaintLabel = mTextPaintLabelsIncomplete
@@ -770,7 +770,7 @@ class StatusView @JvmOverloads constructor(
770770

771771
if(pos<statusData.size){
772772
val radii = if(isShowingCurrentStatus() && alignStatusWithCurrent) currentStatusRadius else circleRadius
773-
labelItemText = StatusItemText(circleItem.center.x, circleItem.center.y + radii + circleStrokeWidth/2 + labelTopMargin, statusData[pos].staticLayout)
773+
labelItemText = StatusItemText(circleItem.center.x, circleItem.center.y + radii + circleStrokeWidth/2 + statusTopMargin, statusData[pos].staticLayout)
774774
}
775775

776776

@@ -815,7 +815,7 @@ class StatusView @JvmOverloads constructor(
815815

816816
val item = statusData[pos]
817817
when (pos) {
818-
0, statusCountIndex() -> {
818+
0, stepCountIndex() -> {
819819

820820
val minStatusWidthExtremes = minStatusWidthExtremes(pos)
821821
val minStatusWidth = minStatusWidth(pos)
@@ -871,7 +871,7 @@ class StatusView @JvmOverloads constructor(
871871
for (pos in 0 until statusData.size) {
872872
val item = statusData[pos]
873873
when (pos) {
874-
0, statusCountIndex() -> {
874+
0, stepCountIndex() -> {
875875

876876
item.width = if (pos == 0) {
877877
widestLineData.extremeLeftStatusWidth
@@ -889,16 +889,16 @@ class StatusView @JvmOverloads constructor(
889889
else -> item.width = widestLineData.widestStatus.width
890890
}
891891

892-
if(minMarginStatusText> 0 && !addMinStatusMargin && pos in 1 until statusData.size){
893-
if(minStatusWidth(pos)+ minStatusWidth(pos-1) - (item.width+statusData[pos-1].width)<minMarginStatusText){
892+
if(minStatusAdjacentMargin> 0 && !addMinStatusMargin && pos in 1 until statusData.size){
893+
if(minStatusWidth(pos)+ minStatusWidth(pos-1) - (item.width+statusData[pos-1].width)<minStatusAdjacentMargin){
894894
addMinStatusMargin = true
895895
}
896896

897897
}
898898
}
899899
if(addMinStatusMargin){
900900
//add additional padding only if it is required
901-
lineLengthComputed+= minMarginStatusText
901+
lineLengthComputed+= minStatusAdjacentMargin
902902
}
903903
return extraWidth
904904
}
@@ -1015,7 +1015,7 @@ class StatusView @JvmOverloads constructor(
10151015

10161016
when (pos) {
10171017
0 -> statusWidthInfo.extremeLeftStatusWidth= result
1018-
statusCountIndex() -> statusWidthInfo.extremeRightStatusWidth = result
1018+
stepCountIndex() -> statusWidthInfo.extremeRightStatusWidth = result
10191019
}
10201020

10211021
}
@@ -1063,9 +1063,9 @@ class StatusView @JvmOverloads constructor(
10631063
private fun currentCountIndex() = currentCount-1
10641064

10651065
/**
1066-
* actual position in list for statusCount
1066+
* actual position in list for stepCount
10671067
*/
1068-
private fun statusCountIndex() = statusCount-1
1068+
private fun stepCountIndex() = stepCount-1
10691069

10701070

10711071
/**
@@ -1111,7 +1111,7 @@ class StatusView @JvmOverloads constructor(
11111111
return TypedValue.applyDimension(unit,this,resources.displayMetrics)
11121112
}
11131113

1114-
fun getScrollPosForStatus(count: Int): Int {
1114+
fun getScrollPosForStep(count: Int): Int {
11151115
val posIndex = count - 1
11161116
return if (posIndex> 0 && posIndex < drawingData.size) {
11171117
drawingData[posIndex].circleItem.center.x.toInt()

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

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,32 @@
1010

1111

1212
<params.com.statusView.StatusViewScroller
13-
android:id="@+id/statusView"
1413
android:layout_width="wrap_content"
1514
android:layout_height="wrap_content"
1615
app:layout_constraintTop_toTopOf="parent"
1716
app:layout_constraintBottom_toBottomOf="parent"
1817
app:layout_constraintStart_toStartOf="parent"
1918
app:layout_constraintEnd_toEndOf="parent"
20-
app:circleColor="#F1EA7F"
21-
app:circleRadius="20dp"
22-
app:complete_drawable="@drawable/ic_done_black_24dp"
23-
app:statusCount="4"
19+
app:stepCount="5"
2420
app:currentCount="4"
25-
app:drawCount="true"
26-
android:entries="@array/statuses" />
21+
app:drawLabels="true"
22+
android:entries="@array/status"
23+
app:circleColorType="fillStroke"
24+
app:lineGap="5dp"
25+
app:lineWidth="3dp"
26+
app:lineColor="@android:color/black"
27+
app:lineColorIncomplete="#B4B7BA"
28+
app:lineColorCurrent="#91A8D0"
29+
app:circleColor="#CC004B8D"
30+
app:circleColorCurrent="#004B8D"
31+
app:circleColorIncomplete="#BCBCBE"
32+
app:textColorLabels="@android:color/white"
33+
app:textColorLabelsCurrent="@android:color/white"
34+
app:textColorLabelsIncomplete="@android:color/black"
35+
app:circleStrokeWidth="4dp"
36+
app:circleStrokeColorCurrent="#91A8D0"
37+
app:textSizeLabels="15sp"
38+
app:completeDrawable="@drawable/ic_done_black_24dp"/>
2739

2840

2941

0 commit comments

Comments
 (0)