aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain-API/example-app
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2014-02-14 02:33:21 +0100
committerDominik Schürmann <dominik@dominikschuermann.de>2014-02-14 02:33:21 +0100
commit7939aaaa440f84a0df5524f8a1a1c04dd569eedd (patch)
tree5b1db4213863508a48e369271e1a18a283dab206 /OpenPGP-Keychain-API/example-app
parent7b819e65de71a17827a3264a1a8663ca0d30b48c (diff)
downloadopen-keychain-7939aaaa440f84a0df5524f8a1a1c04dd569eedd.tar.gz
open-keychain-7939aaaa440f84a0df5524f8a1a1c04dd569eedd.tar.bz2
open-keychain-7939aaaa440f84a0df5524f8a1a1c04dd569eedd.zip
Introducing new ParcelFileDescriptor pipes
Diffstat (limited to 'OpenPGP-Keychain-API/example-app')
-rw-r--r--OpenPGP-Keychain-API/example-app/build.gradle3
-rw-r--r--OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml2
-rw-r--r--OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java332
-rw-r--r--OpenPGP-Keychain-API/example-app/src/main/res/xml/base_preference.xml2
4 files changed, 178 insertions, 161 deletions
diff --git a/OpenPGP-Keychain-API/example-app/build.gradle b/OpenPGP-Keychain-API/example-app/build.gradle
index 99a09f094..373f83690 100644
--- a/OpenPGP-Keychain-API/example-app/build.gradle
+++ b/OpenPGP-Keychain-API/example-app/build.gradle
@@ -1,3 +1,4 @@
+// please leave this here, so this library builds on its own
buildscript {
repositories {
mavenCentral()
@@ -20,7 +21,7 @@ android {
buildToolsVersion "19.0.1"
defaultConfig {
- minSdkVersion 8
+ minSdkVersion 9
targetSdkVersion 19
}
diff --git a/OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml b/OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml
index 8b8c43776..39a990f72 100644
--- a/OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml
+++ b/OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml
@@ -5,7 +5,7 @@
android:versionName="1.1" >
<uses-sdk
- android:minSdkVersion="8"
+ android:minSdkVersion="9"
android:targetSdkVersion="19" />
<application
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 4a96de5a1..81f9eee68 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
@@ -16,17 +16,6 @@
package org.sufficientlysecure.keychain.demo;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.openintents.openpgp.IOpenPgpKeyIdsCallback;
-import org.openintents.openpgp.OpenPgpData;
-import org.openintents.openpgp.OpenPgpError;
-import org.openintents.openpgp.OpenPgpServiceConnection;
-import org.openintents.openpgp.OpenPgpSignatureResult;
-import org.openintents.openpgp.IOpenPgpCallback;
-import org.openintents.openpgp.IOpenPgpService;
-
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
@@ -34,7 +23,6 @@ import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
-import android.os.RemoteException;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
@@ -44,6 +32,19 @@ import android.widget.ListAdapter;
import android.widget.TextView;
import android.widget.Toast;
+import org.openintents.openpgp.IOpenPgpService;
+import org.openintents.openpgp.OpenPgpError;
+import org.openintents.openpgp.util.OpenPgpApi;
+import org.openintents.openpgp.util.OpenPgpConstants;
+import org.openintents.openpgp.util.OpenPgpServiceConnection;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+
public class OpenPgpProviderActivity extends Activity {
Activity mActivity;
@@ -67,123 +68,123 @@ public class OpenPgpProviderActivity extends Activity {
selectCryptoProvider();
}
- /**
- * Callback from remote openpgp service
- */
- final IOpenPgpKeyIdsCallback.Stub getKeysEncryptCallback = new IOpenPgpKeyIdsCallback.Stub() {
-
- @Override
- public void onSuccess(final long[] keyIds) throws RemoteException {
- Log.d(Constants.TAG, "getKeysEncryptCallback keyId " + keyIds[0]);
- mActivity.runOnUiThread(new Runnable() {
-
- @Override
- public void run() {
- // encrypt after getting key ids
- String inputStr = mMessage.getText().toString();
- OpenPgpData input = new OpenPgpData(inputStr);
-
- Log.d(Constants.TAG, "getKeysEncryptCallback inputStr " + inputStr);
-
- try {
- mCryptoServiceConnection.getService().encrypt(input,
- new OpenPgpData(OpenPgpData.TYPE_STRING), keyIds, encryptCallback);
- } catch (RemoteException e) {
- Log.e(Constants.TAG, "CryptoProviderDemo", e);
- }
- }
- });
- }
-
- @Override
- public void onError(OpenPgpError error) throws RemoteException {
- handleError(error);
- }
-
- };
-
- final IOpenPgpKeyIdsCallback.Stub getKeysSignAndEncryptCallback = new IOpenPgpKeyIdsCallback.Stub() {
-
- @Override
- public void onSuccess(final long[] keyIds) throws RemoteException {
- Log.d(Constants.TAG, "getKeysSignAndEncryptCallback keyId " + keyIds[0]);
-
- mActivity.runOnUiThread(new Runnable() {
-
- @Override
- public void run() {
- // encrypt after getting key ids
- String inputStr = mMessage.getText().toString();
- OpenPgpData input = new OpenPgpData(inputStr);
-
- try {
- mCryptoServiceConnection.getService().signAndEncrypt(input,
- new OpenPgpData(OpenPgpData.TYPE_STRING), keyIds, encryptCallback);
- } catch (RemoteException e) {
- Log.e(Constants.TAG, "CryptoProviderDemo", e);
- }
- }
- });
- }
-
- @Override
- public void onError(OpenPgpError error) throws RemoteException {
- handleError(error);
- }
-
- };
-
- final IOpenPgpCallback.Stub encryptCallback = new IOpenPgpCallback.Stub() {
-
- @Override
- public void onSuccess(final OpenPgpData output, OpenPgpSignatureResult signatureResult)
- throws RemoteException {
- Log.d(Constants.TAG, "encryptCallback");
-
- runOnUiThread(new Runnable() {
-
- @Override
- public void run() {
- mCiphertext.setText(output.getString());
- }
- });
- }
-
- @Override
- public void onError(OpenPgpError error) throws RemoteException {
- handleError(error);
- }
-
- };
-
- final IOpenPgpCallback.Stub decryptAndVerifyCallback = new IOpenPgpCallback.Stub() {
-
- @Override
- public void onSuccess(final OpenPgpData output, final OpenPgpSignatureResult signatureResult)
- throws RemoteException {
- Log.d(Constants.TAG, "decryptAndVerifyCallback");
-
- runOnUiThread(new Runnable() {
-
- @Override
- public void run() {
- mMessage.setText(output.getString());
- if (signatureResult != null) {
- Toast.makeText(OpenPgpProviderActivity.this,
- "signature result:\n" + signatureResult.toString(),
- Toast.LENGTH_LONG).show();
- }
- }
- });
-
- }
-
- @Override
- public void onError(OpenPgpError error) throws RemoteException {
- handleError(error);
- }
-
- };
+// /**
+// * Callback from remote openpgp service
+// */
+// final IOpenPgpKeyIdsCallback.Stub getKeysEncryptCallback = new IOpenPgpKeyIdsCallback.Stub() {
+//
+// @Override
+// public void onSuccess(final long[] keyIds) throws RemoteException {
+// Log.d(Constants.TAG, "getKeysEncryptCallback keyId " + keyIds[0]);
+// mActivity.runOnUiThread(new Runnable() {
+//
+// @Override
+// public void run() {
+// // encrypt after getting key ids
+// String inputStr = mMessage.getText().toString();
+// OpenPgpData input = new OpenPgpData(inputStr);
+//
+// Log.d(Constants.TAG, "getKeysEncryptCallback inputStr " + inputStr);
+//
+// try {
+// mCryptoServiceConnection.getService().encrypt(input,
+// new OpenPgpData(OpenPgpData.TYPE_STRING), keyIds, encryptCallback);
+// } catch (RemoteException e) {
+// Log.e(Constants.TAG, "CryptoProviderDemo", e);
+// }
+// }
+// });
+// }
+//
+// @Override
+// public void onError(OpenPgpError error) throws RemoteException {
+// handleError(error);
+// }
+//
+// };
+//
+// final IOpenPgpKeyIdsCallback.Stub getKeysSignAndEncryptCallback = new IOpenPgpKeyIdsCallback.Stub() {
+//
+// @Override
+// public void onSuccess(final long[] keyIds) throws RemoteException {
+// Log.d(Constants.TAG, "getKeysSignAndEncryptCallback keyId " + keyIds[0]);
+//
+// mActivity.runOnUiThread(new Runnable() {
+//
+// @Override
+// public void run() {
+// // encrypt after getting key ids
+// String inputStr = mMessage.getText().toString();
+// OpenPgpData input = new OpenPgpData(inputStr);
+//
+// try {
+// mCryptoServiceConnection.getService().signAndEncrypt(input,
+// new OpenPgpData(OpenPgpData.TYPE_STRING), keyIds, encryptCallback);
+// } catch (RemoteException e) {
+// Log.e(Constants.TAG, "CryptoProviderDemo", e);
+// }
+// }
+// });
+// }
+//
+// @Override
+// public void onError(OpenPgpError error) throws RemoteException {
+// handleError(error);
+// }
+//
+// };
+//
+// final IOpenPgpCallback.Stub encryptCallback = new IOpenPgpCallback.Stub() {
+//
+// @Override
+// public void onSuccess(final OpenPgpData output, OpenPgpSignatureResult signatureResult)
+// throws RemoteException {
+// Log.d(Constants.TAG, "encryptCallback");
+//
+// runOnUiThread(new Runnable() {
+//
+// @Override
+// public void run() {
+// mCiphertext.setText(output.getString());
+// }
+// });
+// }
+//
+// @Override
+// public void onError(OpenPgpError error) throws RemoteException {
+// handleError(error);
+// }
+//
+// };
+//
+// final IOpenPgpCallback.Stub decryptAndVerifyCallback = new IOpenPgpCallback.Stub() {
+//
+// @Override
+// public void onSuccess(final OpenPgpData output, final OpenPgpSignatureResult signatureResult)
+// throws RemoteException {
+// Log.d(Constants.TAG, "decryptAndVerifyCallback");
+//
+// runOnUiThread(new Runnable() {
+//
+// @Override
+// public void run() {
+// mMessage.setText(output.getString());
+// if (signatureResult != null) {
+// Toast.makeText(OpenPgpProviderActivity.this,
+// "signature result:\n" + signatureResult.toString(),
+// Toast.LENGTH_LONG).show();
+// }
+// }
+// });
+//
+// }
+//
+// @Override
+// public void onError(OpenPgpError error) throws RemoteException {
+// handleError(error);
+// }
+//
+// };
private void handleError(final OpenPgpError error) {
mActivity.runOnUiThread(new Runnable() {
@@ -200,46 +201,61 @@ public class OpenPgpProviderActivity extends Activity {
}
public void encryptOnClick(View view) {
- try {
- mCryptoServiceConnection.getService().getKeyIds(
- mEncryptUserIds.getText().toString().split(","), true, getKeysEncryptCallback);
- } catch (RemoteException e) {
- Log.e(Constants.TAG, "CryptoProviderDemo", e);
- }
+// try {
+// mCryptoServiceConnection.getService().getKeyIds(
+// mEncryptUserIds.getText().toString().split(","), true, getKeysEncryptCallback);
+// } catch (RemoteException e) {
+// Log.e(Constants.TAG, "CryptoProviderDemo", e);
+// }
}
public void signOnClick(View view) {
- String inputStr = mMessage.getText().toString();
- OpenPgpData input = new OpenPgpData(inputStr);
-
try {
- mCryptoServiceConnection.getService().sign(input,
- new OpenPgpData(OpenPgpData.TYPE_STRING), encryptCallback);
- } catch (RemoteException e) {
- Log.e(Constants.TAG, "CryptoProviderDemo", e);
+ String inputStr = mMessage.getText().toString();
+ InputStream is = new ByteArrayInputStream(inputStr.getBytes("UTF-8"));
+
+ final ByteArrayOutputStream os = new ByteArrayOutputStream();
+
+ OpenPgpApi api = new OpenPgpApi(mCryptoServiceConnection.getService());
+ api.sign(is, os);
+
+ Log.d(OpenPgpConstants.TAG, "Test #1 read result: " + os.toByteArray().length
+ + " str=" + os.toString("UTF-8"));
+
+ mCiphertext.setText(os.toString("UTF-8"));
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
}
+// OpenPgpData input = new OpenPgpData(inputStr);
+//
+// try {
+// mCryptoServiceConnection.getService().sign(input,
+// new OpenPgpData(OpenPgpData.TYPE_STRING), encryptCallback);
+// } catch (RemoteException e) {
+// Log.e(Constants.TAG, "CryptoProviderDemo", e);
+// }
}
public void signAndEncryptOnClick(View view) {
- try {
- mCryptoServiceConnection.getService().getKeyIds(
- mEncryptUserIds.getText().toString().split(","), true,
- getKeysSignAndEncryptCallback);
- } catch (RemoteException e) {
- Log.e(Constants.TAG, "CryptoProviderDemo", e);
- }
+// try {
+// mCryptoServiceConnection.getService().getKeyIds(
+// mEncryptUserIds.getText().toString().split(","), true,
+// getKeysSignAndEncryptCallback);
+// } catch (RemoteException e) {
+// Log.e(Constants.TAG, "CryptoProviderDemo", e);
+// }
}
public void decryptAndVerifyOnClick(View view) {
- String inputStr = mCiphertext.getText().toString();
- OpenPgpData input = new OpenPgpData(inputStr);
-
- try {
- mCryptoServiceConnection.getService().decryptAndVerify(input,
- new OpenPgpData(OpenPgpData.TYPE_STRING), decryptAndVerifyCallback);
- } catch (RemoteException e) {
- Log.e(Constants.TAG, "CryptoProviderDemo", e);
- }
+// String inputStr = mCiphertext.getText().toString();
+// OpenPgpData input = new OpenPgpData(inputStr);
+//
+// try {
+// mCryptoServiceConnection.getService().decryptAndVerify(input,
+// new OpenPgpData(OpenPgpData.TYPE_STRING), decryptAndVerifyCallback);
+// } catch (RemoteException e) {
+// Log.e(Constants.TAG, "CryptoProviderDemo", e);
+// }
}
@Override
diff --git a/OpenPGP-Keychain-API/example-app/src/main/res/xml/base_preference.xml b/OpenPGP-Keychain-API/example-app/src/main/res/xml/base_preference.xml
index 5febfad44..86b461742 100644
--- a/OpenPGP-Keychain-API/example-app/src/main/res/xml/base_preference.xml
+++ b/OpenPGP-Keychain-API/example-app/src/main/res/xml/base_preference.xml
@@ -12,7 +12,7 @@
<!-- android:title="AIDL Demo (ACCESS_KEYS permission)" /> -->
<!-- </PreferenceCategory> -->
<PreferenceCategory android:title="OpenPGP Provider" >
- <org.openintents.openpgp.OpenPgpListPreference
+ <org.openintents.openpgp.util.OpenPgpListPreference
android:key="openpgp_provider_list"
android:title="Select OpenPGP Provider!" />
<Preference