- Replaces bottom toast: dark rounded card centered on screen, auto-hides after 5 seconds - Optional test trigger via node_toast_test intent extra
72 lines
2.0 KiB
Kotlin
72 lines
2.0 KiB
Kotlin
package ru.ua1zbe.svxremote
|
||
|
||
import android.app.Activity
|
||
import android.content.Intent
|
||
import android.os.Bundle
|
||
import android.view.View
|
||
import android.view.animation.AccelerateDecelerateInterpolator
|
||
|
||
/** Красивая заставка с плавным появлением логотипа. */
|
||
class SplashActivity : Activity() {
|
||
|
||
companion object {
|
||
@Volatile
|
||
var mainAlive = false
|
||
}
|
||
|
||
override fun onCreate(savedInstanceState: Bundle?) {
|
||
super.onCreate(savedInstanceState)
|
||
if (mainAlive) {
|
||
openMain()
|
||
return
|
||
}
|
||
setContentView(R.layout.activity_splash)
|
||
|
||
val title = findViewById<View>(R.id.splash_title)
|
||
val subtitle = findViewById<View>(R.id.splash_subtitle)
|
||
val line = findViewById<View>(R.id.splash_line)
|
||
|
||
title.alpha = 0f
|
||
subtitle.alpha = 0f
|
||
line.alpha = 0f
|
||
|
||
title.animate()
|
||
.alpha(1f)
|
||
.scaleX(1.0f)
|
||
.scaleY(1.0f)
|
||
.setStartDelay(150)
|
||
.setDuration(700)
|
||
.setInterpolator(AccelerateDecelerateInterpolator())
|
||
.start()
|
||
|
||
subtitle.animate()
|
||
.alpha(1f)
|
||
.setStartDelay(600)
|
||
.setDuration(600)
|
||
.start()
|
||
|
||
line.animate()
|
||
.alpha(1f)
|
||
.setStartDelay(900)
|
||
.setDuration(500)
|
||
.start()
|
||
|
||
window.decorView.postDelayed({
|
||
openMain()
|
||
}, 4000)
|
||
}
|
||
|
||
private fun openMain() {
|
||
val intent = Intent(this, MainActivity::class.java)
|
||
.addFlags(
|
||
Intent.FLAG_ACTIVITY_NEW_TASK or
|
||
Intent.FLAG_ACTIVITY_CLEAR_TOP or
|
||
Intent.FLAG_ACTIVITY_SINGLE_TOP
|
||
)
|
||
val testText = this.intent?.getStringExtra("node_toast_test")
|
||
if (testText != null) intent.putExtra("node_toast_test", testText)
|
||
startActivity(intent)
|
||
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
|
||
finish()
|
||
}
|
||
} |