From c9b028804cc4eed313ffe67baba3a60b02995166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 1 Aug 2014 17:47:07 +0200 Subject: Add user id with dialog --- .../sufficientlysecure/keychain/pgp/KeyRing.java | 28 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/KeyRing.java') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/KeyRing.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/KeyRing.java index ebc49ab05..7d11a20d3 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/KeyRing.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/KeyRing.java @@ -1,12 +1,15 @@ package org.sufficientlysecure.keychain.pgp; +import android.text.TextUtils; + import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import java.util.regex.Matcher; import java.util.regex.Pattern; -/** An abstract KeyRing. - * +/** + * An abstract KeyRing. + *

* This is an abstract class for all KeyRing constructs. It serves as a common * denominator of available information, two implementations wrapping the same * keyring should in all cases agree on the output of all methods described @@ -14,7 +17,6 @@ import java.util.regex.Pattern; * * @see CanonicalizedKeyRing * @see org.sufficientlysecure.keychain.provider.CachedPublicKeyRing - * */ public abstract class KeyRing { @@ -77,4 +79,24 @@ public abstract class KeyRing { return result; } + /** + * Returns a composed user id. Returns null if name is null! + * + * @param name + * @param email + * @param comment + * @return + */ + public static String createUserId(String name, String email, String comment) { + String userId = name; // consider name a required value + if (userId != null && !TextUtils.isEmpty(comment)) { + userId += " (" + comment + ")"; + } + if (userId != null && !TextUtils.isEmpty(email)) { + userId += " <" + email + ">"; + } + + return userId; + } + } -- cgit v1.2.3