Handle intent after navigator is initialized
Fixes crash if opening from widget or notification when activity isn't already launched. (cherry picked from commit 09cebf20f3ee150629fe3c62d3974180fec6f8a2) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt
This commit is contained in:
parent
44feb3569d
commit
bcad021e00
@ -95,8 +95,6 @@ class MainActivity : BaseActivity() {
|
|||||||
private val unsortedPreferences: UnsortedPreferences by injectLazy()
|
private val unsortedPreferences: UnsortedPreferences by injectLazy()
|
||||||
// SY <--
|
// SY <--
|
||||||
|
|
||||||
private var isHandlingShortcut: Boolean = false
|
|
||||||
|
|
||||||
private val chapterCache: ChapterCache by injectLazy()
|
private val chapterCache: ChapterCache by injectLazy()
|
||||||
|
|
||||||
// To be checked by splash screen. If true then splash screen will be removed.
|
// To be checked by splash screen. If true then splash screen will be removed.
|
||||||
@ -107,6 +105,7 @@ class MainActivity : BaseActivity() {
|
|||||||
*/
|
*/
|
||||||
private var settingsSheet: LibrarySettingsSheet? = null
|
private var settingsSheet: LibrarySettingsSheet? = null
|
||||||
|
|
||||||
|
private var isHandlingShortcut: Boolean = false
|
||||||
private lateinit var navigator: Navigator
|
private lateinit var navigator: Navigator
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
@ -131,6 +130,12 @@ class MainActivity : BaseActivity() {
|
|||||||
// SY <--
|
// SY <--
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
// Do not let the launcher create a new activity http://stackoverflow.com/questions/16283079
|
||||||
|
if (!isTaskRoot) {
|
||||||
|
finish()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Prevent splash screen showing up on configuration changes
|
// Prevent splash screen showing up on configuration changes
|
||||||
val splashScreen = if (savedInstanceState == null) installSplashScreen() else null
|
val splashScreen = if (savedInstanceState == null) installSplashScreen() else null
|
||||||
|
|
||||||
@ -158,14 +163,10 @@ class MainActivity : BaseActivity() {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not let the launcher create a new activity http://stackoverflow.com/questions/16283079
|
// SY -->
|
||||||
if (!isTaskRoot) {
|
|
||||||
finish()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
@Suppress("KotlinConstantConditions")
|
@Suppress("KotlinConstantConditions")
|
||||||
val hasDebugOverlay = (BuildConfig.DEBUG || BuildConfig.BUILD_TYPE == "releaseTest")
|
val hasDebugOverlay = (BuildConfig.DEBUG || BuildConfig.BUILD_TYPE == "releaseTest")
|
||||||
|
// SY <--
|
||||||
|
|
||||||
// Draw edge-to-edge
|
// Draw edge-to-edge
|
||||||
WindowCompat.setDecorFitsSystemWindows(window, false)
|
WindowCompat.setDecorFitsSystemWindows(window, false)
|
||||||
@ -184,6 +185,32 @@ class MainActivity : BaseActivity() {
|
|||||||
ConfirmExit()
|
ConfirmExit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LaunchedEffect(navigator) {
|
||||||
|
this@MainActivity.navigator = navigator
|
||||||
|
|
||||||
|
if (savedInstanceState == null) {
|
||||||
|
// Set start screen
|
||||||
|
handleIntentAction(intent)
|
||||||
|
|
||||||
|
// Reset Incognito Mode on relaunch
|
||||||
|
preferences.incognitoMode().set(false)
|
||||||
|
|
||||||
|
// SY -->
|
||||||
|
initWhenIdle {
|
||||||
|
// Upload settings
|
||||||
|
if (unsortedPreferences.enableExhentai().get() &&
|
||||||
|
unsortedPreferences.exhShowSettingsUploadWarning().get()
|
||||||
|
) {
|
||||||
|
runExhConfigureDialog = true
|
||||||
|
}
|
||||||
|
// Scheduler uploader job if required
|
||||||
|
|
||||||
|
EHentaiUpdateWorker.scheduleBackground(this@MainActivity)
|
||||||
|
}
|
||||||
|
// SY <--
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Shows current screen
|
// Shows current screen
|
||||||
ScreenTransition(navigator = navigator, transition = { Transition.OneWayFade })
|
ScreenTransition(navigator = navigator, transition = { Transition.OneWayFade })
|
||||||
|
|
||||||
@ -204,13 +231,10 @@ class MainActivity : BaseActivity() {
|
|||||||
.launchIn(this)
|
.launchIn(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(navigator) {
|
|
||||||
this@MainActivity.navigator = navigator
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckForUpdate()
|
CheckForUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SY -->
|
||||||
if (hasDebugOverlay) {
|
if (hasDebugOverlay) {
|
||||||
val isDebugOverlayEnabled by remember {
|
val isDebugOverlayEnabled by remember {
|
||||||
DebugToggles.ENABLE_DEBUG_OVERLAY.asPref(lifecycleScope)
|
DebugToggles.ENABLE_DEBUG_OVERLAY.asPref(lifecycleScope)
|
||||||
@ -219,6 +243,7 @@ class MainActivity : BaseActivity() {
|
|||||||
DebugModeOverlay()
|
DebugModeOverlay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// SY <--
|
||||||
|
|
||||||
var showChangelog by remember { mutableStateOf(didMigration && !BuildConfig.DEBUG) }
|
var showChangelog by remember { mutableStateOf(didMigration && !BuildConfig.DEBUG) }
|
||||||
if (showChangelog) {
|
if (showChangelog) {
|
||||||
@ -227,7 +252,9 @@ class MainActivity : BaseActivity() {
|
|||||||
// SY <--
|
// SY <--
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SY -->
|
||||||
ConfigureExhDialog(run = runExhConfigureDialog, onRunning = { runExhConfigureDialog = false })
|
ConfigureExhDialog(run = runExhConfigureDialog, onRunning = { runExhConfigureDialog = false })
|
||||||
|
// SY <--
|
||||||
}
|
}
|
||||||
|
|
||||||
val startTime = System.currentTimeMillis()
|
val startTime = System.currentTimeMillis()
|
||||||
@ -237,27 +264,6 @@ class MainActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
setSplashScreenExitAnimation(splashScreen)
|
setSplashScreenExitAnimation(splashScreen)
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
|
||||||
// Set start screen
|
|
||||||
lifecycleScope.launch { handleIntentAction(intent) }
|
|
||||||
|
|
||||||
// Reset Incognito Mode on relaunch
|
|
||||||
preferences.incognitoMode().set(false)
|
|
||||||
|
|
||||||
// SY -->
|
|
||||||
initWhenIdle {
|
|
||||||
// Upload settings
|
|
||||||
if (unsortedPreferences.enableExhentai().get() &&
|
|
||||||
unsortedPreferences.exhShowSettingsUploadWarning().get()
|
|
||||||
) {
|
|
||||||
runExhConfigureDialog = true
|
|
||||||
}
|
|
||||||
// Scheduler uploader job if required
|
|
||||||
|
|
||||||
EHentaiUpdateWorker.scheduleBackground(this)
|
|
||||||
}
|
|
||||||
// SY <--
|
|
||||||
}
|
|
||||||
// SY -->
|
// SY -->
|
||||||
if (!unsortedPreferences.isHentaiEnabled().get()) {
|
if (!unsortedPreferences.isHentaiEnabled().get()) {
|
||||||
BlacklistedSources.HIDDEN_SOURCES += EH_SOURCE_ID
|
BlacklistedSources.HIDDEN_SOURCES += EH_SOURCE_ID
|
||||||
|
Loading…
x
Reference in New Issue
Block a user