From 5467104b955fc854285f22f9be56083a1d503144 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 15 Jul 2023 13:23:25 -0400 Subject: [PATCH] Fix window undimming when reader custom filter settings are open --- .../reader/settings/ReaderSettingsDialog.kt | 25 +++++++++---------- .../kanade/tachiyomi/ui/main/MainActivity.kt | 8 +++--- .../kanade/tachiyomi/network/NetworkHelper.kt | 6 ++--- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/reader/settings/ReaderSettingsDialog.kt b/app/src/main/java/eu/kanade/presentation/reader/settings/ReaderSettingsDialog.kt index 44f1bc27f..cf5b08997 100644 --- a/app/src/main/java/eu/kanade/presentation/reader/settings/ReaderSettingsDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/reader/settings/ReaderSettingsDialog.kt @@ -23,9 +23,6 @@ fun ReaderSettingsDialog( onHideMenus: () -> Unit, screenModel: ReaderSettingsScreenModel, ) { - // TODO: undimming doesn't seem to work - val window = (LocalView.current.parent as? DialogWindowProvider)?.window - val tabTitles = listOf( stringResource(R.string.pref_category_reading_mode), stringResource(R.string.pref_category_general), @@ -33,16 +30,6 @@ fun ReaderSettingsDialog( ) val pagerState = rememberPagerState { tabTitles.size } - LaunchedEffect(pagerState.currentPage) { - if (pagerState.currentPage == 2) { - window?.setDimAmount(0f) - onHideMenus() - } else { - window?.setDimAmount(0.75f) - onShowMenus() - } - } - TabbedDialog( onDismissRequest = { onDismissRequest() @@ -51,6 +38,18 @@ fun ReaderSettingsDialog( tabTitles = tabTitles, pagerState = pagerState, ) { page -> + val window = (LocalView.current.parent as? DialogWindowProvider)?.window + + LaunchedEffect(pagerState.currentPage) { + if (pagerState.currentPage == 2) { + window?.setDimAmount(0f) + onHideMenus() + } else { + window?.setDimAmount(0.5f) + onShowMenus() + } + } + Column( modifier = Modifier .padding(vertical = TabbedDialogPaddings.Vertical) 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 4612eec34..9fd4674fe 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 @@ -113,6 +113,10 @@ class MainActivity : BaseActivity() { private var navigator: Navigator? = null + init { + registerSecureActivity(this) + } + override fun onCreate(savedInstanceState: Bundle?) { val isLaunch = savedInstanceState == null @@ -429,10 +433,6 @@ class MainActivity : BaseActivity() { return true } - init { - registerSecureActivity(this) - } - companion object { // Splash screen private const val SPLASH_MIN_DURATION = 500 // ms diff --git a/core/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt b/core/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt index 8af3d45be..38ba749d2 100644 --- a/core/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt +++ b/core/src/main/java/eu/kanade/tachiyomi/network/NetworkHelper.kt @@ -15,9 +15,9 @@ class NetworkHelper( private val preferences: NetworkPreferences, ) { - val cookieJar by lazy { AndroidCookieJar() } + val cookieJar = AndroidCookieJar() - val client by lazy { + val client: OkHttpClient = run { val builder = OkHttpClient.Builder() .cookieJar(cookieJar) .connectTimeout(30, TimeUnit.SECONDS) @@ -64,7 +64,7 @@ class NetworkHelper( */ @Deprecated("The regular client handles Cloudflare by default") @Suppress("UNUSED") - val cloudflareClient by lazy { client } + val cloudflareClient: OkHttpClient = client fun defaultUserAgentProvider() = preferences.defaultUserAgent().get().trim() }