Replace custom splashscreen with native one
This commit is contained in:
@@ -65,6 +65,7 @@ if (project.hasProperty('sign')) {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation project(':client')
|
implementation project(':client')
|
||||||
implementation 'androidx.appcompat:appcompat:1.5.1'
|
implementation 'androidx.appcompat:appcompat:1.5.1'
|
||||||
|
implementation 'androidx.core:core-splashscreen:1.0.0'
|
||||||
implementation 'com.google.android.material:material:1.4.0'
|
implementation 'com.google.android.material:material:1.4.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||||
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
|
||||||
|
|||||||
@@ -17,12 +17,12 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:usesCleartextTraffic="true"
|
android:usesCleartextTraffic="true"
|
||||||
android:networkSecurityConfig="@xml/network_security_config"
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme.SplashScreen">
|
||||||
<activity
|
<activity
|
||||||
android:name=".init.InitializationActivity"
|
android:name=".init.InitializationActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/AppTheme.NoActionBar"
|
android:theme="@style/AppTheme.SplashScreen"
|
||||||
android:windowSoftInputMode="adjustResize">
|
android:windowSoftInputMode="adjustResize">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import android.os.Build
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import com.github.gotify.NotificationSupport
|
import com.github.gotify.NotificationSupport
|
||||||
import com.github.gotify.R
|
import com.github.gotify.R
|
||||||
@@ -30,6 +31,7 @@ import com.livinglifetechway.quickpermissionskotlin.util.QuickPermissionsRequest
|
|||||||
internal class InitializationActivity : AppCompatActivity() {
|
internal class InitializationActivity : AppCompatActivity() {
|
||||||
|
|
||||||
private lateinit var settings: Settings
|
private lateinit var settings: Settings
|
||||||
|
private var splashScreenActive = true
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
@@ -38,8 +40,6 @@ internal class InitializationActivity : AppCompatActivity() {
|
|||||||
.getString(getString(R.string.setting_key_theme), getString(R.string.theme_default))!!
|
.getString(getString(R.string.setting_key_theme), getString(R.string.theme_default))!!
|
||||||
ThemeHelper.setTheme(this, theme)
|
ThemeHelper.setTheme(this, theme)
|
||||||
|
|
||||||
setContentView(R.layout.splash)
|
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
NotificationSupport.createChannels(
|
NotificationSupport.createChannels(
|
||||||
this.getSystemService(NOTIFICATION_SERVICE) as NotificationManager
|
this.getSystemService(NOTIFICATION_SERVICE) as NotificationManager
|
||||||
@@ -49,6 +49,8 @@ internal class InitializationActivity : AppCompatActivity() {
|
|||||||
settings = Settings(this)
|
settings = Settings(this)
|
||||||
Log.i("Entering ${javaClass.simpleName}")
|
Log.i("Entering ${javaClass.simpleName}")
|
||||||
|
|
||||||
|
installSplashScreen().setKeepOnScreenCondition { splashScreenActive }
|
||||||
|
|
||||||
if (settings.tokenExists()) {
|
if (settings.tokenExists()) {
|
||||||
runWithNeededPermissions {
|
runWithNeededPermissions {
|
||||||
tryAuthenticate()
|
tryAuthenticate()
|
||||||
@@ -59,6 +61,7 @@ internal class InitializationActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun showLogin() {
|
private fun showLogin() {
|
||||||
|
splashScreenActive = false
|
||||||
startActivity(Intent(this, LoginActivity::class.java))
|
startActivity(Intent(this, LoginActivity::class.java))
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
@@ -76,6 +79,8 @@ internal class InitializationActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun failed(exception: ApiException) {
|
private fun failed(exception: ApiException) {
|
||||||
|
splashScreenActive = false
|
||||||
|
setContentView(R.layout.splash)
|
||||||
when (exception.code) {
|
when (exception.code) {
|
||||||
0 -> {
|
0 -> {
|
||||||
dialog(getString(R.string.not_available, settings.url))
|
dialog(getString(R.string.not_available, settings.url))
|
||||||
@@ -98,6 +103,7 @@ internal class InitializationActivity : AppCompatActivity() {
|
|||||||
.setMessage(message)
|
.setMessage(message)
|
||||||
.setPositiveButton(R.string.retry) { _, _ -> tryAuthenticate() }
|
.setPositiveButton(R.string.retry) { _, _ -> tryAuthenticate() }
|
||||||
.setNegativeButton(R.string.logout) { _, _ -> showLogin() }
|
.setNegativeButton(R.string.logout) { _, _ -> showLogin() }
|
||||||
|
.setCancelable(false)
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,6 +112,7 @@ internal class InitializationActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
settings.setUser(user.name, user.isAdmin)
|
settings.setUser(user.name, user.isAdmin)
|
||||||
requestVersion {
|
requestVersion {
|
||||||
|
splashScreenActive = false
|
||||||
startActivity(Intent(this, MessagesActivity::class.java))
|
startActivity(Intent(this, MessagesActivity::class.java))
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
app/src/main/res/drawable/gotify_splash.png
Normal file
BIN
app/src/main/res/drawable/gotify_splash.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 95 KiB |
@@ -15,6 +15,11 @@
|
|||||||
<item name="windowActionBar">false</item>
|
<item name="windowActionBar">false</item>
|
||||||
<item name="windowNoTitle">true</item>
|
<item name="windowNoTitle">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="AppTheme.SplashScreen" parent="Theme.SplashScreen">
|
||||||
|
<item name="windowSplashScreenAnimatedIcon">@drawable/gotify_splash</item>
|
||||||
|
<item name="postSplashScreenTheme">@style/AppTheme.NoActionBar</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.MaterialComponents.Dark.ActionBar" />
|
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.MaterialComponents.Dark.ActionBar" />
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user