From 214e62a5aed6fb651d5cba7b747aa623de4a3c05 Mon Sep 17 00:00:00 2001 From: Jonas Lochmann Date: Mon, 20 Jan 2020 01:00:00 +0100 Subject: [PATCH] Extend connected mode migration routine --- .../migrate_to_connected/OfflineModeStatus.kt | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/timelimit/android/ui/migrate_to_connected/OfflineModeStatus.kt b/app/src/main/java/io/timelimit/android/ui/migrate_to_connected/OfflineModeStatus.kt index cd40017..45f8731 100644 --- a/app/src/main/java/io/timelimit/android/ui/migrate_to_connected/OfflineModeStatus.kt +++ b/app/src/main/java/io/timelimit/android/ui/migrate_to_connected/OfflineModeStatus.kt @@ -1,5 +1,5 @@ /* - * TimeLimit Copyright 2019 Jonas Lochmann + * TimeLimit Copyright 2019 - 2020 Jonas Lochmann * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -144,6 +144,35 @@ data class OfflineModeStatus( ) } + if (category.minBatteryLevelMobile > 0 || category.minBatteryLevelWhileCharging > 0) { + apply( + UpdateCategoryBatteryLimit( + categoryId = category.id, + mobileLimit = category.minBatteryLevelMobile, + chargingLimit = category.minBatteryLevelWhileCharging + ) + ) + } + + if (category.timeWarnings != 0) { + apply( + UpdateCategoryTimeWarningsAction( + categoryId = category.id, + enable = true, + flags = category.timeWarnings + ) + ) + } + + if (category.blockAllNotifications) { + apply( + UpdateCategoryBlockAllNotificationsAction( + categoryId = category.id, + blocked = true + ) + ) + } + // add category apps val thisCategoryApps = categoryApps.filter { it.categoryId == category.id } if (thisCategoryApps.isNotEmpty()) { @@ -219,5 +248,12 @@ data class OfflineModeStatus( considerRebootManipulation = true )) } + + if (device.enableActivityLevelBlocking) { + apply(UpdateEnableActivityLevelBlocking( + deviceId = newDeviceId, + enable = true + )) + } } } \ No newline at end of file