-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a67978
commit 6e779ca
Showing
9 changed files
with
216 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
...rc/main/kotlin/com/arturogutierrez/openticator/domain/welcome/activity/WelcomeActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package com.arturogutierrez.openticator.domain.welcome.activity | ||
|
||
import android.os.Bundle | ||
import android.support.v4.view.ViewCompat | ||
import android.support.v7.app.AppCompatActivity | ||
import android.view.View | ||
import android.widget.Button | ||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import com.arturogutierrez.openticator.R | ||
import com.arturogutierrez.openticator.application.OpenticatorApplication | ||
import com.arturogutierrez.openticator.domain.navigator.Navigator | ||
import org.jetbrains.anko.find | ||
import javax.inject.Inject | ||
|
||
class WelcomeActivity : AppCompatActivity() { | ||
|
||
companion object Animation { | ||
val STARTUP_DELAY = 400L | ||
val ITEM_DELAY = 200L | ||
val LOGO_DURATION = 1000L | ||
val TEXT_DURATION = 500L | ||
val BUTTON_DURATION = 1000L | ||
} | ||
|
||
private val container by lazy { find<View>(R.id.welcome_container) } | ||
private val logoImageView by lazy { find<ImageView>(R.id.logo_iv) } | ||
private val logoPlaceholder by lazy { find<View>(R.id.logo_placeholder) } | ||
private val title by lazy { find<TextView>(R.id.title_tv) } | ||
private val bodyFirst by lazy { find<TextView>(R.id.title_first) } | ||
private val bodySecond by lazy { find<TextView>(R.id.title_second) } | ||
private val startButton by lazy { find<Button>(R.id.start_btn) } | ||
|
||
@Inject | ||
lateinit var navigator: Navigator | ||
|
||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_welcome) | ||
|
||
initializeInjector() | ||
|
||
startButton.setOnClickListener { | ||
navigator.goToInitialWizard(this) | ||
finish() | ||
} | ||
} | ||
|
||
override fun onWindowFocusChanged(hasFocus: Boolean) { | ||
super.onWindowFocusChanged(hasFocus) | ||
|
||
if (hasFocus) { | ||
startAnimation() | ||
} | ||
} | ||
|
||
private fun initializeInjector() { | ||
(application as OpenticatorApplication).applicationComponent.inject(this) | ||
} | ||
|
||
private fun startAnimation() { | ||
val translationY = (logoPlaceholder.y + container.y) - logoImageView.y | ||
|
||
ViewCompat.animate(logoImageView) | ||
.translationY(translationY) | ||
.setStartDelay(STARTUP_DELAY) | ||
.setDuration(LOGO_DURATION) | ||
.start() | ||
|
||
ViewCompat.animate(title) | ||
.alpha(1f) | ||
.setStartDelay(STARTUP_DELAY + LOGO_DURATION) | ||
.setDuration(TEXT_DURATION) | ||
.start() | ||
|
||
ViewCompat.animate(bodyFirst) | ||
.alpha(1f) | ||
.setStartDelay(STARTUP_DELAY + LOGO_DURATION + ITEM_DELAY) | ||
.setDuration(TEXT_DURATION) | ||
.start() | ||
|
||
ViewCompat.animate(bodySecond) | ||
.alpha(1f) | ||
.setStartDelay(STARTUP_DELAY + LOGO_DURATION + ITEM_DELAY * 2) | ||
.setDuration(TEXT_DURATION) | ||
.start() | ||
|
||
ViewCompat.animate(startButton) | ||
.alpha(1f) | ||
.setStartDelay(STARTUP_DELAY + LOGO_DURATION + ITEM_DELAY * 3) | ||
.setDuration(BUTTON_DURATION) | ||
.start() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<FrameLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:id="@+id/activity_welcome" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:paddingLeft="@dimen/content_padding_left" | ||
android:paddingRight="@dimen/content_padding_right" | ||
android:paddingTop="@dimen/content_padding_top" | ||
android:paddingBottom="@dimen/content_padding_bottom" | ||
android:background="?colorPrimary" | ||
tools:context="com.arturogutierrez.openticator.domain.welcome.activity.WelcomeActivity"> | ||
|
||
<ImageView | ||
android:id="@+id/logo_iv" | ||
android:src="@mipmap/ic_splash" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
tools:visibility="gone" | ||
/> | ||
|
||
<LinearLayout | ||
android:id="@+id/welcome_container" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_gravity="center" | ||
android:gravity="center" | ||
android:orientation="vertical"> | ||
|
||
<View | ||
android:id="@+id/logo_placeholder" | ||
android:layout_width="144dp" | ||
android:layout_height="144dp" | ||
android:layout_gravity="center_horizontal" | ||
android:visibility="invisible" | ||
/> | ||
|
||
<TextView | ||
android:id="@+id/title_tv" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="50dp" | ||
android:text="@string/welcome_body_title" | ||
android:textColor="@android:color/white" | ||
android:alpha="0" | ||
style="@style/TextAppearance.AppCompat.Title" | ||
/> | ||
|
||
<TextView | ||
android:id="@+id/title_first" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="20dp" | ||
android:text="@string/welcome_body_first" | ||
android:textColor="@android:color/white" | ||
android:alpha="0" | ||
style="@style/TextAppearance.AppCompat.Body1" | ||
/> | ||
|
||
<TextView | ||
android:id="@+id/title_second" | ||
android:layout_marginTop="10dp" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:text="@string/welcome_body_second" | ||
android:textColor="@android:color/white" | ||
android:alpha="0" | ||
style="@style/TextAppearance.AppCompat.Body1" | ||
/> | ||
|
||
|
||
<Button | ||
android:id="@+id/start_btn" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="30dp" | ||
android:text="@string/start" | ||
android:alpha="0" | ||
style="@style/Widget.AppCompat.Button" | ||
/> | ||
|
||
</LinearLayout> | ||
|
||
</FrameLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters