Skip to content

Commit

Permalink
Merge pull request #212 from stepstone-tech/develop
Browse files Browse the repository at this point in the history
Merge develop - release of 4.3.0
  • Loading branch information
zawadz88 authored Sep 27, 2017
2 parents f831bed + 53cc965 commit c63fd62
Show file tree
Hide file tree
Showing 26 changed files with 332 additions and 84 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [4.3.0]
### Added
- A way to set bottom navigation button colors programmatically via:
`StepperLayout#setNextButtonColor(int)`/`StepperLayout#setNextButtonColor(ColorStateList)`,
`StepperLayout#setCompleteButtonColor(int)`/`StepperLayout#setCompleteButtonColor(ColorStateList)` and
`StepperLayout#setBackButtonColor(int)`/`StepperLayout#setBackButtonColor(ColorStateList)` (issue #132).

### Fixed
- Tab circle background color so that it is possible now to use colors with transparency (issue #207).

## [4.2.0]
### Added
- A new artifact `espresso-material-stepper` with useful Espresso actions and matchers for testing `StepperLayout` with Espresso.
Expand All @@ -30,6 +40,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- **Breaking change:** Changed `setNextButtonLabel` methods in `StepViewModel.Builder` to `setEndButtonLabel` so that it works for both Next and Complete buttons (issue #107)
- **Breaking change:** Split `content` stepper feedback type into `content_progress` and `content_fade`.

[4.3.0]: https://github.com/stepstone-tech/android-material-stepper/compare/v4.2.0...v4.3.0
[4.2.0]: https://github.com/stepstone-tech/android-material-stepper/compare/v4.1.0...v4.2.0
[4.1.0]: https://github.com/stepstone-tech/android-material-stepper/compare/v4.0.0...v4.1.0
[4.0.0]: https://github.com/stepstone-tech/android-material-stepper/compare/v3.3.0...v4.0.0
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Moreover, you can find there other examples, e.g. how to persist state on rotati

### Download (from JCenter)
```groovy
compile 'com.stepstone.stepper:material-stepper:4.2.0'
compile 'com.stepstone.stepper:material-stepper:4.3.0'
```

*Note:* This library adds a transitive dependency to AppCompat `25.4.0`
Expand Down Expand Up @@ -477,9 +477,9 @@ For advanced styling please see [StepperLayout style attributes](#stepperlayout-
| Attribute name | Format | Description |
| --------------------------------|---------------------------------------------------------------------|-------------|
| *ms_stepperType* | one of `dots`, `progress_bar`, `tabs` or `none` | **REQUIRED:** Type of the stepper |
| *ms_backButtonColor* | color or reference | BACK button's text color |
| *ms_nextButtonColor* | color or reference | NEXT button's text color |
| *ms_completeButtonColor* | color or reference | COMPLETE button's text color |
| *ms_backButtonColor* | color or reference | BACK button's text color, can be also set via `StepperLayout#setBackButtonColor(int)`/`StepperLayout#setBackButtonColor(ColorStateList)` |
| *ms_nextButtonColor* | color or reference | NEXT button's text color, can be also set via `StepperLayout#setNextButtonColor(int)`/`StepperLayout#setNextButtonColor(ColorStateList)` |
| *ms_completeButtonColor* | color or reference | COMPLETE button's text color, can be also set via `StepperLayout#setCompleteButtonColor(int)`/`StepperLayout#setCompleteButtonColor(ColorStateList)` |
| *ms_activeStepColor* | color or reference | Active step's color |
| *ms_inactiveStepColor* | color or reference | Inactive step's color |
| *ms_bottomNavigationBackground* | reference | Background of the bottom navigation |
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.gradleAndroidVersion = '3.0.0-beta4'
ext.gradleAndroidVersion = '3.0.0-beta6'
ext.kotlinVersion = '1.1.3-2'
ext.bintrayVersion = '1.7.3'
ext.mavenGradlePluginVersion = '2.0'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
POM_GROUP_ID=com.stepstone.stepper
POM_ARTIFACT_ID=material-stepper
POM_TEST_ARTIFACT_ID=espresso-material-stepper
POM_VERSION=4.2.0
POM_VERSION=4.3.0

#Needed so that Robolectric is working: https://github.com/robolectric/robolectric/issues/3169
android.enableAapt2=false
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,63 @@ public void setTabNavigationEnabled(boolean tabNavigationEnabled) {
mTabNavigationEnabled = tabNavigationEnabled;
}

/**
* Changes the text and compound drawable color of the Next bottom navigation button.
*
* @param newButtonColor new color state list
*/
public void setNextButtonColor(@NonNull ColorStateList newButtonColor) {
mNextButtonColor = newButtonColor;
TintUtil.tintTextView(mNextNavigationButton, mNextButtonColor);
}

/**
* Changes the text and compound drawable color of the Complete bottom navigation button.
*
* @param newButtonColor new color state list
*/
public void setCompleteButtonColor(@NonNull ColorStateList newButtonColor) {
mCompleteButtonColor = newButtonColor;
TintUtil.tintTextView(mCompleteNavigationButton, mCompleteButtonColor);
}

/**
* Changes the text and compound drawable color of the Back bottom navigation button.
*
* @param newButtonColor new color state list
*/
public void setBackButtonColor(@NonNull ColorStateList newButtonColor) {
mBackButtonColor = newButtonColor;
TintUtil.tintTextView(mBackNavigationButton, mBackButtonColor);
}

/**
* Changes the text and compound drawable color of the Next bottom navigation button.
*
* @param newButtonColor new color int
*/
public void setNextButtonColor(@ColorInt int newButtonColor) {
setNextButtonColor(ColorStateList.valueOf(newButtonColor));
}

/**
* Changes the text and compound drawable color of the Complete bottom navigation button.
*
* @param newButtonColor new color int
*/
public void setCompleteButtonColor(@ColorInt int newButtonColor) {
setCompleteButtonColor(ColorStateList.valueOf(newButtonColor));
}

/**
* Changes the text and compound drawable color of the Back bottom navigation button.
*
* @param newButtonColor new color int
*/
public void setBackButtonColor(@ColorInt int newButtonColor) {
setBackButtonColor(ColorStateList.valueOf(newButtonColor));
}

/**
* Updates the error state in the UI.
* It does nothing if showing error state is disabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.stepstone.stepper.internal.widget;

import android.content.Context;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Animatable;
import android.graphics.drawable.Drawable;
Expand Down Expand Up @@ -295,7 +296,7 @@ protected void changeToDone() {
protected void changeToWarning(@Nullable CharSequence errorMessage) {
mStepDoneIndicator.setVisibility(View.GONE);
mStepNumberTextView.setVisibility(View.GONE);
mStepIconBackground.setColorFilter(mErrorColor);
mStepIconBackground.setColorFilter(mErrorColor, PorterDuff.Mode.SRC_IN);
mStepTitleTextView.setTextColor(mErrorColor);
mStepSubtitleTextView.setTextColor(mErrorColor);
updateSubtitle(errorMessage);
Expand Down Expand Up @@ -330,7 +331,7 @@ class InactiveNumberState extends AbstractNumberState {

@Override
protected void changeToInactiveNumber() {
mStepIconBackground.setColorFilter(mUnselectedColor);
mStepIconBackground.setColorFilter(mUnselectedColor, PorterDuff.Mode.SRC_IN);
mStepTitleTextView.setTextColor(mTitleColor);
mStepTitleTextView.setAlpha(ALPHA_INACTIVE_STEP_TITLE);
mStepSubtitleTextView.setTextColor(mSubtitleColor);
Expand All @@ -339,7 +340,7 @@ protected void changeToInactiveNumber() {

@Override
protected void changeToActiveNumber() {
mStepIconBackground.setColorFilter(mSelectedColor);
mStepIconBackground.setColorFilter(mSelectedColor, PorterDuff.Mode.SRC_IN);
mStepTitleTextView.setAlpha(ALPHA_ACTIVE_STEP_TITLE);
super.changeToActiveNumber();
}
Expand All @@ -357,7 +358,7 @@ class ActiveNumberState extends AbstractNumberState {

@Override
protected void changeToInactiveNumber() {
mStepIconBackground.setColorFilter(mUnselectedColor);
mStepIconBackground.setColorFilter(mUnselectedColor, PorterDuff.Mode.SRC_IN);
mStepTitleTextView.setAlpha(ALPHA_INACTIVE_STEP_TITLE);
super.changeToInactiveNumber();
}
Expand All @@ -370,7 +371,7 @@ class DoneState extends AbstractState {
protected void changeToInactiveNumber() {
mStepDoneIndicator.setVisibility(GONE);
mStepNumberTextView.setVisibility(VISIBLE);
mStepIconBackground.setColorFilter(mUnselectedColor);
mStepIconBackground.setColorFilter(mUnselectedColor, PorterDuff.Mode.SRC_IN);
mStepTitleTextView.setAlpha(ALPHA_INACTIVE_STEP_TITLE);
super.changeToInactiveNumber();
}
Expand Down Expand Up @@ -398,7 +399,7 @@ class WarningState extends AbstractState {
protected void changeToDone() {
animateViewIn(mStepDoneIndicator);

mStepIconBackground.setColorFilter(mSelectedColor);
mStepIconBackground.setColorFilter(mSelectedColor, PorterDuff.Mode.SRC_IN);
mStepTitleTextView.setTextColor(mTitleColor);
mStepSubtitleTextView.setTextColor(mSubtitleColor);
super.changeToDone();
Expand All @@ -408,7 +409,7 @@ protected void changeToDone() {
protected void changeToInactiveNumber() {
animateViewIn(mStepNumberTextView);

mStepIconBackground.setColorFilter(mUnselectedColor);
mStepIconBackground.setColorFilter(mUnselectedColor, PorterDuff.Mode.SRC_IN);
mStepTitleTextView.setTextColor(mTitleColor);
mStepTitleTextView.setAlpha(ALPHA_INACTIVE_STEP_TITLE);
mStepSubtitleTextView.setTextColor(mSubtitleColor);
Expand All @@ -420,7 +421,7 @@ protected void changeToInactiveNumber() {
protected void changeToActiveNumber() {
animateViewIn(mStepNumberTextView);

mStepIconBackground.setColorFilter(mSelectedColor);
mStepIconBackground.setColorFilter(mSelectedColor, PorterDuff.Mode.SRC_IN);
mStepTitleTextView.setTextColor(mTitleColor);
mStepSubtitleTextView.setTextColor(mSubtitleColor);
super.changeToActiveNumber();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,16 @@ public void shouldOpenCustomStepperLayoutThemeActivity() {
SpoonScreenshotAction.perform(getScreenshotTag(24, R.string.custom_stepperlayout_theme));
}

@Test
public void shouldOpenSetButtonColorProgrammaticallyActivity() {
//when
clickRowWithText(R.string.set_button_color_programmatically);

//then
intended(hasComponent(SetButtonColorProgrammaticallyActivity.class.getName()));
SpoonScreenshotAction.perform(getScreenshotTag(25, R.string.set_button_color_programmatically));
}

@NonNull
private String getScreenshotTag(int position, @StringRes int titleResId) {
return String.format(Locale.ENGLISH,"%02d", position) + ". " + intentsTestRule.getActivity().getString(titleResId);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package com.stepstone.stepper.sample;

import android.support.test.filters.LargeTest;

import com.stepstone.stepper.sample.test.action.SpoonScreenshotAction;

import org.junit.Test;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.doubleClick;
import static android.support.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static com.stepstone.stepper.sample.test.matcher.CommonMatchers.checkBackButtonColor;
import static com.stepstone.stepper.sample.test.matcher.CommonMatchers.checkCompleteButtonColor;
import static com.stepstone.stepper.sample.test.matcher.CommonMatchers.checkCompleteButtonShown;
import static com.stepstone.stepper.sample.test.matcher.CommonMatchers.checkCurrentStepIs;
import static com.stepstone.stepper.sample.test.matcher.CommonMatchers.checkNextButtonColor;
import static com.stepstone.stepper.test.StepperNavigationActions.clickComplete;
import static com.stepstone.stepper.test.StepperNavigationActions.clickNext;
import static org.hamcrest.Matchers.allOf;

/**
* Performs tests on a stepper on which we change the button colors in code.
*
* @author Piotr Zawadzki
*/
@LargeTest
public class SetButtonColorProgrammaticallyActivityTest extends AbstractActivityTest<SetButtonColorProgrammaticallyActivity> {

@Test
public void shouldStayOnTheFirstStepWhenVerificationFails() {
//when
onView(withId(R.id.stepperLayout)).perform(clickNext());

//then
SpoonScreenshotAction.perform(getScreenshotTag(1, "Verification failure test"));
checkCurrentStepIs(0);
checkNextButtonColor(R.color.verification_failed_color);
}

@Test
public void shouldGoToTheNextStepWhenVerificationSucceeds() {
//given
onView(allOf(withId(R.id.button), isCompletelyDisplayed())).perform(doubleClick());

//when
onView(withId(R.id.stepperLayout)).perform(clickNext());

//then
SpoonScreenshotAction.perform(getScreenshotTag(2, "Verification success test"));
checkCurrentStepIs(1);
checkNextButtonColor(R.color.ms_black);
checkBackButtonColor(R.color.ms_white);
}

@Test
public void shouldShowCompleteButtonOnTheLastStep() {
//given
onView(allOf(withId(R.id.button), isCompletelyDisplayed())).perform(doubleClick());
onView(withId(R.id.stepperLayout)).perform(clickNext());
onView(allOf(withId(R.id.button), isCompletelyDisplayed())).perform(doubleClick());

//when
onView(withId(R.id.stepperLayout)).perform(clickNext());

//then
SpoonScreenshotAction.perform(getScreenshotTag(3, "Last step test"));
checkCurrentStepIs(2);
checkCompleteButtonShown();
checkCompleteButtonColor(R.color.verification_failed_color);
checkBackButtonColor(R.color.ms_black);
}

@Test
public void shouldCompleteStepperFlow() {
//given
onView(allOf(withId(R.id.button), isCompletelyDisplayed())).perform(doubleClick());
onView(withId(R.id.stepperLayout)).perform(clickNext());
onView(allOf(withId(R.id.button), isCompletelyDisplayed())).perform(doubleClick());
onView(withId(R.id.stepperLayout)).perform(clickNext());
onView(allOf(withId(R.id.button), isCompletelyDisplayed())).perform(doubleClick());

//when
onView(withId(R.id.stepperLayout)).perform(clickComplete());

//then
SpoonScreenshotAction.perform(getScreenshotTag(4, "Completion test"));
checkCurrentStepIs(2);
checkCompleteButtonColor(R.color.ms_black);
checkBackButtonColor(R.color.ms_black);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.stepstone.stepper.sample.test.matcher;

import android.support.annotation.ColorRes;
import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.view.View;
Expand All @@ -11,6 +12,7 @@

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.hasTextColor;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static com.stepstone.stepper.sample.test.matcher.StepperLayoutTabStateMatcher.tabAtPositionIsInState;
Expand Down Expand Up @@ -43,4 +45,16 @@ public static void checkCompleteButtonShown() {
onView(withId(R.id.ms_stepCompleteButton)).check(matches(isDisplayed()));
}

public static void checkBackButtonColor(@ColorRes int expectedColor) {
onView(withId(com.stepstone.stepper.R.id.ms_stepPrevButton)).check(matches(hasTextColor(expectedColor)));
}

public static void checkNextButtonColor(@ColorRes int expectedColor) {
onView(withId(com.stepstone.stepper.R.id.ms_stepNextButton)).check(matches(hasTextColor(expectedColor)));
}

public static void checkCompleteButtonColor(@ColorRes int expectedColor) {
onView(withId(com.stepstone.stepper.R.id.ms_stepCompleteButton)).check(matches(hasTextColor(expectedColor)));
}

}
1 change: 1 addition & 0 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<activity
android:name=".CustomStepperLayoutThemeActivity"
android:theme="@style/AppThemeDark" />
<activity android:name=".SetButtonColorProgrammaticallyActivity" />
</application>

</manifest>
Loading

0 comments on commit c63fd62

Please sign in to comment.