Skip to content

Commit 65e89b1

Browse files
committed
dev: some fixes related to attrs
1 parent bb8e5b9 commit 65e89b1

4 files changed

Lines changed: 46 additions & 49 deletions

File tree

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

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,10 @@ class StatusView @JvmOverloads constructor(
151151
/**
152152
* Stroke width of the line between circles (dp)
153153
*/
154-
var lineStrokeWidth: Float by OnValidateProp(2.0f.pxValue()) {
154+
var lineStrokeWidth: Float by OnValidateProp(1.5f.pxValue()) {
155155
mLinePaint.strokeWidth = lineStrokeWidth
156156
mLinePaintIncomplete.strokeWidth = lineStrokeWidth
157+
mLinePaintCurrent.strokeWidth = lineStrokeWidth
157158
}
158159

159160
/**
@@ -413,51 +414,52 @@ class StatusView @JvmOverloads constructor(
413414
init {
414415

415416

416-
val a = context.theme.obtainStyledAttributes(attrs, R.styleable.StatusView, 0, 0)
417+
val a = context.theme.obtainStyledAttributes(attrs, R.styleable.StatusViewScroller, 0, 0)
417418

418419
try {
419420

420-
statusCount = a.getInt(R.styleable.StatusView_statusCount, statusCount)
421-
currentCount = a.getInt(R.styleable.StatusView_currentCount, INVALID_STATUS_COUNT)
422-
circleRadius = a.getDimension(R.styleable.StatusView_circleRadius, circleRadius)
423-
lineLength = a.getDimension(R.styleable.StatusView_lineLength, lineLength)
424-
circleStrokeWidth = a.getDimension(R.styleable.StatusView_circleStrokeWidth, circleStrokeWidth)
425-
lineStrokeWidth = a.getDimension(R.styleable.StatusView_lineWidth, lineStrokeWidth)
426-
completeDrawable = a.getDrawable(R.styleable.StatusView_complete_drawable)
427-
incompleteDrawable = a.getDrawable(R.styleable.StatusView_incomplete_drawable)
428-
currentDrawable = a.getDrawable(R.styleable.StatusView_current_drawable)
429-
drawLabels = a.getBoolean(R.styleable.StatusView_drawCount, drawLabels)
430-
obeyLineLength = a.getBoolean(R.styleable.StatusView_obeyLineLength, obeyLineLength)
431-
lineGap = a.getDimension(R.styleable.StatusView_lineGap, lineGap)
432-
minMarginStatusText = a.getDimension(R.styleable.StatusView_minStatusMargin, minMarginStatusText)
433-
labelTopMargin = a.getDimension(R.styleable.StatusView_labelTopMargin, labelTopMargin)
434-
lineColor = a.getColor(R.styleable.StatusView_lineColor, lineColor)
435-
circleFillColor = a.getColor(R.styleable.StatusView_circleColor, circleFillColor)
436-
circleStrokeColor = a.getColor(R.styleable.StatusView_circleStrokeColor, circleStrokeColor)
437-
textColorStatus = a.getColor(R.styleable.StatusView_textColor, textColorStatus)
438-
textColorLabels = a.getColor(R.styleable.StatusView_textColorLabels, textColorLabels)
439-
textSizeStatus = a.getDimension(R.styleable.StatusView_textSize, textSizeStatus)
440-
textSizeLabels = a.getDimension(R.styleable.StatusView_textSizeLabels, textSizeLabels)
441-
circleColorType = a.getInteger(R.styleable.StatusView_circleColorType, circleColorType)
442-
textColorLabelsIncomplete = a.getColor(R.styleable.StatusView_textColorLabelsIncomplete, textColorStatus)
443-
textColorLabelCurrent = a.getColor(R.styleable.StatusView_textColorLabelsCurrent, textColorLabelCurrent)
444-
lineColorIncomplete = a.getColor(R.styleable.StatusView_lineColorIncomplete, lineColorIncomplete)
445-
lineColorCurrent= a.getColor(R.styleable.StatusView_lineColorCurrent, lineColorCurrent)
446-
circleFillColorIncomplete = a.getColor(R.styleable.StatusView_circleColorIncomplete, circleFillColor)
447-
circleStrokeColorIncomplete = a.getColor(R.styleable.StatusView_circleStrokeColorIncomplete, circleStrokeColor)
448-
circleFillColorCurrent = a.getColor(R.styleable.StatusView_circleColorCurrent, circleFillColorIncomplete)
449-
currentStatusZoom = a.getFloat(R.styleable.StatusView_currentStatusZoom, currentStatusZoom)
450-
alignStatusWithCurrent = a.getBoolean(R.styleable.StatusView_alignStatusWithCurrent, alignStatusWithCurrent)
451-
452-
val entries = a.getTextArray(R.styleable.StatusView_android_entries)
421+
statusCount = a.getInt(R.styleable.StatusViewScroller_statusCount, statusCount)
422+
currentCount = a.getInt(R.styleable.StatusViewScroller_currentCount, INVALID_STATUS_COUNT)
423+
circleRadius = a.getDimension(R.styleable.StatusViewScroller_circleRadius, circleRadius)
424+
lineLength = a.getDimension(R.styleable.StatusViewScroller_lineLength, lineLength)
425+
circleStrokeWidth = a.getDimension(R.styleable.StatusViewScroller_circleStrokeWidth, circleStrokeWidth)
426+
lineStrokeWidth = a.getDimension(R.styleable.StatusViewScroller_lineWidth, lineStrokeWidth)
427+
completeDrawable = a.getDrawable(R.styleable.StatusViewScroller_complete_drawable)
428+
incompleteDrawable = a.getDrawable(R.styleable.StatusViewScroller_incomplete_drawable)
429+
currentDrawable = a.getDrawable(R.styleable.StatusViewScroller_current_drawable)
430+
drawLabels = a.getBoolean(R.styleable.StatusViewScroller_drawCount, drawLabels)
431+
obeyLineLength = a.getBoolean(R.styleable.StatusViewScroller_obeyLineLength, obeyLineLength)
432+
lineGap = a.getDimension(R.styleable.StatusViewScroller_lineGap, lineGap)
433+
minMarginStatusText = a.getDimension(R.styleable.StatusViewScroller_minStatusMargin, minMarginStatusText)
434+
labelTopMargin = a.getDimension(R.styleable.StatusViewScroller_labelTopMargin, labelTopMargin)
435+
lineColor = a.getColor(R.styleable.StatusViewScroller_lineColor, lineColor)
436+
circleFillColor = a.getColor(R.styleable.StatusViewScroller_circleColor, circleFillColor)
437+
circleStrokeColor = a.getColor(R.styleable.StatusViewScroller_circleStrokeColor, circleStrokeColor)
438+
textColorStatus = a.getColor(R.styleable.StatusViewScroller_textColor, textColorStatus)
439+
textColorLabels = a.getColor(R.styleable.StatusViewScroller_textColorLabels, textColorLabels)
440+
textSizeStatus = a.getDimension(R.styleable.StatusViewScroller_textSize, textSizeStatus)
441+
textSizeLabels = a.getDimension(R.styleable.StatusViewScroller_textSizeLabels, textSizeLabels)
442+
circleColorType = a.getInteger(R.styleable.StatusViewScroller_circleColorType, circleColorType)
443+
textColorLabelsIncomplete = a.getColor(R.styleable.StatusViewScroller_textColorLabelsIncomplete, textColorLabels)
444+
textColorLabelCurrent = a.getColor(R.styleable.StatusViewScroller_textColorLabelsCurrent, textColorLabelsIncomplete)
445+
lineColorIncomplete = a.getColor(R.styleable.StatusViewScroller_lineColorIncomplete, lineColor)
446+
lineColorCurrent= a.getColor(R.styleable.StatusViewScroller_lineColorCurrent, lineColorIncomplete)
447+
circleFillColorIncomplete = a.getColor(R.styleable.StatusViewScroller_circleColorIncomplete, circleFillColor)
448+
circleStrokeColorIncomplete = a.getColor(R.styleable.StatusViewScroller_circleStrokeColorIncomplete, circleStrokeColor)
449+
circleStrokeColorCurrent = a.getColor(R.styleable.StatusViewScroller_circleStrokeColorCurrent, circleStrokeColorIncomplete)
450+
circleFillColorCurrent = a.getColor(R.styleable.StatusViewScroller_circleColorCurrent, circleFillColorIncomplete)
451+
currentStatusZoom = a.getFloat(R.styleable.StatusViewScroller_currentStatusZoom, currentStatusZoom)
452+
alignStatusWithCurrent = a.getBoolean(R.styleable.StatusViewScroller_alignStatusWithCurrent, alignStatusWithCurrent)
453+
454+
val entries = a.getTextArray(R.styleable.StatusViewScroller_android_entries)
453455
if (entries != null) {
454456
for(entry in entries){
455457
statusData.add(StatusInfo(entry.toString()))
456458
}
457459
}
458460

459461
try {
460-
val resource: Int = a.getResourceId(R.styleable.StatusView_statusFont, -1)
462+
val resource: Int = a.getResourceId(R.styleable.StatusViewScroller_statusFont, -1)
461463
if (resource != -1) {
462464
statusTypeface = ResourcesCompat.getFont(getContext(), resource)
463465
}
@@ -466,7 +468,7 @@ class StatusView @JvmOverloads constructor(
466468
}
467469

468470
try {
469-
val resource: Int = a.getResourceId(R.styleable.StatusView_labelFont, -1)
471+
val resource: Int = a.getResourceId(R.styleable.StatusViewScroller_labelFont, -1)
470472
if (resource != -1) {
471473
labelsTypeface = ResourcesCompat.getFont(getContext(), resource)
472474
}

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,13 @@
1717
app:layout_constraintBottom_toBottomOf="parent"
1818
app:layout_constraintStart_toStartOf="parent"
1919
app:layout_constraintEnd_toEndOf="parent"
20-
app:circleColorType="fillStroke"
21-
app:statusCount="15"
22-
app:currentCount="3"
23-
app:lineLength="25dp"
24-
app:circleRadius="25dp"
25-
app:obeyLineLength="false"
26-
app:currentStatusZoom="0.5"
20+
app:circleColor="#F1EA7F"
21+
app:circleRadius="20dp"
22+
app:complete_drawable="@drawable/ic_done_black_24dp"
23+
app:statusCount="4"
24+
app:currentCount="4"
2725
app:drawCount="true"
28-
app:statusFont="@font/montserrat_r"
29-
app:labelFont="@font/roboto_r"
30-
android:entries="@array/statuses"
31-
app:current_drawable="@drawable/ic_tag_faces_black_24dp" />
26+
android:entries="@array/statuses" />
3227

3328

3429

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<resources>
33

44

5-
<declare-styleable name="StatusView">
5+
<declare-styleable name="StatusViewScroller">
66
<attr name="circleRadius" format="dimension" />
77
<attr name="statusCount" format="integer" />
88
<attr name="currentCount" format="integer" />

screenshots/basic_stepview.png

-8.75 KB
Loading

0 commit comments

Comments
 (0)