mirror of
https://github.com/JustinZeus/Wholphin.git
synced 2026-07-09 16:11:20 +02:00
Add setting to toggle automatic sign in (#538)
## Description The major user facing change in this PR is adding back the setting to toggle automatic sign in on or off. This controls whether to restore the app to where you left off or go the user selection page. If enabled: re-opening the app will restore the previous user's session If disabled: re-opening the app will always start with the user selection page for the most recent server, or if there isn't a recent server, the server selection page This also separate this setting from the PIN protection settings in previous PRs. ### Dev changes This PR refactors the "setup" UI (server & user selection) to be separate from the "app" UI (the actually app content). There is now a `NavDisplay` for the setup flow which ends with displaying the `ApplicationContent`'s `NavDisplay`. Most of the logic is moved out of Compose code and into a `ViewModel`. This means to switch users/server, the `SetupNavigationManager` must be used instead of `NavigationManager`. ### Related issues Closes #396 Fixes #376
This commit is contained in:
parent
20fe5e2626
commit
eb4e9b93be
14 changed files with 302 additions and 198 deletions
|
|
@ -20,7 +20,7 @@ class DeviceProfileService
|
|||
constructor(
|
||||
@param:ApplicationContext private val context: Context,
|
||||
) {
|
||||
private val mediaCodecCapabilitiesTest by lazy {
|
||||
val mediaCodecCapabilitiesTest by lazy {
|
||||
// Created lazily below on the IO thread since it cn take time
|
||||
MediaCodecCapabilitiesTest(context)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,12 +29,7 @@ class NavigationManager
|
|||
*/
|
||||
fun navigateToFromDrawer(destination: Destination) {
|
||||
goToHome()
|
||||
if (destination == Destination.ServerList || destination is Destination.UserList) {
|
||||
backStack.add(destination)
|
||||
(0..<backStack.size - 1).forEach { _ -> backStack.removeAt(0) }
|
||||
} else {
|
||||
backStack.add(destination)
|
||||
}
|
||||
backStack.add(destination)
|
||||
log()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,54 @@
|
|||
package com.github.damontecres.wholphin.services
|
||||
|
||||
import androidx.compose.runtime.mutableStateListOf
|
||||
import androidx.navigation3.runtime.NavKey
|
||||
import com.github.damontecres.wholphin.data.CurrentUser
|
||||
import com.github.damontecres.wholphin.data.model.JellyfinServer
|
||||
import kotlinx.serialization.Serializable
|
||||
import org.acra.ACRA
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
/**
|
||||
* Manages navigating for setup
|
||||
*/
|
||||
@Singleton
|
||||
class SetupNavigationManager
|
||||
@Inject
|
||||
constructor() {
|
||||
var backStack: MutableList<NavKey> = mutableStateListOf(SetupDestination.Loading)
|
||||
|
||||
/**
|
||||
* Go to the specified [SetupDestination]
|
||||
*/
|
||||
fun navigateTo(destination: SetupDestination) {
|
||||
backStack[0] = destination
|
||||
log()
|
||||
}
|
||||
|
||||
private fun log() {
|
||||
val dest = backStack.lastOrNull().toString()
|
||||
Timber.i("Current setup destination: %s", dest)
|
||||
ACRA.errorReporter.putCustomData("setupDestination", dest)
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
sealed interface SetupDestination : NavKey {
|
||||
@Serializable
|
||||
data object Loading : SetupDestination
|
||||
|
||||
@Serializable
|
||||
data object ServerList : SetupDestination
|
||||
|
||||
@Serializable
|
||||
data class UserList(
|
||||
val server: JellyfinServer,
|
||||
) : SetupDestination
|
||||
|
||||
@Serializable
|
||||
data class AppContent(
|
||||
val current: CurrentUser,
|
||||
) : SetupDestination
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue