From 48571e2d0de5cdca0e30ae9369902c9dcb7dc6d2 Mon Sep 17 00:00:00 2001 From: Adrian Castro <22133246+castdrian@users.noreply.github.com> Date: Sun, 23 Aug 2026 10:33:56 +0200 Subject: [PATCH] fix: normalize Thor identifiers across property formats --- app/src/main/java/dev/adrian/thortools/ThorDeviceProfile.kt | 3 ++- .../test/java/dev/adrian/thortools/ThorDeviceProfileTest.kt | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) 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)