Commit Graph

2090 Commits

Author SHA1 Message Date
Zaiyue Xue
b4fe32640f Fix b/242009481: Refine the battery usage chart timestamp label rule
Draw the first and the last labels. Then recursively draws axis labels between the start index and the end index. If the inner number can be exactly divided into 2 parts, check and draw the middle index label and then recursively draw the 2 parts. Otherwise, divide into 3 parts. Check and draw the middle two labels and then recursively draw the 3 parts. If there are any overlaps, skip drawing and go back to the uplevel of the recursion.

screenshots: https://drive.google.com/drive/folders/11AJ4Fz6xS76LGlbAy9WfvjZpffgFkMji?resourcekey=0-HBWCQa1oQW4e0UfvLzEXGQ&usp=sharing

Bug: 242009481
Fix: 242009481
Test: manual
Change-Id: Iaa9019feba7693638d5ae64bbbee7298eb74f749
2022-08-17 08:50:54 +00:00
Tiffany Nguyen
3acd34fe4a Move restricted apps page to new battery optimization page.
New entry: https://screenshot.googleplex.com/BbU6RnQhBbpnBc3.png
Restricted: https://screenshot.googleplex.com/5ggid7TcSsH9CUF.png
Old entry: https://screenshot.googleplex.com/7JgZpSfKs5zZb3Z.png

Bug: 240711616
Test: manual
Change-Id: I03d17beac0fb85a3d17acd7d0d581feb35e9582b
2022-08-16 22:38:05 +00:00
Zaiyue Xue
c931670a99 Fix b/242252080: Add padding space on the top of the battery chart
screenshot: https://screenshot.googleplex.com/9XU9Yiwv9YAVd46.png

Bug: 242252080
Test: manual
Change-Id: I81730168337b311600a12b844753848c21105d46
2022-08-15 16:19:19 +08:00
Zaiyue Xue
284e049cc1 Switch Battery Usage Chart from V1 to V2.
Test: manual
Bug: 236101166
Change-Id: I9142c0d4e00dea3771777ba9aedeab07b635fa1a
2022-08-10 13:55:54 +08:00
TreeHugger Robot
6b806e31f9 Merge "New way to draw battery chart axis labels" 2022-08-09 11:38:17 +00:00
TreeHugger Robot
8ebd4a5f8e Merge "Fix b/241885070: Unexpected texts moving when going back to battery usage page" 2022-08-09 11:12:55 +00:00
TreeHugger Robot
aaaed2f0c1 Merge "Fix b/241872474 Battery usage page will crash when selecting the last hour chart bar, going to app detail page, and going back" 2022-08-09 10:54:16 +00:00
Zaiyue Xue
72b64f2515 New way to draw battery chart axis labels
Pairly draws axis labels from left and right side to middle. If the pair of labels have any overlap, skips that pair of labels.

https://drive.google.com/drive/folders/1tR4xfJsJGakuH5JRdn74kPD5GBH6u6CL?resourcekey=0-Ikp5CV0DpxllWv7n5-UHnw&usp=sharing

Test: manual
Bug: 236101166
Change-Id: Ib13d4c73b31ad86ac9e318d4315b5a1a0bb25814
2022-08-09 17:27:11 +08:00
Zaiyue Xue
5316bb71fe Fix b/241885070: Unexpected texts moving when going back to battery usage page
This bug is because two charts visibility were set to visible everytime
when entering the battery usage page. Only after loading the data and
refresh the UI, one of them could be hidden.

screen record after fix: https://drive.google.com/file/d/1zpynm8UX3XXunlD-WE1eyv6yenrVhAH5/view?usp=sharing&resourcekey=0-y79NYHcm8lgiNRbgy8SEfQ

Test: manual
Bug: 236101166
Bug: 241885070
Change-Id: I9c1dbf79a95dad2c3dece71af6d52f546d8a5808
2022-08-09 17:08:13 +08:00
Zaiyue Xue
8d0030d874 Fix b/241872474 Battery usage page will crash when selecting the last hour chart bar, going to app detail page, and going back
This bug is because we always use mHourlyChartIndex to construct
every view model in mHoulyViewModels. However, mHourlyChartIndex could
be got from saved instance. So mHourlyChartIndex may be out of bound in
some hourly view model which has not many hours data.

This fix removes the selectedIndex in BatteryChartViewModel constructor. Suppose the selectedIndex should be set everytime the view model is used.

