Skip to content
This repository was archived by the owner on Apr 19, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion sample/src/main/res/layout/activity_simple.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:sv_animationType="All"
app:sv_stepPadding="12dp"
app:sv_stepPadding="0dp"
app:sv_typeface="@font/iran_sans_mobile"
app:sv_enableStroke="true"
app:sv_strokeWidth="1dp"
app:sv_strokeColor="#FFFFFF"
app:sv_stepsNumber="5"/>

<Button
Expand Down
4 changes: 2 additions & 2 deletions stepview/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apply plugin: 'com.android.library'

ext {
PUBLISH_GROUP_ID = 'com.github.shuhart'
PUBLISH_VERSION = '1.5.1'
PUBLISH_GROUP_ID = 'com.github.antran-arv'
PUBLISH_VERSION = '1.0.0'
PUBLISH_ARTIFACT_ID = 'stepview'
}

Expand Down
24 changes: 22 additions & 2 deletions stepview/src/main/java/com/shuhart/stepview/StepView.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ public interface OnStepClickListener {
@ColorInt
private int nextStepCircleColor;

@Dimension
private int strokeWidth;

@ColorInt
private int strokeColor;

private boolean strokeEnabled = false;

private Paint paint;
private TextPaint textPaint;
private ValueAnimator animator;
Expand Down Expand Up @@ -171,6 +179,9 @@ private void applyStyles(Context context, AttributeSet attrs, int defStyleAttr)
stepsNumber = ta.getInteger(R.styleable.StepView_sv_stepsNumber, 0);
nextStepCircleEnabled = ta.getBoolean(R.styleable.StepView_sv_nextStepCircleEnabled, false);
nextStepCircleColor = ta.getColor(R.styleable.StepView_sv_nextStepCircleColor, 0);
strokeWidth = ta.getDimensionPixelSize(R.styleable.StepView_sv_strokeWidth, 0);
strokeColor = ta.getColor(R.styleable.StepView_sv_strokeColor, 0);
strokeEnabled = ta.getBoolean(R.styleable.StepView_sv_enableStroke, false);
CharSequence[] descriptions = ta.getTextArray(R.styleable.StepView_sv_steps);
if (descriptions != null) {
for (CharSequence description : descriptions) {
Expand Down Expand Up @@ -455,7 +466,7 @@ private int measureStepsHeight() {

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private boolean isRtl() {
return ViewCompat.getLayoutDirection(this) == View.LAYOUT_DIRECTION_RTL;
return ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;
}

private void measureAttributes() {
Expand Down Expand Up @@ -729,7 +740,16 @@ private void drawStep(Canvas canvas, int step, int circleCenterX, int circleCent
paint.setColor(nextStepCircleColor);
canvas.drawCircle(circleCenterX, circleCenterY, selectedCircleRadius, paint);
}

if(strokeEnabled && strokeColor != 0 && strokeWidth != 0){
Paint strokePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
strokePaint.setTextAlign(Paint.Align.CENTER);;
strokePaint.setColor(strokeColor);
strokePaint.setStrokeWidth(strokeWidth);
strokePaint.setStyle(Paint.Style.STROKE);
strokePaint.setAntiAlias(true);
strokePaint.setDither(true);
canvas.drawCircle(circleCenterX, circleCenterY, selectedCircleRadius, strokePaint);
}
paint.setColor(nextTextColor);

paint.setTextSize(stepNumberTextSize);
Expand Down
3 changes: 3 additions & 0 deletions stepview/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@
<attr name="sv_typeface" format="reference" />
<attr name="sv_nextStepCircleEnabled" format="boolean" />
<attr name="sv_nextStepCircleColor" format="color" />
<attr name="sv_strokeWidth" format="dimension" />
<attr name="sv_enableStroke" format="boolean" />
<attr name="sv_strokeColor" format="color"/>
</declare-styleable>
</resources>