Skip to content

Commit 9405a52

Browse files
afohrmancketcham
authored andcommitted
Split icon text field demos into their own demos.
Now that there are a nice amount of text fields in the controllable text field demos, the controls are hidden in almost all cases. Splitting the icon text field demos into their own demos to avoid hiding the text field demo controls. PiperOrigin-RevId: 239257310
1 parent 0ce688d commit 9405a52

File tree

8 files changed

+309
-172
lines changed

8 files changed

+309
-172
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2019 The Android Open Source Project
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+
* https://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+
17+
package io.material.catalog.textfield;
18+
19+
import io.material.catalog.R;
20+
21+
import androidx.annotation.LayoutRes;
22+
23+
/**
24+
* A fragment that displays the filled text field demos with start and end icons and controls for
25+
* the Catalog app.
26+
*/
27+
public class TextFieldFilledIconsDemoFragment extends TextFieldFilledDemoFragment {
28+
29+
@Override
30+
@LayoutRes
31+
public int getTextFieldContent() {
32+
return R.layout.cat_textfield_filled_icons_content;
33+
}
34+
}

catalog/java/io/material/catalog/textfield/TextFieldFragment.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,27 @@ public Fragment createFragment() {
6363
return new TextFieldFilledDemoFragment();
6464
}
6565
});
66+
additionalDemos.add(
67+
new Demo(R.string.cat_textfield_filled_icons_demo_title) {
68+
@Override
69+
public Fragment createFragment() {
70+
return new TextFieldFilledIconsDemoFragment();
71+
}
72+
});
6673
additionalDemos.add(
6774
new Demo(R.string.cat_textfield_outlined_demo_title) {
6875
@Override
6976
public Fragment createFragment() {
7077
return new TextFieldOutlinedDemoFragment();
7178
}
7279
});
80+
additionalDemos.add(
81+
new Demo(R.string.cat_textfield_outlined_icons_demo_title) {
82+
@Override
83+
public Fragment createFragment() {
84+
return new TextFieldOutlinedIconsDemoFragment();
85+
}
86+
});
7387
additionalDemos.add(
7488
new Demo(R.string.cat_textfield_legacy_demo_title) {
7589
@Override
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2019 The Android Open Source Project
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+
* https://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+
17+
package io.material.catalog.textfield;
18+
19+
import io.material.catalog.R;
20+
21+
import androidx.annotation.LayoutRes;
22+
23+
/**
24+
* A fragment that displays the outlined text field demos with start and end icons and controls for
25+
* the Catalog app.
26+
*/
27+
public class TextFieldOutlinedIconsDemoFragment extends TextFieldOutlinedDemoFragment {
28+
29+
@Override
30+
@LayoutRes
31+
public int getTextFieldContent() {
32+
return R.layout.cat_textfield_outlined_icons_content;
33+
}
34+
}

catalog/java/io/material/catalog/textfield/res/layout/cat_textfield_filled_content.xml

Lines changed: 1 addition & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
android:layout_width="match_parent"
2222
android:layout_height="wrap_content"
2323
android:orientation="vertical">
24+
2425
<com.google.android.material.textfield.TextInputLayout
2526
android:layout_width="match_parent"
2627
android:layout_height="wrap_content"
@@ -52,90 +53,4 @@
5253
android:layout_height="wrap_content"/>
5354
</com.google.android.material.textfield.TextInputLayout>
5455

55-
<com.google.android.material.textfield.TextInputLayout
56-
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.Dense"
57-
android:layout_width="match_parent"
58-
android:layout_height="wrap_content"
59-
android:layout_margin="4dp"
60-
android:hint="@string/cat_textfield_password"
61-
app:endIconMode="password_toggle"
62-
app:errorEnabled="true"
63-
app:helperText="@string/cat_textfield_filled_dense_password_helper_text"
64-
app:helperTextEnabled="true">
65-
<com.google.android.material.textfield.TextInputEditText
66-
android:layout_width="match_parent"
67-
android:layout_height="wrap_content"
68-
android:inputType="textPassword"/>
69-
</com.google.android.material.textfield.TextInputLayout>
70-
71-
<com.google.android.material.textfield.TextInputLayout
72-
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
73-
android:layout_width="match_parent"
74-
android:layout_height="wrap_content"
75-
android:layout_margin="4dp"
76-
android:hint="@string/cat_textfield_label"
77-
app:endIconMode="clear_text"
78-
app:errorEnabled="true"
79-
app:helperText="@string/cat_textfield_filled_clear_button_helper_text"
80-
app:helperTextEnabled="true">
81-
<com.google.android.material.textfield.TextInputEditText
82-
android:layout_width="match_parent"
83-
android:layout_height="wrap_content"/>
84-
</com.google.android.material.textfield.TextInputLayout>
85-
86-
<com.google.android.material.textfield.TextInputLayout
87-
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
88-
android:layout_width="match_parent"
89-
android:layout_height="wrap_content"
90-
android:layout_margin="4dp"
91-
android:hint="@string/cat_textfield_label"
92-
app:endIconContentDescription="@string/cat_textfield_custom_end_icon_content_description"
93-
app:endIconDrawable="@drawable/ic_accelerator_24px"
94-
app:endIconMode="custom"
95-
app:errorEnabled="true"
96-
app:helperText="@string/cat_textfield_filled_custom_end_icon_helper_text"
97-
app:helperTextEnabled="true">
98-
<com.google.android.material.textfield.TextInputEditText
99-
android:layout_width="match_parent"
100-
android:layout_height="wrap_content"/>
101-
</com.google.android.material.textfield.TextInputLayout>
102-
103-
<com.google.android.material.textfield.TextInputLayout
104-
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
105-
android:layout_width="match_parent"
106-
android:layout_height="wrap_content"
107-
android:layout_margin="4dp"
108-
android:hint="@string/cat_textfield_label"
109-
app:counterEnabled="true"
110-
app:counterMaxLength="10"
111-
app:errorEnabled="true"
112-
app:helperText="@string/cat_textfield_filled_start_icon_helper_text"
113-
app:helperTextEnabled="true"
114-
app:startIconContentDescription="@string/cat_textfield_custom_start_icon_content_description"
115-
app:startIconDrawable="@drawable/ic_search_24px">
116-
<com.google.android.material.textfield.TextInputEditText
117-
android:layout_width="match_parent"
118-
android:layout_height="wrap_content"/>
119-
</com.google.android.material.textfield.TextInputLayout>
120-
121-
<com.google.android.material.textfield.TextInputLayout
122-
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
123-
android:layout_width="match_parent"
124-
android:layout_height="wrap_content"
125-
android:layout_margin="4dp"
126-
android:hint="@string/cat_textfield_label"
127-
app:counterEnabled="true"
128-
app:counterMaxLength="10"
129-
app:endIconContentDescription="@string/cat_textfield_custom_end_icon_content_description"
130-
app:endIconDrawable="@drawable/ic_accelerator_24px"
131-
app:endIconMode="custom"
132-
app:errorEnabled="true"
133-
app:helperText="@string/cat_textfield_filled_start_end_icons_helper_text"
134-
app:helperTextEnabled="true"
135-
app:startIconContentDescription="@string/cat_textfield_custom_start_icon_content_description"
136-
app:startIconDrawable="@drawable/ic_search_24px">
137-
<com.google.android.material.textfield.TextInputEditText
138-
android:layout_width="match_parent"
139-
android:layout_height="wrap_content"/>
140-
</com.google.android.material.textfield.TextInputLayout>
14156
</LinearLayout>
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright 2019 The Android Open Source Project
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+
~ https://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+
<LinearLayout
19+
xmlns:android="http://schemas.android.com/apk/res/android"
20+
xmlns:app="http://schemas.android.com/apk/res-auto"
21+
android:layout_width="match_parent"
22+
android:layout_height="wrap_content"
23+
android:orientation="vertical">
24+
25+
<com.google.android.material.textfield.TextInputLayout
26+
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox.Dense"
27+
android:layout_width="match_parent"
28+
android:layout_height="wrap_content"
29+
android:layout_margin="4dp"
30+
android:hint="@string/cat_textfield_password"
31+
app:endIconMode="password_toggle"
32+
app:errorEnabled="true"
33+
app:helperText="@string/cat_textfield_filled_dense_password_helper_text"
34+
app:helperTextEnabled="true">
35+
<com.google.android.material.textfield.TextInputEditText
36+
android:layout_width="match_parent"
37+
android:layout_height="wrap_content"
38+
android:inputType="textPassword"/>
39+
</com.google.android.material.textfield.TextInputLayout>
40+
41+
<com.google.android.material.textfield.TextInputLayout
42+
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
43+
android:layout_width="match_parent"
44+
android:layout_height="wrap_content"
45+
android:layout_margin="4dp"
46+
android:hint="@string/cat_textfield_label"
47+
app:endIconMode="clear_text"
48+
app:errorEnabled="true"
49+
app:helperText="@string/cat_textfield_filled_clear_button_helper_text"
50+
app:helperTextEnabled="true">
51+
<com.google.android.material.textfield.TextInputEditText
52+
android:layout_width="match_parent"
53+
android:layout_height="wrap_content"/>
54+
</com.google.android.material.textfield.TextInputLayout>
55+
56+
<com.google.android.material.textfield.TextInputLayout
57+
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
58+
android:layout_width="match_parent"
59+
android:layout_height="wrap_content"
60+
android:layout_margin="4dp"
61+
android:hint="@string/cat_textfield_label"
62+
app:endIconContentDescription="@string/cat_textfield_custom_end_icon_content_description"
63+
app:endIconDrawable="@drawable/ic_accelerator_24px"
64+
app:endIconMode="custom"
65+
app:errorEnabled="true"
66+
app:helperText="@string/cat_textfield_filled_custom_end_icon_helper_text"
67+
app:helperTextEnabled="true">
68+
<com.google.android.material.textfield.TextInputEditText
69+
android:layout_width="match_parent"
70+
android:layout_height="wrap_content"/>
71+
</com.google.android.material.textfield.TextInputLayout>
72+
73+
<com.google.android.material.textfield.TextInputLayout
74+
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
75+
android:layout_width="match_parent"
76+
android:layout_height="wrap_content"
77+
android:layout_margin="4dp"
78+
android:hint="@string/cat_textfield_label"
79+
app:counterEnabled="true"
80+
app:counterMaxLength="10"
81+
app:errorEnabled="true"
82+
app:helperText="@string/cat_textfield_filled_start_icon_helper_text"
83+
app:helperTextEnabled="true"
84+
app:startIconContentDescription="@string/cat_textfield_custom_start_icon_content_description"
85+
app:startIconDrawable="@drawable/ic_search_24px">
86+
<com.google.android.material.textfield.TextInputEditText
87+
android:layout_width="match_parent"
88+
android:layout_height="wrap_content"/>
89+
</com.google.android.material.textfield.TextInputLayout>
90+
91+
<com.google.android.material.textfield.TextInputLayout
92+
style="@style/Widget.MaterialComponents.TextInputLayout.FilledBox"
93+
android:layout_width="match_parent"
94+
android:layout_height="wrap_content"
95+
android:layout_margin="4dp"
96+
android:hint="@string/cat_textfield_label"
97+
app:counterEnabled="true"
98+
app:counterMaxLength="10"
99+
app:endIconContentDescription="@string/cat_textfield_custom_end_icon_content_description"
100+
app:endIconDrawable="@drawable/ic_accelerator_24px"
101+
app:endIconMode="custom"
102+
app:errorEnabled="true"
103+
app:helperText="@string/cat_textfield_filled_start_end_icons_helper_text"
104+
app:helperTextEnabled="true"
105+
app:startIconContentDescription="@string/cat_textfield_custom_start_icon_content_description"
106+
app:startIconDrawable="@drawable/ic_search_24px">
107+
<com.google.android.material.textfield.TextInputEditText
108+
android:layout_width="match_parent"
109+
android:layout_height="wrap_content"/>
110+
</com.google.android.material.textfield.TextInputLayout>
111+
112+
</LinearLayout>

0 commit comments

Comments
 (0)