Skip to content

Commit d9653b6

Browse files
santosh-pingleSantosh Pingle
and
Santosh Pingle
authored
Per question custom style (google#2636)
* per question custom style * adding missing file. * update default style. * textAppearance support * rename custom attributes. * github documentation for custom style example. * Address review comments. * address review comment. * update text format icon as component icon. * code cleanup. * Code refactoring and cleanup. * custom style example with multiple question items. * Address review comments. * support prefix per question item custom style * Revert dataconfig changes for custom style mapping. * Address review comments. * Address review comments. * Address review comments. * Address review comments. * Address review comment. --------- Co-authored-by: Santosh Pingle <[email protected]>
1 parent 65ffde8 commit d9653b6

File tree

15 files changed

+897
-3
lines changed

15 files changed

+897
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
{
2+
"resourceType": "Questionnaire",
3+
"item": [
4+
{
5+
"linkId": "1",
6+
"text": "Custom style 1",
7+
"type": "display",
8+
"extension": [
9+
{
10+
"url": "https://github.com/google/android-fhir/tree/master/datacapture/android-style",
11+
"extension": [
12+
{
13+
"url": "question_text_view",
14+
"valueString": "CustomStyle_1"
15+
}
16+
]
17+
}
18+
]
19+
},
20+
{
21+
"linkId": "2",
22+
"text": "Custom style 2",
23+
"type": "display",
24+
"extension": [
25+
{
26+
"url": "https://github.com/google/android-fhir/tree/master/datacapture/android-style",
27+
"extension": [
28+
{
29+
"url": "question_text_view",
30+
"valueString": "CustomStyle_2"
31+
}
32+
]
33+
}
34+
]
35+
},
36+
{
37+
"linkId": "3",
38+
"text": "Custom style 3",
39+
"type": "display",
40+
"extension": [
41+
{
42+
"url": "https://github.com/google/android-fhir/tree/master/datacapture/android-style",
43+
"extension": [
44+
{
45+
"url": "question_text_view",
46+
"valueString": "CustomStyle_3"
47+
}
48+
]
49+
}
50+
]
51+
},
52+
{
53+
"linkId": "4",
54+
"text": "Custom style 4",
55+
"type": "display",
56+
"extension": [
57+
{
58+
"url": "https://github.com/google/android-fhir/tree/master/datacapture/android-style",
59+
"extension": [
60+
{
61+
"url": "question_text_view",
62+
"valueString": "CustomStyle_4"
63+
}
64+
]
65+
}
66+
]
67+
},
68+
{
69+
"linkId": "5",
70+
"text": "Custom style 5",
71+
"type": "display",
72+
"extension": [
73+
{
74+
"url": "https://github.com/google/android-fhir/tree/master/datacapture/android-style",
75+
"extension": [
76+
{
77+
"url": "question_text_view",
78+
"valueString": "CustomStyle_5"
79+
}
80+
]
81+
}
82+
]
83+
},
84+
{
85+
"linkId": "6",
86+
"text": "Custom style 6",
87+
"type": "display",
88+
"extension": [
89+
{
90+
"url": "https://github.com/google/android-fhir/tree/master/datacapture/android-style",
91+
"extension": [
92+
{
93+
"url": "question_text_view",
94+
"valueString": "CustomStyle_6"
95+
}
96+
]
97+
}
98+
]
99+
},
100+
{
101+
"linkId": "7",
102+
"text": "Custom style 7",
103+
"type": "display",
104+
"extension": [
105+
{
106+
"url": "https://github.com/google/android-fhir/tree/master/datacapture/android-style",
107+
"extension": [
108+
{
109+
"url": "question_text_view",
110+
"valueString": "CustomStyle_7"
111+
}
112+
]
113+
}
114+
]
115+
},
116+
{
117+
"linkId": "8",
118+
"text": "Custom style 8",
119+
"type": "display",
120+
"extension": [
121+
{
122+
"url": "https://github.com/google/android-fhir/tree/master/datacapture/android-style",
123+
"extension": [
124+
{
125+
"url": "question_text_view",
126+
"valueString": "CustomStyle_8"
127+
}
128+
]
129+
}
130+
]
131+
},
132+
{
133+
"linkId": "9",
134+
"text": "Custom style 9",
135+
"type": "display",
136+
"extension": [
137+
{
138+
"url": "https://github.com/google/android-fhir/tree/master/datacapture/android-style",
139+
"extension": [
140+
{
141+
"url": "question_text_view",
142+
"valueString": "CustomStyle_9"
143+
}
144+
]
145+
}
146+
]
147+
}
148+
]
149+
}

catalog/src/main/java/com/google/android/fhir/catalog/ComponentListViewModel.kt

+6
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ class ComponentListViewModel(application: Application, private val state: SavedS
152152
R.string.component_name_location_widget,
153153
"component_location_widget.json",
154154
),
155+
QUESTION_ITEM_CUSTOM_STYLE(
156+
R.drawable.text_format_48dp,
157+
R.string.component_name_per_question_custom_style,
158+
"component_per_question_custom_style.json",
159+
),
155160
}
156161

