diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index f9a9e3f13..6a794b1b9 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -96,18 +96,6 @@
android:label="@string/title_decrypt"
android:configChanges="keyboardHidden|orientation|keyboard">
-
-
-
-
-
-
-
-
-
-
-
-
@@ -118,6 +106,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/layout/main.xml b/res/layout/main.xml
index f88c393db..3603f656e 100644
--- a/res/layout/main.xml
+++ b/res/layout/main.xml
@@ -50,14 +50,14 @@
@@ -71,14 +71,14 @@
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 72c1d1f9c..e4f89baf5 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -243,5 +243,12 @@
Read key details from APG.
Read of public and secret keys stored in APG, such as key ID and user IDs. The keys themselves can NOT be read.
+
+ Encrypt
+ Decrypt
+ Import Public Keys
+ Import Secret Keys
+
+
diff --git a/src/org/thialfihar/android/apg/GeneralActivity.java b/src/org/thialfihar/android/apg/GeneralActivity.java
new file mode 100644
index 000000000..1a80368aa
--- /dev/null
+++ b/src/org/thialfihar/android/apg/GeneralActivity.java
@@ -0,0 +1,141 @@
+package org.thialfihar.android.apg;
+
+import java.io.ByteArrayInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.Vector;
+
+import org.thialfihar.android.apg.utils.Choice;
+
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.Button;
+import android.widget.ListView;
+import android.widget.Toast;
+import android.widget.AdapterView.OnItemClickListener;
+
+public class GeneralActivity extends BaseActivity {
+ private Intent mIntent;
+ private ArrayAdapter mAdapter;
+ private ListView mList;
+ private Button mCancelButton;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.general);
+
+ mIntent = getIntent();
+
+ boolean isEncrypted = false;
+ boolean containsKeys = false;
+
+ InputStream inStream = null;
+ {
+ byte[] data = mIntent.getByteArrayExtra(Intent.EXTRA_TEXT);
+ if (data != null) {
+ inStream = new ByteArrayInputStream(data);
+ }
+ }
+
+ if (inStream == null) {
+ Uri data = mIntent.getData();
+ if (data != null) {
+ try {
+ inStream = getContentResolver().openInputStream(data);
+ } catch (FileNotFoundException e) {
+ // didn't work
+ Toast.makeText(this, "failed to open stream", Toast.LENGTH_SHORT);
+ }
+ }
+ }
+
+ if (inStream == null) {
+ Toast.makeText(this, "no data found", Toast.LENGTH_SHORT);
+ finish();
+ return;
+ }
+
+ mList = (ListView) findViewById(R.id.options);
+ Vector choices = new Vector();
+
+ if (containsKeys) {
+ choices.add(new Choice(Id.choice.action.import_public, getString(R.string.action_import_public)));
+ choices.add(new Choice(Id.choice.action.import_secret, getString(R.string.action_import_secret)));
+ }
+
+ if (isEncrypted) {
+ choices.add(new Choice(Id.choice.action.decrypt, getString(R.string.action_decrypt)));
+ }
+
+ if (!containsKeys && !isEncrypted) {
+ choices.add(new Choice(Id.choice.action.encrypt, getString(R.string.action_encrypt)));
+ }
+
+ mAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, choices);
+ mList.setAdapter(mAdapter);
+
+ mList.setOnItemClickListener(new OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView> arg0, View arg1, int arg2, long arg3) {
+ clicked(mAdapter.getItem(arg2).getId());
+ }
+ });
+
+ mCancelButton = (Button) findViewById(R.id.btn_cancel);
+ mCancelButton.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ GeneralActivity.this.finish();
+ }
+ });
+
+ if (choices.size() == 1) {
+ clicked(choices.get(0).getId());
+ }
+ }
+
+ private void clicked(int id) {
+ Intent intent = new Intent();
+ switch (id) {
+ case Id.choice.action.encrypt: {
+ intent.setClass(this, EncryptActivity.class);
+ if (mIntent.hasExtra(Intent.EXTRA_TEXT)) {
+ intent.putExtra(Intent.EXTRA_TEXT, mIntent.getByteArrayExtra(Intent.EXTRA_TEXT));
+ } else if (mIntent.getData() != null) {
+ intent.setData(mIntent.getData());
+ intent.setType(mIntent.getType());
+ }
+
+ break;
+ }
+
+ case Id.choice.action.decrypt: {
+ break;
+ }
+
+ case Id.choice.action.import_public: {
+ break;
+ }
+
+ case Id.choice.action.import_secret: {
+ break;
+ }
+
+ default: {
+ // shouldn't happen
+ return;
+ }
+ }
+
+ startActivity(intent);
+ finish();
+ }
+}
diff --git a/src/org/thialfihar/android/apg/Id.java b/src/org/thialfihar/android/apg/Id.java
index 4567f937d..73d4ddc85 100644
--- a/src/org/thialfihar/android/apg/Id.java
+++ b/src/org/thialfihar/android/apg/Id.java
@@ -111,6 +111,13 @@ public final class Id {
public static final int encrypt_only = 0x21070002;
public static final int sign_and_encrypt = 0x21070003;
}
+
+ public static final class action {
+ public static final int encrypt = 0x21070001;
+ public static final int decrypt = 0x21070002;
+ public static final int import_public = 0x21070003;
+ public static final int import_secret = 0x21070004;
+ }
}
public static final class return_value {