Use category for Apps without category

This commit is contained in:
Jonas L 2019-01-24 20:36:54 +01:00
parent 0c60d0be42
commit bb918eac7a
2 changed files with 13 additions and 1 deletions

View file

@ -185,6 +185,7 @@ class BackgroundTaskLogic(val appLogic: AppLogic) {
} else if (foregroundAppPackageName != null) {
val appCategory = appCategories.get(Pair(foregroundAppPackageName, categories.map { it.id })).waitForNullableValue()
val category = categories.find { it.id == appCategory?.categoryId }
?: categories.find { it.id == deviceUserEntry.categoryForNotAssignedApps }
if (category == null) {
usedTimeUpdateHelper?.commit(appLogic)

View file

@ -120,7 +120,18 @@ class BlockingReasonUtil(private val appLogic: AppLogic) {
categoryEntry ->
if (categoryEntry == null) {
liveDataFromValue(BlockingReason.NotPartOfAnCategory)
val defaultCategory = if (child.categoryForNotAssignedApps.isEmpty())
liveDataFromValue(null as Category?)
else
appLogic.database.category().getCategoryByChildIdAndId(child.id, child.categoryForNotAssignedApps)
defaultCategory.switchMap { categoryEntry2 ->
if (categoryEntry2 == null) {
liveDataFromValue(BlockingReason.NotPartOfAnCategory)
} else {
getBlockingReasonStep4Point5(categoryEntry2, child, timeZone)
}
}
} else if (categoryEntry.temporarilyBlocked) {
liveDataFromValue(BlockingReason.TemporarilyBlocked)
} else {