157162
val viewItemList =
@@ -177,6 +182,7 @@ class ComponentListViewModel(application: Application, private val state: SavedS
177182
ViewItem.ComponentItem(Component.ITEM_ANSWER_MEDIA),
178183
ViewItem.ComponentItem(Component.INITIAL_VALUE),
179184
ViewItem.ComponentItem(Component.LOCATION_WIDGET),
185+
ViewItem.ComponentItem(Component.QUESTION_ITEM_CUSTOM_STYLE),
180186
)
181187

182188
fun isComponent(context: Context, title: String) =

catalog/src/main/res/drawable/ic_location_on.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<vector
22
xmlns:android="http://schemas.android.com/apk/res/android"
3-
android:width="128dp"
4-
android:height="128dp"
3+
android:width="64dp"
4+
android:height="64dp"
55
android:tint="#1A73E8"
66
android:viewportWidth="24"
77
android:viewportHeight="24"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<vector
2+
xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:autoMirrored="true"
4+
android:height="64dp"
5+
android:viewportHeight="960"
6+
android:viewportWidth="960"
7+
android:width="64dp"
8+
>
9+
10+
<path
11+
android:fillColor="#1A73E8"
12+
android:pathData="M200,760v-60h560v60L200,760ZM276,600 L451,160h58l175,440h-55l-45,-119L376,481l-45,119h-55ZM393,436h174l-85,-222h-4l-85,222Z"
13+
/>
14+
15+
</vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<!--
3+
Copyright 2020 Google LLC
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+
<resources>
18+
<color name="custom_style_primary_100">#000000</color>
19+
<color name="custom_style_primary_200">#0C0A20</color>
20+
<color name="custom_style_primary_300">#201441</color>
21+
<color name="custom_style_primary_400">#341F63</color>
22+
<color name="custom_style_primary_500">#482A85</color>
23+
<color name="custom_style_primary_600">#5C35A6</color>
24+
<color name="custom_style_primary_700">#7F5FBA</color>
25+
<color name="custom_style_primary_800">#A289CF</color>
26+
<color name="custom_style_primary_900">#C5B3E3</color>
27+
<color name="custom_style_on_primary_100">#FFFFFF</color>
28+
<color name="custom_style_on_primary_200">#FFFFFF</color>
29+
<color name="custom_style_on_primary_300">#FFFFFF</color>
30+
<color name="custom_style_on_primary_400">#FFFFFF</color>
31+
<color name="custom_style_on_primary_500">#FFFFFF</color>
32+
<color name="custom_style_on_primary_600">#FFFFFF</color>
33+
<color name="custom_style_on_primary_700">#FFFFFF</color>
34+
<color name="custom_style_on_primary_800">#000000</color>
35+
<color name="custom_style_on_primary_900">#000000</color>
36+
</resources>

catalog/src/main/res/values/colors.xml

+22
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,26 @@
102102
<color name="onSurfaceVariant_neutral_variant_80">#C4C7C5</color>
103103

104104
<color name="outline_neutral_variant_60">#8E918F</color>
105+
106+
<!-- colors for custom style example -->
107+
<color name="custom_style_primary_900">#7A9FFF</color>
108+
<color name="custom_style_primary_800">#668FFF</color>
109+
<color name="custom_style_primary_700">#5581FF</color>
110+
<color name="custom_style_primary_600">#476FFF</color>
111+
<color name="custom_style_primary_500">#3B5CFF</color>
112+
<color name="custom_style_primary_400">#3249FF</color>
113+
<color name="custom_style_primary_300">#2936FF</color>
114+
<color name="custom_style_primary_200">#2024FF</color>
115+
<color name="custom_style_primary_100">#1816FF</color>
116+
<color name="custom_style_on_primary">#FFFFFF</color>
117+
<color name="custom_style_on_primary_900">#FFFFFF</color>
118+
<color name="custom_style_on_primary_800">#FFFFFF</color>
119+
<color name="custom_style_on_primary_700">#FFFFFF</color>
120+
<color name="custom_style_on_primary_600">#FFFFFF</color>
121+
<color name="custom_style_on_primary_500">#FFFFFF</color>
122+
<color name="custom_style_on_primary_400">#FFFFFF</color>
123+
<color name="custom_style_on_primary_300">#FFFFFF</color>
124+
<color name="custom_style_on_primary_200">#FFFFFF</color>
125+
<color name="custom_style_on_primary_100">#FFFFFF</color>
126+
105127
</resources>

catalog/src/main/res/values/strings.xml

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
<string name="component_name_repeated_group">Repeated Group</string>
3838
<string name="component_name_attachment">Attachment</string>
3939
<string name="component_name_location_widget">Location Widget</string>
40+
<string
41+
name="component_name_per_question_custom_style"
42+
>Per question custom style</string>
4043
<string name="layout_name_default_text">Default</string>
4144
<string name="layout_name_paginated">Paginated</string>
4245
<string name="layout_name_review">Review</string>

0 commit comments

Comments
 (0)