intent to create a new key
This commit is contained in:
@@ -125,6 +125,7 @@ public class Apg {
|
||||
public static final String GENERATE_SIGNATURE = "org.apg.intent.GENERATE_SIGNATURE";
|
||||
public static final String EXPORT_KEY_TO_SERVER = "org.apg.intent.EXPORT_KEY_TO_SERVER";
|
||||
public static final String IMPORT_FROM_QR_CODE = "org.apg.intent.IMPORT_FROM_QR_CODE";
|
||||
public static final String EDIT_KEY = "org.apg.intent.EDIT_KEY";
|
||||
}
|
||||
|
||||
public static final String EXTRA_TEXT = "text";
|
||||
@@ -153,7 +154,7 @@ public class Apg {
|
||||
public static final String EXTRA_ASCII_ARMOUR = "asciiArmour";
|
||||
public static final String EXTRA_BINARY = "binary";
|
||||
public static final String EXTRA_KEY_SERVERS = "keyServers";
|
||||
public static final String EXTRA_EXPECTED_FINGERPRINT = "org.apg.EXPECTED_FINGERPRINT";
|
||||
public static final String EXTRA_EXPECTED_FINGERPRINT = "expectedFingerprint";
|
||||
|
||||
public static final String AUTHORITY = DataProvider.AUTHORITY;
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.spongycastle.openpgp.PGPException;
|
||||
import org.spongycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.apg.R;
|
||||
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
@@ -249,6 +250,12 @@ public class DecryptActivity extends BaseActivity {
|
||||
Log.d(Constants.TAG, "got extras");
|
||||
}
|
||||
|
||||
// disable home button on actionbar because this activity is run from another app
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
||||
actionBar.setHomeButtonEnabled(false);
|
||||
|
||||
mData = extras.getByteArray(Apg.EXTRA_DATA);
|
||||
String textData = null;
|
||||
if (mData == null) {
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.spongycastle.openpgp.PGPSecretKey;
|
||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.apg.R;
|
||||
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
@@ -36,6 +37,7 @@ import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -53,6 +55,7 @@ import java.security.SignatureException;
|
||||
import java.util.Vector;
|
||||
|
||||
public class EditKeyActivity extends BaseActivity {
|
||||
private Intent mIntent = null;
|
||||
|
||||
private PGPSecretKeyRing mKeyRing = null;
|
||||
|
||||
@@ -66,12 +69,10 @@ public class EditKeyActivity extends BaseActivity {
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
menu.add(1, Id.menu.option.cancel, 0, R.string.btn_doNotSave)
|
||||
// .setIcon(R.drawable.ic_menu_search_holo_light)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
menu.add(1, Id.menu.option.save, 1, R.string.btn_save)
|
||||
// .setIcon(R.drawable.ic_suggestions_add)
|
||||
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
menu.add(1, Id.menu.option.cancel, 0, R.string.btn_doNotSave).setShowAsAction(
|
||||
MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
menu.add(1, Id.menu.option.save, 1, R.string.btn_save).setShowAsAction(
|
||||
MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -128,6 +129,26 @@ public class EditKeyActivity extends BaseActivity {
|
||||
}
|
||||
}
|
||||
|
||||
// Catch Intents opened from other apps
|
||||
mIntent = getIntent();
|
||||
if (Apg.Intent.EDIT_KEY.equals(mIntent.getAction())) {
|
||||
Bundle extras = mIntent.getExtras();
|
||||
if (extras == null) {
|
||||
extras = new Bundle();
|
||||
}
|
||||
|
||||
// disable home button on actionbar because this activity is run from another app
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
||||
actionBar.setHomeButtonEnabled(false);
|
||||
|
||||
// if userId is given, prefill the fields
|
||||
if (extras.containsKey(Apg.EXTRA_USER_IDS)) {
|
||||
userIds.add(extras.getString(Apg.EXTRA_USER_IDS));
|
||||
}
|
||||
}
|
||||
|
||||
mChangePassPhrase = (Button) findViewById(R.id.btn_change_pass_phrase);
|
||||
mChangePassPhrase.setOnClickListener(new OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
@@ -135,12 +156,7 @@ public class EditKeyActivity extends BaseActivity {
|
||||
}
|
||||
});
|
||||
|
||||
// mSaveButton = (Button) findViewById(R.id.btn_save);
|
||||
// mDiscardButton = (Button) findViewById(R.id.btn_discard);
|
||||
|
||||
// mSaveButton.setOnClickListener(this);
|
||||
// mDiscardButton.setOnClickListener(this);
|
||||
|
||||
// Build layout based on given userIds and keys
|
||||
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
|
||||
LinearLayout container = (LinearLayout) findViewById(R.id.container);
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.spongycastle.openpgp.PGPSecretKey;
|
||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.apg.R;
|
||||
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
@@ -125,15 +126,12 @@ public class EncryptActivity extends BaseActivity {
|
||||
|
||||
if (mEncryptToClipboardEnabled) {
|
||||
menu.add(1, Id.menu.option.encrypt_to_clipboard, 0, mEncryptToClipboardString)
|
||||
// .setIcon(R.drawable.ic_menu_encrypt)
|
||||
.setShowAsAction(
|
||||
MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
}
|
||||
if (mEncryptEnabled) {
|
||||
menu.add(1, Id.menu.option.encrypt, 1, mEncryptString)
|
||||
// .setIcon(R.drawable.ic_menu_decrypt)
|
||||
.setShowAsAction(
|
||||
MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
menu.add(1, Id.menu.option.encrypt, 1, mEncryptString).setShowAsAction(
|
||||
MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -233,8 +231,6 @@ public class EncryptActivity extends BaseActivity {
|
||||
|
||||
mMessage = (EditText) findViewById(R.id.message);
|
||||
mSelectKeysButton = (Button) findViewById(R.id.btn_selectEncryptKeys);
|
||||
// mEncryptButton = (Button) findViewById(R.id.btn_encrypt);
|
||||
// mEncryptToClipboardButton = (Button) findViewById(R.id.btn_encryptToClipboard);
|
||||
mSign = (CheckBox) findViewById(R.id.sign);
|
||||
mMainUserId = (TextView) findViewById(R.id.mainUserId);
|
||||
mMainUserIdRest = (TextView) findViewById(R.id.mainUserIdRest);
|
||||
@@ -317,6 +313,12 @@ public class EncryptActivity extends BaseActivity {
|
||||
extras = new Bundle();
|
||||
}
|
||||
|
||||
// disable home button on actionbar because this activity is run from another app
|
||||
final ActionBar actionBar = getSupportActionBar();
|
||||
actionBar.setDisplayShowTitleEnabled(true);
|
||||
actionBar.setDisplayHomeAsUpEnabled(false);
|
||||
actionBar.setHomeButtonEnabled(false);
|
||||
|
||||
if (Apg.Intent.ENCRYPT_AND_RETURN.equals(mIntent.getAction())
|
||||
|| Apg.Intent.GENERATE_SIGNATURE.equals(mIntent.getAction())) {
|
||||
mReturnResult = true;
|
||||
@@ -483,8 +485,6 @@ public class EncryptActivity extends BaseActivity {
|
||||
mEncryptEnabled = true;
|
||||
mEncryptToClipboardEnabled = false;
|
||||
|
||||
// mEncryptToClipboardButton.setVisibility(View.INVISIBLE);
|
||||
// mEncryptButton.setText(R.string.btn_encrypt);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Vector;
|
||||
import org.apg.Apg;
|
||||
import org.apg.Id;
|
||||
import org.apg.R;
|
||||
import org.apg.ui.widget.SelectPublicKeyListAdapter;
|
||||
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.apg.ui;
|
||||
import org.apg.Apg;
|
||||
import org.apg.Id;
|
||||
import org.apg.R;
|
||||
import org.apg.ui.widget.SelectSecretKeyListAdapter;
|
||||
|
||||
import com.actionbarsherlock.app.ActionBar;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apg.ui;
|
||||
package org.apg.ui.widget;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apg.ui;
|
||||
package org.apg.ui.widget;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@@ -40,9 +40,12 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene
|
||||
private EditText mEmail;
|
||||
private EditText mComment;
|
||||
|
||||
private static final Pattern EMAIL_PATTERN = Pattern.compile(
|
||||
"^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+[.]([a-zA-Z])+([a-zA-Z])+",
|
||||
Pattern.CASE_INSENSITIVE);
|
||||
// see http://www.regular-expressions.info/email.html
|
||||
// RFC 2822 if we omit the syntax using double quotes and square brackets
|
||||
private static final Pattern EMAIL_PATTERN = Pattern
|
||||
.compile(
|
||||
"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?",
|
||||
Pattern.CASE_INSENSITIVE);
|
||||
|
||||
public static class NoNameException extends Exception {
|
||||
static final long serialVersionUID = 0xf812773343L;
|
||||
|
||||
Reference in New Issue
Block a user