|
@@ -3,8 +3,6 @@ package io.legado.app.ui.config.themeConfig
|
|
|
import android.annotation.SuppressLint
|
|
import android.annotation.SuppressLint
|
|
|
import android.content.Context
|
|
import android.content.Context
|
|
|
import android.content.Intent
|
|
import android.content.Intent
|
|
|
-import android.os.Handler
|
|
|
|
|
-import android.os.Looper
|
|
|
|
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
|
import androidx.activity.compose.rememberLauncherForActivityResult
|
|
|
import androidx.activity.result.contract.ActivityResultContracts
|
|
import androidx.activity.result.contract.ActivityResultContracts
|
|
|
import androidx.compose.animation.AnimatedVisibility
|
|
import androidx.compose.animation.AnimatedVisibility
|
|
@@ -85,7 +83,6 @@ import io.legado.app.ui.widget.components.AppScaffold
|
|
|
import io.legado.app.ui.widget.components.FontFolderState
|
|
import io.legado.app.ui.widget.components.FontFolderState
|
|
|
import io.legado.app.ui.widget.components.FontSelectSheet
|
|
import io.legado.app.ui.widget.components.FontSelectSheet
|
|
|
import io.legado.app.ui.widget.components.SplicedColumnGroup
|
|
import io.legado.app.ui.widget.components.SplicedColumnGroup
|
|
|
-import io.legado.app.ui.widget.components.alert.AppAlertDialog
|
|
|
|
|
import io.legado.app.ui.widget.components.button.series.SmallPlainButton
|
|
import io.legado.app.ui.widget.components.button.series.SmallPlainButton
|
|
|
import io.legado.app.ui.widget.components.card.GlassCard
|
|
import io.legado.app.ui.widget.components.card.GlassCard
|
|
|
import io.legado.app.ui.widget.components.dialog.ColorPickerSheet
|
|
import io.legado.app.ui.widget.components.dialog.ColorPickerSheet
|
|
@@ -99,7 +96,6 @@ import io.legado.app.ui.widget.components.topbar.GlassMediumFlexibleTopAppBar
|
|
|
import io.legado.app.ui.widget.components.topbar.GlassTopAppBarDefaults
|
|
import io.legado.app.ui.widget.components.topbar.GlassTopAppBarDefaults
|
|
|
import io.legado.app.ui.widget.components.topbar.TopBarNavigationButton
|
|
import io.legado.app.ui.widget.components.topbar.TopBarNavigationButton
|
|
|
import io.legado.app.utils.postEvent
|
|
import io.legado.app.utils.postEvent
|
|
|
-import io.legado.app.utils.restart
|
|
|
|
|
import io.legado.app.utils.takePersistablePermissionSafely
|
|
import io.legado.app.utils.takePersistablePermissionSafely
|
|
|
import io.legado.app.utils.toastOnUi
|
|
import io.legado.app.utils.toastOnUi
|
|
|
import org.koin.androidx.compose.koinViewModel
|
|
import org.koin.androidx.compose.koinViewModel
|
|
@@ -119,7 +115,6 @@ fun ThemeConfigScreen(
|
|
|
var selectedThemeMode by remember { mutableStateOf(ThemeConfig.themeMode) }
|
|
var selectedThemeMode by remember { mutableStateOf(ThemeConfig.themeMode) }
|
|
|
var selectedTheme by remember { mutableStateOf(ThemeConfig.appTheme) }
|
|
var selectedTheme by remember { mutableStateOf(ThemeConfig.appTheme) }
|
|
|
var useMiuixMonet by remember { mutableStateOf(ThemeConfig.useMiuixMonet) }
|
|
var useMiuixMonet by remember { mutableStateOf(ThemeConfig.useMiuixMonet) }
|
|
|
- var showRestartDialog by remember { mutableStateOf(false) }
|
|
|
|
|
var showLauncherIconPicker by remember { mutableStateOf(false) }
|
|
var showLauncherIconPicker by remember { mutableStateOf(false) }
|
|
|
var showBorderColorPicker by remember { mutableStateOf(false) }
|
|
var showBorderColorPicker by remember { mutableStateOf(false) }
|
|
|
var showNavIconSheet by remember { mutableStateOf(false) }
|
|
var showNavIconSheet by remember { mutableStateOf(false) }
|
|
@@ -268,7 +263,7 @@ fun ThemeConfigScreen(
|
|
|
selectedTheme = newTheme
|
|
selectedTheme = newTheme
|
|
|
ThemeConfig.appTheme = newTheme
|
|
ThemeConfig.appTheme = newTheme
|
|
|
if (oldTheme != newTheme) {
|
|
if (oldTheme != newTheme) {
|
|
|
- showRestartDialog = true
|
|
|
|
|
|
|
+ postEvent(EventBus.RECREATE, "")
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
@@ -310,15 +305,9 @@ fun ThemeConfigScreen(
|
|
|
ThemeConfig.containerOpacity = 0
|
|
ThemeConfig.containerOpacity = 0
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- val oldTheme = selectedTheme
|
|
|
|
|
selectedTheme = theme
|
|
selectedTheme = theme
|
|
|
ThemeConfig.appTheme = theme
|
|
ThemeConfig.appTheme = theme
|
|
|
- val isDynamicSwitch = (oldTheme == "12" || theme == "12")
|
|
|
|
|
- if (isDynamicSwitch) {
|
|
|
|
|
- showRestartDialog = true
|
|
|
|
|
- } else {
|
|
|
|
|
- postEvent(EventBus.RECREATE, "")
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ postEvent(EventBus.RECREATE, "")
|
|
|
}
|
|
}
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|
|
@@ -819,25 +808,6 @@ fun ThemeConfigScreen(
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- AppAlertDialog(
|
|
|
|
|
- show = showRestartDialog,
|
|
|
|
|
- onDismissRequest = { showRestartDialog = false },
|
|
|
|
|
- title = stringResource(R.string.restart_required_message),
|
|
|
|
|
- onConfirm = {
|
|
|
|
|
- showRestartDialog = false
|
|
|
|
|
- Handler(Looper.getMainLooper()).postDelayed({
|
|
|
|
|
- context.restart()
|
|
|
|
|
- }, 100)
|
|
|
|
|
- },
|
|
|
|
|
- confirmText = stringResource(R.string.ok),
|
|
|
|
|
- onDismiss = {
|
|
|
|
|
- showRestartDialog = false
|
|
|
|
|
- context.toastOnUi(R.string.restart_later_message)
|
|
|
|
|
- },
|
|
|
|
|
- dismissText = stringResource(R.string.cancel)
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
BackgroundImageManageSheet(
|
|
BackgroundImageManageSheet(
|
|
|
isDarkTheme = manageKey,
|
|
isDarkTheme = manageKey,
|
|
|
onDismissRequest = { manageKey = null }
|
|
onDismissRequest = { manageKey = null }
|