Fix UI flashes issue when entering to the app in the cold start am: 5b27fd923a

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/14456007

Change-Id: If983fe7b512bd3c10bbcc4b63096424b44a0b15a
This commit is contained in:
ykhung
2021-05-09 04:26:44 +00:00
committed by Automerger Merge Worker
6 changed files with 14 additions and 7 deletions

View File

@@ -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" />
<TextView

View File

@@ -25,8 +25,7 @@
android:key="battery_graph"/>
<PreferenceCategory
android:key="app_list"
android:title="@string/power_usage_list_summary"/>
android:key="app_list"/>
<com.android.settingslib.widget.FooterPreference
android:title="@string/battery_usage_screen_footer"

View File

@@ -167,6 +167,7 @@ public class BatteryAppListPreferenceController extends AbstractPreferenceContro
super.displayPreference(screen);
mPrefContext = screen.getContext();
mAppListGroup = screen.findPreference(mPreferenceKey);
mAppListGroup.setTitle(mPrefContext.getString(R.string.power_usage_list_summary));
}
@Override

View File

@@ -157,6 +157,7 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
} else {
mTextPaint = null;
}
setVisibility(View.VISIBLE);
requestLayout();
}

View File

@@ -214,13 +214,11 @@ public final class ConvertUtils {
currentEntry.mBackgroundUsageTimeInMs,
nextEntry.mBackgroundUsageTimeInMs,
nextTwoEntry.mBackgroundUsageTimeInMs);
final double consumePower =
double consumePower =
getDiffValue(
currentEntry.mConsumePower,
nextEntry.mConsumePower,
nextTwoEntry.mConsumePower);
totalConsumePower += consumePower;
// Excludes entry since we don't have enough data to calculate.
if (foregroundUsageTimeInMs == 0
&& backgroundUsageTimeInMs == 0
@@ -246,7 +244,9 @@ public final class ConvertUtils {
Math.round(foregroundUsageTimeInMs * ratio);
backgroundUsageTimeInMs =
Math.round(backgroundUsageTimeInMs * ratio);
consumePower = consumePower * ratio;
}
totalConsumePower += consumePower;
batteryDiffEntryList.add(
new BatteryDiffEntry(
context,

View File

@@ -286,9 +286,14 @@ public final class ConvertUtilsTest {
final List<BatteryDiffEntry> 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