1 /* 2 * Copyright (C) 2025 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 * http://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 package com.android.healthconnect.controller.data.entries 17 18 import android.health.connect.MedicalResourceId 19 import android.health.connect.datatypes.ExercisePerformanceGoal 20 import android.health.connect.datatypes.ExerciseRoute 21 import android.health.connect.datatypes.PlannedExerciseBlock 22 import android.health.connect.datatypes.PlannedExerciseStep 23 import com.android.healthconnect.controller.shared.DataType 24 import com.android.healthconnect.controller.shared.recyclerview.RecyclerViewItemDisplayType 25 import com.android.healthconnect.controller.shared.recyclerview.RecyclerViewItemDisplayType.GROUP_ITEM 26 import com.android.healthconnect.controller.shared.recyclerview.RecyclerViewItemDisplayType.HEADER_ITEM 27 import com.android.healthconnect.controller.shared.recyclerview.RecyclerViewItemDisplayType.SPACE 28 import com.android.healthconnect.controller.shared.recyclerview.RecyclerViewItemDisplayType.STANDALONE_ITEM 29 import com.android.healthconnect.controller.shared.recyclerview.RecyclerViewItemDisplayType.UNKNOWN 30 import java.time.Instant 31 32 sealed class FormattedEntry( 33 open val uuid: String, 34 val displayType: RecyclerViewItemDisplayType = UNKNOWN, 35 ) { 36 interface HasDataType { 37 val dataType: DataType 38 } 39 40 data class FormattedDataEntry( 41 override val uuid: String, 42 val header: String, 43 val headerA11y: String, 44 val title: String, 45 val titleA11y: String, 46 override val dataType: DataType, 47 val startTime: Instant? = null, 48 val endTime: Instant? = null, 49 ) : FormattedEntry(uuid, GROUP_ITEM), HasDataType 50 51 data class FormattedMedicalDataEntry( 52 val header: String, 53 val headerA11y: String, 54 val title: String, 55 val titleA11y: String, 56 val time: Instant? = null, 57 val medicalResourceId: MedicalResourceId, 58 ) : FormattedEntry(uuid = "", GROUP_ITEM) 59 60 data class SleepSessionEntry( 61 override val uuid: String, 62 val header: String, 63 val headerA11y: String, 64 val title: String, 65 val titleA11y: String, 66 override val dataType: DataType, 67 val notes: String?, 68 ) : FormattedEntry(uuid, GROUP_ITEM), HasDataType 69 70 data class ExerciseSessionEntry( 71 override val uuid: String, 72 val header: String, 73 val headerA11y: String, 74 val title: String, 75 val titleA11y: String, 76 override val dataType: DataType, 77 val notes: String?, 78 val route: ExerciseRoute? = null, 79 val isClickable: Boolean = true, 80 ) : FormattedEntry(uuid, GROUP_ITEM), HasDataType 81 82 data class SeriesDataEntry( 83 override val uuid: String, 84 val header: String, 85 val headerA11y: String, 86 val title: String, 87 val titleA11y: String, 88 override val dataType: DataType, 89 ) : FormattedEntry(uuid, GROUP_ITEM), HasDataType 90 91 data class SessionHeader(val header: String) : FormattedEntry(uuid = "", HEADER_ITEM) 92 93 data class FormattedSectionTitle(val title: String) : FormattedEntry(uuid = "", HEADER_ITEM) 94 95 data class FormattedSectionContent(val title: String, val bulleted: Boolean = false) : 96 FormattedEntry(uuid = "", GROUP_ITEM) 97 98 data class ItemDataEntrySeparator(val title: String = "") : FormattedEntry(uuid = "", SPACE) 99 100 data class SelectAllHeader(val title: String = "Select all") : 101 FormattedEntry(uuid = "", STANDALONE_ITEM) 102 103 data class ReverseSessionDetail( 104 override val uuid: String, 105 val header: String, 106 val headerA11y: String, 107 val title: String, 108 val titleA11y: String, 109 ) : FormattedEntry(uuid, GROUP_ITEM) 110 111 data class FormattedSessionDetail( 112 override val uuid: String, 113 val header: String, 114 val headerA11y: String, 115 val title: String, 116 val titleA11y: String, 117 ) : FormattedEntry(uuid, GROUP_ITEM) 118 119 data class FormattedAggregation( 120 val aggregation: String, 121 val aggregationA11y: String, 122 val contributingApps: String, 123 ) : FormattedEntry(aggregation, STANDALONE_ITEM) 124 125 data class EntryDateSectionHeader(val date: String) : FormattedEntry(date, HEADER_ITEM) 126 127 data class PlannedExerciseSessionEntry( 128 override val uuid: String, 129 val header: String, 130 val headerA11y: String, 131 val title: String, 132 override val dataType: DataType, 133 val titleA11y: String, 134 val notes: String?, 135 ) : FormattedEntry(uuid, GROUP_ITEM), HasDataType 136 137 data class PlannedExerciseBlockEntry( 138 val block: PlannedExerciseBlock, 139 val title: String, 140 val titleA11y: String, 141 ) : FormattedEntry(uuid = "", UNKNOWN) 142 143 data class PlannedExerciseStepEntry( 144 val step: PlannedExerciseStep, 145 val title: String, 146 val titleA11y: String, 147 ) : FormattedEntry(uuid = "", UNKNOWN) 148 149 data class ExercisePerformanceGoalEntry( 150 val goal: ExercisePerformanceGoal, 151 val title: String, 152 val titleA11y: String, 153 ) : FormattedEntry(uuid = "", UNKNOWN) 154 } 155