mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-27 06:29:54 +00:00
Make CameraX blocklist remote configurable.
This commit is contained in:
committed by
Cody Henthorne
parent
ace4157a14
commit
91d3f331e5
@@ -0,0 +1,23 @@
|
||||
package org.signal.core.util
|
||||
|
||||
/**
|
||||
* Treats the string as a serialized list of tokens and tells you if an item is present in the list.
|
||||
* In addition to exact matches, this handles wildcards at the end of an item.
|
||||
*
|
||||
* e.g. a,b,c*,d
|
||||
*/
|
||||
fun String.asListContains(item: String): Boolean {
|
||||
val items: List<String> = this
|
||||
.split(",")
|
||||
.map { it.trim() }
|
||||
.filter { it.isNotEmpty() }
|
||||
.toList()
|
||||
|
||||
val exactMatches = items.filter { it.last() != '*' }
|
||||
val prefixMatches = items.filter { it.last() == '*' }
|
||||
|
||||
return exactMatches.contains(item) ||
|
||||
prefixMatches
|
||||
.map { it.substring(0, it.length - 1) }
|
||||
.any { item.startsWith(it) }
|
||||
}
|
||||
Reference in New Issue
Block a user