|
@@ -66,8 +66,6 @@ import kotlin.coroutines.suspendCoroutine
|
|
|
open class MainActivity : BaseComposeActivity(), VariableDialog.Callback {
|
|
open class MainActivity : BaseComposeActivity(), VariableDialog.Callback {
|
|
|
|
|
|
|
|
companion object {
|
|
companion object {
|
|
|
- private var isFirstLaunch = true
|
|
|
|
|
-
|
|
|
|
|
@Volatile
|
|
@Volatile
|
|
|
var hasActiveReadBookRoute: Boolean = false
|
|
var hasActiveReadBookRoute: Boolean = false
|
|
|
|
|
|
|
@@ -143,9 +141,11 @@ open class MainActivity : BaseComposeActivity(), VariableDialog.Callback {
|
|
|
private val viewModel by viewModel<MainViewModel>()
|
|
private val viewModel by viewModel<MainViewModel>()
|
|
|
private val routeEvents = MutableSharedFlow<NavKey>(extraBufferCapacity = 1)
|
|
private val routeEvents = MutableSharedFlow<NavKey>(extraBufferCapacity = 1)
|
|
|
private var bookInfoVariableSetter: ((String, String?) -> Unit)? = null
|
|
private var bookInfoVariableSetter: ((String, String?) -> Unit)? = null
|
|
|
|
|
+ private var shouldApplyDefaultToRead = true
|
|
|
internal var activeReadBookInputHandler: ReadBookInputHandler? = null
|
|
internal var activeReadBookInputHandler: ReadBookInputHandler? = null
|
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
|
installSplashScreen()
|
|
installSplashScreen()
|
|
|
|
|
+ shouldApplyDefaultToRead = savedInstanceState == null
|
|
|
super.onCreate(savedInstanceState)
|
|
super.onCreate(savedInstanceState)
|
|
|
|
|
|
|
|
if (checkStartupRoute()) return
|
|
if (checkStartupRoute()) return
|
|
@@ -193,14 +193,13 @@ open class MainActivity : BaseComposeActivity(), VariableDialog.Callback {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
val startRoutes = remember {
|
|
val startRoutes = remember {
|
|
|
- val resolved = MainNavigator.resolveStartRoute(intent)
|
|
|
|
|
- if (isFirstLaunch && OtherConfig.defaultToRead && resolved == MainRouteHome) {
|
|
|
|
|
- isFirstLaunch = false
|
|
|
|
|
- arrayOf(MainRouteHome, MainRouteReadBook())
|
|
|
|
|
- } else {
|
|
|
|
|
- isFirstLaunch = false
|
|
|
|
|
- arrayOf(resolved)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ val routes = resolveInitialStartRoutes(
|
|
|
|
|
+ resolved = MainNavigator.resolveStartRoute(intent),
|
|
|
|
|
+ defaultToRead = OtherConfig.defaultToRead,
|
|
|
|
|
+ isFreshCreate = shouldApplyDefaultToRead,
|
|
|
|
|
+ )
|
|
|
|
|
+ shouldApplyDefaultToRead = false
|
|
|
|
|
+ routes.toTypedArray()
|
|
|
}
|
|
}
|
|
|
val backStack = rememberNavBackStack(*startRoutes)
|
|
val backStack = rememberNavBackStack(*startRoutes)
|
|
|
|
|
|
|
@@ -422,9 +421,6 @@ open class MainActivity : BaseComposeActivity(), VariableDialog.Callback {
|
|
|
|
|
|
|
|
override fun onDestroy() {
|
|
override fun onDestroy() {
|
|
|
super.onDestroy()
|
|
super.onDestroy()
|
|
|
- if (!isChangingConfigurations) {
|
|
|
|
|
- isFirstLaunch = true
|
|
|
|
|
- }
|
|
|
|
|
Coroutine.async {
|
|
Coroutine.async {
|
|
|
BookHelp.clearInvalidCache()
|
|
BookHelp.clearInvalidCache()
|
|
|
}
|
|
}
|
|
@@ -439,6 +435,18 @@ open class MainActivity : BaseComposeActivity(), VariableDialog.Callback {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+internal fun resolveInitialStartRoutes(
|
|
|
|
|
+ resolved: NavKey,
|
|
|
|
|
+ defaultToRead: Boolean,
|
|
|
|
|
+ isFreshCreate: Boolean,
|
|
|
|
|
+): List<NavKey> {
|
|
|
|
|
+ return if (isFreshCreate && defaultToRead && resolved == MainRouteHome) {
|
|
|
|
|
+ listOf(MainRouteHome, MainRouteReadBook())
|
|
|
|
|
+ } else {
|
|
|
|
|
+ listOf(resolved)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
class LauncherW : MainActivity()
|
|
class LauncherW : MainActivity()
|
|
|
class Launcher1 : MainActivity()
|
|
class Launcher1 : MainActivity()
|
|
|
class Launcher2 : MainActivity()
|
|
class Launcher2 : MainActivity()
|