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 5a43b386c..9ddba716f 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 = 75 + const val versionCode = 77 const val versionName = "1.46" const val minSDK = 21 const val currentSDK = 34 diff --git a/core/src/main/java/com/example/util/simpletimetracker/core/utils/CoreConsts.kt b/core/src/main/java/com/example/util/simpletimetracker/core/utils/CoreConsts.kt index d5caa8c00..ae767a88a 100644 --- a/core/src/main/java/com/example/util/simpletimetracker/core/utils/CoreConsts.kt +++ b/core/src/main/java/com/example/util/simpletimetracker/core/utils/CoreConsts.kt @@ -6,13 +6,14 @@ const val SHORTCUT_NAVIGATION_RECORDS = "recordsTab" const val SHORTCUT_NAVIGATION_STATISTICS = "statisticsTab" const val SHORTCUT_NAVIGATION_SETTINGS = "settingsTab" -const val ACTION_START_ACTIVITY = "com.razeeman.util.simpletimetracker.ACTION_START_ACTIVITY" -const val ACTION_STOP_ACTIVITY = "com.razeeman.util.simpletimetracker.ACTION_STOP_ACTIVITY" -const val ACTION_STOP_ALL_ACTIVITIES = "com.razeeman.util.simpletimetracker.ACTION_STOP_ALL_ACTIVITIES" -const val ACTION_STOP_SHORTEST_ACTIVITY = "com.razeeman.util.simpletimetracker.ACTION_STOP_SHORTEST_ACTIVITY" -const val ACTION_STOP_LONGEST_ACTIVITY = "com.razeeman.util.simpletimetracker.ACTION_STOP_LONGEST_ACTIVITY" -const val ACTION_RESTART_ACTIVITY = "com.razeeman.util.simpletimetracker.ACTION_RESTART_ACTIVITY" -const val ACTION_ADD_RECORD = "com.razeeman.util.simpletimetracker.ACTION_ADD_RECORD" +const val ACTION_EXTERNAL_START_ACTIVITY = "com.razeeman.util.simpletimetracker.ACTION_START_ACTIVITY" +const val ACTION_EXTERNAL_STOP_ACTIVITY = "com.razeeman.util.simpletimetracker.ACTION_STOP_ACTIVITY" +const val ACTION_EXTERNAL_STOP_ALL_ACTIVITIES = "com.razeeman.util.simpletimetracker.ACTION_STOP_ALL_ACTIVITIES" +const val ACTION_EXTERNAL_STOP_SHORTEST_ACTIVITY = "com.razeeman.util.simpletimetracker.ACTION_STOP_SHORTEST_ACTIVITY" +const val ACTION_EXTERNAL_STOP_LONGEST_ACTIVITY = "com.razeeman.util.simpletimetracker.ACTION_STOP_LONGEST_ACTIVITY" +const val ACTION_EXTERNAL_RESTART_ACTIVITY = "com.razeeman.util.simpletimetracker.ACTION_RESTART_ACTIVITY" +const val ACTION_EXTERNAL_ADD_RECORD = "com.razeeman.util.simpletimetracker.ACTION_ADD_RECORD" + const val EVENT_STARTED_ACTIVITY = "com.razeeman.util.simpletimetracker.EVENT_STARTED_ACTIVITY" const val EVENT_STOPPED_ACTIVITY = "com.razeeman.util.simpletimetracker.EVENT_STOPPED_ACTIVITY" const val EXTRA_ACTIVITY_NAME = "extra_activity_name" diff --git a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/manager/NotificationActivitySwitchManager.kt b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/manager/NotificationActivitySwitchManager.kt index bcf88c6b4..f2bb43499 100644 --- a/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/manager/NotificationActivitySwitchManager.kt +++ b/features/feature_notification/src/main/java/com/example/util/simpletimetracker/feature_notification/activitySwitch/manager/NotificationActivitySwitchManager.kt @@ -15,7 +15,6 @@ import android.widget.RemoteViews import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import com.example.util.simpletimetracker.core.extension.allowVmViolations -import com.example.util.simpletimetracker.core.mapper.ColorMapper import com.example.util.simpletimetracker.core.utils.PendingIntents import com.example.util.simpletimetracker.feature_notification.R import com.example.util.simpletimetracker.feature_notification.recordType.customView.NotificationIconView @@ -30,7 +29,6 @@ import javax.inject.Singleton @Singleton class NotificationActivitySwitchManager @Inject constructor( @ApplicationContext private val context: Context, - private val colorMapper: ColorMapper, private val router: Router, private val controlsManager: NotificationControlsManager, ) { 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 dd8df8797..d02b664f2 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 @@ -5,13 +5,13 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import com.example.util.simpletimetracker.core.extension.goAsync -import com.example.util.simpletimetracker.core.utils.ACTION_ADD_RECORD -import com.example.util.simpletimetracker.core.utils.ACTION_RESTART_ACTIVITY -import com.example.util.simpletimetracker.core.utils.ACTION_START_ACTIVITY -import com.example.util.simpletimetracker.core.utils.ACTION_STOP_ACTIVITY -import com.example.util.simpletimetracker.core.utils.ACTION_STOP_ALL_ACTIVITIES -import com.example.util.simpletimetracker.core.utils.ACTION_STOP_LONGEST_ACTIVITY -import com.example.util.simpletimetracker.core.utils.ACTION_STOP_SHORTEST_ACTIVITY +import com.example.util.simpletimetracker.core.utils.ACTION_EXTERNAL_ADD_RECORD +import com.example.util.simpletimetracker.core.utils.ACTION_EXTERNAL_RESTART_ACTIVITY +import com.example.util.simpletimetracker.core.utils.ACTION_EXTERNAL_START_ACTIVITY +import com.example.util.simpletimetracker.core.utils.ACTION_EXTERNAL_STOP_ACTIVITY +import com.example.util.simpletimetracker.core.utils.ACTION_EXTERNAL_STOP_ALL_ACTIVITIES +import com.example.util.simpletimetracker.core.utils.ACTION_EXTERNAL_STOP_LONGEST_ACTIVITY +import com.example.util.simpletimetracker.core.utils.ACTION_EXTERNAL_STOP_SHORTEST_ACTIVITY import com.example.util.simpletimetracker.core.utils.EXTRA_ACTIVITY_NAME import com.example.util.simpletimetracker.core.utils.EXTRA_RECORD_COMMENT import com.example.util.simpletimetracker.core.utils.EXTRA_RECORD_TAG_NAME @@ -128,47 +128,47 @@ class NotificationReceiver : BroadcastReceiver() { finally = { automaticExportController.onFinished() }, block = { automaticExportController.onReminder() }, ) - ACTION_START_ACTIVITY -> { + ACTION_EXTERNAL_START_ACTIVITY -> { val name = intent.getStringExtra(EXTRA_ACTIVITY_NAME) val comment = intent.getStringExtra(EXTRA_RECORD_COMMENT) val tagNames = intent.getStringExtra(EXTRA_RECORD_TAG_NAME) ?.slipTagNames().orEmpty() - typeController.onActionActivityStart( + typeController.onActionExternalActivityStart( name = name, comment = comment, tagNames = tagNames, ) } - ACTION_STOP_ACTIVITY -> { + ACTION_EXTERNAL_STOP_ACTIVITY -> { val name = intent.getStringExtra(EXTRA_ACTIVITY_NAME) - typeController.onActionActivityStop(name) + typeController.onActionExternalActivityStop(name) } - ACTION_STOP_ALL_ACTIVITIES -> { - typeController.onActionActivityStopAll() + ACTION_EXTERNAL_STOP_ALL_ACTIVITIES -> { + typeController.onActionExternalActivityStopAll() } - ACTION_STOP_SHORTEST_ACTIVITY -> { - typeController.onActionActivityStopShortest() + ACTION_EXTERNAL_STOP_SHORTEST_ACTIVITY -> { + typeController.onActionExternalActivityStopShortest() } - ACTION_STOP_LONGEST_ACTIVITY -> { - typeController.onActionActivityStopLongest() + ACTION_EXTERNAL_STOP_LONGEST_ACTIVITY -> { + typeController.onActionExternalActivityStopLongest() } - ACTION_RESTART_ACTIVITY -> { + ACTION_EXTERNAL_RESTART_ACTIVITY -> { val comment = intent.getStringExtra(EXTRA_RECORD_COMMENT) val tagNames = intent.getStringExtra(EXTRA_RECORD_TAG_NAME) ?.slipTagNames().orEmpty() - typeController.onActionActivityRestart( + typeController.onActionExternalActivityRestart( comment = comment, tagNames = tagNames, ) } - ACTION_ADD_RECORD -> { + ACTION_EXTERNAL_ADD_RECORD -> { val name = intent.getStringExtra(EXTRA_ACTIVITY_NAME) val timeStarted = intent.getStringExtra(EXTRA_TIME_STARTED) val timeEnded = intent.getStringExtra(EXTRA_TIME_ENDED) val comment = intent.getStringExtra(EXTRA_RECORD_COMMENT) val tagNames = intent.getStringExtra(EXTRA_RECORD_TAG_NAME) ?.slipTagNames().orEmpty() - typeController.onActionRecordAdd( + typeController.onActionExternalRecordAdd( name = name, timeStarted = timeStarted, timeEnded = timeEnded, 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 a18a3a236..18fb1d38b 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 @@ -7,9 +7,13 @@ import com.example.util.simpletimetracker.feature_notification.recordType.intera import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch +import kotlinx.coroutines.sync.Mutex +import kotlinx.coroutines.sync.withLock import javax.inject.Inject +import javax.inject.Singleton @OptIn(DelicateCoroutinesApi::class) +@Singleton class NotificationTypeBroadcastController @Inject constructor( private val notificationTypeInteractor: NotificationTypeInteractor, private val notificationActivitySwitchInteractor: NotificationActivitySwitchInteractor, @@ -17,24 +21,26 @@ class NotificationTypeBroadcastController @Inject constructor( private val notificationControlsMapper: NotificationControlsMapper, ) { - fun onActionActivityStart( + private val mutex = Mutex() + + fun onActionExternalActivityStart( name: String?, comment: String?, tagNames: List, - ) { - name ?: return - GlobalScope.launch { + ) = GlobalScope.launch { + name ?: return@launch + mutex.withLock { activityStartStopFromBroadcastInteractor.onActionActivityStart( name = name, comment = comment, tagNames = tagNames, ) } } - fun onActionActivityStop( + fun onActionExternalActivityStop( name: String?, - ) { - name ?: return - GlobalScope.launch { + ) = GlobalScope.launch { + name ?: return@launch + mutex.withLock { activityStartStopFromBroadcastInteractor.onActionActivityStop(name) } } @@ -48,46 +54,46 @@ class NotificationTypeBroadcastController @Inject constructor( } } - fun onActionActivityStopAll() { - GlobalScope.launch { + fun onActionExternalActivityStopAll() = GlobalScope.launch { + mutex.withLock { activityStartStopFromBroadcastInteractor.onActionActivityStopAll() } } - fun onActionActivityStopShortest() { - GlobalScope.launch { + fun onActionExternalActivityStopShortest() = GlobalScope.launch { + mutex.withLock { activityStartStopFromBroadcastInteractor.onActionActivityStopShortest() } } - fun onActionActivityStopLongest() { - GlobalScope.launch { + fun onActionExternalActivityStopLongest() = GlobalScope.launch { + mutex.withLock { activityStartStopFromBroadcastInteractor.onActionActivityStopLongest() } } - fun onActionActivityRestart( + fun onActionExternalActivityRestart( comment: String?, tagNames: List, - ) { - GlobalScope.launch { + ) = GlobalScope.launch { + mutex.withLock { activityStartStopFromBroadcastInteractor.onActionActivityRestart( comment = comment, tagNames = tagNames, ) } } - fun onActionRecordAdd( + fun onActionExternalRecordAdd( name: String?, timeStarted: String?, timeEnded: String?, comment: String?, tagNames: List, - ) { - name ?: return - timeStarted ?: return - timeEnded ?: return - GlobalScope.launch { + ) = GlobalScope.launch { + name ?: return@launch + timeStarted ?: return@launch + timeEnded ?: return@launch + mutex.withLock { activityStartStopFromBroadcastInteractor.onRecordAdd( name = name, timeStarted = timeStarted, diff --git a/features/feature_settings/src/main/java/com/example/util/simpletimetracker/feature_settings/mapper/SettingsMapper.kt b/features/feature_settings/src/main/java/com/example/util/simpletimetracker/feature_settings/mapper/SettingsMapper.kt index 89f9dda48..b081cb804 100644 --- a/features/feature_settings/src/main/java/com/example/util/simpletimetracker/feature_settings/mapper/SettingsMapper.kt +++ b/features/feature_settings/src/main/java/com/example/util/simpletimetracker/feature_settings/mapper/SettingsMapper.kt @@ -10,13 +10,13 @@ import com.example.util.simpletimetracker.core.manager.ClipboardManager import com.example.util.simpletimetracker.core.mapper.TimeMapper import com.example.util.simpletimetracker.core.provider.ApplicationDataProvider import com.example.util.simpletimetracker.core.repo.ResourceRepo -import com.example.util.simpletimetracker.core.utils.ACTION_ADD_RECORD -import com.example.util.simpletimetracker.core.utils.ACTION_RESTART_ACTIVITY -import com.example.util.simpletimetracker.core.utils.ACTION_START_ACTIVITY -import com.example.util.simpletimetracker.core.utils.ACTION_STOP_ACTIVITY -import com.example.util.simpletimetracker.core.utils.ACTION_STOP_ALL_ACTIVITIES -import com.example.util.simpletimetracker.core.utils.ACTION_STOP_LONGEST_ACTIVITY -import com.example.util.simpletimetracker.core.utils.ACTION_STOP_SHORTEST_ACTIVITY +import com.example.util.simpletimetracker.core.utils.ACTION_EXTERNAL_ADD_RECORD +import com.example.util.simpletimetracker.core.utils.ACTION_EXTERNAL_RESTART_ACTIVITY +import com.example.util.simpletimetracker.core.utils.ACTION_EXTERNAL_START_ACTIVITY +import com.example.util.simpletimetracker.core.utils.ACTION_EXTERNAL_STOP_ACTIVITY +import com.example.util.simpletimetracker.core.utils.ACTION_EXTERNAL_STOP_ALL_ACTIVITIES +import com.example.util.simpletimetracker.core.utils.ACTION_EXTERNAL_STOP_LONGEST_ACTIVITY +import com.example.util.simpletimetracker.core.utils.ACTION_EXTERNAL_STOP_SHORTEST_ACTIVITY import com.example.util.simpletimetracker.core.utils.EVENT_STARTED_ACTIVITY import com.example.util.simpletimetracker.core.utils.EVENT_STOPPED_ACTIVITY import com.example.util.simpletimetracker.core.utils.EXTRA_ACTIVITY_NAME @@ -123,17 +123,17 @@ class SettingsMapper @Inject constructor( R.string.settings_automated_tracking_text, isDarkTheme, listOf( - HelpText(ACTION_START_ACTIVITY, canCopy = true), - HelpText(ACTION_STOP_ACTIVITY, canCopy = true), + HelpText(ACTION_EXTERNAL_START_ACTIVITY, canCopy = true), + HelpText(ACTION_EXTERNAL_STOP_ACTIVITY, canCopy = true), HelpText(EXTRA_ACTIVITY_NAME, canCopy = true), HelpText(applicationDataProvider.getPackageName(), canCopy = true), HelpText(EXTRA_RECORD_COMMENT, canCopy = true), HelpText(EXTRA_RECORD_TAG_NAME, canCopy = true), - HelpText(ACTION_STOP_ALL_ACTIVITIES, canCopy = true), - HelpText(ACTION_STOP_SHORTEST_ACTIVITY, canCopy = true), - HelpText(ACTION_STOP_LONGEST_ACTIVITY, canCopy = true), - HelpText(ACTION_RESTART_ACTIVITY, canCopy = true), - HelpText(ACTION_ADD_RECORD, canCopy = true), + HelpText(ACTION_EXTERNAL_STOP_ALL_ACTIVITIES, canCopy = true), + HelpText(ACTION_EXTERNAL_STOP_SHORTEST_ACTIVITY, canCopy = true), + HelpText(ACTION_EXTERNAL_STOP_LONGEST_ACTIVITY, canCopy = true), + HelpText(ACTION_EXTERNAL_RESTART_ACTIVITY, canCopy = true), + HelpText(ACTION_EXTERNAL_ADD_RECORD, canCopy = true), HelpText(EXTRA_ACTIVITY_NAME, canCopy = true), HelpText(EXTRA_RECORD_COMMENT, canCopy = true), HelpText(EXTRA_RECORD_TAG_NAME, canCopy = true),