Skip to content

Commit

Permalink
Merge pull request #150 from stepstone-tech/develop
Browse files Browse the repository at this point in the history
Release 3.3.0 from develop
  • Loading branch information
zawadz88 authored Jun 10, 2017
2 parents c233abb + af9578e commit 2007d5b
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 5 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Moreover, you can find there other examples, e.g. how to persist state on rotati
- [Showing an error on tabs if step verification failed](#showing-an-error-on-tabs-if-step-verification-failed)
- [Stepper feedback](#stepper-feedback)
- [Changing button text color when going to the next step should be disabled](#changing-button-text-color-when-going-to-the-next-step-should-be-disabled)
- [Hiding bottom navigation bar](#hiding-bottom-navigation-bar)
- [StepperLayout attributes](#stepperlayout-attributes)
- [View attributes](#view-attributes)
- [StepperLayout style attributes](#stepperlayout-style-attributes)
Expand Down Expand Up @@ -56,7 +57,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:3.2.3'
compile 'com.stepstone.stepper:material-stepper:3.3.0'
```

### Create layout in XML
Expand Down Expand Up @@ -435,6 +436,13 @@ In order to set that color:
mStepperLayout.setCompleteButtonVerificationFailed(!enabled);
```

### Hiding bottom navigation bar
Bottom navigation bar is shown by default. If in your UI you would like to
hide the bottom navigation bar you can do that by either setting
the `ms_showBottomNavigation` attribute in XML to `false`
or by setting it programmatically by calling ```StepperLayout#setShowBottomNavigation(boolean)```
with `false`.

## StepperLayout attributes

### View attributes
Expand Down Expand Up @@ -463,6 +471,7 @@ For advanced styling please see [StepperLayout style attributes](#stepperlayout-
| *ms_showErrorStateOnBackEnabled*| boolean | Flag indicating whether to keep showing the error state when user moves back. Only applicable for 'tabs' type. False by default. |
| *ms_tabNavigationEnabled* | boolean | Flag indicating whether step navigation is possible by clicking on the tabs directly. Only applicable for 'tabs' type. True by default. |
| *ms_stepperFeedbackType* | flag(s): `none` or `tabs`, `content` & `disabled_bottom_navigation` | Type(s) of stepper feedback. Can be a combination of `tabs`, `content` & `disabled_bottom_navigation`. Default is `none`.|
| *ms_showBottomNavigation* | boolean | Flag indicating if the Bottom Navigation bar should be shown on the layout. True by default. |
| *ms_stepperLayoutTheme* | reference | Theme to use for even more custom styling of the stepper layout. It is recommended that it should extend @style/MSDefaultStepperLayoutTheme, which is the default theme used. |
### StepperLayout style attributes
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@

POM_GROUP_ID=com.stepstone.stepper
POM_ARTIFACT_ID=material-stepper
POM_VERSION=3.2.3
POM_VERSION=3.3.0
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ public void goToPrevStep() {

private boolean mShowBackButtonOnFirstStep;

private boolean mShowBottomNavigation;

private int mTypeIdentifier = AbstractStepperType.PROGRESS_BAR;

private int mFeedbackTypeMask = StepperFeedbackType.NONE;
Expand Down Expand Up @@ -431,26 +433,62 @@ public int getCurrentStepPosition() {
return mCurrentStepPosition;
}

/**
* Sets whether the Next button in the bottom navigation bar should be in the
* 'verification failed' state i.e. still clickable but with an option to display it
* differently to indicate to the user that he cannot go to the next step yet.
* @param verificationFailed false if verification failed, true otherwise
*/
public void setNextButtonVerificationFailed(boolean verificationFailed) {
mNextNavigationButton.setVerificationFailed(verificationFailed);
}

/**
* Sets whether the Complete button in the bottom navigation bar should be in the
* 'verification failed' state i.e. still clickable but with an option to display it
* differently to indicate to the user that he cannot finish the process yet.
* @param verificationFailed false if verification failed, true otherwise
*/
public void setCompleteButtonVerificationFailed(boolean verificationFailed) {
mCompleteNavigationButton.setVerificationFailed(verificationFailed);
}

/**
* Sets whether the Next button in the bottom navigation bar should be enabled (clickable).
* setting this to <i>false</i> will make it unclickable.
* @param enabled true if the button should be clickable, false otherwise
*/
public void setNextButtonEnabled(boolean enabled) {
mNextNavigationButton.setEnabled(enabled);
}

/**
* Sets whether the Complete button in the bottom navigation bar should be enabled (clickable).
* setting this to <i>false</i> will make it unclickable.
* @param enabled true if the button should be clickable, false otherwise
*/
public void setCompleteButtonEnabled(boolean enabled) {
mCompleteNavigationButton.setEnabled(enabled);
}

/**
* Sets whether the Back button in the bottom navigation bar should be enabled (clickable).
* setting this to <i>false</i> will make it unclickable.
* @param enabled true if the button should be clickable, false otherwise
*/
public void setBackButtonEnabled(boolean enabled) {
mBackNavigationButton.setEnabled(enabled);
}

/**
* Set whether the bottom navigation bar (with Back/Next/Complete buttons) should be visible.
* <i>true</i> by default.
* @param showBottomNavigation true if bottom navigation should be visible, false otherwise
*/
public void setShowBottomNavigation(boolean showBottomNavigation) {
mStepNavigation.setVisibility(showBottomNavigation ? View.VISIBLE : View.GONE);
}

/**
* Set whether when going backwards should clear the error state from the Tab. Default is <code>false</code>.
*
Expand Down Expand Up @@ -618,6 +656,7 @@ public boolean onTouch(View view, MotionEvent motionEvent) {
mDottedProgressBar.setVisibility(GONE);
mProgressBar.setVisibility(GONE);
mTabsContainer.setVisibility(GONE);
mStepNavigation.setVisibility(mShowBottomNavigation ? View.VISIBLE : View.GONE);

mStepperType = StepperTypeFactory.createType(mTypeIdentifier, this);
mStepperFeedbackType = StepperFeedbackTypeFactory.createType(mFeedbackTypeMask, this);
Expand Down Expand Up @@ -739,6 +778,8 @@ private void extractValuesFromAttributes(AttributeSet attrs, @AttrRes int defSty

mShowBackButtonOnFirstStep = a.getBoolean(R.styleable.StepperLayout_ms_showBackButtonOnFirstStep, false);

mShowBottomNavigation = a.getBoolean(R.styleable.StepperLayout_ms_showBottomNavigation, true);

mShowErrorStateEnabled = a.getBoolean(R.styleable.StepperLayout_ms_showErrorState, false);
mShowErrorStateEnabled = a.getBoolean(R.styleable.StepperLayout_ms_showErrorStateEnabled, mShowErrorStateEnabled);

Expand Down
3 changes: 3 additions & 0 deletions material-stepper/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ limitations under the License.
<!-- Flag indicating if the Back (Previous step) button should be shown on the first step. False by default. -->
<attr name="ms_showBackButtonOnFirstStep" format="boolean" />

<!-- Flag indicating if the Bottom Navigation should be shown on the layout. True by default. -->
<attr name="ms_showBottomNavigation" format="boolean" />

<!-- DEPRECATED: Use ms_showErrorStateEnabled instead -->
<attr name="ms_showErrorState" format="boolean" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,58 @@ class StepperLayoutTest {
assertStepperLayout().hasOrientation(LinearLayout.VERTICAL)
}

@Test
fun `Horizontal orientation should be set by default`() {
//given
val attributeSet = createAttributeSetWithStepperType(TYPE_DOTS)

//when
stepperLayout = createStepperLayoutInActivity(attributeSet)

//then
assertStepperLayout().hasOrientation(LinearLayout.VERTICAL)
}

@Test
fun `Bottom navigation should be visible by default`() {
//given
val attributeSet = createAttributeSetWithStepperType(TYPE_TABS)

//when
stepperLayout = createStepperLayoutInActivity(attributeSet)

//then
assertStepperLayout().hasBottomNavigationShown()
}

@Test
fun `Bottom navigation should be hidden if 'ms_showBottomNavigation' attribute is set to 'false' in XML`() {
//given
val attributeSet = Robolectric.buildAttributeSet()
.addAttribute(R.attr.ms_stepperType, TYPE_TABS)
.addAttribute(R.attr.ms_showBottomNavigation, "false")
.build()

//when
stepperLayout = createStepperLayoutInActivity(attributeSet)

//then
assertStepperLayout().hasBottomNavigationHidden()
}

@Test
fun `Bottom navigation should be hidden if set programmatically`() {
//given
val attributeSet = createAttributeSetWithStepperType(TYPE_TABS)
stepperLayout = createStepperLayoutInActivity(attributeSet)

//when
stepperLayout.setShowBottomNavigation(false)

//then
assertStepperLayout().hasBottomNavigationHidden()
}

fun createAttributeSetWithStepperType(stepperType: String): AttributeSet {
return Robolectric.buildAttributeSet()
.addAttribute(R.attr.ms_stepperType, stepperType)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package com.stepstone.stepper.test.assertion

import android.support.annotation.IdRes
import android.view.View

import com.stepstone.stepper.R
import com.stepstone.stepper.StepperLayout

import org.assertj.android.api.Assertions
import org.assertj.android.api.view.ViewAssert
import org.assertj.android.api.widget.AbstractLinearLayoutAssert
Expand Down Expand Up @@ -53,6 +50,16 @@ class StepperLayoutAssert constructor(actual: StepperLayout) : AbstractLinearLay
return this
}

fun hasBottomNavigationShown(): StepperLayoutAssert {
hasNotNullChildView(R.id.ms_bottomNavigation).isVisible
return this
}

fun hasBottomNavigationHidden(): StepperLayoutAssert {
hasNotNullChildView(R.id.ms_bottomNavigation).isGone
return this
}

private fun hasNotNullChildView(@IdRes childId: Int): ViewAssert {
val progressBar = actual.findViewById(childId)
return Assertions.assertThat(progressBar).isNotNull
Expand Down
1 change: 1 addition & 0 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<activity android:name=".PassDataBetweenStepsActivity"
android:windowSoftInputMode="stateVisible"/>
<activity android:name=".DisabledTabNavigationActivity" />
<activity android:name=".HiddenBottomNavigationActivity" />
<activity
android:name=".CustomStepperLayoutThemeActivity"
android:theme="@style/AppThemeDark" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Copyright 2017 StepStone Services
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package com.stepstone.stepper.sample

class HiddenBottomNavigationActivity : AbstractStepperActivity() {

override val layoutResId: Int
get() = R.layout.activity_hidden_bottom_navigation

}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class MainActivity : AppCompatActivity() {
SampleItem(getString(R.string.proceed_programmatically), getString(R.string.proceed_programmatically_description), ProceedProgrammaticallyActivity::class.java),
SampleItem(getString(R.string.passing_data_between_steps), getString(R.string.passing_data_between_steps_description), PassDataBetweenStepsActivity::class.java),
SampleItem(getString(R.string.disabled_tab_navigation), getString(R.string.disabled_tab_navigation_description), DisabledTabNavigationActivity::class.java),
SampleItem(getString(R.string.hidden_bottom_navigation), getString(R.string.hidden_bottom_navigation_description), HiddenBottomNavigationActivity::class.java),
SampleItem(getString(R.string.custom_stepperlayout_theme), getString(R.string.custom_stepperlayout_theme_description), CustomStepperLayoutThemeActivity::class.java)
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<com.stepstone.stepper.StepperLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/stepperLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:ms_showBottomNavigation="false"
app:ms_stepperType="tabs" />
2 changes: 2 additions & 0 deletions sample/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<string name="proceed_programmatically">Proceed programmatically</string>
<string name="passing_data_between_steps">Passing data between steps</string>
<string name="disabled_tab_navigation">Disabled tab navigation</string>
<string name="hidden_bottom_navigation">Hidden bottom navigation</string>
<string name="custom_stepperlayout_theme">Custom StepperLayout theme</string>

<string name="default_dots_description">The default implementation of a dotted stepper</string>
Expand All @@ -43,6 +44,7 @@
<string name="proceed_programmatically_description">Shows how to navigate to the next steps without clicking on the bottom navigation buttons</string>
<string name="passing_data_between_steps_description">Shows how to pass data from one fragment to the next by using parent Activity</string>
<string name="disabled_tab_navigation_description">Shows how to disable clicking on tabs in a tabbed stepper</string>
<string name="hidden_bottom_navigation_description">Shows how to hide bottom navigation</string>
<string name="custom_stepperlayout_theme_description">Shows a styled stepper layout with custom fonts &amp; colors</string>

<string name="tab_title">Tab title</string>
Expand Down

0 comments on commit 2007d5b

Please sign in to comment.