From cec6c3ab5a884dc49b92055fb684ba66a612e195 Mon Sep 17 00:00:00 2001
From: "M. Dietrich" <mdt@emdete.de>
Date: Fri, 28 Feb 2014 15:18:54 +0100
Subject: prevent null byte[] in case of encoding exc

---
 .../java/org/sufficientlysecure/keychain/demo/IntentActivity.java   | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'OpenPGP-Keychain-API/example-app')

diff --git a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/IntentActivity.java b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/IntentActivity.java
index fdcabaf7c..e8aa2a2e7 100644
--- a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/IntentActivity.java
+++ b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/IntentActivity.java
@@ -112,11 +112,11 @@ public class IntentActivity extends PreferenceActivity {
                     byte[] pubkey = null;
                     try {
                         pubkey = TEST_PUBKEY.getBytes("UTF-8");
+                        intent.putExtra(OpenKeychainIntents.IMPORT_KEY_EXTRA_KEY_BYTES, pubkey);
+                        startActivity(intent);
                     } catch (UnsupportedEncodingException e) {
-                        e.printStackTrace();
+                        Log.e(Constants.TAG, "UnsupportedEncodingException", e);
                     }
-                    intent.putExtra(OpenKeychainIntents.IMPORT_KEY_EXTRA_KEY_BYTES, pubkey);
-                    startActivity(intent);
                 } catch (ActivityNotFoundException e) {
                     Toast.makeText(IntentActivity.this, "Activity not found!", Toast.LENGTH_LONG).show();
                 }
-- 
cgit v1.2.3


From 4a13f70a88d64591eb878ea2a9ff70b062c7cc52 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= <dominik@dominikschuermann.de>
Date: Sun, 2 Mar 2014 01:20:06 +0100
Subject: API changes

---
 .../keychain/demo/OpenPgpProviderActivity.java     | 72 +++++++++++-----------
 1 file changed, 37 insertions(+), 35 deletions(-)

(limited to 'OpenPGP-Keychain-API/example-app')

diff --git a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java
index 2f7f085c2..4d143ade6 100644
--- a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java
+++ b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java
@@ -33,7 +33,6 @@ import android.widget.Toast;
 import org.openintents.openpgp.OpenPgpError;
 import org.openintents.openpgp.OpenPgpSignatureResult;
 import org.openintents.openpgp.util.OpenPgpApi;
-import org.openintents.openpgp.util.OpenPgpConstants;
 import org.openintents.openpgp.util.OpenPgpServiceConnection;
 
 import java.io.ByteArrayInputStream;
@@ -73,25 +72,25 @@ public class OpenPgpProviderActivity extends Activity {
         mSign.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                sign(new Bundle());
+                sign(new Intent());
             }
         });
         mEncrypt.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                encrypt(new Bundle());
+                encrypt(new Intent());
             }
         });
         mSignAndEncrypt.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                signAndEncrypt(new Bundle());
+                signAndEncrypt(new Intent());
             }
         });
         mDecryptAndVerify.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                decryptAndVerify(new Bundle());
+                decryptAndVerify(new Intent());
             }
         });
 
@@ -169,11 +168,11 @@ public class OpenPgpProviderActivity extends Activity {
         }
 
         @Override