Test: manual
Bug: 236101166
Bug: 241872474
Change-Id: I0bb5568ac33fcc23c406fe3af308b8d2706c5542
2022-08-09 16:39:36 +08:00
Kuan Wang
8d88148036 Avoid NullPointerException when batteryLevelData is null.
Bug: 236101687
Bug: 241738105
Test: make RunSettingsRoboTests
Change-Id: Iee04f96083eff7ff5cd61a7c1f2eda20a6dc9149
2022-08-09 14:10:44 +08:00
Zaiyue Xue
b9bf92f5ae Add margin between battery daily and hourly charts
screenshot: https://drive.google.com/file/d/1vXL4XO9HezZ4fTJ5wh6Fi13oXf54yc9q/view?usp=sharing&resourcekey=0--k4_Qk4e9ELyENeAySlYFw

Bug: 236101166
Test: manual
Change-Id: Ib4f5705661d2799cc74f6a957ce715ebb93b28b8
2022-08-08 17:44:39 +08:00
Kuan Wang
373390f660 Update usage data for EBS app usage list and App usage detail from 24
hours to last full charge.

Bug: 236101687
Test: manual + make RunSettingsRoboTests
Change-Id: I48097dcaaf7b4100fbd7802940aac7c5ef92ee0b
2022-08-08 03:29:12 +00:00
Zaiyue Xue
693711469d Updates battery usage messages from last 24hr to last full charge. (Part2: non-V2 files)
Test: manual
Bug: 236101166
Change-Id: Id5ad3e859a01d3288a950bf6288eafc6144a23d6
2022-08-05 10:52:38 +08:00
TreeHugger Robot
85b03538d0 Merge "Update the selected period message in battery chart" 2022-08-04 09:51:07 +00:00
TreeHugger Robot
bc52343473 Merge "Updates battery usage messages from last 24hr to last full charge. (Part1: V2 files)" 2022-08-04 09:45:50 +00:00
Zaiyue Xue
49e67c9f33 Updates battery usage messages from last 24hr to last full charge. (Part1: V2 files)
Test: manual
Bug: 236101166
Change-Id: I0aa9a1a4c902764bb9937e422e5e7f60b6e86859
2022-08-04 14:59:58 +08:00
Zaiyue Xue
e2087bb5f3 Update the selected period message in battery chart
screenshots: https://drive.google.com/drive/folders/1pxyrmaerZbD2FdEJohnsgqACXXno1Ve5?resourcekey=0-SXu6D9TLvmXDVgVKkZge8Q&usp=sharing
Next cl will change "last 24hr" to "last full charge".

Test: manual
Bug: 236101166
Change-Id: If850d65056add04f0b2ecb6aed418e799ae15fb6
2022-08-04 14:54:53 +08:00
Tiffany Nguyen
0e37ac8d7a Merge "Add Apps > Battery optimization page implementation." 2022-08-03 15:02:11 +00:00
TreeHugger Robot
8d1c50b4dc Merge "Support showing app usage list for two battery charts" 2022-08-03 11:49:26 +00:00
Kuan Wang
b6b6ae4ef0 Always do interpolation for battery level data in daily chart.
Bug: 236101687
Test: make RunSettingsRoboTests
Change-Id: I07ca512ceb7a74da4256f5d6fffed6d2432f89e0
2022-08-03 09:32:22 +00:00
Zaiyue Xue
ba6c435eff Support showing app usage list for two battery charts
Test: manual
Bug: 236101166
Change-Id: I29b4615bd5a967bcfd0a4ab378fec4e700dfc7f0
2022-08-03 08:57:48 +00:00
Tiffany Nguyen
5ecb1a1d69 Add Apps > Battery optimization page implementation.
Moving the old restricted page to the new optimization page will happen
in a follow-up CL.

Test: Unit, manual
Bug: 238026672
Change-Id: I5fee9ebe03284a013da6bfca9ada8b166c6af91c
2022-08-02 18:43:53 +00:00
Kuan Wang
0dc8d58de5 Add the async task to compute diff usage data and load labels and icons.
Bug: 236101687
Test: make RunSettingsRoboTests
Change-Id: Ie24ea89fa6cfd351c73e64de40e2c9315867af9a
2022-08-01 18:45:00 +08:00
Zaiyue Xue
a14c9dfc4f Improve X axis labels in battery chart (2)
Support showing different numbers of labels for different count of
trapezoids.

screen_record: https://drive.google.com/file/d/1CIgppQllHlKC3BGG7hBvOjGDGVOs6OYC/view?usp=sharing&resourcekey=0-mbofu5KOO2dqCwL7K0zakg

Test: manual
Bug: 239491373
Bug: 236101166
Change-Id: I865dae760b491bdd7c93bbd29fd7dbc33204a60a
2022-07-30 15:24:06 +00:00
Zaiyue Xue
e9ab2f5365 Improve X axis labels in battery chart (1)
Support showing labels under the trapezoids instead of between the
trapezoids. For daily chart, the labels are under the trapezoids, for
hourly chart, the labels are between the trapezoids.

