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:
ziro 2024-02-08 12:23:01 +07:00
parent 88f1a56adf
commit 9561999161
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
3 changed files with 19 additions and 1 deletions

View file

@ -15,6 +15,7 @@ Since there's a lot of new people coming over, I'll repeat my statement a few re
## Changes
- Repositioned cutout options in settings
- Splash icon now uses coloured variant of the icon
- Removed deep link for sources, this should be handled by extensions
## Fixes
- Fixed splash icon hardcoded to white

View file

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

View file

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