aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.gradle17
-rw-r--r--build.xml92
-rw-r--r--proguard-project.txt20
-rw-r--r--project.properties15
-rw-r--r--src/main/AndroidManifest.xml (renamed from AndroidManifest.xml)0
-rw-r--r--src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl (renamed from src/org/openintents/openpgp/IOpenPgpService.aidl)0
-rw-r--r--src/main/java/org/openintents/openpgp/OpenPgpError.java (renamed from src/org/openintents/openpgp/OpenPgpError.java)0
-rw-r--r--src/main/java/org/openintents/openpgp/OpenPgpMetadata.java (renamed from src/org/openintents/openpgp/OpenPgpMetadata.java)0
-rw-r--r--src/main/java/org/openintents/openpgp/OpenPgpSignatureResult.java (renamed from src/org/openintents/openpgp/OpenPgpSignatureResult.java)0
-rw-r--r--src/main/java/org/openintents/openpgp/util/OpenPgpApi.java (renamed from src/org/openintents/openpgp/util/OpenPgpApi.java)0
-rw-r--r--src/main/java/org/openintents/openpgp/util/OpenPgpListPreference.java (renamed from src/org/openintents/openpgp/util/OpenPgpListPreference.java)0
-rw-r--r--src/main/java/org/openintents/openpgp/util/OpenPgpServiceConnection.java (renamed from src/org/openintents/openpgp/util/OpenPgpServiceConnection.java)0
-rw-r--r--src/main/java/org/openintents/openpgp/util/OpenPgpUtils.java (renamed from src/org/openintents/openpgp/util/OpenPgpUtils.java)53
-rw-r--r--src/main/java/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java (renamed from src/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java)0
-rw-r--r--src/main/res/drawable-hdpi/ic_action_cancel_launchersize.png (renamed from res/drawable-hdpi/ic_action_cancel_launchersize.png)bin1520 -> 1520 bytes
-rw-r--r--src/main/res/drawable-hdpi/ic_action_cancel_launchersize_light.png (renamed from res/drawable-hdpi/ic_action_cancel_launchersize_light.png)bin1940 -> 1940 bytes
-rw-r--r--src/main/res/drawable-mdpi/ic_action_cancel_launchersize.png (renamed from res/drawable-mdpi/ic_action_cancel_launchersize.png)bin1032 -> 1032 bytes
-rw-r--r--src/main/res/drawable-mdpi/ic_action_cancel_launchersize_light.png (renamed from res/drawable-mdpi/ic_action_cancel_launchersize_light.png)bin1098 -> 1098 bytes
-rw-r--r--src/main/res/drawable-xhdpi/ic_action_cancel_launchersize.png (renamed from res/drawable-xhdpi/ic_action_cancel_launchersize.png)bin1570 -> 1570 bytes
-rw-r--r--src/main/res/drawable-xhdpi/ic_action_cancel_launchersize_light.png (renamed from res/drawable-xhdpi/ic_action_cancel_launchersize_light.png)bin2039 -> 2039 bytes
-rw-r--r--src/main/res/drawable-xxhdpi/ic_action_cancel_launchersize.png (renamed from res/drawable-xxhdpi/ic_action_cancel_launchersize.png)bin2345 -> 2345 bytes
-rw-r--r--src/main/res/drawable-xxhdpi/ic_action_cancel_launchersize_light.png (renamed from res/drawable-xxhdpi/ic_action_cancel_launchersize_light.png)bin2404 -> 2404 bytes
-rw-r--r--src/main/res/values-cs/strings.xml (renamed from res/values-cs/strings.xml)0
-rw-r--r--src/main/res/values-de/strings.xml (renamed from res/values-de/strings.xml)0
-rw-r--r--src/main/res/values-es/strings.xml (renamed from res/values-es/strings.xml)0
-rw-r--r--src/main/res/values-et/strings.xml (renamed from res/values-et/strings.xml)0
-rw-r--r--src/main/res/values-fi/strings.xml (renamed from res/values-fi/strings.xml)0
-rw-r--r--src/main/res/values-fr/strings.xml (renamed from res/values-fr/strings.xml)0
-rw-r--r--src/main/res/values-is/strings.xml (renamed from res/values-is/strings.xml)0
-rw-r--r--src/main/res/values-it/strings.xml (renamed from res/values-it/strings.xml)0
-rw-r--r--src/main/res/values-ja/strings.xml (renamed from res/values-ja/strings.xml)0
-rw-r--r--src/main/res/values-nl/strings.xml (renamed from res/values-nl/strings.xml)0
-rw-r--r--src/main/res/values-pl/strings.xml (renamed from res/values-pl/strings.xml)0
-rw-r--r--src/main/res/values-pt/strings.xml (renamed from res/values-pt/strings.xml)0
-rw-r--r--src/main/res/values-ru/strings.xml (renamed from res/values-ru/strings.xml)0
-rw-r--r--src/main/res/values-sl/strings.xml (renamed from res/values-sl/strings.xml)0
-rw-r--r--src/main/res/values-tr/strings.xml (renamed from res/values-tr/strings.xml)0
-rw-r--r--src/main/res/values-uk/strings.xml (renamed from res/values-uk/strings.xml)0
-rw-r--r--src/main/res/values-zh/strings.xml (renamed from res/values-zh/strings.xml)0
-rw-r--r--src/main/res/values/strings.xml (renamed from res/values/strings.xml)0
-rw-r--r--src/main/test/org/openintents/openpgp/OpenPgpUtilsTest.java50
41 files changed, 76 insertions, 171 deletions
diff --git a/build.gradle b/build.gradle
index e07c6a3..0b0647f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -12,21 +12,8 @@ buildscript {
apply plugin: 'com.android.library'
android {
- compileSdkVersion 19
- buildToolsVersion '19.1'
-
- // NOTE: We are using the old folder structure to also support Eclipse
- sourceSets {
- main {
- manifest.srcFile 'AndroidManifest.xml'
- java.srcDirs = ['src']
- resources.srcDirs = ['src']
- aidl.srcDirs = ['src']
- renderscript.srcDirs = ['src']
- res.srcDirs = ['res']
- assets.srcDirs = ['assets']
- }
- }
+ compileSdkVersion 21
+ buildToolsVersion '21.1.1'
// Do not abort build if lint finds errors
lintOptions {
diff --git a/build.xml b/build.xml
deleted file mode 100644
index 48ebf19..0000000
--- a/build.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="keychain-api-library" default="help">
-
- <!-- The local.properties file is created and updated by the 'android' tool.
- It contains the path to the SDK. It should *NOT* be checked into
- Version Control Systems. -->
- <property file="local.properties" />
-
- <!-- The ant.properties file can be created by you. It is only edited by the
- 'android' tool to add properties to it.
- This is the place to change some Ant specific build properties.
- Here are some properties you may want to change/update:
-
- source.dir
- The name of the source directory. Default is 'src'.
- out.dir
- The name of the output directory. Default is 'bin'.
-
- For other overridable properties, look at the beginning of the rules
- files in the SDK, at tools/ant/build.xml
-
- Properties related to the SDK location or the project target should
- be updated using the 'android' tool with the 'update' action.
-
- This file is an integral part of the build system for your
- application and should be checked into Version Control Systems.
-
- -->
- <property file="ant.properties" />
-
- <!-- if sdk.dir was not set from one of the property file, then
- get it from the ANDROID_HOME env var.
- This must be done before we load project.properties since
- the proguard config can use sdk.dir -->
- <property environment="env" />
- <condition property="sdk.dir" value="${env.ANDROID_HOME}">
- <isset property="env.ANDROID_HOME" />
- </condition>
-
- <!-- The project.properties file is created and updated by the 'android'
- tool, as well as ADT.
-
- This contains project specific properties such as project target, and library
- dependencies. Lower level build properties are stored in ant.properties
- (or in .classpath for Eclipse projects).
-
- This file is an integral part of the build system for your
- application and should be checked into Version Control Systems. -->
- <loadproperties srcFile="project.properties" />
-
- <!-- quick check on sdk.dir -->
- <fail
- message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
- unless="sdk.dir"
- />
-
- <!--
- Import per project custom build rules if present at the root of the project.
- This is the place to put custom intermediary targets such as:
- -pre-build
- -pre-compile
- -post-compile (This is typically used for code obfuscation.
- Compiled code location: ${out.classes.absolute.dir}
- If this is not done in place, override ${out.dex.input.absolute.dir})
- -post-package
- -post-build
- -pre-clean
- -->
- <import file="custom_rules.xml" optional="true" />
-
- <!-- Import the actual build file.
-
- To customize existing targets, there are two options:
- - Customize only one target:
- - copy/paste the target into this file, *before* the
- <import> task.
- - customize it to your needs.
- - Customize the whole content of build.xml
- - copy/paste the content of the rules files (minus the top node)
- into this file, replacing the <import> task.
- - customize to your needs.
-
- ***********************
- ****** IMPORTANT ******
- ***********************
- In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
- in order to avoid having your file be overridden by tools such as "android update project"
- -->
- <!-- version-tag: 1 -->
- <import file="${sdk.dir}/tools/ant/build.xml" />
-
-</project>
diff --git a/proguard-project.txt b/proguard-project.txt
deleted file mode 100644
index f2fe155..0000000
--- a/proguard-project.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# To enable ProGuard in your project, edit project.properties
-# to define the proguard.config property as described in that file.
-#
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in ${sdk.dir}/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/project.properties b/project.properties
deleted file mode 100644
index 91d2b02..0000000
--- a/project.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-19
-android.library=true
diff --git a/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 98cb89f..98cb89f 100644
--- a/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
diff --git a/src/org/openintents/openpgp/IOpenPgpService.aidl b/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl
index 2451207..2451207 100644
--- a/src/org/openintents/openpgp/IOpenPgpService.aidl
+++ b/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl
diff --git a/src/org/openintents/openpgp/OpenPgpError.java b/src/main/java/org/openintents/openpgp/OpenPgpError.java
index ce8f21f..ce8f21f 100644
--- a/src/org/openintents/openpgp/OpenPgpError.java
+++ b/src/main/java/org/openintents/openpgp/OpenPgpError.java
diff --git a/src/org/openintents/openpgp/OpenPgpMetadata.java b/src/main/java/org/openintents/openpgp/OpenPgpMetadata.java
index d620a57..d620a57 100644
--- a/src/org/openintents/openpgp/OpenPgpMetadata.java
+++ b/src/main/java/org/openintents/openpgp/OpenPgpMetadata.java
diff --git a/src/org/openintents/openpgp/OpenPgpSignatureResult.java b/src/main/java/org/openintents/openpgp/OpenPgpSignatureResult.java
index 7eb06d9..7eb06d9 100644
--- a/src/org/openintents/openpgp/OpenPgpSignatureResult.java
+++ b/src/main/java/org/openintents/openpgp/OpenPgpSignatureResult.java
diff --git a/src/org/openintents/openpgp/util/OpenPgpApi.java b/src/main/java/org/openintents/openpgp/util/OpenPgpApi.java
index dbfb797..dbfb797 100644
--- a/src/org/openintents/openpgp/util/OpenPgpApi.java
+++ b/src/main/java/org/openintents/openpgp/util/OpenPgpApi.java
diff --git a/src/org/openintents/openpgp/util/OpenPgpListPreference.java b/src/main/java/org/openintents/openpgp/util/OpenPgpListPreference.java
index 31ba97c..31ba97c 100644
--- a/src/org/openintents/openpgp/util/OpenPgpListPreference.java
+++ b/src/main/java/org/openintents/openpgp/util/OpenPgpListPreference.java
diff --git a/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java b/src/main/java/org/openintents/openpgp/util/OpenPgpServiceConnection.java
index bbc8645..bbc8645 100644
--- a/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java
+++ b/src/main/java/org/openintents/openpgp/util/OpenPgpServiceConnection.java
diff --git a/src/org/openintents/openpgp/util/OpenPgpUtils.java b/src/main/java/org/openintents/openpgp/util/OpenPgpUtils.java
index a5e0163..ef0a88c 100644
--- a/src/org/openintents/openpgp/util/OpenPgpUtils.java
+++ b/src/main/java/org/openintents/openpgp/util/OpenPgpUtils.java
@@ -24,6 +24,7 @@ import java.util.regex.Pattern;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
+import android.text.TextUtils;
public class OpenPgpUtils {
@@ -55,11 +56,7 @@ public class OpenPgpUtils {
public static boolean isAvailable(Context context) {
Intent intent = new Intent(OpenPgpApi.SERVICE_INTENT);
List<ResolveInfo> resInfo = context.getPackageManager().queryIntentServices(intent, 0);
- if (!resInfo.isEmpty()) {
- return true;
- } else {
- return false;
- }
+ return !resInfo.isEmpty();
}
public static String convertKeyIdToHex(long keyId) {
@@ -74,38 +71,36 @@ public class OpenPgpUtils {
return hexString;
}
- private static final Pattern USER_ID_PATTERN = Pattern.compile("^(.*?)(?: \\((.*)\\))?(?: <(.*)>)?$");
+ private static final Pattern USER_ID_PATTERN = Pattern.compile("^(.*?)(?: (\\[.*\\]))?(?: \\((.*)\\))?(?: <(.*)>)?$");
/**
* Splits userId string into naming part, email part, and comment part
+ * <p/>
+ * User ID matching:
+ * http://fiddle.re/t4p6f
*
* @param userId
- * @return array with naming (0), email (1), comment (2)
+ * @return theParsedUserInfo
*/
- public static String[] splitUserId(String userId) {
- String[] result = new String[]{null, null, null};
-
- if (userId == null || userId.equals("")) {
- return result;
+ public static UserInfo splitUserId(final String userId) {
+ if (!TextUtils.isEmpty(userId)) {
+ final Matcher matcher = USER_ID_PATTERN.matcher(userId);
+ if (matcher.matches()) {
+ return new UserInfo(matcher.group(1), matcher.group(4), matcher.group(3));
+ }
}
+ return new UserInfo(null, null, null);
+ }
- /*
- * User ID matching:
- * http://fiddle.re/t4p6f
- *
- * test cases:
- * "Max Mustermann (this is a comment) <max@example.com>"
- * "Max Mustermann <max@example.com>"
- * "Max Mustermann (this is a comment)"
- * "Max Mustermann [this is nothing]"
- */
- Matcher matcher = USER_ID_PATTERN.matcher(userId);
- if (matcher.matches()) {
- result[0] = matcher.group(1);
- result[1] = matcher.group(3);
- result[2] = matcher.group(2);
- }
+ public static class UserInfo {
+ public final String name;
+ public final String email;
+ public final String comment;
- return result;
+ public UserInfo(String name, String email, String comment) {
+ this.name = name;
+ this.email = email;
+ this.comment = comment;
+ }
}
}
diff --git a/src/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java b/src/main/java/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java
index b9492f9..b9492f9 100644
--- a/src/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java
+++ b/src/main/java/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java
diff --git a/res/drawable-hdpi/ic_action_cancel_launchersize.png b/src/main/res/drawable-hdpi/ic_action_cancel_launchersize.png
index 71b9118..71b9118 100644
--- a/res/drawable-hdpi/ic_action_cancel_launchersize.png
+++ b/src/main/res/drawable-hdpi/ic_action_cancel_launchersize.png
Binary files differ
diff --git a/res/drawable-hdpi/ic_action_cancel_launchersize_light.png b/src/main/res/drawable-hdpi/ic_action_cancel_launchersize_light.png
index 73b1d08..73b1d08 100644
--- a/res/drawable-hdpi/ic_action_cancel_launchersize_light.png
+++ b/src/main/res/drawable-hdpi/ic_action_cancel_launchersize_light.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_action_cancel_launchersize.png b/src/main/res/drawable-mdpi/ic_action_cancel_launchersize.png
index 270abf4..270abf4 100644
--- a/res/drawable-mdpi/ic_action_cancel_launchersize.png
+++ b/src/main/res/drawable-mdpi/ic_action_cancel_launchersize.png
Binary files differ
diff --git a/res/drawable-mdpi/ic_action_cancel_launchersize_light.png b/src/main/res/drawable-mdpi/ic_action_cancel_launchersize_light.png
index d841821..d841821 100644
--- a/res/drawable-mdpi/ic_action_cancel_launchersize_light.png
+++ b/src/main/res/drawable-mdpi/ic_action_cancel_launchersize_light.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_action_cancel_launchersize.png b/src/main/res/drawable-xhdpi/ic_action_cancel_launchersize.png
index 1e3571f..1e3571f 100644
--- a/res/drawable-xhdpi/ic_action_cancel_launchersize.png
+++ b/src/main/res/drawable-xhdpi/ic_action_cancel_launchersize.png
Binary files differ
diff --git a/res/drawable-xhdpi/ic_action_cancel_launchersize_light.png b/src/main/res/drawable-xhdpi/ic_action_cancel_launchersize_light.png
index d505046..d505046 100644
--- a/res/drawable-xhdpi/ic_action_cancel_launchersize_light.png
+++ b/src/main/res/drawable-xhdpi/ic_action_cancel_launchersize_light.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_action_cancel_launchersize.png b/src/main/res/drawable-xxhdpi/ic_action_cancel_launchersize.png
index 5204460..5204460 100644
--- a/res/drawable-xxhdpi/ic_action_cancel_launchersize.png
+++ b/src/main/res/drawable-xxhdpi/ic_action_cancel_launchersize.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_action_cancel_launchersize_light.png b/src/main/res/drawable-xxhdpi/ic_action_cancel_launchersize_light.png
index d6fb86b..d6fb86b 100644
--- a/res/drawable-xxhdpi/ic_action_cancel_launchersize_light.png
+++ b/src/main/res/drawable-xxhdpi/ic_action_cancel_launchersize_light.png
Binary files differ
diff --git a/res/values-cs/strings.xml b/src/main/res/values-cs/strings.xml
index c9fe1fa..c9fe1fa 100644
--- a/res/values-cs/strings.xml
+++ b/src/main/res/values-cs/strings.xml
diff --git a/res/values-de/strings.xml b/src/main/res/values-de/strings.xml
index 91e800a..91e800a 100644
--- a/res/values-de/strings.xml
+++ b/src/main/res/values-de/strings.xml
diff --git a/res/values-es/strings.xml b/src/main/res/values-es/strings.xml
index da8979b..da8979b 100644
--- a/res/values-es/strings.xml
+++ b/src/main/res/values-es/strings.xml
diff --git a/res/values-et/strings.xml b/src/main/res/values-et/strings.xml
index c757504..c757504 100644
--- a/res/values-et/strings.xml
+++ b/src/main/res/values-et/strings.xml
diff --git a/res/values-fi/strings.xml b/src/main/res/values-fi/strings.xml
index c757504..c757504 100644
--- a/res/values-fi/strings.xml
+++ b/src/main/res/values-fi/strings.xml
diff --git a/res/values-fr/strings.xml b/src/main/res/values-fr/strings.xml
index 9b36df2..9b36df2 100644
--- a/res/values-fr/strings.xml
+++ b/src/main/res/values-fr/strings.xml
diff --git a/res/values-is/strings.xml b/src/main/res/values-is/strings.xml
index c757504..c757504 100644
--- a/res/values-is/strings.xml
+++ b/src/main/res/values-is/strings.xml
diff --git a/res/values-it/strings.xml b/src/main/res/values-it/strings.xml
index 23e8e80..23e8e80 100644
--- a/res/values-it/strings.xml
+++ b/src/main/res/values-it/strings.xml
diff --git a/res/values-ja/strings.xml b/src/main/res/values-ja/strings.xml
index 5e337f5..5e337f5 100644
--- a/res/values-ja/strings.xml
+++ b/src/main/res/values-ja/strings.xml
diff --git a/res/values-nl/strings.xml b/src/main/res/values-nl/strings.xml
index c757504..c757504 100644
--- a/res/values-nl/strings.xml
+++ b/src/main/res/values-nl/strings.xml
diff --git a/res/values-pl/strings.xml b/src/main/res/values-pl/strings.xml
index c757504..c757504 100644
--- a/res/values-pl/strings.xml
+++ b/src/main/res/values-pl/strings.xml
diff --git a/res/values-pt/strings.xml b/src/main/res/values-pt/strings.xml
index c757504..c757504 100644
--- a/res/values-pt/strings.xml
+++ b/src/main/res/values-pt/strings.xml
diff --git a/res/values-ru/strings.xml b/src/main/res/values-ru/strings.xml
index e8fd1dd..e8fd1dd 100644
--- a/res/values-ru/strings.xml
+++ b/src/main/res/values-ru/strings.xml
diff --git a/res/values-sl/strings.xml b/src/main/res/values-sl/strings.xml
index 20bf70b..20bf70b 100644
--- a/res/values-sl/strings.xml
+++ b/src/main/res/values-sl/strings.xml
diff --git a/res/values-tr/strings.xml b/src/main/res/values-tr/strings.xml
index c757504..c757504 100644
--- a/res/values-tr/strings.xml
+++ b/src/main/res/values-tr/strings.xml
diff --git a/res/values-uk/strings.xml b/src/main/res/values-uk/strings.xml
index baf600a..baf600a 100644
--- a/res/values-uk/strings.xml
+++ b/src/main/res/values-uk/strings.xml
diff --git a/res/values-zh/strings.xml b/src/main/res/values-zh/strings.xml
index c757504..c757504 100644
--- a/res/values-zh/strings.xml
+++ b/src/main/res/values-zh/strings.xml
diff --git a/res/values/strings.xml b/src/main/res/values/strings.xml
index 0119831..0119831 100644
--- a/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
diff --git a/src/main/test/org/openintents/openpgp/OpenPgpUtilsTest.java b/src/main/test/org/openintents/openpgp/OpenPgpUtilsTest.java
new file mode 100644
index 0000000..f115398
--- /dev/null
+++ b/src/main/test/org/openintents/openpgp/OpenPgpUtilsTest.java
@@ -0,0 +1,50 @@
+package test.org.openintents.openpgp;
+
+import org.openintents.openpgp.util.OpenPgpUtils;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNull;
+
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.openintents.openpgp.util.OpenPgpUtils;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNull;
+
+@RunWith(AndroidJUnit4.class)
+public class OpenPgpUtilsTest {
+ @Test
+ public void splitCompleteUserIdShouldReturnAll3Components() throws Exception {
+ OpenPgpUtils.UserInfo info = OpenPgpUtils.splitUserId("Max Mustermann (this is a comment) <max@example.com>");
+ assertEquals("Max Mustermann", info.name);
+ assertEquals("this is a comment", info.comment);
+ assertEquals("max@example.com", info.email);
+ }
+
+ @Test
+ public void splitUserIdWithAllButCommentShouldReturnNameAndEmail() throws Exception {
+ OpenPgpUtils.UserInfo info = OpenPgpUtils.splitUserId("Max Mustermann <max@example.com>");
+ assertEquals("Max Mustermann", info.name);
+ assertNull(info.comment);
+ assertEquals("max@example.com", info.email);
+ }
+
+ @Test
+ public void splitUserIdWithAllButEmailShouldReturnNameAndComment() throws Exception {
+ OpenPgpUtils.UserInfo info = OpenPgpUtils.splitUserId("Max Mustermann (this is a comment)");
+ assertEquals(info.name, "Max Mustermann");
+ assertEquals(info.comment, "this is a comment");
+ assertNull(info.email);
+ }
+
+ @Test
+ public void splitUserIdWithOnlyNameShouldReturnNameOnly() throws Exception {
+ OpenPgpUtils.UserInfo info = OpenPgpUtils.splitUserId("Max Mustermann [this is a nothing]");
+ assertEquals("Max Mustermann", info.name);
+ assertNull(info.comment);
+ assertNull(info.email);
+ }
+} \ No newline at end of file