Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e5b389d authored by Chaohui Wang's avatar Chaohui Wang
Browse files

Fix flicker of "App data usage"

Use placeholder to hold the place.

Fix: 323466366
Test: manual - on Mobile Settings
Test: unit test
Change-Id: I3c4d9ff6538a79500318869f01f4b88b55bd9475
(cherry picked from commit 74fe516e)
Merged-In: I3c4d9ff6538a79500318869f01f4b88b55bd9475
parent bc4293cb
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import com.android.settings.datausage.DataUsageUtils
import com.android.settings.datausage.lib.DataUsageLib
import com.android.settings.datausage.lib.NetworkCycleDataRepository
import com.android.settings.datausage.lib.NetworkStatsRepository.Companion.AllTimeRange
import com.android.settingslib.spaprivileged.framework.compose.getPlaceholder
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@@ -63,6 +64,7 @@ class DataUsagePreferenceController(context: Context, key: String) :
    }

    override fun onViewCreated(viewLifecycleOwner: LifecycleOwner) {
        preference.summary = mContext.getPlaceholder()
        viewLifecycleOwner.lifecycleScope.launch {
            viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
                update()
@@ -113,7 +115,6 @@ class DataUsagePreferenceController(context: Context, key: String) :
        }

        val allTimeUsage = repository.queryUsage(AllTimeRange)
        if (allTimeUsage.usage > 0) return allTimeUsage.getDataUsedString(mContext) to true
        return null to false
        return allTimeUsage.getDataUsedString(mContext) to (allTimeUsage.usage > 0)
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ class DataUsagePreferenceControllerTest {
            on { loadFirstCycle() } doReturn usageData
        }
        controller.onViewCreated(TestLifecycleOwner())
        waitUntil { preference.summary != null }
        waitUntil { !preference.summary.isNullOrBlank() }

        controller.handlePreferenceTreeClick(preference)