Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class MultiSelectCoinListBottomSheetDialogFragment : MixinBottomSheetDialogFragm
selectedCoinItems.clear()
selectedCoinItems.addAll(provider.getCurrentCoins())
}
groupAdapter.checkedCoinItems = selectedCoinItems
contentView = binding.root
binding.ph.doOnPreDraw {
binding.ph.updateLayoutParams<ViewGroup.LayoutParams> {
Expand Down Expand Up @@ -217,4 +218,4 @@ class MultiSelectCoinListBottomSheetDialogFragment : MixinBottomSheetDialogFragm
this.dataProvider = dataProvider
return this
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ fun AlertEditPage(
alert: Alert?,
onAdd: (CoinItem) -> Unit,
pop: () -> Unit,
onSaved: (Boolean) -> Unit,
onShowTypeSelector: (AlertType, (AlertType) -> Unit) -> Unit,
onShowFrequencySelector: (AlertFrequency, (AlertFrequency) -> Unit) -> Unit,
) {
Expand All @@ -120,7 +121,7 @@ fun AlertEditPage(
var inputError by remember { mutableStateOf(if (alertValue.toBigDecimalOrNull() == currentPrice && selectedAlertType != AlertType.PRICE_REACHED) InputError.EQUALS_CURRENT_PRICE else null) }
val viewModel = hiltViewModel<AlertViewModel>()
PageScaffold(
title = stringResource(id = if (alert == null) R.string.Alert else R.string.Edit_Alert),
title = stringResource(id = if (alert == null) R.string.Add_Alert else R.string.Edit_Alert),
verticalScrollable = false,
pop = pop,
) {
Expand Down Expand Up @@ -430,7 +431,7 @@ fun AlertEditPage(
)
val re = viewModel.updateAlert(alert.alertId, alertRequest)
if (re?.isSuccess == true) {
pop.invoke()
onSaved(false)
}
} else {
val alertRequest = AlertRequest(
Expand All @@ -449,7 +450,7 @@ fun AlertEditPage(
val re = viewModel.add(alertRequest)
if (re?.isSuccess == true) {
onAdd.invoke(coin)
pop.invoke()
onSaved(true)
}
}
isLoading = false
Expand All @@ -476,7 +477,7 @@ fun AlertEditPage(
}
Text(
modifier = Modifier.alpha(if (isLoading) 0f else 1f),
text = stringResource(if (alert == null) R.string.Alert else R.string.Save),
text = stringResource(if (alert == null) R.string.Add_Alert else R.string.Save),
color = if (enable) Color.White else MixinAppTheme.colors.textAssist,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class AlertFragment : BaseFragment(), MultiSelectCoinListBottomSheetDialogFragme
}

enum class AlertDestination {
Alert, All, Edit,
All, Edit,
}
Comment on lines 55 to 57
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the Alert destination from the NavHost can crash state restoration (e.g., process recreation or app update) if a previously-saved back stack contains the old "Alert" route; Navigation will try to restore a destination that no longer exists. Consider keeping an Alert route that redirects to All (or keeping the enum value + composable) for backward compatibility, at least for one release.

Copilot uses AI. Check for mistakes.

private val alertViewModel by viewModels<AlertViewModel>()
Expand All @@ -69,6 +69,7 @@ class AlertFragment : BaseFragment(), MultiSelectCoinListBottomSheetDialogFragme

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
coins = setOf(coin)
Comment on lines 70 to +72
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coins is initialized to emptySet() for the first composition and then set to setOf(coin) in onViewCreated(), which can briefly start collecting all alert groups (and potentially render an unfiltered UI) before switching to the single-coin filtered flow. Initialize coins before setContent (e.g., in onCreate, or set the initial state from args) to avoid unnecessary collection/flicker.

Suggested change
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
coins = setOf(coin)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
coins = setOf(coin)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

Copilot uses AI. Check for mistakes.
jobManager.addJobInBackground(RefreshAlertsJob())
}

Expand All @@ -85,7 +86,7 @@ class AlertFragment : BaseFragment(), MultiSelectCoinListBottomSheetDialogFragme
val navController = rememberNavController()
NavHost(
navController = navController,
startDestination = AlertDestination.Alert.name,
startDestination = if (goAlert) AlertDestination.Edit.name else AlertDestination.All.name,
enterTransition = {
slideIntoContainer(
AnimatedContentTransitionScope.SlideDirection.Left,
Expand All @@ -111,24 +112,8 @@ class AlertFragment : BaseFragment(), MultiSelectCoinListBottomSheetDialogFragme
)
},
) {
composable(AlertDestination.Alert.name) {
AlertPage(coin = coin, pop = { requireActivity().onBackPressedDispatcher.onBackPressed() }, toAll = {
coins = emptySet()
selectCoin = null
navController.navigate(AlertDestination.All.name)
}, onAdd = { onAddAlert(navController, coin) }, onEdit = { alert ->
lifecycleScope.launch {
val coin = alertViewModel.simpleCoinItem(alert.coinId)
if (coin != null) {
selectCoin = coin
currentAlert = alert
navController.navigate(AlertDestination.Edit.name)
}
}
})
}
composable(AlertDestination.All.name) {
AllAlertPage(coins = coins, openFilter = { openFilter() }, pop = { requireActivity().onBackPressedDispatcher.onBackPressed() }, to = { onAddAlert(navController) }, onEdit = { alert ->
AllAlertPage(coins = coins, openFilter = { openFilter() }, pop = { requireActivity().onBackPressedDispatcher.onBackPressed() }, to = { onAddAlert(navController, coins.singleOrNull()) }, onEdit = { alert ->
lifecycleScope.launch {
val coin = alertViewModel.simpleCoinItem(alert.coinId)
if (coin != null) {
Expand All @@ -150,6 +135,18 @@ class AlertFragment : BaseFragment(), MultiSelectCoinListBottomSheetDialogFragme
}
},
pop = { navigateUp(navController) },
onSaved = { created ->
if (created && goAlert) {
navController.navigate(AlertDestination.All.name) {
popUpTo(AlertDestination.Edit.name) {
inclusive = true
}
launchSingleTop = true
}
} else {
navigateUp(navController)
}
},
onShowTypeSelector = { selectedType, onSelected ->
AlertSelectionBottomSheetDialogFragment.newTypeInstance(selectedType).apply {
onTypeSelected = onSelected
Expand All @@ -167,7 +164,6 @@ class AlertFragment : BaseFragment(), MultiSelectCoinListBottomSheetDialogFragme
LaunchedEffect(Unit) {
if (goAlert) {
selectCoin = coin
navController.navigate(AlertDestination.Edit.name)
}
}
}
Expand All @@ -183,17 +179,15 @@ class AlertFragment : BaseFragment(), MultiSelectCoinListBottomSheetDialogFragme
if (isTotalAlertCountExceeded) {
toast(getString(R.string.alert_limit_exceeded, maxTotalAlerts))
} else if (coinItem != null) {
lifecycleScope.launch {
val isAssetAlertCountExceeded = withContext(Dispatchers.IO) {
alertViewModel.isAssetAlertCountExceeded(coinItem.coinId)
}
if (isAssetAlertCountExceeded) {
toast(getString(R.string.alert_per_asset_limit_exceeded, maxAlertsPerAsset))
} else {
selectCoin = coinItem
currentAlert = null
navController.navigate(AlertDestination.Edit.name)
}
val isAssetAlertCountExceeded = withContext(Dispatchers.IO) {
alertViewModel.isAssetAlertCountExceeded(coinItem.coinId)
}
if (isAssetAlertCountExceeded) {
toast(getString(R.string.alert_per_asset_limit_exceeded, maxAlertsPerAsset))
} else {
selectCoin = coinItem
currentAlert = null
navController.navigate(AlertDestination.Edit.name)
}
} else {
selectTokenListBottomSheetDialogFragment.setOnMultiSelectCoinListener(object : MultiSelectCoinListBottomSheetDialogFragment.OnMultiSelectCoinListener {
Expand Down
148 changes: 0 additions & 148 deletions app/src/main/java/one/mixin/android/ui/wallet/alert/AlertPage.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fun AllAlertPage(coins: Set<CoinItem>?, openFilter: () -> Unit, pop: () -> Unit,
}

PageScaffold(
title = stringResource(id = R.string.All_Alert),
title = stringResource(id = R.string.Price_Alerts),
verticalScrollable = false,
pop = pop,
) {
Expand All @@ -82,7 +82,7 @@ fun AllAlertPage(coins: Set<CoinItem>?, openFilter: () -> Unit, pop: () -> Unit,
)
Spacer(modifier = Modifier.width(4.dp))
Text(
text = stringResource(R.string.Alert), color = Color(0xFF3D75E3)
text = stringResource(R.string.Add_Alert), color = Color(0xFF3D75E3)
)
}
}
Expand Down Expand Up @@ -117,7 +117,7 @@ fun AllAlertPage(coins: Set<CoinItem>?, openFilter: () -> Unit, pop: () -> Unit,
)
Spacer(modifier = Modifier.width(4.dp))
Text(
text = stringResource(R.string.Alert), color = Color(0xFF3D75E3)
text = stringResource(R.string.Add_Alert), color = Color(0xFF3D75E3)
)
}
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1769,6 +1769,7 @@
<string name="red_up_green_down">红涨绿跌</string>
<string name="green_up_red_down">绿涨红跌</string>
<string name="Alert">价格预警</string>
<string name="Add_Alert">添加价格预警</string>
<string name="Edit_Alert">编辑价格预警</string>
<string name="NO_ALERTS">没有价格预警</string>
<string name="Current_price">当前价格:%1$s</string>
Expand Down Expand Up @@ -1813,7 +1814,7 @@
<string name="error_decrease_too_high">跌幅不能超过-99.99%。</string>
<string name="error_decrease_too_low">跌幅必须至少为-0.01%。</string>
<string name="Alert_Not_Support">暂不支持</string>
<string name="All_Alert">所有价格预警</string>
<string name="Price_Alerts">价格预警</string>
<string name="Trending_Dapps">热门 app</string>
<string name="Paste">粘贴</string>
<string name="or">或者</string>
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1815,6 +1815,7 @@
<string name="red_up_green_down">Red Up / Green Down</string>
<string name="green_up_red_down">Green Up / Red Down</string>
<string name="Alert">Alert</string>
<string name="Add_Alert">Add Alert</string>
<string name="Edit_Alert">Edit Alert</string>
<string name="NO_ALERTS">NO ALERTS</string>
<string name="Current_price">Current price: %1$s</string>
Expand Down Expand Up @@ -1859,7 +1860,7 @@
<string name="error_decrease_too_high">The decrease percentage cannot exceed -99.99%.</string>
<string name="error_decrease_too_low">The decrease percentage must be at least -0.01%.</string>
<string name="Alert_Not_Support">Not Supported</string>
<string name="All_Alert">All Alerts</string>
<string name="Price_Alerts">Price Alerts</string>
<string name="Trending_Dapps">Trending Apps</string>
<string name="Paste">Paste</string>
<string name="or">or</string>
Expand Down
Loading