mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
fix: Skip splash screen for some actions
I hate this, but SplashScreen API not making it easy for me. Classic Google API moment...
This commit is contained in:
parent
88f1a56adf
commit
9561999161
3 changed files with 19 additions and 1 deletions
|
@ -240,10 +240,23 @@ open class MainActivity : BaseActivity<MainActivityBinding>() {
|
|||
}
|
||||
}
|
||||
|
||||
var skipSplashInstall = false
|
||||
var ready = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
val splashScreen = if (savedInstanceState == null) installSplashScreen() else null
|
||||
if (this !is SearchActivity) skipSplashInstall = intent.action !in listOf(Intent.ACTION_MAIN, Intent.ACTION_VIEW)
|
||||
skipSplashInstall = intent.extras?.getBoolean(SPLASH_SKIP, false) ?: skipSplashInstall
|
||||
|
||||
val splashScreen = if (skipSplashInstall) {
|
||||
null
|
||||
} else {
|
||||
if (savedInstanceState == null) installSplashScreen() else null
|
||||
}
|
||||
|
||||
if (skipSplashInstall && splashScreen == null) {
|
||||
setTheme(R.style.Theme_Tachiyomi)
|
||||
ready = true
|
||||
}
|
||||
|
||||
// Set up shared element transition and disable overlay so views don't show above system bars
|
||||
window.requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)
|
||||
|
@ -1626,6 +1639,7 @@ open class MainActivity : BaseActivity<MainActivityBinding>() {
|
|||
private const val SPLASH_MIN_DURATION = 500 // ms
|
||||
private const val SPLASH_MAX_DURATION = 5000 // ms
|
||||
private const val SPLASH_EXIT_ANIM_DURATION = 400L // ms
|
||||
const val SPLASH_SKIP = "${BuildConfig.APPLICATION_ID}.SHOULD_SKIP_SPLASH"
|
||||
|
||||
var chapterIdToExitTo = 0L
|
||||
var backVelocity = 0f
|
||||
|
|
|
@ -33,6 +33,8 @@ class SearchActivity : MainActivity() {
|
|||
private var backToMain = false
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
skipSplashInstall = intentShouldGoBack()
|
||||
|
||||
super.onCreate(savedInstanceState)
|
||||
binding.toolbar.navigationIcon = backDrawable
|
||||
binding.toolbar.setNavigationOnClickListener { popToRoot() }
|
||||
|
@ -73,6 +75,7 @@ class SearchActivity : MainActivity() {
|
|||
} else if (!router.handleBack()) {
|
||||
val intent = Intent(this, MainActivity::class.java).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
putExtra(SPLASH_SKIP, true)
|
||||
}
|
||||
backToMain = true
|
||||
startActivity(intent)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue