Revert "Remove PIN & sign-in auto settings (#397)"

This reverts commit 82927d1968.
This commit is contained in:
damontecres 2025-12-08 10:13:58 -05:00 committed by GitHub
parent 82927d1968
commit e26add224d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 47 additions and 50 deletions

View file

@ -1,6 +1,7 @@
package com.github.damontecres.wholphin package com.github.damontecres.wholphin
import android.os.Bundle import android.os.Bundle
import android.view.WindowManager
import androidx.activity.compose.setContent import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.background import androidx.compose.foundation.background
@ -9,6 +10,7 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.material3.CircularProgressIndicator import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
@ -43,6 +45,7 @@ import com.github.damontecres.wholphin.services.UpdateChecker
import com.github.damontecres.wholphin.services.hilt.AuthOkHttpClient import com.github.damontecres.wholphin.services.hilt.AuthOkHttpClient
import com.github.damontecres.wholphin.ui.CoilConfig import com.github.damontecres.wholphin.ui.CoilConfig
import com.github.damontecres.wholphin.ui.LocalImageUrlService import com.github.damontecres.wholphin.ui.LocalImageUrlService
import com.github.damontecres.wholphin.ui.isNotNullOrBlank
import com.github.damontecres.wholphin.ui.launchIO import com.github.damontecres.wholphin.ui.launchIO
import com.github.damontecres.wholphin.ui.nav.ApplicationContent import com.github.damontecres.wholphin.ui.nav.ApplicationContent
import com.github.damontecres.wholphin.ui.nav.Destination import com.github.damontecres.wholphin.ui.nav.Destination
@ -50,6 +53,8 @@ import com.github.damontecres.wholphin.ui.theme.WholphinTheme
import com.github.damontecres.wholphin.util.DebugLogTree import com.github.damontecres.wholphin.util.DebugLogTree
import dagger.hilt.android.AndroidEntryPoint import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import okhttp3.OkHttpClient import okhttp3.OkHttpClient
import org.jellyfin.sdk.model.serializer.toUUIDOrNull import org.jellyfin.sdk.model.serializer.toUUIDOrNull
@ -141,17 +146,16 @@ class MainActivity : AppCompatActivity() {
) { ) {
var isRestoringSession by remember { mutableStateOf(true) } var isRestoringSession by remember { mutableStateOf(true) }
LaunchedEffect(Unit) { LaunchedEffect(Unit) {
// TODO PIN-related if (appPreferences.signInAutomatically) {
// if (appPreferences.signInAutomatically) { try {
try { serverRepository.restoreSession(
serverRepository.restoreSession( appPreferences.currentServerId?.toUUIDOrNull(),
appPreferences.currentServerId?.toUUIDOrNull(), appPreferences.currentUserId?.toUUIDOrNull(),
appPreferences.currentUserId?.toUUIDOrNull(), )
) } catch (ex: Exception) {
} catch (ex: Exception) { Timber.e(ex, "Exception restoring session")
Timber.e(ex, "Exception restoring session") }
} }
// }
isRestoringSession = false isRestoringSession = false
} }
val current by serverRepository.current.observeAsState() val current by serverRepository.current.observeAsState()
@ -173,34 +177,32 @@ class MainActivity : AppCompatActivity() {
) )
} }
} else { } else {
// TODO PIN-related DisposableEffect(Unit) {
// DisposableEffect(Unit) { onDispose {
// onDispose { if (!appPreferences.signInAutomatically || current?.user?.hasPin == true) {
// if (!appPreferences.signInAutomatically || current?.user?.hasPin == true) { serverRepository.closeSession()
// serverRepository.closeSession() }
// } }
// } }
// }
key(current?.server?.id, current?.user?.id) { key(current?.server?.id, current?.user?.id) {
// TODO PIN-related LaunchedEffect(current?.user?.pin) {
// LaunchedEffect(current?.user?.pin) { if (current?.user?.pin?.isNotNullOrBlank() == true) {
// if (current?.user?.pin?.isNotNullOrBlank() == true) { // If user has a pin, then obscure the window in previews
// // If user has a pin, then obscure the window in previews window?.setFlags(
// window?.setFlags( WindowManager.LayoutParams.FLAG_SECURE,
// WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE,
// WindowManager.LayoutParams.FLAG_SECURE, )
// ) } else {
// } else { window?.clearFlags(WindowManager.LayoutParams.FLAG_SECURE)
// window?.clearFlags(WindowManager.LayoutParams.FLAG_SECURE) }
// } }
// }
val initialDestination = val initialDestination =
when { when {
current != null -> Destination.Home() current != null -> Destination.Home()
// TODO PIN-related !appPreferences.signInAutomatically -> Destination.ServerList
// !appPreferences.signInAutomatically -> Destination.ServerList
// TODO user list?
else -> Destination.ServerList else -> Destination.ServerList
} }
val backStack = rememberNavBackStack(initialDestination) val backStack = rememberNavBackStack(initialDestination)
@ -247,12 +249,11 @@ class MainActivity : AppCompatActivity() {
override fun onRestart() { override fun onRestart() {
super.onRestart() super.onRestart()
// TODO PIN-related val signInAutomatically =
// val signInAutomatically = runBlocking { userPreferencesDataStore.data.firstOrNull()?.signInAutomatically } ?: true
// runBlocking { userPreferencesDataStore.data.firstOrNull()?.signInAutomatically } ?: true Timber.i("onRestart: signInAutomatically=$signInAutomatically")
// Timber.i("onRestart: signInAutomatically=$signInAutomatically") if (!signInAutomatically || serverRepository.currentUser.value?.hasPin == true) {
// if (!signInAutomatically || serverRepository.currentUser.value?.hasPin == true) { serverRepository.closeSession()
// serverRepository.closeSession() }
// }
} }
} }

View file

@ -793,8 +793,7 @@ val basicPreferences =
title = R.string.ui_interface, title = R.string.ui_interface,
preferences = preferences =
listOf( listOf(
// TODO PIN-related AppPreference.SignInAuto,
// AppPreference.SignInAuto,
AppPreference.HomePageItems, AppPreference.HomePageItems,
AppPreference.CombineContinueNext, AppPreference.CombineContinueNext,
AppPreference.RewatchNextUp, AppPreference.RewatchNextUp,
@ -827,8 +826,7 @@ val basicPreferences =
title = R.string.profile_specific_settings, title = R.string.profile_specific_settings,
preferences = preferences =
listOf( listOf(
// TODO PIN-related AppPreference.RequireProfilePin,
// AppPreference.RequireProfilePin,
AppPreference.UserPinnedNavDrawerItems, AppPreference.UserPinnedNavDrawerItems,
), ),
), ),

View file

@ -119,13 +119,11 @@ fun SwitchUserContent(
users = users, users = users,
currentUser = currentUser, currentUser = currentUser,
onSwitchUser = { user -> onSwitchUser = { user ->
// TODO PIN-related if (user.pin.isNotNullOrBlank()) {
// if (user.pin.isNotNullOrBlank()) { switchUserWithPin = user
// switchUserWithPin = user } else {
// } else { viewModel.switchUser(user)
// viewModel.switchUser(user) }
// }
viewModel.switchUser(user)
}, },
onAddUser = { showAddUser = true }, onAddUser = { showAddUser = true },
onRemoveUser = { user -> onRemoveUser = { user ->