Skip to content

Commit 2007d5b

Browse files
authored
Merge pull request #150 from stepstone-tech/develop
Release 3.3.0 from develop
2 parents c233abb + af9578e commit 2007d5b

File tree

11 files changed

+153
-5
lines changed

11 files changed

+153
-5
lines changed

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Moreover, you can find there other examples, e.g. how to persist state on rotati
2727
- [Showing an error on tabs if step verification failed](#showing-an-error-on-tabs-if-step-verification-failed)
2828
- [Stepper feedback](#stepper-feedback)
2929
- [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)
30+
- [Hiding bottom navigation bar](#hiding-bottom-navigation-bar)
3031
- [StepperLayout attributes](#stepperlayout-attributes)
3132
- [View attributes](#view-attributes)
3233
- [StepperLayout style attributes](#stepperlayout-style-attributes)
@@ -56,7 +57,7 @@ Moreover, you can find there other examples, e.g. how to persist state on rotati
5657

5758
### Download (from JCenter)
5859
```groovy
59-
compile 'com.stepstone.stepper:material-stepper:3.2.3'
60+
compile 'com.stepstone.stepper:material-stepper:3.3.0'
6061
```
6162

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

439+
### Hiding bottom navigation bar
440+
Bottom navigation bar is shown by default. If in your UI you would like to
441+
hide the bottom navigation bar you can do that by either setting
442+
the `ms_showBottomNavigation` attribute in XML to `false`
443+
or by setting it programmatically by calling ```StepperLayout#setShowBottomNavigation(boolean)```
444+
with `false`.
445+
438446
## StepperLayout attributes
439447

440448
### View attributes
@@ -463,6 +471,7 @@ For advanced styling please see [StepperLayout style attributes](#stepperlayout-
463471
| *ms_showErrorStateOnBackEnabled*| boolean | Flag indicating whether to keep showing the error state when user moves back. Only applicable for 'tabs' type. False by default. |
464472
| *ms_tabNavigationEnabled* | boolean | Flag indicating whether step navigation is possible by clicking on the tabs directly. Only applicable for 'tabs' type. True by default. |
465473
| *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`.|
474+
| *ms_showBottomNavigation* | boolean | Flag indicating if the Bottom Navigation bar should be shown on the layout. True by default. |
466475
| *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. |
467476
468477
### StepperLayout style attributes

gradle.properties

+1-1
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=3.2.3
22+
POM_VERSION=3.3.0

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

+41
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ public void goToPrevStep() {
224224

225225
private boolean mShowBackButtonOnFirstStep;
226226

227+
private boolean mShowBottomNavigation;
228+
227229
private int mTypeIdentifier = AbstractStepperType.PROGRESS_BAR;
228230

229231
private int mFeedbackTypeMask = StepperFeedbackType.NONE;
@@ -431,26 +433,62 @@ public int getCurrentStepPosition() {
431433
return mCurrentStepPosition;
432434
}
433435

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

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

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

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

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

483+
/**
484+
* Set whether the bottom navigation bar (with Back/Next/Complete buttons) should be visible.
485+
* <i>true</i> by default.
486+
* @param showBottomNavigation true if bottom navigation should be visible, false otherwise
487+
*/
488+
public void setShowBottomNavigation(boolean showBottomNavigation) {
489+
mStepNavigation.setVisibility(showBottomNavigation ? View.VISIBLE : View.GONE);
490+
}
491+
454492
/**
455493
* Set whether when going backwards should clear the error state from the Tab. Default is <code>false</code>.
456494
*
@@ -618,6 +656,7 @@ public boolean onTouch(View view, MotionEvent motionEvent) {
618656
mDottedProgressBar.setVisibility(GONE);
619657
mProgressBar.setVisibility(GONE);
620658
mTabsContainer.setVisibility(GONE);
659+
mStepNavigation.setVisibility(mShowBottomNavigation ? View.VISIBLE : View.GONE);
621660

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

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

781+
mShowBottomNavigation = a.getBoolean(R.styleable.StepperLayout_ms_showBottomNavigation, true);
782+
742783
mShowErrorStateEnabled = a.getBoolean(R.styleable.StepperLayout_ms_showErrorState, false);
743784
mShowErrorStateEnabled = a.getBoolean(R.styleable.StepperLayout_ms_showErrorStateEnabled, mShowErrorStateEnabled);
744785

material-stepper/src/main/res/values/attrs.xml

+3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ limitations under the License.
5252
<!-- Flag indicating if the Back (Previous step) button should be shown on the first step. False by default. -->
5353
<attr name="ms_showBackButtonOnFirstStep" format="boolean" />
5454

55+
<!-- Flag indicating if the Bottom Navigation should be shown on the layout. True by default. -->
56+
<attr name="ms_showBottomNavigation" format="boolean" />
57+
5558
<!-- DEPRECATED: Use ms_showErrorStateEnabled instead -->
5659
<attr name="ms_showErrorState" format="boolean" />
5760

material-stepper/src/test/java/com/stepstone/stepper/StepperLayoutTest.kt

+52
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,58 @@ class StepperLayoutTest {
153153
assertStepperLayout().hasOrientation(LinearLayout.VERTICAL)
154154
}
155155

156+
@Test
157+
fun `Horizontal orientation should be set by default`() {
158+
//given
159+
val attributeSet = createAttributeSetWithStepperType(TYPE_DOTS)
160+
161+
//when
162+
stepperLayout = createStepperLayoutInActivity(attributeSet)
163+
164+
//then
165+
assertStepperLayout().hasOrientation(LinearLayout.VERTICAL)
166+
}
167+
168+
@Test
169+
fun `Bottom navigation should be visible by default`() {
170+
//given
171+
val attributeSet = createAttributeSetWithStepperType(TYPE_TABS)
172+
173+
//when
174+
stepperLayout = createStepperLayoutInActivity(attributeSet)
175+
176+
//then
177+
assertStepperLayout().hasBottomNavigationShown()
178+
}
179+
180+
@Test
181+
fun `Bottom navigation should be hidden if 'ms_showBottomNavigation' attribute is set to 'false' in XML`() {
182+
//given
183+
val attributeSet = Robolectric.buildAttributeSet()
184+
.addAttribute(R.attr.ms_stepperType, TYPE_TABS)
185+
.addAttribute(R.attr.ms_showBottomNavigation, "false")
186+
.build()
187+
188+
//when
189+
stepperLayout = createStepperLayoutInActivity(attributeSet)
190+
191+
//then
192+
assertStepperLayout().hasBottomNavigationHidden()
193+
}
194+
195+
@Test
196+
fun `Bottom navigation should be hidden if set programmatically`() {
197+
//given
198+
val attributeSet = createAttributeSetWithStepperType(TYPE_TABS)
199+
stepperLayout = createStepperLayoutInActivity(attributeSet)
200+
201+
//when
202+
stepperLayout.setShowBottomNavigation(false)
203+
204+
//then
205+
assertStepperLayout().hasBottomNavigationHidden()
206+
}
207+
156208
fun createAttributeSetWithStepperType(stepperType: String): AttributeSet {
157209
return Robolectric.buildAttributeSet()
158210
.addAttribute(R.attr.ms_stepperType, stepperType)

material-stepper/src/test/java/com/stepstone/stepper/test/assertion/StepperLayoutAssert.kt

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package com.stepstone.stepper.test.assertion
22

33
import android.support.annotation.IdRes
4-
import android.view.View
5-
64
import com.stepstone.stepper.R
75
import com.stepstone.stepper.StepperLayout
8-
96
import org.assertj.android.api.Assertions
107
import org.assertj.android.api.view.ViewAssert
118
import org.assertj.android.api.widget.AbstractLinearLayoutAssert
@@ -53,6 +50,16 @@ class StepperLayoutAssert constructor(actual: StepperLayout) : AbstractLinearLay
5350
return this
5451
}
5552

53+
fun hasBottomNavigationShown(): StepperLayoutAssert {
54+
hasNotNullChildView(R.id.ms_bottomNavigation).isVisible
55+
return this
56+
}
57+
58+
fun hasBottomNavigationHidden(): StepperLayoutAssert {
59+
hasNotNullChildView(R.id.ms_bottomNavigation).isGone
60+
return this
61+
}
62+
5663
private fun hasNotNullChildView(@IdRes childId: Int): ViewAssert {
5764
val progressBar = actual.findViewById(childId)
5865
return Assertions.assertThat(progressBar).isNotNull

sample/src/main/AndroidManifest.xml

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<activity android:name=".PassDataBetweenStepsActivity"
4141
android:windowSoftInputMode="stateVisible"/>
4242
<activity android:name=".DisabledTabNavigationActivity" />
43+
<activity android:name=".HiddenBottomNavigationActivity" />
4344
<activity
4445
android:name=".CustomStepperLayoutThemeActivity"
4546
android:theme="@style/AppThemeDark" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Copyright 2017 StepStone Services
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package com.stepstone.stepper.sample
18+
19+
class HiddenBottomNavigationActivity : AbstractStepperActivity() {
20+
21+
override val layoutResId: Int
22+
get() = R.layout.activity_hidden_bottom_navigation
23+
24+
}

sample/src/main/java/com/stepstone/stepper/sample/MainActivity.kt

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class MainActivity : AppCompatActivity() {
7373
SampleItem(getString(R.string.proceed_programmatically), getString(R.string.proceed_programmatically_description), ProceedProgrammaticallyActivity::class.java),
7474
SampleItem(getString(R.string.passing_data_between_steps), getString(R.string.passing_data_between_steps_description), PassDataBetweenStepsActivity::class.java),
7575
SampleItem(getString(R.string.disabled_tab_navigation), getString(R.string.disabled_tab_navigation_description), DisabledTabNavigationActivity::class.java),
76+
SampleItem(getString(R.string.hidden_bottom_navigation), getString(R.string.hidden_bottom_navigation_description), HiddenBottomNavigationActivity::class.java),
7677
SampleItem(getString(R.string.custom_stepperlayout_theme), getString(R.string.custom_stepperlayout_theme_description), CustomStepperLayoutThemeActivity::class.java)
7778
)
7879

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<com.stepstone.stepper.StepperLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
4+
android:id="@+id/stepperLayout"
5+
android:layout_width="match_parent"
6+
android:layout_height="match_parent"
7+
app:ms_showBottomNavigation="false"
8+
app:ms_stepperType="tabs" />

sample/src/main/res/values/strings.xml

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<string name="proceed_programmatically">Proceed programmatically</string>
2222
<string name="passing_data_between_steps">Passing data between steps</string>
2323
<string name="disabled_tab_navigation">Disabled tab navigation</string>
24+
<string name="hidden_bottom_navigation">Hidden bottom navigation</string>
2425
<string name="custom_stepperlayout_theme">Custom StepperLayout theme</string>
2526

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

4850
<string name="tab_title">Tab title</string>

0 commit comments

Comments
 (0)