mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-15 01:35:07 +08:00
Add splash screen faking toolbar
This commit is contained in:
parent
4656429d83
commit
21c7cf2498
@ -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>
|
@ -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()
|
||||
}
|
||||
|
||||
}
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
16
app/src/main/res/drawable/bg_splash.xml
Normal file
16
app/src/main/res/drawable/bg_splash.xml
Normal 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>
|
@ -5,5 +5,9 @@
|
||||
|
||||
</style>
|
||||
|
||||
<style name="Theme.Riot.Splash">
|
||||
<item name="android:windowBackground">@drawable/bg_splash</item>
|
||||
</style>
|
||||
|
||||
|
||||
</resources>
|
@ -11,4 +11,5 @@
|
||||
<style name="Base.Theme.Riot" parent="Base.V1.Theme.Riot" />
|
||||
|
||||
|
||||
|
||||
</resources>
|
Loading…
Reference in New Issue
Block a user