aboutsummaryrefslogtreecommitdiffstats
path: root/org_apg/src/org
diff options
context:
space:
mode:
authorDominik <dominik@dominikschuermann.de>2012-03-12 15:10:26 +0100
committerDominik <dominik@dominikschuermann.de>2012-03-12 15:10:26 +0100
commit518fc2a310942809d77b2577276d0f855ff403e3 (patch)
treec3ffaa972af6a4422d2ab324bf6bbb5b8025a69c /org_apg/src/org
parent87e456e77c570f3e17cfdadf5db23cd1733033ea (diff)
downloadopen-keychain-518fc2a310942809d77b2577276d0f855ff403e3.tar.gz
open-keychain-518fc2a310942809d77b2577276d0f855ff403e3.tar.bz2
open-keychain-518fc2a310942809d77b2577276d0f855ff403e3.zip
help activity
Diffstat (limited to 'org_apg/src/org')
-rw-r--r--org_apg/src/org/apg/Id.java2
-rw-r--r--org_apg/src/org/apg/ui/DecryptActivity.java64
-rw-r--r--org_apg/src/org/apg/ui/HelpActivity.java79
-rw-r--r--org_apg/src/org/apg/ui/MainActivity.java3
-rw-r--r--org_apg/src/org/apg/util/Utils.java54
5 files changed, 177 insertions, 25 deletions
diff --git a/org_apg/src/org/apg/Id.java b/org_apg/src/org/apg/Id.java
index f64038e48..6b721d3a8 100644
--- a/org_apg/src/org/apg/Id.java
+++ b/org_apg/src/org/apg/Id.java
@@ -47,7 +47,7 @@ public final class Id {
public static final int encrypt = 0x21070013;
public static final int encrypt_to_clipboard = 0x21070014;
public static final int decrypt = 0x21070015;
- public static final int decrypt_to_clipboard = 0x21070016;
+ public static final int reply = 0x21070016;
public static final int cancel = 0x21070017;
public static final int save = 0x21070018;
diff --git a/org_apg/src/org/apg/ui/DecryptActivity.java b/org_apg/src/org/apg/ui/DecryptActivity.java
index 2809a31d5..53df18867 100644
--- a/org_apg/src/org/apg/ui/DecryptActivity.java
+++ b/org_apg/src/org/apg/ui/DecryptActivity.java
@@ -117,13 +117,13 @@ public class DecryptActivity extends BaseActivity {
public boolean onCreateOptionsMenu(Menu menu) {
if (mDecryptEnabled) {
- menu.add(1, Id.menu.option.encrypt_to_clipboard, 0, mDecryptString)
+ menu.add(1, Id.menu.option.decrypt, 0, mDecryptString)
// .setIcon(R.drawable.ic_menu_encrypt)
.setShowAsAction(
MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
}
if (mReplyEnabled) {
- menu.add(1, Id.menu.option.encrypt, 1, mReplyString)
+ menu.add(1, Id.menu.option.reply, 1, mReplyString)
// .setIcon(R.drawable.ic_menu_decrypt)
.setShowAsAction(
MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
@@ -133,6 +133,26 @@ public class DecryptActivity extends BaseActivity {
}
@Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case Id.menu.option.decrypt: {
+ decryptClicked();
+
+ return true;
+ }
+ case Id.menu.option.reply: {
+ replyClicked();
+
+ return true;
+ }
+
+ default: {
+ return super.onOptionsItemSelected(item);
+ }
+ }
+ }
+
+ @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.decrypt);
@@ -171,8 +191,6 @@ public class DecryptActivity extends BaseActivity {
mSourceLabel.setOnClickListener(nextSourceClickListener);
mMessage = (EditText) findViewById(R.id.message);
- // mDecryptButton = (Button) findViewById(R.id.btn_decrypt);
- // mReplyButton = (Button) findViewById(R.id.btn_reply);
mSignatureLayout = (LinearLayout) findViewById(R.id.signature);
mSignatureStatusImage = (ImageView) findViewById(R.id.ic_signature_status);
mUserId = (TextView) findViewById(R.id.mainUserId);
@@ -258,6 +276,9 @@ public class DecryptActivity extends BaseActivity {
mMessage.setText(textData);
mDecryptString = getString(R.string.btn_verify);
// mDecryptButton.setText(R.string.btn_verify);
+
+ // build new action bar
+ invalidateOptionsMenu();
} else {
Log.d(Constants.TAG, "Nothing matched!");
}
@@ -305,7 +326,8 @@ public class DecryptActivity extends BaseActivity {
mMessage.setText(data);
mDecryptString = getString(R.string.btn_verify);
- // mDecryptButton.setText(R.string.btn_verify);
+ // build new action bar
+ invalidateOptionsMenu();
}
}
}
@@ -348,21 +370,11 @@ public class DecryptActivity extends BaseActivity {
}
});
- // mDecryptButton.setOnClickListener(new OnClickListener() {
- // public void onClick(View v) {
- // decryptClicked();
- // }
- // });
- //
- // mReplyButton.setOnClickListener(new OnClickListener() {
- // public void onClick(View v) {
- // replyClicked();
- // }
- // });
- // mReplyButton.setVisibility(View.INVISIBLE);
-
mReplyEnabled = false;
+ // build new actionbar
+ invalidateOptionsMenu();
+
if (mReturnResult) {
mSourcePrevious.setClickable(false);
mSourcePrevious.setEnabled(false);
@@ -381,6 +393,7 @@ public class DecryptActivity extends BaseActivity {
if (mSource.getCurrentView().getId() == R.id.sourceMessage
&& (mMessage.getText().length() > 0 || mData != null || mContentUri != null)) {
// mDecryptButton.performClick();
+ // TODO: why was it performClick()???
decryptClicked();
}
}
@@ -416,16 +429,19 @@ public class DecryptActivity extends BaseActivity {
switch (mSource.getCurrentView().getId()) {
case R.id.sourceFile: {
mSourceLabel.setText(R.string.label_file);
- // mDecryptButton.setText(R.string.btn_decrypt);
mDecryptString = getString(R.string.btn_decrypt);
+
+ // build new action bar
+ invalidateOptionsMenu();
break;
}
case R.id.sourceMessage: {
mSourceLabel.setText(R.string.label_message);
- // mDecryptButton.setText(R.string.btn_decrypt);
mDecryptString = getString(R.string.btn_decrypt);
+ // build new action bar
+ invalidateOptionsMenu();
break;
}
@@ -633,9 +649,11 @@ public class DecryptActivity extends BaseActivity {
removeDialog(Id.dialog.decrypting);
mSignatureKeyId = 0;
mSignatureLayout.setVisibility(View.GONE);
- // mReplyButton.setVisibility(View.INVISIBLE);
mReplyEnabled = false;
+ // build new action bar
+ invalidateOptionsMenu();
+
String error = data.getString(Apg.EXTRA_ERROR);
if (error != null) {
Toast.makeText(this, getString(R.string.errorMessage, error), Toast.LENGTH_SHORT)
@@ -657,8 +675,10 @@ public class DecryptActivity extends BaseActivity {
String decryptedMessage = data.getString(Apg.EXTRA_DECRYPTED_MESSAGE);
mMessage.setText(decryptedMessage);
mMessage.setHorizontallyScrolling(false);
- // mReplyButton.setVisibility(View.VISIBLE);
mReplyEnabled = false;
+
+ // build new action bar
+ invalidateOptionsMenu();
break;
}
diff --git a/org_apg/src/org/apg/ui/HelpActivity.java b/org_apg/src/org/apg/ui/HelpActivity.java
new file mode 100644
index 000000000..9a4dc7f76
--- /dev/null
+++ b/org_apg/src/org/apg/ui/HelpActivity.java
@@ -0,0 +1,79 @@
+/*
+ * 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.ui;
+
+import org.apg.R;
+import org.apg.util.Utils;
+
+import com.actionbarsherlock.app.ActionBar;
+import com.actionbarsherlock.app.SherlockActivity;
+import com.actionbarsherlock.view.MenuItem;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.text.Html;
+import android.text.method.LinkMovementMethod;
+import android.widget.TextView;
+
+public class HelpActivity extends SherlockActivity {
+ Activity mActivity;
+ TextView mHelpText;
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+
+ case android.R.id.home:
+ startActivity(new Intent(this, MainActivity.class));
+ return true;
+
+ default:
+ break;
+
+ }
+ return false;
+ }
+
+ /**
+ * Instantiate View for this Activity
+ */
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.help_activity);
+
+ final ActionBar actionBar = getSupportActionBar();
+ actionBar.setDisplayShowTitleEnabled(true);
+ actionBar.setDisplayHomeAsUpEnabled(true);
+
+ mActivity = this;
+
+ mHelpText = (TextView) findViewById(R.id.help_text);
+
+ // load html from html file from /res/raw
+ String helpText = Utils.readContentFromResource(mActivity, R.raw.help);
+
+ // set text from resources with html markup
+ mHelpText.setText(Html.fromHtml(helpText));
+ // make links work
+ mHelpText.setMovementMethod(LinkMovementMethod.getInstance());
+
+ }
+
+}
diff --git a/org_apg/src/org/apg/ui/MainActivity.java b/org_apg/src/org/apg/ui/MainActivity.java
index e096f477a..f19c76ad7 100644
--- a/org_apg/src/org/apg/ui/MainActivity.java
+++ b/org_apg/src/org/apg/ui/MainActivity.java
@@ -46,7 +46,6 @@ public class MainActivity extends BaseActivity {
public void myKeysOnClick(View view) {
startActivity(new Intent(this, SecretKeyListActivity.class));
-
}
public void encryptOnClick(View view) {
@@ -68,7 +67,7 @@ public class MainActivity extends BaseActivity {
}
public void helpOnClick(View view) {
- // TODO: implement help view
+ startActivity(new Intent(this, HelpActivity.class));
}
@Override
diff --git a/org_apg/src/org/apg/util/Utils.java b/org_apg/src/org/apg/util/Utils.java
new file mode 100644
index 000000000..45b18afd1
--- /dev/null
+++ b/org_apg/src/org/apg/util/Utils.java
@@ -0,0 +1,54 @@
+/*
+ * 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.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import android.content.Context;
+
+public class Utils {
+
+ /**
+ * Reads html files from /res/raw/example.html to output them as string. See
+ * http://www.monocube.com/2011/02/08/android-tutorial-html-file-in-webview/
+ *
+ * @param context
+ * current context
+ * @param resourceID
+ * of html file to read
+ * @return content of html file with formatting
+ */
+ public static String readContentFromResource(Context context, int resourceID) {
+ InputStream raw = context.getResources().openRawResource(resourceID);
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ int i;
+ try {
+ i = raw.read();
+ while (i != -1) {
+ stream.write(i);
+ i = raw.read();
+ }
+ raw.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return stream.toString();
+ }
+
+}