Test: manual
Bug: 239491373
Bug: 236101166
Change-Id: I2efb5192d4baafc7745ce269224639511848293e
2022-07-30 15:23:28 +00:00
Zaiyue Xue
eaf4d1bb50 Support daily and hourly battery chartview.
https://drive.google.com/file/d/1vjt6FPFAiFakb158t1IBku1IQNzVPW46/view?usp=sharing&resourcekey=0-f5m2eUKWbth6gdEFh5lOIQ

Test: manual
Bug: 236101166
Change-Id: I47d899b936742514801cd4fa7a82ddaea5d21c31
2022-07-30 14:44:41 +08:00
Zaiyue Xue
532defdc85 Update trapezoid validation in battery chart view.
If the battery level data cannot be gotten for an hour, ag/19358207 changes the level indication from 0 to null. This cl updates the battery chart view trapezoid validation logic from checking the level not zero to not null.

Test: manual
Bug: 236101166
Change-Id: I240f2b02b94ba1a3d99022c7c72a7a5adb21f9a5
2022-07-26 18:04:00 +08:00
Zaiyue Xue
05bf785859 Add battery chart view model.
Test: manual
Bug: 239491373
Bug: 236101166
Change-Id: I1ae0e5fcc006855ac552fbbdfb4cd73f3dec52e7
2022-07-26 06:34:43 +00:00
Kuan Wang
287a40a9e9 Add DataProcessor to process raw history map for UI.
- Move interpolation from DatabaseUtil
- Add the logic to wrap processed history map to BatteryLevelData
- Change ImmutableList to List in BatteryLevelData because
  ImmutableList.of doesn't support null element.

Bug: 236101687
Test: make RunSettingsRoboTests
Change-Id: I0a842f24e5481faf65f667c08a4fdc11fe2f235c
2022-07-25 08:39:45 +00:00
Wesley Wang
01eabef95b Merge "Update battery optimize page states condition" 2022-07-22 06:16:08 +00:00
TreeHugger Robot
ef289f99b5 Merge "Refactor Battery Chart View State Controll" 2022-07-20 13:34:35 +00:00
Zaiyue Xue
d4f9588a3d Refactor Battery Chart View State Controll
When users click the battery chart, the orignal behavior is that the view changes the state by itself.
This cl refactors the bahavior to that the view callbacks to the controller, and
the controller changes the view's state.
In this way, the controller is the only source of truth of the state.
This meets the controller-view model.

Test: manual
Bug: 239491373, 236101166
Change-Id: I754ded2dba20319f1571374dfdbef27f2420ed78
2022-07-20 09:38:23 +00:00
TreeHugger Robot
f7f800793c Merge "Add class BatteryDiffData used to parcel battery usage data" 2022-07-19 18:01:45 +00:00
Kuan Wang
5c98e155c2 Add class BatteryDiffData used to parcel battery usage data
Add class BatteryDiffData used to parcel battery usage diff data per
apps. It behaves as an interface between UI and data.

Bug: 236101687
Test: make RunSettingsRoboTests
Change-Id: I59daa9e8c5de2105ebf24c7a585c02e554735e78
2022-07-19 15:47:51 +00:00
Zaiyue Xue
837a8f0063 In BatteryChartViewV2, use levels.length-1 to replace mTrapezoidCount. So the chartview could show any number of slots as the given levels length-1.
Test: manual
Bug: 236101166, 239491373
Change-Id: I9625ed80e8eba6632cc864ada0ba3e9cf11de82a
2022-07-19 16:54:59 +08:00
Wesley Wang
7e8d79b3c2 Update battery optimize page states condition
- Keep apps optimize state as what it set even it's a system or default
   app
 - Previously we force system/defualt apps present as Unrestricted mode
   only and disable other options but that can not shows that apps
   actual optimize states, it's possible to be other states even it's a
   system or default apps, so we change the UI logic back to: present
   it's actual states and disable other options when it's a system or
   default apps.

Bug: 234419032
Test: make SettingsRoboTests
Change-Id: Ib5b6cb0aacb570cb8d15b1bb9ac2d480356eda49
2022-07-19 16:27:14 +08:00
Zaiyue Xue
24bc269ec1 Refactor BatteryChartView X-axis labels. Instead of
only timestamps, also support any string[] labels.

