Skip to content

Commit 66397db

Browse files
committed
fix notification switch errors
1 parent d633a0d commit 66397db

File tree

12 files changed

+30
-62
lines changed

12 files changed

+30
-62
lines changed

buildSrc/src/main/kotlin/com/example/util/simpletimetracker/Base.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object Base {
55
const val namespace = "com.example.util.simpletimetracker"
66

77
// Raise by 2 to account for wear version code.
8-
const val versionCode = 73
8+
const val versionCode = 75
99
const val versionName = "1.46"
1010
const val minSDK = 21
1111
const val currentSDK = 34

domain/src/main/java/com/example/util/simpletimetracker/domain/extension/DomainExtensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fun Int?.orZero(): Int = this ?: 0
1919

2020
fun Float?.orZero(): Float = this ?: 0f
2121

22-
fun Range?.orEmpty(): Range = this ?: Range(0,0)
22+
fun Range?.orEmpty(): Range = this ?: Range(0, 0)
2323

2424
fun <T> List<T>?.orEmpty(): List<T> = this ?: emptyList()
2525

domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/RemoveRunningRecordMediator.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class RemoveRunningRecordMediator @Inject constructor(
1616
suspend fun removeWithRecordAdd(
1717
runningRecord: RunningRecord,
1818
updateWidgets: Boolean = true,
19-
updateNotificationSwitch: Boolean = true,
2019
timeEnded: Long? = null, // null - take current time.
2120
) {
2221
val recordTimeEnded = timeEnded ?: System.currentTimeMillis()
@@ -39,7 +38,6 @@ class RemoveRunningRecordMediator @Inject constructor(
3938
remove(
4039
typeId = runningRecord.id,
4140
updateWidgets = updateWidgets,
42-
updateNotificationSwitch = updateNotificationSwitch,
4341
)
4442
pomodoroStopInteractor.checkAndStop(runningRecord.id)
4543
}

features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/viewModel/ChangeRunningRecordViewModel.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ class ChangeRunningRecordViewModel @Inject constructor(
132132
doAfter: suspend () -> Unit,
133133
) {
134134
// Widgets will update on adding.
135-
removeRunningRecordMediator.remove(extra.id, updateWidgets = false)
135+
removeRunningRecordMediator.remove(
136+
typeId = extra.id,
137+
updateWidgets = false,
138+
updateNotificationSwitch = false,
139+
)
136140
addRunningRecordMediator.addAfterChange(
137141
typeId = newTypeId,
138142
timeStarted = newTimeStarted,

features/feature_dialogs/src/main/java/com/example/util/simpletimetracker/feature_dialogs/recordQuickActions/viewModel/RecordQuickActionsViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class RecordQuickActionsViewModel @Inject constructor(
234234
is Type.RecordRunning -> listOf(
235235
RecordQuickActionsState.Button.Statistics(false),
236236
RecordQuickActionsState.Button.Delete(false),
237-
RecordQuickActionsState.Button.Stop(true)
237+
RecordQuickActionsState.Button.Stop(true),
238238
)
239239
null -> emptyList()
240240
}

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import com.example.util.simpletimetracker.domain.REPEAT_BUTTON_ITEM_ID
1111
import com.example.util.simpletimetracker.domain.model.RecordTag
1212
import com.example.util.simpletimetracker.domain.model.RecordType
1313
import com.example.util.simpletimetracker.domain.model.RecordTypeGoal
14-
import com.example.util.simpletimetracker.domain.model.RunningRecord
1514
import com.example.util.simpletimetracker.feature_notification.R
1615
import com.example.util.simpletimetracker.feature_notification.activitySwitch.manager.NotificationControlsParams
1716
import com.example.util.simpletimetracker.feature_views.viewData.RecordTypeIcon
@@ -30,7 +29,6 @@ class GetNotificationActivitySwitchControlsInteractor @Inject constructor(
3029
hint: String,
3130
isDarkTheme: Boolean,
3231
types: List<RecordType>,
33-
runningRecords: List<RunningRecord> = emptyList(),
3432
showRepeatButton: Boolean,
3533
typesShift: Int = 0,
3634
tags: List<RecordTag> = emptyList(),
@@ -40,7 +38,6 @@ class GetNotificationActivitySwitchControlsInteractor @Inject constructor(
4038
allDailyCurrents: Map<Long, GetCurrentRecordsDurationInteractor.Result>,
4139
): NotificationControlsParams {
4240
val typesMap = types.associateBy { it.id }
43-
val runningRecordsIds = runningRecords.map { it.id }
4441

4542
val repeatButtonViewData = if (showRepeatButton) {
4643
val viewData = recordTypeViewDataMapper.mapToRepeatItem(
@@ -64,11 +61,7 @@ class GetNotificationActivitySwitchControlsInteractor @Inject constructor(
6461
NotificationControlsParams.Type(
6562
id = type.id,
6663
icon = type.icon.let(iconMapper::mapIcon),
67-
color = if (type.id in runningRecordsIds) {
68-
colorMapper.toFilteredColor(isDarkTheme)
69-
} else {
70-
type.color.let { colorMapper.mapToColorInt(it, isDarkTheme) }
71-
},
64+
color = type.color.let { colorMapper.mapToColorInt(it, isDarkTheme) },
7265
isChecked = recordTypeViewDataMapper.mapGoalCheckmark(
7366
type = type,
7467
goals = goals,
@@ -111,6 +104,7 @@ class GetNotificationActivitySwitchControlsInteractor @Inject constructor(
111104
controlIconPrev = RecordTypeIcon.Image(R.drawable.arrow_left),
112105
controlIconNext = RecordTypeIcon.Image(R.drawable.arrow_right),
113106
controlIconColor = colorMapper.toInactiveColor(isDarkTheme),
107+
filteredTypeColor = colorMapper.toInactiveColor(isDarkTheme),
114108
selectedTypeId = selectedTypeId,
115109
)
116110
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class NotificationActivitySwitchInteractorImpl @Inject constructor(
6969
val firstDayOfWeek = prefsInteractor.getFirstDayOfWeek()
7070
val startOfDayShift = prefsInteractor.getStartOfDayShift()
7171
val retroactiveTrackingModeEnabled = prefsInteractor.getRetroactiveTrackingMode()
72-
val runningRecords = runningRecordInteractor.getAll()
7372
val range = timeMapper.getRangeStartAndEnd(
7473
rangeLength = RangeLength.Day,
7574
shift = 0,
@@ -97,7 +96,7 @@ class NotificationActivitySwitchInteractorImpl @Inject constructor(
9796
val allDailyCurrents = if (goals.isNotEmpty()) {
9897
getCurrentRecordsDurationInteractor.getAllDailyCurrents(
9998
typeIds = recordTypes.keys.toList(),
100-
runningRecords = runningRecords,
99+
runningRecords = runningRecordInteractor.getAll(),
101100
)
102101
} else {
103102
// No goals - no need to calculate durations.
@@ -107,7 +106,6 @@ class NotificationActivitySwitchInteractorImpl @Inject constructor(
107106
hint = "", // Replaced later.
108107
isDarkTheme = isDarkTheme,
109108
types = recordTypes.values.toList(),
110-
runningRecords = runningRecords,
111109
showRepeatButton = showRepeatButton,
112110
typesShift = typesShift,
113111
tags = viewedTags,

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ class NotificationControlsManager @Inject constructor(
8181
// Types buttons
8282
val currentTypes = params.types.drop(params.typesShift).take(TYPES_LIST_SIZE)
8383
currentTypes.forEach {
84+
val recordTypeId = (from as? From.ActivityNotification)?.recordTypeId
8485
val action = when (from) {
8586
is From.ActivityNotification -> {
86-
val recordTypeId = (from as? From.ActivityNotification)?.recordTypeId
8787
if (it.id == recordTypeId) {
8888
ACTION_NOTIFICATION_CONTROLS_STOP
8989
} else {
@@ -94,9 +94,14 @@ class NotificationControlsManager @Inject constructor(
9494
ACTION_NOTIFICATION_CONTROLS_TYPE_CLICK
9595
}
9696
}
97+
val color = if (recordTypeId == it.id) {
98+
params.filteredTypeColor
99+
} else {
100+
it.color
101+
}
97102
getTypeControlView(
98103
icon = it.icon,
99-
color = it.color,
104+
color = color,
100105
isChecked = it.isChecked,
101106
isComplete = it.isComplete,
102107
intent = getPendingSelfIntent(

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ sealed interface NotificationControlsParams {
1414
val controlIconPrev: RecordTypeIcon,
1515
val controlIconNext: RecordTypeIcon,
1616
val controlIconColor: Int,
17+
val filteredTypeColor: Int,
1718
val selectedTypeId: Long?,
1819
) : NotificationControlsParams
1920

features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recevier/NotificationReceiver.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,8 @@ class NotificationReceiver : BroadcastReceiver() {
181181
typeController.onActionActivityStop(typeId)
182182
}
183183
ACTION_NOTIFICATION_CONTROLS_STOP -> {
184-
val from = intent.getIntExtra(ARGS_CONTROLS_FROM, 0)
185184
val typeId = intent.getLongExtra(ARGS_TYPE_ID, 0)
186-
typeController.onActionActivityStop(from, typeId)
185+
typeController.onActionActivityStop(typeId)
187186
}
188187
ACTION_NOTIFICATION_CONTROLS_TYPE_CLICK -> {
189188
val from = intent.getIntExtra(ARGS_CONTROLS_FROM, 0)

0 commit comments

Comments
 (0)