Skip to content

Commit

Permalink
Implement Language Schema Support for Supported Languages
Browse files Browse the repository at this point in the history
  • Loading branch information
teogor committed Nov 2, 2023
1 parent 743aafd commit ad02c59
Show file tree
Hide file tree
Showing 54 changed files with 2,404 additions and 159 deletions.
29 changes: 29 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*/
import dev.teogor.ceres.CeresBuildType
import dev.teogor.ceres.Version
import dev.teogor.linguistic.Country
import dev.teogor.linguistic.Language
import dev.teogor.linguistic.territorialize

plugins {
id("dev.teogor.ceres.android.application")
Expand All @@ -24,13 +27,38 @@ plugins {
id("dev.teogor.ceres.android.library.config")
id("dev.teogor.ceres.android.hilt")
id("dev.teogor.ceres.android.room")
id("dev.teogor.querent.plugin")
id("kotlinx-serialization")
id("jacoco")

// Feature :: About
alias(libs.plugins.about.libraries) apply true
}

querenet {
buildFeatures {
buildProfile = true
xmlResources = true
languagesSchema = true
}

languagesSchemaOptions {
unqualifiedResLocale = Language.English territorialize Country.UnitedStates
addSupportedLanguages {
+(Language.Romanian territorialize Country.Romania)
+(Language.English territorialize Country.UnitedKingdom)
+(Language.Korean territorialize Country.SouthKorea)
+(Language.Dutch territorialize Country.Netherlands)
+(Language.German territorialize Country.Germany)
+(Language.Chinese territorialize Country.China)
+Language.Japanese
+Language.Spanish
+Language.Hindi
+Language.Arabic
}
}
}

roomOptions {
enableSchemaProvider = true
}
Expand Down Expand Up @@ -105,6 +133,7 @@ dependencies {
implementation(project(":screen:core"))

// default screens
// TODO split into locale and ui
implementation(project(":screen:ui"))

// theme config
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Ceres.Splash"
tools:targetApi="31">
android:localeConfig="@xml/locale_config"
tools:targetApi="33">
<profileable android:shell="true" tools:targetApi="q" />

<meta-data
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/kotlin/dev/teogor/ceres/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@ package dev.teogor.ceres

import dagger.hilt.android.HiltAndroidApp
import dev.teogor.ceres.ads.ApplicationOpenAd
import dev.teogor.ceres.build.BuildProfile
import dev.teogor.ceres.core.register.LocalBuildProfiler
import dev.teogor.ceres.core.register.LocalSupportedDialects
import dev.teogor.ceres.core.register.RegistryStartup
import dev.teogor.ceres.framework.core.Application
import dev.teogor.ceres.framework.core.model.ThemeBuilder
import dev.teogor.ceres.lang.SupportedDialects
import dev.teogor.ceres.monetisation.admob.AdMob
import dev.teogor.ceres.monetisation.ads.extensions.setForChildrenApp
import dev.teogor.ceres.monetisation.ads.extensions.setForEveryoneApp
Expand Down Expand Up @@ -51,6 +56,11 @@ class Application : Application() {
override fun onCreate() {
super.onCreate()

RegistryStartup.provides(
LocalBuildProfiler provide BuildProfile,
LocalSupportedDialects provide SupportedDialects(),
)

AdMob.configureAdRequest {
maxAdContentRating = AdContentRating.UNSPECIFIED
tagForChildDirectedTreatment = TagForChildDirectedTreatment.UNSPECIFIED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import dev.teogor.ceres.screen.ui.about.aboutMadeIn
import dev.teogor.ceres.screen.ui.about.aboutOpenAppInfo
import dev.teogor.ceres.screen.ui.about.aboutOpenSourceLicenses
import java.time.LocalDateTime
import dev.teogor.ceres.screen.ui.res.Resources

@Composable
internal fun AboutRoute(
Expand Down Expand Up @@ -106,14 +107,14 @@ private fun AboutLayout() = LazyColumnLayoutBase(
BuildConfig.BUILD_DATE_TIME.toLong(),
0,
AppMetadataManager.zoneOffset,
)
),
)

aboutHeaderAboutUs()

developerInfo()

aboutMadeIn()
aboutMadeIn("Brasov, Romania")

aboutHeaderSecurityPatch()

Expand All @@ -132,7 +133,7 @@ private fun AboutLayout() = LazyColumnLayoutBase(

private fun ScreenListScope.developerInfo() = item {
SimpleView(
title = "Developer",
title = Resources.Developer,
subtitle = "Teodor Grigor",
icon = Icons.Default.Business,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ import dev.teogor.ceres.screen.ui.lookandfeel.lookAndFeelDynamicTheming
import dev.teogor.ceres.screen.ui.lookandfeel.lookAndFeelHeaderAppearance
import dev.teogor.ceres.screen.ui.lookandfeel.lookAndFeelHeaderFeedback
import dev.teogor.ceres.screen.ui.lookandfeel.lookAndFeelJustBlack
import dev.teogor.ceres.screen.ui.lookandfeel.lookAndFeelLanguage
import dev.teogor.ceres.screen.ui.lookandfeel.lookAndFeelSoundFeedback
import dev.teogor.ceres.screen.ui.lookandfeel.lookAndFeelVibrationFeedback
import dev.teogor.ceres.screen.ui.res.Resources

@Composable
internal fun LookAndFeelRoute(
baseActions: BaseActions,
) {
val title = Resources.LookAndFeel

baseActions.setScreenInfo {
showNavBar {
false
Expand All @@ -52,7 +56,7 @@ internal fun LookAndFeelRoute(
}
toolbarTokens {
toolbarTitle {
"Look & Feel"
title
}
showSettingsButton {
false
Expand All @@ -78,6 +82,8 @@ private fun LookAndFeelLayout() = LazyColumnLayoutBase(
) {
lookAndFeelHeaderAppearance()

lookAndFeelLanguage()

lookAndFeelAppTheme()

lookAndFeelDynamicTheming()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ import dev.teogor.ceres.screen.ui.privacy.privacyResetOnboarding
import dev.teogor.ceres.screen.ui.privacy.privacyUserId
import dev.teogor.ceres.screen.ui.privacy.resetAdsConsentOption
import dev.teogor.ceres.screen.ui.privacy.termsOfServiceOption
import dev.teogor.ceres.screen.ui.res.Resources

@Composable
internal fun PrivacyOptionsRoute(
baseActions: BaseActions,
) {
val title = Resources.PrivacyOptions

baseActions.setScreenInfo {
showNavBar {
false
Expand All @@ -53,7 +56,7 @@ internal fun PrivacyOptionsRoute(
}
toolbarTokens {
toolbarTitle {
"Privacy Options"
title
}
showSettingsButton {
false
Expand Down Expand Up @@ -95,5 +98,5 @@ private fun PrivacyOptionsLayout() = LazyColumnLayoutBase(

// policyRefundPolicy()

policyAppLicensePolicy()
policyAppLicensePolicy(license = 0)
}
36 changes: 31 additions & 5 deletions app/src/main/kotlin/dev/teogor/ceres/menu/Menu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ import androidx.compose.material.icons.outlined.Settings
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import dev.teogor.ceres.core.foundation.DefaultResources
import dev.teogor.ceres.core.foundation.ui.platform.LocalApplicationDetails
import dev.teogor.ceres.core.startup.ApplicationContextProvider.context
import dev.teogor.ceres.framework.core.menu.MenuTitle
import dev.teogor.ceres.framework.core.menu.menu
import dev.teogor.ceres.framework.core.menu.menuContent
Expand All @@ -39,9 +41,30 @@ import dev.teogor.ceres.framework.core.model.MenuConfig
import dev.teogor.ceres.navigation.core.LocalNavigationParameters
import dev.teogor.ceres.navigation.core.ScreenRoute
import dev.teogor.ceres.screen.ui.about.AboutScreenRoute
import dev.teogor.ceres.screen.ui.res.ResourceKey
import dev.teogor.ceres.screen.ui.res.ResourceType
import dev.teogor.ceres.screen.ui.res.Resources
import dev.teogor.ceres.screen.ui.settings.SettingsScreenRoute
import dev.teogor.ceres.screen.ui.userprefs.UserPreferencesScreenRoute

inline fun <reified Type> ResourceKey.asRes(quantity: Int = 0, vararg args: Any): Type =
when (type) {
ResourceType.Array -> {
DefaultResources(resources = context.resources)
.getStringArray(id) as Type
}

ResourceType.Plurals -> {
DefaultResources(resources = context.resources)
.getQuantityString(id, quantity, *args) as Type
}

ResourceType.String -> {
DefaultResources(resources = context.resources)
.getString(id, *args) as Type
}
}

/**
* Applies the menu configuration to this [MenuConfig].
*
Expand All @@ -57,6 +80,9 @@ fun MenuConfig.applyMenuConfig() = apply {
navigationParameters.screenRoute = this
}

val resSettingsTitle = Resources.Settings
val resHelpAndFeedback = Resources.HelpAndFeedback

// Set the header content
headerContent = {
MenuTitle(
Expand Down Expand Up @@ -94,30 +120,30 @@ fun MenuConfig.applyMenuConfig() = apply {

menuContent {
menuItem(
content = "Settings",
content = ResourceKey.SETTINGS.asRes(),
icon = Icons.Outlined.Settings,
clickable = {
SettingsScreenRoute.navigateTo()
},
)

menuItem(
content = "Help and feedback",
content = ResourceKey.HELP_AND_FEEDBACK.asRes(),
icon = Icons.Outlined.HelpOutline,
)

menuItem(
content = "Privacy Policy",
content = ResourceKey.PRIVACY_POLICY.asRes(),
icon = Icons.Outlined.Link,
)

menuItem(
content = "Terms of service",
content = ResourceKey.TERMS_OF_SERVICE.asRes(),
icon = Icons.Outlined.Link,
)

menuItem(
content = "About",
content = ResourceKey.ABOUT.asRes(),
icon = Icons.Outlined.Details,
clickable = {
AboutScreenRoute.navigateTo()
Expand Down
1 change: 1 addition & 0 deletions core/register/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
Loading

0 comments on commit ad02c59

Please sign in to comment.