Fix window undimming when reader custom filter settings are open

This commit is contained in:
arkon 2023-07-15 13:23:25 -04:00
parent e0733c1a4c
commit 5467104b95
3 changed files with 19 additions and 20 deletions

View File

@ -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)

View File

@ -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

View File

@ -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()
}