Skip to content

Commit

Permalink
Merge pull request #149 from natura-cosmeticos/splash-screen
Browse files Browse the repository at this point in the history
[DSY-1423] Splash screen
  • Loading branch information
mlcsouza authored Sep 14, 2020
2 parents 5faaef0 + 060c999 commit 859d5df
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.natura.android.sample

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.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class SplashScreenFunctionalTests {
@Before
fun setup() {
ActivityScenario.launch(SplashActivity::class.java)
}

@Test
fun shouldOpenBorderRadiusScreenWhenTapOnItButton() {
onView(withText("NATDS"))
.check(matches(isDisplayed()))

onView(withText("Natura Design System"))
.check(matches(isDisplayed()))

onView(withId(R.id.naturaCoLogo))
.check(matches(isDisplayed()))
}
}
16 changes: 8 additions & 8 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.AppCompat.Light">

<activity android:name=".BrandSelectorActivity">
<activity
android:name=".SplashActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".BrandSelectorActivity"/>
<activity android:name=".MainActivity" />
<activity
android:name=".tokens.ElevationActivity"
Expand Down Expand Up @@ -52,16 +53,16 @@
</activity>
<activity
android:name=".components.BadgeActivity"
android:theme="@style/Theme.Natura"/>
android:theme="@style/Theme.Natura" />
<activity
android:name=".components.DialogActivity"
android:theme="@style/Theme.AppCompat"/>
android:theme="@style/Theme.AppCompat" />
<activity
android:name=".patterns.ErrorActivity"
android:theme="@style/Theme.Natura" />
<activity
android:name=".patterns.LogoActivity"
android:theme="@style/Theme.Natura"/>
android:theme="@style/Theme.Natura" />
<activity
android:name=".components.TextFieldActivity"
android:theme="@style/Theme.Natura" />
Expand Down Expand Up @@ -96,8 +97,7 @@
android:name=".components.ExpansionPanelActivity"
android:theme="@style/Theme.Natura" />
<activity android:name=".tokens.ColorsActivity" />
<activity
android:name=".components.ShortcutActivity"/>
<activity android:name=".components.ShortcutActivity" />
</application>

</manifest>
47 changes: 47 additions & 0 deletions sample/src/main/java/com/natura/android/sample/SplashActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.natura.android.sample

import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.view.animation.AccelerateInterpolator
import android.view.animation.AlphaAnimation
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_splash.*

class SplashActivity : AppCompatActivity() {
lateinit var mDelayHandler: Handler

private val mRunnable: Runnable = Runnable {
if (!isFinishing) {
val intent = Intent(applicationContext, BrandSelectorActivity::class.java)
startActivity(intent)
finish()
}
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_splash)

val fadeIn = AlphaAnimation(0f, 1f)
fadeIn.interpolator = AccelerateInterpolator()
fadeIn.duration = 2000

splashContainer.apply {
animation = fadeIn
}

mDelayHandler = Handler()

mDelayHandler?.postDelayed(mRunnable, SPLASH_DELAY)
}

public override fun onDestroy() {
mDelayHandler?.removeCallbacks(mRunnable)
super.onDestroy()
}

