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_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

View File

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

View File

@@ -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

View File

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

View File

@@ -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,

View File

@@ -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