• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5  * in compliance with the License. You may obtain a copy of the License at
6  *
7  * ```
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  * ```
10  *
11  * Unless required by applicable law or agreed to in writing, software distributed under the License
12  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13  * or implied. See the License for the specific language governing permissions and limitations under
14  * the License.
15  */
16 package com.android.healthconnect.controller.permissions.data
17 
18 import androidx.annotation.StringRes
19 import com.android.healthconnect.controller.R
20 import com.google.common.collect.ImmutableMap
21 
22 data class FitnessPermissionStrings(
23     @StringRes val uppercaseLabel: Int,
24     @StringRes val lowercaseLabel: Int,
25     @StringRes val readContentDescription: Int,
26     @StringRes val writeContentDescription: Int,
27 ) {
28     companion object {
fromPermissionTypenull29         fun fromPermissionType(
30             fitnessPermissionType: FitnessPermissionType
31         ): FitnessPermissionStrings {
32             return PERMISSION_TYPE_STRINGS[fitnessPermissionType]
33                 ?: throw IllegalArgumentException(
34                     "No strings for permission group " + fitnessPermissionType.name
35                 )
36         }
37     }
38 }
39 
40 private val PERMISSION_TYPE_STRINGS: ImmutableMap<FitnessPermissionType, FitnessPermissionStrings> =
41     ImmutableMap.Builder<FitnessPermissionType, FitnessPermissionStrings>()
42         .put(
43             FitnessPermissionType.ACTIVE_CALORIES_BURNED,
44             FitnessPermissionStrings(
45                 R.string.active_calories_burned_uppercase_label,
46                 R.string.active_calories_burned_lowercase_label,
47                 R.string.active_calories_burned_read_content_description,
48                 R.string.active_calories_burned_write_content_description,
49             ),
50         )
51         .put(
52             FitnessPermissionType.ACTIVITY_INTENSITY,
53             FitnessPermissionStrings(
54                 R.string.activity_intensity_uppercase_label,
55                 R.string.activity_intensity_lowercase_label,
56                 R.string.activity_intensity_read_content_description,
57                 R.string.activity_intensity_write_content_description,
58             ),
59         )
60         .put(
61             FitnessPermissionType.DISTANCE,
62             FitnessPermissionStrings(
63                 R.string.distance_uppercase_label,
64                 R.string.distance_lowercase_label,
65                 R.string.distance_read_content_description,
66                 R.string.distance_write_content_description,
67             ),
68         )
69         .put(
70             FitnessPermissionType.ELEVATION_GAINED,
71             FitnessPermissionStrings(
72                 R.string.elevation_gained_uppercase_label,
73                 R.string.elevation_gained_lowercase_label,
74                 R.string.elevation_gained_read_content_description,
75                 R.string.elevation_gained_write_content_description,
76             ),
77         )
78         .put(
79             FitnessPermissionType.EXERCISE,
80             FitnessPermissionStrings(
81                 R.string.exercise_uppercase_label,
82                 R.string.exercise_lowercase_label,
83                 R.string.exercise_read_content_description,
84                 R.string.exercise_write_content_description,
85             ),
86         )
87         .put(
88             FitnessPermissionType.SPEED,
89             FitnessPermissionStrings(
90                 R.string.speed_uppercase_label,
91                 R.string.speed_lowercase_label,
92                 R.string.speed_read_content_description,
93                 R.string.speed_write_content_description,
94             ),
95         )
96         .put(
97             FitnessPermissionType.POWER,
98             FitnessPermissionStrings(
99                 R.string.power_uppercase_label,
100                 R.string.power_lowercase_label,
101                 R.string.power_read_content_description,
102                 R.string.power_write_content_description,
103             ),
104         )
105         .put(
106             FitnessPermissionType.FLOORS_CLIMBED,
107             FitnessPermissionStrings(
108                 R.string.floors_climbed_uppercase_label,
109                 R.string.floors_climbed_lowercase_label,
110                 R.string.floors_climbed_read_content_description,
111                 R.string.floors_climbed_write_content_description,
112             ),
113         )
114         .put(
115             FitnessPermissionType.INTERMENSTRUAL_BLEEDING,
116             FitnessPermissionStrings(
117                 R.string.spotting_uppercase_label,
118                 R.string.spotting_lowercase_label,
119                 R.string.spotting_read_content_description,
120                 R.string.spotting_write_content_description,
121             ),
122         )
123         .put(
124             FitnessPermissionType.STEPS,
125             FitnessPermissionStrings(
126                 R.string.steps_uppercase_label,
127                 R.string.steps_lowercase_label,
128                 R.string.steps_read_content_description,
129                 R.string.steps_write_content_description,
130             ),
131         )
132         .put(
133             FitnessPermissionType.TOTAL_CALORIES_BURNED,
134             FitnessPermissionStrings(
135                 R.string.total_calories_burned_uppercase_label,
136                 R.string.total_calories_burned_lowercase_label,
137                 R.string.total_calories_burned_read_content_description,
138                 R.string.total_calories_burned_write_content_description,
139             ),
140         )
141         .put(
142             FitnessPermissionType.VO2_MAX,
143             FitnessPermissionStrings(
144                 R.string.vo2_max_uppercase_label,
145                 R.string.vo2_max_lowercase_label,
146                 R.string.vo2_max_read_content_description,
147                 R.string.vo2_max_write_content_description,
148             ),
149         )
150         .put(
151             FitnessPermissionType.WHEELCHAIR_PUSHES,
152             FitnessPermissionStrings(
153                 R.string.wheelchair_pushes_uppercase_label,
154                 R.string.wheelchair_pushes_lowercase_label,
155                 R.string.wheelchair_pushes_read_content_description,
156                 R.string.wheelchair_pushes_write_content_description,
157             ),
158         )
159         .put(
160             FitnessPermissionType.BASAL_METABOLIC_RATE,
161             FitnessPermissionStrings(
162                 R.string.basal_metabolic_rate_uppercase_label,
163                 R.string.basal_metabolic_rate_lowercase_label,
164                 R.string.basal_metabolic_rate_read_content_description,
165                 R.string.basal_metabolic_rate_write_content_description,
166             ),
167         )
168         .put(
169             FitnessPermissionType.BODY_FAT,
170             FitnessPermissionStrings(
171                 R.string.body_fat_uppercase_label,
172                 R.string.body_fat_lowercase_label,
173                 R.string.body_fat_read_content_description,
174                 R.string.body_fat_write_content_description,
175             ),
176         )
177         .put(
178             FitnessPermissionType.BODY_WATER_MASS,
179             FitnessPermissionStrings(
180                 R.string.body_water_mass_uppercase_label,
181                 R.string.body_water_mass_lowercase_label,
182                 R.string.body_water_mass_read_content_description,
183                 R.string.body_water_mass_write_content_description,
184             ),
185         )
186         .put(
187             FitnessPermissionType.BONE_MASS,
188             FitnessPermissionStrings(
189                 R.string.bone_mass_uppercase_label,
190                 R.string.bone_mass_lowercase_label,
191                 R.string.bone_mass_read_content_description,
192                 R.string.bone_mass_write_content_description,
193             ),
194         )
195         .put(
196             FitnessPermissionType.HEIGHT,
197             FitnessPermissionStrings(
198                 R.string.height_uppercase_label,
199                 R.string.height_lowercase_label,
200                 R.string.height_read_content_description,
201                 R.string.height_write_content_description,
202             ),
203         )
204         .put(
205             FitnessPermissionType.LEAN_BODY_MASS,
206             FitnessPermissionStrings(
207                 R.string.lean_body_mass_uppercase_label,
208                 R.string.lean_body_mass_lowercase_label,
209                 R.string.lean_body_mass_read_content_description,
210                 R.string.lean_body_mass_write_content_description,
211             ),
212         )
213         .put(
214             FitnessPermissionType.WEIGHT,
215             FitnessPermissionStrings(
216                 R.string.weight_uppercase_label,
217                 R.string.weight_lowercase_label,
218                 R.string.weight_read_content_description,
219                 R.string.weight_write_content_description,
220             ),
221         )
222         .put(
223             FitnessPermissionType.CERVICAL_MUCUS,
224             FitnessPermissionStrings(
225                 R.string.cervical_mucus_uppercase_label,
226                 R.string.cervical_mucus_lowercase_label,
227                 R.string.cervical_mucus_read_content_description,
228                 R.string.cervical_mucus_write_content_description,
229             ),
230         )
231         .put(
232             FitnessPermissionType.MENSTRUATION,
233             FitnessPermissionStrings(
234                 R.string.menstruation_uppercase_label,
235                 R.string.menstruation_lowercase_label,
236                 R.string.menstruation_read_content_description,
237                 R.string.menstruation_write_content_description,
238             ),
239         )
240         .put(
241             FitnessPermissionType.OVULATION_TEST,
242             FitnessPermissionStrings(
243                 R.string.ovulation_test_uppercase_label,
244                 R.string.ovulation_test_lowercase_label,
245                 R.string.ovulation_test_read_content_description,
246                 R.string.ovulation_test_write_content_description,
247             ),
248         )
249         .put(
250             FitnessPermissionType.SEXUAL_ACTIVITY,
251             FitnessPermissionStrings(
252                 R.string.sexual_activity_uppercase_label,
253                 R.string.sexual_activity_lowercase_label,
254                 R.string.sexual_activity_read_content_description,
255                 R.string.sexual_activity_write_content_description,
256             ),
257         )
258         .put(
259             FitnessPermissionType.HYDRATION,
260             FitnessPermissionStrings(
261                 R.string.hydration_uppercase_label,
262                 R.string.hydration_lowercase_label,
263                 R.string.hydration_read_content_description,
264                 R.string.hydration_write_content_description,
265             ),
266         )
267         .put(
268             FitnessPermissionType.NUTRITION,
269             FitnessPermissionStrings(
270                 R.string.nutrition_uppercase_label,
271                 R.string.nutrition_lowercase_label,
272                 R.string.nutrition_read_content_description,
273                 R.string.nutrition_write_content_description,
274             ),
275         )
276         .put(
277             FitnessPermissionType.SLEEP,
278             FitnessPermissionStrings(
279                 R.string.sleep_uppercase_label,
280                 R.string.sleep_lowercase_label,
281                 R.string.sleep_read_content_description,
282                 R.string.sleep_write_content_description,
283             ),
284         )
285         .put(
286             FitnessPermissionType.BASAL_BODY_TEMPERATURE,
287             FitnessPermissionStrings(
288                 R.string.basal_body_temperature_uppercase_label,
289                 R.string.basal_body_temperature_lowercase_label,
290                 R.string.basal_body_temperature_read_content_description,
291                 R.string.basal_body_temperature_write_content_description,
292             ),
293         )
294         .put(
295             FitnessPermissionType.BLOOD_GLUCOSE,
296             FitnessPermissionStrings(
297                 R.string.blood_glucose_uppercase_label,
298                 R.string.blood_glucose_lowercase_label,
299                 R.string.blood_glucose_read_content_description,
300                 R.string.blood_glucose_write_content_description,
301             ),
302         )
303         .put(
304             FitnessPermissionType.BLOOD_PRESSURE,
305             FitnessPermissionStrings(
306                 R.string.blood_pressure_uppercase_label,
307                 R.string.blood_pressure_lowercase_label,
308                 R.string.blood_pressure_read_content_description,
309                 R.string.blood_pressure_write_content_description,
310             ),
311         )
312         .put(
313             FitnessPermissionType.BODY_TEMPERATURE,
314             FitnessPermissionStrings(
315                 R.string.body_temperature_uppercase_label,
316                 R.string.body_temperature_lowercase_label,
317                 R.string.body_temperature_read_content_description,
318                 R.string.body_temperature_write_content_description,
319             ),
320         )
321         .put(
322             FitnessPermissionType.HEART_RATE,
323             FitnessPermissionStrings(
324                 R.string.heart_rate_uppercase_label,
325                 R.string.heart_rate_lowercase_label,
326                 R.string.heart_rate_read_content_description,
327                 R.string.heart_rate_write_content_description,
328             ),
329         )
330         .put(
331             FitnessPermissionType.HEART_RATE_VARIABILITY,
332             FitnessPermissionStrings(
333                 R.string.heart_rate_variability_uppercase_label,
334                 R.string.heart_rate_variability_lowercase_label,
335                 R.string.heart_rate_variability_read_content_description,
336                 R.string.heart_rate_variability_write_content_description,
337             ),
338         )
339         .put(
340             FitnessPermissionType.OXYGEN_SATURATION,
341             FitnessPermissionStrings(
342                 R.string.oxygen_saturation_uppercase_label,
343                 R.string.oxygen_saturation_lowercase_label,
344                 R.string.oxygen_saturation_read_content_description,
345                 R.string.oxygen_saturation_write_content_description,
346             ),
347         )
348         .put(
349             FitnessPermissionType.RESPIRATORY_RATE,
350             FitnessPermissionStrings(
351                 R.string.respiratory_rate_uppercase_label,
352                 R.string.respiratory_rate_lowercase_label,
353                 R.string.respiratory_rate_read_content_description,
354                 R.string.respiratory_rate_write_content_description,
355             ),
356         )
357         .put(
358             FitnessPermissionType.RESTING_HEART_RATE,
359             FitnessPermissionStrings(
360                 R.string.resting_heart_rate_uppercase_label,
361                 R.string.resting_heart_rate_lowercase_label,
362                 R.string.resting_heart_rate_read_content_description,
363                 R.string.resting_heart_rate_write_content_description,
364             ),
365         )
366         .put(
367             FitnessPermissionType.SKIN_TEMPERATURE,
368             FitnessPermissionStrings(
369                 R.string.skin_temperature_uppercase_label,
370                 R.string.skin_temperature_lowercase_label,
371                 R.string.skin_temperature_read_content_description,
372                 R.string.skin_temperature_write_content_description,
373             ),
374         )
375         .put(
376             FitnessPermissionType.EXERCISE_ROUTE,
377             FitnessPermissionStrings(
378                 R.string.exercise_route_uppercase_label,
379                 R.string.exercise_route_lowercase_label,
380                 R.string.exercise_route_read_content_description,
381                 R.string.exercise_route_write_content_description,
382             ),
383         )
384         .put(
385             FitnessPermissionType.PLANNED_EXERCISE,
386             FitnessPermissionStrings(
387                 R.string.planned_exercise_uppercase_label,
388                 R.string.planned_exercise_lowercase_label,
389                 R.string.planned_exercise_read_content_description,
390                 R.string.planned_exercise_write_content_description,
391             ),
392         )
393         .put(
394             FitnessPermissionType.MINDFULNESS,
395             FitnessPermissionStrings(
396                 R.string.mindfulness_uppercase_label,
397                 R.string.mindfulness_lowercase_label,
398                 R.string.mindfulness_read_content_description,
399                 R.string.mindfulness_write_content_description,
400             ),
401         )
402         .buildOrThrow()
403