Skip to content

Commit 68cc1fe

Browse files
committedAug 18, 2016
Animated DN password visibility toggle.
1 parent 98d4c4b commit 68cc1fe

7 files changed

+298
-1
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2016 Google Inc.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<animated-selector xmlns:android="http://schemas.android.com/apk/res/android">
19+
20+
<item
21+
android:id="@+id/visible"
22+
android:state_checked="true"
23+
android:drawable="@drawable/ic_password_visible" />
24+
25+
<item
26+
android:id="@+id/masked"
27+
android:drawable="@drawable/ic_password_masked" />
28+
29+
<transition
30+
android:fromId="@id/masked"
31+
android:toId="@id/visible"
32+
android:drawable="@drawable/avd_show_password" />
33+
34+
<transition
35+
android:fromId="@id/visible"
36+
android:toId="@id/masked"
37+
android:drawable="@drawable/avd_hide_password" />
38+
39+
</animated-selector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2015 Google Inc.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<animated-vector
19+
xmlns:android="http://schemas.android.com/apk/res/android"
20+
xmlns:aapt="http://schemas.android.com/aapt">
21+
22+
<aapt:attr name="android:drawable">
23+
24+
<vector
25+
android:width="24dp"
26+
android:height="24dp"
27+
android:viewportWidth="24"
28+
android:viewportHeight="24">
29+
30+
<path
31+
android:name="strike_through"
32+
android:pathData="@string/path_password_strike_through"
33+
android:strokeColor="@android:color/white"
34+
android:strokeWidth="1.8"
35+
android:strokeLineCap="square"
36+
android:trimPathEnd="0" />
37+
38+
<group>
39+
40+
<clip-path
41+
android:name="eye_mask"
42+
android:pathData="@string/path_password_eye_mask_visible" />
43+
44+
<path
45+
android:name="eye"
46+
android:fillColor="@android:color/white"
47+
android:pathData="@string/path_password_eye" />
48+
49+
</group>
50+
51+
</vector>
52+
53+
</aapt:attr>
54+
55+
<target android:name="eye_mask">
56+
57+
<aapt:attr name="android:animation">
58+
59+
<objectAnimator
60+
android:propertyName="pathData"
61+
android:valueFrom="@string/path_password_eye_mask_visible"
62+
android:valueTo="@string/path_password_eye_mask_strike_through"
63+
android:duration="@integer/password_strike"
64+
android:interpolator="@android:interpolator/fast_out_slow_in"
65+
android:valueType="pathType" />
66+
67+
</aapt:attr>
68+
69+
</target>
70+
71+
<target android:name="strike_through">
72+
73+
<aapt:attr name="android:animation">
74+
75+
<objectAnimator
76+
android:propertyName="trimPathEnd"
77+
android:valueFrom="0"
78+
android:valueTo="1"
79+
android:duration="@integer/password_strike"
80+
android:interpolator="@android:interpolator/fast_out_slow_in" />
81+
82+
</aapt:attr>
83+
84+
</target>
85+
86+
</animated-vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2015 Google Inc.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<animated-vector
19+
xmlns:android="http://schemas.android.com/apk/res/android"
20+
xmlns:aapt="http://schemas.android.com/aapt">
21+
22+
<aapt:attr name="android:drawable">
23+
24+
<vector
25+
android:width="24dp"
26+
android:height="24dp"
27+
android:viewportWidth="24"
28+
android:viewportHeight="24">
29+
30+
<path
31+
android:name="strike_through"
32+
android:pathData="@string/path_password_strike_through"
33+
android:strokeColor="@android:color/white"
34+
android:strokeWidth="1.8"
35+
android:strokeLineCap="square" />
36+
37+
<group>
38+
39+
<clip-path
40+
android:name="eye_mask"
41+
android:pathData="@string/path_password_eye_mask_strike_through" />
42+
43+
<path
44+
android:name="eye"
45+
android:fillColor="@android:color/white"
46+
android:pathData="@string/path_password_eye" />
47+
48+
</group>
49+
50+
</vector>
51+
52+
</aapt:attr>
53+
54+
<target android:name="eye_mask">
55+
56+
<aapt:attr name="android:animation">
57+
58+
<objectAnimator
59+
android:propertyName="pathData"
60+
android:valueFrom="@string/path_password_eye_mask_strike_through"
61+
android:valueTo="@string/path_password_eye_mask_visible"
62+
android:duration="@integer/password_strike"
63+
android:interpolator="@android:interpolator/fast_out_slow_in"
64+
android:valueType="pathType" />
65+
66+
</aapt:attr>
67+
68+
</target>
69+
70+
<target android:name="strike_through">
71+
72+
<aapt:attr name="android:animation">
73+
74+
<objectAnimator
75+
android:propertyName="trimPathEnd"
76+
android:valueFrom="1"
77+
android:valueTo="0"
78+
android:duration="@integer/password_strike"
79+
android:interpolator="@android:interpolator/fast_out_slow_in" />
80+
81+
</aapt:attr>
82+
83+
</target>
84+
85+
</animated-vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2016 Google Inc.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<vector
19+
xmlns:android="http://schemas.android.com/apk/res/android"
20+
android:width="24dp"
21+
android:height="24dp"
22+
android:viewportWidth="24"
23+
android:viewportHeight="24">
24+
25+
<path
26+
android:pathData="M12,7c2.76,0 5,2.24 5,5 0,0.65 -0.13,1.26 -0.36,1.83l2.92,2.92c1.51,-1.26 2.7,-2.89 3.43,-4.75 -1.73,-4.39 -6,-7.5 -11,-7.5 -1.4,0 -2.74,0.25 -3.98,0.7l2.16,2.16C10.74,7.13 11.35,7 12,7zM2,4.27l2.28,2.28 0.46,0.46C3.08,8.3 1.78,10.02 1,12c1.73,4.39 6,7.5 11,7.5 1.55,0 3.03,-0.3 4.38,-0.84l0.42,0.42L19.73,22 21,20.73 3.27,3 2,4.27zM7.53,9.8l1.55,1.55c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.66 1.34,3 3,3 0.22,0 0.44,-0.03 0.65,-0.08l1.55,1.55c-0.67,0.33 -1.41,0.53 -2.2,0.53 -2.76,0 -5,-2.24 -5,-5 0,-0.79 0.2,-1.53 0.53,-2.2zM11.84,9.02l3.15,3.15 0.02,-0.16c0,-1.66 -1.34,-3 -3,-3l-0.17,0.01z"
27+
android:fillColor="@android:color/white" />
28+
29+
</vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2016 Google Inc.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<vector
19+
xmlns:android="http://schemas.android.com/apk/res/android"
20+
android:width="24dp"
21+
android:height="24dp"
22+
android:viewportWidth="24"
23+
android:viewportHeight="24">
24+
25+
<path
26+
android:pathData="@string/path_password_eye"
27+
android:fillColor="@android:color/white" />
28+
29+
</vector>

