diff --git a/OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml b/OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml
index 3658283ba..42465cef8 100644
--- a/OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml
+++ b/OpenPGP-Keychain-API/example-app/src/main/AndroidManifest.xml
@@ -25,6 +25,9 @@
android:name=".OpenPgpProviderActivity"
android:label="OpenPGP Provider"
android:windowSoftInputMode="stateHidden" />
+
\ No newline at end of file
diff --git a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/BaseActivity.java b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/BaseActivity.java
index d37689afc..dd642d879 100644
--- a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/BaseActivity.java
+++ b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/BaseActivity.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Dominik Schürmann
+ * Copyright (C) 2012-2014 Dominik Schürmann
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,8 +44,7 @@ public class BaseActivity extends PreferenceActivity {
mIntentDemo.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
- // startActivity(new Intent(mActivity, IntentDemoActivity.class));
- Toast.makeText(BaseActivity.this, "Not implemented!", Toast.LENGTH_LONG).show();
+ startActivity(new Intent(BaseActivity.this, IntentActivity.class));
return false;
}
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
new file mode 100644
index 000000000..8fe0d2d9c
--- /dev/null
+++ b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/IntentActivity.java
@@ -0,0 +1,209 @@
+/*
+ * Copyright (C) 2014 Dominik Schürmann
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.sufficientlysecure.keychain.demo;
+
+import android.content.ActivityNotFoundException;
+import android.content.Intent;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceClickListener;
+import android.preference.PreferenceActivity;
+import android.provider.MediaStore;
+import android.util.Log;
+import android.widget.Toast;
+
+import org.sufficientlysecure.keychain.api.KeychainIntents;
+
+public class IntentActivity extends PreferenceActivity {
+
+ private static final int SELECT_PHOTO = 100;
+
+ /**
+ * Called when the activity is first created.
+ */
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // load preferences from xml
+ addPreferencesFromResource(R.xml.intent_preference);
+
+ // find preferences
+ Preference encrypt = (Preference) findPreference("ENCRYPT");
+ Preference encryptUri = (Preference) findPreference("ENCRYPT_URI");
+ Preference decrypt = (Preference) findPreference("DECRYPT");
+ Preference import_key = (Preference) findPreference("IMPORT_KEY");
+ Preference import_key_from_keyserver = (Preference) findPreference("IMPORT_KEY_FROM_KEYSERVER");
+ Preference import_key_from_qr_code = (Preference) findPreference("IMPORT_KEY_FROM_QR_CODE");
+ Preference openpgp4fpr = (Preference) findPreference("openpgp4fpr");
+
+ encrypt.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ try {
+ Intent intent = new Intent(KeychainIntents.ENCRYPT);
+ intent.putExtra(KeychainIntents.ENCRYPT_EXTRA_TEXT, "Hello world!");
+ startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ Toast.makeText(IntentActivity.this, "Activity not found!", Toast.LENGTH_LONG).show();
+ }
+
+ return false;
+ }
+ });
+
+ encryptUri.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
+ photoPickerIntent.setType("image/*");
+ startActivityForResult(photoPickerIntent, SELECT_PHOTO);
+
+ return false;
+ }
+ });
+
+ decrypt.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ String text = "-----BEGIN PGP SIGNED MESSAGE-----\n" +
+ "Hash: SHA1\n" +
+ "\n" +
+ "Hello world!\n" +
+ "-----BEGIN PGP SIGNATURE-----\n" +
+ "Version: GnuPG v1.4.12 (GNU/Linux)\n" +
+ "Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/\n" +
+ "\n" +
+ "iQEcBAEBAgAGBQJS/7vTAAoJEHGMBwEAASKCkGYH/2jBLzamVyqd61jrjMQM0jUv\n" +
+ "MkDcPUxPrYH3wZOO0HcgdBQEo66GZEC2ATmo8izJUMk35Q5jas99k0ac9pXhPUPE\n" +
+ "5qDXdQS10S07R6J0SeDYFWDSyrSiDTCZpFkVu3JGP/3S0SkMYXPzfYlh8Ciuxu7i\n" +
+ "FR5dmIiz3VQaBgTBSCBFEomNFM5ypynBJqKIzIty8v0NbV72Rtg6Xg76YqWQ/6MC\n" +
+ "/MlT3y3++HhfpEmLf5WLEXljbuZ4SfCybgYXG9gBzhJu3+gmBoSicdYTZDHSxBBR\n" +
+ "BwI+ueLbhgRz+gU+WJFE7xNw35xKtBp1C4PR0iKI8rZCSHLjsRVzor7iwDaR51M=\n" +
+ "=3Ydc\n" +
+ "-----END PGP SIGNATURE-----";
+ try {
+ Intent intent = new Intent(KeychainIntents.DECRYPT);
+ intent.putExtra(KeychainIntents.DECRYPT_EXTRA_TEXT, text);
+ startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ Toast.makeText(IntentActivity.this, "Activity not found!", Toast.LENGTH_LONG).show();
+ }
+
+ return false;
+ }
+ });
+
+ import_key.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ try {
+ Intent intent = new Intent(KeychainIntents.IMPORT_KEY);
+// intent.putExtra(KeychainIntents.IMPORT_KEY_EXTRA_KEY_BYTES, TODO);
+ startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ Toast.makeText(IntentActivity.this, "Activity not found!", Toast.LENGTH_LONG).show();
+ }
+
+ return false;
+ }
+ });
+
+ import_key_from_keyserver.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ try {
+ Intent intent = new Intent(KeychainIntents.IMPORT_KEY_FROM_KEYSERVER);
+ intent.putExtra(KeychainIntents.IMPORT_KEY_FROM_KEYSERVER_QUERY, "Richard Stallman");
+ startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ Toast.makeText(IntentActivity.this, "Activity not found!", Toast.LENGTH_LONG).show();
+ }
+
+ return false;
+ }
+ });
+
+ import_key_from_qr_code.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ try {
+ Intent intent = new Intent(KeychainIntents.IMPORT_KEY_FROM_QR_CODE);
+ startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ Toast.makeText(IntentActivity.this, "Activity not found!", Toast.LENGTH_LONG).show();
+ }
+
+ return false;
+ }
+ });
+
+ openpgp4fpr.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ try {
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setData(Uri.parse("openpgp4fpr:73EE2314F65FA92EC2390D3A718C070100012282"));
+ startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ Toast.makeText(IntentActivity.this, "Activity not found!", Toast.LENGTH_LONG).show();
+ }
+
+ return false;
+ }
+ });
+
+
+ }
+
+ protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
+ super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
+
+ switch (requestCode) {
+ case SELECT_PHOTO:
+ if (resultCode == RESULT_OK) {
+ Uri selectedImage = imageReturnedIntent.getData();
+
+ String[] filePathColumn = {MediaStore.Images.Media.DATA};
+
+ Cursor cursor = getContentResolver().query(
+ selectedImage, filePathColumn, null, null, null);
+ cursor.moveToFirst();
+
+ int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
+ String filePath = cursor.getString(columnIndex);
+ cursor.close();
+
+ // TODO: after fixing DECRYPT, we could use Uri selectedImage directly
+ Log.d(Constants.TAG, "filePath: " + filePath);
+
+ try {
+ Intent intent = new Intent(KeychainIntents.ENCRYPT);
+ Uri dataUri = Uri.parse("file://" + filePath);
+ Log.d(Constants.TAG, "Uri: " + dataUri);
+ intent.setData(dataUri);
+ startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ Toast.makeText(IntentActivity.this, "Activity not found!", Toast.LENGTH_LONG).show();
+ }
+ }
+ }
+ }
+
+}
diff --git a/OpenPGP-Keychain-API/example-app/src/main/res/xml/intent_preference.xml b/OpenPGP-Keychain-API/example-app/src/main/res/xml/intent_preference.xml
new file mode 100644
index 000000000..ffbf1c475
--- /dev/null
+++ b/OpenPGP-Keychain-API/example-app/src/main/res/xml/intent_preference.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpConstants.java b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpConstants.java
index 263b42aaa..9a2d3c054 100644
--- a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpConstants.java
+++ b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/openintents/openpgp/util/OpenPgpConstants.java
@@ -23,7 +23,6 @@ public class OpenPgpConstants {
public static final int API_VERSION = 1;
public static final String SERVICE_INTENT = "org.openintents.openpgp.IOpenPgpService";
-
/* Bundle params */
public static final String PARAMS_API_VERSION = "api_version";
// request ASCII Armor for output
diff --git a/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/sufficientlysecure/keychain/api/KeychainIntents.java b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/sufficientlysecure/keychain/api/KeychainIntents.java
new file mode 100644
index 000000000..12e32933b
--- /dev/null
+++ b/OpenPGP-Keychain-API/libraries/keychain-api-library/src/org/sufficientlysecure/keychain/api/KeychainIntents.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2014 Dominik Schürmann
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.sufficientlysecure.keychain.api;
+
+public class KeychainIntents {
+
+ public static final String ENCRYPT = "org.sufficientlysecure.keychain.action.ENCRYPT";
+ public static final String ENCRYPT_EXTRA_TEXT = "text";
+ public static final String ENCRYPT_ASCII_ARMOR = "ascii_armor";
+
+ public static final String DECRYPT = "org.sufficientlysecure.keychain.action.DECRYPT";
+ public static final String DECRYPT_EXTRA_TEXT = "text";
+
+ public static final String IMPORT_KEY = "org.sufficientlysecure.keychain.action.IMPORT_KEY";
+ public static final String IMPORT_KEY_EXTRA_KEY_BYTES = "key_bytes";
+
+ public static final String IMPORT_KEY_FROM_KEYSERVER = "org.sufficientlysecure.keychain.action.IMPORT_KEY_FROM_KEYSERVER";
+ public static final String IMPORT_KEY_FROM_KEYSERVER_QUERY = "query";
+ public static final String IMPORT_KEY_FROM_KEYSERVER_FINGERPRINT = "fingerprint";
+
+ public static final String IMPORT_KEY_FROM_QR_CODE = "org.sufficientlysecure.keychain.action.IMPORT_KEY_FROM_QR_CODE";
+
+}
diff --git a/OpenPGP-Keychain/src/main/AndroidManifest.xml b/OpenPGP-Keychain/src/main/AndroidManifest.xml
index 3b9cc1a8d..0a9c9e638 100644
--- a/OpenPGP-Keychain/src/main/AndroidManifest.xml
+++ b/OpenPGP-Keychain/src/main/AndroidManifest.xml
@@ -153,12 +153,19 @@
android:windowSoftInputMode="stateHidden">
+
+
+
+
+
-
+
+
+
@@ -176,12 +183,19 @@
android:windowSoftInputMode="stateHidden">
+
+
+
+
+
-
+
+
+
@@ -293,7 +307,7 @@
-
+
@@ -392,17 +406,17 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
+
+
+
diff --git a/libraries/keychain-api-library/src/org/sufficientlysecure/keychain/api/KeychainIntents.java b/libraries/keychain-api-library/src/org/sufficientlysecure/keychain/api/KeychainIntents.java
new file mode 100644
index 000000000..12e32933b
--- /dev/null
+++ b/libraries/keychain-api-library/src/org/sufficientlysecure/keychain/api/KeychainIntents.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2014 Dominik Schürmann
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.sufficientlysecure.keychain.api;
+
+public class KeychainIntents {
+
+ public static final String ENCRYPT = "org.sufficientlysecure.keychain.action.ENCRYPT";
+ public static final String ENCRYPT_EXTRA_TEXT = "text";
+ public static final String ENCRYPT_ASCII_ARMOR = "ascii_armor";
+
+ public static final String DECRYPT = "org.sufficientlysecure.keychain.action.DECRYPT";
+ public static final String DECRYPT_EXTRA_TEXT = "text";
+
+ public static final String IMPORT_KEY = "org.sufficientlysecure.keychain.action.IMPORT_KEY";
+ public static final String IMPORT_KEY_EXTRA_KEY_BYTES = "key_bytes";
+
+ public static final String IMPORT_KEY_FROM_KEYSERVER = "org.sufficientlysecure.keychain.action.IMPORT_KEY_FROM_KEYSERVER";
+ public static final String IMPORT_KEY_FROM_KEYSERVER_QUERY = "query";
+ public static final String IMPORT_KEY_FROM_KEYSERVER_FINGERPRINT = "fingerprint";
+
+ public static final String IMPORT_KEY_FROM_QR_CODE = "org.sufficientlysecure.keychain.action.IMPORT_KEY_FROM_QR_CODE";
+
+}