aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain
diff options
context:
space:
mode:
Diffstat (limited to 'OpenPGP-Keychain')
-rw-r--r--OpenPGP-Keychain/res/layout/crypto_consumer_list_activity.xml (renamed from OpenPGP-Keychain/res/layout/crypto_consumers_activity.xml)0
-rw-r--r--OpenPGP-Keychain/res/layout/crypto_consumer_register_activity.xml102
-rw-r--r--OpenPGP-Keychain/res/layout/decrypt.xml1
-rw-r--r--OpenPGP-Keychain/res/layout/register_crypto_consumer_activity.xml25
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoConsumersActivity.java2
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java6
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/IServiceActivityCallback.aidl8
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java50
8 files changed, 147 insertions, 47 deletions
diff --git a/OpenPGP-Keychain/res/layout/crypto_consumers_activity.xml b/OpenPGP-Keychain/res/layout/crypto_consumer_list_activity.xml
index b314173eb..b314173eb 100644
--- a/OpenPGP-Keychain/res/layout/crypto_consumers_activity.xml
+++ b/OpenPGP-Keychain/res/layout/crypto_consumer_list_activity.xml
diff --git a/OpenPGP-Keychain/res/layout/crypto_consumer_register_activity.xml b/OpenPGP-Keychain/res/layout/crypto_consumer_register_activity.xml
new file mode 100644
index 000000000..3af373956
--- /dev/null
+++ b/OpenPGP-Keychain/res/layout/crypto_consumer_register_activity.xml
@@ -0,0 +1,102 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical" >
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:paddingBottom="3dip" >
+
+ <TextView
+ android:id="@+id/register_crypto_consumer_select_key"
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:layout_weight="1"
+ android:text="Select key"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <Button
+ android:id="@+id/register_crypto_consumer_select_key_button"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:text="TD Select priv key" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal" >
+
+ <CheckBox
+ android:id="@+id/asciiArmour"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_vertical"
+ android:text="@string/label_asciiArmour" />
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/register_crypto_consumer_register_layout"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:paddingBottom="3dip" >
+
+ <TextView
+ android:id="@+id/register_crypto_consumer_question"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="Package TODO requests permanent access to OpenPGP Keychain\&apos;s API. Allow permanent access?"
+ android:textAppearance="?android:attr/textAppearanceMedium" />
+
+ <LinearLayout
+ android:id="@+id/register_crypto_consumer_register_layout"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:paddingBottom="3dip" >
+
+ <Button
+ android:id="@+id/register_crypto_consumer_disallow"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="Disallow access" />
+
+ <Button
+ android:id="@+id/register_crypto_consumer_allow"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="Allow access" />
+ </LinearLayout>
+ </LinearLayout>
+
+ <LinearLayout
+ android:id="@+id/register_crypto_consumer_edit_layout"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal"
+ android:paddingBottom="3dip" >
+
+ <Button
+ android:id="@+id/register_crypto_consumer_disallow"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="Revoke access" />
+
+ <Button
+ android:id="@+id/register_crypto_consumer_allow"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:text="Save" />
+ </LinearLayout>
+
+</LinearLayout> \ No newline at end of file
diff --git a/OpenPGP-Keychain/res/layout/decrypt.xml b/OpenPGP-Keychain/res/layout/decrypt.xml
index 4901536ae..84f1fc298 100644
--- a/OpenPGP-Keychain/res/layout/decrypt.xml
+++ b/OpenPGP-Keychain/res/layout/decrypt.xml
@@ -22,7 +22,6 @@
android:orientation="vertical" >
<ScrollView
- xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
diff --git a/OpenPGP-Keychain/res/layout/register_crypto_consumer_activity.xml b/OpenPGP-Keychain/res/layout/register_crypto_consumer_activity.xml
deleted file mode 100644
index 24a64f1ac..000000000
--- a/OpenPGP-Keychain/res/layout/register_crypto_consumer_activity.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
-
- <TextView
- android:id="@+id/textView1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Register?" />
-
- <Button
- android:id="@+id/register_crypto_consumer_allow"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Allow access" />
-
- <Button
- android:id="@+id/register_crypto_consumer_disallow"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Disallow" />
-
-</LinearLayout> \ No newline at end of file
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoConsumersActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoConsumersActivity.java
index e3aa0ed49..3f12a5e8b 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoConsumersActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoConsumersActivity.java
@@ -19,7 +19,7 @@ public class CryptoConsumersActivity extends SherlockFragmentActivity {
mActionBar = getSupportActionBar();
- setContentView(R.layout.crypto_consumers_activity);
+ setContentView(R.layout.crypto_consumer_list_activity);
mActionBar.setDisplayShowTitleEnabled(true);
mActionBar.setDisplayHomeAsUpEnabled(true);
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
index c7d40d376..71b78ee01 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
@@ -263,7 +263,7 @@ public class CryptoService extends Service {
private final IServiceActivityCallback.Stub mBinderServiceActivity = new IServiceActivityCallback.Stub() {
@Override
- public void register(boolean success, String packageName) throws RemoteException {
+ public void onRegistered(boolean success, String packageName) throws RemoteException {
if (success) {
// resume threads
@@ -280,7 +280,7 @@ public class CryptoService extends Service {
}
@Override
- public void cachePassphrase(boolean success, String passphrase) throws RemoteException {
+ public void onCachedPassphrase(boolean success) throws RemoteException {
}
@@ -355,8 +355,6 @@ public class CryptoService extends Service {
Log.d(Constants.TAG, "starting activity...");
Intent intent = new Intent(getBaseContext(), ServiceActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- // intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
- // intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
intent.setAction(action);
if (extras != null) {
intent.putExtras(extras);
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/IServiceActivityCallback.aidl b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/IServiceActivityCallback.aidl
index 871560cc8..e9949e1ae 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/IServiceActivityCallback.aidl
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/IServiceActivityCallback.aidl
@@ -19,10 +19,8 @@ package org.sufficientlysecure.keychain.remote_api;
interface IServiceActivityCallback {
+ oneway void onRegistered(in boolean success, in String packageName);
- oneway void register(in boolean success, in String packageName);
-
- oneway void cachePassphrase(in boolean success, in String passphrase);
-
-
+ oneway void onCachedPassphrase(in boolean success);
+
} \ No newline at end of file
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java
index 055de9be1..981568944 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/ServiceActivity.java
@@ -16,6 +16,8 @@
package org.sufficientlysecure.keychain.remote_api;
+import java.util.ArrayList;
+
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.remote_api.IServiceActivityCallback;
@@ -35,30 +37,32 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;
+import android.os.RemoteException;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
+import android.widget.LinearLayout;
public class ServiceActivity extends SherlockFragmentActivity {
- public static final String ACTION_REGISTER = "org.sufficientlysecure.keychain.REGISTER";
- public static final String ACTION_CACHE_PASSPHRASE = "org.sufficientlysecure.keychain.CRYPTO_CACHE_PASSPHRASE";
+ public static final String ACTION_REGISTER = "org.sufficientlysecure.keychain.remote_api.REGISTER";
+ public static final String ACTION_CACHE_PASSPHRASE = "org.sufficientlysecure.keychain.remote_api.CRYPTO_CACHE_PASSPHRASE";
public static final String EXTRA_SECRET_KEY_ID = "secretKeyId";
public static final String EXTRA_PACKAGE_NAME = "packageName";
- private IServiceActivityCallback mService;
+ private IServiceActivityCallback mServiceCallback;
private boolean mServiceBound;
private ServiceConnection mServiceActivityConnection = new ServiceConnection() {
public void onServiceConnected(ComponentName name, IBinder service) {
- mService = IServiceActivityCallback.Stub.asInterface(service);
+ mServiceCallback = IServiceActivityCallback.Stub.asInterface(service);
Log.d(Constants.TAG, "connected to ICryptoServiceActivity");
mServiceBound = true;
}
public void onServiceDisconnected(ComponentName name) {
- mService = null;
+ mServiceCallback = null;
Log.d(Constants.TAG, "disconnected from ICryptoServiceActivity");
mServiceBound = false;
}
@@ -70,7 +74,7 @@ public class ServiceActivity extends SherlockFragmentActivity {
* @return
*/
public boolean bindToService() {
- if (mService == null && !mServiceBound) { // if not already connected
+ if (mServiceCallback == null && !mServiceBound) { // if not already connected
try {
Log.d(Constants.TAG, "not bound yet");
@@ -129,7 +133,20 @@ public class ServiceActivity extends SherlockFragmentActivity {
if (ACTION_REGISTER.equals(action)) {
final String packageName = extras.getString(EXTRA_PACKAGE_NAME);
- setContentView(R.layout.register_crypto_consumer_activity);
+ setContentView(R.layout.crypto_consumer_register_activity);
+ LinearLayout layoutRegister = (LinearLayout) findViewById(R.id.register_crypto_consumer_register_layout);
+ LinearLayout layoutEdit = (LinearLayout) findViewById(R.id.register_crypto_consumer_edit_layout);
+
+ // if already registered show edit buttons
+ ArrayList<String> allowedPkgs = ProviderHelper.getCryptoConsumers(this);
+ if (allowedPkgs.contains(packageName)) {
+ Log.d(Constants.TAG, "Package is allowed! packageName: " + packageName);
+ layoutRegister.setVisibility(View.GONE);
+ layoutEdit.setVisibility(View.VISIBLE);
+ } else {
+ layoutRegister.setVisibility(View.VISIBLE);
+ layoutEdit.setVisibility(View.GONE);
+ }
Button allowButton = (Button) findViewById(R.id.register_crypto_consumer_allow);
Button disallowButton = (Button) findViewById(R.id.register_crypto_consumer_disallow);
@@ -141,7 +158,11 @@ public class ServiceActivity extends SherlockFragmentActivity {
ProviderHelper.addCryptoConsumer(ServiceActivity.this, packageName);
// Intent data = new Intent();
- setResult(RESULT_OK);
+ try {
+ mServiceCallback.onRegistered(true, packageName);
+ } catch (RemoteException e) {
+ Log.e(Constants.TAG, "ServiceActivity");
+ }
finish();
}
});
@@ -150,7 +171,11 @@ public class ServiceActivity extends SherlockFragmentActivity {
@Override
public void onClick(View v) {
- setResult(RESULT_CANCELED);
+ try {
+ mServiceCallback.onRegistered(false, packageName);
+ } catch (RemoteException e) {
+ Log.e(Constants.TAG, "ServiceActivity");
+ }
finish();
}
});
@@ -160,7 +185,6 @@ public class ServiceActivity extends SherlockFragmentActivity {
showPassphraseDialog(secretKeyId);
} else {
Log.e(Constants.TAG, "Wrong action!");
- setResult(RESULT_CANCELED);
finish();
}
}
@@ -176,7 +200,11 @@ public class ServiceActivity extends SherlockFragmentActivity {
@Override
public void handleMessage(Message message) {
if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) {
- setResult(RESULT_OK);
+ try {
+ mServiceCallback.onCachedPassphrase(true);
+ } catch (RemoteException e) {
+ Log.e(Constants.TAG, "ServiceActivity");
+ }
finish();
}
}