aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--OpenPGP-Keychain-API-Demo/src/org/openintents/crypto/ICryptoCallback.aidl8
-rw-r--r--OpenPGP-Keychain-API-Demo/src/org/openintents/crypto/ICryptoService.aidl8
-rw-r--r--OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/CryptoProviderDemoActivity.java25
-rw-r--r--OpenPGP-Keychain/AndroidManifest.xml4
-rw-r--r--OpenPGP-Keychain/build.gradle2
-rw-r--r--OpenPGP-Keychain/res/layout/crypto_consumers_activity.xml12
-rw-r--r--OpenPGP-Keychain/res/values/strings.xml2
-rw-r--r--OpenPGP-Keychain/src/org/openintents/crypto/ICryptoCallback.aidl8
-rw-r--r--OpenPGP-Keychain/src/org/openintents/crypto/ICryptoService.aidl8
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/Id.java1
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/crypto_provider/CryptoService.java9
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/CryptoConsumersActivity.java43
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/CryptoConsumersFragment.java85
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/MainActivity.java7
14 files changed, 205 insertions, 17 deletions
diff --git a/OpenPGP-Keychain-API-Demo/src/org/openintents/crypto/ICryptoCallback.aidl b/OpenPGP-Keychain-API-Demo/src/org/openintents/crypto/ICryptoCallback.aidl
index 80c741a9e..1f910d4c6 100644
--- a/OpenPGP-Keychain-API-Demo/src/org/openintents/crypto/ICryptoCallback.aidl
+++ b/OpenPGP-Keychain-API-Demo/src/org/openintents/crypto/ICryptoCallback.aidl
@@ -20,10 +20,12 @@ import org.openintents.crypto.CryptoSignatureResult;
import org.openintents.crypto.CryptoError;
interface ICryptoCallback {
-
- oneway void onEncryptSignSuccess(in byte[] outputBytes);
- oneway void onDecryptVerifySuccess(in byte[] outputBytes, in CryptoSignatureResult signatureResult);
+ /**
+ * CryptoSignatureResult is only returned if the Callback was used from decryptAndVerify
+ *
+ */
+ oneway void onSuccess(in byte[] outputBytes, in CryptoSignatureResult signatureResult);
oneway void onError(in CryptoError error);
diff --git a/OpenPGP-Keychain-API-Demo/src/org/openintents/crypto/ICryptoService.aidl b/OpenPGP-Keychain-API-Demo/src/org/openintents/crypto/ICryptoService.aidl
index 53f39dffc..c84ca28fb 100644
--- a/OpenPGP-Keychain-API-Demo/src/org/openintents/crypto/ICryptoService.aidl
+++ b/OpenPGP-Keychain-API-Demo/src/org/openintents/crypto/ICryptoService.aidl
@@ -71,6 +71,12 @@ interface ICryptoService {
* @param callback
* Callback where to return results
*/
- oneway void decryptAndVerify(in byte[] inputBytes, in ICryptoCallback callback);
+ oneway void decryptAndVerify(in byte[] inputBytes, in ICryptoCallback callback);
+
+ /**
+ * Opens setup using default parameters
+ *
+ */
+ oneway void setup(boolean asciiArmor, boolean newKeyring, String newKeyringUserId);
} \ No newline at end of file
diff --git a/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/CryptoProviderDemoActivity.java b/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/CryptoProviderDemoActivity.java
index 831c269e1..a82c44c6a 100644
--- a/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/CryptoProviderDemoActivity.java
+++ b/OpenPGP-Keychain-API-Demo/src/org/sufficientlysecure/keychain/demo/CryptoProviderDemoActivity.java
@@ -71,17 +71,28 @@ public class CryptoProviderDemoActivity extends Activity {
/**
* Callback from remote crypto service
*/
- final ICryptoCallback.Stub callback = new ICryptoCallback.Stub() {
+ final ICryptoCallback.Stub encryptCallback = new ICryptoCallback.Stub() {
@Override
- public void onEncryptSignSuccess(byte[] outputBytes) throws RemoteException {
+ public void onSuccess(byte[] outputBytes, CryptoSignatureResult signatureResult)
+ throws RemoteException {
Log.d(Constants.TAG, "onEncryptSignSuccess");
// TODO
}
@Override
- public void onDecryptVerifySuccess(byte[] outputBytes, CryptoSignatureResult signatureResult)
+ public void onError(CryptoError error) throws RemoteException {
+ Log.e(Constants.TAG, "onError getErrorId:" + error.getErrorId());
+ Log.e(Constants.TAG, "onError getMessage:" + error.getMessage());
+ }
+
+ };
+
+ final ICryptoCallback.Stub decryptCallback = new ICryptoCallback.Stub() {
+
+ @Override
+ public void onSuccess(byte[] outputBytes, CryptoSignatureResult signatureResult)
throws RemoteException {
Log.d(Constants.TAG, "onDecryptVerifySuccess");
@@ -101,7 +112,7 @@ public class CryptoProviderDemoActivity extends Activity {
try {
mCryptoServiceConnection.getService().encrypt(inputBytes,
- new String[] { mEncryptUserId.getText().toString() }, callback);
+ new String[] { mEncryptUserId.getText().toString() }, encryptCallback);
} catch (RemoteException e) {
Log.e(Constants.TAG, "CryptoProviderDemo", e);
}
@@ -112,7 +123,7 @@ public class CryptoProviderDemoActivity extends Activity {
try {
mCryptoServiceConnection.getService().sign(inputBytes,
- mSignUserId.getText().toString(), callback);
+ mSignUserId.getText().toString(), encryptCallback);
} catch (RemoteException e) {
Log.e(Constants.TAG, "CryptoProviderDemo", e);
}
@@ -124,7 +135,7 @@ public class CryptoProviderDemoActivity extends Activity {
try {
mCryptoServiceConnection.getService().encryptAndSign(inputBytes,
new String[] { mEncryptUserId.getText().toString() },
- mSignUserId.getText().toString(), callback);
+ mSignUserId.getText().toString(), encryptCallback);
} catch (RemoteException e) {
Log.e(Constants.TAG, "CryptoProviderDemo", e);
}
@@ -134,7 +145,7 @@ public class CryptoProviderDemoActivity extends Activity {
byte[] inputBytes = mCiphertext.getText().toString().getBytes();
try {
- mCryptoServiceConnection.getService().decryptAndVerify(inputBytes, callback);
+ mCryptoServiceConnection.getService().decryptAndVerify(inputBytes, decryptCallback);
} catch (RemoteException e) {
Log.e(Constants.TAG, "CryptoProviderDemo", e);
}
diff --git a/OpenPGP-Keychain/AndroidManifest.xml b/OpenPGP-Keychain/AndroidManifest.xml
index 0f80604ef..d87e8ec0d 100644
--- a/OpenPGP-Keychain/AndroidManifest.xml
+++ b/OpenPGP-Keychain/AndroidManifest.xml
@@ -299,6 +299,10 @@
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
android:label="@string/title_preferences" />
<activity
+ android:name=".ui.CryptoConsumersActivity"
+ android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
+ android:label="@string/title_crypto_consumers" />
+ <activity
android:name=".ui.PreferencesKeyServerActivity"
android:configChanges="orientation|screenSize|keyboardHidden|keyboard"
android:label="@string/title_keyServerPreference"
diff --git a/OpenPGP-Keychain/build.gradle b/OpenPGP-Keychain/build.gradle
index ec8e07cbd..2f3a0d81a 100644
--- a/OpenPGP-Keychain/build.gradle
+++ b/OpenPGP-Keychain/build.gradle
@@ -4,7 +4,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:0.4.1'
+ classpath 'com.android.tools.build:gradle:0.4.+'
}
}
diff --git a/OpenPGP-Keychain/res/layout/crypto_consumers_activity.xml b/OpenPGP-Keychain/res/layout/crypto_consumers_activity.xml
new file mode 100644
index 000000000..87a7c1739
--- /dev/null
+++ b/OpenPGP-Keychain/res/layout/crypto_consumers_activity.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <fragment
+ android:id="@+id/crypto_consumers_list_fragment"
+ android:name="org.sufficientlysecure.keychain.ui.CryptoConsumersFragment"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
+
+</LinearLayout> \ No newline at end of file
diff --git a/OpenPGP-Keychain/res/values/strings.xml b/OpenPGP-Keychain/res/values/strings.xml
index 5e3807a3a..835198af5 100644
--- a/OpenPGP-Keychain/res/values/strings.xml
+++ b/OpenPGP-Keychain/res/values/strings.xml
@@ -31,6 +31,7 @@
<string name="title_editKey">Edit Keyring</string>
<string name="title_createKey">Create Keyring</string>
<string name="title_preferences">Preferences</string>
+ <string name="title_crypto_consumers">Crypto Consumers</string>
<string name="title_keyServerPreference">Key Server Preference</string>
<string name="title_changePassPhrase">Change Passphrase</string>
<string name="title_setPassPhrase">Set Passphrase</string>
@@ -89,6 +90,7 @@
<string name="menu_managePublicKeys">Manage Public Keyrings</string>
<string name="menu_manageSecretKeys">Manage Secret Keyrings</string>
<string name="menu_preferences">Settings</string>
+ <string name="menu_crypto_consumers">Crypto Consumers</string>
<string name="menu_importFromFile">Import from file</string>
<string name="menu_importFromQrCode">Import from QR Code</string>
<string name="menu_importFromNfc">Import from NFC</string>
diff --git a/OpenPGP-Keychain/src/org/openintents/crypto/ICryptoCallback.aidl b/OpenPGP-Keychain/src/org/openintents/crypto/ICryptoCallback.aidl
index 80c741a9e..1f910d4c6 100644
--- a/OpenPGP-Keychain/src/org/openintents/crypto/ICryptoCallback.aidl
+++ b/OpenPGP-Keychain/src/org/openintents/crypto/ICryptoCallback.aidl
@@ -20,10 +20,12 @@ import org.openintents.crypto.CryptoSignatureResult;
import org.openintents.crypto.CryptoError;
interface ICryptoCallback {
-
- oneway void onEncryptSignSuccess(in byte[] outputBytes);
- oneway void onDecryptVerifySuccess(in byte[] outputBytes, in CryptoSignatureResult signatureResult);
+ /**
+ * CryptoSignatureResult is only returned if the Callback was used from decryptAndVerify
+ *
+ */
+ oneway void onSuccess(in byte[] outputBytes, in CryptoSignatureResult signatureResult);
oneway void onError(in CryptoError error);
diff --git a/OpenPGP-Keychain/src/org/openintents/crypto/ICryptoService.aidl b/OpenPGP-Keychain/src/org/openintents/crypto/ICryptoService.aidl
index 53f39dffc..c84ca28fb 100644
--- a/OpenPGP-Keychain/src/org/openintents/crypto/ICryptoService.aidl
+++ b/OpenPGP-Keychain/src/org/openintents/crypto/ICryptoService.aidl
@@ -71,6 +71,12 @@ interface ICryptoService {
* @param callback
* Callback where to return results
*/
- oneway void decryptAndVerify(in byte[] inputBytes, in ICryptoCallback callback);
+ oneway void decryptAndVerify(in byte[] inputBytes, in ICryptoCallback callback);
+
+ /**
+ * Opens setup using default parameters
+ *
+ */
+ oneway void setup(boolean asciiArmor, boolean newKeyring, String newKeyringUserId);
} \ No newline at end of file
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/Id.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/Id.java
index 382f144d7..b0d60cf94 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/Id.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/Id.java
@@ -62,6 +62,7 @@ public final class Id {
public static final int import_from_file = 0x21070020;
public static final int import_from_qr_code = 0x21070021;
public static final int import_from_nfc = 0x21070022;
+ public static final int crypto_consumers = 0x21070023;
}
}
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/crypto_provider/CryptoService.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/crypto_provider/CryptoService.java
index 7ff8c0e3e..e601620ea 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/crypto_provider/CryptoService.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/crypto_provider/CryptoService.java
@@ -184,7 +184,7 @@ public class CryptoService extends Service {
signatureSuccess, signatureUnknown);
// return over handler on client side
- callback.onDecryptVerifySuccess(outputBytes, sigResult);
+ callback.onSuccess(outputBytes, sigResult);
} catch (Exception e) {
Log.e(Constants.TAG, "KeychainService, Exception!", e);
@@ -250,6 +250,13 @@ public class CryptoService extends Service {
checkAndEnqueue(r);
}
+ @Override
+ public void setup(boolean asciiArmor, boolean newKeyring, String newKeyringUserId)
+ throws RemoteException {
+ // TODO Auto-generated method stub
+
+ }
+
};
private final IServiceActivityCallback.Stub mBinderServiceActivity = new IServiceActivityCallback.Stub() {
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/CryptoConsumersActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/CryptoConsumersActivity.java
new file mode 100644
index 000000000..59eaa063f
--- /dev/null
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/CryptoConsumersActivity.java
@@ -0,0 +1,43 @@
+package org.sufficientlysecure.keychain.ui;
+
+import org.sufficientlysecure.keychain.R;
+
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.app.SherlockFragmentActivity;
+import com.actionbarsherlock.view.MenuItem;
+
+import android.content.Intent;
+import android.os.Bundle;
+
+public class CryptoConsumersActivity extends SherlockFragmentActivity {
+ private ActionBar mActionBar;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ mActionBar = getSupportActionBar();
+
+ setContentView(R.layout.crypto_consumers_activity);
+
+ mActionBar.setDisplayShowTitleEnabled(true);
+ mActionBar.setDisplayHomeAsUpEnabled(true);
+ }
+
+ /**
+ * Menu Options
+ */
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ // app icon in Action Bar clicked; go home
+ Intent intent = new Intent(this, MainActivity.class);
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ startActivity(intent);
+ return true;
+ default:
+ return super.onOptionsItemSelected(item);
+ }
+ }
+}
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/CryptoConsumersFragment.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/CryptoConsumersFragment.java
new file mode 100644
index 000000000..8ecc5ced1
--- /dev/null
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/CryptoConsumersFragment.java
@@ -0,0 +1,85 @@
+package org.sufficientlysecure.keychain.ui;
+
+import org.sufficientlysecure.keychain.provider.KeychainContract.CryptoConsumers;
+import org.sufficientlysecure.keychain.util.Log;
+
+import com.actionbarsherlock.app.SherlockListFragment;
+import android.database.Cursor;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.v4.app.LoaderManager;
+import android.support.v4.content.CursorLoader;
+import android.support.v4.content.Loader;
+import android.support.v4.widget.SimpleCursorAdapter;
+
+import android.view.View;
+import android.widget.ListView;
+
+public class CryptoConsumersFragment extends SherlockListFragment implements
+ LoaderManager.LoaderCallbacks<Cursor> {
+
+ // This is the Adapter being used to display the list's data.
+ SimpleCursorAdapter mAdapter;
+
+ // If non-null, this is the current filter the user has provided.
+ String mCurFilter;
+
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+
+ // Give some text to display if there is no data. In a real
+ // application this would come from a resource.
+ setEmptyText("TODO no crypto consumers");
+
+ // We have a menu item to show in action bar.
+ setHasOptionsMenu(true);
+
+ // Create an empty adapter we will use to display the loaded data.
+ mAdapter = new SimpleCursorAdapter(getActivity(), android.R.layout.simple_list_item_2,
+ null, new String[] { CryptoConsumers.PACKAGE_NAME, CryptoConsumers.PACKAGE_NAME },
+ new int[] { android.R.id.text1, android.R.id.text2 }, 0);
+ setListAdapter(mAdapter);
+
+ // Prepare the loader. Either re-connect with an existing one,
+ // or start a new one.
+ getLoaderManager().initLoader(0, null, this);
+ }
+
+ @Override
+ public void onListItemClick(ListView l, View v, int position, long id) {
+ // Insert desired behavior here.
+ Log.i("FragmentComplexList", "Item clicked: " + id);
+ }
+
+ // These are the Contacts rows that we will retrieve.
+ static final String[] CONSUMERS_SUMMARY_PROJECTION = new String[] { CryptoConsumers._ID,
+ CryptoConsumers.PACKAGE_NAME };
+
+ public Loader<Cursor> onCreateLoader(int id, Bundle args) {
+ // This is called when a new Loader needs to be created. This
+ // sample only has one Loader, so we don't care about the ID.
+ // First, pick the base URI to use depending on whether we are
+ // currently filtering.
+ Uri baseUri = CryptoConsumers.CONTENT_URI;
+
+ // Now create and return a CursorLoader that will take care of
+ // creating a Cursor for the data being displayed.
+ return new CursorLoader(getActivity(), baseUri, CONSUMERS_SUMMARY_PROJECTION, null, null,
+ CryptoConsumers.PACKAGE_NAME + " COLLATE LOCALIZED ASC");
+ }
+
+ public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
+ // Swap the new cursor in. (The framework will take care of closing the
+ // old cursor once we return.)
+ mAdapter.swapCursor(data);
+ }
+
+ public void onLoaderReset(Loader<Cursor> loader) {
+ // This is called when the last Cursor provided to onLoadFinished()
+ // above is about to be closed. We need to make sure we are no
+ // longer using it.
+ mAdapter.swapCursor(null);
+ }
+
+} \ No newline at end of file
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/MainActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/MainActivity.java
index 447801e55..a108b3db4 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/MainActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/ui/MainActivity.java
@@ -80,6 +80,9 @@ public class MainActivity extends SherlockActivity {
menu.add(0, Id.menu.option.preferences, 0, R.string.menu_preferences)
.setIcon(R.drawable.ic_menu_settings)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
+ menu.add(0, Id.menu.option.crypto_consumers, 0, R.string.menu_crypto_consumers)
+ .setIcon(R.drawable.ic_menu_settings)
+ .setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT);
return true;
}
@@ -91,6 +94,10 @@ public class MainActivity extends SherlockActivity {
startActivity(new Intent(this, PreferencesActivity.class));
return true;
+ case Id.menu.option.crypto_consumers:
+ startActivity(new Intent(this, CryptoConsumersActivity.class));
+ return true;
+
default:
break;