diff options
Diffstat (limited to 'APG-API-Demo')
19 files changed, 0 insertions, 1091 deletions
diff --git a/APG-API-Demo/.gitignore b/APG-API-Demo/.gitignore deleted file mode 100644 index 2e423e1a3..000000000 --- a/APG-API-Demo/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -#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/APG-API-Demo/AndroidManifest.xml b/APG-API-Demo/AndroidManifest.xml deleted file mode 100644 index 812b5d45e..000000000 --- a/APG-API-Demo/AndroidManifest.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<manifest xmlns:android="http://schemas.android.com/apk/res/android" - package="org.thialfihar.android.apg.demo" - android:versionCode="1" - android:versionName="1.0" > - - <uses-permission android:name="org.thialfihar.android.apg.permission.ACCESS_API" /> - <uses-permission android:name="org.thialfihar.android.apg.permission.ACCESS_KEYS" /> - - <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" - android:windowSoftInputMode="stateHidden" /> - <activity - android:name=".AidlDemoActivity" - android:label="Aidl Demo (ACCESS_API permission)" - android:windowSoftInputMode="stateHidden" /> - <activity - android:name=".AidlDemoActivity2" - android:label="Aidl Demo (ACCESS_KEYS permission)" - android:windowSoftInputMode="stateHidden" /> - <activity - android:name=".ContentProviderDemoActivity" - android:label="Content Provider Demo" - android:windowSoftInputMode="stateHidden" /> - </application> - -</manifest>
\ No newline at end of file diff --git a/APG-API-Demo/build.xml b/APG-API-Demo/build.xml deleted file mode 100644 index e72865c84..000000000 --- a/APG-API-Demo/build.xml +++ /dev/null @@ -1,83 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project name="APG Integration Demo" 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/APG-API-Demo/proguard-project.txt b/APG-API-Demo/proguard-project.txt deleted file mode 100644 index f2fe1559a..000000000 --- a/APG-API-Demo/proguard-project.txt +++ /dev/null @@ -1,20 +0,0 @@ -# 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/APG-API-Demo/project.properties b/APG-API-Demo/project.properties deleted file mode 100644 index ea95f1b11..000000000 --- a/APG-API-Demo/project.properties +++ /dev/null @@ -1,12 +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 use, -# "ant.properties", and override values to adapt the script to your -# project structure. - -# Project target. -target=android-15 -android.library.reference.1=../APG-API-Lib diff --git a/APG-API-Demo/res/drawable-hdpi/icon.png b/APG-API-Demo/res/drawable-hdpi/icon.png Binary files differdeleted file mode 100644 index 6b8cc3d73..000000000 --- a/APG-API-Demo/res/drawable-hdpi/icon.png +++ /dev/null diff --git a/APG-API-Demo/res/drawable-ldpi/icon.png b/APG-API-Demo/res/drawable-ldpi/icon.png Binary files differdeleted file mode 100644 index a1adf6bcb..000000000 --- a/APG-API-Demo/res/drawable-ldpi/icon.png +++ /dev/null diff --git a/APG-API-Demo/res/drawable-mdpi/icon.png b/APG-API-Demo/res/drawable-mdpi/icon.png Binary files differdeleted file mode 100644 index 6b10a2ad3..000000000 --- a/APG-API-Demo/res/drawable-mdpi/icon.png +++ /dev/null diff --git a/APG-API-Demo/res/drawable-xhdpi/icon.png b/APG-API-Demo/res/drawable-xhdpi/icon.png Binary files differdeleted file mode 100644 index 03ee31bbd..000000000 --- a/APG-API-Demo/res/drawable-xhdpi/icon.png +++ /dev/null diff --git a/APG-API-Demo/res/layout/aidl_demo.xml b/APG-API-Demo/res/layout/aidl_demo.xml deleted file mode 100644 index 59977869d..000000000 --- a/APG-API-Demo/res/layout/aidl_demo.xml +++ /dev/null @@ -1,72 +0,0 @@ -<?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/aidl_demo_create_new_key" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:onClick="createNewKeyOnClick" - android:text="Create new key" /> - - <Button - android:id="@+id/aidl_demo_select_secret_key" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:onClick="selectSecretKeyOnClick" - android:text="Select secret key" /> - - <Button - android:id="@+id/aidl_demo_select_encryption_key" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:onClick="selectEncryptionKeysOnClick" - android:text="Select encryption key(s)" /> - - <EditText - android:id="@+id/aidl_demo_message" - android:layout_width="match_parent" - android:layout_height="150dip" - android:text="message" - android:textAppearance="@android:style/TextAppearance.Small" /> - - <EditText - android:id="@+id/aidl_demo_ciphertext" - android:layout_width="match_parent" - android:layout_height="150dip" - android:text="ciphertext" - android:textAppearance="@android:style/TextAppearance.Small" /> - - <Button - android:id="@+id/aidl_demo_encrypt" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:onClick="encryptOnClick" - android:text="Encrypt" /> - - <Button - android:id="@+id/aidl_demo_decrypt" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:onClick="decryptOnClick" - android:text="Decrypt" /> - - <TextView - android:layout_width="match_parent" - android:layout_height="match_parent" - android:text="APG Data:" /> - - <TextView - android:id="@+id/aidl_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/APG-API-Demo/res/layout/aidl_demo2.xml b/APG-API-Demo/res/layout/aidl_demo2.xml deleted file mode 100644 index 73abd9b5c..000000000 --- a/APG-API-Demo/res/layout/aidl_demo2.xml +++ /dev/null @@ -1,40 +0,0 @@ -<?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="wrap_content" - android:orientation="vertical" > - - <Button - android:id="@+id/aidl_demo_select_encryption_key" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:onClick="selectEncryptionKeysOnClick" - android:text="Select encryption key(s)" /> - - <EditText - android:id="@+id/aidl_demo_keyrings" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:text="keyrings output" - android:textAppearance="@android:style/TextAppearance.Small" /> - - <Button - android:id="@+id/aidl_demo_get_keyrings_strings" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:onClick="getKeyringsStringsOnClick" - android:text="getKeyrings as Strings" /> - - <Button - android:id="@+id/aidl_demo_get_keyrings_bytes" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:onClick="getKeyringsBytesOnClick" - android:text="getKeyringsBytes" /> - </LinearLayout> - -</ScrollView>
\ No newline at end of file diff --git a/APG-API-Demo/res/layout/content_provider_demo.xml b/APG-API-Demo/res/layout/content_provider_demo.xml deleted file mode 100644 index 279324cda..000000000 --- a/APG-API-Demo/res/layout/content_provider_demo.xml +++ /dev/null @@ -1,33 +0,0 @@ -<?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="wrap_content" - android:orientation="vertical" > - - <Button - android:id="@+id/content_provider_test1" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:onClick="test1OnClick" - android:text="Test 1" /> - - <Button - android:id="@+id/content_provider_test2" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:onClick="test2OnClick" - android:text="Test 2" /> - - <EditText - android:id="@+id/content_provider_output" - android:layout_width="match_parent" - android:layout_height="150dip" - android:text="output" - android:textAppearance="@android:style/TextAppearance.Small" /> - </LinearLayout> - -</ScrollView>
\ No newline at end of file diff --git a/APG-API-Demo/res/layout/intent_demo.xml b/APG-API-Demo/res/layout/intent_demo.xml deleted file mode 100644 index a765343f9..000000000 --- a/APG-API-Demo/res/layout/intent_demo.xml +++ /dev/null @@ -1,93 +0,0 @@ -<?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/Button02" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:onClick="encryptOnClick" - android:text="Encrypt" /> - - <Button - android:id="@+id/intent_demo_create_new_key" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:onClick="createNewKeyOnClick" - android:text="Create new key" /> - - <Button - android:id="@+id/intent_demo_select_secret_key" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:onClick="selectSecretKeyOnClick" - 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="selectEncryptionKeysOnClick" - 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="encryptOnClick" - android:text="Encrypt" /> - - <Button - android:id="@+id/intent_demo_encrypt" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:onClick="encryptAndReturnOnClick" - android:text="Encrypt and return result" /> - - <Button - android:id="@+id/intent_demo_decrypt" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:onClick="decryptOnClick" - android:text="Decrypt" /> - - <Button - android:id="@+id/intent_demo_decrypt" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:onClick="decryptAndReturnOnClick" - android:text="Decrypt and return result" /> - - <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/APG-API-Demo/res/xml/base_preference.xml b/APG-API-Demo/res/xml/base_preference.xml deleted file mode 100644 index c9a34efd1..000000000 --- a/APG-API-Demo/res/xml/base_preference.xml +++ /dev/null @@ -1,23 +0,0 @@ -<?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="Content Provider" > - <Preference - android:key="content_provider_demo" - android:title="Content Provider Demo" /> - </PreferenceCategory> - <PreferenceCategory android:title="AIDL" > - <Preference - android:key="aidl_demo" - android:title="AIDL Demo (ACCESS_API permission)" /> - <Preference - android:key="aidl_demo2" - android:title="AIDL Demo (ACCESS_KEYS permission)" /> - </PreferenceCategory> - -</PreferenceScreen>
\ No newline at end of file diff --git a/APG-API-Demo/src/org/thialfihar/android/apg/demo/AidlDemoActivity.java b/APG-API-Demo/src/org/thialfihar/android/apg/demo/AidlDemoActivity.java deleted file mode 100644 index 2174b6e09..000000000 --- a/APG-API-Demo/src/org/thialfihar/android/apg/demo/AidlDemoActivity.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * 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.thialfihar.android.apg.demo; - -import org.thialfihar.android.apg.integration.ApgData; -import org.thialfihar.android.apg.integration.ApgIntentHelper; -import org.thialfihar.android.apg.service.IApgApiService; -import org.thialfihar.android.apg.service.IApgKeyService; -import org.thialfihar.android.apg.service.handler.IApgDecryptHandler; -import org.thialfihar.android.apg.service.handler.IApgEncryptHandler; -import org.thialfihar.android.apg.service.handler.IApgGetDecryptionKeyIdHandler; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.ServiceConnection; -import android.os.Bundle; -import android.os.IBinder; -import android.os.RemoteException; -import android.view.View; -import android.widget.TextView; - -public class AidlDemoActivity extends Activity { - Activity mActivity; - - TextView mMessageTextView; - TextView mCiphertextTextView; - TextView mDataTextView; - - ApgIntentHelper mApgIntentHelper; - ApgData mApgData; - - private IApgApiService service = null; - private ServiceConnection svcConn = new ServiceConnection() { - public void onServiceConnected(ComponentName className, IBinder binder) { - service = IApgApiService.Stub.asInterface(binder); - } - - public void onServiceDisconnected(ComponentName className) { - service = null; - } - }; - - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - setContentView(R.layout.aidl_demo); - - mActivity = this; - - mMessageTextView = (TextView) findViewById(R.id.aidl_demo_message); - mCiphertextTextView = (TextView) findViewById(R.id.aidl_demo_ciphertext); - mDataTextView = (TextView) findViewById(R.id.aidl_demo_data); - - mApgIntentHelper = new ApgIntentHelper(mActivity); - mApgData = new ApgData(); - - bindService(new Intent(IApgApiService.class.getName()), svcConn, Context.BIND_AUTO_CREATE); - } - - public void encryptOnClick(View view) { - byte[] inputBytes = mMessageTextView.getText().toString().getBytes(); - - try { - service.encryptAsymmetric(inputBytes, null, true, 0, mApgData.getPublicKeys(), 7, - encryptHandler); - } catch (RemoteException e) { - exceptionImplementation(-1, e.toString()); - } - } - - public void decryptOnClick(View view) { - byte[] inputBytes = mCiphertextTextView.getText().toString().getBytes(); - - try { - service.decryptAndVerifyAsymmetric(inputBytes, null, null, decryptHandler); - } catch (RemoteException e) { - exceptionImplementation(-1, e.toString()); - } - } - - private void updateView() { - if (mApgData.getDecryptedData() != null) { - mMessageTextView.setText(mApgData.getDecryptedData()); - } - if (mApgData.getEncryptedData() != null) { - mCiphertextTextView.setText(mApgData.getEncryptedData()); - } - mDataTextView.setText(mApgData.toString()); - } - - @Override - public void onDestroy() { - super.onDestroy(); - - unbindService(svcConn); - } - - private void exceptionImplementation(int exceptionId, String error) { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle("Exception!").setMessage(error).setPositiveButton("OK", null).show(); - } - - private final IApgEncryptHandler.Stub encryptHandler = new IApgEncryptHandler.Stub() { - - @Override - public void onException(final int exceptionId, final String message) throws RemoteException { - runOnUiThread(new Runnable() { - public void run() { - exceptionImplementation(exceptionId, message); - } - }); - } - - @Override - public void onSuccess(final byte[] outputBytes, String outputUri) throws RemoteException { - runOnUiThread(new Runnable() { - public void run() { - mApgData.setEncryptedData(new String(outputBytes)); - updateView(); - } - }); - } - - }; - - private final IApgDecryptHandler.Stub decryptHandler = new IApgDecryptHandler.Stub() { - - @Override - public void onException(final int exceptionId, final String message) throws RemoteException { - runOnUiThread(new Runnable() { - public void run() { - exceptionImplementation(exceptionId, message); - } - }); - } - - @Override - public void onSuccess(final byte[] outputBytes, String outputUri, boolean signature, - long signatureKeyId, String signatureUserId, boolean signatureSuccess, - boolean signatureUnknown) throws RemoteException { - runOnUiThread(new Runnable() { - public void run() { - mApgData.setDecryptedData(new String(outputBytes)); - updateView(); - } - }); - - } - - }; - - private final IApgGetDecryptionKeyIdHandler.Stub helperHandler = new IApgGetDecryptionKeyIdHandler.Stub() { - - @Override - public void onException(final int exceptionId, final String message) throws RemoteException { - runOnUiThread(new Runnable() { - public void run() { - exceptionImplementation(exceptionId, message); - } - }); - } - - @Override - public void onSuccess(long arg0, boolean arg1) throws RemoteException { - // TODO Auto-generated method stub - - } - - }; - - /** - * Selection is done with Intents, not AIDL! - * - * @param view - */ - public void selectSecretKeyOnClick(View view) { - mApgIntentHelper.selectSecretKey(); - } - - public void selectEncryptionKeysOnClick(View view) { - mApgIntentHelper.selectPublicKeys("user@example.com"); - - } - - @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); - } -} diff --git a/APG-API-Demo/src/org/thialfihar/android/apg/demo/AidlDemoActivity2.java b/APG-API-Demo/src/org/thialfihar/android/apg/demo/AidlDemoActivity2.java deleted file mode 100644 index 4a862e8ae..000000000 --- a/APG-API-Demo/src/org/thialfihar/android/apg/demo/AidlDemoActivity2.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * 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.thialfihar.android.apg.demo; - -import java.util.ArrayList; -import java.util.List; - -import org.thialfihar.android.apg.integration.ApgData; -import org.thialfihar.android.apg.integration.ApgIntentHelper; -import org.thialfihar.android.apg.service.IApgKeyService; -import org.thialfihar.android.apg.service.handler.IApgGetKeyringsHandler; - -import android.annotation.SuppressLint; -import android.app.Activity; -import android.app.AlertDialog; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.ServiceConnection; -import android.os.Bundle; -import android.os.IBinder; -import android.os.RemoteException; -import android.util.Base64; -import android.view.View; -import android.widget.TextView; - -public class AidlDemoActivity2 extends Activity { - Activity mActivity; - - TextView mKeyringsTextView; - - ApgIntentHelper mApgIntentHelper; - ApgData mApgData; - - byte[] keysBytes; - ArrayList<String> keysStrings; - - private IApgKeyService service = null; - private ServiceConnection svcConn = new ServiceConnection() { - public void onServiceConnected(ComponentName className, IBinder binder) { - service = IApgKeyService.Stub.asInterface(binder); - } - - public void onServiceDisconnected(ComponentName className) { - service = null; - } - }; - - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - setContentView(R.layout.aidl_demo2); - - mActivity = this; - - mKeyringsTextView = (TextView) findViewById(R.id.aidl_demo_keyrings); - - mApgIntentHelper = new ApgIntentHelper(mActivity); - mApgData = new ApgData(); - - bindService(new Intent(IApgKeyService.class.getName()), svcConn, Context.BIND_AUTO_CREATE); - } - - public void getKeyringsStringsOnClick(View view) { - try { - service.getPublicKeyRings(mApgData.getPublicKeys(), true, getKeyringsHandler); - } catch (RemoteException e) { - exceptionImplementation(-1, e.toString()); - } - } - - public void getKeyringsBytesOnClick(View view) { - try { - service.getPublicKeyRings(mApgData.getPublicKeys(), false, getKeyringsHandler); - } catch (RemoteException e) { - exceptionImplementation(-1, e.toString()); - } - } - - @SuppressLint("NewApi") - private void updateView() { - if (keysBytes != null) { - mKeyringsTextView.setText(Base64.encodeToString(keysBytes, Base64.DEFAULT)); - } else if (keysStrings != null) { - mKeyringsTextView.setText(""); - for (String output : keysStrings) { - mKeyringsTextView.append(output); - } - } - } - - @Override - public void onDestroy() { - super.onDestroy(); - - unbindService(svcConn); - } - - private void exceptionImplementation(int exceptionId, String error) { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle("Exception!").setMessage(error).setPositiveButton("OK", null).show(); - } - - private final IApgGetKeyringsHandler.Stub getKeyringsHandler = new IApgGetKeyringsHandler.Stub() { - - @Override - public void onException(final int exceptionId, final String message) throws RemoteException { - runOnUiThread(new Runnable() { - public void run() { - exceptionImplementation(exceptionId, message); - } - }); - } - - @Override - public void onSuccess(final byte[] outputBytes, final List<String> outputStrings) - throws RemoteException { - runOnUiThread(new Runnable() { - public void run() { - if (outputBytes != null) { - keysBytes = outputBytes; - keysStrings = null; - } else if (outputStrings != null) { - keysBytes = null; - keysStrings = (ArrayList<String>) outputStrings; - } - updateView(); - } - }); - - } - - }; - - public void selectEncryptionKeysOnClick(View view) { - mApgIntentHelper.selectPublicKeys("user@example.com"); - } - - @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); - } - -} diff --git a/APG-API-Demo/src/org/thialfihar/android/apg/demo/BaseActivity.java b/APG-API-Demo/src/org/thialfihar/android/apg/demo/BaseActivity.java deleted file mode 100644 index 5e2108c50..000000000 --- a/APG-API-Demo/src/org/thialfihar/android/apg/demo/BaseActivity.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.thialfihar.android.apg.demo; - -import org.thialfihar.android.apg.demo.R; - -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; - -public class BaseActivity extends PreferenceActivity { - private Activity mActivity; - - private Preference mIntentDemo; - private Preference mContentProviderDemo; - private Preference mAidlDemo; - private Preference mAidlDemo2; - - /** - * 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"); - mContentProviderDemo = (Preference) findPreference("content_provider_demo"); - mAidlDemo = (Preference) findPreference("aidl_demo"); - mAidlDemo2 = (Preference) findPreference("aidl_demo2"); - - mIntentDemo.setOnPreferenceClickListener(new OnPreferenceClickListener() { - @Override - public boolean onPreferenceClick(Preference preference) { - startActivity(new Intent(mActivity, IntentDemoActivity.class)); - - return false; - } - }); - - mContentProviderDemo.setOnPreferenceClickListener(new OnPreferenceClickListener() { - @Override - public boolean onPreferenceClick(Preference preference) { - startActivity(new Intent(mActivity, ContentProviderDemoActivity.class)); - - return false; - } - }); - - mAidlDemo.setOnPreferenceClickListener(new OnPreferenceClickListener() { - @Override - public boolean onPreferenceClick(Preference preference) { - startActivity(new Intent(mActivity, AidlDemoActivity.class)); - - return false; - } - }); - - mAidlDemo2.setOnPreferenceClickListener(new OnPreferenceClickListener() { - @Override - public boolean onPreferenceClick(Preference preference) { - startActivity(new Intent(mActivity, AidlDemoActivity2.class)); - - return false; - } - }); - - } - -} diff --git a/APG-API-Demo/src/org/thialfihar/android/apg/demo/ContentProviderDemoActivity.java b/APG-API-Demo/src/org/thialfihar/android/apg/demo/ContentProviderDemoActivity.java deleted file mode 100644 index 892b41429..000000000 --- a/APG-API-Demo/src/org/thialfihar/android/apg/demo/ContentProviderDemoActivity.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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.thialfihar.android.apg.demo; - -import java.util.Arrays; - -import org.thialfihar.android.apg.demo.R; -import org.thialfihar.android.apg.integration.ApgContentProviderHelper; - -import android.app.Activity; -import android.os.Bundle; -import android.view.View; -import android.widget.TextView; - -public class ContentProviderDemoActivity extends Activity { - Activity mActivity; - - TextView mOutputTextView; - TextView mCiphertextTextView; - TextView mDataTextView; - - ApgContentProviderHelper mApgContentProviderHelper; - - /** - * Instantiate View for this Activity - */ - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setContentView(R.layout.content_provider_demo); - - mActivity = this; - - mOutputTextView = (TextView) findViewById(R.id.content_provider_output); - - mApgContentProviderHelper = new ApgContentProviderHelper(mActivity); - } - - public void test1OnClick(View view) { - long[] test = mApgContentProviderHelper.getPublicKeyringIdsByEmail("user@example.com"); - mOutputTextView.setText(Arrays.toString(test)); - } - - public void test2OnClick(View view) { - boolean test = mApgContentProviderHelper.hasPublicKeyringByEmail("user@example.com"); - if (test) { - mOutputTextView.setText("true"); - } else { - mOutputTextView.setText("false"); - } - } - -} diff --git a/APG-API-Demo/src/org/thialfihar/android/apg/demo/IntentDemoActivity.java b/APG-API-Demo/src/org/thialfihar/android/apg/demo/IntentDemoActivity.java deleted file mode 100644 index b789dccb1..000000000 --- a/APG-API-Demo/src/org/thialfihar/android/apg/demo/IntentDemoActivity.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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.thialfihar.android.apg.demo; - -import org.thialfihar.android.apg.demo.R; -import org.thialfihar.android.apg.integration.ApgData; -import org.thialfihar.android.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; - - TextView mMessageTextView; - TextView mCiphertextTextView; - TextView mDataTextView; - - ApgIntentHelper mApgIntentHelper; - ApgData mApgData; - - /** - * Instantiate View for this Activity - */ - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setContentView(R.layout.intent_demo); - - mActivity = this; - - mMessageTextView = (TextView) findViewById(R.id.intent_demo_message); - mCiphertextTextView = (TextView) findViewById(R.id.intent_demo_ciphertext); - mDataTextView = (TextView) findViewById(R.id.intent_demo_data); - - mApgIntentHelper = new ApgIntentHelper(mActivity); - mApgData = new ApgData(); - } - - public void createNewKeyOnClick(View view) { - // mApgIntentHelper.createNewKey(); - mApgIntentHelper.createNewKey("test <user@example.com>", true, true); - } - - public void selectSecretKeyOnClick(View view) { - mApgIntentHelper.selectSecretKey(); - } - - public void selectEncryptionKeysOnClick(View view) { - mApgIntentHelper.selectPublicKeys("user@example.com"); - } - - public void encryptOnClick(View view) { - mApgIntentHelper.encrypt(mMessageTextView.getText().toString(), mApgData.getPublicKeys(), - mApgData.getSecretKeyId(), false); - } - - public void encryptAndReturnOnClick(View view) { - mApgIntentHelper.encrypt(mMessageTextView.getText().toString(), mApgData.getPublicKeys(), - mApgData.getSecretKeyId(), true); - } - - public void decryptOnClick(View view) { - mApgIntentHelper.decrypt(mCiphertextTextView.getText().toString(), false); - } - - public void decryptAndReturnOnClick(View view) { - mApgIntentHelper.decrypt(mCiphertextTextView.getText().toString(), true); - } - - @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()); - } -} |