aboutsummaryrefslogtreecommitdiffstats
path: root/org_apg_integration_demo
diff options
context:
space:
mode:
Diffstat (limited to 'org_apg_integration_demo')
-rw-r--r--org_apg_integration_demo/.gitignore23
-rw-r--r--org_apg_integration_demo/AndroidManifest.xml31
-rw-r--r--org_apg_integration_demo/build.xml83
-rw-r--r--org_apg_integration_demo/libs/org_apg_integration_lib.jarbin0 -> 8258 bytes
-rw-r--r--org_apg_integration_demo/proguard-project.txt20
-rw-r--r--org_apg_integration_demo/project.properties11
-rw-r--r--org_apg_integration_demo/res/drawable-hdpi/icon.pngbin0 -> 3869 bytes
-rw-r--r--org_apg_integration_demo/res/drawable-ldpi/icon.pngbin0 -> 1765 bytes
-rw-r--r--org_apg_integration_demo/res/drawable-mdpi/icon.pngbin0 -> 2488 bytes
-rw-r--r--org_apg_integration_demo/res/drawable-xhdpi/icon.pngbin0 -> 5832 bytes
-rw-r--r--org_apg_integration_demo/res/layout/intent_demo.xml65
-rw-r--r--org_apg_integration_demo/res/xml/base_preference.xml15
-rw-r--r--org_apg_integration_demo/src/org/apg/api_demo/BaseActivity.java71
-rw-r--r--org_apg_integration_demo/src/org/apg/api_demo/IntentDemoActivity.java95
14 files changed, 414 insertions, 0 deletions
diff --git a/org_apg_integration_demo/.gitignore b/org_apg_integration_demo/.gitignore
new file mode 100644
index 000000000..2e423e1a3
--- /dev/null
+++ b/org_apg_integration_demo/.gitignore
@@ -0,0 +1,23 @@
+#Android generated
+bin
+gen
+obj
+libs/armeabi
+lint.xml
+local.properties
+
+#Eclipse
+.project
+.classpath
+.settings
+
+#IntelliJ IDEA
+.idea
+*.iml
+
+#Maven
+target
+release.properties
+
+#Mac
+.DS_Store \ No newline at end of file
diff --git a/org_apg_integration_demo/AndroidManifest.xml b/org_apg_integration_demo/AndroidManifest.xml
new file mode 100644
index 000000000..a8aa9394b
--- /dev/null
+++ b/org_apg_integration_demo/AndroidManifest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.apg.api_demo"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <!-- permission to access provider and service, intents are public! -->
+ <uses-permission android:name="org.apg.permission.READ_KEY_DETAILS" />
+
+ <uses-sdk
+ android:minSdkVersion="7"
+ android:targetSdkVersion="14" />
+
+ <application
+ android:icon="@drawable/icon"
+ android:label="APG API Demo" >
+ <activity
+ android:name=".BaseActivity"
+ android:label="APG API Demo" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <activity
+ android:name=".IntentDemoActivity"
+ android:label="Intent Demo 1" />
+ </application>
+
+</manifest> \ No newline at end of file
diff --git a/org_apg_integration_demo/build.xml b/org_apg_integration_demo/build.xml
new file mode 100644
index 000000000..c5049ee1b
--- /dev/null
+++ b/org_apg_integration_demo/build.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="BaseActivity" 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" />
+
+ <!-- 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 an env var"
+ 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/org_apg_integration_demo/libs/org_apg_integration_lib.jar b/org_apg_integration_demo/libs/org_apg_integration_lib.jar
new file mode 100644
index 000000000..43bcec37b
--- /dev/null
+++ b/org_apg_integration_demo/libs/org_apg_integration_lib.jar
Binary files differ
diff --git a/org_apg_integration_demo/proguard-project.txt b/org_apg_integration_demo/proguard-project.txt
new file mode 100644
index 000000000..f2fe1559a
--- /dev/null
+++ b/org_apg_integration_demo/proguard-project.txt
@@ -0,0 +1,20 @@
+# 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/org_apg_integration_demo/project.properties b/org_apg_integration_demo/project.properties
new file mode 100644
index 000000000..8da376af8
--- /dev/null
+++ b/org_apg_integration_demo/project.properties
@@ -0,0 +1,11 @@
+# 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 use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-15
diff --git a/org_apg_integration_demo/res/drawable-hdpi/icon.png b/org_apg_integration_demo/res/drawable-hdpi/icon.png
new file mode 100644
index 000000000..d0a519c3e
--- /dev/null
+++ b/org_apg_integration_demo/res/drawable-hdpi/icon.png
Binary files differ
diff --git a/org_apg_integration_demo/res/drawable-ldpi/icon.png b/org_apg_integration_demo/res/drawable-ldpi/icon.png
new file mode 100644
index 000000000..c3e3a4ee7
--- /dev/null
+++ b/org_apg_integration_demo/res/drawable-ldpi/icon.png
Binary files differ
diff --git a/org_apg_integration_demo/res/drawable-mdpi/icon.png b/org_apg_integration_demo/res/drawable-mdpi/icon.png
new file mode 100644
index 000000000..b23eeb8ab
--- /dev/null
+++ b/org_apg_integration_demo/res/drawable-mdpi/icon.png
Binary files differ
diff --git a/org_apg_integration_demo/res/drawable-xhdpi/icon.png b/org_apg_integration_demo/res/drawable-xhdpi/icon.png
new file mode 100644
index 000000000..52842c4f6
--- /dev/null
+++ b/org_apg_integration_demo/res/drawable-xhdpi/icon.png
Binary files differ
diff --git a/org_apg_integration_demo/res/layout/intent_demo.xml b/org_apg_integration_demo/res/layout/intent_demo.xml
new file mode 100644
index 000000000..825a198b5
--- /dev/null
+++ b/org_apg_integration_demo/res/layout/intent_demo.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" >
+
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:orientation="vertical" >
+
+ <Button
+ android:id="@+id/intent_demo_select_secret_key"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:onClick="intentDemoSelectSecretKeyOnClick"
+ android:text="Select secret key" />
+
+ <Button
+ android:id="@+id/intent_demo_select_encryption_key"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:onClick="intentDemoSelectEncryptionKeysOnClick"
+ android:text="Select encryption key(s)" />
+
+ <EditText
+ android:id="@+id/intent_demo_message"
+ android:layout_width="match_parent"
+ android:layout_height="150dip"
+ android:text="message"
+ android:textAppearance="@android:style/TextAppearance.Small" />
+
+ <EditText
+ android:id="@+id/intent_demo_ciphertext"
+ android:layout_width="match_parent"
+ android:layout_height="150dip"
+ android:text="ciphertext"
+ android:textAppearance="@android:style/TextAppearance.Small" />
+
+ <Button
+ android:id="@+id/intent_demo_encrypt"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:onClick="intentDemoEncryptOnClick"
+ android:text="Encrypt" />
+
+ <Button
+ android:id="@+id/intent_demo_decrypt"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:onClick="intentDemoDecryptOnClick"
+ android:text="Decrypt" />
+
+ <TextView
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:text="APG Data:" />
+
+ <TextView
+ android:id="@+id/intent_demo_data"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:minLines="10" />
+ </LinearLayout>
+
+</ScrollView> \ No newline at end of file
diff --git a/org_apg_integration_demo/res/xml/base_preference.xml b/org_apg_integration_demo/res/xml/base_preference.xml
new file mode 100644
index 000000000..c56e54746
--- /dev/null
+++ b/org_apg_integration_demo/res/xml/base_preference.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8"?>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
+
+ <PreferenceCategory android:title="Intent" >
+ <Preference
+ android:key="intent_demo"
+ android:title="Intent Demo" />
+ </PreferenceCategory>
+ <PreferenceCategory android:title="AIDL" >
+ <Preference
+ android:key="aidl_demo"
+ android:title="AIDL Demo" />
+ </PreferenceCategory>
+
+</PreferenceScreen> \ No newline at end of file
diff --git a/org_apg_integration_demo/src/org/apg/api_demo/BaseActivity.java b/org_apg_integration_demo/src/org/apg/api_demo/BaseActivity.java
new file mode 100644
index 000000000..2a6d87498
--- /dev/null
+++ b/org_apg_integration_demo/src/org/apg/api_demo/BaseActivity.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2012 Dominik Schürmann <dominik@dominikschuermann.de>
+ *
+ * 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.apg.api_demo;
+
+import org.apg.api_demo.R;
+import org.apg.integration.ApgIntentHelper;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceClickListener;
+import android.preference.PreferenceActivity;
+import android.widget.Toast;
+
+public class BaseActivity extends PreferenceActivity {
+ private Activity mActivity;
+
+ private Preference mIntentDemo;
+ private Preference mAidlDemo;
+
+ /**
+ * Called when the activity is first created.
+ */
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mActivity = this;
+
+ // load preferences from xml
+ addPreferencesFromResource(R.xml.base_preference);
+
+ // find preferences
+ mIntentDemo = (Preference) findPreference("intent_demo");
+ mAidlDemo = (Preference) findPreference("aidl_demo");
+
+ mIntentDemo.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ startActivity(new Intent(mActivity, IntentDemoActivity.class));
+
+ return false;
+ }
+ });
+
+ mAidlDemo.setOnPreferenceClickListener(new OnPreferenceClickListener() {
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ Toast.makeText(mActivity, "Currently not implemented!", Toast.LENGTH_LONG).show();
+
+ return false;
+ }
+ });
+ }
+
+}
diff --git a/org_apg_integration_demo/src/org/apg/api_demo/IntentDemoActivity.java b/org_apg_integration_demo/src/org/apg/api_demo/IntentDemoActivity.java
new file mode 100644
index 000000000..d5b9fd5f8
--- /dev/null
+++ b/org_apg_integration_demo/src/org/apg/api_demo/IntentDemoActivity.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2012 Dominik Schürmann <dominik@dominikschuermann.de>
+ *
+ * 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.apg.api_demo;
+
+import org.apg.api_demo.R;
+import org.apg.integration.ApgData;
+import org.apg.integration.ApgIntentHelper;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.TextView;
+
+public class IntentDemoActivity extends Activity {
+ Activity mActivity;
+ ApgIntentHelper mApgIntentHelper;
+ TextView mMessageTextView;
+ TextView mCiphertextTextView;
+ TextView mDataTextView;
+
+ ApgData mApgData;
+
+ /**
+ * Instantiate View for this Activity
+ */
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.intent_demo);
+
+ mActivity = this;
+ mApgIntentHelper = new ApgIntentHelper(mActivity);
+ mMessageTextView = (TextView) findViewById(R.id.intent_demo_message);
+ mCiphertextTextView = (TextView) findViewById(R.id.intent_demo_ciphertext);
+
+ mDataTextView = (TextView) findViewById(R.id.intent_demo_data);
+
+ mApgData = new ApgData();
+ }
+
+ public void intentDemoSelectSecretKeyOnClick(View view) {
+ mApgIntentHelper.selectSecretKey();
+ }
+
+ public void intentDemoSelectEncryptionKeysOnClick(View view) {
+ mApgIntentHelper.selectEncryptionKeys("usera@example.com");
+ }
+
+ public void intentDemoEncryptOnClick(View view) {
+ mApgIntentHelper.encrypt(mMessageTextView.getText().toString(),
+ mApgData.getEncryptionKeys(), mApgData.getSignatureKeyId());
+ }
+
+ public void intentDemoDecryptOnClick(View view) {
+ mApgIntentHelper.decrypt(mCiphertextTextView.getText().toString());
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ // this updates the mApgData object to the result of the methods
+ boolean result = mApgIntentHelper.onActivityResult(requestCode, resultCode, data, mApgData);
+ if (result) {
+ updateView();
+ }
+
+ // continue with other activity results
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+
+ private void updateView() {
+ if (mApgData.getDecryptedData() != null) {
+ mMessageTextView.setText(mApgData.getDecryptedData());
+ }
+ if (mApgData.getEncryptedData() != null) {
+ mCiphertextTextView.setText(mApgData.getEncryptedData());
+ }
+ mDataTextView.setText(mApgData.toString());
+ }
+}