Skip to content

Commit b7cd6ac

Browse files
Piotr ZawadzkiPiotr Zawadzki
Piotr Zawadzki
authored and
Piotr Zawadzki
committed
- updated version to 2.1.0 + README
- added missing JavaDoc - fixed indentations
1 parent cc56792 commit b7cd6ac

File tree

6 files changed

+39
-23
lines changed

6 files changed

+39
-23
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Quoting the [documentation](https://www.google.com/design/spec/components/steppe
1111
1212
## Download (from JCenter)
1313
```groovy
14-
compile 'com.stepstone.stepper:material-stepper:2.0.0'
14+
compile 'com.stepstone.stepper:material-stepper:2.1.0'
1515
```
1616

1717
## Supported steppers
@@ -28,6 +28,7 @@ compile 'com.stepstone.stepper:material-stepper:2.0.0'
2828
- custom texts of individual widgets inside of the stepper via View attributes or a style from a theme
2929
- embedding the stepper anywhere in the view hierarchy and changing the stepper type for various device configurations, e.g. phone/tablet, portrait/landscape
3030
- step validation
31+
- use with Fragments or Views
3132

3233
## Getting started
3334

@@ -333,6 +334,8 @@ For other examples, e.g. persisting state on rotation, displaying errors, changi
333334
| *ms_completeButtonText* | string or reference | COMPLETE button's text |
334335
| *ms_tabStepDividerWidth* | dimension or reference | The width of the horizontal tab divider used in tabs stepper type |
335336
| *ms_showBackButtonOnFirstStep* | boolean | Flag indicating if the Back (Previous step) button should be shown on the first step. False by default. |
337+
| *ms_showErrorState* | boolean | Flag indicating whether to show the error state. Only available with 'tabs' type. False by default. |
338+
| *ms_showErrorStateOnBack* | boolean | Flag indicating whether to keep showing the error state when user moves back. Only available with 'tabs' type. False by default. |
336339

337340
## Missing features
338341
- support for non-linear steppers

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919

2020
POM_GROUP_ID=com.stepstone.stepper
2121
POM_ARTIFACT_ID=material-stepper
22-
POM_VERSION=2.0.0
22+
POM_VERSION=2.1.0

material-stepper/src/main/java/com/stepstone/stepper/StepperLayout.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -339,17 +339,18 @@ public void setCompleteButtonVerificationFailed(boolean verificationFailed) {
339339
}
340340

341341
/**
342-
343-
* Set whether when going backwards should clear the error state from the Tab. Default is false.
344-
* @param mShowErrorStateOnBack
342+
* Set whether when going backwards should clear the error state from the Tab. Default is <code>false</code>.
343+
*
344+
* @param mShowErrorStateOnBack true if navigating backwards should keep the error state, false otherwise
345345
*/
346346
public void setShowErrorStateOnBack(boolean mShowErrorStateOnBack) {
347347
this.mShowErrorStateOnBack = mShowErrorStateOnBack;
348348
}
349349

350350
/**
351-
* Set whether the tab should display error or not. Default false.
352-
* @param mShowErrorState
351+
* Set whether the errors should be displayed when they occur or not. Default is <code>false</code>.
352+
*
353+
* @param mShowErrorState true if the errors should be displayed when they occur, false otherwise
353354
*/
354355
public void setShowErrorState(boolean mShowErrorState) {
355356
this.mShowErrorState = mShowErrorState;
@@ -547,8 +548,9 @@ private void onNext() {
547548
}
548549

549550
//if moving forward and got no errors, set hasError to false, so we can have the tab with the check mark.
550-
if(mShowErrorState)
551+
if (mShowErrorState) {
551552
mStepperType.setErrorStep(mCurrentStepPosition, false);
553+
}
552554

553555
OnNextClickedCallback onNextClickedCallback = new OnNextClickedCallback();
554556
if (step instanceof BlockingStep) {
@@ -573,9 +575,9 @@ private void onError(@NonNull VerificationError verificationError) {
573575
step.onError(verificationError);
574576

575577
//if moving forward and got errors, set hasError to true, showing the error drawable.
576-
if(mShowErrorState)
578+
if (mShowErrorState) {
577579
mStepperType.setErrorStep(mCurrentStepPosition, true);
578-
580+
}
579581
}
580582
mListener.onError(verificationError);
581583
}

material-stepper/src/main/java/com/stepstone/stepper/internal/StepTab.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@
1717
package com.stepstone.stepper.internal;
1818

1919
import android.content.Context;
20-
import android.content.res.ColorStateList;
2120
import android.graphics.Typeface;
2221
import android.graphics.drawable.Drawable;
2322
import android.support.annotation.ColorInt;
2423
import android.support.v4.content.ContextCompat;
25-
import android.support.v4.graphics.drawable.DrawableCompat;
2624
import android.support.v7.widget.AppCompatImageView;
2725
import android.util.AttributeSet;
2826
import android.view.LayoutInflater;
@@ -92,6 +90,7 @@ public StepTab(Context context, AttributeSet attrs, int defStyleAttr) {
9290

9391
/**
9492
* Changes the visibility of the horizontal line in the tab
93+
*
9594
* @param show true if the line should be shown, false otherwise
9695
*/
9796
public void toggleDividerVisibility(boolean show) {
@@ -100,13 +99,16 @@ public void toggleDividerVisibility(boolean show) {
10099

101100
/**
102101
* Updates tab's UI
103-
* @param done true if the step is done and the step's number should be replaced with a <i>done</i> icon, false otherwise
102+
*
103+
* @param done true if the step is done and the step's number should be replaced with a <i>done</i> icon, false otherwise
104+
* @param showErrorOnBack true if an error should be shown if verification failed, false otherwise
104105
* @param current true if the step is the current step, false otherwise
105106
*/
106107
public void updateState(final boolean done, final boolean showErrorOnBack, final boolean current) {
107108
//if this tab has errors and the user decide not to clear when going backwards, simply ignore the update
108-
if(this.hasError && showErrorOnBack)
109+
if (this.hasError && showErrorOnBack) {
109110
return;
111+
}
110112

111113
mStepDoneIndicator.setVisibility(done ? View.VISIBLE : View.GONE);
112114
mStepNumber.setVisibility(!done ? View.VISIBLE : View.GONE);
@@ -122,16 +124,18 @@ public void updateState(final boolean done, final boolean showErrorOnBack, final
122124

123125
/**
124126
* Update the error state of this tab. If it has error, show the error drawable.
127+
*
128+
* @param isLastStep whether this is the tab of the last step
125129
* @param hasError whether the tab has errors or not.
126130
*/
127-
public void updateErrorState(boolean done, boolean hasError) {
128-
if(hasError) {
131+
public void updateErrorState(boolean isLastStep, boolean hasError) {
132+
if (hasError) {
129133
mStepDoneIndicator.setVisibility(View.GONE);
130134
mStepNumber.setVisibility(View.GONE);
131135
mStepErrorIndicator.setVisibility(VISIBLE);
132136
mStepErrorIndicator.setColorFilter(mErrorColor);
133137
mStepTitle.setTextColor(mErrorColor);
134-
} else if(done) {
138+
} else if (isLastStep) {
135139
mStepDoneIndicator.setVisibility(View.VISIBLE);
136140
mStepErrorIndicator.setVisibility(GONE);
137141
colorViewBackground(mStepDoneIndicator, true);
@@ -144,6 +148,7 @@ public void updateErrorState(boolean done, boolean hasError) {
144148

145149
/**
146150
* Sets the name of the step
151+
*
147152
* @param title step name
148153
*/
149154
public void setStepTitle(CharSequence title) {
@@ -152,6 +157,7 @@ public void setStepTitle(CharSequence title) {
152157

153158
/**
154159
* Sets the position of the step
160+
*
155161
* @param number step position
156162
*/
157163
public void setStepNumber(CharSequence number) {

material-stepper/src/main/java/com/stepstone/stepper/internal/TabsContainer.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public interface TabItemListener {
4949

5050
/**
5151
* Called when a tab gets clicked
52+
*
5253
* @param position position of the tab/step
5354
*/
5455
@UiThread
@@ -144,6 +145,7 @@ public void setListener(@NonNull TabItemListener listener) {
144145

145146
/**
146147
* Sets the steps to display in the {@link TabsContainer}.
148+
*
147149
* @param stepTitles a list of tab titles
148150
*/
149151
public void setSteps(List<CharSequence> stepTitles) {
@@ -158,6 +160,7 @@ public void setSteps(List<CharSequence> stepTitles) {
158160

159161
/**
160162
* Changes the position of the current step and updates the UI based on it.
163+
*
161164
* @param newStepPosition new current step
162165
*/
163166
public void setCurrentStep(int newStepPosition) {
@@ -175,20 +178,22 @@ public void setCurrentStep(int newStepPosition) {
175178

176179
/**
177180
* Set whether when going backwards should clear the error state from the Tab. Default is false
178-
* @param mShowErrorStateOnBack
181+
*
182+
* @param mShowErrorStateOnBack true if navigating backwards should keep the error state, false otherwise
179183
*/
180184
public void setShowErrorStateOnBack(boolean mShowErrorStateOnBack) {
181185
this.mShowErrorStateOnBack = mShowErrorStateOnBack;
182186
}
183187

184-
public void setErrorStep(int stepPosition, boolean hasError){
185-
if(mStepTitles.size() < stepPosition)
188+
public void setErrorStep(int stepPosition, boolean hasError) {
189+
if (mStepTitles.size() < stepPosition) {
186190
return;
191+
}
187192

188193
StepTab childTab = (StepTab) mTabsInnerContainer.getChildAt(stepPosition);
189-
childTab.updateErrorState(mStepTitles.size() - 1 == stepPosition ,hasError);
194+
childTab.updateErrorState(mStepTitles.size() - 1 == stepPosition, hasError);
190195
}
191-
196+
192197
private View createStepTab(final int position, @Nullable CharSequence title) {
193198
StepTab view = (StepTab) LayoutInflater.from(getContext()).inflate(R.layout.ms_step_tab_container, mTabsInnerContainer, false);
194199
view.setStepNumber(String.valueOf(position + 1));

material-stepper/src/main/java/com/stepstone/stepper/type/AbstractStepperType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void setErrorStep(int stepPosition, boolean hasError){ }
6363

6464
/**
6565
* Called to set whether navigating backwards should keep the error state.
66-
* @param mShowErrorStateOnBack
66+
* @param mShowErrorStateOnBack true if navigating backwards should keep the error state, false otherwise
6767
*/
6868
public void showErrorStateOnBack(boolean mShowErrorStateOnBack){ }
6969

0 commit comments

Comments
 (0)