Skip to content

Commit

Permalink
update protocol urls
Browse files Browse the repository at this point in the history
  • Loading branch information
aderan committed Sep 11, 2024
1 parent 34c979e commit 0be5ffc
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 20 deletions.
4 changes: 0 additions & 4 deletions app/src/main/java/io/agora/flat/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ class Constants {
}

object URL {
const val Service = "https://www.flat.apprtc.cn/service.html"

const val Privacy = "https://www.flat.apprtc.cn/privacy.html"

const val Registration = "https://beian.miit.gov.cn"

const val Libraries = "https://www.flat.apprtc.cn/privacy-extra/libraries.html"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/io/agora/flat/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import dagger.hilt.android.HiltAndroidApp
import io.agora.flat.common.android.CallingCodeManager
import io.agora.flat.common.android.DarkModeManager
import io.agora.flat.common.android.LanguageManager
import io.agora.flat.common.android.ProtocolUrlManager
import io.agora.flat.common.upload.UploadManager
import io.agora.flat.di.GlobalInstanceProvider
import io.agora.flat.util.isApkInDebug
Expand All @@ -23,6 +24,7 @@ class MainApplication : Application(), CameraXConfig.Provider {
DarkModeManager.init(this)
CallingCodeManager.init(this)
GlobalInstanceProvider.init(this)
ProtocolUrlManager.init(this)
WebView.setWebContentsDebuggingEnabled(isApkInDebug())
WhiteboardView.setEntryUrl("file:///android_asset/flatboard/index.html")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package io.agora.flat.common.android

import android.app.Application
import android.content.Context
import io.agora.flat.data.AppEnv
import io.agora.flat.data.AppEnv.Companion.ENV_CN_DEV
import io.agora.flat.data.AppEnv.Companion.ENV_CN_PROD
import io.agora.flat.data.AppEnv.Companion.ENV_SG_DEV
import io.agora.flat.data.AppEnv.Companion.ENV_SG_PROD

object ProtocolUrlManager {
private const val PRIVACY = "privacy"
private const val SERVICE = "service"

private lateinit var application: Context

private val appEnv by lazy { AppEnv(application) }

private val urls: Map<String, Map<String, Map<String, String>>> = mapOf(
PRIVACY to mapOf(
ENV_CN_PROD to mapOf(
"en" to "https://www.flat.apprtc.cn/en/privacy.html", "zh" to "https://www.flat.apprtc.cn/privacy.html"
), ENV_CN_DEV to mapOf(
"en" to "https://www.flat.apprtc.cn/en/privacy.html", "zh" to "https://www.flat.apprtc.cn/privacy.html"
), ENV_SG_PROD to mapOf(
"en" to "https://flat.agora.io/privacy.html", "zh" to "https://flat.agora.io/zh/privacy.html"
), ENV_SG_DEV to mapOf(
"en" to "https://flat.agora.io/privacy.html", "zh" to "https://flat.agora.io/zh/privacy.html"
)
),
SERVICE to mapOf(
ENV_CN_PROD to mapOf(
"en" to "https://www.flat.apprtc.cn/en/service.html", "zh" to "https://www.flat.apprtc.cn/service.html"
), ENV_CN_DEV to mapOf(
"en" to "https://www.flat.apprtc.cn/en/service.html", "zh" to "https://www.flat.apprtc.cn/service.html"
), ENV_SG_PROD to mapOf(
"en" to "https://flat.agora.io/en/service.html", "zh" to "https://flat.agora.io/zh/service.html"
), ENV_SG_DEV to mapOf(
"en" to "https://flat.agora.io/en/service.html", "zh" to "https://flat.agora.io/zh/service.html"
)
),
)

fun init(app: Application) {
application = app
}

val Service: String
get() {
val env = appEnv.getEnv()
val lang = LanguageManager.currentLocale().language
return urls[SERVICE]!![env]?.get(lang) ?: "https://www.flat.apprtc.cn/service.html"
}

val Privacy: String
get() {
val env = appEnv.getEnv()
val lang = LanguageManager.currentLocale().language
return urls[PRIVACY]!![env]?.get(lang) ?: "https://www.flat.apprtc.cn/privacy.html"
}
}
10 changes: 5 additions & 5 deletions app/src/main/java/io/agora/flat/ui/activity/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.core.view.WindowCompat
import dagger.hilt.android.AndroidEntryPoint
import io.agora.flat.Constants
import io.agora.flat.R
import io.agora.flat.common.Navigator
import io.agora.flat.common.android.LanguageManager
import io.agora.flat.common.android.ProtocolUrlManager
import io.agora.flat.common.login.LoginActivityHandler
import io.agora.flat.common.login.LoginState
import io.agora.flat.common.login.LoginType
Expand Down Expand Up @@ -125,11 +125,11 @@ class LoginActivity : BaseComposeActivity() {
}

LoginUiAction.OpenServiceProtocol -> {
Navigator.launchWebViewActivity(this, Constants.URL.Service)
Navigator.launchWebViewActivity(this, ProtocolUrlManager.Service)
}

LoginUiAction.OpenPrivacyProtocol -> {
Navigator.launchWebViewActivity(this, Constants.URL.Privacy)
Navigator.launchWebViewActivity(this, ProtocolUrlManager.Privacy)
}

is LoginUiAction.PhoneLogin -> {
Expand Down Expand Up @@ -618,8 +618,8 @@ fun LoginAgreement(
Checkbox(checked = checked, onCheckedChange = onCheckedChange)
Spacer(Modifier.width(4.dp))
val items = listOf(
ClickableItem(stringResource(R.string.privacy_policy), "privacy", Constants.URL.Privacy),
ClickableItem(stringResource(R.string.term_of_service), "service", Constants.URL.Service)
ClickableItem(stringResource(R.string.privacy_policy), "privacy", ProtocolUrlManager.Privacy),
ClickableItem(stringResource(R.string.term_of_service), "service", ProtocolUrlManager.Service)
)
FlatClickableText(stringResource(R.string.login_agreement_message), items = items)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import dagger.hilt.android.AndroidEntryPoint
import io.agora.flat.Constants
import io.agora.flat.R
import io.agora.flat.common.Navigator
import io.agora.flat.common.android.ProtocolUrlManager
import io.agora.flat.data.AppEnv
import io.agora.flat.ui.activity.base.BaseComposeActivity
import io.agora.flat.ui.compose.BackTopAppBar
Expand All @@ -54,11 +55,11 @@ class AboutUsActivity : BaseComposeActivity() {
when (action) {
is AboutUiAction.Back -> finish()
is AboutUiAction.OpenServiceProtocol -> {
Navigator.launchWebViewActivity(this@AboutUsActivity, Constants.URL.Service)
Navigator.launchWebViewActivity(this@AboutUsActivity, ProtocolUrlManager.Service)
}

is AboutUiAction.OpenPrivacyProtocol -> {
Navigator.launchWebViewActivity(this@AboutUsActivity, Constants.URL.Privacy)
Navigator.launchWebViewActivity(this@AboutUsActivity, ProtocolUrlManager.Privacy)
}

is AboutUiAction.OpenRegistration -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import androidx.navigation.NavController
import io.agora.flat.Constants
import io.agora.flat.R
import io.agora.flat.common.Navigator
import io.agora.flat.common.android.ProtocolUrlManager
import io.agora.flat.ui.compose.BackTopAppBar
import io.agora.flat.ui.compose.FlatColumnPage
import io.agora.flat.ui.compose.FlatDivider
Expand Down Expand Up @@ -126,12 +127,12 @@ private fun SettingsList(state: SettingsUiState, onDownload: suspend () -> Uri,
SettingItem(
id = R.drawable.ic_settings_privacy_policy,
tip = stringResource(R.string.privacy_policy),
onClick = { Navigator.launchWebViewActivity(context, Constants.URL.Privacy) })
onClick = { Navigator.launchWebViewActivity(context, ProtocolUrlManager.Privacy) })
SettingItemDivider()
SettingItem(
id = R.drawable.ic_settings_term_of_service,
tip = stringResource(R.string.term_of_service),
onClick = { Navigator.launchWebViewActivity(context, Constants.URL.Service) })
onClick = { Navigator.launchWebViewActivity(context, ProtocolUrlManager.Service) })
SettingItemDivider()
SettingItem(
id = R.drawable.ic_settings_info_gathering,
Expand Down
14 changes: 7 additions & 7 deletions app/src/main/java/io/agora/flat/ui/compose/FlatAgreement.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
import io.agora.flat.Constants
import io.agora.flat.R
import io.agora.flat.common.android.ProtocolUrlManager
import io.agora.flat.data.model.Agreement
import io.agora.flat.ui.theme.Shapes

Expand Down Expand Up @@ -82,8 +82,8 @@ internal fun AgreementDialog(agreement: Agreement? = null, onAgree: () -> Unit,
private fun LoginAgreementDialogMessage(agreement: Agreement?) {
var text = agreement?.message ?: stringResource(R.string.login_agreement_dialog_message)
val items = listOf(
ClickableItem(stringResource(R.string.agreement_global_privacy), "privacy", Constants.URL.Privacy),
ClickableItem(stringResource(R.string.agreement_global_service), "service", Constants.URL.Service)
ClickableItem(stringResource(R.string.agreement_global_privacy), "privacy", ProtocolUrlManager.Privacy),
ClickableItem(stringResource(R.string.agreement_global_service), "service", ProtocolUrlManager.Service)
)

FlatClickableText(text = text, items = items)
Expand All @@ -93,8 +93,8 @@ private fun LoginAgreementDialogMessage(agreement: Agreement?) {
private fun GlobalAgreementMessage() {
val text = stringResource(R.string.agreement_global_dialog_message)
val items = listOf(
ClickableItem(stringResource(R.string.agreement_global_privacy), "privacy", Constants.URL.Privacy),
ClickableItem(stringResource(R.string.agreement_global_service), "service", Constants.URL.Service)
ClickableItem(stringResource(R.string.agreement_global_privacy), "privacy", ProtocolUrlManager.Privacy),
ClickableItem(stringResource(R.string.agreement_global_service), "service", ProtocolUrlManager.Service)
)

FlatClickableText(text = text, items = items)
Expand All @@ -104,8 +104,8 @@ private fun GlobalAgreementMessage() {
private fun GlobalRecheckAgreementMessage() {
val text = stringResource(R.string.agreement_global_recheck_dialog_message)
val items = listOf(
ClickableItem(stringResource(R.string.agreement_global_privacy), "privacy", Constants.URL.Privacy),
ClickableItem(stringResource(R.string.agreement_global_service), "service", Constants.URL.Service)
ClickableItem(stringResource(R.string.agreement_global_privacy), "privacy", ProtocolUrlManager.Privacy),
ClickableItem(stringResource(R.string.agreement_global_service), "service", ProtocolUrlManager.Service)
)

FlatClickableText(text = text, items = items)
Expand Down

0 comments on commit 0be5ffc

Please sign in to comment.