-        public void onReturn(Bundle result) {
-            switch (result.getInt(OpenPgpConstants.RESULT_CODE)) {
-                case OpenPgpConstants.RESULT_CODE_SUCCESS: {
+        public void onReturn(Intent result) {
+            switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) {
+                case OpenPgpApi.RESULT_CODE_SUCCESS: {
                     try {
-                        Log.d(OpenPgpConstants.TAG, "result: " + os.toByteArray().length
+                        Log.d(OpenPgpApi.TAG, "result: " + os.toByteArray().length
                                 + " str=" + os.toString("UTF-8"));
 
                         if (returnToCiphertextField) {
@@ -185,15 +184,15 @@ public class OpenPgpProviderActivity extends Activity {
                         Log.e(Constants.TAG, "UnsupportedEncodingException", e);
                     }
 
-                    if (result.containsKey(OpenPgpConstants.RESULT_SIGNATURE)) {
+                    if (result.hasExtra(OpenPgpApi.RESULT_SIGNATURE)) {
                         OpenPgpSignatureResult sigResult
-                                = result.getParcelable(OpenPgpConstants.RESULT_SIGNATURE);
+                                = result.getParcelableExtra(OpenPgpApi.RESULT_SIGNATURE);
                         handleSignature(sigResult);
                     }
                     break;
                 }
-                case OpenPgpConstants.RESULT_CODE_USER_INTERACTION_REQUIRED: {
-                    PendingIntent pi = result.getParcelable(OpenPgpConstants.RESULT_INTENT);
+                case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: {
+                    PendingIntent pi = result.getParcelableExtra(OpenPgpApi.RESULT_INTENT);
                     try {
                         OpenPgpProviderActivity.this.startIntentSenderForResult(pi.getIntentSender(),
                                 requestCode, null, 0, 0, 0);
@@ -202,8 +201,8 @@ public class OpenPgpProviderActivity extends Activity {
                     }
                     break;
                 }
-                case OpenPgpConstants.RESULT_CODE_ERROR: {
-                    OpenPgpError error = result.getParcelable(OpenPgpConstants.RESULT_ERRORS);
+                case OpenPgpApi.RESULT_CODE_ERROR: {
+                    OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERRORS);
                     handleError(error);
                     break;
                 }
@@ -211,46 +210,50 @@ public class OpenPgpProviderActivity extends Activity {
         }
     }
 
-    public void sign(Bundle params) {
-        params.putBoolean(OpenPgpConstants.PARAMS_REQUEST_ASCII_ARMOR, true);
+    public void sign(Intent data) {
+        data.setAction(OpenPgpApi.ACTION_SIGN);
+        data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
 
         InputStream is = getInputstream(false);
         final ByteArrayOutputStream os = new ByteArrayOutputStream();
 
         OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
-        api.sign(params, is, os, new MyCallback(true, os, REQUEST_CODE_SIGN));
+        api.executeApiAsync(data, is, os, new MyCallback(true, os, REQUEST_CODE_SIGN));
     }
 
-    public void encrypt(Bundle params) {
-        params.putStringArray(OpenPgpConstants.PARAMS_USER_IDS, mEncryptUserIds.getText().toString().split(","));
-        params.putBoolean(OpenPgpConstants.PARAMS_REQUEST_ASCII_ARMOR, true);
+    public void encrypt(Intent data) {
+        data.setAction(OpenPgpApi.ACTION_ENCRYPT);
+        data.putExtra(OpenPgpApi.EXTRA_USER_IDS, mEncryptUserIds.getText().toString().split(","));
+        data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
 
         InputStream is = getInputstream(false);
         final ByteArrayOutputStream os = new ByteArrayOutputStream();
 
         OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
-        api.encrypt(params, is, os, new MyCallback(true, os, REQUEST_CODE_ENCRYPT));
+        api.executeApiAsync(data, is, os, new MyCallback(true, os, REQUEST_CODE_ENCRYPT));
     }
 
-    public void signAndEncrypt(Bundle params) {
-        params.putStringArray(OpenPgpConstants.PARAMS_USER_IDS, mEncryptUserIds.getText().toString().split(","));
-        params.putBoolean(OpenPgpConstants.PARAMS_REQUEST_ASCII_ARMOR, true);
+    public void signAndEncrypt(Intent data) {
+        data.setAction(OpenPgpApi.ACTION_SIGN_AND_ENCTYPT);
+        data.putExtra(OpenPgpApi.EXTRA_USER_IDS, mEncryptUserIds.getText().toString().split(","));
+        data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
 
         InputStream is = getInputstream(false);
         final ByteArrayOutputStream os = new ByteArrayOutputStream();
 
         OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
-        api.signAndEncrypt(params, is, os, new MyCallback(true, os, REQUEST_CODE_SIGN_AND_ENCRYPT));
+        api.executeApiAsync(data, is, os, new MyCallback(true, os, REQUEST_CODE_SIGN_AND_ENCRYPT));
     }
 
-    public void decryptAndVerify(Bundle params) {
-        params.putBoolean(OpenPgpConstants.PARAMS_REQUEST_ASCII_ARMOR, true);
+    public void decryptAndVerify(Intent data) {
+        data.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
+        data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
 
         InputStream is = getInputstream(true);
         final ByteArrayOutputStream os = new ByteArrayOutputStream();
 
         OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService());
-        api.decryptAndVerify(params, is, os, new MyCallback(false, os, REQUEST_CODE_DECRYPT_AND_VERIFY));
+        api.executeApiAsync(data, is, os, new MyCallback(false, os, REQUEST_CODE_DECRYPT_AND_VERIFY));
     }
 
     @Override
@@ -261,29 +264,28 @@ public class OpenPgpProviderActivity extends Activity {
         // try again after user interaction
         if (resultCode == RESULT_OK) {
             /*
-             * The params originally given to the pgp method are are again
+             * The data originally given to the pgp method are are again
              * returned here to be used when calling again after user interaction.
              *
              * They also contain results from the user interaction which happened,
              * for example selected key ids.
              */
-            Bundle params = data.getBundleExtra(OpenPgpConstants.PI_RESULT_PARAMS);
 
             switch (requestCode) {
                 case REQUEST_CODE_SIGN: {
-                    sign(params);
+                    sign(data);
                     break;
                 }
                 case REQUEST_CODE_ENCRYPT: {
-                    encrypt(params);
+                    encrypt(data);
                     break;
                 }
                 case REQUEST_CODE_SIGN_AND_ENCRYPT: {
-                    signAndEncrypt(params);
+                    signAndEncrypt(data);
                     break;
                 }
                 case REQUEST_CODE_DECRYPT_AND_VERIFY: {
-                    decryptAndVerify(params);
+                    decryptAndVerify(data);
                     break;
                 }
             }
-- 
cgit v1.2.3


From 7f384e73467c0f09e44d1f37cbc83df68799b75b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= <dominik@dominikschuermann.de>
Date: Sun, 2 Mar 2014 18:21:32 +0100
Subject: version code 3 API lib

---
 OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'OpenPGP-Keychain-API/example-app')

diff --git a/OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml b/OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml
index 7803ccd27..74bc88708 100644
--- a/OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml
+++ b/OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="org.sufficientlysecure.keychain.demo"
-    android:versionCode="2"
-    android:versionName="1.1">
+    android:versionCode="3"
+    android:versionName="2">
 
     <uses-sdk
         android:minSdkVersion="9"
-- 
cgit v1.2.3