From 5b27fd923acd67d15787cd1a70ab873900f677e0 Mon Sep 17 00:00:00 2001 From: ykhung Date: Sat, 8 May 2021 15:19:19 +0800 Subject: [PATCH] Fix UI flashes issue when entering to the app in the cold start 1. fix the chart % info will flash issue by deferring the showing time until the chart content is ready to show (set default as invisible) 2. fix the category title will flash issue by set the default value as empty to avoid refresh the title twice in the start time Bug: 177406865 Test: make SettingsRoboTests Change-Id: If8f247cf5b01c529bc5e4d18fcf409ba296cc2f4 --- res/layout/battery_chart_graph.xml | 1 + res/xml/power_usage_advanced.xml | 3 +-- .../fuelgauge/BatteryAppListPreferenceController.java | 1 + src/com/android/settings/fuelgauge/BatteryChartView.java | 1 + src/com/android/settings/fuelgauge/ConvertUtils.java | 6 +++--- .../com/android/settings/fuelgauge/ConvertUtilsTest.java | 9 +++++++-- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/res/layout/battery_chart_graph.xml b/res/layout/battery_chart_graph.xml index 18e650ce1d4..1896b78d016 100644 --- a/res/layout/battery_chart_graph.xml +++ b/res/layout/battery_chart_graph.xml @@ -36,6 +36,7 @@ android:layout_width="match_parent" android:layout_height="165dp" android:layout_marginBottom="16dp" + android:visibility="invisible" android:textAppearance="?android:attr/textAppearanceSmall" settings:textColor="?android:attr/textColorSecondary" /> + android:key="app_list"/> entryList = purgedResultMap.get(0); assertThat(entryList).hasSize(1); // Verifies the clipped usage time. + final float ratio = (float) (7200) / (float) (3600 + 7200); final BatteryDiffEntry resultEntry = entryList.get(0); - assertThat(resultEntry.mForegroundUsageTimeInMs).isEqualTo(2400000); - assertThat(resultEntry.mBackgroundUsageTimeInMs).isEqualTo(4800000); + assertThat(resultEntry.mForegroundUsageTimeInMs) + .isEqualTo(Math.round(entry.mForegroundUsageTimeInMs * ratio)); + assertThat(resultEntry.mBackgroundUsageTimeInMs) + .isEqualTo(Math.round(entry.mBackgroundUsageTimeInMs * ratio)); + assertThat(resultEntry.mConsumePower) + .isEqualTo(entry.mConsumePower * ratio); } @Test