Add debug preference to rebuild icon pack cache

This commit is contained in:
MM20
2023-04-17 18:57:15 +02:00
parent d3e1fb2767
commit d4cf895481
5 changed files with 23 additions and 2 deletions
@@ -56,6 +56,12 @@ fun DebugSettingsScreen() {
).show()
}
})
Preference(
title = stringResource(R.string.preference_debug_reinstall_iconpacks),
summary = stringResource(R.string.preference_debug_reinstall_iconpacks_summary),
onClick = {
viewModel.reinstallIconPacks()
})
}
}
}
@@ -2,6 +2,7 @@ package de.mm20.launcher2.ui.settings.debug
import androidx.lifecycle.ViewModel
import de.mm20.launcher2.data.customattrs.CustomAttributesRepository
import de.mm20.launcher2.icons.IconService
import de.mm20.launcher2.searchable.SearchableRepository
import org.koin.core.component.KoinComponent
import org.koin.core.component.inject
@@ -10,9 +11,14 @@ class DebugSettingsScreenVM: ViewModel(), KoinComponent {
private val searchableRepository: SearchableRepository by inject()
private val customAttributesRepository: CustomAttributesRepository by inject()
private val iconService: IconService by inject()
suspend fun cleanUpDatabase(): Int {
var removed = searchableRepository.cleanupDatabase()
removed += customAttributesRepository.cleanupDatabase()
return removed
}
fun reinstallIconPacks() {
iconService.reinstallAllIconPacks()
}
}