add setting to exclude apps from shortcuts search
This commit is contained in:
@@ -5,7 +5,11 @@ import android.os.Process
|
||||
import android.os.UserHandle
|
||||
import android.os.UserManager
|
||||
|
||||
private val cache = mutableMapOf<Int, Long>()
|
||||
|
||||
fun UserHandle.getSerialNumber(context: Context): Long {
|
||||
val userManager = context.getSystemService(Context.USER_SERVICE) as UserManager
|
||||
return userManager.getSerialNumberForUser(this)
|
||||
return cache.getOrPut(hashCode()) {
|
||||
val userManager = context.getSystemService(Context.USER_SERVICE) as UserManager
|
||||
userManager.getSerialNumberForUser(this)
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,7 @@ data class LauncherSettingsData internal constructor(
|
||||
val calendarSearchExcludedCalendars: Set<String> = setOf(),
|
||||
|
||||
val shortcutSearchEnabled: Boolean = true,
|
||||
val shortcutSearchBlocklist: Set<String> = setOf(),
|
||||
|
||||
val calculatorEnabled: Boolean = true,
|
||||
|
||||
|
||||
@@ -10,9 +10,22 @@ class ShortcutSearchSettings internal constructor(
|
||||
val enabled
|
||||
get() = dataStore.data.map { it.shortcutSearchEnabled }.distinctUntilChanged()
|
||||
|
||||
/**
|
||||
* Set of blocked packages that should not be shown in the search results.
|
||||
* Format: packageName:userId
|
||||
*/
|
||||
val blocklist
|
||||
get() = dataStore.data.map { it.shortcutSearchBlocklist }.distinctUntilChanged()
|
||||
|
||||
fun setEnabled(enabled: Boolean) {
|
||||
dataStore.update {
|
||||
it.copy(shortcutSearchEnabled = enabled)
|
||||
}
|
||||
}
|
||||
|
||||
fun setBlocklist(blocklist: Set<String>) {
|
||||
dataStore.update {
|
||||
it.copy(shortcutSearchBlocklist = blocklist)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user