Improve the number on "Label SIM" page
Bug: 318310357 Test: manual - on Mobile Settings Change-Id: I79149db550e8d84dd2104cbfd72e144dddeb81cd
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package com.android.settings.spa.network
|
package com.android.settings.spa.network
|
||||||
|
|
||||||
|
import android.telephony.SubscriptionInfo
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
@@ -63,52 +64,55 @@ fun SimOnboardingLabelSimImpl(
|
|||||||
cancelAction
|
cancelAction
|
||||||
),
|
),
|
||||||
) {
|
) {
|
||||||
labelSimBody(onboardingService)
|
LabelSimBody(onboardingService)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun labelSimBody(onboardingService: SimOnboardingService) {
|
private fun LabelSimBody(onboardingService: SimOnboardingService) {
|
||||||
Column(Modifier.padding(SettingsDimension.itemPadding)) {
|
Column(Modifier.padding(SettingsDimension.itemPadding)) {
|
||||||
SettingsBody(stringResource(R.string.sim_onboarding_label_sim_msg))
|
SettingsBody(stringResource(R.string.sim_onboarding_label_sim_msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
for (subInfo in onboardingService.getSelectableSubscriptionInfoList()) {
|
for (subInfo in onboardingService.getSelectableSubscriptionInfoList()) {
|
||||||
var titleSimName by remember {
|
LabelSimPreference(onboardingService, subInfo)
|
||||||
mutableStateOf(
|
|
||||||
onboardingService.getSubscriptionInfoDisplayName(subInfo)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
var summaryNumber = subInfo.number
|
|
||||||
// TODO using the SubscriptionUtil.getFormattedPhoneNumber
|
|
||||||
val alertDialogPresenter = rememberAlertDialogPresenter(
|
|
||||||
confirmButton = AlertDialogButton(
|
|
||||||
stringResource(R.string.mobile_network_sim_name_rename)
|
|
||||||
) {
|
|
||||||
onboardingService.addItemForRenaming(subInfo, titleSimName)
|
|
||||||
},
|
|
||||||
dismissButton = AlertDialogButton(stringResource(R.string.cancel)) {
|
|
||||||
titleSimName = onboardingService.getSubscriptionInfoDisplayName(subInfo)
|
|
||||||
},
|
|
||||||
title = stringResource(R.string.sim_onboarding_label_sim_dialog_title),
|
|
||||||
text = {
|
|
||||||
Text(summaryNumber,
|
|
||||||
modifier = Modifier.padding(bottom = SettingsDimension.itemPaddingVertical))
|
|
||||||
SettingsOutlinedTextField(
|
|
||||||
value = titleSimName,
|
|
||||||
label = stringResource(R.string.sim_onboarding_label_sim_dialog_label),
|
|
||||||
enabled = true,
|
|
||||||
shape = MaterialTheme.shapes.extraLarge
|
|
||||||
) {
|
|
||||||
titleSimName = it
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
|
||||||
Preference(object : PreferenceModel {
|
|
||||||
override val title = titleSimName
|
|
||||||
override val summary: () -> String
|
|
||||||
get() = { summaryNumber }
|
|
||||||
override val onClick = alertDialogPresenter::open
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun LabelSimPreference(
|
||||||
|
onboardingService: SimOnboardingService,
|
||||||
|
subInfo: SubscriptionInfo,
|
||||||
|
) {
|
||||||
|
var titleSimName by remember {
|
||||||
|
mutableStateOf(onboardingService.getSubscriptionInfoDisplayName(subInfo))
|
||||||
|
}
|
||||||
|
val phoneNumber = phoneNumber(subInfo)
|
||||||
|
val alertDialogPresenter = rememberAlertDialogPresenter(
|
||||||
|
confirmButton = AlertDialogButton(stringResource(R.string.mobile_network_sim_name_rename)) {
|
||||||
|
onboardingService.addItemForRenaming(subInfo, titleSimName)
|
||||||
|
},
|
||||||
|
dismissButton = AlertDialogButton(stringResource(R.string.cancel)) {
|
||||||
|
titleSimName = onboardingService.getSubscriptionInfoDisplayName(subInfo)
|
||||||
|
},
|
||||||
|
title = stringResource(R.string.sim_onboarding_label_sim_dialog_title),
|
||||||
|
text = {
|
||||||
|
Text(
|
||||||
|
phoneNumber.value ?: "",
|
||||||
|
modifier = Modifier.padding(bottom = SettingsDimension.itemPaddingVertical)
|
||||||
|
)
|
||||||
|
SettingsOutlinedTextField(
|
||||||
|
value = titleSimName,
|
||||||
|
label = stringResource(R.string.sim_onboarding_label_sim_dialog_label),
|
||||||
|
shape = MaterialTheme.shapes.extraLarge
|
||||||
|
) {
|
||||||
|
titleSimName = it
|
||||||
|
}
|
||||||
|
},
|
||||||
|
)
|
||||||
|
Preference(object : PreferenceModel {
|
||||||
|
override val title = titleSimName
|
||||||
|
override val summary = { phoneNumber.value ?: "" }
|
||||||
|
override val onClick = alertDialogPresenter::open
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@@ -25,6 +25,7 @@ import androidx.compose.foundation.layout.Column
|
|||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.outlined.Add
|
import androidx.compose.material.icons.outlined.Add
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.State
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
@@ -58,9 +59,7 @@ private fun SimPreference(subInfo: SubscriptionInfo) {
|
|||||||
val checked = remember(subInfo.subscriptionId) {
|
val checked = remember(subInfo.subscriptionId) {
|
||||||
context.isSubscriptionEnabledFlow(subInfo.subscriptionId)
|
context.isSubscriptionEnabledFlow(subInfo.subscriptionId)
|
||||||
}.collectAsStateWithLifecycle(initialValue = false)
|
}.collectAsStateWithLifecycle(initialValue = false)
|
||||||
val phoneNumber = remember(subInfo) {
|
val phoneNumber = phoneNumber(subInfo)
|
||||||
context.phoneNumberFlow(subInfo)
|
|
||||||
}.collectAsStateWithLifecycle(initialValue = null)
|
|
||||||
RestrictedTwoTargetSwitchPreference(
|
RestrictedTwoTargetSwitchPreference(
|
||||||
model = object : SwitchPreferenceModel {
|
model = object : SwitchPreferenceModel {
|
||||||
override val title = subInfo.displayName.toString()
|
override val title = subInfo.displayName.toString()
|
||||||
@@ -80,6 +79,14 @@ private fun SimPreference(subInfo: SubscriptionInfo) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun phoneNumber(subInfo: SubscriptionInfo): State<String?> {
|
||||||
|
val context = LocalContext.current
|
||||||
|
return remember(subInfo) {
|
||||||
|
context.phoneNumberFlow(subInfo)
|
||||||
|
}.collectAsStateWithLifecycle(initialValue = null)
|
||||||
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun AddSim() {
|
private fun AddSim() {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
Reference in New Issue
Block a user