feat(ui): complete ABox app experience redesign #10

Merged
KremeCN merged 40 commits from feat/ui-ux-redesign into main 2026-08-27 23:25:08 +08:00
2 changed files with 11 additions and 1 deletions
Showing only changes of commit 5a25c31b39 - Show all commits
@@ -4,13 +4,22 @@ import com.flagship.abox.manager.domain.ProviderProfileStore
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.collectLatest import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import com.flagship.abox.manager.domain.ProviderProfileId
class AutomationBootstrapper( class AutomationBootstrapper(
private val profileStore: ProviderProfileStore, private val profileStore: ProviderProfileStore,
private val scheduler: AutomationScheduler, private val scheduler: AutomationScheduler,
private val scope: CoroutineScope, private val scope: CoroutineScope,
) { ) {
private var previousProfileId: ProviderProfileId? = null
fun start() { fun start() {
scope.launch { profileStore.observeActiveProfile().collectLatest { scheduler.reconcileActiveProfile() } } scope.launch {
profileStore.observeActiveProfile().collectLatest { active ->
previousProfileId?.takeIf { it != active?.id }?.let { scheduler.cancel(it) }
previousProfileId = active?.id
scheduler.reconcileActiveProfile()
}
}
} }
} }
@@ -13,6 +13,7 @@ class WorkManagerAutomationScheduleStore(context: Context) : AutomationScheduleS
private val workManager = WorkManager.getInstance(context) private val workManager = WorkManager.getInstance(context)
override suspend fun replace(profileId: ProviderProfileId, scenes: List<Scene>): DomainResult<Unit> { override suspend fun replace(profileId: ProviderProfileId, scenes: List<Scene>): DomainResult<Unit> {
if (scenes.isEmpty()) return remove(profileId)
val request = PeriodicWorkRequestBuilder<AutomationPollWorker>(15, TimeUnit.MINUTES) val request = PeriodicWorkRequestBuilder<AutomationPollWorker>(15, TimeUnit.MINUTES)
.setInputData(androidx.work.Data.Builder().putString(KEY_PROFILE_ID, profileId.value).build()) .setInputData(androidx.work.Data.Builder().putString(KEY_PROFILE_ID, profileId.value).build())
.build() .build()