Show "0 B used" when no data usage this cycle

When the latest cycle has no data usage, currently it shows all time
usage without cycle info, which could confuse user.

Change to "0 B used used xxx - xxx" to fix this issue.

Fix: 292346951
Test: manual - on Mobile Settings
Test: unit tests
Change-Id: Ic06fd63a3bc049d70538d0a3cd1fa3d62dbd71d7
This commit is contained in:
Chaohui Wang
2024-01-06 00:00:30 +08:00
parent b236498939
commit f28d119560
2 changed files with 12 additions and 13 deletions

View File

@@ -107,7 +107,7 @@ class DataUsagePreferenceController(context: Context, key: String) :
private fun getDataUsageSummary(): String? {
val repository = createNetworkCycleDataRepository() ?: return null
repository.loadFirstCycle()?.takeIf { it.usage > 0 }?.let { usageData ->
repository.loadFirstCycle()?.let { usageData ->
return mContext.getString(
R.string.data_usage_template,
usageData.formatUsage(mContext),