From 21c7cf2498cb9f74bb10b96f359d25113257f1ef Mon Sep 17 00:00:00 2001 From: ganfra Date: Mon, 17 Dec 2018 18:55:15 +0100 Subject: [PATCH] Add splash screen faking toolbar --- app/src/main/AndroidManifest.xml | 7 ++++- .../riotredesign/features/MainActivity.kt | 27 +++++++++++++++++++ .../features/login/LoginActivity.kt | 15 ++++++----- app/src/main/res/drawable/bg_splash.xml | 16 +++++++++++ app/src/main/res/values/themes.xml | 4 +++ app/src/main/res/values/themes_base.xml | 1 + 6 files changed, 63 insertions(+), 7 deletions(-) create mode 100644 app/src/main/java/im/vector/riotredesign/features/MainActivity.kt create mode 100644 app/src/main/res/drawable/bg_splash.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a07bbbeb..05b64b0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -13,14 +13,19 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.Riot"> - + + + + \ No newline at end of file diff --git a/app/src/main/java/im/vector/riotredesign/features/MainActivity.kt b/app/src/main/java/im/vector/riotredesign/features/MainActivity.kt new file mode 100644 index 00000000..d56ebe72 --- /dev/null +++ b/app/src/main/java/im/vector/riotredesign/features/MainActivity.kt @@ -0,0 +1,27 @@ +package im.vector.riotredesign.features + +import android.os.Bundle +import im.vector.matrix.android.api.Matrix +import im.vector.riotredesign.core.platform.RiotActivity +import im.vector.riotredesign.features.home.HomeActivity +import im.vector.riotredesign.features.login.LoginActivity +import org.koin.android.ext.android.inject + + +class MainActivity : RiotActivity() { + + private val matrix by inject() + private val authenticator = matrix.authenticator() + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + val intent = if (authenticator.hasActiveSessions()) { + HomeActivity.newIntent(this) + } else { + LoginActivity.newIntent(this) + } + startActivity(intent) + finish() + } + +} \ No newline at end of file diff --git a/app/src/main/java/im/vector/riotredesign/features/login/LoginActivity.kt b/app/src/main/java/im/vector/riotredesign/features/login/LoginActivity.kt index e3acb888..e39faf73 100644 --- a/app/src/main/java/im/vector/riotredesign/features/login/LoginActivity.kt +++ b/app/src/main/java/im/vector/riotredesign/features/login/LoginActivity.kt @@ -1,5 +1,7 @@ package im.vector.riotredesign.features.login +import android.content.Context +import android.content.Intent import android.os.Bundle import android.view.View import android.widget.Toast @@ -21,7 +23,6 @@ class LoginActivity : RiotActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_login) - checkActiveSessions() authenticateButton.setOnClickListener { authenticate() } } @@ -49,11 +50,6 @@ class LoginActivity : RiotActivity() { }) } - private fun checkActiveSessions() { - if (authenticator.hasActiveSessions()) { - goToHome() - } - } private fun goToHome() { val intent = HomeActivity.newIntent(this) @@ -61,4 +57,11 @@ class LoginActivity : RiotActivity() { finish() } + companion object { + fun newIntent(context: Context): Intent { + return Intent(context, LoginActivity::class.java) + } + + } + } diff --git a/app/src/main/res/drawable/bg_splash.xml b/app/src/main/res/drawable/bg_splash.xml new file mode 100644 index 00000000..ede95098 --- /dev/null +++ b/app/src/main/res/drawable/bg_splash.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index f9f41d58..751344c7 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -5,5 +5,9 @@ + + \ No newline at end of file diff --git a/app/src/main/res/values/themes_base.xml b/app/src/main/res/values/themes_base.xml index 4773884c..04ea854a 100644 --- a/app/src/main/res/values/themes_base.xml +++ b/app/src/main/res/values/themes_base.xml @@ -11,4 +11,5 @@