File tree Expand file tree Collapse file tree 7 files changed +33
-7
lines changed
buildSrc/src/main/kotlin/com/example/util/simpletimetracker
features/feature_wear/src/main/java/com/example/util/simpletimetracker/feature_wear
wear_api/src/main/java/com/example/util/simpletimetracker/wear_api
main/java/com/example/util/simpletimetracker
features/tagsSelection/viewModel
test/java/com/example/util/simpletimetracker/wear Expand file tree Collapse file tree 7 files changed +33
-7
lines changed Original file line number Diff line number Diff line change @@ -17,5 +17,5 @@ object Base {
1717 const val targetSDKWear = 34
1818
1919 // Raise after wear api changes.
20- const val wearApiVersion = 5
20+ const val wearApiVersion = 6
2121}
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import com.example.util.simpletimetracker.core.interactor.StatisticsMediator
1010import com.example.util.simpletimetracker.core.mapper.TimeMapper
1111import com.example.util.simpletimetracker.core.provider.ApplicationDataProvider
1212import com.example.util.simpletimetracker.domain.activitySuggestion.interactor.GetCurrentActivitySuggestionsInteractor
13+ import com.example.util.simpletimetracker.domain.extension.orFalse
1314import com.example.util.simpletimetracker.domain.extension.orZero
1415import com.example.util.simpletimetracker.domain.notifications.interactor.UpdateExternalViewsInteractor
1516import com.example.util.simpletimetracker.domain.prefs.interactor.PrefsInteractor
@@ -168,7 +169,7 @@ class WearDataRepo @Inject constructor(
168169 )
169170 },
170171 comment = " " ,
171- useSelectedTags = true ,
172+ useSelectedTags = request.useSelectedTags.orFalse() ,
172173 )
173174 if (recordTypeInteractor.get(typeId)?.defaultDuration.orZero() > 0 ) {
174175 updateExternalViewsInteractor.get().onInstantRecordAdd()
Original file line number Diff line number Diff line change @@ -115,7 +115,11 @@ class WearDataRepo @Inject constructor(
115115 }
116116 }
117117
118- suspend fun startActivity (id : Long , tags : List <WearRecordTag >): Result <Unit > = mutex.withLock {
118+ suspend fun startActivity (
119+ id : Long ,
120+ tags : List <WearRecordTag >,
121+ useSelectedTags : Boolean ,
122+ ): Result <Unit > = mutex.withLock {
119123 return runCatching {
120124 val request = WearStartActivityRequest (
121125 id = id,
@@ -125,6 +129,7 @@ class WearDataRepo @Inject constructor(
125129 numericValue = it.numericValue,
126130 )
127131 },
132+ useSelectedTags = useSelectedTags,
128133 )
129134 wearRPCClient.startActivity(request)
130135 }
Original file line number Diff line number Diff line change @@ -33,15 +33,24 @@ class StartActivityMediator @Inject constructor(
3333 onRequestTagSelection()
3434 Result .success(Unit )
3535 } else {
36- start(activityId, emptyList())
36+ start(
37+ activityId = activityId,
38+ tags = emptyList(),
39+ useSelectedTags = false ,
40+ )
3741 }
3842 }
3943
4044 suspend fun start (
4145 activityId : Long ,
4246 tags : List <WearRecordTag >,
47+ useSelectedTags : Boolean ,
4348 ): Result <Unit > {
44- return wearDataRepo.startActivity(activityId, tags)
49+ return wearDataRepo.startActivity(
50+ id = activityId,
51+ tags = tags,
52+ useSelectedTags = useSelectedTags,
53+ )
4554 }
4655
4756 suspend fun stop (currentId : Long ): Result <Unit > {
Original file line number Diff line number Diff line change @@ -185,6 +185,7 @@ class TagsViewModel @Inject constructor(
185185 val result = startActivityMediator.start(
186186 activityId = activityId,
187187 tags = selectedTags,
188+ useSelectedTags = true ,
188189 )
189190 if (result.isFailure) {
190191 showError()
Original file line number Diff line number Diff line change @@ -59,7 +59,11 @@ class StartActivityMediatorTest {
5959 )
6060
6161 // Then
62- Mockito .verify(wearDataRepo).startActivity(sampleActivity.id, emptyList())
62+ Mockito .verify(wearDataRepo).startActivity(
63+ id = sampleActivity.id,
64+ tags = emptyList(),
65+ useSelectedTags = false ,
66+ )
6367 assertEquals(false , onRequestTagSelectionCalled)
6468 assertEquals(true , onProgressChanged)
6569 }
@@ -85,7 +89,11 @@ class StartActivityMediatorTest {
8589 )
8690
8791 // Then
88- Mockito .verify(wearDataRepo, Mockito .never()).startActivity(sampleActivity.id, emptyList())
92+ Mockito .verify(wearDataRepo, Mockito .never()).startActivity(
93+ id = sampleActivity.id,
94+ tags = emptyList(),
95+ useSelectedTags = false ,
96+ )
8997 assertEquals(true , onRequestTagSelectionCalled)
9098 assertEquals(false , onProgressChanged)
9199 }
Original file line number Diff line number Diff line change @@ -134,6 +134,8 @@ data class WearStartActivityRequest(
134134 val id : Long? ,
135135 @SerializedName(" tags" )
136136 val tags : List <Tag ?>? ,
137+ @SerializedName(" useSelectedTags" )
138+ val useSelectedTags : Boolean? ,
137139) : Parcelable {
138140
139141 @Parcelize
You can’t perform that action at this time.
0 commit comments