From a00a119e1830726bb09eb71f4b587a0f6de1e50f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 29 Jan 2015 20:53:25 +0100 Subject: [PATCH] Update OpenPGP API lib to newest version --- plugins/openpgp-api-library/build.gradle | 15 +----- .../openpgp-api-library/project.properties | 15 ------ .../{ => src/main}/AndroidManifest.xml | 0 .../openintents/openpgp/IOpenPgpService.aidl | 0 .../org/openintents/openpgp/OpenPgpError.java | 0 .../openintents/openpgp/OpenPgpMetadata.java | 0 .../openpgp/OpenPgpSignatureResult.java | 0 .../openintents/openpgp/util/OpenPgpApi.java | 35 +++++++++--- .../openpgp/util/OpenPgpListPreference.java | 11 +++- .../util/OpenPgpServiceConnection.java | 0 .../openpgp/util/OpenPgpUtils.java | 10 ++-- .../util/ParcelFileDescriptorUtil.java | 0 .../ic_action_cancel_launchersize.png | Bin .../ic_action_cancel_launchersize_light.png | Bin .../ic_action_cancel_launchersize.png | Bin .../ic_action_cancel_launchersize_light.png | Bin .../ic_action_cancel_launchersize.png | Bin .../ic_action_cancel_launchersize_light.png | Bin .../ic_action_cancel_launchersize.png | Bin .../ic_action_cancel_launchersize_light.png | Bin .../{ => src/main}/res/values-cs/strings.xml | 0 .../{ => src/main}/res/values-de/strings.xml | 0 .../{ => src/main}/res/values-es/strings.xml | 0 .../{ => src/main}/res/values-et/strings.xml | 0 .../{ => src/main}/res/values-fi/strings.xml | 0 .../{ => src/main}/res/values-fr/strings.xml | 0 .../{ => src/main}/res/values-is/strings.xml | 0 .../{ => src/main}/res/values-it/strings.xml | 0 .../{ => src/main}/res/values-ja/strings.xml | 0 .../{ => src/main}/res/values-nl/strings.xml | 0 .../{ => src/main}/res/values-pl/strings.xml | 0 .../{ => src/main}/res/values-pt/strings.xml | 0 .../{ => src/main}/res/values-ru/strings.xml | 0 .../{ => src/main}/res/values-sl/strings.xml | 0 .../{ => src/main}/res/values-tr/strings.xml | 0 .../{ => src/main}/res/values-uk/strings.xml | 0 .../{ => src/main}/res/values-zh/strings.xml | 0 .../{ => src/main}/res/values/strings.xml | 0 .../openintents/openpgp/OpenPgpUtilsTest.java | 50 ++++++++++++++++++ 39 files changed, 94 insertions(+), 42 deletions(-) delete mode 100644 plugins/openpgp-api-library/project.properties rename plugins/openpgp-api-library/{ => src/main}/AndroidManifest.xml (100%) rename plugins/openpgp-api-library/src/{ => main/aidl}/org/openintents/openpgp/IOpenPgpService.aidl (100%) rename plugins/openpgp-api-library/src/{ => main/java}/org/openintents/openpgp/OpenPgpError.java (100%) rename plugins/openpgp-api-library/src/{ => main/java}/org/openintents/openpgp/OpenPgpMetadata.java (100%) rename plugins/openpgp-api-library/src/{ => main/java}/org/openintents/openpgp/OpenPgpSignatureResult.java (100%) rename plugins/openpgp-api-library/src/{ => main/java}/org/openintents/openpgp/util/OpenPgpApi.java (94%) rename plugins/openpgp-api-library/src/{ => main/java}/org/openintents/openpgp/util/OpenPgpListPreference.java (95%) rename plugins/openpgp-api-library/src/{ => main/java}/org/openintents/openpgp/util/OpenPgpServiceConnection.java (100%) rename plugins/openpgp-api-library/src/{ => main/java}/org/openintents/openpgp/util/OpenPgpUtils.java (100%) rename plugins/openpgp-api-library/src/{ => main/java}/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java (100%) rename plugins/openpgp-api-library/{ => src/main}/res/drawable-hdpi/ic_action_cancel_launchersize.png (100%) rename plugins/openpgp-api-library/{ => src/main}/res/drawable-hdpi/ic_action_cancel_launchersize_light.png (100%) rename plugins/openpgp-api-library/{ => src/main}/res/drawable-mdpi/ic_action_cancel_launchersize.png (100%) rename plugins/openpgp-api-library/{ => src/main}/res/drawable-mdpi/ic_action_cancel_launchersize_light.png (100%) rename plugins/openpgp-api-library/{ => src/main}/res/drawable-xhdpi/ic_action_cancel_launchersize.png (100%) rename plugins/openpgp-api-library/{ => src/main}/res/drawable-xhdpi/ic_action_cancel_launchersize_light.png (100%) rename plugins/openpgp-api-library/{ => src/main}/res/drawable-xxhdpi/ic_action_cancel_launchersize.png (100%) rename plugins/openpgp-api-library/{ => src/main}/res/drawable-xxhdpi/ic_action_cancel_launchersize_light.png (100%) rename plugins/openpgp-api-library/{ => src/main}/res/values-cs/strings.xml (100%) rename plugins/openpgp-api-library/{ => src/main}/res/values-de/strings.xml (100%) rename plugins/openpgp-api-library/{ => src/main}/res/values-es/strings.xml (100%) rename plugins/openpgp-api-library/{ => src/main}/res/values-et/strings.xml (100%) rename plugins/openpgp-api-library/{ => src/main}/res/values-fi/strings.xml (100%) rename plugins/openpgp-api-library/{ => src/main}/res/values-fr/strings.xml (100%) rename plugins/openpgp-api-library/{ => src/main}/res/values-is/strings.xml (100%) rename plugins/openpgp-api-library/{ => src/main}/res/values-it/strings.xml (100%) rename plugins/openpgp-api-library/{ => src/main}/res/values-ja/strings.xml (100%) rename plugins/openpgp-api-library/{ => src/main}/res/values-nl/strings.xml (100%) rename plugins/openpgp-api-library/{ => src/main}/res/values-pl/strings.xml (100%) rename plugins/openpgp-api-library/{ => src/main}/res/values-pt/strings.xml (100%) rename plugins/openpgp-api-library/{ => src/main}/res/values-ru/strings.xml (100%) rename plugins/openpgp-api-library/{ => src/main}/res/values-sl/strings.xml (100%) rename plugins/openpgp-api-library/{ => src/main}/res/values-tr/strings.xml (100%) rename plugins/openpgp-api-library/{ => src/main}/res/values-uk/strings.xml (100%) rename plugins/openpgp-api-library/{ => src/main}/res/values-zh/strings.xml (100%) rename plugins/openpgp-api-library/{ => src/main}/res/values/strings.xml (100%) create mode 100644 plugins/openpgp-api-library/src/main/test/org/openintents/openpgp/OpenPgpUtilsTest.java diff --git a/plugins/openpgp-api-library/build.gradle b/plugins/openpgp-api-library/build.gradle index 0a69ae4cd..0b0647f71 100644 --- a/plugins/openpgp-api-library/build.gradle +++ b/plugins/openpgp-api-library/build.gradle @@ -13,20 +13,7 @@ apply plugin: 'com.android.library' android { compileSdkVersion 21 - buildToolsVersion '21.1.2' - - // 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'] - } - } + buildToolsVersion '21.1.1' // Do not abort build if lint finds errors lintOptions { diff --git a/plugins/openpgp-api-library/project.properties b/plugins/openpgp-api-library/project.properties deleted file mode 100644 index 91d2b0246..000000000 --- a/plugins/openpgp-api-library/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/plugins/openpgp-api-library/AndroidManifest.xml b/plugins/openpgp-api-library/src/main/AndroidManifest.xml similarity index 100% rename from plugins/openpgp-api-library/AndroidManifest.xml rename to plugins/openpgp-api-library/src/main/AndroidManifest.xml diff --git a/plugins/openpgp-api-library/src/org/openintents/openpgp/IOpenPgpService.aidl b/plugins/openpgp-api-library/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl similarity index 100% rename from plugins/openpgp-api-library/src/org/openintents/openpgp/IOpenPgpService.aidl rename to plugins/openpgp-api-library/src/main/aidl/org/openintents/openpgp/IOpenPgpService.aidl diff --git a/plugins/openpgp-api-library/src/org/openintents/openpgp/OpenPgpError.java b/plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/OpenPgpError.java similarity index 100% rename from plugins/openpgp-api-library/src/org/openintents/openpgp/OpenPgpError.java rename to plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/OpenPgpError.java diff --git a/plugins/openpgp-api-library/src/org/openintents/openpgp/OpenPgpMetadata.java b/plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/OpenPgpMetadata.java similarity index 100% rename from plugins/openpgp-api-library/src/org/openintents/openpgp/OpenPgpMetadata.java rename to plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/OpenPgpMetadata.java diff --git a/plugins/openpgp-api-library/src/org/openintents/openpgp/OpenPgpSignatureResult.java b/plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/OpenPgpSignatureResult.java similarity index 100% rename from plugins/openpgp-api-library/src/org/openintents/openpgp/OpenPgpSignatureResult.java rename to plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/OpenPgpSignatureResult.java diff --git a/plugins/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpApi.java b/plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpApi.java similarity index 94% rename from plugins/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpApi.java rename to plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpApi.java index 589b51445..dbfb7971f 100644 --- a/plugins/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpApi.java +++ b/plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpApi.java @@ -27,6 +27,7 @@ import android.util.Log; import org.openintents.openpgp.IOpenPgpService; import org.openintents.openpgp.OpenPgpError; +import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -290,14 +291,24 @@ public class OpenPgpApi { } } + /** + * InputStream and OutputStreams are always closed after operating on them! + * + * @param data + * @param is + * @param os + * @return + */ public Intent executeApi(Intent data, InputStream is, OutputStream os) { + ParcelFileDescriptor input = null; + ParcelFileDescriptor output = null; try { + // always send version from client data.putExtra(EXTRA_API_VERSION, OpenPgpApi.API_VERSION); Intent result; // pipe the input and output - ParcelFileDescriptor input = null; if (is != null) { input = ParcelFileDescriptorUtil.pipeFrom(is, new ParcelFileDescriptorUtil.IThreadListener() { @@ -309,7 +320,6 @@ public class OpenPgpApi { } ); } - ParcelFileDescriptor output = null; if (os != null) { output = ParcelFileDescriptorUtil.pipeTo(os, new ParcelFileDescriptorUtil.IThreadListener() { @@ -324,11 +334,6 @@ public class OpenPgpApi { // blocks until result is ready result = mService.execute(data, input, output); - // close() is required to halt the TransferThread - if (output != null) { - output.close(); - } - // TODO: close input? // set class loader to current context to allow unparcelling // of OpenPgpError and OpenPgpSignatureResult @@ -343,6 +348,22 @@ public class OpenPgpApi { result.putExtra(RESULT_ERROR, new OpenPgpError(OpenPgpError.CLIENT_SIDE_ERROR, e.getMessage())); return result; + } finally { + // close() is required to halt the TransferThread + if (output != null) { + try { + output.close(); + } catch (IOException e) { + Log.e(OpenPgpApi.TAG, "IOException when closing ParcelFileDescriptor!", e); + } + } + if (input != null) { + try { + input.close(); + } catch (IOException e) { + Log.e(OpenPgpApi.TAG, "IOException when closing ParcelFileDescriptor!", e); + } + } } } diff --git a/plugins/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpListPreference.java b/plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpListPreference.java similarity index 95% rename from plugins/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpListPreference.java rename to plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpListPreference.java index 5058b9ae0..31ba97c33 100644 --- a/plugins/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpListPreference.java +++ b/plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpListPreference.java @@ -46,6 +46,13 @@ public class OpenPgpListPreference extends DialogPreference { private static final Intent MARKET_INTENT = new Intent(Intent.ACTION_VIEW, Uri.parse( String.format(MARKET_INTENT_URI_BASE, OPENKEYCHAIN_PACKAGE))); + private static final ArrayList PROVIDER_BLACKLIST = new ArrayList(); + + static { + // Unfortunately, the current released version of APG includes a broken version of the API + PROVIDER_BLACKLIST.add("org.thialfihar.android.apg"); + } + private ArrayList mLegacyList = new ArrayList(); private ArrayList mList = new ArrayList(); @@ -96,7 +103,9 @@ public class OpenPgpListPreference extends DialogPreference { .getPackageManager())); Drawable icon = resolveInfo.serviceInfo.loadIcon(getContext().getPackageManager()); - providerList.add(new OpenPgpProviderEntry(packageName, simpleName, icon)); + if (!PROVIDER_BLACKLIST.contains(packageName)) { + providerList.add(new OpenPgpProviderEntry(packageName, simpleName, icon)); + } } } diff --git a/plugins/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java b/plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpServiceConnection.java similarity index 100% rename from plugins/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpServiceConnection.java rename to plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpServiceConnection.java diff --git a/plugins/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpUtils.java b/plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpUtils.java similarity index 100% rename from plugins/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpUtils.java rename to plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpUtils.java index 67f63f97f..ef0a88ce1 100644 --- a/plugins/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpUtils.java +++ b/plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/util/OpenPgpUtils.java @@ -16,16 +16,16 @@ package org.openintents.openpgp.util; -import android.content.Context; -import android.content.Intent; -import android.content.pm.ResolveInfo; -import android.text.TextUtils; - import java.util.List; import java.util.Locale; import java.util.regex.Matcher; 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 { public static final Pattern PGP_MESSAGE = Pattern.compile( diff --git a/plugins/openpgp-api-library/src/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java b/plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java similarity index 100% rename from plugins/openpgp-api-library/src/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java rename to plugins/openpgp-api-library/src/main/java/org/openintents/openpgp/util/ParcelFileDescriptorUtil.java diff --git a/plugins/openpgp-api-library/res/drawable-hdpi/ic_action_cancel_launchersize.png b/plugins/openpgp-api-library/src/main/res/drawable-hdpi/ic_action_cancel_launchersize.png similarity index 100% rename from plugins/openpgp-api-library/res/drawable-hdpi/ic_action_cancel_launchersize.png rename to plugins/openpgp-api-library/src/main/res/drawable-hdpi/ic_action_cancel_launchersize.png diff --git a/plugins/openpgp-api-library/res/drawable-hdpi/ic_action_cancel_launchersize_light.png b/plugins/openpgp-api-library/src/main/res/drawable-hdpi/ic_action_cancel_launchersize_light.png similarity index 100% rename from plugins/openpgp-api-library/res/drawable-hdpi/ic_action_cancel_launchersize_light.png rename to plugins/openpgp-api-library/src/main/res/drawable-hdpi/ic_action_cancel_launchersize_light.png diff --git a/plugins/openpgp-api-library/res/drawable-mdpi/ic_action_cancel_launchersize.png b/plugins/openpgp-api-library/src/main/res/drawable-mdpi/ic_action_cancel_launchersize.png similarity index 100% rename from plugins/openpgp-api-library/res/drawable-mdpi/ic_action_cancel_launchersize.png rename to plugins/openpgp-api-library/src/main/res/drawable-mdpi/ic_action_cancel_launchersize.png diff --git a/plugins/openpgp-api-library/res/drawable-mdpi/ic_action_cancel_launchersize_light.png b/plugins/openpgp-api-library/src/main/res/drawable-mdpi/ic_action_cancel_launchersize_light.png similarity index 100% rename from plugins/openpgp-api-library/res/drawable-mdpi/ic_action_cancel_launchersize_light.png rename to plugins/openpgp-api-library/src/main/res/drawable-mdpi/ic_action_cancel_launchersize_light.png diff --git a/plugins/openpgp-api-library/res/drawable-xhdpi/ic_action_cancel_launchersize.png b/plugins/openpgp-api-library/src/main/res/drawable-xhdpi/ic_action_cancel_launchersize.png similarity index 100% rename from plugins/openpgp-api-library/res/drawable-xhdpi/ic_action_cancel_launchersize.png rename to plugins/openpgp-api-library/src/main/res/drawable-xhdpi/ic_action_cancel_launchersize.png diff --git a/plugins/openpgp-api-library/res/drawable-xhdpi/ic_action_cancel_launchersize_light.png b/plugins/openpgp-api-library/src/main/res/drawable-xhdpi/ic_action_cancel_launchersize_light.png similarity index 100% rename from plugins/openpgp-api-library/res/drawable-xhdpi/ic_action_cancel_launchersize_light.png rename to plugins/openpgp-api-library/src/main/res/drawable-xhdpi/ic_action_cancel_launchersize_light.png diff --git a/plugins/openpgp-api-library/res/drawable-xxhdpi/ic_action_cancel_launchersize.png b/plugins/openpgp-api-library/src/main/res/drawable-xxhdpi/ic_action_cancel_launchersize.png similarity index 100% rename from plugins/openpgp-api-library/res/drawable-xxhdpi/ic_action_cancel_launchersize.png rename to plugins/openpgp-api-library/src/main/res/drawable-xxhdpi/ic_action_cancel_launchersize.png diff --git a/plugins/openpgp-api-library/res/drawable-xxhdpi/ic_action_cancel_launchersize_light.png b/plugins/openpgp-api-library/src/main/res/drawable-xxhdpi/ic_action_cancel_launchersize_light.png similarity index 100% rename from plugins/openpgp-api-library/res/drawable-xxhdpi/ic_action_cancel_launchersize_light.png rename to plugins/openpgp-api-library/src/main/res/drawable-xxhdpi/ic_action_cancel_launchersize_light.png diff --git a/plugins/openpgp-api-library/res/values-cs/strings.xml b/plugins/openpgp-api-library/src/main/res/values-cs/strings.xml similarity index 100% rename from plugins/openpgp-api-library/res/values-cs/strings.xml rename to plugins/openpgp-api-library/src/main/res/values-cs/strings.xml diff --git a/plugins/openpgp-api-library/res/values-de/strings.xml b/plugins/openpgp-api-library/src/main/res/values-de/strings.xml similarity index 100% rename from plugins/openpgp-api-library/res/values-de/strings.xml rename to plugins/openpgp-api-library/src/main/res/values-de/strings.xml diff --git a/plugins/openpgp-api-library/res/values-es/strings.xml b/plugins/openpgp-api-library/src/main/res/values-es/strings.xml similarity index 100% rename from plugins/openpgp-api-library/res/values-es/strings.xml rename to plugins/openpgp-api-library/src/main/res/values-es/strings.xml diff --git a/plugins/openpgp-api-library/res/values-et/strings.xml b/plugins/openpgp-api-library/src/main/res/values-et/strings.xml similarity index 100% rename from plugins/openpgp-api-library/res/values-et/strings.xml rename to plugins/openpgp-api-library/src/main/res/values-et/strings.xml diff --git a/plugins/openpgp-api-library/res/values-fi/strings.xml b/plugins/openpgp-api-library/src/main/res/values-fi/strings.xml similarity index 100% rename from plugins/openpgp-api-library/res/values-fi/strings.xml rename to plugins/openpgp-api-library/src/main/res/values-fi/strings.xml diff --git a/plugins/openpgp-api-library/res/values-fr/strings.xml b/plugins/openpgp-api-library/src/main/res/values-fr/strings.xml similarity index 100% rename from plugins/openpgp-api-library/res/values-fr/strings.xml rename to plugins/openpgp-api-library/src/main/res/values-fr/strings.xml diff --git a/plugins/openpgp-api-library/res/values-is/strings.xml b/plugins/openpgp-api-library/src/main/res/values-is/strings.xml similarity index 100% rename from plugins/openpgp-api-library/res/values-is/strings.xml rename to plugins/openpgp-api-library/src/main/res/values-is/strings.xml diff --git a/plugins/openpgp-api-library/res/values-it/strings.xml b/plugins/openpgp-api-library/src/main/res/values-it/strings.xml similarity index 100% rename from plugins/openpgp-api-library/res/values-it/strings.xml rename to plugins/openpgp-api-library/src/main/res/values-it/strings.xml diff --git a/plugins/openpgp-api-library/res/values-ja/strings.xml b/plugins/openpgp-api-library/src/main/res/values-ja/strings.xml similarity index 100% rename from plugins/openpgp-api-library/res/values-ja/strings.xml rename to plugins/openpgp-api-library/src/main/res/values-ja/strings.xml diff --git a/plugins/openpgp-api-library/res/values-nl/strings.xml b/plugins/openpgp-api-library/src/main/res/values-nl/strings.xml similarity index 100% rename from plugins/openpgp-api-library/res/values-nl/strings.xml rename to plugins/openpgp-api-library/src/main/res/values-nl/strings.xml diff --git a/plugins/openpgp-api-library/res/values-pl/strings.xml b/plugins/openpgp-api-library/src/main/res/values-pl/strings.xml similarity index 100% rename from plugins/openpgp-api-library/res/values-pl/strings.xml rename to plugins/openpgp-api-library/src/main/res/values-pl/strings.xml diff --git a/plugins/openpgp-api-library/res/values-pt/strings.xml b/plugins/openpgp-api-library/src/main/res/values-pt/strings.xml similarity index 100% rename from plugins/openpgp-api-library/res/values-pt/strings.xml rename to plugins/openpgp-api-library/src/main/res/values-pt/strings.xml diff --git a/plugins/openpgp-api-library/res/values-ru/strings.xml b/plugins/openpgp-api-library/src/main/res/values-ru/strings.xml similarity index 100% rename from plugins/openpgp-api-library/res/values-ru/strings.xml rename to plugins/openpgp-api-library/src/main/res/values-ru/strings.xml diff --git a/plugins/openpgp-api-library/res/values-sl/strings.xml b/plugins/openpgp-api-library/src/main/res/values-sl/strings.xml similarity index 100% rename from plugins/openpgp-api-library/res/values-sl/strings.xml rename to plugins/openpgp-api-library/src/main/res/values-sl/strings.xml diff --git a/plugins/openpgp-api-library/res/values-tr/strings.xml b/plugins/openpgp-api-library/src/main/res/values-tr/strings.xml similarity index 100% rename from plugins/openpgp-api-library/res/values-tr/strings.xml rename to plugins/openpgp-api-library/src/main/res/values-tr/strings.xml diff --git a/plugins/openpgp-api-library/res/values-uk/strings.xml b/plugins/openpgp-api-library/src/main/res/values-uk/strings.xml similarity index 100% rename from plugins/openpgp-api-library/res/values-uk/strings.xml rename to plugins/openpgp-api-library/src/main/res/values-uk/strings.xml diff --git a/plugins/openpgp-api-library/res/values-zh/strings.xml b/plugins/openpgp-api-library/src/main/res/values-zh/strings.xml similarity index 100% rename from plugins/openpgp-api-library/res/values-zh/strings.xml rename to plugins/openpgp-api-library/src/main/res/values-zh/strings.xml diff --git a/plugins/openpgp-api-library/res/values/strings.xml b/plugins/openpgp-api-library/src/main/res/values/strings.xml similarity index 100% rename from plugins/openpgp-api-library/res/values/strings.xml rename to plugins/openpgp-api-library/src/main/res/values/strings.xml diff --git a/plugins/openpgp-api-library/src/main/test/org/openintents/openpgp/OpenPgpUtilsTest.java b/plugins/openpgp-api-library/src/main/test/org/openintents/openpgp/OpenPgpUtilsTest.java new file mode 100644 index 000000000..f115398f2 --- /dev/null +++ b/plugins/openpgp-api-library/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) "); + 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 "); + 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