Skip to content

Commit b6f19d1

Browse files
wcshihunterstich
authored andcommitted
Add toggle to switch between enabling / disabling textfields.
Also added a button to toggle between showing/hiding leading icons in the exposed dropdown menu demo. PiperOrigin-RevId: 305468134
1 parent 72a710b commit b6f19d1

File tree

5 files changed

+82
-166
lines changed

5 files changed

+82
-166
lines changed

catalog/baseline.xml

Lines changed: 28 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
3-
Copyright 2019 The Android Open Source Project
3+
Copyright 2020 The Android Open Source Project
44
55
Licensed under the Apache License, Version 2.0 (the "License");
66
you may not use this file except in compliance with the License.
@@ -67,7 +67,7 @@
6767
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
6868
<location
6969
file="build.gradle"
70-
line="75"
70+
line="87"
7171
column="5"/>
7272
</issue>
7373

@@ -89,19 +89,19 @@
8989
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
9090
<location
9191
file="java/io/material/catalog/card/res/layout/cat_card_rich_media_demo_fragment.xml"
92-
line="94"
92+
line="93"
9393
column="13"/>
9494
</issue>
9595

9696
<issue
9797
id="UnusedAttribute"
9898
message="Attribute `layout_marginVertical` is only used in API level 26 and higher (current min is 14)"
99-
errorLine1=" android:layout_marginVertical=&quot;8dp&quot;"
100-
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
99+
errorLine1=" android:layout_marginVertical=&quot;8dp&quot;"
100+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
101101
<location
102102
file="java/io/material/catalog/tabs/res/layout/cat_tabs_main_content.xml"
103-
line="103"
104-
column="7"/>
103+
line="106"
104+
column="9"/>
105105
</issue>
106106

107107
<issue
@@ -243,7 +243,7 @@
243243
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
244244
<location
245245
file="java/io/material/catalog/themeswitcher/res/layout/mtrl_theme_switcher_dialog.xml"
246-
line="81"
246+
line="82"
247247
column="7"/>
248248
</issue>
249249

@@ -254,7 +254,7 @@
254254
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
255255
<location
256256
file="java/io/material/catalog/themeswitcher/res/layout/mtrl_theme_switcher_dialog.xml"
257-
line="120"
257+
line="121"
258258
column="7"/>
259259
</issue>
260260

@@ -273,28 +273,6 @@
273273
column="7"/>
274274
</issue>
275275

276-
<issue
277-
id="Deprecated"
278-
message="`android:editable` is deprecated: Use an `&lt;EditText>` to make it editable"
279-
errorLine1=" android:editable=&quot;false&quot;/>"
280-
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
281-
<location
282-
file="java/io/material/catalog/textfield/res/layout/cat_textfield_exposed_dropdown_menu_content.xml"
283-
line="39"
284-
column="9"/>
285-
</issue>
286-
287-
<issue
288-
id="Deprecated"
289-
message="`android:editable` is deprecated: Use an `&lt;EditText>` to make it editable"
290-
errorLine1=" android:editable=&quot;false&quot;/>"
291-
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~">
292-
<location
293-
file="java/io/material/catalog/textfield/res/layout/cat_textfield_exposed_dropdown_menu_content.xml"
294-
line="71"
295-
column="9"/>
296-
</issue>
297-
298276
<issue
299277
id="Typos"
300278
message="Repeated word &quot;very&quot; in message: possible typo"
@@ -526,17 +504,6 @@
526504
column="10"/>
527505
</issue>
528506

529-
<issue
530-
id="UnusedResources"
531-
message="The resource `R.dimen.cat_elevation_demo_card_bottom_padding` appears to be unused"
532-
errorLine1=" &lt;dimen name=&quot;cat_elevation_demo_card_bottom_padding&quot;>6dp&lt;/dimen>"
533-
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
534-
<location
535-
file="java/io/material/catalog/elevation/res/values/dimens.xml"
536-
line="21"
537-
column="10"/>
538-
</issue>
539-
540507
<issue
541508
id="UnusedResources"
542509
message="The resource `R.dimen.cat_toc_toolbar_image_offset` appears to be unused"
@@ -625,32 +592,6 @@
625592
column="1"/>
626593
</issue>
627594

