diff options
author | Thialfihar <thialfihar@gmail.com> | 2010-05-09 13:29:30 +0000 |
---|---|---|
committer | Thialfihar <thialfihar@gmail.com> | 2010-05-09 13:29:30 +0000 |
commit | 73888622f4d4d73c80cf877444dade3cf9470831 (patch) | |
tree | ff9cf653f1e7962e033b09c385768b7dcce5ef58 /src/org/thialfihar/android/apg/EncryptMessageActivity.java | |
parent | 2e1aad0f81c1511c741b391b4d8254f92ba56271 (diff) | |
download | open-keychain-73888622f4d4d73c80cf877444dade3cf9470831.tar.gz open-keychain-73888622f4d4d73c80cf877444dade3cf9470831.tar.bz2 open-keychain-73888622f4d4d73c80cf877444dade3cf9470831.zip |
added a button to encrypt to clipboard, change log and about window got their own layout now with proper linkification
Diffstat (limited to 'src/org/thialfihar/android/apg/EncryptMessageActivity.java')
-rw-r--r-- | src/org/thialfihar/android/apg/EncryptMessageActivity.java | 63 |
1 files changed, 51 insertions, 12 deletions
diff --git a/src/org/thialfihar/android/apg/EncryptMessageActivity.java b/src/org/thialfihar/android/apg/EncryptMessageActivity.java index 6e88253a1..3e49d7c50 100644 --- a/src/org/thialfihar/android/apg/EncryptMessageActivity.java +++ b/src/org/thialfihar/android/apg/EncryptMessageActivity.java @@ -34,6 +34,7 @@ import org.bouncycastle2.util.Strings; import android.content.Intent; import android.os.Bundle; import android.os.Message; +import android.text.ClipboardManager; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; @@ -50,11 +51,14 @@ public class EncryptMessageActivity extends BaseActivity { private EditText mMessage = null; private Button mSelectKeysButton = null; + private Button mEncryptButton = null; private Button mSendButton = null; private CheckBox mSign = null; private TextView mMainUserId = null; private TextView mMainUserIdRest = null; + private int mEncryptTarget; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -62,6 +66,7 @@ public class EncryptMessageActivity extends BaseActivity { mMessage = (EditText) findViewById(R.id.message); mSelectKeysButton = (Button) findViewById(R.id.btn_selectEncryptKeys); + mEncryptButton = (Button) findViewById(R.id.btn_encrypt_to_clipboard); mSendButton = (Button) findViewById(R.id.btn_send); mSign = (CheckBox) findViewById(R.id.sign); mMainUserId = (TextView) findViewById(R.id.main_user_id); @@ -119,6 +124,13 @@ public class EncryptMessageActivity extends BaseActivity { } } + mEncryptButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + encryptClicked(); + } + }); + mSendButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { @@ -150,7 +162,17 @@ public class EncryptMessageActivity extends BaseActivity { updateView(); } + private void encryptClicked() { + mEncryptTarget = Id.target.clipboard; + if (getSecretKeyId() != 0 && Apg.getPassPhrase() == null) { + showDialog(Id.dialog.pass_phrase); + } else { + encryptStart(); + } + } + private void sendClicked() { + mEncryptTarget = Id.target.email; if (getSecretKeyId() != 0 && Apg.getPassPhrase() == null) { showDialog(Id.dialog.pass_phrase); } else { @@ -322,19 +344,36 @@ public class EncryptMessageActivity extends BaseActivity { return; } else { String message = data.getString("message"); - Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); - emailIntent.setType("text/plain; charset=utf-8"); - emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message); - if (mSubject != null) { - emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, - mSubject); - } - if (mSendTo != null) { - emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, - new String[] { mSendTo }); + switch (mEncryptTarget) { + case Id.target.clipboard: { + ClipboardManager clip = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); + clip.setText(message); + Toast.makeText(this, "Successfully encrypted to clipboard.", + Toast.LENGTH_SHORT).show(); + break; + } + + case Id.target.email: { + Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); + emailIntent.setType("text/plain; charset=utf-8"); + emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, message); + if (mSubject != null) { + emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, + mSubject); + } + if (mSendTo != null) { + emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, + new String[] { mSendTo }); + } + EncryptMessageActivity.this. + startActivity(Intent.createChooser(emailIntent, "Send mail...")); + } + + default: { + // shouldn't happen + break; + } } - EncryptMessageActivity.this. - startActivity(Intent.createChooser(emailIntent, "Send mail...")); } } }
\ No newline at end of file |