Skip to content

Commit

Permalink
Merge branch 'master' of github.com:natura-cosmeticos/natds-android
Browse files Browse the repository at this point in the history
  • Loading branch information
mlcsouza committed Dec 2, 2020
2 parents 343890f + 133d506 commit 1db39ca
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.natura.android.progressindicator

import android.content.Context
import android.util.AttributeSet
import android.widget.ProgressBar

class ProgressIndicator @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null
) : ProgressBar(context)
17 changes: 17 additions & 0 deletions doc/progress-indicator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Progress Indicator

### What is it?
A user interface element that indicates the progress of an operation.

### How to use it?
Nat DS Android Progress Indicator is based on a android [ProgressBar](https://developer.android.com/reference/android/widget/ProgressBar) with styles provided by Nat DS Theme.
To use it, a Nat DS Theme must be provided to the view or its parents. After that, its possible to add a ProgressIndicator component on xml layout:

```android
<com.natura.android.progressindicator.ProgressIndicator
android:id="@+id/ds_loading"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
```

⚠️⚠️⚠️ Nat DS Android supports for now only Circular variant of Progress Indicator ⚠️⚠️⚠️
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,11 @@ class MainActivityFunctionalTests {
}

@Test
fun shouldOpenLoadingScreenWhenTapOnItButton() {
onView(withId(R.id.btnLoader)).perform(scrollTo())
onView(withId(R.id.btnLoader)).perform(click())
fun shouldOpenProgressIndicatorScreenWhenTapOnItButton() {
onView(withId(R.id.progressIndicatorButton)).perform(scrollTo())
onView(withId(R.id.progressIndicatorButton)).perform(click())

onView(withText("Loading Pattern")).check(matches(isDisplayed()))
onView(withText("Progress Indicator")).check(matches(isDisplayed()))
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
android:name=".tokens.icons.DrawableActivity"
android:theme="@style/Theme.Natura" />
<activity
android:name=".patterns.LoadingActivity"
android:name=".components.ProgressIndicatorActivity"
android:theme="@style/Theme.Natura" />
<activity
android:name=".components.ValueTextHighlightActivity"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.natura.android.sample.components.*
import com.natura.android.sample.patterns.ErrorActivity
import com.natura.android.sample.patterns.LoadingActivity
import com.natura.android.sample.components.ProgressIndicatorActivity
import com.natura.android.sample.patterns.LogoActivity
import com.natura.android.sample.tokens.*
import com.natura.android.sample.tokens.icons.DrawableActivity
Expand Down Expand Up @@ -108,8 +108,8 @@ class MainActivity : AppCompatActivity() {
startActivity(Intent(this, ExpandableNavigationViewActivity::class.java))
}

btnLoader.setOnClickListener {
startActivity(Intent(this, LoadingActivity::class.java))
progressIndicatorButton.setOnClickListener {
startActivity(Intent(this, ProgressIndicatorActivity::class.java))
}

btnErrorDefault.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.natura.android.sample.patterns
package com.natura.android.sample.components

import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import com.natura.android.sample.R
import com.natura.android.sample.setChosenDefaultTheme

class LoadingActivity : AppCompatActivity() {
class ProgressIndicatorActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
setChosenDefaultTheme()

super.onCreate(savedInstanceState)
setContentView(R.layout.activity_loading)
setContentView(R.layout.activity_progress_indicator)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.title = "Loading Pattern"
supportActionBar?.title = "Progress Indicator"
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
Expand Down
9 changes: 0 additions & 9 deletions sample/src/main/res/layout/activity_loading.xml

This file was deleted.

24 changes: 12 additions & 12 deletions sample/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,18 @@
android:background="@color/surface"
android:textColor="@color/highEmphasis" />

<Button
android:id="@+id/progressIndicatorButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Progress Indicator"
android:drawableRight="@drawable/ds_ic_outlined_navigation_arrowleft"
android:textAlignment="textStart"
android:layout_gravity="start"
android:padding="16dp"
android:background="@color/surface"
android:textColor="@color/highEmphasis" />

<Button
android:id="@+id/btnSelection"
android:layout_width="match_parent"
Expand Down Expand Up @@ -280,18 +292,6 @@
android:background="@color/surface"
android:textColor="@color/highEmphasis" />

<Button
android:id="@+id/btnLoader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Loading"
android:drawableRight="@drawable/ds_ic_outlined_navigation_arrowleft"
android:textAlignment="textStart"
android:layout_gravity="start"
android:padding="16dp"
android:background="@color/surface"
android:textColor="@color/highEmphasis" />

<Button
android:id="@+id/logoPatternButton"
android:layout_width="match_parent"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
android:orientation="vertical">

<ProgressBar
<com.natura.android.progressindicator.ProgressIndicator
android:id="@+id/ds_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -15,6 +16,6 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.5"
tools:visibility="visible" />

</merge>
</androidx.constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.widget.Button
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.natura.android.sample.components.*
import com.natura.android.sample.patterns.ErrorActivity
import com.natura.android.sample.patterns.LoadingActivity
import com.natura.android.sample.components.ProgressIndicatorActivity
import com.natura.android.sample.patterns.LogoActivity
import com.natura.android.sample.tokens.*
import com.natura.android.sample.tokens.icons.DrawableActivity
Expand Down Expand Up @@ -151,14 +151,14 @@ class MainActivityTest {
}

@Test
fun checksLoadingButtonClickStartsLoadingScreen() {
val button = mainActivity.findViewById<Button>(R.id.btnLoader)
fun checksProgressIndicatorButtonClickStartsProgressIndicatorScreen() {
val button = mainActivity.findViewById<Button>(R.id.progressIndicatorButton)

button.performClick()
val startedIntent = shadowActivity.peekNextStartedActivity()
val shadowIntent = shadowOf(startedIntent)

assertEquals(LoadingActivity::class.java, shadowIntent.intentClass)
assertEquals(ProgressIndicatorActivity::class.java, shadowIntent.intentClass)
}

@Test
Expand Down

0 comments on commit 1db39ca

Please sign in to comment.