From 051d455c9f68d7edbc75abbc8d9293dd34d1d250 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Mon, 15 Feb 2021 13:05:09 +0530 Subject: Add tests for GPG identifier parsing (#1319) --- .../src/main/java/me/msfjarvis/openpgpktx/util/OpenPgpUtils.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'openpgp-ktx/src') diff --git a/openpgp-ktx/src/main/java/me/msfjarvis/openpgpktx/util/OpenPgpUtils.kt b/openpgp-ktx/src/main/java/me/msfjarvis/openpgpktx/util/OpenPgpUtils.kt index cca90653..439c9278 100644 --- a/openpgp-ktx/src/main/java/me/msfjarvis/openpgpktx/util/OpenPgpUtils.kt +++ b/openpgp-ktx/src/main/java/me/msfjarvis/openpgpktx/util/OpenPgpUtils.kt @@ -6,7 +6,6 @@ package me.msfjarvis.openpgpktx.util import android.content.Context import android.content.Intent -import android.text.TextUtils import java.io.Serializable import java.util.Locale import java.util.regex.Pattern @@ -64,7 +63,7 @@ public object OpenPgpUtils { * See SplitUserIdTest for examples. */ public fun splitUserId(userId: String): UserId { - if (!TextUtils.isEmpty(userId)) { + if (userId.isNotEmpty()) { val matcher = USER_ID_PATTERN.matcher(userId) if (matcher.matches()) { var name = if (matcher.group(1).isEmpty()) null else matcher.group(1) @@ -95,15 +94,15 @@ public object OpenPgpUtils { */ public fun createUserId(userId: UserId): String? { val userIdBuilder = StringBuilder() - if (!TextUtils.isEmpty(userId.name)) { + if (!userId.name.isNullOrEmpty()) { userIdBuilder.append(userId.name) } - if (!TextUtils.isEmpty(userId.comment)) { + if (!userId.comment.isNullOrEmpty()) { userIdBuilder.append(" (") userIdBuilder.append(userId.comment) userIdBuilder.append(")") } - if (!TextUtils.isEmpty(userId.email)) { + if (!userId.email.isNullOrEmpty()) { userIdBuilder.append(" <") userIdBuilder.append(userId.email) userIdBuilder.append(">") -- cgit v1.2.3