diff --git a/app-common/src/main/java/im/angry/openeuicc/ui/NotificationsActivity.kt b/app-common/src/main/java/im/angry/openeuicc/ui/NotificationsActivity.kt index 099c627..02cdac8 100644 --- a/app-common/src/main/java/im/angry/openeuicc/ui/NotificationsActivity.kt +++ b/app-common/src/main/java/im/angry/openeuicc/ui/NotificationsActivity.kt @@ -164,14 +164,14 @@ class NotificationsActivity: BaseEuiccAccessActivity(), OpenEuiccContextMarker { } - private fun operationToLocalizedText(operation: ProfileManagementOperation?) = - root.context.getString(when (operation) { - ProfileManagementOperation.Install -> R.string.profile_notification_operation_download - ProfileManagementOperation.Delete -> R.string.profile_notification_operation_delete - ProfileManagementOperation.Enable -> R.string.profile_notification_operation_enable - ProfileManagementOperation.Disable -> R.string.profile_notification_operation_disable - else -> throw IllegalStateException("Unknown operation: $operation") - }) + private fun operationToLocalizedText(operation: ProfileManagementOperation) = + root.context.getText( + when (operation) { + ProfileManagementOperation.Install -> R.string.profile_notification_operation_download + ProfileManagementOperation.Delete -> R.string.profile_notification_operation_delete + ProfileManagementOperation.Enable -> R.string.profile_notification_operation_enable + ProfileManagementOperation.Disable -> R.string.profile_notification_operation_disable + }) fun updateNotification(value: LocalProfileNotificationWrapper) { notification = value diff --git a/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/EuiccConfiguredAddresses.kt b/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/EuiccConfiguredAddresses.kt index 9320de8..2a622ed 100644 --- a/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/EuiccConfiguredAddresses.kt +++ b/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/EuiccConfiguredAddresses.kt @@ -9,21 +9,21 @@ private val invalidDPAddresses = setOf( "testrootsmds.example.com", ) -data class EuiccConfiguredAddresses( - val defaultDPAddress: String, - val rootDSAddress: String -) { +class EuiccConfiguredAddresses(defaultDPAddress: String, rootDSAddress: String) { + val defaultDPAddress = defaultDPAddress.takeUnless(::isInvalidDPAddress) + val rootDSAddress = rootDSAddress.takeUnless(::isInvalidDSAddress) + val discoverable: Boolean - get() = isValidDPAddress(defaultDPAddress) || - isValidDSAddress(rootDSAddress) + get() = !defaultDPAddress.isNullOrBlank() || !rootDSAddress.isNullOrBlank() } -private fun isValidDPAddress(address: String): Boolean { - return address.isNotBlank() && Patterns.DOMAIN_NAME.matcher(address).matches() +private fun isInvalidDPAddress(address: String?): Boolean { + if (address.isNullOrBlank()) return true + return !Patterns.DOMAIN_NAME.matcher(address).matches() } -private fun isValidDSAddress(address: String): Boolean { - if (address.isBlank()) return false - if (address in invalidDPAddresses) return false - return Patterns.DOMAIN_NAME.matcher(address).matches() +private fun isInvalidDSAddress(address: String?): Boolean { + if (address.isNullOrBlank()) return true + if (address in invalidDPAddresses) return true + return !Patterns.DOMAIN_NAME.matcher(address).matches() } \ No newline at end of file diff --git a/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/LocalProfileNotification.kt b/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/LocalProfileNotification.kt index 2261f6d..3ecb65b 100644 --- a/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/LocalProfileNotification.kt +++ b/libs/lpac-jni/src/main/java/net/typeblog/lpac_jni/LocalProfileNotification.kt @@ -2,7 +2,7 @@ package net.typeblog.lpac_jni data class LocalProfileNotification( val seqNumber: Long, - val profileManagementOperation: ProfileManagementOperation?, + val profileManagementOperation: ProfileManagementOperation, val notificationAddress: String, val iccid: String, )