Bug: 236101166
Test: manual
Change-Id: I84763ccce0ee63da0b5b26e1416bf5bd5b58963d
2022-07-18 14:25:24 +08:00
Kuan Wang
d2fcbf4120 Add class BatteryLevelData used to parcel the battery timestamps and
levels. It behaves as an interface between UI and data.

Bug: 236101687
Test: make RunSettingsRoboTests
Change-Id: I4f79165125254ce1372abf1a207411a183aabb23
2022-07-14 16:34:42 +08:00
Kuan Wang
3d2e5a2447 Duplicate BatteryChartPreferenceController and BatteryChartView into new
files for better diff review purpose

Bug: 236101687
Test: make RunSettingsRoboTests
Change-Id: I2d29bbfe14bcc5df7c09bceec2cbb0673685f522
2022-07-14 02:35:55 +00:00
TreeHugger Robot
0931e3895c Merge "Support multi-user privacy for battery usage chart" into tm-qpr-dev am: fedab69c9a am: a51b1baeaa
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/19235726

Change-Id: Ib9c678e1bcb7dcc562301a1f039f20eb7d3caccd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-12 17:22:43 +00:00
TreeHugger Robot
51d087cd67 Merge "Add function getBatteryHistorySinceLastFullCharge, used to replace getBatteryHistory in BatteryHistoryLoader." into tm-qpr-dev 2022-07-12 16:47:13 +00:00
ykhung
764d513d00 Support multi-user privacy for battery usage chart
When there are multiple accounts in the devices, the battery usage list
is shared in the current design. We will aggregate other users usage
data into a single item to support multi-user privacy requirements

Screenshot: https://screenshot.googleplex.com/AkFTUtNvnoxcuGR

Bug: 202119550
Test: make RunSettingsRoboTests
Change-Id: I6cb55f0d50a4caca83212a0a54410530a032c089
2022-07-12 00:17:43 +08:00
Wesley Wang
d3bead822c Export callback to receive seekbar change event from SeekBarPrefernce
- Export onSeekBarChangeListener callback to receive change event from parent
  - Update battery saver schedule trigger threshold after seekbar tounch
    ending instead of update it every time during dragging or touching

Bug: 236356020
Test: make RunSettingsRoboTests
Change-Id: Ifee7cd9e7cabfbec0817a4c28254228f885d6a8d
2022-07-11 17:49:00 +08:00
Kuan Wang
e39ecafa1f Add function getBatteryHistorySinceLastFullCharge, used to replace
getBatteryHistory in BatteryHistoryLoader.

getBatteryHistory couldn't be changed directly as it needs to be kept
for other features.

Bug: 236101687
Test: make RunSettingsRoboTests
Change-Id: I3e3cdd3a0225228bf76f6750f6a56f031666720f
Merged-In: I3e3cdd3a0225228bf76f6750f6a56f031666720f
2022-07-11 09:10:08 +00:00
Kuan Wang
315c78b8e2 Add function getBatteryHistorySinceLastFullCharge, used to replace
getBatteryHistory in BatteryHistoryLoader.

getBatteryHistory couldn't be changed directly as it needs to be kept
for other features.

Bug: 236101687
Test: make RunSettingsRoboTests
Change-Id: I3e3cdd3a0225228bf76f6750f6a56f031666720f
2022-07-08 14:46:46 +08:00
Zaiyue Xue
7e6aa69cca Merge "Move battery usage files to a separate folder." into tm-qpr-dev am: 3b7953eac2 am: 6470ada117
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/18797446

Change-Id: I3d6a155e80a5d54c309061c41d0b6436e61cc4cb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-06-20 09:42:01 +00:00
xuezaiyue
ac7318419a Move battery usage files to a separate folder.
Bug: 202118250
Test: presubmit
Change-Id: I21aa58ebc02327849ed2161dbbafcdc806c007f2
2022-06-19 05:59:35 +00:00
Kuan Wang
02b6451258 Clean up legacy "optimization mode" design.
We have two different "Optimization mode" page design in the android R to support bi-state for AOSP and tri-state for Pixel device. From android T, we always show tri-state for both AOSP and Pixel. So it's time to clean up the legacy design for bi-state.
This change doesn't include string resources cleanup, which will be
included in a separated cl.

Bug: 232037602
Test: make RunSettingsRoboTests
Change-Id: I5194201d0b11e2dcea958d49bf07ed837a386465
2022-06-06 02:11:09 +00:00
Edgar Wang
b9a06a9f34 Merge "Update learn more string of FooterPrefernce" into tm-dev am: 24654a3d61 am: eaa0a1cf5c am: 21ddf79998
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/18356903

Change-Id: I2f7ce317b7bb9d355fbb1e5f0fc2aacb1da7f8d2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-21 00:02:22 +00:00