companion object {
private const val SPLASH_DELAY: Long = 3000
}
}
33 changes: 33 additions & 0 deletions sample/src/main/res/drawable/logo_natura_co.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="209dp"
android:height="30dp"
android:viewportWidth="209"
android:viewportHeight="30">
<path
android:pathData="M16.333,27.635L6.402,16.402V28.53H0.012V8.139C-0.02,7.854 0.013,7.565 0.108,7.294C0.203,7.023 0.358,6.776 0.561,6.573C0.764,6.37 1.01,6.215 1.281,6.12C1.552,6.025 1.841,5.992 2.127,6.023H3.348C3.842,6.014 4.333,6.104 4.793,6.288C5.235,6.479 5.631,6.763 5.954,7.121L15.844,18.314V6.227H22.274V26.618C22.305,26.904 22.272,27.193 22.177,27.464C22.082,27.735 21.927,27.982 21.724,28.185C21.521,28.388 21.275,28.543 21.003,28.638C20.732,28.733 20.443,28.767 20.158,28.735H18.937C18.442,28.744 17.951,28.654 17.492,28.47C17.05,28.278 16.655,27.993 16.333,27.636"
android:fillColor="#ffffff"/>
<path
android:pathData="M37.499,23.524C38.279,23.546 39.055,23.397 39.772,23.088C40.488,22.779 41.129,22.317 41.649,21.734C42.738,20.532 43.322,18.956 43.278,17.334C43.298,15.76 42.715,14.238 41.649,13.08C41.132,12.492 40.493,12.025 39.775,11.712C39.058,11.399 38.281,11.248 37.499,11.269C36.737,11.25 35.981,11.403 35.288,11.716C34.594,12.03 33.979,12.496 33.491,13.08C32.448,14.281 31.889,15.826 31.924,17.416C31.88,19.007 32.44,20.555 33.491,21.75C33.986,22.324 34.602,22.78 35.295,23.086C35.988,23.392 36.741,23.541 37.499,23.52V23.524ZM36.075,29.178C34.613,29.191 33.167,28.878 31.842,28.263C30.566,27.671 29.424,26.826 28.485,25.78C27.521,24.69 26.774,23.425 26.285,22.055C25.746,20.568 25.477,18.997 25.491,17.416C25.481,15.84 25.757,14.274 26.305,12.796C26.806,11.415 27.559,10.138 28.525,9.031C29.466,7.969 30.616,7.11 31.902,6.508C33.231,5.881 34.685,5.561 36.155,5.572C37.429,5.561 38.691,5.825 39.855,6.345C41.005,6.87 42.021,7.649 42.826,8.625V6.225H48.972V28.525H43.152V25.798C42.345,26.882 41.282,27.749 40.059,28.322C38.808,28.897 37.446,29.189 36.07,29.176"
android:fillColor="#ffffff"/>
<path
android:pathData="M61.427,28.531C59.185,28.661 56.983,27.9 55.301,26.414C54.544,25.653 53.955,24.742 53.574,23.74C53.192,22.737 53.025,21.665 53.084,20.594V0H59.676V6.227H65.496V11.803H59.676V20.147C59.655,20.524 59.714,20.902 59.847,21.255C59.98,21.609 60.185,21.931 60.449,22.201C60.754,22.468 61.108,22.672 61.492,22.801C61.876,22.931 62.282,22.983 62.687,22.955H65.496V28.531H61.427Z"
android:fillColor="#ffffff"/>
<path
android:pathData="M79.947,29.182C76.473,29.182 73.78,28.219 71.868,26.293C70.889,25.258 70.131,24.036 69.637,22.7C69.145,21.364 68.927,19.941 68.999,18.519V6.227H75.757V18.885C75.704,20.101 76.063,21.298 76.775,22.285C77.193,22.704 77.689,23.036 78.236,23.263C78.782,23.489 79.368,23.606 79.96,23.606C80.551,23.606 81.137,23.489 81.684,23.263C82.23,23.036 82.727,22.704 83.145,22.285C83.844,21.293 84.196,20.098 84.145,18.885V6.227H90.901V18.519C90.976,19.945 90.76,21.371 90.267,22.711C89.774,24.051 89.013,25.277 88.032,26.314C86.118,28.227 83.425,29.184 79.953,29.183"
android:fillColor="#ffffff"/>
<path
android:pathData="M103.061,6.227H107.131V11.803H104.322C103.917,11.775 103.511,11.827 103.127,11.957C102.743,12.086 102.389,12.29 102.084,12.557C101.82,12.827 101.615,13.149 101.482,13.503C101.349,13.856 101.29,14.234 101.311,14.611V28.531H94.721V14.163C94.662,13.092 94.829,12.02 95.211,11.018C95.593,10.016 96.181,9.104 96.938,8.344C98.62,6.858 100.822,6.097 103.064,6.227"
android:fillColor="#ffffff"/>
<path
android:pathData="M120.523,23.524C121.303,23.546 122.079,23.397 122.796,23.088C123.513,22.779 124.154,22.317 124.674,21.734C125.762,20.531 126.345,18.955 126.301,17.334C126.321,15.76 125.739,14.238 124.674,13.08C124.157,12.492 123.517,12.025 122.8,11.712C122.082,11.399 121.305,11.248 120.523,11.269C119.761,11.25 119.006,11.403 118.312,11.717C117.618,12.03 117.003,12.496 116.515,13.08C115.472,14.281 114.913,15.826 114.948,17.416C114.904,19.007 115.464,20.555 116.515,21.75C117.01,22.324 117.626,22.78 118.319,23.086C119.013,23.392 119.765,23.541 120.523,23.52V23.524ZM119.099,29.178C117.637,29.191 116.191,28.878 114.866,28.263C113.59,27.671 112.448,26.826 111.509,25.78C110.545,24.69 109.798,23.425 109.309,22.055C108.771,20.568 108.502,18.997 108.516,17.416C108.506,15.84 108.782,14.274 109.33,12.796C109.83,11.415 110.582,10.139 111.547,9.031C112.489,7.968 113.638,7.11 114.925,6.508C116.255,5.881 117.708,5.561 119.179,5.572C120.453,5.561 121.715,5.825 122.879,6.345C124.029,6.87 125.045,7.649 125.85,8.625V6.225H131.996V28.525H126.175V25.798C125.369,26.883 124.306,27.75 123.082,28.322C121.832,28.898 120.47,29.189 119.094,29.176"
android:fillColor="#ffffff"/>
<path
android:pathData="M148.88,13.676L149.206,14.042C149.746,13.736 150.228,13.336 150.63,12.862C150.968,12.464 151.156,11.959 151.159,11.436C151.152,11.04 151.008,10.659 150.751,10.358C150.608,10.186 150.426,10.051 150.221,9.963C150.016,9.874 149.793,9.835 149.571,9.849C149.348,9.847 149.127,9.889 148.921,9.973C148.715,10.057 148.528,10.181 148.371,10.338C148.205,10.494 148.073,10.684 147.986,10.894C147.898,11.105 147.856,11.331 147.862,11.559C147.866,11.904 147.942,12.245 148.087,12.559C148.288,12.973 148.556,13.351 148.88,13.678V13.676ZM145.299,22.51C145.309,22.748 145.369,22.981 145.474,23.194C145.579,23.408 145.727,23.597 145.909,23.751C146.147,23.959 146.425,24.119 146.725,24.22C147.026,24.321 147.343,24.362 147.66,24.341C148.281,24.337 148.898,24.241 149.491,24.056C150.131,23.859 150.746,23.586 151.322,23.242L147.904,19.701L146.967,20.189C146.453,20.448 146.007,20.825 145.667,21.289C145.429,21.652 145.302,22.077 145.302,22.511L145.299,22.51ZM147.418,29.023C146.271,29.043 145.129,28.871 144.04,28.515C143.148,28.224 142.32,27.768 141.597,27.171C140.969,26.645 140.468,25.984 140.132,25.238C139.81,24.521 139.644,23.744 139.644,22.958C139.652,21.87 139.947,20.803 140.499,19.865C141.292,18.662 142.405,17.704 143.713,17.098L144.813,16.487C144.055,15.694 143.448,14.77 143.022,13.76C142.688,12.96 142.509,12.104 142.493,11.237C142.484,10.394 142.667,9.561 143.026,8.799C143.386,8.037 143.913,7.366 144.569,6.837C145.972,5.636 147.77,4.998 149.616,5.046C150.602,5.029 151.583,5.201 152.505,5.554C153.295,5.861 154.015,6.326 154.621,6.919C155.174,7.466 155.615,8.115 155.921,8.831C156.214,9.513 156.367,10.247 156.369,10.99C156.376,12.243 155.992,13.467 155.269,14.49C154.454,15.625 153.415,16.581 152.217,17.299L154.862,20.188C155.214,19.755 155.554,19.294 155.881,18.805C156.196,18.335 156.455,17.829 156.653,17.299H162.106C161.607,18.514 161.008,19.684 160.315,20.799C159.67,21.839 158.934,22.82 158.115,23.729L162.552,28.529H156.406L154.656,26.696C153.544,27.43 152.339,28.011 151.074,28.426C149.891,28.813 148.655,29.012 147.411,29.016"
android:fillColor="#ffffff"/>
<path
android:pathData="M176.511,29.182C174.732,29.204 172.965,28.894 171.3,28.267C169.81,27.709 168.448,26.859 167.292,25.767C166.188,24.702 165.315,23.42 164.729,22.003C164.113,20.527 163.802,18.941 163.813,17.342C163.803,15.762 164.114,14.197 164.729,12.742C165.316,11.337 166.189,10.068 167.292,9.018C168.455,7.935 169.816,7.086 171.3,6.518C172.975,5.876 174.757,5.558 176.551,5.582C177.454,5.583 178.354,5.678 179.238,5.867C180.006,6.018 180.756,6.25 181.476,6.559V12.38C180.923,12.138 180.351,11.94 179.767,11.789C178.917,11.572 178.043,11.469 177.167,11.484C175.351,11.377 173.567,11.992 172.202,13.194C171.627,13.72 171.17,14.362 170.862,15.078C170.553,15.793 170.399,16.566 170.411,17.345C170.391,18.143 170.54,18.937 170.849,19.674C171.157,20.41 171.618,21.073 172.202,21.619C173.567,22.821 175.351,23.435 177.167,23.328C178.044,23.344 178.92,23.234 179.767,23.002C180.35,22.84 180.921,22.636 181.476,22.392V28.211C180.766,28.528 180.022,28.76 179.259,28.904C178.355,29.093 177.434,29.188 176.511,29.189"
android:fillColor="#ffffff"/>
<path
android:pathData="M195.884,23.524C196.657,23.549 197.426,23.403 198.136,23.097C198.847,22.791 199.481,22.333 199.995,21.754C201.066,20.538 201.633,18.959 201.581,17.339C201.618,15.758 201.051,14.222 199.995,13.045C199.472,12.486 198.84,12.041 198.138,11.736C197.436,11.432 196.679,11.275 195.914,11.275C195.149,11.275 194.392,11.432 193.69,11.736C192.988,12.041 192.356,12.486 191.834,13.045C190.764,14.216 190.188,15.754 190.226,17.339C190.174,18.963 190.75,20.544 191.834,21.754C192.339,22.326 192.963,22.782 193.663,23.087C194.362,23.393 195.12,23.542 195.884,23.524ZM195.884,29.182C194.231,29.199 192.592,28.888 191.061,28.267C189.634,27.692 188.334,26.842 187.235,25.767C186.155,24.697 185.298,23.424 184.712,22.022C184.093,20.54 183.782,18.948 183.797,17.342C183.772,15.012 184.452,12.73 185.749,10.794C187.045,8.858 188.897,7.36 191.061,6.496C192.592,5.875 194.231,5.564 195.884,5.58C197.542,5.565 199.188,5.876 200.727,6.496C202.161,7.067 203.468,7.917 204.573,8.996C205.671,10.089 206.54,11.39 207.131,12.822C207.721,14.255 208.02,15.791 208.012,17.34C208.027,18.946 207.716,20.538 207.097,22.02C206.51,23.422 205.652,24.695 204.573,25.765C203.468,26.843 202.161,27.693 200.727,28.265C199.188,28.884 197.542,29.195 195.884,29.18"
android:fillColor="#ffffff"/>
</vector>
Binary file not shown.
49 changes: 49 additions & 0 deletions sample/src/main/res/layout/activity_splash.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<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:id="@+id/splashContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SplashActivity"
android:background="@android:color/transparent">
<ImageView
android:id="@+id/naturaCoLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="65dp"
android:src="@drawable/logo_natura_co"
app:layout_constraintBottom_toTopOf="@+id/title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0" />

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NATDS"
android:textColor="#FAFAFA"
android:textSize="22sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/subtitle"
app:layout_constraintHorizontal_bias="0.495"
app:layout_constraintStart_toStartOf="@+id/subtitle"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.60" />

<TextView
android:id="@+id/subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Natura Design System"
android:textColor="#FAFAFA"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
7 changes: 7 additions & 0 deletions sample/src/main/res/values/style.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowBackground">@drawable/splash_full_background</item>
<item name="android:windowFullscreen">true</item>
</style>
</resources>

0 comments on commit 859d5df

Please sign in to comment.