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 1830b3fe9..5a43b386c 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 = 73 + const val versionCode = 75 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/extension/DomainExtensions.kt b/domain/src/main/java/com/example/util/simpletimetracker/domain/extension/DomainExtensions.kt index 4289c3db4..b313b3880 100644 --- a/domain/src/main/java/com/example/util/simpletimetracker/domain/extension/DomainExtensions.kt +++ b/domain/src/main/java/com/example/util/simpletimetracker/domain/extension/DomainExtensions.kt @@ -19,7 +19,7 @@ fun Int?.orZero(): Int = this ?: 0 fun Float?.orZero(): Float = this ?: 0f -fun Range?.orEmpty(): Range = this ?: Range(0,0) +fun Range?.orEmpty(): Range = this ?: Range(0, 0) fun List?.orEmpty(): List = this ?: emptyList() diff --git a/domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/RemoveRunningRecordMediator.kt b/domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/RemoveRunningRecordMediator.kt index 41be4a2d6..5cfebf017 100644 --- a/domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/RemoveRunningRecordMediator.kt +++ b/domain/src/main/java/com/example/util/simpletimetracker/domain/interactor/RemoveRunningRecordMediator.kt @@ -16,7 +16,6 @@ class RemoveRunningRecordMediator @Inject constructor( suspend fun removeWithRecordAdd( runningRecord: RunningRecord, updateWidgets: Boolean = true, - updateNotificationSwitch: Boolean = true, timeEnded: Long? = null, // null - take current time. ) { val recordTimeEnded = timeEnded ?: System.currentTimeMillis() @@ -39,7 +38,6 @@ class RemoveRunningRecordMediator @Inject constructor( remove( typeId = runningRecord.id, updateWidgets = updateWidgets, - updateNotificationSwitch = updateNotificationSwitch, ) pomodoroStopInteractor.checkAndStop(runningRecord.id) } diff --git a/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/viewModel/ChangeRunningRecordViewModel.kt b/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/viewModel/ChangeRunningRecordViewModel.kt index 7fa577de4..d4b7c30ec 100644 --- a/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/viewModel/ChangeRunningRecordViewModel.kt +++ b/features/feature_change_running_record/src/main/java/com/example/util/simpletimetracker/feature_change_running_record/viewModel/ChangeRunningRecordViewModel.kt @@ -132,7 +132,11 @@ class ChangeRunningRecordViewModel @Inject constructor( doAfter: suspend () -> Unit, ) { // Widgets will update on adding. - removeRunningRecordMediator.remove(extra.id, updateWidgets = false) + removeRunningRecordMediator.remove( + typeId = extra.id, + updateWidgets = false, + updateNotificationSwitch = false, + ) addRunningRecordMediator.addAfterChange( typeId = newTypeId, timeStarted = newTimeStarted, diff --git a/features/feature_dialogs/src/main/java/com/example/util/simpletimetracker/feature_dialogs/recordQuickActions/viewModel/RecordQuickActionsViewModel.kt b/features/feature_dialogs/src/main/java/com/example/util/simpletimetracker/feature_dialogs/recordQuickActions/viewModel/RecordQuickActionsViewModel.kt index 57b6d2ed1..19c20f0a5 100644 --- a/features/feature_dialogs/src/main/java/com/example/util/simpletimetracker/feature_dialogs/recordQuickActions/viewModel/RecordQuickActionsViewModel.kt +++ b/features/feature_dialogs/src/main/java/com/example/util/simpletimetracker/feature_dialogs/recordQuickActions/viewModel/RecordQuickActionsViewModel.kt @@ -234,7 +234,7 @@ class RecordQuickActionsViewModel @Inject constructor( is Type.RecordRunning -> listOf( RecordQuickActionsState.Button.Statistics(false), RecordQuickActionsState.Button.Delete(false), - RecordQuickActionsState.Button.Stop(true) + RecordQuickActionsState.Button.Stop(true), ) null -> emptyList() } diff --git a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/interactor/GetNotificationActivitySwitchControlsInteractor.kt b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/interactor/GetNotificationActivitySwitchControlsInteractor.kt index 96f32b440..6d218b9f4 100644 --- a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/interactor/GetNotificationActivitySwitchControlsInteractor.kt +++ b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/interactor/GetNotificationActivitySwitchControlsInteractor.kt @@ -11,7 +11,6 @@ import com.example.util.simpletimetracker.domain.REPEAT_BUTTON_ITEM_ID import com.example.util.simpletimetracker.domain.model.RecordTag import com.example.util.simpletimetracker.domain.model.RecordType import com.example.util.simpletimetracker.domain.model.RecordTypeGoal -import com.example.util.simpletimetracker.domain.model.RunningRecord import com.example.util.simpletimetracker.feature_notification.R import com.example.util.simpletimetracker.feature_notification.activitySwitch.manager.NotificationControlsParams import com.example.util.simpletimetracker.feature_views.viewData.RecordTypeIcon @@ -30,7 +29,6 @@ class GetNotificationActivitySwitchControlsInteractor @Inject constructor( hint: String, isDarkTheme: Boolean, types: List, - runningRecords: List = emptyList(), showRepeatButton: Boolean, typesShift: Int = 0, tags: List = emptyList(), @@ -40,7 +38,6 @@ class GetNotificationActivitySwitchControlsInteractor @Inject constructor( allDailyCurrents: Map, ): NotificationControlsParams { val typesMap = types.associateBy { it.id } - val runningRecordsIds = runningRecords.map { it.id } val repeatButtonViewData = if (showRepeatButton) { val viewData = recordTypeViewDataMapper.mapToRepeatItem( @@ -64,11 +61,7 @@ class GetNotificationActivitySwitchControlsInteractor @Inject constructor( NotificationControlsParams.Type( id = type.id, icon = type.icon.let(iconMapper::mapIcon), - color = if (type.id in runningRecordsIds) { - colorMapper.toFilteredColor(isDarkTheme) - } else { - type.color.let { colorMapper.mapToColorInt(it, isDarkTheme) } - }, + color = type.color.let { colorMapper.mapToColorInt(it, isDarkTheme) }, isChecked = recordTypeViewDataMapper.mapGoalCheckmark( type = type, goals = goals, @@ -111,6 +104,7 @@ class GetNotificationActivitySwitchControlsInteractor @Inject constructor( controlIconPrev = RecordTypeIcon.Image(R.drawable.arrow_left), controlIconNext = RecordTypeIcon.Image(R.drawable.arrow_right), controlIconColor = colorMapper.toInactiveColor(isDarkTheme), + filteredTypeColor = colorMapper.toInactiveColor(isDarkTheme), selectedTypeId = selectedTypeId, ) } 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 ac4fd136b..e6aff2884 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 @@ -69,7 +69,6 @@ class NotificationActivitySwitchInteractorImpl @Inject constructor( val firstDayOfWeek = prefsInteractor.getFirstDayOfWeek() val startOfDayShift = prefsInteractor.getStartOfDayShift() val retroactiveTrackingModeEnabled = prefsInteractor.getRetroactiveTrackingMode() - val runningRecords = runningRecordInteractor.getAll() val range = timeMapper.getRangeStartAndEnd( rangeLength = RangeLength.Day, shift = 0, @@ -97,7 +96,7 @@ class NotificationActivitySwitchInteractorImpl @Inject constructor( val allDailyCurrents = if (goals.isNotEmpty()) { getCurrentRecordsDurationInteractor.getAllDailyCurrents( typeIds = recordTypes.keys.toList(), - runningRecords = runningRecords, + runningRecords = runningRecordInteractor.getAll(), ) } else { // No goals - no need to calculate durations. @@ -107,7 +106,6 @@ class NotificationActivitySwitchInteractorImpl @Inject constructor( hint = "", // Replaced later. isDarkTheme = isDarkTheme, types = recordTypes.values.toList(), - runningRecords = runningRecords, showRepeatButton = showRepeatButton, typesShift = typesShift, tags = viewedTags, diff --git a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/manager/NotificationControlsManager.kt b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/manager/NotificationControlsManager.kt index f227451c8..3e261d93b 100644 --- a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/manager/NotificationControlsManager.kt +++ b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/manager/NotificationControlsManager.kt @@ -81,9 +81,9 @@ class NotificationControlsManager @Inject constructor( // Types buttons val currentTypes = params.types.drop(params.typesShift).take(TYPES_LIST_SIZE) currentTypes.forEach { + val recordTypeId = (from as? From.ActivityNotification)?.recordTypeId val action = when (from) { is From.ActivityNotification -> { - val recordTypeId = (from as? From.ActivityNotification)?.recordTypeId if (it.id == recordTypeId) { ACTION_NOTIFICATION_CONTROLS_STOP } else { @@ -94,9 +94,14 @@ class NotificationControlsManager @Inject constructor( ACTION_NOTIFICATION_CONTROLS_TYPE_CLICK } } + val color = if (recordTypeId == it.id) { + params.filteredTypeColor + } else { + it.color + } getTypeControlView( icon = it.icon, - color = it.color, + color = color, isChecked = it.isChecked, isComplete = it.isComplete, intent = getPendingSelfIntent( diff --git a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/manager/NotificationControlsParams.kt b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/manager/NotificationControlsParams.kt index 11544dfe2..562654ab6 100644 --- a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/manager/NotificationControlsParams.kt +++ b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/manager/NotificationControlsParams.kt @@ -14,6 +14,7 @@ sealed interface NotificationControlsParams { val controlIconPrev: RecordTypeIcon, val controlIconNext: RecordTypeIcon, val controlIconColor: Int, + val filteredTypeColor: Int, val selectedTypeId: Long?, ) : NotificationControlsParams diff --git a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recevier/NotificationReceiver.kt b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recevier/NotificationReceiver.kt index 38a6a7fcf..dd8df8797 100644 --- a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recevier/NotificationReceiver.kt +++ b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recevier/NotificationReceiver.kt @@ -181,9 +181,8 @@ class NotificationReceiver : BroadcastReceiver() { typeController.onActionActivityStop(typeId) } ACTION_NOTIFICATION_CONTROLS_STOP -> { - val from = intent.getIntExtra(ARGS_CONTROLS_FROM, 0) val typeId = intent.getLongExtra(ARGS_TYPE_ID, 0) - typeController.onActionActivityStop(from, typeId) + typeController.onActionActivityStop(typeId) } ACTION_NOTIFICATION_CONTROLS_TYPE_CLICK -> { val from = intent.getIntExtra(ARGS_CONTROLS_FROM, 0) diff --git a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recordType/controller/NotificationTypeBroadcastController.kt b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recordType/controller/NotificationTypeBroadcastController.kt index 0b4afab97..a18a3a236 100644 --- a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recordType/controller/NotificationTypeBroadcastController.kt +++ b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recordType/controller/NotificationTypeBroadcastController.kt @@ -2,7 +2,6 @@ package com.example.util.simpletimetracker.feature_notification.recordType.contr import com.example.util.simpletimetracker.domain.interactor.NotificationActivitySwitchInteractor import com.example.util.simpletimetracker.domain.interactor.NotificationTypeInteractor -import com.example.util.simpletimetracker.feature_notification.activitySwitch.manager.NotificationControlsManager import com.example.util.simpletimetracker.feature_notification.activitySwitch.mapper.NotificationControlsMapper import com.example.util.simpletimetracker.feature_notification.recordType.interactor.ActivityStartStopFromBroadcastInteractor import kotlinx.coroutines.DelicateCoroutinesApi @@ -45,27 +44,7 @@ class NotificationTypeBroadcastController @Inject constructor( ) { if (typeId == 0L) return GlobalScope.launch { - activityStartStopFromBroadcastInteractor.onActionActivityStop( - typeId = typeId, - fromControls = false, - ) - } - } - - fun onActionActivityStop( - from: Int, - typeId: Long, - ) { - if (typeId == 0L) return - val fromData = notificationControlsMapper.mapExtraToFrom( - extra = from, - recordTypeId = typeId, - ) - GlobalScope.launch { - activityStartStopFromBroadcastInteractor.onActionActivityStop( - typeId = typeId, - fromControls = fromData is NotificationControlsManager.From.ActivitySwitch, - ) + activityStartStopFromBroadcastInteractor.onActionActivityStop(typeId) } } diff --git a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recordType/interactor/ActivityStartStopFromBroadcastInteractor.kt b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recordType/interactor/ActivityStartStopFromBroadcastInteractor.kt index 56140c567..9d54de998 100644 --- a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recordType/interactor/ActivityStartStopFromBroadcastInteractor.kt +++ b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/recordType/interactor/ActivityStartStopFromBroadcastInteractor.kt @@ -58,19 +58,17 @@ class ActivityStartStopFromBroadcastInteractor @Inject constructor( name: String, ) { val typeId = getTypeIdByName(name) ?: return - onActionActivityStop(typeId = typeId, fromControls = false) + onActionActivityStop(typeId) } suspend fun onActionActivityStop( typeId: Long, - fromControls: Boolean, ) { val runningRecord = runningRecordInteractor.get(typeId) ?: return // Not running. removeRunningRecordMediator.removeWithRecordAdd( runningRecord = runningRecord, - updateNotificationSwitch = !fromControls, ) } @@ -146,22 +144,11 @@ class ActivityStartStopFromBroadcastInteractor @Inject constructor( return } - // Switch controls are updated separately right from here, - // so no need to update after record change. - if (from is NotificationControlsManager.From.ActivitySwitch) { - if (runningRecordInteractor.get(selectedTypeId) != null) { - onActionActivityStop( - typeId = selectedTypeId, - fromControls = true, - ) - update(from, typesShift) - return - } - } - val updateNotificationSwitch = from !is NotificationControlsManager.From.ActivitySwitch val started = addRunningRecordMediator.tryStartTimer( typeId = selectedTypeId, - updateNotificationSwitch = updateNotificationSwitch, + // Switch controls are updated separately right from here, + // so no need to update after record change. + updateNotificationSwitch = false, commentInputAvailable = false, // TODO open activity? ) { // Update to show tag selection. @@ -196,9 +183,12 @@ class ActivityStartStopFromBroadcastInteractor @Inject constructor( typeId = selectedTypeId, comment = "", tagIds = listOfNotNull(tagId.takeUnless { it == 0L }), - updateNotificationSwitch = from !is NotificationControlsManager.From.ActivitySwitch, ) - update(from, typesShift) + if (from !is NotificationControlsManager.From.ActivitySwitch) { + // Hide tag selection on current notification. + // Switch would be hidden on start timer. + update(from, typesShift) + } } suspend fun onRequestUpdate(