diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/MainActivity.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/MainActivity.kt index 6ef5477..72bbd4c 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/MainActivity.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/MainActivity.kt @@ -46,8 +46,6 @@ import top.fatweb.oxygen.toolbox.ui.util.LocalTimeZone import top.fatweb.oxygen.toolbox.ui.util.LocaleUtils import javax.inject.Inject -const val TAG = "MainActivity" - @OptIn(ExperimentalMaterial3WindowSizeClassApi::class) @AndroidEntryPoint class MainActivity : ComponentActivity() { @@ -153,9 +151,9 @@ private fun shouldUseDarkTheme( ): Boolean = when (uiState) { MainActivityUiState.Loading -> isSystemInDarkTheme() is MainActivityUiState.Success -> when (uiState.userData.darkThemeConfig) { - DarkThemeConfig.FOLLOW_SYSTEM -> isSystemInDarkTheme() - DarkThemeConfig.LIGHT -> false - DarkThemeConfig.DARK -> true + DarkThemeConfig.FollowSystem -> isSystemInDarkTheme() + DarkThemeConfig.Light -> false + DarkThemeConfig.Dark -> true } } @@ -165,8 +163,8 @@ private fun shouldUseAndroidTheme( ): Boolean = when (uiState) { MainActivityUiState.Loading -> false is MainActivityUiState.Success -> when (uiState.userData.themeBrandConfig) { - ThemeBrandConfig.DEFAULT -> false - ThemeBrandConfig.ANDROID -> true + ThemeBrandConfig.Default -> false + ThemeBrandConfig.Android -> true } } @@ -182,7 +180,7 @@ private fun shouldUseDynamicColor( private fun whatLocale( uiState: MainActivityUiState ): LanguageConfig = when (uiState) { - MainActivityUiState.Loading -> LanguageConfig.FOLLOW_SYSTEM + MainActivityUiState.Loading -> LanguageConfig.FollowSystem is MainActivityUiState.Success -> uiState.userData.languageConfig } @@ -190,6 +188,6 @@ private fun whatLocale( private fun whatLaunchPage( uiState: MainActivityUiState ): LaunchPageConfig = when (uiState) { - MainActivityUiState.Loading -> LaunchPageConfig.TOOLS + MainActivityUiState.Loading -> LaunchPageConfig.Tools is MainActivityUiState.Success -> uiState.userData.launchPageConfig } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/network/OxygenNetworkDataSource.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/network/OxygenNetworkDataSource.kt index 0071850..9f5ba91 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/network/OxygenNetworkDataSource.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/network/OxygenNetworkDataSource.kt @@ -17,6 +17,6 @@ interface OxygenNetworkDataSource { username: String, toolId: String, ver: String = "latest", - platform: ToolBaseVo.Platform = ToolBaseVo.Platform.ANDROID + platform: ToolBaseVo.Platform = ToolBaseVo.Platform.Android ): Flow> } \ No newline at end of file diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/OxygenPreferencesDataSource.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/OxygenPreferencesDataSource.kt index 57e7b7f..491c38a 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/OxygenPreferencesDataSource.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/data/userdata/OxygenPreferencesDataSource.kt @@ -26,23 +26,23 @@ class OxygenPreferencesDataSource @Inject constructor( LanguageConfigProto.UNRECOGNIZED, LanguageConfigProto.LANGUAGE_CONFIG_UNSPECIFIED, LanguageConfigProto.LANGUAGE_CONFIG_FOLLOW_SYSTEM - -> LanguageConfig.FOLLOW_SYSTEM + -> LanguageConfig.FollowSystem LanguageConfigProto.LANGUAGE_CONFIG_CHINESE - -> LanguageConfig.CHINESE + -> LanguageConfig.Chinese LanguageConfigProto.LANGUAGE_CONFIG_ENGLISH - -> LanguageConfig.ENGLISH + -> LanguageConfig.English }, launchPageConfig = when (it.launchPageConfig) { null, LaunchPageConfigProto.UNRECOGNIZED, LaunchPageConfigProto.LAUNCH_PAGE_CONFIG_UNSPECIFIED, LaunchPageConfigProto.LAUNCH_PAGE_CONFIG_TOOLS - -> LaunchPageConfig.TOOLS + -> LaunchPageConfig.Tools LaunchPageConfigProto.LAUNCH_PAGE_CONFIG_STAR - -> LaunchPageConfig.STAR + -> LaunchPageConfig.Star }, themeBrandConfig = when (it.themeBrandConfig) { null, @@ -50,10 +50,10 @@ class OxygenPreferencesDataSource @Inject constructor( ThemeBrandConfigProto.THEME_BRAND_CONFIG_UNSPECIFIED, ThemeBrandConfigProto.THEME_BRAND_CONFIG_DEFAULT -> - ThemeBrandConfig.DEFAULT + ThemeBrandConfig.Default ThemeBrandConfigProto.THEME_BRAND_CONFIG_ANDROID - -> ThemeBrandConfig.ANDROID + -> ThemeBrandConfig.Android }, darkThemeConfig = when (it.darkThemeConfig) { null, @@ -61,13 +61,13 @@ class OxygenPreferencesDataSource @Inject constructor( DarkThemeConfigProto.DARK_THEME_CONFIG_UNSPECIFIED, DarkThemeConfigProto.DARK_THEME_CONFIG_FOLLOW_SYSTEM -> - DarkThemeConfig.FOLLOW_SYSTEM + DarkThemeConfig.FollowSystem DarkThemeConfigProto.DARK_THEME_CONFIG_LIGHT - -> DarkThemeConfig.LIGHT + -> DarkThemeConfig.Light DarkThemeConfigProto.DARK_THEME_CONFIG_DARK - -> DarkThemeConfig.DARK + -> DarkThemeConfig.Dark }, useDynamicColor = it.useDynamicColor ) @@ -77,9 +77,9 @@ class OxygenPreferencesDataSource @Inject constructor( userPreferences.updateData { it.copy { this.languageConfig = when (languageConfig) { - LanguageConfig.FOLLOW_SYSTEM -> LanguageConfigProto.LANGUAGE_CONFIG_FOLLOW_SYSTEM - LanguageConfig.CHINESE -> LanguageConfigProto.LANGUAGE_CONFIG_CHINESE - LanguageConfig.ENGLISH -> LanguageConfigProto.LANGUAGE_CONFIG_ENGLISH + LanguageConfig.FollowSystem -> LanguageConfigProto.LANGUAGE_CONFIG_FOLLOW_SYSTEM + LanguageConfig.Chinese -> LanguageConfigProto.LANGUAGE_CONFIG_CHINESE + LanguageConfig.English -> LanguageConfigProto.LANGUAGE_CONFIG_ENGLISH } } } @@ -89,8 +89,8 @@ class OxygenPreferencesDataSource @Inject constructor( userPreferences.updateData { it.copy { this.launchPageConfig = when (launchPageConfig) { - LaunchPageConfig.TOOLS -> LaunchPageConfigProto.LAUNCH_PAGE_CONFIG_TOOLS - LaunchPageConfig.STAR -> LaunchPageConfigProto.LAUNCH_PAGE_CONFIG_STAR + LaunchPageConfig.Tools -> LaunchPageConfigProto.LAUNCH_PAGE_CONFIG_TOOLS + LaunchPageConfig.Star -> LaunchPageConfigProto.LAUNCH_PAGE_CONFIG_STAR } } } @@ -100,8 +100,8 @@ class OxygenPreferencesDataSource @Inject constructor( userPreferences.updateData { it.copy { this.themeBrandConfig = when (themeBrandConfig) { - ThemeBrandConfig.DEFAULT -> ThemeBrandConfigProto.THEME_BRAND_CONFIG_DEFAULT - ThemeBrandConfig.ANDROID -> ThemeBrandConfigProto.THEME_BRAND_CONFIG_ANDROID + ThemeBrandConfig.Default -> ThemeBrandConfigProto.THEME_BRAND_CONFIG_DEFAULT + ThemeBrandConfig.Android -> ThemeBrandConfigProto.THEME_BRAND_CONFIG_ANDROID } } } @@ -111,9 +111,9 @@ class OxygenPreferencesDataSource @Inject constructor( userPreferences.updateData { it.copy { this.darkThemeConfig = when (darkThemeConfig) { - DarkThemeConfig.FOLLOW_SYSTEM -> DarkThemeConfigProto.DARK_THEME_CONFIG_FOLLOW_SYSTEM - DarkThemeConfig.LIGHT -> DarkThemeConfigProto.DARK_THEME_CONFIG_LIGHT - DarkThemeConfig.DARK -> DarkThemeConfigProto.DARK_THEME_CONFIG_DARK + DarkThemeConfig.FollowSystem -> DarkThemeConfigProto.DARK_THEME_CONFIG_FOLLOW_SYSTEM + DarkThemeConfig.Light -> DarkThemeConfigProto.DARK_THEME_CONFIG_LIGHT + DarkThemeConfig.Dark -> DarkThemeConfigProto.DARK_THEME_CONFIG_DARK } } } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/tool/ToolEntity.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/tool/ToolEntity.kt index 87c6b38..84a292d 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/tool/ToolEntity.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/tool/ToolEntity.kt @@ -55,10 +55,10 @@ data class ToolEntity( val upgrade: String? = null ) { enum class Platform { - WEB, + Web, - DESKTOP, + Desktop, - ANDROID + Android } } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/DarkThemeConfig.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/DarkThemeConfig.kt index 666ab4d..02900b2 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/DarkThemeConfig.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/DarkThemeConfig.kt @@ -1,7 +1,7 @@ package top.fatweb.oxygen.toolbox.model.userdata enum class DarkThemeConfig { - FOLLOW_SYSTEM, - LIGHT, - DARK, + FollowSystem, + Light, + Dark, } \ No newline at end of file diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/LanguageConfig.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/LanguageConfig.kt index d3dcc53..97e3c37 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/LanguageConfig.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/LanguageConfig.kt @@ -1,7 +1,7 @@ package top.fatweb.oxygen.toolbox.model.userdata enum class LanguageConfig(val code: String? = null) { - FOLLOW_SYSTEM, - CHINESE("cn"), - ENGLISH("en") + FollowSystem, + Chinese("cn"), + English("en") } \ No newline at end of file diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/LaunchPageConfig.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/LaunchPageConfig.kt index 9ce742c..5e94ea6 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/LaunchPageConfig.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/LaunchPageConfig.kt @@ -1,6 +1,6 @@ package top.fatweb.oxygen.toolbox.model.userdata enum class LaunchPageConfig { - TOOLS, - STAR + Tools, + Star } \ No newline at end of file diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/ThemeBrandConfig.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/ThemeBrandConfig.kt index 1f5b1b9..691e9cd 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/ThemeBrandConfig.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/model/userdata/ThemeBrandConfig.kt @@ -1,6 +1,6 @@ package top.fatweb.oxygen.toolbox.model.userdata enum class ThemeBrandConfig { - DEFAULT, - ANDROID + Default, + Android } \ No newline at end of file diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/OxygenNavHost.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/OxygenNavHost.kt index 2e0b1de..cc4c3f9 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/OxygenNavHost.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/OxygenNavHost.kt @@ -34,7 +34,7 @@ fun OxygenNavHost( toolsScreen( onShowSnackbar = onShowSnackbar, onNavigateToToolView = navController::navigateToToolView, - onNavigateToToolStore = { appState.navigateToTopLevelDestination(TopLevelDestination.TOOL_STORE) } + onNavigateToToolStore = { appState.navigateToTopLevelDestination(TopLevelDestination.ToolStore) } ) toolViewScreen( onBackClick = navController::popBackStack diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/TopLevelDestination.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/TopLevelDestination.kt index 4984405..9653dd9 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/TopLevelDestination.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/navigation/TopLevelDestination.kt @@ -11,21 +11,21 @@ enum class TopLevelDestination( @StringRes val iconTextId: Int, @StringRes val titleTextId: Int ) { - TOOL_STORE( + ToolStore( selectedIcon = OxygenIcons.Store, unselectedIcon = OxygenIcons.StoreBorder, iconTextId = R.string.feature_store_title, titleTextId = R.string.feature_store_title ), - TOOLS( + Tools( selectedIcon = OxygenIcons.Home, unselectedIcon = OxygenIcons.HomeBorder, iconTextId = R.string.feature_tools_title, titleTextId = R.string.feature_tools_title ), - STAR( + Star( selectedIcon = OxygenIcons.Star, unselectedIcon = OxygenIcons.StarBorder, iconTextId = R.string.feature_star_title, diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/ToolBaseVo.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/ToolBaseVo.kt index 07d7780..358b77c 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/ToolBaseVo.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/ToolBaseVo.kt @@ -29,13 +29,16 @@ data class ToolBaseVo( @Serializable enum class Platform { @SerialName("WEB") - WEB, + Web, @SerialName("DESKTOP") - DESKTOP, + Desktop, @SerialName("ANDROID") - ANDROID + Android; + + override fun toString(): String = + javaClass.getField(name).getAnnotation(SerialName::class.java)!!.value } } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/ToolVo.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/ToolVo.kt index 17db05e..7e877f9 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/ToolVo.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/model/ToolVo.kt @@ -49,16 +49,16 @@ data class ToolVo( @Serializable enum class ReviewType { @SerialName("NONE") - NONE, + None, @SerialName("PROCESSING") - PROCESSING, + Processing, @SerialName("PASS") - PASS, + Pass, @SerialName("REJECT") - REJECT + Reject } } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/retrofit/RetrofitOxygenNetwork.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/retrofit/RetrofitOxygenNetwork.kt index 3c4b51e..5ee93f2 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/retrofit/RetrofitOxygenNetwork.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/network/retrofit/RetrofitOxygenNetwork.kt @@ -25,7 +25,7 @@ private interface RetrofitOxygenNetworkApi { suspend fun getStore( @Query("currentPage") currentPage: Int, @Query("searchValue") searchValue: String, - @Query("platform") platform: ToolBaseVo.Platform? = ToolBaseVo.Platform.ANDROID + @Query("platform") platform: ToolBaseVo.Platform? = ToolBaseVo.Platform.Android ): ResponseResult> @GET(value = "/tool/detail/{username}/{toolId}/{ver}") @@ -33,7 +33,7 @@ private interface RetrofitOxygenNetworkApi { @Path("username") username: String, @Path("toolId") toolId: String, @Path("ver") ver: String, - @Query("platform") platform: String + @Query("platform") platform: ToolBaseVo.Platform? = ToolBaseVo.Platform.Android ): ResponseResult } @@ -69,7 +69,7 @@ internal class RetrofitOxygenNetwork @Inject constructor( username = username, toolId = toolId, ver = ver, - platform = platform.name + platform = platform ) ) }.asResult() diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/StoreRepository.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/StoreRepository.kt index c50169d..e79af2c 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/StoreRepository.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/StoreRepository.kt @@ -11,7 +11,6 @@ interface StoreRepository { fun detail( username: String, toolId: String, - ver: String = "latest", - platform: ToolEntity.Platform = ToolEntity.Platform.ANDROID + ver: String = "latest" ): Flow> } \ No newline at end of file diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/impl/NetworkStoreRepository.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/impl/NetworkStoreRepository.kt index e8296a1..0b4d14a 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/impl/NetworkStoreRepository.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/repository/tool/impl/NetworkStoreRepository.kt @@ -10,7 +10,6 @@ import top.fatweb.oxygen.toolbox.data.tool.dao.ToolDao import top.fatweb.oxygen.toolbox.model.Result import top.fatweb.oxygen.toolbox.model.asExternalModel import top.fatweb.oxygen.toolbox.model.tool.ToolEntity -import top.fatweb.oxygen.toolbox.network.model.ToolBaseVo import top.fatweb.oxygen.toolbox.network.model.ToolVo import top.fatweb.oxygen.toolbox.network.model.asExternalModel import top.fatweb.oxygen.toolbox.network.paging.ToolStorePagingSource @@ -42,14 +41,12 @@ internal class NetworkStoreRepository @Inject constructor( override fun detail( username: String, toolId: String, - ver: String, - platform: ToolEntity.Platform + ver: String ): Flow> = oxygenNetworkDataSource.detail( username, toolId, - ver, - ToolBaseVo.Platform.valueOf(platform.name) + ver ).map { it.asExternalModel(ToolVo::asExternalModel) } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt index 014a431..6a4cbd5 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenApp.kt @@ -60,7 +60,7 @@ import top.fatweb.oxygen.toolbox.ui.theme.LocalGradientColors @Composable fun OxygenApp(appState: OxygenAppState) { val shouldShowGradientBackground = - appState.currentTopLevelDestination == TopLevelDestination.TOOLS + appState.currentTopLevelDestination == TopLevelDestination.Tools var showSettingsDialog by rememberSaveable { mutableStateOf(false) } @@ -171,8 +171,8 @@ fun OxygenApp(appState: OxygenAppState) { ) == SnackbarResult.ActionPerformed }, startDestination = when (appState.launchPageConfig) { - LaunchPageConfig.TOOLS -> TOOLS_ROUTE - LaunchPageConfig.STAR -> STAR_ROUTE + LaunchPageConfig.Tools -> TOOLS_ROUTE + LaunchPageConfig.Star -> STAR_ROUTE } ) } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenAppState.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenAppState.kt index 1548e57..ce92dc4 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenAppState.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/OxygenAppState.kt @@ -75,9 +75,9 @@ class OxygenAppState( val currentTopLevelDestination: TopLevelDestination? @Composable get() = when (currentDestination?.route) { - TOOL_STORE_ROUTE -> TopLevelDestination.TOOL_STORE - TOOLS_ROUTE -> TopLevelDestination.TOOLS - STAR_ROUTE -> TopLevelDestination.STAR + TOOL_STORE_ROUTE -> TopLevelDestination.ToolStore + TOOLS_ROUTE -> TopLevelDestination.Tools + STAR_ROUTE -> TopLevelDestination.Star else -> null } @@ -113,9 +113,9 @@ class OxygenAppState( } when (topLevelDestination) { - TopLevelDestination.TOOL_STORE -> navController.navigateToToolStore(topLevelNavOptions) - TopLevelDestination.TOOLS -> navController.navigateToTools(topLevelNavOptions) - TopLevelDestination.STAR -> navController.navigateToStar(topLevelNavOptions) + TopLevelDestination.ToolStore -> navController.navigateToToolStore(topLevelNavOptions) + TopLevelDestination.Tools -> navController.navigateToTools(topLevelNavOptions) + TopLevelDestination.Star -> navController.navigateToStar(topLevelNavOptions) } } diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/settings/SettingsDialog.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/settings/SettingsDialog.kt index cb0df19..593c9a5 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/settings/SettingsDialog.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/settings/SettingsDialog.kt @@ -175,47 +175,47 @@ private fun ColumnScope.SettingsPanel( DialogSectionGroup { DialogChooserRow( text = stringResource(R.string.feature_settings_language_system_default), - selected = settings.languageConfig == LanguageConfig.FOLLOW_SYSTEM, - onClick = { onChangeLanguageConfig(LanguageConfig.FOLLOW_SYSTEM) } + selected = settings.languageConfig == LanguageConfig.FollowSystem, + onClick = { onChangeLanguageConfig(LanguageConfig.FollowSystem) } ) DialogChooserRow( text = stringResource(R.string.feature_settings_language_chinese), - selected = settings.languageConfig == LanguageConfig.CHINESE, - onClick = { onChangeLanguageConfig(LanguageConfig.CHINESE) } + selected = settings.languageConfig == LanguageConfig.Chinese, + onClick = { onChangeLanguageConfig(LanguageConfig.Chinese) } ) DialogChooserRow( text = stringResource(R.string.feature_settings_language_english), - selected = settings.languageConfig == LanguageConfig.ENGLISH, - onClick = { onChangeLanguageConfig(LanguageConfig.ENGLISH) } + selected = settings.languageConfig == LanguageConfig.English, + onClick = { onChangeLanguageConfig(LanguageConfig.English) } ) } DialogSectionTitle(text = stringResource(R.string.feature_settings_launch_page)) DialogSectionGroup { DialogChooserRow( text = stringResource(R.string.feature_settings_launch_page_tools), - selected = settings.launchPageConfig == LaunchPageConfig.TOOLS, - onClick = { onChangeLaunchPageConfig(LaunchPageConfig.TOOLS) } + selected = settings.launchPageConfig == LaunchPageConfig.Tools, + onClick = { onChangeLaunchPageConfig(LaunchPageConfig.Tools) } ) DialogChooserRow( text = stringResource(R.string.feature_settings_launch_page_star), - selected = settings.launchPageConfig == LaunchPageConfig.STAR, - onClick = { onChangeLaunchPageConfig(LaunchPageConfig.STAR) } + selected = settings.launchPageConfig == LaunchPageConfig.Star, + onClick = { onChangeLaunchPageConfig(LaunchPageConfig.Star) } ) } DialogSectionTitle(text = stringResource(R.string.feature_settings_theme_brand)) DialogSectionGroup { DialogChooserRow( text = stringResource(R.string.feature_settings_theme_brand_default), - selected = settings.themeBrandConfig == ThemeBrandConfig.DEFAULT, - onClick = { onchangeThemeBrandConfig(ThemeBrandConfig.DEFAULT) } + selected = settings.themeBrandConfig == ThemeBrandConfig.Default, + onClick = { onchangeThemeBrandConfig(ThemeBrandConfig.Default) } ) DialogChooserRow( text = stringResource(R.string.feature_settings_theme_brand_android), - selected = settings.themeBrandConfig == ThemeBrandConfig.ANDROID, - onClick = { onchangeThemeBrandConfig(ThemeBrandConfig.ANDROID) } + selected = settings.themeBrandConfig == ThemeBrandConfig.Android, + onClick = { onchangeThemeBrandConfig(ThemeBrandConfig.Android) } ) } - AnimatedVisibility(visible = settings.themeBrandConfig == ThemeBrandConfig.DEFAULT && supportDynamicColor) { + AnimatedVisibility(visible = settings.themeBrandConfig == ThemeBrandConfig.Default && supportDynamicColor) { DialogSectionGroup { DialogSectionTitle(text = stringResource(R.string.feature_settings_dynamic_color)) DialogChooserRow( @@ -234,18 +234,18 @@ private fun ColumnScope.SettingsPanel( DialogSectionGroup { DialogChooserRow( text = stringResource(R.string.feature_settings_dark_mode_system_default), - selected = settings.darkThemeConfig == DarkThemeConfig.FOLLOW_SYSTEM, - onClick = { onChangeDarkThemeConfig(DarkThemeConfig.FOLLOW_SYSTEM) } + selected = settings.darkThemeConfig == DarkThemeConfig.FollowSystem, + onClick = { onChangeDarkThemeConfig(DarkThemeConfig.FollowSystem) } ) DialogChooserRow( text = stringResource(R.string.feature_settings_dark_mode_light), - selected = settings.darkThemeConfig == DarkThemeConfig.LIGHT, - onClick = { onChangeDarkThemeConfig(DarkThemeConfig.LIGHT) } + selected = settings.darkThemeConfig == DarkThemeConfig.Light, + onClick = { onChangeDarkThemeConfig(DarkThemeConfig.Light) } ) DialogChooserRow( text = stringResource(R.string.feature_settings_dark_mode_dark), - selected = settings.darkThemeConfig == DarkThemeConfig.DARK, - onClick = { onChangeDarkThemeConfig(DarkThemeConfig.DARK) } + selected = settings.darkThemeConfig == DarkThemeConfig.Dark, + onClick = { onChangeDarkThemeConfig(DarkThemeConfig.Dark) } ) } DialogSectionTitle(text = stringResource(R.string.feature_settings_more)) @@ -296,10 +296,10 @@ private fun SettingDialogPreview() { onDismiss = {}, settingsUiState = SettingsUiState.Success( UserData( - languageConfig = LanguageConfig.FOLLOW_SYSTEM, - launchPageConfig = LaunchPageConfig.TOOLS, - themeBrandConfig = ThemeBrandConfig.DEFAULT, - darkThemeConfig = DarkThemeConfig.FOLLOW_SYSTEM, + languageConfig = LanguageConfig.FollowSystem, + launchPageConfig = LaunchPageConfig.Tools, + themeBrandConfig = ThemeBrandConfig.Default, + darkThemeConfig = DarkThemeConfig.FollowSystem, useDynamicColor = true ) ), diff --git a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/util/LocaleUtils.kt b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/util/LocaleUtils.kt index 7f51b79..f2adc61 100644 --- a/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/util/LocaleUtils.kt +++ b/app/src/main/kotlin/top/fatweb/oxygen/toolbox/ui/util/LocaleUtils.kt @@ -11,9 +11,9 @@ import java.util.Locale object LocaleUtils { fun switchLocale(activity: Activity, languageConfig: LanguageConfig) { val newLanguage = when (languageConfig) { - LanguageConfig.FOLLOW_SYSTEM -> ResourcesUtils.getSystemLocale().get(0)!!.language - LanguageConfig.CHINESE -> "zh" - LanguageConfig.ENGLISH -> "en" + LanguageConfig.FollowSystem -> ResourcesUtils.getSystemLocale().get(0)!!.language + LanguageConfig.Chinese -> "zh" + LanguageConfig.English -> "en" } val currentLanguage = ResourcesUtils.getAppLocale(activity).language if (newLanguage != currentLanguage) { @@ -33,9 +33,9 @@ object LocaleUtils { private fun getLocaleFromLanguageConfig(languageConfig: LanguageConfig): Locale = when (languageConfig) { - LanguageConfig.FOLLOW_SYSTEM -> ResourcesUtils.getSystemLocale().get(0)!! - LanguageConfig.CHINESE -> Locale("zh") - LanguageConfig.ENGLISH -> Locale("en") + LanguageConfig.FollowSystem -> ResourcesUtils.getSystemLocale().get(0)!! + LanguageConfig.Chinese -> Locale("zh") + LanguageConfig.English -> Locale("en") } @RequiresApi(Build.VERSION_CODES.N)