Skip to content

Commit c63fd62

Browse files
authored
Merge pull request #212 from stepstone-tech/develop
Merge develop - release of 4.3.0
2 parents f831bed + 53cc965 commit c63fd62

26 files changed

+332
-84
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [4.3.0]
8+
### Added
9+
- A way to set bottom navigation button colors programmatically via:
10+
`StepperLayout#setNextButtonColor(int)`/`StepperLayout#setNextButtonColor(ColorStateList)`,
11+
`StepperLayout#setCompleteButtonColor(int)`/`StepperLayout#setCompleteButtonColor(ColorStateList)` and
12+
`StepperLayout#setBackButtonColor(int)`/`StepperLayout#setBackButtonColor(ColorStateList)` (issue #132).
13+
14+
### Fixed
15+
- Tab circle background color so that it is possible now to use colors with transparency (issue #207).
16+
717
## [4.2.0]
818
### Added
919
- A new artifact `espresso-material-stepper` with useful Espresso actions and matchers for testing `StepperLayout` with Espresso.
@@ -30,6 +40,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3040
- **Breaking change:** Changed `setNextButtonLabel` methods in `StepViewModel.Builder` to `setEndButtonLabel` so that it works for both Next and Complete buttons (issue #107)
3141
- **Breaking change:** Split `content` stepper feedback type into `content_progress` and `content_fade`.
3242

43+
[4.3.0]: https://github.com/stepstone-tech/android-material-stepper/compare/v4.2.0...v4.3.0
3344
[4.2.0]: https://github.com/stepstone-tech/android-material-stepper/compare/v4.1.0...v4.2.0
3445
[4.1.0]: https://github.com/stepstone-tech/android-material-stepper/compare/v4.0.0...v4.1.0
3546
[4.0.0]: https://github.com/stepstone-tech/android-material-stepper/compare/v3.3.0...v4.0.0

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Moreover, you can find there other examples, e.g. how to persist state on rotati
6666

6767
### Download (from JCenter)
6868
```groovy
69-
compile 'com.stepstone.stepper:material-stepper:4.2.0'
69+
compile 'com.stepstone.stepper:material-stepper:4.3.0'
7070
```
7171

7272
*Note:* This library adds a transitive dependency to AppCompat `25.4.0`
@@ -477,9 +477,9 @@ For advanced styling please see [StepperLayout style attributes](#stepperlayout-
477477
| Attribute name | Format | Description |
478478
| --------------------------------|---------------------------------------------------------------------|-------------|
479479
| *ms_stepperType* | one of `dots`, `progress_bar`, `tabs` or `none` | **REQUIRED:** Type of the stepper |
480-
| *ms_backButtonColor* | color or reference | BACK button's text color |
481-
| *ms_nextButtonColor* | color or reference | NEXT button's text color |
482-
| *ms_completeButtonColor* | color or reference | COMPLETE button's text color |
480+
| *ms_backButtonColor* | color or reference | BACK button's text color, can be also set via `StepperLayout#setBackButtonColor(int)`/`StepperLayout#setBackButtonColor(ColorStateList)` |
481+
| *ms_nextButtonColor* | color or reference | NEXT button's text color, can be also set via `StepperLayout#setNextButtonColor(int)`/`StepperLayout#setNextButtonColor(ColorStateList)` |
482+
| *ms_completeButtonColor* | color or reference | COMPLETE button's text color, can be also set via `StepperLayout#setCompleteButtonColor(int)`/`StepperLayout#setCompleteButtonColor(ColorStateList)` |
483483
| *ms_activeStepColor* | color or reference | Active step's color |
484484
| *ms_inactiveStepColor* | color or reference | Inactive step's color |
485485
| *ms_bottomNavigationBackground* | reference | Background of the bottom navigation |

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.gradleAndroidVersion = '3.0.0-beta4'
2+
ext.gradleAndroidVersion = '3.0.0-beta6'
33
ext.kotlinVersion = '1.1.3-2'
44
ext.bintrayVersion = '1.7.3'
55
ext.mavenGradlePluginVersion = '2.0'

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
POM_GROUP_ID=com.stepstone.stepper
2121
POM_ARTIFACT_ID=material-stepper
2222
POM_TEST_ARTIFACT_ID=espresso-material-stepper
23-
POM_VERSION=4.2.0
23+
POM_VERSION=4.3.0
2424

2525
#Needed so that Robolectric is working: https://github.com/robolectric/robolectric/issues/3169
2626
android.enableAapt2=false

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

+57
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,63 @@ public void setTabNavigationEnabled(boolean tabNavigationEnabled) {
591591
mTabNavigationEnabled = tabNavigationEnabled;
592592
}
593593

594+
/**
595+
* Changes the text and compound drawable color of the Next bottom navigation button.
596+
*
597+
* @param newButtonColor new color state list
598+
*/
599+
public void setNextButtonColor(@NonNull ColorStateList newButtonColor) {
600+
mNextButtonColor = newButtonColor;
601+
TintUtil.tintTextView(mNextNavigationButton, mNextButtonColor);
602+
}
603+
604+
/**
605+
* Changes the text and compound drawable color of the Complete bottom navigation button.
606+
*
607+
* @param newButtonColor new color state list
608+
*/
609+
public void setCompleteButtonColor(@NonNull ColorStateList newButtonColor) {
610+
mCompleteButtonColor = newButtonColor;
611+
TintUtil.tintTextView(mCompleteNavigationButton, mCompleteButtonColor);
612+
}
613+
614+
/**
615+
* Changes the text and compound drawable color of the Back bottom navigation button.
616+
*
617+
* @param newButtonColor new color state list
618+
*/
619+
public void setBackButtonColor(@NonNull ColorStateList newButtonColor) {
620+
mBackButtonColor = newButtonColor;
621+
TintUtil.tintTextView(mBackNavigationButton, mBackButtonColor);
622+
}
623+
624+
/**
625+
* Changes the text and compound drawable color of the Next bottom navigation button.
626+
*
627+
* @param newButtonColor new color int
628+
*/
629+
public void setNextButtonColor(@ColorInt int newButtonColor) {
630+
setNextButtonColor(ColorStateList.valueOf(newButtonColor));
631+
}
632+
633+
/**
634+
* Changes the text and compound drawable color of the Complete bottom navigation button.
635+
*
636+
* @param newButtonColor new color int
637+
*/
638+
public void setCompleteButtonColor(@ColorInt int newButtonColor) {
639+
setCompleteButtonColor(ColorStateList.valueOf(newButtonColor));
640+
}
641+
642+
/**
643+
* Changes the text and compound drawable color of the Back bottom navigation button.
644+
*
645+
* @param newButtonColor new color int
646+
*/
647+
public void setBackButtonColor(@ColorInt int newButtonColor) {
648+
setBackButtonColor(ColorStateList.valueOf(newButtonColor));
649+
}
650+
594651
/**
595652
* Updates the error state in the UI.
596653
* It does nothing if showing error state is disabled.

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

+9-8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.stepstone.stepper.internal.widget;
1818

1919
import android.content.Context;
20+
import android.graphics.PorterDuff;
2021
import android.graphics.Typeface;
2122
import android.graphics.drawable.Animatable;
2223
import android.graphics.drawable.Drawable;
@@ -295,7 +296,7 @@ protected void changeToDone() {
295296
protected void changeToWarning(@Nullable CharSequence errorMessage) {
296297
mStepDoneIndicator.setVisibility(View.GONE);
297298
mStepNumberTextView.setVisibility(View.GONE);
298-
mStepIconBackground.setColorFilter(mErrorColor);
299+
mStepIconBackground.setColorFilter(mErrorColor, PorterDuff.Mode.SRC_IN);
299300
mStepTitleTextView.setTextColor(mErrorColor);
300301
mStepSubtitleTextView.setTextColor(mErrorColor);
301302
updateSubtitle(errorMessage);
@@ -330,7 +331,7 @@ class InactiveNumberState extends AbstractNumberState {
330331

331332
@Override
332333
protected void changeToInactiveNumber() {
333-
mStepIconBackground.setColorFilter(mUnselectedColor);
334+
mStepIconBackground.setColorFilter(mUnselectedColor, PorterDuff.Mode.SRC_IN);
334335
mStepTitleTextView.setTextColor(mTitleColor);
335336
mStepTitleTextView.setAlpha(ALPHA_INACTIVE_STEP_TITLE);
336337
mStepSubtitleTextView.setTextColor(mSubtitleColor);
@@ -339,7 +340,7 @@ protected void changeToInactiveNumber() {
339340

340341
@Override
341342
protected void changeToActiveNumber() {
342-
mStepIconBackground.setColorFilter(mSelectedColor);
343+
mStepIconBackground.setColorFilter(mSelectedColor, PorterDuff.Mode.SRC_IN);
343344
mStepTitleTextView.setAlpha(ALPHA_ACTIVE_STEP_TITLE);
344345
super.changeToActiveNumber();
345346
}
@@ -357,7 +358,7 @@ class ActiveNumberState extends AbstractNumberState {
357358

358359
@Override
359360
protected void changeToInactiveNumber() {
360-
mStepIconBackground.setColorFilter(mUnselectedColor);
361+
mStepIconBackground.setColorFilter(mUnselectedColor, PorterDuff.Mode.SRC_IN);
361362
mStepTitleTextView.setAlpha(ALPHA_INACTIVE_STEP_TITLE);
362363
super.changeToInactiveNumber();
363364
}
@@ -370,7 +371,7 @@ class DoneState extends AbstractState {
370371
protected void changeToInactiveNumber() {
371372
mStepDoneIndicator.setVisibility(GONE);
372373
mStepNumberTextView.setVisibility(VISIBLE);
373-
mStepIconBackground.setColorFilter(mUnselectedColor);
374+
mStepIconBackground.setColorFilter(mUnselectedColor, PorterDuff.Mode.SRC_IN);
374375
mStepTitleTextView.setAlpha(ALPHA_INACTIVE_STEP_TITLE);
375376
super.changeToInactiveNumber();
376377
}
@@ -398,7 +399,7 @@ class WarningState extends AbstractState {
398399
protected void changeToDone() {
399400
animateViewIn(mStepDoneIndicator);
400401

401-
mStepIconBackground.setColorFilter(mSelectedColor);
402+
mStepIconBackground.setColorFilter(mSelectedColor, PorterDuff.Mode.SRC_IN);
402403
mStepTitleTextView.setTextColor(mTitleColor);
403404
mStepSubtitleTextView.setTextColor(mSubtitleColor);
404405
super.changeToDone();
@@ -408,7 +409,7 @@ protected void changeToDone() {
408409
protected void changeToInactiveNumber() {
409410
animateViewIn(mStepNumberTextView);
410411

411-
mStepIconBackground.setColorFilter(mUnselectedColor);
412+
mStepIconBackground.setColorFilter(mUnselectedColor, PorterDuff.Mode.SRC_IN);
412413
mStepTitleTextView.setTextColor(mTitleColor);
413414
mStepTitleTextView.setAlpha(ALPHA_INACTIVE_STEP_TITLE);
414415
mStepSubtitleTextView.setTextColor(mSubtitleColor);
@@ -420,7 +421,7 @@ protected void changeToInactiveNumber() {
420421
protected void changeToActiveNumber() {
421422
animateViewIn(mStepNumberTextView);
422423

423-
mStepIconBackground.setColorFilter(mSelectedColor);
424+
mStepIconBackground.setColorFilter(mSelectedColor, PorterDuff.Mode.SRC_IN);
424425
mStepTitleTextView.setTextColor(mTitleColor);
425426
mStepSubtitleTextView.setTextColor(mSubtitleColor);
426427
super.changeToActiveNumber();

sample/src/androidTest/java/com/stepstone/stepper/sample/SanityTest.java

+10
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,16 @@ public void shouldOpenCustomStepperLayoutThemeActivity() {
267267
SpoonScreenshotAction.perform(getScreenshotTag(24, R.string.custom_stepperlayout_theme));
268268
}
269269

270+
@Test
271+
public void shouldOpenSetButtonColorProgrammaticallyActivity() {
272+
//when
273+
clickRowWithText(R.string.set_button_color_programmatically);
274+
275+
//then
276+
intended(hasComponent(SetButtonColorProgrammaticallyActivity.class.getName()));
277+
SpoonScreenshotAction.perform(getScreenshotTag(25, R.string.set_button_color_programmatically));
278+
}
279+
270280
@NonNull
271281
private String getScreenshotTag(int position, @StringRes int titleResId) {
272282
return String.format(Locale.ENGLISH,"%02d", position) + ". " + intentsTestRule.getActivity().getString(titleResId);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
package com.stepstone.stepper.sample;
2+
3+
import android.support.test.filters.LargeTest;
4+
5+
import com.stepstone.stepper.sample.test.action.SpoonScreenshotAction;
6+
7+
import org.junit.Test;
8+
9+
import static android.support.test.espresso.Espresso.onView;
10+
import static android.support.test.espresso.action.ViewActions.doubleClick;
11+
import static android.support.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed;
12+
import static android.support.test.espresso.matcher.ViewMatchers.withId;
13+
import static com.stepstone.stepper.sample.test.matcher.CommonMatchers.checkBackButtonColor;
14+
import static com.stepstone.stepper.sample.test.matcher.CommonMatchers.checkCompleteButtonColor;
15+
import static com.stepstone.stepper.sample.test.matcher.CommonMatchers.checkCompleteButtonShown;
16+
import static com.stepstone.stepper.sample.test.matcher.CommonMatchers.checkCurrentStepIs;
17+
import static com.stepstone.stepper.sample.test.matcher.CommonMatchers.checkNextButtonColor;
18+
import static com.stepstone.stepper.test.StepperNavigationActions.clickComplete;
19+
import static com.stepstone.stepper.test.StepperNavigationActions.clickNext;
20+
import static org.hamcrest.Matchers.allOf;
21+
22+
/**
23+
* Performs tests on a stepper on which we change the button colors in code.
24+
*
25+
* @author Piotr Zawadzki
26+
*/
27+
@LargeTest
28+
public class SetButtonColorProgrammaticallyActivityTest extends AbstractActivityTest<SetButtonColorProgrammaticallyActivity> {
29+
30+
@Test
31+
public void shouldStayOnTheFirstStepWhenVerificationFails() {
32+
//when
33+
onView(withId(R.id.stepperLayout)).perform(clickNext());
34+
35+
//then
36+
SpoonScreenshotAction.perform(getScreenshotTag(1, "Verification failure test"));
37+
checkCurrentStepIs(0);
38+
checkNextButtonColor(R.color.verification_failed_color);
39+
}
40+
41+
@Test
42+
public void shouldGoToTheNextStepWhenVerificationSucceeds() {
43+
//given
44+
onView(allOf(withId(R.id.button), isCompletelyDisplayed())).perform(doubleClick());
45+
46+
//when
47+
onView(withId(R.id.stepperLayout)).perform(clickNext());
48+
49+
//then
50+
SpoonScreenshotAction.perform(getScreenshotTag(2, "Verification success test"));
51+
checkCurrentStepIs(1);
52+
checkNextButtonColor(R.color.ms_black);
53+
checkBackButtonColor(R.color.ms_white);
54+
}
55+
56+
@Test
57+
public void shouldShowCompleteButtonOnTheLastStep() {
58+
//given
59+
onView(allOf(withId(R.id.button), isCompletelyDisplayed())).perform(doubleClick());
60+
onView(withId(R.id.stepperLayout)).perform(clickNext());
61+
onView(allOf(withId(R.id.button), isCompletelyDisplayed())).perform(doubleClick());
62+
63+
//when
64+
onView(withId(R.id.stepperLayout)).perform(clickNext());
65+
66+
//then
67+
SpoonScreenshotAction.perform(getScreenshotTag(3, "Last step test"));
68+
checkCurrentStepIs(2);
69+
checkCompleteButtonShown();
70+
checkCompleteButtonColor(R.color.verification_failed_color);
71+
checkBackButtonColor(R.color.ms_black);
72+
}
73+
74+
@Test
75+
public void shouldCompleteStepperFlow() {
76+
//given
77+
onView(allOf(withId(R.id.button), isCompletelyDisplayed())).perform(doubleClick());
78+
onView(withId(R.id.stepperLayout)).perform(clickNext());
79+
onView(allOf(withId(R.id.button), isCompletelyDisplayed())).perform(doubleClick());
80+
onView(withId(R.id.stepperLayout)).perform(clickNext());
81+
onView(allOf(withId(R.id.button), isCompletelyDisplayed())).perform(doubleClick());
82+
83+
//when
84+
onView(withId(R.id.stepperLayout)).perform(clickComplete());
85+
86+
//then
87+
SpoonScreenshotAction.perform(getScreenshotTag(4, "Completion test"));
88+
checkCurrentStepIs(2);
89+
checkCompleteButtonColor(R.color.ms_black);
90+
checkBackButtonColor(R.color.ms_black);
91+
}
92+
93+
}

sample/src/androidTest/java/com/stepstone/stepper/sample/test/matcher/CommonMatchers.java

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.stepstone.stepper.sample.test.matcher;
22

3+
import android.support.annotation.ColorRes;
34
import android.support.annotation.IntRange;
45
import android.support.annotation.NonNull;
56
import android.view.View;
@@ -11,6 +12,7 @@
1112

1213
import static android.support.test.espresso.Espresso.onView;
1314
import static android.support.test.espresso.assertion.ViewAssertions.matches;
15+
import static android.support.test.espresso.matcher.ViewMatchers.hasTextColor;
1416
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
1517
import static android.support.test.espresso.matcher.ViewMatchers.withId;
1618
import static com.stepstone.stepper.sample.test.matcher.StepperLayoutTabStateMatcher.tabAtPositionIsInState;
@@ -43,4 +45,16 @@ public static void checkCompleteButtonShown() {
4345
onView(withId(R.id.ms_stepCompleteButton)).check(matches(isDisplayed()));
4446
}
4547

48+
public static void checkBackButtonColor(@ColorRes int expectedColor) {
49+
onView(withId(com.stepstone.stepper.R.id.ms_stepPrevButton)).check(matches(hasTextColor(expectedColor)));
50+
}
51+
52+
public static void checkNextButtonColor(@ColorRes int expectedColor) {
53+
onView(withId(com.stepstone.stepper.R.id.ms_stepNextButton)).check(matches(hasTextColor(expectedColor)));
54+
}
55+
56+
public static void checkCompleteButtonColor(@ColorRes int expectedColor) {
57+
onView(withId(com.stepstone.stepper.R.id.ms_stepCompleteButton)).check(matches(hasTextColor(expectedColor)));
58+
}
59+
4660
}

sample/src/main/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
<activity
5454
android:name=".CustomStepperLayoutThemeActivity"
5555
android:theme="@style/AppThemeDark" />
56+
<activity android:name=".SetButtonColorProgrammaticallyActivity" />
5657
</application>
5758

5859
</manifest>

0 commit comments

Comments
 (0)