Skip to content

Commit ceb96a4

Browse files
committed
change value tag selection on wear
1 parent d4e6975 commit ceb96a4

File tree

23 files changed

+597
-25
lines changed

23 files changed

+597
-25
lines changed

features/feature_dialogs/src/main/java/com/example/util/simpletimetracker/feature_dialogs/recordQuickActions/interactor/RecordQuickActionsInteractor.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ class RecordQuickActionsInteractor @Inject constructor(
7070
.mapNotNull { recordInteractor.get(it) }
7171
.filter {
7272
// TODO TAG translate strings
73-
// TODO TAG add to wear
7473
it.tags.sortedBy(RecordBase.Tag::tagId) !=
7574
newTags.sortedBy(RecordBase.Tag::tagId)
7675
}

features/feature_dialogs/src/main/java/com/example/util/simpletimetracker/feature_dialogs/recordTagValueSelection/viewModel/RecordTagValueSelectionViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class RecordTagValueSelectionViewModel @Inject constructor(
4747
newValue?.let { onDataSelected.set(it) }
4848
}
4949

50+
@Suppress("SameParameterValue")
5051
private fun updateViewData(
5152
fromCommentChange: Boolean = false,
5253
) = viewModelScope.launch {

features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/interactor/GetNotificationActivitySwitchControlsInteractor.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,22 +189,22 @@ class GetNotificationActivitySwitchControlsInteractor @Inject constructor(
189189

190190
val controlIconColor = colorMapper.toInactiveColor(isDarkTheme)
191191

192-
val numbers = (0..9).map { number ->
192+
val numbers = ((1..9).toList() + 0).map { number ->
193193
NotificationControlsParams.TagValueControls.Present(
194194
type = NotificationControlsParams.TagValueControls.Present.Type.Number(number),
195195
text = number.toString(),
196196
color = controlIconColor,
197197
)
198198
}.plus(
199199
NotificationControlsParams.TagValueControls.Present(
200-
type = NotificationControlsParams.TagValueControls.Present.Type.DoubleZero,
201-
text = "00",
200+
type = NotificationControlsParams.TagValueControls.Present.Type.Dot,
201+
text = TAG_VALUE_DECIMAL_DELIMITER.toString(),
202202
color = controlIconColor,
203203
),
204204
).plus(
205205
NotificationControlsParams.TagValueControls.Present(
206-
type = NotificationControlsParams.TagValueControls.Present.Type.Dot,
207-
text = TAG_VALUE_DECIMAL_DELIMITER.toString(),
206+
type = NotificationControlsParams.TagValueControls.Present.Type.PlusMinus,
207+
text = "+/−",
208208
color = controlIconColor,
209209
),
210210
).let {

features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/manager/NotificationControlsManager.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.example.util.simpletimetracker.domain.extension.orZero
1414
import com.example.util.simpletimetracker.feature_notification.R
1515
import com.example.util.simpletimetracker.feature_notification.activitySwitch.mapper.NotificationControlsMapper
1616
import com.example.util.simpletimetracker.feature_notification.core.TAG_VALUE_DECIMAL_DELIMITER
17+
import com.example.util.simpletimetracker.feature_notification.core.TAG_VALUE_MINUS_SIGN
1718
import com.example.util.simpletimetracker.feature_notification.recevier.NotificationReceiver
1819
import com.example.util.simpletimetracker.feature_notification.recordType.customView.NotificationIconView
1920
import com.example.util.simpletimetracker.feature_views.GoalCheckmarkView
@@ -320,8 +321,13 @@ class NotificationControlsManager @Inject constructor(
320321
is NotificationControlsParams.TagValueControls.Present.Type.Number -> {
321322
params.selectedTagValue.orEmpty().plus(data.type.number.toString())
322323
}
323-
NotificationControlsParams.TagValueControls.Present.Type.DoubleZero -> {
324-
params.selectedTagValue.orEmpty().plus("00")
324+
NotificationControlsParams.TagValueControls.Present.Type.PlusMinus -> {
325+
val current = params.selectedTagValue.orEmpty()
326+
if (current.startsWith(TAG_VALUE_MINUS_SIGN)) {
327+
current.removePrefix(TAG_VALUE_MINUS_SIGN.toString())
328+
} else {
329+
TAG_VALUE_MINUS_SIGN + current
330+
}
325331
}
326332
NotificationControlsParams.TagValueControls.Present.Type.Dot -> {
327333
params.selectedTagValue.orEmpty().plus(TAG_VALUE_DECIMAL_DELIMITER)

features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/manager/NotificationControlsParams.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ sealed interface NotificationControlsParams {
7070

7171
sealed interface Type {
7272
data class Number(val number: Int) : Type
73-
data object DoubleZero : Type
7473
data object Dot : Type
74+
data object PlusMinus : Type
7575
}
7676
}
7777

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
package com.example.util.simpletimetracker.feature_notification.core
22

3-
const val TAG_VALUE_DECIMAL_DELIMITER = '.'
3+
const val TAG_VALUE_DECIMAL_DELIMITER = '.'
4+
const val TAG_VALUE_MINUS_SIGN = ''

features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recordType/interactor/ActivityStartStopFromBroadcastInteractor.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.example.util.simpletimetracker.domain.record.model.RecordBase
1414
import com.example.util.simpletimetracker.domain.recordTag.interactor.NeedTagValueSelectionInteractor
1515
import com.example.util.simpletimetracker.feature_notification.activitySwitch.manager.NotificationControlsManager
1616
import com.example.util.simpletimetracker.feature_notification.core.TAG_VALUE_DECIMAL_DELIMITER
17+
import com.example.util.simpletimetracker.feature_notification.core.TAG_VALUE_MINUS_SIGN
1718
import kotlinx.coroutines.delay
1819
import javax.inject.Inject
1920

@@ -120,6 +121,7 @@ class ActivityStartStopFromBroadcastInteractor @Inject constructor(
120121
// toDoubleOrNull need a dot as a separator.
121122
val actualTagValue = tagValue
122123
?.replace(TAG_VALUE_DECIMAL_DELIMITER, '.')
124+
?.replace(TAG_VALUE_MINUS_SIGN, '-')
123125
?.toDoubleOrNull()
124126
startFromTagSelection(
125127
from = from,

wear/src/main/java/com/example/util/simpletimetracker/domain/base/DomainConsts.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ package com.example.util.simpletimetracker.domain.base
99
const val UNTRACKED_ITEM_ID = -1L
1010
const val UNCATEGORIZED_ITEM_ID = -2L
1111
const val REPEAT_BUTTON_ITEM_ID = -4L
12+
13+
const val TAG_VALUE_DECIMAL_DELIMITER = '.'
14+
const val TAG_VALUE_MINUS_SIGN = ''
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* This Source Code Form is subject to the terms of the Mozilla Public
3+
* License, v. 2.0. If a copy of the MPL was not distributed with this
4+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
*/
6+
package com.example.util.simpletimetracker.features.tagValueSelection.interactor
7+
8+
import kotlinx.coroutines.channels.BufferOverflow
9+
import kotlinx.coroutines.flow.MutableSharedFlow
10+
import kotlinx.coroutines.flow.SharedFlow
11+
import kotlinx.coroutines.flow.asSharedFlow
12+
import javax.inject.Inject
13+
import javax.inject.Singleton
14+
15+
@Singleton
16+
class TagValueSelectedInteractor @Inject constructor() {
17+
18+
val data: SharedFlow<Result> get() = _data.asSharedFlow()
19+
20+
private val _data = MutableSharedFlow<Result>(
21+
extraBufferCapacity = 1,
22+
onBufferOverflow = BufferOverflow.DROP_OLDEST,
23+
)
24+
25+
suspend fun send(data: Result) {
26+
_data.emit(data)
27+
}
28+
29+
data class Result(
30+
val tagId: Long,
31+
val value: Double?,
32+
)
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* This Source Code Form is subject to the terms of the Mozilla Public
3+
* License, v. 2.0. If a copy of the MPL was not distributed with this
4+
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
5+
*/
6+
package com.example.util.simpletimetracker.features.tagValueSelection.mapper
7+
8+
import com.example.util.simpletimetracker.R
9+
import com.example.util.simpletimetracker.data.WearResourceRepo
10+
import com.example.util.simpletimetracker.features.tagValueSelection.screen.TagValueSelectionState
11+
import javax.inject.Inject
12+
13+
class TagValueSelectionViewDataMapper @Inject constructor(
14+
private val resourceRepo: WearResourceRepo,
15+
) {
16+
17+
fun mapState(
18+
currentValue: String,
19+
): TagValueSelectionState {
20+
val value = if (currentValue.isEmpty()) {
21+
resourceRepo.getString(R.string.change_record_type_value_selection_hint)
22+
} else {
23+
currentValue
24+
}
25+
26+
return TagValueSelectionState(
27+
value = value,
28+
)
29+
}
30+
}

0 commit comments

Comments
 (0)