628-
<issue
629-
id="UnusedResources"
630-
message="The resource `R.drawable.ic_lists_24px` appears to be unused"
631-
errorLine1="&lt;vector xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;"
632-
errorLine2="^">
633-
<location
634-
file="java/io/material/catalog/assets/res/drawable/ic_lists_24px.xml"
635-
line="16"
636-
column="1"/>
637-
</issue>
638-
639-
<issue
640-
id="UnusedResources"
641-
message="The resource `R.drawable.ic_placeholder` appears to be unused">
642-
<location
643-
file="java/io/material/catalog/assets/res/drawable-hdpi/ic_placeholder.png"/>
644-
<location
645-
file="java/io/material/catalog/assets/res/drawable-mdpi/ic_placeholder.png"/>
646-
<location
647-
file="java/io/material/catalog/assets/res/drawable-xhdpi/ic_placeholder.png"/>
648-
<location
649-
file="java/io/material/catalog/assets/res/drawable-xxhdpi/ic_placeholder.png"/>
650-
<location
651-
file="java/io/material/catalog/assets/res/drawable-xxxhdpi/ic_placeholder.png"/>
652-
</issue>
653-
654595
<issue
655596
id="UnusedResources"
656597
message="The resource `R.drawable.ic_progress_activity_24px` appears to be unused"
@@ -798,17 +739,6 @@
798739
column="1"/>
799740
</issue>
800741

801-
<issue
802-
id="UnusedResources"
803-
message="The resource `R.drawable.logo_avatar_anonymous_40dp` appears to be unused"
804-
errorLine1="&lt;vector xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;"
805-
errorLine2="^">
806-
<location
807-
file="java/io/material/catalog/assets/res/drawable/logo_avatar_anonymous_40dp.xml"
808-
line="16"
809-
column="1"/>
810-
</issue>
811-
812742
<issue
813743
id="UnusedResources"
814744
message="The resource `R.xml.standalone_chip` appears to be unused"
@@ -910,23 +840,23 @@
910840

911841
<issue
912842
id="UnusedResources"
913-
message="The resource `R.string.cat_bottomappbar_fab_circle` appears to be unused"
914-
errorLine1=" &lt;string name=&quot;cat_bottomappbar_fab_circle&quot;>Circle&lt;/string>"
915-
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
843+
message="The resource `R.string.cat_shape_theming_placeholder` appears to be unused"
844+
errorLine1=" &lt;string name=&quot;cat_shape_theming_placeholder&quot;>Shape theming demo coming soon...&lt;/string>"
845+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
916846
<location
917-
file="java/io/material/catalog/bottomappbar/res/values/strings.xml"
847+
file="java/io/material/catalog/shapetheming/res/values/strings.xml"
918848
line="35"
919849
column="11"/>
920850
</issue>
921851

922852
<issue
923853
id="UnusedResources"
924-
message="The resource `R.string.cat_shape_theming_placeholder` appears to be unused"
925-
errorLine1=" &lt;string name=&quot;cat_shape_theming_placeholder&quot;>Shape theming demo coming soon...&lt;/string>"
926-
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
854+
message="The resource `R.string.cat_bottomappbar_fab_circle` appears to be unused"
855+
errorLine1=" &lt;string name=&quot;cat_bottomappbar_fab_circle&quot;>Circle&lt;/string>"
856+
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
927857
<location
928-
file="java/io/material/catalog/shapetheming/res/values/strings.xml"
929-
line="35"
858+
file="java/io/material/catalog/bottomappbar/res/values/strings.xml"
859+
line="36"
930860
column="11"/>
931861
</issue>
932862

@@ -937,7 +867,7 @@
937867
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
938868
<location
939869
file="java/io/material/catalog/bottomappbar/res/values/strings.xml"
940-
line="36"
870+
line="37"
941871
column="11"/>
942872
</issue>
943873

@@ -1040,28 +970,6 @@
1040970
column="11"/>
1041971
</issue>
1042972

