···33 * License, v. 2.0. If a copy of the MPL was not distributed with this
44 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
55 */
66- package com.example.util.simpletimetracker.wear
66+package com.example.util.simpletimetracker.wear
7788import com.example.util.simpletimetracker.domain.interactor.PrefsInteractor
99+import com.example.util.simpletimetracker.domain.interactor.RecordTagInteractor
910import com.example.util.simpletimetracker.domain.interactor.RecordTypeInteractor
1011import com.example.util.simpletimetracker.domain.interactor.RunningRecordInteractor
1112import com.example.util.simpletimetracker.domain.mapper.AppColorMapper
···1516import com.example.util.simpletimetracker.wearrpc.SimpleTimeTrackerAPI
1617import com.example.util.simpletimetracker.wearrpc.Tag
17181818-class DomainAPI (
1919+class DomainAPI(
1920 private val prefsInteractor: PrefsInteractor,
2021 private val recordTypeInteractor: RecordTypeInteractor,
2222+ private val recordTagInteractor: RecordTagInteractor,
2123 private val runningRecordInteractor: RunningRecordInteractor,
2224 private val appColorMapper: AppColorMapper,
2323-): SimpleTimeTrackerAPI {
2525+) : SimpleTimeTrackerAPI {
24262527 override suspend fun queryActivities(): Array<Activity> {
2626- return recordTypeInteractor.getAll()
2727- .filter { recordType -> !recordType.hidden }
2828+ return recordTypeInteractor.getAll().filter { recordType -> !recordType.hidden }
2829 .map { recordType ->
2930 val color = appColorMapper.mapToColorInt(recordType.color)
3031 val hex = String.format("#%06X", (0xFFFFFF and color))
3132 Activity(recordType.id, recordType.name, recordType.icon, hex)
3232- }
3333- .toTypedArray()
3333+ }.toTypedArray()
3434 }
35353636 override suspend fun queryCurrentActivities(): Array<CurrentActivity> {
···3838 CurrentActivity(
3939 it.id,
4040 it.timeStarted,
4141- arrayOf() // TODO - Pull actual list of active tags
4141+ arrayOf(), // TODO - Pull actual list of active tags
4242 )
4343 }.toTypedArray()
4444 }
···5454 // Activities in the given Array that are not running should be started
55555656 // For activities in the given Array which are running...
5757- // If the start dates + tags are unchanged, then leave the activity running.
5858- // If the start dates and/or tags are different, stop the current running activity
5959- // instance and restart it as of the requested start date.
5757+ // If the start dates + tags are unchanged, then leave the activity running.
5858+ // If the start dates and/or tags are different, stop the current running activity
5959+ // instance and restart it as of the requested start date.
60606161 }
62626363 override suspend fun queryTagsForActivity(activityId: Long): Array<Tag> {
6464- TODO("Not yet implemented")
6565- // Look up the tags which can be associated with this activity and return them
6464+ return recordTagInteractor.getByTypeOrUntyped(activityId).filter { !it.archived }.map {
6565+ Tag(id = it.id, name = it.name)
6666+ }.toTypedArray()
6667 }
67686869 override suspend fun querySettings(): Settings {