[QPR1] Add time unit into battery usage chart and refine some UI

- add time unit into battery chart for 12/24 hours
- refine the radius size for chart bar
- use fixed font size for timestamp and percentage

screenshots:
24-hour format: https://screenshot.googleplex.com/3VNedE2nAx6LrXu
12-hour format: https://screenshot.googleplex.com/3tpTXjYfrasrenW
fixed-size: https://screenshot.googleplex.com/nPRKm7XCkmFzW6K

Bug: 194836607
Test: make SettingsRoboTests
Change-Id: I5b35b0fa808eb8a5f607962ee973c2896529b078
Merged-In: I5b35b0fa808eb8a5f607962ee973c2896529b078
This commit is contained in:
ykhung
2021-08-09 23:02:29 +08:00
committed by YUKAI HUNG
parent 36a42b630b
commit 0791d77df0
8 changed files with 31 additions and 178 deletions

View File

@@ -33,7 +33,6 @@ import android.view.accessibility.AccessibilityManager;
import com.android.settings.testutils.FakeFeatureFactory;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -44,7 +43,6 @@ import org.robolectric.RuntimeEnvironment;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Locale;
import java.util.TimeZone;
@RunWith(RobolectricTestRunner.class)
public final class BatteryChartViewTest {
@@ -233,21 +231,4 @@ public final class BatteryChartViewTest {
verify(mBatteryChartView.mHandler)
.postDelayed(mBatteryChartView.mUpdateClickableStateRun, 500L);
}
@Ignore
@Test
public void testSetLatestTimestamp_generateExpectedTimestamps() {
final long timestamp = 1619196786769L;
ConvertUtils.sSimpleDateFormatForHour = null;
// Invokes the method first to create the SimpleDateFormat.
ConvertUtils.utcToLocalTimeHour(
mContext, /*timestamp=*/ 0, /*is24HourFormat=*/ false);
ConvertUtils.sSimpleDateFormatForHour
.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
final String[] expectedTimestamps = new String[] {"00", "06", "12", "18", "00"};
mBatteryChartView.setLatestTimestamp(timestamp);
assertThat(mBatteryChartView.mTimestamps).isEqualTo(expectedTimestamps);
}
}