1043-
<issue
1044-
id="UnusedResources"
1045-
message="The resource `R.string.cat_textfield_disable` appears to be unused"
1046-
errorLine1=" &lt;string name=&quot;cat_textfield_disable&quot; translatable=&quot;false&quot;>Disable&lt;/string>"
1047-
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
1048-
<location
1049-
file="java/io/material/catalog/textfield/res/values/strings.xml"
1050-
line="76"
1051-
column="11"/>
1052-
</issue>
1053-
1054-
<issue
1055-
id="UnusedResources"
1056-
message="The resource `R.string.cat_textfield_enable` appears to be unused"
1057-
errorLine1=" &lt;string name=&quot;cat_textfield_enable&quot; translatable=&quot;false&quot;>Enable&lt;/string>"
1058-
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~">
1059-
<location
1060-
file="java/io/material/catalog/textfield/res/values/strings.xml"
1061-
line="77"
1062-
column="11"/>
1063-
</issue>
1064-
1065973
<issue
1066974
id="UselessParent"
1067975
message="This `ScrollView` layout or its `FrameLayout` parent is useless"
@@ -1123,28 +1031,6 @@
11231031
file="java/io/material/catalog/assets/res/drawable-xxhdpi"/>
11241032
</issue>
11251033

1126-
<issue
1127-
id="ButtonStyle"
1128-
message="Buttons in button bars should be borderless; use `style=&quot;?android:attr/buttonBarButtonStyle&quot;` (and `?android:attr/buttonBarStyle` on the parent)"
1129-
errorLine1=" &lt;Button"
1130-
errorLine2=" ~~~~~~">
1131-
<location
1132-
file="java/io/material/catalog/elevation/res/layout/cat_elevation_shadows_fragment.xml"
1133-
line="35"
1134-
column="8"/>
1135-
</issue>
1136-
1137-
<issue
1138-
id="ButtonStyle"
1139-
message="Buttons in button bars should be borderless; use `style=&quot;?android:attr/buttonBarButtonStyle&quot;` (and `?android:attr/buttonBarStyle` on the parent)"
1140-
errorLine1=" &lt;Button"
1141-
errorLine2=" ~~~~~~">
1142-
<location
1143-
file="java/io/material/catalog/elevation/res/layout/cat_elevation_shadows_fragment.xml"
1144-
line="42"
1145-
column="8"/>
1146-
</issue>
1147-
11481034
<issue
11491035
id="ButtonStyle"
11501036
message="Buttons in button bars should be borderless; use `style=&quot;?android:attr/buttonBarButtonStyle&quot;` (and `?android:attr/buttonBarStyle` on the parent)"
@@ -1427,7 +1313,7 @@
14271313
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
14281314
<location
14291315
file="java/io/material/catalog/themeswitcher/res/layout/mtrl_theme_switcher_dialog.xml"
1430-
line="86"
1316+
line="87"
14311317
column="7"/>
14321318
</issue>
14331319

@@ -1438,7 +1324,7 @@
14381324
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
14391325
<location
14401326
file="java/io/material/catalog/themeswitcher/res/layout/mtrl_theme_switcher_dialog.xml"
1441-
line="102"
1327+
line="103"
14421328
column="7"/>
14431329
</issue>
14441330

@@ -1702,7 +1588,7 @@
17021588
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
17031589
<location
17041590
file="java/io/material/catalog/card/res/layout/cat_card_rich_media_demo_fragment.xml"
1705-
line="81"
1591+
line="80"
17061592
column="15"/>
17071593
</issue>
17081594

@@ -1717,28 +1603,6 @@
17171603
column="5"/>
17181604
</issue>
17191605

