diff --git a/app/src/main/java/dev/adrian/thortools/ThorDeviceProfile.kt b/app/src/main/java/dev/adrian/thortools/ThorDeviceProfile.kt index 0b2c5bd..ae63736 100644 --- a/app/src/main/java/dev/adrian/thortools/ThorDeviceProfile.kt +++ b/app/src/main/java/dev/adrian/thortools/ThorDeviceProfile.kt @@ -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( @@ -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, diff --git a/app/src/test/java/dev/adrian/thortools/ThorDeviceProfileTest.kt b/app/src/test/java/dev/adrian/thortools/ThorDeviceProfileTest.kt index 7a7db8c..77a0e8a 100644 --- a/app/src/test/java/dev/adrian/thortools/ThorDeviceProfileTest.kt +++ b/app/src/test/java/dev/adrian/thortools/ThorDeviceProfileTest.kt @@ -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)