Skip to content

Commit

Permalink
add icp registration record
Browse files Browse the repository at this point in the history
  • Loading branch information
AderanFeng committed Mar 6, 2024
1 parent 2bd3b33 commit ea5db6e
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 20 deletions.
2 changes: 2 additions & 0 deletions app/src/main/java/io/agora/flat/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

Expand Down
14 changes: 11 additions & 3 deletions app/src/main/java/io/agora/flat/data/AppEnv.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand All @@ -193,6 +199,8 @@ class AppEnv @Inject constructor(@ApplicationContext context: Context) {
val region: String = "cn-hz",

val loginConfig: LoginConfig = LoginConfig(),

val showIcp: Boolean = false,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -13,18 +16,20 @@ 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
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
Expand All @@ -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 -> {
Expand All @@ -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)
}
}
}
}
Expand All @@ -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()}"

Expand All @@ -77,31 +91,56 @@ 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
.height(16.dp)
.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)
}
}

Expand All @@ -118,4 +157,5 @@ internal sealed class AboutUiAction {
object Back : AboutUiAction()
object OpenServiceProtocol : AboutUiAction()
object OpenPrivacyProtocol : AboutUiAction()
object OpenRegistration : AboutUiAction()
}
3 changes: 2 additions & 1 deletion app/src/main/res/values-zh/strings.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<resources>
<resources xmlns:tools="http://schemas.android.com/tools">
<string name="app_name">Flat</string>
<string name="toast_in_development">Not Supported Yet</string>

Expand Down Expand Up @@ -271,6 +271,7 @@
<string name="upload_failure">上传失败</string>
<string name="service_agreement">服务协议</string>
<string name="privacy_agreement">隐私协议</string>
<string name="icp_registration_record">ICP编号: 沪ICP备14053584号-25A</string>
<string name="network_error">网络异常,请检查网络设置</string>
<string name="copy_success">复制成功</string>

Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<string name="title_country_or_area">Country/Area</string>
<string name="privacy_policy">Privacy Policy</string>
<string name="term_of_service">Term of Service</string>
<string name="icp_registration_record">ICP编号: 沪ICP备14053584号-25A</string>
<string name="info_gathering">Information Gathering</string>
<string name="info_third_party">Third-party Information</string>
<string name="network_acceleration">Network Acceleration</string>
Expand Down

0 comments on commit ea5db6e

Please sign in to comment.