···11+import com.example.util.simpletimetracker.Deps
22+13/*
24 * This Source Code Form is subject to the terms of the Mozilla Public
35 * License, v. 2.0. If a copy of the MPL was not distributed with this
···79plugins {
810 id("com.android.application")
911 id("kotlin-android")
1212+ id("kotlin-kapt")
1313+ id("dagger.hilt.android.plugin")
1014}
11151216android {
···7478 // Default Dependencies
7579 implementation("androidx.core:core-ktx:1.7.0")
7680 implementation("com.google.android.gms:play-services-wearable:17.1.0")
8181+ implementation(Deps.Google.gson)
7782 implementation("androidx.percentlayout:percentlayout:1.0.0")
7883 implementation("androidx.legacy:legacy-support-v4:1.0.0")
7984 implementation("androidx.recyclerview:recyclerview:1.2.1")
···8489 implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1")
8590 implementation("androidx.activity:activity-compose:1.3.1")
8691 implementation("androidx.appcompat:appcompat:1.6.0")
9292+9393+ implementation(Deps.Google.dagger)
9494+ kapt(Deps.Kapt.dagger)
9595+9696+ testImplementation(Deps.Test.junit)
9797+ testImplementation(Deps.Test.coroutines)
8798 androidTestImplementation("androidx.compose.ui:ui-test-junit4:$compose_version")
8899 debugImplementation("androidx.compose.ui:ui-tooling:$compose_version")
89100 debugImplementation("androidx.compose.ui:ui-test-manifest:$compose_version")
···11+/*
22+ * This Source Code Form is subject to the terms of the Mozilla Public
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.presentation.data
77+88+// TODO catch exception and show error?
99+class WearRPCException(message: String) : Exception(message)
···55 */
66package com.example.util.simpletimetracker.wearrpc
7788+import android.os.Parcelable
99+import kotlinx.parcelize.Parcelize
1010+811/**
912 * Data Transfer Objects
1013 *
1114 * Object definitions for records sent between Wear/Mobile
1215 */
13161717+@Parcelize
1418data class Activity(
1519 val id: Long,
1620 val name: String,
1721 val icon: String,
1822 val color: Long,
1919-)
2323+): Parcelable
20242525+@Parcelize
2126data class CurrentActivity(
2227 val id: Long,
2328 val startedAt: Long,
2429 val tags: List<Tag>,
2525-)
3030+): Parcelable
26313232+@Parcelize
2733data class Tag(
2834 val id: Long,
2935 val name: String,
3036 val isGeneral: Boolean,
3137 val color: Long,
3232-)
3838+): Parcelable
33394040+@Parcelize
3441data class Settings(
3542 val allowMultitasking: Boolean,
3643 val showRecordTagSelection: Boolean,
3744 val recordTagSelectionCloseAfterOne: Boolean,
3845 val recordTagSelectionEvenForGeneralTags: Boolean,
3939-)4646+): Parcelable
···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.wearrpc
66+package com.example.util.simpletimetracker.presentation.mediators
77+88+import com.example.util.simpletimetracker.wearrpc.Activity
99+import com.example.util.simpletimetracker.wearrpc.Settings
1010+import com.example.util.simpletimetracker.wearrpc.WearCommunicationAPI
711812class StartActivityMediator(
913 private val api: WearCommunicationAPI,
···3636 *
3737 * Replaces the currently running activity/activities with the given activities
3838 */
3939- suspend fun setCurrentActivities(activities: List<CurrentActivity>)
3939+ suspend fun setCurrentActivities(starting: List<CurrentActivity>)
40404141 /**
4242 * [Request.QUERY_TAGS_FOR_ACTIVITY]
···11-/*
22- * This Source Code Form is subject to the terms of the Mozilla Public
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.wearrpc
77-88-class WearRPCException(message: String) : Exception(message) {}
···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.wearrpc
66+package com.example.util.simpletimetracker.wear
7788+import com.example.util.simpletimetracker.presentation.mediators.StartActivityMediator
99+import com.example.util.simpletimetracker.wearrpc.Activity
1010+import com.example.util.simpletimetracker.wearrpc.MockWearCommunicationAPI
1111+import com.example.util.simpletimetracker.wearrpc.Settings
1212+import com.example.util.simpletimetracker.wearrpc.Tag
813import kotlinx.coroutines.test.runTest
914import org.junit.Assert.assertEquals
1015import org.junit.Before
···6671 recordTagSelectionEvenForGeneralTags = false,
6772 ),
6873 )
6969- api.mock_queryTagsForActivity(mapOf(sampleActivity.id to arrayOf(sampleGeneralTag)))
7474+ api.mock_queryTagsForActivity(mapOf(sampleActivity.id to listOf(sampleGeneralTag)))
7075 mediator.requestStart(sampleActivity)
7176 `assert only start callback invoked`()
7277 }
···8085 @Test
8186 fun `activity has non-general tags`() = runTest {
8287 api.mock_querySettings(sampleSettings)
8383- api.mock_queryTagsForActivity(mapOf(sampleActivity.id to arrayOf(sampleNonGeneralTag)))
8888+ api.mock_queryTagsForActivity(mapOf(sampleActivity.id to listOf(sampleNonGeneralTag)))
8489 mediator.requestStart(sampleActivity)
8590 `assert only tag callback invoked`()
8691 }
···8893 @Test
8994 fun `activity has only general tags and tag selection enabled for only generals`() = runTest {
9095 api.mock_querySettings(sampleSettings.copy(recordTagSelectionEvenForGeneralTags = true))
9191- api.mock_queryTagsForActivity(mapOf(sampleActivity.id to arrayOf(sampleGeneralTag)))
9696+ api.mock_queryTagsForActivity(mapOf(sampleActivity.id to listOf(sampleGeneralTag)))
9297 mediator.requestStart(sampleActivity)
9398 `assert only tag callback invoked`()
9499 }