diff --git a/buildSrc/src/main/kotlin/com/example/util/simpletimetracker/Base.kt b/buildSrc/src/main/kotlin/com/example/util/simpletimetracker/Base.kt index a621c42aa..58f5d54c4 100644 --- a/buildSrc/src/main/kotlin/com/example/util/simpletimetracker/Base.kt +++ b/buildSrc/src/main/kotlin/com/example/util/simpletimetracker/Base.kt @@ -5,7 +5,7 @@ object Base { const val namespace = "com.example.util.simpletimetracker" // Raise by 2 to account for wear version code. - const val versionCode = 79 + const val versionCode = 81 const val versionName = "1.46" const val minSDK = 21 const val currentSDK = 34 diff --git a/domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/AddRunningRecordMediator.kt b/domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/AddRunningRecordMediator.kt index 8dd25d450..93811de78 100644 --- a/domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/AddRunningRecordMediator.kt +++ b/domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/AddRunningRecordMediator.kt @@ -132,7 +132,9 @@ class AddRunningRecordMediator @Inject constructor( } // Show goal count only on timer start, otherwise it would show on change also. notificationGoalCountInteractor.checkAndShow(typeId) - pomodoroStartInteractor.checkAndStart(typeId) + if (!retroactiveTrackingMode) { + pomodoroStartInteractor.checkAndStart(typeId) + } } // Used separately only for changing running activity, diff --git a/domain/src/test/java/com/example/util/simpletimetracker/domain/mapper/AddRunningRecordMediatorTest.kt b/domain/src/test/java/com/example/util/simpletimetracker/domain/mapper/AddRunningRecordMediatorTest.kt index cc2af8f54..af203913d 100644 --- a/domain/src/test/java/com/example/util/simpletimetracker/domain/mapper/AddRunningRecordMediatorTest.kt +++ b/domain/src/test/java/com/example/util/simpletimetracker/domain/mapper/AddRunningRecordMediatorTest.kt @@ -321,7 +321,6 @@ class AddRunningRecordMediatorTest { ) } - @Test fun defaultTag(): Unit = runBlocking { // Given diff --git a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/interactor/NotificationActivitySwitchInteractorImpl.kt b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/interactor/NotificationActivitySwitchInteractorImpl.kt index b05abac55..c1d589fb3 100644 --- a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/interactor/NotificationActivitySwitchInteractorImpl.kt +++ b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/interactor/NotificationActivitySwitchInteractorImpl.kt @@ -10,6 +10,7 @@ import com.example.util.simpletimetracker.domain.interactor.GetSelectableTagsInt import com.example.util.simpletimetracker.domain.interactor.NotificationActivitySwitchInteractor import com.example.util.simpletimetracker.domain.interactor.PrefsInteractor import com.example.util.simpletimetracker.domain.interactor.RecordInteractor +import com.example.util.simpletimetracker.domain.interactor.RecordTagInteractor import com.example.util.simpletimetracker.domain.interactor.RecordTypeGoalInteractor import com.example.util.simpletimetracker.domain.interactor.RecordTypeInteractor import com.example.util.simpletimetracker.domain.interactor.RunningRecordInteractor @@ -19,6 +20,7 @@ import com.example.util.simpletimetracker.feature_notification.R import com.example.util.simpletimetracker.feature_notification.activitySwitch.manager.NotificationActivitySwitchManager import com.example.util.simpletimetracker.feature_notification.activitySwitch.manager.NotificationActivitySwitchParams import com.example.util.simpletimetracker.feature_notification.activitySwitch.manager.NotificationControlsParams +import com.example.util.simpletimetracker.feature_notification.core.NotificationCommonMapper import com.example.util.simpletimetracker.feature_views.viewData.RecordTypeIcon import javax.inject.Inject @@ -31,12 +33,14 @@ class NotificationActivitySwitchInteractorImpl @Inject constructor( private val recordTypeInteractor: RecordTypeInteractor, private val recordTypeGoalInteractor: RecordTypeGoalInteractor, private val runningRecordInteractor: RunningRecordInteractor, + private val recordTagInteractor: RecordTagInteractor, private val getCurrentRecordsDurationInteractor: GetCurrentRecordsDurationInteractor, private val timeMapper: TimeMapper, private val filterGoalsByDayOfWeekInteractor: FilterGoalsByDayOfWeekInteractor, private val getSelectableTagsInteractor: GetSelectableTagsInteractor, private val getNotificationActivitySwitchControlsInteractor: GetNotificationActivitySwitchControlsInteractor, private val recordInteractor: RecordInteractor, + private val notificationCommonMapper: NotificationCommonMapper, ) : NotificationActivitySwitchInteractor { override suspend fun updateNotification( @@ -82,6 +86,7 @@ class NotificationActivitySwitchInteractorImpl @Inject constructor( emptyList() } val recordTypes = recordTypeInteractor.getAll().associateBy(RecordType::id) + val recordTags = recordTagInteractor.getAll() val prevRecord = if (retroactiveTrackingModeEnabled) { // TODO several previous? recordInteractor.getAllPrev(timeStarted = System.currentTimeMillis()) @@ -128,9 +133,12 @@ class NotificationActivitySwitchInteractorImpl @Inject constructor( hint = resourceRepo.getString(R.string.retroactive_tracking_mode_hint) icon = prevRecordType.icon.let(iconMapper::mapIcon) color = colorMapper.mapToColorInt(prevRecordType.color, isDarkTheme) - title = resourceRepo.getString(R.string.statistics_detail_last_record) + - " - " + - prevRecordType.name + val namePrefix = resourceRepo.getString(R.string.statistics_detail_last_record) + val fullName = notificationCommonMapper.getNotificationText( + recordType = prevRecordType, + recordTags = recordTags.filter { it.id in prevRecord.tagIds }, + ) + title = "$namePrefix - $fullName" subtitle = timeMapper.formatTime( time = prevRecord.timeEnded, useMilitaryTime = prefsInteractor.getUseMilitaryTimeFormat(), diff --git a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/core/NotificationCommonMapper.kt b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/core/NotificationCommonMapper.kt new file mode 100644 index 000000000..4a3e42547 --- /dev/null +++ b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/core/NotificationCommonMapper.kt @@ -0,0 +1,22 @@ +package com.example.util.simpletimetracker.feature_notification.core + +import com.example.util.simpletimetracker.domain.extension.getFullName +import com.example.util.simpletimetracker.domain.model.RecordTag +import com.example.util.simpletimetracker.domain.model.RecordType +import javax.inject.Inject + +class NotificationCommonMapper @Inject constructor() { + + fun getNotificationText( + recordType: RecordType, + recordTags: List, + ): String { + val tag = recordTags.getFullName() + + return if (tag.isEmpty()) { + recordType.name + } else { + "${recordType.name} - $tag" + } + } +} \ No newline at end of file diff --git a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recordType/interactor/NotificationTypeInteractorImpl.kt b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recordType/interactor/NotificationTypeInteractorImpl.kt index 92e22acf0..996e52027 100644 --- a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recordType/interactor/NotificationTypeInteractorImpl.kt +++ b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recordType/interactor/NotificationTypeInteractorImpl.kt @@ -7,7 +7,6 @@ import com.example.util.simpletimetracker.core.mapper.IconMapper import com.example.util.simpletimetracker.core.mapper.TimeMapper import com.example.util.simpletimetracker.core.repo.ResourceRepo import com.example.util.simpletimetracker.domain.extension.getDailyDuration -import com.example.util.simpletimetracker.domain.extension.getFullName import com.example.util.simpletimetracker.domain.extension.getSessionDuration import com.example.util.simpletimetracker.domain.extension.hasDailyDuration import com.example.util.simpletimetracker.domain.extension.value @@ -26,6 +25,7 @@ import com.example.util.simpletimetracker.domain.model.RunningRecord import com.example.util.simpletimetracker.feature_notification.R import com.example.util.simpletimetracker.feature_notification.activitySwitch.interactor.GetNotificationActivitySwitchControlsInteractor import com.example.util.simpletimetracker.feature_notification.activitySwitch.manager.NotificationControlsParams +import com.example.util.simpletimetracker.feature_notification.core.NotificationCommonMapper import com.example.util.simpletimetracker.feature_notification.recordType.manager.NotificationTypeManager import com.example.util.simpletimetracker.feature_notification.recordType.manager.NotificationTypeParams import javax.inject.Inject @@ -45,6 +45,7 @@ class NotificationTypeInteractorImpl @Inject constructor( private val filterGoalsByDayOfWeekInteractor: FilterGoalsByDayOfWeekInteractor, private val getSelectableTagsInteractor: GetSelectableTagsInteractor, private val getNotificationActivitySwitchControlsInteractor: GetNotificationActivitySwitchControlsInteractor, + private val notificationCommonMapper: NotificationCommonMapper, ) : NotificationTypeInteractor { // TODO merge with update function? @@ -226,7 +227,10 @@ class NotificationTypeInteractorImpl @Inject constructor( id = recordType.id, icon = recordType.icon.let(iconMapper::mapIcon), color = colorMapper.mapToColorInt(recordType.color, isDarkTheme), - text = getNotificationText(recordType, recordTags), + text = notificationCommonMapper.getNotificationText( + recordType = recordType, + recordTags = recordTags, + ), timeStarted = timeMapper.formatTime( time = runningRecord.timeStarted, useMilitaryTime = useMilitaryTime, @@ -246,19 +250,6 @@ class NotificationTypeInteractorImpl @Inject constructor( ).let(notificationTypeManager::show) } - private fun getNotificationText( - recordType: RecordType, - recordTags: List, - ): String { - val tag = recordTags.getFullName() - - return if (tag.isEmpty()) { - recordType.name - } else { - "${recordType.name} - $tag" - } - } - private fun hide(typeId: Long) { notificationTypeManager.hide(typeId.toInt()) }