From 8f4bc71cf7b99fe0b0d2ea68dfca0140477686cc Mon Sep 17 00:00:00 2001 From: arkon Date: Wed, 31 May 2023 18:51:01 -0400 Subject: [PATCH] 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. --- .../eu/kanade/domain/base/BasePreferences.kt | 2 -- .../settings/screen/SettingsGeneralScreen.kt | 19 +++++--------- .../kanade/tachiyomi/ui/main/MainActivity.kt | 26 ------------------- .../tachiyomi/core/util/system/ImageUtil.kt | 2 +- i18n/src/main/res/values/strings.xml | 1 - 5 files changed, 7 insertions(+), 43 deletions(-) diff --git a/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt b/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt index b7e0e47ce..ba3cebc86 100644 --- a/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt +++ b/app/src/main/java/eu/kanade/domain/base/BasePreferences.kt @@ -11,8 +11,6 @@ class BasePreferences( private val preferenceStore: PreferenceStore, ) { - fun confirmExit() = preferenceStore.getBoolean("pref_confirm_exit", false) - fun downloadedOnly() = preferenceStore.getBoolean("pref_downloaded_only", false) fun incognitoMode() = preferenceStore.getBoolean("incognito_mode", false) diff --git a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsGeneralScreen.kt b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsGeneralScreen.kt index 1feac3156..c609b3626 100644 --- a/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsGeneralScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/more/settings/screen/SettingsGeneralScreen.kt @@ -16,7 +16,6 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.core.os.LocaleListCompat -import eu.kanade.domain.base.BasePreferences import eu.kanade.presentation.more.settings.Preference import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.util.system.LocaleHelper @@ -34,9 +33,13 @@ object SettingsGeneralScreen : SearchableSettings { @Composable override fun getPreferences(): List { - val prefs = remember { Injekt.get() } val libraryPrefs = remember { Injekt.get() } - return mutableListOf().apply { + val context = LocalContext.current + + val langs = remember { getLangs(context) } + var currentLanguage by remember { mutableStateOf(AppCompatDelegate.getApplicationLocales().get(0)?.toLanguageTag() ?: "") } + + return buildList { add( Preference.PreferenceItem.SwitchPreference( pref = libraryPrefs.newShowUpdatesCount(), @@ -44,14 +47,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) { add( Preference.PreferenceItem.TextPreference( @@ -66,8 +61,6 @@ object SettingsGeneralScreen : SearchableSettings { ) } - val langs = remember { getLangs(context) } - var currentLanguage by remember { mutableStateOf(AppCompatDelegate.getApplicationLocales().get(0)?.toLanguageTag() ?: "") } add( Preference.PreferenceItem.BasicListPreference( value = currentLanguage, diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index be1652bd5..92ea5e945 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -9,9 +9,7 @@ import android.graphics.Color import android.os.Build import android.os.Bundle import android.view.View -import android.widget.Toast import androidx.activity.ComponentActivity -import androidx.activity.compose.BackHandler import androidx.compose.foundation.isSystemInDarkTheme import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.WindowInsets @@ -32,7 +30,6 @@ import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember -import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.luminance @@ -80,10 +77,8 @@ import eu.kanade.tachiyomi.ui.more.NewUpdateScreen import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.isNavigationBarNeedsScrim import eu.kanade.tachiyomi.util.system.openInBrowser -import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.view.setComposeContent import kotlinx.coroutines.channels.awaitClose -import kotlinx.coroutines.delay import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.drop @@ -100,7 +95,6 @@ import tachiyomi.presentation.core.components.material.Scaffold import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get import uy.kohesive.injekt.injectLazy -import kotlin.time.Duration.Companion.seconds import androidx.compose.ui.graphics.Color.Companion as ComposeColor class MainActivity : BaseActivity() { @@ -192,10 +186,6 @@ class MainActivity : BaseActivity() { screen = HomeScreen, disposeBehavior = NavigatorDisposeBehavior(disposeNestedNavigators = false, disposeSteps = true), ) { navigator -> - if (navigator.size == 1) { - ConfirmExit() - } - LaunchedEffect(navigator) { this@MainActivity.navigator = navigator @@ -288,22 +278,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 fun HandleOnNewIntent(context: Context, navigator: Navigator) { LaunchedEffect(Unit) { diff --git a/core/src/main/java/tachiyomi/core/util/system/ImageUtil.kt b/core/src/main/java/tachiyomi/core/util/system/ImageUtil.kt index 911673fd2..786d44423 100644 --- a/core/src/main/java/tachiyomi/core/util/system/ImageUtil.kt +++ b/core/src/main/java/tachiyomi/core/util/system/ImageUtil.kt @@ -329,7 +329,7 @@ object ImageUtil { "$partCount parts @ ${optimalSplitHeight}px height per part" } - return mutableListOf().apply { + return buildList { val range = 0 until partCount for (index in range) { // Only continue if the list is empty or there is image remaining diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index 774f34072..ddeab2a1c 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -206,7 +206,6 @@ Long (Short+, n days ago) Date format - Confirm exit Manage notifications App language