diff options
author | Dominik <dominik@dominikschuermann.de> | 2012-04-12 15:23:00 +0200 |
---|---|---|
committer | Dominik <dominik@dominikschuermann.de> | 2012-06-13 19:28:22 +0300 |
commit | 1a33f4d886ce45596dd7f6dfc3356fe32ec71c1c (patch) | |
tree | f59a5b0dd99581bfd7615bd56df869420540c769 /org_apg | |
parent | dfa4e084dd885a875763014bd18e698325bf576e (diff) | |
download | open-keychain-1a33f4d886ce45596dd7f6dfc3356fe32ec71c1c.tar.gz open-keychain-1a33f4d886ce45596dd7f6dfc3356fe32ec71c1c.tar.bz2 open-keychain-1a33f4d886ce45596dd7f6dfc3356fe32ec71c1c.zip |
intent to create a new key
Diffstat (limited to 'org_apg')
-rw-r--r-- | org_apg/AndroidManifest.xml | 8 | ||||
-rw-r--r-- | org_apg/res/layout/edit_key.xml | 22 | ||||
-rw-r--r-- | org_apg/src/org/apg/Apg.java | 3 | ||||
-rw-r--r-- | org_apg/src/org/apg/ui/DecryptActivity.java | 7 | ||||
-rw-r--r-- | org_apg/src/org/apg/ui/EditKeyActivity.java | 40 | ||||
-rw-r--r-- | org_apg/src/org/apg/ui/EncryptActivity.java | 18 | ||||
-rw-r--r-- | org_apg/src/org/apg/ui/SelectPublicKeyListActivity.java | 1 | ||||
-rw-r--r-- | org_apg/src/org/apg/ui/SelectSecretKeyListActivity.java | 1 | ||||
-rw-r--r-- | org_apg/src/org/apg/ui/widget/SelectPublicKeyListAdapter.java (renamed from org_apg/src/org/apg/ui/SelectPublicKeyListAdapter.java) | 2 | ||||
-rw-r--r-- | org_apg/src/org/apg/ui/widget/SelectSecretKeyListAdapter.java (renamed from org_apg/src/org/apg/ui/SelectSecretKeyListAdapter.java) | 2 | ||||
-rw-r--r-- | org_apg/src/org/apg/ui/widget/UserIdEditor.java | 9 |
11 files changed, 63 insertions, 50 deletions
diff --git a/org_apg/AndroidManifest.xml b/org_apg/AndroidManifest.xml index 2f250ae1a..60c76079b 100644 --- a/org_apg/AndroidManifest.xml +++ b/org_apg/AndroidManifest.xml @@ -75,7 +75,13 @@ android:name=".ui.EditKeyActivity" android:configChanges="keyboardHidden|orientation|keyboard" android:label="@string/title_editKey" - android:uiOptions="splitActionBarWhenNarrow" /> + android:uiOptions="splitActionBarWhenNarrow" > + <intent-filter> + <action android:name="org.apg.intent.EDIT_KEY" /> + + <category android:name="android.intent.category.DEFAULT" /> + </intent-filter> + </activity> <activity android:name=".ui.SelectPublicKeyListActivity" android:configChanges="keyboardHidden|orientation|keyboard" diff --git a/org_apg/res/layout/edit_key.xml b/org_apg/res/layout/edit_key.xml index c93899bdf..de004f0b5 100644 --- a/org_apg/res/layout/edit_key.xml +++ b/org_apg/res/layout/edit_key.xml @@ -62,26 +62,4 @@ </ScrollView> -<!-- <LinearLayout --> -<!-- android:layout_width="fill_parent" --> -<!-- android:layout_height="wrap_content" --> -<!-- android:orientation="horizontal" --> -<!-- style="@android:style/ButtonBar"> --> - -<!-- <Button --> -<!-- android:id="@+id/btn_save" --> -<!-- android:layout_width="0dip" --> -<!-- android:layout_height="fill_parent" --> -<!-- android:layout_weight="1" --> -<!-- android:text="@string/btn_save"/> --> - -<!-- <Button --> -<!-- android:id="@+id/btn_discard" --> -<!-- android:layout_width="0dip" --> -<!-- android:layout_height="fill_parent" --> -<!-- android:layout_weight="1" --> -<!-- android:text="@string/btn_doNotSave"/> --> - -<!-- </LinearLayout> --> - </LinearLayout> diff --git a/org_apg/src/org/apg/Apg.java b/org_apg/src/org/apg/Apg.java index e3a2b5eb8..dbe60e65e 100644 --- a/org_apg/src/org/apg/Apg.java +++ b/org_apg/src/org/apg/Apg.java @@ -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; diff --git a/org_apg/src/org/apg/ui/DecryptActivity.java b/org_apg/src/org/apg/ui/DecryptActivity.java index 53df18867..b1726194b 100644 --- a/org_apg/src/org/apg/ui/DecryptActivity.java +++ b/org_apg/src/org/apg/ui/DecryptActivity.java @@ -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) { diff --git a/org_apg/src/org/apg/ui/EditKeyActivity.java b/org_apg/src/org/apg/ui/EditKeyActivity.java index 8f7a642f9..b0e59a7bf 100644 --- a/org_apg/src/org/apg/ui/EditKeyActivity.java +++ b/org_apg/src/org/apg/ui/EditKeyActivity.java @@ -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); diff --git a/org_apg/src/org/apg/ui/EncryptActivity.java b/org_apg/src/org/apg/ui/EncryptActivity.java index a4194d778..c437ebe27 100644 --- a/org_apg/src/org/apg/ui/EncryptActivity.java +++ b/org_apg/src/org/apg/ui/EncryptActivity.java @@ -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; } diff --git a/org_apg/src/org/apg/ui/SelectPublicKeyListActivity.java b/org_apg/src/org/apg/ui/SelectPublicKeyListActivity.java index 0b6d6c43a..e2dcc8d4d 100644 --- a/org_apg/src/org/apg/ui/SelectPublicKeyListActivity.java +++ b/org_apg/src/org/apg/ui/SelectPublicKeyListActivity.java @@ -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; diff --git a/org_apg/src/org/apg/ui/SelectSecretKeyListActivity.java b/org_apg/src/org/apg/ui/SelectSecretKeyListActivity.java index 774ce6e41..dadc6f5bf 100644 --- a/org_apg/src/org/apg/ui/SelectSecretKeyListActivity.java +++ b/org_apg/src/org/apg/ui/SelectSecretKeyListActivity.java @@ -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; diff --git a/org_apg/src/org/apg/ui/SelectPublicKeyListAdapter.java b/org_apg/src/org/apg/ui/widget/SelectPublicKeyListAdapter.java index 93844601b..b98a76661 100644 --- a/org_apg/src/org/apg/ui/SelectPublicKeyListAdapter.java +++ b/org_apg/src/org/apg/ui/widget/SelectPublicKeyListAdapter.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.apg.ui; +package org.apg.ui.widget; import java.util.Date; diff --git a/org_apg/src/org/apg/ui/SelectSecretKeyListAdapter.java b/org_apg/src/org/apg/ui/widget/SelectSecretKeyListAdapter.java index 3c0b803eb..1b6d115b7 100644 --- a/org_apg/src/org/apg/ui/SelectSecretKeyListAdapter.java +++ b/org_apg/src/org/apg/ui/widget/SelectSecretKeyListAdapter.java @@ -12,7 +12,7 @@ * limitations under the License. */ -package org.apg.ui; +package org.apg.ui.widget; import java.util.Date; diff --git a/org_apg/src/org/apg/ui/widget/UserIdEditor.java b/org_apg/src/org/apg/ui/widget/UserIdEditor.java index ebbc608f0..ce5594c8e 100644 --- a/org_apg/src/org/apg/ui/widget/UserIdEditor.java +++ b/org_apg/src/org/apg/ui/widget/UserIdEditor.java @@ -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; |