Remove confirm exit option
Redundant with predictive back, but also just sort of pointless since it doesn't help with any sort of app state retention. (cherry picked from commit 8f4bc71cf7b99fe0b0d2ea68dfca0140477686cc) # Conflicts: # app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsGeneralScreen.kt # app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt
This commit is contained in:
parent
728c715bf4
commit
8877ddb015
@ -11,8 +11,6 @@ class BasePreferences(
|
|||||||
private val preferenceStore: PreferenceStore,
|
private val preferenceStore: PreferenceStore,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun confirmExit() = preferenceStore.getBoolean("pref_confirm_exit", false)
|
|
||||||
|
|
||||||
fun downloadedOnly() = preferenceStore.getBoolean("pref_downloaded_only", false)
|
fun downloadedOnly() = preferenceStore.getBoolean("pref_downloaded_only", false)
|
||||||
|
|
||||||
fun incognitoMode() = preferenceStore.getBoolean("incognito_mode", false)
|
fun incognitoMode() = preferenceStore.getBoolean("incognito_mode", false)
|
||||||
|
@ -16,7 +16,6 @@ import androidx.compose.runtime.setValue
|
|||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.core.os.LocaleListCompat
|
import androidx.core.os.LocaleListCompat
|
||||||
import eu.kanade.domain.base.BasePreferences
|
|
||||||
import eu.kanade.domain.ui.UiPreferences
|
import eu.kanade.domain.ui.UiPreferences
|
||||||
import eu.kanade.presentation.more.settings.Preference
|
import eu.kanade.presentation.more.settings.Preference
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
@ -35,12 +34,16 @@ object SettingsGeneralScreen : SearchableSettings {
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun getPreferences(): List<Preference> {
|
override fun getPreferences(): List<Preference> {
|
||||||
val prefs = remember { Injekt.get<BasePreferences>() }
|
|
||||||
val libraryPrefs = remember { Injekt.get<LibraryPreferences>() }
|
val libraryPrefs = remember { Injekt.get<LibraryPreferences>() }
|
||||||
// SY -->
|
// SY -->
|
||||||
val uiPrefs = remember { Injekt.get<UiPreferences>() }
|
val uiPrefs = remember { Injekt.get<UiPreferences>() }
|
||||||
// SY <--
|
// SY <--
|
||||||
return mutableListOf<Preference>().apply {
|
val context = LocalContext.current
|
||||||
|
|
||||||
|
val langs = remember { getLangs(context) }
|
||||||
|
var currentLanguage by remember { mutableStateOf(AppCompatDelegate.getApplicationLocales().get(0)?.toLanguageTag() ?: "") }
|
||||||
|
|
||||||
|
return buildList {
|
||||||
add(
|
add(
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
Preference.PreferenceItem.SwitchPreference(
|
||||||
pref = libraryPrefs.newShowUpdatesCount(),
|
pref = libraryPrefs.newShowUpdatesCount(),
|
||||||
@ -48,14 +51,6 @@ object SettingsGeneralScreen : SearchableSettings {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
add(
|
|
||||||
Preference.PreferenceItem.SwitchPreference(
|
|
||||||
pref = prefs.confirmExit(),
|
|
||||||
title = stringResource(R.string.pref_confirm_exit),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
val context = LocalContext.current
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
add(
|
add(
|
||||||
Preference.PreferenceItem.TextPreference(
|
Preference.PreferenceItem.TextPreference(
|
||||||
@ -70,8 +65,6 @@ object SettingsGeneralScreen : SearchableSettings {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val langs = remember { getLangs(context) }
|
|
||||||
var currentLanguage by remember { mutableStateOf(AppCompatDelegate.getApplicationLocales().get(0)?.toLanguageTag() ?: "") }
|
|
||||||
add(
|
add(
|
||||||
Preference.PreferenceItem.BasicListPreference(
|
Preference.PreferenceItem.BasicListPreference(
|
||||||
value = currentLanguage,
|
value = currentLanguage,
|
||||||
|
@ -10,9 +10,7 @@ import android.os.Build
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.BackHandler
|
|
||||||
import androidx.compose.foundation.isSystemInDarkTheme
|
import androidx.compose.foundation.isSystemInDarkTheme
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
@ -30,7 +28,6 @@ import androidx.compose.runtime.collectAsState
|
|||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.mutableStateOf
|
import androidx.compose.runtime.mutableStateOf
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
|
||||||
import androidx.compose.runtime.setValue
|
import androidx.compose.runtime.setValue
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.luminance
|
import androidx.compose.ui.graphics.luminance
|
||||||
@ -65,7 +62,6 @@ import eu.kanade.presentation.util.AssistContentScreen
|
|||||||
import eu.kanade.presentation.util.DefaultNavigatorScreenTransition
|
import eu.kanade.presentation.util.DefaultNavigatorScreenTransition
|
||||||
import eu.kanade.presentation.util.collectAsState
|
import eu.kanade.presentation.util.collectAsState
|
||||||
import eu.kanade.tachiyomi.BuildConfig
|
import eu.kanade.tachiyomi.BuildConfig
|
||||||
import eu.kanade.tachiyomi.R
|
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadCache
|
import eu.kanade.tachiyomi.data.download.DownloadCache
|
||||||
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
||||||
import eu.kanade.tachiyomi.data.updater.AppUpdateChecker
|
import eu.kanade.tachiyomi.data.updater.AppUpdateChecker
|
||||||
@ -79,7 +75,6 @@ import eu.kanade.tachiyomi.ui.more.NewUpdateScreen
|
|||||||
import eu.kanade.tachiyomi.util.system.dpToPx
|
import eu.kanade.tachiyomi.util.system.dpToPx
|
||||||
import eu.kanade.tachiyomi.util.system.isNavigationBarNeedsScrim
|
import eu.kanade.tachiyomi.util.system.isNavigationBarNeedsScrim
|
||||||
import eu.kanade.tachiyomi.util.system.isPreviewBuildType
|
import eu.kanade.tachiyomi.util.system.isPreviewBuildType
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
|
||||||
import eu.kanade.tachiyomi.util.view.setComposeContent
|
import eu.kanade.tachiyomi.util.view.setComposeContent
|
||||||
import exh.EXHMigrations
|
import exh.EXHMigrations
|
||||||
import exh.debug.DebugToggles
|
import exh.debug.DebugToggles
|
||||||
@ -90,7 +85,6 @@ import exh.source.EH_SOURCE_ID
|
|||||||
import exh.source.EXH_SOURCE_ID
|
import exh.source.EXH_SOURCE_ID
|
||||||
import exh.syDebugVersion
|
import exh.syDebugVersion
|
||||||
import kotlinx.coroutines.channels.awaitClose
|
import kotlinx.coroutines.channels.awaitClose
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.coroutines.flow.callbackFlow
|
import kotlinx.coroutines.flow.callbackFlow
|
||||||
import kotlinx.coroutines.flow.collectLatest
|
import kotlinx.coroutines.flow.collectLatest
|
||||||
import kotlinx.coroutines.flow.drop
|
import kotlinx.coroutines.flow.drop
|
||||||
@ -109,7 +103,6 @@ import uy.kohesive.injekt.Injekt
|
|||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.util.LinkedList
|
import java.util.LinkedList
|
||||||
import kotlin.time.Duration.Companion.seconds
|
|
||||||
import androidx.compose.ui.graphics.Color.Companion as ComposeColor
|
import androidx.compose.ui.graphics.Color.Companion as ComposeColor
|
||||||
|
|
||||||
class MainActivity : BaseActivity() {
|
class MainActivity : BaseActivity() {
|
||||||
@ -232,10 +225,6 @@ class MainActivity : BaseActivity() {
|
|||||||
screen = HomeScreen,
|
screen = HomeScreen,
|
||||||
disposeBehavior = NavigatorDisposeBehavior(disposeNestedNavigators = false, disposeSteps = true),
|
disposeBehavior = NavigatorDisposeBehavior(disposeNestedNavigators = false, disposeSteps = true),
|
||||||
) { navigator ->
|
) { navigator ->
|
||||||
if (navigator.size == 1) {
|
|
||||||
ConfirmExit()
|
|
||||||
}
|
|
||||||
|
|
||||||
LaunchedEffect(navigator) {
|
LaunchedEffect(navigator) {
|
||||||
this@MainActivity.navigator = navigator
|
this@MainActivity.navigator = navigator
|
||||||
|
|
||||||
@ -353,22 +342,6 @@ class MainActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun ConfirmExit() {
|
|
||||||
val scope = rememberCoroutineScope()
|
|
||||||
val confirmExit by preferences.confirmExit().collectAsState()
|
|
||||||
var waitingConfirmation by remember { mutableStateOf(false) }
|
|
||||||
BackHandler(enabled = !waitingConfirmation && confirmExit) {
|
|
||||||
scope.launch {
|
|
||||||
waitingConfirmation = true
|
|
||||||
val toast = toast(R.string.confirm_exit, Toast.LENGTH_LONG)
|
|
||||||
delay(2.seconds)
|
|
||||||
toast.cancel()
|
|
||||||
waitingConfirmation = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun HandleOnNewIntent(context: Context, navigator: Navigator) {
|
fun HandleOnNewIntent(context: Context, navigator: Navigator) {
|
||||||
LaunchedEffect(Unit) {
|
LaunchedEffect(Unit) {
|
||||||
|
@ -446,7 +446,7 @@ object ImageUtil {
|
|||||||
"$partCount parts @ ${optimalSplitHeight}px height per part"
|
"$partCount parts @ ${optimalSplitHeight}px height per part"
|
||||||
}
|
}
|
||||||
|
|
||||||
return mutableListOf<SplitData>().apply {
|
return buildList {
|
||||||
val range = 0 until partCount
|
val range = 0 until partCount
|
||||||
for (index in range) {
|
for (index in range) {
|
||||||
// Only continue if the list is empty or there is image remaining
|
// Only continue if the list is empty or there is image remaining
|
||||||
|
@ -206,7 +206,6 @@
|
|||||||
<string name="pref_relative_time_long">Long (Short+, n days ago)</string>
|
<string name="pref_relative_time_long">Long (Short+, n days ago)</string>
|
||||||
<string name="pref_date_format">Date format</string>
|
<string name="pref_date_format">Date format</string>
|
||||||
|
|
||||||
<string name="pref_confirm_exit">Confirm exit</string>
|
|
||||||
<string name="pref_manage_notifications">Manage notifications</string>
|
<string name="pref_manage_notifications">Manage notifications</string>
|
||||||
<string name="pref_app_language">App language</string>
|
<string name="pref_app_language">App language</string>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user