Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/src/main/java/dev/adrian/thortools/ThorDeviceProfile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ object DeviceProfile {
const val THOR_DISPLAY_ROTATION = 0

private val thorPattern = Regex("(^|\\s)(ayn\\s*)?thor(?:\\s*(lite|base|pro|max))?(\\s|$)")
private val identifierSeparatorPattern = Regex("[^a-z0-9]+")

fun detect(properties: DeviceProperties): ThorDeviceProfile {
val searchable = listOf(
Expand Down Expand Up @@ -102,7 +103,7 @@ object DeviceProfile {
}
}

private fun String.normalized(): String = lowercase().replace('_', ' ').replace('-', ' ')
private fun String.normalized(): String = identifierSeparatorPattern.replace(lowercase(), " ").trim()

fun isThorLowerDisplay(
widthPixels: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class ThorDeviceProfileTest {
assertTrue(DeviceProfile.detect(DeviceProperties(device = "thorpro")).isThor)
assertTrue(DeviceProfile.detect(DeviceProperties(product = "AYNThorMax")).isThor)
assertTrue(DeviceProfile.detect(DeviceProperties(product = "AYN Thor Max")).isThor)
assertEquals(ThorVariant.PRO, DeviceProfile.detect(DeviceProperties(model = "AYN/Thor Pro")).variant)
assertEquals(ThorVariant.LITE, DeviceProfile.detect(DeviceProperties(model = "AYN.Thor Lite")).variant)
assertTrue(DeviceProfile.detect(DeviceProperties(manufacturer = "AYN", model = "Thor")).isThor)
assertTrue(DeviceProfile.detect(DeviceProperties(hardware = "thor_lite")).isThor)
assertTrue(DeviceProfile.detect(DeviceProperties(board = "thor_max_board")).isThor)
Expand Down