1720-
<issue
1721-
id="RtlHardcoded"
1722-
message="Consider adding `android:layout_marginEnd=&quot;@dimen/cat_elevation_demo_text_padding&quot;` to better support right-to-left layouts"
1723-
errorLine1=" android:layout_marginRight=&quot;@dimen/cat_elevation_demo_text_padding&quot;"
1724-
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~~">
1725-
<location
1726-
file="java/io/material/catalog/elevation/res/layout/cat_elevation_shadows_fragment.xml"
1727-
line="40"
1728-
column="9"/>
1729-
</issue>
1730-
1731-
<issue
1732-
id="RtlHardcoded"
1733-
message="Consider adding `android:layout_marginStart=&quot;@dimen/cat_elevation_demo_text_padding&quot;` to better support right-to-left layouts"
1734-
errorLine1=" android:layout_marginLeft=&quot;@dimen/cat_elevation_demo_text_padding&quot;"
1735-
errorLine2=" ~~~~~~~~~~~~~~~~~~~~~~~~~">
1736-
<location
1737-
file="java/io/material/catalog/elevation/res/layout/cat_elevation_shadows_fragment.xml"
1738-
line="47"
1739-
column="9"/>
1740-
</issue>
1741-
17421606
<issue
17431607
id="RtlHardcoded"
17441608
message="Consider adding `android:layout_marginEnd=&quot;24dp&quot;` to better support right-to-left layouts"
@@ -1823,7 +1687,7 @@
18231687
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
18241688
<location
18251689
file="java/io/material/catalog/themeswitcher/res/layout/mtrl_theme_switcher_dialog.xml"
1826-
line="43"
1690+
line="44"
18271691
column="9"/>
18281692
</issue>
18291693

@@ -1834,7 +1698,7 @@
18341698
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
18351699
<location
18361700
file="java/io/material/catalog/themeswitcher/res/layout/mtrl_theme_switcher_dialog.xml"
1837-
line="44"
1701+
line="45"
18381702
column="9"/>
18391703
</issue>
18401704

@@ -1845,7 +1709,7 @@
18451709
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
18461710
<location
18471711
file="java/io/material/catalog/themeswitcher/res/layout/mtrl_theme_switcher_dialog.xml"
1848-
line="55"
1712+
line="56"
18491713
column="9"/>
18501714
</issue>
18511715

@@ -1856,7 +1720,7 @@
18561720
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
18571721
<location
18581722
file="java/io/material/catalog/themeswitcher/res/layout/mtrl_theme_switcher_dialog.xml"
1859-
line="56"
1723+
line="57"
18601724
column="9"/>
18611725
</issue>
18621726

@@ -1867,7 +1731,7 @@
18671731
errorLine2=" ~~~~~~~~~~~~~~~~~~~">
18681732
<location
18691733
file="java/io/material/catalog/themeswitcher/res/layout/mtrl_theme_switcher_dialog.xml"
1870-
line="67"
1734+
line="68"
18711735
column="9"/>
18721736
</issue>
18731737

@@ -1878,7 +1742,7 @@
18781742
errorLine2=" ~~~~~~~~~~~~~~~~~~~~">
18791743
<location
18801744
file="java/io/material/catalog/themeswitcher/res/layout/mtrl_theme_switcher_dialog.xml"
1881-
line="68"
1745+
line="69"
18821746
column="9"/>
18831747
</issue>
18841748

catalog/java/io/material/catalog/textfield/TextFieldControllableDemoFragment.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import android.view.View;
2626
import android.view.ViewGroup;
2727
import android.widget.Button;
28+
import com.google.android.material.switchmaterial.SwitchMaterial;
2829
import com.google.android.material.textfield.TextInputEditText;
2930
import com.google.android.material.textfield.TextInputLayout;
3031

@@ -106,6 +107,15 @@ public void initTextFieldDemoControls(LayoutInflater layoutInflater, View view)
106107
setAllTextFieldsCounterMax(length);
107108
}
108109
});
110+
111+
// Initializing switch to toggle between disabling or enabling text fields.
112+
SwitchMaterial enabledSwitch = view.findViewById(R.id.cat_textfield_enabled_switch);
113+
enabledSwitch.setOnCheckedChangeListener(
114+
(buttonView, isChecked) -> {
115+
for (TextInputLayout textfield : textfields) {
116+
textfield.setEnabled(isChecked);
117+
}
118+
});
109119
}
110120

111121
private void changeTextFieldColors(int color) {

0 commit comments

Comments
 (0)