diff --git a/app/src/main/java/space/celestia/mobilecelestia/MainActivity.kt b/app/src/main/java/space/celestia/mobilecelestia/MainActivity.kt index d8154603..61409045 100644 --- a/app/src/main/java/space/celestia/mobilecelestia/MainActivity.kt +++ b/app/src/main/java/space/celestia/mobilecelestia/MainActivity.kt @@ -226,7 +226,9 @@ class MainActivity : AppCompatActivity(R.layout.activity_main), builder.setTitle(R.string.privacy_policy_alert_title) builder.setMessage(R.string.privacy_policy_alert_detail) builder.setNeutralButton(R.string.privacy_policy_alert_show_policy_button_title) { _, _ -> - openURL("https://celestia.mobi/privacy") + val baseURL = "https://celestia.mobi/privacy" + val uri = Uri.parse(baseURL).buildUpon().appendQueryParameter("lang", "zh_CN").build() + openURI(uri) finishAndRemoveTask() exitProcess(0) } @@ -1331,8 +1333,11 @@ class MainActivity : AppCompatActivity(R.layout.activity_main), (supportFragmentManager.findFragmentById(R.id.celestia_fragment_container) as? CelestiaFragment)?.updateFrameRateOption(frameRateOption) } - override fun onAboutURLSelected(url: String) { - openURL(url) + override fun onAboutURLSelected(url: String, localizable: Boolean) { + var uri = Uri.parse(url) + if (localizable) + uri = uri.buildUpon().appendQueryParameter("lang", AppCore.getLanguage()).build() + openURI(uri) } override fun onSearchForEvent(objectName: String, startDate: Date, endDate: Date) { @@ -1416,7 +1421,11 @@ class MainActivity : AppCompatActivity(R.layout.activity_main), } private fun openURL(url: String) { - val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)) + openURI(Uri.parse(url)) + } + + private fun openURI(uri: Uri) { + val intent = Intent(Intent.ACTION_VIEW, uri) val ai = intent.resolveActivityInfo(packageManager, PackageManager.MATCH_DEFAULT_ONLY) if (ai != null && ai.exported) startActivity(intent) diff --git a/app/src/main/java/space/celestia/mobilecelestia/settings/AboutFragment.kt b/app/src/main/java/space/celestia/mobilecelestia/settings/AboutFragment.kt index 57dbc037..d9f09291 100644 --- a/app/src/main/java/space/celestia/mobilecelestia/settings/AboutFragment.kt +++ b/app/src/main/java/space/celestia/mobilecelestia/settings/AboutFragment.kt @@ -94,7 +94,7 @@ class AboutFragment : NavigationFragment.SubFragment() { when (item) { is ActionItem -> { TextRow(primaryText = item.title, primaryTextColor = MaterialTheme.colorScheme.primary, modifier = Modifier.clickable { - listener?.onAboutURLSelected(item.url) + listener?.onAboutURLSelected(item.url, localizable = item.localizable) }) } is VersionItem -> { @@ -134,7 +134,7 @@ class AboutFragment : NavigationFragment.SubFragment() { vertical = dimensionResource(id = R.dimen.list_item_medium_margin_vertical) )) { Text(text = "苏ICP备2023039249号-4A", color = colorResource(id = com.google.android.material.R.color.material_on_background_emphasis_medium), style = MaterialTheme.typography.bodySmall, modifier = Modifier.clickable { - listener?.onAboutURLSelected("https://beian.miit.gov.cn") + listener?.onAboutURLSelected("https://beian.miit.gov.cn", localizable = false) }) } } @@ -165,16 +165,16 @@ class AboutFragment : NavigationFragment.SubFragment() { // Links array.add( listOf( - ActionItem(CelestiaString("Development", "URL for Development wiki"),"https://celestia.mobi/help/development"), - ActionItem(CelestiaString("Third Party Dependencies", "URL for Third Party Dependencies wiki"), "https://celestia.mobi/help/dependencies"), - ActionItem(CelestiaString("Privacy Policy and Service Agreement", "Privacy Policy and Service Agreement"), "https://celestia.mobi/privacy") + ActionItem(CelestiaString("Development", "URL for Development wiki"),"https://celestia.mobi/help/development", localizable = false), + ActionItem(CelestiaString("Third Party Dependencies", "URL for Third Party Dependencies wiki"), "https://celestia.mobi/help/dependencies", localizable = true), + ActionItem(CelestiaString("Privacy Policy and Service Agreement", "Privacy Policy and Service Agreement"), "https://celestia.mobi/privacy", localizable = true) ) ) array.add( listOf( - ActionItem(CelestiaString("Official Website", ""), "https://celestia.mobi"), - ActionItem(CelestiaString("About Celestia", "System menu item"), "https://celestia.mobi/about") + ActionItem(CelestiaString("Official Website", ""), "https://celestia.mobi", localizable = true), + ActionItem(CelestiaString("About Celestia", "System menu item"), "https://celestia.mobi/about", localizable = true) ) ) @@ -208,7 +208,7 @@ class AboutFragment : NavigationFragment.SubFragment() { } interface Listener { - fun onAboutURLSelected(url: String) + fun onAboutURLSelected(url: String, localizable: Boolean) } companion object { diff --git a/app/src/main/java/space/celestia/mobilecelestia/settings/AboutItem.kt b/app/src/main/java/space/celestia/mobilecelestia/settings/AboutItem.kt index 4bdd6ced..9265dfaf 100644 --- a/app/src/main/java/space/celestia/mobilecelestia/settings/AboutItem.kt +++ b/app/src/main/java/space/celestia/mobilecelestia/settings/AboutItem.kt @@ -13,6 +13,6 @@ package space.celestia.mobilecelestia.settings sealed class AboutItem class VersionItem(val versionName: String) : AboutItem() -class ActionItem(val title: String, val url: String) : AboutItem() +class ActionItem(val title: String, val url: String, val localizable: Boolean) : AboutItem() class TitleItem(val title: String) : AboutItem() class DetailItem(val detail: String) : AboutItem() \ No newline at end of file