• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.android.healthconnect.controller.permissions.data
2 
3 import androidx.annotation.StringRes
4 import com.android.healthconnect.controller.R
5 import com.google.common.collect.ImmutableMap
6 
7 data class HealthPermissionStrings(
8     @StringRes val uppercaseLabel: Int,
9     @StringRes val lowercaseLabel: Int,
10     @StringRes val readContentDescription: Int,
11     @StringRes val writeContentDescription: Int
12 ) {
13     companion object {
fromPermissionTypenull14         fun fromPermissionType(
15             healthPermissionType: HealthPermissionType
16         ): HealthPermissionStrings {
17             return PERMISSION_TYPE_STRINGS[healthPermissionType]
18                 ?: throw IllegalArgumentException(
19                     "No strings for permission group " + healthPermissionType.name)
20         }
21     }
22 }
23 
24 private val PERMISSION_TYPE_STRINGS: ImmutableMap<HealthPermissionType, HealthPermissionStrings> =
25     ImmutableMap.Builder<HealthPermissionType, HealthPermissionStrings>()
26         .put(
27             HealthPermissionType.ACTIVE_CALORIES_BURNED,
28             HealthPermissionStrings(
29                 R.string.active_calories_burned_uppercase_label,
30                 R.string.active_calories_burned_lowercase_label,
31                 R.string.active_calories_burned_read_content_description,
32                 R.string.active_calories_burned_write_content_description))
33         .put(
34             HealthPermissionType.DISTANCE,
35             HealthPermissionStrings(
36                 R.string.distance_uppercase_label,
37                 R.string.distance_lowercase_label,
38                 R.string.distance_read_content_description,
39                 R.string.distance_write_content_description))
40         .put(
41             HealthPermissionType.ELEVATION_GAINED,
42             HealthPermissionStrings(
43                 R.string.elevation_gained_uppercase_label,
44                 R.string.elevation_gained_lowercase_label,
45                 R.string.elevation_gained_read_content_description,
46                 R.string.elevation_gained_write_content_description))
47         .put(
48             HealthPermissionType.EXERCISE,
49             HealthPermissionStrings(
50                 R.string.exercise_uppercase_label,
51                 R.string.exercise_lowercase_label,
52                 R.string.exercise_read_content_description,
53                 R.string.exercise_write_content_description))
54         .put(
55             HealthPermissionType.SPEED,
56             HealthPermissionStrings(
57                 R.string.speed_uppercase_label,
58                 R.string.speed_lowercase_label,
59                 R.string.speed_read_content_description,
60                 R.string.speed_write_content_description))
61         .put(
62             HealthPermissionType.POWER,
63             HealthPermissionStrings(
64                 R.string.power_uppercase_label,
65                 R.string.power_lowercase_label,
66                 R.string.power_read_content_description,
67                 R.string.power_write_content_description))
68         .put(
69             HealthPermissionType.FLOORS_CLIMBED,
70             HealthPermissionStrings(
71                 R.string.floors_climbed_uppercase_label,
72                 R.string.floors_climbed_lowercase_label,
73                 R.string.floors_climbed_read_content_description,
74                 R.string.floors_climbed_write_content_description))
75         .put(
76             HealthPermissionType.INTERMENSTRUAL_BLEEDING,
77             HealthPermissionStrings(
78                 R.string.spotting_uppercase_label,
79                 R.string.spotting_lowercase_label,
80                 R.string.spotting_read_content_description,
81                 R.string.spotting_write_content_description))
82         .put(
83             HealthPermissionType.STEPS,
84             HealthPermissionStrings(
85                 R.string.steps_uppercase_label,
86                 R.string.steps_lowercase_label,
87                 R.string.steps_read_content_description,
88                 R.string.steps_write_content_description))
89         .put(
90             HealthPermissionType.TOTAL_CALORIES_BURNED,
91             HealthPermissionStrings(
92                 R.string.total_calories_burned_uppercase_label,
93                 R.string.total_calories_burned_lowercase_label,
94                 R.string.total_calories_burned_read_content_description,
95                 R.string.total_calories_burned_write_content_description))
96         .put(
97             HealthPermissionType.VO2_MAX,
98             HealthPermissionStrings(
99                 R.string.vo2_max_uppercase_label,
100                 R.string.vo2_max_lowercase_label,
101                 R.string.vo2_max_read_content_description,
102                 R.string.vo2_max_write_content_description))
103         .put(
104             HealthPermissionType.WHEELCHAIR_PUSHES,
105             HealthPermissionStrings(
106                 R.string.wheelchair_pushes_uppercase_label,
107                 R.string.wheelchair_pushes_lowercase_label,
108                 R.string.wheelchair_pushes_read_content_description,
109                 R.string.wheelchair_pushes_write_content_description))
110         .put(
111             HealthPermissionType.BASAL_METABOLIC_RATE,
112             HealthPermissionStrings(
113                 R.string.basal_metabolic_rate_uppercase_label,
114                 R.string.basal_metabolic_rate_lowercase_label,
115                 R.string.basal_metabolic_rate_read_content_description,
116                 R.string.basal_metabolic_rate_write_content_description))
117         .put(
118             HealthPermissionType.BODY_FAT,
119             HealthPermissionStrings(
120                 R.string.body_fat_uppercase_label,
121                 R.string.body_fat_lowercase_label,
122                 R.string.body_fat_read_content_description,
123                 R.string.body_fat_write_content_description))
124         .put(
125             HealthPermissionType.BODY_WATER_MASS,
126             HealthPermissionStrings(
127                 R.string.body_water_mass_uppercase_label,
128                 R.string.body_water_mass_lowercase_label,
129                 R.string.body_water_mass_read_content_description,
130                 R.string.body_water_mass_write_content_description))
131         .put(
132             HealthPermissionType.BONE_MASS,
133             HealthPermissionStrings(
134                 R.string.bone_mass_uppercase_label,
135                 R.string.bone_mass_lowercase_label,
136                 R.string.bone_mass_read_content_description,
137                 R.string.bone_mass_write_content_description))
138         .put(
139             HealthPermissionType.HEIGHT,
140             HealthPermissionStrings(
141                 R.string.height_uppercase_label,
142                 R.string.height_lowercase_label,
143                 R.string.height_read_content_description,
144                 R.string.height_write_content_description))
145         .put(
146             HealthPermissionType.LEAN_BODY_MASS,
147             HealthPermissionStrings(
148                 R.string.lean_body_mass_uppercase_label,
149                 R.string.lean_body_mass_lowercase_label,
150                 R.string.lean_body_mass_read_content_description,
151                 R.string.lean_body_mass_write_content_description))
152         .put(
153             HealthPermissionType.WEIGHT,
154             HealthPermissionStrings(
155                 R.string.weight_uppercase_label,
156                 R.string.weight_lowercase_label,
157                 R.string.weight_read_content_description,
158                 R.string.weight_write_content_description))
159         .put(
160             HealthPermissionType.CERVICAL_MUCUS,
161             HealthPermissionStrings(
162                 R.string.cervical_mucus_uppercase_label,
163                 R.string.cervical_mucus_lowercase_label,
164                 R.string.cervical_mucus_read_content_description,
165                 R.string.cervical_mucus_write_content_description))
166         .put(
167             HealthPermissionType.MENSTRUATION,
168             HealthPermissionStrings(
169                 R.string.menstruation_uppercase_label,
170                 R.string.menstruation_lowercase_label,
171                 R.string.menstruation_read_content_description,
172                 R.string.menstruation_write_content_description))
173         .put(
174             HealthPermissionType.OVULATION_TEST,
175             HealthPermissionStrings(
176                 R.string.ovulation_test_uppercase_label,
177                 R.string.ovulation_test_lowercase_label,
178                 R.string.ovulation_test_read_content_description,
179                 R.string.ovulation_test_write_content_description))
180         .put(
181             HealthPermissionType.SEXUAL_ACTIVITY,
182             HealthPermissionStrings(
183                 R.string.sexual_activity_uppercase_label,
184                 R.string.sexual_activity_lowercase_label,
185                 R.string.sexual_activity_read_content_description,
186                 R.string.sexual_activity_write_content_description))
187         .put(
188             HealthPermissionType.HYDRATION,
189             HealthPermissionStrings(
190                 R.string.hydration_uppercase_label,
191                 R.string.hydration_lowercase_label,
192                 R.string.hydration_read_content_description,
193                 R.string.hydration_write_content_description))
194         .put(
195             HealthPermissionType.NUTRITION,
196             HealthPermissionStrings(
197                 R.string.nutrition_uppercase_label,
198                 R.string.nutrition_lowercase_label,
199                 R.string.nutrition_read_content_description,
200                 R.string.nutrition_write_content_description))
201         .put(
202             HealthPermissionType.SLEEP,
203             HealthPermissionStrings(
204                 R.string.sleep_uppercase_label,
205                 R.string.sleep_lowercase_label,
206                 R.string.sleep_read_content_description,
207                 R.string.sleep_write_content_description))
208         .put(
209             HealthPermissionType.BASAL_BODY_TEMPERATURE,
210             HealthPermissionStrings(
211                 R.string.basal_body_temperature_uppercase_label,
212                 R.string.basal_body_temperature_lowercase_label,
213                 R.string.basal_body_temperature_read_content_description,
214                 R.string.basal_body_temperature_write_content_description))
215         .put(
216             HealthPermissionType.BLOOD_GLUCOSE,
217             HealthPermissionStrings(
218                 R.string.blood_glucose_uppercase_label,
219                 R.string.blood_glucose_lowercase_label,
220                 R.string.blood_glucose_read_content_description,
221                 R.string.blood_glucose_write_content_description))
222         .put(
223             HealthPermissionType.BLOOD_PRESSURE,
224             HealthPermissionStrings(
225                 R.string.blood_pressure_uppercase_label,
226                 R.string.blood_pressure_lowercase_label,
227                 R.string.blood_pressure_read_content_description,
228                 R.string.blood_pressure_write_content_description))
229         .put(
230             HealthPermissionType.BODY_TEMPERATURE,
231             HealthPermissionStrings(
232                 R.string.body_temperature_uppercase_label,
233                 R.string.body_temperature_lowercase_label,
234                 R.string.body_temperature_read_content_description,
235                 R.string.body_temperature_write_content_description))
236         .put(
237             HealthPermissionType.HEART_RATE,
238             HealthPermissionStrings(
239                 R.string.heart_rate_uppercase_label,
240                 R.string.heart_rate_lowercase_label,
241                 R.string.heart_rate_read_content_description,
242                 R.string.heart_rate_write_content_description))
243         .put(
244             HealthPermissionType.HEART_RATE_VARIABILITY,
245             HealthPermissionStrings(
246                 R.string.heart_rate_variability_uppercase_label,
247                 R.string.heart_rate_variability_lowercase_label,
248                 R.string.heart_rate_variability_read_content_description,
249                 R.string.heart_rate_variability_write_content_description))
250         .put(
251             HealthPermissionType.OXYGEN_SATURATION,
252             HealthPermissionStrings(
253                 R.string.oxygen_saturation_uppercase_label,
254                 R.string.oxygen_saturation_lowercase_label,
255                 R.string.oxygen_saturation_read_content_description,
256                 R.string.oxygen_saturation_write_content_description))
257         .put(
258             HealthPermissionType.RESPIRATORY_RATE,
259             HealthPermissionStrings(
260                 R.string.respiratory_rate_uppercase_label,
261                 R.string.respiratory_rate_lowercase_label,
262                 R.string.respiratory_rate_read_content_description,
263                 R.string.respiratory_rate_write_content_description))
264         .put(
265             HealthPermissionType.RESTING_HEART_RATE,
266             HealthPermissionStrings(
267                 R.string.resting_heart_rate_uppercase_label,
268                 R.string.resting_heart_rate_lowercase_label,
269                 R.string.resting_heart_rate_read_content_description,
270                 R.string.resting_heart_rate_write_content_description))
271         .put(
272             HealthPermissionType.EXERCISE_ROUTE,
273             HealthPermissionStrings(
274                 R.string.exercise_route_uppercase_label,
275                 R.string.exercise_route_lowercase_label,
276                 R.string.exercise_route_read_content_description,
277                 R.string.exercise_route_write_content_description,
278             ))
279         .buildOrThrow()
280