Skip to content

Commit f4d99d8

Browse files
andrewfluckralph950412
authored andcommitted
SystemUI: Animate auto brightness toggle
Also enforce restriction for toggle and fix the visibility of the toggle if the device does not support auto brightness Author: Andrew Fluck <andrew@aospa.co> Signed-off-by: Fazil Sheik <fazil.sheik96@gmail.com> Change-Id: Ia80713220e47948a3cdf244f7bf8f69ce4421c08 Signed-off-by: ralph950412 <ralph950412@gmail.com>
1 parent c460542 commit f4d99d8

18 files changed

Lines changed: 545 additions & 170 deletions

packages/SystemUI/res/drawable/bg_qs_brightness_auto_off.xml

Lines changed: 0 additions & 22 deletions
This file was deleted.

packages/SystemUI/res/drawable/bg_qs_brightness_auto_on.xml

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2022 Paranoid Android
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<animated-selector xmlns:android="http://schemas.android.com/apk/res/android">
17+
<item
18+
android:id="@+id/checked"
19+
android:drawable="@drawable/ic_qs_brightness_auto_on"
20+
android:state_checked="true" />
21+
22+
<item
23+
android:id="@+id/unchecked"
24+
android:drawable="@drawable/ic_qs_brightness_auto_off" />
25+
26+
<transition
27+
android:drawable="@drawable/ic_qs_brightness_auto_on_avd"
28+
android:fromId="@id/unchecked"
29+
android:toId="@id/checked" />
30+
31+
<transition
32+
android:drawable="@drawable/ic_qs_brightness_auto_off_avd"
33+
android:fromId="@id/checked"
34+
android:toId="@id/unchecked" />
35+
</animated-selector>
Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
3-
Copyright (C) 2014 The Android Open Source Project
2+
<!-- Copyright (C) 2022 Paranoid Android
43
54
Licensed under the Apache License, Version 2.0 (the "License");
65
you may not use this file except in compliance with the License.
@@ -14,15 +13,43 @@
1413
See the License for the specific language governing permissions and
1514
limitations under the License.
1615
-->
17-
<vector xmlns:android="http://schemas.android.com/apk/res/android"
18-
android:width="22dp"
19-
android:height="22dp"
20-
android:viewportWidth="22"
21-
android:viewportHeight="22"
22-
android:tint="?android:attr/textColorPrimary">
23-
16+
<vector
17+
xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:width="@dimen/qs_icon_size"
19+
android:height="@dimen/qs_icon_size"
20+
android:viewportWidth="24"
21+
android:viewportHeight="24">
2422
<path
25-
android:pathData="M 19.31 8 L 19.31 3.31 L 14.62 3.31 L 11.31 0 L 8 3.31 L 3.31 3.31 L 3.31 8 L 0 11.31 L 3.31 14.62 L 3.31 19.31 L 8 19.31 L 11.31 22.62 L 14.62 19.31 L 19.31 19.31 L 19.31 14.62 L 22.62 11.31 Z M 2.83 11.31 L 5.31 8.83 L 5.31 5.31 L 8.83 5.31 L 11.31 2.83 L 13.79 5.31 L 15.68 5.31 L 12.93 8.06 L 12.31 6.31 L 10.31 6.31 L 7.9 13.09 L 5.31 15.68 L 5.31 13.79 Z M 12.46 11.96 L 11.71 11.96 L 12.28 11.39 Z M 10.68 10.31 L 11.31 8.31 L 11.64 9.31 Z M 17.31 13.79 L 17.31 17.31 L 13.79 17.31 L 11.31 19.79 L 8.83 17.31 L 6.36 17.31 L 8.36 15.31 L 9 15.31 L 9.35 14.31 L 10.35 13.31 L 12.9 13.31 L 13.6 15.31 L 15.5 15.31 L 13.63 10 L 17.31 6.32 L 17.31 8.83 L 19.79 11.31 Z"
26-
android:fillColor="#ffffff"
27-
android:strokeWidth="1"/>
23+
android:name="sun"
24+
android:pathData="M 20 8.69 L 20 4 L 15.31 4 L 12 0.69 L 8.69 4 L 4 4 L 4 8.69 L 0.69 12 L 4 15.31 L 4 20 L 8.69 20 L 12 23.31 L 15.31 20 L 20 20 L 20 15.31 L 23.31 12 L 20 8.69 Z M 18 14.48 L 18 18 L 14.48 18 L 12 20.48 L 9.52 18 L 6 18 L 6 14.48 L 3.52 12 L 6 9.52 L 6 6 L 9.52 6 L 12 3.52 L 14.48 6 L 18 6 L 18 9.52 L 20.48 12 L 18 14.48 Z"
25+
android:fillColor="#ffffff" />
26+
<group android:name="mask_group">
27+
<clip-path
28+
android:name="mask"
29+
android:pathData="M 18 14.48 L 18 18 L 14.48 18 L 12 20.48 L 9.52 18 L 6 18 L 6 14.48 L 3.52 12 L 6 9.52 L 6 6 L 9.52 6 L 12 3.52 L 14.48 6 L 18 6 L 18 9.52 L 20.48 12 L 18 14.48 Z"/>
30+
<group
31+
android:name="auto_transform"
32+
android:pivotX="12"
33+
android:pivotY="12"
34+
android:translateX="-24"
35+
android:scaleX="0.5"
36+
android:scaleY="0.5">
37+
<path
38+
android:name="auto"
39+
android:pathData="M 11 7 L 7.8 16 L 9.7 16 L 10.4 14 L 13.6 14 L 14.3 16 L 16.2 16 L 13 7 L 11 7 Z M 12 9 L 13.15 12.65 L 10.85 12.65 L 12 9 Z"
40+
android:fillColor="#ffffff" />
41+
</group>
42+
<group
43+
android:name="manual_transform"
44+
android:pivotX="12"
45+
android:pivotY="12"
46+
android:translateX="0"
47+
android:scaleX="1"
48+
android:scaleY="1">
49+
<path
50+
android:name="manual"
51+
android:pathData="M 11.994 13.159 L 10.159 7.007 L 7.929 7.007 L 7.929 16 L 9.678 16 L 9.678 12.936 L 9.56 9.809 L 11.314 16 L 12.667 16 L 14.427 9.809 L 14.31 12.936 L 14.31 16 L 16.052 16 L 16.052 7.007 L 13.822 7.007 L 11.994 13.159 Z"
52+
android:fillColor="#ffffff" />
53+
</group>
54+
</group>
2855
</vector>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2022 Paranoid Android
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<animated-vector
17+
xmlns:android="http://schemas.android.com/apk/res/android"
18+
xmlns:aapt="http://schemas.android.com/aapt"
19+
android:drawable="@drawable/ic_qs_brightness_auto_off">
20+
<target android:name="auto_transform">
21+
<aapt:attr name="android:animation">
22+
<set>
23+
<objectAnimator
24+
android:propertyName="translateX"
25+
android:duration="300"
26+
android:valueFrom="0"
27+
android:valueTo="24"
28+
android:valueType="floatType"
29+
android:interpolator="@android:interpolator/fast_out_slow_in" />
30+
<objectAnimator
31+
android:propertyName="scaleX"
32+
android:duration="300"
33+
android:valueFrom="1"
34+
android:valueTo="0.5"
35+
android:valueType="floatType"
36+
android:interpolator="@android:interpolator/fast_out_slow_in" />
37+
<objectAnimator
38+
android:propertyName="scaleY"
39+
android:duration="300"
40+
android:valueFrom="1"
41+
android:valueTo="0.5"
42+
android:valueType="floatType"
43+
android:interpolator="@android:interpolator/fast_out_slow_in" />
44+
</set>
45+
</aapt:attr>
46+
</target>
47+
<target android:name="manual_transform">
48+
<aapt:attr name="android:animation">
49+
<set>
50+
<objectAnimator
51+
android:propertyName="translateX"
52+
android:duration="300"
53+
android:valueFrom="-24"
54+
android:valueTo="0"
55+
android:valueType="floatType"
56+
android:interpolator="@android:interpolator/fast_out_slow_in" />
57+
<objectAnimator
58+
android:propertyName="scaleX"
59+
android:duration="300"
60+
android:valueFrom="0.5"
61+
android:valueTo="1"
62+
android:valueType="floatType"
63+
android:interpolator="@android:interpolator/fast_out_slow_in" />
64+
<objectAnimator
65+
android:propertyName="scaleY"
66+
android:duration="300"
67+
android:valueFrom="0.5"
68+
android:valueTo="1"
69+
android:valueType="floatType"
70+
android:interpolator="@android:interpolator/fast_out_slow_in" />
71+
</set>
72+
</aapt:attr>
73+
</target>
74+
</animated-vector>
Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!--
3-
Copyright (C) 2014 The Android Open Source Project
2+
<!-- Copyright (C) 2022 Paranoid Android
43
54
Licensed under the Apache License, Version 2.0 (the "License");
65
you may not use this file except in compliance with the License.
@@ -14,13 +13,44 @@
1413
See the License for the specific language governing permissions and
1514
limitations under the License.
1615
-->
17-
<vector xmlns:android="http://schemas.android.com/apk/res/android"
18-
android:width="36.0dip"
19-
android:height="48.0dip"
20-
android:viewportWidth="36.0"
21-
android:viewportHeight="48.0"
22-
android:tint="?android:attr/textColorPrimaryInverse">
23-
24-
<path android:fillColor="#FFFFFFFF"
25-
android:pathData="m 17,19 -3.2,9 h 1.9 l 0.7,-2 h 3.2 l 0.7,2 h 1.9 L 19,19 Z M 16.85,24.65 18,21 19.15,24.65 Z M 26,20.69 V 16 H 21.31 L 18,12.69 14.69,16 H 10 v 4.69 L 6.69,24 10,27.31 V 32 h 4.69 L 18,35.31 21.31,32 H 26 V 27.31 L 29.31,24 Z m -2,5.79 V 30 H 20.48 L 18,32.48 15.52,30 H 12 V 26.48 L 9.52,24 12,21.52 V 18 h 3.52 L 18,15.52 20.48,18 H 24 v 3.52 L 26.48,24 Z" />
16+
<vector
17+
xmlns:android="http://schemas.android.com/apk/res/android"
18+
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
19+
android:width="@dimen/qs_icon_size"
20+
android:height="@dimen/qs_icon_size"
21+
android:viewportWidth="24"
22+
android:viewportHeight="24">
23+
<path
24+
android:name="sun"
25+
android:pathData="M 20 8.69 L 20 4 L 15.31 4 L 12 0.69 L 8.69 4 L 4 4 L 4 8.69 L 0.69 12 L 4 15.31 L 4 20 L 8.69 20 L 12 23.31 L 15.31 20 L 20 20 L 20 15.31 L 23.31 12 L 20 8.69 Z M 18 14.48 L 18 18 L 14.48 18 L 12 20.48 L 9.52 18 L 6 18 L 6 14.48 L 3.52 12 L 6 9.52 L 6 6 L 9.52 6 L 12 3.52 L 14.48 6 L 18 6 L 18 9.52 L 20.48 12 L 18 14.48 Z"
26+
android:fillColor="#ffffff" />
27+
<group android:name="mask_group">
28+
<clip-path
29+
android:name="mask"
30+
android:pathData="M 18 14.48 L 18 18 L 14.48 18 L 12 20.48 L 9.52 18 L 6 18 L 6 14.48 L 3.52 12 L 6 9.52 L 6 6 L 9.52 6 L 12 3.52 L 14.48 6 L 18 6 L 18 9.52 L 20.48 12 L 18 14.48 Z"/>
31+
<group
32+
android:name="auto_transform"
33+
android:pivotX="12"
34+
android:pivotY="12"
35+
android:translateX="0"
36+
android:scaleX="1"
37+
android:scaleY="1">
38+
<path
39+
android:name="auto"
40+
android:pathData="M 11 7 L 7.8 16 L 9.7 16 L 10.4 14 L 13.6 14 L 14.3 16 L 16.2 16 L 13 7 L 11 7 Z M 12 9 L 13.15 12.65 L 10.85 12.65 L 12 9 Z"
41+
android:fillColor="#ffffff" />
42+
</group>
43+
<group
44+
android:name="manual_transform"
45+
android:pivotX="12"
46+
android:pivotY="12"
47+
android:translateX="-24"
48+
android:scaleX="0.5"
49+
android:scaleY="0.5">
50+
<path
51+
android:name="manual"
52+
android:pathData="M 11.994 13.159 L 10.159 7.007 L 7.929 7.007 L 7.929 16 L 9.678 16 L 9.678 12.936 L 9.56 9.809 L 11.314 16 L 12.667 16 L 14.427 9.809 L 14.31 12.936 L 14.31 16 L 16.052 16 L 16.052 7.007 L 13.822 7.007 L 11.994 13.159 Z"
53+
android:fillColor="#ffffff" />
54+
</group>
55+
</group>
2656
</vector>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2022 Paranoid Android
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<animated-vector
17+
xmlns:android="http://schemas.android.com/apk/res/android"
18+
xmlns:aapt="http://schemas.android.com/aapt"
19+
android:drawable="@drawable/ic_qs_brightness_auto_on">
20+
<target android:name="auto_transform">
21+
<aapt:attr name="android:animation">
22+
<set>
23+
<objectAnimator
24+
android:propertyName="translateX"
25+
android:duration="300"
26+
android:valueFrom="-24"
27+
android:valueTo="0"
28+
android:valueType="floatType"
29+
android:interpolator="@android:interpolator/fast_out_slow_in" />
30+
<objectAnimator
31+
android:propertyName="scaleX"
32+
android:duration="300"
33+
android:valueFrom="0.5"
34+
android:valueTo="1"
35+
android:valueType="floatType"
36+
android:interpolator="@android:interpolator/fast_out_slow_in" />
37+
<objectAnimator
38+
android:propertyName="scaleY"
39+
android:duration="300"
40+
android:valueFrom="0.5"
41+
android:valueTo="1"
42+
android:valueType="floatType"
43+
android:interpolator="@android:interpolator/fast_out_slow_in" />
44+
</set>
45+
</aapt:attr>
46+
</target>
47+
<target android:name="manual_transform">
48+
<aapt:attr name="android:animation">
49+
<set>
50+
<objectAnimator
51+
android:propertyName="translateX"
52+
android:duration="300"
53+
android:valueFrom="0"
54+
android:valueTo="24"
55+
android:valueType="floatType"
56+
android:interpolator="@android:interpolator/fast_out_slow_in" />
57+
<objectAnimator
58+
android:propertyName="scaleX"
59+
android:duration="300"
60+
android:valueFrom="1"
61+
android:valueTo="0.5"
62+
android:valueType="floatType"
63+
android:interpolator="@android:interpolator/fast_out_slow_in" />
64+
<objectAnimator
65+
android:propertyName="scaleY"
66+
android:duration="300"
67+
android:valueFrom="1"
68+
android:valueTo="0.5"
69+
android:valueType="floatType"
70+
android:interpolator="@android:interpolator/fast_out_slow_in" />
71+
</set>
72+
</aapt:attr>
73+
</target>
74+
</animated-vector>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- Copyright (C) 2022 Paranoid Android
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
<com.android.systemui.settings.brightness.ToggleIconView
17+
xmlns:android="http://schemas.android.com/apk/res/android"
18+
android:id="@+id/toggle"
19+
android:layout_width="48dp"
20+
android:layout_height="48dp"
21+
android:layout_marginStart="8dp"
22+
android:button="@null"
23+
android:foreground="@drawable/ic_qs_brightness_auto"
24+
android:foregroundGravity="center"
25+
android:background="@drawable/qs_tile_background"
26+
android:clipToOutline="true" />

0 commit comments

Comments
 (0)