Skip to content

Commit

Permalink
Adding a Welcome screen (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
arturogutierrez committed Nov 28, 2016
1 parent 9a67978 commit 6e779ca
Show file tree
Hide file tree
Showing 9 changed files with 216 additions and 15 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
@@ -1,6 +1,7 @@
### 0.8.4 (Unreleased)
### 0.9.0 (Unreleased)

* New: Splash added [#46](https://github.com/arturogutierrez/Openticator/pull/46)
* New: Welcome screen added [#47](https://github.com/arturogutierrez/Openticator/pull/47)

### 0.8.3 (25/11/2016)

Expand Down
23 changes: 12 additions & 11 deletions app/src/main/AndroidManifest.xml
@@ -1,33 +1,34 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.arturogutierrez.openticator">

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA"/>

<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.camera.autofocus"/>

<application
android:name=".application.OpenticatorApplication"
android:allowBackup="false"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:hardwareAccelerated="true"
tools:replace="android:allowBackup"
>

<activity android:name=".view.activity.SplashActivity"
tools:replace="android:allowBackup">
<activity
android:name=".view.activity.SplashActivity"
android:label="@string/app_name"
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=".domain.welcome.activity.WelcomeActivity"/>
<activity android:name=".domain.password.wizard.activity.MasterPasswordActivity"/>
<activity android:name=".domain.account.list.activity.AccountListActivity"/>
<activity android:name=".domain.account.add.activity.AddAccountManuallyActivity"/>
Expand All @@ -36,8 +37,8 @@

<meta-data
android:name="io.fabric.ApiKey"
android:value="${fabricApiKey}"
/>
android:value="${fabricApiKey}"/>

</application>

</manifest>
</manifest>
Expand Up @@ -9,6 +9,7 @@ import com.arturogutierrez.openticator.domain.account.repository.AccountReposito
import com.arturogutierrez.openticator.domain.category.CategorySelector
import com.arturogutierrez.openticator.domain.category.repository.CategoryRepository
import com.arturogutierrez.openticator.domain.issuer.repository.IssuerRepository
import com.arturogutierrez.openticator.domain.welcome.activity.WelcomeActivity
import com.arturogutierrez.openticator.executor.PostExecutionThread
import com.arturogutierrez.openticator.executor.ThreadExecutor
import com.arturogutierrez.openticator.storage.clipboard.ClipboardRepository
Expand All @@ -27,6 +28,8 @@ interface ApplicationComponent {

fun inject(splashActivity: SplashActivity)

fun inject(welcomeActivity: WelcomeActivity)

fun inject(baseActivity: BaseActivity)

fun context(): Context
Expand Down
Expand Up @@ -7,12 +7,17 @@ import com.arturogutierrez.openticator.domain.account.add.activity.AddAccountMan
import com.arturogutierrez.openticator.domain.account.camera.activity.CaptureActivity
import com.arturogutierrez.openticator.domain.account.list.activity.AccountListActivity
import com.arturogutierrez.openticator.domain.password.wizard.activity.MasterPasswordActivity
import com.arturogutierrez.openticator.domain.welcome.activity.WelcomeActivity
import org.jetbrains.anko.intentFor
import org.jetbrains.anko.startActivity
import javax.inject.Inject

class Navigator @Inject constructor() {

fun goToWelcomeScreen(context: Context) {
context.startActivity<WelcomeActivity>()
}

fun goToInitialWizard(context: Context) {
context.startActivity<MasterPasswordActivity>()
}
Expand Down
@@ -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()
}
}
Expand Up @@ -25,7 +25,7 @@ class SplashActivity : AppCompatActivity() {
super.onResume()

if (screenSelector.shouldShowWizard()) {
navigator.goToInitialWizard(this)
navigator.goToWelcomeScreen(this)
} else {
navigator.goToAccountList(this)
}
Expand Down
86 changes: 86 additions & 0 deletions app/src/main/res/layout/activity_welcome.xml
@@ -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>
11 changes: 11 additions & 0 deletions app/src/main/res/values/strings.xml
@@ -1,6 +1,17 @@
<resources>
<string name="app_name">Openticator</string>

<!-- Welcome -->
<string name="welcome_body_title">Gives a extra security layer to your accounts using Openticator.
</string>
<string name="welcome_body_first">Improve the protection of your online accounts enabling
two-factor authentications (2FA).
</string>
<string name="welcome_body_second">Openticator generates single-use codes to be used along your
password when log into your protected accounts with two-factor authentications.
</string>
<string name="start">Start</string>

<!-- Master Password -->
<string name="configure_master_password">Configure Master Password</string>
<string name="password">Password</string>
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Expand Up @@ -21,8 +21,8 @@ allprojects {
ext {
application = [
package: 'com.arturogutierrez.openticator',
versionCode: 8003,
versionName: '0.8.3',
versionCode: 9000,
versionName: '0.9.0',
]
}
}

0 comments on commit 6e779ca

Please sign in to comment.