‎app/src/main/res/layout/activity_designer_news_login.xml

+3-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@
8181
android:layout_width="match_parent"
8282
android:layout_height="wrap_content"
8383
android:layout_marginStart="@dimen/spacing_micro"
84-
app:hintTextAppearance="@style/TextAppearance.FloatLabelHint">
84+
app:hintTextAppearance="@style/TextAppearance.FloatLabelHint"
85+
app:passwordToggleDrawable="@drawable/asl_password_visibility"
86+
app:passwordToggleTint="?colorControlNormal">
8587

8688
<android.support.design.widget.TextInputEditText
8789
android:id="@+id/password"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2016 Google Inc.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<resources>
19+
20+
<!-- resources used in the password visibility anim, see @drawable/asl_password_visibility -->
21+
<string name="path_password_eye_mask_visible">M2,4.27 L2,4.27 L4.54,1.73 L4.54,1.73 L4.54,1 L23,1 L23,23 L1,23 L1,4.27 Z</string>
22+
<string name="path_password_eye_mask_strike_through">M2,4.27 L19.73,22 L22.27,19.46 L4.54,1.73 L4.54,1 L23,1 L23,23 L1,23 L1,4.27 Z</string>
23+
<string name="path_password_eye">M12,4.5C7,4.5 2.73,7.61 1,12c1.73,4.39 6,7.5 11,7.5s9.27,-3.11 11,-7.5c-1.73,-4.39 -6,-7.5 -11,-7.5zM12,17c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5zM12,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3 3,-1.34 3,-3 -1.34,-3 -3,-3z</string>
24+
<string name="path_password_strike_through">M3.27,4.27 L19.74,20.74</string>
25+
<integer name="password_strike">320</integer>
26+
27+
</resources>

0 commit comments

Comments
 (0)