From ea5db6ee61270c3073ec7635ca58fd230bacd551 Mon Sep 17 00:00:00 2001 From: fenglibin Date: Wed, 6 Mar 2024 17:23:36 +0800 Subject: [PATCH] add icp registration record --- app/src/main/java/io/agora/flat/Constants.kt | 2 + .../main/java/io/agora/flat/data/AppEnv.kt | 14 +++- .../ui/activity/setting/AboutUsActivity.kt | 72 ++++++++++++++----- app/src/main/res/values-zh/strings.xml | 3 +- app/src/main/res/values/strings.xml | 1 + 5 files changed, 72 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/io/agora/flat/Constants.kt b/app/src/main/java/io/agora/flat/Constants.kt index 9110ed07..af991df2 100644 --- a/app/src/main/java/io/agora/flat/Constants.kt +++ b/app/src/main/java/io/agora/flat/Constants.kt @@ -12,6 +12,8 @@ class Constants { const val Privacy = "https://www.flat.shengwang.cn/privacy.html" + const val Registration = "https://beian.miit.gov.cn" + const val Libraries = "https://www.flat.shengwang.cn/privacy-extra/libraries.html" } diff --git a/app/src/main/java/io/agora/flat/data/AppEnv.kt b/app/src/main/java/io/agora/flat/data/AppEnv.kt index a1669dc3..8de3c1f7 100644 --- a/app/src/main/java/io/agora/flat/data/AppEnv.kt +++ b/app/src/main/java/io/agora/flat/data/AppEnv.kt @@ -56,7 +56,9 @@ class AppEnv @Inject constructor(@ApplicationContext context: Context) { whiteAppId = "cFjxAJjiEeuUQ0211QCRBw/mO9uJB_DiCIqug", googleClientId = "273996094508-p97og69ojac5ja0khn1rvmi3tb7vgfgm.apps.googleusercontent.com", - loginConfig = LoginConfig(google = false) + loginConfig = LoginConfig(google = false), + + showIcp = true, ) envMap[ENV_CN_PROD] = EnvItem( @@ -73,11 +75,13 @@ class AppEnv @Inject constructor(@ApplicationContext context: Context) { endpoint = "https://cn-hangzhou.log.aliyuncs.com", ), ossKey = "LTAI5tMwHQ1xyroeneA9XLh4", - wechatId = "wx09437693798bc108", + wechatId = "wx09437693798bc108", whiteAppId = "cFjxAJjiEeuUQ0211QCRBw/mO9uJB_DiCIqug", googleClientId = "273996094508-p97og69ojac5ja0khn1rvmi3tb7vgfgm.apps.googleusercontent.com", - loginConfig = LoginConfig(google = false) + loginConfig = LoginConfig(google = false), + + showIcp = true, ) envMap[ENV_SG_PROD] = EnvItem( @@ -178,6 +182,8 @@ class AppEnv @Inject constructor(@ApplicationContext context: Context) { val phoneFirst get() = currentEnvItem.loginConfig.phoneFirst + val showIcp get() = currentEnvItem.showIcp + data class EnvItem( val agoraAppId: String, val serviceUrl: String, @@ -193,6 +199,8 @@ class AppEnv @Inject constructor(@ApplicationContext context: Context) { val region: String = "cn-hz", val loginConfig: LoginConfig = LoginConfig(), + + val showIcp: Boolean = false, ) } diff --git a/app/src/main/java/io/agora/flat/ui/activity/setting/AboutUsActivity.kt b/app/src/main/java/io/agora/flat/ui/activity/setting/AboutUsActivity.kt index ea899780..1f63aa6d 100644 --- a/app/src/main/java/io/agora/flat/ui/activity/setting/AboutUsActivity.kt +++ b/app/src/main/java/io/agora/flat/ui/activity/setting/AboutUsActivity.kt @@ -3,7 +3,10 @@ package io.agora.flat.ui.activity.setting import android.os.Bundle import androidx.activity.compose.setContent import androidx.compose.foundation.Image +import androidx.compose.foundation.LocalIndication import androidx.compose.foundation.background +import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -13,8 +16,8 @@ import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.material.MaterialTheme -import androidx.compose.material.TextButton import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext @@ -22,9 +25,11 @@ import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +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.data.AppEnv import io.agora.flat.ui.activity.base.BaseComposeActivity import io.agora.flat.ui.compose.BackTopAppBar import io.agora.flat.ui.compose.FlatPage @@ -33,14 +38,19 @@ import io.agora.flat.ui.compose.FlatTextBodyTwo import io.agora.flat.ui.compose.FlatTextTitle import io.agora.flat.ui.theme.FlatTheme import io.agora.flat.util.getAppVersion +import javax.inject.Inject +@AndroidEntryPoint class AboutUsActivity : BaseComposeActivity() { + @Inject + lateinit var appEnv: AppEnv; + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContent { FlatPage { - AboutUsScreen { action -> + AboutUsScreen(showIcp = appEnv.showIcp) { action -> when (action) { is AboutUiAction.Back -> finish() is AboutUiAction.OpenServiceProtocol -> { @@ -50,6 +60,10 @@ class AboutUsActivity : BaseComposeActivity() { is AboutUiAction.OpenPrivacyProtocol -> { Navigator.launchWebViewActivity(this@AboutUsActivity, Constants.URL.Privacy) } + + is AboutUiAction.OpenRegistration -> { + Navigator.launchWebViewActivity(this@AboutUsActivity, Constants.URL.Registration) + } } } } @@ -58,7 +72,7 @@ class AboutUsActivity : BaseComposeActivity() { } @Composable -private fun AboutUsScreen(actioner: (AboutUiAction) -> Unit) { +private fun AboutUsScreen(showIcp: Boolean = true, actioner: (AboutUiAction) -> Unit) { val context = LocalContext.current val version = "Version ${context.getAppVersion()}" @@ -77,16 +91,14 @@ private fun AboutUsScreen(actioner: (AboutUiAction) -> Unit) { FlatTextBodyOne(version) } } - Box( - Modifier - .fillMaxWidth() - .padding(vertical = 32.dp), Alignment.Center - ) { + + Box(Modifier.fillMaxWidth(), Alignment.Center) { Row(verticalAlignment = Alignment.CenterVertically) { - TextButton( - modifier = Modifier.padding(horizontal = 16.dp), - onClick = { actioner(AboutUiAction.OpenServiceProtocol) }) { - FlatTextBodyTwo(stringResource(R.string.service_agreement), color = MaterialTheme.colors.primary) + AboutTextButton( + Modifier.padding(vertical = 4.dp, horizontal = 16.dp), + text = stringResource(R.string.service_agreement) + ) { + actioner(AboutUiAction.OpenServiceProtocol) } Spacer( Modifier @@ -94,14 +106,41 @@ private fun AboutUsScreen(actioner: (AboutUiAction) -> Unit) { .width(1.dp) .background(FlatTheme.colors.divider) ) - TextButton( - onClick = { actioner(AboutUiAction.OpenPrivacyProtocol) }, - modifier = Modifier.padding(horizontal = 16.dp) + AboutTextButton( + Modifier.padding(vertical = 4.dp, horizontal = 16.dp), + text = stringResource(R.string.privacy_agreement) ) { - FlatTextBodyTwo(stringResource(R.string.privacy_agreement), color = MaterialTheme.colors.primary) + actioner(AboutUiAction.OpenPrivacyProtocol) + } + } + } + if (showIcp) { + Spacer(modifier = Modifier.height(8.dp)) + Box(Modifier.fillMaxWidth(), Alignment.Center) { + AboutTextButton(Modifier.padding(4.dp), text = stringResource(R.string.icp_registration_record)) { + actioner(AboutUiAction.OpenRegistration) } } } + Spacer(modifier = Modifier.height(32.dp)) + } +} + +@Composable +private fun AboutTextButton( + modifier: Modifier = Modifier, + text: String, + onClick: () -> Unit +) { + Box( + modifier = modifier + .clickable( + indication = LocalIndication.current, + interactionSource = remember { MutableInteractionSource() }, + onClick = onClick, + ) + ) { + FlatTextBodyTwo(text, color = MaterialTheme.colors.primary) } } @@ -118,4 +157,5 @@ internal sealed class AboutUiAction { object Back : AboutUiAction() object OpenServiceProtocol : AboutUiAction() object OpenPrivacyProtocol : AboutUiAction() + object OpenRegistration : AboutUiAction() } \ No newline at end of file diff --git a/app/src/main/res/values-zh/strings.xml b/app/src/main/res/values-zh/strings.xml index 8b5c53d8..66f5bd2d 100644 --- a/app/src/main/res/values-zh/strings.xml +++ b/app/src/main/res/values-zh/strings.xml @@ -1,4 +1,4 @@ - + Flat Not Supported Yet @@ -271,6 +271,7 @@ 上传失败 服务协议 隐私协议 + ICP编号: 沪ICP备14053584号-25A 网络异常,请检查网络设置 复制成功 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b421cd0c..a4eb52a6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -51,6 +51,7 @@ Country/Area Privacy Policy Term of Service + ICP编号: 沪ICP备14053584号-25A Information Gathering Third-party Information Network Acceleration