Add splash screen faking toolbar

This commit is contained in:
ganfra 2018-12-17 18:55:15 +01:00
parent 4656429d83
commit 21c7cf2498
6 changed files with 63 additions and 7 deletions

View File

@ -13,14 +13,19 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Riot">
<activity android:name=".features.login.LoginActivity">

<activity
android:name=".features.MainActivity"
android:theme="@style/Theme.Riot.Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".features.home.HomeActivity" />
<activity android:name=".features.login.LoginActivity" />
</application>

</manifest>

View File

@ -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<Matrix>()
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()
}

}

View File

@ -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)
}

}

}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:opacity="opaque">
<item>
<shape>
<solid android:color="@android:color/white" />
</shape>
</item>

<item android:gravity="top">
<shape android:shape="rectangle">
<size android:height="80dp" />
<solid android:color="?colorPrimary" />
</shape>
</item>
</layer-list>

View File

@ -5,5 +5,9 @@

</style>

<style name="Theme.Riot.Splash">
<item name="android:windowBackground">@drawable/bg_splash</item>
</style>


</resources>

View File

@ -11,4 +11,5 @@
<style name="Base.Theme.Riot" parent="Base.V1.Theme.Riot" />



</resources>