From 99fbbf87172182e330047da4c3ab796219b1dc9a Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Sat, 18 Jul 2020 02:58:58 +0000 Subject: [PATCH] Reduce usages of ContextThemeWrapper causing memory churn - Cache light/dark icon colors so we don't have to create additional theme wrappers when updating them - Convert rotation styles to separate drawables so we can skip creating theme wrappers just to change some attributes of the drawable, these icons are not changed much so it's worth the memory savings even if this introduces copies of the drawable - Clean up floating rotation drawable initialization slightly, only create when updating the icon, and only start the animation when showing the drawable - Removed some unused code Bug: 157510126 Test: atest SystemUiTests Test: Verify rotation icon looks the same in all orientations with both three button and gestural, and also with light/dark nav bar Signed-off-by: Winson Chung Change-Id: I31e89f7aef00b38f2a7953d6e229c9ed7df8b479 --- ...> ic_sysbar_rotate_button_ccw_start_0.xml} | 40 ++-- .../ic_sysbar_rotate_button_ccw_start_90.xml | 187 ++++++++++++++++++ .../ic_sysbar_rotate_button_cw_start_0.xml | 187 ++++++++++++++++++ .../ic_sysbar_rotate_button_cw_start_90.xml | 187 ++++++++++++++++++ packages/SystemUI/res/values/attrs.xml | 5 - packages/SystemUI/res/values/styles.xml | 25 --- .../statusbar/phone/ContextualButton.java | 10 +- .../phone/ContextualButtonGroup.java | 4 +- .../phone/FloatingRotationButton.java | 37 +--- .../statusbar/phone/NavigationBarView.java | 32 +-- .../statusbar/phone/RotationButton.java | 2 +- .../phone/RotationButtonController.java | 49 +++-- .../phone/RotationContextButton.java | 22 +-- .../statusbar/policy/KeyButtonDrawable.java | 29 --- .../phone/NavigationBarContextTest.java | 9 +- .../NavigationBarRotationContextTest.java | 4 +- 16 files changed, 663 insertions(+), 166 deletions(-) rename packages/SystemUI/res/drawable/{ic_sysbar_rotate_button.xml => ic_sysbar_rotate_button_ccw_start_0.xml} (84%) create mode 100644 packages/SystemUI/res/drawable/ic_sysbar_rotate_button_ccw_start_90.xml create mode 100644 packages/SystemUI/res/drawable/ic_sysbar_rotate_button_cw_start_0.xml create mode 100644 packages/SystemUI/res/drawable/ic_sysbar_rotate_button_cw_start_90.xml diff --git a/packages/SystemUI/res/drawable/ic_sysbar_rotate_button.xml b/packages/SystemUI/res/drawable/ic_sysbar_rotate_button_ccw_start_0.xml similarity index 84% rename from packages/SystemUI/res/drawable/ic_sysbar_rotate_button.xml rename to packages/SystemUI/res/drawable/ic_sysbar_rotate_button_ccw_start_0.xml index 3304c19b1ed8c..ff5cb9ef6b67f 100644 --- a/packages/SystemUI/res/drawable/ic_sysbar_rotate_button.xml +++ b/packages/SystemUI/res/drawable/ic_sysbar_rotate_button_ccw_start_0.xml @@ -1,6 +1,6 @@ + android:scaleX="1"> @@ -107,8 +107,8 @@ + android:valueFrom="0" + android:valueTo="-90"> @@ -118,14 +118,14 @@ + android:valueFrom="0" + android:valueTo="0"/> + android:valueFrom="0" + android:valueTo="-90"> @@ -135,14 +135,14 @@ + android:valueFrom="0" + android:valueTo="0"/> + android:valueFrom="0" + android:valueTo="-90"> @@ -152,14 +152,14 @@ + android:valueFrom="0" + android:valueTo="0"/> + android:valueFrom="0" + android:valueTo="-90"> @@ -169,14 +169,14 @@ + android:valueFrom="0" + android:valueTo="0"/> + android:valueFrom="0" + android:valueTo="-90"> diff --git a/packages/SystemUI/res/drawable/ic_sysbar_rotate_button_ccw_start_90.xml b/packages/SystemUI/res/drawable/ic_sysbar_rotate_button_ccw_start_90.xml new file mode 100644 index 0000000000000..90fedb17ecf18 --- /dev/null +++ b/packages/SystemUI/res/drawable/ic_sysbar_rotate_button_ccw_start_90.xml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/drawable/ic_sysbar_rotate_button_cw_start_0.xml b/packages/SystemUI/res/drawable/ic_sysbar_rotate_button_cw_start_0.xml new file mode 100644 index 0000000000000..a89e7a34ad26e --- /dev/null +++ b/packages/SystemUI/res/drawable/ic_sysbar_rotate_button_cw_start_0.xml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/drawable/ic_sysbar_rotate_button_cw_start_90.xml b/packages/SystemUI/res/drawable/ic_sysbar_rotate_button_cw_start_90.xml new file mode 100644 index 0000000000000..0dc67b0d22af1 --- /dev/null +++ b/packages/SystemUI/res/drawable/ic_sysbar_rotate_button_cw_start_90.xml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/values/attrs.xml b/packages/SystemUI/res/values/attrs.xml index 10c72102bba38..84dbd60b799db 100644 --- a/packages/SystemUI/res/values/attrs.xml +++ b/packages/SystemUI/res/values/attrs.xml @@ -133,11 +133,6 @@ - - - - - diff --git a/packages/SystemUI/res/values/styles.xml b/packages/SystemUI/res/values/styles.xml index 68c2a38f53c36..9e5b94ee855c4 100644 --- a/packages/SystemUI/res/values/styles.xml +++ b/packages/SystemUI/res/values/styles.xml @@ -604,31 +604,6 @@ ?android:attr/colorSecondary - - - - - - - - -