Skip to content

Commit

Permalink
Merge branch 'release' into feature/NFS-408-text-field-input
Browse files Browse the repository at this point in the history
  • Loading branch information
pmunizferreira authored Mar 12, 2020
2 parents 88cb478 + 2982ba3 commit 789de3e
Show file tree
Hide file tree
Showing 23 changed files with 505 additions and 2 deletions.
3 changes: 3 additions & 0 deletions bitrise-test3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Teste para adicionar o bitrise
--Adicionando webhook para testes
Adicionando mais linhas
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.natura.android.widget

import android.content.Context
import android.support.constraint.ConstraintLayout
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.TextView
import com.natura.android.R

class TextInputHighlight @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr) {

private lateinit var descriptionLabel: TextView
private lateinit var highlightInfoLabel: TextView

init {
LayoutInflater.from(context)
.inflate(R.layout.ds_input_text_highlight_view, this, true)

with(context.obtainStyledAttributes(attrs, R.styleable.ds_text_input_highlight)) {
val description = this.getString(R.styleable.ds_text_input_highlight_description_label)
val highlight = this.getString(R.styleable.ds_text_input_highlight_highlight_label)

setupView(description, highlight)

this.recycle()
}
}

private fun setupView(description: String?, highlight: String?) {
descriptionLabel = findViewById(R.id.description_label)
highlightInfoLabel = findViewById(R.id.highlight_label)

description?.let { descriptionLabel.text = it }
highlight?.let { highlightInfoLabel.text = it }
}

fun setDescription(description: String) {
descriptionLabel.text = description
descriptionLabel.invalidate()
descriptionLabel.requestLayout()
}

fun setHighlightedInfo(highlightStr: String) {
highlightInfoLabel.text = highlightStr
highlightInfoLabel.invalidate()
highlightInfoLabel.requestLayout()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@android:color/black" android:state_enabled="true"/>
<item android:color="@color/mtrlBtnTextColorDisabled"/>
</selector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?colorSecondary" android:state_enabled="true"/>
<item android:color="@color/colorBrdBlack_12"/>
</selector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@android:color/black" android:state_enabled="true"/>
<item android:color="@color/mtrlBtnTextColorDisabled"/>
</selector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="?colorSecondary" android:state_enabled="true"/>
<item android:color="@color/mtrlBtnTextColorDisabled"/>
</selector>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:alpha="0.16" android:color="?attr/colorSecondary" android:state_pressed="true"/>
<item android:alpha="0.12" android:color="?attr/colorSecondary" android:state_focused="true" android:state_hovered="true"/>
<item android:alpha="0.12" android:color="?attr/colorSecondary" android:state_focused="true"/>
<item android:alpha="0.04" android:color="?attr/colorSecondary" android:state_hovered="true"/>
<item android:alpha="0.00" android:color="?attr/colorSecondary"/>
</selector>
49 changes: 49 additions & 0 deletions designsystem/src/main/res/layout/ds_input_text_highlight_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<merge
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="wrap_content"
tools:parentTag="android.support.constraint.ConstraintLayout">

<View
android:id="@+id/superior_divider"
style="@style/Widget.Natura.Divider"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/description_label"
style="@style/TextAppearence.Natura.Default"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/ds_spacin_tiny"
android:layout_marginLeft="@dimen/ds_spacin_tiny"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/superior_divider"
tools:text="AMOUNT TO TRANSFER" />

<TextView
android:id="@+id/highlight_label"
style="@style/TextAppearence.Natura.Highlight"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/ds_spacin_tiny"
android:layout_marginRight="@dimen/ds_spacin_tiny"
android:gravity="end"
app:layout_constraintBottom_toBottomOf="@id/description_label"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/description_label"
app:layout_constraintTop_toTopOf="@id/description_label"
tools:text="$ 120,75" />

<View
android:id="@+id/inferior_divider"
style="@style/Widget.Natura.Divider"
android:layout_marginTop="@dimen/ds_spacing_standard"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/highlight_label" />

</merge>
26 changes: 26 additions & 0 deletions designsystem/src/main/res/values/button_styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="Widget.Natura.Button" parent="Widget.MaterialComponents.Button">
<item name="android:textColor">@color/ds_mtrl_default_btn_text_color_selector</item>
</style>

<style name="Widget.Natura.Button.Secondary" parent="Widget.Natura.Button">
<item name="backgroundTint">@color/ds_mtrl_sec_btn_background_selector</item>
</style>

<style name="Widget.Natura.Button.Outlined" parent="Widget.MaterialComponents.Button.OutlinedButton"/>

<style name="Widget.Natura.Button.Outlined.Secondary" parent="Widget.Natura.Button.Outlined">
<item name="android:textColor">@color/ds_mtrl_sec_colored_btn_text_color_selector</item>
<item name="rippleColor">@color/ds_mtrl_sec_colored_ripple_color_selector</item>
</style>

<style name="Widget.Natura.Button.TextButton" parent="Widget.MaterialComponents.Button.TextButton"/>

<style name="Widget.Natura.Button.TextButton.Secondary" parent="Widget.Natura.Button.TextButton">
<item name="android:textColor">@color/ds_mtrl_sec_colored_btn_text_color_selector</item>
<item name="rippleColor">@color/ds_mtrl_sec_colored_ripple_color_selector</item>
</style>

</resources>
17 changes: 16 additions & 1 deletion designsystem/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
<resources>
<color name="colorBrdNatRed">#e74627</color>
<color name="colorBrdNatGreen">#569A32</color>
<color name="colorBrdNatOrange">#FF6B0B</color>
<color name="colorBrdNatOrange">#FF6B06</color>
<color name="colorBrdNatOrangeDark">#EF8426</color>
<color name="colorBrdNatYellow">#F4AB34</color>
<color name="colorBrdNatYellowDark">#EF8426</color>
<color name="colorBrdNatWhite">#FFFFFF</color>
<color name="colorBrdNatGray">#333333</color>
<color name="colorBrdBlack_12">#1F000000</color>
Expand All @@ -14,4 +16,17 @@
<color name="colorMediumEmphasis">#777777</color>
<color name="colorHighEmphasis">#333333</color>
<color name="colorHighEmphasis_48">#3333330A</color>
<color name="mtrlBtnTextColorDisabled">#61000000</color>

<!--Light Text Content-->
<color name="lightHighlight">#000000</color>
<color name="lightHighEmphasis">#333333</color>
<color name="lightMediumEmphasis">#777777</color>
<color name="lightLowEmphasis">#BBBBBB</color>
<color name="lightLink">#227BBD</color>

<!--Feedback-->
<color name="feedback_success">#569A32</color>
<color name="feedback_warning">#FCC433</color>
<color name="feedback_error">#E74627</color>
</resources>
4 changes: 4 additions & 0 deletions designsystem/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<dimen name="ds_spacin_tiny">8dp</dimen>
<dimen name="ds_spacing_micro">4dp</dimen>
<dimen name="ds_spacing_standard">24dp</dimen>
<dimen name="ds_size_line">1dp</dimen>
<dimen name="ds_border_tiny">1dp</dimen>
<dimen name="ds_border_emphasis">2dp</dimen>
<dimen name="ds_spacing_border_top">18dp</dimen>
Expand All @@ -31,4 +32,7 @@
<!-- Button dimens -->
<dimen name="ds_button_primary_radius">4dp</dimen>
<dimen name="ds_button_primary_label_margin">40dp</dimen>

<!-- Progress dimens -->
<dimen name="ds_loading_size">24dp</dimen>
</resources>
5 changes: 5 additions & 0 deletions designsystem/src/main/res/values/ds_attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
<attr name="error_button_label" format="string" />
</declare-styleable>

<declare-styleable name="ds_text_input_highlight">
<attr name="description_label" format="string" />
<attr name="highlight_label" format="string" />
</declare-styleable>

<declare-styleable name="ds_text_field_input">
<attr name="android:inputType" />
<attr name="android:maxLines" />
Expand Down
22 changes: 21 additions & 1 deletion designsystem/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,29 @@
<style name="RobotoMedium">
<item name="android:fontFamily">@string/font_fontFamily_medium</item>
</style>

<!-- Roboto Regular-->
<style name="RobotoRegular">
<item name="android:fontFamily">@string/font_roboto_regular</item>
</style>

<style name="Widget.Natura.Divider">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">@dimen/ds_size_line</item>
<item name="android:background">@color/colorBrdBlack_12</item>
</style>

<style name="TextAppearence.Natura.Default" parent="TextAppearance.AppCompat">
<item name="android:textSize">@dimen/ds_text_small</item>
<item name="android:textColor">@color/lightMediumEmphasis</item>
<item name="android:fontFamily">@string/font_roboto_regular</item>
</style>

<style name="TextAppearence.Natura.Highlight" parent="TextAppearance.AppCompat">
<item name="android:textSize">@dimen/ds_text_big</item>
<item name="android:textColor">@color/lightHighEmphasis</item>
<item name="android:fontFamily">@string/font_roboto_regular</item>
</style>

<style name="Widget"/>
<style name="Widget.Natura"/>
</resources>
9 changes: 9 additions & 0 deletions designsystem/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@
<item name="colorSecondary">@color/colorBrdNatOrange</item>

<item name="android:colorBackground">@color/colorBrdNatWhite</item>
<item name="colorError">@color/feedback_error</item>

<!-- Type styles -->
<item name="textAppearanceHeadline6">@style/TextAppearance.MaterialComponents.Headline6</item>
<item name="textAppearanceBody2">@style/TextAppearance.MaterialComponents.Body2</item>

<!--Component styles-->
<item name="navigationViewStyle">@style/Widget.Natura.NavigationView</item>

<!--Remap legacy AppCompat attributes to MaterialComponent attributes-->
<item name="colorAccent">?colorPrimary</item>
</style>

<style name="Theme.Avon" parent="Theme.Natura">
<item name="colorPrimary">#DE0085</item>
<item name="colorSecondary">#A70058</item>
</style>
</resources>
3 changes: 3 additions & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ dependencies {
androidTestImplementation "androidx.test.ext:junit:$rootProject.junitExtVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$rootProject.expressoVersion"
androidTestImplementation "androidx.test:rules:$rootProject.androidXTestVersion"
androidTestImplementation "androidx.test:runner:$rootProject.androidXTestVersion"
androidTestImplementation "androidx.test:core-ktx:$rootProject.testCoreKtxVersion"
androidTestImplementation "androidx.test.ext:junit:$rootProject.androidxJunitVersion"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.natura.android.sample.components

import android.view.View
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.natura.android.sample.R
import org.hamcrest.Matcher
import org.hamcrest.Matchers.allOf
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class TextInputHighlightActivityTest {

@Before
fun setup() {
ActivityScenario.launch(TextInputHighlightActivity::class.java)
}

@Test
fun shouldDisplayInitialViewValues() {
onView(matchHighlightChild(
childId = R.id.description_label,
parentId = R.id.highlightInitOnXml)
)
.check(matches(withText("Description on Xml")))

onView(matchHighlightChild(
childId = R.id.highlight_label,
parentId = R.id.highlightInitOnXml)
)
.check(matches(withText("R\$ 11,02")))

onView(matchHighlightChild(
childId = R.id.highlight_label,
parentId = R.id.highlightInitViaCode)
)
.check(matches(withText("\$ 00.00")))

onView(matchHighlightChild(
childId = R.id.description_label,
parentId = R.id.highlightInitViaCode)
)
.check(matches(withText("Add description via code")))
}

private fun matchHighlightChild(childId: Int, parentId: Int): Matcher<View>? {
return allOf(
withId(childId),
withParent(withId(parentId))
)
}
}
6 changes: 6 additions & 0 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
<activity
android:name=".components.LoadingActivity"
android:theme="@style/Theme.Natura" />
<activity
android:name=".components.TextInputHighlightActivity"
android:theme="@style/Theme.Natura" />
<activity
android:name=".components.StyleButtonActivity"
android:theme="@style/Theme.Natura" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ class MainActivity : AppCompatActivity() {
findViewById<Button>(R.id.btn_error_default).setOnClickListener {
startActivity(Intent(this, ErrorActivity::class.java))
}

findViewById<Button>(R.id.btn_input_text_highlight).setOnClickListener {
startActivity(Intent(this, TextInputHighlightActivity::class.java))
}

findViewById<Button>(R.id.btn_style_buttons).setOnClickListener {
startActivity(Intent(this, StyleButtonActivity::class.java))
}
}
}

Loading

0 comments on commit 789de3e

Please sign in to comment.