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
This commit is contained in:
@@ -36,6 +36,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="165dp"
|
android:layout_height="165dp"
|
||||||
android:layout_marginBottom="16dp"
|
android:layout_marginBottom="16dp"
|
||||||
|
android:visibility="invisible"
|
||||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||||
settings:textColor="?android:attr/textColorSecondary" />
|
settings:textColor="?android:attr/textColorSecondary" />
|
||||||
<TextView
|
<TextView
|
||||||
|
@@ -25,8 +25,7 @@
|
|||||||
android:key="battery_graph"/>
|
android:key="battery_graph"/>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="app_list"
|
android:key="app_list"/>
|
||||||
android:title="@string/power_usage_list_summary"/>
|
|
||||||
|
|
||||||
<com.android.settingslib.widget.FooterPreference
|
<com.android.settingslib.widget.FooterPreference
|
||||||
android:title="@string/battery_usage_screen_footer"
|
android:title="@string/battery_usage_screen_footer"
|
||||||
|
@@ -167,6 +167,7 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
|
|||||||
super.displayPreference(screen);
|
super.displayPreference(screen);
|
||||||
mPrefContext = screen.getContext();
|
mPrefContext = screen.getContext();
|
||||||
mAppListGroup = screen.findPreference(mPreferenceKey);
|
mAppListGroup = screen.findPreference(mPreferenceKey);
|
||||||
|
mAppListGroup.setTitle(mPrefContext.getString(R.string.power_usage_list_summary));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -157,6 +157,7 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
|||||||
} else {
|
} else {
|
||||||
mTextPaint = null;
|
mTextPaint = null;
|
||||||
}
|
}
|
||||||
|
setVisibility(View.VISIBLE);
|
||||||
requestLayout();
|
requestLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -214,13 +214,11 @@ public final class ConvertUtils {
|
|||||||
currentEntry.mBackgroundUsageTimeInMs,
|
currentEntry.mBackgroundUsageTimeInMs,
|
||||||
nextEntry.mBackgroundUsageTimeInMs,
|
nextEntry.mBackgroundUsageTimeInMs,
|
||||||
nextTwoEntry.mBackgroundUsageTimeInMs);
|
nextTwoEntry.mBackgroundUsageTimeInMs);
|
||||||
final double consumePower =
|
double consumePower =
|
||||||
getDiffValue(
|
getDiffValue(
|
||||||
currentEntry.mConsumePower,
|
currentEntry.mConsumePower,
|
||||||
nextEntry.mConsumePower,
|
nextEntry.mConsumePower,
|
||||||
nextTwoEntry.mConsumePower);
|
nextTwoEntry.mConsumePower);
|
||||||
totalConsumePower += consumePower;
|
|
||||||
|
|
||||||
// Excludes entry since we don't have enough data to calculate.
|
// Excludes entry since we don't have enough data to calculate.
|
||||||
if (foregroundUsageTimeInMs == 0
|
if (foregroundUsageTimeInMs == 0
|
||||||
&& backgroundUsageTimeInMs == 0
|
&& backgroundUsageTimeInMs == 0
|
||||||
@@ -246,7 +244,9 @@ public final class ConvertUtils {
|
|||||||
Math.round(foregroundUsageTimeInMs * ratio);
|
Math.round(foregroundUsageTimeInMs * ratio);
|
||||||
backgroundUsageTimeInMs =
|
backgroundUsageTimeInMs =
|
||||||
Math.round(backgroundUsageTimeInMs * ratio);
|
Math.round(backgroundUsageTimeInMs * ratio);
|
||||||
|
consumePower = consumePower * ratio;
|
||||||
}
|
}
|
||||||
|
totalConsumePower += consumePower;
|
||||||
batteryDiffEntryList.add(
|
batteryDiffEntryList.add(
|
||||||
new BatteryDiffEntry(
|
new BatteryDiffEntry(
|
||||||
context,
|
context,
|
||||||
|
@@ -286,9 +286,14 @@ public final class ConvertUtilsTest {
|
|||||||
final List<BatteryDiffEntry> entryList = purgedResultMap.get(0);
|
final List<BatteryDiffEntry> entryList = purgedResultMap.get(0);
|
||||||
assertThat(entryList).hasSize(1);
|
assertThat(entryList).hasSize(1);
|
||||||
// Verifies the clipped usage time.
|
// Verifies the clipped usage time.
|
||||||
|
final float ratio = (float) (7200) / (float) (3600 + 7200);
|
||||||
final BatteryDiffEntry resultEntry = entryList.get(0);
|
final BatteryDiffEntry resultEntry = entryList.get(0);
|
||||||
assertThat(resultEntry.mForegroundUsageTimeInMs).isEqualTo(2400000);
|
assertThat(resultEntry.mForegroundUsageTimeInMs)
|
||||||
assertThat(resultEntry.mBackgroundUsageTimeInMs).isEqualTo(4800000);
|
.isEqualTo(Math.round(entry.mForegroundUsageTimeInMs * ratio));
|
||||||
|
assertThat(resultEntry.mBackgroundUsageTimeInMs)
|
||||||
|
.isEqualTo(Math.round(entry.mBackgroundUsageTimeInMs * ratio));
|
||||||
|
assertThat(resultEntry.mConsumePower)
|
||||||
|
.isEqualTo(entry.mConsumePower * ratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user