From 212ee222c3cf66adda0842176a17f9302549f51b Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sun, 2 Feb 2014 22:14:07 +0000 Subject: replace spinner with non-functioning checkboxes --- .../keychain/ui/widget/KeyEditor.java | 44 +++++++++--------- .../src/main/res/layout/edit_key_key_item.xml | 54 ++++++++++++++++++++-- OpenPGP-Keychain/src/main/res/values/strings.xml | 9 ++-- 3 files changed, 77 insertions(+), 30 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 6c265057e..16e868a2c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -89,18 +89,18 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { mKeyId = (TextView) findViewById(R.id.keyId); mCreationDate = (TextView) findViewById(R.id.creation); mExpiryDateButton = (BootstrapButton) findViewById(R.id.expiry); - mUsage = (Spinner) findViewById(R.id.usage); - Choice choices[] = { - new Choice(Id.choice.usage.sign_only, getResources().getString( - R.string.choice_sign_only)), - new Choice(Id.choice.usage.encrypt_only, getResources().getString( - R.string.choice_encrypt_only)), - new Choice(Id.choice.usage.sign_and_encrypt, getResources().getString( - R.string.choice_sign_and_encrypt)), }; - ArrayAdapter adapter = new ArrayAdapter(getContext(), - android.R.layout.simple_spinner_item, choices); - adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - mUsage.setAdapter(adapter); + //mUsage = (Spinner) findViewById(R.id.usage); + //Choice choices[] = { + // new Choice(Id.choice.usage.sign_only, getResources().getString( + // R.string.choice_sign_only)), + // new Choice(Id.choice.usage.encrypt_only, getResources().getString( + // R.string.choice_encrypt_only)), + // new Choice(Id.choice.usage.sign_and_encrypt, getResources().getString( + // R.string.choice_sign_and_encrypt)), }; + //ArrayAdapter adapter = new ArrayAdapter(getContext(), + // android.R.layout.simple_spinner_item, choices); + //adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + //mUsage.setAdapter(adapter); mDeleteButton = (BootstrapButton) findViewById(R.id.delete); mDeleteButton.setOnClickListener(this); @@ -139,7 +139,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { public void setCanEdit(boolean bCanEdit) { if (!bCanEdit) { mDeleteButton.setVisibility(View.INVISIBLE); - mUsage.setEnabled(false); + //mUsage.setEnabled(false); mExpiryDateButton.setEnabled(false); } } @@ -161,22 +161,22 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { boolean isElGamalKey = (key.getPublicKey().getAlgorithm() == PGPPublicKey.ELGAMAL_ENCRYPT); boolean isDSAKey = (key.getPublicKey().getAlgorithm() == PGPPublicKey.DSA); if (!isElGamalKey) { - choices.add(new Choice(Id.choice.usage.sign_only, getResources().getString( - R.string.choice_sign_only))); + //choices.add(new Choice(Id.choice.usage.sign_only, getResources().getString( + // R.string.choice_sign_only))); } if (!mIsMasterKey && !isDSAKey) { - choices.add(new Choice(Id.choice.usage.encrypt_only, getResources().getString( - R.string.choice_encrypt_only))); + //choices.add(new Choice(Id.choice.usage.encrypt_only, getResources().getString( + // R.string.choice_encrypt_only))); } if (!isElGamalKey && !isDSAKey) { - choices.add(new Choice(Id.choice.usage.sign_and_encrypt, getResources().getString( - R.string.choice_sign_and_encrypt))); + //choices.add(new Choice(Id.choice.usage.sign_and_encrypt, getResources().getString( + // R.string.choice_sign_and_encrypt))); } ArrayAdapter adapter = new ArrayAdapter(getContext(), android.R.layout.simple_spinner_item, choices); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - mUsage.setAdapter(adapter); + //mUsage.setAdapter(adapter); // Set value in choice dropdown to key int selectId = 0; @@ -198,7 +198,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { for (int i = 0; i < choices.size(); ++i) { if (choices.get(i).getId() == selectId) { - mUsage.setSelection(i); + //mUsage.setSelection(i); break; } } @@ -249,7 +249,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { } public int getUsage() { - return ((Choice) mUsage.getSelectedItem()).getId(); + return 1; //((Choice) mUsage.getSelectedItem()).getId(); } } diff --git a/OpenPGP-Keychain/src/main/res/layout/edit_key_key_item.xml b/OpenPGP-Keychain/src/main/res/layout/edit_key_key_item.xml index 4bf4aa38a..ef913b039 100644 --- a/OpenPGP-Keychain/src/main/res/layout/edit_key_key_item.xml +++ b/OpenPGP-Keychain/src/main/res/layout/edit_key_key_item.xml @@ -97,11 +97,54 @@ android:layout_gravity="center_vertical" android:paddingRight="10dip" android:text="@string/label_usage" /> + + - + + + + + + + + + + + + + + + + @@ -122,4 +165,5 @@ android:layout_height="1dip" android:background="?android:attr/listDivider" /> - \ No newline at end of file + + diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index fb7b60b7c..438a5384c 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -153,9 +153,6 @@ None - Sign only - Encrypt only - Sign and Encrypt 15 secs 1 min 3 mins @@ -176,6 +173,12 @@ Error Error: %s + + Certify + Sign + Encrypt + Authenticate + Wrong passphrase. Using clipboard content. -- cgit v1.2.3 From a90b748611126cd122e39ef944f4c268798419f0 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sun, 2 Feb 2014 23:56:53 +0000 Subject: set checkboxes from key properties --- .../keychain/ui/widget/KeyEditor.java | 74 +++++++++++----------- .../src/main/res/layout/edit_key_key_item.xml | 17 +++-- 2 files changed, 49 insertions(+), 42 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 16e868a2c..f845b53a7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -39,9 +39,12 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ArrayAdapter; +import android.widget.CheckBox; import android.widget.DatePicker; import android.widget.LinearLayout; import android.widget.Spinner; +import android.widget.TableLayout; +import android.widget.TableRow; import android.widget.TextView; import com.beardedhen.androidbootstrap.BootstrapButton; @@ -59,6 +62,10 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { TextView mCreationDate; BootstrapButton mExpiryDateButton; GregorianCalendar mExpiryDate; + CheckBox mChkCertify; + CheckBox mChkSign; + CheckBox mChkEncrypt; + CheckBox mChkAuthenticate; private int mDatePickerResultCount = 0; private DatePickerDialog.OnDateSetListener mExpiryDateSetListener = new DatePickerDialog.OnDateSetListener() { @@ -89,21 +96,13 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { mKeyId = (TextView) findViewById(R.id.keyId); mCreationDate = (TextView) findViewById(R.id.creation); mExpiryDateButton = (BootstrapButton) findViewById(R.id.expiry); - //mUsage = (Spinner) findViewById(R.id.usage); - //Choice choices[] = { - // new Choice(Id.choice.usage.sign_only, getResources().getString( - // R.string.choice_sign_only)), - // new Choice(Id.choice.usage.encrypt_only, getResources().getString( - // R.string.choice_encrypt_only)), - // new Choice(Id.choice.usage.sign_and_encrypt, getResources().getString( - // R.string.choice_sign_and_encrypt)), }; - //ArrayAdapter adapter = new ArrayAdapter(getContext(), - // android.R.layout.simple_spinner_item, choices); - //adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - //mUsage.setAdapter(adapter); mDeleteButton = (BootstrapButton) findViewById(R.id.delete); mDeleteButton.setOnClickListener(this); + mChkCertify = (CheckBox) findViewById(R.id.chkCertify); + mChkSign = (CheckBox) findViewById(R.id.chkSign); + mChkEncrypt = (CheckBox) findViewById(R.id.chkEncrypt); + mChkAuthenticate = (CheckBox) findViewById(R.id.chkAuthenticate); setExpiryDate(null); @@ -139,8 +138,10 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { public void setCanEdit(boolean bCanEdit) { if (!bCanEdit) { mDeleteButton.setVisibility(View.INVISIBLE); - //mUsage.setEnabled(false); mExpiryDateButton.setEnabled(false); + mChkSign.setEnabled(false); //certify is always disabled + mChkEncrypt.setEnabled(false); + mChkAuthenticate.setEnabled(false); } } @@ -160,17 +161,26 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { Vector choices = new Vector(); boolean isElGamalKey = (key.getPublicKey().getAlgorithm() == PGPPublicKey.ELGAMAL_ENCRYPT); boolean isDSAKey = (key.getPublicKey().getAlgorithm() == PGPPublicKey.DSA); - if (!isElGamalKey) { - //choices.add(new Choice(Id.choice.usage.sign_only, getResources().getString( - // R.string.choice_sign_only))); + if (isElGamalKey) { + mChkSign.setVisibility(View.INVISIBLE); + TableLayout table = (TableLayout)findViewById(R.id.table_keylayout); + TableRow row = (TableRow)findViewById(R.id.row_sign); + table.removeView(row); } - if (!mIsMasterKey && !isDSAKey) { - //choices.add(new Choice(Id.choice.usage.encrypt_only, getResources().getString( - // R.string.choice_encrypt_only))); + if (isDSAKey) { + mChkEncrypt.setVisibility(View.INVISIBLE); + TableLayout table = (TableLayout)findViewById(R.id.table_keylayout); + TableRow row = (TableRow)findViewById(R.id.row_encrypt); + table.removeView(row); } - if (!isElGamalKey && !isDSAKey) { - //choices.add(new Choice(Id.choice.usage.sign_and_encrypt, getResources().getString( - // R.string.choice_sign_and_encrypt))); + if (!mIsMasterKey) { + mChkCertify.setVisibility(View.INVISIBLE); + TableLayout table = (TableLayout)findViewById(R.id.table_keylayout); + TableRow row = (TableRow)findViewById(R.id.row_certify); + table.removeView(row); + } else { + TextView mLabelUsage2= (TextView) findViewById(R.id.label_usage2); + mLabelUsage2.setVisibility(View.INVISIBLE); } ArrayAdapter adapter = new ArrayAdapter(getContext(), @@ -180,21 +190,11 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { // Set value in choice dropdown to key int selectId = 0; - if (PgpKeyHelper.isEncryptionKey(key)) { - if (PgpKeyHelper.isSigningKey(key)) { - selectId = Id.choice.usage.sign_and_encrypt; - } else { - selectId = Id.choice.usage.encrypt_only; - } - } else { - // set usage if it is predefined - if (usage != -1) { - selectId = usage; - } else { - selectId = Id.choice.usage.sign_only; - } - - } + if (key.isMasterKey()) + mChkCertify.setChecked(PgpKeyHelper.isCertificationKey(key)); + mChkSign.setChecked(PgpKeyHelper.isSigningKey(key)); + mChkEncrypt.setChecked(PgpKeyHelper.isEncryptionKey(key)); + // TODO: use usage argument? for (int i = 0; i < choices.size(); ++i) { if (choices.get(i).getId() == selectId) { diff --git a/OpenPGP-Keychain/src/main/res/layout/edit_key_key_item.xml b/OpenPGP-Keychain/src/main/res/layout/edit_key_key_item.xml index ef913b039..499fd5aa9 100644 --- a/OpenPGP-Keychain/src/main/res/layout/edit_key_key_item.xml +++ b/OpenPGP-Keychain/src/main/res/layout/edit_key_key_item.xml @@ -11,6 +11,7 @@ android:orientation="horizontal" > - + - + + android:paddingRight="10dip" + android:text="@string/label_usage" /> - + - + Date: Mon, 3 Feb 2014 00:05:45 +0000 Subject: include authentication keys --- .../keychain/pgp/PgpKeyHelper.java | 30 ++++++++++++++++++++++ .../keychain/ui/widget/KeyEditor.java | 1 + 2 files changed, 31 insertions(+) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index 3fc63cda1..bef41ce64 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -397,6 +397,36 @@ public class PgpKeyHelper { return false; } + public static boolean isAuthenticationKey(PGPSecretKey key) { + return isAuthenticationKey(key.getPublicKey()); + } + + @SuppressWarnings("unchecked") + public static boolean isAuthenticationKey(PGPPublicKey key) { + if (key.getVersion() <= 3) { + return true; + } + + for (PGPSignature sig : new IterableIterator(key.getSignatures())) { + if (key.isMasterKey() && sig.getKeyID() != key.getKeyID()) { + continue; + } + PGPSignatureSubpacketVector hashed = sig.getHashedSubPackets(); + + if (hashed != null && (hashed.getKeyFlags() & KeyFlags.AUTHENTICATION) != 0) { + return true; + } + + PGPSignatureSubpacketVector unhashed = sig.getUnhashedSubPackets(); + + if (unhashed != null && (unhashed.getKeyFlags() & KeyFlags.AUTHENTICATION) != 0) { + return true; + } + } + + return false; + } + public static boolean isCertificationKey(PGPSecretKey key) { return isCertificationKey(key.getPublicKey()); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index f845b53a7..b05963385 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -194,6 +194,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { mChkCertify.setChecked(PgpKeyHelper.isCertificationKey(key)); mChkSign.setChecked(PgpKeyHelper.isSigningKey(key)); mChkEncrypt.setChecked(PgpKeyHelper.isEncryptionKey(key)); + mChkAuthenticate.setChecked(PgpKeyHelper.isAuthenticationKey(key)); // TODO: use usage argument? for (int i = 0; i < choices.size(); ++i) { -- cgit v1.2.3 From 089a70fe323ee0628b05709f2f831d6aa32e0281 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Mon, 3 Feb 2014 01:15:29 +0000 Subject: save flags from checkboxes --- .../keychain/pgp/PgpKeyOperation.java | 22 +++++------------- .../keychain/ui/widget/KeyEditor.java | 26 ++++++++++------------ 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 9782d1ac2..d2793a859 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -237,8 +237,8 @@ public class PgpKeyOperation { updateProgress(R.string.progress_preparing_master_key, 10, 100); int usageId = keysUsages.get(0); - boolean canSign = (usageId == Id.choice.usage.sign_only || usageId == Id.choice.usage.sign_and_encrypt); - boolean canEncrypt = (usageId == Id.choice.usage.encrypt_only || usageId == Id.choice.usage.sign_and_encrypt); + boolean canSign = (usageId & KeyFlags.SIGN_DATA) > 0; + boolean canEncrypt = (usageId & (KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE)) > 0; String mainUserId = userIds.get(0); @@ -287,11 +287,7 @@ public class PgpKeyOperation { PGPSignatureSubpacketGenerator hashedPacketsGen = new PGPSignatureSubpacketGenerator(); PGPSignatureSubpacketGenerator unhashedPacketsGen = new PGPSignatureSubpacketGenerator(); - int keyFlags = KeyFlags.CERTIFY_OTHER | KeyFlags.SIGN_DATA; - if (canEncrypt) { - keyFlags |= KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE; - } - hashedPacketsGen.setKeyFlags(true, keyFlags); + hashedPacketsGen.setKeyFlags(true, usageId); hashedPacketsGen.setPreferredSymmetricAlgorithms(true, PREFERRED_SYMMETRIC_ALGORITHMS); hashedPacketsGen.setPreferredHashAlgorithms(true, PREFERRED_HASH_ALGORITHMS); @@ -349,14 +345,11 @@ public class PgpKeyOperation { hashedPacketsGen = new PGPSignatureSubpacketGenerator(); unhashedPacketsGen = new PGPSignatureSubpacketGenerator(); - keyFlags = 0; - usageId = keysUsages.get(i); - canSign = (usageId == Id.choice.usage.sign_only || usageId == Id.choice.usage.sign_and_encrypt); - canEncrypt = (usageId == Id.choice.usage.encrypt_only || usageId == Id.choice.usage.sign_and_encrypt); + canSign = (usageId & KeyFlags.SIGN_DATA) > 0; //todo - separate function for this + canEncrypt = (usageId & (KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE)) > 0; if (canSign) { Date todayDate = new Date(); //both sig times the same - keyFlags |= KeyFlags.SIGN_DATA; // cross-certify signing keys hashedPacketsGen.setSignatureCreationTime(false, todayDate); //set outer creation time PGPSignatureSubpacketGenerator subHashedPacketsGen = new PGPSignatureSubpacketGenerator(); @@ -371,10 +364,7 @@ public class PgpKeyOperation { subPublicKey); unhashedPacketsGen.setEmbeddedSignature(false, certification); } - if (canEncrypt) { - keyFlags |= KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE; - } - hashedPacketsGen.setKeyFlags(false, keyFlags); + hashedPacketsGen.setKeyFlags(false, usageId); if (keysExpiryDates.get(i) != null) { GregorianCalendar creationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC")); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index b05963385..2bedafc9f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -23,6 +23,7 @@ import java.util.GregorianCalendar; import java.util.TimeZone; import java.util.Vector; +import org.spongycastle.bcpg.sig.KeyFlags; import org.spongycastle.openpgp.PGPPublicKey; import org.spongycastle.openpgp.PGPSecretKey; import org.sufficientlysecure.keychain.Id; @@ -183,12 +184,6 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { mLabelUsage2.setVisibility(View.INVISIBLE); } - ArrayAdapter adapter = new ArrayAdapter(getContext(), - android.R.layout.simple_spinner_item, choices); - adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - //mUsage.setAdapter(adapter); - - // Set value in choice dropdown to key int selectId = 0; if (key.isMasterKey()) mChkCertify.setChecked(PgpKeyHelper.isCertificationKey(key)); @@ -197,13 +192,6 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { mChkAuthenticate.setChecked(PgpKeyHelper.isAuthenticationKey(key)); // TODO: use usage argument? - for (int i = 0; i < choices.size(); ++i) { - if (choices.get(i).getId() == selectId) { - //mUsage.setSelection(i); - break; - } - } - GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC")); cal.setTime(PgpKeyHelper.getCreationDate(key)); mCreationDate.setText(DateFormat.getDateInstance().format(cal.getTime())); @@ -250,7 +238,17 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { } public int getUsage() { - return 1; //((Choice) mUsage.getSelectedItem()).getId(); + int result = 0; // TODO: preserve other flags + if (mChkCertify.isChecked()) + result |= KeyFlags.CERTIFY_OTHER; + if (mChkSign.isChecked()) //TODO: fix what happens when we remove sign flag from master - should still be able to certify + result |= KeyFlags.SIGN_DATA; + if (mChkEncrypt.isChecked()) + result |= KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE; + if (mChkAuthenticate.isChecked()) + result |= KeyFlags.AUTHENTICATION; + + return result; } } -- cgit v1.2.3 From 82b94838c3132064c8011a041466fea04a602b19 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Tue, 4 Feb 2014 00:38:19 +0000 Subject: fix certify keys without sign flag --- .../sufficientlysecure/keychain/provider/ProviderHelper.java | 12 +++++------- .../org/sufficientlysecure/keychain/ui/EditKeyActivity.java | 2 +- .../org/sufficientlysecure/keychain/ui/widget/KeyEditor.java | 1 - 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java index a4992163a..12bc33995 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -23,8 +23,6 @@ import java.util.ArrayList; import java.util.Date; import org.spongycastle.bcpg.ArmoredOutputStream; -import org.spongycastle.bcpg.UserAttributePacket; -import org.spongycastle.bcpg.UserAttributeSubpacket; import org.spongycastle.openpgp.PGPKeyRing; import org.spongycastle.openpgp.PGPPublicKey; import org.spongycastle.openpgp.PGPPublicKeyRing; @@ -348,7 +346,7 @@ public class ProviderHelper { values.put(Keys.KEY_SIZE, key.getPublicKey().getBitStrength()); values.put(Keys.CAN_CERTIFY, (PgpKeyHelper.isCertificationKey(key) && has_private)); values.put(Keys.CAN_SIGN, (PgpKeyHelper.isSigningKey(key) && has_private)); - values.put(Keys.CAN_ENCRYPT, PgpKeyHelper.isEncryptionKey(key)); + values.put(Keys.CAN_ENCRYPT, PgpKeyHelper.isEncryptionKey(key) && has_private); values.put(Keys.IS_REVOKED, key.getPublicKey().isRevoked()); values.put(Keys.CREATION, PgpKeyHelper.getCreationDate(key).getTime() / 1000); Date expiryDate = PgpKeyHelper.getExpiryDate(key); @@ -441,21 +439,21 @@ public class ProviderHelper { /** * Get empty status of master key of keyring by its row id */ - public static boolean getSecretMasterKeyCanSign(Context context, long keyRingRowId) { + public static boolean getSecretMasterKeyCanCertify(Context context, long keyRingRowId) { Uri queryUri = KeyRings.buildSecretKeyRingsUri(String.valueOf(keyRingRowId)); - return getMasterKeyCanSign(context, queryUri, keyRingRowId); + return getMasterKeyCanCertify(context, queryUri, keyRingRowId); } /** * Private helper method to get master key private empty status of keyring by its row id */ - private static boolean getMasterKeyCanSign(Context context, Uri queryUri, long keyRingRowId) { + private static boolean getMasterKeyCanCertify(Context context, Uri queryUri, long keyRingRowId) { String[] projection = new String[]{ KeyRings.MASTER_KEY_ID, "(SELECT COUNT(sign_keys." + Keys._ID + ") FROM " + Tables.KEYS + " AS sign_keys WHERE sign_keys." + Keys.KEY_RING_ROW_ID + " = " + KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings._ID - + " AND sign_keys." + Keys.CAN_SIGN + " = '1' AND " + Keys.IS_MASTER_KEY + + " AND sign_keys." + Keys.CAN_CERTIFY + " = '1' AND " + Keys.IS_MASTER_KEY + " = 1) AS sign",}; ContentResolver cr = context.getContentResolver(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 73426e32d..2c49d4921 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -256,7 +256,7 @@ public class EditKeyActivity extends ActionBarActivity { // get master key id using row id long masterKeyId = ProviderHelper.getSecretMasterKeyId(this, keyRingRowId); - masterCanSign = ProviderHelper.getSecretMasterKeyCanSign(this, keyRingRowId); + masterCanSign = ProviderHelper.getSecretMasterKeyCanCertify(this, keyRingRowId); finallyEdit(masterKeyId, masterCanSign); } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 2bedafc9f..2ea044e66 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -59,7 +59,6 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { BootstrapButton mDeleteButton; TextView mAlgorithm; TextView mKeyId; - Spinner mUsage; TextView mCreationDate; BootstrapButton mExpiryDateButton; GregorianCalendar mExpiryDate; -- cgit v1.2.3 From 64aa2b7701fc6fa1992540f32f18bad34e011b31 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Tue, 4 Feb 2014 00:46:03 +0000 Subject: slight clarification --- OpenPGP-Keychain/src/main/res/values/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index 438a5384c..becf2417e 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -56,8 +56,8 @@ Delete None Okay - Change Passphrase - Set Passphrase + Change New Passphrase + Set New Passphrase Search Upload To Key Server Next -- cgit v1.2.3 From fe3db8f0e68b7490bf98e356474a631dec32530c Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Tue, 4 Feb 2014 01:18:54 +0000 Subject: preserve keys that we don\'t use in the app --- .../keychain/pgp/PgpKeyHelper.java | 27 +++++++++++++++++++--- .../keychain/ui/widget/KeyEditor.java | 20 ++++++++-------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index bef41ce64..78d42cbf9 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -209,9 +209,8 @@ public class PgpKeyHelper { Calendar calendar = GregorianCalendar.getInstance(); calendar.setTime(creationDate); calendar.add(Calendar.DATE, key.getValidDays()); - Date expiryDate = calendar.getTime(); - return expiryDate; + return calendar.getTime(); } public static Date getExpiryDate(PGPSecretKey key) { @@ -291,6 +290,28 @@ public class PgpKeyHelper { return userId; } + public static int getKeyUsage(PGPSecretKey key) + { + return getKeyUsage(key.getPublicKey()); + } + + @SuppressWarnings("unchecked") + private static int getKeyUsage(PGPPublicKey key) { + int usage = 0; + if (key.getVersion() >= 4) { + for (PGPSignature sig : new IterableIterator(key.getSignatures())) { + if (key.isMasterKey() && sig.getKeyID() != key.getKeyID()) continue; + + PGPSignatureSubpacketVector hashed = sig.getHashedSubPackets(); + if (hashed != null) usage |= hashed.getKeyFlags(); + + PGPSignatureSubpacketVector unhashed = sig.getUnhashedSubPackets(); + if (unhashed != null) usage |= unhashed.getKeyFlags(); + } + } + return usage; + } + @SuppressWarnings("unchecked") public static boolean isEncryptionKey(PGPPublicKey key) { if (!key.isEncryptionKey()) { @@ -440,7 +461,7 @@ public class PgpKeyHelper { } public static String getAlgorithmInfo(int algorithm, int keySize) { - String algorithmStr = null; + String algorithmStr; switch (algorithm) { case PGPPublicKey.RSA_ENCRYPT: diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 2ea044e66..8443895e8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -66,6 +66,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { CheckBox mChkSign; CheckBox mChkEncrypt; CheckBox mChkAuthenticate; + int mUsage; private int mDatePickerResultCount = 0; private DatePickerDialog.OnDateSetListener mExpiryDateSetListener = new DatePickerDialog.OnDateSetListener() { @@ -189,6 +190,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { mChkSign.setChecked(PgpKeyHelper.isSigningKey(key)); mChkEncrypt.setChecked(PgpKeyHelper.isEncryptionKey(key)); mChkAuthenticate.setChecked(PgpKeyHelper.isAuthenticationKey(key)); + mUsage = PgpKeyHelper.getKeyUsage(key); // TODO: use usage argument? GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC")); @@ -237,17 +239,13 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { } public int getUsage() { - int result = 0; // TODO: preserve other flags - if (mChkCertify.isChecked()) - result |= KeyFlags.CERTIFY_OTHER; - if (mChkSign.isChecked()) //TODO: fix what happens when we remove sign flag from master - should still be able to certify - result |= KeyFlags.SIGN_DATA; - if (mChkEncrypt.isChecked()) - result |= KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE; - if (mChkAuthenticate.isChecked()) - result |= KeyFlags.AUTHENTICATION; - - return result; + mUsage = (mUsage & ~KeyFlags.CERTIFY_OTHER) | (mChkCertify.isChecked() ? KeyFlags.CERTIFY_OTHER : 0); + mUsage = (mUsage & ~KeyFlags.SIGN_DATA) | (mChkSign.isChecked() ? KeyFlags.SIGN_DATA : 0); + mUsage = (mUsage & ~KeyFlags.ENCRYPT_COMMS) | (mChkEncrypt.isChecked() ? KeyFlags.ENCRYPT_COMMS : 0); + mUsage = (mUsage & ~KeyFlags.ENCRYPT_STORAGE) | (mChkEncrypt.isChecked() ? KeyFlags.ENCRYPT_STORAGE : 0); + mUsage = (mUsage & ~KeyFlags.AUTHENTICATION) | (mChkAuthenticate.isChecked() ? KeyFlags.AUTHENTICATION : 0); + + return mUsage; } } -- cgit v1.2.3 From 6d40bc3c0c5e14b77f7de734e57e351eacd6e98c Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Tue, 4 Feb 2014 22:02:53 +0000 Subject: use usage argument if needed --- .../java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java | 8 +++++--- .../org/sufficientlysecure/keychain/ui/widget/SectionView.java | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 8443895e8..2e56c65bc 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -146,7 +146,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { } } - public void setValue(PGPSecretKey key, boolean isMasterKey, int usage) { + public void setValue(PGPSecretKey key, boolean isMasterKey, int usage, boolean isNewKey) { mKey = key; mIsMasterKey = isMasterKey; @@ -190,8 +190,10 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { mChkSign.setChecked(PgpKeyHelper.isSigningKey(key)); mChkEncrypt.setChecked(PgpKeyHelper.isEncryptionKey(key)); mChkAuthenticate.setChecked(PgpKeyHelper.isAuthenticationKey(key)); - mUsage = PgpKeyHelper.getKeyUsage(key); - // TODO: use usage argument? + if (isNewKey) + mUsage = usage; + else + mUsage = PgpKeyHelper.getKeyUsage(key); GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC")); cal.setTime(PgpKeyHelper.getCreationDate(key)); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 9d3643914..df69ff60b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -272,7 +272,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor false); view.setEditorListener(this); boolean isMasterKey = (mEditors.getChildCount() == 0); - view.setValue(list.get(i), isMasterKey, usages.get(i)); + view.setValue(list.get(i), isMasterKey, usages.get(i), false); view.setCanEdit(canEdit); mEditors.addView(view); } @@ -344,7 +344,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor KeyEditor view = (KeyEditor) mInflater.inflate(R.layout.edit_key_key_item, mEditors, false); view.setEditorListener(SectionView.this); - view.setValue(newKey, newKey.isMasterKey(), -1); + view.setValue(newKey, newKey.isMasterKey(), -1, true); mEditors.addView(view); SectionView.this.updateEditorsVisible(); } -- cgit v1.2.3 From 8d7cc6755349d06dcd9a2c28dc556c7adb71b8a4 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Wed, 5 Feb 2014 21:04:20 +0000 Subject: save --- .../keychain/ui/EditKeyActivity.java | 13 +++++++- .../keychain/ui/PreferencesKeyServerActivity.java | 7 +++- .../keychain/ui/widget/Editor.java | 4 ++- .../keychain/ui/widget/KeyEditor.java | 37 +++++++++++++++++++--- .../keychain/ui/widget/KeyServerEditor.java | 2 +- .../keychain/ui/widget/SectionView.java | 29 +++++++++++++++-- .../keychain/ui/widget/UserIdEditor.java | 7 +++- 7 files changed, 87 insertions(+), 12 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 2c49d4921..b28ed8922 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -38,9 +38,11 @@ import org.sufficientlysecure.keychain.service.PassphraseCacheService; import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment; +import org.sufficientlysecure.keychain.ui.widget.Editor; import org.sufficientlysecure.keychain.ui.widget.KeyEditor; import org.sufficientlysecure.keychain.ui.widget.SectionView; import org.sufficientlysecure.keychain.ui.widget.UserIdEditor; +import org.sufficientlysecure.keychain.ui.widget.Editor.EditorListener; import org.sufficientlysecure.keychain.util.IterableIterator; import org.sufficientlysecure.keychain.util.Log; @@ -67,7 +69,7 @@ import android.widget.Toast; import com.beardedhen.androidbootstrap.BootstrapButton; -public class EditKeyActivity extends ActionBarActivity { +public class EditKeyActivity extends ActionBarActivity implements EditorListener { // Actions for internal use only: public static final String ACTION_CREATE_KEY = Constants.INTENT_PREFIX + "CREATE_KEY"; @@ -106,6 +108,15 @@ public class EditKeyActivity extends ActionBarActivity { ExportHelper mExportHelper; + public void onDeleted(Editor e, boolean wasNewItem) + { + } + + public void onEdited() + { + + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java index b5ac739ae..b39b93f52 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesKeyServerActivity.java @@ -91,10 +91,15 @@ public class PreferencesKeyServerActivity extends ActionBarActivity implements O } } - public void onDeleted(Editor editor) { + public void onDeleted(Editor editor, boolean wasNewItem) { // nothing to do } + @Override + public void onEdited() { + + } + public void onClick(View v) { KeyServerEditor view = (KeyServerEditor) mInflater.inflate(R.layout.key_server_editor, mEditors, false); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/Editor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/Editor.java index 1cf510d3a..7b21c189d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/Editor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/Editor.java @@ -18,8 +18,10 @@ package org.sufficientlysecure.keychain.ui.widget; public interface Editor { public interface EditorListener { - public void onDeleted(Editor editor); + public void onDeleted(Editor editor, boolean wasNewItem); + public void onEdited(); } public void setEditorListener(EditorListener listener); + public boolean needsSaving(); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 2e56c65bc..c941ea908 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -26,7 +26,6 @@ import java.util.Vector; import org.spongycastle.bcpg.sig.KeyFlags; import org.spongycastle.openpgp.PGPPublicKey; import org.spongycastle.openpgp.PGPSecretKey; -import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.util.Choice; @@ -39,11 +38,9 @@ import android.util.AttributeSet; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; -import android.widget.ArrayAdapter; import android.widget.CheckBox; import android.widget.DatePicker; import android.widget.LinearLayout; -import android.widget.Spinner; import android.widget.TableLayout; import android.widget.TableRow; import android.widget.TextView; @@ -62,11 +59,14 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { TextView mCreationDate; BootstrapButton mExpiryDateButton; GregorianCalendar mExpiryDate; + GregorianCalendar mOriginalExpiryDate = null; CheckBox mChkCertify; CheckBox mChkSign; CheckBox mChkEncrypt; CheckBox mChkAuthenticate; int mUsage; + int mOriginalUsage; + boolean mIsNewKey; private int mDatePickerResultCount = 0; private DatePickerDialog.OnDateSetListener mExpiryDateSetListener = new DatePickerDialog.OnDateSetListener() { @@ -190,10 +190,13 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { mChkSign.setChecked(PgpKeyHelper.isSigningKey(key)); mChkEncrypt.setChecked(PgpKeyHelper.isEncryptionKey(key)); mChkAuthenticate.setChecked(PgpKeyHelper.isAuthenticationKey(key)); + mIsNewKey = isNewKey; if (isNewKey) mUsage = usage; - else + else { mUsage = PgpKeyHelper.getKeyUsage(key); + mOriginalUsage = mUsage; + } GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC")); cal.setTime(PgpKeyHelper.getCreationDate(key)); @@ -205,6 +208,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { } else { cal.setTime(PgpKeyHelper.getExpiryDate(key)); setExpiryDate(cal); + mOriginalExpiryDate = cal; // TODO: ensure time doesn't matter when selecting the same date as before } } @@ -218,7 +222,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { if (v == mDeleteButton) { parent.removeView(this); if (mEditorListener != null) { - mEditorListener.onDeleted(this); + mEditorListener.onDeleted(this, mIsNewKey); } } } @@ -250,4 +254,27 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { return mUsage; } + public boolean needsSaving() + { + if (mIsNewKey) + return true; + + boolean retval = (getUsage() != mOriginalUsage); + + boolean dateChanged; + boolean mOEDNull = (mOriginalExpiryDate == null); + boolean mEDNull = (mExpiryDate == null); + if (mOEDNull != mEDNull) { + dateChanged = true; + } else { + if(mOEDNull) //both null, no change + dateChanged = false; + else + dateChanged = ((mExpiryDate.compareTo(mOriginalExpiryDate)) != 0); + } + retval |= dateChanged; + + return retval; + } + } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyServerEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyServerEditor.java index 01259ccd1..a75aafc11 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyServerEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyServerEditor.java @@ -68,7 +68,7 @@ public class KeyServerEditor extends LinearLayout implements Editor, OnClickList if (v == mDeleteButton) { parent.removeView(this); if (mEditorListener != null) { - mEditorListener.onDeleted(this); + mEditorListener.onDeleted(this, false); } } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index df69ff60b..19926abd3 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -50,21 +50,27 @@ import android.widget.TextView; import com.beardedhen.androidbootstrap.BootstrapButton; -public class SectionView extends LinearLayout implements OnClickListener, EditorListener { +public class SectionView extends LinearLayout implements OnClickListener, EditorListener, Editor { private LayoutInflater mInflater; private BootstrapButton mPlusButton; private ViewGroup mEditors; private TextView mTitle; private int mType = 0; + private EditorListener mEditorListener = null; private Choice mNewKeyAlgorithmChoice; private int mNewKeySize; private boolean canEdit = true; + private boolean oldItemDeleted = false; private ActionBarActivity mActivity; private ProgressDialogFragment mGeneratingDialog; + public void setEditorListener(EditorListener listener) { + mEditorListener = listener; + } + public SectionView(Context context) { super(context); mActivity = (ActionBarActivity) context; @@ -124,15 +130,34 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor } /** {@inheritDoc} */ - public void onDeleted(Editor editor) { + public void onDeleted(Editor editor, boolean wasNewItem) { + oldItemDeleted |= !wasNewItem; this.updateEditorsVisible(); } + @Override + public void onEdited() { + if (mEditorListener != null) { + mEditorListener.onEdited(); + } + } + protected void updateEditorsVisible() { final boolean hasChildren = mEditors.getChildCount() > 0; mEditors.setVisibility(hasChildren ? View.VISIBLE : View.GONE); } + public boolean needsSaving() + { + //check each view for needs saving, take account of deleted items + boolean ret = oldItemDeleted; + for (int i = 0; i < mEditors.getChildCount(); ++i) { + Editor editor = (Editor) mEditors.getChildAt(i); + ret |= editor.needsSaving(); + } + return ret; + } + /** {@inheritDoc} */ public void onClick(View v) { if (canEdit) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index 5428b626e..a56340582 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -175,7 +175,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene boolean wasMainUserId = mIsMainUserId.isChecked(); parent.removeView(this); if (mEditorListener != null) { - mEditorListener.onDeleted(this); + mEditorListener.onDeleted(this, false); } if (wasMainUserId && parent.getChildCount() > 0) { UserIdEditor editor = (UserIdEditor) parent.getChildAt(0); @@ -204,4 +204,9 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene public void setEditorListener(EditorListener listener) { mEditorListener = listener; } + + @Override + public boolean needsSaving() { + return false; + } } -- cgit v1.2.3 From 262425c6ad7cfa6509dc53150e592b3f6fd366c1 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Wed, 5 Feb 2014 21:36:11 +0000 Subject: edit ui knows it it has been changed --- .../keychain/ui/widget/SectionView.java | 5 +---- .../keychain/ui/widget/UserIdEditor.java | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 19926abd3..bf8a3f96b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -273,10 +273,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor UserIdEditor view = (UserIdEditor) mInflater.inflate(R.layout.edit_key_user_id_item, mEditors, false); view.setEditorListener(this); - view.setValue(userId); - if (mEditors.getChildCount() == 0) { - view.setIsMainUserId(true); - } + view.setValue(userId, mEditors.getChildCount() == 0); view.setCanEdit(canEdit); mEditors.addView(view); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index a56340582..4cd1392c2 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -38,8 +38,12 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene private BootstrapButton mDeleteButton; private RadioButton mIsMainUserId; private EditText mName; + private String mOriginalName; private EditText mEmail; + private String mOriginalEmail; private EditText mComment; + private String mOriginalComment; + private boolean mOriginallyMainUserID; // see http://www.regular-expressions.info/email.html // RFC 2822 if we omit the syntax using double quotes and square brackets @@ -108,17 +112,22 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene super.onFinishInflate(); } - public void setValue(String userId) { + public void setValue(String userId, boolean isMainID) { mName.setText(""); mComment.setText(""); mEmail.setText(""); + //TODO: update this file for blank email/name? + Pattern withComment = Pattern.compile("^(.*) [(](.*)[)] <(.*)>$"); Matcher matcher = withComment.matcher(userId); if (matcher.matches()) { mName.setText(matcher.group(1)); + mOriginalName = matcher.group(1); mComment.setText(matcher.group(2)); + mOriginalComment = matcher.group(2); mEmail.setText(matcher.group(3)); + mOriginalEmail = matcher.group(3); return; } @@ -126,9 +135,14 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene matcher = withoutComment.matcher(userId); if (matcher.matches()) { mName.setText(matcher.group(1)); + mOriginalName = matcher.group(1); mEmail.setText(matcher.group(2)); + mOriginalEmail = matcher.group(2); + mOriginalComment = ""; return; } + mOriginallyMainUserID = isMainID; + setIsMainUserId(isMainID); } public String getValue() throws NoNameException, NoEmailException, InvalidEmailException { @@ -207,6 +221,10 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene @Override public boolean needsSaving() { - return false; + boolean retval = (mOriginallyMainUserID != isMainUserId()); + retval |= (mOriginalName.equals( ("" + mName.getText()).trim() ) ); + retval |= (mOriginalEmail.equals( ("" + mEmail.getText()).trim() ) ); + retval |= (mOriginalComment.equals( ("" + mComment.getText()).trim() ) ); + return retval; } } -- cgit v1.2.3 From 83514b82c0861b90f33a2b32f9dfc1dd54f2cde4 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Wed, 5 Feb 2014 22:19:07 +0000 Subject: notify of changes --- .../keychain/ui/widget/KeyEditor.java | 24 ++++++++++++++++++++++ .../keychain/ui/widget/UserIdEditor.java | 24 +++++++++++++++++++++- 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index c941ea908..0ec1bad92 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -39,6 +39,7 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.CheckBox; +import android.widget.CompoundButton; import android.widget.DatePicker; import android.widget.LinearLayout; import android.widget.TableLayout; @@ -68,6 +69,19 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { int mOriginalUsage; boolean mIsNewKey; + private CheckBox.OnCheckedChangeListener mCheckChanged = new CheckBox.OnCheckedChangeListener() + { + @Override + public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) + { + if (mEditorListener != null) { + mEditorListener.onEdited(); + } + } + + } + + private int mDatePickerResultCount = 0; private DatePickerDialog.OnDateSetListener mExpiryDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { @@ -76,6 +90,9 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { GregorianCalendar date = new GregorianCalendar(TimeZone.getTimeZone("UTC")); date.set(year, monthOfYear, dayOfMonth); setExpiryDate(date); + if (mEditorListener != null) { + mEditorListener.onEdited(); + } } } }; @@ -101,9 +118,13 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { mDeleteButton = (BootstrapButton) findViewById(R.id.delete); mDeleteButton.setOnClickListener(this); mChkCertify = (CheckBox) findViewById(R.id.chkCertify); + mChkCertify.setOnCheckedChangeListener(mCheckChanged); mChkSign = (CheckBox) findViewById(R.id.chkSign); + mChkSign.setOnCheckedChangeListener(mCheckChanged); mChkEncrypt = (CheckBox) findViewById(R.id.chkEncrypt); + mChkEncrypt.setOnCheckedChangeListener(mCheckChanged); mChkAuthenticate = (CheckBox) findViewById(R.id.chkAuthenticate); + mChkAuthenticate.setOnCheckedChangeListener(mCheckChanged); setExpiryDate(null); @@ -126,6 +147,9 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { // Note: Ignore results after the first one - android sends multiples. if (mDatePickerResultCount++ == 0) { setExpiryDate(null); + if (mEditorListener != null) { + mEditorListener.onEdited(); + } } } }); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index 4cd1392c2..4b550c580 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -22,6 +22,8 @@ import java.util.regex.Pattern; import org.sufficientlysecure.keychain.R; import android.content.Context; +import android.text.Editable; +import android.text.TextWatcher; import android.util.AttributeSet; import android.view.View; import android.view.View.OnClickListener; @@ -106,6 +108,23 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene mIsMainUserId.setOnClickListener(this); mName = (EditText) findViewById(R.id.name); + mName.addTextChangedListener(new TextWatcher() { + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + @Override + public void afterTextChanged(Editable s) + { + if (mEditorListener != null) { + mEditorListener.onEdited(); + } + } + }); mEmail = (EditText) findViewById(R.id.email); mComment = (EditText) findViewById(R.id.comment); @@ -189,7 +208,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene boolean wasMainUserId = mIsMainUserId.isChecked(); parent.removeView(this); if (mEditorListener != null) { - mEditorListener.onDeleted(this, false); + mEditorListener.onDeleted(this, false); //TODO: WAS THIS A NEW ITEM } if (wasMainUserId && parent.getChildCount() > 0) { UserIdEditor editor = (UserIdEditor) parent.getChildAt(0); @@ -204,6 +223,9 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene editor.setIsMainUserId(false); } } + if (mEditorListener != null) { + mEditorListener.onEdited(); + } } } -- cgit v1.2.3 From 603665976a3a75918fb9838361b7194c5def6968 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Thu, 6 Feb 2014 09:00:36 +0000 Subject: new Ids need to be saved --- .../java/org/sufficientlysecure/keychain/ui/widget/SectionView.java | 6 ++---- .../org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java | 5 ++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index bf8a3f96b..e0d31fa3f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -166,9 +166,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor UserIdEditor view = (UserIdEditor) mInflater.inflate( R.layout.edit_key_user_id_item, mEditors, false); view.setEditorListener(this); - if (mEditors.getChildCount() == 0) { - view.setIsMainUserId(true); - } + view.setValue("", mEditors.getChildCount() == 0, true); mEditors.addView(view); break; } @@ -273,7 +271,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor UserIdEditor view = (UserIdEditor) mInflater.inflate(R.layout.edit_key_user_id_item, mEditors, false); view.setEditorListener(this); - view.setValue(userId, mEditors.getChildCount() == 0); + view.setValue(userId, mEditors.getChildCount() == 0, false); view.setCanEdit(canEdit); mEditors.addView(view); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index 4b550c580..0509e69f2 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -46,6 +46,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene private EditText mComment; private String mOriginalComment; private boolean mOriginallyMainUserID; + private boolean mIsNewId; // see http://www.regular-expressions.info/email.html // RFC 2822 if we omit the syntax using double quotes and square brackets @@ -131,10 +132,11 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene super.onFinishInflate(); } - public void setValue(String userId, boolean isMainID) { + public void setValue(String userId, boolean isMainID, boolean isNewId) { mName.setText(""); mComment.setText(""); mEmail.setText(""); + mIsNewId = isNewId; //TODO: update this file for blank email/name? @@ -247,6 +249,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene retval |= (mOriginalName.equals( ("" + mName.getText()).trim() ) ); retval |= (mOriginalEmail.equals( ("" + mEmail.getText()).trim() ) ); retval |= (mOriginalComment.equals( ("" + mComment.getText()).trim() ) ); + retval |= mIsNewId; return retval; } } -- cgit v1.2.3 From a5aae930e5e857005563c21fb2c7ca86d6e235da Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Thu, 6 Feb 2014 13:28:59 +0000 Subject: allow blank names and emails --- .../keychain/ui/widget/UserIdEditor.java | 67 ++++++---------------- 1 file changed, 17 insertions(+), 50 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index 0509e69f2..641b710a9 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -20,6 +20,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import android.content.Context; import android.text.Editable; @@ -56,14 +57,6 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene "[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; - - public NoNameException(String message) { - super(message); - } - } - public void setCanEdit(boolean bCanEdit) { if (!bCanEdit) { mDeleteButton.setVisibility(View.INVISIBLE); @@ -74,14 +67,6 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene } } - public static class NoEmailException extends Exception { - static final long serialVersionUID = 0xf812773344L; - - public NoEmailException(String message) { - super(message); - } - } - public static class InvalidEmailException extends Exception { static final long serialVersionUID = 0xf812773345L; @@ -133,40 +118,31 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene } public void setValue(String userId, boolean isMainID, boolean isNewId) { + mName.setText(""); mComment.setText(""); mEmail.setText(""); mIsNewId = isNewId; - //TODO: update this file for blank email/name? - - Pattern withComment = Pattern.compile("^(.*) [(](.*)[)] <(.*)>$"); - Matcher matcher = withComment.matcher(userId); - if (matcher.matches()) { - mName.setText(matcher.group(1)); - mOriginalName = matcher.group(1); - mComment.setText(matcher.group(2)); - mOriginalComment = matcher.group(2); - mEmail.setText(matcher.group(3)); - mOriginalEmail = matcher.group(3); - return; + String[] result = PgpKeyHelper.splitUserId(userId); + if (result[0] != null) { + mName.setText(result[0]); + mOriginalName = result[0]; } - - Pattern withoutComment = Pattern.compile("^(.*) <(.*)>$"); - matcher = withoutComment.matcher(userId); - if (matcher.matches()) { - mName.setText(matcher.group(1)); - mOriginalName = matcher.group(1); - mEmail.setText(matcher.group(2)); - mOriginalEmail = matcher.group(2); - mOriginalComment = ""; - return; + if (result[1] != null) { + mComment.setText(result[1]); + mOriginalComment = result[1]; + } + if (result[2] != null) { + mEmail.setText(result[2]); + mOriginalEmail = result[2]; } + mOriginallyMainUserID = isMainID; setIsMainUserId(isMainID); } - public String getValue() throws NoNameException, NoEmailException, InvalidEmailException { + public String getValue() throws InvalidEmailException { String name = ("" + mName.getText()).trim(); String email = ("" + mEmail.getText()).trim(); String comment = ("" + mComment.getText()).trim(); @@ -191,16 +167,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene // ok, empty one... return userId; } - - // otherwise make sure that name and email exist - if (name.equals("")) { - throw new NoNameException("need a name"); - } - - if (email.equals("")) { - throw new NoEmailException("need an email"); - } - + //TODO: check gpg accepts an entirely empty ID packet. specs say this is allowed return userId; } @@ -210,7 +177,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene boolean wasMainUserId = mIsMainUserId.isChecked(); parent.removeView(this); if (mEditorListener != null) { - mEditorListener.onDeleted(this, false); //TODO: WAS THIS A NEW ITEM + mEditorListener.onDeleted(this, mIsNewId); } if (wasMainUserId && parent.getChildCount() > 0) { UserIdEditor editor = (UserIdEditor) parent.getChildAt(0); -- cgit v1.2.3 From e7ebbc5ef662ecfe4f43ae203731c6d25cc26e0d Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Thu, 6 Feb 2014 13:56:34 +0000 Subject: final link in chain, fix compile --- .../org/sufficientlysecure/keychain/ui/EditKeyActivity.java | 12 ++++++------ .../org/sufficientlysecure/keychain/ui/widget/KeyEditor.java | 3 +-- .../keychain/ui/widget/KeyServerEditor.java | 5 +++++ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index b28ed8922..d8489ce65 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -96,6 +96,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener private String mNewPassPhrase = null; private String mSavedNewPassPhrase = null; private boolean mIsPassPhraseSet; + private boolean mNeedsSaving; private BootstrapButton mChangePassPhrase; @@ -114,7 +115,9 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener public void onEdited() { - + mNeedsSaving = mUserIdsView.needsSaving(); + mNeedsSaving |= mKeysView.needsSaving(); + Toast.makeText(this, "Needs saving: " + Boolean.toString(mNeedsSaving), Toast.LENGTH_LONG).show(); } @Override @@ -437,11 +440,13 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener mUserIdsView.setType(Id.type.user_id); mUserIdsView.setCanEdit(masterCanSign); mUserIdsView.setUserIds(mUserIds); + mUserIdsView.setEditorListener(this); container.addView(mUserIdsView); mKeysView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false); mKeysView.setType(Id.type.key); mKeysView.setCanEdit(masterCanSign); mKeysView.setKeys(mKeys, mKeysUsages); + mKeysView.setEditorListener(this); container.addView(mKeysView); updatePassPhraseButtonText(); @@ -597,11 +602,6 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener String userId = null; try { userId = editor.getValue(); - } catch (UserIdEditor.NoNameException e) { - throw new PgpGeneralException(this.getString(R.string.error_user_id_needs_a_name)); - } catch (UserIdEditor.NoEmailException e) { - throw new PgpGeneralException( - this.getString(R.string.error_user_id_needs_an_email_address)); } catch (UserIdEditor.InvalidEmailException e) { throw new PgpGeneralException(e.getMessage()); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 0ec1bad92..009b0cb10 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -78,8 +78,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { mEditorListener.onEdited(); } } - - } + }; private int mDatePickerResultCount = 0; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyServerEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyServerEditor.java index a75aafc11..47238cd56 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyServerEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyServerEditor.java @@ -73,6 +73,11 @@ public class KeyServerEditor extends LinearLayout implements Editor, OnClickList } } + @Override + public boolean needsSaving() { + return false; + } + public void setEditorListener(EditorListener listener) { mEditorListener = listener; } -- cgit v1.2.3 From d6726fe9d6a2efccca394567424342df9a941f2e Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Thu, 6 Feb 2014 14:25:09 +0000 Subject: some fixes --- .../keychain/ui/widget/UserIdEditor.java | 47 +++++++++++++--------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index 641b710a9..e3747aeb9 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -83,6 +83,24 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene super(context, attrs); } + TextWatcher mTextWatcher = new TextWatcher() { + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + @Override + public void afterTextChanged(Editable s) + { + if (mEditorListener != null) { + mEditorListener.onEdited(); + } + } + }; + @Override protected void onFinishInflate() { setDrawingCacheEnabled(true); @@ -94,25 +112,11 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene mIsMainUserId.setOnClickListener(this); mName = (EditText) findViewById(R.id.name); - mName.addTextChangedListener(new TextWatcher() { - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - - @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - @Override - public void afterTextChanged(Editable s) - { - if (mEditorListener != null) { - mEditorListener.onEdited(); - } - } - }); + mName.addTextChangedListener(mTextWatcher); mEmail = (EditText) findViewById(R.id.email); + mEmail.addTextChangedListener(mTextWatcher); mComment = (EditText) findViewById(R.id.comment); + mComment.addTextChangedListener(mTextWatcher); super.onFinishInflate(); } @@ -120,8 +124,11 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene public void setValue(String userId, boolean isMainID, boolean isNewId) { mName.setText(""); + mOriginalName = ""; mComment.setText(""); + mOriginalComment = ""; mEmail.setText(""); + mOriginalEmail = ""; mIsNewId = isNewId; String[] result = PgpKeyHelper.splitUserId(userId); @@ -213,9 +220,9 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene @Override public boolean needsSaving() { boolean retval = (mOriginallyMainUserID != isMainUserId()); - retval |= (mOriginalName.equals( ("" + mName.getText()).trim() ) ); - retval |= (mOriginalEmail.equals( ("" + mEmail.getText()).trim() ) ); - retval |= (mOriginalComment.equals( ("" + mComment.getText()).trim() ) ); + retval |= !(mOriginalName.equals( ("" + mName.getText()).trim() ) ); + retval |= !(mOriginalEmail.equals( ("" + mEmail.getText()).trim() ) ); + retval |= !(mOriginalComment.equals( ("" + mComment.getText()).trim() ) ); retval |= mIsNewId; return retval; } -- cgit v1.2.3 From 53dc044ab4da1e177f4259863cb7fb0266521f6e Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Thu, 6 Feb 2014 14:33:29 +0000 Subject: pass message when key added --- .../java/org/sufficientlysecure/keychain/ui/widget/SectionView.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index e0d31fa3f..072c04f03 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -168,6 +168,9 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor view.setEditorListener(this); view.setValue("", mEditors.getChildCount() == 0, true); mEditors.addView(view); + if (mEditorListener != null) { + mEditorListener.onEdited(); + } break; } @@ -367,5 +370,8 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor view.setValue(newKey, newKey.isMasterKey(), -1, true); mEditors.addView(view); SectionView.this.updateEditorsVisible(); + if (mEditorListener != null) { + mEditorListener.onEdited(); + } } } -- cgit v1.2.3 From 6dbf48275518b6089d4f4a92d20e460d0a2f96ba Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Thu, 6 Feb 2014 15:21:29 +0000 Subject: passphrase changes update need to save --- .../keychain/ui/EditKeyActivity.java | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index d8489ce65..b3df52726 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -109,15 +109,22 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener ExportHelper mExportHelper; + public void somethingChanged() + { + mNeedsSaving = mUserIdsView.needsSaving(); + mNeedsSaving |= mKeysView.needsSaving(); + mNeedsSaving |= hasPassphraseChanged(); + Toast.makeText(this, "Needs saving: " + Boolean.toString(mNeedsSaving) + "(" + Boolean.toString(mUserIdsView.needsSaving()) + ", " + Boolean.toString(mKeysView.needsSaving()) + ")", Toast.LENGTH_LONG).show(); + } + public void onDeleted(Editor e, boolean wasNewItem) { + somethingChanged(); } public void onEdited() { - mNeedsSaving = mUserIdsView.needsSaving(); - mNeedsSaving |= mKeysView.needsSaving(); - Toast.makeText(this, "Needs saving: " + Boolean.toString(mNeedsSaving), Toast.LENGTH_LONG).show(); + somethingChanged(); } @Override @@ -400,6 +407,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener .getString(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE); updatePassPhraseButtonText(); + somethingChanged(); } } }; @@ -471,6 +479,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener mNewPassPhrase = mSavedNewPassPhrase; mChangePassPhrase.setVisibility(View.VISIBLE); } + somethingChanged(); } }); } @@ -493,6 +502,15 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } } + public boolean hasPassphraseChanged() + { + if (mNoPassphrase.isChecked()) { + return mIsPassPhraseSet; + } else { + return (mNewPassPhrase != null && !mNewPassPhrase.equals("")); + } + } + private void saveClicked() { long masterKeyId = getMasterKeyId(); try { -- cgit v1.2.3 From d4d6de1bc5c538c17613f5918e70ee0932637915 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Thu, 6 Feb 2014 20:07:04 +0000 Subject: select old date doesn't need save --- .../java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 009b0cb10..ba10c7603 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -88,7 +88,11 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { if (mDatePickerResultCount++ == 0) { GregorianCalendar date = new GregorianCalendar(TimeZone.getTimeZone("UTC")); date.set(year, monthOfYear, dayOfMonth); - setExpiryDate(date); + long numDays = (date.getTimeInMillis() / 86400000) - (mOriginalExpiryDate.getTimeInMillis() / 86400000); + if (numDays == 0) + setExpiryDate(mOriginalExpiryDate); + else + setExpiryDate(date); if (mEditorListener != null) { mEditorListener.onEdited(); } @@ -231,7 +235,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { } else { cal.setTime(PgpKeyHelper.getExpiryDate(key)); setExpiryDate(cal); - mOriginalExpiryDate = cal; // TODO: ensure time doesn't matter when selecting the same date as before + mOriginalExpiryDate = cal; } } -- cgit v1.2.3 From aee4ec6d1f5b41d882dea747915af93cd7d84652 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Thu, 6 Feb 2014 22:16:41 +0000 Subject: action bar and a small fix --- .../keychain/ui/EditKeyActivity.java | 57 ++++++++++++---------- .../keychain/ui/widget/SectionView.java | 3 ++ .../keychain/ui/widget/UserIdEditor.java | 8 +-- OpenPGP-Keychain/src/main/res/menu/key_edit.xml | 6 +++ 4 files changed, 44 insertions(+), 30 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index b3df52726..89af2d683 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -55,6 +55,7 @@ import android.os.Handler; import android.os.Message; import android.os.Messenger; import android.support.v7.app.ActionBarActivity; +import android.support.v4.app.ActivityCompat; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; @@ -97,6 +98,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener private String mSavedNewPassPhrase = null; private boolean mIsPassPhraseSet; private boolean mNeedsSaving; + private MenuItem mSaveButton; private BootstrapButton mChangePassPhrase; @@ -109,12 +111,19 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener ExportHelper mExportHelper; - public void somethingChanged() + public boolean needsSaving() { mNeedsSaving = mUserIdsView.needsSaving(); mNeedsSaving |= mKeysView.needsSaving(); mNeedsSaving |= hasPassphraseChanged(); - Toast.makeText(this, "Needs saving: " + Boolean.toString(mNeedsSaving) + "(" + Boolean.toString(mUserIdsView.needsSaving()) + ", " + Boolean.toString(mKeysView.needsSaving()) + ")", Toast.LENGTH_LONG).show(); + return mNeedsSaving; + } + + + public void somethingChanged() + { + ActivityCompat.invalidateOptionsMenu(this); + //Toast.makeText(this, "Needs saving: " + Boolean.toString(mNeedsSaving) + "(" + Boolean.toString(mUserIdsView.needsSaving()) + ", " + Boolean.toString(mKeysView.needsSaving()) + ")", Toast.LENGTH_LONG).show(); } public void onDeleted(Editor e, boolean wasNewItem) @@ -133,6 +142,10 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener mExportHelper = new ExportHelper(this); + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setIcon(android.R.color.transparent); + getSupportActionBar().setHomeButtonEnabled(true); + mUserIds = new Vector(); mKeys = new Vector(); mKeysUsages = new Vector(); @@ -153,20 +166,6 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener * @param intent */ private void handleActionCreateKey(Intent intent) { - // Inflate a "Done"/"Cancel" custom action bar - ActionBarHelper.setDoneCancelView(getSupportActionBar(), R.string.btn_save, - new View.OnClickListener() { - @Override - public void onClick(View v) { - saveClicked(); - } - }, R.string.btn_do_not_save, new View.OnClickListener() { - @Override - public void onClick(View v) { - cancelClicked(); - } - }); - Bundle extras = intent.getExtras(); mCurrentPassPhrase = ""; @@ -255,15 +254,6 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener * @param intent */ private void handleActionEditKey(Intent intent) { - // Inflate a "Done"/"Cancel" custom action bar - ActionBarHelper.setDoneView(getSupportActionBar(), R.string.btn_save, - new View.OnClickListener() { - @Override - public void onClick(View v) { - saveClicked(); - } - }); - mDataUri = intent.getData(); if (mDataUri == null) { Log.e(Constants.TAG, "Intent data missing. Should be Uri of key!"); @@ -325,12 +315,17 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.key_edit, menu); + mSaveButton = (MenuItem) menu.findItem(R.id.menu_key_edit_save); + mSaveButton.setEnabled(needsSaving()); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { + case android.R.id.home: + cancelClicked(); + return true; case R.id.menu_key_edit_cancel: cancelClicked(); return true; @@ -353,6 +348,9 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener mExportHelper.deleteKey(mDataUri, Id.type.secret_key, returnHandler); return true; } + case R.id.menu_key_edit_save: + saveClicked(); + return true; } return super.onOptionsItemSelected(item); } @@ -373,8 +371,15 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener Toast.makeText(this, R.string.error_no_secret_key_found, Toast.LENGTH_LONG).show(); } if (masterKey != null) { + boolean isSet = false; for (String userId : new IterableIterator(masterKey.getUserIDs())) { Log.d(Constants.TAG, "Added userId " + userId); + if (!isSet) { + isSet = true; + String[] parts = PgpKeyHelper.splitUserId(userId); + if (parts[0] != null) + setTitle(parts[0]); + } mUserIds.add(userId); } } @@ -465,7 +470,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } }); - // disable passphrase when no passphrase checkobox is checked! + // disable passphrase when no passphrase checkbox is checked! mNoPassphrase.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 072c04f03..21ebff102 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -133,6 +133,9 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor public void onDeleted(Editor editor, boolean wasNewItem) { oldItemDeleted |= !wasNewItem; this.updateEditorsVisible(); + if (mEditorListener != null) { + mEditorListener.onEdited(); + } } @Override diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index e3747aeb9..b499a429a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -137,12 +137,12 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene mOriginalName = result[0]; } if (result[1] != null) { - mComment.setText(result[1]); - mOriginalComment = result[1]; + mEmail.setText(result[1]); + mOriginalEmail = result[1]; } if (result[2] != null) { - mEmail.setText(result[2]); - mOriginalEmail = result[2]; + mComment.setText(result[2]); + mOriginalComment = result[2]; } mOriginallyMainUserID = isMainID; diff --git a/OpenPGP-Keychain/src/main/res/menu/key_edit.xml b/OpenPGP-Keychain/src/main/res/menu/key_edit.xml index 16992affb..ede1d03c0 100644 --- a/OpenPGP-Keychain/src/main/res/menu/key_edit.xml +++ b/OpenPGP-Keychain/src/main/res/menu/key_edit.xml @@ -2,6 +2,12 @@ + + Date: Thu, 6 Feb 2014 22:35:27 +0000 Subject: ask for save --- .../keychain/ui/EditKeyActivity.java | 33 ++++++++++++++++++++-- OpenPGP-Keychain/src/main/res/values/strings.xml | 1 + 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 89af2d683..49713db71 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -46,8 +46,10 @@ import org.sufficientlysecure.keychain.ui.widget.Editor.EditorListener; import org.sufficientlysecure.keychain.util.IterableIterator; import org.sufficientlysecure.keychain.util.Log; +import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -604,8 +606,35 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } private void cancelClicked() { - setResult(RESULT_CANCELED); - finish(); + if (mNeedsSaving && masterCanSign) { //ask if we want to save + AlertDialog.Builder alert = new AlertDialog.Builder( + EditKeyActivity.this); + + alert.setIcon(android.R.drawable.ic_dialog_alert); + alert.setTitle(R.string.warning); + alert.setMessage(EditKeyActivity.this.getString(R.string.ask_save_changed_key)); + + alert.setPositiveButton(EditKeyActivity.this.getString(android.R.string.yes), + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.dismiss(); + saveClicked(); + } + }); + alert.setNegativeButton(this.getString(android.R.string.no), + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.dismiss(); + setResult(RESULT_CANCELED); + finish(); + } + }); + alert.setCancelable(false); + alert.create().show(); + } else { + setResult(RESULT_CANCELED); + finish(); + } } /** diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index becf2417e..69a941b02 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -204,6 +204,7 @@ Do you really want to delete the key \'%s\'?\nYou can\'t undo this! Do you really want to delete all selected keys?\nYou can\'t undo this! Do you really want to delete the SECRET key \'%s\'?\nYou can\'t undo this! + You have made changes to the keyring, would you like to save it? Successfully added %d key -- cgit v1.2.3 From 899fadb9169e93105f633c0925835cce9c413b24 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Thu, 6 Feb 2014 22:43:59 +0000 Subject: can change passwords --- .../main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 49713db71..694e52f71 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -606,7 +606,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } private void cancelClicked() { - if (mNeedsSaving && masterCanSign) { //ask if we want to save + if (mNeedsSaving) { //ask if we want to save AlertDialog.Builder alert = new AlertDialog.Builder( EditKeyActivity.this); -- cgit v1.2.3 From 8d1047d05c3a0e1e1310fb1a47dc6d4f80b2c0f4 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Thu, 6 Feb 2014 22:52:22 +0000 Subject: fix a crash --- .../org/sufficientlysecure/keychain/ui/widget/KeyEditor.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index ba10c7603..fa220313c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -88,11 +88,15 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { if (mDatePickerResultCount++ == 0) { GregorianCalendar date = new GregorianCalendar(TimeZone.getTimeZone("UTC")); date.set(year, monthOfYear, dayOfMonth); - long numDays = (date.getTimeInMillis() / 86400000) - (mOriginalExpiryDate.getTimeInMillis() / 86400000); - if (numDays == 0) - setExpiryDate(mOriginalExpiryDate); - else + if (mOriginalExpiryDate != null) { + long numDays = (date.getTimeInMillis() / 86400000) - (mOriginalExpiryDate.getTimeInMillis() / 86400000); + if (numDays == 0) + setExpiryDate(mOriginalExpiryDate); + else + setExpiryDate(date); + } else { setExpiryDate(date); + } if (mEditorListener != null) { mEditorListener.onEdited(); } -- cgit v1.2.3 From cd2b493ea8d25796bf666b46597e6b6bd416f64b Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sat, 8 Feb 2014 12:12:17 +0000 Subject: small extra check --- .../keychain/ui/EditKeyActivity.java | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 694e52f71..d53a1f836 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -326,7 +326,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: - cancelClicked(); + cancelClicked(); //TODO: why isn't this triggered on my tablet - one of many ui problems I've had with this device. A code compatibility issue or a Samsung fail? return true; case R.id.menu_key_edit_cancel: cancelClicked(); @@ -520,25 +520,27 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener private void saveClicked() { long masterKeyId = getMasterKeyId(); - try { - if (!isPassphraseSet()) { - throw new PgpGeneralException(this.getString(R.string.set_a_passphrase)); - } + if (needsSaving()) { //make sure, as some versions don't support invalidateOptionsMenu + try { + if (!isPassphraseSet()) { + throw new PgpGeneralException(this.getString(R.string.set_a_passphrase)); + } - String passphrase = null; - if (mIsPassPhraseSet) - passphrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId); - else - passphrase = ""; - if (passphrase == null) { - showPassphraseDialog(masterKeyId, masterCanSign); - } else { - mCurrentPassPhrase = passphrase; - finallySaveClicked(); + String passphrase = null; + if (mIsPassPhraseSet) + passphrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId); + else + passphrase = ""; + if (passphrase == null) { + showPassphraseDialog(masterKeyId, masterCanSign); + } else { + mCurrentPassPhrase = passphrase; + finallySaveClicked(); + } + } catch (PgpGeneralException e) { + Toast.makeText(this, getString(R.string.error_message, e.getMessage()), + Toast.LENGTH_SHORT).show(); } - } catch (PgpGeneralException e) { - //Toast.makeText(this, getString(R.string.error_message, e.getMessage()), - // Toast.LENGTH_SHORT).show(); } } -- cgit v1.2.3 From b74ed4643453cd089ec885bb3f56169629f8cacf Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sat, 8 Feb 2014 15:35:44 +0000 Subject: disable export if unsaved --- .../java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java | 8 ++++++-- OpenPGP-Keychain/src/main/res/values/strings.xml | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index d53a1f836..66f23e22e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -332,8 +332,12 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener cancelClicked(); return true; case R.id.menu_key_edit_export_file: - mExportHelper.showExportKeysDialog(mDataUri, Id.type.secret_key, Constants.path.APP_DIR - + "/secexport.asc"); + if (needsSaving()) { + Toast.makeText(this, R.string.error_save_first, Toast.LENGTH_LONG).show(); + } else { + mExportHelper.showExportKeysDialog(mDataUri, Id.type.secret_key, Constants.path.APP_DIR + + "/secexport.asc"); + } return true; case R.id.menu_key_edit_delete: { // Message is received after key is deleted diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index 69a941b02..64c9be32d 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -286,6 +286,7 @@ NFC is not available on your device! Nothing to import! expiry date must come after creation date + please save the keyring first done. -- cgit v1.2.3 From 44ee7137632c2fd8e6d97a8f05a213467ecf1dc6 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sat, 8 Feb 2014 15:51:11 +0000 Subject: fix create keyring crash --- .../sufficientlysecure/keychain/ui/EditKeyActivity.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 66f23e22e..802d29a44 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -115,8 +115,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener public boolean needsSaving() { - mNeedsSaving = mUserIdsView.needsSaving(); - mNeedsSaving |= mKeysView.needsSaving(); + mNeedsSaving = (mUserIdsView == null) ? false : mUserIdsView.needsSaving(); + mNeedsSaving |= (mKeysView == null) ? false : mKeysView.needsSaving(); mNeedsSaving |= hasPassphraseChanged(); return mNeedsSaving; } @@ -515,10 +515,14 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener public boolean hasPassphraseChanged() { - if (mNoPassphrase.isChecked()) { - return mIsPassPhraseSet; - } else { - return (mNewPassPhrase != null && !mNewPassPhrase.equals("")); + if (mNoPassphrase != null) { + if (mNoPassphrase.isChecked()) { + return mIsPassPhraseSet; + } else { + return (mNewPassPhrase != null && !mNewPassPhrase.equals("")); + } + }else { + return false; } } -- cgit v1.2.3 From 5def251e62d383f023c62fea1734977e11b0fa27 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sat, 8 Feb 2014 15:59:44 +0000 Subject: keep track of brand new keys, they need saving --- .../java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 802d29a44..9ddfadef1 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -100,6 +100,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener private String mSavedNewPassPhrase = null; private boolean mIsPassPhraseSet; private boolean mNeedsSaving; + private boolean mIsBrandNewKeyring = false; private MenuItem mSaveButton; private BootstrapButton mChangePassPhrase; @@ -118,6 +119,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener mNeedsSaving = (mUserIdsView == null) ? false : mUserIdsView.needsSaving(); mNeedsSaving |= (mKeysView == null) ? false : mKeysView.needsSaving(); mNeedsSaving |= hasPassphraseChanged(); + mNeedsSaving |= mIsBrandNewKeyring; return mNeedsSaving; } @@ -171,6 +173,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener Bundle extras = intent.getExtras(); mCurrentPassPhrase = ""; + mIsBrandNewKeyring = true; if (extras != null) { // if userId is given, prefill the fields @@ -616,7 +619,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } private void cancelClicked() { - if (mNeedsSaving) { //ask if we want to save + if (needsSaving()) { //ask if we want to save AlertDialog.Builder alert = new AlertDialog.Builder( EditKeyActivity.this); -- cgit v1.2.3 From 33f41e66a0a39ab7b8eb48c1055ba16ce8d784f5 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sat, 8 Feb 2014 16:18:30 +0000 Subject: consistent ui --- .../sufficientlysecure/keychain/ui/EditKeyActivity.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 9ddfadef1..a0c2871ae 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -306,22 +306,19 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } } - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - // show menu only on edit - if (mDataUri != null) { - return super.onPrepareOptionsMenu(menu); - } else { - return false; - } - } - @Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.key_edit, menu); mSaveButton = (MenuItem) menu.findItem(R.id.menu_key_edit_save); mSaveButton.setEnabled(needsSaving()); + //totally get rid of some actions for new keys + if (mDataUri == null) { + MenuItem mButton = (MenuItem) menu.findItem(R.id.menu_key_edit_export_file); + mButton.setVisible(false); + mButton = (MenuItem) menu.findItem(R.id.menu_key_edit_delete); + mButton.setVisible(false); + } return true; } -- cgit v1.2.3 From adc6a3ea64c00f35e881e856d2877c2ea88c7e51 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sat, 8 Feb 2014 16:33:37 +0000 Subject: some AS Inspect Code fixes --- .../keychain/ui/EditKeyActivity.java | 33 ++++++++++------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index a0c2871ae..d12a5479d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -26,7 +26,6 @@ import org.spongycastle.openpgp.PGPSecretKeyRing; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.helper.ActionBarHelper; import org.sufficientlysecure.keychain.helper.ExportHelper; import org.sufficientlysecure.keychain.pgp.PgpConversionHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; @@ -218,10 +217,10 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { // get new key from data bundle returned from service Bundle data = message.getData(); - PGPSecretKey masterKey = (PGPSecretKey) PgpConversionHelper + PGPSecretKey masterKey = PgpConversionHelper .BytesToPGPSecretKey(data .getByteArray(KeychainIntentService.RESULT_NEW_KEY)); - PGPSecretKey subKey = (PGPSecretKey) PgpConversionHelper + PGPSecretKey subKey = PgpConversionHelper .BytesToPGPSecretKey(data .getByteArray(KeychainIntentService.RESULT_NEW_KEY2)); @@ -235,7 +234,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener buildLayout(); } - }; + } }; // Create a new Messenger for the communication back @@ -263,7 +262,6 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener if (mDataUri == null) { Log.e(Constants.TAG, "Intent data missing. Should be Uri of key!"); finish(); - return; } else { Log.d(Constants.TAG, "uri: " + mDataUri); @@ -273,19 +271,18 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener long masterKeyId = ProviderHelper.getSecretMasterKeyId(this, keyRingRowId); masterCanSign = ProviderHelper.getSecretMasterKeyCanCertify(this, keyRingRowId); - finallyEdit(masterKeyId, masterCanSign); + finallyEdit(masterKeyId); } } - private void showPassphraseDialog(final long masterKeyId, final boolean masterCanSign) { + private void showPassphraseDialog(final long masterKeyId) { // Message is received after passphrase is cached Handler returnHandler = new Handler() { @Override public void handleMessage(Message message) { if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) { - String passPhrase = PassphraseCacheService.getCachedPassphrase( + mCurrentPassPhrase = PassphraseCacheService.getCachedPassphrase( EditKeyActivity.this, masterKeyId); - mCurrentPassPhrase = passPhrase; finallySaveClicked(); } } @@ -310,13 +307,13 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.key_edit, menu); - mSaveButton = (MenuItem) menu.findItem(R.id.menu_key_edit_save); + mSaveButton = menu.findItem(R.id.menu_key_edit_save); mSaveButton.setEnabled(needsSaving()); //totally get rid of some actions for new keys if (mDataUri == null) { - MenuItem mButton = (MenuItem) menu.findItem(R.id.menu_key_edit_export_file); + MenuItem mButton = menu.findItem(R.id.menu_key_edit_export_file); mButton.setVisible(false); - mButton = (MenuItem) menu.findItem(R.id.menu_key_edit_delete); + mButton = menu.findItem(R.id.menu_key_edit_delete); mButton.setVisible(false); } return true; @@ -362,7 +359,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } @SuppressWarnings("unchecked") - private void finallyEdit(final long masterKeyId, final boolean masterCanSign) { + private void finallyEdit(final long masterKeyId) { if (masterKeyId != 0) { PGPSecretKey masterKey = null; mKeyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(this, masterKeyId); @@ -427,7 +424,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener Messenger messenger = new Messenger(returnHandler); // set title based on isPassphraseSet() - int title = -1; + int title; if (isPassphraseSet()) { title = R.string.title_change_pass_phrase; } else { @@ -534,13 +531,13 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener throw new PgpGeneralException(this.getString(R.string.set_a_passphrase)); } - String passphrase = null; + String passphrase; if (mIsPassPhraseSet) passphrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId); else passphrase = ""; if (passphrase == null) { - showPassphraseDialog(masterKeyId, masterCanSign); + showPassphraseDialog(masterKeyId); } else { mCurrentPassPhrase = passphrase; finallySaveClicked(); @@ -598,7 +595,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener setResult(RESULT_OK, data); finish(); } - }; + } }; // Create a new Messenger for the communication back @@ -661,7 +658,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener boolean gotMainUserId = false; for (int i = 0; i < userIdEditors.getChildCount(); ++i) { UserIdEditor editor = (UserIdEditor) userIdEditors.getChildAt(i); - String userId = null; + String userId; try { userId = editor.getValue(); } catch (UserIdEditor.InvalidEmailException e) { -- cgit v1.2.3 From 75640934a080d21113f501ed604b85de3eab6b51 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sat, 8 Feb 2014 21:04:38 +0000 Subject: saving fixes --- .../keychain/ui/EditKeyActivity.java | 26 +++++++++++----------- .../keychain/ui/widget/KeyEditor.java | 20 +++++++++++------ .../keychain/ui/widget/SectionView.java | 10 ++++++--- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index d12a5479d..132141bc5 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.GregorianCalendar; import java.util.Vector; +import org.spongycastle.bcpg.sig.KeyFlags; import org.spongycastle.openpgp.PGPSecretKey; import org.spongycastle.openpgp.PGPSecretKeyRing; import org.sufficientlysecure.keychain.Constants; @@ -224,15 +225,17 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener .BytesToPGPSecretKey(data .getByteArray(KeychainIntentService.RESULT_NEW_KEY2)); + //We must set the key flags here as they are not set when we make the + //key pair. Because we are not generating hashed packets there... // add master key mKeys.add(masterKey); - mKeysUsages.add(Id.choice.usage.sign_only); //TODO: get from key flags + mKeysUsages.add(KeyFlags.CERTIFY_OTHER); // add sub key mKeys.add(subKey); - mKeysUsages.add(Id.choice.usage.encrypt_only); //TODO: get from key flags + mKeysUsages.add(KeyFlags.ENCRYPT_COMMS + KeyFlags.ENCRYPT_STORAGE); - buildLayout(); + buildLayout(true); } } }; @@ -248,7 +251,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } } } else { - buildLayout(); + buildLayout(false); } } @@ -390,7 +393,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener mCurrentPassPhrase = ""; - buildLayout(); + buildLayout(false); mIsPassPhraseSet = PassphraseCacheService.hasPassphrase(this, masterKeyId); if (!mIsPassPhraseSet) { // check "no passphrase" checkbox and remove button @@ -440,8 +443,9 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener /** * Build layout based on mUserId, mKeys and mKeysUsages Vectors. It creates Views for every user * id and key. + * @param newKeys */ - private void buildLayout() { + private void buildLayout(boolean newKeys) { setContentView(R.layout.edit_key_activity); // find views @@ -461,7 +465,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener mKeysView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false); mKeysView.setType(Id.type.key); mKeysView.setCanEdit(masterCanSign); - mKeysView.setKeys(mKeys, mKeysUsages); + mKeysView.setKeys(mKeys, mKeysUsages, newKeys); mKeysView.setEditorListener(this); container.addView(mKeysView); @@ -607,8 +611,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener // start service with intent startService(intent); } catch (PgpGeneralException e) { - //Toast.makeText(this, getString(R.string.error_message, e.getMessage()), - // Toast.LENGTH_SHORT).show(); + Toast.makeText(this, getString(R.string.error_message, e.getMessage()), + Toast.LENGTH_SHORT).show(); } } @@ -665,10 +669,6 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener throw new PgpGeneralException(e.getMessage()); } - if (userId.equals("")) { - continue; - } - if (editor.isMainUserId()) { userIds.add(0, userId); gotMainUserId = true; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index fa220313c..5ce5d89d7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -24,6 +24,7 @@ import java.util.TimeZone; import java.util.Vector; import org.spongycastle.bcpg.sig.KeyFlags; +import org.spongycastle.openpgp.PGPKeyFlags; import org.spongycastle.openpgp.PGPPublicKey; import org.spongycastle.openpgp.PGPSecretKey; import org.sufficientlysecure.keychain.R; @@ -216,17 +217,22 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { } int selectId = 0; - if (key.isMasterKey()) - mChkCertify.setChecked(PgpKeyHelper.isCertificationKey(key)); - mChkSign.setChecked(PgpKeyHelper.isSigningKey(key)); - mChkEncrypt.setChecked(PgpKeyHelper.isEncryptionKey(key)); - mChkAuthenticate.setChecked(PgpKeyHelper.isAuthenticationKey(key)); mIsNewKey = isNewKey; - if (isNewKey) + if (isNewKey) { mUsage = usage; - else { + mChkCertify.setChecked((usage &= KeyFlags.CERTIFY_OTHER) == KeyFlags.CERTIFY_OTHER); + mChkSign.setChecked((usage &= KeyFlags.SIGN_DATA) == KeyFlags.SIGN_DATA); + mChkEncrypt.setChecked(((usage &= KeyFlags.ENCRYPT_COMMS) == KeyFlags.ENCRYPT_COMMS) || + ((usage &= KeyFlags.ENCRYPT_STORAGE) == KeyFlags.ENCRYPT_STORAGE)); + mChkAuthenticate.setChecked((usage &= KeyFlags.AUTHENTICATION) == KeyFlags.AUTHENTICATION); + } else { mUsage = PgpKeyHelper.getKeyUsage(key); mOriginalUsage = mUsage; + if (key.isMasterKey()) + mChkCertify.setChecked(PgpKeyHelper.isCertificationKey(key)); + mChkSign.setChecked(PgpKeyHelper.isSigningKey(key)); + mChkEncrypt.setChecked(PgpKeyHelper.isEncryptionKey(key)); + mChkAuthenticate.setChecked(PgpKeyHelper.isAuthenticationKey(key)); } GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC")); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 21ebff102..315a8faba 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -18,6 +18,7 @@ package org.sufficientlysecure.keychain.ui.widget; import java.util.Vector; +import org.spongycastle.openpgp.PGPKeyFlags; import org.spongycastle.openpgp.PGPSecretKey; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; @@ -285,7 +286,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor this.updateEditorsVisible(); } - public void setKeys(Vector list, Vector usages) { + public void setKeys(Vector list, Vector usages, boolean newKeys) { if (mType != Id.type.key) { return; } @@ -298,7 +299,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor false); view.setEditorListener(this); boolean isMasterKey = (mEditors.getChildCount() == 0); - view.setValue(list.get(i), isMasterKey, usages.get(i), false); + view.setValue(list.get(i), isMasterKey, usages.get(i), newKeys); view.setCanEdit(canEdit); mEditors.addView(view); } @@ -370,7 +371,10 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor KeyEditor view = (KeyEditor) mInflater.inflate(R.layout.edit_key_key_item, mEditors, false); view.setEditorListener(SectionView.this); - view.setValue(newKey, newKey.isMasterKey(), -1, true); + int usage = 0; + if (mEditors.getChildCount() == 0) + usage = PGPKeyFlags.CAN_CERTIFY; + view.setValue(newKey, newKey.isMasterKey(), usage, true); mEditors.addView(view); SectionView.this.updateEditorsVisible(); if (mEditorListener != null) { -- cgit v1.2.3 From 5bd0a2ebc8d4738d53d5ba3e112069ca6a0d049a Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sat, 8 Feb 2014 21:38:56 +0000 Subject: fix Android Studio analysis issues --- .../keychain/pgp/PgpKeyOperation.java | 54 +++++++--------------- 1 file changed, 17 insertions(+), 37 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index d2793a859..7ab5df613 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -23,6 +23,7 @@ import java.security.InvalidAlgorithmParameterException; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; +import java.security.PublicKey; import java.security.SecureRandom; import java.security.SignatureException; import java.util.ArrayList; @@ -56,6 +57,7 @@ import org.spongycastle.openpgp.operator.PGPContentSignerBuilder; import org.spongycastle.openpgp.operator.PGPDigestCalculator; import org.spongycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder; import org.spongycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBuilder; +import org.spongycastle.openpgp.operator.jcajce.JcaPGPKeyConverter; import org.spongycastle.openpgp.operator.jcajce.JcaPGPKeyPair; import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder; import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder; @@ -71,8 +73,8 @@ import org.sufficientlysecure.keychain.util.ProgressDialogUpdater; import android.content.Context; public class PgpKeyOperation { - private Context mContext; - private ProgressDialogUpdater mProgress; + private final Context mContext; + private final ProgressDialogUpdater mProgress; private static final int[] PREFERRED_SYMMETRIC_ALGORITHMS = new int[] { SymmetricKeyAlgorithmTags.AES_256, SymmetricKeyAlgorithmTags.AES_192, @@ -90,34 +92,18 @@ public class PgpKeyOperation { this.mProgress = progress; } - public void updateProgress(int message, int current, int total) { + void updateProgress(int message, int current, int total) { if (mProgress != null) { mProgress.setProgress(message, current, total); } } - public void updateProgress(int current, int total) { + void updateProgress(int current, int total) { if (mProgress != null) { mProgress.setProgress(current, total); } } - /** - * Creates new secret key. - * - * @param algorithmChoice - * @param keySize - * @param passPhrase - * @param isMasterKey - * @return - * @throws NoSuchAlgorithmException - * @throws PGPException - * @throws NoSuchProviderException - * @throws PgpGeneralException - * @throws InvalidAlgorithmParameterException - */ - - // TODO: key flags? public PGPSecretKey createKey(int algorithmChoice, int keySize, String passPhrase, boolean isMasterKey) throws NoSuchAlgorithmException, PGPException, NoSuchProviderException, PgpGeneralException, InvalidAlgorithmParameterException { @@ -130,8 +116,8 @@ public class PgpKeyOperation { passPhrase = ""; } - int algorithm = 0; - KeyPairGenerator keyGen = null; + int algorithm; + KeyPairGenerator keyGen; switch (algorithmChoice) { case Id.choice.algorithm.dsa: { @@ -183,15 +169,13 @@ public class PgpKeyOperation { PGPEncryptedData.CAST5, sha1Calc) .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(passPhrase.toCharArray()); - PGPSecretKey secKey = new PGPSecretKey(keyPair.getPrivateKey(), keyPair.getPublicKey(), + return new PGPSecretKey(keyPair.getPrivateKey(), keyPair.getPublicKey(), sha1Calc, isMasterKey, keyEncryptor); - return secKey; } public void changeSecretKeyPassphrase(PGPSecretKeyRing keyRing, String oldPassPhrase, - String newPassPhrase) throws IOException, PGPException, PGPException, - NoSuchProviderException { + String newPassPhrase) throws IOException, PGPException { updateProgress(R.string.progress_building_key, 0, 100); if (oldPassPhrase == null) { @@ -219,9 +203,8 @@ public class PgpKeyOperation { public void buildSecretKey(ArrayList userIds, ArrayList keys, ArrayList keysUsages, ArrayList keysExpiryDates, - long masterKeyId, String oldPassPhrase, - String newPassPhrase) throws PgpGeneralException, NoSuchProviderException, - PGPException, NoSuchAlgorithmException, SignatureException, IOException { + String oldPassPhrase, String newPassPhrase) throws PgpGeneralException, + PGPException, SignatureException, IOException { Log.d(Constants.TAG, "userIds: " + userIds.toString()); @@ -237,17 +220,16 @@ public class PgpKeyOperation { updateProgress(R.string.progress_preparing_master_key, 10, 100); int usageId = keysUsages.get(0); - boolean canSign = (usageId & KeyFlags.SIGN_DATA) > 0; - boolean canEncrypt = (usageId & (KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE)) > 0; - + boolean canSign; String mainUserId = userIds.get(0); PGPSecretKey masterKey = keys.get(0); // this removes all userIds and certifications previously attached to the masterPublicKey PGPPublicKey tmpKey = masterKey.getPublicKey(); - PGPPublicKey masterPublicKey = new PGPPublicKey(tmpKey.getAlgorithm(), - tmpKey.getKey(new BouncyCastleProvider()), tmpKey.getCreationTime()); + PublicKey tmpPuK = new JcaPGPKeyConverter().setProvider(new BouncyCastleProvider()).getPublicKey(tmpKey); + PGPPublicKey masterPublicKey = new JcaPGPKeyConverter().getPGPPublicKey(tmpKey.getAlgorithm(), + tmpPuK, tmpKey.getCreationTime()); // already done by code above: // PGPPublicKey masterPublicKey = masterKey.getPublicKey(); @@ -347,7 +329,6 @@ public class PgpKeyOperation { usageId = keysUsages.get(i); canSign = (usageId & KeyFlags.SIGN_DATA) > 0; //todo - separate function for this - canEncrypt = (usageId & (KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE)) > 0; if (canSign) { Date todayDate = new Date(); //both sig times the same // cross-certify signing keys @@ -396,8 +377,7 @@ public class PgpKeyOperation { } public PGPPublicKeyRing signKey(long masterKeyId, long pubKeyId, String passphrase) - throws PgpGeneralException, NoSuchAlgorithmException, NoSuchProviderException, - PGPException, SignatureException { + throws PgpGeneralException, PGPException, SignatureException { if (passphrase == null) { throw new PgpGeneralException("Unable to obtain passphrase"); } else { -- cgit v1.2.3 From e150004e32d4f4278950dc2b24a9cf70885c468f Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sat, 8 Feb 2014 21:42:04 +0000 Subject: should have used refactor... --- .../org/sufficientlysecure/keychain/service/KeychainIntentService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 657d40a5a..a31ddc53e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -542,7 +542,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial ProviderHelper.getPGPSecretKeyRingByKeyId(this, masterKeyId), oldPassPhrase, newPassPhrase); } else { - keyOperations.buildSecretKey(userIds, keys, keysUsages, keysExpiryDates, masterKeyId, + keyOperations.buildSecretKey(userIds, keys, keysUsages, keysExpiryDates, oldPassPhrase, newPassPhrase); } PassphraseCacheService.addCachedPassphrase(this, masterKeyId, newPassPhrase); -- cgit v1.2.3 From 076a7ec4a16a6db5df0bbe5490d44cbd514f10c1 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Thu, 13 Feb 2014 22:05:36 +0000 Subject: save work, this code doesn't work... --- .../keychain/pgp/PgpKeyOperation.java | 34 ++++++++++------------ .../keychain/service/KeychainIntentService.java | 11 +++++-- .../keychain/ui/EditKeyActivity.java | 15 ++++++++++ .../keychain/ui/widget/SectionView.java | 19 ++++++++++++ 4 files changed, 58 insertions(+), 21 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 7ab5df613..505d3ba55 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -23,7 +23,6 @@ import java.security.InvalidAlgorithmParameterException; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; -import java.security.PublicKey; import java.security.SecureRandom; import java.security.SignatureException; import java.util.ArrayList; @@ -35,7 +34,6 @@ import org.spongycastle.bcpg.CompressionAlgorithmTags; import org.spongycastle.bcpg.HashAlgorithmTags; import org.spongycastle.bcpg.SymmetricKeyAlgorithmTags; import org.spongycastle.bcpg.sig.KeyFlags; -import org.spongycastle.jce.provider.BouncyCastleProvider; import org.spongycastle.jce.spec.ElGamalParameterSpec; import org.spongycastle.openpgp.PGPEncryptedData; import org.spongycastle.openpgp.PGPException; @@ -57,7 +55,6 @@ import org.spongycastle.openpgp.operator.PGPContentSignerBuilder; import org.spongycastle.openpgp.operator.PGPDigestCalculator; import org.spongycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder; import org.spongycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBuilder; -import org.spongycastle.openpgp.operator.jcajce.JcaPGPKeyConverter; import org.spongycastle.openpgp.operator.jcajce.JcaPGPKeyPair; import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder; import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder; @@ -201,9 +198,7 @@ public class PgpKeyOperation { } - public void buildSecretKey(ArrayList userIds, ArrayList keys, - ArrayList keysUsages, ArrayList keysExpiryDates, - String oldPassPhrase, String newPassPhrase) throws PgpGeneralException, + public void buildSecretKey(ArrayList userIds, ArrayList OriginalIDs, ArrayList deletedIDs, ArrayList keys, boolean[] modded_keys, String newPassPhrase, ArrayList keysExpiryDates, String oldPassPhrase, ArrayList keysUsages) throws PgpGeneralException, PGPException, SignatureException, IOException { Log.d(Constants.TAG, "userIds: " + userIds.toString()); @@ -226,10 +221,7 @@ public class PgpKeyOperation { PGPSecretKey masterKey = keys.get(0); // this removes all userIds and certifications previously attached to the masterPublicKey - PGPPublicKey tmpKey = masterKey.getPublicKey(); - PublicKey tmpPuK = new JcaPGPKeyConverter().setProvider(new BouncyCastleProvider()).getPublicKey(tmpKey); - PGPPublicKey masterPublicKey = new JcaPGPKeyConverter().getPGPPublicKey(tmpKey.getAlgorithm(), - tmpPuK, tmpKey.getCreationTime()); + PGPPublicKey masterPublicKey = masterKey.getPublicKey(); // already done by code above: // PGPPublicKey masterPublicKey = masterKey.getPublicKey(); @@ -243,6 +235,8 @@ public class PgpKeyOperation { // masterPublicKey = masterPublicKeyRmCert; // } + + PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider( Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassPhrase.toCharArray()); PGPPrivateKey masterPrivateKey = masterKey.extractPrivateKey(keyDecryptor); @@ -250,18 +244,22 @@ public class PgpKeyOperation { updateProgress(R.string.progress_certifying_master_key, 20, 100); // TODO: if we are editing a key, keep old certs, don't remake certs we don't have to. - + int user_id_index = 0; for (String userId : userIds) { - PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( - masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1) - .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME); - PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder); + if (OriginalIDs[user_id_index]) { + PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( + masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1) + .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME); + PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder); - sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey); + sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey); - PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); + PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); - masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification); + masterPublicKey = PGPPublicKey.removeCertification(); + masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification); + } + user_id_index++; } PGPKeyPair masterKeyPair = new PGPKeyPair(masterPublicKey, masterPrivateKey); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index a31ddc53e..4cace2658 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -54,7 +54,6 @@ import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; import org.sufficientlysecure.keychain.util.HkpKeyServer; import org.sufficientlysecure.keychain.util.InputData; import org.sufficientlysecure.keychain.util.Log; -import org.sufficientlysecure.keychain.util.PositionAwareInputStream; import org.sufficientlysecure.keychain.util.ProgressDialogUpdater; import android.app.IntentService; @@ -135,6 +134,9 @@ public class KeychainIntentService extends IntentService implements ProgressDial public static final String SAVE_KEYRING_KEYS_EXPIRY_DATES = "keys_expiry_dates"; public static final String SAVE_KEYRING_MASTER_KEY_ID = "master_key_id"; public static final String SAVE_KEYRING_CAN_SIGN = "can_sign"; + public static final String SAVE_KEYRING_ORIGINAL_IDS = "original_ids"; + public static final String SAVE_KEYRING_DELETED_IDS = "deleted_ids"; + public static final String SAVE_KEYRING_MODDED_KEYS = "modified_keys"; // generate key public static final String GENERATE_KEY_ALGORITHM = "algorithm"; @@ -532,6 +534,9 @@ public class KeychainIntentService extends IntentService implements ProgressDial .getByteArray(SAVE_KEYRING_KEYS)); ArrayList keysUsages = data.getIntegerArrayList(SAVE_KEYRING_KEYS_USAGES); ArrayList keysExpiryDates = (ArrayList) data.getSerializable(SAVE_KEYRING_KEYS_EXPIRY_DATES); + ArrayList original_ids = data.getStringArrayList(SAVE_KEYRING_ORIGINAL_IDS); + ArrayList deleted_ids = data.getStringArrayList(SAVE_KEYRING_DELETED_IDS); + boolean[] modded_keys = data.getBooleanArray(SAVE_KEYRING_MODDED_KEYS); long masterKeyId = data.getLong(SAVE_KEYRING_MASTER_KEY_ID); @@ -542,8 +547,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial ProviderHelper.getPGPSecretKeyRingByKeyId(this, masterKeyId), oldPassPhrase, newPassPhrase); } else { - keyOperations.buildSecretKey(userIds, keys, keysUsages, keysExpiryDates, - oldPassPhrase, newPassPhrase); + keyOperations.buildSecretKey(userIds, original_ids, deleted_ids, keys, modded_keys, + newPassPhrase, keysExpiryDates, oldPassPhrase, keysUsages); } PassphraseCacheService.addCachedPassphrase(this, masterKeyId, newPassPhrase); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 132141bc5..5adb65342 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -19,6 +19,7 @@ package org.sufficientlysecure.keychain.ui; import java.util.ArrayList; import java.util.GregorianCalendar; +import java.util.List; import java.util.Vector; import org.spongycastle.bcpg.sig.KeyFlags; @@ -553,6 +554,15 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } } + private boolean[] toPrimitiveArray(final List booleanList) { + final boolean[] primitives = new boolean[booleanList.size()]; + int index = 0; + for (Boolean object : booleanList) { + primitives[index++] = object; + } + return primitives; + } + private void finallySaveClicked() { try { // Send all information needed to service to edit key in other thread @@ -576,6 +586,11 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener getKeysExpiryDates(mKeysView)); data.putLong(KeychainIntentService.SAVE_KEYRING_MASTER_KEY_ID, getMasterKeyId()); data.putBoolean(KeychainIntentService.SAVE_KEYRING_CAN_SIGN, masterCanSign); + data.putStringArrayList(KeychainIntentService.SAVE_KEYRING_ORIGINAL_IDS, ); + data.putBooleanArray(KeychainIntentService.SAVE_KEYRING_ORIGINAL_IDS, + toPrimitiveArray(mUserIdsView.getNeedsSavingArray())); + data.putBooleanArray(KeychainIntentService.SAVE_KEYRING_MODDED_KEYS, + toPrimitiveArray(mKeysView.getNeedsSavingArray())); intent.putExtra(KeychainIntentService.EXTRA_DATA, data); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 315a8faba..5eaf54841 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -16,6 +16,8 @@ package org.sufficientlysecure.keychain.ui.widget; +import java.util.ArrayList; +import java.util.List; import java.util.Vector; import org.spongycastle.openpgp.PGPKeyFlags; @@ -162,6 +164,23 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor return ret; } + public List getNeedsSavingArray() + { + ArrayList mList = new ArrayList(); + for (int i = 0; i < mEditors.getChildCount(); ++i) { + Editor editor = (Editor) mEditors.getChildAt(i); + if (mType == Id.type.user_id) { + try { + if (((UserIdEditor)editor).getValue().equals("")) //other code ignores empty user id + continue; + } catch (UserIdEditor.InvalidEmailException e) { + } + } + mList.add(editor.needsSaving()); + } + return mList; + } + /** {@inheritDoc} */ public void onClick(View v) { if (canEdit) { -- cgit v1.2.3 From ba62d30563ee5dd316528decd272f1bbdcbee5bd Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Fri, 14 Feb 2014 17:40:11 +0000 Subject: propgate through --- .../keychain/ui/EditKeyActivity.java | 7 +++--- .../keychain/ui/widget/SectionView.java | 29 ++++++++++++++++------ .../keychain/ui/widget/UserIdEditor.java | 7 ++++++ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 5adb65342..9ebe73197 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -586,9 +586,10 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener getKeysExpiryDates(mKeysView)); data.putLong(KeychainIntentService.SAVE_KEYRING_MASTER_KEY_ID, getMasterKeyId()); data.putBoolean(KeychainIntentService.SAVE_KEYRING_CAN_SIGN, masterCanSign); - data.putStringArrayList(KeychainIntentService.SAVE_KEYRING_ORIGINAL_IDS, ); - data.putBooleanArray(KeychainIntentService.SAVE_KEYRING_ORIGINAL_IDS, - toPrimitiveArray(mUserIdsView.getNeedsSavingArray())); + data.putStringArrayList(KeychainIntentService.SAVE_KEYRING_DELETED_IDS, + mUserIdsView.getDeletedIDs()); + data.putStringArrayList(KeychainIntentService.SAVE_KEYRING_ORIGINAL_IDS, + mUserIdsView.getOriginalIDs()); data.putBooleanArray(KeychainIntentService.SAVE_KEYRING_MODDED_KEYS, toPrimitiveArray(mKeysView.getNeedsSavingArray())); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 5eaf54841..788a80a60 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -65,6 +65,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor private int mNewKeySize; private boolean canEdit = true; private boolean oldItemDeleted = false; + private ArrayList mDeletedIDs = new ArrayList(); private ActionBarActivity mActivity; @@ -135,6 +136,8 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor /** {@inheritDoc} */ public void onDeleted(Editor editor, boolean wasNewItem) { oldItemDeleted |= !wasNewItem; + if (oldItemDeleted && mType == Id.type.user_id) + mDeletedIDs.add(((UserIdEditor)editor).getOriginalID()); this.updateEditorsVisible(); if (mEditorListener != null) { mEditorListener.onEdited(); @@ -164,18 +167,30 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor return ret; } + public ArrayList getOriginalIDs() + { + ArrayList orig = new ArrayList(); + if (mType == Id.type.user_id) { + for (int i = 0; i < mEditors.getChildCount(); ++i) { + UserIdEditor editor = (UserIdEditor) mEditors.getChildAt(i); + orig.add(editor.getOriginalID()); + } + return orig; + } else { + return null; + } + } + + public ArrayList getDeletedIDs() + { + return mDeletedIDs; + } + public List getNeedsSavingArray() { ArrayList mList = new ArrayList(); for (int i = 0; i < mEditors.getChildCount(); ++i) { Editor editor = (Editor) mEditors.getChildAt(i); - if (mType == Id.type.user_id) { - try { - if (((UserIdEditor)editor).getValue().equals("")) //other code ignores empty user id - continue; - } catch (UserIdEditor.InvalidEmailException e) { - } - } mList.add(editor.needsSaving()); } return mList; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index b499a429a..37ab0e051 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -40,6 +40,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene private BootstrapButton mDeleteButton; private RadioButton mIsMainUserId; + private String mOriginalID; private EditText mName; private String mOriginalName; private EditText mEmail; @@ -130,6 +131,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene mEmail.setText(""); mOriginalEmail = ""; mIsNewId = isNewId; + mOriginalID = userId; String[] result = PgpKeyHelper.splitUserId(userId); if (result[0] != null) { @@ -226,4 +228,9 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene retval |= mIsNewId; return retval; } + + public String getOriginalID() + { + return mOriginalID; + } } -- cgit v1.2.3 From c9d9c800b609d4bc9ed4b9f20a4085d4ad3f13bc Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sat, 15 Feb 2014 14:45:57 +0000 Subject: pass through deleted keys --- .../sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 2 +- .../keychain/service/KeychainIntentService.java | 5 ++++- .../sufficientlysecure/keychain/ui/EditKeyActivity.java | 3 +++ .../keychain/ui/widget/SectionView.java | 15 +++++++++++++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 505d3ba55..c57718540 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -198,7 +198,7 @@ public class PgpKeyOperation { } - public void buildSecretKey(ArrayList userIds, ArrayList OriginalIDs, ArrayList deletedIDs, ArrayList keys, boolean[] modded_keys, String newPassPhrase, ArrayList keysExpiryDates, String oldPassPhrase, ArrayList keysUsages) throws PgpGeneralException, + public void buildSecretKey(ArrayList userIds, ArrayList OriginalIDs, ArrayList deletedIDs, ArrayList keys, boolean[] modded_keys, ArrayList deleted_keys, ArrayList keysExpiryDates, ArrayList keysUsages, String newPassPhrase, String oldPassPhrase) throws PgpGeneralException, PGPException, SignatureException, IOException { Log.d(Constants.TAG, "userIds: " + userIds.toString()); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 4cace2658..5e5735c88 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -137,6 +137,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial public static final String SAVE_KEYRING_ORIGINAL_IDS = "original_ids"; public static final String SAVE_KEYRING_DELETED_IDS = "deleted_ids"; public static final String SAVE_KEYRING_MODDED_KEYS = "modified_keys"; + public static final String SAVE_KEYRING_DELETED_KEYS = "deleted_keys"; // generate key public static final String GENERATE_KEY_ALGORITHM = "algorithm"; @@ -537,6 +538,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial ArrayList original_ids = data.getStringArrayList(SAVE_KEYRING_ORIGINAL_IDS); ArrayList deleted_ids = data.getStringArrayList(SAVE_KEYRING_DELETED_IDS); boolean[] modded_keys = data.getBooleanArray(SAVE_KEYRING_MODDED_KEYS); + ArrayList deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(data + .getByteArray(SAVE_KEYRING_DELETED_KEYS)); long masterKeyId = data.getLong(SAVE_KEYRING_MASTER_KEY_ID); @@ -548,7 +551,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial oldPassPhrase, newPassPhrase); } else { keyOperations.buildSecretKey(userIds, original_ids, deleted_ids, keys, modded_keys, - newPassPhrase, keysExpiryDates, oldPassPhrase, keysUsages); + deletedKeys, keysExpiryDates, keysUsages, newPassPhrase, oldPassPhrase); } PassphraseCacheService.addCachedPassphrase(this, masterKeyId, newPassPhrase); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 9ebe73197..ec7dd1330 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -580,6 +580,9 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener ArrayList keys = getKeys(mKeysView); data.putByteArray(KeychainIntentService.SAVE_KEYRING_KEYS, PgpConversionHelper.PGPSecretKeyArrayListToBytes(keys)); + ArrayList dKeys = mKeysView.getDeletedKeys(); + data.putByteArray(KeychainIntentService.SAVE_KEYRING_DELETED_KEYS, + PgpConversionHelper.PGPSecretKeyArrayListToBytes(dKeys)); data.putIntegerArrayList(KeychainIntentService.SAVE_KEYRING_KEYS_USAGES, getKeysUsages(mKeysView)); data.putSerializable(KeychainIntentService.SAVE_KEYRING_KEYS_EXPIRY_DATES, diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 788a80a60..369288d2c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -66,6 +66,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor private boolean canEdit = true; private boolean oldItemDeleted = false; private ArrayList mDeletedIDs = new ArrayList(); + private ArrayList mDeletedKeys = new ArrayList(); private ActionBarActivity mActivity; @@ -136,8 +137,13 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor /** {@inheritDoc} */ public void onDeleted(Editor editor, boolean wasNewItem) { oldItemDeleted |= !wasNewItem; - if (oldItemDeleted && mType == Id.type.user_id) - mDeletedIDs.add(((UserIdEditor)editor).getOriginalID()); + if (oldItemDeleted) { + if (mType == Id.type.user_id) + mDeletedIDs.add(((UserIdEditor)editor).getOriginalID()); + else if (mType == Id.type.key) + mDeletedKeys.add(((KeyEditor)editor).getValue()); + + } this.updateEditorsVisible(); if (mEditorListener != null) { mEditorListener.onEdited(); @@ -186,6 +192,11 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor return mDeletedIDs; } + public ArrayList getDeletedKeys() + { + return mDeletedKeys; + } + public List getNeedsSavingArray() { ArrayList mList = new ArrayList(); -- cgit v1.2.3 From 034deaacba5cdccf422fbba26d6244c0a4cf2554 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Fri, 21 Feb 2014 15:01:59 +0000 Subject: initial split into two functions --- .../keychain/pgp/PgpKeyOperation.java | 178 ++++++++++++++++++--- 1 file changed, 154 insertions(+), 24 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index c57718540..6055aebfc 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -198,12 +198,158 @@ public class PgpKeyOperation { } - public void buildSecretKey(ArrayList userIds, ArrayList OriginalIDs, ArrayList deletedIDs, ArrayList keys, boolean[] modded_keys, ArrayList deleted_keys, ArrayList keysExpiryDates, ArrayList keysUsages, String newPassPhrase, String oldPassPhrase) throws PgpGeneralException, + private void buildNewSecretKey(ArrayList userIds, ArrayList keys, ArrayList keysExpiryDates, ArrayList keysUsages, String newPassPhrase, String oldPassPhrase) throws PgpGeneralException, PGPException, SignatureException, IOException { - Log.d(Constants.TAG, "userIds: " + userIds.toString()); + int usageId = keysUsages.get(0); + boolean canSign; + String mainUserId = userIds.get(0); + + PGPSecretKey masterKey = keys.get(0); + + // this removes all userIds and certifications previously attached to the masterPublicKey + PGPPublicKey masterPublicKey = masterKey.getPublicKey(); + + PGPSecretKeyRing mKR = ProviderHelper.getPGPSecretKeyRingByKeyId(mContext, masterKey.getKeyID()); + + PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider( + Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassPhrase.toCharArray()); + PGPPrivateKey masterPrivateKey = masterKey.extractPrivateKey(keyDecryptor); + + updateProgress(R.string.progress_certifying_master_key, 20, 100); + int user_id_index = 0; + for (String userId : userIds) { + PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( + masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1) + .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME); + PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder); + + sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey); + + PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); + masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification); + user_id_index++; + } + + PGPKeyPair masterKeyPair = new PGPKeyPair(masterPublicKey, masterPrivateKey); + + PGPSignatureSubpacketGenerator hashedPacketsGen = new PGPSignatureSubpacketGenerator(); + PGPSignatureSubpacketGenerator unhashedPacketsGen = new PGPSignatureSubpacketGenerator(); + + hashedPacketsGen.setKeyFlags(true, usageId); + + hashedPacketsGen.setPreferredSymmetricAlgorithms(true, PREFERRED_SYMMETRIC_ALGORITHMS); + hashedPacketsGen.setPreferredHashAlgorithms(true, PREFERRED_HASH_ALGORITHMS); + hashedPacketsGen.setPreferredCompressionAlgorithms(true, PREFERRED_COMPRESSION_ALGORITHMS); + + if (keysExpiryDates.get(0) != null) { + GregorianCalendar creationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC")); + creationDate.setTime(masterPublicKey.getCreationTime()); + GregorianCalendar expiryDate = keysExpiryDates.get(0); + //note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c + //here we purposefully ignore partial days in each date - long type has no fractional part! + long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000); + if (numDays <= 0) + throw new PgpGeneralException(mContext.getString(R.string.error_expiry_must_come_after_creation)); + hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400); + } else { + hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding, + //this happens anyway + } + + updateProgress(R.string.progress_building_master_key, 30, 100); + + // define hashing and signing algos + PGPDigestCalculator sha1Calc = new JcaPGPDigestCalculatorProviderBuilder().build().get( + HashAlgorithmTags.SHA1); + PGPContentSignerBuilder certificationSignerBuilder = new JcaPGPContentSignerBuilder( + masterKeyPair.getPublicKey().getAlgorithm(), HashAlgorithmTags.SHA1); + + // Build key encrypter based on passphrase + PBESecretKeyEncryptor keyEncryptor = new JcePBESecretKeyEncryptorBuilder( + PGPEncryptedData.CAST5, sha1Calc) + .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( + newPassPhrase.toCharArray()); + + PGPKeyRingGenerator keyGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, + masterKeyPair, mainUserId, sha1Calc, hashedPacketsGen.generate(), + unhashedPacketsGen.generate(), certificationSignerBuilder, keyEncryptor); + + updateProgress(R.string.progress_adding_sub_keys, 40, 100); + + for (int i = 1; i < keys.size(); ++i) { + updateProgress(40 + 50 * (i - 1) / (keys.size() - 1), 100); + + PGPSecretKey subKey = keys.get(i); + PGPPublicKey subPublicKey = subKey.getPublicKey(); + + PBESecretKeyDecryptor keyDecryptor2 = new JcePBESecretKeyDecryptorBuilder() + .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( + oldPassPhrase.toCharArray()); + PGPPrivateKey subPrivateKey = subKey.extractPrivateKey(keyDecryptor2); + + // TODO: now used without algorithm and creation time?! (APG 1) + PGPKeyPair subKeyPair = new PGPKeyPair(subPublicKey, subPrivateKey); + + hashedPacketsGen = new PGPSignatureSubpacketGenerator(); + unhashedPacketsGen = new PGPSignatureSubpacketGenerator(); + + usageId = keysUsages.get(i); + canSign = (usageId & KeyFlags.SIGN_DATA) > 0; //todo - separate function for this + if (canSign) { + Date todayDate = new Date(); //both sig times the same + // cross-certify signing keys + hashedPacketsGen.setSignatureCreationTime(false, todayDate); //set outer creation time + PGPSignatureSubpacketGenerator subHashedPacketsGen = new PGPSignatureSubpacketGenerator(); + subHashedPacketsGen.setSignatureCreationTime(false, todayDate); //set inner creation time + PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( + subPublicKey.getAlgorithm(), PGPUtil.SHA1) + .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME); + PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder); + sGen.init(PGPSignature.PRIMARYKEY_BINDING, subPrivateKey); + sGen.setHashedSubpackets(subHashedPacketsGen.generate()); + PGPSignature certification = sGen.generateCertification(masterPublicKey, + subPublicKey); + unhashedPacketsGen.setEmbeddedSignature(false, certification); + } + hashedPacketsGen.setKeyFlags(false, usageId); + + if (keysExpiryDates.get(i) != null) { + GregorianCalendar creationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC")); + creationDate.setTime(subPublicKey.getCreationTime()); + GregorianCalendar expiryDate = keysExpiryDates.get(i); + //note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c + //here we purposefully ignore partial days in each date - long type has no fractional part! + long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000); + if (numDays <= 0) + throw new PgpGeneralException(mContext.getString(R.string.error_expiry_must_come_after_creation)); + hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400); + } else { + hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding, + //this happens anyway + } + + keyGen.addSubKey(subKeyPair, hashedPacketsGen.generate(), unhashedPacketsGen.generate()); + } + + PGPSecretKeyRing secretKeyRing = keyGen.generateSecretKeyRing(); + PGPPublicKeyRing publicKeyRing = keyGen.generatePublicKeyRing(); + + updateProgress(R.string.progress_saving_key_ring, 90, 100); + + ProviderHelper.saveKeyRing(mContext, secretKeyRing); + ProviderHelper.saveKeyRing(mContext, publicKeyRing); + + updateProgress(R.string.progress_done, 100, 100); + } + + public void buildSecretKey(ArrayList userIds, ArrayList OriginalIDs, ArrayList deletedIDs, ArrayList keys, boolean[] modded_keys, ArrayList deleted_keys, ArrayList keysExpiryDates, ArrayList keysUsages, String newPassPhrase, String oldPassPhrase) throws PgpGeneralException, + PGPException, SignatureException, IOException { updateProgress(R.string.progress_building_key, 0, 100); + PGPSecretKey masterKey = keys.get(0); + + PGPSecretKeyRing mKR = ProviderHelper.getPGPSecretKeyRingByKeyId(mContext, masterKey.getKeyID()); if (oldPassPhrase == null) { oldPassPhrase = ""; @@ -212,41 +358,25 @@ public class PgpKeyOperation { newPassPhrase = ""; } - updateProgress(R.string.progress_preparing_master_key, 10, 100); + if (mKR == null) + buildNewSecretKey(userIds, keys, keysExpiryDates, keysUsages, newPassPhrase, oldPassPhrase); //new Keyring + + masterKey = mKR.getSecretKey(); + PGPPublicKey masterPublicKey = masterKey.getPublicKey(); int usageId = keysUsages.get(0); boolean canSign; String mainUserId = userIds.get(0); - PGPSecretKey masterKey = keys.get(0); - - // this removes all userIds and certifications previously attached to the masterPublicKey - PGPPublicKey masterPublicKey = masterKey.getPublicKey(); - - // already done by code above: - // PGPPublicKey masterPublicKey = masterKey.getPublicKey(); - // // Somehow, the PGPPublicKey already has an empty certification attached to it when the - // // keyRing is generated the first time, we remove that when it exists, before adding the - // new - // // ones - // PGPPublicKey masterPublicKeyRmCert = PGPPublicKey.removeCertification(masterPublicKey, - // ""); - // if (masterPublicKeyRmCert != null) { - // masterPublicKey = masterPublicKeyRmCert; - // } - - - PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider( Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassPhrase.toCharArray()); PGPPrivateKey masterPrivateKey = masterKey.extractPrivateKey(keyDecryptor); updateProgress(R.string.progress_certifying_master_key, 20, 100); - // TODO: if we are editing a key, keep old certs, don't remake certs we don't have to. int user_id_index = 0; for (String userId : userIds) { - if (OriginalIDs[user_id_index]) { + if (!OriginalIDs.get(user_id_index).equals(userIds.get(user_id_index))) { PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1) .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME); -- cgit v1.2.3 From c3c311152ef33a6887909dbbeae40e8d01f96a9d Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Fri, 21 Feb 2014 15:09:49 +0000 Subject: put main original id at the top --- .../java/org/sufficientlysecure/keychain/ui/widget/SectionView.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 369288d2c..2e06f3f34 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -179,7 +179,10 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor if (mType == Id.type.user_id) { for (int i = 0; i < mEditors.getChildCount(); ++i) { UserIdEditor editor = (UserIdEditor) mEditors.getChildAt(i); - orig.add(editor.getOriginalID()); + if (editor.isMainUserId()) + orig.add(0, editor.getOriginalID()); + else + orig.add(editor.getOriginalID()); } return orig; } else { -- cgit v1.2.3 From 1a28a4e9214add62b2b1e23b4579e0a4d585f52e Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sat, 22 Feb 2014 13:54:59 +0000 Subject: change how primary id changing is passed through --- .../sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 4 ++-- .../keychain/service/KeychainIntentService.java | 7 +++++-- .../org/sufficientlysecure/keychain/ui/EditKeyActivity.java | 2 ++ .../sufficientlysecure/keychain/ui/widget/SectionView.java | 13 +++++++++++++ .../sufficientlysecure/keychain/ui/widget/UserIdEditor.java | 7 ++++++- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 80831d35f..cc9384821 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -343,7 +343,7 @@ public class PgpKeyOperation { updateProgress(R.string.progress_done, 100, 100); } - public void buildSecretKey(ArrayList userIds, ArrayList OriginalIDs, ArrayList deletedIDs, ArrayList keys, boolean[] modded_keys, ArrayList deleted_keys, ArrayList keysExpiryDates, ArrayList keysUsages, String newPassPhrase, String oldPassPhrase) throws PgpGeneralException, + public void buildSecretKey(ArrayList userIds, ArrayList OriginalIDs, ArrayList deletedIDs, boolean primaryIDChanged, boolean[] modded_keys, ArrayList deleted_keys, ArrayList keysExpiryDates, ArrayList keysUsages, String newPassPhrase, String oldPassPhrase, ArrayList keys) throws PgpGeneralException, PGPException, SignatureException, IOException { updateProgress(R.string.progress_building_key, 0, 100); @@ -386,7 +386,7 @@ public class PgpKeyOperation { PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); - masterPublicKey = PGPPublicKey.removeCertification(); + //masterPublicKey = PGPPublicKey.removeCertification(); masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification); } user_id_index++; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 9e517b93e..73de7ca6e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -128,6 +128,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial public static final String SAVE_KEYRING_NEW_PASSPHRASE = "new_passphrase"; public static final String SAVE_KEYRING_CURRENT_PASSPHRASE = "current_passphrase"; public static final String SAVE_KEYRING_USER_IDS = "user_ids"; + public static final String SAVE_KEYRING_PRIMARY_ID_CHANGED = "primary_id_changed"; public static final String SAVE_KEYRING_KEYS = "keys"; public static final String SAVE_KEYRING_KEYS_USAGES = "keys_usages"; public static final String SAVE_KEYRING_KEYS_EXPIRY_DATES = "keys_expiry_dates"; @@ -549,6 +550,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial boolean[] modded_keys = data.getBooleanArray(SAVE_KEYRING_MODDED_KEYS); ArrayList deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(data .getByteArray(SAVE_KEYRING_DELETED_KEYS)); + boolean primaryChanged = data.getBoolean(SAVE_KEYRING_PRIMARY_ID_CHANGED); long masterKeyId = data.getLong(SAVE_KEYRING_MASTER_KEY_ID); @@ -559,8 +561,9 @@ public class KeychainIntentService extends IntentService implements ProgressDial ProviderHelper.getPGPSecretKeyRingByKeyId(this, masterKeyId), oldPassPhrase, newPassPhrase); } else { - keyOperations.buildSecretKey(userIds, original_ids, deleted_ids, keys, modded_keys, - deletedKeys, keysExpiryDates, keysUsages, newPassPhrase, oldPassPhrase); + keyOperations.buildSecretKey(userIds, original_ids, deleted_ids, primaryChanged, + modded_keys, deletedKeys, keysExpiryDates, keysUsages, newPassPhrase, + oldPassPhrase, keys); } PassphraseCacheService.addCachedPassphrase(this, masterKeyId, newPassPhrase); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index ec7dd1330..09be0dc79 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -595,6 +595,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener mUserIdsView.getOriginalIDs()); data.putBooleanArray(KeychainIntentService.SAVE_KEYRING_MODDED_KEYS, toPrimitiveArray(mKeysView.getNeedsSavingArray())); + data.putBoolean(KeychainIntentService.SAVE_KEYRING_PRIMARY_ID_CHANGED, + mUserIdsView.primaryChanged()); intent.putExtra(KeychainIntentService.EXTRA_DATA, data); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 2e06f3f34..014a891a5 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -169,6 +169,19 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor for (int i = 0; i < mEditors.getChildCount(); ++i) { Editor editor = (Editor) mEditors.getChildAt(i); ret |= editor.needsSaving(); + if (mType == Id.type.user_id) + ret |= ((UserIdEditor)editor).primarySwapped(); + } + return ret; + } + + public boolean primaryChanged() + { + boolean ret = false; + for (int i = 0; i < mEditors.getChildCount(); ++i) { + Editor editor = (Editor) mEditors.getChildAt(i); + if (mType == Id.type.user_id) + ret |= ((UserIdEditor)editor).primarySwapped(); } return ret; } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index 37ab0e051..5098c8713 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -221,7 +221,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene @Override public boolean needsSaving() { - boolean retval = (mOriginallyMainUserID != isMainUserId()); + boolean retval = false; //(mOriginallyMainUserID != isMainUserId()); retval |= !(mOriginalName.equals( ("" + mName.getText()).trim() ) ); retval |= !(mOriginalEmail.equals( ("" + mEmail.getText()).trim() ) ); retval |= !(mOriginalComment.equals( ("" + mComment.getText()).trim() ) ); @@ -229,6 +229,11 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene return retval; } + public boolean primarySwapped() + { + return (mOriginallyMainUserID != isMainUserId()); + } + public String getOriginalID() { return mOriginalID; -- cgit v1.2.3 From a39c73ca12dabba01412083afbf0b58dfb42a79e Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sat, 22 Feb 2014 15:29:19 +0000 Subject: first go at saving IDs correctly --- .../keychain/pgp/PgpKeyOperation.java | 78 ++++++++++++++++++---- 1 file changed, 64 insertions(+), 14 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index cc9384821..f3b289f66 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -28,6 +28,7 @@ import java.security.SignatureException; import java.util.ArrayList; import java.util.Date; import java.util.GregorianCalendar; +import java.util.Iterator; import java.util.TimeZone; import org.spongycastle.bcpg.CompressionAlgorithmTags; @@ -68,6 +69,7 @@ import org.sufficientlysecure.keychain.util.Primes; import org.sufficientlysecure.keychain.util.ProgressDialogUpdater; import android.content.Context; +import android.util.Pair; public class PgpKeyOperation { private final Context mContext; @@ -361,6 +363,21 @@ public class PgpKeyOperation { if (mKR == null) buildNewSecretKey(userIds, keys, keysExpiryDates, keysUsages, newPassPhrase, oldPassPhrase); //new Keyring + /* + IDs - + remove deleted ids + if the primary ID changed we need to: + remove all of the IDs from the keyring, saving their certifications + add them all in again, updating certs of IDs which have changed + else + remove changed IDs and add in with new certs + + Keys + remove deleted keys + if a key is modified, re-sign it + do we need to remove and add in? + */ + masterKey = mKR.getSecretKey(); PGPPublicKey masterPublicKey = masterKey.getPublicKey(); @@ -374,22 +391,55 @@ public class PgpKeyOperation { updateProgress(R.string.progress_certifying_master_key, 20, 100); - int user_id_index = 0; - for (String userId : userIds) { - if (!OriginalIDs.get(user_id_index).equals(userIds.get(user_id_index))) { - PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( - masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1) - .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME); - PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder); - - sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey); - - PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); + for (String delID : deletedIDs) { + masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, delID); + } - //masterPublicKey = PGPPublicKey.removeCertification(); - masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification); + int user_id_index = 0; + if (primaryIDChanged) { + ArrayList> sigList = new ArrayList>(); + for (String userId : userIds) { + String orig_id = OriginalIDs.get(user_id_index); + if (orig_id.equals(userId)) { + Iterator orig_sigs = masterPublicKey.getSignaturesForID(orig_id); //TODO: make sure this iterator only has signatures we are interested in + while (orig_sigs.hasNext()) { + PGPSignature orig_sig = orig_sigs.next(); + sigList.add(new Pair(orig_id, orig_sig)); + } + } else { + PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( + masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1) + .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME); + PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder); + + sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey); + + PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); + sigList.add(new Pair(userId, certification)); + } + masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, orig_id); + user_id_index++; + } + for (Pair to_add : sigList) { + masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, to_add.first, to_add.second); + } + } else { + for (String userId : userIds) { + String orig_id = OriginalIDs.get(user_id_index); + if (!orig_id.equals(userId)) { + PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( + masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1) + .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME); + PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder); + + sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey); + + PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); + masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, orig_id); + masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification); + } + user_id_index++; } - user_id_index++; } PGPKeyPair masterKeyPair = new PGPKeyPair(masterPublicKey, masterPrivateKey); -- cgit v1.2.3 From fab74590eb0984e055f98ccf3af4390d3e3c0c15 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sat, 22 Feb 2014 15:41:15 +0000 Subject: remove deleted keys --- .../java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index f3b289f66..ab4408056 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -378,6 +378,10 @@ public class PgpKeyOperation { do we need to remove and add in? */ + for (PGPSecretKey dKey : deleted_keys) { + mKR = PGPSecretKeyRing.removeSecretKey(mKR, dKey); + } + masterKey = mKR.getSecretKey(); PGPPublicKey masterPublicKey = masterKey.getPublicKey(); -- cgit v1.2.3 From fa533dda325b5d56db16dee2f84152ec4807a2b2 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sat, 22 Feb 2014 16:08:38 +0000 Subject: pass through which keys are new --- .../org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 9 +++++++-- .../keychain/service/KeychainIntentService.java | 4 +++- .../org/sufficientlysecure/keychain/ui/EditKeyActivity.java | 2 ++ .../org/sufficientlysecure/keychain/ui/widget/KeyEditor.java | 5 +++++ .../sufficientlysecure/keychain/ui/widget/SectionView.java | 12 ++++++++++++ 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index ab4408056..a6ff60442 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -345,7 +345,7 @@ public class PgpKeyOperation { updateProgress(R.string.progress_done, 100, 100); } - public void buildSecretKey(ArrayList userIds, ArrayList OriginalIDs, ArrayList deletedIDs, boolean primaryIDChanged, boolean[] modded_keys, ArrayList deleted_keys, ArrayList keysExpiryDates, ArrayList keysUsages, String newPassPhrase, String oldPassPhrase, ArrayList keys) throws PgpGeneralException, + public void buildSecretKey(ArrayList userIds, ArrayList OriginalIDs, ArrayList deletedIDs, boolean primaryIDChanged, boolean[] modded_keys, ArrayList deleted_keys, ArrayList keysExpiryDates, ArrayList keysUsages, String newPassPhrase, String oldPassPhrase, boolean[] new_keys, ArrayList keys) throws PgpGeneralException, PGPException, SignatureException, IOException { updateProgress(R.string.progress_building_key, 0, 100); @@ -490,6 +490,11 @@ public class PgpKeyOperation { masterKeyPair, mainUserId, sha1Calc, hashedPacketsGen.generate(), unhashedPacketsGen.generate(), certificationSignerBuilder, keyEncryptor); + //updating master is slightly different to updating the others + if (modded_keys[0]) { + + } + updateProgress(R.string.progress_adding_sub_keys, 40, 100); for (int i = 1; i < keys.size(); ++i) { @@ -549,7 +554,7 @@ public class PgpKeyOperation { PGPSecretKeyRing secretKeyRing = keyGen.generateSecretKeyRing(); PGPPublicKeyRing publicKeyRing = keyGen.generatePublicKeyRing(); - +//must copy with new passphrase... new keys will have an empty passphrase... pass in boolean array to mark new key? updateProgress(R.string.progress_saving_key_ring, 90, 100); ProviderHelper.saveKeyRing(mContext, secretKeyRing); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 73de7ca6e..3610ddc9e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -138,6 +138,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial public static final String SAVE_KEYRING_DELETED_IDS = "deleted_ids"; public static final String SAVE_KEYRING_MODDED_KEYS = "modified_keys"; public static final String SAVE_KEYRING_DELETED_KEYS = "deleted_keys"; + public static final String SAVE_KEYRING_NEW_KEYS = "new_keys"; // generate key public static final String GENERATE_KEY_ALGORITHM = "algorithm"; @@ -548,6 +549,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial ArrayList original_ids = data.getStringArrayList(SAVE_KEYRING_ORIGINAL_IDS); ArrayList deleted_ids = data.getStringArrayList(SAVE_KEYRING_DELETED_IDS); boolean[] modded_keys = data.getBooleanArray(SAVE_KEYRING_MODDED_KEYS); + boolean[] new_keys = data.getBooleanArray(SAVE_KEYRING_NEW_KEYS); ArrayList deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(data .getByteArray(SAVE_KEYRING_DELETED_KEYS)); boolean primaryChanged = data.getBoolean(SAVE_KEYRING_PRIMARY_ID_CHANGED); @@ -563,7 +565,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial } else { keyOperations.buildSecretKey(userIds, original_ids, deleted_ids, primaryChanged, modded_keys, deletedKeys, keysExpiryDates, keysUsages, newPassPhrase, - oldPassPhrase, keys); + oldPassPhrase, new_keys, keys); } PassphraseCacheService.addCachedPassphrase(this, masterKeyId, newPassPhrase); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 09be0dc79..bb38ac979 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -597,6 +597,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener toPrimitiveArray(mKeysView.getNeedsSavingArray())); data.putBoolean(KeychainIntentService.SAVE_KEYRING_PRIMARY_ID_CHANGED, mUserIdsView.primaryChanged()); + data.putBooleanArray(KeychainIntentService.SAVE_KEYRING_NEW_KEYS, + toPrimitiveArray(mKeysView.getNewKeysArray())); intent.putExtra(KeychainIntentService.EXTRA_DATA, data); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 5ce5d89d7..68bfc573e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -314,4 +314,9 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { return retval; } + public boolean getIsNewKey() + { + return mIsNewKey; + } + } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 014a891a5..93c10a2b0 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -223,6 +223,18 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor return mList; } + public List getNewKeysArray() + { + ArrayList mList = new ArrayList(); + if (mType == Id.type.key) { + for (int i = 0; i < mEditors.getChildCount(); ++i) { + KeyEditor editor = (KeyEditor) mEditors.getChildAt(i); + mList.add(editor.getIsNewKey()); + } + } + return mList; + } + /** {@inheritDoc} */ public void onClick(View v) { if (canEdit) { -- cgit v1.2.3 From d6b0975f9b666dc30edab36e6f2c68c0022790d1 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sun, 2 Mar 2014 20:34:28 +0000 Subject: begin adding parcel for save intent --- .../keychain/pgp/PgpKeyOperation.java | 10 ++- .../keychain/service/SaveKeyringParcel.java | 90 ++++++++++++++++++++++ 2 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index a6ff60442..a52f247c6 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.GregorianCalendar; import java.util.Iterator; +import java.util.List; import java.util.TimeZone; import org.spongycastle.bcpg.CompressionAlgorithmTags; @@ -490,11 +491,14 @@ public class PgpKeyOperation { masterKeyPair, mainUserId, sha1Calc, hashedPacketsGen.generate(), unhashedPacketsGen.generate(), certificationSignerBuilder, keyEncryptor); - //updating master is slightly different to updating the others - if (modded_keys[0]) { + for (int i = 0; i < keys.size(); ++i) { + updateProgress(40 + 50 * (i - 1) / (keys.size() - 1), 100); + if (new_keys[i]) { - } + } else { + } + } updateProgress(R.string.progress_adding_sub_keys, 40, 100); for (int i = 1; i < keys.size(); ++i) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java new file mode 100644 index 000000000..bdabc70a2 --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2014 Ash Hughes + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + +package org.sufficientlysecure.keychain.service; + +import android.os.Parcel; +import android.os.Parcelable; + +import org.spongycastle.openpgp.PGPSecretKey; +import org.sufficientlysecure.keychain.pgp.PgpConversionHelper; + +import java.util.ArrayList; +import java.util.GregorianCalendar; + +public class SaveKeyringParcel implements Parcelable { + + public ArrayList userIDs; + public ArrayList originalIDs; + public ArrayList deletedIDs; + public boolean primaryIDChanged; + public boolean[] moddedKeys; + public ArrayList deletedKeys; + public ArrayList keysExpiryDates; + public ArrayList keysUsages; + public String newPassPhrase; + public String oldPassPhrase; + public boolean[] newKeys; + public ArrayList keys; + + private SaveKeyringParcel(Parcel source) + { + byte[] tmpB; + userIDs = (ArrayList)source.readSerializable(); + originalIDs = (ArrayList)source.readSerializable(); + deletedIDs = (ArrayList)source.readSerializable(); + primaryIDChanged = source.readByte() != 0; + source.readBooleanArray(moddedKeys); + deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(source.createByteArray()); + keysExpiryDates = (ArrayList)source.readSerializable(); + keysUsages = source.readArrayList(Integer.class.getClassLoader()); + } + + @Override + public void writeToParcel(Parcel destination, int flags) + { + destination.writeSerializable(userIDs); + destination.writeSerializable(originalIDs); + destination.writeSerializable(deletedIDs); + destination.writeByte((byte) (primaryIDChanged ? 1 : 0)); + destination.writeBooleanArray(moddedKeys); + destination.writeByteArray(PgpConversionHelper.PGPSecretKeyArrayListToBytes(deletedKeys)); + destination.writeSerializable(keysExpiryDates); + destination.writeList(keysUsages); + destination.writeString(newPassPhrase); + destination.writeString(oldPassPhrase); + destination.writeBooleanArray(newKeys); + destination.writeByteArray(); + } + + public static final Creator CREATOR = new Creator() { + public SaveKeyringParcel createFromParcel(final Parcel source) { + return new SaveKeyringParcel(source); + } + + public SaveKeyringParcel[] newArray(final int size) { + return new SaveKeyringParcel[size]; + } + }; + + @Override + public int describeContents() + { + return 0; + } +} -- cgit v1.2.3 From 8662ca2928ac0b007d4ee5d00f6de3211f5d3d2c Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Thu, 6 Mar 2014 12:25:35 +0000 Subject: a method, if not the best one, for each property --- .../sufficientlysecure/keychain/service/SaveKeyringParcel.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java index bdabc70a2..9e290c1b6 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java @@ -53,12 +53,16 @@ public class SaveKeyringParcel implements Parcelable { deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(source.createByteArray()); keysExpiryDates = (ArrayList)source.readSerializable(); keysUsages = source.readArrayList(Integer.class.getClassLoader()); + newPassPhrase = source.readString(); + oldPassPhrase = source.readString(); + source.readBooleanArray(newKeys); + keys = PgpConversionHelper.BytesToPGPSecretKeyList(source.createByteArray()); } @Override public void writeToParcel(Parcel destination, int flags) { - destination.writeSerializable(userIDs); + destination.writeSerializable(userIDs); //might not be the best method to store. destination.writeSerializable(originalIDs); destination.writeSerializable(deletedIDs); destination.writeByte((byte) (primaryIDChanged ? 1 : 0)); @@ -69,7 +73,7 @@ public class SaveKeyringParcel implements Parcelable { destination.writeString(newPassPhrase); destination.writeString(oldPassPhrase); destination.writeBooleanArray(newKeys); - destination.writeByteArray(); + destination.writeByteArray(PgpConversionHelper.PGPSecretKeyArrayListToBytes(keys)); } public static final Creator CREATOR = new Creator() { -- cgit v1.2.3 From 01951810ae1b3a0e4fefab7d55c090fc8f776ce5 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Thu, 6 Mar 2014 13:00:17 +0000 Subject: fix saving new key (tmp) --- .../java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 4 +++- .../sufficientlysecure/keychain/service/KeychainIntentService.java | 7 ++++++- .../java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index a52f247c6..66665df3c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -361,8 +361,10 @@ public class PgpKeyOperation { newPassPhrase = ""; } - if (mKR == null) + if (mKR == null) { buildNewSecretKey(userIds, keys, keysExpiryDates, keysUsages, newPassPhrase, oldPassPhrase); //new Keyring + return; + } /* IDs - diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 3610ddc9e..9d6e24d30 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -550,8 +550,13 @@ public class KeychainIntentService extends IntentService implements ProgressDial ArrayList deleted_ids = data.getStringArrayList(SAVE_KEYRING_DELETED_IDS); boolean[] modded_keys = data.getBooleanArray(SAVE_KEYRING_MODDED_KEYS); boolean[] new_keys = data.getBooleanArray(SAVE_KEYRING_NEW_KEYS); - ArrayList deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(data + byte[] tmp = data.getByteArray(SAVE_KEYRING_DELETED_KEYS); + ArrayList deletedKeys; + if (tmp != null) + deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(data .getByteArray(SAVE_KEYRING_DELETED_KEYS)); + else + deletedKeys = new ArrayList(); boolean primaryChanged = data.getBoolean(SAVE_KEYRING_PRIMARY_ID_CHANGED); long masterKeyId = data.getLong(SAVE_KEYRING_MASTER_KEY_ID); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index bb38ac979..044d15ec7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -581,8 +581,11 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener data.putByteArray(KeychainIntentService.SAVE_KEYRING_KEYS, PgpConversionHelper.PGPSecretKeyArrayListToBytes(keys)); ArrayList dKeys = mKeysView.getDeletedKeys(); + byte[] tmp = null; + if (dKeys.size() != 0) + tmp = PgpConversionHelper.PGPSecretKeyArrayListToBytes(dKeys); data.putByteArray(KeychainIntentService.SAVE_KEYRING_DELETED_KEYS, - PgpConversionHelper.PGPSecretKeyArrayListToBytes(dKeys)); + tmp); data.putIntegerArrayList(KeychainIntentService.SAVE_KEYRING_KEYS_USAGES, getKeysUsages(mKeysView)); data.putSerializable(KeychainIntentService.SAVE_KEYRING_KEYS_EXPIRY_DATES, -- cgit v1.2.3 From 04fa0e9cc7fbfc117948d60a3ad8bfab0b0060ba Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Thu, 6 Mar 2014 23:47:11 +0000 Subject: use parcel to save keys, but saving existing keys is disabled, pending a rewrite... --- .../keychain/pgp/PgpKeyOperation.java | 18 +++++---- .../keychain/service/KeychainIntentService.java | 45 ++++----------------- .../keychain/service/SaveKeyringParcel.java | 18 ++++++--- .../keychain/ui/EditKeyActivity.java | 46 ++++++++-------------- 4 files changed, 49 insertions(+), 78 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 66665df3c..0073107a0 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -65,6 +65,7 @@ import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.service.SaveKeyringParcel; import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Primes; import org.sufficientlysecure.keychain.util.ProgressDialogUpdater; @@ -346,23 +347,24 @@ public class PgpKeyOperation { updateProgress(R.string.progress_done, 100, 100); } - public void buildSecretKey(ArrayList userIds, ArrayList OriginalIDs, ArrayList deletedIDs, boolean primaryIDChanged, boolean[] modded_keys, ArrayList deleted_keys, ArrayList keysExpiryDates, ArrayList keysUsages, String newPassPhrase, String oldPassPhrase, boolean[] new_keys, ArrayList keys) throws PgpGeneralException, + public void buildSecretKey(SaveKeyringParcel saveParcel) throws PgpGeneralException, PGPException, SignatureException, IOException { updateProgress(R.string.progress_building_key, 0, 100); - PGPSecretKey masterKey = keys.get(0); + PGPSecretKey masterKey = saveParcel.keys.get(0); PGPSecretKeyRing mKR = ProviderHelper.getPGPSecretKeyRingByKeyId(mContext, masterKey.getKeyID()); - if (oldPassPhrase == null) { - oldPassPhrase = ""; + if (saveParcel.oldPassPhrase == null) { + saveParcel.oldPassPhrase = ""; } - if (newPassPhrase == null) { - newPassPhrase = ""; + if (saveParcel.newPassPhrase == null) { + saveParcel.newPassPhrase = ""; } if (mKR == null) { - buildNewSecretKey(userIds, keys, keysExpiryDates, keysUsages, newPassPhrase, oldPassPhrase); //new Keyring + buildNewSecretKey(saveParcel.userIDs, saveParcel.keys, saveParcel.keysExpiryDates, + saveParcel.keysUsages, saveParcel.newPassPhrase, saveParcel.oldPassPhrase); //new Keyring return; } @@ -381,6 +383,7 @@ public class PgpKeyOperation { do we need to remove and add in? */ + /* for (PGPSecretKey dKey : deleted_keys) { mKR = PGPSecretKeyRing.removeSecretKey(mKR, dKey); } @@ -567,6 +570,7 @@ public class PgpKeyOperation { ProviderHelper.saveKeyRing(mContext, publicKeyRing); updateProgress(R.string.progress_done, 100, 100); + */ } public PGPPublicKeyRing certifyKey(long masterKeyId, long pubKeyId, String passphrase) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 9d6e24d30..24bce8eeb 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -125,20 +125,9 @@ public class KeychainIntentService extends IntentService implements ProgressDial public static final String DECRYPT_ASSUME_SYMMETRIC = "assume_symmetric"; // save keyring - public static final String SAVE_KEYRING_NEW_PASSPHRASE = "new_passphrase"; - public static final String SAVE_KEYRING_CURRENT_PASSPHRASE = "current_passphrase"; - public static final String SAVE_KEYRING_USER_IDS = "user_ids"; - public static final String SAVE_KEYRING_PRIMARY_ID_CHANGED = "primary_id_changed"; - public static final String SAVE_KEYRING_KEYS = "keys"; - public static final String SAVE_KEYRING_KEYS_USAGES = "keys_usages"; - public static final String SAVE_KEYRING_KEYS_EXPIRY_DATES = "keys_expiry_dates"; - public static final String SAVE_KEYRING_MASTER_KEY_ID = "master_key_id"; + public static final String SAVE_KEYRING_PARCEL = "save_parcel"; public static final String SAVE_KEYRING_CAN_SIGN = "can_sign"; - public static final String SAVE_KEYRING_ORIGINAL_IDS = "original_ids"; - public static final String SAVE_KEYRING_DELETED_IDS = "deleted_ids"; - public static final String SAVE_KEYRING_MODDED_KEYS = "modified_keys"; - public static final String SAVE_KEYRING_DELETED_KEYS = "deleted_keys"; - public static final String SAVE_KEYRING_NEW_KEYS = "new_keys"; + // generate key public static final String GENERATE_KEY_ALGORITHM = "algorithm"; @@ -530,8 +519,9 @@ public class KeychainIntentService extends IntentService implements ProgressDial } else if (ACTION_SAVE_KEYRING.equals(action)) { try { /* Input */ - String oldPassPhrase = data.getString(SAVE_KEYRING_CURRENT_PASSPHRASE); - String newPassPhrase = data.getString(SAVE_KEYRING_NEW_PASSPHRASE); + SaveKeyringParcel saveParams = data.getParcelable(SAVE_KEYRING_PARCEL); + String oldPassPhrase = saveParams.oldPassPhrase; + String newPassPhrase = saveParams.newPassPhrase; boolean canSign = true; if (data.containsKey(SAVE_KEYRING_CAN_SIGN)) { @@ -541,25 +531,8 @@ public class KeychainIntentService extends IntentService implements ProgressDial if (newPassPhrase == null) { newPassPhrase = oldPassPhrase; } - ArrayList userIds = data.getStringArrayList(SAVE_KEYRING_USER_IDS); - ArrayList keys = PgpConversionHelper.BytesToPGPSecretKeyList(data - .getByteArray(SAVE_KEYRING_KEYS)); - ArrayList keysUsages = data.getIntegerArrayList(SAVE_KEYRING_KEYS_USAGES); - ArrayList keysExpiryDates = (ArrayList) data.getSerializable(SAVE_KEYRING_KEYS_EXPIRY_DATES); - ArrayList original_ids = data.getStringArrayList(SAVE_KEYRING_ORIGINAL_IDS); - ArrayList deleted_ids = data.getStringArrayList(SAVE_KEYRING_DELETED_IDS); - boolean[] modded_keys = data.getBooleanArray(SAVE_KEYRING_MODDED_KEYS); - boolean[] new_keys = data.getBooleanArray(SAVE_KEYRING_NEW_KEYS); - byte[] tmp = data.getByteArray(SAVE_KEYRING_DELETED_KEYS); - ArrayList deletedKeys; - if (tmp != null) - deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(data - .getByteArray(SAVE_KEYRING_DELETED_KEYS)); - else - deletedKeys = new ArrayList(); - boolean primaryChanged = data.getBoolean(SAVE_KEYRING_PRIMARY_ID_CHANGED); - - long masterKeyId = data.getLong(SAVE_KEYRING_MASTER_KEY_ID); + + long masterKeyId = saveParams.keys.get(0).getKeyID(); PgpKeyOperation keyOperations = new PgpKeyOperation(this, this); /* Operation */ @@ -568,9 +541,7 @@ public class KeychainIntentService extends IntentService implements ProgressDial ProviderHelper.getPGPSecretKeyRingByKeyId(this, masterKeyId), oldPassPhrase, newPassPhrase); } else { - keyOperations.buildSecretKey(userIds, original_ids, deleted_ids, primaryChanged, - modded_keys, deletedKeys, keysExpiryDates, keysUsages, newPassPhrase, - oldPassPhrase, new_keys, keys); + keyOperations.buildSecretKey(saveParams); } PassphraseCacheService.addCachedPassphrase(this, masterKeyId, newPassPhrase); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java index 9e290c1b6..ae481aa80 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java @@ -42,20 +42,25 @@ public class SaveKeyringParcel implements Parcelable { public boolean[] newKeys; public ArrayList keys; + public SaveKeyringParcel() {} + private SaveKeyringParcel(Parcel source) { - byte[] tmpB; userIDs = (ArrayList)source.readSerializable(); originalIDs = (ArrayList)source.readSerializable(); deletedIDs = (ArrayList)source.readSerializable(); primaryIDChanged = source.readByte() != 0; - source.readBooleanArray(moddedKeys); - deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(source.createByteArray()); + moddedKeys = source.createBooleanArray(); + byte[] tmp = source.createByteArray(); + if (tmp == null) + deletedKeys = null; + else + deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(tmp); keysExpiryDates = (ArrayList)source.readSerializable(); keysUsages = source.readArrayList(Integer.class.getClassLoader()); newPassPhrase = source.readString(); oldPassPhrase = source.readString(); - source.readBooleanArray(newKeys); + newKeys = source.createBooleanArray(); keys = PgpConversionHelper.BytesToPGPSecretKeyList(source.createByteArray()); } @@ -67,7 +72,10 @@ public class SaveKeyringParcel implements Parcelable { destination.writeSerializable(deletedIDs); destination.writeByte((byte) (primaryIDChanged ? 1 : 0)); destination.writeBooleanArray(moddedKeys); - destination.writeByteArray(PgpConversionHelper.PGPSecretKeyArrayListToBytes(deletedKeys)); + byte[] tmp = null; + if (deletedKeys.size() != 0) + tmp = PgpConversionHelper.PGPSecretKeyArrayListToBytes(deletedKeys); + destination.writeByteArray(tmp); destination.writeSerializable(keysExpiryDates); destination.writeList(keysUsages); destination.writeString(newPassPhrase); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 044d15ec7..6ce2a8f6b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -36,6 +36,7 @@ import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; import org.sufficientlysecure.keychain.service.PassphraseCacheService; +import org.sufficientlysecure.keychain.service.SaveKeyringParcel; import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment; @@ -570,38 +571,25 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener intent.setAction(KeychainIntentService.ACTION_SAVE_KEYRING); + SaveKeyringParcel saveParams = new SaveKeyringParcel(); + saveParams.userIDs = getUserIds(mUserIdsView); + saveParams.originalIDs = mUserIdsView.getOriginalIDs(); + saveParams.deletedIDs = mUserIdsView.getDeletedIDs(); + saveParams.primaryIDChanged = mUserIdsView.primaryChanged(); + saveParams.moddedKeys = toPrimitiveArray(mKeysView.getNeedsSavingArray()); + saveParams.deletedKeys = mKeysView.getDeletedKeys(); + saveParams.keysExpiryDates = getKeysExpiryDates(mKeysView); + saveParams.keysUsages = getKeysUsages(mKeysView); + saveParams.newPassPhrase = mNewPassPhrase; + saveParams.oldPassPhrase = mCurrentPassPhrase; + saveParams.newKeys = toPrimitiveArray(mKeysView.getNewKeysArray()); + saveParams.keys = getKeys(mKeysView); + + // fill values for this action Bundle data = new Bundle(); - data.putString(KeychainIntentService.SAVE_KEYRING_CURRENT_PASSPHRASE, - mCurrentPassPhrase); - data.putString(KeychainIntentService.SAVE_KEYRING_NEW_PASSPHRASE, mNewPassPhrase); - data.putStringArrayList(KeychainIntentService.SAVE_KEYRING_USER_IDS, - getUserIds(mUserIdsView)); - ArrayList keys = getKeys(mKeysView); - data.putByteArray(KeychainIntentService.SAVE_KEYRING_KEYS, - PgpConversionHelper.PGPSecretKeyArrayListToBytes(keys)); - ArrayList dKeys = mKeysView.getDeletedKeys(); - byte[] tmp = null; - if (dKeys.size() != 0) - tmp = PgpConversionHelper.PGPSecretKeyArrayListToBytes(dKeys); - data.putByteArray(KeychainIntentService.SAVE_KEYRING_DELETED_KEYS, - tmp); - data.putIntegerArrayList(KeychainIntentService.SAVE_KEYRING_KEYS_USAGES, - getKeysUsages(mKeysView)); - data.putSerializable(KeychainIntentService.SAVE_KEYRING_KEYS_EXPIRY_DATES, - getKeysExpiryDates(mKeysView)); - data.putLong(KeychainIntentService.SAVE_KEYRING_MASTER_KEY_ID, getMasterKeyId()); data.putBoolean(KeychainIntentService.SAVE_KEYRING_CAN_SIGN, masterCanSign); - data.putStringArrayList(KeychainIntentService.SAVE_KEYRING_DELETED_IDS, - mUserIdsView.getDeletedIDs()); - data.putStringArrayList(KeychainIntentService.SAVE_KEYRING_ORIGINAL_IDS, - mUserIdsView.getOriginalIDs()); - data.putBooleanArray(KeychainIntentService.SAVE_KEYRING_MODDED_KEYS, - toPrimitiveArray(mKeysView.getNeedsSavingArray())); - data.putBoolean(KeychainIntentService.SAVE_KEYRING_PRIMARY_ID_CHANGED, - mUserIdsView.primaryChanged()); - data.putBooleanArray(KeychainIntentService.SAVE_KEYRING_NEW_KEYS, - toPrimitiveArray(mKeysView.getNewKeysArray())); + data.putParcelable(KeychainIntentService.SAVE_KEYRING_PARCEL, saveParams); intent.putExtra(KeychainIntentService.EXTRA_DATA, data); -- cgit v1.2.3 From b06e4d827a65838cc7085040ea465c1163f1cdd9 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Fri, 7 Mar 2014 15:36:01 +0000 Subject: uncomment, use Parcel. Builds, not functional --- .../keychain/pgp/PgpKeyOperation.java | 48 +++++++++++----------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index f744fbcec..87f8fdebb 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -383,33 +383,32 @@ public class PgpKeyOperation { do we need to remove and add in? */ - /* - for (PGPSecretKey dKey : deleted_keys) { + for (PGPSecretKey dKey : saveParcel.deletedKeys) { mKR = PGPSecretKeyRing.removeSecretKey(mKR, dKey); } masterKey = mKR.getSecretKey(); PGPPublicKey masterPublicKey = masterKey.getPublicKey(); - int usageId = keysUsages.get(0); + int usageId = saveParcel.keysUsages.get(0); boolean canSign; - String mainUserId = userIds.get(0); + String mainUserId = saveParcel.userIDs.get(0); PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider( - Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassPhrase.toCharArray()); + Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(saveParcel.oldPassPhrase.toCharArray()); PGPPrivateKey masterPrivateKey = masterKey.extractPrivateKey(keyDecryptor); updateProgress(R.string.progress_certifying_master_key, 20, 100); - for (String delID : deletedIDs) { + for (String delID : saveParcel.deletedIDs) { masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, delID); } int user_id_index = 0; - if (primaryIDChanged) { + if (saveParcel.primaryIDChanged) { ArrayList> sigList = new ArrayList>(); - for (String userId : userIds) { - String orig_id = OriginalIDs.get(user_id_index); + for (String userId : saveParcel.userIDs) { + String orig_id = saveParcel.originalIDs.get(user_id_index); if (orig_id.equals(userId)) { Iterator orig_sigs = masterPublicKey.getSignaturesForID(orig_id); //TODO: make sure this iterator only has signatures we are interested in while (orig_sigs.hasNext()) { @@ -434,8 +433,8 @@ public class PgpKeyOperation { masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, to_add.first, to_add.second); } } else { - for (String userId : userIds) { - String orig_id = OriginalIDs.get(user_id_index); + for (String userId : saveParcel.userIDs) { + String orig_id = saveParcel.originalIDs.get(user_id_index); if (!orig_id.equals(userId)) { PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1) @@ -463,10 +462,10 @@ public class PgpKeyOperation { hashedPacketsGen.setPreferredHashAlgorithms(true, PREFERRED_HASH_ALGORITHMS); hashedPacketsGen.setPreferredCompressionAlgorithms(true, PREFERRED_COMPRESSION_ALGORITHMS); - if (keysExpiryDates.get(0) != null) { + if (saveParcel.keysExpiryDates.get(0) != null) { GregorianCalendar creationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC")); creationDate.setTime(masterPublicKey.getCreationTime()); - GregorianCalendar expiryDate = keysExpiryDates.get(0); + GregorianCalendar expiryDate = saveParcel.keysExpiryDates.get(0); //note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c //here we purposefully ignore partial days in each date - long type has no fractional part! long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000); @@ -490,15 +489,15 @@ public class PgpKeyOperation { PBESecretKeyEncryptor keyEncryptor = new JcePBESecretKeyEncryptorBuilder( PGPEncryptedData.CAST5, sha1Calc) .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( - newPassPhrase.toCharArray()); + saveParcel.newPassPhrase.toCharArray()); PGPKeyRingGenerator keyGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, masterKeyPair, mainUserId, sha1Calc, hashedPacketsGen.generate(), unhashedPacketsGen.generate(), certificationSignerBuilder, keyEncryptor); - for (int i = 0; i < keys.size(); ++i) { - updateProgress(40 + 50 * (i - 1) / (keys.size() - 1), 100); - if (new_keys[i]) { + for (int i = 0; i < saveParcel.keys.size(); ++i) { + updateProgress(40 + 50 * (i - 1) / (saveParcel.keys.size() - 1), 100); + if (saveParcel.newKeys[i]) { } else { @@ -506,15 +505,15 @@ public class PgpKeyOperation { } updateProgress(R.string.progress_adding_sub_keys, 40, 100); - for (int i = 1; i < keys.size(); ++i) { - updateProgress(40 + 50 * (i - 1) / (keys.size() - 1), 100); + for (int i = 1; i < saveParcel.keys.size(); ++i) { + updateProgress(40 + 50 * (i - 1) / (saveParcel.keys.size() - 1), 100); - PGPSecretKey subKey = keys.get(i); + PGPSecretKey subKey = saveParcel.keys.get(i); PGPPublicKey subPublicKey = subKey.getPublicKey(); PBESecretKeyDecryptor keyDecryptor2 = new JcePBESecretKeyDecryptorBuilder() .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( - oldPassPhrase.toCharArray()); + saveParcel.oldPassPhrase.toCharArray()); PGPPrivateKey subPrivateKey = subKey.extractPrivateKey(keyDecryptor2); // TODO: now used without algorithm and creation time?! (APG 1) @@ -523,7 +522,7 @@ public class PgpKeyOperation { hashedPacketsGen = new PGPSignatureSubpacketGenerator(); unhashedPacketsGen = new PGPSignatureSubpacketGenerator(); - usageId = keysUsages.get(i); + usageId = saveParcel.keysUsages.get(i); canSign = (usageId & KeyFlags.SIGN_DATA) > 0; //todo - separate function for this if (canSign) { Date todayDate = new Date(); //both sig times the same @@ -543,10 +542,10 @@ public class PgpKeyOperation { } hashedPacketsGen.setKeyFlags(false, usageId); - if (keysExpiryDates.get(i) != null) { + if (saveParcel.keysExpiryDates.get(i) != null) { GregorianCalendar creationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC")); creationDate.setTime(subPublicKey.getCreationTime()); - GregorianCalendar expiryDate = keysExpiryDates.get(i); + GregorianCalendar expiryDate = saveParcel.keysExpiryDates.get(i); //note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c //here we purposefully ignore partial days in each date - long type has no fractional part! long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000); @@ -570,7 +569,6 @@ public class PgpKeyOperation { ProviderHelper.saveKeyRing(mContext, publicKeyRing); updateProgress(R.string.progress_done, 100, 100); - */ } public PGPPublicKeyRing certifyKey(long masterKeyId, long pubKeyId, String passphrase) -- cgit v1.2.3 From 6f0a5d39b2931981fb521f533acb5c2c33514734 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Mon, 10 Mar 2014 23:53:28 +0000 Subject: start modifying save code --- .../keychain/pgp/PgpKeyOperation.java | 34 +++++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 87f8fdebb..89be90ab8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -73,6 +73,8 @@ import org.sufficientlysecure.keychain.util.ProgressDialogUpdater; import android.content.Context; import android.util.Pair; +import javax.crypto.SecretKey; + public class PgpKeyOperation { private final Context mContext; private final ProgressDialogUpdater mProgress; @@ -354,6 +356,7 @@ public class PgpKeyOperation { PGPSecretKey masterKey = saveParcel.keys.get(0); PGPSecretKeyRing mKR = ProviderHelper.getPGPSecretKeyRingByKeyId(mContext, masterKey.getKeyID()); + PGPPublicKeyRing pKR = ProviderHelper.getPGPPublicKeyRingByKeyId(mContext, masterKey.getKeyID()); if (saveParcel.oldPassPhrase == null) { saveParcel.oldPassPhrase = ""; @@ -497,11 +500,27 @@ public class PgpKeyOperation { for (int i = 0; i < saveParcel.keys.size(); ++i) { updateProgress(40 + 50 * (i - 1) / (saveParcel.keys.size() - 1), 100); - if (saveParcel.newKeys[i]) { - + if (saveParcel.moddedKeys[i]) { +//secretkey.replacepublickey with updated public key +//secretkeyring.insertsecretkey with newly signed secret key } else { - +//else nothing, right? + } + if (saveParcel.newKeys[i]) { + //set the passphrase to the old one, so we can update the whole keyring passphrase later + PBESecretKeyEncryptor keyEncryptorOld = new JcePBESecretKeyEncryptorBuilder( + PGPEncryptedData.CAST5, sha1Calc) + .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( + saveParcel.oldPassPhrase.toCharArray()); + PBESecretKeyDecryptor keyDecryptorBlank = new JcePBESecretKeyDecryptorBuilder() + .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( + saveParcel.oldPassPhrase.toCharArray()); + saveParcel.keys.set(i, PGPSecretKey.copyWithNewPassword(saveParcel.keys.get(i), + keyDecryptorBlank, keyEncryptorOld)); } + //finally, update the keyrings + mKR = PGPSecretKeyRing.insertSecretKey(mKR, saveParcel.keys.get(i)); + pKR = PGPPublicKeyRing.insertPublicKey(pKR, saveParcel.keys.get(i).getPublicKey()); } updateProgress(R.string.progress_adding_sub_keys, 40, 100); @@ -560,13 +579,12 @@ public class PgpKeyOperation { keyGen.addSubKey(subKeyPair, hashedPacketsGen.generate(), unhashedPacketsGen.generate()); } - PGPSecretKeyRing secretKeyRing = keyGen.generateSecretKeyRing(); - PGPPublicKeyRing publicKeyRing = keyGen.generatePublicKeyRing(); -//must copy with new passphrase... new keys will have an empty passphrase... pass in boolean array to mark new key? + //update the passphrase + mKR = PGPSecretKeyRing.copyWithNewPassword(mKR, keyDecryptor, keyEncryptor); updateProgress(R.string.progress_saving_key_ring, 90, 100); - ProviderHelper.saveKeyRing(mContext, secretKeyRing); - ProviderHelper.saveKeyRing(mContext, publicKeyRing); + ProviderHelper.saveKeyRing(mContext, mKR); + ProviderHelper.saveKeyRing(mContext, pKR); updateProgress(R.string.progress_done, 100, 100); } -- cgit v1.2.3 From fdb013a0529e4fcf3b602f856c0290f5626789aa Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Tue, 11 Mar 2014 00:00:19 +0000 Subject: unused imports --- .../java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 89be90ab8..8ef2a7452 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -29,7 +29,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.GregorianCalendar; import java.util.Iterator; -import java.util.List; import java.util.TimeZone; import org.spongycastle.bcpg.CompressionAlgorithmTags; @@ -66,15 +65,12 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.service.SaveKeyringParcel; -import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.Primes; import org.sufficientlysecure.keychain.util.ProgressDialogUpdater; import android.content.Context; import android.util.Pair; -import javax.crypto.SecretKey; - public class PgpKeyOperation { private final Context mContext; private final ProgressDialogUpdater mProgress; -- cgit v1.2.3 From 5eb12ef88f93bfadb51ac28e31bcf4935647b827 Mon Sep 17 00:00:00 2001 From: Daniel Hammann Date: Wed, 12 Mar 2014 21:36:42 +0100 Subject: Squashed commit of the following: commit 1df4d4a9e047f70f284183185d81070e49097ad3 Author: Daniel Hammann Date: Wed Mar 12 21:33:13 2014 +0100 Added Windows section to CheckStyle configuration information part (and splitted Linux and MacOSX up). --- README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4b997c59f..8954bdcda 100644 --- a/README.md +++ b/README.md @@ -156,12 +156,21 @@ See http://source.android.com/source/code-style.html See http://www.androidpolice.com/2009/11/04/auto-formatting-android-xml-files-with-eclipse/ ### Automated syntax check with CheckStyle -* Paste the tools/checkstyle.xml file to ~/.AndroidStudioPreview/config/codestyles/ (in Linux/Unix) - or ~/Library/Preferences/AndroidStudioPreview/codestyles (in Mac OSX) -* Go to Settings (or Preferences in Mac OS X) > Code Style > Java, select OpenPgpChecker, - as well as Code Style > XML and select OpenPgpChecker again. -* Start code inspection and see the results by selecting Analyze > Inspect Code from Android-Studio - or you can directly run checkstyle via cli with .tools/checkstyle. Make sure it's executable first. + +####Linux +1. Paste the `tools/checkstyle.xml` file to `~/.AndroidStudioPreview/config/codestyles/` +2. Go to Settings > Code Style > Java, select OpenPgpChecker, as well as Code Style > XML and select OpenPgpChecker again. +3. Start code inspection and see the results by selecting Analyze > Inspect Code from Android-Studio or you can directly run checkstyle via cli with `.tools/checkstyle`. Make sure it's executable first. + +####Mac OSX +1. Paste the `tools/checkstyle.xml` file to `~/Library/Preferences/AndroidStudioPreview/codestyles` +2. Go to Preferences > Code Style > Java, select OpenPgpChecker, as well as Code Style > XML and select OpenPgpChecker again. +3. Start code inspection and see the results by selecting Analyze > Inspect Code from Android-Studio or you can directly run checkstyle via cli with `.tools/checkstyle`. Make sure it's executable first. + +####Windows +1. Paste the `tools/checkstyle.xml` file to `C:\Users\\.AndroidStudioPreview\config\codestyles` +2. Go to File > Settings > Code Style > Java, select OpenPgpChecker, as well as Code Style > XML and select OpenPgpChecker again. +3. Start code inspection and see the results by selecting Analyze > Inspect Code from Android-Studio. ## Licenses OpenPGP Kechain is licensed under GPLv3+. -- cgit v1.2.3 From 3abe17090e1f0a654c50679231d1232516b2d815 Mon Sep 17 00:00:00 2001 From: gogowitczak Date: Fri, 14 Mar 2014 20:24:27 +0100 Subject: Added FAQ: specifying connection port for Keyserver. --- OpenPGP-Keychain/src/main/res/raw/help_faq.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/raw/help_faq.html b/OpenPGP-Keychain/src/main/res/raw/help_faq.html index b3d5b3a11..bfd43eafd 100644 --- a/OpenPGP-Keychain/src/main/res/raw/help_faq.html +++ b/OpenPGP-Keychain/src/main/res/raw/help_faq.html @@ -5,8 +5,9 @@ And don't add newlines before or after p tags because of transifex --> -

TODO

-

text

+

How can I specify connection port for Keyserver?

+

Add a new Keyserver (or modify existing one) by going to Preferences -> General -> Keyservers. Enter the port number after the Keyserver address and preceded it by a colon. For example, "p80.pool.sks-keyservers.net:80" (without quotation marks) means that server "p80.pool.sks-keyservers.net" is working on a port 80.

+

Default connection port is 11371 and it doesn't need to be specified.

-- cgit v1.2.3 From e387dd7c54ddfdbe8379b57e00fed567510fd863 Mon Sep 17 00:00:00 2001 From: uberspot Date: Sat, 15 Mar 2014 01:51:01 +0200 Subject: Fix export for new unified key list #409 --- .../java/org/sufficientlysecure/keychain/Id.java | 1 + .../keychain/helper/ExportHelper.java | 34 ++++++----- .../keychain/pgp/PgpImportExport.java | 69 ++++++++++++---------- .../keychain/service/KeychainIntentService.java | 50 ++++++++-------- .../keychain/ui/EditKeyActivity.java | 6 +- .../keychain/ui/KeyListActivity.java | 5 +- .../keychain/ui/KeyListFragment.java | 18 ++++-- .../keychain/ui/ViewKeyActivity.java | 7 ++- OpenPGP-Keychain/src/main/res/values/strings.xml | 1 + 9 files changed, 112 insertions(+), 79 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Id.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Id.java index 1d79edd43..784ec340e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Id.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Id.java @@ -119,6 +119,7 @@ public final class Id { public static final int secret_key = 0x21070002; public static final int user_id = 0x21070003; public static final int key = 0x21070004; + public static final int public_secret_key = 0x21070005; } public static final class choice { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java index 557d75dbf..03cf936ee 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java @@ -30,12 +30,18 @@ import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; +import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.FileDialogFragment; import org.sufficientlysecure.keychain.util.Log; +import java.lang.reflect.Array; +import java.security.Provider; +import java.util.ArrayList; + public class ExportHelper { protected FileDialogFragment mFileDialog; protected String mExportFilename; @@ -62,8 +68,8 @@ public class ExportHelper { /** * Show dialog where to export keys */ - public void showExportKeysDialog(final long[] rowIds, final int keyType, - final String exportFilename) { + public void showExportKeysDialog(final long[] masterKeyIds, final int keyType, + final String exportFilename, final String checkboxString) { mExportFilename = exportFilename; // Message is received after file is selected @@ -72,9 +78,14 @@ public class ExportHelper { public void handleMessage(Message message) { if (message.what == FileDialogFragment.MESSAGE_OKAY) { Bundle data = message.getData(); + int type = keyType; mExportFilename = data.getString(FileDialogFragment.MESSAGE_DATA_FILENAME); - exportKeys(rowIds, keyType); + if( data.getBoolean(FileDialogFragment.MESSAGE_DATA_CHECKED) ) { + type = Id.type.public_secret_key; + } + + exportKeys(masterKeyIds, type); } } }; @@ -85,7 +96,7 @@ public class ExportHelper { DialogFragmentWorkaround.INTERFACE.runnableRunDelayed(new Runnable() { public void run() { String title = null; - if (rowIds == null) { + if (masterKeyIds == null) { // export all keys title = mActivity.getString(R.string.title_export_keys); } else { @@ -93,15 +104,10 @@ public class ExportHelper { title = mActivity.getString(R.string.title_export_key); } - String message = null; - if (keyType == Id.type.public_key) { - message = mActivity.getString(R.string.specify_file_to_export_to); - } else { - message = mActivity.getString(R.string.specify_file_to_export_secret_keys_to); - } + String message = mActivity.getString(R.string.specify_file_to_export_to); mFileDialog = FileDialogFragment.newInstance(messenger, title, message, - exportFilename, null); + exportFilename, checkboxString); mFileDialog.show(mActivity.getSupportFragmentManager(), "fileDialog"); } @@ -111,7 +117,7 @@ public class ExportHelper { /** * Export keys */ - public void exportKeys(long[] rowIds, int keyType) { + public void exportKeys(long[] masterKeyIds, int keyType) { Log.d(Constants.TAG, "exportKeys started"); // Send all information needed to service to export key in other thread @@ -125,10 +131,10 @@ public class ExportHelper { data.putString(KeychainIntentService.EXPORT_FILENAME, mExportFilename); data.putInt(KeychainIntentService.EXPORT_KEY_TYPE, keyType); - if (rowIds == null) { + if (masterKeyIds == null) { data.putBoolean(KeychainIntentService.EXPORT_ALL, true); } else { - data.putLongArray(KeychainIntentService.EXPORT_KEY_RING_ROW_ID, rowIds); + data.putLongArray(KeychainIntentService.EXPORT_KEY_RING_MASTER_KEY_ID, masterKeyIds); } intent.putExtra(KeychainIntentService.EXTRA_DATA, data); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java index dbfa521e5..0e0fdec83 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java @@ -36,6 +36,7 @@ import org.sufficientlysecure.keychain.util.KeyServer.AddKeyException; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.security.Provider; import java.util.ArrayList; import java.util.List; @@ -158,60 +159,68 @@ public class PgpImportExport { return returnData; } - public Bundle exportKeyRings(ArrayList keyRingRowIds, int keyType, + public Bundle exportKeyRings(ArrayList publicKeyRingMasterIds, ArrayList secretKeyRingMasterIds, OutputStream outStream) throws PgpGeneralException, PGPException, IOException { Bundle returnData = new Bundle(); - int rowIdsSize = keyRingRowIds.size(); + int masterKeyIdsSize = publicKeyRingMasterIds.size() + secretKeyRingMasterIds.size(); + int progress = 0; updateProgress( mContext.getResources().getQuantityString(R.plurals.progress_exporting_key, - rowIdsSize), 0, 100); + masterKeyIdsSize), 0, 100); if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { throw new PgpGeneralException( mContext.getString(R.string.error_external_storage_not_ready)); } - // For each row id - for (int i = 0; i < rowIdsSize; ++i) { + // For each public masterKey id + for (long pubKeyMasterId : publicKeyRingMasterIds) { + progress++; // Create an output stream ArmoredOutputStream arOutStream = new ArmoredOutputStream(outStream); arOutStream.setHeader("Version", PgpHelper.getFullVersion(mContext)); - // If the keyType is secret get the PGPSecretKeyRing - // based on the row id and encode it to the output - if (keyType == Id.type.secret_key) { - updateProgress(i * 100 / rowIdsSize / 2, 100); - PGPSecretKeyRing secretKeyRing = - ProviderHelper.getPGPSecretKeyRingByRowId(mContext, keyRingRowIds.get(i)); + updateProgress(progress * 100 / masterKeyIdsSize, 100); + PGPPublicKeyRing publicKeyRing = + ProviderHelper.getPGPPublicKeyRingByMasterKeyId(mContext, pubKeyMasterId); - if (secretKeyRing != null) { - secretKeyRing.encode(arOutStream); - } - if (mKeychainServiceListener.hasServiceStopped()) { - arOutStream.close(); - return null; - } - } else { - updateProgress(i * 100 / rowIdsSize, 100); - PGPPublicKeyRing publicKeyRing = - ProviderHelper.getPGPPublicKeyRingByRowId(mContext, keyRingRowIds.get(i)); + if (publicKeyRing != null) { + publicKeyRing.encode(arOutStream); + } - if (publicKeyRing != null) { - publicKeyRing.encode(arOutStream); - } + if (mKeychainServiceListener.hasServiceStopped()) { + arOutStream.close(); + return null; + } - if (mKeychainServiceListener.hasServiceStopped()) { - arOutStream.close(); - return null; - } + arOutStream.close(); + } + + // For each secret masterKey id + for (long secretKeyMasterId : secretKeyRingMasterIds) { + progress++; + // Create an output stream + ArmoredOutputStream arOutStream = new ArmoredOutputStream(outStream); + arOutStream.setHeader("Version", PgpHelper.getFullVersion(mContext)); + + updateProgress(progress * 100 / masterKeyIdsSize, 100); + PGPSecretKeyRing secretKeyRing = + ProviderHelper.getPGPSecretKeyRingByMasterKeyId(mContext, secretKeyMasterId); + + if (secretKeyRing != null) { + secretKeyRing.encode(arOutStream); + } + if (mKeychainServiceListener.hasServiceStopped()) { + arOutStream.close(); + return null; } arOutStream.close(); } - returnData.putInt(KeychainIntentService.RESULT_EXPORT, rowIdsSize); + returnData.putInt(KeychainIntentService.RESULT_EXPORT, masterKeyIdsSize); updateProgress(R.string.progress_done, 100, 100); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 4e5812202..a44b121ec 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -131,7 +131,6 @@ public class KeychainIntentService extends IntentService public static final String EXPORT_KEY_TYPE = "export_key_type"; public static final String EXPORT_ALL = "export_all"; public static final String EXPORT_KEY_RING_MASTER_KEY_ID = "export_key_ring_id"; - public static final String EXPORT_KEY_RING_ROW_ID = "export_key_rind_row_id"; // upload key public static final String UPLOAD_KEY_SERVER = "upload_key_server"; @@ -660,16 +659,11 @@ public class KeychainIntentService extends IntentService if (data.containsKey(EXPORT_KEY_TYPE)) { keyType = data.getInt(EXPORT_KEY_TYPE); } - + long[] masterKeyIds = data.getLongArray(EXPORT_KEY_RING_MASTER_KEY_ID); String outputFile = data.getString(EXPORT_FILENAME); - long[] rowIds = new long[0]; - - // If not exporting all keys get the rowIds of the keys to export from the intent + // If not exporting all keys get the masterKeyIds of the keys to export from the intent boolean exportAll = data.getBoolean(EXPORT_ALL); - if (!exportAll) { - rowIds = data.getLongArray(EXPORT_KEY_RING_ROW_ID); - } /* Operation */ @@ -678,30 +672,38 @@ public class KeychainIntentService extends IntentService throw new PgpGeneralException(getString(R.string.error_external_storage_not_ready)); } - // OutputStream - FileOutputStream outStream = new FileOutputStream(outputFile); + ArrayList publicMasterKeyIds = new ArrayList(); + ArrayList secretMasterKeyIds = new ArrayList(); + ArrayList allPublicMasterKeyIds = ProviderHelper.getPublicKeyRingsMasterKeyIds(this); + ArrayList allSecretMasterKeyIds = ProviderHelper.getSecretKeyRingsMasterKeyIds(this); - ArrayList keyRingRowIds = new ArrayList(); if (exportAll) { - - // get all key ring row ids based on export type - if (keyType == Id.type.public_key) { - keyRingRowIds = ProviderHelper.getPublicKeyRingsRowIds(this); - } else { - keyRingRowIds = ProviderHelper.getSecretKeyRingsRowIds(this); + // get all public key ring MasterKey ids + if (keyType == Id.type.public_key || keyType == Id.type.public_secret_key) { + publicMasterKeyIds = allPublicMasterKeyIds; + } + // get all secret key ring MasterKey ids + if (keyType == Id.type.secret_key || keyType == Id.type.public_secret_key) { + secretMasterKeyIds = allSecretMasterKeyIds; } } else { - for (long rowId : rowIds) { - keyRingRowIds.add(rowId); + + for (long masterKeyId : masterKeyIds) { + if ((keyType == Id.type.public_key || keyType == Id.type.public_secret_key) + && allPublicMasterKeyIds.contains(masterKeyId)) { + publicMasterKeyIds.add(masterKeyId); + } + if ((keyType == Id.type.secret_key || keyType == Id.type.public_secret_key) + && allSecretMasterKeyIds.contains(masterKeyId)) { + secretMasterKeyIds.add(masterKeyId); + } } } - Bundle resultData; - PgpImportExport pgpImportExport = new PgpImportExport(this, this, this); - - resultData = pgpImportExport - .exportKeyRings(keyRingRowIds, keyType, outStream); + Bundle resultData = pgpImportExport + .exportKeyRings(publicMasterKeyIds, secretMasterKeyIds, + new FileOutputStream(outputFile)); if (mIsCanceled) { boolean isDeleted = new File(outputFile).delete(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index edf980773..7edb61b09 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -322,8 +322,10 @@ public class EditKeyActivity extends ActionBarActivity { cancelClicked(); return true; case R.id.menu_key_edit_export_file: - long[] ids = new long[]{Long.valueOf(mDataUri.getLastPathSegment())}; - mExportHelper.showExportKeysDialog(ids, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC); + long masterKeyId = ProviderHelper.getMasterKeyId(this, mDataUri); + long[] ids = new long[]{masterKeyId}; + mExportHelper.showExportKeysDialog(ids, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC, + null); return true; case R.id.menu_key_edit_delete: { // Message is received after key is deleted diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java index 078b998e1..5ff4dbdeb 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java @@ -58,8 +58,7 @@ public class KeyListActivity extends DrawerActivity { return true; case R.id.menu_key_list_export: - // TODO fix this for unified keylist - mExportHelper.showExportKeysDialog(null, Id.type.public_key, Constants.Path.APP_DIR_FILE_PUB); + mExportHelper.showExportKeysDialog(null, Id.type.public_key, Constants.Path.APP_DIR_FILE_PUB, null); return true; case R.id.menu_key_list_create: @@ -71,7 +70,7 @@ public class KeyListActivity extends DrawerActivity { return true; case R.id.menu_key_list_secret_export: - mExportHelper.showExportKeysDialog(null, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC); + mExportHelper.showExportKeysDialog(null, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC, null); return true; default: diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 5ac59965d..cac8b7046 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -49,6 +49,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyTypes; import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; import org.sufficientlysecure.keychain.provider.KeychainDatabase; +import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.ui.adapter.HighlightQueryCursorAdapter; import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment; import org.sufficientlysecure.keychain.util.Log; @@ -183,13 +184,22 @@ public class KeyListFragment extends Fragment break; } case R.id.menu_key_list_multi_export: { - // todo: public/secret needs to be handled differently here ids = mStickyList.getWrappedList().getCheckedItemIds(); + long[] masterKeyIds = new long[2*ids.length]; + ArrayList allPubRowIds = + ProviderHelper.getPublicKeyRingsRowIds(getActivity()); + for (int i = 0; i < ids.length; i++) { + if (allPubRowIds.contains(ids[i])) { + masterKeyIds[i] = ProviderHelper.getPublicMasterKeyId(getActivity(), ids[i]); + } else { + masterKeyIds[i] = ProviderHelper.getSecretMasterKeyId(getActivity(), ids[i]); + } + } ExportHelper mExportHelper = new ExportHelper((ActionBarActivity) getActivity()); mExportHelper - .showExportKeysDialog(ids, - Id.type.public_key, - Constants.Path.APP_DIR_FILE_PUB); + .showExportKeysDialog(masterKeyIds, Id.type.public_key, + Constants.Path.APP_DIR_FILE_PUB, + getString(R.string.also_export_secret_keys)); break; } case R.id.menu_key_list_multi_select_all: { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index 93bb83003..c4097403c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -124,8 +124,11 @@ public class ViewKeyActivity extends ActionBarActivity { uploadToKeyserver(mDataUri); return true; case R.id.menu_key_view_export_file: - long[] ids = new long[]{Long.valueOf(mDataUri.getLastPathSegment())}; - mExportHelper.showExportKeysDialog(ids, Id.type.public_key, Constants.Path.APP_DIR_FILE_PUB); + long masterKeyId = + ProviderHelper.getPublicMasterKeyId(this, Long.valueOf(mDataUri.getLastPathSegment())); + long[] ids = new long[]{masterKeyId}; + mExportHelper.showExportKeysDialog(ids, Id.type.public_key, + Constants.Path.APP_DIR_FILE_PUB, null); return true; case R.id.menu_key_view_share_default_fingerprint: shareKey(mDataUri, true); diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index 77891d6c7..947801217 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -219,6 +219,7 @@ Do you really want to delete the key \'%s\'?\nYou can\'t undo this! Do you really want to delete all selected keys?\nYou can\'t undo this! Do you really want to delete the SECRET key \'%s\'?\nYou can\'t undo this! + Also export secret keys? Successfully added %d key -- cgit v1.2.3 From 207010dd86c11db2db04f426d434b68784baacbe Mon Sep 17 00:00:00 2001 From: gogowitczak Date: Sat, 15 Mar 2014 21:16:34 +0100 Subject: Keyserver query now uses machine readable output for search and get. Added separate function for converting algorithm integer ID to String. --- .../keychain/pgp/PgpKeyHelper.java | 4 +- .../keychain/ui/adapter/ImportKeysListEntry.java | 45 +++-- .../keychain/util/HkpKeyServer.java | 193 +++++++++++++-------- 3 files changed, 150 insertions(+), 92 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index 436c26700..b93c68677 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -477,7 +477,7 @@ public class PgpKeyHelper { * @return */ public static String convertKeyIdToHex(long keyId) { - return "0x" + convertKeyIdToHex32bit(keyId >> 32) + convertKeyIdToHex32bit(keyId); + return "0x" + ((keyId >> 32) > 0 ? convertKeyIdToHex32bit(keyId >> 32) : "") + convertKeyIdToHex32bit(keyId); } private static String convertKeyIdToHex32bit(long keyId) { @@ -498,7 +498,7 @@ public class PgpKeyHelper { int len = hexString.length(); String s2 = hexString.substring(len - 8); String s1 = hexString.substring(0, len - 8); - return (Long.parseLong(s1, 16) << 32) | Long.parseLong(s2, 16); + return ((!s1.isEmpty() ? Long.parseLong(s1, 16) << 32 : 0) | Long.parseLong(s2, 16)); } /** diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java index 19f0d1eaf..13309435d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java @@ -19,6 +19,7 @@ package org.sufficientlysecure.keychain.ui.adapter; import android.os.Parcel; import android.os.Parcelable; +import android.util.SparseArray; import org.spongycastle.openpgp.PGPKeyRing; import org.spongycastle.openpgp.PGPPublicKey; import org.spongycastle.openpgp.PGPSecretKeyRing; @@ -171,20 +172,34 @@ public class ImportKeysListEntry implements Serializable, Parcelable { .getFingerprint(), true); this.hexKeyId = PgpKeyHelper.convertKeyIdToHex(keyId); this.bitStrength = pgpKeyRing.getPublicKey().getBitStrength(); - int algorithm = pgpKeyRing.getPublicKey().getAlgorithm(); - if (algorithm == PGPPublicKey.RSA_ENCRYPT || algorithm == PGPPublicKey.RSA_GENERAL - || algorithm == PGPPublicKey.RSA_SIGN) { - this.algorithm = "RSA"; - } else if (algorithm == PGPPublicKey.DSA) { - this.algorithm = "DSA"; - } else if (algorithm == PGPPublicKey.ELGAMAL_ENCRYPT - || algorithm == PGPPublicKey.ELGAMAL_GENERAL) { - this.algorithm = "ElGamal"; - } else if (algorithm == PGPPublicKey.EC || algorithm == PGPPublicKey.ECDSA) { - this.algorithm = "ECC"; - } else { - // TODO: with resources - this.algorithm = "unknown"; - } + final int algorithm = pgpKeyRing.getPublicKey().getAlgorithm(); + this.algorithm = getAlgorithmFromId(algorithm); } + + /** + * Based on OpenPGP Message Format + */ + private final static SparseArray ALGORITHM_IDS = new SparseArray() {{ + put(-1, "unknown"); // TODO: with resources + put(0, "unencrypted"); + put(PGPPublicKey.RSA_GENERAL, "RSA"); + put(PGPPublicKey.RSA_ENCRYPT, "RSA"); + put(PGPPublicKey.RSA_SIGN, "RSA"); + put(PGPPublicKey.ELGAMAL_ENCRYPT, "ElGamal"); + put(PGPPublicKey.ELGAMAL_GENERAL, "ElGamal"); + put(PGPPublicKey.DSA, "DSA"); + put(PGPPublicKey.EC, "ECC"); + put(PGPPublicKey.ECDSA, "ECC"); + put(PGPPublicKey.ECDH, "ECC"); + }}; + + /** + * Based on OpenPGP Message Format + */ + public static String getAlgorithmFromId(int algorithmId) { + return (ALGORITHM_IDS.get(algorithmId) != null ? ALGORITHM_IDS.get(algorithmId) : ALGORITHM_IDS.get(-1)); + } + } + + diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java index 42fb03a3e..7ec532f5b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java @@ -43,6 +43,8 @@ import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; +import static org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry.getAlgorithmFromId; + /** * TODO: * rewrite to use machine readable output. @@ -74,16 +76,55 @@ public class HkpKeyServer extends KeyServer { private String mHost; private short mPort; - // example: - // pub 2048R/9F5C9090 2009-08-17 Jörg Runge - // <joerg@joergrunge.de> - public static final Pattern PUB_KEY_LINE = Pattern - .compile( - "pub +([0-9]+)([a-z]+)/.*?0x([0-9a-z]+).*? +([0-9-]+) +(.+)[\n\r]+((?: +.+[\n\r]+)*)", - Pattern.CASE_INSENSITIVE); - public static final Pattern USER_ID_LINE = Pattern.compile("^ +(.+)$", Pattern.MULTILINE - | Pattern.CASE_INSENSITIVE); + /** + * pub:%keyid%:%algo%:%keylen%:%creationdate%:%expirationdate%:%flags% + *
    + *
  • %keyid% = this is either the fingerprint or the key ID of the key. + * Either the 16-digit or 8-digit key IDs are acceptable, but obviously the fingerprint is best.
  • + *
  • %algo% = the algorithm number, (i.e. 1==RSA, 17==DSA, etc). See RFC-2440
  • + *
  • %keylen% = the key length (i.e. 1024, 2048, 4096, etc.)
  • + *
  • %creationdate% = creation date of the key in standard RFC-2440 form (i.e. number of seconds since 1/1/1970 UTC time)
  • + *
  • %expirationdate% = expiration date of the key in standard RFC-2440 form (i.e. number of seconds since 1/1/1970 UTC time)
  • + *
  • %flags% = letter codes to indicate details of the key, if any. Flags may be in any order. The + * meaning of "disabled" is implementation-specific. Note that individual flags may be unimplemented, so + * the absence of a given flag does not necessarily mean the absence of the detail. + *
      + *
    • r == revoked
    • + *
    • d == disabled
    • + *
    • e == expired
    • + *
    + *
  • + *
+ * + * + * @see 5.2. Machine Readable Indexes in Internet-Draft OpenPGP HTTP Keyserver Protocol Document + */ + public static final Pattern PUB_KEY_LINE = Pattern + .compile("pub:([0-9a-fA-F]+):([0-9]+):([0-9]+):([0-9]+):([0-9]*):([rde]*)[ \n\r]*" // pub line + + "(uid:(.*):([0-9]+):([0-9]*):([rde]*))+", // one or more uid lines + Pattern.CASE_INSENSITIVE); + + /** + * uid:%escaped uid string%:%creationdate%:%expirationdate%:%flags% + *
    + *
  • %escaped uid string% = the user ID string, with HTTP %-escaping for anything that isn't 7-bit + * safe as well as for the ":" character. Any other characters may be escaped, as desired.
  • + *
  • %creationdate% = creation date of the key in standard RFC-2440 form (i.e. number of seconds since 1/1/1970 UTC time)
  • + *
  • %expirationdate% = expiration date of the key in standard RFC-2440 form (i.e. number of seconds since 1/1/1970 UTC time)
  • + *
  • %flags% = letter codes to indicate details of the key, if any. Flags may be in any order. The + * meaning of "disabled" is implementation-specific. Note that individual flags may be unimplemented, so + * the absence of a given flag does not necessarily mean the absence of the detail. + *
      + *
    • r == revoked
    • + *
    • d == disabled
    • + *
    • e == expired
    • + *
    + *
  • + *
+ */ + public static final Pattern UID_LINE = Pattern + .compile("uid:(.*):([0-9]+):([0-9]*):([rde]*)", + Pattern.CASE_INSENSITIVE); private static final short PORT_DEFAULT = 11371; @@ -158,82 +199,84 @@ public class HkpKeyServer extends KeyServer { throw new QueryException("querying server(s) for '" + mHost + "' failed"); } - @Override - public ArrayList search(String query) throws QueryException, TooManyResponses, - InsufficientQuery { - ArrayList results = new ArrayList(); + @Override + public ArrayList search(String query) throws QueryException, TooManyResponses, + InsufficientQuery { + ArrayList results = new ArrayList(); - if (query.length() < 3) { - throw new InsufficientQuery(); - } + if (query.length() < 3) { + throw new InsufficientQuery(); + } - String encodedQuery; - try { - encodedQuery = URLEncoder.encode(query, "utf8"); - } catch (UnsupportedEncodingException e) { - return null; - } - String request = "/pks/lookup?op=index&search=" + encodedQuery; + String encodedQuery; + try { + encodedQuery = URLEncoder.encode(query, "utf8"); + } catch (UnsupportedEncodingException e) { + return null; + } + String request = "/pks/lookup?op=index&search=" + encodedQuery + "&options=mr"; - String data = null; - try { - data = query(request); - } catch (HttpError e) { - if (e.getCode() == 404) { - return results; - } else { - if (e.getData().toLowerCase(Locale.US).contains("no keys found")) { - return results; - } else if (e.getData().toLowerCase(Locale.US).contains("too many")) { - throw new TooManyResponses(); - } else if (e.getData().toLowerCase(Locale.US).contains("insufficient")) { - throw new InsufficientQuery(); - } - } - throw new QueryException("querying server(s) for '" + mHost + "' failed"); - } + String data = null; + try { + data = query(request); + } catch (HttpError e) { + if (e.getCode() == 404) { + return results; + } else { + if (e.getData().toLowerCase(Locale.US).contains("no keys found")) { + return results; + } else if (e.getData().toLowerCase(Locale.US).contains("too many")) { + throw new TooManyResponses(); + } else if (e.getData().toLowerCase(Locale.US).contains("insufficient")) { + throw new InsufficientQuery(); + } + } + throw new QueryException("querying server(s) for '" + mHost + "' failed"); + } - Matcher matcher = PUB_KEY_LINE.matcher(data); - while (matcher.find()) { - ImportKeysListEntry info = new ImportKeysListEntry(); - info.bitStrength = Integer.parseInt(matcher.group(1)); - info.algorithm = matcher.group(2); - info.hexKeyId = "0x" + matcher.group(3); - info.keyId = PgpKeyHelper.convertHexToKeyId(matcher.group(3)); - String chunks[] = matcher.group(4).split("-"); - - GregorianCalendar tmpGreg = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - tmpGreg.set(Integer.parseInt(chunks[0]), Integer.parseInt(chunks[1]), - Integer.parseInt(chunks[2])); - info.date = tmpGreg.getTime(); - info.userIds = new ArrayList(); - if (matcher.group(5).startsWith("*** KEY")) { - info.revoked = true; - } else { - String tmp = matcher.group(5).replaceAll("<.*?>", ""); - tmp = Html.fromHtml(tmp).toString(); - info.userIds.add(tmp); - } - if (matcher.group(6).length() > 0) { - Matcher matcher2 = USER_ID_LINE.matcher(matcher.group(6)); - while (matcher2.find()) { - String tmp = matcher2.group(1).replaceAll("<.*?>", ""); - tmp = Html.fromHtml(tmp).toString(); - info.userIds.add(tmp); - } - } - results.add(info); - } + final Matcher matcher = PUB_KEY_LINE.matcher(data); + while (matcher.find()) { + final ImportKeysListEntry info = new ImportKeysListEntry(); + info.bitStrength = Integer.parseInt(matcher.group(3)); + final int algorithmId = Integer.decode(matcher.group(2)); + info.algorithm = getAlgorithmFromId(algorithmId); - return results; - } + info.hexKeyId = "0x" + matcher.group(1); + info.keyId = PgpKeyHelper.convertHexToKeyId(matcher.group(1)); + + final long creationDate = Long.parseLong(matcher.group(4)); + final GregorianCalendar tmpGreg = new GregorianCalendar(TimeZone.getTimeZone("UTC")); + tmpGreg.setTimeInMillis(creationDate*1000); + info.date = tmpGreg.getTime(); + + info.revoked = matcher.group(6).contains("r"); + info.userIds = new ArrayList(); + + final String uidLines = matcher.group(7); + final Matcher uidMatcher = UID_LINE.matcher(uidLines); + while (uidMatcher.find()) { + String tmp = uidMatcher.group(1).replaceAll("<.*?>", ""); + tmp = Html.fromHtml(tmp).toString().trim(); + if (tmp.contains("%")) + { + try { + tmp = (URLDecoder.decode(tmp, "UTF8")); // converts String like "Universit%C3%A4t" to a proper form "Universität". + } catch (UnsupportedEncodingException ignored) { + } + } + info.userIds.add(tmp); + } + results.add(info); + } + return results; + } @Override public String get(long keyId) throws QueryException { HttpClient client = new DefaultHttpClient(); try { HttpGet get = new HttpGet("http://" + mHost + ":" + mPort - + "/pks/lookup?op=get&search=" + PgpKeyHelper.convertKeyIdToHex(keyId)); + + "/pks/lookup?op=get&search=" + PgpKeyHelper.convertKeyIdToHex(keyId) + "&options=mr"); HttpResponse response = client.execute(get); if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { -- cgit v1.2.3 From 5277e4c1e76e185132716b0a807066c5abbf340c Mon Sep 17 00:00:00 2001 From: gogowitczak Date: Sat, 15 Mar 2014 22:01:37 +0100 Subject: removed TODO comment --- .../java/org/sufficientlysecure/keychain/util/HkpKeyServer.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java index 7ec532f5b..0839fc494 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java @@ -45,13 +45,6 @@ import java.util.regex.Pattern; import static org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry.getAlgorithmFromId; -/** - * TODO: - * rewrite to use machine readable output. - *

- * see http://tools.ietf.org/html/draft-shaw-openpgp-hkp-00#section-5 - * https://github.com/openpgp-keychain/openpgp-keychain/issues/259 - */ public class HkpKeyServer extends KeyServer { private static class HttpError extends Exception { private static final long serialVersionUID = 1718783705229428893L; -- cgit v1.2.3 From cea62b1857a9b5dbade8dcff6009f72e309b7469 Mon Sep 17 00:00:00 2001 From: uberspot Date: Sun, 16 Mar 2014 23:35:14 +0200 Subject: Lock drawer as open in tablets --- .../keychain/helper/ActionBarHelper.java | 1 - .../keychain/ui/DrawerActivity.java | 86 +++-- .../keychain/ui/KeyListActivity.java | 3 + .../res/layout-large/api_apps_list_activity.xml | 20 ++ .../src/main/res/layout-large/decrypt_activity.xml | 19 + .../src/main/res/layout-large/encrypt_activity.xml | 19 + .../main/res/layout-large/import_keys_activity.xml | 21 ++ .../main/res/layout-large/key_list_activity.xml | 18 + .../src/main/res/layout/api_apps_list_activity.xml | 11 +- .../src/main/res/layout/api_apps_list_content.xml | 14 + .../src/main/res/layout/decrypt_activity.xml | 201 +---------- .../src/main/res/layout/decrypt_content.xml | 205 +++++++++++ .../src/main/res/layout/drawer_list.xml | 2 +- .../src/main/res/layout/encrypt_activity.xml | 394 +------------------- .../src/main/res/layout/encrypt_content.xml | 398 +++++++++++++++++++++ .../src/main/res/layout/import_keys_activity.xml | 53 +-- .../src/main/res/layout/import_keys_content.xml | 56 +++ .../src/main/res/layout/key_list_activity.xml | 11 +- .../src/main/res/layout/key_list_content.xml | 14 + .../src/main/res/values-large/dimens.xml | 4 + OpenPGP-Keychain/src/main/res/values/dimens.xml | 5 + 21 files changed, 863 insertions(+), 692 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/res/layout-large/api_apps_list_activity.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout-large/decrypt_activity.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout-large/encrypt_activity.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout-large/import_keys_activity.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout-large/key_list_activity.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout/api_apps_list_content.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout/decrypt_content.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout/import_keys_content.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout/key_list_content.xml create mode 100644 OpenPGP-Keychain/src/main/res/values-large/dimens.xml create mode 100644 OpenPGP-Keychain/src/main/res/values/dimens.xml diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java index 91e50637e..a26df556d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ActionBarHelper.java @@ -37,7 +37,6 @@ public class ActionBarHelper { * @param activity */ public static void setBackButton(ActionBarActivity activity) { - // set actionbar without home button if called from another app final ActionBar actionBar = activity.getSupportActionBar(); Log.d(Constants.TAG, "calling package (only set when using startActivityForResult)=" + activity.getCallingPackage()); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java index c0fd53007..985f6c309 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java @@ -21,18 +21,17 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.res.Configuration; +import android.graphics.Color; import android.os.Bundle; import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarActivity; import android.view.*; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.ListView; -import android.widget.TextView; +import android.widget.*; import com.beardedhen.androidbootstrap.FontAwesomeText; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.ActionBarHelper; import org.sufficientlysecure.keychain.service.remote.RegisteredAppsListActivity; public class DrawerActivity extends ActionBarActivity { @@ -42,6 +41,7 @@ public class DrawerActivity extends ActionBarActivity { private CharSequence mDrawerTitle; private CharSequence mTitle; + private boolean mIsDrawerLocked = false; private static Class[] mItemsClass = new Class[]{KeyListActivity.class, EncryptActivity.class, DecryptActivity.class, ImportKeysActivity.class, @@ -55,10 +55,22 @@ public class DrawerActivity extends ActionBarActivity { mDrawerTitle = getString(R.string.app_name); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); - - // set a custom shadow that overlays the main content when the drawer - // opens - mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); + ViewGroup viewGroup = (ViewGroup) findViewById(R.id.content_frame); + int leftMarginLoaded = ((ViewGroup.MarginLayoutParams) viewGroup.getLayoutParams()).leftMargin; + int leftMarginInTablets = (int) getResources().getDimension(R.dimen.drawer_size); + int errorInMarginAllowed = 5; + + // if the left margin of the loaded layout is close to the + // one used in tablets then set drawer as open and locked + if( Math.abs(leftMarginLoaded - leftMarginInTablets) < errorInMarginAllowed) { + mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerList); + mDrawerLayout.setScrimColor(Color.TRANSPARENT); + mIsDrawerLocked = true; + } else { + // set a custom shadow that overlays the main content when the drawer opens + mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); + mIsDrawerLocked = false; + } NavItem mItemIconTexts[] = new NavItem[]{ new NavItem("fa-user", getString(R.string.nav_contacts)), @@ -73,8 +85,11 @@ public class DrawerActivity extends ActionBarActivity { mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // enable ActionBar app icon to behave as action to toggle nav drawer - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setHomeButtonEnabled(true); + // if the drawer is not locked + if ( !mIsDrawerLocked ) { + getSupportActionBar().setDisplayHomeAsUpEnabled(true); + getSupportActionBar().setHomeButtonEnabled(true); + } // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon @@ -86,19 +101,8 @@ public class DrawerActivity extends ActionBarActivity { ) { public void onDrawerClosed(View view) { getSupportActionBar().setTitle(mTitle); - // creates call to onPrepareOptionsMenu() - supportInvalidateOptionsMenu(); - // call intent activity if selected - if (mSelectedItem != null) { - finish(); - overridePendingTransition(0, 0); - - Intent intent = new Intent(DrawerActivity.this, mSelectedItem); - startActivity(intent); - // disable animation of activity start - overridePendingTransition(0, 0); - } + callIntentForSelectedItem(); } public void onDrawerOpened(View drawerView) { @@ -108,13 +112,37 @@ public class DrawerActivity extends ActionBarActivity { supportInvalidateOptionsMenu(); } }; - mDrawerLayout.setDrawerListener(mDrawerToggle); + if ( !mIsDrawerLocked ) { + mDrawerLayout.setDrawerListener(mDrawerToggle); + } + if ( mIsDrawerLocked ) { + // If the drawer is locked open make it un-focusable + // so that it doesn't consume all the Back button presses + mDrawerLayout.setFocusableInTouchMode(false); + } // if (savedInstanceState == null) { // selectItem(0); // } } + private void callIntentForSelectedItem() { + // creates call to onPrepareOptionsMenu() + supportInvalidateOptionsMenu(); + + // call intent activity if selected + if (mSelectedItem != null) { + finish(); + overridePendingTransition(0, 0); + + Intent intent = new Intent(this, mSelectedItem); + startActivity(intent); + + // disable animation of activity start + overridePendingTransition(0, 0); + } + } + @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(42, MENU_ID_PREFERENCE, 100, R.string.menu_preferences); @@ -185,10 +213,18 @@ public class DrawerActivity extends ActionBarActivity { private void selectItem(int position) { // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); - // setTitle(mDrawerTitles[position]); - mDrawerLayout.closeDrawer(mDrawerList); // set selected class mSelectedItem = mItemsClass[position]; + + // setTitle(mDrawerTitles[position]); + // If drawer isn't locked just close the drawer and + // it will move to the selected item by itself (via drawer toggle listener) + if ( !mIsDrawerLocked ) { + mDrawerLayout.closeDrawer(mDrawerList); + // else move to the selected item yourself + } else { + callIntentForSelectedItem(); + } } /** diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java index 5ff4dbdeb..57709350e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java @@ -53,8 +53,11 @@ public class KeyListActivity extends DrawerActivity { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_key_list_import: + + overridePendingTransition(0, 0); Intent intentImport = new Intent(this, ImportKeysActivity.class); startActivityForResult(intentImport, 0); + overridePendingTransition(0, 0); return true; case R.id.menu_key_list_export: diff --git a/OpenPGP-Keychain/src/main/res/layout-large/api_apps_list_activity.xml b/OpenPGP-Keychain/src/main/res/layout-large/api_apps_list_activity.xml new file mode 100644 index 000000000..c0021261e --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout-large/api_apps_list_activity.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout-large/decrypt_activity.xml b/OpenPGP-Keychain/src/main/res/layout-large/decrypt_activity.xml new file mode 100644 index 000000000..26aed0831 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout-large/decrypt_activity.xml @@ -0,0 +1,19 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout-large/encrypt_activity.xml b/OpenPGP-Keychain/src/main/res/layout-large/encrypt_activity.xml new file mode 100644 index 000000000..7d0d44074 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout-large/encrypt_activity.xml @@ -0,0 +1,19 @@ + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout-large/import_keys_activity.xml b/OpenPGP-Keychain/src/main/res/layout-large/import_keys_activity.xml new file mode 100644 index 000000000..2cb408441 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout-large/import_keys_activity.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout-large/key_list_activity.xml b/OpenPGP-Keychain/src/main/res/layout-large/key_list_activity.xml new file mode 100644 index 000000000..6636f12ff --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout-large/key_list_activity.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/api_apps_list_activity.xml b/OpenPGP-Keychain/src/main/res/layout/api_apps_list_activity.xml index 71fbcfb12..9f95e9f3b 100644 --- a/OpenPGP-Keychain/src/main/res/layout/api_apps_list_activity.xml +++ b/OpenPGP-Keychain/src/main/res/layout/api_apps_list_activity.xml @@ -4,16 +4,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" > - - - - + diff --git a/OpenPGP-Keychain/src/main/res/layout/api_apps_list_content.xml b/OpenPGP-Keychain/src/main/res/layout/api_apps_list_content.xml new file mode 100644 index 000000000..b8606b929 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/api_apps_list_content.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml index 25c7c000c..c4709a67e 100644 --- a/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_activity.xml @@ -5,206 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_content.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_content.xml new file mode 100644 index 000000000..a847d9e46 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_content.xml @@ -0,0 +1,205 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/drawer_list.xml b/OpenPGP-Keychain/src/main/res/layout/drawer_list.xml index 81ceba20c..ab00c0073 100644 --- a/OpenPGP-Keychain/src/main/res/layout/drawer_list.xml +++ b/OpenPGP-Keychain/src/main/res/layout/drawer_list.xml @@ -9,7 +9,7 @@ --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml new file mode 100644 index 000000000..d6a05f0d4 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml @@ -0,0 +1,398 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/import_keys_activity.xml b/OpenPGP-Keychain/src/main/res/layout/import_keys_activity.xml index d7794ace3..b11f99757 100644 --- a/OpenPGP-Keychain/src/main/res/layout/import_keys_activity.xml +++ b/OpenPGP-Keychain/src/main/res/layout/import_keys_activity.xml @@ -5,58 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" > - - - - - - - - - - - - - - - - - - - + diff --git a/OpenPGP-Keychain/src/main/res/layout/import_keys_content.xml b/OpenPGP-Keychain/src/main/res/layout/import_keys_content.xml new file mode 100644 index 000000000..fae8147e5 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/import_keys_content.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/key_list_activity.xml b/OpenPGP-Keychain/src/main/res/layout/key_list_activity.xml index 65d246d7b..fcb376fa8 100644 --- a/OpenPGP-Keychain/src/main/res/layout/key_list_activity.xml +++ b/OpenPGP-Keychain/src/main/res/layout/key_list_activity.xml @@ -4,16 +4,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" > - - - - + diff --git a/OpenPGP-Keychain/src/main/res/layout/key_list_content.xml b/OpenPGP-Keychain/src/main/res/layout/key_list_content.xml new file mode 100644 index 000000000..e58e42961 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/key_list_content.xml @@ -0,0 +1,14 @@ + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/values-large/dimens.xml b/OpenPGP-Keychain/src/main/res/values-large/dimens.xml new file mode 100644 index 000000000..192a4bb99 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/values-large/dimens.xml @@ -0,0 +1,4 @@ + + + 240dp + diff --git a/OpenPGP-Keychain/src/main/res/values/dimens.xml b/OpenPGP-Keychain/src/main/res/values/dimens.xml new file mode 100644 index 000000000..e1a7749f0 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/values/dimens.xml @@ -0,0 +1,5 @@ + + + 240dp + 0dp + \ No newline at end of file -- cgit v1.2.3 From e01c99a193528df717d5cf5bd9fe20c649297375 Mon Sep 17 00:00:00 2001 From: uberspot Date: Mon, 17 Mar 2014 00:27:52 +0200 Subject: make loading of drawer items a bit more dynamic --- .../org/sufficientlysecure/keychain/Constants.java | 14 +++++++++++ .../keychain/ui/DrawerActivity.java | 27 +++++++++++----------- .../keychain/ui/KeyListActivity.java | 6 +---- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java index 011cd9663..ff4abe56a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java @@ -19,6 +19,11 @@ package org.sufficientlysecure.keychain; import android.os.Environment; import org.spongycastle.jce.provider.BouncyCastleProvider; +import org.sufficientlysecure.keychain.service.remote.RegisteredAppsListActivity; +import org.sufficientlysecure.keychain.ui.DecryptActivity; +import org.sufficientlysecure.keychain.ui.EncryptActivity; +import org.sufficientlysecure.keychain.ui.ImportKeysActivity; +import org.sufficientlysecure.keychain.ui.KeyListActivity; public final class Constants { @@ -63,4 +68,13 @@ public final class Constants { public static final String KEY_SERVERS = "pool.sks-keyservers.net, subkeys.pgp.net, pgp.mit.edu"; } + public static final class DrawerItems { + public static final Class KEY_LIST = KeyListActivity.class; + public static final Class ENCRYPT = EncryptActivity.class; + public static final Class DECRYPT = DecryptActivity.class; + public static final Class IMPORT_KEYS = ImportKeysActivity.class; + public static final Class REGISTERED_APPS_LIST = RegisteredAppsListActivity.class; + public static final Class[] ARRAY = new Class[]{KEY_LIST, ENCRYPT, DECRYPT, + IMPORT_KEYS, REGISTERED_APPS_LIST}; + } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java index 985f6c309..f01e67449 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java @@ -30,9 +30,8 @@ import android.support.v7.app.ActionBarActivity; import android.view.*; import android.widget.*; import com.beardedhen.androidbootstrap.FontAwesomeText; +import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.helper.ActionBarHelper; -import org.sufficientlysecure.keychain.service.remote.RegisteredAppsListActivity; public class DrawerActivity extends ActionBarActivity { private DrawerLayout mDrawerLayout; @@ -43,9 +42,6 @@ public class DrawerActivity extends ActionBarActivity { private CharSequence mTitle; private boolean mIsDrawerLocked = false; - private static Class[] mItemsClass = new Class[]{KeyListActivity.class, - EncryptActivity.class, DecryptActivity.class, ImportKeysActivity.class, - RegisteredAppsListActivity.class}; private Class mSelectedItem; private static final int MENU_ID_PREFERENCE = 222; @@ -102,7 +98,7 @@ public class DrawerActivity extends ActionBarActivity { public void onDrawerClosed(View view) { getSupportActionBar().setTitle(mTitle); - callIntentForSelectedItem(); + callIntentForDrawerItem(mSelectedItem); } public void onDrawerOpened(View drawerView) { @@ -112,11 +108,10 @@ public class DrawerActivity extends ActionBarActivity { supportInvalidateOptionsMenu(); } }; + if ( !mIsDrawerLocked ) { mDrawerLayout.setDrawerListener(mDrawerToggle); - } - - if ( mIsDrawerLocked ) { + } else { // If the drawer is locked open make it un-focusable // so that it doesn't consume all the Back button presses mDrawerLayout.setFocusableInTouchMode(false); @@ -126,16 +121,20 @@ public class DrawerActivity extends ActionBarActivity { // } } - private void callIntentForSelectedItem() { + /** + * Uses startActivity to call the Intent of the given class + * @param drawerItem the class of the drawer item you want to load. Based on Constants.DrawerItems.* + */ + public void callIntentForDrawerItem(Class drawerItem) { // creates call to onPrepareOptionsMenu() supportInvalidateOptionsMenu(); // call intent activity if selected - if (mSelectedItem != null) { + if (drawerItem != null) { finish(); overridePendingTransition(0, 0); - Intent intent = new Intent(this, mSelectedItem); + Intent intent = new Intent(this, drawerItem); startActivity(intent); // disable animation of activity start @@ -214,7 +213,7 @@ public class DrawerActivity extends ActionBarActivity { // update selected item and title, then close the drawer mDrawerList.setItemChecked(position, true); // set selected class - mSelectedItem = mItemsClass[position]; + mSelectedItem = Constants.DrawerItems.ARRAY[position]; // setTitle(mDrawerTitles[position]); // If drawer isn't locked just close the drawer and @@ -223,7 +222,7 @@ public class DrawerActivity extends ActionBarActivity { mDrawerLayout.closeDrawer(mDrawerList); // else move to the selected item yourself } else { - callIntentForSelectedItem(); + callIntentForDrawerItem(mSelectedItem); } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java index 57709350e..06df6f12d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java @@ -53,11 +53,7 @@ public class KeyListActivity extends DrawerActivity { public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.menu_key_list_import: - - overridePendingTransition(0, 0); - Intent intentImport = new Intent(this, ImportKeysActivity.class); - startActivityForResult(intentImport, 0); - overridePendingTransition(0, 0); + callIntentForDrawerItem(Constants.DrawerItems.IMPORT_KEYS); return true; case R.id.menu_key_list_export: -- cgit v1.2.3 From b39d37f59c5d1633f22a45a37c7dc94d6c37d010 Mon Sep 17 00:00:00 2001 From: Daniel Hammann Date: Mon, 17 Mar 2014 22:17:05 +0100 Subject: #429 4) In the clicking for a particular contact , two icon in the actionbar show the same hint ('Share'). Second icon hint can be 'Keyserver' or just only 'server' --- OpenPGP-Keychain/src/main/res/menu/key_view.xml | 2 +- OpenPGP-Keychain/src/main/res/values/arrays.xml | 2 +- OpenPGP-Keychain/src/main/res/values/strings.xml | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/menu/key_view.xml b/OpenPGP-Keychain/src/main/res/menu/key_view.xml index cd84cc91a..105368cbb 100644 --- a/OpenPGP-Keychain/src/main/res/menu/key_view.xml +++ b/OpenPGP-Keychain/src/main/res/menu/key_view.xml @@ -52,7 +52,7 @@ android:id="@+id/menu_key_keyserver" android:icon="@drawable/ic_action_import_export" app:showAsAction="always" - android:title="@string/menu_share"> + android:title="@string/menu_key_server">

@string/key_size_4096 - @string/menu_key_server + @string/menu_import_from_key_server @string/menu_import_from_file @string/menu_import_from_qr_code @string/import_from_clipboard diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index 77891d6c7..d6550d63d 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -84,10 +84,11 @@ Create key Create key (expert) Search - Import from keyserver + Keyserver + Keyserver… Update from keyserver Upload to key server - Share + Share… Share fingerprint… Share whole key… with… -- cgit v1.2.3 From fee18bd33e56a90f3d0df9d39dc70b3a2bf30132 Mon Sep 17 00:00:00 2001 From: gogowitczak Date: Tue, 18 Mar 2014 15:44:20 +0100 Subject: Fixed coding style. --- .../keychain/ui/adapter/ImportKeysListEntry.java | 49 ++-- .../keychain/util/HkpKeyServer.java | 250 +++++++++++---------- 2 files changed, 153 insertions(+), 146 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java index 13309435d..05521b0c9 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java @@ -173,33 +173,30 @@ public class ImportKeysListEntry implements Serializable, Parcelable { this.hexKeyId = PgpKeyHelper.convertKeyIdToHex(keyId); this.bitStrength = pgpKeyRing.getPublicKey().getBitStrength(); final int algorithm = pgpKeyRing.getPublicKey().getAlgorithm(); - this.algorithm = getAlgorithmFromId(algorithm); + this.algorithm = getAlgorithmFromId(algorithm); } - /** - * Based on OpenPGP Message Format - */ - private final static SparseArray ALGORITHM_IDS = new SparseArray() {{ - put(-1, "unknown"); // TODO: with resources - put(0, "unencrypted"); - put(PGPPublicKey.RSA_GENERAL, "RSA"); - put(PGPPublicKey.RSA_ENCRYPT, "RSA"); - put(PGPPublicKey.RSA_SIGN, "RSA"); - put(PGPPublicKey.ELGAMAL_ENCRYPT, "ElGamal"); - put(PGPPublicKey.ELGAMAL_GENERAL, "ElGamal"); - put(PGPPublicKey.DSA, "DSA"); - put(PGPPublicKey.EC, "ECC"); - put(PGPPublicKey.ECDSA, "ECC"); - put(PGPPublicKey.ECDH, "ECC"); - }}; - - /** - * Based on OpenPGP Message Format - */ - public static String getAlgorithmFromId(int algorithmId) { - return (ALGORITHM_IDS.get(algorithmId) != null ? ALGORITHM_IDS.get(algorithmId) : ALGORITHM_IDS.get(-1)); - } + /** + * Based on OpenPGP Message Format + */ + private final static SparseArray ALGORITHM_IDS = new SparseArray() {{ + put(-1, "unknown"); // TODO: with resources + put(0, "unencrypted"); + put(PGPPublicKey.RSA_GENERAL, "RSA"); + put(PGPPublicKey.RSA_ENCRYPT, "RSA"); + put(PGPPublicKey.RSA_SIGN, "RSA"); + put(PGPPublicKey.ELGAMAL_ENCRYPT, "ElGamal"); + put(PGPPublicKey.ELGAMAL_GENERAL, "ElGamal"); + put(PGPPublicKey.DSA, "DSA"); + put(PGPPublicKey.EC, "ECC"); + put(PGPPublicKey.ECDSA, "ECC"); + put(PGPPublicKey.ECDH, "ECC"); + }}; + /** + * Based on OpenPGP Message Format + */ + public static String getAlgorithmFromId(int algorithmId) { + return (ALGORITHM_IDS.get(algorithmId) != null ? ALGORITHM_IDS.get(algorithmId) : ALGORITHM_IDS.get(-1)); + } } - - diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java index 0839fc494..a354d19e8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java @@ -69,55 +69,64 @@ public class HkpKeyServer extends KeyServer { private String mHost; private short mPort; - /** - * pub:%keyid%:%algo%:%keylen%:%creationdate%:%expirationdate%:%flags% - *
    - *
  • %keyid% = this is either the fingerprint or the key ID of the key. - * Either the 16-digit or 8-digit key IDs are acceptable, but obviously the fingerprint is best.
  • - *
  • %algo% = the algorithm number, (i.e. 1==RSA, 17==DSA, etc). See RFC-2440
  • - *
  • %keylen% = the key length (i.e. 1024, 2048, 4096, etc.)
  • - *
  • %creationdate% = creation date of the key in standard RFC-2440 form (i.e. number of seconds since 1/1/1970 UTC time)
  • - *
  • %expirationdate% = expiration date of the key in standard RFC-2440 form (i.e. number of seconds since 1/1/1970 UTC time)
  • - *
  • %flags% = letter codes to indicate details of the key, if any. Flags may be in any order. The - * meaning of "disabled" is implementation-specific. Note that individual flags may be unimplemented, so - * the absence of a given flag does not necessarily mean the absence of the detail. - *
      - *
    • r == revoked
    • - *
    • d == disabled
    • - *
    • e == expired
    • - *
    - *
  • - *
- * - * - * @see 5.2. Machine Readable Indexes in Internet-Draft OpenPGP HTTP Keyserver Protocol Document - */ - public static final Pattern PUB_KEY_LINE = Pattern - .compile("pub:([0-9a-fA-F]+):([0-9]+):([0-9]+):([0-9]+):([0-9]*):([rde]*)[ \n\r]*" // pub line - + "(uid:(.*):([0-9]+):([0-9]*):([rde]*))+", // one or more uid lines - Pattern.CASE_INSENSITIVE); - - /** - * uid:%escaped uid string%:%creationdate%:%expirationdate%:%flags% - *
    - *
  • %escaped uid string% = the user ID string, with HTTP %-escaping for anything that isn't 7-bit - * safe as well as for the ":" character. Any other characters may be escaped, as desired.
  • - *
  • %creationdate% = creation date of the key in standard RFC-2440 form (i.e. number of seconds since 1/1/1970 UTC time)
  • - *
  • %expirationdate% = expiration date of the key in standard RFC-2440 form (i.e. number of seconds since 1/1/1970 UTC time)
  • - *
  • %flags% = letter codes to indicate details of the key, if any. Flags may be in any order. The - * meaning of "disabled" is implementation-specific. Note that individual flags may be unimplemented, so - * the absence of a given flag does not necessarily mean the absence of the detail. - *
      - *
    • r == revoked
    • - *
    • d == disabled
    • - *
    • e == expired
    • - *
    - *
  • - *
- */ - public static final Pattern UID_LINE = Pattern - .compile("uid:(.*):([0-9]+):([0-9]*):([rde]*)", - Pattern.CASE_INSENSITIVE); + /** + * pub:%keyid%:%algo%:%keylen%:%creationdate%:%expirationdate%:%flags% + *
    + *
  • %keyid% = this is either the fingerprint or the key ID of the key. Either the 16-digit or 8-digit + * key IDs are acceptable, but obviously the fingerprint is best.
  • + *
  • %algo% = the algorithm number, (i.e. 1==RSA, 17==DSA, etc). + * See RFC-2440
  • + *
  • %keylen% = the key length (i.e. 1024, 2048, 4096, etc.)
  • + *
  • %creationdate% = creation date of the key in standard + * RFC-2440 form (i.e. number of seconds since + * 1/1/1970 UTC time)
  • + *
  • %expirationdate% = expiration date of the key in standard + * RFC-2440 form (i.e. number of seconds since + * 1/1/1970 UTC time)
  • + *
  • %flags% = letter codes to indicate details of the key, if any. Flags may be in any order. The + * meaning of "disabled" is implementation-specific. Note that individual flags may be unimplemented, so + * the absence of a given flag does not necessarily mean the absence of the detail. + *
      + *
    • r == revoked
    • + *
    • d == disabled
    • + *
    • e == expired
    • + *
    + *
  • + *
+ * + * @see 5.2. Machine Readable Indexes + * in Internet-Draft OpenPGP HTTP Keyserver Protocol Document + */ + public static final Pattern PUB_KEY_LINE = Pattern + .compile("pub:([0-9a-fA-F]+):([0-9]+):([0-9]+):([0-9]+):([0-9]*):([rde]*)[ \n\r]*" // pub line + + "(uid:(.*):([0-9]+):([0-9]*):([rde]*))+", // one or more uid lines + Pattern.CASE_INSENSITIVE); + + /** + * uid:%escaped uid string%:%creationdate%:%expirationdate%:%flags% + *
    + *
  • %escaped uid string% = the user ID string, with HTTP %-escaping for anything that isn't 7-bit + * safe as well as for the ":" character. Any other characters may be escaped, as desired.
  • + *
  • %creationdate% = creation date of the key in standard + * RFC-2440 form (i.e. number of seconds since + * 1/1/1970 UTC time)
  • + *
  • %expirationdate% = expiration date of the key in standard + * RFC-2440 form (i.e. number of seconds since + * 1/1/1970 UTC time)
  • + *
  • %flags% = letter codes to indicate details of the key, if any. Flags may be in any order. The + * meaning of "disabled" is implementation-specific. Note that individual flags may be unimplemented, so + * the absence of a given flag does not necessarily mean the absence of the detail. + *
      + *
    • r == revoked
    • + *
    • d == disabled
    • + *
    • e == expired
    • + *
    + *
  • + *
+ */ + public static final Pattern UID_LINE = Pattern + .compile("uid:(.*):([0-9]+):([0-9]*):([rde]*)", + Pattern.CASE_INSENSITIVE); private static final short PORT_DEFAULT = 11371; @@ -192,77 +201,78 @@ public class HkpKeyServer extends KeyServer { throw new QueryException("querying server(s) for '" + mHost + "' failed"); } - @Override - public ArrayList search(String query) throws QueryException, TooManyResponses, - InsufficientQuery { - ArrayList results = new ArrayList(); - - if (query.length() < 3) { - throw new InsufficientQuery(); - } - - String encodedQuery; - try { - encodedQuery = URLEncoder.encode(query, "utf8"); - } catch (UnsupportedEncodingException e) { - return null; - } - String request = "/pks/lookup?op=index&search=" + encodedQuery + "&options=mr"; - - String data = null; - try { - data = query(request); - } catch (HttpError e) { - if (e.getCode() == 404) { - return results; - } else { - if (e.getData().toLowerCase(Locale.US).contains("no keys found")) { - return results; - } else if (e.getData().toLowerCase(Locale.US).contains("too many")) { - throw new TooManyResponses(); - } else if (e.getData().toLowerCase(Locale.US).contains("insufficient")) { - throw new InsufficientQuery(); - } - } - throw new QueryException("querying server(s) for '" + mHost + "' failed"); - } - - final Matcher matcher = PUB_KEY_LINE.matcher(data); - while (matcher.find()) { - final ImportKeysListEntry info = new ImportKeysListEntry(); - info.bitStrength = Integer.parseInt(matcher.group(3)); - final int algorithmId = Integer.decode(matcher.group(2)); - info.algorithm = getAlgorithmFromId(algorithmId); - - info.hexKeyId = "0x" + matcher.group(1); - info.keyId = PgpKeyHelper.convertHexToKeyId(matcher.group(1)); - - final long creationDate = Long.parseLong(matcher.group(4)); - final GregorianCalendar tmpGreg = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - tmpGreg.setTimeInMillis(creationDate*1000); - info.date = tmpGreg.getTime(); - - info.revoked = matcher.group(6).contains("r"); - info.userIds = new ArrayList(); - - final String uidLines = matcher.group(7); - final Matcher uidMatcher = UID_LINE.matcher(uidLines); - while (uidMatcher.find()) { - String tmp = uidMatcher.group(1).replaceAll("<.*?>", ""); - tmp = Html.fromHtml(tmp).toString().trim(); - if (tmp.contains("%")) - { - try { - tmp = (URLDecoder.decode(tmp, "UTF8")); // converts String like "Universit%C3%A4t" to a proper form "Universität". - } catch (UnsupportedEncodingException ignored) { - } - } - info.userIds.add(tmp); - } - results.add(info); - } - return results; - } + @Override + public ArrayList search(String query) throws QueryException, TooManyResponses, + InsufficientQuery { + ArrayList results = new ArrayList(); + + if (query.length() < 3) { + throw new InsufficientQuery(); + } + + String encodedQuery; + try { + encodedQuery = URLEncoder.encode(query, "utf8"); + } catch (UnsupportedEncodingException e) { + return null; + } + String request = "/pks/lookup?op=index&search=" + encodedQuery + "&options=mr"; + + String data = null; + try { + data = query(request); + } catch (HttpError e) { + if (e.getCode() == 404) { + return results; + } else { + if (e.getData().toLowerCase(Locale.US).contains("no keys found")) { + return results; + } else if (e.getData().toLowerCase(Locale.US).contains("too many")) { + throw new TooManyResponses(); + } else if (e.getData().toLowerCase(Locale.US).contains("insufficient")) { + throw new InsufficientQuery(); + } + } + throw new QueryException("querying server(s) for '" + mHost + "' failed"); + } + + final Matcher matcher = PUB_KEY_LINE.matcher(data); + while (matcher.find()) { + final ImportKeysListEntry info = new ImportKeysListEntry(); + info.bitStrength = Integer.parseInt(matcher.group(3)); + final int algorithmId = Integer.decode(matcher.group(2)); + info.algorithm = getAlgorithmFromId(algorithmId); + + info.hexKeyId = "0x" + matcher.group(1); + info.keyId = PgpKeyHelper.convertHexToKeyId(matcher.group(1)); + + final long creationDate = Long.parseLong(matcher.group(4)); + final GregorianCalendar tmpGreg = new GregorianCalendar(TimeZone.getTimeZone("UTC")); + tmpGreg.setTimeInMillis(creationDate * 1000); + info.date = tmpGreg.getTime(); + + info.revoked = matcher.group(6).contains("r"); + info.userIds = new ArrayList(); + + final String uidLines = matcher.group(7); + final Matcher uidMatcher = UID_LINE.matcher(uidLines); + while (uidMatcher.find()) { + String tmp = uidMatcher.group(1).replaceAll("<.*?>", ""); + tmp = Html.fromHtml(tmp).toString().trim(); + if (tmp.contains("%")) { + try { + // converts Strings like "Universit%C3%A4t" to a proper encoding form "Universität". + tmp = (URLDecoder.decode(tmp, "UTF8")); + } catch (UnsupportedEncodingException ignored) { + // will never happen, because "UTF8" is supported + } + } + info.userIds.add(tmp); + } + results.add(info); + } + return results; + } @Override public String get(long keyId) throws QueryException { -- cgit v1.2.3 From fa439c1a721320eb6c4bb17532ff96937bbb4a17 Mon Sep 17 00:00:00 2001 From: Sreeram Boyapati Date: Tue, 18 Mar 2014 07:17:05 +0530 Subject: Can_Encrypt Check added to hide Button --- .../java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index eeb17fea2..b2f9c9f40 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -266,7 +266,10 @@ public class ViewKeyMainFragment extends Fragment implements if (data.moveToFirst()) { // get key id from MASTER_KEY_ID long keyId = data.getLong(KEYS_INDEX_KEY_ID); - + long can_encrypt = data.getLong(KEYS_INDEX_CAN_ENCRYPT); + if(can_encrypt == 0){ + mActionEncrypt.setVisibility(View.GONE); + } String keyIdStr = PgpKeyHelper.convertKeyIdToHex(keyId); mKeyId.setText(keyIdStr); -- cgit v1.2.3 From 93447bf3f866efe35d3fe7713693ccb03ec2628e Mon Sep 17 00:00:00 2001 From: Daniel Hammann Date: Tue, 18 Mar 2014 16:07:17 +0100 Subject: Show revocation status in SelectPublicKeyFragment #375 Added revocation status in Key List View (graphical symbol and red coloring) --- .../keychain/ui/ViewKeyMainFragment.java | 11 +- .../keychain/ui/adapter/ViewKeyKeysAdapter.java | 13 +- .../main/res/drawable-hdpi/revoked_key_small.png | Bin 0 -> 2509 bytes .../src/main/res/drawable/revoked_key_small.png | Bin 0 -> 1793 bytes .../src/main/res/layout/view_key_keys_item.xml | 4 + Resources/graphics/revokedKey.png | Bin 0 -> 68871 bytes Resources/graphics/revokedKey.svg | 14909 +++++++++++++++++++ 7 files changed, 14931 insertions(+), 6 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/res/drawable-hdpi/revoked_key_small.png create mode 100644 OpenPGP-Keychain/src/main/res/drawable/revoked_key_small.png create mode 100644 Resources/graphics/revokedKey.png create mode 100644 Resources/graphics/revokedKey.svg diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index eeb17fea2..c5f2e0d8e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -192,8 +192,8 @@ public class ViewKeyMainFragment extends Fragment implements KeychainContract.Keys.IS_MASTER_KEY, KeychainContract.Keys.ALGORITHM, KeychainContract.Keys.KEY_SIZE, KeychainContract.Keys.CAN_CERTIFY, KeychainContract.Keys.CAN_SIGN, KeychainContract.Keys.CAN_ENCRYPT, - KeychainContract.Keys.CREATION, KeychainContract.Keys.EXPIRY, - KeychainContract.Keys.FINGERPRINT}; + KeychainContract.Keys.IS_REVOKED, KeychainContract.Keys.CREATION, + KeychainContract.Keys.EXPIRY, KeychainContract.Keys.FINGERPRINT}; static final String KEYS_SORT_ORDER = KeychainContract.Keys.RANK + " ASC"; static final int KEYS_INDEX_ID = 0; static final int KEYS_INDEX_KEY_ID = 1; @@ -203,9 +203,10 @@ public class ViewKeyMainFragment extends Fragment implements static final int KEYS_INDEX_CAN_CERTIFY = 5; static final int KEYS_INDEX_CAN_SIGN = 6; static final int KEYS_INDEX_CAN_ENCRYPT = 7; - static final int KEYS_INDEX_CREATION = 8; - static final int KEYS_INDEX_EXPIRY = 9; - static final int KEYS_INDEX_FINGERPRINT = 10; + static final int KEY_INDEX_IS_REVOKED = 8; + static final int KEYS_INDEX_CREATION = 9; + static final int KEYS_INDEX_EXPIRY = 10; + static final int KEYS_INDEX_FINGERPRINT = 11; public Loader onCreateLoader(int id, Bundle args) { switch (id) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java index 153a3f266..5f911275d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java @@ -19,6 +19,7 @@ package org.sufficientlysecure.keychain.ui.adapter; import android.content.Context; import android.database.Cursor; +import android.graphics.Color; import android.support.v4.widget.CursorAdapter; import android.view.LayoutInflater; import android.view.View; @@ -39,6 +40,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter { private int mIndexCanCertify; private int mIndexCanEncrypt; private int mIndexCanSign; + private int mIndexRevokedKey; public ViewKeyKeysAdapter(Context context, Cursor c, int flags) { super(context, c, flags); @@ -70,6 +72,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter { mIndexCanCertify = cursor.getColumnIndexOrThrow(Keys.CAN_CERTIFY); mIndexCanEncrypt = cursor.getColumnIndexOrThrow(Keys.CAN_ENCRYPT); mIndexCanSign = cursor.getColumnIndexOrThrow(Keys.CAN_SIGN); + mIndexRevokedKey = cursor.getColumnIndexOrThrow(Keys.IS_REVOKED); } } @@ -81,13 +84,13 @@ public class ViewKeyKeysAdapter extends CursorAdapter { ImageView certifyIcon = (ImageView) view.findViewById(R.id.ic_certifyKey); ImageView encryptIcon = (ImageView) view.findViewById(R.id.ic_encryptKey); ImageView signIcon = (ImageView) view.findViewById(R.id.ic_signKey); + ImageView revokedKeyIcon = (ImageView) view.findViewById(R.id.ic_revokedKey); String keyIdStr = PgpKeyHelper.convertKeyIdToHex(cursor.getLong(mIndexKeyId)); String algorithmStr = PgpKeyHelper.getAlgorithmInfo(cursor.getInt(mIndexAlgorithm), cursor.getInt(mIndexKeySize)); keyId.setText(keyIdStr); - keyDetails.setText("(" + algorithmStr + ")"); if (cursor.getInt(mIndexIsMasterKey) != 1) { @@ -113,6 +116,14 @@ public class ViewKeyKeysAdapter extends CursorAdapter { } else { signIcon.setVisibility(View.VISIBLE); } + + if (cursor.getInt(mIndexRevokedKey) > 0) { + revokedKeyIcon.setVisibility(View.VISIBLE); + keyId.setTextColor(Color.RED); + keyDetails.setTextColor(Color.RED); + } else { + revokedKeyIcon.setVisibility(View.GONE); + } } @Override diff --git a/OpenPGP-Keychain/src/main/res/drawable-hdpi/revoked_key_small.png b/OpenPGP-Keychain/src/main/res/drawable-hdpi/revoked_key_small.png new file mode 100644 index 000000000..75f45eb54 Binary files /dev/null and b/OpenPGP-Keychain/src/main/res/drawable-hdpi/revoked_key_small.png differ diff --git a/OpenPGP-Keychain/src/main/res/drawable/revoked_key_small.png b/OpenPGP-Keychain/src/main/res/drawable/revoked_key_small.png new file mode 100644 index 000000000..f9ed0596f Binary files /dev/null and b/OpenPGP-Keychain/src/main/res/drawable/revoked_key_small.png differ diff --git a/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml b/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml index 9e4bc70eb..235949ce2 100644 --- a/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml +++ b/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml @@ -40,6 +40,10 @@ android:paddingBottom="2dip" android:paddingTop="2dip" > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + email + send + mail + user + not available + + + + Sept 2009 + + + Franziska Sponsel + + + + + Franziska Sponsel + + + + + RRZE + + + + + Beate Kaspar, Hendrik Eggers + + + uses < http://ftp.uni-erlangen.de/pub/rrze/tango/rrze-icon-set/tango/scalable/categories/email.svg>, < http://ftp.uni-erlangen.de/pub/rrze/tango/rrze-icon-set/tango/scalable/actions/action-undo.svg> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From f34b3ee5316b95bbef9c9ac30b753d1708c4dbc4 Mon Sep 17 00:00:00 2001 From: Sreeram Boyapati Date: Tue, 18 Mar 2014 20:40:09 +0530 Subject: Button Text changes to Change Passphrase if Passphrase is set --- .../java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index edf980773..93099427d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -368,9 +368,8 @@ public class EditKeyActivity extends ActionBarActivity { } mCurrentPassphrase = ""; - - buildLayout(); mIsPassPhraseSet = PassphraseCacheService.hasPassphrase(this, masterKeyId); + buildLayout(); if (!mIsPassPhraseSet) { // check "no passphrase" checkbox and remove button mNoPassphrase.setChecked(true); @@ -425,11 +424,14 @@ public class EditKeyActivity extends ActionBarActivity { // find views mChangePassphrase = (BootstrapButton) findViewById(R.id.edit_key_btn_change_passphrase); mNoPassphrase = (CheckBox) findViewById(R.id.edit_key_no_passphrase); - // Build layout based on given userIds and keys + LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout container = (LinearLayout) findViewById(R.id.edit_key_container); + if(mIsPassPhraseSet){ + mChangePassphrase.setText(getString(R.string.btn_change_passphrase)); + } mUserIdsView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false); mUserIdsView.setType(Id.type.user_id); mUserIdsView.setCanEdit(mMasterCanSign); -- cgit v1.2.3 From eebf1c171a0ba70a92d76f5affb93476f6813e30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 18 Mar 2014 16:29:40 +0100 Subject: add mr option in keyserver class before query (code simplification) --- .../java/org/sufficientlysecure/keychain/util/HkpKeyServer.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java index a354d19e8..0c07e9b06 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java @@ -216,9 +216,9 @@ public class HkpKeyServer extends KeyServer { } catch (UnsupportedEncodingException e) { return null; } - String request = "/pks/lookup?op=index&search=" + encodedQuery + "&options=mr"; + String request = "/pks/lookup?op=index&options=mr&search=" + encodedQuery; - String data = null; + String data; try { data = query(request); } catch (HttpError e) { @@ -279,7 +279,7 @@ public class HkpKeyServer extends KeyServer { HttpClient client = new DefaultHttpClient(); try { HttpGet get = new HttpGet("http://" + mHost + ":" + mPort - + "/pks/lookup?op=get&search=" + PgpKeyHelper.convertKeyIdToHex(keyId) + "&options=mr"); + + "/pks/lookup?op=get&options=mr&search=" + PgpKeyHelper.convertKeyIdToHex(keyId)); HttpResponse response = client.execute(get); if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { -- cgit v1.2.3 From 2d3f47eb99c18b188ed6e4f396605d6b0340de16 Mon Sep 17 00:00:00 2001 From: Daniel Hammann Date: Tue, 18 Mar 2014 16:07:17 +0100 Subject: Show revocation status in SelectPublicKeyFragment #375 Added revocation status in Key List View (graphical symbol and red coloring) --- .../keychain/ui/ViewKeyMainFragment.java | 11 +- .../keychain/ui/adapter/ViewKeyKeysAdapter.java | 13 +- .../main/res/drawable-hdpi/revoked_key_small.png | Bin 0 -> 2509 bytes .../src/main/res/drawable/revoked_key_small.png | Bin 0 -> 1793 bytes .../src/main/res/layout/view_key_keys_item.xml | 4 + Resources/graphics/revokedKey.png | Bin 0 -> 68871 bytes Resources/graphics/revokedKey.svg | 14909 +++++++++++++++++++ 7 files changed, 14931 insertions(+), 6 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/res/drawable-hdpi/revoked_key_small.png create mode 100644 OpenPGP-Keychain/src/main/res/drawable/revoked_key_small.png create mode 100644 Resources/graphics/revokedKey.png create mode 100644 Resources/graphics/revokedKey.svg diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index eeb17fea2..7ff4e0c57 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -192,8 +192,8 @@ public class ViewKeyMainFragment extends Fragment implements KeychainContract.Keys.IS_MASTER_KEY, KeychainContract.Keys.ALGORITHM, KeychainContract.Keys.KEY_SIZE, KeychainContract.Keys.CAN_CERTIFY, KeychainContract.Keys.CAN_SIGN, KeychainContract.Keys.CAN_ENCRYPT, - KeychainContract.Keys.CREATION, KeychainContract.Keys.EXPIRY, - KeychainContract.Keys.FINGERPRINT}; + KeychainContract.Keys.IS_REVOKED, KeychainContract.Keys.CREATION, + KeychainContract.Keys.EXPIRY, KeychainContract.Keys.FINGERPRINT}; static final String KEYS_SORT_ORDER = KeychainContract.Keys.RANK + " ASC"; static final int KEYS_INDEX_ID = 0; static final int KEYS_INDEX_KEY_ID = 1; @@ -203,9 +203,10 @@ public class ViewKeyMainFragment extends Fragment implements static final int KEYS_INDEX_CAN_CERTIFY = 5; static final int KEYS_INDEX_CAN_SIGN = 6; static final int KEYS_INDEX_CAN_ENCRYPT = 7; - static final int KEYS_INDEX_CREATION = 8; - static final int KEYS_INDEX_EXPIRY = 9; - static final int KEYS_INDEX_FINGERPRINT = 10; + static final int KEYS_INDEX_IS_REVOKED = 8; + static final int KEYS_INDEX_CREATION = 9; + static final int KEYS_INDEX_EXPIRY = 10; + static final int KEYS_INDEX_FINGERPRINT = 11; public Loader onCreateLoader(int id, Bundle args) { switch (id) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java index 153a3f266..5f911275d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java @@ -19,6 +19,7 @@ package org.sufficientlysecure.keychain.ui.adapter; import android.content.Context; import android.database.Cursor; +import android.graphics.Color; import android.support.v4.widget.CursorAdapter; import android.view.LayoutInflater; import android.view.View; @@ -39,6 +40,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter { private int mIndexCanCertify; private int mIndexCanEncrypt; private int mIndexCanSign; + private int mIndexRevokedKey; public ViewKeyKeysAdapter(Context context, Cursor c, int flags) { super(context, c, flags); @@ -70,6 +72,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter { mIndexCanCertify = cursor.getColumnIndexOrThrow(Keys.CAN_CERTIFY); mIndexCanEncrypt = cursor.getColumnIndexOrThrow(Keys.CAN_ENCRYPT); mIndexCanSign = cursor.getColumnIndexOrThrow(Keys.CAN_SIGN); + mIndexRevokedKey = cursor.getColumnIndexOrThrow(Keys.IS_REVOKED); } } @@ -81,13 +84,13 @@ public class ViewKeyKeysAdapter extends CursorAdapter { ImageView certifyIcon = (ImageView) view.findViewById(R.id.ic_certifyKey); ImageView encryptIcon = (ImageView) view.findViewById(R.id.ic_encryptKey); ImageView signIcon = (ImageView) view.findViewById(R.id.ic_signKey); + ImageView revokedKeyIcon = (ImageView) view.findViewById(R.id.ic_revokedKey); String keyIdStr = PgpKeyHelper.convertKeyIdToHex(cursor.getLong(mIndexKeyId)); String algorithmStr = PgpKeyHelper.getAlgorithmInfo(cursor.getInt(mIndexAlgorithm), cursor.getInt(mIndexKeySize)); keyId.setText(keyIdStr); - keyDetails.setText("(" + algorithmStr + ")"); if (cursor.getInt(mIndexIsMasterKey) != 1) { @@ -113,6 +116,14 @@ public class ViewKeyKeysAdapter extends CursorAdapter { } else { signIcon.setVisibility(View.VISIBLE); } + + if (cursor.getInt(mIndexRevokedKey) > 0) { + revokedKeyIcon.setVisibility(View.VISIBLE); + keyId.setTextColor(Color.RED); + keyDetails.setTextColor(Color.RED); + } else { + revokedKeyIcon.setVisibility(View.GONE); + } } @Override diff --git a/OpenPGP-Keychain/src/main/res/drawable-hdpi/revoked_key_small.png b/OpenPGP-Keychain/src/main/res/drawable-hdpi/revoked_key_small.png new file mode 100644 index 000000000..75f45eb54 Binary files /dev/null and b/OpenPGP-Keychain/src/main/res/drawable-hdpi/revoked_key_small.png differ diff --git a/OpenPGP-Keychain/src/main/res/drawable/revoked_key_small.png b/OpenPGP-Keychain/src/main/res/drawable/revoked_key_small.png new file mode 100644 index 000000000..f9ed0596f Binary files /dev/null and b/OpenPGP-Keychain/src/main/res/drawable/revoked_key_small.png differ diff --git a/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml b/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml index 9e4bc70eb..235949ce2 100644 --- a/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml +++ b/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml @@ -40,6 +40,10 @@ android:paddingBottom="2dip" android:paddingTop="2dip" > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + email + send + mail + user + not available + + + + Sept 2009 + + + Franziska Sponsel + + + + + Franziska Sponsel + + + + + RRZE + + + + + Beate Kaspar, Hendrik Eggers + + + uses < http://ftp.uni-erlangen.de/pub/rrze/tango/rrze-icon-set/tango/scalable/categories/email.svg>, < http://ftp.uni-erlangen.de/pub/rrze/tango/rrze-icon-set/tango/scalable/actions/action-undo.svg> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From 163e9fddb9f16d50efe2f936c096bcfec1de2117 Mon Sep 17 00:00:00 2001 From: Sreeram Boyapati Date: Tue, 18 Mar 2014 21:10:09 +0530 Subject: Code Style fix --- .../java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index b2f9c9f40..4844c4028 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -266,8 +266,8 @@ public class ViewKeyMainFragment extends Fragment implements if (data.moveToFirst()) { // get key id from MASTER_KEY_ID long keyId = data.getLong(KEYS_INDEX_KEY_ID); - long can_encrypt = data.getLong(KEYS_INDEX_CAN_ENCRYPT); - if(can_encrypt == 0){ + long canEncrypt = data.getLong(KEYS_INDEX_CAN_ENCRYPT); + if(canEncrypt == 0){ mActionEncrypt.setVisibility(View.GONE); } String keyIdStr = PgpKeyHelper.convertKeyIdToHex(keyId); -- cgit v1.2.3 From ea648e5a431e20bf7a49ff7e6f41ae89465db8c1 Mon Sep 17 00:00:00 2001 From: uberspot Date: Tue, 18 Mar 2014 19:24:04 +0200 Subject: fix emails not showing up in import keyserver search --- .../main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java index 0c07e9b06..9d6850027 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java @@ -257,8 +257,7 @@ public class HkpKeyServer extends KeyServer { final String uidLines = matcher.group(7); final Matcher uidMatcher = UID_LINE.matcher(uidLines); while (uidMatcher.find()) { - String tmp = uidMatcher.group(1).replaceAll("<.*?>", ""); - tmp = Html.fromHtml(tmp).toString().trim(); + String tmp = uidMatcher.group(1).trim(); if (tmp.contains("%")) { try { // converts Strings like "Universit%C3%A4t" to a proper encoding form "Universität". -- cgit v1.2.3 From 4aa24413deaa46fc5a583d6e380231a8ce630e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 18 Mar 2014 18:35:59 +0100 Subject: revert ca_necrypt patch --- .../java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index 1958d3bb8..e140cb21e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -286,10 +286,6 @@ public class ViewKeyMainFragment extends Fragment implements if (data.moveToFirst()) { // get key id from MASTER_KEY_ID long keyId = data.getLong(KEYS_INDEX_KEY_ID); - long canEncrypt = data.getLong(KEYS_INDEX_CAN_ENCRYPT); - if(canEncrypt == 0){ - mActionEncrypt.setVisibility(View.GONE); - } String keyIdStr = PgpKeyHelper.convertKeyIdToHex(keyId); mKeyId.setText(keyIdStr); -- cgit v1.2.3 From 654c3029610f932d3d3396ce70e4bf2702427b38 Mon Sep 17 00:00:00 2001 From: uberspot Date: Tue, 18 Mar 2014 20:13:33 +0200 Subject: CertifyKeyActivity sets error if no key is selected --- .../sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java index 3d22ca9f6..6b57fc568 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java @@ -119,8 +119,8 @@ public class SelectSecretKeyLayoutFragment extends Fragment { } public void setError(String error) { - mKeyUserId.requestFocus(); - mKeyUserId.setError(error); + mNoKeySelected.requestFocus(); + mNoKeySelected.setError(error); } /** -- cgit v1.2.3 From 9d60224980e33552993baa20e99c656b1203ab55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 18 Mar 2014 19:36:59 +0100 Subject: Cleanup SelectSecretKeyActivity and also return Uri --- .../keychain/ui/SelectSecretKeyActivity.java | 89 +++++----------------- .../keychain/ui/SelectSecretKeyFragment.java | 12 +-- 2 files changed, 26 insertions(+), 75 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java index 1509bc88c..40771b90d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java @@ -1,36 +1,32 @@ /* - * Copyright (C) 2012 Dominik Schürmann - * Copyright (C) 2010 Thialfihar + * Copyright (C) 2012-2014 Dominik Schürmann * - * 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 + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * 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. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package org.sufficientlysecure.keychain.ui; import android.content.Intent; +import android.net.Uri; import android.os.Bundle; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; -import android.view.Menu; -import org.sufficientlysecure.keychain.Constants; + import org.sufficientlysecure.keychain.R; public class SelectSecretKeyActivity extends ActionBarActivity { - // Actions for internal use only: - public static final String ACTION_SELECT_SECRET_KEY = Constants.INTENT_PREFIX - + "SELECT_SECRET_KEYRING"; - public static final String EXTRA_FILTER_CERTIFY = "filter_certify"; public static final String RESULT_EXTRA_MASTER_KEY_ID = "master_key_id"; @@ -50,23 +46,8 @@ public class SelectSecretKeyActivity extends ActionBarActivity { actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setHomeButtonEnabled(false); - setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); - - // TODO: reimplement! - // mFilterLayout = findViewById(R.id.layout_filter); - // mFilterInfo = (TextView) mFilterLayout.findViewById(R.id.filterInfo); - // mClearFilterButton = (Button) mFilterLayout.findViewById(R.id.btn_clear); - // - // mClearFilterButton.setOnClickListener(new OnClickListener() { - // public void onClick(View v) { - // handleIntent(new Intent()); - // } - // }); - mFilterCertify = getIntent().getBooleanExtra(EXTRA_FILTER_CERTIFY, false); - handleIntent(getIntent()); - // Check that the activity is using the layout version with // the fragment_container FrameLayout if (findViewById(R.id.select_secret_key_fragment_container) != null) { @@ -90,48 +71,18 @@ public class SelectSecretKeyActivity extends ActionBarActivity { /** * This is executed by SelectSecretKeyFragment after clicking on an item * - * @param masterKeyId - * @param userId + * @param selectedUri */ - public void afterListSelection(long masterKeyId, String userId) { + public void afterListSelection(Uri selectedUri) { Intent data = new Intent(); + data.setData(selectedUri); + + // TODO: deprecate RESULT_EXTRA_MASTER_KEY_ID! + long masterKeyId = Long.valueOf(selectedUri.getLastPathSegment()); data.putExtra(RESULT_EXTRA_MASTER_KEY_ID, masterKeyId); - data.putExtra(RESULT_EXTRA_USER_ID, (String) userId); + setResult(RESULT_OK, data); finish(); } - @Override - protected void onNewIntent(Intent intent) { - super.onNewIntent(intent); - handleIntent(intent); - } - - private void handleIntent(Intent intent) { - // TODO: reimplement! - - // String searchString = null; - // if (Intent.ACTION_SEARCH.equals(intent.getAction())) { - // searchString = intent.getStringExtra(SearchManager.QUERY); - // if (searchString != null && searchString.trim().length() == 0) { - // searchString = null; - // } - // } - - // if (searchString == null) { - // mFilterLayout.setVisibility(View.GONE); - // } else { - // mFilterLayout.setVisibility(View.VISIBLE); - // mFilterInfo.setText(getString(R.string.filterInfo, searchString)); - // } - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - // TODO: reimplement! - // menu.add(0, Id.menu.option.search, 0, R.string.menu_search).setIcon( - // android.R.drawable.ic_menu_search); - return true; - } - } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java index 47a3fbad3..2efa7d33a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2013 Dominik Schürmann + * Copyright (C) 2012-2014 Dominik Schürmann * Copyright (C) 2010 Thialfihar * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,6 +28,7 @@ import android.view.View; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; + import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; @@ -55,10 +56,9 @@ public class SelectSecretKeyFragment extends ListFragment implements */ public static SelectSecretKeyFragment newInstance(boolean filterCertify) { SelectSecretKeyFragment frag = new SelectSecretKeyFragment(); - Bundle args = new Bundle(); + Bundle args = new Bundle(); args.putBoolean(ARG_FILTER_CERTIFY, filterCertify); - frag.setArguments(args); return frag; @@ -85,10 +85,10 @@ public class SelectSecretKeyFragment extends ListFragment implements @Override public void onItemClick(AdapterView adapterView, View view, int position, long id) { long masterKeyId = mAdapter.getMasterKeyId(position); - String userId = mAdapter.getUserId(position); + Uri result = KeyRings.buildSecretKeyRingsByMasterKeyIdUri(String.valueOf(masterKeyId)); // return data to activity, which results in finishing it - mActivity.afterListSelection(masterKeyId, userId); + mActivity.afterListSelection(result); } }); @@ -141,7 +141,7 @@ public class SelectSecretKeyFragment extends ListFragment implements + Keys.IS_REVOKED + " = '0' AND valid_keys." + Keys.CAN_SIGN + " = '1' AND valid_keys." + Keys.CREATION + " <= '" + now + "' AND " + "(valid_keys." + Keys.EXPIRY + " IS NULL OR valid_keys." + Keys.EXPIRY - + " >= '" + now + "')) AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID, }; + + " >= '" + now + "')) AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID,}; String orderBy = UserIds.USER_ID + " ASC"; -- cgit v1.2.3 From 2435794279bbf8ee8775f4a2629c91827b0a278e Mon Sep 17 00:00:00 2001 From: gogowitczak Date: Tue, 18 Mar 2014 21:52:44 +0100 Subject: Blocked ok button for generating weak (<1024) RSA key. --- .../ui/dialog/CreateKeyDialogFragment.java | 39 +++++++++++++--------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java index a41bc2bee..ffb45afc5 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java @@ -25,6 +25,7 @@ import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; import android.view.LayoutInflater; import android.view.View; +import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Spinner; import org.sufficientlysecure.keychain.Id; @@ -113,21 +114,8 @@ public class CreateKeyDialogFragment extends DialogFragment { public void onClick(DialogInterface di, int id) { di.dismiss(); try { - int nKeyIndex = keySize.getSelectedItemPosition(); - switch (nKeyIndex) { - case 0: - mNewKeySize = 512; - break; - case 1: - mNewKeySize = 1024; - break; - case 2: - mNewKeySize = 2048; - break; - case 3: - mNewKeySize = 4096; - break; - } + final String selectedItem = (String) keySize.getSelectedItem(); + mNewKeySize = Integer.parseInt(selectedItem); } catch (NumberFormatException e) { mNewKeySize = 0; } @@ -145,7 +133,26 @@ public class CreateKeyDialogFragment extends DialogFragment { } }); - return dialog.create(); + final AlertDialog alertDialog = dialog.create(); + + final AdapterView.OnItemSelectedListener weakRsaListener = new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + final Choice selectedAlgorithm = (Choice)algorithm.getSelectedItem(); + final int selectedKeySize = Integer.parseInt((String)keySize.getSelectedItem()); + final boolean isWeakRsa = (selectedAlgorithm.getId() == Id.choice.algorithm.rsa && selectedKeySize <= 1024); + alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(!isWeakRsa); + } + + @Override + public void onNothingSelected(AdapterView parent) { + } + }; + + keySize.setOnItemSelectedListener(weakRsaListener); + algorithm.setOnItemSelectedListener(weakRsaListener); + + return alertDialog; } } -- cgit v1.2.3 From 19e962481d171efa587e928ce2339ee42de251c7 Mon Sep 17 00:00:00 2001 From: gogowitczak Date: Tue, 18 Mar 2014 23:30:42 +0100 Subject: Note about blocked possibility to generate weak (<1024) RSA key. --- OpenPGP-Keychain/src/main/res/layout/create_key_dialog.xml | 7 +++++++ OpenPGP-Keychain/src/main/res/values/strings.xml | 1 + 2 files changed, 8 insertions(+) diff --git a/OpenPGP-Keychain/src/main/res/layout/create_key_dialog.xml b/OpenPGP-Keychain/src/main/res/layout/create_key_dialog.xml index a2e908433..57a1b865f 100644 --- a/OpenPGP-Keychain/src/main/res/layout/create_key_dialog.xml +++ b/OpenPGP-Keychain/src/main/res/layout/create_key_dialog.xml @@ -17,6 +17,13 @@ android:padding="4dp" android:text="@string/key_creation_el_gamal_info" /> + + Successfully exported %d keys. No keys exported. Note: only subkeys support ElGamal, and for ElGamal the nearest keysize of 1536, 2048, 3072, 4096, or 8192 will be used. + Note: generating RSA key with length 1024-bit and less is considered unsafe and it\'s disabled for generating new keys. Couldn\'t find key %08X. -- cgit v1.2.3 From 69d26496a22dbc341fc9e646c13516626007aa08 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 19 Mar 2014 03:32:09 +0100 Subject: use correct LongSparseArray for minimum api level --- .../org/sufficientlysecure/keychain/service/PassphraseCacheService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java index 176d09c1a..5825db01b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java @@ -26,7 +26,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.os.*; import android.util.Log; -import android.util.LongSparseArray; +import android.support.v4.util.LongSparseArray; import org.spongycastle.openpgp.PGPException; import org.spongycastle.openpgp.PGPPrivateKey; import org.spongycastle.openpgp.PGPSecretKey; -- cgit v1.2.3 From 12b97d251a345cbea644c830fb323b90fa24fdbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 19 Mar 2014 16:22:10 +0100 Subject: Cleanup --- .../org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java index 40771b90d..82a3c2e8e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java @@ -30,9 +30,8 @@ public class SelectSecretKeyActivity extends ActionBarActivity { public static final String EXTRA_FILTER_CERTIFY = "filter_certify"; public static final String RESULT_EXTRA_MASTER_KEY_ID = "master_key_id"; - public static final String RESULT_EXTRA_USER_ID = "user_id"; - private boolean mFilterCertify = false; + private boolean mFilterCertify; private SelectSecretKeyFragment mSelectFragment; @Override -- cgit v1.2.3 From 8059c78e55b4a29c9a8e66a7614c27732447c926 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 19 Mar 2014 16:22:22 +0100 Subject: Remove oxygen text from icon --- .../src/main/res/drawable-hdpi/icon.png | Bin 5101 -> 5093 bytes .../src/main/res/drawable-ldpi/icon.png | Bin 1969 -> 1967 bytes .../src/main/res/drawable-mdpi/icon.png | Bin 2906 -> 2896 bytes .../src/main/res/drawable-xhdpi/icon.png | Bin 7895 -> 7870 bytes .../src/main/res/drawable-xxhdpi/icon.png | Bin 14188 -> 14153 bytes .../src/main/res/drawable-xxxhdpi/icon.png | Bin 20919 -> 20825 bytes Resources/graphics/icon.png | Bin 78773 -> 77995 bytes Resources/graphics/icon.svg | 14 -------------- Resources/graphics/update-icon.sh | 2 +- 9 files changed, 1 insertion(+), 15 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/drawable-hdpi/icon.png b/OpenPGP-Keychain/src/main/res/drawable-hdpi/icon.png index 571634090..f5487599b 100644 Binary files a/OpenPGP-Keychain/src/main/res/drawable-hdpi/icon.png and b/OpenPGP-Keychain/src/main/res/drawable-hdpi/icon.png differ diff --git a/OpenPGP-Keychain/src/main/res/drawable-ldpi/icon.png b/OpenPGP-Keychain/src/main/res/drawable-ldpi/icon.png index 63bdba209..7cd482bff 100644 Binary files a/OpenPGP-Keychain/src/main/res/drawable-ldpi/icon.png and b/OpenPGP-Keychain/src/main/res/drawable-ldpi/icon.png differ diff --git a/OpenPGP-Keychain/src/main/res/drawable-mdpi/icon.png b/OpenPGP-Keychain/src/main/res/drawable-mdpi/icon.png index bab8c56bb..34f1420ac 100644 Binary files a/OpenPGP-Keychain/src/main/res/drawable-mdpi/icon.png and b/OpenPGP-Keychain/src/main/res/drawable-mdpi/icon.png differ diff --git a/OpenPGP-Keychain/src/main/res/drawable-xhdpi/icon.png b/OpenPGP-Keychain/src/main/res/drawable-xhdpi/icon.png index 79b8e27c6..32584f3ff 100644 Binary files a/OpenPGP-Keychain/src/main/res/drawable-xhdpi/icon.png and b/OpenPGP-Keychain/src/main/res/drawable-xhdpi/icon.png differ diff --git a/OpenPGP-Keychain/src/main/res/drawable-xxhdpi/icon.png b/OpenPGP-Keychain/src/main/res/drawable-xxhdpi/icon.png index ac8190c93..b2922309f 100644 Binary files a/OpenPGP-Keychain/src/main/res/drawable-xxhdpi/icon.png and b/OpenPGP-Keychain/src/main/res/drawable-xxhdpi/icon.png differ diff --git a/OpenPGP-Keychain/src/main/res/drawable-xxxhdpi/icon.png b/OpenPGP-Keychain/src/main/res/drawable-xxxhdpi/icon.png index cdc0fc9f0..93ea6b0f5 100644 Binary files a/OpenPGP-Keychain/src/main/res/drawable-xxxhdpi/icon.png and b/OpenPGP-Keychain/src/main/res/drawable-xxxhdpi/icon.png differ diff --git a/Resources/graphics/icon.png b/Resources/graphics/icon.png index de58949eb..a7b133eb9 100644 Binary files a/Resources/graphics/icon.png and b/Resources/graphics/icon.png differ diff --git a/Resources/graphics/icon.svg b/Resources/graphics/icon.svg index 4a584dcf7..2532ed83c 100644 --- a/Resources/graphics/icon.svg +++ b/Resources/graphics/icon.svg @@ -13,7 +13,6 @@ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" inkscape:export-ydpi="90" inkscape:export-xdpi="90" - inkscape:export-filename="/home/ds1/Projekte/APG Plus/Resources/icon_google_play.png" version="1.0" inkscape:output_extension="org.inkscape.output.svg.inkscape" sodipodi:docname="icon.svg" @@ -3474,19 +3473,6 @@ style="fill:url(#linearGradient9381-884-21);fill-opacity:1;fill-rule:nonzero;stroke:none" d="m 24.453487,40.951785 c -0.278503,0.0893 -0.539938,0.227781 -0.81312,0.325928 l 0.1981,0.739317 1.195316,-1.184717 -0.009,-0.03361 c -0.188236,0.05559 -0.385377,0.09346 -0.571291,0.153077 z m 1.814688,-0.486244 -0.539453,0.540744 0.522263,1.949109 1.428138,-1.391176 -0.351176,-1.310607 c -0.353713,0.06954 -0.70601,0.126491 -1.059772,0.21193 z m 1.682677,-0.306801 0.234117,0.873739 1.078904,-1.081489 c -0.444796,0.05158 -0.866983,0.13148 -1.313021,0.20775 z m -4.897371,1.348266 c -0.284754,0.110431 -0.566288,0.210126 -0.846725,0.334933 0.333398,0.03079 0.654403,0.111242 0.981793,0.169147 l -0.135068,-0.50408 z m 7.196364,-1.640116 -0.17462,0.154843 0.432217,1.613055 1.419136,-1.42478 -0.108054,-0.403263 c -0.521384,0.0068 -1.043367,0.01983 -1.568679,0.06014 z m -5.026967,1.671134 -0.772277,0.747203 C 24.813169,42.390423 25.17,42.509101 25.520027,42.647 l -0.297149,-1.108976 z m 4.346501,-0.984552 -1.204319,1.151112 0.441221,1.646661 1.186311,-1.218322 -0.423213,-1.579451 z m 3.649798,-0.76185 -0.597659,0.592358 0.531267,1.982714 1.161709,-1.175713 -0.36018,-1.344213 c -0.249836,-0.01881 -0.48382,-0.04396 -0.735137,-0.05515 z m 1.394059,0.0947 0.207104,0.772923 0.655864,-0.643973 c -0.283232,-0.03902 -0.577362,-0.09978 -0.862968,-0.12895 z m -2.497563,1.029401 -1.419136,1.42478 0.522262,1.949109 1.419136,-1.424781 -0.522262,-1.949108 z m -4.256459,1.320605 -1.020695,1.029874 c 0.434477,0.233862 0.850384,0.49579 1.253693,0.780634 l 0.199219,-0.197453 -0.432217,-1.613055 z m 8.403743,-2.107704 -1.253522,1.236332 0.432217,1.613055 1.419135,-1.42478 -0.369186,-1.377818 c -0.08434,-0.01531 -0.144054,-0.03236 -0.228644,-0.04679 z m 0.914582,0.187155 0.198099,0.739317 0.564051,-0.583354 c -0.249905,-0.06107 -0.509667,-0.102698 -0.76215,-0.155963 z m -6.995853,2.522859 -1.195314,1.184717 0.234117,0.873738 c 0.239867,0.215264 0.463772,0.445851 0.686583,0.680464 l 0.805881,-0.756206 -0.531267,-1.982713 z m 8.48655,-2.201928 -1.112508,1.090493 0.522262,1.949108 1.204319,-1.151112 -0.495249,-1.848292 c -0.04572,-0.01294 -0.07301,-0.02753 -0.118824,-0.0402 z m -4.173651,1.22638 -1.16171,1.175713 0.432217,1.613056 1.16171,-1.175713 -0.432217,-1.613056 z m 5.005426,-0.945001 0.288145,1.075371 0.73867,-0.738198 c -0.331899,-0.121338 -0.688782,-0.230193 -1.026815,-0.337173 z m -2.450129,1.340854 -1.42814,1.391175 0.531267,1.982713 1.419135,-1.42478 -0.522262,-1.949108 z m -4.222852,1.3116 -1.428141,1.391174 0.441222,1.646662 1.410131,-1.458387 -0.423212,-1.579449 z m 8.31193,-2.047085 -1.170714,1.142107 0.441222,1.646661 1.41013,-1.458385 -0.324163,-1.209792 c -0.118639,-0.04937 -0.236932,-0.07308 -0.356475,-0.120591 z m 1.096438,0.46259 0.09905,0.369659 0.22382,-0.240063 c -0.11157,-0.05308 -0.210394,-0.07821 -0.32287,-0.129596 z m -7.119502,2.195809 -1.161709,1.175713 0.522262,1.949108 1.16171,-1.175712 -0.522263,-1.949109 z m -4.222853,1.311601 -0.573056,0.549749 c 0.314089,0.36607 0.584652,0.770104 0.855256,1.175539 l 0.141013,-0.145838 -0.423213,-1.57945 z m 8.569356,-2.296152 -1.195314,1.184717 0.432217,1.613054 1.18631,-1.218321 -0.423213,-1.57945 z m 3.683403,-0.770856 -0.622259,0.634968 0.522262,1.949108 1.18631,-1.218322 -0.252126,-0.940949 C 43.714301,42.702794 43.417501,42.564812 43.145802,42.42645 z m -9.706465,3.429255 -1.419136,1.42478 0.522262,1.949108 1.42814,-1.391174 -0.531266,-1.982714 z m 8.569356,-2.296152 -1.419135,1.42478 0.522262,1.949108 1.428139,-1.391174 -0.531266,-1.982714 z m -4.256459,1.320605 -1.419135,1.424779 0.432217,1.613057 1.419135,-1.424782 -0.432217,-1.613054 z m 7.524058,-1.223668 -0.340231,0.34329 0.432217,1.613057 1.137109,-1.133103 C 46.107003,44.18387 45.693405,43.926727 45.276292,43.656487 z m -5.192581,1.859582 -1.204319,1.151112 0.531267,1.982714 1.195314,-1.184717 -0.522262,-1.949109 z m 4.337499,-1.018157 -1.195315,1.184719 0.441221,1.646659 1.186311,-1.218322 -0.432217,-1.613056 z m -8.593956,2.338763 -1.170714,1.142108 0.441221,1.646659 1.152705,-1.209318 -0.423212,-1.579449 z m 11.140248,-1.976516 -1.41013,1.458385 0.522262,1.949109 1.41013,-1.458386 -0.522262,-1.949108 z m -8.593956,2.338763 -1.419135,1.424779 0.522262,1.949109 1.419135,-1.42478 -0.522262,-1.949108 z m -4.222852,1.3116 -1.419136,1.424779 0.432217,1.613056 1.419135,-1.424781 -0.432216,-1.613054 z m 8.569355,-2.296152 -1.419134,1.424779 0.432217,1.613056 1.419134,-1.424781 -0.432217,-1.613054 z m 5.059454,-0.74337 0.234117,0.873738 0.331227,-0.376895 C 48.159743,45.798299 47.970076,45.634344 47.779503,45.471 z m -11.339943,3.650835 -1.161709,1.175714 0.522262,1.949108 1.170714,-1.142108 -0.531267,-1.982714 z m 8.602962,-2.305156 -1.195315,1.184718 0.522262,1.949108 1.195315,-1.184717 -0.522262,-1.949109 z M 8.7331833,56.617773 c -0.080856,0.257998 -0.185146,0.528328 -0.2567787,0.789166 L 8.8412374,57.021037 8.7331833,56.617773 z m 32.0528797,-8.480489 -1.195313,1.184718 0.432216,1.613055 1.195314,-1.184717 -0.432217,-1.613056 z m 8.005304,-1.712797 -0.597656,0.592359 0.432217,1.613054 1.195314,-1.184717 c -0.32357,-0.356241 -0.684705,-0.686305 -1.029875,-1.020696 z M 9.0303324,57.726749 8.1998504,58.525565 c -0.1251137,0.570603 -0.2112478,1.15432 -0.2915036,1.73494 l 0.2251128,0.840132 1.419135,-1.424779 -0.5222622,-1.949109 z m 25.7416726,-6.89746 -1.42814,1.391175 0.531267,1.982713 1.419135,-1.42478 -0.522262,-1.949108 z m 8.569356,-2.296152 -1.428139,1.391174 0.531266,1.982714 1.419135,-1.42478 -0.522262,-1.949108 z m 4.337498,-1.018157 -1.419134,1.42478 0.441221,1.64666 1.41013,-1.458386 -0.432217,-1.613054 z m -8.593956,2.338762 -1.42814,1.391174 0.441222,1.64666 1.41013,-1.458385 -0.423212,-1.579449 z m -29.1435218,8.853506 0.1170588,0.43687 0.05821,-0.05161 C 10.05758,58.966431 9.9963541,58.836017 9.9413812,58.707248 z m 40.0599508,-10.589959 -1.186309,1.218323 0.522261,1.949107 1.18631,-1.218321 -0.522262,-1.949109 z m -8.593957,2.338762 -1.195314,1.184718 0.522262,1.949107 1.195314,-1.184716 -0.522262,-1.949109 z m 4.337499,-1.018158 -1.18631,1.218323 0.432217,1.613056 1.18631,-1.218323 -0.432217,-1.613056 z m -8.593956,2.338763 -1.16171,1.175712 0.432217,1.613056 1.152705,-1.209318 -0.423212,-1.57945 z m 13.635401,-3.149341 0.261131,0.974553 0.248421,-0.282672 C 51.124502,49.08394 50.966383,48.85514 50.786319,48.627315 z m -40.364165,11.067671 -0.174619,0.154843 0.432217,1.613056 0.505846,-0.531741 c -0.279386,-0.394934 -0.53067,-0.804288 -0.763444,-1.236158 z m 29.275056,-7.556083 -1.419135,1.42478 0.522262,1.949108 1.428139,-1.391174 -0.531266,-1.982714 z m 8.602961,-2.305157 -1.41013,1.458385 0.513257,1.915503 1.419135,-1.424779 -0.522262,-1.949109 z M 9.7326848,60.347964 8.3135497,61.772743 8.7457669,63.385799 10.173906,61.994625 9.7326848,60.347964 z m 25.7416732,-6.897461 -1.419136,1.42478 0.432217,1.613056 1.419135,-1.424781 -0.432216,-1.613055 z m 8.569355,-2.296152 -1.419134,1.424779 0.432217,1.613057 1.428139,-1.391175 -0.441222,-1.646661 z m -10.827504,3.009276 c -0.0046,0.245127 -0.0022,0.483366 -0.02154,0.726133 l 0.165613,-0.188448 -0.144072,-0.537685 z m 18.458971,-4.369778 -0.44764,0.480125 0.432217,1.613056 0.787871,-0.823417 C 52.194092,50.635328 51.955417,50.201646 51.67518,49.793849 z m -13.902951,4.301574 -1.161709,1.175712 0.522262,1.949108 1.161709,-1.175712 -0.522262,-1.949108 z m 8.602962,-2.305156 -1.195316,1.184716 0.522262,1.949108 1.186311,-1.218322 -0.513257,-1.915502 z m 4.337498,-1.018158 -1.195314,1.184718 0.441221,1.646659 1.18631,-1.218322 -0.432217,-1.613055 z m -42.9049849,11.532375 -0.125417,0.06962 c -0.027907,0.674826 0.00787,1.360371 0.042783,2.041566 L 8.2399208,63.917539 7.8077041,62.304484 z m 25.7416719,-6.89746 -0.456644,0.44652 c -0.10047,0.621903 -0.256883,1.220038 -0.450526,1.813566 l 0.144072,0.537685 1.18631,-1.218322 -0.423212,-1.579449 z m 8.569356,-2.296152 -1.204318,1.151112 0.441221,1.646659 1.195314,-1.184717 -0.432217,-1.613054 z m -30.54482,8.328532 -0.705065,0.729192 0.522261,1.949108 1.16171,-1.175712 -0.153077,-0.57129 c -0.284683,-0.293438 -0.570662,-0.608229 -0.825829,-0.931298 z m -1.219916,1.227326 -1.4191343,1.424781 0.5222619,1.949108 1.4191354,-1.42478 -0.522263,-1.949109 z m 25.741673,-6.89746 -1.419135,1.42478 0.522262,1.949108 1.419135,-1.424779 -0.522262,-1.949109 z m 8.569356,-2.296152 -1.41013,1.458386 0.513257,1.915502 1.419135,-1.424779 -0.522262,-1.949109 z m 4.337498,-1.018157 -1.41013,1.458385 0.432217,1.613056 1.419135,-1.42478 -0.441222,-1.646661 z m -8.593956,2.338762 -1.419135,1.424779 0.432217,1.613057 1.419134,-1.424781 -0.432216,-1.613055 z m 12.378174,-3.136631 -0.928885,0.969255 0.513258,1.915502 1.25352,-1.23633 c -0.249728,-0.558508 -0.545759,-1.118305 -0.837893,-1.648427 z m -39.520973,11.526083 0.414208,1.545844 0.714071,-0.695587 c -0.390445,-0.258687 -0.769263,-0.547599 -1.128279,-0.850257 z m -4.8457568,1.40647 -0.646859,0.677579 c 0.064396,0.720367 0.1518557,1.433511 0.2894373,2.155565 l 0.8886882,-0.85043 -0.5312665,-1.982714 z m 25.7416718,-6.89746 -1.195315,1.184718 0.522262,1.949107 1.20432,-1.151112 -0.531267,-1.982713 z m 8.569356,-2.296152 -1.186309,1.218322 0.513257,1.915503 1.204319,-1.151112 -0.531267,-1.982713 z m 8.602962,-2.305157 -1.18631,1.218322 0.513258,1.915504 1.204318,-1.151112 -0.531266,-1.982714 z m -38.601093,10.523222 -1.161709,1.175713 0.432217,1.613055 1.170714,-1.142108 -0.441222,-1.64666 z m 25.741674,-6.89746 -1.16171,1.175713 0.432217,1.613054 1.170714,-1.142107 -0.441221,-1.64666 z m 8.602961,-2.305157 -1.195315,1.184718 0.432217,1.613054 1.195315,-1.184717 -0.432217,-1.613055 z m -14.824125,4.224238 c -0.01593,0.03765 -0.02389,0.08134 -0.0402,0.118826 l 0.05821,-0.05161 -0.01801,-0.06721 z m 0.207104,0.772923 -1.25352,1.236332 c -0.04927,0.07437 -0.105705,0.14876 -0.15661,0.222053 l 0.513258,1.915503 1.419135,-1.424779 -0.522263,-1.949109 z m 8.569356,-2.296152 -1.419135,1.424779 0.522263,1.949109 1.419134,-1.424779 -0.522262,-1.949109 z m 8.602962,-2.305157 -1.419135,1.424779 0.522262,1.949109 1.419135,-1.424779 -0.522262,-1.949109 z m -38.567487,10.514217 -1.428139,1.391175 0.441221,1.64666 1.419135,-1.424779 -0.432217,-1.613056 z m 25.741673,-6.89746 -1.42814,1.391175 0.441221,1.64666 1.419136,-1.42478 -0.432217,-1.613055 z m 8.569356,-2.296152 -1.428139,1.391175 0.441221,1.64666 1.419135,-1.424779 -0.432217,-1.613056 z m 8.477545,-2.235534 -1.302723,1.321552 0.441221,1.64666 1.419135,-1.424779 -0.144072,-0.537686 c -0.122462,-0.344034 -0.2754,-0.671033 -0.413561,-1.005747 z m -38.939559,10.469843 -1.054302,1.038878 0.531266,1.982713 1.419136,-1.424779 -0.342171,-1.277002 c -0.189223,-0.09925 -0.370192,-0.210796 -0.553929,-0.31981 z m 1.302896,0.695413 0.09905,0.369659 0.257425,-0.249068 c -0.116016,-0.04678 -0.242034,-0.0703 -0.356475,-0.120591 z m -2.863044,0.875205 -1.161709,1.175713 0.522262,1.949109 1.161709,-1.175714 -0.522262,-1.949108 z m 25.741673,-6.89746 -1.152705,1.209317 0.513258,1.915504 1.161709,-1.175714 -0.522262,-1.949107 z m 8.602962,-2.305157 -1.186311,1.218322 0.513258,1.915504 1.195315,-1.184718 -0.522262,-1.949108 z m 4.337498,-1.018157 -1.186309,1.218323 0.441221,1.64666 1.186309,-1.218323 -0.441221,-1.64666 z M 9.1313681,67.244465 8.2180792,68.137505 c 0.06532,0.289689 0.1475965,0.550838 0.2251128,0.840133 0.068354,0.255102 0.1303727,0.522294 0.2071039,0.772922 L 9.5635848,68.85752 9.1313681,67.244465 z M 30.571561,61.499583 c -0.356828,0.448638 -0.75809,0.855854 -1.177307,1.251928 l 0.459231,1.713872 1.195315,-1.184719 -0.477239,-1.781081 z m 4.301479,-1.152578 -1.195315,1.184718 0.432217,1.613054 1.195315,-1.184717 -0.432217,-1.613055 z m 8.569356,-2.296152 -1.195314,1.184717 0.432217,1.613055 1.195314,-1.184717 -0.432217,-1.613055 z m -26.222918,7.386591 -0.714069,0.695587 0.432217,1.613054 1.195315,-1.184717 -0.252127,-0.940949 c -0.22098,-0.06106 -0.444699,-0.109715 -0.661336,-0.182975 z m -5.541818,2.169268 -1.419134,1.42478 0.522262,1.949109 1.428139,-1.391175 -0.531267,-1.982714 z m 25.741673,-6.897461 -1.410131,1.458386 0.513258,1.915504 1.42814,-1.391175 -0.531267,-1.982715 z m 17.172317,-4.601308 -1.410129,1.458385 0.513257,1.915504 1.428139,-1.391175 -0.531267,-1.982714 z m -36.015895,9.686448 0.07204,0.268842 0.19922,-0.197453 c -0.09261,-0.0175 -0.179227,-0.05176 -0.271256,-0.07139 z m 27.421939,-7.347686 -1.419135,1.42478 0.513258,1.915503 1.428139,-1.391174 -0.522262,-1.949109 z m -30.007136,8.18446 -1.419135,1.42478 0.432217,1.613056 1.42814,-1.391175 -0.441222,-1.646661 z m 17.172317,-4.601309 -1.419135,1.424781 0.432217,1.613055 1.428139,-1.391175 -0.441221,-1.646661 z m 8.569356,-2.296152 -1.419135,1.424781 0.432217,1.613055 1.428139,-1.391175 -0.441221,-1.646661 z m 8.602961,-2.305156 -1.419135,1.42478 0.441222,1.64666 1.419134,-1.424779 -0.441221,-1.646661 z m -21.455788,5.821097 c -0.362299,0.303527 -0.742129,0.584795 -1.141935,0.846252 l -0.340232,0.343291 0.522262,1.949109 1.42814,-1.391175 -0.468235,-1.747477 z m -9.312852,2.747497 -0.738671,0.738198 0.522263,1.949109 1.428139,-1.391175 -0.333167,-1.243397 c -0.285691,-0.01577 -0.596661,-0.01699 -0.878564,-0.05273 z m 1.528482,0.05868 0.189095,0.705712 0.738671,-0.738199 c -0.313681,0.0242 -0.616551,0.03276 -0.927766,0.03249 z m 4.810386,-1.000795 c -0.140151,0.06034 -0.266567,0.162508 -0.409855,0.217874 l 0.04502,0.168027 0.364833,-0.385901 z m -2.695018,0.830182 0.396199,1.478634 1.42814,-1.391175 -0.144072,-0.537685 c -0.218378,0.07192 -0.43826,0.153449 -0.663103,0.213696 -0.346732,0.09291 -0.670138,0.175199 -1.017164,0.23653 z m -13.4577222,3.678022 -0.8886882,0.85043 c 0.2083439,0.613006 0.4397248,1.210458 0.6968803,1.794265 L 10.274942,71.51234 9.7526798,69.563232 z m 8.5693562,-2.296152 -1.195315,1.184718 0.513257,1.915502 0.06721,-0.01801 1.13711,-1.133103 -0.522262,-1.949108 z m 8.569356,-2.296152 -1.16171,1.175713 0.513257,1.915502 0.06721,-0.01801 1.103503,-1.124099 -0.522261,-1.949108 z m 8.60296,-2.305156 -1.195315,1.184717 0.513257,1.915503 0.06721,-0.01801 1.137109,-1.133103 -0.522262,-1.949108 z m 17.172317,-4.601309 -1.195314,1.184718 0.522262,1.949107 1.195314,-1.184717 -0.522262,-1.949108 z m -8.593957,2.338762 -1.204318,1.151112 0.513257,1.915503 0.06721,-0.01801 1.137109,-1.133103 -0.513258,-1.915503 z m 4.328495,-1.051762 -1.195315,1.184717 0.450226,1.680266 1.18631,-1.218323 -0.441221,-1.64666 z m -34.33563,9.236222 -1.170714,1.142108 0.441222,1.646661 1.161709,-1.175714 -0.432217,-1.613055 z m 8.602961,-2.305156 -1.204319,1.151112 0.441221,1.646661 1.195315,-1.184719 -0.432217,-1.613054 z m 8.569357,-2.296153 -1.20432,1.151113 0.441221,1.646661 1.195316,-1.184719 -0.432217,-1.613055 z m 8.569355,-2.296151 -1.170714,1.142107 0.441222,1.646661 1.161709,-1.175714 -0.432217,-1.613054 z m -23.19538,7.259706 -1.419135,1.424781 0.162081,0.604895 c 0.100985,-0.05316 0.220969,-0.05921 0.336053,-0.09005 l 1.344213,-0.360181 -0.423212,-1.57945 z m 8.602961,-2.305156 -1.419135,1.42478 0.162081,0.604896 1.680267,-0.450226 -0.423213,-1.57945 z m 8.569355,-2.296152 -1.41013,1.458386 0.153077,0.57129 1.680266,-0.450226 -0.423213,-1.57945 z m 17.172318,-4.601309 -1.41013,1.458386 0.153076,0.57129 0.806528,-0.216108 c 0.342878,-0.09187 0.651309,-0.05658 0.954779,0.06833 l -0.504253,-1.881898 z m -8.593957,2.338763 -1.419135,1.42478 0.153077,0.57129 1.680266,-0.450226 -0.414208,-1.545844 z m -29.97353,8.175455 -1.419134,1.424781 0.432217,1.613055 1.419134,-1.424781 -0.432217,-1.613055 z m 8.569356,-2.296152 -1.419134,1.424781 0.117058,0.436868 1.680266,-0.450226 -0.37819,-1.411423 z m 8.569356,-2.296152 -1.419135,1.424781 0.117059,0.436868 1.680266,-0.450226 -0.37819,-1.411423 z m 8.602961,-2.305157 -1.419135,1.424782 0.117058,0.436868 1.680267,-0.450226 -0.37819,-1.411424 z m 8.569356,-2.296152 -1.419134,1.424782 0.117058,0.436867 1.680266,-0.450225 -0.37819,-1.411424 z m 8.544755,-2.253542 -1.360928,1.373167 0.441221,1.646659 1.152705,-1.209317 c -0.04622,-0.610934 -0.134328,-1.197792 -0.232998,-1.810509 z m -40.566917,12.058469 -1.161709,1.175713 0.522262,1.949109 0.68947,-0.652978 -0.153077,-0.57129 c -0.126204,-0.471001 7.12e-4,-0.930958 0.265136,-1.295657 l -0.162082,-0.604897 z m 8.602962,-2.305156 -0.398439,0.394905 0.470475,-0.126063 -0.07204,-0.268842 z m 8.569356,-2.296152 -0.364833,0.385901 0.436869,-0.117059 -0.07204,-0.268842 z m 17.172317,-4.601309 -0.364833,0.385901 0.436869,-0.117058 -0.07204,-0.268843 z m -8.593957,2.338762 -0.340233,0.343292 0.403264,-0.108055 -0.06303,-0.235237 z m -29.97353,8.175456 -0.622258,0.634969 c 0.217477,0.456 0.434455,0.894051 0.680637,1.330382 l 0.382842,-0.318691 -0.441221,-1.64666 z m 8.569356,-2.296152 -0.141013,0.145838 0.168026,-0.04502 -0.02701,-0.100815 z m 8.569356,-2.296152 -0.141013,0.145838 0.168026,-0.04502 -0.02701,-0.100815 z m 8.60296,-2.305157 -0.141013,0.145839 0.168027,-0.04502 -0.02701,-0.100816 z m 8.569356,-2.296152 -0.141012,0.145838 0.168026,-0.04502 -0.02701,-0.100816 z m 8.602961,-2.305156 -1.195313,1.184717 0.207103,0.772922 0.234118,0.873738 1.195314,-1.184717 -0.441222,-1.64666 z m -40.358692,11.89462 -1.428139,1.391175 0.531265,1.982709 1.419136,-1.424775 -0.522262,-1.949109 z m 42.515552,-11.103862 -1.020696,1.029875 0.52226,1.949102 0.456646,-0.446513 c 0.06462,-0.834666 0.07352,-1.686628 0.04179,-2.532464 z M 11.076344,74.503212 10.843519,74.70967 c 0.139763,0.231452 0.319261,0.441865 0.466942,0.66728 l -0.234117,-0.873738 z m 42.913989,-11.498768 -1.186309,1.218321 0.522261,1.949106 1.186309,-1.218322 -0.522261,-1.949105 z m -39.082336,11.012351 -0.680465,0.686583 0.432217,1.613057 0.680466,-0.686582 -0.432218,-1.613058 z m -1.195315,1.184719 -1.419136,1.424777 0.06303,0.235242 c 0.255635,0.328728 0.485738,0.636179 0.758618,0.949302 l 1.038707,-0.962659 -0.441222,-1.646662 z m 41.644872,-10.186223 -0.141013,0.145836 0.09005,0.336055 c 0.0241,-0.16474 0.03055,-0.31645 0.05097,-0.481891 z m -0.655864,0.643973 -1.195314,1.184718 0.441222,1.646662 0.987089,-1.020873 c 0.03721,-0.155386 0.09327,-0.310064 0.127183,-0.466296 l -0.36018,-1.344211 z m -39.172382,10.676294 -0.680466,0.686582 0.522263,1.949113 1.103504,-1.1241 C 16.102003,77.653875 15.80009,77.34613 15.682386,76.906856 l -0.153078,-0.571297 z m -1.195315,1.184719 -0.763272,0.780804 c 0.39765,0.431059 0.798073,0.82161 1.227328,1.219922 l 0.05821,-0.05161 -0.522263,-1.949113 z m 38.864634,-9.405244 c -0.200355,0.259912 -0.449818,0.444695 -0.792696,0.536568 l -0.806528,0.216109 0.414209,1.545848 1.410128,-1.458391 -0.225113,-0.840134 z m -35.943858,9.955294 0.405204,1.512244 1.419134,-1.424788 -0.144072,-0.537682 -1.344213,0.360181 c -0.115084,0.03084 -0.222019,0.08559 -0.336053,0.09005 z m 2.285162,-0.612307 0.05403,0.201637 0.282025,-0.291683 -0.336053,0.09005 z m 2.016319,-0.540272 0.450226,1.680267 1.419135,-1.424777 -0.189096,-0.705715 -1.680265,0.450225 z m 2.285161,-0.612307 0.09905,0.36966 0.539451,-0.540746 -0.638501,0.171086 z m 2.016319,-0.540271 0.405205,1.512244 1.419133,-1.424787 -0.144071,-0.537683 -1.680267,0.450226 z m 2.285162,-0.612307 0.05403,0.201637 0.282025,-0.291682 -0.336054,0.09004 z m 1.982714,-0.531267 0.450226,1.680267 1.419135,-1.424777 -0.189096,-0.705715 -1.680265,0.450225 z m 2.285161,-0.612307 0.09905,0.36966 0.539452,-0.540746 -0.638502,0.171086 z m 2.016319,-0.540271 0.414209,1.545849 1.419132,-1.424787 -0.153075,-0.571287 -1.680266,0.450225 z m 2.285161,-0.612307 0.06303,0.235242 0.340232,-0.343296 -0.403265,0.108054 z m 2.016319,-0.540271 0.450226,1.680267 1.419137,-1.424778 -0.189096,-0.705715 -1.680267,0.450226 z m 2.285162,-0.612307 0.09905,0.36966 0.53945,-0.540746 -0.6385,0.171086 z m 1.982714,-0.531267 0.414209,1.545849 1.419132,-1.424787 -0.153076,-0.571287 -1.680265,0.450225 z m 2.285162,-0.612307 0.06303,0.235242 0.340229,-0.343296 -0.403262,0.108054 z m 2.016319,-0.540271 0.45923,1.713871 1.419136,-1.424777 -0.1981,-0.73932 -1.680266,0.450226 z m 2.285161,-0.612307 0.09905,0.36966 0.539451,-0.540746 -0.638501,0.171086 z m -28.604717,7.772662 -1.195314,1.184719 0.513258,1.915508 1.204319,-1.151114 -0.522263,-1.949113 z m 8.569356,-2.296152 -1.161709,1.175714 0.513259,1.915509 1.170713,-1.14211 -0.522263,-1.949113 z m 8.60296,-2.305156 -1.195314,1.184719 0.513259,1.915508 1.204319,-1.151114 -0.522264,-1.949113 z m 8.569356,-2.296152 -1.186309,1.218323 0.513259,1.915508 1.195314,-1.184718 -0.522264,-1.949113 z m -30.007133,8.184467 -1.161709,1.175714 0.189093,0.705705 c 0.214273,0.178473 0.387276,0.35082 0.607956,0.52145 l 0.805882,-0.756207 -0.441222,-1.646662 z m 8.602961,-2.305157 -1.195314,1.184719 0.432214,1.613048 1.204322,-1.151105 -0.441222,-1.646662 z m 8.569357,-2.296152 -1.195316,1.184719 0.44122,1.646652 1.204322,-1.151104 -0.450226,-1.680267 z m 8.569355,-2.296152 -1.161709,1.175714 0.441219,1.646653 1.170716,-1.1421 -0.450226,-1.680267 z m 8.602961,-2.305156 -1.18631,1.218323 0.432215,1.613048 1.195317,-1.184709 -0.441222,-1.646662 z m 3.517786,-0.582416 -0.447639,0.480128 0.144074,0.537692 c 0.116139,-0.330894 0.202775,-0.681866 0.303565,-1.01782 z m -0.96249,0.978265 -1.419135,1.424777 0.522263,1.949113 0.141014,-0.145837 c 0.382886,-0.719825 0.730277,-1.432221 1.034997,-2.186293 l -0.279139,-1.04176 z m -34.335629,9.236221 -1.428141,1.391173 0.522264,1.949113 1.419136,-1.42478 -0.513259,-1.915506 z m 8.602961,-2.305157 -1.42814,1.391174 0.522263,1.949112 1.419136,-1.424777 -0.513259,-1.915509 z m 8.569355,-2.296151 -1.428139,1.391173 0.522263,1.949112 1.419135,-1.424777 -0.513259,-1.915508 z m 8.569356,-2.296152 -1.419135,1.424777 0.513259,1.915508 1.428139,-1.391172 -0.522263,-1.949113 z m -21.404175,5.8793 -1.428137,1.391183 0.44122,1.646653 1.419135,-1.424778 -0.432218,-1.613058 z m 8.569356,-2.296152 -1.428137,1.391183 0.450226,1.680266 1.419133,-1.424787 -0.441222,-1.646662 z m 8.602962,-2.305156 -1.428138,1.391182 0.450226,1.680267 1.419133,-1.424787 -0.441221,-1.646662 z m 8.578362,-2.262538 -1.428139,1.391173 0.441222,1.646662 1.419132,-1.424787 -0.432215,-1.613048 z m 2.313467,0.568699 -1.18631,1.218323 0.522263,1.949112 1.18631,-1.218323 -0.522263,-1.949112 z m -34.33563,9.236223 -0.456643,0.44652 c 0.235943,0.17204 0.466314,0.33126 0.708769,0.49443 l -0.252126,-0.94095 z m 8.602961,-2.305158 -1.195314,1.184718 0.513258,1.91551 1.195315,-1.18472 -0.513259,-1.915508 z m 8.569357,-2.296153 -1.195316,1.184719 0.513259,1.915508 1.195316,-1.184718 -0.513259,-1.915509 z m 8.569355,-2.296151 -1.152705,1.209318 0.513259,1.915508 1.161709,-1.175714 -0.522263,-1.949112 z m -21.404175,5.8793 -1.195314,1.184722 0.432217,1.61305 1.195315,-1.18471 -0.432218,-1.613062 z m 8.569356,-2.296152 -1.161709,1.175714 0.441222,1.646662 1.161709,-1.175714 -0.441222,-1.646662 z m 8.602961,-2.305156 -1.195315,1.184718 0.441222,1.646662 1.195314,-1.184718 -0.441221,-1.646662 z m 8.578362,-2.262538 -1.195316,1.184709 0.432217,1.613057 1.195314,-1.184718 -0.432215,-1.613048 z m -23.19538,7.259705 -1.419136,1.424773 0.513259,1.91551 1.428137,-1.39118 -0.52226,-1.949103 z m 8.569356,-2.296152 -1.419136,1.424777 0.513259,1.915508 1.428137,-1.391182 -0.52226,-1.949103 z m 8.602961,-2.305157 -1.410132,1.458382 0.513259,1.915509 1.419134,-1.424788 -0.522261,-1.949103 z m 8.569356,-2.296152 -1.419136,1.424778 0.522264,1.949112 1.419132,-1.424787 -0.52226,-1.949103 z M 19.970555,81.48471 18.934262,82.5908 c 0.429888,0.24941 0.856871,0.47298 1.302895,0.69542 l 0.17462,-0.15484 -0.441222,-1.64667 z m 8.602961,-2.305153 -1.419136,1.424777 0.441222,1.646666 1.42814,-1.39118 -0.450226,-1.680263 z m 8.569355,-2.296152 -1.419135,1.424777 0.441221,1.646662 1.42814,-1.391173 -0.450226,-1.680266 z m 8.57836,-2.262548 -1.419135,1.424778 0.432217,1.613057 1.42814,-1.391173 -0.441222,-1.646662 z m -23.410194,7.533383 -1.204319,1.15111 0.117059,0.43687 c 0.444778,0.19669 0.91894,0.39769 1.376697,0.56758 l 0.223819,-0.24007 -0.513256,-1.91549 z m 8.569356,-2.296157 -1.170714,1.142107 0.522261,1.94911 1.161709,-1.17572 -0.513256,-1.915497 z m 8.60296,-2.305156 -1.195315,1.184718 0.513257,1.915499 1.204321,-1.151104 -0.522263,-1.949113 z m 8.569356,-2.296152 -1.204318,1.151114 0.522261,1.949103 1.20432,-1.151104 -0.522263,-1.949113 z m -21.404175,5.879305 -1.204319,1.15111 0.450226,1.68027 1.195315,-1.18472 -0.441222,-1.64666 z m 8.569357,-2.296157 -1.20432,1.151114 0.450226,1.680263 1.195316,-1.184715 -0.441222,-1.646662 z m 8.578359,-2.262547 -1.170713,1.142109 0.441222,1.646662 1.161709,-1.175714 -0.432218,-1.613057 z m 7.74788,-1.463724 -0.349237,0.309681 0.02701,0.100814 c 0.09969,-0.140033 0.225699,-0.268515 0.322224,-0.410495 z m -22.340296,6.418278 -1.419137,1.42478 0.513257,1.9155 1.419136,-1.42478 -0.513256,-1.9155 z m 8.569355,-2.296148 -1.419136,1.424777 0.522261,1.949101 1.419135,-1.42478 -0.52226,-1.949098 z m 8.569355,-2.296152 -1.419135,1.424777 0.522261,1.949103 1.419135,-1.424777 -0.522261,-1.949103 z m -21.404174,5.8793 -1.419136,1.42478 0.117059,0.43687 c 0.394597,0.12628 0.776933,0.26212 1.179247,0.36837 l 0.564052,-0.58336 -0.441222,-1.64666 z m 8.569356,-2.296152 -1.419136,1.424782 0.441222,1.64666 1.419135,-1.42478 -0.441221,-1.646662 z m 8.611965,-2.271552 -1.419136,1.424778 0.432217,1.613056 1.419137,-1.424776 -0.432218,-1.613058 z m 8.569356,-2.296152 -1.419135,1.424778 0.117059,0.436869 c 0.477746,-0.522483 0.928752,-1.10114 1.356102,-1.660019 l -0.05403,-0.201628 z m -23.419199,7.499776 -1.195315,1.18472 0.189093,0.7057 c 0.438297,0.08759 0.884162,0.19249 1.329264,0.25614 l 0.199218,-0.19746 -0.52226,-1.9491 z m 8.569356,-2.29615 -1.186311,1.21832 0.513256,1.9155 1.195316,-1.18472 -0.522261,-1.9491 z m 8.569355,-2.296156 -1.161709,1.175714 0.522261,1.949102 1.161709,-1.17571 -0.522261,-1.949106 z m -12.834819,3.583146 -1.161709,1.17572 0.441222,1.64666 1.170714,-1.14211 -0.450227,-1.68027 z m 8.611965,-2.27155 -1.195314,1.18472 0.432217,1.61306 1.204319,-1.15112 -0.441222,-1.64666 z m 8.569356,-2.296152 -1.195314,1.184719 0.108055,0.403264 c 0.406645,-0.365398 0.834514,-0.728004 1.213322,-1.117509 l -0.126063,-0.470474 z m -23.186376,7.293312 -0.05821,0.05161 c 0.02091,0.0049 0.04628,-0.02281 0.06721,-0.01801 l -0.009,-0.0336 z m 17.172317,-4.601311 -1.428138,1.391181 0.396198,1.47863 c 0.421481,-0.19782 0.832645,-0.40094 1.23857,-0.62002 l 0.315633,-0.30068 -0.522263,-1.949111 z m -8.593957,2.338761 -1.428137,1.39118 0.387193,1.44503 c 0.232467,-0.01947 0.466108,-0.05312 0.69912,-0.07928 l 0.855083,-0.84142 -0.513259,-1.91551 z m -4.240859,1.2444 -1.428141,1.39117 0.04502,0.16802 c 0.598027,0.06253 1.183809,0.07812 1.790735,0.09647 l 0.03361,-0.009 -0.441222,-1.64666 z m 8.578359,-2.26255 -1.42814,1.39117 0.441222,1.64666 1.419135,-1.42477 -0.432217,-1.61306 z m 8.569356,-2.296152 -1.42814,1.391172 0.03602,0.13442 c 0.512616,-0.370138 1.012852,-0.750913 1.491173,-1.155932 l -0.09905,-0.36966 z m -6.246885,2.898452 -1.195315,1.18472 0.153079,0.5713 c 0.462149,-0.17092 0.920198,-0.35074 1.366399,-0.54622 l -0.324163,-1.2098 z m -8.593954,2.33877 -1.029702,0.99627 c 0.424597,-0.0025 0.854389,-0.03061 1.281828,-0.05532 l -0.252126,-0.94095 z m 4.337499,-1.01816 -1.195316,1.18472 0.117059,0.43687 c 0.476116,-0.08601 0.943997,-0.22979 1.420428,-0.34458 l -0.342171,-1.27701 z m 2.54629,0.36225 -0.456643,0.44652 c 0.172308,-0.05482 0.367383,-0.08585 0.537685,-0.14407 l -0.08104,-0.30245 z" id="path3410" /> - OXYGEN Date: Wed, 19 Mar 2014 18:28:34 +0200 Subject: add apg's fix for Key id display --- .../main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java | 6 +++++- .../java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java | 2 +- .../keychain/ui/SelectSecretKeyLayoutFragment.java | 2 +- .../keychain/ui/adapter/SelectKeyCursorAdapter.java | 2 +- .../sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index b93c68677..5b00d163a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -477,7 +477,11 @@ public class PgpKeyHelper { * @return */ public static String convertKeyIdToHex(long keyId) { - return "0x" + ((keyId >> 32) > 0 ? convertKeyIdToHex32bit(keyId >> 32) : "") + convertKeyIdToHex32bit(keyId); + return "0x" + convertKeyIdToHex32bit(keyId >> 32) + convertKeyIdToHex32bit(keyId); + } + + public static String convertKeyIdToHexShort(long keyId) { + return "0x" + convertKeyIdToHex32bit(keyId); } private static String convertKeyIdToHex32bit(long keyId) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java index d8df5ced3..bd14369b0 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java @@ -199,7 +199,7 @@ public class CertifyKeyActivity extends ActionBarActivity implements // the first key here is our master key if (data.moveToFirst()) { long keyId = data.getLong(INDEX_MASTER_KEY_ID); - String keyIdStr = PgpKeyHelper.convertKeyIdToHex(keyId); + String keyIdStr = PgpKeyHelper.convertKeyIdToHexShort(keyId); ((TextView) findViewById(R.id.key_id)).setText(keyIdStr); String mainUserId = data.getString(INDEX_USER_ID); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java index 6b57fc568..960b4aafb 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java @@ -71,7 +71,7 @@ public class SelectSecretKeyLayoutFragment extends Fragment { getActivity(), secretKeyId); if (keyRing != null) { PGPSecretKey key = PgpKeyHelper.getMasterKey(keyRing); - String masterkeyIdHex = PgpKeyHelper.convertKeyIdToHex(secretKeyId); + String masterkeyIdHex = PgpKeyHelper.convertKeyIdToHexShort(secretKeyId); if (key != null) { String userId = PgpKeyHelper.getMainUserIdSafe(getActivity(), key); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java index beb76fc10..fbbb9caa4 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/SelectKeyCursorAdapter.java @@ -115,7 +115,7 @@ public class SelectKeyCursorAdapter extends HighlightQueryCursorAdapter { // TODO: needed to key id to no? keyId.setText(R.string.no_key); long masterKeyId = cursor.getLong(mIndexMasterKeyId); - keyId.setText(PgpKeyHelper.convertKeyIdToHex(masterKeyId)); + keyId.setText(PgpKeyHelper.convertKeyIdToHexShort(masterKeyId)); // TODO: needed to set unknown_status? status.setText(R.string.unknown_status); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java index 5f911275d..0064e9f13 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java @@ -86,7 +86,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter { ImageView signIcon = (ImageView) view.findViewById(R.id.ic_signKey); ImageView revokedKeyIcon = (ImageView) view.findViewById(R.id.ic_revokedKey); - String keyIdStr = PgpKeyHelper.convertKeyIdToHex(cursor.getLong(mIndexKeyId)); + String keyIdStr = PgpKeyHelper.convertKeyIdToHexShort(cursor.getLong(mIndexKeyId)); String algorithmStr = PgpKeyHelper.getAlgorithmInfo(cursor.getInt(mIndexAlgorithm), cursor.getInt(mIndexKeySize)); -- cgit v1.2.3 From 62fb1fb57931626e73e9928cc44f6eb60f3c101e Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Thu, 20 Mar 2014 00:29:40 +0100 Subject: Fix key list views in main key view Since the views are being reused, a revoked key might set the text color of a view and when the view is being reused for a non-revoked key it is still red. So grab the default text colour and set it explicitly when the key is not revoked. --- .../keychain/ui/adapter/ViewKeyKeysAdapter.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java index 0064e9f13..068d6e6e9 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java @@ -18,6 +18,7 @@ package org.sufficientlysecure.keychain.ui.adapter; import android.content.Context; +import android.content.res.ColorStateList; import android.database.Cursor; import android.graphics.Color; import android.support.v4.widget.CursorAdapter; @@ -42,6 +43,8 @@ public class ViewKeyKeysAdapter extends CursorAdapter { private int mIndexCanSign; private int mIndexRevokedKey; + private ColorStateList mDefaultTextColor; + public ViewKeyKeysAdapter(Context context, Cursor c, int flags) { super(context, c, flags); @@ -122,13 +125,20 @@ public class ViewKeyKeysAdapter extends CursorAdapter { keyId.setTextColor(Color.RED); keyDetails.setTextColor(Color.RED); } else { + keyId.setTextColor(mDefaultTextColor); + keyDetails.setTextColor(mDefaultTextColor); revokedKeyIcon.setVisibility(View.GONE); } } @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { - return mInflater.inflate(R.layout.view_key_keys_item, null); + View view = mInflater.inflate(R.layout.view_key_keys_item, null); + if (mDefaultTextColor == null) { + TextView keyId = (TextView) view.findViewById(R.id.keyId); + mDefaultTextColor = keyId.getTextColors(); + } + return view; } } -- cgit v1.2.3 From 16ae9c899949b5443c06226993ca2efc23591e72 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Thu, 20 Mar 2014 14:09:35 +0100 Subject: Let convertKeyIdToHex handle short key IDs If a short key ID is given, then it should only be displayed as such. --- .../main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index 5b00d163a..d201a1426 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -477,6 +477,11 @@ public class PgpKeyHelper { * @return */ public static String convertKeyIdToHex(long keyId) { + long upper = keyId >> 32; + if (upper == 0) { + // this is a short key id + return convertKeyIdToHexShort(keyId); + } return "0x" + convertKeyIdToHex32bit(keyId >> 32) + convertKeyIdToHex32bit(keyId); } -- cgit v1.2.3 From 3fa3fc444bf8a0f21d5bd2949d2141e555077f50 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Thu, 20 Mar 2014 14:14:02 +0100 Subject: Add debug logging for hkp keyserver actions --- .../sufficientlysecure/keychain/util/HkpKeyServer.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java index 9d6850027..43b40a4db 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java @@ -30,9 +30,11 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; +import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.pgp.PgpHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; +import org.sufficientlysecure.keychain.util.Log; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -179,6 +181,7 @@ public class HkpKeyServer extends KeyServer { for (int i = 0; i < ips.length; ++i) { try { String url = "http://" + ips[i].getHostAddress() + ":" + mPort + request; + Log.d(Constants.TAG, "hkp keyserver query: " + url); URL realUrl = new URL(url); HttpURLConnection conn = (HttpURLConnection) realUrl.openConnection(); conn.setConnectTimeout(5000); @@ -277,9 +280,10 @@ public class HkpKeyServer extends KeyServer { public String get(long keyId) throws QueryException { HttpClient client = new DefaultHttpClient(); try { - HttpGet get = new HttpGet("http://" + mHost + ":" + mPort - + "/pks/lookup?op=get&options=mr&search=" + PgpKeyHelper.convertKeyIdToHex(keyId)); - + String query = "http://" + mHost + ":" + mPort + + "/pks/lookup?op=get&options=mr&search=" + PgpKeyHelper.convertKeyIdToHex(keyId); + Log.d(Constants.TAG, "hkp keyserver get: " + query); + HttpGet get = new HttpGet(query); HttpResponse response = client.execute(get); if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { throw new QueryException("not found"); @@ -305,8 +309,9 @@ public class HkpKeyServer extends KeyServer { public void add(String armoredText) throws AddKeyException { HttpClient client = new DefaultHttpClient(); try { - HttpPost post = new HttpPost("http://" + mHost + ":" + mPort + "/pks/add"); - + String query = "http://" + mHost + ":" + mPort + "/pks/add"; + HttpPost post = new HttpPost(query); + Log.d(Constants.TAG, "hkp keyserver add: " + query); List nameValuePairs = new ArrayList(2); nameValuePairs.add(new BasicNameValuePair("keytext", armoredText)); post.setEntity(new UrlEncodedFormEntity(nameValuePairs)); -- cgit v1.2.3 From 2b774899322ae31f1d22999caae68c3f80985c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 20 Mar 2014 15:54:49 +0100 Subject: Dont try to parse key/fingerprint result from keyserver query --- .../keychain/pgp/PgpKeyHelper.java | 19 ++--- .../keychain/service/KeychainIntentService.java | 2 +- .../keychain/ui/adapter/ImportKeysAdapter.java | 6 +- .../keychain/ui/adapter/ImportKeysListEntry.java | 43 +++++----- .../keychain/util/HkpKeyServer.java | 98 ++++++++++++---------- .../keychain/util/KeyServer.java | 4 +- .../src/main/res/layout/import_keys_list_entry.xml | 7 +- 7 files changed, 91 insertions(+), 88 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index d201a1426..09c0b2d8f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -460,12 +460,16 @@ public class PgpKeyHelper { public static String convertFingerprintToHex(byte[] fingerprint, boolean split) { String hexString = Hex.toHexString(fingerprint); if (split) { - hexString = hexString.replaceAll("(.{4})(?!$)", "$1 "); + hexString = splitFingerprintHex(hexString); } return hexString; } + public static String splitFingerprintHex(String hexString) { + return hexString.replaceAll("(.{4})(?!$)", "$1 "); + } + /** * Convert key id from long to 64 bit hex string *

@@ -497,19 +501,6 @@ public class PgpKeyHelper { return hexString; } - /** - * Used in HkpKeyServer to convert hex encoded key ids back to long. - * - * @param hexString - * @return - */ - public static long convertHexToKeyId(String hexString) { - int len = hexString.length(); - String s2 = hexString.substring(len - 8); - String s1 = hexString.substring(0, len - 8); - return ((!s1.isEmpty() ? Long.parseLong(s1, 16) << 32 : 0) | Long.parseLong(s2, 16)); - } - /** * Splits userId string into naming part, email part, and comment part * diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 6ec6dcf8a..5af81d39d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -749,7 +749,7 @@ public class KeychainIntentService extends IntentService HkpKeyServer server = new HkpKeyServer(keyServer); for (ImportKeysListEntry entry : entries) { - byte[] downloadedKey = server.get(entry.getKeyId()).getBytes(); + byte[] downloadedKey = server.get(entry.getKeyIdHex()).getBytes(); /** * TODO: copied from ImportKeysListLoader diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java index 0f05af447..37a8dd416 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java @@ -134,10 +134,10 @@ public class ImportKeysAdapter extends ArrayAdapter { holder.mMainUserIdRest.setVisibility(View.GONE); } - holder.mKeyId.setText(entry.hexKeyId); + holder.mKeyId.setText(entry.keyIdHex); - if (entry.fingerPrint != null) { - holder.mFingerprint.setText(mActivity.getString(R.string.fingerprint) + " " + entry.fingerPrint); + if (entry.fingerPrintHex != null) { + holder.mFingerprint.setText(mActivity.getString(R.string.fingerprint) + " " + entry.fingerPrintHex); holder.mFingerprint.setVisibility(View.VISIBLE); } else { holder.mFingerprint.setVisibility(View.GONE); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java index 05521b0c9..d7c38213d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java @@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.ui.adapter; import android.os.Parcel; import android.os.Parcelable; import android.util.SparseArray; + import org.spongycastle.openpgp.PGPKeyRing; import org.spongycastle.openpgp.PGPPublicKey; import org.spongycastle.openpgp.PGPSecretKeyRing; @@ -38,10 +39,11 @@ public class ImportKeysListEntry implements Serializable, Parcelable { public ArrayList userIds; public long keyId; + public String keyIdHex; + public boolean revoked; public Date date; // TODO: not displayed - public String fingerPrint; - public String hexKeyId; + public String fingerPrintHex; public int bitStrength; public String algorithm; public boolean secretKey; @@ -55,8 +57,8 @@ public class ImportKeysListEntry implements Serializable, Parcelable { this.keyId = b.keyId; this.revoked = b.revoked; this.date = b.date; - this.fingerPrint = b.fingerPrint; - this.hexKeyId = b.hexKeyId; + this.fingerPrintHex = b.fingerPrintHex; + this.keyIdHex = b.keyIdHex; this.bitStrength = b.bitStrength; this.algorithm = b.algorithm; this.secretKey = b.secretKey; @@ -74,8 +76,8 @@ public class ImportKeysListEntry implements Serializable, Parcelable { dest.writeLong(keyId); dest.writeByte((byte) (revoked ? 1 : 0)); dest.writeSerializable(date); - dest.writeString(fingerPrint); - dest.writeString(hexKeyId); + dest.writeString(fingerPrintHex); + dest.writeString(keyIdHex); dest.writeInt(bitStrength); dest.writeString(algorithm); dest.writeByte((byte) (secretKey ? 1 : 0)); @@ -92,8 +94,8 @@ public class ImportKeysListEntry implements Serializable, Parcelable { vr.keyId = source.readLong(); vr.revoked = source.readByte() == 1; vr.date = (Date) source.readSerializable(); - vr.fingerPrint = source.readString(); - vr.hexKeyId = source.readString(); + vr.fingerPrintHex = source.readString(); + vr.keyIdHex = source.readString(); vr.bitStrength = source.readInt(); vr.algorithm = source.readString(); vr.secretKey = source.readByte() == 1; @@ -109,8 +111,8 @@ public class ImportKeysListEntry implements Serializable, Parcelable { } }; - public long getKeyId() { - return keyId; + public String getKeyIdHex() { + return keyIdHex; } public byte[] getBytes() { @@ -121,6 +123,14 @@ public class ImportKeysListEntry implements Serializable, Parcelable { this.mBytes = bytes; } + public boolean isSelected() { + return mSelected; + } + + public void setSelected(boolean selected) { + this.mSelected = selected; + } + /** * Constructor for later querying from keyserver */ @@ -132,14 +142,6 @@ public class ImportKeysListEntry implements Serializable, Parcelable { userIds = new ArrayList(); } - public boolean isSelected() { - return mSelected; - } - - public void setSelected(boolean selected) { - this.mSelected = selected; - } - /** * Constructor based on key object, used for import from NFC, QR Codes, files */ @@ -165,12 +167,13 @@ public class ImportKeysListEntry implements Serializable, Parcelable { for (String userId : new IterableIterator(pgpKeyRing.getPublicKey().getUserIDs())) { userIds.add(userId); } + this.keyId = pgpKeyRing.getPublicKey().getKeyID(); + this.keyIdHex = PgpKeyHelper.convertKeyIdToHex(keyId); this.revoked = pgpKeyRing.getPublicKey().isRevoked(); - this.fingerPrint = PgpKeyHelper.convertFingerprintToHex(pgpKeyRing.getPublicKey() + this.fingerPrintHex = PgpKeyHelper.convertFingerprintToHex(pgpKeyRing.getPublicKey() .getFingerprint(), true); - this.hexKeyId = PgpKeyHelper.convertKeyIdToHex(keyId); this.bitStrength = pgpKeyRing.getPublicKey().getBitStrength(); final int algorithm = pgpKeyRing.getPublicKey().getAlgorithm(); this.algorithm = getAlgorithmFromId(algorithm); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java index 43b40a4db..3658ef6c6 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java @@ -18,7 +18,6 @@ package org.sufficientlysecure.keychain.util; -import android.text.Html; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.HttpStatus; @@ -34,7 +33,6 @@ import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.pgp.PgpHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; -import org.sufficientlysecure.keychain.util.Log; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -74,26 +72,26 @@ public class HkpKeyServer extends KeyServer { /** * pub:%keyid%:%algo%:%keylen%:%creationdate%:%expirationdate%:%flags% *

    - *
  • %keyid% = this is either the fingerprint or the key ID of the key. Either the 16-digit or 8-digit - * key IDs are acceptable, but obviously the fingerprint is best.
  • - *
  • %algo% = the algorithm number, (i.e. 1==RSA, 17==DSA, etc). - * See RFC-2440
  • - *
  • %keylen% = the key length (i.e. 1024, 2048, 4096, etc.)
  • - *
  • %creationdate% = creation date of the key in standard - * RFC-2440 form (i.e. number of seconds since - * 1/1/1970 UTC time)
  • - *
  • %expirationdate% = expiration date of the key in standard - * RFC-2440 form (i.e. number of seconds since - * 1/1/1970 UTC time)
  • - *
  • %flags% = letter codes to indicate details of the key, if any. Flags may be in any order. The - * meaning of "disabled" is implementation-specific. Note that individual flags may be unimplemented, so - * the absence of a given flag does not necessarily mean the absence of the detail. - *
      - *
    • r == revoked
    • - *
    • d == disabled
    • - *
    • e == expired
    • - *
    - *
  • + *
  • %keyid% = this is either the fingerprint or the key ID of the key. Either the 16-digit or 8-digit + * key IDs are acceptable, but obviously the fingerprint is best.
  • + *
  • %algo% = the algorithm number, (i.e. 1==RSA, 17==DSA, etc). + * See RFC-2440
  • + *
  • %keylen% = the key length (i.e. 1024, 2048, 4096, etc.)
  • + *
  • %creationdate% = creation date of the key in standard + * RFC-2440 form (i.e. number of seconds since + * 1/1/1970 UTC time)
  • + *
  • %expirationdate% = expiration date of the key in standard + * RFC-2440 form (i.e. number of seconds since + * 1/1/1970 UTC time)
  • + *
  • %flags% = letter codes to indicate details of the key, if any. Flags may be in any order. The + * meaning of "disabled" is implementation-specific. Note that individual flags may be unimplemented, so + * the absence of a given flag does not necessarily mean the absence of the detail. + *
      + *
    • r == revoked
    • + *
    • d == disabled
    • + *
    • e == expired
    • + *
    + *
  • *
* * @see 5.2. Machine Readable Indexes @@ -107,23 +105,23 @@ public class HkpKeyServer extends KeyServer { /** * uid:%escaped uid string%:%creationdate%:%expirationdate%:%flags% *
    - *
  • %escaped uid string% = the user ID string, with HTTP %-escaping for anything that isn't 7-bit - * safe as well as for the ":" character. Any other characters may be escaped, as desired.
  • - *
  • %creationdate% = creation date of the key in standard - * RFC-2440 form (i.e. number of seconds since - * 1/1/1970 UTC time)
  • - *
  • %expirationdate% = expiration date of the key in standard - * RFC-2440 form (i.e. number of seconds since - * 1/1/1970 UTC time)
  • - *
  • %flags% = letter codes to indicate details of the key, if any. Flags may be in any order. The - * meaning of "disabled" is implementation-specific. Note that individual flags may be unimplemented, so - * the absence of a given flag does not necessarily mean the absence of the detail. - *
      - *
    • r == revoked
    • - *
    • d == disabled
    • - *
    • e == expired
    • - *
    - *
  • + *
  • %escaped uid string% = the user ID string, with HTTP %-escaping for anything that isn't 7-bit + * safe as well as for the ":" character. Any other characters may be escaped, as desired.
  • + *
  • %creationdate% = creation date of the key in standard + * RFC-2440 form (i.e. number of seconds since + * 1/1/1970 UTC time)
  • + *
  • %expirationdate% = expiration date of the key in standard + * RFC-2440 form (i.e. number of seconds since + * 1/1/1970 UTC time)
  • + *
  • %flags% = letter codes to indicate details of the key, if any. Flags may be in any order. The + * meaning of "disabled" is implementation-specific. Note that individual flags may be unimplemented, so + * the absence of a given flag does not necessarily mean the absence of the detail. + *
      + *
    • r == revoked
    • + *
    • d == disabled
    • + *
    • e == expired
    • + *
    + *
  • *
*/ public static final Pattern UID_LINE = Pattern @@ -246,8 +244,18 @@ public class HkpKeyServer extends KeyServer { final int algorithmId = Integer.decode(matcher.group(2)); info.algorithm = getAlgorithmFromId(algorithmId); - info.hexKeyId = "0x" + matcher.group(1); - info.keyId = PgpKeyHelper.convertHexToKeyId(matcher.group(1)); + // group 1 contains the full fingerprint (v4) or the long key id if available + // see https://bitbucket.org/skskeyserver/sks-keyserver/pull-request/12/fixes-for-machine-readable-indexes/diff + // and https://github.com/openpgp-keychain/openpgp-keychain/issues/259#issuecomment-38168176 + String fingerprintOrKeyId = matcher.group(1); + if (fingerprintOrKeyId.length() > 16) { + info.fingerPrintHex = "0x" + PgpKeyHelper.splitFingerprintHex(fingerprintOrKeyId); + info.keyIdHex = "0x" + fingerprintOrKeyId.substring(fingerprintOrKeyId.length() + - 16, fingerprintOrKeyId.length()); + } else { + // set key id only + info.keyIdHex = "0x" + fingerprintOrKeyId; + } final long creationDate = Long.parseLong(matcher.group(4)); final GregorianCalendar tmpGreg = new GregorianCalendar(TimeZone.getTimeZone("UTC")); @@ -277,11 +285,11 @@ public class HkpKeyServer extends KeyServer { } @Override - public String get(long keyId) throws QueryException { + public String get(String keyIdHex) throws QueryException { HttpClient client = new DefaultHttpClient(); try { String query = "http://" + mHost + ":" + mPort + - "/pks/lookup?op=get&options=mr&search=" + PgpKeyHelper.convertKeyIdToHex(keyId); + "/pks/lookup?op=get&options=mr&search=" + keyIdHex; Log.d(Constants.TAG, "hkp keyserver get: " + query); HttpGet get = new HttpGet(query); HttpResponse response = client.execute(get); @@ -306,14 +314,14 @@ public class HkpKeyServer extends KeyServer { } @Override - public void add(String armoredText) throws AddKeyException { + public void add(String armoredKey) throws AddKeyException { HttpClient client = new DefaultHttpClient(); try { String query = "http://" + mHost + ":" + mPort + "/pks/add"; HttpPost post = new HttpPost(query); Log.d(Constants.TAG, "hkp keyserver add: " + query); List nameValuePairs = new ArrayList(2); - nameValuePairs.add(new BasicNameValuePair("keytext", armoredText)); + nameValuePairs.add(new BasicNameValuePair("keytext", armoredKey)); post.setEntity(new UrlEncodedFormEntity(nameValuePairs)); HttpResponse response = client.execute(post); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/KeyServer.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/KeyServer.java index a31fdc5ae..7f70867a5 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/KeyServer.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/KeyServer.java @@ -46,7 +46,7 @@ public abstract class KeyServer { abstract List search(String query) throws QueryException, TooManyResponses, InsufficientQuery; - abstract String get(long keyId) throws QueryException; + abstract String get(String keyIdHex) throws QueryException; - abstract void add(String armoredText) throws AddKeyException; + abstract void add(String armoredKey) throws AddKeyException; } diff --git a/OpenPGP-Keychain/src/main/res/layout/import_keys_list_entry.xml b/OpenPGP-Keychain/src/main/res/layout/import_keys_list_entry.xml index 3cc0bc6dc..fb092793b 100644 --- a/OpenPGP-Keychain/src/main/res/layout/import_keys_list_entry.xml +++ b/OpenPGP-Keychain/src/main/res/layout/import_keys_list_entry.xml @@ -77,10 +77,11 @@ + android:typeface="monospace" + android:layout_weight="1" /> Date: Thu, 20 Mar 2014 16:04:05 +0100 Subject: Use getter and setter --- .../keychain/ui/adapter/ImportKeysAdapter.java | 51 ++++++++-------- .../keychain/ui/adapter/ImportKeysListEntry.java | 71 +++++++++++++++++++++- .../keychain/util/HkpKeyServer.java | 29 +++++---- 3 files changed, 111 insertions(+), 40 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java index 37a8dd416..d174bd0c8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java @@ -43,13 +43,12 @@ public class ImportKeysAdapter extends ArrayAdapter { protected List mData; static class ViewHolder { - private TextView mMainUserId; - private TextView mMainUserIdRest; - private TextView mKeyId; - private TextView mFingerprint; - private TextView mAlgorithm; - private TextView mStatus; - + private TextView mainUserId; + private TextView mainUserIdRest; + private TextView keyId; + private TextView fingerprint; + private TextView algorithm; + private TextView status; } public ImportKeysAdapter(Activity activity) { @@ -100,12 +99,12 @@ public class ImportKeysAdapter extends ArrayAdapter { if (convertView == null) { holder = new ViewHolder(); convertView = mInflater.inflate(R.layout.import_keys_list_entry, null); - holder.mMainUserId = (TextView) convertView.findViewById(R.id.mainUserId); - holder.mMainUserIdRest = (TextView) convertView.findViewById(R.id.mainUserIdRest); - holder.mKeyId = (TextView) convertView.findViewById(R.id.keyId); - holder.mFingerprint = (TextView) convertView.findViewById(R.id.fingerprint); - holder.mAlgorithm = (TextView) convertView.findViewById(R.id.algorithm); - holder.mStatus = (TextView) convertView.findViewById(R.id.status); + holder.mainUserId = (TextView) convertView.findViewById(R.id.mainUserId); + holder.mainUserIdRest = (TextView) convertView.findViewById(R.id.mainUserIdRest); + holder.keyId = (TextView) convertView.findViewById(R.id.keyId); + holder.fingerprint = (TextView) convertView.findViewById(R.id.fingerprint); + holder.algorithm = (TextView) convertView.findViewById(R.id.algorithm); + holder.status = (TextView) convertView.findViewById(R.id.status); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); @@ -119,36 +118,36 @@ public class ImportKeysAdapter extends ArrayAdapter { // show red user id if it is a secret key if (entry.secretKey) { userIdSplit[0] = mActivity.getString(R.string.secret_key) + " " + userIdSplit[0]; - holder.mMainUserId.setTextColor(Color.RED); + holder.mainUserId.setTextColor(Color.RED); } - holder.mMainUserId.setText(userIdSplit[0]); + holder.mainUserId.setText(userIdSplit[0]); } else { - holder.mMainUserId.setText(R.string.user_id_no_name); + holder.mainUserId.setText(R.string.user_id_no_name); } // email if (userIdSplit[1] != null) { - holder.mMainUserIdRest.setText(userIdSplit[1]); - holder.mMainUserIdRest.setVisibility(View.VISIBLE); + holder.mainUserIdRest.setText(userIdSplit[1]); + holder.mainUserIdRest.setVisibility(View.VISIBLE); } else { - holder.mMainUserIdRest.setVisibility(View.GONE); + holder.mainUserIdRest.setVisibility(View.GONE); } - holder.mKeyId.setText(entry.keyIdHex); + holder.keyId.setText(entry.keyIdHex); if (entry.fingerPrintHex != null) { - holder.mFingerprint.setText(mActivity.getString(R.string.fingerprint) + " " + entry.fingerPrintHex); - holder.mFingerprint.setVisibility(View.VISIBLE); + holder.fingerprint.setText(mActivity.getString(R.string.fingerprint) + " " + entry.fingerPrintHex); + holder.fingerprint.setVisibility(View.VISIBLE); } else { - holder.mFingerprint.setVisibility(View.GONE); + holder.fingerprint.setVisibility(View.GONE); } - holder.mAlgorithm.setText("" + entry.bitStrength + "/" + entry.algorithm); + holder.algorithm.setText("" + entry.bitStrength + "/" + entry.algorithm); if (entry.revoked) { - holder.mStatus.setText(R.string.revoked); + holder.status.setText(R.string.revoked); } else { - holder.mStatus.setVisibility(View.GONE); + holder.status.setVisibility(View.GONE); } LinearLayout ll = (LinearLayout) convertView.findViewById(R.id.list); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java index d7c38213d..2610dfb3e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java @@ -36,11 +36,10 @@ import java.util.Date; public class ImportKeysListEntry implements Serializable, Parcelable { private static final long serialVersionUID = -7797972103284992662L; - public ArrayList userIds; + public ArrayList userIds; public long keyId; public String keyIdHex; - public boolean revoked; public Date date; // TODO: not displayed public String fingerPrintHex; @@ -131,6 +130,74 @@ public class ImportKeysListEntry implements Serializable, Parcelable { this.mSelected = selected; } + public long getKeyId() { + return keyId; + } + + public void setKeyId(long keyId) { + this.keyId = keyId; + } + + public void setKeyIdHex(String keyIdHex) { + this.keyIdHex = keyIdHex; + } + + public boolean isRevoked() { + return revoked; + } + + public void setRevoked(boolean revoked) { + this.revoked = revoked; + } + + public Date getDate() { + return date; + } + + public void setDate(Date date) { + this.date = date; + } + + public String getFingerPrintHex() { + return fingerPrintHex; + } + + public void setFingerPrintHex(String fingerPrintHex) { + this.fingerPrintHex = fingerPrintHex; + } + + public int getBitStrength() { + return bitStrength; + } + + public void setBitStrength(int bitStrength) { + this.bitStrength = bitStrength; + } + + public String getAlgorithm() { + return algorithm; + } + + public void setAlgorithm(String algorithm) { + this.algorithm = algorithm; + } + + public boolean isSecretKey() { + return secretKey; + } + + public void setSecretKey(boolean secretKey) { + this.secretKey = secretKey; + } + + public ArrayList getUserIds() { + return userIds; + } + + public void setUserIds(ArrayList userIds) { + this.userIds = userIds; + } + /** * Constructor for later querying from keyserver */ diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java index 3658ef6c6..a25e3d748 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java @@ -239,32 +239,35 @@ public class HkpKeyServer extends KeyServer { final Matcher matcher = PUB_KEY_LINE.matcher(data); while (matcher.find()) { - final ImportKeysListEntry info = new ImportKeysListEntry(); - info.bitStrength = Integer.parseInt(matcher.group(3)); + final ImportKeysListEntry entry = new ImportKeysListEntry(); + + entry.setBitStrength(Integer.parseInt(matcher.group(3))); + final int algorithmId = Integer.decode(matcher.group(2)); - info.algorithm = getAlgorithmFromId(algorithmId); + entry.setAlgorithm(getAlgorithmFromId(algorithmId)); // group 1 contains the full fingerprint (v4) or the long key id if available // see https://bitbucket.org/skskeyserver/sks-keyserver/pull-request/12/fixes-for-machine-readable-indexes/diff // and https://github.com/openpgp-keychain/openpgp-keychain/issues/259#issuecomment-38168176 String fingerprintOrKeyId = matcher.group(1); if (fingerprintOrKeyId.length() > 16) { - info.fingerPrintHex = "0x" + PgpKeyHelper.splitFingerprintHex(fingerprintOrKeyId); - info.keyIdHex = "0x" + fingerprintOrKeyId.substring(fingerprintOrKeyId.length() - - 16, fingerprintOrKeyId.length()); + entry.setFingerPrintHex(PgpKeyHelper.splitFingerprintHex( + fingerprintOrKeyId.toLowerCase(Locale.US))); + entry.setKeyIdHex("0x" + fingerprintOrKeyId.substring(fingerprintOrKeyId.length() + - 16, fingerprintOrKeyId.length())); } else { // set key id only - info.keyIdHex = "0x" + fingerprintOrKeyId; + entry.setKeyIdHex("0x" + fingerprintOrKeyId); } final long creationDate = Long.parseLong(matcher.group(4)); final GregorianCalendar tmpGreg = new GregorianCalendar(TimeZone.getTimeZone("UTC")); tmpGreg.setTimeInMillis(creationDate * 1000); - info.date = tmpGreg.getTime(); + entry.setDate(tmpGreg.getTime()); - info.revoked = matcher.group(6).contains("r"); - info.userIds = new ArrayList(); + entry.setRevoked(matcher.group(6).contains("r")); + ArrayList userIds = new ArrayList(); final String uidLines = matcher.group(7); final Matcher uidMatcher = UID_LINE.matcher(uidLines); while (uidMatcher.find()) { @@ -277,9 +280,11 @@ public class HkpKeyServer extends KeyServer { // will never happen, because "UTF8" is supported } } - info.userIds.add(tmp); + userIds.add(tmp); } - results.add(info); + entry.setUserIds(userIds); + + results.add(entry); } return results; } -- cgit v1.2.3 From 81e0d04230963cdd6db9c64e51316533c0a1d103 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 20 Mar 2014 16:09:05 +0100 Subject: colorize fingerprint in import --- .../org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java index d174bd0c8..57aaf0733 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java @@ -30,7 +30,9 @@ import android.widget.CheckBox; import android.widget.LinearLayout; import android.widget.LinearLayout.LayoutParams; import android.widget.TextView; + import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.OtherHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import java.util.ArrayList; @@ -136,7 +138,7 @@ public class ImportKeysAdapter extends ArrayAdapter { holder.keyId.setText(entry.keyIdHex); if (entry.fingerPrintHex != null) { - holder.fingerprint.setText(mActivity.getString(R.string.fingerprint) + " " + entry.fingerPrintHex); + holder.fingerprint.setText(OtherHelper.colorizeFingerprint(entry.fingerPrintHex)); holder.fingerprint.setVisibility(View.VISIBLE); } else { holder.fingerprint.setVisibility(View.GONE); -- cgit v1.2.3 From 77365202e0771abb0a1e8e3a2599ecb9664b3990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 20 Mar 2014 16:10:42 +0100 Subject: put colorize method into key helper --- .../keychain/helper/OtherHelper.java | 77 ------------------- .../keychain/pgp/PgpKeyHelper.java | 86 ++++++++++++++++++++++ .../keychain/ui/CertifyKeyActivity.java | 2 +- .../keychain/ui/ViewKeyMainFragment.java | 2 +- .../keychain/ui/adapter/ImportKeysAdapter.java | 2 +- 5 files changed, 89 insertions(+), 80 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java index 736bff02d..d0ba20ea6 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java @@ -65,81 +65,4 @@ public class OtherHelper { } } - public static SpannableStringBuilder colorizeFingerprint(String fingerprint) { - SpannableStringBuilder sb = new SpannableStringBuilder(fingerprint); - try { - // for each 4 characters of the fingerprint + 1 space - for (int i = 0; i < fingerprint.length(); i += 5) { - int spanEnd = Math.min(i + 4, fingerprint.length()); - String fourChars = fingerprint.substring(i, spanEnd); - - int raw = Integer.parseInt(fourChars, 16); - byte[] bytes = {(byte) ((raw >> 8) & 0xff - 128), (byte) (raw & 0xff - 128)}; - int[] color = OtherHelper.getRgbForData(bytes); - int r = color[0]; - int g = color[1]; - int b = color[2]; - - // we cannot change black by multiplication, so adjust it to an almost-black grey, - // which will then be brightened to the minimal brightness level - if (r == 0 && g == 0 && b == 0) { - r = 1; - g = 1; - b = 1; - } - - // Convert rgb to brightness - double brightness = 0.2126 * r + 0.7152 * g + 0.0722 * b; - - // If a color is too dark to be seen on black, - // then brighten it up to a minimal brightness. - if (brightness < 80) { - double factor = 80.0 / brightness; - r = Math.min(255, (int) (r * factor)); - g = Math.min(255, (int) (g * factor)); - b = Math.min(255, (int) (b * factor)); - - // If it is too light, then darken it to a respective maximal brightness. - } else if (brightness > 180) { - double factor = 180.0 / brightness; - r = (int) (r * factor); - g = (int) (g * factor); - b = (int) (b * factor); - } - - // Create a foreground color with the 3 digest integers as RGB - // and then converting that int to hex to use as a color - sb.setSpan(new ForegroundColorSpan(Color.rgb(r, g, b)), - i, spanEnd, Spannable.SPAN_INCLUSIVE_INCLUSIVE); - } - } catch (Exception e) { - Log.e(Constants.TAG, "Colorization failed", e); - // if anything goes wrong, then just display the fingerprint without colour, - // instead of partially correct colour or wrong colours - return new SpannableStringBuilder(fingerprint); - } - - return sb; - } - - /** - * Converts the given bytes to a unique RGB color using SHA1 algorithm - * - * @param bytes - * @return an integer array containing 3 numeric color representations (Red, Green, Black) - * @throws NoSuchAlgorithmException - * @throws DigestException - */ - public static int[] getRgbForData(byte[] bytes) throws NoSuchAlgorithmException, DigestException { - MessageDigest md = MessageDigest.getInstance("SHA1"); - - md.update(bytes); - byte[] digest = md.digest(); - - int[] result = {((int) digest[0] + 256) % 256, - ((int) digest[1] + 256) % 256, - ((int) digest[2] + 256) % 256}; - return result; - } - } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index 09c0b2d8f..35412d4b8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -18,6 +18,11 @@ package org.sufficientlysecure.keychain.pgp; import android.content.Context; +import android.graphics.Color; +import android.text.Spannable; +import android.text.SpannableStringBuilder; +import android.text.style.ForegroundColorSpan; + import org.spongycastle.bcpg.sig.KeyFlags; import org.spongycastle.openpgp.*; import org.spongycastle.util.encoders.Hex; @@ -27,6 +32,9 @@ import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.util.IterableIterator; import org.sufficientlysecure.keychain.util.Log; +import java.security.DigestException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -501,6 +509,84 @@ public class PgpKeyHelper { return hexString; } + + public static SpannableStringBuilder colorizeFingerprint(String fingerprint) { + SpannableStringBuilder sb = new SpannableStringBuilder(fingerprint); + try { + // for each 4 characters of the fingerprint + 1 space + for (int i = 0; i < fingerprint.length(); i += 5) { + int spanEnd = Math.min(i + 4, fingerprint.length()); + String fourChars = fingerprint.substring(i, spanEnd); + + int raw = Integer.parseInt(fourChars, 16); + byte[] bytes = {(byte) ((raw >> 8) & 0xff - 128), (byte) (raw & 0xff - 128)}; + int[] color = getRgbForData(bytes); + int r = color[0]; + int g = color[1]; + int b = color[2]; + + // we cannot change black by multiplication, so adjust it to an almost-black grey, + // which will then be brightened to the minimal brightness level + if (r == 0 && g == 0 && b == 0) { + r = 1; + g = 1; + b = 1; + } + + // Convert rgb to brightness + double brightness = 0.2126 * r + 0.7152 * g + 0.0722 * b; + + // If a color is too dark to be seen on black, + // then brighten it up to a minimal brightness. + if (brightness < 80) { + double factor = 80.0 / brightness; + r = Math.min(255, (int) (r * factor)); + g = Math.min(255, (int) (g * factor)); + b = Math.min(255, (int) (b * factor)); + + // If it is too light, then darken it to a respective maximal brightness. + } else if (brightness > 180) { + double factor = 180.0 / brightness; + r = (int) (r * factor); + g = (int) (g * factor); + b = (int) (b * factor); + } + + // Create a foreground color with the 3 digest integers as RGB + // and then converting that int to hex to use as a color + sb.setSpan(new ForegroundColorSpan(Color.rgb(r, g, b)), + i, spanEnd, Spannable.SPAN_INCLUSIVE_INCLUSIVE); + } + } catch (Exception e) { + Log.e(Constants.TAG, "Colorization failed", e); + // if anything goes wrong, then just display the fingerprint without colour, + // instead of partially correct colour or wrong colours + return new SpannableStringBuilder(fingerprint); + } + + return sb; + } + + /** + * Converts the given bytes to a unique RGB color using SHA1 algorithm + * + * @param bytes + * @return an integer array containing 3 numeric color representations (Red, Green, Black) + * @throws java.security.NoSuchAlgorithmException + * @throws java.security.DigestException + */ + private static int[] getRgbForData(byte[] bytes) throws NoSuchAlgorithmException, DigestException { + MessageDigest md = MessageDigest.getInstance("SHA1"); + + md.update(bytes); + byte[] digest = md.digest(); + + int[] result = {((int) digest[0] + 256) % 256, + ((int) digest[1] + 256) % 256, + ((int) digest[2] + 256) % 256}; + return result; + } + /** * Splits userId string into naming part, email part, and comment part * diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java index bd14369b0..0983d54fb 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java @@ -211,7 +211,7 @@ public class CertifyKeyActivity extends ActionBarActivity implements fingerprintBlob = ProviderHelper.getFingerprint(this, mDataUri); } String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob, true); - ((TextView) findViewById(R.id.fingerprint)).setText(OtherHelper.colorizeFingerprint(fingerprint)); + ((TextView) findViewById(R.id.fingerprint)).setText(PgpKeyHelper.colorizeFingerprint(fingerprint)); } break; case LOADER_ID_USER_IDS: diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index e140cb21e..7beef4b5e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -322,7 +322,7 @@ public class ViewKeyMainFragment extends Fragment implements } String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob, true); - mFingerprint.setText(OtherHelper.colorizeFingerprint(fingerprint)); + mFingerprint.setText(PgpKeyHelper.colorizeFingerprint(fingerprint)); } mKeysAdapter.swapCursor(data); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java index 57aaf0733..7d3166af9 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java @@ -138,7 +138,7 @@ public class ImportKeysAdapter extends ArrayAdapter { holder.keyId.setText(entry.keyIdHex); if (entry.fingerPrintHex != null) { - holder.fingerprint.setText(OtherHelper.colorizeFingerprint(entry.fingerPrintHex)); + holder.fingerprint.setText(PgpKeyHelper.colorizeFingerprint(entry.fingerPrintHex)); holder.fingerprint.setVisibility(View.VISIBLE); } else { holder.fingerprint.setVisibility(View.GONE); -- cgit v1.2.3 From a17481b80a2d717afdfc981c5c7e7528d1a7abca Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Thu, 20 Mar 2014 18:33:19 +0100 Subject: Group fingerprint again to make it visually consistent --- .../main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index 35412d4b8..ec0932773 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -511,6 +511,11 @@ public class PgpKeyHelper { public static SpannableStringBuilder colorizeFingerprint(String fingerprint) { + // add line breaks to have a consistent "image" that can be recognized + char[] chars = fingerprint.toCharArray(); + chars[24] = '\n'; + fingerprint = String.valueOf(chars); + SpannableStringBuilder sb = new SpannableStringBuilder(fingerprint); try { // for each 4 characters of the fingerprint + 1 space -- cgit v1.2.3 From 602fb654af521c7a892ea0c8557a74d8e9cffeda Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Thu, 20 Mar 2014 18:33:46 +0100 Subject: Move fingerprint to the right in key list entry Fits much better there and doesn't separate the user ID. --- .../src/main/res/layout/import_keys_list_entry.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/layout/import_keys_list_entry.xml b/OpenPGP-Keychain/src/main/res/layout/import_keys_list_entry.xml index fb092793b..724f538dd 100644 --- a/OpenPGP-Keychain/src/main/res/layout/import_keys_list_entry.xml +++ b/OpenPGP-Keychain/src/main/res/layout/import_keys_list_entry.xml @@ -51,13 +51,6 @@ android:text="@string/label_main_user_id" android:textAppearance="?android:attr/textAppearanceMedium" /> - - + + - \ No newline at end of file + -- cgit v1.2.3 From f5ecd2ae466837f24f4a9614240fd9eb4a6fb536 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Thu, 20 Mar 2014 18:34:40 +0100 Subject: Move fingerprint up below the algorithm in key view This makes it consistent with the key list entry layout and it also makes more sense, as it belongs to key identification. --- .../src/main/res/layout/view_key_main_fragment.xml | 30 +++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/layout/view_key_main_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/view_key_main_fragment.xml index 6ef3f3072..adbdb98dd 100644 --- a/OpenPGP-Keychain/src/main/res/layout/view_key_main_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/view_key_main_fragment.xml @@ -130,19 +130,23 @@ android:text="" /> - + + android:text="@string/label_fingerprint" /> + android:layout_height="wrap_content" + android:typeface="monospace" /> @@ -152,31 +156,27 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:paddingRight="10dip" - android:text="@string/label_expiry" /> + android:text="@string/label_creation" /> - + + android:text="@string/label_expiry" /> + android:layout_height="wrap_content" /> @@ -264,4 +264,4 @@ - \ No newline at end of file + -- cgit v1.2.3 From 0a8b45ee88b9dcdc7a2c6e067fe65f815641b8ee Mon Sep 17 00:00:00 2001 From: Nikhil Peter Raj Date: Thu, 20 Mar 2014 23:37:29 +0530 Subject: Fix for #451 --- .../keychain/ui/SelectSecretKeyLayoutFragment.java | 164 ++++++++++++--------- 1 file changed, 96 insertions(+), 68 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java index 960b4aafb..5b441f17b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java @@ -19,22 +19,24 @@ package org.sufficientlysecure.keychain.ui; import android.app.Activity; import android.content.Intent; +import android.database.Cursor; +import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.CursorLoader; +import android.support.v4.content.Loader; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.TextView; import com.beardedhen.androidbootstrap.BootstrapButton; -import org.spongycastle.openpgp.PGPSecretKey; -import org.spongycastle.openpgp.PGPSecretKeyRing; -import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; -import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.provider.KeychainContract; -public class SelectSecretKeyLayoutFragment extends Fragment { +public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderManager.LoaderCallbacks { private TextView mKeyUserId; private TextView mKeyUserIdRest; @@ -43,12 +45,25 @@ public class SelectSecretKeyLayoutFragment extends Fragment { private BootstrapButton mSelectKeyButton; private Boolean mFilterCertify; + private Uri mReceivedUri = null; + private SelectSecretKeyCallback mCallback; private static final int REQUEST_CODE_SELECT_KEY = 8882; + //Loader ID needs to be different from the usual 0 + private static final int LOADER_ID = 2; + + //The Projection we will retrieve, Master Key ID is for convenience sake, + //to avoid having to pass the Key Around + final String[] PROJECTION = new String[]{KeychainContract.UserIds.USER_ID + , KeychainContract.KeyRings.MASTER_KEY_ID}; + final int INDEX_USER_ID = 0; + final int INDEX_MASTER_KEY_ID = 1; + public interface SelectSecretKeyCallback { void onKeySelected(long secretKeyId); + } public void setCallback(SelectSecretKeyCallback callback) { @@ -59,63 +74,25 @@ public class SelectSecretKeyLayoutFragment extends Fragment { mFilterCertify = filterCertify; } - public void selectKey(long secretKeyId) { - if (secretKeyId == Id.key.none) { - mNoKeySelected.setVisibility(View.VISIBLE); - mKeyUserId.setVisibility(View.GONE); - mKeyUserIdRest.setVisibility(View.GONE); - mKeyMasterKeyIdHex.setVisibility(View.GONE); + public void setNoKeySelected() { + mNoKeySelected.setVisibility(View.VISIBLE); + mKeyUserId.setVisibility(View.GONE); + mKeyUserIdRest.setVisibility(View.GONE); + mKeyMasterKeyIdHex.setVisibility(View.GONE); + } - } else { - PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId( - getActivity(), secretKeyId); - if (keyRing != null) { - PGPSecretKey key = PgpKeyHelper.getMasterKey(keyRing); - String masterkeyIdHex = PgpKeyHelper.convertKeyIdToHexShort(secretKeyId); - - if (key != null) { - String userId = PgpKeyHelper.getMainUserIdSafe(getActivity(), key); - - String[] userIdSplit = PgpKeyHelper.splitUserId(userId); - String userName, userEmail; - - if (userIdSplit[0] != null) { - userName = userIdSplit[0]; - } else { - userName = getActivity().getResources().getString(R.string.user_id_no_name); - } - - if (userIdSplit[1] != null) { - userEmail = userIdSplit[1]; - } else { - userEmail = getActivity().getResources().getString(R.string.error_user_id_no_email); - } - - mKeyMasterKeyIdHex.setText(masterkeyIdHex); - mKeyUserId.setText(userName); - mKeyUserIdRest.setText(userEmail); - mKeyMasterKeyIdHex.setVisibility(View.VISIBLE); - mKeyUserId.setVisibility(View.VISIBLE); - mKeyUserIdRest.setVisibility(View.VISIBLE); - mNoKeySelected.setVisibility(View.GONE); - } else { - mKeyMasterKeyIdHex.setVisibility(View.GONE); - mKeyUserId.setVisibility(View.GONE); - mKeyUserIdRest.setVisibility(View.GONE); - mNoKeySelected.setVisibility(View.VISIBLE); - } - } else { - mKeyMasterKeyIdHex.setText( - getActivity().getResources() - .getString(R.string.no_keys_added_or_updated) - + " for master id: " + secretKeyId); - mKeyMasterKeyIdHex.setVisibility(View.VISIBLE); - mKeyUserId.setVisibility(View.GONE); - mKeyUserIdRest.setVisibility(View.GONE); - mNoKeySelected.setVisibility(View.GONE); - } + public void setSelectedKeyData(String userName, String email, String masterKeyHex) { + + mNoKeySelected.setVisibility(View.GONE); + + mKeyUserId.setText(userName); + mKeyUserIdRest.setText(email); + mKeyMasterKeyIdHex.setText(masterKeyHex); + + mKeyUserId.setVisibility(View.VISIBLE); + mKeyUserIdRest.setVisibility(View.VISIBLE); + mKeyMasterKeyIdHex.setVisibility(View.VISIBLE); - } } public void setError(String error) { @@ -147,29 +124,80 @@ public class SelectSecretKeyLayoutFragment extends Fragment { return view; } + //For AppSettingsFragment + public void selectKey(long masterKeyId){ + Uri buildUri = KeychainContract.KeyRings.buildSecretKeyRingsByMasterKeyIdUri(String.valueOf(masterKeyId)); + mReceivedUri=buildUri; + getActivity().getSupportLoaderManager().restartLoader(LOADER_ID, null, this); + } + private void startSelectKeyActivity() { Intent intent = new Intent(getActivity(), SelectSecretKeyActivity.class); intent.putExtra(SelectSecretKeyActivity.EXTRA_FILTER_CERTIFY, mFilterCertify); startActivityForResult(intent, REQUEST_CODE_SELECT_KEY); } + @Override + public Loader onCreateLoader(int id, Bundle args) { + //We don't care about the Loader id + return new CursorLoader(getActivity(), mReceivedUri, PROJECTION, null, null, null); + } + + @Override + public void onLoadFinished(Loader loader, Cursor data) { + if (data.moveToFirst()) { + String userName, email, masterKeyHex; + String userID = data.getString(INDEX_USER_ID); + long masterKeyID = data.getLong(INDEX_MASTER_KEY_ID); + + String splitUserID[] = PgpKeyHelper.splitUserId(userID); + + if (splitUserID[0] != null) { + userName = splitUserID[0]; + } else { + userName = getActivity().getResources().getString(R.string.user_id_no_name); + } + + if (splitUserID[1] != null) { + email = splitUserID[1]; + } else { + email = getActivity().getResources().getString(R.string.error_user_id_no_email); + } + + //TODO Can the cursor return invalid values for the Master Key ? + masterKeyHex = PgpKeyHelper.convertKeyIdToHexShort(masterKeyID); + + //Set the data + setSelectedKeyData(userName, email, masterKeyHex); + + //Give value to the callback + mCallback.onKeySelected(masterKeyID); + } else { + //Set The empty View + setNoKeySelected(); + } + + } + + @Override + public void onLoaderReset(Loader loader) { + return; + } + // Select Secret Key Activity delivers the intent which was sent by it using interface to Select - // Secret Key Fragment.Intent contains Master Key Id, User Email, User Name, Master Key Id Hex. + // Secret Key Fragment.Intent contains the passed Uri @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode & 0xFFFF) { case REQUEST_CODE_SELECT_KEY: { - long secretKeyId; if (resultCode == Activity.RESULT_OK) { - Bundle bundle = data.getExtras(); - secretKeyId = bundle.getLong(SelectSecretKeyActivity.RESULT_EXTRA_MASTER_KEY_ID); - selectKey(secretKeyId); + mReceivedUri = data.getData(); + + //Must be restartLoader() or the data will not be updated on selecting a new key + getActivity().getSupportLoaderManager().restartLoader(LOADER_ID, null, this); - // remove displayed errors mKeyUserId.setError(null); - // give value back to callback - mCallback.onKeySelected(secretKeyId); } break; } -- cgit v1.2.3 From 0510e0e217f5b7bab548dccf7bdd75f2bd5c0463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 20 Mar 2014 19:11:51 +0100 Subject: verify downloaded key by comparing fingerprints --- .../keychain/service/KeychainIntentService.java | 80 ++++++++++++---------- 1 file changed, 45 insertions(+), 35 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 5af81d39d..19358adc9 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -25,6 +25,7 @@ import android.os.Bundle; import android.os.Message; import android.os.Messenger; import android.os.RemoteException; + import org.spongycastle.openpgp.*; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; @@ -692,11 +693,11 @@ public class KeychainIntentService extends IntentService for (long masterKeyId : masterKeyIds) { if ((keyType == Id.type.public_key || keyType == Id.type.public_secret_key) - && allPublicMasterKeyIds.contains(masterKeyId)) { + && allPublicMasterKeyIds.contains(masterKeyId)) { publicMasterKeyIds.add(masterKeyId); } if ((keyType == Id.type.secret_key || keyType == Id.type.public_secret_key) - && allSecretMasterKeyIds.contains(masterKeyId)) { + && allSecretMasterKeyIds.contains(masterKeyId)) { secretMasterKeyIds.add(masterKeyId); } } @@ -745,49 +746,58 @@ public class KeychainIntentService extends IntentService ArrayList entries = data.getParcelableArrayList(DOWNLOAD_KEY_LIST); String keyServer = data.getString(DOWNLOAD_KEY_SERVER); + // TODO: add extra which requires fingerprint suport and force verification! + // only supported by newer sks keyserver versions + // this downloads the keys and places them into the ImportKeysListEntry entries HkpKeyServer server = new HkpKeyServer(keyServer); for (ImportKeysListEntry entry : entries) { - byte[] downloadedKey = server.get(entry.getKeyIdHex()).getBytes(); - - /** - * TODO: copied from ImportKeysListLoader - * - * - * this parses the downloaded key - */ - // need to have access to the bufferedInput, so we can reuse it for the possible - // PGPObject chunks after the first one, e.g. files with several consecutive ASCII - // armor blocks - BufferedInputStream bufferedInput = - new BufferedInputStream(new ByteArrayInputStream(downloadedKey)); - try { - - // read all available blocks... (asc files can contain many blocks with BEGIN END) - while (bufferedInput.available() > 0) { - InputStream in = PGPUtil.getDecoderStream(bufferedInput); - PGPObjectFactory objectFactory = new PGPObjectFactory(in); - - // go through all objects in this block - Object obj; - while ((obj = objectFactory.nextObject()) != null) { - Log.d(Constants.TAG, "Found class: " + obj.getClass()); - - if (obj instanceof PGPKeyRing) { - PGPKeyRing newKeyring = (PGPKeyRing) obj; + // if available use complete fingerprint for get request + byte[] downloadedKeyBytes; + if (entry.getFingerPrintHex() != null) { + downloadedKeyBytes = server.get(entry.getFingerPrintHex()).getBytes(); + } else { + downloadedKeyBytes = server.get(entry.getKeyIdHex()).getBytes(); + } - entry.setBytes(newKeyring.getEncoded()); - } else { - Log.e(Constants.TAG, "Object not recognized as PGPKeyRing!"); - } + // create PGPKeyRing object based on downloaded armored key + PGPKeyRing downloadedKey = null; + BufferedInputStream bufferedInput = + new BufferedInputStream(new ByteArrayInputStream(downloadedKeyBytes)); + if (bufferedInput.available() > 0) { + InputStream in = PGPUtil.getDecoderStream(bufferedInput); + PGPObjectFactory objectFactory = new PGPObjectFactory(in); + + // get first object in block + Object obj; + if ((obj = objectFactory.nextObject()) != null) { + Log.d(Constants.TAG, "Found class: " + obj.getClass()); + + if (obj instanceof PGPKeyRing) { + downloadedKey = (PGPKeyRing) obj; + } else { + throw new PgpGeneralException("Object not recognized as PGPKeyRing!"); } } - } catch (Exception e) { - Log.e(Constants.TAG, "Exception on parsing key file!", e); } + + // verify downloaded key by comparing fingerprints + if (entry.getFingerPrintHex() != null) { + String downloadedKeyFp = PgpKeyHelper.convertFingerprintToHex(downloadedKey.getPublicKey().getFingerprint(), false); + if (downloadedKeyFp.equals(entry.getFingerPrintHex())) { + Log.d(Constants.TAG, "fingerprint of downloaded key is the same as the requested fingerprint!"); + } else { + throw new PgpGeneralException("fingerprint of downloaded key is NOT the same as the requested fingerprint!"); + } + } + + // save key bytes in entry object for doing the + // actual import afterwards + entry.setBytes(downloadedKey.getEncoded()); } + Intent importIntent = new Intent(this, KeychainIntentService.class); importIntent.setAction(ACTION_IMPORT_KEYRING); Bundle importData = new Bundle(); -- cgit v1.2.3 From 016641a422ddff652b697a76d7ed59ab9954239e Mon Sep 17 00:00:00 2001 From: Nikhil Peter Raj Date: Thu, 20 Mar 2014 23:46:26 +0530 Subject: Cleanup for #451 --- .../org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java | 4 ---- .../sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java | 1 - 2 files changed, 5 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java index 82a3c2e8e..0ff88d97c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyActivity.java @@ -76,10 +76,6 @@ public class SelectSecretKeyActivity extends ActionBarActivity { Intent data = new Intent(); data.setData(selectedUri); - // TODO: deprecate RESULT_EXTRA_MASTER_KEY_ID! - long masterKeyId = Long.valueOf(selectedUri.getLastPathSegment()); - data.putExtra(RESULT_EXTRA_MASTER_KEY_ID, masterKeyId); - setResult(RESULT_OK, data); finish(); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java index 5b441f17b..41e250bb7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java @@ -63,7 +63,6 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan public interface SelectSecretKeyCallback { void onKeySelected(long secretKeyId); - } public void setCallback(SelectSecretKeyCallback callback) { -- cgit v1.2.3 From 59d51fe68eb6502c313c6a74d4a1e04d0e959b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 20 Mar 2014 19:48:18 +0100 Subject: Fix fingerprint handling --- .../org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java | 14 +++++--------- .../keychain/service/KeychainIntentService.java | 4 ++-- .../sufficientlysecure/keychain/ui/CertifyKeyActivity.java | 4 +++- .../sufficientlysecure/keychain/ui/ViewKeyActivity.java | 2 +- .../keychain/ui/ViewKeyMainFragment.java | 2 +- .../keychain/ui/adapter/ImportKeysListEntry.java | 2 +- .../keychain/ui/dialog/ShareQrCodeDialogFragment.java | 2 +- .../org/sufficientlysecure/keychain/util/HkpKeyServer.java | 3 +-- .../src/main/res/layout/import_keys_list_entry.xml | 7 ++++--- 9 files changed, 19 insertions(+), 21 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index ec0932773..b7db92b9b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -452,7 +452,7 @@ public class PgpKeyHelper { key = secretKey.getPublicKey(); } - return convertFingerprintToHex(key.getFingerprint(), true); + return convertFingerprintToHex(key.getFingerprint()); } /** @@ -465,19 +465,12 @@ public class PgpKeyHelper { * @param split split into 4 character chunks * @return */ - public static String convertFingerprintToHex(byte[] fingerprint, boolean split) { + public static String convertFingerprintToHex(byte[] fingerprint) { String hexString = Hex.toHexString(fingerprint); - if (split) { - hexString = splitFingerprintHex(hexString); - } return hexString; } - public static String splitFingerprintHex(String hexString) { - return hexString.replaceAll("(.{4})(?!$)", "$1 "); - } - /** * Convert key id from long to 64 bit hex string *

@@ -511,6 +504,9 @@ public class PgpKeyHelper { public static SpannableStringBuilder colorizeFingerprint(String fingerprint) { + // split by 4 characters + fingerprint = fingerprint.replaceAll("(.{4})(?!$)", "$1 "); + // add line breaks to have a consistent "image" that can be recognized char[] chars = fingerprint.toCharArray(); chars[24] = '\n'; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 19358adc9..0751fa33c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -756,7 +756,7 @@ public class KeychainIntentService extends IntentService // if available use complete fingerprint for get request byte[] downloadedKeyBytes; if (entry.getFingerPrintHex() != null) { - downloadedKeyBytes = server.get(entry.getFingerPrintHex()).getBytes(); + downloadedKeyBytes = server.get("0x" + entry.getFingerPrintHex()).getBytes(); } else { downloadedKeyBytes = server.get(entry.getKeyIdHex()).getBytes(); } @@ -784,7 +784,7 @@ public class KeychainIntentService extends IntentService // verify downloaded key by comparing fingerprints if (entry.getFingerPrintHex() != null) { - String downloadedKeyFp = PgpKeyHelper.convertFingerprintToHex(downloadedKey.getPublicKey().getFingerprint(), false); + String downloadedKeyFp = PgpKeyHelper.convertFingerprintToHex(downloadedKey.getPublicKey().getFingerprint()); if (downloadedKeyFp.equals(entry.getFingerPrintHex())) { Log.d(Constants.TAG, "fingerprint of downloaded key is the same as the requested fingerprint!"); } else { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java index 0983d54fb..dff4e9d72 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java @@ -198,6 +198,8 @@ public class CertifyKeyActivity extends ActionBarActivity implements case LOADER_ID_KEYRING: // the first key here is our master key if (data.moveToFirst()) { + // TODO: put findViewById in onCreate! + long keyId = data.getLong(INDEX_MASTER_KEY_ID); String keyIdStr = PgpKeyHelper.convertKeyIdToHexShort(keyId); ((TextView) findViewById(R.id.key_id)).setText(keyIdStr); @@ -210,7 +212,7 @@ public class CertifyKeyActivity extends ActionBarActivity implements // FALLBACK for old database entries fingerprintBlob = ProviderHelper.getFingerprint(this, mDataUri); } - String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob, true); + String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob); ((TextView) findViewById(R.id.fingerprint)).setText(PgpKeyHelper.colorizeFingerprint(fingerprint)); } break; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index c4097403c..41bd95db3 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -182,7 +182,7 @@ public class ViewKeyActivity extends ActionBarActivity { String content; if (fingerprintOnly) { byte[] fingerprintBlob = ProviderHelper.getFingerprint(this, dataUri); - String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob, false); + String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob); content = Constants.FINGERPRINT_SCHEME + ":" + fingerprint; } else { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index 7beef4b5e..dd4e7fa94 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -320,7 +320,7 @@ public class ViewKeyMainFragment extends Fragment implements // FALLBACK for old database entries fingerprintBlob = ProviderHelper.getFingerprint(getActivity(), mDataUri); } - String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob, true); + String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob); mFingerprint.setText(PgpKeyHelper.colorizeFingerprint(fingerprint)); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java index 2610dfb3e..9b20effc2 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java @@ -240,7 +240,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable { this.revoked = pgpKeyRing.getPublicKey().isRevoked(); this.fingerPrintHex = PgpKeyHelper.convertFingerprintToHex(pgpKeyRing.getPublicKey() - .getFingerprint(), true); + .getFingerprint()); this.bitStrength = pgpKeyRing.getPublicKey().getBitStrength(); final int algorithm = pgpKeyRing.getPublicKey().getAlgorithm(); this.algorithm = getAlgorithmFromId(algorithm); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java index b501ba230..94586810e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java @@ -90,7 +90,7 @@ public class ShareQrCodeDialogFragment extends DialogFragment { alert.setPositiveButton(R.string.btn_okay, null); byte[] fingerprintBlob = ProviderHelper.getFingerprint(getActivity(), dataUri); - String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob, false); + String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob); mText.setText(getString(R.string.share_qr_code_dialog_fingerprint_text) + " " + fingerprint); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java index a25e3d748..b987e1533 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java @@ -251,8 +251,7 @@ public class HkpKeyServer extends KeyServer { // and https://github.com/openpgp-keychain/openpgp-keychain/issues/259#issuecomment-38168176 String fingerprintOrKeyId = matcher.group(1); if (fingerprintOrKeyId.length() > 16) { - entry.setFingerPrintHex(PgpKeyHelper.splitFingerprintHex( - fingerprintOrKeyId.toLowerCase(Locale.US))); + entry.setFingerPrintHex(fingerprintOrKeyId.toLowerCase(Locale.US)); entry.setKeyIdHex("0x" + fingerprintOrKeyId.substring(fingerprintOrKeyId.length() - 16, fingerprintOrKeyId.length())); } else { diff --git a/OpenPGP-Keychain/src/main/res/layout/import_keys_list_entry.xml b/OpenPGP-Keychain/src/main/res/layout/import_keys_list_entry.xml index 724f538dd..f5a39f115 100644 --- a/OpenPGP-Keychain/src/main/res/layout/import_keys_list_entry.xml +++ b/OpenPGP-Keychain/src/main/res/layout/import_keys_list_entry.xml @@ -15,7 +15,7 @@ limitations under the License. --> @@ -87,6 +87,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="fingerprint" + android:typeface="monospace" android:textAppearance="?android:attr/textAppearanceSmall" /> -- cgit v1.2.3 From d9b909a24f4b32225027451062ed6304b1cf9a2e Mon Sep 17 00:00:00 2001 From: Nikhil Peter Raj Date: Fri, 21 Mar 2014 00:27:03 +0530 Subject: Update fix for #451 --- .../keychain/ui/SelectSecretKeyLayoutFragment.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java index 41e250bb7..2fcfc9650 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java @@ -50,9 +50,8 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan private SelectSecretKeyCallback mCallback; private static final int REQUEST_CODE_SELECT_KEY = 8882; - - //Loader ID needs to be different from the usual 0 - private static final int LOADER_ID = 2; + + private static final int LOADER_ID = 0; //The Projection we will retrieve, Master Key ID is for convenience sake, //to avoid having to pass the Key Around -- cgit v1.2.3 From 2816461283c0067f524d94ddf9702e119025c9d3 Mon Sep 17 00:00:00 2001 From: Nikhil Peter Raj Date: Fri, 21 Mar 2014 01:50:20 +0530 Subject: Fix for #410 --- .../keychain/helper/ExportHelper.java | 4 +- .../keychain/provider/ProviderHelper.java | 23 ++- .../keychain/ui/EditKeyActivity.java | 14 +- .../keychain/ui/KeyListFragment.java | 22 +-- .../keychain/ui/ViewKeyActivity.java | 19 +- .../ui/dialog/DeleteKeyDialogFragment.java | 207 ++++++++++++--------- .../main/res/layout/view_key_delete_fragment.xml | 38 ++++ OpenPGP-Keychain/src/main/res/values/strings.xml | 2 + 8 files changed, 187 insertions(+), 142 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/res/layout/view_key_delete_fragment.xml diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java index 03cf936ee..2bfa796c7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java @@ -53,14 +53,14 @@ public class ExportHelper { this.mActivity = activity; } - public void deleteKey(Uri dataUri, final int keyType, Handler deleteHandler) { + public void deleteKey(Uri dataUri, Handler deleteHandler) { long keyRingRowId = Long.valueOf(dataUri.getLastPathSegment()); // Create a new Messenger for the communication back Messenger messenger = new Messenger(deleteHandler); DeleteKeyDialogFragment deleteKeyDialog = DeleteKeyDialogFragment.newInstance(messenger, - new long[]{keyRingRowId}, keyType); + new long[]{keyRingRowId}); deleteKeyDialog.show(mActivity.getSupportFragmentManager(), "deleteKeyDialog"); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java index db2c57207..8b6feeafd 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2013 Dominik Schürmann + * Copyright (C) 2012-2013 Dominik Schürmann * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -230,7 +230,7 @@ public class ProviderHelper { // get current _ID of key long currentRowId = -1; Cursor oldQuery = context.getContentResolver() - .query(deleteUri, new String[]{KeyRings._ID}, null, null, null); + .query(deleteUri, new String[]{KeyRings._ID}, null, null, null); if (oldQuery != null && oldQuery.moveToFirst()) { currentRowId = oldQuery.getLong(0); } else { @@ -288,7 +288,7 @@ public class ProviderHelper { * Build ContentProviderOperation to add PGPPublicKey to database corresponding to a keyRing */ private static ContentProviderOperation buildPublicKeyOperations(Context context, - long keyRingRowId, PGPPublicKey key, int rank) throws IOException { + long keyRingRowId, PGPPublicKey key, int rank) throws IOException { ContentValues values = new ContentValues(); values.put(Keys.KEY_ID, key.getKeyID()); values.put(Keys.IS_MASTER_KEY, key.isMasterKey()); @@ -316,7 +316,7 @@ public class ProviderHelper { * Build ContentProviderOperation to add PublicUserIds to database corresponding to a keyRing */ private static ContentProviderOperation buildPublicUserIdOperations(Context context, - long keyRingRowId, String userId, int rank) { + long keyRingRowId, String userId, int rank) { ContentValues values = new ContentValues(); values.put(UserIds.KEY_RING_ROW_ID, keyRingRowId); values.put(UserIds.USER_ID, userId); @@ -331,7 +331,7 @@ public class ProviderHelper { * Build ContentProviderOperation to add PGPSecretKey to database corresponding to a keyRing */ private static ContentProviderOperation buildSecretKeyOperations(Context context, - long keyRingRowId, PGPSecretKey key, int rank) throws IOException { + long keyRingRowId, PGPSecretKey key, int rank) throws IOException { ContentValues values = new ContentValues(); boolean hasPrivate = true; @@ -368,7 +368,7 @@ public class ProviderHelper { * Build ContentProviderOperation to add SecretUserIds to database corresponding to a keyRing */ private static ContentProviderOperation buildSecretUserIdOperations(Context context, - long keyRingRowId, String userId, int rank) { + long keyRingRowId, String userId, int rank) { ContentValues values = new ContentValues(); values.put(UserIds.KEY_RING_ROW_ID, keyRingRowId); values.put(UserIds.USER_ID, userId); @@ -469,6 +469,15 @@ public class ProviderHelper { cr.delete(KeyRings.buildSecretKeyRingsUri(Long.toString(rowId)), null, null); } + public static void deleteUnifiedKeyRing(Context context,String masterKeyId,boolean isSecretKey){ + ContentResolver cr= context.getContentResolver(); + cr.delete(KeyRings.buildPublicKeyRingsByMasterKeyIdUri(masterKeyId),null,null); + if(isSecretKey){ + cr.delete(KeyRings.buildSecretKeyRingsByMasterKeyIdUri(masterKeyId),null,null); + } + + } + /** * Get master key id of keyring by its row id */ @@ -855,4 +864,4 @@ public class ProviderHelper { return signature; } -} +} \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 31804719f..654942db7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2013 Dominik Schürmann + * Copyright (C) 2012-2013 Dominik Schürmann * Copyright (C) 2010 Thialfihar * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -46,6 +46,7 @@ import org.sufficientlysecure.keychain.helper.ExportHelper; import org.sufficientlysecure.keychain.pgp.PgpConversionHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; +import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; @@ -58,7 +59,6 @@ import org.sufficientlysecure.keychain.ui.widget.SectionView; import org.sufficientlysecure.keychain.ui.widget.UserIdEditor; import org.sufficientlysecure.keychain.util.IterableIterator; import org.sufficientlysecure.keychain.util.Log; - import java.util.ArrayList; import java.util.GregorianCalendar; import java.util.Vector; @@ -325,9 +325,13 @@ public class EditKeyActivity extends ActionBarActivity { long masterKeyId = ProviderHelper.getMasterKeyId(this, mDataUri); long[] ids = new long[]{masterKeyId}; mExportHelper.showExportKeysDialog(ids, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC, - null); + null); return true; case R.id.menu_key_edit_delete: { + //Convert the uri to one based on rowId + long rowId= ProviderHelper.getRowId(this,mDataUri); + Uri convertUri = KeychainContract.KeyRings.buildSecretKeyRingsUri(Long.toString(rowId)); + // Message is received after key is deleted Handler returnHandler = new Handler() { @Override @@ -339,7 +343,7 @@ public class EditKeyActivity extends ActionBarActivity { } }; - mExportHelper.deleteKey(mDataUri, Id.type.secret_key, returnHandler); + mExportHelper.deleteKey(convertUri, returnHandler); return true; } } @@ -697,4 +701,4 @@ public class EditKeyActivity extends ActionBarActivity { : getString(R.string.btn_set_passphrase)); } -} +} \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index cac8b7046..daf455c03 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -355,25 +355,7 @@ public class KeyListFragment extends Fragment @Override public void handleMessage(Message message) { if (message.what == DeleteKeyDialogFragment.MESSAGE_OKAY) { - Bundle returnData = message.getData(); - if (returnData != null - && returnData.containsKey(DeleteKeyDialogFragment.MESSAGE_NOT_DELETED)) { - ArrayList notDeleted = - returnData.getStringArrayList(DeleteKeyDialogFragment.MESSAGE_NOT_DELETED); - String notDeletedMsg = ""; - for (String userId : notDeleted) { - notDeletedMsg += userId + "\n"; - } - Toast.makeText(getActivity(), - getString(R.string.error_can_not_delete_contacts, notDeletedMsg) - + getResources() - .getQuantityString( - R.plurals.error_can_not_delete_info, - notDeleted.size()), - Toast.LENGTH_LONG).show(); - - mode.finish(); - } + mode.finish(); } } }; @@ -382,7 +364,7 @@ public class KeyListFragment extends Fragment Messenger messenger = new Messenger(returnHandler); DeleteKeyDialogFragment deleteKeyDialog = DeleteKeyDialogFragment.newInstance(messenger, - keyRingRowIds, Id.type.public_key); + keyRingRowIds); deleteKeyDialog.show(getActivity().getSupportFragmentManager(), "deleteKeyDialog"); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index c4097403c..5e7cabcac 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -237,25 +237,12 @@ public class ViewKeyActivity extends ActionBarActivity { Handler returnHandler = new Handler() { @Override public void handleMessage(Message message) { - if (message.what == DeleteKeyDialogFragment.MESSAGE_OKAY) { - Bundle returnData = message.getData(); - if (returnData != null - && returnData.containsKey(DeleteKeyDialogFragment.MESSAGE_NOT_DELETED)) { - // we delete only this key, so MESSAGE_NOT_DELETED will solely contain this key - Toast.makeText(ViewKeyActivity.this, - getString(R.string.error_can_not_delete_contact) - + getResources() - .getQuantityString(R.plurals.error_can_not_delete_info, 1), - Toast.LENGTH_LONG).show(); - } else { - setResult(RESULT_CANCELED); - finish(); - } - } + setResult(RESULT_CANCELED); + finish(); } }; - mExportHelper.deleteKey(dataUri, Id.type.public_key, returnHandler); + mExportHelper.deleteKey(dataUri, returnHandler); } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java index 1bcf5b33c..76a69328a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2013 Dominik Schürmann + * Copyright (C) 2013-2014 Dominik Schürmann * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - package org.sufficientlysecure.keychain.ui.dialog; import android.app.AlertDialog; @@ -28,6 +27,11 @@ import android.os.Messenger; import android.os.RemoteException; import android.support.v4.app.DialogFragment; import android.support.v4.app.FragmentActivity; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.CheckBox; +import android.widget.LinearLayout; +import android.widget.TextView; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; @@ -35,148 +39,167 @@ import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainDatabase; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.util.Log; - import java.util.ArrayList; public class DeleteKeyDialogFragment extends DialogFragment { private static final String ARG_MESSENGER = "messenger"; private static final String ARG_DELETE_KEY_RING_ROW_IDS = "delete_file"; - private static final String ARG_KEY_TYPE = "key_type"; public static final int MESSAGE_OKAY = 1; + public static final int MESSAGE_ERROR = 0; + + private boolean isSingleSelection = false; - public static final String MESSAGE_NOT_DELETED = "not_deleted"; + private TextView mainMessage; + private CheckBox checkDeleteSecret; + private LinearLayout deleteSecretKeyView; + private View inflateView; private Messenger mMessenger; /** * Creates new instance of this delete file dialog fragment */ - public static DeleteKeyDialogFragment newInstance(Messenger messenger, long[] keyRingRowIds, - int keyType) { + public static DeleteKeyDialogFragment newInstance(Messenger messenger, long[] keyRingRowIds + ) { DeleteKeyDialogFragment frag = new DeleteKeyDialogFragment(); Bundle args = new Bundle(); args.putParcelable(ARG_MESSENGER, messenger); args.putLongArray(ARG_DELETE_KEY_RING_ROW_IDS, keyRingRowIds); - args.putInt(ARG_KEY_TYPE, keyType); + //We don't need the key type frag.setArguments(args); return frag; } - /** - * Creates dialog - */ + @Override public Dialog onCreateDialog(Bundle savedInstanceState) { + final FragmentActivity activity = getActivity(); mMessenger = getArguments().getParcelable(ARG_MESSENGER); final long[] keyRingRowIds = getArguments().getLongArray(ARG_DELETE_KEY_RING_ROW_IDS); - final int keyType = getArguments().getInt(ARG_KEY_TYPE); AlertDialog.Builder builder = new AlertDialog.Builder(activity); + + //Setup custom View to display in AlertDialog + LayoutInflater inflater = activity.getLayoutInflater(); + inflateView = inflater.inflate(R.layout.view_key_delete_fragment, null); + builder.setView(inflateView); + + deleteSecretKeyView = (LinearLayout) inflateView.findViewById(R.id.deleteSecretKeyView); + mainMessage = (TextView) inflateView.findViewById(R.id.mainMessage); + checkDeleteSecret = (CheckBox) inflateView.findViewById(R.id.checkDeleteSecret); + builder.setTitle(R.string.warning); + //If only a single key has been selected if (keyRingRowIds.length == 1) { Uri dataUri; - if (keyType == Id.type.public_key) { - dataUri = KeychainContract.KeyRings.buildPublicKeyRingsUri(String.valueOf(keyRingRowIds[0])); + ArrayList publicKeyRings; //Any one will do + isSingleSelection = true; + + long selectedRow = keyRingRowIds[0]; + long keyType; + publicKeyRings = ProviderHelper.getPublicKeyRingsRowIds(activity); + + if (publicKeyRings.contains(selectedRow)) { + //TODO Should be a better method to do this other than getting all the KeyRings + dataUri = KeychainContract.KeyRings.buildPublicKeyRingsUri(String.valueOf(selectedRow)); + keyType = Id.type.public_key; } else { - dataUri = KeychainContract.KeyRings.buildSecretKeyRingsUri(String.valueOf(keyRingRowIds[0])); + dataUri = KeychainContract.KeyRings.buildSecretKeyRingsUri(String.valueOf(selectedRow)); + keyType = Id.type.secret_key; } + String userId = ProviderHelper.getUserId(activity, dataUri); + //Hide the Checkbox and TextView since this is a single selection,user will be notified thru message + deleteSecretKeyView.setVisibility(View.GONE); + //Set message depending on which key it is. + mainMessage.setText(getString(keyType == Id.type.secret_key ? R.string.secret_key_deletion_confirmation + : R.string.public_key_deletetion_confirmation, userId)); + - builder.setMessage(getString( - keyType == Id.type.public_key ? R.string.key_deletion_confirmation - : R.string.secret_key_deletion_confirmation, userId)); } else { - builder.setMessage(R.string.key_deletion_confirmation_multi); + deleteSecretKeyView.setVisibility(View.VISIBLE); + mainMessage.setText(R.string.key_deletion_confirmation_multi); } + builder.setIcon(R.drawable.ic_dialog_alert_holo_light); builder.setPositiveButton(R.string.btn_delete, new DialogInterface.OnClickListener() { - - @Override - public void onClick(DialogInterface dialog, int id) { - ArrayList notDeleted = new ArrayList(); - - if (keyType == Id.type.public_key) { - Uri queryUri = KeychainContract.KeyRings.buildPublicKeyRingsUri(); - String[] projection = new String[]{ - KeychainContract.KeyRings._ID, // 0 - KeychainContract.KeyRings.MASTER_KEY_ID, // 1 - KeychainContract.UserIds.USER_ID // 2 - }; - - // make selection with all entries where _ID is one of the given row ids - String selection = KeychainDatabase.Tables.KEY_RINGS + "." + - KeychainContract.KeyRings._ID + " IN("; - String selectionIDs = ""; - for (int i = 0; i < keyRingRowIds.length; i++) { - selectionIDs += "'" + String.valueOf(keyRingRowIds[i]) + "'"; - if (i + 1 < keyRingRowIds.length) { - selectionIDs += ","; + @Override + public void onClick(DialogInterface dialog, int which) { + Uri queryUri = KeychainContract.KeyRings.buildUnifiedKeyRingsUri(); + String[] projection = new String[]{ + KeychainContract.KeyRings.MASTER_KEY_ID, // 0 + KeychainContract.KeyRings.TYPE// 1 + }; + + // make selection with all entries where _ID is one of the given row ids + String selection = KeychainDatabase.Tables.KEY_RINGS + "." + + KeychainContract.KeyRings._ID + " IN("; + String selectionIDs = ""; + for (int i = 0; i < keyRingRowIds.length; i++) { + selectionIDs += "'" + String.valueOf(keyRingRowIds[i]) + "'"; + if (i + 1 < keyRingRowIds.length) + selectionIDs += ","; } - } - selection += selectionIDs + ")"; - - Cursor cursor = activity.getContentResolver().query(queryUri, projection, - selection, null, null); - - long rowId; - long masterKeyId; - String userId; - try { - while (cursor != null && cursor.moveToNext()) { - rowId = cursor.getLong(0); - masterKeyId = cursor.getLong(1); - userId = cursor.getString(2); - - Log.d(Constants.TAG, "rowId: " + rowId + ", masterKeyId: " + masterKeyId - + ", userId: " + userId); - - // check if a corresponding secret key exists... - Cursor secretCursor = activity.getContentResolver().query( - KeychainContract.KeyRings - .buildSecretKeyRingsByMasterKeyIdUri( - String.valueOf(masterKeyId)), - null, null, null, null - ); - if (secretCursor != null && secretCursor.getCount() > 0) { - notDeleted.add(userId); - } else { - // it is okay to delete this key, no secret key found! - ProviderHelper.deletePublicKeyRing(activity, rowId); + selection += selectionIDs + ")"; + + Cursor cursor = activity.getContentResolver().query(queryUri, projection, + selection, null, null); + + + long masterKeyId; + long keyType; + boolean isSuccessfullyDeleted; + try { + isSuccessfullyDeleted = false; + while (cursor != null && cursor.moveToNext()) { + masterKeyId = cursor.getLong(0); + keyType = cursor.getLong(1); + + Log.d(Constants.TAG, "masterKeyId: " + masterKeyId + + ", keyType:" + (keyType == KeychainContract.KeyTypes.PUBLIC ? "Public" : "Private")); + + + if (keyType == KeychainContract.KeyTypes.SECRET) { + if (checkDeleteSecret.isChecked() || isSingleSelection) { + ProviderHelper.deleteUnifiedKeyRing(activity, String.valueOf(masterKeyId), true); + } + } else { + ProviderHelper.deleteUnifiedKeyRing(activity, String.valueOf(masterKeyId), false); + } } - if (secretCursor != null) { - secretCursor.close(); + + //Check if the selected rows have actually been deleted + cursor = activity.getContentResolver().query(queryUri, projection, selection, null, null); + if (cursor == null || cursor.getCount() == 0 || !checkDeleteSecret.isChecked()) { + isSuccessfullyDeleted = true; + } + + } finally { + if (cursor != null) { + cursor.close(); } + } - } finally { - if (cursor != null) { - cursor.close(); + + dismiss(); + + if (isSuccessfullyDeleted) { + sendMessageToHandler(MESSAGE_OKAY, null); + } else { + sendMessageToHandler(MESSAGE_ERROR, null); } } - } else { - for (long keyRowId : keyRingRowIds) { - ProviderHelper.deleteSecretKeyRing(activity, keyRowId); - } - } - - dismiss(); - if (notDeleted.size() > 0) { - Bundle data = new Bundle(); - data.putStringArrayList(MESSAGE_NOT_DELETED, notDeleted); - sendMessageToHandler(MESSAGE_OKAY, data); - } else { - sendMessageToHandler(MESSAGE_OKAY, null); } - } - }); + ); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override @@ -198,7 +221,6 @@ public class DeleteKeyDialogFragment extends DialogFragment { if (data != null) { msg.setData(data); } - try { mMessenger.send(msg); } catch (RemoteException e) { @@ -207,4 +229,5 @@ public class DeleteKeyDialogFragment extends DialogFragment { Log.w(Constants.TAG, "Messenger is null!", e); } } -} + +} \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/view_key_delete_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/view_key_delete_fragment.xml new file mode 100644 index 000000000..ef31f7690 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/view_key_delete_fragment.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index 9b4ab0747..6713153bf 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -220,6 +220,8 @@ Do you really want to delete the key \'%s\'?\nYou can\'t undo this! Do you really want to delete all selected keys?\nYou can\'t undo this! Do you really want to delete the SECRET key \'%s\'?\nYou can\'t undo this! + Do you really want to delete the PUBLIC key \'%s\'?\nYou can\'t undo this! + Delete Secret Keys ? Also export secret keys? -- cgit v1.2.3 From 4e6325a14068c173ed4372f60a3fae968b676e51 Mon Sep 17 00:00:00 2001 From: Nikhil Peter Raj Date: Fri, 21 Mar 2014 01:56:33 +0530 Subject: Fix GPL Headers --- .../java/org/sufficientlysecure/keychain/provider/ProviderHelper.java | 2 +- .../main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java | 2 +- .../sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java index 8b6feeafd..2fa903fe2 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2013 Dominik Schürmann + * Copyright (C) 2012-2013 Dominik Schürmann * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 654942db7..9b64def1e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2013 Dominik Schürmann + * Copyright (C) 2012-2013 Dominik Schürmann * Copyright (C) 2010 Thialfihar * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java index 76a69328a..a43debd07 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013-2014 Dominik Schürmann + * Copyright (C) 2013-2014 Dominik Schürmann * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by -- cgit v1.2.3 From 2f0075e043daab6d59e38cdb110960895a06a2b4 Mon Sep 17 00:00:00 2001 From: Daniel Hammann Date: Thu, 20 Mar 2014 22:35:05 +0100 Subject: URI is transported in intents data not extra. --- .../main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java index 1231b6209..28c9c7b28 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java @@ -1002,8 +1002,8 @@ public class EncryptActivity extends DrawerActivity { case Id.request.secret_keys: { if (resultCode == RESULT_OK) { - Bundle bundle = data.getExtras(); - mSecretKeyId = bundle.getLong(SelectSecretKeyActivity.RESULT_EXTRA_MASTER_KEY_ID); + Uri uri_master_key = data.getData(); + mSecretKeyId = Long.valueOf(uri_master_key.getLastPathSegment()); } else { mSecretKeyId = Id.key.none; } -- cgit v1.2.3 From e00eeab1bfcda87e82c5ca51468cb4a5d12ae397 Mon Sep 17 00:00:00 2001 From: Daniel Hammann Date: Thu, 20 Mar 2014 22:41:12 +0100 Subject: UI-Icon-Modifying #429 added hint to text edit, different icons for share and clipboard button --- OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml | 7 ++++--- OpenPGP-Keychain/src/main/res/values/strings.xml | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml index d6a05f0d4..bb947fb5a 100644 --- a/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml @@ -215,7 +215,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="top" - android:inputType="text|textCapSentences|textMultiLine|textLongMessage"/> + android:inputType="text|textCapSentences|textMultiLine|textLongMessage" + android:hint="@string/encrypt_content_edit_text_hint"/> User IDs to sign Reapplying certificates + + Write message here to encrypt… + -- cgit v1.2.3 From 620c67f4412fa56d7edfbfad3ace13f3e409ac5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 21 Mar 2014 10:05:59 +0100 Subject: reformat merge --- .../keychain/ui/SelectSecretKeyLayoutFragment.java | 8 +- .../ui/dialog/DeleteKeyDialogFragment.java | 115 +++++++++++---------- 2 files changed, 64 insertions(+), 59 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java index 2fcfc9650..cbc0f4c5c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java @@ -31,7 +31,9 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.TextView; + import com.beardedhen.androidbootstrap.BootstrapButton; + import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.provider.KeychainContract; @@ -50,7 +52,7 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan private SelectSecretKeyCallback mCallback; private static final int REQUEST_CODE_SELECT_KEY = 8882; - + private static final int LOADER_ID = 0; //The Projection we will retrieve, Master Key ID is for convenience sake, @@ -123,9 +125,9 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan } //For AppSettingsFragment - public void selectKey(long masterKeyId){ + public void selectKey(long masterKeyId) { Uri buildUri = KeychainContract.KeyRings.buildSecretKeyRingsByMasterKeyIdUri(String.valueOf(masterKeyId)); - mReceivedUri=buildUri; + mReceivedUri = buildUri; getActivity().getSupportLoaderManager().restartLoader(LOADER_ID, null, this); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java index a43debd07..3ff88aa2b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java @@ -14,6 +14,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + package org.sufficientlysecure.keychain.ui.dialog; import android.app.AlertDialog; @@ -32,6 +33,7 @@ import android.view.View; import android.widget.CheckBox; import android.widget.LinearLayout; import android.widget.TextView; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; @@ -39,11 +41,12 @@ import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainDatabase; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.util.Log; + import java.util.ArrayList; public class DeleteKeyDialogFragment extends DialogFragment { private static final String ARG_MESSENGER = "messenger"; - private static final String ARG_DELETE_KEY_RING_ROW_IDS = "delete_file"; + private static final String ARG_DELETE_KEY_RING_ROW_IDS = "delete_key_ring_row_ids"; public static final int MESSAGE_OKAY = 1; public static final int MESSAGE_ERROR = 0; @@ -131,74 +134,74 @@ public class DeleteKeyDialogFragment extends DialogFragment { builder.setIcon(R.drawable.ic_dialog_alert_holo_light); builder.setPositiveButton(R.string.btn_delete, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - Uri queryUri = KeychainContract.KeyRings.buildUnifiedKeyRingsUri(); - String[] projection = new String[]{ - KeychainContract.KeyRings.MASTER_KEY_ID, // 0 - KeychainContract.KeyRings.TYPE// 1 - }; - - // make selection with all entries where _ID is one of the given row ids - String selection = KeychainDatabase.Tables.KEY_RINGS + "." + - KeychainContract.KeyRings._ID + " IN("; - String selectionIDs = ""; - for (int i = 0; i < keyRingRowIds.length; i++) { - selectionIDs += "'" + String.valueOf(keyRingRowIds[i]) + "'"; - if (i + 1 < keyRingRowIds.length) - selectionIDs += ","; - } - selection += selectionIDs + ")"; - - Cursor cursor = activity.getContentResolver().query(queryUri, projection, - selection, null, null); - + @Override + public void onClick(DialogInterface dialog, int which) { + Uri queryUri = KeychainContract.KeyRings.buildUnifiedKeyRingsUri(); + String[] projection = new String[]{ + KeychainContract.KeyRings.MASTER_KEY_ID, // 0 + KeychainContract.KeyRings.TYPE// 1 + }; + + // make selection with all entries where _ID is one of the given row ids + String selection = KeychainDatabase.Tables.KEY_RINGS + "." + + KeychainContract.KeyRings._ID + " IN("; + String selectionIDs = ""; + for (int i = 0; i < keyRingRowIds.length; i++) { + selectionIDs += "'" + String.valueOf(keyRingRowIds[i]) + "'"; + if (i + 1 < keyRingRowIds.length) + selectionIDs += ","; + } + selection += selectionIDs + ")"; - long masterKeyId; - long keyType; - boolean isSuccessfullyDeleted; - try { - isSuccessfullyDeleted = false; - while (cursor != null && cursor.moveToNext()) { - masterKeyId = cursor.getLong(0); - keyType = cursor.getLong(1); + Cursor cursor = activity.getContentResolver().query(queryUri, projection, + selection, null, null); - Log.d(Constants.TAG, "masterKeyId: " + masterKeyId - + ", keyType:" + (keyType == KeychainContract.KeyTypes.PUBLIC ? "Public" : "Private")); + long masterKeyId; + long keyType; + boolean isSuccessfullyDeleted; + try { + isSuccessfullyDeleted = false; + while (cursor != null && cursor.moveToNext()) { + masterKeyId = cursor.getLong(0); + keyType = cursor.getLong(1); - if (keyType == KeychainContract.KeyTypes.SECRET) { - if (checkDeleteSecret.isChecked() || isSingleSelection) { - ProviderHelper.deleteUnifiedKeyRing(activity, String.valueOf(masterKeyId), true); - } - } else { - ProviderHelper.deleteUnifiedKeyRing(activity, String.valueOf(masterKeyId), false); - } - } + Log.d(Constants.TAG, "masterKeyId: " + masterKeyId + + ", keyType:" + (keyType == KeychainContract.KeyTypes.PUBLIC ? "Public" : "Private")); - //Check if the selected rows have actually been deleted - cursor = activity.getContentResolver().query(queryUri, projection, selection, null, null); - if (cursor == null || cursor.getCount() == 0 || !checkDeleteSecret.isChecked()) { - isSuccessfullyDeleted = true; - } - } finally { - if (cursor != null) { - cursor.close(); + if (keyType == KeychainContract.KeyTypes.SECRET) { + if (checkDeleteSecret.isChecked() || isSingleSelection) { + ProviderHelper.deleteUnifiedKeyRing(activity, String.valueOf(masterKeyId), true); } - + } else { + ProviderHelper.deleteUnifiedKeyRing(activity, String.valueOf(masterKeyId), false); } + } - dismiss(); + //Check if the selected rows have actually been deleted + cursor = activity.getContentResolver().query(queryUri, projection, selection, null, null); + if (cursor == null || cursor.getCount() == 0 || !checkDeleteSecret.isChecked()) { + isSuccessfullyDeleted = true; + } - if (isSuccessfullyDeleted) { - sendMessageToHandler(MESSAGE_OKAY, null); - } else { - sendMessageToHandler(MESSAGE_ERROR, null); - } + } finally { + if (cursor != null) { + cursor.close(); } } + + dismiss(); + + if (isSuccessfullyDeleted) { + sendMessageToHandler(MESSAGE_OKAY, null); + } else { + sendMessageToHandler(MESSAGE_ERROR, null); + } + } + + } ); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { -- cgit v1.2.3 From 4dac00bb21e01203f3f9ee04cb8d3420784059b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 21 Mar 2014 10:28:26 +0100 Subject: Pull from transifex --- .../src/main/res/raw-de/help_changelog.html | 12 +-- .../src/main/res/raw-de/help_start.html | 4 +- .../src/main/res/raw-zh/help_about.html | 6 +- .../src/main/res/raw-zh/help_nfc_beam.html | 10 +- .../src/main/res/raw-zh/help_start.html | 12 +-- .../src/main/res/raw-zh/nfc_beam_share.html | 8 +- .../src/main/res/values-de/strings.xml | 107 +++++++++++++++------ .../src/main/res/values-el/strings.xml | 1 + .../src/main/res/values-es-rCO/strings.xml | 1 + .../src/main/res/values-es/strings.xml | 46 ++++++++- .../src/main/res/values-fa-rIR/strings.xml | 1 + .../src/main/res/values-fr/strings.xml | 35 ++++++- .../src/main/res/values-it-rIT/strings.xml | 35 ++++++- .../src/main/res/values-ja/strings.xml | 35 +++++-- .../src/main/res/values-nl-rNL/strings.xml | 2 +- .../src/main/res/values-pt-rBR/strings.xml | 1 + .../src/main/res/values-ru/strings.xml | 26 ++++- .../src/main/res/values-sl-rSI/strings.xml | 1 + .../src/main/res/values-tr/strings.xml | 2 +- .../src/main/res/values-uk/strings.xml | 37 ++++++- .../src/main/res/values-zh/strings.xml | 4 +- 21 files changed, 294 insertions(+), 92 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/raw-de/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-de/help_changelog.html index 1197869b5..e414324d0 100644 --- a/OpenPGP-Keychain/src/main/res/raw-de/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-de/help_changelog.html @@ -8,7 +8,7 @@

  • more internal fixes when editing keys (thanks to Ash Hughes)
  • querying keyservers directly from the import screen
  • fix layout and dialog style on Android 2.2-3.0
  • -
  • fix crash on keys with empty user ids
  • +
  • Absturz bei leeren Nutzer IDs behoben
  • fix crash and empty lists when coming back from signing screen
  • Bouncy Castle (cryptography library) updated from 1.47 to 1.50 and build from source
  • fix upload of key from signing screen
  • @@ -38,15 +38,15 @@

    2.0

    • Komlett neu designd
    • -
    • share public keys via qr codes, nfc beam
    • +
    • Öffentliche Schlüssel teilen via QR Code, NFC Beam
    • Schlüssel signieren
    • Schlüssel auf den Server hochladen
    • -
    • fixes import issues
    • +
    • Importprobleme behoben
    • new AIDL API

    1.0.8

      -
    • basic keyserver support
    • +
    • Grundlegende Schlüsselserverunterstützung
    • app2sd
    • mehr Auswahlmöglichkeiten für den Passwortcache: 1, 2, 4, 8, Stunden
    • Übersetzungen: norwegisch (Danke, Sander Danielsen), chinesisch (danke, Zhang Fredrick)
    • @@ -98,8 +98,8 @@

      1.0.0

      • K-9 Mail integration, APG supporting beta build of K-9 Mail
      • -
      • support of more file managers (including ASTRO)
      • -
      • Slovenian translation
      • +
      • Unterstützung von mehr Filemanagern (einschließlich ASTRO)
      • +
      • Slowenische Übersetzung
      • Neue Datenbank, viel schneller, weniger Speicherbedarf
      • defined Intents and content provider for other apps
      • Fehlerbehebungen
      • diff --git a/OpenPGP-Keychain/src/main/res/raw-de/help_start.html b/OpenPGP-Keychain/src/main/res/raw-de/help_start.html index d2735f739..a7949dd64 100644 --- a/OpenPGP-Keychain/src/main/res/raw-de/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-de/help_start.html @@ -1,7 +1,7 @@ -

        Getting started

        +

        Los gehts

        First you need a personal key pair. Create one via the option menus in "My Keys" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

        It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

        @@ -9,7 +9,7 @@

        Ich habe einen Fehler in OpenKeychain gefunden!

        Please report the bug using the issue tracker of OpenKeychain.

        -

        Contribute

        +

        Unterstützen

        If you want to help us developing OpenKeychain by contributing code follow our small guide on Github.

        Übersetzungen

        diff --git a/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html b/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html index 863aeee58..23b904995 100644 --- a/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html @@ -3,14 +3,14 @@

        http://www.openkeychain.org

        OpenKeychain is an OpenPGP implementation for Android.

        -

        License: GPLv3+

        +

        授權:GPLv3+

        Developers OpenKeychain

        • Dominik Schürmann (Lead developer)
        • Ash Hughes (crypto patches)
        • Brian C. Barnes
        • -
        • Bahtiar 'kalkin' Gadimov (UI)
        • +
        • Bahtiar 'kalkin' Gadimov (介面)

        Developers APG 1.x

        @@ -20,7 +20,7 @@
      • Oliver Runge
      • Markus Doits
      -

      Libraries

      +

      函式庫

      • Android Support Library v4 (Apache License v2)
      • diff --git a/OpenPGP-Keychain/src/main/res/raw-zh/help_nfc_beam.html b/OpenPGP-Keychain/src/main/res/raw-zh/help_nfc_beam.html index 88492731c..7a90a794b 100644 --- a/OpenPGP-Keychain/src/main/res/raw-zh/help_nfc_beam.html +++ b/OpenPGP-Keychain/src/main/res/raw-zh/help_nfc_beam.html @@ -1,12 +1,12 @@ -

        How to receive keys

        +

        如何接收金要

          -
        1. Go to your partners contacts and open the contact you want to share.
        2. -
        3. Hold the two devices back to back (they have to be almost touching) and you’ll feel a vibration.
        4. -
        5. After it vibrates you’ll see the content on your partners device turn into a card-like object with Star Trek warp speed-looking animation in the background.
        6. -
        7. Tap the card and the content will then load on the your device.
        8. +
        9. 前往你夥伴裝置上的聯絡人清單,並點選你要分享的聯絡人。
        10. +
        11. 將兩部裝置背對背貼近(幾乎接觸),你會感覺到一股震動。
        12. +
        13. 震動之後你會看見你夥伴的畫面變成卡片狀,並且背景帶有如 Star Trek 般的特效。
        14. +
        15. 輕觸卡片,內容隨即顯示在你的裝置上。
        diff --git a/OpenPGP-Keychain/src/main/res/raw-zh/help_start.html b/OpenPGP-Keychain/src/main/res/raw-zh/help_start.html index 3a6443a2f..104bdd545 100644 --- a/OpenPGP-Keychain/src/main/res/raw-zh/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-zh/help_start.html @@ -1,18 +1,18 @@ -

        Getting started

        -

        First you need a personal key pair. Create one via the option menus in "My Keys" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

        +

        快速上手

        +

        首先你需要屬於你個人的金鑰對,從〝我的金鑰〞選單中建立一個或是使用〝匯入金鑰〞匯入現有的金鑰對。在這之後,你可以下載你朋友的公鑰或者是透過二維條碼或NFC和他交換公鑰。

        It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

        -

        I found a bug in OpenKeychain!

        -

        Please report the bug using the issue tracker of OpenKeychain.

        +

        我在OpenKeychain發現問題!

        +

        請利用 OpenKeychain 項目回報系統回報問題。

        -

        Contribute

        +

        發布

        If you want to help us developing OpenKeychain by contributing code follow our small guide on Github.

        -

        Translations

        +

        翻譯

        Help translating OpenKeychain! Everybody can participate at OpenKeychain on Transifex.

        diff --git a/OpenPGP-Keychain/src/main/res/raw-zh/nfc_beam_share.html b/OpenPGP-Keychain/src/main/res/raw-zh/nfc_beam_share.html index 083e055c7..99ffe4c12 100644 --- a/OpenPGP-Keychain/src/main/res/raw-zh/nfc_beam_share.html +++ b/OpenPGP-Keychain/src/main/res/raw-zh/nfc_beam_share.html @@ -2,10 +2,10 @@
          -
        1. Make sure that NFC is turned on in Settings > More > NFC and make sure that Android Beam is also on in the same section.
        2. -
        3. Hold the two devices back to back (they have to be almost touching) and you'll feel a vibration.
        4. -
        5. After it vibrates you'll see the content on your device turn into a card-like object with Star Trek warp speed-looking animation in the background.
        6. -
        7. Tap the card and the content will then load on the other person’s device.
        8. +
        9. 確定在 "設定" > "更多內容…" > "NFC" 裡面已經開啟 NFC 和 Android Beam。
        10. +
        11. 將兩部裝置背對背貼近(幾乎接觸),你會感覺到一股震動。
        12. +
        13. 震動之後你會看見你夥伴的畫面變成卡片狀,並且背景帶有如 Star Trek 般的特效。
        14. +
        15. 輕觸卡片,內容隨即顯示在你的裝置上。
        diff --git a/OpenPGP-Keychain/src/main/res/values-de/strings.xml b/OpenPGP-Keychain/src/main/res/values-de/strings.xml index 1e0fda3bc..493b81314 100644 --- a/OpenPGP-Keychain/src/main/res/values-de/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-de/strings.xml @@ -13,8 +13,10 @@ Einstellungen Registrierte Anwendungen Schlüsselserver + Passphrase ändern Passwort setzen E-Mail senden... + Datei senden In eine Datei verschlüsseln In eine Datei entschlüsseln Schlüssel importieren @@ -62,6 +64,8 @@ Zwischenablage Teilen mit… Schlüssel nachschlagen + Erweiterte Einstellungen anzeigen + Erweiterte Einstellungen verbergen Einstellungen Hilfe @@ -70,15 +74,17 @@ Importieren NFC Alle Schlüssel exportieren + Alle geheimen Schlüssel exportieren In Datei exportieren Schlüssel löschen Schlüssel erstellen Schlüssel erstellen (Experte) Suchen - Schlüsselserver + Schlüsselserver + Schlüsselserver… Von einem Schlüsselserver aktualisieren Auf Schlüsselserver hochladen - Teilen + Teilen… Teile Fingerabdruck… Teile gesamten Schlüssel… mit… @@ -91,6 +97,7 @@ Beam-Einstellungen Abbrechen Verschlüsseln nach… + Alles auswählen Signieren Nachricht @@ -103,6 +110,7 @@ Empfänger Nach Verschlüsselung löschen Nach Entschlüsselung löschen + Nach dem Verschlüsseln teilen Verschlüsselungsalgorithmus Hash-Algorithmus Öffentlicher Schlüssel @@ -121,9 +129,12 @@ Name Kommentar E-Mail + Benutzer ID unterschreiben + Email unterschreiben Schlüssel nach Beglaubigung auf ausgewählten Schlüsselserver hochladen Fingerabdruck Auswählen + Ablaufdatum festsetzen %d ausgewählt %d ausgewählt @@ -131,11 +142,17 @@ <kein Name> <keine> <kein Schlüssel> + <Keine E-Mail> kann verschlüsseln kann signieren abgelaufen zurückgezogen + Benutzer ID + + 1 Kontakt + %d Kontakte + %d Schlüsselserver %d Schlüsselserver @@ -191,6 +208,7 @@ Soll der Schlüssel \'%s\' wirklich gelöscht werden?\nDies kann nicht rückgängig gemacht werden! Möchtest du wirklich alle ausgewählten Schlüssel löschen?\nDies kann nicht rückgängig gemacht werden! Soll der PRIVATE Schlüssel \'%s\' wirklich gelöscht werden?\nDies kann nicht rückgängig gemacht werden! + Private Schlüssel auch exportieren %d Schlüssel erfolgreich hinzugefügt %d Schlüssel erfolgreich hinzugefügt @@ -212,6 +230,7 @@ %d Schlüssel erfolgreich exportiert. Keine Schlüssel exportiert. Beachte: nur Unterschlüssel unterstützen ElGamal. Für ElGamal wird die am nächsten liegende Schlüssellänge von 1536, 2048, 3072, 4096 oder 8192 verwendet. + Beachte: RSA-Schlüssel mit einer Schlüssellänge von 1024-Bits oder weniger werden als unsicher angesehen und können daher nicht für neue Schlüssel erstellt werden. Schlüssel %08X konnte nicht gefunden werden. %d Schlüssel gefunden. @@ -243,6 +262,7 @@ Der Hauptschlüssel kann kein ElGamal Schlüssel sein Unbekannte Auswahl für Algorithmus ein Name muss angegeben werden + keine E-Mail gefunden eine E-Mail-Adresse muss angegeben werden Mindestens eine Benutzer-ID wird benötigt Hauptbenutzer-ID darf nicht leer sein @@ -265,48 +285,59 @@ Ablaufdatum muss später sein als das Erstellungsdatum Sie können diesen Kontakt nicht löschen, denn es ist ihr eigener. Sie können folgende Kontakte nicht löschen, denn sie gehören Ihnen selbst:\n%s + Unzureichende Serveranfrage Keyserveranfrage fehlgeschlagen + Zu viele Antworten + Datei ist leer + Ein allgemeiner Fehler trat auf, bitte schreiben Sie einen neuen Bugreport für OpenKeychain. Bitte lösche ihn unter \'Meine Schlüssel\'! Bitte lösche sie unter \'Meine Schlüssel\'! + + Ein Teil der geladenen Datei ist ein gültiges OpenPGP Objekt aber kein OpenPGP Schlüssel + Teile der geladenen Dateien sind gültige OpenPGP Objekte aber keine OpenPGP Schlüssel + - fertig. + Erledigt Abbrechen - speichern... - importieren... - exportieren... - erstelle Schlüssel, dies kann bis zu 3 Minuten dauern... - erstelle Schlüssel... - Hauptschlüssel wird vorbereitet... - Hauptschlüssel wird beglaubigt... - erstelle Hauptring... - füge Unterschlüssel hinzu... - Schlüssel wird gespeichert... + speichern… + importieren… + exportieren… + erstelle Schlüssel… + Hauptschlüssel wird vorbereitet… + Hauptschlüssel wird beglaubigt… + erstelle Hauptring… + füge Unterschlüssel hinzu… + Schlüssel wird gespeichert… Schlüssel wird exportiert… Schlüssel werden exportiert… - extrahiere Signaturschlüssel... - extrahiere Schlüssel... - Datenstrom wird vorbereitet... - Daten werden verschlüsselt... - Daten werden entschlüsselt... - Signatur wird vorbereitet... - Signatur wird erstellt... - Signatur wird verarbeitet... - Signatur wird verifiziert... - signiere... - Daten werden gelesen... - Schlüssel wird gesucht... - Daten werden entpackt... - Integrität wird überprüft... - \'%s\' wird sicher gelöscht... - Anfrage wird gestellt... + + erstelle Schlüssel, das kann bis zu 3 Minuten dauern… + erstelle Schlüssel, das kann bis zu 3 Minuten dauern… + + extrahiere Signaturschlüssel… + extrahiere Schlüssel… + Datenstrom wird vorbereitet… + Daten werden verschlüsselt… + Daten werden entschlüsselt… + Signatur wird vorbereitet… + Signatur wird erstellt… + Signatur wird verarbeitet… + Signatur wird verifiziert… + signiere… + Daten werden gelesen… + Schlüssel wird gesucht… + Daten werden entpackt… + Integrität wird überprüft… + \'%s\' wird sicher gelöscht… + Anfrage wird gestellt… Öffentliche Schlüssel suchen Private Schlüssel suchen - Teile Schlüssel über... + Teile Schlüssel über… 512 1024 @@ -317,6 +348,7 @@ sehr langsam Start + FAQ NFC-Beam Changelog Über @@ -338,6 +370,10 @@ Hilfe Füge den Schlüssel aus der Zwischenablage ein + Datei mit OpenKeychain entschlüsseln + Schlüssel mit OpenKeychain importieren + Mit OpenKeychain verschlüsseln + Mit OpenKeychain entschlüsseln Keine registrierten Anwendungen vorhanden!\n\nAnwendungen von Dritten können Zugriff auf OpenKeychain erbitten. Nachdem Zugriff gewährt wurde, werden diese hier aufgelistet. Erweiterte Einstellungen anzeigen @@ -356,7 +392,7 @@ Für diese Benutzer-IDs wurden keine öffentlichen Schlüssel gefunden: Für diese Benutzer-IDs existieren mehrere öffentliche Schlüssel: Bitte die Liste der Empfänger überprüfen! - Signaturüberprüfung fehlgeschlagen! Haben Sie diese App von einer anderen Quelle installiert? Wenn Sie eine Attacke ausschließen können, sollten Sie die Registrierung der App in OpenKeychain widerrufen und die App erneut registrieren. + Signaturüberprüfung fehlgeschlagen! Haben Sie diese App von einer anderen Quelle installiert? Wenn Sie eine Attacke ausschliessen können, sollten Sie die Registrierung der App in OpenKeychain widerrufen und die App erneut registrieren. Über QR Code teilen Mit \'Weiter\' durch alle QR-Codes gehen und diese nacheinander scannen. @@ -374,6 +410,7 @@ deinen eigenen Schlüssel erstellst existierende Schlüssel importierst. + Diesen Schlüssel bearbeiten Für diesen Kontakt verschlüsseln Schlüssel dieses Kontakts beglaubigen Info @@ -387,4 +424,12 @@ Registrierte Anwendungen Menu öffnen Menu schließen + Bearbeiten + Meine Schlüssel + Geheime Schlüssel + verfügbar + nicht verfügbar + Benutzer-IDs, die beglaubigt werden sollen + Wiederhinzufügen der Zertifikate + diff --git a/OpenPGP-Keychain/src/main/res/values-el/strings.xml b/OpenPGP-Keychain/src/main/res/values-el/strings.xml index 84b39c221..094dfe28a 100644 --- a/OpenPGP-Keychain/src/main/res/values-el/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-el/strings.xml @@ -50,4 +50,5 @@ + diff --git a/OpenPGP-Keychain/src/main/res/values-es-rCO/strings.xml b/OpenPGP-Keychain/src/main/res/values-es-rCO/strings.xml index 41dc629aa..ce365b776 100644 --- a/OpenPGP-Keychain/src/main/res/values-es-rCO/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-es-rCO/strings.xml @@ -97,4 +97,5 @@ + diff --git a/OpenPGP-Keychain/src/main/res/values-es/strings.xml b/OpenPGP-Keychain/src/main/res/values-es/strings.xml index c643a3cd8..85c77b0da 100644 --- a/OpenPGP-Keychain/src/main/res/values-es/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-es/strings.xml @@ -16,6 +16,7 @@ Cambiar frase de contraseña Establecer frase de contraseña Enviar email... + Enviar archivo... Cifrar hacia archivo Descifrar hacia archivo Importar claves @@ -63,6 +64,8 @@ Portapapeles Compartir con... Buscar clave + Mostrar ajustes avanzados + Ocultar ajustes avanzados Ajustes Ayuda @@ -71,15 +74,17 @@ Importar Importar desde NFC Exportar todas las claves + Exportar todas las claves secretas Exportar hacia archivo Borrar clave Crear clave Crear clave (experto) Buscar - Importar desde servidor de claves + Servidor de claves... + Servidor de claves... Actualizar desde servidor de claves Cargar al servidor de claves - Compartir + Compartir... Compartir la huella digital... Compartir la clave completa... con... @@ -105,6 +110,7 @@ Destinatarios Borrar después del cifrado Borrar después del descifrado + Compartir después del cifrado Algoritmo de cifrado Algoritmo de Hash Clave pública @@ -123,6 +129,8 @@ Nombre Comentario Email + Firmar Id de usuario + Firmar correo Cargar clave al servidor de claves seleccionado después de la certificación Huella digital Seleccionar @@ -134,11 +142,17 @@ <sin nombre> <ninguna> <sin clave> + <No hay un email> se puede cifrar se puede firmar caducado revocado + ID de usuario + + 1 contacto + %d contactos + %d servidor de claves %d servidores de claves @@ -194,6 +208,7 @@ ¿Quieres realmente borrar la clave \'%s\'?\n¡No podrás deshacerlo! ¿Quieres realmente borrar todas las claves seleccionadas?\n¡No podrás deshacerlo! ¿Quieres realmente borrar la clave SECRETA \'%s\'?\n¡No podrás deshacerlo! + ¿Exportar también las claves secretas? %d clave añadida satisfactoriamente %d claves añadidas satisfactoriamente @@ -215,6 +230,7 @@ %d claves exportadas satisfactoriamente. No se han exportado claves. Nota: solo las subclaves son compatibles con ElGamal, y para ElGamal debe usarse el tamaño de clave más próximo de 1536, 2048, 3072, 4096, o 8192. + Nota: generar una clave RSA de longitud 1024-bit o menos está considerado inseguro y desactivado para generar nuevas claves. No se puede encontrar la clave %08X. Se ha encontrado %d clave. @@ -246,6 +262,7 @@ la clave maestra no puede ser una clave ElGamal elegido algoritmo desconocido necesitas determinar un nombre + no se ha encontrado un email tienes que determinar una dirección de email necesitas al menos una ID de usuario la ID del usuario principal no puede estar vacía @@ -271,17 +288,22 @@ Consulta al servidor insuficiente La consulta al servidor de claves ha fallado Demasiadas respuestas + El archivo está vacio + Ha ocurrido un error genérico, por favor, informa de este bug a OpenKeychain Por favor, bórralo desde la pantalla \'Mis claves\'! Por favor, bórralos desde la pantalla \'Mis claves\'! + + parte del archivo cargado es un objeto OpenPGP válido pero no una clave OpenPGP + partes del archivo cargado son objetos OpenPGP válidos pero no claves OpenPGP + - hecho. - cancelar + Hecho. + Cancelar guardando... importando... exportando... - generando la clave, esto puede tardar más de 3 minutos... construyendo la clave... preparando la clave maestra... certificando la clave maestra... @@ -292,6 +314,10 @@ exportando clave... exportando claves... + + generando clave, esto puede tardar más de 3 minutos... + generando claves, esto puede tardar más de 3 minutos... + extrayendo la clave de firma... extrayendo la clave... preparando las transmisiones... @@ -322,6 +348,7 @@ muy lento Comenzar + FAQ NFC Beam Registro de cambios A cerca de @@ -383,6 +410,7 @@ crear tu propia clave importar claves + Editar esta clave Cifrar hacia este contacto Certificar la clave de este contacto Información @@ -396,4 +424,12 @@ Aplicaciones registradas Abrir el Navigation Drawer Cerrar el Navigation Drawer + Editar + Mis claves + Claves secretas + disponible + no disponible + IDs de usuario para firmar + Nueva aplicación de certificados + diff --git a/OpenPGP-Keychain/src/main/res/values-fa-rIR/strings.xml b/OpenPGP-Keychain/src/main/res/values-fa-rIR/strings.xml index 6bb115049..3d00a143f 100644 --- a/OpenPGP-Keychain/src/main/res/values-fa-rIR/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-fa-rIR/strings.xml @@ -23,4 +23,5 @@ + diff --git a/OpenPGP-Keychain/src/main/res/values-fr/strings.xml b/OpenPGP-Keychain/src/main/res/values-fr/strings.xml index d99bbcd7c..4f92f7855 100644 --- a/OpenPGP-Keychain/src/main/res/values-fr/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-fr/strings.xml @@ -64,6 +64,8 @@ Presse-papiers Partager avec... Rechercher la clef + Afficher les paramètres avancés + Masquer les paramètres avancés Paramètres Aide @@ -72,15 +74,17 @@ Importer Importer avec NFC Exporter toutes les clefs + Exporter toutes les clefs secrètes Exporter vers un fichier Supprimer la clef Créer une clef Créer une clef (expert) Rechercher - Importer depuis le serveur de clefs + Serveur de clefs + Serveur de clefs... Mettre à jour depuis le serveur de clefs Téléverser vers le serveur de clefs - Partager + Partager... Partager l\'empreinte... Partager la clef entière... avec... @@ -138,12 +142,17 @@ <aucun nom> <aucune> <pas de clef> + <aucun courriel> peut chiffrer peut signer expiré révoquée ID utilisateur + + 1 contact + %d contacts + %d serveur de clefs %d serveurs de clefs @@ -199,6 +208,7 @@ Voulez-vous vraiment supprimer la clef %s ?\nVous ne pourrez pas la restituer ! Voulez-vous vraiment supprimer toutes les clefs choisies ?\nCeci est irréversible ! Voulez-vous vraiment supprimer la clef SECRÈTE %s ?\nVous ne pourrez pas la restituer ! + Exporter aussi les clefs secrètes? %d clef ajoutée avec succès %d clefs ajoutées avec succès @@ -220,6 +230,7 @@ %d clefs exportées avec succès. Aucune clef exportée. Note : seules les sous-clefs prennent en charge ElGamal, et pour ElGamal la taille de clef la plus proche de 1 536, 2 048, 3 072, 4 096 ou 8 192 sera utilisée. + Note : générer des clefs RSA d\'une longueur de 1024 bits ou moins est considéré non sécuritaire et est désactivé pour la génération de nouvelles clefs. Clef %08X introuvable. %d clef trouvée. @@ -251,6 +262,7 @@ la clef maîtresse ne peut être une clef ElGama choix d\'algorhitme inconnu vous devez spécifier un nom + aucun courriel trouvé vous devez spécifier une adresse courriel vous avez besoin d\'au moins un ID utilisateur l\'ID utilisateur principal ne doit pas être vide @@ -287,12 +299,11 @@ certaines parties du fichier chargé sont des objets OpenPGP valides mais pas des clefs OpenPGP - fait. - annuler + Terminé. + Annuler sauvegarde... importation... exportation... - génération de la clef, ceci peut prendre jusqu\'à 3 minutes... assemblage de la clef... préparation de la clef maîtresse... certification de la clef maîtresse... @@ -303,6 +314,10 @@ exportation de la clef... exportation des clefs... + + génération de la clef, ceci peut prendre jusqu\'à 3 min... + génération des clefs, ceci peut prendre jusqu\'à 3 min... + extraction de la clef de signature... extraction de la clef... préparation des flux... @@ -333,6 +348,7 @@ très lent Commencer + FAQ NFC Beam Journal des changements À propos de @@ -394,6 +410,7 @@ créer votre propre clef Importer des clefs. + Modifier cette clef Chiffrer vers ce contact Certifier la clef de ce contact Infos @@ -407,4 +424,12 @@ Applis enregistrées Ouvrir le tiroir de navigation Fermer le tiroir de navigation + Modifier + Mes clefs + Clef secrète + disponible + non disponible + ID utilisateur pour signer + Nouvel application des certificats + diff --git a/OpenPGP-Keychain/src/main/res/values-it-rIT/strings.xml b/OpenPGP-Keychain/src/main/res/values-it-rIT/strings.xml index f9e7074da..b125de448 100644 --- a/OpenPGP-Keychain/src/main/res/values-it-rIT/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-it-rIT/strings.xml @@ -64,6 +64,8 @@ Appunti Condividi con... Chiave di ricerca + Mostra impostazioni avanzate + Nascondi impostazioni avanzate Impostazioni Aiuto @@ -72,15 +74,17 @@ Importa Importa tramite NFC Esporta tutte le chiavi + Esporta tutte le chiavi segrete Esporta su un file Cancella chiave Crea chiave Crea chiave (esperto) Cerca - Importa dal server delle chiavi + Server delle Chiavi + Server delle Chiavi... Aggiorna dal server delle chiavi Carica chiave nel server - Condividi + Condividi... Condivi impronta... Condividi intera chiave... con.. @@ -138,12 +142,17 @@ <nessun nome> <nessuno> <nessuna chiave> + <Nessuna Email> puo\'; codificare puo\' firmare scaduto revocato ID Utente + + 1 contatto + %d contatti + %d server delle chiavi %d server delle chiavi @@ -199,6 +208,7 @@ Vuoi veramente eliminare la chiave \'%s\'?\nNon potrai annullare! Vuoi veramente eliminare le chiavi selezionate?\nNon potrai annullare! Vuoi veramente eliminare la chiave PRIVATA \'%s\'?\nNon potrai annullare! + Esportare anche le chiavi segrete? %d chiave aggiunta correttamente %d chiavi aggiunte correttamente @@ -220,6 +230,7 @@ %d chiavi esportate correttamente. Nessuna chiave esportata. Nota: solo le sottochiavi supportano ElGamal, e per ElGamal verra\' usata la grandezza chiave piu\' vicina a 1536, 2048, 3072, 4096 o 8192. + Nota: la generazione di chiavi RSA con lunghezza pari a 1024 bit o inferiore è considerata non sicura ed è disabilitata per la generazione di nuove chiavi. Impossibile trovare la chiave %08X. Trovata %d chiave. @@ -251,6 +262,7 @@ La chiave principale non puo\' essere ElGamal opzione algoritmo sconosciuta devi specificare un nome + Nessuna email trovata devi specificare un indirizzo email necessario almeno un id utente id utente principale non puo\' essere vuoto @@ -287,12 +299,11 @@ parti del file caricato sono oggetti OpenPGP validi, ma non chavi OpenPGP - fatto. - cancella + Fatto. + Annulla salvataggio... importazione... esportazione... - generazione chiave, richiede fino a 3 minuti... fabbricazione chiave... preparazione chiave principale... certificazione chiave principale... @@ -303,6 +314,10 @@ esportazione chiave... esportazione chiavi... + + generazione chiave, sono necessari fino a 3 minuti... + generazione chiavi, sono necessari fino a 3 minuti... + estrazione chiavi di firma... estrazione chiave... preparazione flussi... @@ -333,6 +348,7 @@ molto lento Inizia + FAQ NFC Beam Novita\' Info @@ -394,6 +410,7 @@ creazione della tua chiave importazione chiavi. + Modifica chiave Codifica a questo contatto Certifica la chiave di questo contatto Info @@ -407,4 +424,12 @@ App Registrate Apri drawer di navigazione Chiudi drawer di navigazione + Modifica + Le Mie Chiavi + Chiave Segreta + disponibile + non disponibile + ID Utente da firmare + Riapplicazione certificati + diff --git a/OpenPGP-Keychain/src/main/res/values-ja/strings.xml b/OpenPGP-Keychain/src/main/res/values-ja/strings.xml index e5ee5ecc0..97f0c6eed 100644 --- a/OpenPGP-Keychain/src/main/res/values-ja/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-ja/strings.xml @@ -62,8 +62,10 @@ 戻る クリップボード - 共有... + ...で共有 鍵検出 + 拡張設定を表示 + 拡張設定を隠す 設定 ヘルプ @@ -72,15 +74,17 @@ インポート NFCからインポート すべての鍵のエクスポート + すべての秘密鍵のエクスポート ファイルへのエクスポート 鍵の削除 鍵の生成 鍵の生成(上級) 検索 - 鍵サーバからのインポート + 鍵サーバ + 鍵サーバ... 鍵サーバからの更新 鍵サーバへのアップロード - 共有 + 共有... 指紋の共有... すべての鍵の共有... ...(指紋) @@ -137,12 +141,16 @@ <名前なし> <無し> <鍵無し> + <メールなし> 暗号化可能 署名可能 期限切れ 破棄 ユーザーID + + %d個の連絡先 + %d の鍵サーバ @@ -197,6 +205,7 @@ 鍵\'%s\'を本当に削除してもよいですか?\nこれは元に戻せません! 選択したすべての鍵を本当に削除してよいですか?\nこれは元に戻せません。 秘密鍵\'%s\'を本当に削除してもよいですか?\nこれは元に戻せません! + 秘密鍵もエクスポートしますか? %d の鍵を追加しました @@ -214,6 +223,7 @@ %d の鍵をエクスポートしました。 鍵をエクスポートしていません。 備考: 副鍵として ElGamalだけがサポートされ, ElGamal は鍵サイズとして1536, 2048, 3072, 4096, 8192 だけが使えます。 + 付記: 長さ1024bitかそれ以下で生成されたRSA鍵は安全とはみなされず、新な鍵の生成は無効にされています。 鍵 %08X は見付かりませんでした。 %d の鍵を発見。 @@ -243,6 +253,7 @@ 主鍵を ElGamal にすることはできません 未知のアルゴリズムを選択しています 名前を特定する必要があります + メールが見付かりません Eメールアドレスを特定する必要があります 最低でも1つのユーザIDが必要です 主ユーザIDは空にすることはできません @@ -282,7 +293,6 @@ 保存... インポート... エクスポート... - 鍵の生成、3分ほどかかります... 鍵の構築中... 主鍵の準備中... 主鍵の検証中... @@ -292,6 +302,9 @@ 鍵のエクスポート... + + 鍵の生成中、最大3分ほどかかります... + 署名鍵の取り出し中... 鍵の取り出し中... ストリームの準備中... @@ -311,7 +324,7 @@ 公開鍵の検索 秘密鍵の検索 - 鍵の共有... + ...で鍵の共有 512 1024 @@ -322,6 +335,7 @@ とても遅い 開始 + FAQ NFC Beam Changelog これについて @@ -349,7 +363,7 @@ 登録されていないアプリケーション!\n\nサードパーティアプリケーションはOpenKeychainにアクセスを要求できます。アクセスを与えた後、それらはここにリストされます。 拡張設定を表示 - 拡張設定を非表示 + 拡張設定を隠す 鍵が選択されていない 鍵の選択 保存 @@ -381,6 +395,7 @@ あなた所有の鍵を作る 鍵のインポート。 + この鍵の編集 この連絡先を暗号化 この連絡先の鍵を検証 情報 @@ -394,4 +409,12 @@ 登録済みのアプリ ナビゲーションドロワーを開く ナビゲーションドロワーを閉める + 編集 + 自分の鍵 + 秘密鍵 + 存在する + 存在しない + 署名に使うユーザーID + 検証を再適用する + diff --git a/OpenPGP-Keychain/src/main/res/values-nl-rNL/strings.xml b/OpenPGP-Keychain/src/main/res/values-nl-rNL/strings.xml index de6ba554d..a7f674ea0 100644 --- a/OpenPGP-Keychain/src/main/res/values-nl-rNL/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-nl-rNL/strings.xml @@ -170,7 +170,6 @@ Uw apparaat biedt geen ondersteuning voor NFC Niets te importeren - gereed. opslaan... importeren... exporteren... @@ -236,4 +235,5 @@ + diff --git a/OpenPGP-Keychain/src/main/res/values-pt-rBR/strings.xml b/OpenPGP-Keychain/src/main/res/values-pt-rBR/strings.xml index 6bb115049..3d00a143f 100644 --- a/OpenPGP-Keychain/src/main/res/values-pt-rBR/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-pt-rBR/strings.xml @@ -23,4 +23,5 @@ + diff --git a/OpenPGP-Keychain/src/main/res/values-ru/strings.xml b/OpenPGP-Keychain/src/main/res/values-ru/strings.xml index 22f676ccb..55e778bee 100644 --- a/OpenPGP-Keychain/src/main/res/values-ru/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-ru/strings.xml @@ -16,6 +16,7 @@ Изменить пароль Задать пароль Отправить... + Отправить файл Зашифровать в файл Расшифровать в файл Импорт ключей @@ -63,6 +64,8 @@ Буфер обмена Поделиться... Найти ключ + Показать расширенные настройки + Скрыть расширенные настройки Настройки Помощь @@ -76,10 +79,8 @@ Создать ключ Создать ключ (эксперт) Поиск - Импорт с сервера ключей Обновить с сервера ключей Загрузить на сервер ключей - Отправить... Отправить отпечаток... Отправить ключ... Отправить @@ -105,6 +106,7 @@ Получатели Удалить после шифрования Удалить после расшифровки + Отправить после шифрования Алгоритм шифрования Hash-алгоритм Публичный ключ @@ -135,6 +137,7 @@ <нет имени> <нет> <нет ключа> + <нет email> шифрование подпись @@ -254,6 +257,7 @@ ключ ElGamal не может быть основным выбран неизвестный алгоритм необходимо указать имя + email не найден необходимо указать email необходим хотя бы один id пользователя основная запись пользователя не может быть пустой @@ -279,18 +283,24 @@ Ограничение запроса сервера Сбой запроса сервера ключей Слишком много ответов + Файл пуст + Выявлена ошибка. Пожалуйста, сообщите о ней разработчику. Пожалуйста, удалите его в разделе \'Мои ключи\'! Пожалуйста, удалите их в разделе \'Мои ключи\'! Пожалуйста, удалите их в разделе \'Мои ключи\'! + + часть загруженного файла содержит данные OpenPGP, но это не ключ + части загруженного файла содержат данные OpenPGP, но это не ключ + части загруженного файла содержат данные OpenPGP, но это не ключ + - готово. - отмена + Готово. + Отмена сохранение... импорт... экспорт... - создание ключа. это может занять до 3 минут... создание ключа... подготовка основного ключа... сертификация основного ключа... @@ -302,6 +312,11 @@ экспорт ключей... экспорт ключей... + + создание ключа. это может занять до 3 минут... + создание ключей. это может занять до 3 минут... + создание ключей. это может занять до 3 минут... + извлечение подписи ключа... извлечение ключа... подготовка к передаче... @@ -408,4 +423,5 @@ Связанные приложения Открыть панель навигации Закрыть панель навигации + diff --git a/OpenPGP-Keychain/src/main/res/values-sl-rSI/strings.xml b/OpenPGP-Keychain/src/main/res/values-sl-rSI/strings.xml index 6bb115049..3d00a143f 100644 --- a/OpenPGP-Keychain/src/main/res/values-sl-rSI/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-sl-rSI/strings.xml @@ -23,4 +23,5 @@ + diff --git a/OpenPGP-Keychain/src/main/res/values-tr/strings.xml b/OpenPGP-Keychain/src/main/res/values-tr/strings.xml index 5bb5225b5..174d8538f 100644 --- a/OpenPGP-Keychain/src/main/res/values-tr/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-tr/strings.xml @@ -95,7 +95,6 @@ anahtar uzunluğu en az 512bit olmalı bozuk veri - bitti. kaydediliyor... alıyor... veriyor... @@ -135,4 +134,5 @@ + diff --git a/OpenPGP-Keychain/src/main/res/values-uk/strings.xml b/OpenPGP-Keychain/src/main/res/values-uk/strings.xml index 7ccb661d3..58ac643af 100644 --- a/OpenPGP-Keychain/src/main/res/values-uk/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-uk/strings.xml @@ -64,6 +64,8 @@ Буфер обміну Поділитися через… Шукати ключ + Показати додаткові налаштування + Приховати додаткові налаштування Параметри Довідка @@ -72,15 +74,17 @@ Імпорт Імпорт з NFC Експортувати усі ключі + Експортувати усі секретні ключі Експорт до файлу Вилучити ключ Створити ключ Створити ключ (експерт) Пошук - Імпорт з сервера ключів + Сервер ключів + Сервер ключів… Оновити з сервера ключів Завантажити на сервер ключів - Поділитися + Поділитися… Поділитися відбитком… Поділитися цілим ключем… з… @@ -139,12 +143,18 @@ <без імені> <жоден> <без ключа> + <Немає ел. пошти> можна зашифрувати можна підписати закінчився скасовано ІД користувача + + 1 контакт + %d контакти + %d контактів + %d сервер ключів %d сервери ключів @@ -201,6 +211,7 @@ Ви справді хочете вилучити ключ \'%s\'?\nВи не зможете це відмінити! Ви справді хочете вилучити усі вибрані ключі?\nВи не зможете це відмінити! Ви справді хочете вилучити секретний ключ \'%s\'?\nВи не зможете це відмінити! + Також експортувати секретні ключі? Успішно додано %d ключ Успішно додано %d ключі @@ -226,6 +237,7 @@ Успішно експортовано %d ключів. Жодного ключа не експортовано. Примітка: тільки підключі підтримують ElGamal, а для ElGamal буде використаний найближчий розмір ключа з 1536, 2048, 3072, 4096, або 8192. + Примітка: генерація ключа RSA з довжиною 1024 біти і менше вважається небезпечною і вона вимкнена для генерації нових ключів. Не можливо знайти ключ %08X. Знайдено %d ключ. @@ -259,6 +271,7 @@ основний ключ не може бути ключем ElGamal вибір невідомого алгоритму вам потрібно вказати назву + жодного листа не знайдено вам потрібно вказати електронну адресу потрібний хоча б один ІД користувача ІД основного користувача не має бути порожнім @@ -297,12 +310,11 @@ частин завантаженого файлу є вірним об\'єктом OpenPGP, але не ключем OpenPGP - готово. - cкасувати + Готово. + Скасувати збереження… імпортується… експортується… - генерується ключ, вона може тривати до 3 хвилин… будується ключ… підготовка основного ключа… сертифікація основного ключа… @@ -314,6 +326,11 @@ експортуються ключі… експортуються ключі… + + генерується ключ, це може тривати до 3 хвилини + генеруються ключі, це може тривати до 3 хвилини + генеруються ключі, це може тривати до 3 хвилини + видобування ключа підпису… видобувається ключа… підготовка потоків… @@ -344,6 +361,7 @@ дуже повільне Початок + ЧАП NFC промінь Журнал змін Про @@ -407,6 +425,7 @@ створюється ваш власний ключ імпортуюся ключі. + Редагувати цей ключ Зашифрувати у цей контакт Сертифікувати ключ цього контакту Інформація @@ -420,4 +439,12 @@ Зареєстровані програми Відкрити панель навігації Закрити панель навігації + Редагувати + Мої ключі + Секретний ключ + доступний + недоступний + ІД користувача для реєстрації + Перезастосування сертифікатів + diff --git a/OpenPGP-Keychain/src/main/res/values-zh/strings.xml b/OpenPGP-Keychain/src/main/res/values-zh/strings.xml index 80413d589..244e7e57b 100644 --- a/OpenPGP-Keychain/src/main/res/values-zh/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-zh/strings.xml @@ -1,6 +1,7 @@ + 聯絡人 选择公钥 选择私钥 加密 @@ -50,7 +51,6 @@ 创建密钥 创建密钥(专家) 搜索 - 分享 复制到剪贴板 签署密钥 取消 @@ -135,7 +135,6 @@ 损坏的数据 错误的密语 - 完成。 保存... 导入中... 导出中... @@ -187,4 +186,5 @@ 解密 导入密钥 我的密钥 + -- cgit v1.2.3 From c85a0e9cca4af8f42fa2522a8bf808ea6538be96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 21 Mar 2014 10:28:34 +0100 Subject: Pull from transifex --- .../src/main/res/raw-ach/help_about.html | 45 +++ .../src/main/res/raw-ach/help_changelog.html | 108 +++++ .../src/main/res/raw-ach/help_nfc_beam.html | 12 + .../src/main/res/raw-ach/help_start.html | 19 + .../src/main/res/raw-ach/nfc_beam_share.html | 11 + .../src/main/res/raw-cs-rCZ/help_about.html | 45 +++ .../src/main/res/raw-cs-rCZ/help_changelog.html | 108 +++++ .../src/main/res/raw-cs-rCZ/help_nfc_beam.html | 12 + .../src/main/res/raw-cs-rCZ/help_start.html | 19 + .../src/main/res/raw-cs-rCZ/nfc_beam_share.html | 11 + .../src/main/res/raw-pl/help_about.html | 45 +++ .../src/main/res/raw-pl/help_changelog.html | 108 +++++ .../src/main/res/raw-pl/help_nfc_beam.html | 12 + .../src/main/res/raw-pl/help_start.html | 19 + .../src/main/res/raw-pl/nfc_beam_share.html | 11 + .../src/main/res/raw-zh-rTW/help_about.html | 45 +++ .../src/main/res/raw-zh-rTW/help_changelog.html | 108 +++++ .../src/main/res/raw-zh-rTW/help_nfc_beam.html | 12 + .../src/main/res/raw-zh-rTW/help_start.html | 19 + .../src/main/res/raw-zh-rTW/nfc_beam_share.html | 11 + .../src/main/res/values-ach/strings.xml | 27 ++ .../src/main/res/values-cs-rCZ/strings.xml | 27 ++ .../src/main/res/values-pl/strings.xml | 450 +++++++++++++++++++++ .../src/main/res/values-zh-rTW/strings.xml | 27 ++ 24 files changed, 1311 insertions(+) create mode 100644 OpenPGP-Keychain/src/main/res/raw-ach/help_about.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-ach/help_changelog.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-ach/help_nfc_beam.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-ach/help_start.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-ach/nfc_beam_share.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_changelog.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_nfc_beam.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_start.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-cs-rCZ/nfc_beam_share.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-pl/help_about.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-pl/help_changelog.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-pl/help_nfc_beam.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-pl/help_start.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-pl/nfc_beam_share.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_changelog.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_nfc_beam.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_start.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-zh-rTW/nfc_beam_share.html create mode 100644 OpenPGP-Keychain/src/main/res/values-ach/strings.xml create mode 100644 OpenPGP-Keychain/src/main/res/values-cs-rCZ/strings.xml create mode 100644 OpenPGP-Keychain/src/main/res/values-pl/strings.xml create mode 100644 OpenPGP-Keychain/src/main/res/values-zh-rTW/strings.xml diff --git a/OpenPGP-Keychain/src/main/res/raw-ach/help_about.html b/OpenPGP-Keychain/src/main/res/raw-ach/help_about.html new file mode 100644 index 000000000..863aeee58 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-ach/help_about.html @@ -0,0 +1,45 @@ + + + +

        http://www.openkeychain.org

        +

        OpenKeychain is an OpenPGP implementation for Android.

        +

        License: GPLv3+

        + +

        Developers OpenKeychain

        +
          +
        • Dominik Schürmann (Lead developer)
        • +
        • Ash Hughes (crypto patches)
        • +
        • Brian C. Barnes
        • +
        • Bahtiar 'kalkin' Gadimov (UI)
        • + +
        +

        Developers APG 1.x

        +
          +
        • 'Thialfihar' (Lead developer)
        • +
        • 'Senecaso' (QRCode, sign key, upload key)
        • +
        • Oliver Runge
        • +
        • Markus Doits
        • +
        +

        Libraries

        + + + diff --git a/OpenPGP-Keychain/src/main/res/raw-ach/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-ach/help_changelog.html new file mode 100644 index 000000000..abf660ba8 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-ach/help_changelog.html @@ -0,0 +1,108 @@ + + + +

        2.3

        +
          +
        • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
        • +
        • fix setting expiry dates on keys (thanks to Ash Hughes)
        • +
        • more internal fixes when editing keys (thanks to Ash Hughes)
        • +
        • querying keyservers directly from the import screen
        • +
        • fix layout and dialog style on Android 2.2-3.0
        • +
        • fix crash on keys with empty user ids
        • +
        • fix crash and empty lists when coming back from signing screen
        • +
        • Bouncy Castle (cryptography library) updated from 1.47 to 1.50 and build from source
        • +
        • fix upload of key from signing screen
        • +
        +

        2.2

        +
          +
        • new design with navigation drawer
        • +
        • new public key list design
        • +
        • new public key view
        • +
        • bug fixes for importing of keys
        • +
        • key cross-certification (thanks to Ash Hughes)
        • +
        • handle UTF-8 passwords properly (thanks to Ash Hughes)
        • +
        • first version with new languages (thanks to the contributors on Transifex)
        • +
        • sharing of keys via QR Codes fixed and improved
        • +
        • package signature verification for API
        • +
        +

        2.1.1

        +
          +
        • API Updates, preparation for K-9 Mail integration
        • +
        +

        2.1

        +
          +
        • lots of bug fixes
        • +
        • new API for developers
        • +
        • PRNG bug fix by Google
        • +
        +

        2.0

        +
          +
        • complete redesign
        • +
        • share public keys via qr codes, nfc beam
        • +
        • sign keys
        • +
        • upload keys to server
        • +
        • fixes import issues
        • +
        • new AIDL API
        • +
        +

        1.0.8

        +
          +
        • basic keyserver support
        • +
        • app2sd
        • +
        • more choices for pass phrase cache: 1, 2, 4, 8, hours
        • +
        • translations: Norwegian (thanks, Sander Danielsen), Chinese (thanks, Zhang Fredrick)
        • +
        • bugfixes
        • +
        • optimizations
        • +
        +

        1.0.7

        +
          +
        • fixed problem with signature verification of texts with trailing newline
        • +
        • more options for pass phrase cache time to live (20, 40, 60 mins)
        • +
        +

        1.0.6

        +
          +
        • account adding crash on Froyo fixed
        • +
        • secure file deletion
        • +
        • option to delete key file after import
        • +
        • stream encryption/decryption (gallery, etc.)
        • +
        • new options (language, force v3 signatures)
        • +
        • interface changes
        • +
        • bugfixes
        • +
        +

        1.0.5

        +
          +
        • German and Italian translation
        • +
        • much smaller package, due to reduced BC sources
        • +
        • new preferences GUI
        • +
        • layout adjustment for localization
        • +
        • signature bugfix
        • +
        +

        1.0.4

        +
          +
        • fixed another crash caused by some SDK bug with query builder
        • +
        +

        1.0.3

        +
          +
        • fixed crashes during encryption/signing and possibly key export
        • +
        +

        1.0.2

        +
          +
        • filterable key lists
        • +
        • smarter pre-selection of encryption keys
        • +
        • new Intent handling for VIEW and SEND, allows files to be encrypted/decrypted out of file managers
        • +
        • fixes and additional features (key preselection) for K-9 Mail, new beta build available
        • +
        +

        1.0.1

        +
          +
        • GMail account listing was broken in 1.0.0, fixed again
        • +
        +

        1.0.0

        +
          +
        • K-9 Mail integration, APG supporting beta build of K-9 Mail
        • +
        • support of more file managers (including ASTRO)
        • +
        • Slovenian translation
        • +
        • new database, much faster, less memory usage
        • +
        • defined Intents and content provider for other apps
        • +
        • bugfixes
        • +
        + + diff --git a/OpenPGP-Keychain/src/main/res/raw-ach/help_nfc_beam.html b/OpenPGP-Keychain/src/main/res/raw-ach/help_nfc_beam.html new file mode 100644 index 000000000..88492731c --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-ach/help_nfc_beam.html @@ -0,0 +1,12 @@ + + + +

        How to receive keys

        +
          +
        1. Go to your partners contacts and open the contact you want to share.
        2. +
        3. Hold the two devices back to back (they have to be almost touching) and you’ll feel a vibration.
        4. +
        5. After it vibrates you’ll see the content on your partners device turn into a card-like object with Star Trek warp speed-looking animation in the background.
        6. +
        7. Tap the card and the content will then load on the your device.
        8. +
        + + diff --git a/OpenPGP-Keychain/src/main/res/raw-ach/help_start.html b/OpenPGP-Keychain/src/main/res/raw-ach/help_start.html new file mode 100644 index 000000000..3a6443a2f --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-ach/help_start.html @@ -0,0 +1,19 @@ + + + +

        Getting started

        +

        First you need a personal key pair. Create one via the option menus in "My Keys" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

        + +

        It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

        + +

        I found a bug in OpenKeychain!

        +

        Please report the bug using the issue tracker of OpenKeychain.

        + +

        Contribute

        +

        If you want to help us developing OpenKeychain by contributing code follow our small guide on Github.

        + +

        Translations

        +

        Help translating OpenKeychain! Everybody can participate at OpenKeychain on Transifex.

        + + + diff --git a/OpenPGP-Keychain/src/main/res/raw-ach/nfc_beam_share.html b/OpenPGP-Keychain/src/main/res/raw-ach/nfc_beam_share.html new file mode 100644 index 000000000..083e055c7 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-ach/nfc_beam_share.html @@ -0,0 +1,11 @@ + + + +
          +
        1. Make sure that NFC is turned on in Settings > More > NFC and make sure that Android Beam is also on in the same section.
        2. +
        3. Hold the two devices back to back (they have to be almost touching) and you'll feel a vibration.
        4. +
        5. After it vibrates you'll see the content on your device turn into a card-like object with Star Trek warp speed-looking animation in the background.
        6. +
        7. Tap the card and the content will then load on the other person’s device.
        8. +
        + + diff --git a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html new file mode 100644 index 000000000..863aeee58 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html @@ -0,0 +1,45 @@ + + + +

        http://www.openkeychain.org

        +

        OpenKeychain is an OpenPGP implementation for Android.

        +

        License: GPLv3+

        + +

        Developers OpenKeychain

        +
          +
        • Dominik Schürmann (Lead developer)
        • +
        • Ash Hughes (crypto patches)
        • +
        • Brian C. Barnes
        • +
        • Bahtiar 'kalkin' Gadimov (UI)
        • + +
        +

        Developers APG 1.x

        +
          +
        • 'Thialfihar' (Lead developer)
        • +
        • 'Senecaso' (QRCode, sign key, upload key)
        • +
        • Oliver Runge
        • +
        • Markus Doits
        • +
        +

        Libraries

        + + + diff --git a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_changelog.html new file mode 100644 index 000000000..abf660ba8 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_changelog.html @@ -0,0 +1,108 @@ + + + +

        2.3

        +
          +
        • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
        • +
        • fix setting expiry dates on keys (thanks to Ash Hughes)
        • +
        • more internal fixes when editing keys (thanks to Ash Hughes)
        • +
        • querying keyservers directly from the import screen
        • +
        • fix layout and dialog style on Android 2.2-3.0
        • +
        • fix crash on keys with empty user ids
        • +
        • fix crash and empty lists when coming back from signing screen
        • +
        • Bouncy Castle (cryptography library) updated from 1.47 to 1.50 and build from source
        • +
        • fix upload of key from signing screen
        • +
        +

        2.2

        +
          +
        • new design with navigation drawer
        • +
        • new public key list design
        • +
        • new public key view
        • +
        • bug fixes for importing of keys
        • +
        • key cross-certification (thanks to Ash Hughes)
        • +
        • handle UTF-8 passwords properly (thanks to Ash Hughes)
        • +
        • first version with new languages (thanks to the contributors on Transifex)
        • +
        • sharing of keys via QR Codes fixed and improved
        • +
        • package signature verification for API
        • +
        +

        2.1.1

        +
          +
        • API Updates, preparation for K-9 Mail integration
        • +
        +

        2.1

        +
          +
        • lots of bug fixes
        • +
        • new API for developers
        • +
        • PRNG bug fix by Google
        • +
        +

        2.0

        +
          +
        • complete redesign
        • +
        • share public keys via qr codes, nfc beam
        • +
        • sign keys
        • +
        • upload keys to server
        • +
        • fixes import issues
        • +
        • new AIDL API
        • +
        +

        1.0.8

        +
          +
        • basic keyserver support
        • +
        • app2sd
        • +
        • more choices for pass phrase cache: 1, 2, 4, 8, hours
        • +
        • translations: Norwegian (thanks, Sander Danielsen), Chinese (thanks, Zhang Fredrick)
        • +
        • bugfixes
        • +
        • optimizations
        • +
        +

        1.0.7

        +
          +
        • fixed problem with signature verification of texts with trailing newline
        • +
        • more options for pass phrase cache time to live (20, 40, 60 mins)
        • +
        +

        1.0.6

        +
          +
        • account adding crash on Froyo fixed
        • +
        • secure file deletion
        • +
        • option to delete key file after import
        • +
        • stream encryption/decryption (gallery, etc.)
        • +
        • new options (language, force v3 signatures)
        • +
        • interface changes
        • +
        • bugfixes
        • +
        +

        1.0.5

        +
          +
        • German and Italian translation
        • +
        • much smaller package, due to reduced BC sources
        • +
        • new preferences GUI
        • +
        • layout adjustment for localization
        • +
        • signature bugfix
        • +
        +

        1.0.4

        +
          +
        • fixed another crash caused by some SDK bug with query builder
        • +
        +

        1.0.3

        +
          +
        • fixed crashes during encryption/signing and possibly key export
        • +
        +

        1.0.2

        +
          +
        • filterable key lists
        • +
        • smarter pre-selection of encryption keys
        • +
        • new Intent handling for VIEW and SEND, allows files to be encrypted/decrypted out of file managers
        • +
        • fixes and additional features (key preselection) for K-9 Mail, new beta build available
        • +
        +

        1.0.1

        +
          +
        • GMail account listing was broken in 1.0.0, fixed again
        • +
        +

        1.0.0

        +
          +
        • K-9 Mail integration, APG supporting beta build of K-9 Mail
        • +
        • support of more file managers (including ASTRO)
        • +
        • Slovenian translation
        • +
        • new database, much faster, less memory usage
        • +
        • defined Intents and content provider for other apps
        • +
        • bugfixes
        • +
        + + diff --git a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_nfc_beam.html b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_nfc_beam.html new file mode 100644 index 000000000..88492731c --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_nfc_beam.html @@ -0,0 +1,12 @@ + + + +

        How to receive keys

        +
          +
        1. Go to your partners contacts and open the contact you want to share.
        2. +
        3. Hold the two devices back to back (they have to be almost touching) and you’ll feel a vibration.
        4. +
        5. After it vibrates you’ll see the content on your partners device turn into a card-like object with Star Trek warp speed-looking animation in the background.
        6. +
        7. Tap the card and the content will then load on the your device.
        8. +
        + + diff --git a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_start.html b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_start.html new file mode 100644 index 000000000..3a6443a2f --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_start.html @@ -0,0 +1,19 @@ + + + +

        Getting started

        +

        First you need a personal key pair. Create one via the option menus in "My Keys" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

        + +

        It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

        + +

        I found a bug in OpenKeychain!

        +

        Please report the bug using the issue tracker of OpenKeychain.

        + +

        Contribute

        +

        If you want to help us developing OpenKeychain by contributing code follow our small guide on Github.

        + +

        Translations

        +

        Help translating OpenKeychain! Everybody can participate at OpenKeychain on Transifex.

        + + + diff --git a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/nfc_beam_share.html b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/nfc_beam_share.html new file mode 100644 index 000000000..083e055c7 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/nfc_beam_share.html @@ -0,0 +1,11 @@ + + + +
          +
        1. Make sure that NFC is turned on in Settings > More > NFC and make sure that Android Beam is also on in the same section.
        2. +
        3. Hold the two devices back to back (they have to be almost touching) and you'll feel a vibration.
        4. +
        5. After it vibrates you'll see the content on your device turn into a card-like object with Star Trek warp speed-looking animation in the background.
        6. +
        7. Tap the card and the content will then load on the other person’s device.
        8. +
        + + diff --git a/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html b/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html new file mode 100644 index 000000000..de16d333f --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html @@ -0,0 +1,45 @@ + + + +

        http://www.openkeychain.org

        +

        OpenKeychain to implementacja OpenPGP na platformę Android.

        +

        Licencja: GPLv3+

        + +

        Deweloperzy OpenKeychain

        +
          +
        • Dominik Schürmann (Wiodący developer)
        • +
        • Ash Hughes (łatki crypto)
        • +
        • Brian C. Barnes
        • +
        • Bahtiar 'kalkin' Gadimov (Interfejs Użytkownika)
        • + +
        +

        Deweloperzy APG 1.x

        +
          +
        • 'Thialfihar' (Wiodacy deweloper)
        • +
        • 'Senecaso' (kody QR, podpisy kluczy, wysyłanie kluczy)
        • +
        • Oliver Runge
        • +
        • Markus Doits
        • +
        +

        Biblioteki

        + + + diff --git a/OpenPGP-Keychain/src/main/res/raw-pl/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-pl/help_changelog.html new file mode 100644 index 000000000..cdf124d3a --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-pl/help_changelog.html @@ -0,0 +1,108 @@ + + + +

        2.3

        +
          +
        • usunięto zbędne eksportowanie kluczy publicznych przy eksportowaniu kluczy prywatnych (podziękowania dla Ash Hughes)
        • +
        • naprawiono błąd z ustawianiem daty wygaśnięcia kluczy (podziękowania dla Ash Hugens)
        • +
        • więcej wewnętrznych poprawek przy edytowaniu kluczy (podziękowania dla Ash Hughes)
        • +
        • wysyłanie zapytań do serwera kluczy bezpośrednio z ekranu importu
        • +
        • poprawiony wygląd interfejsu i okienek na Androidzie 2.2-3.0
        • +
        • naprawiono awarię programu dla kluczy z pustym identyfikatorem użytkownika
        • +
        • naprawiono awarię aplikacji przy powrocie z ekranu podpisywania
        • +
        • Bouncy Castle (biblioteka kryptograficzna) zaktualizowana z wersji 1.47 do 1.50 i kompilowana ze źródeł
        • +
        • naprawiony błąd przy wysyłaniu klucza z ekranu podpisywania
        • +
        +

        2.2

        +
          +
        • nowy wygląd z panelem nawigacji
        • +
        • nowy wygląd listy kluczy publicznych
        • +
        • nowy widok klucza publicznego
        • +
        • naprawiono błędy związane z importowaniem kluczy
        • +
        • krzyżowa certyfikacja kluczy (podziękowania dla Ash Hughes)
        • +
        • hasła zapisane w UTF-8 są teraz prawidłowo obsługiwane (podziękowania dla Ash Hughes)
        • +
        • pierwsza wersja z nowymi językami (podziękowania dla tłumaczy-wolontariuszy z Transifex)
        • +
        • udostępnianie kluczy przez kody QR zostało poprawione i ulepszone
        • +
        • weryfikacja podpisu paczki dla API
        • +
        +

        2.1.1

        +
          +
        • aktualizacje API, przygotowanie do integracji z K-9 Mail
        • +
        +

        2.1

        +
          +
        • wiele poprawek błędów
        • +
        • nowe API dla programistów
        • +
        • Naprawiono błąd generatora liczb losowych (PRNG), Google.
        • +
        +

        2.0

        +
          +
        • kompletna przebudowa
        • +
        • udostępnianie kluczy publicznych przez kody QR oraz NFC
        • +
        • możliwość podpisywania kluczem
        • +
        • wysyłanie kluczy na serwer
        • +
        • naprawiono problemy związane z importowaniem
        • +
        • nowy AIDL API
        • +
        +

        1.0.8

        +
          +
        • podstawowa obsługa serwerów kluczy
        • +
        • app2sd
        • +
        • dodano więcej przedziałów czasowych zapamiętywania hasła: 1, 2, 4, 8 godzin
        • +
        • tłumaczenia: norweski (podziękowania dla Sander Danielsen), chiński (podziękowania dla Zhang Fredrick)
        • +
        • naprawione błędy
        • +
        • usprawnienia
        • +
        +

        1.0.7

        +
          +
        • naprawiono problem z weryfikowaniem podpisu tekstów kończących się znakiem nowej linii
        • +
        • dodano więcej przedziałów czasowych zapamiętywania hasła (20, 40, 60 minut)
        • +
        +

        1.0.6

        +
          +
        • naprawiono błąd powodujący awarię aplikacji przy dodawaniu nowego konta na Androidzie 2.2 Froyo
        • +
        • dodano bezpieczne usuwanie plików
        • +
        • Dodano możliwość usuwania plików kluczy po zaimportowaniu
        • +
        • możliwość strumieniowego szyfrowania/deszyfrowania (galeria i inne)
        • +
        • nowe opcje (języki, wymuszanie podpisów v3)
        • +
        • zmiany w interfejsie
        • +
        • naprawione błędy
        • +
        +

        1.0.5

        +
          +
        • tłumaczenie na niemiecki i włoski
        • +
        • znaczne zmniejszenie rozmiaru paczki, z powodu zredukowania źródeł BC
        • +
        • nowy interfejs graficzny Właściwości
        • +
        • usprawnienia wyglądu dla lokalizacji
        • +
        • naprawa błędu z podpisami
        • +
        +

        1.0.4

        +
          +
        • naprawiono kolejny błąd powodujący awarię aplikacji, spowodowany przez jakąś usterkę w SDK przy budowaniu zapytań
        • +
        +

        1.0.3

        +
          +
        • naprawiono błąd w trakcie szyfrowania/podpisywania i prawdopodobnie eksportowania klucza
        • +
        +

        1.0.2

        +
          +
        • dodano możliwość filtrowania listy kluczy
        • +
        • sprytniejsze automatyczne wybieranie kluczy szyfrujących
        • +
        • dodano nowy sposób obsługi intencji "wyświetl" i "wyślij", umożliwia szyfrowanie/deszyfrowanie plików wprost z menadżera plików.
        • +
        • poprawki i dodatkowe funkcje (podpowiedź wyboru klucza) dla K-9 Mail, nowe wydanie beta dostępne
        • +
        +

        1.0.1

        +
          +
        • wyświetlanie kont w GMailu było zepsute w 1.0.0, naprawiono je ponownie
        • +
        +

        1.0.0

        +
          +
        • integracja z K-9 Mail, APG obsługuje wersję beta K-9 Mail
        • +
        • dodano wsparcie dla większej liczby menadżerów plików (włącznie z ASTRO)
        • +
        • tłumaczenie na słoweński
        • +
        • Wykorzystanie nowej bazy danych, która jest znacznie szybsza i mniej pamięciożerna
        • +
        • zdefiniowano intecję i dostawców treści dla pozostałych aplikacji
        • +
        • naprawione błędy
        • +
        + + diff --git a/OpenPGP-Keychain/src/main/res/raw-pl/help_nfc_beam.html b/OpenPGP-Keychain/src/main/res/raw-pl/help_nfc_beam.html new file mode 100644 index 000000000..53db5e80c --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-pl/help_nfc_beam.html @@ -0,0 +1,12 @@ + + + +

        Jak odbierać klucze

        +
          +
        1. Wejdź do listy kontaktów Twojego partnera i otwórz kontakt, który chcesz przesłać.
        2. +
        3. Przytrzymaj oba urządzenia plecami do siebie (powinny się niemal dotykać) i poczujesz wibrację.
        4. +
        5. Po zakończeniu wibracji zobaczysz, że zawartość urządzenia partnera zamienia się w obiekt zbliżony do wizytówki, z animacją rodem ze Star Treka w tle.
        6. +
        7. Dotknij wizytówkę, a jej zawartość zostanie wysłana na Twoje urządzenie.
        8. +
        + + diff --git a/OpenPGP-Keychain/src/main/res/raw-pl/help_start.html b/OpenPGP-Keychain/src/main/res/raw-pl/help_start.html new file mode 100644 index 000000000..539388789 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-pl/help_start.html @@ -0,0 +1,19 @@ + + + +

        Pierwsze kroki

        +

        Po pierwsze potrzebujesz swoją osobistą parę kluczy. Stwórz ją, korzystając z odpowiedniej opcji w sekcji "Moje klucze" lub też zaimportuj istniejącą parę korzystając z sekcji "Importuj klucze". Następnie możesz pobrać klucze Twoich znajomych lub wymieniać się z nimi za pośrednictwem kodów QR lub technologii NFC.

        + +

        Zalecana jest instalacja menadżera plików OI File Manager w celu zapewnienia wygodniejszego wyboru plików oraz programu Barcode Scanner, który jest w stanie skanować wygenerowane kody QR. Kliknięcie na powyższe linki przekieruje Cię do sklepu Google Play / F-Droid.

        + +

        Znalazłem błąd w OpenKeychain!

        +

        Zgłoś błąd korzystając z systemu śledzenia błędów OpenKeychain.

        + +

        Wkład

        +

        Jeżeli chcesz pomóc nam rozwijać OpenKeychain jako programista, zapoznaj się z naszym małym poradnikiem na Githubie.

        + +

        Tłumaczenia

        +

        Pomóż przetłumaczyć OpenKeychain! Każdy może wziąć udział przez stronę OpenKeychain w serwisie Transifex.

        + + + diff --git a/OpenPGP-Keychain/src/main/res/raw-pl/nfc_beam_share.html b/OpenPGP-Keychain/src/main/res/raw-pl/nfc_beam_share.html new file mode 100644 index 000000000..f17e44079 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-pl/nfc_beam_share.html @@ -0,0 +1,11 @@ + + + +
          +
        1. Upewnij się, że NFC (Near Field Communication, pol.: komunikacja bliskiego zasięgu) jest włączone. W tym celu wejdź w Ustawienia > Inne > NFC. Upewnij się również, że włączona jest funkcja Android Beam (znajduje się w tym samym miejscu).
        2. +
        3. Przytrzymaj oba urządzenia plecami do siebie (powinny się niemal dotykać) i poczujesz wibrację.
        4. +
        5. Po zakończeniu wibracji zobaczysz, że zawartość urządzenia partnera zamienia się w obiekt zbliżony do wizytówki, z animacją rodem ze Star Treka w tle.
        6. +
        7. Dotknij wizytówkę, a jej zawartość zostanie wysłana na urządzenie drugiej osoby.
        8. +
        + + diff --git a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html new file mode 100644 index 000000000..863aeee58 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html @@ -0,0 +1,45 @@ + + + +

        http://www.openkeychain.org

        +

        OpenKeychain is an OpenPGP implementation for Android.

        +

        License: GPLv3+

        + +

        Developers OpenKeychain

        +
          +
        • Dominik Schürmann (Lead developer)
        • +
        • Ash Hughes (crypto patches)
        • +
        • Brian C. Barnes
        • +
        • Bahtiar 'kalkin' Gadimov (UI)
        • + +
        +

        Developers APG 1.x

        +
          +
        • 'Thialfihar' (Lead developer)
        • +
        • 'Senecaso' (QRCode, sign key, upload key)
        • +
        • Oliver Runge
        • +
        • Markus Doits
        • +
        +

        Libraries

        + + + diff --git a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_changelog.html new file mode 100644 index 000000000..abf660ba8 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_changelog.html @@ -0,0 +1,108 @@ + + + +

        2.3

        +
          +
        • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
        • +
        • fix setting expiry dates on keys (thanks to Ash Hughes)
        • +
        • more internal fixes when editing keys (thanks to Ash Hughes)
        • +
        • querying keyservers directly from the import screen
        • +
        • fix layout and dialog style on Android 2.2-3.0
        • +
        • fix crash on keys with empty user ids
        • +
        • fix crash and empty lists when coming back from signing screen
        • +
        • Bouncy Castle (cryptography library) updated from 1.47 to 1.50 and build from source
        • +
        • fix upload of key from signing screen
        • +
        +

        2.2

        +
          +
        • new design with navigation drawer
        • +
        • new public key list design
        • +
        • new public key view
        • +
        • bug fixes for importing of keys
        • +
        • key cross-certification (thanks to Ash Hughes)
        • +
        • handle UTF-8 passwords properly (thanks to Ash Hughes)
        • +
        • first version with new languages (thanks to the contributors on Transifex)
        • +
        • sharing of keys via QR Codes fixed and improved
        • +
        • package signature verification for API
        • +
        +

        2.1.1

        +
          +
        • API Updates, preparation for K-9 Mail integration
        • +
        +

        2.1

        +
          +
        • lots of bug fixes
        • +
        • new API for developers
        • +
        • PRNG bug fix by Google
        • +
        +

        2.0

        +
          +
        • complete redesign
        • +
        • share public keys via qr codes, nfc beam
        • +
        • sign keys
        • +
        • upload keys to server
        • +
        • fixes import issues
        • +
        • new AIDL API
        • +
        +

        1.0.8

        +
          +
        • basic keyserver support
        • +
        • app2sd
        • +
        • more choices for pass phrase cache: 1, 2, 4, 8, hours
        • +
        • translations: Norwegian (thanks, Sander Danielsen), Chinese (thanks, Zhang Fredrick)
        • +
        • bugfixes
        • +
        • optimizations
        • +
        +

        1.0.7

        +
          +
        • fixed problem with signature verification of texts with trailing newline
        • +
        • more options for pass phrase cache time to live (20, 40, 60 mins)
        • +
        +

        1.0.6

        +
          +
        • account adding crash on Froyo fixed
        • +
        • secure file deletion
        • +
        • option to delete key file after import
        • +
        • stream encryption/decryption (gallery, etc.)
        • +
        • new options (language, force v3 signatures)
        • +
        • interface changes
        • +
        • bugfixes
        • +
        +

        1.0.5

        +
          +
        • German and Italian translation
        • +
        • much smaller package, due to reduced BC sources
        • +
        • new preferences GUI
        • +
        • layout adjustment for localization
        • +
        • signature bugfix
        • +
        +

        1.0.4

        +
          +
        • fixed another crash caused by some SDK bug with query builder
        • +
        +

        1.0.3

        +
          +
        • fixed crashes during encryption/signing and possibly key export
        • +
        +

        1.0.2

        +
          +
        • filterable key lists
        • +
        • smarter pre-selection of encryption keys
        • +
        • new Intent handling for VIEW and SEND, allows files to be encrypted/decrypted out of file managers
        • +
        • fixes and additional features (key preselection) for K-9 Mail, new beta build available
        • +
        +

        1.0.1

        +
          +
        • GMail account listing was broken in 1.0.0, fixed again
        • +
        +

        1.0.0

        +
          +
        • K-9 Mail integration, APG supporting beta build of K-9 Mail
        • +
        • support of more file managers (including ASTRO)
        • +
        • Slovenian translation
        • +
        • new database, much faster, less memory usage
        • +
        • defined Intents and content provider for other apps
        • +
        • bugfixes
        • +
        + + diff --git a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_nfc_beam.html b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_nfc_beam.html new file mode 100644 index 000000000..88492731c --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_nfc_beam.html @@ -0,0 +1,12 @@ + + + +

        How to receive keys

        +
          +
        1. Go to your partners contacts and open the contact you want to share.
        2. +
        3. Hold the two devices back to back (they have to be almost touching) and you’ll feel a vibration.
        4. +
        5. After it vibrates you’ll see the content on your partners device turn into a card-like object with Star Trek warp speed-looking animation in the background.
        6. +
        7. Tap the card and the content will then load on the your device.
        8. +
        + + diff --git a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_start.html b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_start.html new file mode 100644 index 000000000..3a6443a2f --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_start.html @@ -0,0 +1,19 @@ + + + +

        Getting started

        +

        First you need a personal key pair. Create one via the option menus in "My Keys" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

        + +

        It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

        + +

        I found a bug in OpenKeychain!

        +

        Please report the bug using the issue tracker of OpenKeychain.

        + +

        Contribute

        +

        If you want to help us developing OpenKeychain by contributing code follow our small guide on Github.

        + +

        Translations

        +

        Help translating OpenKeychain! Everybody can participate at OpenKeychain on Transifex.

        + + + diff --git a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/nfc_beam_share.html b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/nfc_beam_share.html new file mode 100644 index 000000000..083e055c7 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/nfc_beam_share.html @@ -0,0 +1,11 @@ + + + +
          +
        1. Make sure that NFC is turned on in Settings > More > NFC and make sure that Android Beam is also on in the same section.
        2. +
        3. Hold the two devices back to back (they have to be almost touching) and you'll feel a vibration.
        4. +
        5. After it vibrates you'll see the content on your device turn into a card-like object with Star Trek warp speed-looking animation in the background.
        6. +
        7. Tap the card and the content will then load on the other person’s device.
        8. +
        + + diff --git a/OpenPGP-Keychain/src/main/res/values-ach/strings.xml b/OpenPGP-Keychain/src/main/res/values-ach/strings.xml new file mode 100644 index 000000000..3d00a143f --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/values-ach/strings.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenPGP-Keychain/src/main/res/values-cs-rCZ/strings.xml b/OpenPGP-Keychain/src/main/res/values-cs-rCZ/strings.xml new file mode 100644 index 000000000..3d00a143f --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/values-cs-rCZ/strings.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenPGP-Keychain/src/main/res/values-pl/strings.xml b/OpenPGP-Keychain/src/main/res/values-pl/strings.xml new file mode 100644 index 000000000..afdf72223 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/values-pl/strings.xml @@ -0,0 +1,450 @@ + + + + Kontakty + Klucze prywatne + Wybierz Klucz Publiczny + Wybierz Klucz Prywatny + Zaszyfruj + Odszyfruj + Hasło + Utwórz Klucz + Edytuj Klucz + Właściwości + Zarejestrowane Aplikacje + Właściwości serwera kluczy + Zmień hasło + Ustaw hasło + Wyślij maila... + Wyślij plik... + Zaszyfruj do pliku + Odszyfruj do pliku + Importuj klucze + Eksportuj klucz + Eksportuj klucze + Nie znaleziono klucza + Wyślij zapytanie do serwera kluczy + Wyślij do serwera kluczy + Nieznany klucz podpisu + Certyfikuj klucz + Szczegóły klucza + Pomoc + + Identyfikator użytkownika + Klucze + Ogólne + Domyślne + Zaawansowane + Klucz główny + Główny identyfikator użytkownika + Działania + Twój klucz użyty do certyfikacji + Wyślij klucz + Serwer kluczy + Zaszyfruj i/lub podpisz + Deszyfruj i weryfikuj + + Podpisz + Certyfikuj + Odszyfruj + Deszyfruj i weryfikuj + Wybierz odbiorców + Zaszyfruj plik + Zapisz + Anuluj + Usuń + Żaden + Ok + Zmień hasło + Ustaw hasło + Wyszukaj + Wyślij do serwera kluczy + Dalej + Wstecz + Schowek + Podziel się z... + Klucz wyszukiwania + Pokaż zaawanowane ustawienia + Ukryj zaawansowane ustawienia + + Ustawienia + Pomoc + Zaimportuj z pliku + Zaimportuj z kodu QR + Import + Zaimportuj przy użyciu NFC + Eksportuj wszystkie klucze + Eksportuj wszystkie klucze prywatne + Eksportuj do pliku + Usuń klucz + Stwórz klucz + Stwórz klucz (tryb zaawansowany) + Znajdź + Serwer kluczy + Serwer kluczy... + Aktualizuj z serwera kluczy + Wyślij do serwera kluczy + Udostepnij... + Udostepnij odcisk... + Udostępnij cały klucz... + z... + z... + za pomocą kodu QR + za pomocą kodu QR + za pomocą NFC + Kopiuj do schowka + Klucz podpisu + Ustawienia Beam + Anuluj + Zaszyfruj do... + Wybierz wszystko + + Podpis + Wiadomość + Plik + Brak hasła + Hasło + Ponów + Algorytm + ASCII Armor + Odbiorcy + Usuń po zaszyfrowaniu + Usuń po odszyfrowaniu + Udostępnij po zaszyfrowaniu + Algorytm szyfrujący + Algorytm funkcji skrótu + Klucz publiczny + Hasło + Bufor haseł + Kompresja wiadomości + Kompresja plików + Wymuś stare podpisy OpenPGPv3 + Serwery kluczy + Identyfikator klucza + Utworzenia + Wygaśnięcia + Wykorzystanie + Rozmiar klucza + Identyfikator głównego użytkownika + Imię + Komentarz + Adres email + Identyfikator użytkownika podpisu (sign user id) + Podpisz e-mail + Wyślij klucz do serwera kluczy po certyfikacji + Odcisk + Wybierz + Ustaw datę wygaśnięcia + + wybrano %d + wybrano %d + wybrano %d + + <bez nazwy> + <żaden> + <brak klucza> + <Brak adresu email> + + może szyfrować + może podpisywać + wygasły + unieważniony + Identyfikator użytkownika + + 1 kontakt + %d kontakty + %d kontaktów + + + %d serwer kluczy + %d serwerów kluczy + %d serwerów kluczy + + Odcisk: + Klucz prywatny: + + Żaden + Tylko podpisz + Tylko zaszyfruj + Podpisz i zaszyfruj + 15 sekund + 1 minuta + 3 minuty + 5 minut + 10 minut + 20 minut + 40 minut + 1 godzina + 2 godziny + 4 godziny + 8 godzin + na zawsze + DSA + ElGamal + RSA + Otwórz... + Ostrzeżenie + Błąd + Błąd: %s + + Nieprawidłowe hasło. + Użycie zawartości schowka. + Najpierw ustaw hasło. + Nie zainstalowano żadnego kompatybilnego menadżera plików. + Hasła nie pasują do siebie + Puste hasła nie są dozwolone. + Szyfrowanie symetryczne. + Podaj hasło dla \'%s\' + Czy jesteś pewien że chcesz usunąć\n%s? + Usunięto pomyślnie. + Najpierw wskaż plik. + Odszyfrowano pomyślnie. + Zaszyfrowano pomyślnie. + Pomyślnie zaszyfrowano do schowka. + Podaj hasło dwukrotnie. + Wybierz co najmniej jeden klucz szyfrujący. + Wybierz co najmniej jeden klucz szyfrujący lub klucz podpisujący. + Wskaż, do którego pliku zapisać zaszyfrowane dane.\nOSTRZEŻENIE: Plik zostanie nadpisany, jeżeli istnieje. + Wskaż, do którego pliku zapisać odszyfrowane dane.\nOSTRZEŻENIE: Plik zostanie nadpisany, jeżeli istnieje. + Wskaż, do którego pliku wyeksportować dane.\nOSTRZEŻENIE: Plik zostanie nadpisany, jeżeli istnieje. + Wskaż, do którego pliku zapisać eksportowane dane.\nOSTRZEŻENIE: Masz zamiar zapisać klucze PRYWATNE (tajne)\nOSTRZEŻENIE: Plik zostanie nadpisany, jeżeli istnieje. + Czy na pewno chcesz usunąć klucz \'%s\'?\nNie można cofnąć tej operacji! + Czy na pewno chcesz usunąć wszystkie zaznaczone klucze?\nTej operacji nie można cofnąć! + Czy na pewno chcesz usunąć klucz prywatny \'%s\'?\nNie można cofnąć tej operacji! + Czy wyeksportować również klucze prywatne? + + Pomyślnie dodano %d klucz + Pomyślnie dodano %d kluczy + Pomyślnie dodano %d kluczy + + + i zaktualizowano %d klucz. + i zaktualizowano %d kluczy. + i zaktualizowano %d kluczy. + + + Pomyślnie dodano %d klucz. + Pomyślnie dodano %d kluczy. + Pomyślnie dodano %d kluczy. + + + Pomyślnie zaktualizowano %d klucz. + Pomyślnie zaktualizowano %d kluczy. + Pomyślnie zaktualizowano %d kluczy. + + Nie dodano ani zaktualizowano żadnych kluczy. + Pomyślnie wyeksportowano 1 klucz. + Pomyślnie wyeksportowano %d kluczy. + Nie wyeksportowano żadnych kluczy. + Uwaga: algorytm EnGamal jest obsługiwany tylko przez podklucze i użyty zostanie najbliższy rozmiar klucza z podanych: 1536, 2048, 3072, 4096, 8192. + Uwaga: generowanie klucza RSA o długości 1024 bity i mniejszej jest uważane za niebezpieczne i wyłączone dla tworzenia nowych kluczy. + Nie można znaleźć klucza %08X. + + Znaleziono %d klucz. + Znaleziono %d kluczy. + Znaleziono %d kluczy. + + Nieznany podpis, naciśnij przycisk, aby wyszukać brakujący klucz. + + Zignorowano %d niepoprawny klucz prywatny. Prawdopodobnie został wyeksportowany przy uzyciu opcji\n --export-secret-subkeys\nUpewnij się że eksportujesz go z opcją\n --export-secret-keys\nktóra jest poprawna. + Zignorowano %d niepoprawnych kluczy prywatnych. Prawdopodobnie zostały wyeksportowane przy uzyciu opcji\n --export-secret-subkeys\nUpewnij się że eksportujesz je z opcją\n --export-secret-keys\nktóra jest poprawna. + zignorowano %d niepoprawnych kluczy prywatnych. Prawdopodobnie zostały wyeksportowane przy uzyciu opcji\n --export-secret-subkeys\nUpewnij się że eksportujesz je z opcją\n --export-secret-keys\nktóra jest poprawna. + + Pomyślnie wysłano klucz na serwer + Pomyślnie podpisano klucz + Lista jest pusta! + Pomyślnie wysłano klucz przez NFC! + Klucz został skopiowany do schowka! + Klucz został już wcześniej podpisany! + Wybierz klucz, który zostanie użyty do podpisania! + Klucz ma za duży rozmiar by być udostępniony w ten sposób! + + usuwanie \'%s\' zakończone niepowodzeniem + plik nie znaleziony + nie znaleziono pasującego klucza prywatnego + napotkano nieznany rodzaj szyfrowania + zewnętrzne urządzenie jest niegotowe + nieprawidłowy adres email \'%s\' + klucz musi mieć rozmiar co najmniej 512 bitów + klucz EnGamal nie może być kluczem głównym + wybrano nieznany algorytm + musisz wskazać imię + nie znaleziono adresu email + musisz wskazać adres email + potrzeba co najmniej jednego identyfikatora użytkownika + główny identyfikator użytkownika nie może być pusty + potrzeba co najmniej klucza głównego + nie podano hasła ani klucza szyfrującego + podpisywanie nie powiodło się + nie podano hasła + nie podano klucza podpisu + nieprawidłowe dane + uszkodzone dane + Sprawdzanie spójności zakończone niepowodzeniem! Dane były modyfikowane! + nie znaleziono pakietu z szyfrowaniem symatrycznym + nieprawidłowe hasło + błąd przy zapisywaniu kluczy + nie można wyodrębnić klucza prywatnego + Dane binarne pozbawione pliku nie są obsługiwane. To jest wspierane tylko dla akcji ACTION_ENCRYPT_STREAM_AND_RETURN. + Potrzebujesz Androida 4.1 Jelly Bean, aby korzystać z Android NFC Beam! + NCF jest niedostępne na twoim urządzeniu + Nie ma nic do zaimportowania! + data wygaśnięcia musi być późniejsza niż data stworzenia + nie możesz usunąć tego kontaktu, ponieważ należy do ciebie. + nie możesz usunąć tych kontaktów, ponieważ należą do ciebie:\n%s + Niewystarczające zapytanie do serwera + Odpytywanie serwera zakończone niepowodzeniem + Za dużo odpowiedzi + Plik jest pusty + Wystąpił błąd ogólny, proszę zgłoś go autorom OpenKeychain. + + Usuń go z ekranu \'Moje klucze\'! + Usuń je z ekranu \'Moje klucze\'! + Usuń je z ekranu \'Moje klucze\'! + + + Część wczytanego pliku jest poprawnym obiektem OpenPGP, ale nie jest kluczem OpenPGP + Część wczytanego pliku to poprawne obiekty OpenPGP, ale nie są kluczami OpenPGP + Część wczytanego pliku to poprawne obiekty OpenPGP, ale nie są kluczami OpenPGP + + + Gotowe. + Anuluj + zapisywanie... + importowanie... + eksportowanie... + budowanie klucza... + przygotowywanie klucza glównego... + podpisywanie klucza głównego... + budowanie głównego zbioru kluczy... + dodawanie podkluczy... + zapisywanie klucza... + + eksportowanie klucza... + eksportowanie kluczy... + eksportowanie kluczy... + + + generowanie klucza, może to potrwać do 3 minut... + generowanie kluczy, może to potrwać do 3 minut... + generowanie kluczy, może to potrwać do 3 minut... + + wyodrębnianie klucza podpisu... + wyodrębnianie klucza... + przygotowywanie strumieni... + szyfrowanie danych... + deszyfrowywanie danych... + przygotowywanie podpisu... + generowanie podpisu... + przetwarzanie podpisu... + weryfikowanie podpisu... + podpisywanie... + czytanie danych... + szukanie klucza... + dekompresja danych... + weryfikacja spójności... + usuwanie \'%s\' bezpiecznie… + odpytywanie... + + Wyszukaj klucze publiczne + Wyszukaj klucze prywatne + Udostępnij klucz... + + 512 + 1024 + 2048 + 4096 + + szybka + bardzo wolna + + Początek + FAQ + NFC Beam + Dziennik zmian + O programie + Wersja: + + Zaimportuj wybrane klucze + Importuj, podpisz i wyślij wybrane klucze + Importuj ze schowka + + Brakuje kodu QR o identyfikatorze %s + Brakuje kodów QR o identyfikatorach %s + Brakuje kodów QR o identyfikatorach %s + + Zacznij od kodu QR o identyfikatorze 1 + Kod QR zniekształcony! Spróbuj jeszcze raz! + Skanowanie kodu QR zakończone! + Odcisk klucza zawarty w tym kodzie QR jest za krótki (< 16 znaków) + Odczytaj kod QR przy pomocy \'Barcode Scanner\' + Aby odbierać klucze przez NFC, urządzenie musi być odblokowane. + Pomoc + Odczytaj klucz ze schowka + + Deszyfruj plik korzystając z OpenKeychain + Importuj klucz korzystając z OpenKeychain + Zaszyfruj korzystając z OpenKeychain + Deszyfruj korzystając z OpenKeychain + + Brak zarejestrowanych aplikacji!\n\nZewnętrzne aplikacje mogą żądać dostępu do OpenKeychain. Po przyznaniu dostępu, będa wyświetlone tutaj. + Pokaż zaawanowane ustawienia + Ukryj zaawansowane ustawienia + Nie wybrano klucza + Wybierz klucz + Zapisz + Anuluj + Odwołaj dostęp + Nazwa paczki + Skrót SHA-256 podpisu paczki + Wyświetlona aplikacja prosi o dostęp do OpenKeychain.\nZezwolić?\n\nOSTRZEZENIE: Jeżeli nie wiesz, czemu wyświetlił się ten komunikat, nie zezwalaj na dostęp! Możesz to również zrobić później, korzystając z ekranu \'Zarejestrowane aplikacje\'. + Zezwól na dostęp + Odmów dostępu + Wybierz klucz! + Nie znaleziono kluczy publiczych dla tych identyfikatorów użytkownika: + Więcej niż jeden klucz publiczny istnieje dla tych identyfikatorów użytkownika: + Proszę przejrzeć listę adresatów! + Sprawdzanie podpisu zakończone niepowodzeniem! Czy zainstalowałeś tę aplikację z innego źródła? Jeżeli jesteś pewien, że nie jest to atak, odwołaj rejestrację teg aplikacji w OpenKeychain, a następnie zarejestruj ją ponownie. + + Udostępnij przez kod QR + Przejdź przez wszystkiego kody QR korzystając z przycisku \'Nastepny\' i skanuj je pojedynczo. + Odcisk: + Kod QR o identyfikatorze %1$d z %2$d + Udostępnij przez NFC + + + 1 klucz wybrany. + %d kluczy wybranych. + %d kluczy wybranych. + + Żadne klucze nie są jeszcze dostępne... + Możesz zacząć od + lub + tworzenie własnego klucza + importowanie kluczy. + + Edytuj ten klucz + Zaszyfruj do tego kontaktu + Certyfikuj klucz tego kontaktu + Informacje + Certyfikaty + + Kontakty + Zaszyfruj + Deszyfruj + importuj klucze + Moje klucze + Zarejestrowane aplikacje + Otwórz panel nawigacji + Zamknij panel nawigacji + Edytuj + Moje klucze + Klucz prywatny + dostępny + niedostepny + Identyfikator użytkownika do podpisu + Ponowne stosowanie certyfikatów + + diff --git a/OpenPGP-Keychain/src/main/res/values-zh-rTW/strings.xml b/OpenPGP-Keychain/src/main/res/values-zh-rTW/strings.xml new file mode 100644 index 000000000..3d00a143f --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/values-zh-rTW/strings.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3 From c6189c52186fbbc47ef476f75c66137da1c027eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 21 Mar 2014 10:29:29 +0100 Subject: remove ach language, not supported by android --- .../src/main/res/raw-ach/help_about.html | 45 --------- .../src/main/res/raw-ach/help_changelog.html | 108 --------------------- .../src/main/res/raw-ach/help_nfc_beam.html | 12 --- .../src/main/res/raw-ach/help_start.html | 19 ---- .../src/main/res/raw-ach/nfc_beam_share.html | 11 --- .../src/main/res/values-ach/strings.xml | 27 ------ 6 files changed, 222 deletions(-) delete mode 100644 OpenPGP-Keychain/src/main/res/raw-ach/help_about.html delete mode 100644 OpenPGP-Keychain/src/main/res/raw-ach/help_changelog.html delete mode 100644 OpenPGP-Keychain/src/main/res/raw-ach/help_nfc_beam.html delete mode 100644 OpenPGP-Keychain/src/main/res/raw-ach/help_start.html delete mode 100644 OpenPGP-Keychain/src/main/res/raw-ach/nfc_beam_share.html delete mode 100644 OpenPGP-Keychain/src/main/res/values-ach/strings.xml diff --git a/OpenPGP-Keychain/src/main/res/raw-ach/help_about.html b/OpenPGP-Keychain/src/main/res/raw-ach/help_about.html deleted file mode 100644 index 863aeee58..000000000 --- a/OpenPGP-Keychain/src/main/res/raw-ach/help_about.html +++ /dev/null @@ -1,45 +0,0 @@ - - - -

        http://www.openkeychain.org

        -

        OpenKeychain is an OpenPGP implementation for Android.

        -

        License: GPLv3+

        - -

        Developers OpenKeychain

        -
          -
        • Dominik Schürmann (Lead developer)
        • -
        • Ash Hughes (crypto patches)
        • -
        • Brian C. Barnes
        • -
        • Bahtiar 'kalkin' Gadimov (UI)
        • - -
        -

        Developers APG 1.x

        -
          -
        • 'Thialfihar' (Lead developer)
        • -
        • 'Senecaso' (QRCode, sign key, upload key)
        • -
        • Oliver Runge
        • -
        • Markus Doits
        • -
        -

        Libraries

        - - - diff --git a/OpenPGP-Keychain/src/main/res/raw-ach/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-ach/help_changelog.html deleted file mode 100644 index abf660ba8..000000000 --- a/OpenPGP-Keychain/src/main/res/raw-ach/help_changelog.html +++ /dev/null @@ -1,108 +0,0 @@ - - - -

        2.3

        -
          -
        • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
        • -
        • fix setting expiry dates on keys (thanks to Ash Hughes)
        • -
        • more internal fixes when editing keys (thanks to Ash Hughes)
        • -
        • querying keyservers directly from the import screen
        • -
        • fix layout and dialog style on Android 2.2-3.0
        • -
        • fix crash on keys with empty user ids
        • -
        • fix crash and empty lists when coming back from signing screen
        • -
        • Bouncy Castle (cryptography library) updated from 1.47 to 1.50 and build from source
        • -
        • fix upload of key from signing screen
        • -
        -

        2.2

        -
          -
        • new design with navigation drawer
        • -
        • new public key list design
        • -
        • new public key view
        • -
        • bug fixes for importing of keys
        • -
        • key cross-certification (thanks to Ash Hughes)
        • -
        • handle UTF-8 passwords properly (thanks to Ash Hughes)
        • -
        • first version with new languages (thanks to the contributors on Transifex)
        • -
        • sharing of keys via QR Codes fixed and improved
        • -
        • package signature verification for API
        • -
        -

        2.1.1

        -
          -
        • API Updates, preparation for K-9 Mail integration
        • -
        -

        2.1

        -
          -
        • lots of bug fixes
        • -
        • new API for developers
        • -
        • PRNG bug fix by Google
        • -
        -

        2.0

        -
          -
        • complete redesign
        • -
        • share public keys via qr codes, nfc beam
        • -
        • sign keys
        • -
        • upload keys to server
        • -
        • fixes import issues
        • -
        • new AIDL API
        • -
        -

        1.0.8

        -
          -
        • basic keyserver support
        • -
        • app2sd
        • -
        • more choices for pass phrase cache: 1, 2, 4, 8, hours
        • -
        • translations: Norwegian (thanks, Sander Danielsen), Chinese (thanks, Zhang Fredrick)
        • -
        • bugfixes
        • -
        • optimizations
        • -
        -

        1.0.7

        -
          -
        • fixed problem with signature verification of texts with trailing newline
        • -
        • more options for pass phrase cache time to live (20, 40, 60 mins)
        • -
        -

        1.0.6

        -
          -
        • account adding crash on Froyo fixed
        • -
        • secure file deletion
        • -
        • option to delete key file after import
        • -
        • stream encryption/decryption (gallery, etc.)
        • -
        • new options (language, force v3 signatures)
        • -
        • interface changes
        • -
        • bugfixes
        • -
        -

        1.0.5

        -
          -
        • German and Italian translation
        • -
        • much smaller package, due to reduced BC sources
        • -
        • new preferences GUI
        • -
        • layout adjustment for localization
        • -
        • signature bugfix
        • -
        -

        1.0.4

        -
          -
        • fixed another crash caused by some SDK bug with query builder
        • -
        -

        1.0.3

        -
          -
        • fixed crashes during encryption/signing and possibly key export
        • -
        -

        1.0.2

        -
          -
        • filterable key lists
        • -
        • smarter pre-selection of encryption keys
        • -
        • new Intent handling for VIEW and SEND, allows files to be encrypted/decrypted out of file managers
        • -
        • fixes and additional features (key preselection) for K-9 Mail, new beta build available
        • -
        -

        1.0.1

        -
          -
        • GMail account listing was broken in 1.0.0, fixed again
        • -
        -

        1.0.0

        -
          -
        • K-9 Mail integration, APG supporting beta build of K-9 Mail
        • -
        • support of more file managers (including ASTRO)
        • -
        • Slovenian translation
        • -
        • new database, much faster, less memory usage
        • -
        • defined Intents and content provider for other apps
        • -
        • bugfixes
        • -
        - - diff --git a/OpenPGP-Keychain/src/main/res/raw-ach/help_nfc_beam.html b/OpenPGP-Keychain/src/main/res/raw-ach/help_nfc_beam.html deleted file mode 100644 index 88492731c..000000000 --- a/OpenPGP-Keychain/src/main/res/raw-ach/help_nfc_beam.html +++ /dev/null @@ -1,12 +0,0 @@ - - - -

        How to receive keys

        -
          -
        1. Go to your partners contacts and open the contact you want to share.
        2. -
        3. Hold the two devices back to back (they have to be almost touching) and you’ll feel a vibration.
        4. -
        5. After it vibrates you’ll see the content on your partners device turn into a card-like object with Star Trek warp speed-looking animation in the background.
        6. -
        7. Tap the card and the content will then load on the your device.
        8. -
        - - diff --git a/OpenPGP-Keychain/src/main/res/raw-ach/help_start.html b/OpenPGP-Keychain/src/main/res/raw-ach/help_start.html deleted file mode 100644 index 3a6443a2f..000000000 --- a/OpenPGP-Keychain/src/main/res/raw-ach/help_start.html +++ /dev/null @@ -1,19 +0,0 @@ - - - -

        Getting started

        -

        First you need a personal key pair. Create one via the option menus in "My Keys" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

        - -

        It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

        - -

        I found a bug in OpenKeychain!

        -

        Please report the bug using the issue tracker of OpenKeychain.

        - -

        Contribute

        -

        If you want to help us developing OpenKeychain by contributing code follow our small guide on Github.

        - -

        Translations

        -

        Help translating OpenKeychain! Everybody can participate at OpenKeychain on Transifex.

        - - - diff --git a/OpenPGP-Keychain/src/main/res/raw-ach/nfc_beam_share.html b/OpenPGP-Keychain/src/main/res/raw-ach/nfc_beam_share.html deleted file mode 100644 index 083e055c7..000000000 --- a/OpenPGP-Keychain/src/main/res/raw-ach/nfc_beam_share.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -
          -
        1. Make sure that NFC is turned on in Settings > More > NFC and make sure that Android Beam is also on in the same section.
        2. -
        3. Hold the two devices back to back (they have to be almost touching) and you'll feel a vibration.
        4. -
        5. After it vibrates you'll see the content on your device turn into a card-like object with Star Trek warp speed-looking animation in the background.
        6. -
        7. Tap the card and the content will then load on the other person’s device.
        8. -
        - - diff --git a/OpenPGP-Keychain/src/main/res/values-ach/strings.xml b/OpenPGP-Keychain/src/main/res/values-ach/strings.xml deleted file mode 100644 index 3d00a143f..000000000 --- a/OpenPGP-Keychain/src/main/res/values-ach/strings.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3 From 1b57a10bb6a65a1900c79c68efe4c320177485da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 21 Mar 2014 11:26:18 +0100 Subject: Fix nfc help button --- .../java/org/sufficientlysecure/keychain/ui/ImportKeysNFCFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysNFCFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysNFCFragment.java index 44b5848d8..110647284 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysNFCFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysNFCFragment.java @@ -57,7 +57,7 @@ public class ImportKeysNFCFragment extends Fragment { public void onClick(View v) { // show nfc help Intent intent = new Intent(getActivity(), HelpActivity.class); - intent.putExtra(HelpActivity.EXTRA_SELECTED_TAB, 1); + intent.putExtra(HelpActivity.EXTRA_SELECTED_TAB, 2); startActivityForResult(intent, 0); } }); -- cgit v1.2.3 From b7bc8faee6e9500287baf86a6bb4fe42be80ef0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Fri, 21 Mar 2014 11:43:30 +0100 Subject: raname to mKeychainDatabase --- .../keychain/provider/KeychainProvider.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java index b963ceb39..746449f7e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java @@ -247,7 +247,7 @@ public class KeychainProvider extends ContentProvider { return matcher; } - private KeychainDatabase mApgDatabase; + private KeychainDatabase mKeychainDatabase; /** * {@inheritDoc} @@ -255,7 +255,7 @@ public class KeychainProvider extends ContentProvider { @Override public boolean onCreate() { mUriMatcher = buildUriMatcher(); - mApgDatabase = new KeychainDatabase(getContext()); + mKeychainDatabase = new KeychainDatabase(getContext()); return true; } @@ -486,7 +486,7 @@ public class KeychainProvider extends ContentProvider { Log.v(Constants.TAG, "query(uri=" + uri + ", proj=" + Arrays.toString(projection) + ")"); SQLiteQueryBuilder qb = new SQLiteQueryBuilder(); - SQLiteDatabase db = mApgDatabase.getReadableDatabase(); + SQLiteDatabase db = mKeychainDatabase.getReadableDatabase(); int match = mUriMatcher.match(uri); @@ -715,7 +715,7 @@ public class KeychainProvider extends ContentProvider { public Uri insert(Uri uri, ContentValues values) { Log.d(Constants.TAG, "insert(uri=" + uri + ", values=" + values.toString() + ")"); - final SQLiteDatabase db = mApgDatabase.getWritableDatabase(); + final SQLiteDatabase db = mKeychainDatabase.getWritableDatabase(); Uri rowUri = null; long rowId = -1; @@ -792,7 +792,7 @@ public class KeychainProvider extends ContentProvider { public int delete(Uri uri, String selection, String[] selectionArgs) { Log.v(Constants.TAG, "delete(uri=" + uri + ")"); - final SQLiteDatabase db = mApgDatabase.getWritableDatabase(); + final SQLiteDatabase db = mKeychainDatabase.getWritableDatabase(); int count; final int match = mUriMatcher.match(uri); @@ -853,7 +853,7 @@ public class KeychainProvider extends ContentProvider { public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { Log.v(Constants.TAG, "update(uri=" + uri + ", values=" + values.toString() + ")"); - final SQLiteDatabase db = mApgDatabase.getWritableDatabase(); + final SQLiteDatabase db = mKeychainDatabase.getWritableDatabase(); String defaultSelection = null; int count = 0; -- cgit v1.2.3 From 8f37569967c44f0693ba63541e4e6ecfe42aa73f Mon Sep 17 00:00:00 2001 From: uberspot Date: Fri, 21 Mar 2014 18:43:11 +0200 Subject: Make foldable settings in EncryptActivity a separate widget --- .../keychain/ui/EncryptActivity.java | 47 ----- .../keychain/ui/widget/FoldableLinearLayout.java | 203 +++++++++++++++++++++ .../src/main/res/layout/encrypt_content.xml | 104 ++--------- .../res/layout/encrypt_content_adv_settings.xml | 63 +++++++ .../src/main/res/layout/foldable_linearlayout.xml | 41 +++++ OpenPGP-Keychain/src/main/res/values/attr.xml | 11 ++ 6 files changed, 329 insertions(+), 140 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FoldableLinearLayout.java create mode 100644 OpenPGP-Keychain/src/main/res/layout/encrypt_content_adv_settings.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout/foldable_linearlayout.xml create mode 100644 OpenPGP-Keychain/src/main/res/values/attr.xml diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java index 28c9c7b28..4ccfd393f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java @@ -108,11 +108,6 @@ public class EncryptActivity extends DrawerActivity { private String mInputFilename = null; private String mOutputFilename = null; - private Integer mShortAnimationDuration = null; - private boolean mFileAdvancedSettingsVisible = false; - private TextView mFileAdvancedSettings = null; - private LinearLayout mFileAdvancedSettingsContainer = null; - private FontAwesomeText mAdvancedSettingsIcon; private boolean mAsciiArmorDemand = false; private boolean mOverrideAsciiArmor = false; @@ -147,9 +142,6 @@ public class EncryptActivity extends DrawerActivity { updateMode(); updateActionBarButtons(); - - // retrieve and cache the system's short animation time - mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime); } /** @@ -795,49 +787,10 @@ public class EncryptActivity extends DrawerActivity { } }); - mAdvancedSettingsIcon = (FontAwesomeText) findViewById(R.id.advancedSettingsIcon); - mFileAdvancedSettingsContainer = (LinearLayout) findViewById(R.id.fileAdvancedSettingsContainer); - mFileAdvancedSettings = (TextView) findViewById(R.id.advancedSettings); - LinearLayout advancedSettingsControl = (LinearLayout) findViewById(R.id.advancedSettingsControl); - advancedSettingsControl.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - mFileAdvancedSettingsVisible = !mFileAdvancedSettingsVisible; - if (mFileAdvancedSettingsVisible) { - mAdvancedSettingsIcon.setIcon("fa-chevron-down"); - mFileAdvancedSettingsContainer.setVisibility(View.VISIBLE); - AlphaAnimation animation = new AlphaAnimation(0f, 1f); - animation.setDuration(mShortAnimationDuration); - mFileAdvancedSettingsContainer.startAnimation(animation); - mFileAdvancedSettings.setText(R.string.btn_encryption_advanced_settings_hide); - } else { - mAdvancedSettingsIcon.setIcon("fa-chevron-right"); - AlphaAnimation animation = new AlphaAnimation(1f, 0f); - animation.setDuration(mShortAnimationDuration); - animation.setAnimationListener(new Animation.AnimationListener() { - @Override - public void onAnimationStart(Animation animation) { - // do nothing - } - @Override - public void onAnimationEnd(Animation animation) { - // making sure that at the end the container is completely removed from view - mFileAdvancedSettingsContainer.setVisibility(View.GONE); - } - @Override - public void onAnimationRepeat(Animation animation) { - // do nothing - } - }); - mFileAdvancedSettingsContainer.startAnimation(animation); - mFileAdvancedSettings.setText(R.string.btn_encryption_advanced_settings_show); - } - } - }); mFileCompression = (Spinner) findViewById(R.id.fileCompression); Choice[] choices = new Choice[]{ diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FoldableLinearLayout.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FoldableLinearLayout.java new file mode 100644 index 000000000..f9a5b92f3 --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FoldableLinearLayout.java @@ -0,0 +1,203 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui.widget; + +import android.content.Context; +import android.content.res.TypedArray; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.view.animation.AlphaAnimation; +import android.view.animation.Animation; +import android.widget.LinearLayout; +import android.widget.TextView; +import com.beardedhen.androidbootstrap.FontAwesomeText; +import org.sufficientlysecure.keychain.R; + +/** + * Class representing a LinearLayout that can fold and hide it's content when pressed + * To use just add the following to your xml layout + + + + + + + + */ +public class FoldableLinearLayout extends LinearLayout { + + private FontAwesomeText mFoldableIcon; + private boolean mFolded; + private boolean mHasMigrated = false; + private Integer mShortAnimationDuration = null; + private TextView mFoldableTextView = null; + private LinearLayout mFoldableContainer = null; + private View mFoldableLayout = null; + + private String mFoldedIconName; + private String mUnFoldedIconName; + private String mFoldedLabel; + private String mUnFoldedLabel; + + public FoldableLinearLayout(Context context) { + super(context); + processAttributes(context, null); + } + + public FoldableLinearLayout(Context context, AttributeSet attrs) { + super(context, attrs); + processAttributes(context, attrs); + } + + public FoldableLinearLayout(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs); + processAttributes(context, attrs); + } + + /** + * Load given attributes to inner variables, + * @param context + * @param attrs + */ + private void processAttributes(Context context, AttributeSet attrs) { + if(attrs != null) { + TypedArray a = context.obtainStyledAttributes(attrs, + R.styleable.FoldableLinearLayout, 0, 0); + mFoldedIconName = a.getString(R.styleable.FoldableLinearLayout_foldedIcon); + mUnFoldedIconName = a.getString(R.styleable.FoldableLinearLayout_unFoldedIcon); + mFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_foldedLabel); + mUnFoldedLabel = a.getString(R.styleable.FoldableLinearLayout_unFoldedLabel); + a.recycle(); + } + // If any attribute isn't found then set a default one + mFoldedIconName = (mFoldedIconName == null) ? "fa-chevron-right" : mFoldedIconName; + mUnFoldedIconName = (mUnFoldedIconName == null) ? "fa-chevron-down" : mUnFoldedIconName; + mFoldedLabel = (mFoldedLabel == null) ? context.getString(R.id.none) : mFoldedLabel; + mUnFoldedLabel = (mUnFoldedLabel == null) ? context.getString(R.id.none) : mUnFoldedLabel; + } + + @Override + protected void onFinishInflate() { + // if the migration has already happened + // there is no need to move any children + if(!mHasMigrated) { + migrateChildrenToContainer(); + mHasMigrated = true; + } + + initialiseInnerViews(); + + super.onFinishInflate(); + } + + /** + * Migrates Child views as declared in xml to the inner foldableContainer + */ + private void migrateChildrenToContainer() { + // Collect children of FoldableLinearLayout as declared in XML + int childNum = getChildCount(); + View[] children = new View[childNum]; + + for(int i = 0; i < childNum; i++) { + children[i] = getChildAt(i); + } + if(children[0].getId() == R.id.foldableControl) { + + } + + // remove all of them from FoldableLinearLayout + detachAllViewsFromParent(); + + // Inflate the inner foldable_linearlayout.xml + LayoutInflater inflator = (LayoutInflater)getContext().getSystemService( + Context.LAYOUT_INFLATER_SERVICE); + + mFoldableLayout = inflator.inflate(R.layout.foldable_linearlayout, this, true); + mFoldableContainer = (LinearLayout) mFoldableLayout.findViewById(R.id.foldableContainer); + + // Push previously collected children into foldableContainer. + for(int i = 0; i < childNum; i++) { + addView(children[i]); + } + } + + private void initialiseInnerViews() { + mFoldableIcon = (FontAwesomeText) mFoldableLayout.findViewById(R.id.foldableIcon); + mFoldableIcon.setIcon(mFoldedIconName); + mFoldableTextView = (TextView) mFoldableLayout.findViewById(R.id.foldableText); + mFoldableTextView.setText(mFoldedLabel); + + // retrieve and cache the system's short animation time + mShortAnimationDuration = getResources().getInteger(android.R.integer.config_shortAnimTime); + + LinearLayout foldableControl = (LinearLayout) mFoldableLayout.findViewById(R.id.foldableControl); + foldableControl.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + mFolded = !mFolded; + if (mFolded) { + mFoldableIcon.setIcon(mUnFoldedIconName); + mFoldableContainer.setVisibility(View.VISIBLE); + AlphaAnimation animation = new AlphaAnimation(0f, 1f); + animation.setDuration(mShortAnimationDuration); + mFoldableContainer.startAnimation(animation); + mFoldableTextView.setText(mUnFoldedLabel); + + } else { + mFoldableIcon.setIcon(mFoldedIconName); + AlphaAnimation animation = new AlphaAnimation(1f, 0f); + animation.setDuration(mShortAnimationDuration); + animation.setAnimationListener(new Animation.AnimationListener() { + @Override + public void onAnimationStart(Animation animation) { } + + @Override + public void onAnimationEnd(Animation animation) { + // making sure that at the end the container is completely removed from view + mFoldableContainer.setVisibility(View.GONE); + } + + @Override + public void onAnimationRepeat(Animation animation) { } + }); + mFoldableContainer.startAnimation(animation); + mFoldableTextView.setText(mFoldedLabel); + } + } + }); + + } + + /** + * Adds provided child view to foldableContainer View + * @param child + */ + @Override + public void addView(View child) { + if(mFoldableContainer != null) { + mFoldableContainer.addView(child); + } + } +} diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml index bb947fb5a..03fe496c6 100644 --- a/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml @@ -1,8 +1,9 @@ - - - - - - - - - - - - - - - - - - - - - - + android:layout_height="match_parent" + custom:foldedLabel="@string/btn_encryption_advanced_settings_show" + custom:unFoldedLabel="@string/btn_encryption_advanced_settings_hide" + custom:foldedIcon="fa-chevron-right" + custom:unFoldedIcon="fa-chevron-down"> - - + - + - - - diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_content_adv_settings.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_content_adv_settings.xml new file mode 100644 index 000000000..2281759d1 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_content_adv_settings.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/foldable_linearlayout.xml b/OpenPGP-Keychain/src/main/res/layout/foldable_linearlayout.xml new file mode 100644 index 000000000..2b863d52b --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/foldable_linearlayout.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/values/attr.xml b/OpenPGP-Keychain/src/main/res/values/attr.xml new file mode 100644 index 000000000..86622b3e0 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/values/attr.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3 From 0f6dc253a40ecada0c0c2a467c56ee45b7b9cc72 Mon Sep 17 00:00:00 2001 From: Daniel Hammann Date: Fri, 21 Mar 2014 23:01:24 +0100 Subject: Because of an unknown reason toast messages were commented out. --- .../sufficientlysecure/keychain/ui/EditKeyActivity.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 9b64def1e..092a502e1 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -495,11 +495,10 @@ public class EditKeyActivity extends ActionBarActivity { private void saveClicked() { long masterKeyId = getMasterKeyId(); - try { - if (!isPassphraseSet()) { - throw new PgpGeneralException(this.getString(R.string.set_a_passphrase)); - } - + if (!isPassphraseSet()) { + Log.e(Constants.TAG, "No passphrase has been set"); + Toast.makeText(this, R.string.set_a_passphrase, Toast.LENGTH_LONG).show(); + } else { String passphrase = null; if (mIsPassPhraseSet) { passphrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId); @@ -512,9 +511,6 @@ public class EditKeyActivity extends ActionBarActivity { mCurrentPassphrase = passphrase; finallySaveClicked(); } - } catch (PgpGeneralException e) { - //Toast.makeText(this, getString(R.string.error_message, e.getMessage()), - // Toast.LENGTH_SHORT).show(); } } @@ -576,8 +572,9 @@ public class EditKeyActivity extends ActionBarActivity { // start service with intent startService(intent); } catch (PgpGeneralException e) { - //Toast.makeText(this, getString(R.string.error_message, e.getMessage()), - // Toast.LENGTH_SHORT).show(); + Log.e(Constants.TAG, getString(R.string.error_message, e.getMessage())); + Toast.makeText(this, getString(R.string.error_message, e.getMessage()), + Toast.LENGTH_SHORT).show(); } } -- cgit v1.2.3 From 4e285d9254f98381bd59a9a683d406ad1b6020d6 Mon Sep 17 00:00:00 2001 From: Daniel Hammann Date: Sat, 22 Mar 2014 15:31:18 +0100 Subject: The current implementation of saving new generated key doesn't save the key due to the public key of master key id can not be resolved by ProviderHelper.getPGPPublicKeyByKeyId (via URI/Cursor). Workaround uses local keys-arraylist for resoving the pubkey of master key id. --- .../keychain/service/KeychainIntentService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 0751fa33c..5ef41cced 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -543,7 +543,14 @@ public class KeychainIntentService extends IntentService ProviderHelper.getPGPSecretKeyRingByKeyId(this, masterKeyId), oldPassPhrase, newPassPhrase); } else { - PGPPublicKey pubkey = ProviderHelper.getPGPPublicKeyByKeyId(this, masterKeyId); + PGPPublicKey pubkey = null; + for(PGPSecretKey key : keys) { + PGPPublicKey tempKey = key.getPublicKey(); + if (tempKey.getKeyID() == masterKeyId) { + pubkey = tempKey; + } + } + //PGPPublicKey pubkey = ProviderHelper.getPGPPublicKeyByKeyId(this, masterKeyId); keyOperations.buildSecretKey(userIds, keys, keysUsages, keysExpiryDates, pubkey, oldPassPhrase, newPassPhrase); } -- cgit v1.2.3 From 9c180629510d6b07aa296088f61593234b52a14a Mon Sep 17 00:00:00 2001 From: Daniel Hammann Date: Sat, 22 Mar 2014 15:31:18 +0100 Subject: The current implementation of saving new generated key doesn't save the key due to the public key of master key id can not be resolved by ProviderHelper.getPGPPublicKeyByKeyId (via URI/Cursor). Workaround uses local keys-arraylist for resoving the pubkey of master key id. --- .../keychain/service/KeychainIntentService.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 0751fa33c..e26ee3c76 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -543,7 +543,15 @@ public class KeychainIntentService extends IntentService ProviderHelper.getPGPSecretKeyRingByKeyId(this, masterKeyId), oldPassPhrase, newPassPhrase); } else { - PGPPublicKey pubkey = ProviderHelper.getPGPPublicKeyByKeyId(this, masterKeyId); + //TODO: Workaround due to ProviderHelper.getPGPPublicKeyByKeyId can not resolve public key of master-key id with uri/cursor + PGPPublicKey pubkey = null; + for(PGPSecretKey key : keys) { + PGPPublicKey tempKey = key.getPublicKey(); + if (tempKey.getKeyID() == masterKeyId) { + pubkey = tempKey; + } + } + //PGPPublicKey pubkey = ProviderHelper.getPGPPublicKeyByKeyId(this, masterKeyId); keyOperations.buildSecretKey(userIds, keys, keysUsages, keysExpiryDates, pubkey, oldPassPhrase, newPassPhrase); } -- cgit v1.2.3 From 153b99a186f514ff08f4b2a659202049f237c9fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 23 Mar 2014 00:03:49 +0100 Subject: Use new FoldableLinearLayout in API settings --- .../service/remote/AppSettingsFragment.java | 46 +++------------------- .../main/res/layout/api_app_settings_fragment.xml | 28 +++++-------- 2 files changed, 15 insertions(+), 59 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java index 837295018..52b06a2ae 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java @@ -25,13 +25,13 @@ import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; -import android.view.View.OnClickListener; import android.view.ViewGroup; -import android.view.animation.AlphaAnimation; -import android.view.animation.Animation; -import android.widget.*; +import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; -import com.beardedhen.androidbootstrap.BootstrapButton; +import android.widget.ImageView; +import android.widget.Spinner; +import android.widget.TextView; + import org.spongycastle.util.encoders.Hex; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; @@ -50,8 +50,6 @@ public class AppSettingsFragment extends Fragment implements private AppSettings mAppSettings; // view - private LinearLayout mAdvancedSettingsContainer; - private BootstrapButton mAdvancedSettingsButton; private TextView mAppNameView; private ImageView mAppIconView; private Spinner mEncryptionAlgorithm; @@ -117,11 +115,6 @@ public class AppSettingsFragment extends Fragment implements R.id.api_app_settings_select_key_fragment); mSelectKeyFragment.setCallback(this); - mAdvancedSettingsButton = (BootstrapButton) view - .findViewById(R.id.api_app_settings_advanced_button); - mAdvancedSettingsContainer = (LinearLayout) view - .findViewById(R.id.api_app_settings_advanced); - mAppNameView = (TextView) view.findViewById(R.id.api_app_settings_app_name); mAppIconView = (ImageView) view.findViewById(R.id.api_app_settings_app_icon); mEncryptionAlgorithm = (Spinner) view @@ -176,35 +169,6 @@ public class AppSettingsFragment extends Fragment implements public void onNothingSelected(AdapterView parent) { } }); - - final Animation visibleAnimation = new AlphaAnimation(0.0f, 1.0f); - visibleAnimation.setDuration(250); - final Animation invisibleAnimation = new AlphaAnimation(1.0f, 0.0f); - invisibleAnimation.setDuration(250); - - // TODO: Better: collapse/expand animation - // final Animation animation2 = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, - // Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, - // Animation.RELATIVE_TO_SELF, 0.0f);u - // animation2.setDuration(150); - - mAdvancedSettingsButton.setOnClickListener(new OnClickListener() { - - @Override - public void onClick(View v) { - if (mAdvancedSettingsContainer.getVisibility() == View.VISIBLE) { - mAdvancedSettingsContainer.startAnimation(invisibleAnimation); - mAdvancedSettingsContainer.setVisibility(View.GONE); - mAdvancedSettingsButton.setText(getString(R.string.api_settings_show_advanced)); - mAdvancedSettingsButton.setLeftIcon("fa-caret-up"); - } else { - mAdvancedSettingsContainer.startAnimation(visibleAnimation); - mAdvancedSettingsContainer.setVisibility(View.VISIBLE); - mAdvancedSettingsButton.setText(getString(R.string.api_settings_hide_advanced)); - mAdvancedSettingsButton.setLeftIcon("fa-caret-down"); - } - } - }); } private void setPackage(String packageName) { diff --git a/OpenPGP-Keychain/src/main/res/layout/api_app_settings_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/api_app_settings_fragment.xml index a8b68859b..a7917ad4e 100644 --- a/OpenPGP-Keychain/src/main/res/layout/api_app_settings_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/api_app_settings_fragment.xml @@ -2,6 +2,7 @@ @@ -42,24 +43,13 @@ android:layout_height="wrap_content" tools:layout="@layout/select_secret_key_layout_fragment" /> - - - + android:layout_height="match_parent" + custom:foldedLabel="@string/btn_encryption_advanced_settings_show" + custom:unFoldedLabel="@string/btn_encryption_advanced_settings_hide" + custom:foldedIcon="fa-chevron-right" + custom:unFoldedIcon="fa-chevron-down"> - + + + \ No newline at end of file -- cgit v1.2.3 From 12402d9a513e83755aa657acd29dd7382f355d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 23 Mar 2014 01:16:56 +0100 Subject: New db table for api accounts --- .../keychain/provider/KeychainContract.java | 4 ++++ .../keychain/provider/KeychainDatabase.java | 27 +++++++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java index 5f2354c24..de51cebbb 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java @@ -56,10 +56,14 @@ public class KeychainContract { interface ApiAppsColumns { String PACKAGE_NAME = "package_name"; String PACKAGE_SIGNATURE = "package_signature"; + } + + interface ApiAppsAccountsColumns { String KEY_ID = "key_id"; // not a database id String ENCRYPTION_ALGORITHM = "encryption_algorithm"; String HASH_ALORITHM = "hash_algorithm"; String COMPRESSION = "compression"; + String PACKAGE_NAME = "package_name"; // foreign key to api_apps.package_name } public static final class KeyTypes { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java index 031a7d5ae..f7c9fe79d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java @@ -23,6 +23,7 @@ import android.database.sqlite.SQLiteOpenHelper; import android.provider.BaseColumns; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsColumns; +import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsAccountsColumns; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingsColumns; import org.sufficientlysecure.keychain.provider.KeychainContract.KeysColumns; import org.sufficientlysecure.keychain.provider.KeychainContract.UserIdsColumns; @@ -30,13 +31,14 @@ import org.sufficientlysecure.keychain.util.Log; public class KeychainDatabase extends SQLiteOpenHelper { private static final String DATABASE_NAME = "apg.db"; - private static final int DATABASE_VERSION = 7; + private static final int DATABASE_VERSION = 8; public interface Tables { String KEY_RINGS = "key_rings"; String KEYS = "keys"; String USER_IDS = "user_ids"; String API_APPS = "api_apps"; + String API_APPS_ACCOUNTS = "api_apps_accounts"; } private static final String CREATE_KEY_RINGS = "CREATE TABLE IF NOT EXISTS " + Tables.KEY_RINGS @@ -76,11 +78,17 @@ public class KeychainDatabase extends SQLiteOpenHelper { private static final String CREATE_API_APPS = "CREATE TABLE IF NOT EXISTS " + Tables.API_APPS + " (" + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + ApiAppsColumns.PACKAGE_NAME + " TEXT UNIQUE, " - + ApiAppsColumns.PACKAGE_SIGNATURE + " BLOB, " - + ApiAppsColumns.KEY_ID + " INT64, " - + ApiAppsColumns.ENCRYPTION_ALGORITHM + " INTEGER, " - + ApiAppsColumns.HASH_ALORITHM + " INTEGER, " - + ApiAppsColumns.COMPRESSION + " INTEGER)"; + + ApiAppsColumns.PACKAGE_SIGNATURE + " BLOB)"; + + private static final String CREATE_API_APPS_ACCOUNTS = "CREATE TABLE IF NOT EXISTS " + Tables.API_APPS_ACCOUNTS + + " (" + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + + ApiAppsAccountsColumns.KEY_ID + " INT64, " + + ApiAppsAccountsColumns.ENCRYPTION_ALGORITHM + " INTEGER, " + + ApiAppsAccountsColumns.HASH_ALORITHM + " INTEGER, " + + ApiAppsAccountsColumns.COMPRESSION + " INTEGER" + + ApiAppsAccountsColumns.PACKAGE_NAME + " TEXT NOT NULL, FOREIGN KEY(" + + ApiAppsAccountsColumns.PACKAGE_NAME + ") REFERENCES " + Tables.API_APPS + "(" + + ApiAppsColumns.PACKAGE_NAME + ") ON DELETE CASCADE)"; KeychainDatabase(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); @@ -94,6 +102,7 @@ public class KeychainDatabase extends SQLiteOpenHelper { db.execSQL(CREATE_KEYS); db.execSQL(CREATE_USER_IDS); db.execSQL(CREATE_API_APPS); + db.execSQL(CREATE_API_APPS_ACCOUNTS); } @Override @@ -133,6 +142,12 @@ public class KeychainDatabase extends SQLiteOpenHelper { db.execSQL("ALTER TABLE " + Tables.KEYS + " ADD COLUMN " + KeysColumns.FINGERPRINT + " BLOB;"); break; + case 7: + // new db layout for api apps + db.execSQL("DROP TABLE IF EXISTS " + Tables.API_APPS); + db.execSQL(CREATE_API_APPS); + db.execSQL(CREATE_API_APPS_ACCOUNTS); + break; default: break; -- cgit v1.2.3 From 9555ae3bc1287daa27151456a1f266bdc1640e51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 23 Mar 2014 01:26:49 +0100 Subject: Move classes for OpenPGP API into remote package --- OpenPGP-Keychain/src/main/AndroidManifest.xml | 8 +- .../keychain/provider/ProviderHelper.java | 10 +- .../keychain/remote/AppSettings.java | 94 +++++ .../keychain/remote/OpenPgpService.java | 463 +++++++++++++++++++++ .../keychain/remote/RemoteService.java | 233 +++++++++++ .../remote/WrongPackageSignatureException.java | 27 ++ .../keychain/remote/ui/AppSettingsActivity.java | 109 +++++ .../keychain/remote/ui/AppSettingsFragment.java | 202 +++++++++ .../keychain/remote/ui/RegisteredAppsAdapter.java | 75 ++++ .../remote/ui/RegisteredAppsListActivity.java | 35 ++ .../remote/ui/RegisteredAppsListFragment.java | 101 +++++ .../keychain/remote/ui/RemoteServiceActivity.java | 279 +++++++++++++ .../keychain/service/remote/AppSettings.java | 94 ----- .../service/remote/AppSettingsActivity.java | 108 ----- .../service/remote/AppSettingsFragment.java | 201 --------- .../keychain/service/remote/OpenPgpService.java | 462 -------------------- .../service/remote/RegisteredAppsAdapter.java | 75 ---- .../service/remote/RegisteredAppsListActivity.java | 35 -- .../service/remote/RegisteredAppsListFragment.java | 101 ----- .../keychain/service/remote/RemoteService.java | 232 ----------- .../service/remote/RemoteServiceActivity.java | 278 ------------- .../remote/WrongPackageSignatureException.java | 27 -- 22 files changed, 1627 insertions(+), 1622 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/AppSettings.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/WrongPackageSignatureException.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsFragment.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsAdapter.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsListActivity.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsListFragment.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java delete mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettings.java delete mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsActivity.java delete mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java delete mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java delete mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsAdapter.java delete mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListActivity.java delete mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListFragment.java delete mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteService.java delete mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteServiceActivity.java delete mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/WrongPackageSignatureException.java diff --git a/OpenPGP-Keychain/src/main/AndroidManifest.xml b/OpenPGP-Keychain/src/main/AndroidManifest.xml index b1fbcf555..e2ed8c5e4 100644 --- a/OpenPGP-Keychain/src/main/AndroidManifest.xml +++ b/OpenPGP-Keychain/src/main/AndroidManifest.xml @@ -384,24 +384,24 @@ diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java index 2fa903fe2..e0d007de7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -33,7 +33,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables; -import org.sufficientlysecure.keychain.service.remote.AppSettings; +import org.sufficientlysecure.keychain.remote.AppSettings; import org.sufficientlysecure.keychain.util.IterableIterator; import org.sufficientlysecure.keychain.util.Log; @@ -801,10 +801,10 @@ public class ProviderHelper { ContentValues values = new ContentValues(); values.put(ApiApps.PACKAGE_NAME, appSettings.getPackageName()); values.put(ApiApps.PACKAGE_SIGNATURE, appSettings.getPackageSignature()); - values.put(ApiApps.KEY_ID, appSettings.getKeyId()); - values.put(ApiApps.COMPRESSION, appSettings.getCompression()); - values.put(ApiApps.ENCRYPTION_ALGORITHM, appSettings.getEncryptionAlgorithm()); - values.put(ApiApps.HASH_ALORITHM, appSettings.getHashAlgorithm()); +// values.put(ApiApps.KEY_ID, appSettings.getKeyId()); +// values.put(ApiApps.COMPRESSION, appSettings.getCompression()); +// values.put(ApiApps.ENCRYPTION_ALGORITHM, appSettings.getEncryptionAlgorithm()); +// values.put(ApiApps.HASH_ALORITHM, appSettings.getHashAlgorithm()); return values; } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/AppSettings.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/AppSettings.java new file mode 100644 index 000000000..ad48a402b --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/AppSettings.java @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2013 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.remote; + +import org.spongycastle.bcpg.HashAlgorithmTags; +import org.spongycastle.openpgp.PGPEncryptedData; +import org.sufficientlysecure.keychain.Id; + +public class AppSettings { + private String mPackageName; + private byte[] mPackageSignature; + private long mKeyId = Id.key.none; + private int mEncryptionAlgorithm; + private int mHashAlgorithm; + private int mCompression; + + public AppSettings() { + + } + + public AppSettings(String packageName, byte[] packageSignature) { + super(); + this.mPackageName = packageName; + this.mPackageSignature = packageSignature; + // defaults: + this.mEncryptionAlgorithm = PGPEncryptedData.AES_256; + this.mHashAlgorithm = HashAlgorithmTags.SHA512; + this.mCompression = Id.choice.compression.zlib; + } + + public String getPackageName() { + return mPackageName; + } + + public void setPackageName(String packageName) { + this.mPackageName = packageName; + } + + public byte[] getPackageSignature() { + return mPackageSignature; + } + + public void setPackageSignature(byte[] packageSignature) { + this.mPackageSignature = packageSignature; + } + + public long getKeyId() { + return mKeyId; + } + + public void setKeyId(long scretKeyId) { + this.mKeyId = scretKeyId; + } + + public int getEncryptionAlgorithm() { + return mEncryptionAlgorithm; + } + + public void setEncryptionAlgorithm(int encryptionAlgorithm) { + this.mEncryptionAlgorithm = encryptionAlgorithm; + } + + public int getHashAlgorithm() { + return mHashAlgorithm; + } + + public void setHashAlgorithm(int hashAlgorithm) { + this.mHashAlgorithm = hashAlgorithm; + } + + public int getCompression() { + return mCompression; + } + + public void setCompression(int compression) { + this.mCompression = compression; + } + +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java new file mode 100644 index 000000000..9b56a491a --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -0,0 +1,463 @@ +/* + * Copyright (C) 2013-2014 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.remote; + +import android.app.PendingIntent; +import android.content.Intent; +import android.database.Cursor; +import android.net.Uri; +import android.os.IBinder; +import android.os.ParcelFileDescriptor; +import org.openintents.openpgp.IOpenPgpService; +import org.openintents.openpgp.OpenPgpError; +import org.openintents.openpgp.OpenPgpSignatureResult; +import org.openintents.openpgp.util.OpenPgpApi; +import org.spongycastle.util.Arrays; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.Id; +import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify; +import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult; +import org.sufficientlysecure.keychain.pgp.PgpSignEncrypt; +import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; +import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.remote.ui.RemoteServiceActivity; +import org.sufficientlysecure.keychain.service.PassphraseCacheService; +import org.sufficientlysecure.keychain.util.InputData; +import org.sufficientlysecure.keychain.util.Log; + +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; + +public class OpenPgpService extends RemoteService { + + private static final int PRIVATE_REQUEST_CODE_PASSPHRASE = 551; + private static final int PRIVATE_REQUEST_CODE_USER_IDS = 552; + private static final int PRIVATE_REQUEST_CODE_GET_KEYS = 553; + + /** + * Search database for key ids based on emails. + * + * @param encryptionUserIds + * @return + */ + private Intent getKeyIdsFromEmails(Intent data, String[] encryptionUserIds) { + // find key ids to given emails in database + ArrayList keyIds = new ArrayList(); + + boolean missingUserIdsCheck = false; + boolean dublicateUserIdsCheck = false; + ArrayList missingUserIds = new ArrayList(); + ArrayList dublicateUserIds = new ArrayList(); + + for (String email : encryptionUserIds) { + Uri uri = KeychainContract.KeyRings.buildPublicKeyRingsByEmailsUri(email); + Cursor cur = getContentResolver().query(uri, null, null, null, null); + if (cur.moveToFirst()) { + long id = cur.getLong(cur.getColumnIndex(KeychainContract.KeyRings.MASTER_KEY_ID)); + keyIds.add(id); + } else { + missingUserIdsCheck = true; + missingUserIds.add(email); + Log.d(Constants.TAG, "user id missing"); + } + if (cur.moveToNext()) { + dublicateUserIdsCheck = true; + dublicateUserIds.add(email); + Log.d(Constants.TAG, "more than one user id with the same email"); + } + } + + // convert to long[] + long[] keyIdsArray = new long[keyIds.size()]; + for (int i = 0; i < keyIdsArray.length; i++) { + keyIdsArray[i] = keyIds.get(i); + } + + // allow the user to verify pub key selection + if (missingUserIdsCheck || dublicateUserIdsCheck) { + // build PendingIntent + Intent intent = new Intent(getBaseContext(), RemoteServiceActivity.class); + intent.setAction(RemoteServiceActivity.ACTION_SELECT_PUB_KEYS); + intent.putExtra(RemoteServiceActivity.EXTRA_SELECTED_MASTER_KEY_IDS, keyIdsArray); + intent.putExtra(RemoteServiceActivity.EXTRA_MISSING_USER_IDS, missingUserIds); + intent.putExtra(RemoteServiceActivity.EXTRA_DUBLICATE_USER_IDS, dublicateUserIds); + intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); + + PendingIntent pi = PendingIntent.getActivity + (getBaseContext(), PRIVATE_REQUEST_CODE_USER_IDS, intent, 0); + + // return PendingIntent to be executed by client + Intent result = new Intent(); + result.putExtra(OpenPgpApi.RESULT_INTENT, pi); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED); + return result; + } + + if (keyIdsArray.length == 0) { + return null; + } + + Intent result = new Intent(); + result.putExtra(OpenPgpApi.EXTRA_KEY_IDS, keyIdsArray); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS); + return result; + } + + private Intent getPassphraseBundleIntent(Intent data, long keyId) { + // build PendingIntent for passphrase input + Intent intent = new Intent(getBaseContext(), RemoteServiceActivity.class); + intent.setAction(RemoteServiceActivity.ACTION_CACHE_PASSPHRASE); + intent.putExtra(RemoteServiceActivity.EXTRA_SECRET_KEY_ID, keyId); + // pass params through to activity that it can be returned again later to repeat pgp operation + intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); + PendingIntent pi = PendingIntent.getActivity + (getBaseContext(), PRIVATE_REQUEST_CODE_PASSPHRASE, intent, 0); + + // return PendingIntent to be executed by client + Intent result = new Intent(); + result.putExtra(OpenPgpApi.RESULT_INTENT, pi); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED); + return result; + } + + private Intent signImpl(Intent data, ParcelFileDescriptor input, + ParcelFileDescriptor output, AppSettings appSettings) { + try { + boolean asciiArmor = data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); + + // get passphrase from cache, if key has "no" passphrase, this returns an empty String + String passphrase; + if (data.hasExtra(OpenPgpApi.EXTRA_PASSPHRASE)) { + passphrase = data.getStringExtra(OpenPgpApi.EXTRA_PASSPHRASE); + } else { + passphrase = PassphraseCacheService.getCachedPassphrase(getContext(), appSettings.getKeyId()); + } + if (passphrase == null) { + // get PendingIntent for passphrase input, add it to given params and return to client + Intent passphraseBundle = getPassphraseBundleIntent(data, appSettings.getKeyId()); + return passphraseBundle; + } + + // Get Input- and OutputStream from ParcelFileDescriptor + InputStream is = new ParcelFileDescriptor.AutoCloseInputStream(input); + OutputStream os = new ParcelFileDescriptor.AutoCloseOutputStream(output); + try { + long inputLength = is.available(); + InputData inputData = new InputData(is, inputLength); + + // sign-only + PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder(getContext(), inputData, os); + builder.enableAsciiArmorOutput(asciiArmor) + .signatureHashAlgorithm(appSettings.getHashAlgorithm()) + .signatureForceV3(false) + .signatureKeyId(appSettings.getKeyId()) + .signaturePassphrase(passphrase); + builder.build().execute(); + } finally { + is.close(); + os.close(); + } + + Intent result = new Intent(); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS); + return result; + } catch (Exception e) { + Intent result = new Intent(); + result.putExtra(OpenPgpApi.RESULT_ERROR, + new OpenPgpError(OpenPgpError.GENERIC_ERROR, e.getMessage())); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); + return result; + } + } + + private Intent encryptAndSignImpl(Intent data, ParcelFileDescriptor input, + ParcelFileDescriptor output, AppSettings appSettings, boolean sign) { + try { + boolean asciiArmor = data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); + + long[] keyIds; + if (data.hasExtra(OpenPgpApi.EXTRA_KEY_IDS)) { + keyIds = data.getLongArrayExtra(OpenPgpApi.EXTRA_KEY_IDS); + } else if (data.hasExtra(OpenPgpApi.EXTRA_USER_IDS)) { + // get key ids based on given user ids + String[] userIds = data.getStringArrayExtra(OpenPgpApi.EXTRA_USER_IDS); + // give params through to activity... + Intent result = getKeyIdsFromEmails(data, userIds); + + if (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0) == OpenPgpApi.RESULT_CODE_SUCCESS) { + keyIds = result.getLongArrayExtra(OpenPgpApi.EXTRA_KEY_IDS); + } else { + // if not success -> result contains a PendingIntent for user interaction + return result; + } + } else { + Intent result = new Intent(); + result.putExtra(OpenPgpApi.RESULT_ERROR, + new OpenPgpError(OpenPgpError.GENERIC_ERROR, + "Missing parameter user_ids or key_ids!")); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); + return result; + } + + // add own key for encryption + keyIds = Arrays.copyOf(keyIds, keyIds.length + 1); + keyIds[keyIds.length - 1] = appSettings.getKeyId(); + + // build InputData and write into OutputStream + // Get Input- and OutputStream from ParcelFileDescriptor + InputStream is = new ParcelFileDescriptor.AutoCloseInputStream(input); + OutputStream os = new ParcelFileDescriptor.AutoCloseOutputStream(output); + try { + long inputLength = is.available(); + InputData inputData = new InputData(is, inputLength); + + PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder(getContext(), inputData, os); + builder.enableAsciiArmorOutput(asciiArmor) + .compressionId(appSettings.getCompression()) + .symmetricEncryptionAlgorithm(appSettings.getEncryptionAlgorithm()) + .encryptionKeyIds(keyIds); + + if (sign) { + String passphrase; + if (data.hasExtra(OpenPgpApi.EXTRA_PASSPHRASE)) { + passphrase = data.getStringExtra(OpenPgpApi.EXTRA_PASSPHRASE); + } else { + passphrase = PassphraseCacheService.getCachedPassphrase(getContext(), + appSettings.getKeyId()); + } + if (passphrase == null) { + // get PendingIntent for passphrase input, add it to given params and return to client + Intent passphraseBundle = getPassphraseBundleIntent(data, appSettings.getKeyId()); + return passphraseBundle; + } + + // sign and encrypt + builder.signatureHashAlgorithm(appSettings.getHashAlgorithm()) + .signatureForceV3(false) + .signatureKeyId(appSettings.getKeyId()) + .signaturePassphrase(passphrase); + } else { + // encrypt only + builder.signatureKeyId(Id.key.none); + } + // execute PGP operation! + builder.build().execute(); + } finally { + is.close(); + os.close(); + } + + Intent result = new Intent(); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS); + return result; + } catch (Exception e) { + Intent result = new Intent(); + result.putExtra(OpenPgpApi.RESULT_ERROR, + new OpenPgpError(OpenPgpError.GENERIC_ERROR, e.getMessage())); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); + return result; + } + } + + private Intent decryptAndVerifyImpl(Intent data, ParcelFileDescriptor input, + ParcelFileDescriptor output, AppSettings appSettings) { + try { + // Get Input- and OutputStream from ParcelFileDescriptor + InputStream is = new ParcelFileDescriptor.AutoCloseInputStream(input); + OutputStream os = new ParcelFileDescriptor.AutoCloseOutputStream(output); + + Intent result = new Intent(); + try { + + String passphrase = data.getStringExtra(OpenPgpApi.EXTRA_PASSPHRASE); + long inputLength = is.available(); + InputData inputData = new InputData(is, inputLength); + + PgpDecryptVerify.Builder builder = new PgpDecryptVerify.Builder(this, inputData, os); + builder.assumeSymmetric(false) // no support for symmetric encryption + // allow only the private key for this app for decryption + .enforcedKeyId(appSettings.getKeyId()) + .passphrase(passphrase); + + // TODO: currently does not support binary signed-only content + PgpDecryptVerifyResult decryptVerifyResult = builder.build().execute(); + + if (decryptVerifyResult.isKeyPassphraseNeeded()) { + // get PendingIntent for passphrase input, add it to given params and return to client + Intent passphraseBundle = getPassphraseBundleIntent(data, appSettings.getKeyId()); + return passphraseBundle; + } else if (decryptVerifyResult.isSymmetricPassphraseNeeded()) { + throw new PgpGeneralException("Decryption of symmetric content not supported by API!"); + } + + OpenPgpSignatureResult signatureResult = decryptVerifyResult.getSignatureResult(); + if (signatureResult != null) { + if (signatureResult.getStatus() == OpenPgpSignatureResult.SIGNATURE_UNKNOWN_PUB_KEY) { + // If signature is unknown we return an _additional_ PendingIntent + // to retrieve the missing key + // TODO!!! + Intent intent = new Intent(getBaseContext(), RemoteServiceActivity.class); + intent.setAction(RemoteServiceActivity.ACTION_ERROR_MESSAGE); + intent.putExtra(RemoteServiceActivity.EXTRA_ERROR_MESSAGE, "todo"); + intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); + + PendingIntent pi = PendingIntent.getActivity(getBaseContext(), + PRIVATE_REQUEST_CODE_GET_KEYS, intent, 0); + + result.putExtra(OpenPgpApi.RESULT_INTENT, pi); + } + + result.putExtra(OpenPgpApi.RESULT_SIGNATURE, signatureResult); + } + + } finally { + is.close(); + os.close(); + } + + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS); + return result; + } catch (Exception e) { + Intent result = new Intent(); + result.putExtra(OpenPgpApi.RESULT_ERROR, + new OpenPgpError(OpenPgpError.GENERIC_ERROR, e.getMessage())); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); + return result; + } + } + + private Intent getKeyImpl(Intent data) { + try { + long keyId = data.getLongExtra(OpenPgpApi.EXTRA_KEY_ID, 0); + + if (ProviderHelper.getPGPPublicKeyByKeyId(this, keyId) == null) { + Intent result = new Intent(); + + // If keys are not in db we return an additional PendingIntent + // to retrieve the missing key + // TODO!!! + Intent intent = new Intent(getBaseContext(), RemoteServiceActivity.class); + intent.setAction(RemoteServiceActivity.ACTION_ERROR_MESSAGE); + intent.putExtra(RemoteServiceActivity.EXTRA_ERROR_MESSAGE, "todo"); + intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); + + PendingIntent pi = PendingIntent.getActivity(getBaseContext(), + PRIVATE_REQUEST_CODE_GET_KEYS, intent, 0); + + result.putExtra(OpenPgpApi.RESULT_INTENT, pi); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED); + return result; + } else { + Intent result = new Intent(); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS); + return result; + } + } catch (Exception e) { + Intent result = new Intent(); + result.putExtra(OpenPgpApi.RESULT_ERROR, + new OpenPgpError(OpenPgpError.GENERIC_ERROR, e.getMessage())); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); + return result; + } + } + + private Intent getKeyIdsImpl(Intent data) { + // get key ids based on given user ids + String[] userIds = data.getStringArrayExtra(OpenPgpApi.EXTRA_USER_IDS); + Intent result = getKeyIdsFromEmails(data, userIds); + return result; + } + + /** + * Check requirements: + * - params != null + * - has supported API version + * - is allowed to call the service (access has been granted) + * + * @param data + * @return null if everything is okay, or a Bundle with an error/PendingIntent + */ + private Intent checkRequirements(Intent data) { + // params Bundle is required! + if (data == null) { + Intent result = new Intent(); + OpenPgpError error = new OpenPgpError(OpenPgpError.GENERIC_ERROR, "params Bundle required!"); + result.putExtra(OpenPgpApi.RESULT_ERROR, error); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); + return result; + } + + // version code is required and needs to correspond to version code of service! + if (data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) != OpenPgpApi.API_VERSION) { + Intent result = new Intent(); + OpenPgpError error = new OpenPgpError + (OpenPgpError.INCOMPATIBLE_API_VERSIONS, "Incompatible API versions!"); + result.putExtra(OpenPgpApi.RESULT_ERROR, error); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); + return result; + } + + // check if caller is allowed to access openpgp keychain + Intent result = isAllowed(data); + if (result != null) { + return result; + } + + return null; + } + + // TODO: multi-threading + private final IOpenPgpService.Stub mBinder = new IOpenPgpService.Stub() { + + @Override + public Intent execute(Intent data, ParcelFileDescriptor input, ParcelFileDescriptor output) { + Intent errorResult = checkRequirements(data); + if (errorResult != null) { + return errorResult; + } + + final AppSettings appSettings = getAppSettings(); + + String action = data.getAction(); + if (OpenPgpApi.ACTION_SIGN.equals(action)) { + return signImpl(data, input, output, appSettings); + } else if (OpenPgpApi.ACTION_ENCRYPT.equals(action)) { + return encryptAndSignImpl(data, input, output, appSettings, false); + } else if (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(action)) { + return encryptAndSignImpl(data, input, output, appSettings, true); + } else if (OpenPgpApi.ACTION_DECRYPT_VERIFY.equals(action)) { + return decryptAndVerifyImpl(data, input, output, appSettings); + } else if (OpenPgpApi.ACTION_GET_KEY.equals(action)) { + return getKeyImpl(data); + } else if (OpenPgpApi.ACTION_GET_KEY_IDS.equals(action)) { + return getKeyIdsImpl(data); + } else { + return null; + } + } + + }; + + @Override + public IBinder onBind(Intent intent) { + return mBinder; + } + +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java new file mode 100644 index 000000000..434fe84c1 --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java @@ -0,0 +1,233 @@ +/* + * Copyright (C) 2013-2014 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.remote; + +import android.app.PendingIntent; +import android.app.Service; +import android.content.Context; +import android.content.Intent; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.content.pm.Signature; +import android.net.Uri; +import android.os.Binder; +import org.openintents.openpgp.OpenPgpError; +import org.openintents.openpgp.util.OpenPgpApi; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.remote.ui.RemoteServiceActivity; +import org.sufficientlysecure.keychain.util.Log; + +import java.util.ArrayList; +import java.util.Arrays; + +/** + * Abstract service class for remote APIs that handle app registration and user input. + */ +public abstract class RemoteService extends Service { + Context mContext; + + private static final int PRIVATE_REQUEST_CODE_REGISTER = 651; + private static final int PRIVATE_REQUEST_CODE_ERROR = 652; + + + public Context getContext() { + return mContext; + } + + protected Intent isAllowed(Intent data) { + try { + if (isCallerAllowed(false)) { + + return null; + } else { + String[] callingPackages = getPackageManager().getPackagesForUid( + Binder.getCallingUid()); + // TODO: currently simply uses first entry + String packageName = callingPackages[0]; + + byte[] packageSignature; + try { + packageSignature = getPackageSignature(packageName); + } catch (NameNotFoundException e) { + Log.e(Constants.TAG, "Should not happen, returning!", e); + // return error + Intent result = new Intent(); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); + result.putExtra(OpenPgpApi.RESULT_ERROR, + new OpenPgpError(OpenPgpError.GENERIC_ERROR, e.getMessage())); + return result; + } + Log.e(Constants.TAG, "Not allowed to use service! return PendingIntent for registration!"); + + Intent intent = new Intent(getBaseContext(), RemoteServiceActivity.class); + intent.setAction(RemoteServiceActivity.ACTION_REGISTER); + intent.putExtra(RemoteServiceActivity.EXTRA_PACKAGE_NAME, packageName); + intent.putExtra(RemoteServiceActivity.EXTRA_PACKAGE_SIGNATURE, packageSignature); + intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); + + PendingIntent pi = PendingIntent.getActivity(getBaseContext(), + PRIVATE_REQUEST_CODE_REGISTER, intent, 0); + + // return PendingIntent to be executed by client + Intent result = new Intent(); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED); + result.putExtra(OpenPgpApi.RESULT_INTENT, pi); + + return result; + } + } catch (WrongPackageSignatureException e) { + Log.e(Constants.TAG, "wrong signature!", e); + + Intent intent = new Intent(getBaseContext(), RemoteServiceActivity.class); + intent.setAction(RemoteServiceActivity.ACTION_ERROR_MESSAGE); + intent.putExtra(RemoteServiceActivity.EXTRA_ERROR_MESSAGE, + getString(R.string.api_error_wrong_signature)); + intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); + + PendingIntent pi = PendingIntent.getActivity(getBaseContext(), + PRIVATE_REQUEST_CODE_ERROR, intent, 0); + + // return PendingIntent to be executed by client + Intent result = new Intent(); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED); + result.putExtra(OpenPgpApi.RESULT_INTENT, pi); + + return result; + } + } + + private byte[] getPackageSignature(String packageName) throws NameNotFoundException { + PackageInfo pkgInfo = getPackageManager().getPackageInfo(packageName, + PackageManager.GET_SIGNATURES); + Signature[] signatures = pkgInfo.signatures; + // TODO: Only first signature?! + byte[] packageSignature = signatures[0].toByteArray(); + + return packageSignature; + } + + /** + * Retrieves AppSettings from database for the application calling this remote service + * + * @return + */ + protected AppSettings getAppSettings() { + String[] callingPackages = getPackageManager().getPackagesForUid(Binder.getCallingUid()); + + // get app settings for this package + for (int i = 0; i < callingPackages.length; i++) { + String currentPkg = callingPackages[i]; + + Uri uri = KeychainContract.ApiApps.buildByPackageNameUri(currentPkg); + + AppSettings settings = ProviderHelper.getApiAppSettings(this, uri); + + if (settings != null) { + return settings; + } + } + + return null; + } + + /** + * Checks if process that binds to this service (i.e. the package name corresponding to the + * process) is in the list of allowed package names. + * + * @param allowOnlySelf allow only Keychain app itself + * @return true if process is allowed to use this service + * @throws WrongPackageSignatureException + */ + private boolean isCallerAllowed(boolean allowOnlySelf) throws WrongPackageSignatureException { + return isUidAllowed(Binder.getCallingUid(), allowOnlySelf); + } + + private boolean isUidAllowed(int uid, boolean allowOnlySelf) + throws WrongPackageSignatureException { + if (android.os.Process.myUid() == uid) { + return true; + } + if (allowOnlySelf) { // barrier + return false; + } + + String[] callingPackages = getPackageManager().getPackagesForUid(uid); + + // is calling package allowed to use this service? + for (int i = 0; i < callingPackages.length; i++) { + String currentPkg = callingPackages[i]; + + if (isPackageAllowed(currentPkg)) { + return true; + } + } + + Log.d(Constants.TAG, "Caller is NOT allowed!"); + return false; + } + + /** + * Checks if packageName is a registered app for the API. Does not return true for own package! + * + * @param packageName + * @return + * @throws WrongPackageSignatureException + */ + private boolean isPackageAllowed(String packageName) throws WrongPackageSignatureException { + Log.d(Constants.TAG, "packageName: " + packageName); + + ArrayList allowedPkgs = ProviderHelper.getRegisteredApiApps(this); + Log.d(Constants.TAG, "allowed: " + allowedPkgs); + + // check if package is allowed to use our service + if (allowedPkgs.contains(packageName)) { + Log.d(Constants.TAG, "Package is allowed! packageName: " + packageName); + + // check package signature + byte[] currentSig; + try { + currentSig = getPackageSignature(packageName); + } catch (NameNotFoundException e) { + throw new WrongPackageSignatureException(e.getMessage()); + } + + byte[] storedSig = ProviderHelper.getApiAppSignature(this, packageName); + if (Arrays.equals(currentSig, storedSig)) { + Log.d(Constants.TAG, + "Package signature is correct! (equals signature from database)"); + return true; + } else { + throw new WrongPackageSignatureException( + "PACKAGE NOT ALLOWED! Signature wrong! (Signature not equals signature from database)"); + } + } + + return false; + } + + @Override + public void onCreate() { + super.onCreate(); + mContext = this; + } + +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/WrongPackageSignatureException.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/WrongPackageSignatureException.java new file mode 100644 index 000000000..6f44a65e9 --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/WrongPackageSignatureException.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2013 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.remote; + +public class WrongPackageSignatureException extends Exception { + + private static final long serialVersionUID = -8294642703122196028L; + + public WrongPackageSignatureException(String message) { + super(message); + } +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java new file mode 100644 index 000000000..d544455ec --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2013 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.remote.ui; + +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.support.v7.app.ActionBarActivity; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.ActionBarHelper; +import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.remote.AppSettings; +import org.sufficientlysecure.keychain.util.Log; + +public class AppSettingsActivity extends ActionBarActivity { + private Uri mAppUri; + + private AppSettingsFragment mSettingsFragment; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Inflate a "Done" custom action bar + ActionBarHelper.setOneButtonView(getSupportActionBar(), + R.string.api_settings_save, R.drawable.ic_action_done, + new View.OnClickListener() { + @Override + public void onClick(View v) { + // "Done" + save(); + } + }); + + setContentView(R.layout.api_app_settings_activity); + + mSettingsFragment = (AppSettingsFragment) getSupportFragmentManager().findFragmentById( + R.id.api_app_settings_fragment); + + Intent intent = getIntent(); + mAppUri = intent.getData(); + if (mAppUri == null) { + Log.e(Constants.TAG, "Intent data missing. Should be Uri of app!"); + finish(); + return; + } else { + Log.d(Constants.TAG, "uri: " + mAppUri); + loadData(mAppUri); + } + } + + @Override + public boolean onCreateOptionsMenu(Menu menu) { + super.onCreateOptionsMenu(menu); + getMenuInflater().inflate(R.menu.api_app_settings, menu); + return true; + } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_api_settings_revoke: + revokeAccess(); + return true; + case R.id.menu_api_settings_cancel: + finish(); + return true; + } + return super.onOptionsItemSelected(item); + } + + private void loadData(Uri appUri) { + AppSettings settings = ProviderHelper.getApiAppSettings(this, appUri); + mSettingsFragment.setAppSettings(settings); + } + + private void revokeAccess() { + if (getContentResolver().delete(mAppUri, null, null) <= 0) { + throw new RuntimeException(); + } + finish(); + } + + private void save() { + ProviderHelper.updateApiApp(this, mSettingsFragment.getAppSettings(), mAppUri); + + finish(); + } + +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsFragment.java new file mode 100644 index 000000000..8e8f3827b --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsFragment.java @@ -0,0 +1,202 @@ +/* + * Copyright (C) 2013-2014 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.remote.ui; + +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemSelectedListener; +import android.widget.ImageView; +import android.widget.Spinner; +import android.widget.TextView; + +import org.spongycastle.util.encoders.Hex; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.remote.AppSettings; +import org.sufficientlysecure.keychain.ui.SelectSecretKeyLayoutFragment; +import org.sufficientlysecure.keychain.ui.adapter.KeyValueSpinnerAdapter; +import org.sufficientlysecure.keychain.util.AlgorithmNames; +import org.sufficientlysecure.keychain.util.Log; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class AppSettingsFragment extends Fragment implements + SelectSecretKeyLayoutFragment.SelectSecretKeyCallback { + + // model + private AppSettings mAppSettings; + + // view + private TextView mAppNameView; + private ImageView mAppIconView; + private Spinner mEncryptionAlgorithm; + private Spinner mHashAlgorithm; + private Spinner mCompression; + private TextView mPackageName; + private TextView mPackageSignature; + + private SelectSecretKeyLayoutFragment mSelectKeyFragment; + + KeyValueSpinnerAdapter mEncryptionAdapter; + KeyValueSpinnerAdapter mHashAdapter; + KeyValueSpinnerAdapter mCompressionAdapter; + + public AppSettings getAppSettings() { + return mAppSettings; + } + + public void setAppSettings(AppSettings appSettings) { + this.mAppSettings = appSettings; + setPackage(appSettings.getPackageName()); + mPackageName.setText(appSettings.getPackageName()); + + try { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + md.update(appSettings.getPackageSignature()); + byte[] digest = md.digest(); + String signature = new String(Hex.encode(digest)); + + mPackageSignature.setText(signature); + } catch (NoSuchAlgorithmException e) { + Log.e(Constants.TAG, "Should not happen!", e); + } + + mSelectKeyFragment.selectKey(appSettings.getKeyId()); + mEncryptionAlgorithm.setSelection(mEncryptionAdapter.getPosition(appSettings + .getEncryptionAlgorithm())); + mHashAlgorithm.setSelection(mHashAdapter.getPosition(appSettings.getHashAlgorithm())); + mCompression.setSelection(mCompressionAdapter.getPosition(appSettings.getCompression())); + } + + /** + * Inflate the layout for this fragment + */ + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.api_app_settings_fragment, container, false); + initView(view); + return view; + } + + /** + * Set error String on key selection + * + * @param error + */ + public void setErrorOnSelectKeyFragment(String error) { + mSelectKeyFragment.setError(error); + } + + private void initView(View view) { + mSelectKeyFragment = (SelectSecretKeyLayoutFragment) getFragmentManager().findFragmentById( + R.id.api_app_settings_select_key_fragment); + mSelectKeyFragment.setCallback(this); + + mAppNameView = (TextView) view.findViewById(R.id.api_app_settings_app_name); + mAppIconView = (ImageView) view.findViewById(R.id.api_app_settings_app_icon); + mEncryptionAlgorithm = (Spinner) view + .findViewById(R.id.api_app_settings_encryption_algorithm); + mHashAlgorithm = (Spinner) view.findViewById(R.id.api_app_settings_hash_algorithm); + mCompression = (Spinner) view.findViewById(R.id.api_app_settings_compression); + mPackageName = (TextView) view.findViewById(R.id.api_app_settings_package_name); + mPackageSignature = (TextView) view.findViewById(R.id.api_app_settings_package_signature); + + AlgorithmNames algorithmNames = new AlgorithmNames(getActivity()); + + mEncryptionAdapter = new KeyValueSpinnerAdapter(getActivity(), + algorithmNames.getEncryptionNames()); + mEncryptionAlgorithm.setAdapter(mEncryptionAdapter); + mEncryptionAlgorithm.setOnItemSelectedListener(new OnItemSelectedListener() { + + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + mAppSettings.setEncryptionAlgorithm((int) id); + } + + @Override + public void onNothingSelected(AdapterView parent) { + } + }); + + mHashAdapter = new KeyValueSpinnerAdapter(getActivity(), algorithmNames.getHashNames()); + mHashAlgorithm.setAdapter(mHashAdapter); + mHashAlgorithm.setOnItemSelectedListener(new OnItemSelectedListener() { + + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + mAppSettings.setHashAlgorithm((int) id); + } + + @Override + public void onNothingSelected(AdapterView parent) { + } + }); + + mCompressionAdapter = new KeyValueSpinnerAdapter(getActivity(), + algorithmNames.getCompressionNames()); + mCompression.setAdapter(mCompressionAdapter); + mCompression.setOnItemSelectedListener(new OnItemSelectedListener() { + + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + mAppSettings.setCompression((int) id); + } + + @Override + public void onNothingSelected(AdapterView parent) { + } + }); + } + + private void setPackage(String packageName) { + PackageManager pm = getActivity().getApplicationContext().getPackageManager(); + + // get application name and icon from package manager + String appName = null; + Drawable appIcon = null; + try { + ApplicationInfo ai = pm.getApplicationInfo(packageName, 0); + + appName = (String) pm.getApplicationLabel(ai); + appIcon = pm.getApplicationIcon(ai); + } catch (final NameNotFoundException e) { + // fallback + appName = packageName; + } + mAppNameView.setText(appName); + mAppIconView.setImageDrawable(appIcon); + } + + /** + * callback from select secret key fragment + */ + @Override + public void onKeySelected(long secretKeyId) { + mAppSettings.setKeyId(secretKeyId); + } + +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsAdapter.java new file mode 100644 index 000000000..c846343ab --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsAdapter.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2013 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.remote.ui; + +import android.content.Context; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.database.Cursor; +import android.support.v4.widget.CursorAdapter; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; + +public class RegisteredAppsAdapter extends CursorAdapter { + + private LayoutInflater mInflater; + private PackageManager mPM; + + public RegisteredAppsAdapter(Context context, Cursor c, int flags) { + super(context, c, flags); + + mInflater = LayoutInflater.from(context); + mPM = context.getApplicationContext().getPackageManager(); + } + + @Override + public void bindView(View view, Context context, Cursor cursor) { + TextView text = (TextView) view.findViewById(R.id.api_apps_adapter_item_name); + ImageView icon = (ImageView) view.findViewById(R.id.api_apps_adapter_item_icon); + + String packageName = cursor.getString(cursor.getColumnIndex(ApiApps.PACKAGE_NAME)); + if (packageName != null) { + // get application name + try { + ApplicationInfo ai = mPM.getApplicationInfo(packageName, 0); + + text.setText(mPM.getApplicationLabel(ai)); + icon.setImageDrawable(mPM.getApplicationIcon(ai)); + } catch (final NameNotFoundException e) { + // fallback + text.setText(packageName); + } + } else { + // fallback + text.setText(packageName); + } + + } + + @Override + public View newView(Context context, Cursor cursor, ViewGroup parent) { + return mInflater.inflate(R.layout.api_apps_adapter_list_item, null); + } + +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsListActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsListActivity.java new file mode 100644 index 000000000..79b3c8abc --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsListActivity.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2013 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.remote.ui; + +import android.os.Bundle; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.ui.DrawerActivity; + +public class RegisteredAppsListActivity extends DrawerActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.api_apps_list_activity); + + setupDrawerNavigation(savedInstanceState); + } + +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsListFragment.java new file mode 100644 index 000000000..99e73e510 --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsListFragment.java @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2013 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.remote.ui; + +import android.content.ContentUris; +import android.content.Intent; +import android.database.Cursor; +import android.net.Uri; +import android.os.Bundle; +import android.support.v4.app.ListFragment; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.CursorLoader; +import android.support.v4.content.Loader; +import android.view.View; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; + +public class RegisteredAppsListFragment extends ListFragment implements + LoaderManager.LoaderCallbacks { + + // This is the Adapter being used to display the list's data. + RegisteredAppsAdapter mAdapter; + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + getListView().setOnItemClickListener(new OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int position, long id) { + // edit app settings + Intent intent = new Intent(getActivity(), AppSettingsActivity.class); + intent.setData(ContentUris.withAppendedId(KeychainContract.ApiApps.CONTENT_URI, id)); + startActivity(intent); + } + }); + + // Give some text to display if there is no data. In a real + // application this would come from a resource. + setEmptyText(getString(R.string.api_no_apps)); + + // We have a menu item to show in action bar. + setHasOptionsMenu(true); + + // Create an empty adapter we will use to display the loaded data. + mAdapter = new RegisteredAppsAdapter(getActivity(), null, 0); + setListAdapter(mAdapter); + + // Prepare the loader. Either re-connect with an existing one, + // or start a new one. + getLoaderManager().initLoader(0, null, this); + } + + // These are the Contacts rows that we will retrieve. + static final String[] PROJECTION = new String[]{ApiApps._ID, ApiApps.PACKAGE_NAME}; + + public Loader onCreateLoader(int id, Bundle args) { + // This is called when a new Loader needs to be created. This + // sample only has one Loader, so we don't care about the ID. + // First, pick the base URI to use depending on whether we are + // currently filtering. + Uri baseUri = ApiApps.CONTENT_URI; + + // Now create and return a CursorLoader that will take care of + // creating a Cursor for the data being displayed. + return new CursorLoader(getActivity(), baseUri, PROJECTION, null, null, + ApiApps.PACKAGE_NAME + " COLLATE LOCALIZED ASC"); + } + + public void onLoadFinished(Loader loader, Cursor data) { + // Swap the new cursor in. (The framework will take care of closing the + // old cursor once we return.) + mAdapter.swapCursor(data); + } + + public void onLoaderReset(Loader loader) { + // This is called when the last Cursor provided to onLoadFinished() + // above is about to be closed. We need to make sure we are no + // longer using it. + mAdapter.swapCursor(null); + } + +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java new file mode 100644 index 000000000..3e19a8ef6 --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java @@ -0,0 +1,279 @@ +/* + * Copyright (C) 2013-2014 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.remote.ui; + +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.os.Messenger; +import android.support.v7.app.ActionBarActivity; +import android.view.View; +import org.openintents.openpgp.util.OpenPgpApi; +import org.sufficientlysecure.htmltextview.HtmlTextView; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.Id; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.ActionBarHelper; +import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; +import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.remote.AppSettings; +import org.sufficientlysecure.keychain.ui.SelectPublicKeyFragment; +import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; +import org.sufficientlysecure.keychain.util.Log; + +import java.util.ArrayList; + +public class RemoteServiceActivity extends ActionBarActivity { + + public static final String ACTION_REGISTER = Constants.INTENT_PREFIX + "API_ACTIVITY_REGISTER"; + public static final String ACTION_CACHE_PASSPHRASE = Constants.INTENT_PREFIX + + "API_ACTIVITY_CACHE_PASSPHRASE"; + public static final String ACTION_SELECT_PUB_KEYS = Constants.INTENT_PREFIX + + "API_ACTIVITY_SELECT_PUB_KEYS"; + public static final String ACTION_ERROR_MESSAGE = Constants.INTENT_PREFIX + + "API_ACTIVITY_ERROR_MESSAGE"; + + public static final String EXTRA_MESSENGER = "messenger"; + + public static final String EXTRA_DATA = "data"; + + // passphrase action + public static final String EXTRA_SECRET_KEY_ID = "secret_key_id"; + // register action + public static final String EXTRA_PACKAGE_NAME = "package_name"; + public static final String EXTRA_PACKAGE_SIGNATURE = "package_signature"; + // select pub keys action + public static final String EXTRA_SELECTED_MASTER_KEY_IDS = "master_key_ids"; + public static final String EXTRA_MISSING_USER_IDS = "missing_user_ids"; + public static final String EXTRA_DUBLICATE_USER_IDS = "dublicate_user_ids"; + // error message + public static final String EXTRA_ERROR_MESSAGE = "error_message"; + + // register view + private AppSettingsFragment mSettingsFragment; + // select pub keys view + private SelectPublicKeyFragment mSelectFragment; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + handleActions(getIntent(), savedInstanceState); + } + + protected void handleActions(Intent intent, Bundle savedInstanceState) { + + String action = intent.getAction(); + final Bundle extras = intent.getExtras(); + + + if (ACTION_REGISTER.equals(action)) { + final String packageName = extras.getString(EXTRA_PACKAGE_NAME); + final byte[] packageSignature = extras.getByteArray(EXTRA_PACKAGE_SIGNATURE); + + // Inflate a "Done"/"Cancel" custom action bar view + ActionBarHelper.setTwoButtonView(getSupportActionBar(), + R.string.api_register_allow, R.drawable.ic_action_done, + new View.OnClickListener() { + @Override + public void onClick(View v) { + // Allow + + // user needs to select a key! + if (mSettingsFragment.getAppSettings().getKeyId() == Id.key.none) { + mSettingsFragment.setErrorOnSelectKeyFragment( + getString(R.string.api_register_error_select_key)); + } else { + ProviderHelper.insertApiApp(RemoteServiceActivity.this, + mSettingsFragment.getAppSettings()); + + // give data through for new service call + Intent resultData = extras.getParcelable(EXTRA_DATA); + RemoteServiceActivity.this.setResult(RESULT_OK, resultData); + RemoteServiceActivity.this.finish(); + } + } + }, R.string.api_register_disallow, R.drawable.ic_action_cancel, + new View.OnClickListener() { + @Override + public void onClick(View v) { + // Disallow + RemoteServiceActivity.this.setResult(RESULT_CANCELED); + RemoteServiceActivity.this.finish(); + } + } + ); + + setContentView(R.layout.api_app_register_activity); + + mSettingsFragment = (AppSettingsFragment) getSupportFragmentManager().findFragmentById( + R.id.api_app_settings_fragment); + + AppSettings settings = new AppSettings(packageName, packageSignature); + mSettingsFragment.setAppSettings(settings); + } else if (ACTION_CACHE_PASSPHRASE.equals(action)) { + long secretKeyId = extras.getLong(EXTRA_SECRET_KEY_ID); + Intent resultData = extras.getParcelable(EXTRA_DATA); + + showPassphraseDialog(resultData, secretKeyId); + } else if (ACTION_SELECT_PUB_KEYS.equals(action)) { + long[] selectedMasterKeyIds = intent.getLongArrayExtra(EXTRA_SELECTED_MASTER_KEY_IDS); + ArrayList missingUserIds = intent + .getStringArrayListExtra(EXTRA_MISSING_USER_IDS); + ArrayList dublicateUserIds = intent + .getStringArrayListExtra(EXTRA_DUBLICATE_USER_IDS); + + // TODO: do this with spannable instead of HTML to prevent parsing failures with weird user ids + String text = "" + getString(R.string.api_select_pub_keys_text) + ""; + text += "

        "; + if (missingUserIds != null && missingUserIds.size() > 0) { + text += getString(R.string.api_select_pub_keys_missing_text); + text += "
        "; + text += "
          "; + for (String userId : missingUserIds) { + text += "
        • " + userId + "
        • "; + } + text += "
        "; + text += "
        "; + } + if (dublicateUserIds != null && dublicateUserIds.size() > 0) { + text += getString(R.string.api_select_pub_keys_dublicates_text); + text += "
        "; + text += "
          "; + for (String userId : dublicateUserIds) { + text += "
        • " + userId + "
        • "; + } + text += "
        "; + } + + // Inflate a "Done"/"Cancel" custom action bar view + ActionBarHelper.setTwoButtonView(getSupportActionBar(), + R.string.btn_okay, R.drawable.ic_action_done, + new View.OnClickListener() { + @Override + public void onClick(View v) { + // add key ids to params Bundle for new request + Intent resultData = extras.getParcelable(EXTRA_DATA); + resultData.putExtra(OpenPgpApi.EXTRA_KEY_IDS, + mSelectFragment.getSelectedMasterKeyIds()); + + RemoteServiceActivity.this.setResult(RESULT_OK, resultData); + RemoteServiceActivity.this.finish(); + } + }, R.string.btn_do_not_save, R.drawable.ic_action_cancel, new View.OnClickListener() { + @Override + public void onClick(View v) { + // cancel + RemoteServiceActivity.this.setResult(RESULT_CANCELED); + RemoteServiceActivity.this.finish(); + } + } + ); + + setContentView(R.layout.api_app_select_pub_keys_activity); + + // set text on view + HtmlTextView textView = (HtmlTextView) findViewById(R.id.api_select_pub_keys_text); + textView.setHtmlFromString(text); + + /* Load select pub keys fragment */ + // Check that the activity is using the layout version with + // the fragment_container FrameLayout + if (findViewById(R.id.api_select_pub_keys_fragment_container) != null) { + + // However, if we're being restored from a previous state, + // then we don't need to do anything and should return or else + // we could end up with overlapping fragments. + if (savedInstanceState != null) { + return; + } + + // Create an instance of the fragment + mSelectFragment = SelectPublicKeyFragment.newInstance(selectedMasterKeyIds); + + // Add the fragment to the 'fragment_container' FrameLayout + getSupportFragmentManager().beginTransaction() + .add(R.id.api_select_pub_keys_fragment_container, mSelectFragment).commit(); + } + } else if (ACTION_ERROR_MESSAGE.equals(action)) { + String errorMessage = intent.getStringExtra(EXTRA_ERROR_MESSAGE); + + String text = "" + errorMessage + ""; + + // Inflate a "Done" custom action bar view + ActionBarHelper.setOneButtonView(getSupportActionBar(), + R.string.btn_okay, R.drawable.ic_action_done, + new View.OnClickListener() { + + @Override + public void onClick(View v) { + RemoteServiceActivity.this.setResult(RESULT_CANCELED); + RemoteServiceActivity.this.finish(); + } + }); + + setContentView(R.layout.api_app_error_message); + + // set text on view + HtmlTextView textView = (HtmlTextView) findViewById(R.id.api_app_error_message_text); + textView.setHtmlFromString(text); + } else { + Log.e(Constants.TAG, "Action does not exist!"); + setResult(RESULT_CANCELED); + finish(); + } + } + + /** + * Shows passphrase dialog to cache a new passphrase the user enters for using it later for + * encryption. Based on mSecretKeyId it asks for a passphrase to open a private key or it asks + * for a symmetric passphrase + */ + private void showPassphraseDialog(final Intent data, long secretKeyId) { + // Message is received after passphrase is cached + Handler returnHandler = new Handler() { + @Override + public void handleMessage(Message message) { + if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) { + // return given params again, for calling the service method again + RemoteServiceActivity.this.setResult(RESULT_OK, data); + } else { + RemoteServiceActivity.this.setResult(RESULT_CANCELED); + } + + RemoteServiceActivity.this.finish(); + } + }; + + // Create a new Messenger for the communication back + Messenger messenger = new Messenger(returnHandler); + + try { + PassphraseDialogFragment passphraseDialog = PassphraseDialogFragment.newInstance(this, + messenger, secretKeyId); + + passphraseDialog.show(getSupportFragmentManager(), "passphraseDialog"); + } catch (PgpGeneralException e) { + Log.d(Constants.TAG, "No passphrase for this secret key, do pgp operation directly!"); + // return given params again, for calling the service method again + setResult(RESULT_OK, data); + finish(); + } + } +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettings.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettings.java deleted file mode 100644 index 6f2d67efb..000000000 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettings.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2013 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.service.remote; - -import org.spongycastle.bcpg.HashAlgorithmTags; -import org.spongycastle.openpgp.PGPEncryptedData; -import org.sufficientlysecure.keychain.Id; - -public class AppSettings { - private String mPackageName; - private byte[] mPackageSignature; - private long mKeyId = Id.key.none; - private int mEncryptionAlgorithm; - private int mHashAlgorithm; - private int mCompression; - - public AppSettings() { - - } - - public AppSettings(String packageName, byte[] packageSignature) { - super(); - this.mPackageName = packageName; - this.mPackageSignature = packageSignature; - // defaults: - this.mEncryptionAlgorithm = PGPEncryptedData.AES_256; - this.mHashAlgorithm = HashAlgorithmTags.SHA512; - this.mCompression = Id.choice.compression.zlib; - } - - public String getPackageName() { - return mPackageName; - } - - public void setPackageName(String packageName) { - this.mPackageName = packageName; - } - - public byte[] getPackageSignature() { - return mPackageSignature; - } - - public void setPackageSignature(byte[] packageSignature) { - this.mPackageSignature = packageSignature; - } - - public long getKeyId() { - return mKeyId; - } - - public void setKeyId(long scretKeyId) { - this.mKeyId = scretKeyId; - } - - public int getEncryptionAlgorithm() { - return mEncryptionAlgorithm; - } - - public void setEncryptionAlgorithm(int encryptionAlgorithm) { - this.mEncryptionAlgorithm = encryptionAlgorithm; - } - - public int getHashAlgorithm() { - return mHashAlgorithm; - } - - public void setHashAlgorithm(int hashAlgorithm) { - this.mHashAlgorithm = hashAlgorithm; - } - - public int getCompression() { - return mCompression; - } - - public void setCompression(int compression) { - this.mCompression = compression; - } - -} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsActivity.java deleted file mode 100644 index 2ef170dec..000000000 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsActivity.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (C) 2013 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.service.remote; - -import android.content.Intent; -import android.net.Uri; -import android.os.Bundle; -import android.support.v7.app.ActionBarActivity; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.helper.ActionBarHelper; -import org.sufficientlysecure.keychain.provider.ProviderHelper; -import org.sufficientlysecure.keychain.util.Log; - -public class AppSettingsActivity extends ActionBarActivity { - private Uri mAppUri; - - private AppSettingsFragment mSettingsFragment; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // Inflate a "Done" custom action bar - ActionBarHelper.setOneButtonView(getSupportActionBar(), - R.string.api_settings_save, R.drawable.ic_action_done, - new View.OnClickListener() { - @Override - public void onClick(View v) { - // "Done" - save(); - } - }); - - setContentView(R.layout.api_app_settings_activity); - - mSettingsFragment = (AppSettingsFragment) getSupportFragmentManager().findFragmentById( - R.id.api_app_settings_fragment); - - Intent intent = getIntent(); - mAppUri = intent.getData(); - if (mAppUri == null) { - Log.e(Constants.TAG, "Intent data missing. Should be Uri of app!"); - finish(); - return; - } else { - Log.d(Constants.TAG, "uri: " + mAppUri); - loadData(mAppUri); - } - } - - @Override - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - getMenuInflater().inflate(R.menu.api_app_settings, menu); - return true; - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.menu_api_settings_revoke: - revokeAccess(); - return true; - case R.id.menu_api_settings_cancel: - finish(); - return true; - } - return super.onOptionsItemSelected(item); - } - - private void loadData(Uri appUri) { - AppSettings settings = ProviderHelper.getApiAppSettings(this, appUri); - mSettingsFragment.setAppSettings(settings); - } - - private void revokeAccess() { - if (getContentResolver().delete(mAppUri, null, null) <= 0) { - throw new RuntimeException(); - } - finish(); - } - - private void save() { - ProviderHelper.updateApiApp(this, mSettingsFragment.getAppSettings(), mAppUri); - - finish(); - } - -} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java deleted file mode 100644 index 52b06a2ae..000000000 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/AppSettingsFragment.java +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (C) 2013-2014 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.service.remote; - -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.graphics.drawable.Drawable; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemSelectedListener; -import android.widget.ImageView; -import android.widget.Spinner; -import android.widget.TextView; - -import org.spongycastle.util.encoders.Hex; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.ui.SelectSecretKeyLayoutFragment; -import org.sufficientlysecure.keychain.ui.adapter.KeyValueSpinnerAdapter; -import org.sufficientlysecure.keychain.util.AlgorithmNames; -import org.sufficientlysecure.keychain.util.Log; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; - -public class AppSettingsFragment extends Fragment implements - SelectSecretKeyLayoutFragment.SelectSecretKeyCallback { - - // model - private AppSettings mAppSettings; - - // view - private TextView mAppNameView; - private ImageView mAppIconView; - private Spinner mEncryptionAlgorithm; - private Spinner mHashAlgorithm; - private Spinner mCompression; - private TextView mPackageName; - private TextView mPackageSignature; - - private SelectSecretKeyLayoutFragment mSelectKeyFragment; - - KeyValueSpinnerAdapter mEncryptionAdapter; - KeyValueSpinnerAdapter mHashAdapter; - KeyValueSpinnerAdapter mCompressionAdapter; - - public AppSettings getAppSettings() { - return mAppSettings; - } - - public void setAppSettings(AppSettings appSettings) { - this.mAppSettings = appSettings; - setPackage(appSettings.getPackageName()); - mPackageName.setText(appSettings.getPackageName()); - - try { - MessageDigest md = MessageDigest.getInstance("SHA-256"); - md.update(appSettings.getPackageSignature()); - byte[] digest = md.digest(); - String signature = new String(Hex.encode(digest)); - - mPackageSignature.setText(signature); - } catch (NoSuchAlgorithmException e) { - Log.e(Constants.TAG, "Should not happen!", e); - } - - mSelectKeyFragment.selectKey(appSettings.getKeyId()); - mEncryptionAlgorithm.setSelection(mEncryptionAdapter.getPosition(appSettings - .getEncryptionAlgorithm())); - mHashAlgorithm.setSelection(mHashAdapter.getPosition(appSettings.getHashAlgorithm())); - mCompression.setSelection(mCompressionAdapter.getPosition(appSettings.getCompression())); - } - - /** - * Inflate the layout for this fragment - */ - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.api_app_settings_fragment, container, false); - initView(view); - return view; - } - - /** - * Set error String on key selection - * - * @param error - */ - public void setErrorOnSelectKeyFragment(String error) { - mSelectKeyFragment.setError(error); - } - - private void initView(View view) { - mSelectKeyFragment = (SelectSecretKeyLayoutFragment) getFragmentManager().findFragmentById( - R.id.api_app_settings_select_key_fragment); - mSelectKeyFragment.setCallback(this); - - mAppNameView = (TextView) view.findViewById(R.id.api_app_settings_app_name); - mAppIconView = (ImageView) view.findViewById(R.id.api_app_settings_app_icon); - mEncryptionAlgorithm = (Spinner) view - .findViewById(R.id.api_app_settings_encryption_algorithm); - mHashAlgorithm = (Spinner) view.findViewById(R.id.api_app_settings_hash_algorithm); - mCompression = (Spinner) view.findViewById(R.id.api_app_settings_compression); - mPackageName = (TextView) view.findViewById(R.id.api_app_settings_package_name); - mPackageSignature = (TextView) view.findViewById(R.id.api_app_settings_package_signature); - - AlgorithmNames algorithmNames = new AlgorithmNames(getActivity()); - - mEncryptionAdapter = new KeyValueSpinnerAdapter(getActivity(), - algorithmNames.getEncryptionNames()); - mEncryptionAlgorithm.setAdapter(mEncryptionAdapter); - mEncryptionAlgorithm.setOnItemSelectedListener(new OnItemSelectedListener() { - - @Override - public void onItemSelected(AdapterView parent, View view, int position, long id) { - mAppSettings.setEncryptionAlgorithm((int) id); - } - - @Override - public void onNothingSelected(AdapterView parent) { - } - }); - - mHashAdapter = new KeyValueSpinnerAdapter(getActivity(), algorithmNames.getHashNames()); - mHashAlgorithm.setAdapter(mHashAdapter); - mHashAlgorithm.setOnItemSelectedListener(new OnItemSelectedListener() { - - @Override - public void onItemSelected(AdapterView parent, View view, int position, long id) { - mAppSettings.setHashAlgorithm((int) id); - } - - @Override - public void onNothingSelected(AdapterView parent) { - } - }); - - mCompressionAdapter = new KeyValueSpinnerAdapter(getActivity(), - algorithmNames.getCompressionNames()); - mCompression.setAdapter(mCompressionAdapter); - mCompression.setOnItemSelectedListener(new OnItemSelectedListener() { - - @Override - public void onItemSelected(AdapterView parent, View view, int position, long id) { - mAppSettings.setCompression((int) id); - } - - @Override - public void onNothingSelected(AdapterView parent) { - } - }); - } - - private void setPackage(String packageName) { - PackageManager pm = getActivity().getApplicationContext().getPackageManager(); - - // get application name and icon from package manager - String appName = null; - Drawable appIcon = null; - try { - ApplicationInfo ai = pm.getApplicationInfo(packageName, 0); - - appName = (String) pm.getApplicationLabel(ai); - appIcon = pm.getApplicationIcon(ai); - } catch (final NameNotFoundException e) { - // fallback - appName = packageName; - } - mAppNameView.setText(appName); - mAppIconView.setImageDrawable(appIcon); - } - - /** - * callback from select secret key fragment - */ - @Override - public void onKeySelected(long secretKeyId) { - mAppSettings.setKeyId(secretKeyId); - } - -} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java deleted file mode 100644 index 95dc897f0..000000000 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/OpenPgpService.java +++ /dev/null @@ -1,462 +0,0 @@ -/* - * Copyright (C) 2013-2014 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.service.remote; - -import android.app.PendingIntent; -import android.content.Intent; -import android.database.Cursor; -import android.net.Uri; -import android.os.IBinder; -import android.os.ParcelFileDescriptor; -import org.openintents.openpgp.IOpenPgpService; -import org.openintents.openpgp.OpenPgpError; -import org.openintents.openpgp.OpenPgpSignatureResult; -import org.openintents.openpgp.util.OpenPgpApi; -import org.spongycastle.util.Arrays; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.Id; -import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify; -import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult; -import org.sufficientlysecure.keychain.pgp.PgpSignEncrypt; -import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; -import org.sufficientlysecure.keychain.provider.KeychainContract; -import org.sufficientlysecure.keychain.provider.ProviderHelper; -import org.sufficientlysecure.keychain.service.PassphraseCacheService; -import org.sufficientlysecure.keychain.util.InputData; -import org.sufficientlysecure.keychain.util.Log; - -import java.io.InputStream; -import java.io.OutputStream; -import java.util.ArrayList; - -public class OpenPgpService extends RemoteService { - - private static final int PRIVATE_REQUEST_CODE_PASSPHRASE = 551; - private static final int PRIVATE_REQUEST_CODE_USER_IDS = 552; - private static final int PRIVATE_REQUEST_CODE_GET_KEYS = 553; - - /** - * Search database for key ids based on emails. - * - * @param encryptionUserIds - * @return - */ - private Intent getKeyIdsFromEmails(Intent data, String[] encryptionUserIds) { - // find key ids to given emails in database - ArrayList keyIds = new ArrayList(); - - boolean missingUserIdsCheck = false; - boolean dublicateUserIdsCheck = false; - ArrayList missingUserIds = new ArrayList(); - ArrayList dublicateUserIds = new ArrayList(); - - for (String email : encryptionUserIds) { - Uri uri = KeychainContract.KeyRings.buildPublicKeyRingsByEmailsUri(email); - Cursor cur = getContentResolver().query(uri, null, null, null, null); - if (cur.moveToFirst()) { - long id = cur.getLong(cur.getColumnIndex(KeychainContract.KeyRings.MASTER_KEY_ID)); - keyIds.add(id); - } else { - missingUserIdsCheck = true; - missingUserIds.add(email); - Log.d(Constants.TAG, "user id missing"); - } - if (cur.moveToNext()) { - dublicateUserIdsCheck = true; - dublicateUserIds.add(email); - Log.d(Constants.TAG, "more than one user id with the same email"); - } - } - - // convert to long[] - long[] keyIdsArray = new long[keyIds.size()]; - for (int i = 0; i < keyIdsArray.length; i++) { - keyIdsArray[i] = keyIds.get(i); - } - - // allow the user to verify pub key selection - if (missingUserIdsCheck || dublicateUserIdsCheck) { - // build PendingIntent - Intent intent = new Intent(getBaseContext(), RemoteServiceActivity.class); - intent.setAction(RemoteServiceActivity.ACTION_SELECT_PUB_KEYS); - intent.putExtra(RemoteServiceActivity.EXTRA_SELECTED_MASTER_KEY_IDS, keyIdsArray); - intent.putExtra(RemoteServiceActivity.EXTRA_MISSING_USER_IDS, missingUserIds); - intent.putExtra(RemoteServiceActivity.EXTRA_DUBLICATE_USER_IDS, dublicateUserIds); - intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); - - PendingIntent pi = PendingIntent.getActivity - (getBaseContext(), PRIVATE_REQUEST_CODE_USER_IDS, intent, 0); - - // return PendingIntent to be executed by client - Intent result = new Intent(); - result.putExtra(OpenPgpApi.RESULT_INTENT, pi); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED); - return result; - } - - if (keyIdsArray.length == 0) { - return null; - } - - Intent result = new Intent(); - result.putExtra(OpenPgpApi.EXTRA_KEY_IDS, keyIdsArray); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS); - return result; - } - - private Intent getPassphraseBundleIntent(Intent data, long keyId) { - // build PendingIntent for passphrase input - Intent intent = new Intent(getBaseContext(), RemoteServiceActivity.class); - intent.setAction(RemoteServiceActivity.ACTION_CACHE_PASSPHRASE); - intent.putExtra(RemoteServiceActivity.EXTRA_SECRET_KEY_ID, keyId); - // pass params through to activity that it can be returned again later to repeat pgp operation - intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); - PendingIntent pi = PendingIntent.getActivity - (getBaseContext(), PRIVATE_REQUEST_CODE_PASSPHRASE, intent, 0); - - // return PendingIntent to be executed by client - Intent result = new Intent(); - result.putExtra(OpenPgpApi.RESULT_INTENT, pi); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED); - return result; - } - - private Intent signImpl(Intent data, ParcelFileDescriptor input, - ParcelFileDescriptor output, AppSettings appSettings) { - try { - boolean asciiArmor = data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); - - // get passphrase from cache, if key has "no" passphrase, this returns an empty String - String passphrase; - if (data.hasExtra(OpenPgpApi.EXTRA_PASSPHRASE)) { - passphrase = data.getStringExtra(OpenPgpApi.EXTRA_PASSPHRASE); - } else { - passphrase = PassphraseCacheService.getCachedPassphrase(getContext(), appSettings.getKeyId()); - } - if (passphrase == null) { - // get PendingIntent for passphrase input, add it to given params and return to client - Intent passphraseBundle = getPassphraseBundleIntent(data, appSettings.getKeyId()); - return passphraseBundle; - } - - // Get Input- and OutputStream from ParcelFileDescriptor - InputStream is = new ParcelFileDescriptor.AutoCloseInputStream(input); - OutputStream os = new ParcelFileDescriptor.AutoCloseOutputStream(output); - try { - long inputLength = is.available(); - InputData inputData = new InputData(is, inputLength); - - // sign-only - PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder(getContext(), inputData, os); - builder.enableAsciiArmorOutput(asciiArmor) - .signatureHashAlgorithm(appSettings.getHashAlgorithm()) - .signatureForceV3(false) - .signatureKeyId(appSettings.getKeyId()) - .signaturePassphrase(passphrase); - builder.build().execute(); - } finally { - is.close(); - os.close(); - } - - Intent result = new Intent(); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS); - return result; - } catch (Exception e) { - Intent result = new Intent(); - result.putExtra(OpenPgpApi.RESULT_ERROR, - new OpenPgpError(OpenPgpError.GENERIC_ERROR, e.getMessage())); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); - return result; - } - } - - private Intent encryptAndSignImpl(Intent data, ParcelFileDescriptor input, - ParcelFileDescriptor output, AppSettings appSettings, boolean sign) { - try { - boolean asciiArmor = data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); - - long[] keyIds; - if (data.hasExtra(OpenPgpApi.EXTRA_KEY_IDS)) { - keyIds = data.getLongArrayExtra(OpenPgpApi.EXTRA_KEY_IDS); - } else if (data.hasExtra(OpenPgpApi.EXTRA_USER_IDS)) { - // get key ids based on given user ids - String[] userIds = data.getStringArrayExtra(OpenPgpApi.EXTRA_USER_IDS); - // give params through to activity... - Intent result = getKeyIdsFromEmails(data, userIds); - - if (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0) == OpenPgpApi.RESULT_CODE_SUCCESS) { - keyIds = result.getLongArrayExtra(OpenPgpApi.EXTRA_KEY_IDS); - } else { - // if not success -> result contains a PendingIntent for user interaction - return result; - } - } else { - Intent result = new Intent(); - result.putExtra(OpenPgpApi.RESULT_ERROR, - new OpenPgpError(OpenPgpError.GENERIC_ERROR, - "Missing parameter user_ids or key_ids!")); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); - return result; - } - - // add own key for encryption - keyIds = Arrays.copyOf(keyIds, keyIds.length + 1); - keyIds[keyIds.length - 1] = appSettings.getKeyId(); - - // build InputData and write into OutputStream - // Get Input- and OutputStream from ParcelFileDescriptor - InputStream is = new ParcelFileDescriptor.AutoCloseInputStream(input); - OutputStream os = new ParcelFileDescriptor.AutoCloseOutputStream(output); - try { - long inputLength = is.available(); - InputData inputData = new InputData(is, inputLength); - - PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder(getContext(), inputData, os); - builder.enableAsciiArmorOutput(asciiArmor) - .compressionId(appSettings.getCompression()) - .symmetricEncryptionAlgorithm(appSettings.getEncryptionAlgorithm()) - .encryptionKeyIds(keyIds); - - if (sign) { - String passphrase; - if (data.hasExtra(OpenPgpApi.EXTRA_PASSPHRASE)) { - passphrase = data.getStringExtra(OpenPgpApi.EXTRA_PASSPHRASE); - } else { - passphrase = PassphraseCacheService.getCachedPassphrase(getContext(), - appSettings.getKeyId()); - } - if (passphrase == null) { - // get PendingIntent for passphrase input, add it to given params and return to client - Intent passphraseBundle = getPassphraseBundleIntent(data, appSettings.getKeyId()); - return passphraseBundle; - } - - // sign and encrypt - builder.signatureHashAlgorithm(appSettings.getHashAlgorithm()) - .signatureForceV3(false) - .signatureKeyId(appSettings.getKeyId()) - .signaturePassphrase(passphrase); - } else { - // encrypt only - builder.signatureKeyId(Id.key.none); - } - // execute PGP operation! - builder.build().execute(); - } finally { - is.close(); - os.close(); - } - - Intent result = new Intent(); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS); - return result; - } catch (Exception e) { - Intent result = new Intent(); - result.putExtra(OpenPgpApi.RESULT_ERROR, - new OpenPgpError(OpenPgpError.GENERIC_ERROR, e.getMessage())); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); - return result; - } - } - - private Intent decryptAndVerifyImpl(Intent data, ParcelFileDescriptor input, - ParcelFileDescriptor output, AppSettings appSettings) { - try { - // Get Input- and OutputStream from ParcelFileDescriptor - InputStream is = new ParcelFileDescriptor.AutoCloseInputStream(input); - OutputStream os = new ParcelFileDescriptor.AutoCloseOutputStream(output); - - Intent result = new Intent(); - try { - - String passphrase = data.getStringExtra(OpenPgpApi.EXTRA_PASSPHRASE); - long inputLength = is.available(); - InputData inputData = new InputData(is, inputLength); - - PgpDecryptVerify.Builder builder = new PgpDecryptVerify.Builder(this, inputData, os); - builder.assumeSymmetric(false) // no support for symmetric encryption - // allow only the private key for this app for decryption - .enforcedKeyId(appSettings.getKeyId()) - .passphrase(passphrase); - - // TODO: currently does not support binary signed-only content - PgpDecryptVerifyResult decryptVerifyResult = builder.build().execute(); - - if (decryptVerifyResult.isKeyPassphraseNeeded()) { - // get PendingIntent for passphrase input, add it to given params and return to client - Intent passphraseBundle = getPassphraseBundleIntent(data, appSettings.getKeyId()); - return passphraseBundle; - } else if (decryptVerifyResult.isSymmetricPassphraseNeeded()) { - throw new PgpGeneralException("Decryption of symmetric content not supported by API!"); - } - - OpenPgpSignatureResult signatureResult = decryptVerifyResult.getSignatureResult(); - if (signatureResult != null) { - if (signatureResult.getStatus() == OpenPgpSignatureResult.SIGNATURE_UNKNOWN_PUB_KEY) { - // If signature is unknown we return an _additional_ PendingIntent - // to retrieve the missing key - // TODO!!! - Intent intent = new Intent(getBaseContext(), RemoteServiceActivity.class); - intent.setAction(RemoteServiceActivity.ACTION_ERROR_MESSAGE); - intent.putExtra(RemoteServiceActivity.EXTRA_ERROR_MESSAGE, "todo"); - intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); - - PendingIntent pi = PendingIntent.getActivity(getBaseContext(), - PRIVATE_REQUEST_CODE_GET_KEYS, intent, 0); - - result.putExtra(OpenPgpApi.RESULT_INTENT, pi); - } - - result.putExtra(OpenPgpApi.RESULT_SIGNATURE, signatureResult); - } - - } finally { - is.close(); - os.close(); - } - - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS); - return result; - } catch (Exception e) { - Intent result = new Intent(); - result.putExtra(OpenPgpApi.RESULT_ERROR, - new OpenPgpError(OpenPgpError.GENERIC_ERROR, e.getMessage())); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); - return result; - } - } - - private Intent getKeyImpl(Intent data) { - try { - long keyId = data.getLongExtra(OpenPgpApi.EXTRA_KEY_ID, 0); - - if (ProviderHelper.getPGPPublicKeyByKeyId(this, keyId) == null) { - Intent result = new Intent(); - - // If keys are not in db we return an additional PendingIntent - // to retrieve the missing key - // TODO!!! - Intent intent = new Intent(getBaseContext(), RemoteServiceActivity.class); - intent.setAction(RemoteServiceActivity.ACTION_ERROR_MESSAGE); - intent.putExtra(RemoteServiceActivity.EXTRA_ERROR_MESSAGE, "todo"); - intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); - - PendingIntent pi = PendingIntent.getActivity(getBaseContext(), - PRIVATE_REQUEST_CODE_GET_KEYS, intent, 0); - - result.putExtra(OpenPgpApi.RESULT_INTENT, pi); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED); - return result; - } else { - Intent result = new Intent(); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS); - return result; - } - } catch (Exception e) { - Intent result = new Intent(); - result.putExtra(OpenPgpApi.RESULT_ERROR, - new OpenPgpError(OpenPgpError.GENERIC_ERROR, e.getMessage())); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); - return result; - } - } - - private Intent getKeyIdsImpl(Intent data) { - // get key ids based on given user ids - String[] userIds = data.getStringArrayExtra(OpenPgpApi.EXTRA_USER_IDS); - Intent result = getKeyIdsFromEmails(data, userIds); - return result; - } - - /** - * Check requirements: - * - params != null - * - has supported API version - * - is allowed to call the service (access has been granted) - * - * @param data - * @return null if everything is okay, or a Bundle with an error/PendingIntent - */ - private Intent checkRequirements(Intent data) { - // params Bundle is required! - if (data == null) { - Intent result = new Intent(); - OpenPgpError error = new OpenPgpError(OpenPgpError.GENERIC_ERROR, "params Bundle required!"); - result.putExtra(OpenPgpApi.RESULT_ERROR, error); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); - return result; - } - - // version code is required and needs to correspond to version code of service! - if (data.getIntExtra(OpenPgpApi.EXTRA_API_VERSION, -1) != OpenPgpApi.API_VERSION) { - Intent result = new Intent(); - OpenPgpError error = new OpenPgpError - (OpenPgpError.INCOMPATIBLE_API_VERSIONS, "Incompatible API versions!"); - result.putExtra(OpenPgpApi.RESULT_ERROR, error); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); - return result; - } - - // check if caller is allowed to access openpgp keychain - Intent result = isAllowed(data); - if (result != null) { - return result; - } - - return null; - } - - // TODO: multi-threading - private final IOpenPgpService.Stub mBinder = new IOpenPgpService.Stub() { - - @Override - public Intent execute(Intent data, ParcelFileDescriptor input, ParcelFileDescriptor output) { - Intent errorResult = checkRequirements(data); - if (errorResult != null) { - return errorResult; - } - - final AppSettings appSettings = getAppSettings(); - - String action = data.getAction(); - if (OpenPgpApi.ACTION_SIGN.equals(action)) { - return signImpl(data, input, output, appSettings); - } else if (OpenPgpApi.ACTION_ENCRYPT.equals(action)) { - return encryptAndSignImpl(data, input, output, appSettings, false); - } else if (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(action)) { - return encryptAndSignImpl(data, input, output, appSettings, true); - } else if (OpenPgpApi.ACTION_DECRYPT_VERIFY.equals(action)) { - return decryptAndVerifyImpl(data, input, output, appSettings); - } else if (OpenPgpApi.ACTION_GET_KEY.equals(action)) { - return getKeyImpl(data); - } else if (OpenPgpApi.ACTION_GET_KEY_IDS.equals(action)) { - return getKeyIdsImpl(data); - } else { - return null; - } - } - - }; - - @Override - public IBinder onBind(Intent intent) { - return mBinder; - } - -} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsAdapter.java deleted file mode 100644 index e0dc4162f..000000000 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsAdapter.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2013 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.service.remote; - -import android.content.Context; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.database.Cursor; -import android.support.v4.widget.CursorAdapter; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; - -public class RegisteredAppsAdapter extends CursorAdapter { - - private LayoutInflater mInflater; - private PackageManager mPM; - - public RegisteredAppsAdapter(Context context, Cursor c, int flags) { - super(context, c, flags); - - mInflater = LayoutInflater.from(context); - mPM = context.getApplicationContext().getPackageManager(); - } - - @Override - public void bindView(View view, Context context, Cursor cursor) { - TextView text = (TextView) view.findViewById(R.id.api_apps_adapter_item_name); - ImageView icon = (ImageView) view.findViewById(R.id.api_apps_adapter_item_icon); - - String packageName = cursor.getString(cursor.getColumnIndex(ApiApps.PACKAGE_NAME)); - if (packageName != null) { - // get application name - try { - ApplicationInfo ai = mPM.getApplicationInfo(packageName, 0); - - text.setText(mPM.getApplicationLabel(ai)); - icon.setImageDrawable(mPM.getApplicationIcon(ai)); - } catch (final NameNotFoundException e) { - // fallback - text.setText(packageName); - } - } else { - // fallback - text.setText(packageName); - } - - } - - @Override - public View newView(Context context, Cursor cursor, ViewGroup parent) { - return mInflater.inflate(R.layout.api_apps_adapter_list_item, null); - } - -} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListActivity.java deleted file mode 100644 index f6f216efd..000000000 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListActivity.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2013 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.service.remote; - -import android.os.Bundle; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.ui.DrawerActivity; - -public class RegisteredAppsListActivity extends DrawerActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setContentView(R.layout.api_apps_list_activity); - - setupDrawerNavigation(savedInstanceState); - } - -} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListFragment.java deleted file mode 100644 index 25d0c7593..000000000 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RegisteredAppsListFragment.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2013 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.service.remote; - -import android.content.ContentUris; -import android.content.Intent; -import android.database.Cursor; -import android.net.Uri; -import android.os.Bundle; -import android.support.v4.app.ListFragment; -import android.support.v4.app.LoaderManager; -import android.support.v4.content.CursorLoader; -import android.support.v4.content.Loader; -import android.view.View; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.provider.KeychainContract; -import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; - -public class RegisteredAppsListFragment extends ListFragment implements - LoaderManager.LoaderCallbacks { - - // This is the Adapter being used to display the list's data. - RegisteredAppsAdapter mAdapter; - - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - - getListView().setOnItemClickListener(new OnItemClickListener() { - @Override - public void onItemClick(AdapterView adapterView, View view, int position, long id) { - // edit app settings - Intent intent = new Intent(getActivity(), AppSettingsActivity.class); - intent.setData(ContentUris.withAppendedId(KeychainContract.ApiApps.CONTENT_URI, id)); - startActivity(intent); - } - }); - - // Give some text to display if there is no data. In a real - // application this would come from a resource. - setEmptyText(getString(R.string.api_no_apps)); - - // We have a menu item to show in action bar. - setHasOptionsMenu(true); - - // Create an empty adapter we will use to display the loaded data. - mAdapter = new RegisteredAppsAdapter(getActivity(), null, 0); - setListAdapter(mAdapter); - - // Prepare the loader. Either re-connect with an existing one, - // or start a new one. - getLoaderManager().initLoader(0, null, this); - } - - // These are the Contacts rows that we will retrieve. - static final String[] PROJECTION = new String[]{ApiApps._ID, ApiApps.PACKAGE_NAME}; - - public Loader onCreateLoader(int id, Bundle args) { - // This is called when a new Loader needs to be created. This - // sample only has one Loader, so we don't care about the ID. - // First, pick the base URI to use depending on whether we are - // currently filtering. - Uri baseUri = ApiApps.CONTENT_URI; - - // Now create and return a CursorLoader that will take care of - // creating a Cursor for the data being displayed. - return new CursorLoader(getActivity(), baseUri, PROJECTION, null, null, - ApiApps.PACKAGE_NAME + " COLLATE LOCALIZED ASC"); - } - - public void onLoadFinished(Loader loader, Cursor data) { - // Swap the new cursor in. (The framework will take care of closing the - // old cursor once we return.) - mAdapter.swapCursor(data); - } - - public void onLoaderReset(Loader loader) { - // This is called when the last Cursor provided to onLoadFinished() - // above is about to be closed. We need to make sure we are no - // longer using it. - mAdapter.swapCursor(null); - } - -} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteService.java deleted file mode 100644 index 6a883316a..000000000 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteService.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (C) 2013-2014 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.service.remote; - -import android.app.PendingIntent; -import android.app.Service; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.content.pm.Signature; -import android.net.Uri; -import android.os.Binder; -import org.openintents.openpgp.OpenPgpError; -import org.openintents.openpgp.util.OpenPgpApi; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.provider.KeychainContract; -import org.sufficientlysecure.keychain.provider.ProviderHelper; -import org.sufficientlysecure.keychain.util.Log; - -import java.util.ArrayList; -import java.util.Arrays; - -/** - * Abstract service class for remote APIs that handle app registration and user input. - */ -public abstract class RemoteService extends Service { - Context mContext; - - private static final int PRIVATE_REQUEST_CODE_REGISTER = 651; - private static final int PRIVATE_REQUEST_CODE_ERROR = 652; - - - public Context getContext() { - return mContext; - } - - protected Intent isAllowed(Intent data) { - try { - if (isCallerAllowed(false)) { - - return null; - } else { - String[] callingPackages = getPackageManager().getPackagesForUid( - Binder.getCallingUid()); - // TODO: currently simply uses first entry - String packageName = callingPackages[0]; - - byte[] packageSignature; - try { - packageSignature = getPackageSignature(packageName); - } catch (NameNotFoundException e) { - Log.e(Constants.TAG, "Should not happen, returning!", e); - // return error - Intent result = new Intent(); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR); - result.putExtra(OpenPgpApi.RESULT_ERROR, - new OpenPgpError(OpenPgpError.GENERIC_ERROR, e.getMessage())); - return result; - } - Log.e(Constants.TAG, "Not allowed to use service! return PendingIntent for registration!"); - - Intent intent = new Intent(getBaseContext(), RemoteServiceActivity.class); - intent.setAction(RemoteServiceActivity.ACTION_REGISTER); - intent.putExtra(RemoteServiceActivity.EXTRA_PACKAGE_NAME, packageName); - intent.putExtra(RemoteServiceActivity.EXTRA_PACKAGE_SIGNATURE, packageSignature); - intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); - - PendingIntent pi = PendingIntent.getActivity(getBaseContext(), - PRIVATE_REQUEST_CODE_REGISTER, intent, 0); - - // return PendingIntent to be executed by client - Intent result = new Intent(); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED); - result.putExtra(OpenPgpApi.RESULT_INTENT, pi); - - return result; - } - } catch (WrongPackageSignatureException e) { - Log.e(Constants.TAG, "wrong signature!", e); - - Intent intent = new Intent(getBaseContext(), RemoteServiceActivity.class); - intent.setAction(RemoteServiceActivity.ACTION_ERROR_MESSAGE); - intent.putExtra(RemoteServiceActivity.EXTRA_ERROR_MESSAGE, - getString(R.string.api_error_wrong_signature)); - intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); - - PendingIntent pi = PendingIntent.getActivity(getBaseContext(), - PRIVATE_REQUEST_CODE_ERROR, intent, 0); - - // return PendingIntent to be executed by client - Intent result = new Intent(); - result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED); - result.putExtra(OpenPgpApi.RESULT_INTENT, pi); - - return result; - } - } - - private byte[] getPackageSignature(String packageName) throws NameNotFoundException { - PackageInfo pkgInfo = getPackageManager().getPackageInfo(packageName, - PackageManager.GET_SIGNATURES); - Signature[] signatures = pkgInfo.signatures; - // TODO: Only first signature?! - byte[] packageSignature = signatures[0].toByteArray(); - - return packageSignature; - } - - /** - * Retrieves AppSettings from database for the application calling this remote service - * - * @return - */ - protected AppSettings getAppSettings() { - String[] callingPackages = getPackageManager().getPackagesForUid(Binder.getCallingUid()); - - // get app settings for this package - for (int i = 0; i < callingPackages.length; i++) { - String currentPkg = callingPackages[i]; - - Uri uri = KeychainContract.ApiApps.buildByPackageNameUri(currentPkg); - - AppSettings settings = ProviderHelper.getApiAppSettings(this, uri); - - if (settings != null) { - return settings; - } - } - - return null; - } - - /** - * Checks if process that binds to this service (i.e. the package name corresponding to the - * process) is in the list of allowed package names. - * - * @param allowOnlySelf allow only Keychain app itself - * @return true if process is allowed to use this service - * @throws WrongPackageSignatureException - */ - private boolean isCallerAllowed(boolean allowOnlySelf) throws WrongPackageSignatureException { - return isUidAllowed(Binder.getCallingUid(), allowOnlySelf); - } - - private boolean isUidAllowed(int uid, boolean allowOnlySelf) - throws WrongPackageSignatureException { - if (android.os.Process.myUid() == uid) { - return true; - } - if (allowOnlySelf) { // barrier - return false; - } - - String[] callingPackages = getPackageManager().getPackagesForUid(uid); - - // is calling package allowed to use this service? - for (int i = 0; i < callingPackages.length; i++) { - String currentPkg = callingPackages[i]; - - if (isPackageAllowed(currentPkg)) { - return true; - } - } - - Log.d(Constants.TAG, "Caller is NOT allowed!"); - return false; - } - - /** - * Checks if packageName is a registered app for the API. Does not return true for own package! - * - * @param packageName - * @return - * @throws WrongPackageSignatureException - */ - private boolean isPackageAllowed(String packageName) throws WrongPackageSignatureException { - Log.d(Constants.TAG, "packageName: " + packageName); - - ArrayList allowedPkgs = ProviderHelper.getRegisteredApiApps(this); - Log.d(Constants.TAG, "allowed: " + allowedPkgs); - - // check if package is allowed to use our service - if (allowedPkgs.contains(packageName)) { - Log.d(Constants.TAG, "Package is allowed! packageName: " + packageName); - - // check package signature - byte[] currentSig; - try { - currentSig = getPackageSignature(packageName); - } catch (NameNotFoundException e) { - throw new WrongPackageSignatureException(e.getMessage()); - } - - byte[] storedSig = ProviderHelper.getApiAppSignature(this, packageName); - if (Arrays.equals(currentSig, storedSig)) { - Log.d(Constants.TAG, - "Package signature is correct! (equals signature from database)"); - return true; - } else { - throw new WrongPackageSignatureException( - "PACKAGE NOT ALLOWED! Signature wrong! (Signature not equals signature from database)"); - } - } - - return false; - } - - @Override - public void onCreate() { - super.onCreate(); - mContext = this; - } - -} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteServiceActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteServiceActivity.java deleted file mode 100644 index e20114853..000000000 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/RemoteServiceActivity.java +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (C) 2013-2014 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.service.remote; - -import android.content.Intent; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.os.Messenger; -import android.support.v7.app.ActionBarActivity; -import android.view.View; -import org.openintents.openpgp.util.OpenPgpApi; -import org.sufficientlysecure.htmltextview.HtmlTextView; -import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.Id; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.helper.ActionBarHelper; -import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; -import org.sufficientlysecure.keychain.provider.ProviderHelper; -import org.sufficientlysecure.keychain.ui.SelectPublicKeyFragment; -import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; -import org.sufficientlysecure.keychain.util.Log; - -import java.util.ArrayList; - -public class RemoteServiceActivity extends ActionBarActivity { - - public static final String ACTION_REGISTER = Constants.INTENT_PREFIX + "API_ACTIVITY_REGISTER"; - public static final String ACTION_CACHE_PASSPHRASE = Constants.INTENT_PREFIX - + "API_ACTIVITY_CACHE_PASSPHRASE"; - public static final String ACTION_SELECT_PUB_KEYS = Constants.INTENT_PREFIX - + "API_ACTIVITY_SELECT_PUB_KEYS"; - public static final String ACTION_ERROR_MESSAGE = Constants.INTENT_PREFIX - + "API_ACTIVITY_ERROR_MESSAGE"; - - public static final String EXTRA_MESSENGER = "messenger"; - - public static final String EXTRA_DATA = "data"; - - // passphrase action - public static final String EXTRA_SECRET_KEY_ID = "secret_key_id"; - // register action - public static final String EXTRA_PACKAGE_NAME = "package_name"; - public static final String EXTRA_PACKAGE_SIGNATURE = "package_signature"; - // select pub keys action - public static final String EXTRA_SELECTED_MASTER_KEY_IDS = "master_key_ids"; - public static final String EXTRA_MISSING_USER_IDS = "missing_user_ids"; - public static final String EXTRA_DUBLICATE_USER_IDS = "dublicate_user_ids"; - // error message - public static final String EXTRA_ERROR_MESSAGE = "error_message"; - - // register view - private AppSettingsFragment mSettingsFragment; - // select pub keys view - private SelectPublicKeyFragment mSelectFragment; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - handleActions(getIntent(), savedInstanceState); - } - - protected void handleActions(Intent intent, Bundle savedInstanceState) { - - String action = intent.getAction(); - final Bundle extras = intent.getExtras(); - - - if (ACTION_REGISTER.equals(action)) { - final String packageName = extras.getString(EXTRA_PACKAGE_NAME); - final byte[] packageSignature = extras.getByteArray(EXTRA_PACKAGE_SIGNATURE); - - // Inflate a "Done"/"Cancel" custom action bar view - ActionBarHelper.setTwoButtonView(getSupportActionBar(), - R.string.api_register_allow, R.drawable.ic_action_done, - new View.OnClickListener() { - @Override - public void onClick(View v) { - // Allow - - // user needs to select a key! - if (mSettingsFragment.getAppSettings().getKeyId() == Id.key.none) { - mSettingsFragment.setErrorOnSelectKeyFragment( - getString(R.string.api_register_error_select_key)); - } else { - ProviderHelper.insertApiApp(RemoteServiceActivity.this, - mSettingsFragment.getAppSettings()); - - // give data through for new service call - Intent resultData = extras.getParcelable(EXTRA_DATA); - RemoteServiceActivity.this.setResult(RESULT_OK, resultData); - RemoteServiceActivity.this.finish(); - } - } - }, R.string.api_register_disallow, R.drawable.ic_action_cancel, - new View.OnClickListener() { - @Override - public void onClick(View v) { - // Disallow - RemoteServiceActivity.this.setResult(RESULT_CANCELED); - RemoteServiceActivity.this.finish(); - } - } - ); - - setContentView(R.layout.api_app_register_activity); - - mSettingsFragment = (AppSettingsFragment) getSupportFragmentManager().findFragmentById( - R.id.api_app_settings_fragment); - - AppSettings settings = new AppSettings(packageName, packageSignature); - mSettingsFragment.setAppSettings(settings); - } else if (ACTION_CACHE_PASSPHRASE.equals(action)) { - long secretKeyId = extras.getLong(EXTRA_SECRET_KEY_ID); - Intent resultData = extras.getParcelable(EXTRA_DATA); - - showPassphraseDialog(resultData, secretKeyId); - } else if (ACTION_SELECT_PUB_KEYS.equals(action)) { - long[] selectedMasterKeyIds = intent.getLongArrayExtra(EXTRA_SELECTED_MASTER_KEY_IDS); - ArrayList missingUserIds = intent - .getStringArrayListExtra(EXTRA_MISSING_USER_IDS); - ArrayList dublicateUserIds = intent - .getStringArrayListExtra(EXTRA_DUBLICATE_USER_IDS); - - // TODO: do this with spannable instead of HTML to prevent parsing failures with weird user ids - String text = "" + getString(R.string.api_select_pub_keys_text) + ""; - text += "

        "; - if (missingUserIds != null && missingUserIds.size() > 0) { - text += getString(R.string.api_select_pub_keys_missing_text); - text += "
        "; - text += "
          "; - for (String userId : missingUserIds) { - text += "
        • " + userId + "
        • "; - } - text += "
        "; - text += "
        "; - } - if (dublicateUserIds != null && dublicateUserIds.size() > 0) { - text += getString(R.string.api_select_pub_keys_dublicates_text); - text += "
        "; - text += "
          "; - for (String userId : dublicateUserIds) { - text += "
        • " + userId + "
        • "; - } - text += "
        "; - } - - // Inflate a "Done"/"Cancel" custom action bar view - ActionBarHelper.setTwoButtonView(getSupportActionBar(), - R.string.btn_okay, R.drawable.ic_action_done, - new View.OnClickListener() { - @Override - public void onClick(View v) { - // add key ids to params Bundle for new request - Intent resultData = extras.getParcelable(EXTRA_DATA); - resultData.putExtra(OpenPgpApi.EXTRA_KEY_IDS, - mSelectFragment.getSelectedMasterKeyIds()); - - RemoteServiceActivity.this.setResult(RESULT_OK, resultData); - RemoteServiceActivity.this.finish(); - } - }, R.string.btn_do_not_save, R.drawable.ic_action_cancel, new View.OnClickListener() { - @Override - public void onClick(View v) { - // cancel - RemoteServiceActivity.this.setResult(RESULT_CANCELED); - RemoteServiceActivity.this.finish(); - } - } - ); - - setContentView(R.layout.api_app_select_pub_keys_activity); - - // set text on view - HtmlTextView textView = (HtmlTextView) findViewById(R.id.api_select_pub_keys_text); - textView.setHtmlFromString(text); - - /* Load select pub keys fragment */ - // Check that the activity is using the layout version with - // the fragment_container FrameLayout - if (findViewById(R.id.api_select_pub_keys_fragment_container) != null) { - - // However, if we're being restored from a previous state, - // then we don't need to do anything and should return or else - // we could end up with overlapping fragments. - if (savedInstanceState != null) { - return; - } - - // Create an instance of the fragment - mSelectFragment = SelectPublicKeyFragment.newInstance(selectedMasterKeyIds); - - // Add the fragment to the 'fragment_container' FrameLayout - getSupportFragmentManager().beginTransaction() - .add(R.id.api_select_pub_keys_fragment_container, mSelectFragment).commit(); - } - } else if (ACTION_ERROR_MESSAGE.equals(action)) { - String errorMessage = intent.getStringExtra(EXTRA_ERROR_MESSAGE); - - String text = "" + errorMessage + ""; - - // Inflate a "Done" custom action bar view - ActionBarHelper.setOneButtonView(getSupportActionBar(), - R.string.btn_okay, R.drawable.ic_action_done, - new View.OnClickListener() { - - @Override - public void onClick(View v) { - RemoteServiceActivity.this.setResult(RESULT_CANCELED); - RemoteServiceActivity.this.finish(); - } - }); - - setContentView(R.layout.api_app_error_message); - - // set text on view - HtmlTextView textView = (HtmlTextView) findViewById(R.id.api_app_error_message_text); - textView.setHtmlFromString(text); - } else { - Log.e(Constants.TAG, "Action does not exist!"); - setResult(RESULT_CANCELED); - finish(); - } - } - - /** - * Shows passphrase dialog to cache a new passphrase the user enters for using it later for - * encryption. Based on mSecretKeyId it asks for a passphrase to open a private key or it asks - * for a symmetric passphrase - */ - private void showPassphraseDialog(final Intent data, long secretKeyId) { - // Message is received after passphrase is cached - Handler returnHandler = new Handler() { - @Override - public void handleMessage(Message message) { - if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) { - // return given params again, for calling the service method again - RemoteServiceActivity.this.setResult(RESULT_OK, data); - } else { - RemoteServiceActivity.this.setResult(RESULT_CANCELED); - } - - RemoteServiceActivity.this.finish(); - } - }; - - // Create a new Messenger for the communication back - Messenger messenger = new Messenger(returnHandler); - - try { - PassphraseDialogFragment passphraseDialog = PassphraseDialogFragment.newInstance(this, - messenger, secretKeyId); - - passphraseDialog.show(getSupportFragmentManager(), "passphraseDialog"); - } catch (PgpGeneralException e) { - Log.d(Constants.TAG, "No passphrase for this secret key, do pgp operation directly!"); - // return given params again, for calling the service method again - setResult(RESULT_OK, data); - finish(); - } - } -} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/WrongPackageSignatureException.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/WrongPackageSignatureException.java deleted file mode 100644 index 0b642086a..000000000 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/remote/WrongPackageSignatureException.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2013 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.service.remote; - -public class WrongPackageSignatureException extends Exception { - - private static final long serialVersionUID = -8294642703122196028L; - - public WrongPackageSignatureException(String message) { - super(message); - } -} -- cgit v1.2.3 From f082b53118e7a174b8c9a79964abaeef4a34fa29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 23 Mar 2014 02:17:39 +0100 Subject: Extend provider for new api tables --- .../keychain/provider/KeychainContract.java | 64 ++++++++- .../keychain/provider/KeychainDatabase.java | 8 +- .../keychain/provider/KeychainProvider.java | 149 ++++++++++++++++++--- .../keychain/provider/ProviderHelper.java | 42 ++++-- 4 files changed, 222 insertions(+), 41 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java index de51cebbb..aa4c1f131 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java @@ -63,7 +63,7 @@ public class KeychainContract { String ENCRYPTION_ALGORITHM = "encryption_algorithm"; String HASH_ALORITHM = "hash_algorithm"; String COMPRESSION = "compression"; - String PACKAGE_NAME = "package_name"; // foreign key to api_apps.package_name + String PACKAGE_NAME_FK = "package_name"; // foreign key to api_apps.package_name } public static final class KeyTypes { @@ -90,7 +90,10 @@ public class KeychainContract { public static final String PATH_USER_IDS = "user_ids"; public static final String PATH_KEYS = "keys"; - public static final String BASE_API_APPS = "api_apps"; + public static final String BASE_API = "api"; + public static final String PATH_APPS = "apps"; + public static final String PATH_ACCOUNTS = "accounts"; + public static final String PATH_BY_PACKAGE_NAME = "package_name"; public static class KeyRings implements KeyRingsColumns, BaseColumns { @@ -254,19 +257,70 @@ public class KeychainContract { } } + /** + * Join over ApiApps with ApiAppsAccounts + */ + public static class Api implements ApiAppsColumns, ApiAppsAccountsColumns, BaseColumns { + public static final Uri CONTENT_URI = BASE_CONTENT_URI_INTERNAL.buildUpon() + .appendPath(BASE_API).build(); + + /** + * Use if multiple items get returned + */ + public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.apis"; + + /** + * Use if a single item is returned + */ + public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.api"; + + public static Uri buildIdUri(String rowId) { + return CONTENT_URI.buildUpon().appendPath(rowId).build(); + } + + public static Uri buildByPackageNameUri(String packageName) { + return CONTENT_URI.buildUpon().appendPath(PATH_BY_PACKAGE_NAME).appendPath(packageName) + .build(); + } + } + public static class ApiApps implements ApiAppsColumns, BaseColumns { public static final Uri CONTENT_URI = BASE_CONTENT_URI_INTERNAL.buildUpon() - .appendPath(BASE_API_APPS).build(); + .appendPath(BASE_API).appendPath(PATH_APPS).build(); + + /** + * Use if multiple items get returned + */ + public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.api.app"; + + /** + * Use if a single item is returned + */ + public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.api.apps"; + + public static Uri buildIdUri(String rowId) { + return CONTENT_URI.buildUpon().appendPath(rowId).build(); + } + + public static Uri buildByPackageNameUri(String packageName) { + return CONTENT_URI.buildUpon().appendPath(PATH_BY_PACKAGE_NAME).appendPath(packageName) + .build(); + } + } + + public static class ApiAccounts implements ApiAppsAccountsColumns, BaseColumns { + public static final Uri CONTENT_URI = BASE_CONTENT_URI_INTERNAL.buildUpon() + .appendPath(BASE_API).appendPath(PATH_ACCOUNTS).build(); /** * Use if multiple items get returned */ - public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.api_apps"; + public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.api.acoounts"; /** * Use if a single item is returned */ - public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.api_apps"; + public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.api.account"; public static Uri buildIdUri(String rowId) { return CONTENT_URI.buildUpon().appendPath(rowId).build(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java index f7c9fe79d..e56fa2f8f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java @@ -38,7 +38,7 @@ public class KeychainDatabase extends SQLiteOpenHelper { String KEYS = "keys"; String USER_IDS = "user_ids"; String API_APPS = "api_apps"; - String API_APPS_ACCOUNTS = "api_apps_accounts"; + String API_ACCOUNTS = "api_accounts"; } private static final String CREATE_KEY_RINGS = "CREATE TABLE IF NOT EXISTS " + Tables.KEY_RINGS @@ -80,14 +80,14 @@ public class KeychainDatabase extends SQLiteOpenHelper { + ApiAppsColumns.PACKAGE_NAME + " TEXT UNIQUE, " + ApiAppsColumns.PACKAGE_SIGNATURE + " BLOB)"; - private static final String CREATE_API_APPS_ACCOUNTS = "CREATE TABLE IF NOT EXISTS " + Tables.API_APPS_ACCOUNTS + private static final String CREATE_API_APPS_ACCOUNTS = "CREATE TABLE IF NOT EXISTS " + Tables.API_ACCOUNTS + " (" + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + ApiAppsAccountsColumns.KEY_ID + " INT64, " + ApiAppsAccountsColumns.ENCRYPTION_ALGORITHM + " INTEGER, " + ApiAppsAccountsColumns.HASH_ALORITHM + " INTEGER, " + ApiAppsAccountsColumns.COMPRESSION + " INTEGER" - + ApiAppsAccountsColumns.PACKAGE_NAME + " TEXT NOT NULL, FOREIGN KEY(" - + ApiAppsAccountsColumns.PACKAGE_NAME + ") REFERENCES " + Tables.API_APPS + "(" + + ApiAppsAccountsColumns.PACKAGE_NAME_FK + " TEXT NOT NULL, FOREIGN KEY(" + + ApiAppsAccountsColumns.PACKAGE_NAME_FK + ") REFERENCES " + Tables.API_APPS + "(" + ApiAppsColumns.PACKAGE_NAME + ") ON DELETE CASCADE)"; KeychainDatabase(Context context) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java index 746449f7e..a094b13de 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2013 Dominik Schürmann + * Copyright (C) 2012-2014 Dominik Schürmann * Copyright (C) 2010 Thialfihar * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,8 +28,19 @@ import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri; import android.provider.BaseColumns; import android.text.TextUtils; + import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.provider.KeychainContract.*; +import org.sufficientlysecure.keychain.provider.KeychainContract.Api; +import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAccounts; +import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; +import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsAccountsColumns; +import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; +import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingsColumns; +import org.sufficientlysecure.keychain.provider.KeychainContract.KeyTypes; +import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; +import org.sufficientlysecure.keychain.provider.KeychainContract.KeysColumns; +import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; +import org.sufficientlysecure.keychain.provider.KeychainContract.UserIdsColumns; import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables; import org.sufficientlysecure.keychain.util.Log; @@ -70,9 +81,15 @@ public class KeychainProvider extends ContentProvider { private static final int SECRET_KEY_RING_USER_ID = 221; private static final int SECRET_KEY_RING_USER_ID_BY_ROW_ID = 222; - private static final int API_APPS = 301; - private static final int API_APPS_BY_ROW_ID = 302; - private static final int API_APPS_BY_PACKAGE_NAME = 303; + private static final int API = 301; + private static final int API_BY_ROW_ID = 302; + private static final int API_BY_PACKAGE_NAME = 303; + private static final int API_APPS = 304; + private static final int API_APPS_BY_ROW_ID = 305; + private static final int API_APPS_BY_PACKAGE_NAME = 306; + private static final int API_ACCOUNTS = 307; + private static final int API_ACCOUNTS_BY_ROW_ID = 308; + private static final int API_ACCOUNTS_BY_PACKAGE_NAME = 309; private static final int UNIFIED_KEY_RING = 401; @@ -230,11 +247,27 @@ public class KeychainProvider extends ContentProvider { /** * API apps */ - matcher.addURI(authority, KeychainContract.BASE_API_APPS, API_APPS); - matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/#", API_APPS_BY_ROW_ID); - matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/" + matcher.addURI(authority, KeychainContract.BASE_API, API); + matcher.addURI(authority, KeychainContract.BASE_API + "/#", API_BY_ROW_ID); + matcher.addURI(authority, KeychainContract.BASE_API + "/" + + KeychainContract.PATH_BY_PACKAGE_NAME + "/*", API_BY_PACKAGE_NAME); + + matcher.addURI(authority, KeychainContract.BASE_API + "/" + + KeychainContract.PATH_APPS, API_APPS); + matcher.addURI(authority, KeychainContract.BASE_API + "/" + + KeychainContract.PATH_APPS + "/#", API_APPS_BY_ROW_ID); + matcher.addURI(authority, KeychainContract.BASE_API + "/" + + KeychainContract.PATH_APPS + "/" + KeychainContract.PATH_BY_PACKAGE_NAME + "/*", API_APPS_BY_PACKAGE_NAME); + matcher.addURI(authority, KeychainContract.BASE_API + "/" + + KeychainContract.PATH_ACCOUNTS, API_ACCOUNTS); + matcher.addURI(authority, KeychainContract.BASE_API + "/" + + KeychainContract.PATH_ACCOUNTS + "/#", API_ACCOUNTS_BY_ROW_ID); + matcher.addURI(authority, KeychainContract.BASE_API + "/" + + KeychainContract.PATH_ACCOUNTS + "/" + + KeychainContract.PATH_BY_PACKAGE_NAME + "/*", API_ACCOUNTS_BY_PACKAGE_NAME); + /** * data stream * @@ -299,6 +332,13 @@ public class KeychainProvider extends ContentProvider { case SECRET_KEY_RING_USER_ID_BY_ROW_ID: return UserIds.CONTENT_ITEM_TYPE; + case API: + return Api.CONTENT_TYPE; + + case API_BY_ROW_ID: + case API_BY_PACKAGE_NAME: + return Api.CONTENT_ITEM_TYPE; + case API_APPS: return ApiApps.CONTENT_TYPE; @@ -306,6 +346,13 @@ public class KeychainProvider extends ContentProvider { case API_APPS_BY_PACKAGE_NAME: return ApiApps.CONTENT_ITEM_TYPE; + case API_ACCOUNTS: + return ApiAccounts.CONTENT_TYPE; + + case API_ACCOUNTS_BY_ROW_ID: + case API_ACCOUNTS_BY_PACKAGE_NAME: + return ApiAccounts.CONTENT_ITEM_TYPE; + default: throw new UnsupportedOperationException("Unknown uri: " + uri); } @@ -506,7 +553,6 @@ public class KeychainProvider extends ContentProvider { } break; - case PUBLIC_KEY_RING: case SECRET_KEY_RING: qb = buildKeyRingQuery(qb, match); @@ -516,7 +562,6 @@ public class KeychainProvider extends ContentProvider { } break; - case PUBLIC_KEY_RING_BY_ROW_ID: case SECRET_KEY_RING_BY_ROW_ID: qb = buildKeyRingQuery(qb, match); @@ -529,7 +574,6 @@ public class KeychainProvider extends ContentProvider { } break; - case PUBLIC_KEY_RING_BY_MASTER_KEY_ID: case SECRET_KEY_RING_BY_MASTER_KEY_ID: qb = buildKeyRingQuery(qb, match); @@ -542,7 +586,6 @@ public class KeychainProvider extends ContentProvider { } break; - case SECRET_KEY_RING_BY_KEY_ID: case PUBLIC_KEY_RING_BY_KEY_ID: qb = buildKeyRingQueryWithSpecificKey(qb, match); @@ -555,7 +598,6 @@ public class KeychainProvider extends ContentProvider { } break; - case SECRET_KEY_RING_BY_EMAILS: case PUBLIC_KEY_RING_BY_EMAILS: qb = buildKeyRingQuery(qb, match); @@ -585,7 +627,6 @@ public class KeychainProvider extends ContentProvider { } break; - case SECRET_KEY_RING_BY_LIKE_EMAIL: case PUBLIC_KEY_RING_BY_LIKE_EMAIL: qb = buildKeyRingQuery(qb, match); @@ -601,7 +642,6 @@ public class KeychainProvider extends ContentProvider { + "))"); break; - case PUBLIC_KEY_RING_KEY: case SECRET_KEY_RING_KEY: qb.setTables(Tables.KEYS); @@ -614,7 +654,6 @@ public class KeychainProvider extends ContentProvider { qb.setProjectionMap(getProjectionMapForKeys()); break; - case PUBLIC_KEY_RING_KEY_BY_ROW_ID: case SECRET_KEY_RING_KEY_BY_ROW_ID: qb.setTables(Tables.KEYS); @@ -630,7 +669,6 @@ public class KeychainProvider extends ContentProvider { qb.setProjectionMap(getProjectionMapForKeys()); break; - case PUBLIC_KEY_RING_BY_MASTER_KEY_ID_USER_ID: qb.setTables(Tables.USER_IDS + " INNER JOIN " + Tables.KEY_RINGS + " ON " + "(" + Tables.KEY_RINGS + "." + BaseColumns._ID + " = " + Tables.USER_IDS + "." @@ -641,7 +679,6 @@ public class KeychainProvider extends ContentProvider { qb.setProjectionMap(getProjectionMapForUserIds()); break; - case PUBLIC_KEY_RING_USER_ID: case SECRET_KEY_RING_USER_ID: qb.setTables(Tables.USER_IDS); @@ -649,7 +686,6 @@ public class KeychainProvider extends ContentProvider { qb.appendWhereEscapeString(uri.getPathSegments().get(2)); break; - case PUBLIC_KEY_RING_USER_ID_BY_ROW_ID: case SECRET_KEY_RING_USER_ID_BY_ROW_ID: qb.setTables(Tables.USER_IDS); @@ -660,7 +696,28 @@ public class KeychainProvider extends ContentProvider { qb.appendWhereEscapeString(uri.getLastPathSegment()); break; + case API: + qb.setTables(Tables.API_ACCOUNTS + " INNER JOIN " + Tables.API_APPS + " ON " + "(" + + Tables.API_APPS + "." + ApiApps.PACKAGE_NAME + " = " + Tables.API_ACCOUNTS + "." + + ApiAccounts.PACKAGE_NAME_FK + " )"); + + break; + case API_BY_ROW_ID: + qb.setTables(Tables.API_ACCOUNTS + " INNER JOIN " + Tables.API_APPS + " ON " + "(" + + Tables.API_APPS + "." + ApiApps.PACKAGE_NAME + " = " + Tables.API_ACCOUNTS + "." + + ApiAccounts.PACKAGE_NAME_FK + " )"); + qb.appendWhere(Tables.API_APPS + "." + BaseColumns._ID + " = "); + qb.appendWhereEscapeString(uri.getLastPathSegment()); + + break; + case API_BY_PACKAGE_NAME: + qb.setTables(Tables.API_ACCOUNTS + " INNER JOIN " + Tables.API_APPS + " ON " + "(" + + Tables.API_APPS + "." + ApiApps.PACKAGE_NAME + " = " + Tables.API_ACCOUNTS + "." + + ApiAccounts.PACKAGE_NAME_FK + " )"); + qb.appendWhere(Tables.API_APPS + "." + ApiApps.PACKAGE_NAME + " = "); + qb.appendWhereEscapeString(uri.getLastPathSegment()); + break; case API_APPS: qb.setTables(Tables.API_APPS); @@ -675,10 +732,26 @@ public class KeychainProvider extends ContentProvider { case API_APPS_BY_PACKAGE_NAME: qb.setTables(Tables.API_APPS); qb.appendWhere(ApiApps.PACKAGE_NAME + " = "); - qb.appendWhereEscapeString(uri.getPathSegments().get(2)); + qb.appendWhereEscapeString(uri.getLastPathSegment()); + + break; + case API_ACCOUNTS: + qb.setTables(Tables.API_ACCOUNTS); break; + case API_ACCOUNTS_BY_ROW_ID: + qb.setTables(Tables.API_ACCOUNTS); + qb.appendWhere(BaseColumns._ID + " = "); + qb.appendWhereEscapeString(uri.getLastPathSegment()); + + break; + case API_ACCOUNTS_BY_PACKAGE_NAME: + qb.setTables(Tables.API_ACCOUNTS); + qb.appendWhere(ApiAppsAccountsColumns.PACKAGE_NAME_FK + " = "); + qb.appendWhereEscapeString(uri.getLastPathSegment()); + + break; default: throw new IllegalArgumentException("Unknown URI " + uri); @@ -770,6 +843,11 @@ public class KeychainProvider extends ContentProvider { rowId = db.insertOrThrow(Tables.API_APPS, null, values); rowUri = ApiApps.buildIdUri(Long.toString(rowId)); + break; + case API_ACCOUNTS: + rowId = db.insertOrThrow(Tables.API_ACCOUNTS, null, values); + rowUri = ApiAccounts.buildIdUri(Long.toString(rowId)); + break; default: throw new UnsupportedOperationException("Unknown uri: " + uri); @@ -836,6 +914,14 @@ public class KeychainProvider extends ContentProvider { count = db.delete(Tables.API_APPS, buildDefaultApiAppsSelection(uri, true, selection), selectionArgs); break; + case API_ACCOUNTS_BY_ROW_ID: + count = db.delete(Tables.API_ACCOUNTS, buildDefaultApiAccountsSelection(uri, false, selection), + selectionArgs); + break; + case API_ACCOUNTS_BY_PACKAGE_NAME: + count = db.delete(Tables.API_ACCOUNTS, buildDefaultApiAccountsSelection(uri, true, selection), + selectionArgs); + break; default: throw new UnsupportedOperationException("Unknown uri: " + uri); } @@ -906,6 +992,14 @@ public class KeychainProvider extends ContentProvider { count = db.update(Tables.API_APPS, values, buildDefaultApiAppsSelection(uri, true, selection), selectionArgs); break; + case API_ACCOUNTS_BY_ROW_ID: + count = db.update(Tables.API_ACCOUNTS, values, + buildDefaultApiAccountsSelection(uri, false, selection), selectionArgs); + break; + case API_ACCOUNTS_BY_PACKAGE_NAME: + count = db.update(Tables.API_ACCOUNTS, values, + buildDefaultApiAccountsSelection(uri, true, selection), selectionArgs); + break; default: throw new UnsupportedOperationException("Unknown uri: " + uri); } @@ -1018,6 +1112,21 @@ public class KeychainProvider extends ContentProvider { } } + private String buildDefaultApiAccountsSelection(Uri uri, boolean packageSelection, String selection) { + String lastPathSegment = uri.getLastPathSegment(); + + String andSelection = ""; + if (!TextUtils.isEmpty(selection)) { + andSelection = " AND (" + selection + ")"; + } + + if (packageSelection) { + return ApiAccounts.PACKAGE_NAME_FK + "=" + lastPathSegment + andSelection; + } else { + return BaseColumns._ID + "=" + lastPathSegment + andSelection; + } + } + // @Override // public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException { // int match = mUriMatcher.match(uri); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java index e0d007de7..7e8bfbc7b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -809,44 +809,62 @@ public class ProviderHelper { return values; } - public static void insertApiApp(Context context, AppSettings appSettings) { - context.getContentResolver().insert(ApiApps.CONTENT_URI, + private static ContentValues contentValueForApiAccounts(AppSettings appSettings) { + ContentValues values = new ContentValues(); + values.put(KeychainContract.ApiAccounts.PACKAGE_NAME_FK, appSettings.getPackageName()); + values.put(KeychainContract.ApiAccounts.KEY_ID, appSettings.getKeyId()); + values.put(KeychainContract.ApiAccounts.COMPRESSION, appSettings.getCompression()); + values.put(KeychainContract.ApiAccounts.ENCRYPTION_ALGORITHM, appSettings.getEncryptionAlgorithm()); + values.put(KeychainContract.ApiAccounts.HASH_ALORITHM, appSettings.getHashAlgorithm()); + + return values; + } + + public static void insertApi(Context context, AppSettings appSettings) { + context.getContentResolver().insert(KeychainContract.ApiApps.CONTENT_URI, + contentValueForApiApps(appSettings)); + context.getContentResolver().insert(KeychainContract.ApiAccounts.CONTENT_URI, contentValueForApiApps(appSettings)); } + // TODO: uri not working because it is used for both tables public static void updateApiApp(Context context, AppSettings appSettings, Uri uri) { if (context.getContentResolver().update(uri, contentValueForApiApps(appSettings), null, null) <= 0) { throw new RuntimeException(); } + if (context.getContentResolver().update(uri, contentValueForApiAccounts(appSettings), null, + null) <= 0) { + throw new RuntimeException(); + } } - public static AppSettings getApiAppSettings(Context context, Uri uri) { + public static AppSettings getApiSettings(Context context, Uri uri) { AppSettings settings = null; Cursor cur = context.getContentResolver().query(uri, null, null, null, null); if (cur != null && cur.moveToFirst()) { settings = new AppSettings(); settings.setPackageName(cur.getString(cur - .getColumnIndex(KeychainContract.ApiApps.PACKAGE_NAME))); + .getColumnIndex(KeychainContract.Api.PACKAGE_NAME))); settings.setPackageSignature(cur.getBlob(cur - .getColumnIndex(KeychainContract.ApiApps.PACKAGE_SIGNATURE))); - settings.setKeyId(cur.getLong(cur.getColumnIndex(KeychainContract.ApiApps.KEY_ID))); + .getColumnIndex(KeychainContract.Api.PACKAGE_SIGNATURE))); + settings.setKeyId(cur.getLong(cur.getColumnIndex(KeychainContract.Api.KEY_ID))); settings.setCompression(cur.getInt(cur - .getColumnIndexOrThrow(KeychainContract.ApiApps.COMPRESSION))); + .getColumnIndexOrThrow(KeychainContract.Api.COMPRESSION))); settings.setHashAlgorithm(cur.getInt(cur - .getColumnIndexOrThrow(KeychainContract.ApiApps.HASH_ALORITHM))); + .getColumnIndexOrThrow(KeychainContract.Api.HASH_ALORITHM))); settings.setEncryptionAlgorithm(cur.getInt(cur - .getColumnIndexOrThrow(KeychainContract.ApiApps.ENCRYPTION_ALGORITHM))); + .getColumnIndexOrThrow(KeychainContract.Api.ENCRYPTION_ALGORITHM))); } return settings; } - public static byte[] getApiAppSignature(Context context, String packageName) { - Uri queryUri = KeychainContract.ApiApps.buildByPackageNameUri(packageName); + public static byte[] getApiSignature(Context context, String packageName) { + Uri queryUri = KeychainContract.Api.buildByPackageNameUri(packageName); - String[] projection = new String[]{ApiApps.PACKAGE_SIGNATURE}; + String[] projection = new String[]{KeychainContract.Api.PACKAGE_SIGNATURE}; ContentResolver cr = context.getContentResolver(); Cursor cursor = cr.query(queryUri, projection, null, null, null); -- cgit v1.2.3 From 57f9b55677fd0829280a082f739e7d49fbf61db2 Mon Sep 17 00:00:00 2001 From: Sreeram Boyapati Date: Sun, 23 Mar 2014 14:35:48 +0530 Subject: Added can_encrypt check --- .../sufficientlysecure/keychain/ui/ViewKeyMainFragment.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index e140cb21e..e4f707f3c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -324,7 +324,17 @@ public class ViewKeyMainFragment extends Fragment implements mFingerprint.setText(OtherHelper.colorizeFingerprint(fingerprint)); } - + int valid_keys = 0; + data.moveToFirst(); + do{ + if(data.getInt(KEYS_INDEX_CAN_ENCRYPT) == 1){ + valid_keys++; + } + }while(data.moveToNext()); + if(valid_keys == 0){ + mActionEncrypt.setVisibility(View.GONE); + } + Log.i("Valid Encryption keys", Integer.toString(valid_keys)); mKeysAdapter.swapCursor(data); break; -- cgit v1.2.3 From 900e8ce990862534370df84e6dea53716b7b594c Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Sun, 23 Mar 2014 12:32:13 +0100 Subject: Adjust credits --- OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html | 3 +-- OpenPGP-Keychain/src/main/res/raw-de/help_about.html | 3 +-- OpenPGP-Keychain/src/main/res/raw-el/help_about.html | 3 +-- OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html | 3 +-- OpenPGP-Keychain/src/main/res/raw-es/help_about.html | 3 +-- OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html | 3 +-- OpenPGP-Keychain/src/main/res/raw-fr/help_about.html | 3 +-- OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html | 3 +-- OpenPGP-Keychain/src/main/res/raw-ja/help_about.html | 3 +-- OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html | 3 +-- OpenPGP-Keychain/src/main/res/raw-pl/help_about.html | 3 +-- OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html | 3 +-- OpenPGP-Keychain/src/main/res/raw-ru/help_about.html | 3 +-- OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html | 3 +-- OpenPGP-Keychain/src/main/res/raw-tr/help_about.html | 3 +-- OpenPGP-Keychain/src/main/res/raw-uk/help_about.html | 3 +-- OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html | 3 +-- OpenPGP-Keychain/src/main/res/raw-zh/help_about.html | 3 +-- OpenPGP-Keychain/src/main/res/raw/help_about.html | 3 +-- 19 files changed, 19 insertions(+), 38 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html index 863aeee58..58ce75258 100644 --- a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html @@ -15,9 +15,8 @@

      Developers APG 1.x

        -
      • 'Thialfihar' (Lead developer)
      • +
      • Thialfihar (Lead developer)
      • 'Senecaso' (QRCode, sign key, upload key)
      • -
      • Oliver Runge
      • Markus Doits

      Libraries

      diff --git a/OpenPGP-Keychain/src/main/res/raw-de/help_about.html b/OpenPGP-Keychain/src/main/res/raw-de/help_about.html index 37d4193f7..683c8e859 100644 --- a/OpenPGP-Keychain/src/main/res/raw-de/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-de/help_about.html @@ -15,9 +15,8 @@

    Entwickler APG 1.x

      -
    • 'Thialfihar' (Leitender Entwickler)
    • +
    • Thialfihar (Leitender Entwickler)
    • 'Senecaso' (QR-Code, Schlüssel signtieren, Schlüssel hochladen)
    • -
    • Oliver Runge
    • Markus Doits

    Bibliotheken

    diff --git a/OpenPGP-Keychain/src/main/res/raw-el/help_about.html b/OpenPGP-Keychain/src/main/res/raw-el/help_about.html index 863aeee58..58ce75258 100644 --- a/OpenPGP-Keychain/src/main/res/raw-el/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-el/help_about.html @@ -15,9 +15,8 @@

    Developers APG 1.x

      -
    • 'Thialfihar' (Lead developer)
    • +
    • Thialfihar (Lead developer)
    • 'Senecaso' (QRCode, sign key, upload key)
    • -
    • Oliver Runge
    • Markus Doits

    Libraries

    diff --git a/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html b/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html index 863aeee58..58ce75258 100644 --- a/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html @@ -15,9 +15,8 @@

    Developers APG 1.x

      -
    • 'Thialfihar' (Lead developer)
    • +
    • Thialfihar (Lead developer)
    • 'Senecaso' (QRCode, sign key, upload key)
    • -
    • Oliver Runge
    • Markus Doits

    Libraries

    diff --git a/OpenPGP-Keychain/src/main/res/raw-es/help_about.html b/OpenPGP-Keychain/src/main/res/raw-es/help_about.html index 95189425d..7281e1007 100644 --- a/OpenPGP-Keychain/src/main/res/raw-es/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-es/help_about.html @@ -15,9 +15,8 @@

    Desarrolladores de APG 1.x

      -
    • 'Thialfihar' (Desarrollador principal)
    • +
    • Thialfihar (Desarrollador principal)
    • 'Senecaso' (Código QR, clave de firma, carga de clave)
    • -
    • Oliver Runge
    • Markus Doits

    Librerías

    diff --git a/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html b/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html index 863aeee58..58ce75258 100644 --- a/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html @@ -15,9 +15,8 @@

    Developers APG 1.x

      -
    • 'Thialfihar' (Lead developer)
    • +
    • Thialfihar (Lead developer)
    • 'Senecaso' (QRCode, sign key, upload key)
    • -
    • Oliver Runge
    • Markus Doits

    Libraries

    diff --git a/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html b/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html index 3cbbce4d5..7606292ac 100644 --- a/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html @@ -15,9 +15,8 @@

    Les développeurs d'APG 1.x

      -
    • « Thialfihar (développeur principal)
    • +
    • Thialfihar (développeur principal)
    • « Senecaso » (Code QR, signer/téléverser la clef)
    • -
    • Oliver Runge
    • Markus Doits

    Bibliothèques

    diff --git a/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html b/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html index ba0676f3e..499e33238 100644 --- a/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html @@ -15,9 +15,8 @@

    Sviluppatori APG 1.x

      -
    • 'Thialfihar' (Capo Sviluppatore)
    • +
    • Thialfihar (Capo Sviluppatore)
    • 'Senecaso' (QRCode, firma chiavi, caricamento chiavi)
    • -
    • Oliver Runge
    • Markus Doits

    Librerie

    diff --git a/OpenPGP-Keychain/src/main/res/raw-ja/help_about.html b/OpenPGP-Keychain/src/main/res/raw-ja/help_about.html index 206fc9f8d..206334bcd 100644 --- a/OpenPGP-Keychain/src/main/res/raw-ja/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-ja/help_about.html @@ -15,9 +15,8 @@

    APG 1.xの開発者達

      -
    • 'Thialfihar' (主任開発者)
    • +
    • Thialfihar (主任開発者)
    • 'Senecaso' (QRコード, 鍵署名, 鍵アップロード関係)
    • -
    • Oliver Runge
    • Markus Doits

    ライブラリ

    diff --git a/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html b/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html index 863aeee58..58ce75258 100644 --- a/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html @@ -15,9 +15,8 @@

    Developers APG 1.x

      -
    • 'Thialfihar' (Lead developer)
    • +
    • Thialfihar (Lead developer)
    • 'Senecaso' (QRCode, sign key, upload key)
    • -
    • Oliver Runge
    • Markus Doits

    Libraries

    diff --git a/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html b/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html index de16d333f..aff9a6de6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html @@ -15,9 +15,8 @@

    Deweloperzy APG 1.x

      -
    • 'Thialfihar' (Wiodacy deweloper)
    • +
    • Thialfihar (Wiodacy deweloper)
    • 'Senecaso' (kody QR, podpisy kluczy, wysyłanie kluczy)
    • -
    • Oliver Runge
    • Markus Doits

    Biblioteki

    diff --git a/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html b/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html index 863aeee58..58ce75258 100644 --- a/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html @@ -15,9 +15,8 @@

    Developers APG 1.x

      -
    • 'Thialfihar' (Lead developer)
    • +
    • Thialfihar (Lead developer)
    • 'Senecaso' (QRCode, sign key, upload key)
    • -
    • Oliver Runge
    • Markus Doits

    Libraries

    diff --git a/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html b/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html index 655e98758..ad1fd62b6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html @@ -15,9 +15,8 @@

    Разработчики APG 1.x

      -
    • 'Thialfihar' (главный разработчик)
    • +
    • Thialfihar (главный разработчик)
    • 'Senecaso' (QR коды, подписание и загрузка ключей)
    • -
    • Oliver Runge
    • Markus Doits

    Компоненты

    diff --git a/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html b/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html index 863aeee58..58ce75258 100644 --- a/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html @@ -15,9 +15,8 @@

    Developers APG 1.x

      -
    • 'Thialfihar' (Lead developer)
    • +
    • Thialfihar (Lead developer)
    • 'Senecaso' (QRCode, sign key, upload key)
    • -
    • Oliver Runge
    • Markus Doits

    Libraries

    diff --git a/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html b/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html index eb262b242..6faa367dd 100644 --- a/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html @@ -15,9 +15,8 @@

    Geliştiriciler APG 1.x

      -
    • 'Thialfihar' (Baş geliştirici)
    • +
    • Thialfihar (Baş geliştirici)
    • 'Senecaso' (QR Kodu, anahtar imzalama, anahtar yükleme)
    • -
    • Oliver Runge
    • Markus Doits

    Kütüphaneler

    diff --git a/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html b/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html index c8a5a82c5..f801dd335 100644 --- a/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html @@ -15,9 +15,8 @@

    Розробники APG 1.x

      -
    • 'Thialfihar' (основний розробник)
    • +
    • Thialfihar (основний розробник)
    • 'Senecaso' (штрих-код, підпис і завантаження ключів)
    • -
    • Олівер Ранж
    • Маркус Дойтс

    Бібліотеки

    diff --git a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html index 863aeee58..58ce75258 100644 --- a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html @@ -15,9 +15,8 @@

    Developers APG 1.x

      -
    • 'Thialfihar' (Lead developer)
    • +
    • Thialfihar (Lead developer)
    • 'Senecaso' (QRCode, sign key, upload key)
    • -
    • Oliver Runge
    • Markus Doits

    Libraries

    diff --git a/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html b/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html index 23b904995..9038dc3f4 100644 --- a/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html @@ -15,9 +15,8 @@

    Developers APG 1.x

      -
    • 'Thialfihar' (Lead developer)
    • +
    • Thialfihar (Lead developer)
    • 'Senecaso' (QRCode, sign key, upload key)
    • -
    • Oliver Runge
    • Markus Doits

    函式庫

    diff --git a/OpenPGP-Keychain/src/main/res/raw/help_about.html b/OpenPGP-Keychain/src/main/res/raw/help_about.html index 51e3f1325..0fa14efc4 100644 --- a/OpenPGP-Keychain/src/main/res/raw/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw/help_about.html @@ -19,9 +19,8 @@ And don't add newlines before or after p tags because of transifex -->

    Developers APG 1.x

      -
    • 'Thialfihar' (Lead developer)
    • +
    • Thialfihar (Lead developer)
    • 'Senecaso' (QRCode, sign key, upload key)
    • -
    • Oliver Runge
    • Markus Doits
    -- cgit v1.2.3 From 2ea0cd0e8a02072150230dda7dd24a63ff682603 Mon Sep 17 00:00:00 2001 From: Daniel Hammann Date: Sun, 23 Mar 2014 19:35:12 +0100 Subject: No "empty-list" layout flashing up on start of OpenKeychain --- OpenPGP-Keychain/src/main/res/layout/key_list_fragment.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/layout/key_list_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/key_list_fragment.xml index 77bd6f4e9..f2430f213 100644 --- a/OpenPGP-Keychain/src/main/res/layout/key_list_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/key_list_fragment.xml @@ -11,7 +11,7 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" - android:visibility="gone" + android:visibility="visible" android:gravity="center"> + android:orientation="vertical" + android:visibility="gone"> Date: Sun, 23 Mar 2014 19:21:45 +0100 Subject: Adjust encrypt layout, align signature with button --- OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml index 03fe496c6..1dba66cfa 100644 --- a/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml @@ -72,7 +72,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" - android:paddingLeft="16dp"> + android:paddingLeft="16dp" + android:paddingRight="4dip"> - \ No newline at end of file + -- cgit v1.2.3 From a2048773ee194168594c52c4ea6472b211ef0d5e Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Sun, 23 Mar 2014 19:37:41 +0100 Subject: Fix file decryption interface Actually use mAssumeSymmetricEncryption and set it to false as default. Don't close the file input stream, so we can actually look for PGP encrypted data in the next step. --- .../org/sufficientlysecure/keychain/ui/DecryptActivity.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java index 3e389c034..ed9735d8c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java @@ -443,8 +443,7 @@ public class DecryptActivity extends DrawerActivity { getDecryptionKeyFromInputStream(); // if we need a symmetric passphrase or a passphrase to use a secret key ask for it - if (mSecretKeyId == Id.key.symmetric - || PassphraseCacheService.getCachedPassphrase(this, mSecretKeyId) == null) { + if (mAssumeSymmetricEncryption || PassphraseCacheService.getCachedPassphrase(this, mSecretKeyId) == null) { showPassphraseDialog(); } else { if (mDecryptTarget == Id.target.file) { @@ -494,6 +493,7 @@ public class DecryptActivity extends DrawerActivity { * TODO: Rework function, remove global variables */ private void getDecryptionKeyFromInputStream() { + mAssumeSymmetricEncryption = false; InputStream inStream = null; if (mContentUri != null) { try { @@ -517,13 +517,6 @@ public class DecryptActivity extends DrawerActivity { Log.e(Constants.TAG, "File not found!", e); AppMsg.makeText(this, getString(R.string.error_file_not_found, e.getMessage()), AppMsg.STYLE_ALERT).show(); - } finally { - try { - if (inStream != null) { - inStream.close(); - } - } catch (Exception e) { - } } } else { inStream = new ByteArrayInputStream(mMessage.getText().toString().getBytes()); @@ -540,7 +533,6 @@ public class DecryptActivity extends DrawerActivity { if (mSecretKeyId == Id.key.none) { throw new PgpGeneralException(getString(R.string.error_no_secret_key_found)); } - mAssumeSymmetricEncryption = false; } catch (NoAsymmetricEncryptionException e) { if (inStream.markSupported()) { inStream.reset(); @@ -553,6 +545,7 @@ public class DecryptActivity extends DrawerActivity { mAssumeSymmetricEncryption = true; } } catch (Exception e) { + Log.e(Constants.TAG, "error while reading decryption key from input stream", e); AppMsg.makeText(this, getString(R.string.error_message, e.getMessage()), AppMsg.STYLE_ALERT).show(); } -- cgit v1.2.3 From b4b709b1e0ff9f520ebd63d934cee7b4fcfc274f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 23 Mar 2014 19:42:17 +0100 Subject: put original license of launcher icon into repo --- Resources/graphics/icon/AUTHORS | 21 +++++++++++ Resources/graphics/icon/COPYING | 48 ++++++++++++++++++++++++++ Resources/graphics/icon/kgpg_key2_kopete.svgz | Bin 0 -> 36830 bytes Resources/graphics/kgpg_key2_kopete.svgz | Bin 36830 -> 0 bytes 4 files changed, 69 insertions(+) create mode 100644 Resources/graphics/icon/AUTHORS create mode 100644 Resources/graphics/icon/COPYING create mode 100644 Resources/graphics/icon/kgpg_key2_kopete.svgz delete mode 100644 Resources/graphics/kgpg_key2_kopete.svgz diff --git a/Resources/graphics/icon/AUTHORS b/Resources/graphics/icon/AUTHORS new file mode 100644 index 000000000..dbfcfb4fc --- /dev/null +++ b/Resources/graphics/icon/AUTHORS @@ -0,0 +1,21 @@ +Oxygen for KDE3 +Oxygen Icon Theme has been developed by The Oxygen Team. + +Art Director: +David Vignoni + +Designers: +David J. Miller +David Vignoni +Johann Ollivier Lapeyre +Kenneth Wimer +Nuno F. Pinheiro +Riccardo Iaconelli + +Thanks to: +Lee Olson: Contributed drawing used in application-x-bittorent icon. +Marco Aurélio "Coré": Improved audio-input-microphone icon. +Matthias Kretz: Contributed "audio-input-line" device icon. +Mauricio Piacentini : game icons mashup + +Repackaged by Luke Channings \ No newline at end of file diff --git a/Resources/graphics/icon/COPYING b/Resources/graphics/icon/COPYING new file mode 100644 index 000000000..2faa27568 --- /dev/null +++ b/Resources/graphics/icon/COPYING @@ -0,0 +1,48 @@ +The Oxygen Icon Theme for KDE3 + Copyright (C) 2007 David Vignoni + Copyright (C) 2007 Johann Ollivier Lapeyre + Copyright (C) 2007 Kenneth Wimer + Copyright (C) 2007 Nuno Fernades Pinheiro + Copyright (C) 2007 Riccardo Iaconelli + Copyright (C) 2007 David Miller + +and others + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library. If not, see . + +Clarification: + + The GNU Lesser General Public License or LGPL is written for + software libraries in the first place. We expressly want the LGPL to + be valid for this artwork library too. + + KDE Oxygen theme icons is a special kind of software library, it is an + artwork library, it's elements can be used in a Graphical User Interface, or + GUI. + + Source code, for this library means: + - where they exist, SVG; + - otherwise, if applicable, the multi-layered formats xcf or psd, or + otherwise png. + + The LGPL in some sections obliges you to make the files carry + notices. With images this is in some cases impossible or hardly useful. + + With this library a notice is placed at a prominent place in the directory + containing the elements. You may follow this practice. + + The exception in section 5 of the GNU Lesser General Public License covers + the use of elements of this art library in a GUI. + + kde-artists [at] kde.org diff --git a/Resources/graphics/icon/kgpg_key2_kopete.svgz b/Resources/graphics/icon/kgpg_key2_kopete.svgz new file mode 100644 index 000000000..2d43afb83 Binary files /dev/null and b/Resources/graphics/icon/kgpg_key2_kopete.svgz differ diff --git a/Resources/graphics/kgpg_key2_kopete.svgz b/Resources/graphics/kgpg_key2_kopete.svgz deleted file mode 100644 index 2d43afb83..000000000 Binary files a/Resources/graphics/kgpg_key2_kopete.svgz and /dev/null differ -- cgit v1.2.3 From 3dfcb037dcf5ae18ab34eb8a42a220d695febfe7 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Sun, 23 Mar 2014 12:57:06 +0100 Subject: Remove icon set credits --- OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html | 2 -- OpenPGP-Keychain/src/main/res/raw-de/help_about.html | 2 -- OpenPGP-Keychain/src/main/res/raw-el/help_about.html | 2 -- OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html | 2 -- OpenPGP-Keychain/src/main/res/raw-es/help_about.html | 2 -- OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html | 2 -- OpenPGP-Keychain/src/main/res/raw-fr/help_about.html | 2 -- OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html | 2 -- OpenPGP-Keychain/src/main/res/raw-ja/help_about.html | 2 -- OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html | 2 -- OpenPGP-Keychain/src/main/res/raw-pl/help_about.html | 2 -- OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html | 2 -- OpenPGP-Keychain/src/main/res/raw-ru/help_about.html | 2 -- OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html | 2 -- OpenPGP-Keychain/src/main/res/raw-tr/help_about.html | 2 -- OpenPGP-Keychain/src/main/res/raw-uk/help_about.html | 2 -- OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html | 2 -- OpenPGP-Keychain/src/main/res/raw-zh/help_about.html | 2 -- OpenPGP-Keychain/src/main/res/raw/help_about.html | 2 -- 19 files changed, 38 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html index 58ce75258..5a8f7bde7 100644 --- a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html @@ -37,8 +37,6 @@ HtmlTextView (Apache License v2)
  • Android AppMsg Library (Apache License v2)
  • -
  • Icons from RRZE Icon Set (Creative Commons Attribution Share-Alike licence 3.0)
  • -
  • Icons from Tango Icon Set (Public Domain)
  • diff --git a/OpenPGP-Keychain/src/main/res/raw-de/help_about.html b/OpenPGP-Keychain/src/main/res/raw-de/help_about.html index 683c8e859..4199f9b5e 100644 --- a/OpenPGP-Keychain/src/main/res/raw-de/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-de/help_about.html @@ -37,8 +37,6 @@ HtmlTextView (Apache Lizenz v2)
  • Android AppMsg Bibliothek (Apache Lizenz v2)
  • -
  • Icons von RRZE Icon Set (Creative Commons Attribution Share-Alike Lizenz 3.0)
  • -
  • Icons von Tango Icon Set (Public Domain)
  • diff --git a/OpenPGP-Keychain/src/main/res/raw-el/help_about.html b/OpenPGP-Keychain/src/main/res/raw-el/help_about.html index 58ce75258..5a8f7bde7 100644 --- a/OpenPGP-Keychain/src/main/res/raw-el/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-el/help_about.html @@ -37,8 +37,6 @@ HtmlTextView (Apache License v2)
  • Android AppMsg Library (Apache License v2)
  • -
  • Icons from RRZE Icon Set (Creative Commons Attribution Share-Alike licence 3.0)
  • -
  • Icons from Tango Icon Set (Public Domain)
  • diff --git a/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html b/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html index 58ce75258..5a8f7bde7 100644 --- a/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html @@ -37,8 +37,6 @@ HtmlTextView (Apache License v2)
  • Android AppMsg Library (Apache License v2)
  • -
  • Icons from RRZE Icon Set (Creative Commons Attribution Share-Alike licence 3.0)
  • -
  • Icons from Tango Icon Set (Public Domain)
  • diff --git a/OpenPGP-Keychain/src/main/res/raw-es/help_about.html b/OpenPGP-Keychain/src/main/res/raw-es/help_about.html index 7281e1007..64d80ab74 100644 --- a/OpenPGP-Keychain/src/main/res/raw-es/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-es/help_about.html @@ -37,8 +37,6 @@ HtmlTextView (Licencia Apache v2)
  • Librería Android AppMsg (Licencia Apache v2)
  • -
  • Icons de RRZE Icon Set (Creative Commons Attribution Compartir-Igual licencia 3.0)
  • -
  • Iconos de Tango Icon Set (Dominio Público)
  • diff --git a/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html b/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html index 58ce75258..5a8f7bde7 100644 --- a/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html @@ -37,8 +37,6 @@ HtmlTextView (Apache License v2)
  • Android AppMsg Library (Apache License v2)
  • -
  • Icons from RRZE Icon Set (Creative Commons Attribution Share-Alike licence 3.0)
  • -
  • Icons from Tango Icon Set (Public Domain)
  • diff --git a/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html b/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html index 7606292ac..93e5a5df7 100644 --- a/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html @@ -37,8 +37,6 @@ HtmlTextView (Licence Apache v2)
  • Bibliothèque Android AppMsg (Licence Apache v2)
  • -
  • Icônes du jeu d'icônes RRZE (Licence Creative Commons Paternité - Partage des Conditions Initiales à l'Identique 3.0)
  • -
  • Icônes du jeu d'icônes Tango (domaine public)
  • diff --git a/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html b/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html index 499e33238..5e4a53ed6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html @@ -37,8 +37,6 @@ HtmlTextView (Licenza Apache v2)
  • Android AppMsg Library (Licenza Apache v2)
  • -
  • Icone da RRZE Icon Set (Licenza Creative Commons Attribution Share-Alike 3.0)
  • -
  • Icone da Tango Icon Set (Pubblico Dominio)
  • diff --git a/OpenPGP-Keychain/src/main/res/raw-ja/help_about.html b/OpenPGP-Keychain/src/main/res/raw-ja/help_about.html index 206334bcd..72c7616a3 100644 --- a/OpenPGP-Keychain/src/main/res/raw-ja/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-ja/help_about.html @@ -37,8 +37,6 @@ HtmlTextView (Apache License v2)
  • Android AppMsg Library (Apache License v2)
  • -
  • Icons from RRZE Icon Set (Creative Commons Attribution Share-Alike licence 3.0)
  • -
  • Icons from Tango Icon Set (パブリックドメイン)
  • diff --git a/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html b/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html index 58ce75258..5a8f7bde7 100644 --- a/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html @@ -37,8 +37,6 @@ HtmlTextView (Apache License v2)
  • Android AppMsg Library (Apache License v2)
  • -
  • Icons from RRZE Icon Set (Creative Commons Attribution Share-Alike licence 3.0)
  • -
  • Icons from Tango Icon Set (Public Domain)
  • diff --git a/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html b/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html index aff9a6de6..c07fc503f 100644 --- a/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html @@ -37,8 +37,6 @@ HtmlTextView (Licencja Apache v2)
  • Android AppMsg Library (Licencja Apache v2)
  • -
  • Icons from RRZE Icon Set (Licencja Uznanie autorstwa - Na tych samych warunkach 3.0 CC-BY-SA)
  • -
  • Icons from Tango Icon Set (Domena Publiczna)
  • diff --git a/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html b/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html index 58ce75258..5a8f7bde7 100644 --- a/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html @@ -37,8 +37,6 @@ HtmlTextView (Apache License v2)
  • Android AppMsg Library (Apache License v2)
  • -
  • Icons from RRZE Icon Set (Creative Commons Attribution Share-Alike licence 3.0)
  • -
  • Icons from Tango Icon Set (Public Domain)
  • diff --git a/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html b/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html index ad1fd62b6..8379bf8de 100644 --- a/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html @@ -37,8 +37,6 @@ HtmlTextView (Apache License v2)
  • Библиотека Android AppMsg (Apache License v2)
  • -
  • Иконки RRZE Icon Set (Creative Commons Attribution Share-Alike licence 3.0)
  • -
  • Иконки Tango Icon Set (Public Domain)
  • diff --git a/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html b/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html index 58ce75258..5a8f7bde7 100644 --- a/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html @@ -37,8 +37,6 @@ HtmlTextView (Apache License v2)
  • Android AppMsg Library (Apache License v2)
  • -
  • Icons from RRZE Icon Set (Creative Commons Attribution Share-Alike licence 3.0)
  • -
  • Icons from Tango Icon Set (Public Domain)
  • diff --git a/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html b/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html index 6faa367dd..454d16151 100644 --- a/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html @@ -37,8 +37,6 @@ HtmlTextView (Apache License v2)
  • Android AppMsg Library (Apache License v2)
  • -
  • İkonlar RRZE Icon Set (Creative Commons Attribution Share-Alike licence 3.0)
  • -
  • İkonlar Tango Icon Set (Public Domain)
  • diff --git a/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html b/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html index f801dd335..9526dc0c6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html @@ -37,8 +37,6 @@ HtmlTextView (ліцензія Apache в.2)
  • Бібліотека Android AppMsg Library (Ліцензія Apache в. 2)
  • -
  • Піктограми із набору піктограм RRZE (ліцензія Creative Commons - Із зазначенням авторства - Розповсюдження на тих самих умовах - версія 3.0)
  • -
  • Піктограми із набору піктограм Tango (відкритий домен)
  • diff --git a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html index 58ce75258..5a8f7bde7 100644 --- a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html @@ -37,8 +37,6 @@ HtmlTextView (Apache License v2)
  • Android AppMsg Library (Apache License v2)
  • -
  • Icons from RRZE Icon Set (Creative Commons Attribution Share-Alike licence 3.0)
  • -
  • Icons from Tango Icon Set (Public Domain)
  • diff --git a/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html b/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html index 9038dc3f4..6d00fc6a1 100644 --- a/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html @@ -37,8 +37,6 @@ HtmlTextView (Apache License v2)
  • Android AppMsg Library (Apache License v2)
  • -
  • Icons from RRZE Icon Set (Creative Commons Attribution Share-Alike licence 3.0)
  • -
  • Icons from Tango Icon Set (Public Domain)
  • diff --git a/OpenPGP-Keychain/src/main/res/raw/help_about.html b/OpenPGP-Keychain/src/main/res/raw/help_about.html index 0fa14efc4..8d7714365 100644 --- a/OpenPGP-Keychain/src/main/res/raw/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw/help_about.html @@ -34,8 +34,6 @@ And don't add newlines before or after p tags because of transifex -->
  • SpongyCastle (MIT X11 License)
  • HtmlTextView (Apache License v2)
  • Android AppMsg Library (Apache License v2)
  • -
  • Icons from RRZE Icon Set (Creative Commons Attribution Share-Alike licence 3.0)
  • -
  • Icons from Tango Icon Set (Public Domain)
  • -- cgit v1.2.3 From 9d4582f9689f53589bbf7cc3e224f9fd061f1d51 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Sun, 23 Mar 2014 19:52:25 +0100 Subject: Update README.md, icon set not used anymore --- README.md | 64 ++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 8954bdcda..958a445be 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # OpenKeychain (for Android) -OpenKeychain is an OpenPGP implementation for Android. +OpenKeychain is an OpenPGP implementation for Android. For a more detailed description and installation instructions go to http://www.openkeychain.org . ### Travis CI Build Status @@ -31,9 +31,9 @@ Development mailinglist at http://groups.google.com/d/forum/openpgp-keychain-dev ### Build with Gradle 1. Have Android SDK "tools", "platform-tools", and "build-tools" directories in your PATH (http://developer.android.com/sdk/index.html) -2. Open the Android SDK Manager (shell command: ``android``). -Expand the Tools directory and select "Android SDK Build-tools (Version 19.0.3)". -Expand the Extras directory and install "Android Support Repository" +2. Open the Android SDK Manager (shell command: ``android``). +Expand the Tools directory and select "Android SDK Build-tools (Version 19.0.3)". +Expand the Extras directory and install "Android Support Repository" Select everything for the newest SDK (API-Level 19) 3. Export ANDROID_HOME pointing to your Android SDK 4. Execute ``./gradlew build`` @@ -59,11 +59,11 @@ I am using the newest [Android Studio](http://developer.android.com/sdk/installi OpenKeychain provides two APIs, namely the Intent API and the Remote OpenPGP API. The Intent API can be used without permissions to start OpenKeychain's activities for cryptographic operations, import of keys, etc. -However, it always requires user input, so that no malicious application can use this API without user intervention. +However, it always requires user input, so that no malicious application can use this API without user intervention. The Remote OpenPGP API is more sophisticated and allows to to operations without user interaction in the background. When utilizing this API, OpenKeychain asks the user on first use to grant access for the calling client application. -More technical information and examples about these APIs can be found in the project's wiki: +More technical information and examples about these APIs can be found in the project's wiki: * [Intent API](https://github.com/openpgp-keychain/openpgp-keychain/wiki/Intent-API) * [Remote OpenPGP API](https://github.com/openpgp-keychain/openpgp-keychain/wiki/OpenPGP-API) @@ -110,7 +110,7 @@ see ### Gradle Build System -We try to make our builds as [reproducible/deterministic](https://blog.torproject.org/blog/deterministic-builds-part-one-cyberwar-and-global-compromise) as possible. +We try to make our builds as [reproducible/deterministic](https://blog.torproject.org/blog/deterministic-builds-part-one-cyberwar-and-global-compromise) as possible. When changing build files or dependencies, respect the following requirements: * No precompiled libraries. All libraries should be provided as sourcecode in "libraries" folder (you never know what pre-compiled jar files really contain! The library files are currently directly commited, because git submodules/git subtree are too much of a hassle for new contributors. This could change in the future!) * No dependencies from Maven (also a soft requirement for inclusion in [F-Droid](https://f-droid.org)) @@ -180,59 +180,55 @@ Some parts (older parts and some libraries are Apache License v2, MIT X11 Licens > it under the terms of the GNU General Public License as published by > the Free Software Foundation, either version 3 of the License, or > (at your option) any later version. -> +> > This program is distributed in the hope that it will be useful, > but WITHOUT ANY WARRANTY; without even the implied warranty of > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > GNU General Public License for more details. -> +> > You should have received a copy of the GNU General Public License > along with this program. If not, see . ### Libraries -* SpongyCastle - https://github.com/rtyley/spongycastle +* SpongyCastle + https://github.com/rtyley/spongycastle MIT X11 License -* Android Support Library v4 - http://developer.android.com/tools/support-library/index.html +* Android Support Library v4 + http://developer.android.com/tools/support-library/index.html Apache License v2 - -* Android Support Library v7 'appcompat' - http://developer.android.com/tools/support-library/index.html + +* Android Support Library v7 'appcompat' + http://developer.android.com/tools/support-library/index.html Apache License v2 -* HtmlTextView - https://github.com/dschuermann/html-textview +* HtmlTextView + https://github.com/dschuermann/html-textview Apache License v2 -* ZXing - https://github.com/zxing/zxing +* ZXing + https://github.com/zxing/zxing Apache License v2 - -* StickyListHeaders - https://github.com/emilsjolander/StickyListHeaders + +* StickyListHeaders + https://github.com/emilsjolander/StickyListHeaders Apache License v2 - -* Android-Bootstrap - https://github.com/Bearded-Hen/Android-Bootstrap + +* Android-Bootstrap + https://github.com/Bearded-Hen/Android-Bootstrap MIT License -* Android AppMsg - https://github.com/johnkil/Android-AppMsg +* Android AppMsg + https://github.com/johnkil/Android-AppMsg Apache License v2 ### Images -* icon.svg +* icon.svg modified version of kgpg_key2_kopete.svgz -* key.svg - http://rrze-icon-set.berlios.de/ - Creative Commons Attribution Share-Alike licence 3.0 - -* Menu icons +* Menu icons http://developer.android.com/design/downloads/index.html#action-bar-icon-pack -- cgit v1.2.3 From c9053b97a880ffcc7e7f8a58b9150fa546f87db0 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Sun, 23 Mar 2014 21:56:18 +0100 Subject: Rename old mentionings of APG-named things Mostly in comments, most importantly: STORE_PATH now ends in /KeychainBlobs instead of /ApgBlobs --- .../java/org/sufficientlysecure/keychain/helper/ExportHelper.java | 4 ++-- .../keychain/provider/KeychainServiceBlobProvider.java | 2 +- .../keychain/service/KeychainIntentService.java | 2 +- .../org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java | 8 ++++---- .../java/org/sufficientlysecure/keychain/ui/DecryptActivity.java | 4 ++-- .../java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java | 8 ++++---- .../java/org/sufficientlysecure/keychain/ui/EncryptActivity.java | 4 ++-- .../org/sufficientlysecure/keychain/ui/ImportKeysActivity.java | 2 +- .../org/sufficientlysecure/keychain/ui/UploadKeyActivity.java | 4 ++-- .../keychain/ui/dialog/DeleteFileDialogFragment.java | 4 ++-- .../org/sufficientlysecure/keychain/ui/widget/SectionView.java | 4 ++-- 11 files changed, 23 insertions(+), 23 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java index 2bfa796c7..cc240a67b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java @@ -139,7 +139,7 @@ public class ExportHelper { intent.putExtra(KeychainIntentService.EXTRA_DATA, data); - // Message is received after exporting is done in ApgService + // Message is received after exporting is done in KeychainIntentService KeychainIntentServiceHandler exportHandler = new KeychainIntentServiceHandler(mActivity, mActivity.getString(R.string.progress_exporting), ProgressDialog.STYLE_HORIZONTAL, @@ -151,7 +151,7 @@ public class ExportHelper { } }) { public void handleMessage(Message message) { - // handle messages by standard ApgHandler first + // handle messages by standard KeychainIntentServiceHandler first super.handleMessage(message); if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainServiceBlobProvider.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainServiceBlobProvider.java index 6ac61e157..aa30e845d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainServiceBlobProvider.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainServiceBlobProvider.java @@ -38,7 +38,7 @@ import java.util.List; import java.util.UUID; public class KeychainServiceBlobProvider extends ContentProvider { - private static final String STORE_PATH = Constants.Path.APP_DIR + "/ApgBlobs"; + private static final String STORE_PATH = Constants.Path.APP_DIR + "/KeychainBlobs"; private KeychainServiceBlobDatabase mBlobDatabase = null; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index e26ee3c76..bd3a0421b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -855,7 +855,7 @@ public class KeychainIntentService extends IntentService if (this.mIsCanceled) { return; } - Log.e(Constants.TAG, "ApgService Exception: ", e); + Log.e(Constants.TAG, "KeychainIntentService Exception: ", e); e.printStackTrace(); Bundle data = new Bundle(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java index dff4e9d72..5dc06c16d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java @@ -327,11 +327,11 @@ public class CertifyKeyActivity extends ActionBarActivity implements intent.putExtra(KeychainIntentService.EXTRA_DATA, data); - // Message is received after signing is done in ApgService + // Message is received after signing is done in KeychainIntentService KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(this, getString(R.string.progress_signing), ProgressDialog.STYLE_SPINNER) { public void handleMessage(Message message) { - // handle messages by standard ApgHandler first + // handle messages by standard KeychainIntentServiceHandler first super.handleMessage(message); if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { @@ -380,11 +380,11 @@ public class CertifyKeyActivity extends ActionBarActivity implements intent.putExtra(KeychainIntentService.EXTRA_DATA, data); - // Message is received after uploading is done in ApgService + // Message is received after uploading is done in KeychainIntentService KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(this, getString(R.string.progress_exporting), ProgressDialog.STYLE_HORIZONTAL) { public void handleMessage(Message message) { - // handle messages by standard ApgHandler first + // handle messages by standard KeychainIntentServiceHandler first super.handleMessage(message); if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java index ed9735d8c..9b3b00c19 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java @@ -631,11 +631,11 @@ public class DecryptActivity extends DrawerActivity { intent.putExtra(KeychainIntentService.EXTRA_DATA, data); - // Message is received after encrypting is done in ApgService + // Message is received after encrypting is done in KeychainIntentService KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(this, getString(R.string.progress_decrypting), ProgressDialog.STYLE_HORIZONTAL) { public void handleMessage(Message message) { - // handle messages by standard ApgHandler first + // handle messages by standard KeychainIntentServiceHandler first super.handleMessage(message); if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 092a502e1..6eb5b9d2d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -180,7 +180,7 @@ public class EditKeyActivity extends ActionBarActivity { serviceIntent.putExtra(KeychainIntentService.EXTRA_DATA, data); - // Message is received after generating is done in ApgService + // Message is received after generating is done in KeychainIntentService KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler( this, getResources().getQuantityString(R.plurals.progress_generating, 1), ProgressDialog.STYLE_HORIZONTAL, true, @@ -197,7 +197,7 @@ public class EditKeyActivity extends ActionBarActivity { @Override public void handleMessage(Message message) { - // handle messages by standard ApgHandler first + // handle messages by standard KeychainIntentServiceHandler first super.handleMessage(message); if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { @@ -540,11 +540,11 @@ public class EditKeyActivity extends ActionBarActivity { intent.putExtra(KeychainIntentService.EXTRA_DATA, data); - // Message is received after saving is done in ApgService + // Message is received after saving is done in KeychainIntentService KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(this, getString(R.string.progress_saving), ProgressDialog.STYLE_HORIZONTAL) { public void handleMessage(Message message) { - // handle messages by standard ApgHandler first + // handle messages by standard KeychainIntentServiceHandler first super.handleMessage(message); if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java index 4ccfd393f..4f18f69d7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java @@ -597,11 +597,11 @@ public class EncryptActivity extends DrawerActivity { intent.putExtra(KeychainIntentService.EXTRA_DATA, data); - // Message is received after encrypting is done in ApgService + // Message is received after encrypting is done in KeychainIntentService KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(this, getString(R.string.progress_encrypting), ProgressDialog.STYLE_HORIZONTAL) { public void handleMessage(Message message) { - // handle messages by standard ApgHandler first + // handle messages by standard KeychainIntentServiceHandler first super.handleMessage(message); if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java index 05bfc613e..834509f53 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java @@ -363,7 +363,7 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa * Import keys with mImportData */ public void importKeys() { - // Message is received after importing is done in ApgService + // Message is received after importing is done in KeychainIntentService KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler( this, getString(R.string.progress_importing), diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/UploadKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/UploadKeyActivity.java index 2c8f66488..0e231e6a8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/UploadKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/UploadKeyActivity.java @@ -98,11 +98,11 @@ public class UploadKeyActivity extends ActionBarActivity { intent.putExtra(KeychainIntentService.EXTRA_DATA, data); - // Message is received after uploading is done in ApgService + // Message is received after uploading is done in KeychainIntentService KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(this, getString(R.string.progress_exporting), ProgressDialog.STYLE_HORIZONTAL) { public void handleMessage(Message message) { - // handle messages by standard ApgHandler first + // handle messages by standard KeychainIntentServiceHandler first super.handleMessage(message); if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java index b067010df..b4c38184c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteFileDialogFragment.java @@ -87,11 +87,11 @@ public class DeleteFileDialogFragment extends DialogFragment { false, null); - // Message is received after deleting is done in ApgService + // Message is received after deleting is done in KeychainIntentService KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(activity, deletingDialog) { public void handleMessage(Message message) { - // handle messages by standard ApgHandler first + // handle messages by standard KeychainIntentHandler first super.handleMessage(message); if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index e5b6003b1..1ef178f15 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -256,11 +256,11 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor } }); - // Message is received after generating is done in ApgService + // Message is received after generating is done in KeychainIntentService KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(mActivity, mGeneratingDialog) { public void handleMessage(Message message) { - // handle messages by standard ApgHandler first + // handle messages by standard KeychainIntentServiceHandler first super.handleMessage(message); if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { -- cgit v1.2.3 From 7d5896b107643803aa7d32c0ef4c33c40246a1e2 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Sun, 23 Mar 2014 21:28:29 +0100 Subject: Add recent contributors to credits --- OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html | 6 ++++++ OpenPGP-Keychain/src/main/res/raw-de/help_about.html | 6 ++++++ OpenPGP-Keychain/src/main/res/raw-el/help_about.html | 6 ++++++ OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html | 6 ++++++ OpenPGP-Keychain/src/main/res/raw-es/help_about.html | 6 ++++++ OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html | 6 ++++++ OpenPGP-Keychain/src/main/res/raw-fr/help_about.html | 6 ++++++ OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html | 6 ++++++ OpenPGP-Keychain/src/main/res/raw-ja/help_about.html | 6 ++++++ OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html | 6 ++++++ OpenPGP-Keychain/src/main/res/raw-pl/help_about.html | 6 ++++++ OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html | 6 ++++++ OpenPGP-Keychain/src/main/res/raw-ru/help_about.html | 6 ++++++ OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html | 6 ++++++ OpenPGP-Keychain/src/main/res/raw-tr/help_about.html | 6 ++++++ OpenPGP-Keychain/src/main/res/raw-uk/help_about.html | 6 ++++++ OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html | 6 ++++++ OpenPGP-Keychain/src/main/res/raw-zh/help_about.html | 6 ++++++ OpenPGP-Keychain/src/main/res/raw/help_about.html | 6 ++++++ 19 files changed, 114 insertions(+) diff --git a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html index 5a8f7bde7..d9150a5e8 100644 --- a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html @@ -11,6 +11,12 @@
  • Ash Hughes (crypto patches)
  • Brian C. Barnes
  • Bahtiar 'kalkin' Gadimov (UI)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • Developers APG 1.x

    diff --git a/OpenPGP-Keychain/src/main/res/raw-de/help_about.html b/OpenPGP-Keychain/src/main/res/raw-de/help_about.html index 4199f9b5e..676c2bdd2 100644 --- a/OpenPGP-Keychain/src/main/res/raw-de/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-de/help_about.html @@ -11,6 +11,12 @@
  • Ash Hughes (crypto patches)
  • Brian C. Barnes
  • Bahtiar 'kalkin' Gadimov (UI)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • Entwickler APG 1.x

    diff --git a/OpenPGP-Keychain/src/main/res/raw-el/help_about.html b/OpenPGP-Keychain/src/main/res/raw-el/help_about.html index 5a8f7bde7..d9150a5e8 100644 --- a/OpenPGP-Keychain/src/main/res/raw-el/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-el/help_about.html @@ -11,6 +11,12 @@
  • Ash Hughes (crypto patches)
  • Brian C. Barnes
  • Bahtiar 'kalkin' Gadimov (UI)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • Developers APG 1.x

    diff --git a/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html b/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html index 5a8f7bde7..d9150a5e8 100644 --- a/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html @@ -11,6 +11,12 @@
  • Ash Hughes (crypto patches)
  • Brian C. Barnes
  • Bahtiar 'kalkin' Gadimov (UI)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • Developers APG 1.x

    diff --git a/OpenPGP-Keychain/src/main/res/raw-es/help_about.html b/OpenPGP-Keychain/src/main/res/raw-es/help_about.html index 64d80ab74..552155d68 100644 --- a/OpenPGP-Keychain/src/main/res/raw-es/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-es/help_about.html @@ -11,6 +11,12 @@
  • Ash Hughes (Parches cryptográficos)
  • Brian C. Barnes
  • Bahtiar 'kalkin' Gadimov (UI)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • Desarrolladores de APG 1.x

    diff --git a/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html b/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html index 5a8f7bde7..d9150a5e8 100644 --- a/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html @@ -11,6 +11,12 @@
  • Ash Hughes (crypto patches)
  • Brian C. Barnes
  • Bahtiar 'kalkin' Gadimov (UI)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • Developers APG 1.x

    diff --git a/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html b/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html index 93e5a5df7..43094ce9d 100644 --- a/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html @@ -11,6 +11,12 @@
  • Ash Hughes (correctif crypto)
  • Brian C. Barnes
  • Bahtiar « kalkin » Gadimov (interface utilisateur)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • Les développeurs d'APG 1.x

    diff --git a/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html b/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html index 5e4a53ed6..2d17e1882 100644 --- a/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html @@ -11,6 +11,12 @@
  • Ash Hughes (Patch crittografia)
  • Brian C. Barnes
  • Bahtiar 'kalkin' Gadimov (Interfaccia Utente)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • Sviluppatori APG 1.x

    diff --git a/OpenPGP-Keychain/src/main/res/raw-ja/help_about.html b/OpenPGP-Keychain/src/main/res/raw-ja/help_about.html index 72c7616a3..3f630264c 100644 --- a/OpenPGP-Keychain/src/main/res/raw-ja/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-ja/help_about.html @@ -11,6 +11,12 @@
  • Ash Hughes (暗号関係パッチ提供)
  • Brian C. Barnes
  • Bahtiar 'kalkin' Gadimov (UI)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • APG 1.xの開発者達

    diff --git a/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html b/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html index 5a8f7bde7..d9150a5e8 100644 --- a/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html @@ -11,6 +11,12 @@
  • Ash Hughes (crypto patches)
  • Brian C. Barnes
  • Bahtiar 'kalkin' Gadimov (UI)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • Developers APG 1.x

    diff --git a/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html b/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html index c07fc503f..c41859b60 100644 --- a/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html @@ -11,6 +11,12 @@
  • Ash Hughes (łatki crypto)
  • Brian C. Barnes
  • Bahtiar 'kalkin' Gadimov (Interfejs Użytkownika)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • Deweloperzy APG 1.x

    diff --git a/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html b/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html index 5a8f7bde7..d9150a5e8 100644 --- a/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html @@ -11,6 +11,12 @@
  • Ash Hughes (crypto patches)
  • Brian C. Barnes
  • Bahtiar 'kalkin' Gadimov (UI)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • Developers APG 1.x

    diff --git a/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html b/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html index 8379bf8de..63335110e 100644 --- a/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html @@ -11,6 +11,12 @@
  • Ash Hughes (патчи криптографии)
  • Brian C. Barnes
  • Bahtiar 'kalkin' Gadimov (UI)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • Разработчики APG 1.x

    diff --git a/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html b/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html index 5a8f7bde7..d9150a5e8 100644 --- a/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html @@ -11,6 +11,12 @@
  • Ash Hughes (crypto patches)
  • Brian C. Barnes
  • Bahtiar 'kalkin' Gadimov (UI)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • Developers APG 1.x

    diff --git a/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html b/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html index 454d16151..d50154765 100644 --- a/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html @@ -11,6 +11,12 @@
  • Ash Hughes (kripto yamaları)
  • Brian C. Barnes
  • Bahtiar 'kalkin' Gadimov (Arayüz)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • Geliştiriciler APG 1.x

    diff --git a/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html b/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html index 9526dc0c6..4e6bb02dd 100644 --- a/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html @@ -11,6 +11,12 @@
  • Аш Гюдж (латки шифрування)
  • Браян С. Барнс
  • Бахтіяр 'kalkin' Ґадімов (інтерфейс)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • Розробники APG 1.x

    diff --git a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html index 5a8f7bde7..d9150a5e8 100644 --- a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html @@ -11,6 +11,12 @@
  • Ash Hughes (crypto patches)
  • Brian C. Barnes
  • Bahtiar 'kalkin' Gadimov (UI)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • Developers APG 1.x

    diff --git a/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html b/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html index 6d00fc6a1..1eec8bdbf 100644 --- a/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html @@ -11,6 +11,12 @@
  • Ash Hughes (crypto patches)
  • Brian C. Barnes
  • Bahtiar 'kalkin' Gadimov (介面)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • Developers APG 1.x

    diff --git a/OpenPGP-Keychain/src/main/res/raw/help_about.html b/OpenPGP-Keychain/src/main/res/raw/help_about.html index 8d7714365..2ffbb47a6 100644 --- a/OpenPGP-Keychain/src/main/res/raw/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw/help_about.html @@ -15,6 +15,12 @@ And don't add newlines before or after p tags because of transifex -->
  • Ash Hughes (crypto patches)
  • Brian C. Barnes
  • Bahtiar 'kalkin' Gadimov (UI)
  • +
  • Daniel Hammann
  • +
  • Daniel Haß
  • +
  • Greg Witczak
  • +
  • Miroojin Bakshi
  • +
  • Paul Sarbinowski
  • +
  • Vincent Breitmoser
  • Developers APG 1.x

    -- cgit v1.2.3 From 0867d1f0788660bd62aa50735ff3b7b385da0f23 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Mon, 24 Mar 2014 00:23:18 +0100 Subject: Change the getting started text "My Keys" is now wrapped into "Contacts". --- OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_start.html | 2 +- OpenPGP-Keychain/src/main/res/raw-de/help_start.html | 2 +- OpenPGP-Keychain/src/main/res/raw-el/help_start.html | 2 +- OpenPGP-Keychain/src/main/res/raw-es-rCO/help_start.html | 2 +- OpenPGP-Keychain/src/main/res/raw-es/help_start.html | 2 +- OpenPGP-Keychain/src/main/res/raw-fr/help_start.html | 2 +- OpenPGP-Keychain/src/main/res/raw-it-rIT/help_start.html | 2 +- OpenPGP-Keychain/src/main/res/raw-ja/help_start.html | 2 +- OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_start.html | 2 +- OpenPGP-Keychain/src/main/res/raw-pl/help_start.html | 2 +- OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_start.html | 2 +- OpenPGP-Keychain/src/main/res/raw-ru/help_start.html | 2 +- OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_start.html | 2 +- OpenPGP-Keychain/src/main/res/raw-tr/help_start.html | 2 +- OpenPGP-Keychain/src/main/res/raw-uk/help_start.html | 2 +- OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_start.html | 2 +- OpenPGP-Keychain/src/main/res/raw/help_start.html | 2 +- 17 files changed, 17 insertions(+), 17 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_start.html b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_start.html index 3a6443a2f..0e60c17a7 100644 --- a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_start.html @@ -2,7 +2,7 @@

    Getting started

    -

    First you need a personal key pair. Create one via the option menus in "My Keys" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    +

    First you need a personal key pair. Create one via the option menus in "Contacts" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-de/help_start.html b/OpenPGP-Keychain/src/main/res/raw-de/help_start.html index a7949dd64..7a652682e 100644 --- a/OpenPGP-Keychain/src/main/res/raw-de/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-de/help_start.html @@ -2,7 +2,7 @@

    Los gehts

    -

    First you need a personal key pair. Create one via the option menus in "My Keys" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    +

    First you need a personal key pair. Create one via the option menus in "Contacts" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-el/help_start.html b/OpenPGP-Keychain/src/main/res/raw-el/help_start.html index 3a6443a2f..0e60c17a7 100644 --- a/OpenPGP-Keychain/src/main/res/raw-el/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-el/help_start.html @@ -2,7 +2,7 @@

    Getting started

    -

    First you need a personal key pair. Create one via the option menus in "My Keys" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    +

    First you need a personal key pair. Create one via the option menus in "Contacts" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_start.html b/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_start.html index 3a6443a2f..0e60c17a7 100644 --- a/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_start.html @@ -2,7 +2,7 @@

    Getting started

    -

    First you need a personal key pair. Create one via the option menus in "My Keys" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    +

    First you need a personal key pair. Create one via the option menus in "Contacts" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-es/help_start.html b/OpenPGP-Keychain/src/main/res/raw-es/help_start.html index 2907bbc99..895b52469 100644 --- a/OpenPGP-Keychain/src/main/res/raw-es/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-es/help_start.html @@ -2,7 +2,7 @@

    Primeros pasos

    -

    Primero necesitas un par de claves personales. Crea una a través del menú "Mis claves" o importa un par de claves ya existentes a través de "Importar claves". Después, puedes descargar las claves de tus amigos o intercambiarlas a través de códigos QR o NFC.

    +

    Primero necesitas un par de claves personales. Crea una a través del menú "Contactos" o importa un par de claves ya existentes a través de "Importar claves". Después, puedes descargar las claves de tus amigos o intercambiarlas a través de códigos QR o NFC.

    Es recomendable que instales OI File Manager para una mejor selección de archivos y Barcode Scanner para escanear los códigos QR generados. Pulsando en los enlaces se abrirá Google Play o F-Droid.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-fr/help_start.html b/OpenPGP-Keychain/src/main/res/raw-fr/help_start.html index 0c1610f0c..962c33d86 100644 --- a/OpenPGP-Keychain/src/main/res/raw-fr/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-fr/help_start.html @@ -2,7 +2,7 @@

    Commencer

    -

    Vous avez d'abord besoin d'une paire de clefs personelles. Créez-en une avec l'option du menu « Mes clefs » ou importez des paires de clefs existantes avec « Importer des clefs ». Ensuite vous pouvez télécharger les clefs de vos amis, ou les échanger par codes QR ou NFC.

    +

    Vous avez d'abord besoin d'une paire de clefs personelles. Créez-en une avec l'option du menu « Contacts » ou importez des paires de clefs existantes avec « Importer des clefs ». Ensuite vous pouvez télécharger les clefs de vos amis, ou les échanger par codes QR ou NFC.

    Il vous est recommendé d'installer le gestionnaire de fichiers OI pour sa fonction améliorée de séléction des fichiers et le lecteur de codes à barres pour balayer les codes QR générés. Cliquer sur les liens ouvrira Google Play Store ou F-Droid pour l'installation.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_start.html b/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_start.html index 4eadd82fc..1a4a7303e 100644 --- a/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_start.html @@ -2,7 +2,7 @@

    Per iniziare

    -

    Per prima cosa hai bisogno di un paio di chiavi personali. Creane una tramite i menu di opzione sotto 'Mie Chiavi' o importane di esistenti attraverso "Importa Chiavi". Dopodiche' puoi scaricare le chiavi dei tuoi amici o scambiarle tramite Codici QR o NFC.

    +

    Per prima cosa hai bisogno di un paio di chiavi personali. Creane una tramite i menu di opzione sotto 'Contatti' o importane di esistenti attraverso "Importa Chiavi". Dopodiche' puoi scaricare le chiavi dei tuoi amici o scambiarle tramite Codici QR o NFC.

    Si raccomanda di installare OI File Manager per una migliore selezione dei file e Barcode Scanner per scansionare i codici QR. I collegamenti verranno aperti in Google Play Store o F-Droid per l'installazione.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-ja/help_start.html b/OpenPGP-Keychain/src/main/res/raw-ja/help_start.html index 9764e876a..04ad31352 100644 --- a/OpenPGP-Keychain/src/main/res/raw-ja/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-ja/help_start.html @@ -2,7 +2,7 @@

    入門

    -

    最初にあなたの個人用鍵ペアが必要になります。オプションメニューの"自分の鍵"で生成するか、"鍵のインポート"から既存の鍵ペアをインポートします。その後、あなたの友人の鍵をダウンロード、もしくはQRコードやNFCで交換します。

    +

    最初にあなたの個人用鍵ペアが必要になります。オプションメニューの"連絡先"で生成するか、"鍵のインポート"から既存の鍵ペアをインポートします。その後、あなたの友人の鍵をダウンロード、もしくはQRコードやNFCで交換します。

    ファイルの選択を拡張するにはOI File ManagerBarcode Scannerを生成したQRコードのスキャンのため、それぞれのインストールを必要とします。 リンクをクリックして、Google Play Store上かF-Droidからインストールしてください。

    diff --git a/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_start.html b/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_start.html index 3a6443a2f..0e60c17a7 100644 --- a/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_start.html @@ -2,7 +2,7 @@

    Getting started

    -

    First you need a personal key pair. Create one via the option menus in "My Keys" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    +

    First you need a personal key pair. Create one via the option menus in "Contacts" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-pl/help_start.html b/OpenPGP-Keychain/src/main/res/raw-pl/help_start.html index 539388789..d2faa2db9 100644 --- a/OpenPGP-Keychain/src/main/res/raw-pl/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-pl/help_start.html @@ -2,7 +2,7 @@

    Pierwsze kroki

    -

    Po pierwsze potrzebujesz swoją osobistą parę kluczy. Stwórz ją, korzystając z odpowiedniej opcji w sekcji "Moje klucze" lub też zaimportuj istniejącą parę korzystając z sekcji "Importuj klucze". Następnie możesz pobrać klucze Twoich znajomych lub wymieniać się z nimi za pośrednictwem kodów QR lub technologii NFC.

    +

    Po pierwsze potrzebujesz swoją osobistą parę kluczy. Stwórz ją, korzystając z odpowiedniej opcji w sekcji "Kontakty" lub też zaimportuj istniejącą parę korzystając z sekcji "Importuj klucze". Następnie możesz pobrać klucze Twoich znajomych lub wymieniać się z nimi za pośrednictwem kodów QR lub technologii NFC.

    Zalecana jest instalacja menadżera plików OI File Manager w celu zapewnienia wygodniejszego wyboru plików oraz programu Barcode Scanner, który jest w stanie skanować wygenerowane kody QR. Kliknięcie na powyższe linki przekieruje Cię do sklepu Google Play / F-Droid.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_start.html b/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_start.html index 3a6443a2f..0e60c17a7 100644 --- a/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_start.html @@ -2,7 +2,7 @@

    Getting started

    -

    First you need a personal key pair. Create one via the option menus in "My Keys" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    +

    First you need a personal key pair. Create one via the option menus in "Contacts" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-ru/help_start.html b/OpenPGP-Keychain/src/main/res/raw-ru/help_start.html index 9b2b99e96..bc9dade67 100644 --- a/OpenPGP-Keychain/src/main/res/raw-ru/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-ru/help_start.html @@ -2,7 +2,7 @@

    Приступая

    -

    Для начала вам понадобится своя пара ключей. Воспользуйтесь меню в разделе "Мои ключи", что бы создать новую, или добавьте ранее созданную пару в разделе "Импорт ключей". После этого вы сможете скачать ключи ваших друзей или обменяться ключами посредством QR кодов или NFC.

    +

    Для начала вам понадобится своя пара ключей. Воспользуйтесь меню в разделе "Контакты", что бы создать новую, или добавьте ранее созданную пару в разделе "Импорт ключей". После этого вы сможете скачать ключи ваших друзей или обменяться ключами посредством QR кодов или NFC.

    Рекомендуется установить OI File Manager для удобного выбора файлов и Barcode Scanner для распознавания QR кодов. Перейдите по ссылкам на соответствующие страницы Google Play или F-Droid для дальнейшей установки.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_start.html b/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_start.html index 3a6443a2f..0e60c17a7 100644 --- a/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_start.html @@ -2,7 +2,7 @@

    Getting started

    -

    First you need a personal key pair. Create one via the option menus in "My Keys" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    +

    First you need a personal key pair. Create one via the option menus in "Contacts" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-tr/help_start.html b/OpenPGP-Keychain/src/main/res/raw-tr/help_start.html index 3a6443a2f..0e60c17a7 100644 --- a/OpenPGP-Keychain/src/main/res/raw-tr/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-tr/help_start.html @@ -2,7 +2,7 @@

    Getting started

    -

    First you need a personal key pair. Create one via the option menus in "My Keys" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    +

    First you need a personal key pair. Create one via the option menus in "Contacts" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-uk/help_start.html b/OpenPGP-Keychain/src/main/res/raw-uk/help_start.html index 3bfb40f8a..78443070d 100644 --- a/OpenPGP-Keychain/src/main/res/raw-uk/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-uk/help_start.html @@ -2,7 +2,7 @@

    Приступаючи до роботи

    -

    Спершу вам потрібна персональна в'язка ключів. Створіть одну через меню параметрів у "Мої Ключі" або імпортуйте наявні в'язки ключів через "Імпорт ключів". Після цього ви зможете завантажувати ключі ваших друзів чи обміняти їх через штрих-коди або NFC.

    +

    Спершу вам потрібна персональна в'язка ключів. Створіть одну через меню параметрів у "Контакти" або імпортуйте наявні в'язки ключів через "Імпорт ключів". Після цього ви зможете завантажувати ключі ваших друзів чи обміняти їх через штрих-коди або NFC.

    Рекомендуємо вам встановити OI File Manager для поліпшеного виділення файлів та Barcode Scanner для сканування згенерованих штрих-кодів. Натискання посилань відкриє Google Play або F-Droid для встановлення.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_start.html b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_start.html index 3a6443a2f..0e60c17a7 100644 --- a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_start.html @@ -2,7 +2,7 @@

    Getting started

    -

    First you need a personal key pair. Create one via the option menus in "My Keys" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    +

    First you need a personal key pair. Create one via the option menus in "Contacts" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

    diff --git a/OpenPGP-Keychain/src/main/res/raw/help_start.html b/OpenPGP-Keychain/src/main/res/raw/help_start.html index 7afac0f08..56c02b1fd 100644 --- a/OpenPGP-Keychain/src/main/res/raw/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw/help_start.html @@ -6,7 +6,7 @@ And don't add newlines before or after p tags because of transifex -->

    Getting started

    -

    First you need a personal key pair. Create one via the option menus in "My Keys" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    +

    First you need a personal key pair. Create one via the option menus in "Contacts" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

    -- cgit v1.2.3 From fcc7117770be50b1fdaf204bf725a69a111c26d2 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Sun, 23 Mar 2014 23:41:08 +0000 Subject: move stuff around, save work --- .../keychain/pgp/PgpKeyOperation.java | 120 +++++++++++---------- 1 file changed, 61 insertions(+), 59 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 8ef2a7452..e64c11852 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -497,12 +497,69 @@ public class PgpKeyOperation { for (int i = 0; i < saveParcel.keys.size(); ++i) { updateProgress(40 + 50 * (i - 1) / (saveParcel.keys.size() - 1), 100); if (saveParcel.moddedKeys[i]) { + //to make public key, use a keygen and temp.publickeyring? + + PGPSecretKey subKey = saveParcel.keys.get(i); + PGPPublicKey subPublicKey = subKey.getPublicKey(); + + PBESecretKeyDecryptor keyDecryptor2; + if (saveParcel.newKeys[i]) { + keyDecryptor2 = new JcePBESecretKeyDecryptorBuilder() + .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( + "".toCharArray()); + } else { + keyDecryptor2 = new JcePBESecretKeyDecryptorBuilder() + .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( + saveParcel.oldPassPhrase.toCharArray()); + } + PGPPrivateKey subPrivateKey = subKey.extractPrivateKey(keyDecryptor2); + + // TODO: now used without algorithm and creation time?! (APG 1) + PGPKeyPair subKeyPair = new PGPKeyPair(subPublicKey, subPrivateKey); + + hashedPacketsGen = new PGPSignatureSubpacketGenerator(); + unhashedPacketsGen = new PGPSignatureSubpacketGenerator(); + + usageId = saveParcel.keysUsages.get(i); + canSign = (usageId & KeyFlags.SIGN_DATA) > 0; //todo - separate function for this + if (canSign) { + Date todayDate = new Date(); //both sig times the same + // cross-certify signing keys + hashedPacketsGen.setSignatureCreationTime(false, todayDate); //set outer creation time + PGPSignatureSubpacketGenerator subHashedPacketsGen = new PGPSignatureSubpacketGenerator(); + subHashedPacketsGen.setSignatureCreationTime(false, todayDate); //set inner creation time + PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( + subPublicKey.getAlgorithm(), PGPUtil.SHA1) + .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME); + PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder); + sGen.init(PGPSignature.PRIMARYKEY_BINDING, subPrivateKey); + sGen.setHashedSubpackets(subHashedPacketsGen.generate()); + PGPSignature certification = sGen.generateCertification(masterPublicKey, + subPublicKey); + unhashedPacketsGen.setEmbeddedSignature(false, certification); + } + hashedPacketsGen.setKeyFlags(false, usageId); + + if (saveParcel.keysExpiryDates.get(i) != null) { + GregorianCalendar creationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC")); + creationDate.setTime(subPublicKey.getCreationTime()); + GregorianCalendar expiryDate = saveParcel.keysExpiryDates.get(i); + //note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c + //here we purposefully ignore partial days in each date - long type has no fractional part! + long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000); + if (numDays <= 0) + throw new PgpGeneralException(mContext.getString(R.string.error_expiry_must_come_after_creation)); + hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400); + } else { + hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding, + //this happens anyway + } + + keyGen.addSubKey(subKeyPair, hashedPacketsGen.generate(), unhashedPacketsGen.generate()); + //discard only certain certs //secretkey.replacepublickey with updated public key -//secretkeyring.insertsecretkey with newly signed secret key - } else { -//else nothing, right? } - if (saveParcel.newKeys[i]) { + if (saveParcel.newKeys[i]) { //might not be necessary //set the passphrase to the old one, so we can update the whole keyring passphrase later PBESecretKeyEncryptor keyEncryptorOld = new JcePBESecretKeyEncryptorBuilder( PGPEncryptedData.CAST5, sha1Calc) @@ -520,61 +577,6 @@ public class PgpKeyOperation { } updateProgress(R.string.progress_adding_sub_keys, 40, 100); - for (int i = 1; i < saveParcel.keys.size(); ++i) { - updateProgress(40 + 50 * (i - 1) / (saveParcel.keys.size() - 1), 100); - - PGPSecretKey subKey = saveParcel.keys.get(i); - PGPPublicKey subPublicKey = subKey.getPublicKey(); - - PBESecretKeyDecryptor keyDecryptor2 = new JcePBESecretKeyDecryptorBuilder() - .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( - saveParcel.oldPassPhrase.toCharArray()); - PGPPrivateKey subPrivateKey = subKey.extractPrivateKey(keyDecryptor2); - - // TODO: now used without algorithm and creation time?! (APG 1) - PGPKeyPair subKeyPair = new PGPKeyPair(subPublicKey, subPrivateKey); - - hashedPacketsGen = new PGPSignatureSubpacketGenerator(); - unhashedPacketsGen = new PGPSignatureSubpacketGenerator(); - - usageId = saveParcel.keysUsages.get(i); - canSign = (usageId & KeyFlags.SIGN_DATA) > 0; //todo - separate function for this - if (canSign) { - Date todayDate = new Date(); //both sig times the same - // cross-certify signing keys - hashedPacketsGen.setSignatureCreationTime(false, todayDate); //set outer creation time - PGPSignatureSubpacketGenerator subHashedPacketsGen = new PGPSignatureSubpacketGenerator(); - subHashedPacketsGen.setSignatureCreationTime(false, todayDate); //set inner creation time - PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( - subPublicKey.getAlgorithm(), PGPUtil.SHA1) - .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME); - PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder); - sGen.init(PGPSignature.PRIMARYKEY_BINDING, subPrivateKey); - sGen.setHashedSubpackets(subHashedPacketsGen.generate()); - PGPSignature certification = sGen.generateCertification(masterPublicKey, - subPublicKey); - unhashedPacketsGen.setEmbeddedSignature(false, certification); - } - hashedPacketsGen.setKeyFlags(false, usageId); - - if (saveParcel.keysExpiryDates.get(i) != null) { - GregorianCalendar creationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - creationDate.setTime(subPublicKey.getCreationTime()); - GregorianCalendar expiryDate = saveParcel.keysExpiryDates.get(i); - //note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c - //here we purposefully ignore partial days in each date - long type has no fractional part! - long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000); - if (numDays <= 0) - throw new PgpGeneralException(mContext.getString(R.string.error_expiry_must_come_after_creation)); - hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400); - } else { - hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding, - //this happens anyway - } - - keyGen.addSubKey(subKeyPair, hashedPacketsGen.generate(), unhashedPacketsGen.generate()); - } - //update the passphrase mKR = PGPSecretKeyRing.copyWithNewPassword(mKR, keyDecryptor, keyEncryptor); updateProgress(R.string.progress_saving_key_ring, 90, 100); -- cgit v1.2.3 From 974514e470d6835ee7a2f6cc34863dae23f16a3e Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Mon, 24 Mar 2014 16:15:28 +0000 Subject: work on saving --- .../keychain/pgp/PgpKeyOperation.java | 45 +++++++++++----------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index e64c11852..3d7826553 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -382,6 +382,8 @@ public class PgpKeyOperation { do we need to remove and add in? */ + //todo: flag changes of master key if IDs changed maybe? + for (PGPSecretKey dKey : saveParcel.deletedKeys) { mKR = PGPSecretKeyRing.removeSecretKey(mKR, dKey); } @@ -484,11 +486,11 @@ public class PgpKeyOperation { PGPContentSignerBuilder certificationSignerBuilder = new JcaPGPContentSignerBuilder( masterKeyPair.getPublicKey().getAlgorithm(), HashAlgorithmTags.SHA1); - // Build key encrypter based on passphrase + // Build key encryptor based on old passphrase, as some keys may be unchanged PBESecretKeyEncryptor keyEncryptor = new JcePBESecretKeyEncryptorBuilder( PGPEncryptedData.CAST5, sha1Calc) .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( - saveParcel.newPassPhrase.toCharArray()); + saveParcel.oldPassPhrase.toCharArray()); PGPKeyRingGenerator keyGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, masterKeyPair, mainUserId, sha1Calc, hashedPacketsGen.generate(), @@ -497,8 +499,6 @@ public class PgpKeyOperation { for (int i = 0; i < saveParcel.keys.size(); ++i) { updateProgress(40 + 50 * (i - 1) / (saveParcel.keys.size() - 1), 100); if (saveParcel.moddedKeys[i]) { - //to make public key, use a keygen and temp.publickeyring? - PGPSecretKey subKey = saveParcel.keys.get(i); PGPPublicKey subPublicKey = subKey.getPublicKey(); @@ -513,8 +513,6 @@ public class PgpKeyOperation { saveParcel.oldPassPhrase.toCharArray()); } PGPPrivateKey subPrivateKey = subKey.extractPrivateKey(keyDecryptor2); - - // TODO: now used without algorithm and creation time?! (APG 1) PGPKeyPair subKeyPair = new PGPKeyPair(subPublicKey, subPrivateKey); hashedPacketsGen = new PGPSignatureSubpacketGenerator(); @@ -557,28 +555,31 @@ public class PgpKeyOperation { keyGen.addSubKey(subKeyPair, hashedPacketsGen.generate(), unhashedPacketsGen.generate()); //discard only certain certs -//secretkey.replacepublickey with updated public key } - if (saveParcel.newKeys[i]) { //might not be necessary - //set the passphrase to the old one, so we can update the whole keyring passphrase later - PBESecretKeyEncryptor keyEncryptorOld = new JcePBESecretKeyEncryptorBuilder( - PGPEncryptedData.CAST5, sha1Calc) - .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( - saveParcel.oldPassPhrase.toCharArray()); - PBESecretKeyDecryptor keyDecryptorBlank = new JcePBESecretKeyDecryptorBuilder() - .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( - saveParcel.oldPassPhrase.toCharArray()); - saveParcel.keys.set(i, PGPSecretKey.copyWithNewPassword(saveParcel.keys.get(i), - keyDecryptorBlank, keyEncryptorOld)); + } + + PGPSecretKeyRing updatedSecretKeyRing = keyGen.generateSecretKeyRing(); + //finally, update the keyrings + Iterator itr = updatedSecretKeyRing.getSecretKeys(); + while (itr.hasNext()) { + PGPSecretKey theNextKey = itr.next(); + if ((theNextKey.isMasterKey() && saveParcel.moddedKeys[0]) || !theNextKey.isMasterKey()) { + mKR = PGPSecretKeyRing.insertSecretKey(mKR, theNextKey); + pKR = PGPPublicKeyRing.insertPublicKey(pKR, theNextKey.getPublicKey()); } - //finally, update the keyrings - mKR = PGPSecretKeyRing.insertSecretKey(mKR, saveParcel.keys.get(i)); - pKR = PGPPublicKeyRing.insertPublicKey(pKR, saveParcel.keys.get(i).getPublicKey()); } + + updateProgress(R.string.progress_adding_sub_keys, 40, 100); + // Build key encryptor based on new passphrase + PBESecretKeyEncryptor keyEncryptorNew = new JcePBESecretKeyEncryptorBuilder( + PGPEncryptedData.CAST5, sha1Calc) + .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( + saveParcel.newPassPhrase.toCharArray()); + //update the passphrase - mKR = PGPSecretKeyRing.copyWithNewPassword(mKR, keyDecryptor, keyEncryptor); + mKR = PGPSecretKeyRing.copyWithNewPassword(mKR, keyDecryptor, keyEncryptorNew); updateProgress(R.string.progress_saving_key_ring, 90, 100); ProviderHelper.saveKeyRing(mContext, mKR); -- cgit v1.2.3 From 300b90bcac6fbf5b5e416943e538a2c2bc49342c Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Mon, 24 Mar 2014 16:47:02 +0000 Subject: make sure ID info is saved --- .../sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 3d7826553..5f97aa2e5 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -368,7 +368,7 @@ public class PgpKeyOperation { } /* - IDs - + IDs - NB This might not need to happen later, if we change the way the primary ID is chosen remove deleted ids if the primary ID changed we need to: remove all of the IDs from the keyring, saving their certifications @@ -382,8 +382,6 @@ public class PgpKeyOperation { do we need to remove and add in? */ - //todo: flag changes of master key if IDs changed maybe? - for (PGPSecretKey dKey : saveParcel.deletedKeys) { mKR = PGPSecretKeyRing.removeSecretKey(mKR, dKey); } @@ -406,7 +404,9 @@ public class PgpKeyOperation { } int user_id_index = 0; + boolean anyIDChanged = false; if (saveParcel.primaryIDChanged) { + anyIDChanged = true; ArrayList> sigList = new ArrayList>(); for (String userId : saveParcel.userIDs) { String orig_id = saveParcel.originalIDs.get(user_id_index); @@ -437,6 +437,7 @@ public class PgpKeyOperation { for (String userId : saveParcel.userIDs) { String orig_id = saveParcel.originalIDs.get(user_id_index); if (!orig_id.equals(userId)) { + anyIDChanged = true; PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1) .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME); @@ -452,6 +453,12 @@ public class PgpKeyOperation { } } + //update the keyring with the new ID information + if (anyIDChanged) { + pKR = PGPPublicKeyRing.insertPublicKey(pKR, masterPublicKey); + mKR = PGPSecretKeyRing.replacePublicKeys(mKR, pKR); + } + PGPKeyPair masterKeyPair = new PGPKeyPair(masterPublicKey, masterPrivateKey); PGPSignatureSubpacketGenerator hashedPacketsGen = new PGPSignatureSubpacketGenerator(); -- cgit v1.2.3 From 02688f6ebfb07b70656cbe9fe6d723d36f3ffc35 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Mon, 24 Mar 2014 17:41:45 +0000 Subject: comments, slight change to progress bar --- .../sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 5f97aa2e5..adccc5ba3 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -380,6 +380,10 @@ public class PgpKeyOperation { remove deleted keys if a key is modified, re-sign it do we need to remove and add in? + + Todo + identify more things which need to be preserved - e.g. trust levels? + user attributes */ for (PGPSecretKey dKey : saveParcel.deletedKeys) { @@ -504,7 +508,7 @@ public class PgpKeyOperation { unhashedPacketsGen.generate(), certificationSignerBuilder, keyEncryptor); for (int i = 0; i < saveParcel.keys.size(); ++i) { - updateProgress(40 + 50 * (i - 1) / (saveParcel.keys.size() - 1), 100); + updateProgress(40 + 50 * i/ saveParcel.keys.size(), 100); if (saveParcel.moddedKeys[i]) { PGPSecretKey subKey = saveParcel.keys.get(i); PGPPublicKey subPublicKey = subKey.getPublicKey(); @@ -561,7 +565,11 @@ public class PgpKeyOperation { } keyGen.addSubKey(subKeyPair, hashedPacketsGen.generate(), unhashedPacketsGen.generate()); - //discard only certain certs + //certifications will be discarded if the key is changed, because I think, for a start, + //they will be invalid. Binding certs are regenerated anyway, and other certs which + //need to be kept are on IDs and attributes + //TODO: don't let revoked keys be edited, other than removed - changing one would result in the + //revocation being wrong? } } @@ -575,10 +583,6 @@ public class PgpKeyOperation { pKR = PGPPublicKeyRing.insertPublicKey(pKR, theNextKey.getPublicKey()); } } - - - updateProgress(R.string.progress_adding_sub_keys, 40, 100); - // Build key encryptor based on new passphrase PBESecretKeyEncryptor keyEncryptorNew = new JcePBESecretKeyEncryptorBuilder( PGPEncryptedData.CAST5, sha1Calc) -- cgit v1.2.3 From e7b3dd64f4f0dbf5841ade521fe654ed8e3e0b26 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Tue, 25 Mar 2014 00:20:35 +0000 Subject: results of debugging, fix several bugs - more needed though... --- .../keychain/pgp/PgpKeyOperation.java | 76 +++++++++++++--------- 1 file changed, 45 insertions(+), 31 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index adccc5ba3..fab456bf8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -386,8 +386,10 @@ public class PgpKeyOperation { user attributes */ - for (PGPSecretKey dKey : saveParcel.deletedKeys) { - mKR = PGPSecretKeyRing.removeSecretKey(mKR, dKey); + if (saveParcel.deletedKeys != null) { + for (PGPSecretKey dKey : saveParcel.deletedKeys) { + mKR = PGPSecretKeyRing.removeSecretKey(mKR, dKey); + } } masterKey = mKR.getSecretKey(); @@ -409,6 +411,31 @@ public class PgpKeyOperation { int user_id_index = 0; boolean anyIDChanged = false; + + PGPSignatureSubpacketGenerator hashedPacketsGen = new PGPSignatureSubpacketGenerator(); + PGPSignatureSubpacketGenerator unhashedPacketsGen = new PGPSignatureSubpacketGenerator(); + + hashedPacketsGen.setKeyFlags(true, usageId); + + hashedPacketsGen.setPreferredSymmetricAlgorithms(true, PREFERRED_SYMMETRIC_ALGORITHMS); + hashedPacketsGen.setPreferredHashAlgorithms(true, PREFERRED_HASH_ALGORITHMS); + hashedPacketsGen.setPreferredCompressionAlgorithms(true, PREFERRED_COMPRESSION_ALGORITHMS); + + if (saveParcel.keysExpiryDates.get(0) != null) { + GregorianCalendar creationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC")); + creationDate.setTime(masterPublicKey.getCreationTime()); + GregorianCalendar expiryDate = saveParcel.keysExpiryDates.get(0); + //note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c + //here we purposefully ignore partial days in each date - long type has no fractional part! + long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000); + if (numDays <= 0) + throw new PgpGeneralException(mContext.getString(R.string.error_expiry_must_come_after_creation)); + hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400); + } else { + hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding, + //this happens anyway + } + if (saveParcel.primaryIDChanged) { anyIDChanged = true; ArrayList> sigList = new ArrayList>(); @@ -427,11 +454,16 @@ public class PgpKeyOperation { PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder); sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey); - + if (user_id_index == 0) { + sGen.setHashedSubpackets(hashedPacketsGen.generate()); + sGen.setUnhashedSubpackets(unhashedPacketsGen.generate()); + } PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); sigList.add(new Pair(userId, certification)); } - masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, orig_id); + if (!orig_id.equals("")) { + masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, orig_id); + } user_id_index++; } for (Pair to_add : sigList) { @@ -448,9 +480,14 @@ public class PgpKeyOperation { PGPSignatureGenerator sGen = new PGPSignatureGenerator(signerBuilder); sGen.init(PGPSignature.POSITIVE_CERTIFICATION, masterPrivateKey); - + if (user_id_index == 0) { + sGen.setHashedSubpackets(hashedPacketsGen.generate()); + sGen.setUnhashedSubpackets(unhashedPacketsGen.generate()); + } PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); - masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, orig_id); + if (!orig_id.equals("")) { + masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, orig_id); + } masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification); } user_id_index++; @@ -465,30 +502,6 @@ public class PgpKeyOperation { PGPKeyPair masterKeyPair = new PGPKeyPair(masterPublicKey, masterPrivateKey); - PGPSignatureSubpacketGenerator hashedPacketsGen = new PGPSignatureSubpacketGenerator(); - PGPSignatureSubpacketGenerator unhashedPacketsGen = new PGPSignatureSubpacketGenerator(); - - hashedPacketsGen.setKeyFlags(true, usageId); - - hashedPacketsGen.setPreferredSymmetricAlgorithms(true, PREFERRED_SYMMETRIC_ALGORITHMS); - hashedPacketsGen.setPreferredHashAlgorithms(true, PREFERRED_HASH_ALGORITHMS); - hashedPacketsGen.setPreferredCompressionAlgorithms(true, PREFERRED_COMPRESSION_ALGORITHMS); - - if (saveParcel.keysExpiryDates.get(0) != null) { - GregorianCalendar creationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC")); - creationDate.setTime(masterPublicKey.getCreationTime()); - GregorianCalendar expiryDate = saveParcel.keysExpiryDates.get(0); - //note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c - //here we purposefully ignore partial days in each date - long type has no fractional part! - long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000); - if (numDays <= 0) - throw new PgpGeneralException(mContext.getString(R.string.error_expiry_must_come_after_creation)); - hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400); - } else { - hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding, - //this happens anyway - } - updateProgress(R.string.progress_building_master_key, 30, 100); // define hashing and signing algos @@ -503,11 +516,12 @@ public class PgpKeyOperation { .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( saveParcel.oldPassPhrase.toCharArray()); + //this generates one more signature than necessary... PGPKeyRingGenerator keyGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, masterKeyPair, mainUserId, sha1Calc, hashedPacketsGen.generate(), unhashedPacketsGen.generate(), certificationSignerBuilder, keyEncryptor); - for (int i = 0; i < saveParcel.keys.size(); ++i) { + for (int i = 1; i < saveParcel.keys.size(); ++i) { updateProgress(40 + 50 * i/ saveParcel.keys.size(), 100); if (saveParcel.moddedKeys[i]) { PGPSecretKey subKey = saveParcel.keys.get(i); -- cgit v1.2.3 From 4e481512c31c60177d3c1b404c97fa8d7a004124 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Tue, 25 Mar 2014 05:26:35 +0100 Subject: Display expiry of subkeys in single key view. --- .../keychain/ui/adapter/ViewKeyKeysAdapter.java | 22 ++++++++++++++++++++++ .../src/main/res/layout/view_key_keys_item.xml | 10 +++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java index 068d6e6e9..d925480e9 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java @@ -22,6 +22,7 @@ import android.content.res.ColorStateList; import android.database.Cursor; import android.graphics.Color; import android.support.v4.widget.CursorAdapter; +import android.text.format.DateFormat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -31,6 +32,8 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; +import java.util.Date; + public class ViewKeyKeysAdapter extends CursorAdapter { private LayoutInflater mInflater; @@ -42,6 +45,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter { private int mIndexCanEncrypt; private int mIndexCanSign; private int mIndexRevokedKey; + private int mIndexExpiry; private ColorStateList mDefaultTextColor; @@ -76,6 +80,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter { mIndexCanEncrypt = cursor.getColumnIndexOrThrow(Keys.CAN_ENCRYPT); mIndexCanSign = cursor.getColumnIndexOrThrow(Keys.CAN_SIGN); mIndexRevokedKey = cursor.getColumnIndexOrThrow(Keys.IS_REVOKED); + mIndexExpiry = cursor.getColumnIndexOrThrow(Keys.EXPIRY); } } @@ -83,6 +88,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter { public void bindView(View view, Context context, Cursor cursor) { TextView keyId = (TextView) view.findViewById(R.id.keyId); TextView keyDetails = (TextView) view.findViewById(R.id.keyDetails); + TextView keyExpiry = (TextView) view.findViewById(R.id.keyExpiry); ImageView masterKeyIcon = (ImageView) view.findViewById(R.id.ic_masterKey); ImageView certifyIcon = (ImageView) view.findViewById(R.id.ic_certifyKey); ImageView encryptIcon = (ImageView) view.findViewById(R.id.ic_encryptKey); @@ -129,6 +135,22 @@ public class ViewKeyKeysAdapter extends CursorAdapter { keyDetails.setTextColor(mDefaultTextColor); revokedKeyIcon.setVisibility(View.GONE); } + + boolean valid = true; + if (!cursor.isNull(mIndexExpiry)) { + Date expiryDate = new Date(cursor.getLong(mIndexExpiry) * 1000); + valid = expiryDate.after(new Date()); + keyExpiry.setText("(" + + context.getString(R.string.label_expiry) + ": " + + DateFormat.getDateFormat(context).format(expiryDate) + ")"); + keyExpiry.setVisibility(View.VISIBLE); + } + else { + keyExpiry.setVisibility(View.GONE); + } + keyId.setEnabled(valid); + keyDetails.setEnabled(valid); + keyExpiry.setEnabled(valid); } @Override diff --git a/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml b/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml index 235949ce2..43f06e246 100644 --- a/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml +++ b/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml @@ -28,9 +28,17 @@ android:id="@+id/keyDetails" android:layout_width="wrap_content" android:layout_height="wrap_content" + android:paddingRight="5dip" android:text="(RSA, 1024bit)" android:textAppearance="?android:attr/textAppearanceSmall" /> + + - \ No newline at end of file + -- cgit v1.2.3 From aa35b1f4b5a5198482c9c5a659d357b3ac9a101b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 25 Mar 2014 19:11:20 +0100 Subject: More experimental work on API accounts --- .../org/openintents/openpgp/util/OpenPgpApi.java | 2 + OpenPGP-Keychain/src/main/AndroidManifest.xml | 2 +- .../org/sufficientlysecure/keychain/Constants.java | 4 +- .../keychain/provider/KeychainContract.java | 61 +++---- .../keychain/provider/KeychainDatabase.java | 3 +- .../keychain/provider/KeychainProvider.java | 108 ++++------- .../keychain/provider/ProviderHelper.java | 99 ++++++---- .../keychain/remote/AccountSettings.java | 85 +++++++++ .../keychain/remote/AppSettings.java | 40 ---- .../keychain/remote/OpenPgpService.java | 48 ++--- .../keychain/remote/RemoteService.java | 8 +- .../remote/ui/AccountSettingsFragment.java | 203 +++++++++++++++++++++ .../keychain/remote/ui/AccountsListFragment.java | 174 ++++++++++++++++++ .../keychain/remote/ui/AppSettingsFragment.java | 87 +-------- .../keychain/remote/ui/AppsListActivity.java | 35 ++++ .../keychain/remote/ui/AppsListFragment.java | 152 +++++++++++++++ .../keychain/remote/ui/RegisteredAppsAdapter.java | 75 -------- .../remote/ui/RegisteredAppsListActivity.java | 35 ---- .../remote/ui/RegisteredAppsListFragment.java | 101 ---------- .../keychain/remote/ui/RemoteServiceActivity.java | 84 +++++++-- .../res/layout/api_account_create_activity.xml | 21 +++ .../res/layout/api_account_settings_fragment.xml | 115 ++++++++++++ .../main/res/layout/api_app_register_activity.xml | 2 +- .../main/res/layout/api_app_settings_fragment.xml | 40 ---- .../src/main/res/layout/api_apps_list_content.xml | 2 +- 25 files changed, 1018 insertions(+), 568 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/AccountSettings.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListActivity.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java delete mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsAdapter.java delete mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsListActivity.java delete mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsListFragment.java create mode 100644 OpenPGP-Keychain/src/main/res/layout/api_account_create_activity.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout/api_account_settings_fragment.xml diff --git a/OpenPGP-Keychain-API/libraries/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpApi.java b/OpenPGP-Keychain-API/libraries/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpApi.java index f768a1685..c59590fec 100644 --- a/OpenPGP-Keychain-API/libraries/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpApi.java +++ b/OpenPGP-Keychain-API/libraries/openpgp-api-library/src/org/openintents/openpgp/util/OpenPgpApi.java @@ -126,6 +126,8 @@ public class OpenPgpApi { /* Intent extras */ public static final String EXTRA_API_VERSION = "api_version"; + public static final String EXTRA_ACCOUNT_NAME = "account_name"; + // SIGN, ENCRYPT, SIGN_AND_ENCRYPT, DECRYPT_VERIFY // request ASCII Armor for output // OpenPGP Radix-64, 33 percent overhead compared to binary, see http://tools.ietf.org/html/rfc4880#page-53) diff --git a/OpenPGP-Keychain/src/main/AndroidManifest.xml b/OpenPGP-Keychain/src/main/AndroidManifest.xml index e2ed8c5e4..3ab39280e 100644 --- a/OpenPGP-Keychain/src/main/AndroidManifest.xml +++ b/OpenPGP-Keychain/src/main/AndroidManifest.xml @@ -390,7 +390,7 @@ diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java index ff4abe56a..f9a7962ec 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java @@ -19,7 +19,7 @@ package org.sufficientlysecure.keychain; import android.os.Environment; import org.spongycastle.jce.provider.BouncyCastleProvider; -import org.sufficientlysecure.keychain.service.remote.RegisteredAppsListActivity; +import org.sufficientlysecure.keychain.remote.ui.AppsListActivity; import org.sufficientlysecure.keychain.ui.DecryptActivity; import org.sufficientlysecure.keychain.ui.EncryptActivity; import org.sufficientlysecure.keychain.ui.ImportKeysActivity; @@ -73,7 +73,7 @@ public final class Constants { public static final Class ENCRYPT = EncryptActivity.class; public static final Class DECRYPT = DecryptActivity.class; public static final Class IMPORT_KEYS = ImportKeysActivity.class; - public static final Class REGISTERED_APPS_LIST = RegisteredAppsListActivity.class; + public static final Class REGISTERED_APPS_LIST = AppsListActivity.class; public static final Class[] ARRAY = new Class[]{KEY_LIST, ENCRYPT, DECRYPT, IMPORT_KEYS, REGISTERED_APPS_LIST}; } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java index aa4c1f131..6e7b76fbe 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java @@ -19,6 +19,7 @@ package org.sufficientlysecure.keychain.provider; import android.net.Uri; import android.provider.BaseColumns; + import org.sufficientlysecure.keychain.Constants; public class KeychainContract { @@ -59,6 +60,7 @@ public class KeychainContract { } interface ApiAppsAccountsColumns { + String ACCOUNT_NAME = "account_name"; String KEY_ID = "key_id"; // not a database id String ENCRYPTION_ALGORITHM = "encryption_algorithm"; String HASH_ALORITHM = "hash_algorithm"; @@ -90,8 +92,7 @@ public class KeychainContract { public static final String PATH_USER_IDS = "user_ids"; public static final String PATH_KEYS = "keys"; - public static final String BASE_API = "api"; - public static final String PATH_APPS = "apps"; + public static final String BASE_API_APPS = "api_apps"; public static final String PATH_ACCOUNTS = "accounts"; public static final String PATH_BY_PACKAGE_NAME = "package_name"; @@ -257,36 +258,9 @@ public class KeychainContract { } } - /** - * Join over ApiApps with ApiAppsAccounts - */ - public static class Api implements ApiAppsColumns, ApiAppsAccountsColumns, BaseColumns { - public static final Uri CONTENT_URI = BASE_CONTENT_URI_INTERNAL.buildUpon() - .appendPath(BASE_API).build(); - - /** - * Use if multiple items get returned - */ - public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.apis"; - - /** - * Use if a single item is returned - */ - public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.api"; - - public static Uri buildIdUri(String rowId) { - return CONTENT_URI.buildUpon().appendPath(rowId).build(); - } - - public static Uri buildByPackageNameUri(String packageName) { - return CONTENT_URI.buildUpon().appendPath(PATH_BY_PACKAGE_NAME).appendPath(packageName) - .build(); - } - } - public static class ApiApps implements ApiAppsColumns, BaseColumns { public static final Uri CONTENT_URI = BASE_CONTENT_URI_INTERNAL.buildUpon() - .appendPath(BASE_API).appendPath(PATH_APPS).build(); + .appendPath(BASE_API_APPS).build(); /** * Use if multiple items get returned @@ -303,14 +277,14 @@ public class KeychainContract { } public static Uri buildByPackageNameUri(String packageName) { - return CONTENT_URI.buildUpon().appendPath(PATH_BY_PACKAGE_NAME).appendPath(packageName) - .build(); + return CONTENT_URI.buildUpon().appendPath(PATH_BY_PACKAGE_NAME) + .appendEncodedPath(packageName).build(); } } public static class ApiAccounts implements ApiAppsAccountsColumns, BaseColumns { public static final Uri CONTENT_URI = BASE_CONTENT_URI_INTERNAL.buildUpon() - .appendPath(BASE_API).appendPath(PATH_ACCOUNTS).build(); + .appendPath(BASE_API_APPS).build(); /** * Use if multiple items get returned @@ -322,13 +296,24 @@ public class KeychainContract { */ public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.api.account"; - public static Uri buildIdUri(String rowId) { - return CONTENT_URI.buildUpon().appendPath(rowId).build(); +// public static Uri buildUri(String rowIdApp) { +// return CONTENT_URI.buildUpon().appendPath(rowIdApp).appendPath(PATH_ACCOUNTS) +// .build(); +// } +// +// public static Uri buildIdUri(String rowIdApp, String rowId) { +// return CONTENT_URI.buildUpon().appendPath(rowIdApp).appendPath(PATH_ACCOUNTS) +// .appendPath(rowId).build(); +// } + + public static Uri buildBaseUri(String packageName) { + return CONTENT_URI.buildUpon().appendEncodedPath(packageName).appendPath(PATH_ACCOUNTS) + .build(); } - public static Uri buildByPackageNameUri(String packageName) { - return CONTENT_URI.buildUpon().appendPath(PATH_BY_PACKAGE_NAME).appendPath(packageName) - .build(); + public static Uri buildByPackageAndAccountUri(String packageName, String accountName) { + return CONTENT_URI.buildUpon().appendEncodedPath(packageName).appendPath(PATH_ACCOUNTS) + .appendEncodedPath(accountName).build(); } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java index e56fa2f8f..ca1a47f0c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java @@ -82,10 +82,11 @@ public class KeychainDatabase extends SQLiteOpenHelper { private static final String CREATE_API_APPS_ACCOUNTS = "CREATE TABLE IF NOT EXISTS " + Tables.API_ACCOUNTS + " (" + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + + ApiAppsAccountsColumns.ACCOUNT_NAME + " TEXT UNIQUE, " + ApiAppsAccountsColumns.KEY_ID + " INT64, " + ApiAppsAccountsColumns.ENCRYPTION_ALGORITHM + " INTEGER, " + ApiAppsAccountsColumns.HASH_ALORITHM + " INTEGER, " - + ApiAppsAccountsColumns.COMPRESSION + " INTEGER" + + ApiAppsAccountsColumns.COMPRESSION + " INTEGER, " + ApiAppsAccountsColumns.PACKAGE_NAME_FK + " TEXT NOT NULL, FOREIGN KEY(" + ApiAppsAccountsColumns.PACKAGE_NAME_FK + ") REFERENCES " + Tables.API_APPS + "(" + ApiAppsColumns.PACKAGE_NAME + ") ON DELETE CASCADE)"; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java index a094b13de..cae76003c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java @@ -30,10 +30,8 @@ import android.provider.BaseColumns; import android.text.TextUtils; import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.provider.KeychainContract.Api; import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAccounts; import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; -import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsAccountsColumns; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingsColumns; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyTypes; @@ -81,15 +79,12 @@ public class KeychainProvider extends ContentProvider { private static final int SECRET_KEY_RING_USER_ID = 221; private static final int SECRET_KEY_RING_USER_ID_BY_ROW_ID = 222; - private static final int API = 301; - private static final int API_BY_ROW_ID = 302; - private static final int API_BY_PACKAGE_NAME = 303; - private static final int API_APPS = 304; - private static final int API_APPS_BY_ROW_ID = 305; - private static final int API_APPS_BY_PACKAGE_NAME = 306; - private static final int API_ACCOUNTS = 307; - private static final int API_ACCOUNTS_BY_ROW_ID = 308; - private static final int API_ACCOUNTS_BY_PACKAGE_NAME = 309; + private static final int API_APPS = 301; + private static final int API_APPS_BY_ROW_ID = 302; + private static final int API_APPS_BY_PACKAGE_NAME = 303; + private static final int API_ACCOUNTS = 304; + private static final int API_ACCOUNTS_BY_ROW_ID = 305; + private static final int API_ACCOUNTS_BY_ACCOUNT_NAME = 306; private static final int UNIFIED_KEY_RING = 401; @@ -247,26 +242,18 @@ public class KeychainProvider extends ContentProvider { /** * API apps */ - matcher.addURI(authority, KeychainContract.BASE_API, API); - matcher.addURI(authority, KeychainContract.BASE_API + "/#", API_BY_ROW_ID); - matcher.addURI(authority, KeychainContract.BASE_API + "/" - + KeychainContract.PATH_BY_PACKAGE_NAME + "/*", API_BY_PACKAGE_NAME); - - matcher.addURI(authority, KeychainContract.BASE_API + "/" - + KeychainContract.PATH_APPS, API_APPS); - matcher.addURI(authority, KeychainContract.BASE_API + "/" - + KeychainContract.PATH_APPS + "/#", API_APPS_BY_ROW_ID); - matcher.addURI(authority, KeychainContract.BASE_API + "/" - + KeychainContract.PATH_APPS + "/" + matcher.addURI(authority, KeychainContract.BASE_API_APPS, API_APPS); + matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/#", API_APPS_BY_ROW_ID); + matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/" + KeychainContract.PATH_BY_PACKAGE_NAME + "/*", API_APPS_BY_PACKAGE_NAME); - matcher.addURI(authority, KeychainContract.BASE_API + "/" + matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/" + KeychainContract.PATH_ACCOUNTS, API_ACCOUNTS); - matcher.addURI(authority, KeychainContract.BASE_API + "/" + matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/" + KeychainContract.PATH_ACCOUNTS + "/#", API_ACCOUNTS_BY_ROW_ID); - matcher.addURI(authority, KeychainContract.BASE_API + "/" + matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/" + KeychainContract.PATH_ACCOUNTS + "/" - + KeychainContract.PATH_BY_PACKAGE_NAME + "/*", API_ACCOUNTS_BY_PACKAGE_NAME); + + KeychainContract.PATH_BY_PACKAGE_NAME + "/*", API_ACCOUNTS_BY_ACCOUNT_NAME); /** * data stream @@ -332,13 +319,6 @@ public class KeychainProvider extends ContentProvider { case SECRET_KEY_RING_USER_ID_BY_ROW_ID: return UserIds.CONTENT_ITEM_TYPE; - case API: - return Api.CONTENT_TYPE; - - case API_BY_ROW_ID: - case API_BY_PACKAGE_NAME: - return Api.CONTENT_ITEM_TYPE; - case API_APPS: return ApiApps.CONTENT_TYPE; @@ -350,7 +330,7 @@ public class KeychainProvider extends ContentProvider { return ApiAccounts.CONTENT_TYPE; case API_ACCOUNTS_BY_ROW_ID: - case API_ACCOUNTS_BY_PACKAGE_NAME: + case API_ACCOUNTS_BY_ACCOUNT_NAME: return ApiAccounts.CONTENT_ITEM_TYPE; default: @@ -695,28 +675,6 @@ public class KeychainProvider extends ContentProvider { qb.appendWhere(" AND " + BaseColumns._ID + " = "); qb.appendWhereEscapeString(uri.getLastPathSegment()); - break; - case API: - qb.setTables(Tables.API_ACCOUNTS + " INNER JOIN " + Tables.API_APPS + " ON " + "(" - + Tables.API_APPS + "." + ApiApps.PACKAGE_NAME + " = " + Tables.API_ACCOUNTS + "." - + ApiAccounts.PACKAGE_NAME_FK + " )"); - - break; - case API_BY_ROW_ID: - qb.setTables(Tables.API_ACCOUNTS + " INNER JOIN " + Tables.API_APPS + " ON " + "(" - + Tables.API_APPS + "." + ApiApps.PACKAGE_NAME + " = " + Tables.API_ACCOUNTS + "." - + ApiAccounts.PACKAGE_NAME_FK + " )"); - qb.appendWhere(Tables.API_APPS + "." + BaseColumns._ID + " = "); - qb.appendWhereEscapeString(uri.getLastPathSegment()); - - break; - case API_BY_PACKAGE_NAME: - qb.setTables(Tables.API_ACCOUNTS + " INNER JOIN " + Tables.API_APPS + " ON " + "(" - + Tables.API_APPS + "." + ApiApps.PACKAGE_NAME + " = " + Tables.API_ACCOUNTS + "." - + ApiAccounts.PACKAGE_NAME_FK + " )"); - qb.appendWhere(Tables.API_APPS + "." + ApiApps.PACKAGE_NAME + " = "); - qb.appendWhereEscapeString(uri.getLastPathSegment()); - break; case API_APPS: qb.setTables(Tables.API_APPS); @@ -740,15 +698,24 @@ public class KeychainProvider extends ContentProvider { break; case API_ACCOUNTS_BY_ROW_ID: - qb.setTables(Tables.API_ACCOUNTS); + qb.setTables(Tables.API_ACCOUNTS + " INNER JOIN " + Tables.API_APPS + " ON " + "(" + + Tables.API_APPS + "." + ApiApps.PACKAGE_NAME + " = " + Tables.API_ACCOUNTS + "." + + ApiAccounts.PACKAGE_NAME_FK + " )"); + qb.appendWhere(Tables.API_APPS + "." + BaseColumns._ID + " = "); + qb.appendWhereEscapeString(uri.getPathSegments().get(2)); - qb.appendWhere(BaseColumns._ID + " = "); + qb.appendWhere(" AND " + Tables.API_ACCOUNTS + "." + BaseColumns._ID + " = "); qb.appendWhereEscapeString(uri.getLastPathSegment()); break; - case API_ACCOUNTS_BY_PACKAGE_NAME: - qb.setTables(Tables.API_ACCOUNTS); - qb.appendWhere(ApiAppsAccountsColumns.PACKAGE_NAME_FK + " = "); + case API_ACCOUNTS_BY_ACCOUNT_NAME: + qb.setTables(Tables.API_ACCOUNTS + " INNER JOIN " + Tables.API_APPS + " ON " + "(" + + Tables.API_APPS + "." + ApiApps.PACKAGE_NAME + " = " + Tables.API_ACCOUNTS + "." + + ApiAccounts.PACKAGE_NAME_FK + " )"); + qb.appendWhere(Tables.API_APPS + "." + ApiApps.PACKAGE_NAME + " = "); + qb.appendWhereEscapeString(uri.getPathSegments().get(2)); + + qb.appendWhere(" AND " + Tables.API_ACCOUNTS + "." + ApiAccounts.ACCOUNT_NAME + " = "); qb.appendWhereEscapeString(uri.getLastPathSegment()); break; @@ -808,13 +775,15 @@ public class KeychainProvider extends ContentProvider { values.put(Keys.TYPE, KeyTypes.PUBLIC); rowId = db.insertOrThrow(Tables.KEYS, null, values); - rowUri = Keys.buildPublicKeysUri(Long.toString(rowId)); + // TODO: this is wrong: +// rowUri = Keys.buildPublicKeysUri(Long.toString(rowId)); sendBroadcastDatabaseChange(getKeyType(match), getType(uri)); break; case PUBLIC_KEY_RING_USER_ID: rowId = db.insertOrThrow(Tables.USER_IDS, null, values); - rowUri = UserIds.buildPublicUserIdsUri(Long.toString(rowId)); + // TODO: this is wrong: +// rowUri = UserIds.buildPublicUserIdsUri(Long.toString(rowId)); sendBroadcastDatabaseChange(getKeyType(match), getType(uri)); break; @@ -830,13 +799,15 @@ public class KeychainProvider extends ContentProvider { values.put(Keys.TYPE, KeyTypes.SECRET); rowId = db.insertOrThrow(Tables.KEYS, null, values); - rowUri = Keys.buildSecretKeysUri(Long.toString(rowId)); + // TODO: this is wrong: +// rowUri = Keys.buildSecretKeysUri(Long.toString(rowId)); sendBroadcastDatabaseChange(getKeyType(match), getType(uri)); break; case SECRET_KEY_RING_USER_ID: rowId = db.insertOrThrow(Tables.USER_IDS, null, values); - rowUri = UserIds.buildSecretUserIdsUri(Long.toString(rowId)); + // TODO: this is wrong: +// rowUri = UserIds.buildSecretUserIdsUri(Long.toString(rowId)); break; case API_APPS: @@ -846,7 +817,8 @@ public class KeychainProvider extends ContentProvider { break; case API_ACCOUNTS: rowId = db.insertOrThrow(Tables.API_ACCOUNTS, null, values); - rowUri = ApiAccounts.buildIdUri(Long.toString(rowId)); + // TODO: this is wrong: +// rowUri = ApiAccounts.buildIdUri(Long.toString(rowId)); break; default: @@ -918,7 +890,7 @@ public class KeychainProvider extends ContentProvider { count = db.delete(Tables.API_ACCOUNTS, buildDefaultApiAccountsSelection(uri, false, selection), selectionArgs); break; - case API_ACCOUNTS_BY_PACKAGE_NAME: + case API_ACCOUNTS_BY_ACCOUNT_NAME: count = db.delete(Tables.API_ACCOUNTS, buildDefaultApiAccountsSelection(uri, true, selection), selectionArgs); break; @@ -996,7 +968,7 @@ public class KeychainProvider extends ContentProvider { count = db.update(Tables.API_ACCOUNTS, values, buildDefaultApiAccountsSelection(uri, false, selection), selectionArgs); break; - case API_ACCOUNTS_BY_PACKAGE_NAME: + case API_ACCOUNTS_BY_ACCOUNT_NAME: count = db.update(Tables.API_ACCOUNTS, values, buildDefaultApiAccountsSelection(uri, true, selection), selectionArgs); break; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java index 7e8bfbc7b..e3727b2f8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -22,6 +22,7 @@ import android.database.Cursor; import android.database.DatabaseUtils; import android.net.Uri; import android.os.RemoteException; + import org.spongycastle.bcpg.ArmoredOutputStream; import org.spongycastle.openpgp.*; import org.sufficientlysecure.keychain.Constants; @@ -33,6 +34,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRings; import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds; import org.sufficientlysecure.keychain.provider.KeychainDatabase.Tables; +import org.sufficientlysecure.keychain.remote.AccountSettings; import org.sufficientlysecure.keychain.remote.AppSettings; import org.sufficientlysecure.keychain.util.IterableIterator; import org.sufficientlysecure.keychain.util.Log; @@ -469,11 +471,11 @@ public class ProviderHelper { cr.delete(KeyRings.buildSecretKeyRingsUri(Long.toString(rowId)), null, null); } - public static void deleteUnifiedKeyRing(Context context,String masterKeyId,boolean isSecretKey){ - ContentResolver cr= context.getContentResolver(); - cr.delete(KeyRings.buildPublicKeyRingsByMasterKeyIdUri(masterKeyId),null,null); - if(isSecretKey){ - cr.delete(KeyRings.buildSecretKeyRingsByMasterKeyIdUri(masterKeyId),null,null); + public static void deleteUnifiedKeyRing(Context context, String masterKeyId, boolean isSecretKey) { + ContentResolver cr = context.getContentResolver(); + cr.delete(KeyRings.buildPublicKeyRingsByMasterKeyIdUri(masterKeyId), null, null); + if (isSecretKey) { + cr.delete(KeyRings.buildSecretKeyRingsByMasterKeyIdUri(masterKeyId), null, null); } } @@ -504,7 +506,7 @@ public class ProviderHelper { + " AS sign_keys WHERE sign_keys." + Keys.KEY_RING_ROW_ID + " = " + KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings._ID + " AND sign_keys." + Keys.CAN_SIGN + " = '1' AND " + Keys.IS_MASTER_KEY - + " = 1) AS sign", }; + + " = 1) AS sign",}; ContentResolver cr = context.getContentResolver(); Cursor cursor = cr.query(queryUri, projection, null, null, null); @@ -801,70 +803,93 @@ public class ProviderHelper { ContentValues values = new ContentValues(); values.put(ApiApps.PACKAGE_NAME, appSettings.getPackageName()); values.put(ApiApps.PACKAGE_SIGNATURE, appSettings.getPackageSignature()); -// values.put(ApiApps.KEY_ID, appSettings.getKeyId()); -// values.put(ApiApps.COMPRESSION, appSettings.getCompression()); -// values.put(ApiApps.ENCRYPTION_ALGORITHM, appSettings.getEncryptionAlgorithm()); -// values.put(ApiApps.HASH_ALORITHM, appSettings.getHashAlgorithm()); - return values; } - private static ContentValues contentValueForApiAccounts(AppSettings appSettings) { + private static ContentValues contentValueForApiAccounts(AccountSettings accSettings) { ContentValues values = new ContentValues(); - values.put(KeychainContract.ApiAccounts.PACKAGE_NAME_FK, appSettings.getPackageName()); - values.put(KeychainContract.ApiAccounts.KEY_ID, appSettings.getKeyId()); - values.put(KeychainContract.ApiAccounts.COMPRESSION, appSettings.getCompression()); - values.put(KeychainContract.ApiAccounts.ENCRYPTION_ALGORITHM, appSettings.getEncryptionAlgorithm()); - values.put(KeychainContract.ApiAccounts.HASH_ALORITHM, appSettings.getHashAlgorithm()); - + values.put(KeychainContract.ApiAccounts.ACCOUNT_NAME, accSettings.getAccountName()); + values.put(KeychainContract.ApiAccounts.KEY_ID, accSettings.getKeyId()); + values.put(KeychainContract.ApiAccounts.COMPRESSION, accSettings.getCompression()); + values.put(KeychainContract.ApiAccounts.ENCRYPTION_ALGORITHM, accSettings.getEncryptionAlgorithm()); + values.put(KeychainContract.ApiAccounts.HASH_ALORITHM, accSettings.getHashAlgorithm()); +// values.put(KeychainContract.ApiAccounts.PACKAGE_NAME_FK, accSettings.getPackageName()); return values; } - public static void insertApi(Context context, AppSettings appSettings) { + public static void insertApiApp(Context context, AppSettings appSettings) { context.getContentResolver().insert(KeychainContract.ApiApps.CONTENT_URI, contentValueForApiApps(appSettings)); - context.getContentResolver().insert(KeychainContract.ApiAccounts.CONTENT_URI, - contentValueForApiApps(appSettings)); } - // TODO: uri not working because it is used for both tables + public static void insertApiAccount(Context context, Uri uri, AccountSettings accSettings) { + context.getContentResolver().insert(uri, + contentValueForApiAccounts(accSettings)); + } + public static void updateApiApp(Context context, AppSettings appSettings, Uri uri) { if (context.getContentResolver().update(uri, contentValueForApiApps(appSettings), null, null) <= 0) { throw new RuntimeException(); } - if (context.getContentResolver().update(uri, contentValueForApiAccounts(appSettings), null, + } + + public static void updateApiAccount(Context context, AccountSettings accSettings, Uri uri) { + if (context.getContentResolver().update(uri, contentValueForApiAccounts(accSettings), null, null) <= 0) { throw new RuntimeException(); } } - public static AppSettings getApiSettings(Context context, Uri uri) { + + /** + * Must be an uri pointing to an account + * + * @param context + * @param uri + * @return + */ + public static AppSettings getApiAppSettings(Context context, Uri uri) { AppSettings settings = null; Cursor cur = context.getContentResolver().query(uri, null, null, null, null); if (cur != null && cur.moveToFirst()) { settings = new AppSettings(); - settings.setPackageName(cur.getString(cur - .getColumnIndex(KeychainContract.Api.PACKAGE_NAME))); - settings.setPackageSignature(cur.getBlob(cur - .getColumnIndex(KeychainContract.Api.PACKAGE_SIGNATURE))); - settings.setKeyId(cur.getLong(cur.getColumnIndex(KeychainContract.Api.KEY_ID))); - settings.setCompression(cur.getInt(cur - .getColumnIndexOrThrow(KeychainContract.Api.COMPRESSION))); - settings.setHashAlgorithm(cur.getInt(cur - .getColumnIndexOrThrow(KeychainContract.Api.HASH_ALORITHM))); - settings.setEncryptionAlgorithm(cur.getInt(cur - .getColumnIndexOrThrow(KeychainContract.Api.ENCRYPTION_ALGORITHM))); + settings.setPackageName(cur.getString( + cur.getColumnIndex(KeychainContract.ApiApps.PACKAGE_NAME))); + settings.setPackageSignature(cur.getBlob( + cur.getColumnIndex(KeychainContract.ApiApps.PACKAGE_SIGNATURE))); + } + + return settings; + } + + public static AccountSettings getApiAccountSettings(Context context, Uri uri) { + AccountSettings settings = null; + + Cursor cur = context.getContentResolver().query(uri, null, null, null, null); + if (cur != null && cur.moveToFirst()) { + settings = new AccountSettings(); + + settings.setAccountName(cur.getString( + cur.getColumnIndex(KeychainContract.ApiAccounts.ACCOUNT_NAME))); + settings.setKeyId(cur.getLong( + cur.getColumnIndex(KeychainContract.ApiAccounts.KEY_ID))); + settings.setCompression(cur.getInt( + cur.getColumnIndexOrThrow(KeychainContract.ApiAccounts.COMPRESSION))); + settings.setHashAlgorithm(cur.getInt( + cur.getColumnIndexOrThrow(KeychainContract.ApiAccounts.HASH_ALORITHM))); + settings.setEncryptionAlgorithm(cur.getInt( + cur.getColumnIndexOrThrow(KeychainContract.ApiAccounts.ENCRYPTION_ALGORITHM))); } return settings; } public static byte[] getApiSignature(Context context, String packageName) { - Uri queryUri = KeychainContract.Api.buildByPackageNameUri(packageName); + Uri queryUri = ApiApps.buildByPackageNameUri(packageName); - String[] projection = new String[]{KeychainContract.Api.PACKAGE_SIGNATURE}; + String[] projection = new String[]{ApiApps.PACKAGE_SIGNATURE}; ContentResolver cr = context.getContentResolver(); Cursor cursor = cr.query(queryUri, projection, null, null, null); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/AccountSettings.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/AccountSettings.java new file mode 100644 index 000000000..832cbc752 --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/AccountSettings.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2013 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.remote; + +import org.spongycastle.bcpg.HashAlgorithmTags; +import org.spongycastle.openpgp.PGPEncryptedData; +import org.sufficientlysecure.keychain.Id; + +public class AccountSettings { + private String mAccountName; + private long mKeyId = Id.key.none; + private int mEncryptionAlgorithm; + private int mHashAlgorithm; + private int mCompression; + + public AccountSettings() { + + } + + public AccountSettings(String accountName) { + super(); + this.mAccountName = accountName; + + // defaults: + this.mEncryptionAlgorithm = PGPEncryptedData.AES_256; + this.mHashAlgorithm = HashAlgorithmTags.SHA512; + this.mCompression = Id.choice.compression.zlib; + } + + public String getAccountName() { + return mAccountName; + } + + public void setAccountName(String mAccountName) { + this.mAccountName = mAccountName; + } + + public long getKeyId() { + return mKeyId; + } + + public void setKeyId(long scretKeyId) { + this.mKeyId = scretKeyId; + } + + public int getEncryptionAlgorithm() { + return mEncryptionAlgorithm; + } + + public void setEncryptionAlgorithm(int encryptionAlgorithm) { + this.mEncryptionAlgorithm = encryptionAlgorithm; + } + + public int getHashAlgorithm() { + return mHashAlgorithm; + } + + public void setHashAlgorithm(int hashAlgorithm) { + this.mHashAlgorithm = hashAlgorithm; + } + + public int getCompression() { + return mCompression; + } + + public void setCompression(int compression) { + this.mCompression = compression; + } + +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/AppSettings.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/AppSettings.java index ad48a402b..6c7e51bf0 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/AppSettings.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/AppSettings.java @@ -24,10 +24,6 @@ import org.sufficientlysecure.keychain.Id; public class AppSettings { private String mPackageName; private byte[] mPackageSignature; - private long mKeyId = Id.key.none; - private int mEncryptionAlgorithm; - private int mHashAlgorithm; - private int mCompression; public AppSettings() { @@ -37,10 +33,6 @@ public class AppSettings { super(); this.mPackageName = packageName; this.mPackageSignature = packageSignature; - // defaults: - this.mEncryptionAlgorithm = PGPEncryptedData.AES_256; - this.mHashAlgorithm = HashAlgorithmTags.SHA512; - this.mCompression = Id.choice.compression.zlib; } public String getPackageName() { @@ -59,36 +51,4 @@ public class AppSettings { this.mPackageSignature = packageSignature; } - public long getKeyId() { - return mKeyId; - } - - public void setKeyId(long scretKeyId) { - this.mKeyId = scretKeyId; - } - - public int getEncryptionAlgorithm() { - return mEncryptionAlgorithm; - } - - public void setEncryptionAlgorithm(int encryptionAlgorithm) { - this.mEncryptionAlgorithm = encryptionAlgorithm; - } - - public int getHashAlgorithm() { - return mHashAlgorithm; - } - - public void setHashAlgorithm(int hashAlgorithm) { - this.mHashAlgorithm = hashAlgorithm; - } - - public int getCompression() { - return mCompression; - } - - public void setCompression(int compression) { - this.mCompression = compression; - } - } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java index 9b56a491a..b04e76cbd 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -138,7 +138,7 @@ public class OpenPgpService extends RemoteService { } private Intent signImpl(Intent data, ParcelFileDescriptor input, - ParcelFileDescriptor output, AppSettings appSettings) { + ParcelFileDescriptor output, AccountSettings accSettings) { try { boolean asciiArmor = data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); @@ -147,11 +147,11 @@ public class OpenPgpService extends RemoteService { if (data.hasExtra(OpenPgpApi.EXTRA_PASSPHRASE)) { passphrase = data.getStringExtra(OpenPgpApi.EXTRA_PASSPHRASE); } else { - passphrase = PassphraseCacheService.getCachedPassphrase(getContext(), appSettings.getKeyId()); + passphrase = PassphraseCacheService.getCachedPassphrase(getContext(), accSettings.getKeyId()); } if (passphrase == null) { // get PendingIntent for passphrase input, add it to given params and return to client - Intent passphraseBundle = getPassphraseBundleIntent(data, appSettings.getKeyId()); + Intent passphraseBundle = getPassphraseBundleIntent(data, accSettings.getKeyId()); return passphraseBundle; } @@ -165,9 +165,9 @@ public class OpenPgpService extends RemoteService { // sign-only PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder(getContext(), inputData, os); builder.enableAsciiArmorOutput(asciiArmor) - .signatureHashAlgorithm(appSettings.getHashAlgorithm()) + .signatureHashAlgorithm(accSettings.getHashAlgorithm()) .signatureForceV3(false) - .signatureKeyId(appSettings.getKeyId()) + .signatureKeyId(accSettings.getKeyId()) .signaturePassphrase(passphrase); builder.build().execute(); } finally { @@ -188,7 +188,7 @@ public class OpenPgpService extends RemoteService { } private Intent encryptAndSignImpl(Intent data, ParcelFileDescriptor input, - ParcelFileDescriptor output, AppSettings appSettings, boolean sign) { + ParcelFileDescriptor output, AccountSettings accSettings, boolean sign) { try { boolean asciiArmor = data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); @@ -218,7 +218,7 @@ public class OpenPgpService extends RemoteService { // add own key for encryption keyIds = Arrays.copyOf(keyIds, keyIds.length + 1); - keyIds[keyIds.length - 1] = appSettings.getKeyId(); + keyIds[keyIds.length - 1] = accSettings.getKeyId(); // build InputData and write into OutputStream // Get Input- and OutputStream from ParcelFileDescriptor @@ -230,8 +230,8 @@ public class OpenPgpService extends RemoteService { PgpSignEncrypt.Builder builder = new PgpSignEncrypt.Builder(getContext(), inputData, os); builder.enableAsciiArmorOutput(asciiArmor) - .compressionId(appSettings.getCompression()) - .symmetricEncryptionAlgorithm(appSettings.getEncryptionAlgorithm()) + .compressionId(accSettings.getCompression()) + .symmetricEncryptionAlgorithm(accSettings.getEncryptionAlgorithm()) .encryptionKeyIds(keyIds); if (sign) { @@ -240,18 +240,18 @@ public class OpenPgpService extends RemoteService { passphrase = data.getStringExtra(OpenPgpApi.EXTRA_PASSPHRASE); } else { passphrase = PassphraseCacheService.getCachedPassphrase(getContext(), - appSettings.getKeyId()); + accSettings.getKeyId()); } if (passphrase == null) { // get PendingIntent for passphrase input, add it to given params and return to client - Intent passphraseBundle = getPassphraseBundleIntent(data, appSettings.getKeyId()); + Intent passphraseBundle = getPassphraseBundleIntent(data, accSettings.getKeyId()); return passphraseBundle; } // sign and encrypt - builder.signatureHashAlgorithm(appSettings.getHashAlgorithm()) + builder.signatureHashAlgorithm(accSettings.getHashAlgorithm()) .signatureForceV3(false) - .signatureKeyId(appSettings.getKeyId()) + .signatureKeyId(accSettings.getKeyId()) .signaturePassphrase(passphrase); } else { // encrypt only @@ -277,7 +277,7 @@ public class OpenPgpService extends RemoteService { } private Intent decryptAndVerifyImpl(Intent data, ParcelFileDescriptor input, - ParcelFileDescriptor output, AppSettings appSettings) { + ParcelFileDescriptor output, AccountSettings accSettings) { try { // Get Input- and OutputStream from ParcelFileDescriptor InputStream is = new ParcelFileDescriptor.AutoCloseInputStream(input); @@ -293,7 +293,7 @@ public class OpenPgpService extends RemoteService { PgpDecryptVerify.Builder builder = new PgpDecryptVerify.Builder(this, inputData, os); builder.assumeSymmetric(false) // no support for symmetric encryption // allow only the private key for this app for decryption - .enforcedKeyId(appSettings.getKeyId()) + .enforcedKeyId(accSettings.getKeyId()) .passphrase(passphrase); // TODO: currently does not support binary signed-only content @@ -301,7 +301,7 @@ public class OpenPgpService extends RemoteService { if (decryptVerifyResult.isKeyPassphraseNeeded()) { // get PendingIntent for passphrase input, add it to given params and return to client - Intent passphraseBundle = getPassphraseBundleIntent(data, appSettings.getKeyId()); + Intent passphraseBundle = getPassphraseBundleIntent(data, accSettings.getKeyId()); return passphraseBundle; } else if (decryptVerifyResult.isSymmetricPassphraseNeeded()) { throw new PgpGeneralException("Decryption of symmetric content not supported by API!"); @@ -433,17 +433,23 @@ public class OpenPgpService extends RemoteService { return errorResult; } - final AppSettings appSettings = getAppSettings(); + String accName; + if (data.getStringExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME) != null) { + accName = data.getStringExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME); + } else { + accName = "default"; + } + final AccountSettings accSettings = getAccSettings(accName); String action = data.getAction(); if (OpenPgpApi.ACTION_SIGN.equals(action)) { - return signImpl(data, input, output, appSettings); + return signImpl(data, input, output, accSettings); } else if (OpenPgpApi.ACTION_ENCRYPT.equals(action)) { - return encryptAndSignImpl(data, input, output, appSettings, false); + return encryptAndSignImpl(data, input, output, accSettings, false); } else if (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(action)) { - return encryptAndSignImpl(data, input, output, appSettings, true); + return encryptAndSignImpl(data, input, output, accSettings, true); } else if (OpenPgpApi.ACTION_DECRYPT_VERIFY.equals(action)) { - return decryptAndVerifyImpl(data, input, output, appSettings); + return decryptAndVerifyImpl(data, input, output, accSettings); } else if (OpenPgpApi.ACTION_GET_KEY.equals(action)) { return getKeyImpl(data); } else if (OpenPgpApi.ACTION_GET_KEY_IDS.equals(action)) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java index 434fe84c1..7b66a0b5c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java @@ -130,16 +130,16 @@ public abstract class RemoteService extends Service { * * @return */ - protected AppSettings getAppSettings() { + protected AccountSettings getAccSettings(String accountName) { String[] callingPackages = getPackageManager().getPackagesForUid(Binder.getCallingUid()); // get app settings for this package for (int i = 0; i < callingPackages.length; i++) { String currentPkg = callingPackages[i]; - Uri uri = KeychainContract.ApiApps.buildByPackageNameUri(currentPkg); + Uri uri = KeychainContract.ApiAccounts.buildByPackageAndAccountUri(currentPkg, accountName); - AppSettings settings = ProviderHelper.getApiAppSettings(this, uri); + AccountSettings settings = ProviderHelper.getApiAccountSettings(this, uri); if (settings != null) { return settings; @@ -210,7 +210,7 @@ public abstract class RemoteService extends Service { throw new WrongPackageSignatureException(e.getMessage()); } - byte[] storedSig = ProviderHelper.getApiAppSignature(this, packageName); + byte[] storedSig = ProviderHelper.getApiSignature(this, packageName); if (Arrays.equals(currentSig, storedSig)) { Log.d(Constants.TAG, "Package signature is correct! (equals signature from database)"); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java new file mode 100644 index 000000000..3d88d216e --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java @@ -0,0 +1,203 @@ +/* + * Copyright (C) 2013-2014 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.remote.ui; + +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.graphics.drawable.Drawable; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemSelectedListener; +import android.widget.ImageView; +import android.widget.Spinner; +import android.widget.TextView; + +import org.spongycastle.util.encoders.Hex; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.remote.AccountSettings; +import org.sufficientlysecure.keychain.remote.AppSettings; +import org.sufficientlysecure.keychain.ui.SelectSecretKeyLayoutFragment; +import org.sufficientlysecure.keychain.ui.adapter.KeyValueSpinnerAdapter; +import org.sufficientlysecure.keychain.util.AlgorithmNames; +import org.sufficientlysecure.keychain.util.Log; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class AccountSettingsFragment extends Fragment implements + SelectSecretKeyLayoutFragment.SelectSecretKeyCallback { + + // model + private AccountSettings mAccSettings; + + // view + private TextView mAppNameView; + private ImageView mAppIconView; + private Spinner mEncryptionAlgorithm; + private Spinner mHashAlgorithm; + private Spinner mCompression; + private TextView mPackageName; + private TextView mPackageSignature; + + private SelectSecretKeyLayoutFragment mSelectKeyFragment; + + KeyValueSpinnerAdapter mEncryptionAdapter; + KeyValueSpinnerAdapter mHashAdapter; + KeyValueSpinnerAdapter mCompressionAdapter; + + public AccountSettings getAccSettings() { + return mAccSettings; + } + + public void setAccSettings(AccountSettings appSettings) { + this.mAccSettings = appSettings; +// setPackage(appSettings.getPackageName()); +// mPackageName.setText(appSettings.getPackageName()); + +// try { +// MessageDigest md = MessageDigest.getInstance("SHA-256"); +// md.update(appSettings.getPackageSignature()); +// byte[] digest = md.digest(); +// String signature = new String(Hex.encode(digest)); +// +// mPackageSignature.setText(signature); +// } catch (NoSuchAlgorithmException e) { +// Log.e(Constants.TAG, "Should not happen!", e); +// } + + mSelectKeyFragment.selectKey(appSettings.getKeyId()); + mEncryptionAlgorithm.setSelection(mEncryptionAdapter.getPosition(appSettings + .getEncryptionAlgorithm())); + mHashAlgorithm.setSelection(mHashAdapter.getPosition(appSettings.getHashAlgorithm())); + mCompression.setSelection(mCompressionAdapter.getPosition(appSettings.getCompression())); + } + + /** + * Inflate the layout for this fragment + */ + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.api_account_settings_fragment, container, false); + initView(view); + return view; + } + + /** + * Set error String on key selection + * + * @param error + */ + public void setErrorOnSelectKeyFragment(String error) { + mSelectKeyFragment.setError(error); + } + + private void initView(View view) { + mSelectKeyFragment = (SelectSecretKeyLayoutFragment) getFragmentManager().findFragmentById( + R.id.api_account_settings_select_key_fragment); + mSelectKeyFragment.setCallback(this); + + mAppNameView = (TextView) view.findViewById(R.id.api_account_settings_app_name); + mAppIconView = (ImageView) view.findViewById(R.id.api_account_settings_app_icon); + mEncryptionAlgorithm = (Spinner) view + .findViewById(R.id.api_account_settings_encryption_algorithm); + mHashAlgorithm = (Spinner) view.findViewById(R.id.api_account_settings_hash_algorithm); + mCompression = (Spinner) view.findViewById(R.id.api_account_settings_compression); + mPackageName = (TextView) view.findViewById(R.id.api_account_settings_package_name); + mPackageSignature = (TextView) view.findViewById(R.id.api_account_settings_package_signature); + + AlgorithmNames algorithmNames = new AlgorithmNames(getActivity()); + + mEncryptionAdapter = new KeyValueSpinnerAdapter(getActivity(), + algorithmNames.getEncryptionNames()); + mEncryptionAlgorithm.setAdapter(mEncryptionAdapter); + mEncryptionAlgorithm.setOnItemSelectedListener(new OnItemSelectedListener() { + + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + mAccSettings.setEncryptionAlgorithm((int) id); + } + + @Override + public void onNothingSelected(AdapterView parent) { + } + }); + + mHashAdapter = new KeyValueSpinnerAdapter(getActivity(), algorithmNames.getHashNames()); + mHashAlgorithm.setAdapter(mHashAdapter); + mHashAlgorithm.setOnItemSelectedListener(new OnItemSelectedListener() { + + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + mAccSettings.setHashAlgorithm((int) id); + } + + @Override + public void onNothingSelected(AdapterView parent) { + } + }); + + mCompressionAdapter = new KeyValueSpinnerAdapter(getActivity(), + algorithmNames.getCompressionNames()); + mCompression.setAdapter(mCompressionAdapter); + mCompression.setOnItemSelectedListener(new OnItemSelectedListener() { + + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + mAccSettings.setCompression((int) id); + } + + @Override + public void onNothingSelected(AdapterView parent) { + } + }); + } +// +// private void setPackage(String packageName) { +// PackageManager pm = getActivity().getApplicationContext().getPackageManager(); +// +// // get application name and icon from package manager +// String appName = null; +// Drawable appIcon = null; +// try { +// ApplicationInfo ai = pm.getApplicationInfo(packageName, 0); +// +// appName = (String) pm.getApplicationLabel(ai); +// appIcon = pm.getApplicationIcon(ai); +// } catch (final NameNotFoundException e) { +// // fallback +// appName = packageName; +// } +// mAppNameView.setText(appName); +// mAppIconView.setImageDrawable(appIcon); +// } + + /** + * callback from select secret key fragment + */ + @Override + public void onKeySelected(long secretKeyId) { + mAccSettings.setKeyId(secretKeyId); + } + +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java new file mode 100644 index 000000000..0cec319a5 --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2013 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.remote.ui; + +import android.annotation.TargetApi; +import android.content.ContentUris; +import android.content.Context; +import android.content.Intent; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.database.Cursor; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.support.v4.app.ListFragment; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.CursorLoader; +import android.support.v4.content.Loader; +import android.support.v4.widget.CursorAdapter; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ImageView; +import android.widget.SimpleCursorAdapter; +import android.widget.TextView; + +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; + +// TODO: make compat with < 11 +@TargetApi(Build.VERSION_CODES.HONEYCOMB) +public class AccountsListFragment extends ListFragment implements + LoaderManager.LoaderCallbacks { + + // This is the Adapter being used to display the list's data. + SimpleCursorAdapter mAdapter; + + private String mPackageName; + + public String getPackageName() { + return mPackageName; + } + + public void setPackageName(String packageName) { + this.mPackageName = packageName; + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + getListView().setOnItemClickListener(new OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int position, long id) { + // edit app settings + Intent intent = new Intent(getActivity(), AppSettingsActivity.class); + intent.setData(ContentUris.withAppendedId(ApiApps.CONTENT_URI, id)); + startActivity(intent); + } + }); + + // Give some text to display if there is no data. In a real + // application this would come from a resource. + setEmptyText(getString(R.string.api_no_apps)); + + // We have a menu item to show in action bar. + setHasOptionsMenu(true); + + // Create an empty adapter we will use to display the loaded data. + mAdapter = new SimpleCursorAdapter(getActivity(), + android.R.layout.simple_list_item_1, + null, + new String[]{KeychainContract.ApiAccounts.ACCOUNT_NAME}, + new int[]{android.R.id.text1}, + 0); + setListAdapter(mAdapter); + + // Prepare the loader. Either re-connect with an existing one, + // or start a new one. + getLoaderManager().initLoader(0, null, this); + } + + // These are the Contacts rows that we will retrieve. + static final String[] PROJECTION = new String[]{ + KeychainContract.ApiAccounts._ID, + KeychainContract.ApiAccounts.ACCOUNT_NAME}; + + public Loader onCreateLoader(int id, Bundle args) { + // This is called when a new Loader needs to be created. This + // sample only has one Loader, so we don't care about the ID. + // First, pick the base URI to use depending on whether we are + // currently filtering. + Uri baseUri = KeychainContract.ApiAccounts.buildBaseUri(mPackageName); + + // Now create and return a CursorLoader that will take care of + // creating a Cursor for the data being displayed. + return new CursorLoader(getActivity(), baseUri, PROJECTION, null, null, + KeychainContract.ApiAccounts.ACCOUNT_NAME + " COLLATE LOCALIZED ASC"); + } + + public void onLoadFinished(Loader loader, Cursor data) { + // Swap the new cursor in. (The framework will take care of closing the + // old cursor once we return.) + mAdapter.swapCursor(data); + } + + public void onLoaderReset(Loader loader) { + // This is called when the last Cursor provided to onLoadFinished() + // above is about to be closed. We need to make sure we are no + // longer using it. + mAdapter.swapCursor(null); + } + +// private class RegisteredAppsAdapter extends CursorAdapter { +// +// private LayoutInflater mInflater; +// private PackageManager mPM; +// +// public RegisteredAppsAdapter(Context context, Cursor c, int flags) { +// super(context, c, flags); +// +// mInflater = LayoutInflater.from(context); +// mPM = context.getApplicationContext().getPackageManager(); +// } +// +// @Override +// public void bindView(View view, Context context, Cursor cursor) { +// TextView text = (TextView) view.findViewById(R.id.api_apps_adapter_item_name); +// ImageView icon = (ImageView) view.findViewById(R.id.api_apps_adapter_item_icon); +// +// String packageName = cursor.getString(cursor.getColumnIndex(ApiApps.PACKAGE_NAME)); +// if (packageName != null) { +// // get application name +// try { +// ApplicationInfo ai = mPM.getApplicationInfo(packageName, 0); +// +// text.setText(mPM.getApplicationLabel(ai)); +// icon.setImageDrawable(mPM.getApplicationIcon(ai)); +// } catch (final PackageManager.NameNotFoundException e) { +// // fallback +// text.setText(packageName); +// } +// } else { +// // fallback +// text.setText(packageName); +// } +// +// } +// +// @Override +// public View newView(Context context, Cursor cursor, ViewGroup parent) { +// return mInflater.inflate(R.layout.api_apps_adapter_list_item, null); +// } +// } + +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsFragment.java index 8e8f3827b..8bcd83fc7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsFragment.java @@ -44,8 +44,7 @@ import org.sufficientlysecure.keychain.util.Log; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -public class AppSettingsFragment extends Fragment implements - SelectSecretKeyLayoutFragment.SelectSecretKeyCallback { +public class AppSettingsFragment extends Fragment { // model private AppSettings mAppSettings; @@ -53,18 +52,9 @@ public class AppSettingsFragment extends Fragment implements // view private TextView mAppNameView; private ImageView mAppIconView; - private Spinner mEncryptionAlgorithm; - private Spinner mHashAlgorithm; - private Spinner mCompression; private TextView mPackageName; private TextView mPackageSignature; - private SelectSecretKeyLayoutFragment mSelectKeyFragment; - - KeyValueSpinnerAdapter mEncryptionAdapter; - KeyValueSpinnerAdapter mHashAdapter; - KeyValueSpinnerAdapter mCompressionAdapter; - public AppSettings getAppSettings() { return mAppSettings; } @@ -85,11 +75,6 @@ public class AppSettingsFragment extends Fragment implements Log.e(Constants.TAG, "Should not happen!", e); } - mSelectKeyFragment.selectKey(appSettings.getKeyId()); - mEncryptionAlgorithm.setSelection(mEncryptionAdapter.getPosition(appSettings - .getEncryptionAlgorithm())); - mHashAlgorithm.setSelection(mHashAdapter.getPosition(appSettings.getHashAlgorithm())); - mCompression.setSelection(mCompressionAdapter.getPosition(appSettings.getCompression())); } /** @@ -102,74 +87,13 @@ public class AppSettingsFragment extends Fragment implements return view; } - /** - * Set error String on key selection - * - * @param error - */ - public void setErrorOnSelectKeyFragment(String error) { - mSelectKeyFragment.setError(error); - } private void initView(View view) { - mSelectKeyFragment = (SelectSecretKeyLayoutFragment) getFragmentManager().findFragmentById( - R.id.api_app_settings_select_key_fragment); - mSelectKeyFragment.setCallback(this); - mAppNameView = (TextView) view.findViewById(R.id.api_app_settings_app_name); mAppIconView = (ImageView) view.findViewById(R.id.api_app_settings_app_icon); - mEncryptionAlgorithm = (Spinner) view - .findViewById(R.id.api_app_settings_encryption_algorithm); - mHashAlgorithm = (Spinner) view.findViewById(R.id.api_app_settings_hash_algorithm); - mCompression = (Spinner) view.findViewById(R.id.api_app_settings_compression); + mPackageName = (TextView) view.findViewById(R.id.api_app_settings_package_name); mPackageSignature = (TextView) view.findViewById(R.id.api_app_settings_package_signature); - - AlgorithmNames algorithmNames = new AlgorithmNames(getActivity()); - - mEncryptionAdapter = new KeyValueSpinnerAdapter(getActivity(), - algorithmNames.getEncryptionNames()); - mEncryptionAlgorithm.setAdapter(mEncryptionAdapter); - mEncryptionAlgorithm.setOnItemSelectedListener(new OnItemSelectedListener() { - - @Override - public void onItemSelected(AdapterView parent, View view, int position, long id) { - mAppSettings.setEncryptionAlgorithm((int) id); - } - - @Override - public void onNothingSelected(AdapterView parent) { - } - }); - - mHashAdapter = new KeyValueSpinnerAdapter(getActivity(), algorithmNames.getHashNames()); - mHashAlgorithm.setAdapter(mHashAdapter); - mHashAlgorithm.setOnItemSelectedListener(new OnItemSelectedListener() { - - @Override - public void onItemSelected(AdapterView parent, View view, int position, long id) { - mAppSettings.setHashAlgorithm((int) id); - } - - @Override - public void onNothingSelected(AdapterView parent) { - } - }); - - mCompressionAdapter = new KeyValueSpinnerAdapter(getActivity(), - algorithmNames.getCompressionNames()); - mCompression.setAdapter(mCompressionAdapter); - mCompression.setOnItemSelectedListener(new OnItemSelectedListener() { - - @Override - public void onItemSelected(AdapterView parent, View view, int position, long id) { - mAppSettings.setCompression((int) id); - } - - @Override - public void onNothingSelected(AdapterView parent) { - } - }); } private void setPackage(String packageName) { @@ -191,12 +115,5 @@ public class AppSettingsFragment extends Fragment implements mAppIconView.setImageDrawable(appIcon); } - /** - * callback from select secret key fragment - */ - @Override - public void onKeySelected(long secretKeyId) { - mAppSettings.setKeyId(secretKeyId); - } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListActivity.java new file mode 100644 index 000000000..f86d279f0 --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListActivity.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2013 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.remote.ui; + +import android.os.Bundle; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.ui.DrawerActivity; + +public class AppsListActivity extends DrawerActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + setContentView(R.layout.api_apps_list_activity); + + setupDrawerNavigation(savedInstanceState); + } + +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java new file mode 100644 index 000000000..7054a2195 --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2013 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.remote.ui; + +import android.content.ContentUris; +import android.content.Context; +import android.content.Intent; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; +import android.database.Cursor; +import android.net.Uri; +import android.os.Bundle; +import android.support.v4.app.ListFragment; +import android.support.v4.app.LoaderManager; +import android.support.v4.content.CursorLoader; +import android.support.v4.content.Loader; +import android.support.v4.widget.CursorAdapter; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.ImageView; +import android.widget.TextView; + +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; + +public class AppsListFragment extends ListFragment implements + LoaderManager.LoaderCallbacks { + + // This is the Adapter being used to display the list's data. + RegisteredAppsAdapter mAdapter; + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + getListView().setOnItemClickListener(new OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int position, long id) { + // edit app settings + Intent intent = new Intent(getActivity(), AppSettingsActivity.class); + intent.setData(ContentUris.withAppendedId(KeychainContract.ApiApps.CONTENT_URI, id)); + startActivity(intent); + } + }); + + // Give some text to display if there is no data. In a real + // application this would come from a resource. + setEmptyText(getString(R.string.api_no_apps)); + + // We have a menu item to show in action bar. + setHasOptionsMenu(true); + + // Create an empty adapter we will use to display the loaded data. + mAdapter = new RegisteredAppsAdapter(getActivity(), null, 0); + setListAdapter(mAdapter); + + // Prepare the loader. Either re-connect with an existing one, + // or start a new one. + getLoaderManager().initLoader(0, null, this); + } + + // These are the Contacts rows that we will retrieve. + static final String[] PROJECTION = new String[]{ApiApps._ID, ApiApps.PACKAGE_NAME}; + + public Loader onCreateLoader(int id, Bundle args) { + // This is called when a new Loader needs to be created. This + // sample only has one Loader, so we don't care about the ID. + // First, pick the base URI to use depending on whether we are + // currently filtering. + Uri baseUri = ApiApps.CONTENT_URI; + + // Now create and return a CursorLoader that will take care of + // creating a Cursor for the data being displayed. + return new CursorLoader(getActivity(), baseUri, PROJECTION, null, null, + ApiApps.PACKAGE_NAME + " COLLATE LOCALIZED ASC"); + } + + public void onLoadFinished(Loader loader, Cursor data) { + // Swap the new cursor in. (The framework will take care of closing the + // old cursor once we return.) + mAdapter.swapCursor(data); + } + + public void onLoaderReset(Loader loader) { + // This is called when the last Cursor provided to onLoadFinished() + // above is about to be closed. We need to make sure we are no + // longer using it. + mAdapter.swapCursor(null); + } + + private class RegisteredAppsAdapter extends CursorAdapter { + + private LayoutInflater mInflater; + private PackageManager mPM; + + public RegisteredAppsAdapter(Context context, Cursor c, int flags) { + super(context, c, flags); + + mInflater = LayoutInflater.from(context); + mPM = context.getApplicationContext().getPackageManager(); + } + + @Override + public void bindView(View view, Context context, Cursor cursor) { + TextView text = (TextView) view.findViewById(R.id.api_apps_adapter_item_name); + ImageView icon = (ImageView) view.findViewById(R.id.api_apps_adapter_item_icon); + + String packageName = cursor.getString(cursor.getColumnIndex(ApiApps.PACKAGE_NAME)); + if (packageName != null) { + // get application name + try { + ApplicationInfo ai = mPM.getApplicationInfo(packageName, 0); + + text.setText(mPM.getApplicationLabel(ai)); + icon.setImageDrawable(mPM.getApplicationIcon(ai)); + } catch (final PackageManager.NameNotFoundException e) { + // fallback + text.setText(packageName); + } + } else { + // fallback + text.setText(packageName); + } + + } + + @Override + public View newView(Context context, Cursor cursor, ViewGroup parent) { + return mInflater.inflate(R.layout.api_apps_adapter_list_item, null); + } + } + +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsAdapter.java deleted file mode 100644 index c846343ab..000000000 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsAdapter.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2013 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.remote.ui; - -import android.content.Context; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.database.Cursor; -import android.support.v4.widget.CursorAdapter; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.ImageView; -import android.widget.TextView; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; - -public class RegisteredAppsAdapter extends CursorAdapter { - - private LayoutInflater mInflater; - private PackageManager mPM; - - public RegisteredAppsAdapter(Context context, Cursor c, int flags) { - super(context, c, flags); - - mInflater = LayoutInflater.from(context); - mPM = context.getApplicationContext().getPackageManager(); - } - - @Override - public void bindView(View view, Context context, Cursor cursor) { - TextView text = (TextView) view.findViewById(R.id.api_apps_adapter_item_name); - ImageView icon = (ImageView) view.findViewById(R.id.api_apps_adapter_item_icon); - - String packageName = cursor.getString(cursor.getColumnIndex(ApiApps.PACKAGE_NAME)); - if (packageName != null) { - // get application name - try { - ApplicationInfo ai = mPM.getApplicationInfo(packageName, 0); - - text.setText(mPM.getApplicationLabel(ai)); - icon.setImageDrawable(mPM.getApplicationIcon(ai)); - } catch (final NameNotFoundException e) { - // fallback - text.setText(packageName); - } - } else { - // fallback - text.setText(packageName); - } - - } - - @Override - public View newView(Context context, Cursor cursor, ViewGroup parent) { - return mInflater.inflate(R.layout.api_apps_adapter_list_item, null); - } - -} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsListActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsListActivity.java deleted file mode 100644 index 79b3c8abc..000000000 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsListActivity.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2013 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.remote.ui; - -import android.os.Bundle; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.ui.DrawerActivity; - -public class RegisteredAppsListActivity extends DrawerActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - setContentView(R.layout.api_apps_list_activity); - - setupDrawerNavigation(savedInstanceState); - } - -} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsListFragment.java deleted file mode 100644 index 99e73e510..000000000 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RegisteredAppsListFragment.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (C) 2013 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.remote.ui; - -import android.content.ContentUris; -import android.content.Intent; -import android.database.Cursor; -import android.net.Uri; -import android.os.Bundle; -import android.support.v4.app.ListFragment; -import android.support.v4.app.LoaderManager; -import android.support.v4.content.CursorLoader; -import android.support.v4.content.Loader; -import android.view.View; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemClickListener; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.provider.KeychainContract; -import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; - -public class RegisteredAppsListFragment extends ListFragment implements - LoaderManager.LoaderCallbacks { - - // This is the Adapter being used to display the list's data. - RegisteredAppsAdapter mAdapter; - - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - - getListView().setOnItemClickListener(new OnItemClickListener() { - @Override - public void onItemClick(AdapterView adapterView, View view, int position, long id) { - // edit app settings - Intent intent = new Intent(getActivity(), AppSettingsActivity.class); - intent.setData(ContentUris.withAppendedId(KeychainContract.ApiApps.CONTENT_URI, id)); - startActivity(intent); - } - }); - - // Give some text to display if there is no data. In a real - // application this would come from a resource. - setEmptyText(getString(R.string.api_no_apps)); - - // We have a menu item to show in action bar. - setHasOptionsMenu(true); - - // Create an empty adapter we will use to display the loaded data. - mAdapter = new RegisteredAppsAdapter(getActivity(), null, 0); - setListAdapter(mAdapter); - - // Prepare the loader. Either re-connect with an existing one, - // or start a new one. - getLoaderManager().initLoader(0, null, this); - } - - // These are the Contacts rows that we will retrieve. - static final String[] PROJECTION = new String[]{ApiApps._ID, ApiApps.PACKAGE_NAME}; - - public Loader onCreateLoader(int id, Bundle args) { - // This is called when a new Loader needs to be created. This - // sample only has one Loader, so we don't care about the ID. - // First, pick the base URI to use depending on whether we are - // currently filtering. - Uri baseUri = ApiApps.CONTENT_URI; - - // Now create and return a CursorLoader that will take care of - // creating a Cursor for the data being displayed. - return new CursorLoader(getActivity(), baseUri, PROJECTION, null, null, - ApiApps.PACKAGE_NAME + " COLLATE LOCALIZED ASC"); - } - - public void onLoadFinished(Loader loader, Cursor data) { - // Swap the new cursor in. (The framework will take care of closing the - // old cursor once we return.) - mAdapter.swapCursor(data); - } - - public void onLoaderReset(Loader loader) { - // This is called when the last Cursor provided to onLoadFinished() - // above is about to be closed. We need to make sure we are no - // longer using it. - mAdapter.swapCursor(null); - } - -} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java index 3e19a8ef6..a088ad4b0 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java @@ -24,6 +24,7 @@ import android.os.Message; import android.os.Messenger; import android.support.v7.app.ActionBarActivity; import android.view.View; + import org.openintents.openpgp.util.OpenPgpApi; import org.sufficientlysecure.htmltextview.HtmlTextView; import org.sufficientlysecure.keychain.Constants; @@ -31,7 +32,9 @@ import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.ActionBarHelper; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; +import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.remote.AccountSettings; import org.sufficientlysecure.keychain.remote.AppSettings; import org.sufficientlysecure.keychain.ui.SelectPublicKeyFragment; import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; @@ -42,6 +45,8 @@ import java.util.ArrayList; public class RemoteServiceActivity extends ActionBarActivity { public static final String ACTION_REGISTER = Constants.INTENT_PREFIX + "API_ACTIVITY_REGISTER"; + public static final String ACTION_REGISTER_ACCOUNT = Constants.INTENT_PREFIX + + "API_ACTIVITY_REGISTER_ACCOUNT"; public static final String ACTION_CACHE_PASSPHRASE = Constants.INTENT_PREFIX + "API_ACTIVITY_CACHE_PASSPHRASE"; public static final String ACTION_SELECT_PUB_KEYS = Constants.INTENT_PREFIX @@ -58,6 +63,8 @@ public class RemoteServiceActivity extends ActionBarActivity { // register action public static final String EXTRA_PACKAGE_NAME = "package_name"; public static final String EXTRA_PACKAGE_SIGNATURE = "package_signature"; + // create acc action + public static final String EXTRA_ACC_NAME = "acc_name"; // select pub keys action public static final String EXTRA_SELECTED_MASTER_KEY_IDS = "master_key_ids"; public static final String EXTRA_MISSING_USER_IDS = "missing_user_ids"; @@ -66,7 +73,9 @@ public class RemoteServiceActivity extends ActionBarActivity { public static final String EXTRA_ERROR_MESSAGE = "error_message"; // register view - private AppSettingsFragment mSettingsFragment; + private AppSettingsFragment mAppSettingsFragment; + // create acc view + private AccountSettingsFragment mAccSettingsFragment; // select pub keys view private SelectPublicKeyFragment mSelectFragment; @@ -95,13 +104,52 @@ public class RemoteServiceActivity extends ActionBarActivity { public void onClick(View v) { // Allow + ProviderHelper.insertApiApp(RemoteServiceActivity.this, + mAppSettingsFragment.getAppSettings()); + + // give data through for new service call + Intent resultData = extras.getParcelable(EXTRA_DATA); + RemoteServiceActivity.this.setResult(RESULT_OK, resultData); + RemoteServiceActivity.this.finish(); + } + }, R.string.api_register_disallow, R.drawable.ic_action_cancel, + new View.OnClickListener() { + @Override + public void onClick(View v) { + // Disallow + RemoteServiceActivity.this.setResult(RESULT_CANCELED); + RemoteServiceActivity.this.finish(); + } + } + ); + + setContentView(R.layout.api_app_register_activity); + + mAppSettingsFragment = (AppSettingsFragment) getSupportFragmentManager().findFragmentById( + R.id.api_app_settings_fragment); + + AppSettings settings = new AppSettings(packageName, packageSignature); + mAppSettingsFragment.setAppSettings(settings); + } else if (ACTION_REGISTER_ACCOUNT.equals(action)) { + final String packageName = extras.getString(EXTRA_PACKAGE_NAME); + final String accName = extras.getString(EXTRA_ACC_NAME); + + // Inflate a "Done"/"Cancel" custom action bar view + ActionBarHelper.setTwoButtonView(getSupportActionBar(), + R.string.api_settings_save, R.drawable.ic_action_done, + new View.OnClickListener() { + @Override + public void onClick(View v) { + // Save + // user needs to select a key! - if (mSettingsFragment.getAppSettings().getKeyId() == Id.key.none) { - mSettingsFragment.setErrorOnSelectKeyFragment( + if (mAccSettingsFragment.getAccSettings().getKeyId() == Id.key.none) { + mAccSettingsFragment.setErrorOnSelectKeyFragment( getString(R.string.api_register_error_select_key)); } else { - ProviderHelper.insertApiApp(RemoteServiceActivity.this, - mSettingsFragment.getAppSettings()); + ProviderHelper.insertApiAccount(RemoteServiceActivity.this, + KeychainContract.ApiAccounts.buildBaseUri(packageName), + mAccSettingsFragment.getAccSettings()); // give data through for new service call Intent resultData = extras.getParcelable(EXTRA_DATA); @@ -109,24 +157,24 @@ public class RemoteServiceActivity extends ActionBarActivity { RemoteServiceActivity.this.finish(); } } - }, R.string.api_register_disallow, R.drawable.ic_action_cancel, - new View.OnClickListener() { - @Override - public void onClick(View v) { - // Disallow - RemoteServiceActivity.this.setResult(RESULT_CANCELED); - RemoteServiceActivity.this.finish(); - } + }, R.string.api_settings_cancel, R.drawable.ic_action_cancel, + new View.OnClickListener() { + @Override + public void onClick(View v) { + // Cancel + RemoteServiceActivity.this.setResult(RESULT_CANCELED); + RemoteServiceActivity.this.finish(); + } } ); - setContentView(R.layout.api_app_register_activity); + setContentView(R.layout.api_account_create_activity); - mSettingsFragment = (AppSettingsFragment) getSupportFragmentManager().findFragmentById( - R.id.api_app_settings_fragment); + mAccSettingsFragment = (AccountSettingsFragment) getSupportFragmentManager().findFragmentById( + R.id.api_account_settings_fragment); - AppSettings settings = new AppSettings(packageName, packageSignature); - mSettingsFragment.setAppSettings(settings); + AccountSettings settings = new AccountSettings(accName); + mAccSettingsFragment.setAccSettings(settings); } else if (ACTION_CACHE_PASSPHRASE.equals(action)) { long secretKeyId = extras.getLong(EXTRA_SECRET_KEY_ID); Intent resultData = extras.getParcelable(EXTRA_DATA); diff --git a/OpenPGP-Keychain/src/main/res/layout/api_account_create_activity.xml b/OpenPGP-Keychain/src/main/res/layout/api_account_create_activity.xml new file mode 100644 index 000000000..ead336dbb --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/api_account_create_activity.xml @@ -0,0 +1,21 @@ + + + + + + + + + diff --git a/OpenPGP-Keychain/src/main/res/layout/api_account_settings_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/api_account_settings_fragment.xml new file mode 100644 index 000000000..ff560b657 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/api_account_settings_fragment.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/api_app_register_activity.xml b/OpenPGP-Keychain/src/main/res/layout/api_app_register_activity.xml index aa9d59004..f85f3b8f7 100644 --- a/OpenPGP-Keychain/src/main/res/layout/api_app_register_activity.xml +++ b/OpenPGP-Keychain/src/main/res/layout/api_app_register_activity.xml @@ -20,7 +20,7 @@ diff --git a/OpenPGP-Keychain/src/main/res/layout/api_app_settings_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/api_app_settings_fragment.xml index a7917ad4e..b91025474 100644 --- a/OpenPGP-Keychain/src/main/res/layout/api_app_settings_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/api_app_settings_fragment.xml @@ -36,13 +36,6 @@ android:textAppearance="?android:attr/textAppearanceMedium" /> - - - - - - - - - - - - - - \ No newline at end of file -- cgit v1.2.3 From cff35ca84283202d1a0b824b6eb9eaf4231c061a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 25 Mar 2014 21:23:59 +0100 Subject: More experimental work on api accounts --- .../keychain/provider/KeychainContract.java | 11 ++-- .../keychain/provider/KeychainProvider.java | 61 +++++----------------- .../keychain/remote/ui/AccountsListFragment.java | 44 ++++++++-------- .../keychain/remote/ui/AppSettingsActivity.java | 32 +++++++++++- .../keychain/remote/ui/AppsListFragment.java | 30 +++++++++-- .../res/layout/api_account_settings_fragment.xml | 4 +- .../main/res/layout/api_app_settings_activity.xml | 16 +++++- .../main/res/layout/api_app_settings_fragment.xml | 4 +- OpenPGP-Keychain/src/main/res/values/strings.xml | 4 ++ 9 files changed, 120 insertions(+), 86 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java index 6e7b76fbe..98ce98495 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java @@ -95,8 +95,6 @@ public class KeychainContract { public static final String BASE_API_APPS = "api_apps"; public static final String PATH_ACCOUNTS = "accounts"; - public static final String PATH_BY_PACKAGE_NAME = "package_name"; - public static class KeyRings implements KeyRingsColumns, BaseColumns { public static final Uri CONTENT_URI = BASE_CONTENT_URI_INTERNAL.buildUpon() .appendPath(BASE_KEY_RINGS).build(); @@ -272,13 +270,12 @@ public class KeychainContract { */ public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.api.apps"; - public static Uri buildIdUri(String rowId) { - return CONTENT_URI.buildUpon().appendPath(rowId).build(); - } +// public static Uri buildIdUri(String rowId) { +// return CONTENT_URI.buildUpon().appendPath(rowId).build(); +// } public static Uri buildByPackageNameUri(String packageName) { - return CONTENT_URI.buildUpon().appendPath(PATH_BY_PACKAGE_NAME) - .appendEncodedPath(packageName).build(); + return CONTENT_URI.buildUpon().appendEncodedPath(packageName).build(); } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java index cae76003c..005be2fd6 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java @@ -80,10 +80,8 @@ public class KeychainProvider extends ContentProvider { private static final int SECRET_KEY_RING_USER_ID_BY_ROW_ID = 222; private static final int API_APPS = 301; - private static final int API_APPS_BY_ROW_ID = 302; private static final int API_APPS_BY_PACKAGE_NAME = 303; private static final int API_ACCOUNTS = 304; - private static final int API_ACCOUNTS_BY_ROW_ID = 305; private static final int API_ACCOUNTS_BY_ACCOUNT_NAME = 306; private static final int UNIFIED_KEY_RING = 401; @@ -241,19 +239,22 @@ public class KeychainProvider extends ContentProvider { /** * API apps + * + *
    +         * api_apps
    +         * api_apps/_
    +         *
    +         * api_apps/_/accounts
    +         * api_apps/_/accounts/_
    +         * 
    */ matcher.addURI(authority, KeychainContract.BASE_API_APPS, API_APPS); - matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/#", API_APPS_BY_ROW_ID); - matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/" - + KeychainContract.PATH_BY_PACKAGE_NAME + "/*", API_APPS_BY_PACKAGE_NAME); + matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/*", API_APPS_BY_PACKAGE_NAME); - matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/" + matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/*/" + KeychainContract.PATH_ACCOUNTS, API_ACCOUNTS); - matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/" - + KeychainContract.PATH_ACCOUNTS + "/#", API_ACCOUNTS_BY_ROW_ID); - matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/" - + KeychainContract.PATH_ACCOUNTS + "/" - + KeychainContract.PATH_BY_PACKAGE_NAME + "/*", API_ACCOUNTS_BY_ACCOUNT_NAME); + matcher.addURI(authority, KeychainContract.BASE_API_APPS + "/*/" + + KeychainContract.PATH_ACCOUNTS + "/*", API_ACCOUNTS_BY_ACCOUNT_NAME); /** * data stream @@ -322,14 +323,12 @@ public class KeychainProvider extends ContentProvider { case API_APPS: return ApiApps.CONTENT_TYPE; - case API_APPS_BY_ROW_ID: case API_APPS_BY_PACKAGE_NAME: return ApiApps.CONTENT_ITEM_TYPE; case API_ACCOUNTS: return ApiAccounts.CONTENT_TYPE; - case API_ACCOUNTS_BY_ROW_ID: case API_ACCOUNTS_BY_ACCOUNT_NAME: return ApiAccounts.CONTENT_ITEM_TYPE; @@ -679,13 +678,6 @@ public class KeychainProvider extends ContentProvider { case API_APPS: qb.setTables(Tables.API_APPS); - break; - case API_APPS_BY_ROW_ID: - qb.setTables(Tables.API_APPS); - - qb.appendWhere(BaseColumns._ID + " = "); - qb.appendWhereEscapeString(uri.getLastPathSegment()); - break; case API_APPS_BY_PACKAGE_NAME: qb.setTables(Tables.API_APPS); @@ -696,17 +688,6 @@ public class KeychainProvider extends ContentProvider { case API_ACCOUNTS: qb.setTables(Tables.API_ACCOUNTS); - break; - case API_ACCOUNTS_BY_ROW_ID: - qb.setTables(Tables.API_ACCOUNTS + " INNER JOIN " + Tables.API_APPS + " ON " + "(" - + Tables.API_APPS + "." + ApiApps.PACKAGE_NAME + " = " + Tables.API_ACCOUNTS + "." - + ApiAccounts.PACKAGE_NAME_FK + " )"); - qb.appendWhere(Tables.API_APPS + "." + BaseColumns._ID + " = "); - qb.appendWhereEscapeString(uri.getPathSegments().get(2)); - - qb.appendWhere(" AND " + Tables.API_ACCOUNTS + "." + BaseColumns._ID + " = "); - qb.appendWhereEscapeString(uri.getLastPathSegment()); - break; case API_ACCOUNTS_BY_ACCOUNT_NAME: qb.setTables(Tables.API_ACCOUNTS + " INNER JOIN " + Tables.API_APPS + " ON " + "(" @@ -812,7 +793,7 @@ public class KeychainProvider extends ContentProvider { break; case API_APPS: rowId = db.insertOrThrow(Tables.API_APPS, null, values); - rowUri = ApiApps.buildIdUri(Long.toString(rowId)); +// rowUri = ApiApps.buildIdUri(Long.toString(rowId)); break; case API_ACCOUNTS: @@ -878,18 +859,10 @@ public class KeychainProvider extends ContentProvider { count = db.delete(Tables.KEYS, buildDefaultUserIdsSelection(uri, selection), selectionArgs); break; - case API_APPS_BY_ROW_ID: - count = db.delete(Tables.API_APPS, buildDefaultApiAppsSelection(uri, false, selection), - selectionArgs); - break; case API_APPS_BY_PACKAGE_NAME: count = db.delete(Tables.API_APPS, buildDefaultApiAppsSelection(uri, true, selection), selectionArgs); break; - case API_ACCOUNTS_BY_ROW_ID: - count = db.delete(Tables.API_ACCOUNTS, buildDefaultApiAccountsSelection(uri, false, selection), - selectionArgs); - break; case API_ACCOUNTS_BY_ACCOUNT_NAME: count = db.delete(Tables.API_ACCOUNTS, buildDefaultApiAccountsSelection(uri, true, selection), selectionArgs); @@ -956,18 +929,10 @@ public class KeychainProvider extends ContentProvider { count = db.update(Tables.USER_IDS, values, buildDefaultUserIdsSelection(uri, selection), selectionArgs); break; - case API_APPS_BY_ROW_ID: - count = db.update(Tables.API_APPS, values, - buildDefaultApiAppsSelection(uri, false, selection), selectionArgs); - break; case API_APPS_BY_PACKAGE_NAME: count = db.update(Tables.API_APPS, values, buildDefaultApiAppsSelection(uri, true, selection), selectionArgs); break; - case API_ACCOUNTS_BY_ROW_ID: - count = db.update(Tables.API_ACCOUNTS, values, - buildDefaultApiAccountsSelection(uri, false, selection), selectionArgs); - break; case API_ACCOUNTS_BY_ACCOUNT_NAME: count = db.update(Tables.API_ACCOUNTS, values, buildDefaultApiAccountsSelection(uri, true, selection), selectionArgs); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java index 0cec319a5..853dc2d3c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java @@ -19,10 +19,7 @@ package org.sufficientlysecure.keychain.remote.ui; import android.annotation.TargetApi; import android.content.ContentUris; -import android.content.Context; import android.content.Intent; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; import android.database.Cursor; import android.net.Uri; import android.os.Build; @@ -31,15 +28,10 @@ import android.support.v4.app.ListFragment; import android.support.v4.app.LoaderManager; import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; -import android.support.v4.widget.CursorAdapter; -import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; -import android.widget.ImageView; import android.widget.SimpleCursorAdapter; -import android.widget.TextView; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.provider.KeychainContract; @@ -50,36 +42,46 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; public class AccountsListFragment extends ListFragment implements LoaderManager.LoaderCallbacks { + private static final String ARG_DATA_URI = "uri"; + // This is the Adapter being used to display the list's data. SimpleCursorAdapter mAdapter; - private String mPackageName; + private Uri mDataUri; - public String getPackageName() { - return mPackageName; - } + /** + * Creates new instance of this fragment + */ + public static AccountsListFragment newInstance(Uri dataUri) { + AccountsListFragment frag = new AccountsListFragment(); + + Bundle args = new Bundle(); + args.putParcelable(ARG_DATA_URI, dataUri); - public void setPackageName(String packageName) { - this.mPackageName = packageName; + frag.setArguments(args); + + return frag; } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); + mDataUri = getArguments().getParcelable(ARG_DATA_URI); + getListView().setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView adapterView, View view, int position, long id) { - // edit app settings - Intent intent = new Intent(getActivity(), AppSettingsActivity.class); - intent.setData(ContentUris.withAppendedId(ApiApps.CONTENT_URI, id)); - startActivity(intent); +// // edit app settings +// Intent intent = new Intent(getActivity(), AppSettingsActivity.class); +// intent.setData(ContentUris.withAppendedId(ApiApps.CONTENT_URI, id)); +// startActivity(intent); } }); // Give some text to display if there is no data. In a real // application this would come from a resource. - setEmptyText(getString(R.string.api_no_apps)); + setEmptyText(getString(R.string.api_settings_accounts_empty)); // We have a menu item to show in action bar. setHasOptionsMenu(true); @@ -108,11 +110,11 @@ public class AccountsListFragment extends ListFragment implements // sample only has one Loader, so we don't care about the ID. // First, pick the base URI to use depending on whether we are // currently filtering. - Uri baseUri = KeychainContract.ApiAccounts.buildBaseUri(mPackageName); +// Uri baseUri = KeychainContract.ApiAccounts.buildBaseUri(mPackageName); // Now create and return a CursorLoader that will take care of // creating a Cursor for the data being displayed. - return new CursorLoader(getActivity(), baseUri, PROJECTION, null, null, + return new CursorLoader(getActivity(), mDataUri, PROJECTION, null, null, KeychainContract.ApiAccounts.ACCOUNT_NAME + " COLLATE LOCALIZED ASC"); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java index d544455ec..33cde49ba 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java @@ -24,9 +24,11 @@ import android.support.v7.app.ActionBarActivity; import android.view.Menu; import android.view.MenuItem; import android.view.View; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.ActionBarHelper; +import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.remote.AppSettings; import org.sufficientlysecure.keychain.util.Log; @@ -35,6 +37,7 @@ public class AppSettingsActivity extends ActionBarActivity { private Uri mAppUri; private AppSettingsFragment mSettingsFragment; + private AccountsListFragment mAccountsListFragment; @Override protected void onCreate(Bundle savedInstanceState) { @@ -64,7 +67,7 @@ public class AppSettingsActivity extends ActionBarActivity { return; } else { Log.d(Constants.TAG, "uri: " + mAppUri); - loadData(mAppUri); + loadData(savedInstanceState, mAppUri); } } @@ -88,9 +91,34 @@ public class AppSettingsActivity extends ActionBarActivity { return super.onOptionsItemSelected(item); } - private void loadData(Uri appUri) { + private void loadData(Bundle savedInstanceState, Uri appUri) { + // TODO: load this also like other fragment with newInstance arguments? AppSettings settings = ProviderHelper.getApiAppSettings(this, appUri); mSettingsFragment.setAppSettings(settings); + + Uri accountsUri = appUri.buildUpon().appendPath(KeychainContract.PATH_ACCOUNTS).build(); + Log.d(Constants.TAG, "accountsUri: " + accountsUri); + startListFragment(savedInstanceState, accountsUri); + } + + private void startListFragment(Bundle savedInstanceState, Uri dataUri) { + // However, if we're being restored from a previous state, + // then we don't need to do anything and should return or else + // we could end up with overlapping fragments. + if (savedInstanceState != null) { + return; + } + + // Create an instance of the fragment + mAccountsListFragment = AccountsListFragment.newInstance(dataUri); + + // Add the fragment to the 'fragment_container' FrameLayout + // NOTE: We use commitAllowingStateLoss() to prevent weird crashes! + getSupportFragmentManager().beginTransaction() + .replace(R.id.api_accounts_list_fragment, mAccountsListFragment) + .commitAllowingStateLoss(); + // do it immediately! + getSupportFragmentManager().executePendingTransactions(); } private void revokeAccess() { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java index 7054a2195..f3fa6e7c6 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java @@ -17,7 +17,6 @@ package org.sufficientlysecure.keychain.remote.ui; -import android.content.ContentUris; import android.content.Context; import android.content.Intent; import android.content.pm.ApplicationInfo; @@ -38,9 +37,11 @@ import android.widget.AdapterView.OnItemClickListener; import android.widget.ImageView; import android.widget.TextView; +import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; +import org.sufficientlysecure.keychain.util.Log; public class AppsListFragment extends ListFragment implements LoaderManager.LoaderCallbacks { @@ -55,9 +56,10 @@ public class AppsListFragment extends ListFragment implements getListView().setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView adapterView, View view, int position, long id) { + String selectedPackageName = mAdapter.getItemPackageName(position); // edit app settings Intent intent = new Intent(getActivity(), AppSettingsActivity.class); - intent.setData(ContentUris.withAppendedId(KeychainContract.ApiApps.CONTENT_URI, id)); + intent.setData(KeychainContract.ApiApps.buildByPackageNameUri(selectedPackageName)); startActivity(intent); } }); @@ -79,7 +81,10 @@ public class AppsListFragment extends ListFragment implements } // These are the Contacts rows that we will retrieve. - static final String[] PROJECTION = new String[]{ApiApps._ID, ApiApps.PACKAGE_NAME}; + static final String[] PROJECTION = new String[]{ + ApiApps._ID, // 0 + ApiApps.PACKAGE_NAME // 1 + }; public Loader onCreateLoader(int id, Bundle args) { // This is called when a new Loader needs to be created. This @@ -119,6 +124,25 @@ public class AppsListFragment extends ListFragment implements mPM = context.getApplicationContext().getPackageManager(); } + /** + * Similar to CursorAdapter.getItemId(). + * Required to build Uris for api app view, which is not based on row ids + * + * @param position + * @return + */ + public String getItemPackageName(int position) { + if (mDataValid && mCursor != null) { + if (mCursor.moveToPosition(position)) { + return mCursor.getString(1); + } else { + return null; + } + } else { + return null; + } + } + @Override public void bindView(View view, Context context, Cursor cursor) { TextView text = (TextView) view.findViewById(R.id.api_apps_adapter_item_name); diff --git a/OpenPGP-Keychain/src/main/res/layout/api_account_settings_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/api_account_settings_fragment.xml index ff560b657..3284b5b0a 100644 --- a/OpenPGP-Keychain/src/main/res/layout/api_account_settings_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/api_account_settings_fragment.xml @@ -46,8 +46,8 @@ diff --git a/OpenPGP-Keychain/src/main/res/layout/api_app_settings_activity.xml b/OpenPGP-Keychain/src/main/res/layout/api_app_settings_activity.xml index d83c8e87d..d38567497 100644 --- a/OpenPGP-Keychain/src/main/res/layout/api_app_settings_activity.xml +++ b/OpenPGP-Keychain/src/main/res/layout/api_app_settings_activity.xml @@ -12,10 +12,24 @@ + + + + diff --git a/OpenPGP-Keychain/src/main/res/layout/api_app_settings_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/api_app_settings_fragment.xml index b91025474..96271d418 100644 --- a/OpenPGP-Keychain/src/main/res/layout/api_app_settings_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/api_app_settings_fragment.xml @@ -39,8 +39,8 @@ diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index 11e3028f3..5bf7ca8ca 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -412,6 +412,8 @@ No registered applications!\n\nThird-party applications can request access to OpenKeychain. After granting access, they will be listed here. + Show advanced information + Hide advanced information Show advanced settings Hide advanced settings No key selected @@ -421,6 +423,8 @@ Revoke access Package Name SHA-256 of Package Signature + Accounts + No accounts attached to this application. The displayed application requests access to OpenKeychain.\nAllow access?\n\nWARNING: If you do not know why this screen appeared, disallow access! You can revoke access later using the \'Registered Applications\' screen. Allow access Disallow access -- cgit v1.2.3 From 8c496d3393188559c4ce86d5ac4e3a9b1b2bdff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 25 Mar 2014 21:52:06 +0100 Subject: Fix update and insert for new api content provider --- .../keychain/provider/KeychainProvider.java | 32 ++++++++++------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java index 005be2fd6..1f725266e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java @@ -27,6 +27,7 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri; import android.provider.BaseColumns; +import android.support.v4.database.DatabaseUtilsCompat; import android.text.TextUtils; import org.sufficientlysecure.keychain.Constants; @@ -860,11 +861,11 @@ public class KeychainProvider extends ContentProvider { selectionArgs); break; case API_APPS_BY_PACKAGE_NAME: - count = db.delete(Tables.API_APPS, buildDefaultApiAppsSelection(uri, true, selection), + count = db.delete(Tables.API_APPS, buildDefaultApiAppsSelection(uri, selection), selectionArgs); break; case API_ACCOUNTS_BY_ACCOUNT_NAME: - count = db.delete(Tables.API_ACCOUNTS, buildDefaultApiAccountsSelection(uri, true, selection), + count = db.delete(Tables.API_ACCOUNTS, buildDefaultApiAccountsSelection(uri, selection), selectionArgs); break; default: @@ -931,11 +932,11 @@ public class KeychainProvider extends ContentProvider { break; case API_APPS_BY_PACKAGE_NAME: count = db.update(Tables.API_APPS, values, - buildDefaultApiAppsSelection(uri, true, selection), selectionArgs); + buildDefaultApiAppsSelection(uri, selection), selectionArgs); break; case API_ACCOUNTS_BY_ACCOUNT_NAME: count = db.update(Tables.API_ACCOUNTS, values, - buildDefaultApiAccountsSelection(uri, true, selection), selectionArgs); + buildDefaultApiAccountsSelection(uri, selection), selectionArgs); break; default: throw new UnsupportedOperationException("Unknown uri: " + uri); @@ -1034,34 +1035,29 @@ public class KeychainProvider extends ContentProvider { * @param selection * @return */ - private String buildDefaultApiAppsSelection(Uri uri, boolean packageSelection, String selection) { - String lastPathSegment = uri.getLastPathSegment(); + private String buildDefaultApiAppsSelection(Uri uri, String selection) { + String packageName = DatabaseUtils.sqlEscapeString(uri.getLastPathSegment()); String andSelection = ""; if (!TextUtils.isEmpty(selection)) { andSelection = " AND (" + selection + ")"; } - if (packageSelection) { - return ApiApps.PACKAGE_NAME + "=" + lastPathSegment + andSelection; - } else { - return BaseColumns._ID + "=" + lastPathSegment + andSelection; - } + return ApiApps.PACKAGE_NAME + "=" + packageName + andSelection; } - private String buildDefaultApiAccountsSelection(Uri uri, boolean packageSelection, String selection) { - String lastPathSegment = uri.getLastPathSegment(); + private String buildDefaultApiAccountsSelection(Uri uri, String selection) { + String packageName = DatabaseUtils.sqlEscapeString(uri.getPathSegments().get(2)); + String accountName = DatabaseUtils.sqlEscapeString(uri.getLastPathSegment()); String andSelection = ""; if (!TextUtils.isEmpty(selection)) { andSelection = " AND (" + selection + ")"; } - if (packageSelection) { - return ApiAccounts.PACKAGE_NAME_FK + "=" + lastPathSegment + andSelection; - } else { - return BaseColumns._ID + "=" + lastPathSegment + andSelection; - } + return ApiAccounts.PACKAGE_NAME_FK + "=" + packageName + " AND " + + ApiAccounts.ACCOUNT_NAME + "=" + accountName + + andSelection; } // @Override -- cgit v1.2.3 From dc9fd1221387a4f31ec2ceba615b376b0796ff10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 25 Mar 2014 23:09:57 +0100 Subject: Return account creation intent if account does not exists in db --- .../keychain/provider/KeychainContract.java | 23 ++------ .../keychain/provider/KeychainProvider.java | 5 +- .../keychain/remote/OpenPgpService.java | 3 + .../keychain/remote/RemoteService.java | 69 +++++++++++++++------- .../keychain/remote/ui/RemoteServiceActivity.java | 6 +- 5 files changed, 60 insertions(+), 46 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java index 98ce98495..6e4899fc2 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java @@ -160,6 +160,7 @@ public class KeychainContract { } public static Uri buildSecretKeyRingsByEmailsUri(String emails) { + // TODO: encoded? return CONTENT_URI.buildUpon().appendPath(PATH_SECRET).appendPath(PATH_BY_EMAILS) .appendPath(emails).build(); } @@ -263,16 +264,12 @@ public class KeychainContract { /** * Use if multiple items get returned */ - public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.api.app"; + public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.api_apps"; /** * Use if a single item is returned */ - public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.api.apps"; - -// public static Uri buildIdUri(String rowId) { -// return CONTENT_URI.buildUpon().appendPath(rowId).build(); -// } + public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.api_app"; public static Uri buildByPackageNameUri(String packageName) { return CONTENT_URI.buildUpon().appendEncodedPath(packageName).build(); @@ -286,22 +283,12 @@ public class KeychainContract { /** * Use if multiple items get returned */ - public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.api.acoounts"; + public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.api_app.accounts"; /** * Use if a single item is returned */ - public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.api.account"; - -// public static Uri buildUri(String rowIdApp) { -// return CONTENT_URI.buildUpon().appendPath(rowIdApp).appendPath(PATH_ACCOUNTS) -// .build(); -// } -// -// public static Uri buildIdUri(String rowIdApp, String rowId) { -// return CONTENT_URI.buildUpon().appendPath(rowIdApp).appendPath(PATH_ACCOUNTS) -// .appendPath(rowId).build(); -// } + public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.api_app.account"; public static Uri buildBaseUri(String packageName) { return CONTENT_URI.buildUpon().appendEncodedPath(packageName).appendPath(PATH_ACCOUNTS) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java index 1f725266e..6e5515cab 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java @@ -27,7 +27,6 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteQueryBuilder; import android.net.Uri; import android.provider.BaseColumns; -import android.support.v4.database.DatabaseUtilsCompat; import android.text.TextUtils; import org.sufficientlysecure.keychain.Constants; @@ -243,10 +242,10 @@ public class KeychainProvider extends ContentProvider { * *
              * api_apps
    -         * api_apps/_
    +         * api_apps/_ (package name)
              *
              * api_apps/_/accounts
    -         * api_apps/_/accounts/_
    +         * api_apps/_/accounts/_ (account name)
              * 
    */ matcher.addURI(authority, KeychainContract.BASE_API_APPS, API_APPS); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java index b04e76cbd..fa6ccf63b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -440,6 +440,9 @@ public class OpenPgpService extends RemoteService { accName = "default"; } final AccountSettings accSettings = getAccSettings(accName); + if (accSettings == null) { + return getCreateAccountIntent(data, accName); + } String action = data.getAction(); if (OpenPgpApi.ACTION_SIGN.equals(action)) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java index 7b66a0b5c..0fd9ee7df 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java @@ -27,6 +27,7 @@ import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.Signature; import android.net.Uri; import android.os.Binder; + import org.openintents.openpgp.OpenPgpError; import org.openintents.openpgp.util.OpenPgpApi; import org.sufficientlysecure.keychain.Constants; @@ -48,7 +49,6 @@ public abstract class RemoteService extends Service { private static final int PRIVATE_REQUEST_CODE_REGISTER = 651; private static final int PRIVATE_REQUEST_CODE_ERROR = 652; - public Context getContext() { return mContext; } @@ -56,13 +56,9 @@ public abstract class RemoteService extends Service { protected Intent isAllowed(Intent data) { try { if (isCallerAllowed(false)) { - return null; } else { - String[] callingPackages = getPackageManager().getPackagesForUid( - Binder.getCallingUid()); - // TODO: currently simply uses first entry - String packageName = callingPackages[0]; + String packageName = getCurrentCallingPackage(); byte[] packageSignature; try { @@ -85,7 +81,7 @@ public abstract class RemoteService extends Service { intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); PendingIntent pi = PendingIntent.getActivity(getBaseContext(), - PRIVATE_REQUEST_CODE_REGISTER, intent, 0); + PRIVATE_REQUEST_CODE_REGISTER, intent, 0); // return PendingIntent to be executed by client Intent result = new Intent(); @@ -100,11 +96,11 @@ public abstract class RemoteService extends Service { Intent intent = new Intent(getBaseContext(), RemoteServiceActivity.class); intent.setAction(RemoteServiceActivity.ACTION_ERROR_MESSAGE); intent.putExtra(RemoteServiceActivity.EXTRA_ERROR_MESSAGE, - getString(R.string.api_error_wrong_signature)); + getString(R.string.api_error_wrong_signature)); intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); PendingIntent pi = PendingIntent.getActivity(getBaseContext(), - PRIVATE_REQUEST_CODE_ERROR, intent, 0); + PRIVATE_REQUEST_CODE_ERROR, intent, 0); // return PendingIntent to be executed by client Intent result = new Intent(); @@ -126,27 +122,56 @@ public abstract class RemoteService extends Service { } /** - * Retrieves AppSettings from database for the application calling this remote service + * Returns package name associated with the UID, which is assigned to the process that sent you the + * current transaction that is being processed :) + * + * @return package name + */ + private String getCurrentCallingPackage() { + // TODO: + // callingPackages contains more than one entry when sharedUserId has been used... + String[] callingPackages = getPackageManager().getPackagesForUid(Binder.getCallingUid()); + String currentPkg = callingPackages[0]; + Log.d(Constants.TAG, "currentPkg: " + currentPkg); + + return currentPkg; + } + + /** + * Retrieves AccountSettings from database for the application calling this remote service * * @return */ protected AccountSettings getAccSettings(String accountName) { - String[] callingPackages = getPackageManager().getPackagesForUid(Binder.getCallingUid()); + String currentPkg = getCurrentCallingPackage(); + Log.d(Constants.TAG, "accountName: " + accountName); - // get app settings for this package - for (int i = 0; i < callingPackages.length; i++) { - String currentPkg = callingPackages[i]; + Uri uri = KeychainContract.ApiAccounts.buildByPackageAndAccountUri(currentPkg, accountName); - Uri uri = KeychainContract.ApiAccounts.buildByPackageAndAccountUri(currentPkg, accountName); + AccountSettings settings = ProviderHelper.getApiAccountSettings(this, uri); - AccountSettings settings = ProviderHelper.getApiAccountSettings(this, uri); + return settings; // can be null! + } - if (settings != null) { - return settings; - } - } + protected Intent getCreateAccountIntent(Intent data, String accountName) { + String packageName = getCurrentCallingPackage(); + Log.d(Constants.TAG, "accountName: " + accountName); + + Intent intent = new Intent(getBaseContext(), RemoteServiceActivity.class); + intent.setAction(RemoteServiceActivity.ACTION_CREATE_ACCOUNT); + intent.putExtra(RemoteServiceActivity.EXTRA_PACKAGE_NAME, packageName); + intent.putExtra(RemoteServiceActivity.EXTRA_ACC_NAME, accountName); + intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); + + PendingIntent pi = PendingIntent.getActivity(getBaseContext(), + PRIVATE_REQUEST_CODE_REGISTER, intent, 0); + + // return PendingIntent to be executed by client + Intent result = new Intent(); + result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED); + result.putExtra(OpenPgpApi.RESULT_INTENT, pi); - return null; + return result; } /** @@ -217,7 +242,7 @@ public abstract class RemoteService extends Service { return true; } else { throw new WrongPackageSignatureException( - "PACKAGE NOT ALLOWED! Signature wrong! (Signature not equals signature from database)"); + "PACKAGE NOT ALLOWED! Signature wrong! (Signature not equals signature from database)"); } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java index a088ad4b0..d3ac5cade 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java @@ -45,8 +45,8 @@ import java.util.ArrayList; public class RemoteServiceActivity extends ActionBarActivity { public static final String ACTION_REGISTER = Constants.INTENT_PREFIX + "API_ACTIVITY_REGISTER"; - public static final String ACTION_REGISTER_ACCOUNT = Constants.INTENT_PREFIX - + "API_ACTIVITY_REGISTER_ACCOUNT"; + public static final String ACTION_CREATE_ACCOUNT = Constants.INTENT_PREFIX + + "API_ACTIVITY_CREATE_ACCOUNT"; public static final String ACTION_CACHE_PASSPHRASE = Constants.INTENT_PREFIX + "API_ACTIVITY_CACHE_PASSPHRASE"; public static final String ACTION_SELECT_PUB_KEYS = Constants.INTENT_PREFIX @@ -130,7 +130,7 @@ public class RemoteServiceActivity extends ActionBarActivity { AppSettings settings = new AppSettings(packageName, packageSignature); mAppSettingsFragment.setAppSettings(settings); - } else if (ACTION_REGISTER_ACCOUNT.equals(action)) { + } else if (ACTION_CREATE_ACCOUNT.equals(action)) { final String packageName = extras.getString(EXTRA_PACKAGE_NAME); final String accName = extras.getString(EXTRA_ACC_NAME); -- cgit v1.2.3 From 0edfd7ed48943607ebaaa1dd2c9b1018ace0b024 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 25 Mar 2014 23:25:03 +0100 Subject: Temporary fix for inserting by content provider --- .../sufficientlysecure/keychain/provider/KeychainProvider.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java index 6e5515cab..a5ee723f0 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java @@ -757,14 +757,14 @@ public class KeychainProvider extends ContentProvider { rowId = db.insertOrThrow(Tables.KEYS, null, values); // TODO: this is wrong: -// rowUri = Keys.buildPublicKeysUri(Long.toString(rowId)); + rowUri = Keys.buildPublicKeysUri(Long.toString(rowId)); sendBroadcastDatabaseChange(getKeyType(match), getType(uri)); break; case PUBLIC_KEY_RING_USER_ID: rowId = db.insertOrThrow(Tables.USER_IDS, null, values); // TODO: this is wrong: -// rowUri = UserIds.buildPublicUserIdsUri(Long.toString(rowId)); + rowUri = UserIds.buildPublicUserIdsUri(Long.toString(rowId)); sendBroadcastDatabaseChange(getKeyType(match), getType(uri)); break; @@ -781,14 +781,14 @@ public class KeychainProvider extends ContentProvider { rowId = db.insertOrThrow(Tables.KEYS, null, values); // TODO: this is wrong: -// rowUri = Keys.buildSecretKeysUri(Long.toString(rowId)); + rowUri = Keys.buildSecretKeysUri(Long.toString(rowId)); sendBroadcastDatabaseChange(getKeyType(match), getType(uri)); break; case SECRET_KEY_RING_USER_ID: rowId = db.insertOrThrow(Tables.USER_IDS, null, values); // TODO: this is wrong: -// rowUri = UserIds.buildSecretUserIdsUri(Long.toString(rowId)); + rowUri = UserIds.buildSecretUserIdsUri(Long.toString(rowId)); break; case API_APPS: -- cgit v1.2.3 From 68f035ff88131928cdd0681ba3b1fb4980d9a574 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Tue, 25 Mar 2014 22:28:32 +0000 Subject: allow lists to be subkeys or keyrings --- .../keychain/pgp/PgpConversionHelper.java | 29 +++++++++++++++++----- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java index 20d446824..c7dd7d647 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java @@ -59,13 +59,30 @@ public class PgpConversionHelper { * @return */ public static ArrayList BytesToPGPSecretKeyList(byte[] keysBytes) { - PGPSecretKeyRing keyRing = (PGPSecretKeyRing) BytesToPGPKeyRing(keysBytes); + PGPObjectFactory factory = new PGPObjectFactory(keysBytes); + Object obj = null; ArrayList keys = new ArrayList(); - - @SuppressWarnings("unchecked") - Iterator itr = keyRing.getSecretKeys(); - while (itr.hasNext()) { - keys.add(itr.next()); + try { + while ((obj = factory.nextObject()) != null) { + PGPSecretKey secKey = null; + if(obj instanceof PGPSecretKey) { + if ((secKey = (PGPSecretKey)obj ) == null) { + Log.e(Constants.TAG, "No keys given!"); + } + keys.add(secKey); + } else if(obj instanceof PGPSecretKeyRing) { //master keys are sent as keyrings + PGPSecretKeyRing keyRing = null; + if ((keyRing = (PGPSecretKeyRing)obj) == null) { + Log.e(Constants.TAG, "No keys given!"); + } + @SuppressWarnings("unchecked") + Iterator itr = keyRing.getSecretKeys(); + while (itr.hasNext()) { + keys.add(itr.next()); + } + } + } + } catch (IOException e) { } return keys; -- cgit v1.2.3 From 259a8a63a2efa587c6cbe23ae929d7f8c9478664 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Tue, 25 Mar 2014 22:40:05 +0000 Subject: delete IDs needs to update keyring, flag it --- .../main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index fab456bf8..370f66388 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -405,12 +405,13 @@ public class PgpKeyOperation { updateProgress(R.string.progress_certifying_master_key, 20, 100); + boolean anyIDChanged = false; for (String delID : saveParcel.deletedIDs) { + anyIDChanged = true; masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, delID); } int user_id_index = 0; - boolean anyIDChanged = false; PGPSignatureSubpacketGenerator hashedPacketsGen = new PGPSignatureSubpacketGenerator(); PGPSignatureSubpacketGenerator unhashedPacketsGen = new PGPSignatureSubpacketGenerator(); -- cgit v1.2.3 From b77e0504aa1308da36df63038d4c05ca9aaebd71 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Tue, 25 Mar 2014 23:01:17 +0000 Subject: allow master key updates by removing old primary ID cert --- .../java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 370f66388..9bf9ecc73 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -376,6 +376,9 @@ public class PgpKeyOperation { else remove changed IDs and add in with new certs + if the master key changed, we need to remove the primary ID certification, so we can add + the new one when it is generated, and they don't conflict + Keys remove deleted keys if a key is modified, re-sign it @@ -495,6 +498,11 @@ public class PgpKeyOperation { } } + if (saveParcel.moddedKeys[0]) { + masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, saveParcel.originalIDs.get(0)); + anyIDChanged = true; + } + //update the keyring with the new ID information if (anyIDChanged) { pKR = PGPPublicKeyRing.insertPublicKey(pKR, masterPublicKey); -- cgit v1.2.3 From 028af0c1195b2d6a747874af8cae07dde542dc64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 00:11:49 +0100 Subject: Fix constraints and insert --- .../keychain/provider/KeychainDatabase.java | 25 ++++++++++++---------- .../keychain/provider/KeychainProvider.java | 11 ++++++++-- .../keychain/provider/ProviderHelper.java | 7 ++---- .../keychain/remote/RemoteService.java | 2 +- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java index ca1a47f0c..4abcec435 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java @@ -21,6 +21,7 @@ import android.content.Context; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.provider.BaseColumns; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsColumns; import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsAccountsColumns; @@ -63,33 +64,35 @@ public class KeychainDatabase extends SQLiteOpenHelper { + KeysColumns.KEY_DATA + " BLOB," + KeysColumns.RANK + " INTEGER, " + KeysColumns.FINGERPRINT + " BLOB, " - + KeysColumns.KEY_RING_ROW_ID + " INTEGER NOT NULL, FOREIGN KEY(" - + KeysColumns.KEY_RING_ROW_ID + ") REFERENCES " + Tables.KEY_RINGS + "(" - + BaseColumns._ID + ") ON DELETE CASCADE)"; + + KeysColumns.KEY_RING_ROW_ID + " INTEGER NOT NULL, " + + "FOREIGN KEY(" + KeysColumns.KEY_RING_ROW_ID + ") REFERENCES " + + Tables.KEY_RINGS + "(" + BaseColumns._ID + ") ON DELETE CASCADE)"; private static final String CREATE_USER_IDS = "CREATE TABLE IF NOT EXISTS " + Tables.USER_IDS + " (" + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + UserIdsColumns.USER_ID + " TEXT, " + UserIdsColumns.RANK + " INTEGER, " - + UserIdsColumns.KEY_RING_ROW_ID + " INTEGER NOT NULL, FOREIGN KEY(" - + UserIdsColumns.KEY_RING_ROW_ID + ") REFERENCES " + Tables.KEY_RINGS + "(" - + BaseColumns._ID + ") ON DELETE CASCADE)"; + + UserIdsColumns.KEY_RING_ROW_ID + " INTEGER NOT NULL, " + + "FOREIGN KEY(" + UserIdsColumns.KEY_RING_ROW_ID + ") REFERENCES " + + Tables.KEY_RINGS + "(" + BaseColumns._ID + ") ON DELETE CASCADE)"; private static final String CREATE_API_APPS = "CREATE TABLE IF NOT EXISTS " + Tables.API_APPS + " (" + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " - + ApiAppsColumns.PACKAGE_NAME + " TEXT UNIQUE, " + + ApiAppsColumns.PACKAGE_NAME + " TEXT NOT NULL UNIQUE, " + ApiAppsColumns.PACKAGE_SIGNATURE + " BLOB)"; private static final String CREATE_API_APPS_ACCOUNTS = "CREATE TABLE IF NOT EXISTS " + Tables.API_ACCOUNTS + " (" + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " - + ApiAppsAccountsColumns.ACCOUNT_NAME + " TEXT UNIQUE, " + + ApiAppsAccountsColumns.ACCOUNT_NAME + " TEXT NOT NULL, " + ApiAppsAccountsColumns.KEY_ID + " INT64, " + ApiAppsAccountsColumns.ENCRYPTION_ALGORITHM + " INTEGER, " + ApiAppsAccountsColumns.HASH_ALORITHM + " INTEGER, " + ApiAppsAccountsColumns.COMPRESSION + " INTEGER, " - + ApiAppsAccountsColumns.PACKAGE_NAME_FK + " TEXT NOT NULL, FOREIGN KEY(" - + ApiAppsAccountsColumns.PACKAGE_NAME_FK + ") REFERENCES " + Tables.API_APPS + "(" - + ApiAppsColumns.PACKAGE_NAME + ") ON DELETE CASCADE)"; + + ApiAppsAccountsColumns.PACKAGE_NAME_FK + " TEXT NOT NULL, " + + "UNIQUE(" + ApiAppsAccountsColumns.ACCOUNT_NAME + ", " + + ApiAppsAccountsColumns.PACKAGE_NAME_FK + "), " + + "FOREIGN KEY(" + ApiAppsAccountsColumns.PACKAGE_NAME_FK + ") REFERENCES " + + Tables.API_APPS + "(" + ApiAppsColumns.PACKAGE_NAME + ") ON DELETE CASCADE)"; KeychainDatabase(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java index a5ee723f0..6469da978 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java @@ -694,7 +694,7 @@ public class KeychainProvider extends ContentProvider { + Tables.API_APPS + "." + ApiApps.PACKAGE_NAME + " = " + Tables.API_ACCOUNTS + "." + ApiAccounts.PACKAGE_NAME_FK + " )"); qb.appendWhere(Tables.API_APPS + "." + ApiApps.PACKAGE_NAME + " = "); - qb.appendWhereEscapeString(uri.getPathSegments().get(2)); + qb.appendWhereEscapeString(uri.getPathSegments().get(1)); qb.appendWhere(" AND " + Tables.API_ACCOUNTS + "." + ApiAccounts.ACCOUNT_NAME + " = "); qb.appendWhereEscapeString(uri.getLastPathSegment()); @@ -797,6 +797,13 @@ public class KeychainProvider extends ContentProvider { break; case API_ACCOUNTS: + // set foreign key automatically based on given uri + // e.g., api_apps/com.example.app/accounts/ + String packageName = uri.getPathSegments().get(1); + values.put(ApiAccounts.PACKAGE_NAME_FK, packageName); + + Log.d(Constants.TAG, "provider packageName: " + packageName); + rowId = db.insertOrThrow(Tables.API_ACCOUNTS, null, values); // TODO: this is wrong: // rowUri = ApiAccounts.buildIdUri(Long.toString(rowId)); @@ -1046,7 +1053,7 @@ public class KeychainProvider extends ContentProvider { } private String buildDefaultApiAccountsSelection(Uri uri, String selection) { - String packageName = DatabaseUtils.sqlEscapeString(uri.getPathSegments().get(2)); + String packageName = DatabaseUtils.sqlEscapeString(uri.getPathSegments().get(1)); String accountName = DatabaseUtils.sqlEscapeString(uri.getLastPathSegment()); String andSelection = ""; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java index e3727b2f8..71f74b8d8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -813,7 +813,6 @@ public class ProviderHelper { values.put(KeychainContract.ApiAccounts.COMPRESSION, accSettings.getCompression()); values.put(KeychainContract.ApiAccounts.ENCRYPTION_ALGORITHM, accSettings.getEncryptionAlgorithm()); values.put(KeychainContract.ApiAccounts.HASH_ALORITHM, accSettings.getHashAlgorithm()); -// values.put(KeychainContract.ApiAccounts.PACKAGE_NAME_FK, accSettings.getPackageName()); return values; } @@ -823,8 +822,7 @@ public class ProviderHelper { } public static void insertApiAccount(Context context, Uri uri, AccountSettings accSettings) { - context.getContentResolver().insert(uri, - contentValueForApiAccounts(accSettings)); + context.getContentResolver().insert(uri, contentValueForApiAccounts(accSettings)); } public static void updateApiApp(Context context, AppSettings appSettings, Uri uri) { @@ -841,7 +839,6 @@ public class ProviderHelper { } } - /** * Must be an uri pointing to an account * @@ -886,7 +883,7 @@ public class ProviderHelper { return settings; } - public static byte[] getApiSignature(Context context, String packageName) { + public static byte[] getApiAppSignature(Context context, String packageName) { Uri queryUri = ApiApps.buildByPackageNameUri(packageName); String[] projection = new String[]{ApiApps.PACKAGE_SIGNATURE}; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java index 0fd9ee7df..7e935d317 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java @@ -235,7 +235,7 @@ public abstract class RemoteService extends Service { throw new WrongPackageSignatureException(e.getMessage()); } - byte[] storedSig = ProviderHelper.getApiSignature(this, packageName); + byte[] storedSig = ProviderHelper.getApiAppSignature(this, packageName); if (Arrays.equals(currentSig, storedSig)) { Log.d(Constants.TAG, "Package signature is correct! (equals signature from database)"); -- cgit v1.2.3 From 930d722013c36104300bfe4773798ae3d5089b6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 00:40:13 +0100 Subject: Simplify can encrypt check --- .../keychain/ui/ViewKeyMainFragment.java | 43 ++++++++++++---------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index 8a4f2758a..691be5fa9 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -32,7 +32,9 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ListView; import android.widget.TextView; + import com.beardedhen.androidbootstrap.BootstrapButton; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.OtherHelper; @@ -143,7 +145,7 @@ public class ViewKeyMainFragment extends Fragment implements editIntent.setData( KeychainContract .KeyRings.buildSecretKeyRingsByMasterKeyIdUri( - Long.toString(masterKeyId))); + Long.toString(masterKeyId))); editIntent.setAction(EditKeyActivity.ACTION_EDIT_KEY); startActivityForResult(editIntent, 0); } @@ -192,27 +194,27 @@ public class ViewKeyMainFragment extends Fragment implements static final String[] KEYRING_PROJECTION = new String[]{KeychainContract.KeyRings._ID, KeychainContract.KeyRings.MASTER_KEY_ID, - KeychainContract.UserIds.USER_ID}; + KeychainContract.UserIds.USER_ID}; static final int KEYRING_INDEX_ID = 0; static final int KEYRING_INDEX_MASTER_KEY_ID = 1; static final int KEYRING_INDEX_USER_ID = 2; static final String[] USER_IDS_PROJECTION = new String[]{ - KeychainContract.UserIds._ID, - KeychainContract.UserIds.USER_ID, - KeychainContract.UserIds.RANK, + KeychainContract.UserIds._ID, + KeychainContract.UserIds.USER_ID, + KeychainContract.UserIds.RANK, }; static final String USER_IDS_SORT_ORDER = KeychainContract.UserIds.RANK + " COLLATE LOCALIZED ASC"; static final String[] KEYS_PROJECTION = new String[]{KeychainContract.Keys._ID, KeychainContract.Keys.KEY_ID, - KeychainContract.Keys.IS_MASTER_KEY, KeychainContract.Keys.ALGORITHM, - KeychainContract.Keys.KEY_SIZE, KeychainContract.Keys.CAN_CERTIFY, - KeychainContract.Keys.CAN_SIGN, KeychainContract.Keys.CAN_ENCRYPT, - KeychainContract.Keys.IS_REVOKED, KeychainContract.Keys.CREATION, - KeychainContract.Keys.EXPIRY, KeychainContract.Keys.FINGERPRINT}; + KeychainContract.Keys.IS_MASTER_KEY, KeychainContract.Keys.ALGORITHM, + KeychainContract.Keys.KEY_SIZE, KeychainContract.Keys.CAN_CERTIFY, + KeychainContract.Keys.CAN_SIGN, KeychainContract.Keys.CAN_ENCRYPT, + KeychainContract.Keys.IS_REVOKED, KeychainContract.Keys.CREATION, + KeychainContract.Keys.EXPIRY, KeychainContract.Keys.FINGERPRINT}; static final String KEYS_SORT_ORDER = KeychainContract.Keys.RANK + " ASC"; static final int KEYS_INDEX_ID = 0; static final int KEYS_INDEX_KEY_ID = 1; @@ -297,7 +299,7 @@ public class ViewKeyMainFragment extends Fragment implements mCreation.setText( DateFormat.getDateFormat(getActivity().getApplicationContext()).format( - creationDate)); + creationDate)); } // get expiry date from EXPIRY @@ -308,7 +310,7 @@ public class ViewKeyMainFragment extends Fragment implements mExpiry.setText( DateFormat.getDateFormat(getActivity().getApplicationContext()).format( - expiryDate)); + expiryDate)); } String algorithmStr = PgpKeyHelper.getAlgorithmInfo( @@ -324,17 +326,20 @@ public class ViewKeyMainFragment extends Fragment implements mFingerprint.setText(PgpKeyHelper.colorizeFingerprint(fingerprint)); } - int valid_keys = 0; + + // hide encrypt button if no encryption key is available + boolean canEncrypt = false; data.moveToFirst(); - do{ - if(data.getInt(KEYS_INDEX_CAN_ENCRYPT) == 1){ - valid_keys++; + do { + if (data.getInt(KEYS_INDEX_CAN_ENCRYPT) == 1) { + canEncrypt = true; + break; } - }while(data.moveToNext()); - if(valid_keys == 0){ + } while (data.moveToNext()); + if (!canEncrypt) { mActionEncrypt.setVisibility(View.GONE); } - Log.i("Valid Encryption keys", Integer.toString(valid_keys)); + mKeysAdapter.swapCursor(data); break; -- cgit v1.2.3 From 4923c9b8e3e78c888cde438a5f9aac7155ed30f5 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Wed, 26 Mar 2014 00:29:39 +0000 Subject: add original primary ID field to parcel --- .../org/sufficientlysecure/keychain/service/SaveKeyringParcel.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java index ae481aa80..c99284847 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java @@ -41,6 +41,7 @@ public class SaveKeyringParcel implements Parcelable { public String oldPassPhrase; public boolean[] newKeys; public ArrayList keys; + public String originalPrimaryID; public SaveKeyringParcel() {} @@ -62,6 +63,7 @@ public class SaveKeyringParcel implements Parcelable { oldPassPhrase = source.readString(); newKeys = source.createBooleanArray(); keys = PgpConversionHelper.BytesToPGPSecretKeyList(source.createByteArray()); + originalPrimaryID = source.readString(); } @Override @@ -82,6 +84,7 @@ public class SaveKeyringParcel implements Parcelable { destination.writeString(oldPassPhrase); destination.writeBooleanArray(newKeys); destination.writeByteArray(PgpConversionHelper.PGPSecretKeyArrayListToBytes(keys)); + destination.writeString(originalPrimaryID); } public static final Creator CREATOR = new Creator() { -- cgit v1.2.3 From 9542dc0e12a61535c2866a70cdd9266aff6cd9d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 13:07:32 +0100 Subject: Accounts API, user interface --- OpenPGP-Keychain/src/main/AndroidManifest.xml | 53 +++++---- .../remote/ui/AccountSettingsActivity.java | 110 ++++++++++++++++++ .../keychain/remote/ui/AccountsListFragment.java | 127 ++++++++++----------- .../keychain/remote/ui/AppSettingsActivity.java | 38 +++--- .../keychain/remote/ui/AppSettingsFragment.java | 10 +- .../res/layout/api_account_settings_activity.xml | 20 ++++ .../res/layout/api_accounts_adapter_list_item.xml | 16 +++ 7 files changed, 258 insertions(+), 116 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsActivity.java create mode 100644 OpenPGP-Keychain/src/main/res/layout/api_account_settings_activity.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout/api_accounts_adapter_list_item.xml diff --git a/OpenPGP-Keychain/src/main/AndroidManifest.xml b/OpenPGP-Keychain/src/main/AndroidManifest.xml index 3ab39280e..142174749 100644 --- a/OpenPGP-Keychain/src/main/AndroidManifest.xml +++ b/OpenPGP-Keychain/src/main/AndroidManifest.xml @@ -50,7 +50,7 @@ - + -
    + android:launchMode="singleTop"> - + android:launchMode="singleTop"> - + - - + + - - + + - + - - + + - - + + @@ -236,7 +234,7 @@ + android:label="@string/title_preferences"> @@ -374,17 +372,17 @@ android:exported="false" android:process=":passphrase_cache" /> @@ -395,23 +393,28 @@ android:exported="false" android:label="@string/title_api_registered_apps" /> + + + + - - diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsActivity.java new file mode 100644 index 000000000..1092c7dc8 --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsActivity.java @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2013 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.remote.ui; + +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.support.v7.app.ActionBarActivity; +import android.view.MenuItem; +import android.view.View; + +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.ActionBarHelper; +import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.remote.AccountSettings; +import org.sufficientlysecure.keychain.util.Log; + +public class AccountSettingsActivity extends ActionBarActivity { + private Uri mAccountUri; + + private AccountSettingsFragment mAccountSettingsFragment; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + // Inflate a "Done" custom action bar + ActionBarHelper.setOneButtonView(getSupportActionBar(), + R.string.api_settings_save, R.drawable.ic_action_done, + new View.OnClickListener() { + @Override + public void onClick(View v) { + // "Done" + save(); + } + }); + + setContentView(R.layout.api_account_settings_activity); + + mAccountSettingsFragment = (AccountSettingsFragment) getSupportFragmentManager().findFragmentById( + R.id.api_account_settings_fragment); + + Intent intent = getIntent(); + mAccountUri = intent.getData(); + if (mAccountUri == null) { + Log.e(Constants.TAG, "Intent data missing. Should be Uri of app!"); + finish(); + return; + } else { + Log.d(Constants.TAG, "uri: " + mAccountUri); + loadData(savedInstanceState, mAccountUri); + } + } + +// @Override +// public boolean onCreateOptionsMenu(Menu menu) { +// super.onCreateOptionsMenu(menu); +// getMenuInflater().inflate(R.menu.api_app_settings, menu); +// return true; +// } + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.menu_api_settings_revoke: + deleteAccount(); + return true; + case R.id.menu_api_settings_cancel: + finish(); + return true; + } + return super.onOptionsItemSelected(item); + } + + private void loadData(Bundle savedInstanceState, Uri accountUri) { + // TODO: load this also like other fragment with newInstance arguments? + AccountSettings settings = ProviderHelper.getApiAccountSettings(this, accountUri); + mAccountSettingsFragment.setAccSettings(settings); + } + + private void deleteAccount() { + if (getContentResolver().delete(mAccountUri, null, null) <= 0) { + throw new RuntimeException(); + } + finish(); + } + + private void save() { + ProviderHelper.updateApiAccount(this, mAccountSettingsFragment.getAccSettings(), mAccountUri); + + finish(); + } + +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java index 853dc2d3c..22ee7db76 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Dominik Schürmann + * Copyright (C) 2014 Dominik Schürmann * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,35 +17,35 @@ package org.sufficientlysecure.keychain.remote.ui; -import android.annotation.TargetApi; -import android.content.ContentUris; +import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.support.v4.app.ListFragment; import android.support.v4.app.LoaderManager; import android.support.v4.content.CursorLoader; import android.support.v4.content.Loader; +import android.support.v4.widget.CursorAdapter; +import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; -import android.widget.SimpleCursorAdapter; +import android.widget.TextView; +import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.provider.KeychainContract; -import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; +import org.sufficientlysecure.keychain.util.Log; -// TODO: make compat with < 11 -@TargetApi(Build.VERSION_CODES.HONEYCOMB) public class AccountsListFragment extends ListFragment implements LoaderManager.LoaderCallbacks { private static final String ARG_DATA_URI = "uri"; // This is the Adapter being used to display the list's data. - SimpleCursorAdapter mAdapter; + AccountsAdapter mAdapter; private Uri mDataUri; @@ -72,10 +72,14 @@ public class AccountsListFragment extends ListFragment implements getListView().setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView adapterView, View view, int position, long id) { -// // edit app settings -// Intent intent = new Intent(getActivity(), AppSettingsActivity.class); -// intent.setData(ContentUris.withAppendedId(ApiApps.CONTENT_URI, id)); -// startActivity(intent); + String selectedAccountName = mAdapter.getItemAccountName(position); + Uri accountUri = mDataUri.buildUpon().appendEncodedPath(selectedAccountName).build(); + Log.d(Constants.TAG, "accountUri: " + accountUri); + + // edit account settings + Intent intent = new Intent(getActivity(), AccountSettingsActivity.class); + intent.setData(accountUri); + startActivity(intent); } }); @@ -87,12 +91,7 @@ public class AccountsListFragment extends ListFragment implements setHasOptionsMenu(true); // Create an empty adapter we will use to display the loaded data. - mAdapter = new SimpleCursorAdapter(getActivity(), - android.R.layout.simple_list_item_1, - null, - new String[]{KeychainContract.ApiAccounts.ACCOUNT_NAME}, - new int[]{android.R.id.text1}, - 0); + mAdapter = new AccountsAdapter(getActivity(), null, 0); setListAdapter(mAdapter); // Prepare the loader. Either re-connect with an existing one, @@ -102,15 +101,13 @@ public class AccountsListFragment extends ListFragment implements // These are the Contacts rows that we will retrieve. static final String[] PROJECTION = new String[]{ - KeychainContract.ApiAccounts._ID, - KeychainContract.ApiAccounts.ACCOUNT_NAME}; + KeychainContract.ApiAccounts._ID, // 0 + KeychainContract.ApiAccounts.ACCOUNT_NAME // 1 + }; public Loader onCreateLoader(int id, Bundle args) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't care about the ID. - // First, pick the base URI to use depending on whether we are - // currently filtering. -// Uri baseUri = KeychainContract.ApiAccounts.buildBaseUri(mPackageName); // Now create and return a CursorLoader that will take care of // creating a Cursor for the data being displayed. @@ -131,46 +128,46 @@ public class AccountsListFragment extends ListFragment implements mAdapter.swapCursor(null); } -// private class RegisteredAppsAdapter extends CursorAdapter { -// -// private LayoutInflater mInflater; -// private PackageManager mPM; -// -// public RegisteredAppsAdapter(Context context, Cursor c, int flags) { -// super(context, c, flags); -// -// mInflater = LayoutInflater.from(context); -// mPM = context.getApplicationContext().getPackageManager(); -// } -// -// @Override -// public void bindView(View view, Context context, Cursor cursor) { -// TextView text = (TextView) view.findViewById(R.id.api_apps_adapter_item_name); -// ImageView icon = (ImageView) view.findViewById(R.id.api_apps_adapter_item_icon); -// -// String packageName = cursor.getString(cursor.getColumnIndex(ApiApps.PACKAGE_NAME)); -// if (packageName != null) { -// // get application name -// try { -// ApplicationInfo ai = mPM.getApplicationInfo(packageName, 0); -// -// text.setText(mPM.getApplicationLabel(ai)); -// icon.setImageDrawable(mPM.getApplicationIcon(ai)); -// } catch (final PackageManager.NameNotFoundException e) { -// // fallback -// text.setText(packageName); -// } -// } else { -// // fallback -// text.setText(packageName); -// } -// -// } -// -// @Override -// public View newView(Context context, Cursor cursor, ViewGroup parent) { -// return mInflater.inflate(R.layout.api_apps_adapter_list_item, null); -// } -// } + private class AccountsAdapter extends CursorAdapter { + private LayoutInflater mInflater; + + public AccountsAdapter(Context context, Cursor c, int flags) { + super(context, c, flags); + + mInflater = LayoutInflater.from(context); + } + + /** + * Similar to CursorAdapter.getItemId(). + * Required to build Uris for api app view, which is not based on row ids + * + * @param position + * @return + */ + public String getItemAccountName(int position) { + if (mDataValid && mCursor != null) { + if (mCursor.moveToPosition(position)) { + return mCursor.getString(1); + } else { + return null; + } + } else { + return null; + } + } + + @Override + public void bindView(View view, Context context, Cursor cursor) { + TextView text = (TextView) view.findViewById(R.id.api_accounts_adapter_item_name); + + String accountName = cursor.getString(1); + text.setText(accountName); + } + + @Override + public View newView(Context context, Cursor cursor, ViewGroup parent) { + return mInflater.inflate(R.layout.api_accounts_adapter_list_item, null); + } + } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java index 33cde49ba..e4b943734 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java @@ -18,16 +18,17 @@ package org.sufficientlysecure.keychain.remote.ui; import android.content.Intent; +import android.content.pm.ApplicationInfo; +import android.content.pm.PackageManager; import android.net.Uri; import android.os.Bundle; +import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.view.Menu; import android.view.MenuItem; -import android.view.View; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.helper.ActionBarHelper; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.remote.AppSettings; @@ -43,16 +44,11 @@ public class AppSettingsActivity extends ActionBarActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // Inflate a "Done" custom action bar - ActionBarHelper.setOneButtonView(getSupportActionBar(), - R.string.api_settings_save, R.drawable.ic_action_done, - new View.OnClickListener() { - @Override - public void onClick(View v) { - // "Done" - save(); - } - }); + // let the actionbar look like Android's contact app + ActionBar actionBar = getSupportActionBar(); + actionBar.setDisplayHomeAsUpEnabled(true); + actionBar.setIcon(android.R.color.transparent); + actionBar.setHomeButtonEnabled(true); setContentView(R.layout.api_app_settings_activity); @@ -96,6 +92,18 @@ public class AppSettingsActivity extends ActionBarActivity { AppSettings settings = ProviderHelper.getApiAppSettings(this, appUri); mSettingsFragment.setAppSettings(settings); + String appName; + PackageManager pm = getPackageManager(); + try { + ApplicationInfo ai = pm.getApplicationInfo(settings.getPackageName(), 0); + appName = (String) pm.getApplicationLabel(ai); + } catch (PackageManager.NameNotFoundException e) { + // fallback + appName = settings.getPackageName(); + } + setTitle(appName); + + Uri accountsUri = appUri.buildUpon().appendPath(KeychainContract.PATH_ACCOUNTS).build(); Log.d(Constants.TAG, "accountsUri: " + accountsUri); startListFragment(savedInstanceState, accountsUri); @@ -128,10 +136,4 @@ public class AppSettingsActivity extends ActionBarActivity { finish(); } - private void save() { - ProviderHelper.updateApiApp(this, mSettingsFragment.getAppSettings(), mAppUri); - - finish(); - } - } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsFragment.java index 8bcd83fc7..5a6151d88 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsFragment.java @@ -26,19 +26,13 @@ import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemSelectedListener; import android.widget.ImageView; -import android.widget.Spinner; import android.widget.TextView; import org.spongycastle.util.encoders.Hex; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.remote.AppSettings; -import org.sufficientlysecure.keychain.ui.SelectSecretKeyLayoutFragment; -import org.sufficientlysecure.keychain.ui.adapter.KeyValueSpinnerAdapter; -import org.sufficientlysecure.keychain.util.AlgorithmNames; import org.sufficientlysecure.keychain.util.Log; import java.security.MessageDigest; @@ -100,14 +94,14 @@ public class AppSettingsFragment extends Fragment { PackageManager pm = getActivity().getApplicationContext().getPackageManager(); // get application name and icon from package manager - String appName = null; + String appName; Drawable appIcon = null; try { ApplicationInfo ai = pm.getApplicationInfo(packageName, 0); appName = (String) pm.getApplicationLabel(ai); appIcon = pm.getApplicationIcon(ai); - } catch (final NameNotFoundException e) { + } catch (NameNotFoundException e) { // fallback appName = packageName; } diff --git a/OpenPGP-Keychain/src/main/res/layout/api_account_settings_activity.xml b/OpenPGP-Keychain/src/main/res/layout/api_account_settings_activity.xml new file mode 100644 index 000000000..3557c1f00 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/api_account_settings_activity.xml @@ -0,0 +1,20 @@ + + + + + + + + + diff --git a/OpenPGP-Keychain/src/main/res/layout/api_accounts_adapter_list_item.xml b/OpenPGP-Keychain/src/main/res/layout/api_accounts_adapter_list_item.xml new file mode 100644 index 000000000..bbe6bc2ef --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/api_accounts_adapter_list_item.xml @@ -0,0 +1,16 @@ + + + + + \ No newline at end of file -- cgit v1.2.3 From 438c05025054ac06e136432ff880c4f55e3d3be5 Mon Sep 17 00:00:00 2001 From: uberspot Date: Wed, 26 Mar 2014 13:44:30 +0200 Subject: put expiry on a separate line --- .../src/main/res/layout/view_key_keys_item.xml | 37 +++++++++++++--------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml b/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml index 43f06e246..13813f7e7 100644 --- a/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml +++ b/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml @@ -4,8 +4,7 @@ android:layout_height="wrap_content" android:orientation="horizontal" android:paddingLeft="8dip" - android:paddingRight="3dip" - android:singleLine="true" > + android:paddingRight="3dip" > - + - + + + + Date: Wed, 26 Mar 2014 14:06:40 +0200 Subject: add strike through text for revoked or expired keys and disable views for revoked keys as well --- .../keychain/helper/OtherHelper.java | 14 +++++++------ .../keychain/ui/adapter/ViewKeyKeysAdapter.java | 23 ++++++++++++++++++---- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java index d0ba20ea6..b31a889f0 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/OtherHelper.java @@ -17,18 +17,14 @@ package org.sufficientlysecure.keychain.helper; -import android.graphics.Color; import android.os.Bundle; -import android.text.Spannable; import android.text.SpannableStringBuilder; -import android.text.style.ForegroundColorSpan; +import android.text.Spanned; +import android.text.style.StrikethroughSpan; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.util.Log; -import java.security.DigestException; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; import java.util.Iterator; import java.util.Set; @@ -65,4 +61,10 @@ public class OtherHelper { } } + public static SpannableStringBuilder strikeOutText(CharSequence text) { + SpannableStringBuilder sb = new SpannableStringBuilder(text); + sb.setSpan(new StrikethroughSpan(), 0, text.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); + return sb; + } + } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java index d925480e9..ed4113fb8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java @@ -29,6 +29,7 @@ import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.OtherHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; @@ -126,28 +127,42 @@ public class ViewKeyKeysAdapter extends CursorAdapter { signIcon.setVisibility(View.VISIBLE); } + boolean valid = true; if (cursor.getInt(mIndexRevokedKey) > 0) { revokedKeyIcon.setVisibility(View.VISIBLE); + keyId.setTextColor(Color.RED); keyDetails.setTextColor(Color.RED); + keyExpiry.setTextColor(Color.RED); + + valid = false; } else { keyId.setTextColor(mDefaultTextColor); keyDetails.setTextColor(mDefaultTextColor); + keyExpiry.setTextColor(mDefaultTextColor); + revokedKeyIcon.setVisibility(View.GONE); } - boolean valid = true; if (!cursor.isNull(mIndexExpiry)) { Date expiryDate = new Date(cursor.getLong(mIndexExpiry) * 1000); - valid = expiryDate.after(new Date()); + + valid = valid && expiryDate.after(new Date()); keyExpiry.setText("(" + - context.getString(R.string.label_expiry) + ": " + - DateFormat.getDateFormat(context).format(expiryDate) + ")"); + context.getString(R.string.label_expiry) + ": " + + DateFormat.getDateFormat(context).format(expiryDate) + ")"); + keyExpiry.setVisibility(View.VISIBLE); } else { keyExpiry.setVisibility(View.GONE); } + // if key is expired or revoked, strike through text + if (!valid) { + keyId.setText(OtherHelper.strikeOutText(keyId.getText())); + keyDetails.setText(OtherHelper.strikeOutText(keyDetails.getText())); + keyExpiry.setText(OtherHelper.strikeOutText(keyExpiry.getText())); + } keyId.setEnabled(valid); keyDetails.setEnabled(valid); keyExpiry.setEnabled(valid); -- cgit v1.2.3 From 92a4d0e914d7cd132b7e755caf914710969e512d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 13:21:29 +0100 Subject: Part 2 of basic user interface for api accounts --- .../remote/ui/AccountSettingsActivity.java | 17 ++--- .../remote/ui/AccountSettingsFragment.java | 79 +++++++++------------- .../res/layout/api_account_settings_fragment.xml | 75 ++++++-------------- OpenPGP-Keychain/src/main/res/values/strings.xml | 2 + 4 files changed, 64 insertions(+), 109 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsActivity.java index 1092c7dc8..671a3e0aa 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsActivity.java @@ -21,6 +21,7 @@ import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; +import android.view.Menu; import android.view.MenuItem; import android.view.View; @@ -68,20 +69,20 @@ public class AccountSettingsActivity extends ActionBarActivity { } } -// @Override -// public boolean onCreateOptionsMenu(Menu menu) { -// super.onCreateOptionsMenu(menu); -// getMenuInflater().inflate(R.menu.api_app_settings, menu); -// return true; -// } + @Override + public boolean onCreateOptionsMenu(Menu menu) { + super.onCreateOptionsMenu(menu); + getMenuInflater().inflate(R.menu.api_account_settings, menu); + return true; + } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case R.id.menu_api_settings_revoke: + case R.id.menu_account_settings_delete: deleteAccount(); return true; - case R.id.menu_api_settings_cancel: + case R.id.menu_account_settings_cancel: finish(); return true; } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java index 3d88d216e..91e74f2bf 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java @@ -17,6 +17,7 @@ package org.sufficientlysecure.keychain.remote.ui; +import android.content.Intent; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; @@ -32,11 +33,14 @@ import android.widget.ImageView; import android.widget.Spinner; import android.widget.TextView; +import com.beardedhen.androidbootstrap.BootstrapButton; + import org.spongycastle.util.encoders.Hex; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.remote.AccountSettings; import org.sufficientlysecure.keychain.remote.AppSettings; +import org.sufficientlysecure.keychain.ui.EditKeyActivity; import org.sufficientlysecure.keychain.ui.SelectSecretKeyLayoutFragment; import org.sufficientlysecure.keychain.ui.adapter.KeyValueSpinnerAdapter; import org.sufficientlysecure.keychain.util.AlgorithmNames; @@ -52,15 +56,13 @@ public class AccountSettingsFragment extends Fragment implements private AccountSettings mAccSettings; // view - private TextView mAppNameView; - private ImageView mAppIconView; + private TextView mAccNameView; private Spinner mEncryptionAlgorithm; private Spinner mHashAlgorithm; private Spinner mCompression; - private TextView mPackageName; - private TextView mPackageSignature; private SelectSecretKeyLayoutFragment mSelectKeyFragment; + private BootstrapButton mCreateKeyButton; KeyValueSpinnerAdapter mEncryptionAdapter; KeyValueSpinnerAdapter mHashAdapter; @@ -70,27 +72,15 @@ public class AccountSettingsFragment extends Fragment implements return mAccSettings; } - public void setAccSettings(AccountSettings appSettings) { - this.mAccSettings = appSettings; -// setPackage(appSettings.getPackageName()); -// mPackageName.setText(appSettings.getPackageName()); - -// try { -// MessageDigest md = MessageDigest.getInstance("SHA-256"); -// md.update(appSettings.getPackageSignature()); -// byte[] digest = md.digest(); -// String signature = new String(Hex.encode(digest)); -// -// mPackageSignature.setText(signature); -// } catch (NoSuchAlgorithmException e) { -// Log.e(Constants.TAG, "Should not happen!", e); -// } - - mSelectKeyFragment.selectKey(appSettings.getKeyId()); - mEncryptionAlgorithm.setSelection(mEncryptionAdapter.getPosition(appSettings + public void setAccSettings(AccountSettings accountSettings) { + this.mAccSettings = accountSettings; + + mAccNameView.setText(accountSettings.getAccountName()); + mSelectKeyFragment.selectKey(accountSettings.getKeyId()); + mEncryptionAlgorithm.setSelection(mEncryptionAdapter.getPosition(accountSettings .getEncryptionAlgorithm())); - mHashAlgorithm.setSelection(mHashAdapter.getPosition(appSettings.getHashAlgorithm())); - mCompression.setSelection(mCompressionAdapter.getPosition(appSettings.getCompression())); + mHashAlgorithm.setSelection(mHashAdapter.getPosition(accountSettings.getHashAlgorithm())); + mCompression.setSelection(mCompressionAdapter.getPosition(accountSettings.getCompression())); } /** @@ -117,14 +107,19 @@ public class AccountSettingsFragment extends Fragment implements R.id.api_account_settings_select_key_fragment); mSelectKeyFragment.setCallback(this); - mAppNameView = (TextView) view.findViewById(R.id.api_account_settings_app_name); - mAppIconView = (ImageView) view.findViewById(R.id.api_account_settings_app_icon); + mAccNameView = (TextView) view.findViewById(R.id.api_account_settings_acc_name); mEncryptionAlgorithm = (Spinner) view .findViewById(R.id.api_account_settings_encryption_algorithm); mHashAlgorithm = (Spinner) view.findViewById(R.id.api_account_settings_hash_algorithm); mCompression = (Spinner) view.findViewById(R.id.api_account_settings_compression); - mPackageName = (TextView) view.findViewById(R.id.api_account_settings_package_name); - mPackageSignature = (TextView) view.findViewById(R.id.api_account_settings_package_signature); + mCreateKeyButton = (BootstrapButton) view.findViewById(R.id.api_account_settings_create_key); + + mCreateKeyButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + createKey(); + } + }); AlgorithmNames algorithmNames = new AlgorithmNames(getActivity()); @@ -172,25 +167,15 @@ public class AccountSettingsFragment extends Fragment implements } }); } -// -// private void setPackage(String packageName) { -// PackageManager pm = getActivity().getApplicationContext().getPackageManager(); -// -// // get application name and icon from package manager -// String appName = null; -// Drawable appIcon = null; -// try { -// ApplicationInfo ai = pm.getApplicationInfo(packageName, 0); -// -// appName = (String) pm.getApplicationLabel(ai); -// appIcon = pm.getApplicationIcon(ai); -// } catch (final NameNotFoundException e) { -// // fallback -// appName = packageName; -// } -// mAppNameView.setText(appName); -// mAppIconView.setImageDrawable(appIcon); -// } + + private void createKey() { + Intent intent = new Intent(getActivity(), EditKeyActivity.class); + intent.setAction(EditKeyActivity.ACTION_CREATE_KEY); + intent.putExtra(EditKeyActivity.EXTRA_GENERATE_DEFAULT_KEYS, true); + // set default user id to account name TODO: not working currently in EditKey + intent.putExtra(EditKeyActivity.EXTRA_USER_IDS, mAccSettings.getAccountName()); + startActivityForResult(intent, 0); + } /** * callback from select secret key fragment diff --git a/OpenPGP-Keychain/src/main/res/layout/api_account_settings_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/api_account_settings_fragment.xml index 3284b5b0a..de58b6d19 100644 --- a/OpenPGP-Keychain/src/main/res/layout/api_account_settings_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/api_account_settings_fragment.xml @@ -7,34 +7,14 @@ android:layout_height="wrap_content" android:orientation="vertical"> - - - - - - + + + - - - - - - - - \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index 5bf7ca8ca..0d9cdc1bb 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -418,9 +418,11 @@ Hide advanced settings No key selected Select key + Create new key for this account Save Cancel Revoke access + Delete account Package Name SHA-256 of Package Signature Accounts -- cgit v1.2.3 From f10235220d08628892432142ad632512e3f2c68e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 13:32:36 +0100 Subject: Forgot resource --- .../keychain/remote/ui/AccountSettingsFragment.java | 12 ------------ .../src/main/res/menu/api_account_settings.xml | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/res/menu/api_account_settings.xml diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java index 91e74f2bf..0931e6e31 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java @@ -18,10 +18,6 @@ package org.sufficientlysecure.keychain.remote.ui; import android.content.Intent; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; @@ -29,25 +25,17 @@ import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemSelectedListener; -import android.widget.ImageView; import android.widget.Spinner; import android.widget.TextView; import com.beardedhen.androidbootstrap.BootstrapButton; -import org.spongycastle.util.encoders.Hex; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.remote.AccountSettings; -import org.sufficientlysecure.keychain.remote.AppSettings; import org.sufficientlysecure.keychain.ui.EditKeyActivity; import org.sufficientlysecure.keychain.ui.SelectSecretKeyLayoutFragment; import org.sufficientlysecure.keychain.ui.adapter.KeyValueSpinnerAdapter; import org.sufficientlysecure.keychain.util.AlgorithmNames; -import org.sufficientlysecure.keychain.util.Log; - -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; public class AccountSettingsFragment extends Fragment implements SelectSecretKeyLayoutFragment.SelectSecretKeyCallback { diff --git a/OpenPGP-Keychain/src/main/res/menu/api_account_settings.xml b/OpenPGP-Keychain/src/main/res/menu/api_account_settings.xml new file mode 100644 index 000000000..d08fc7f42 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/menu/api_account_settings.xml @@ -0,0 +1,14 @@ + + + + + + + \ No newline at end of file -- cgit v1.2.3 From b75428daf71ace4b295dddbad2094a593996c085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 13:38:45 +0100 Subject: Revert "Update README.md, icon set not used anymore" This reverts commit 9d4582f9689f53589bbf7cc3e224f9fd061f1d51. --- README.md | 64 +++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 958a445be..8954bdcda 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # OpenKeychain (for Android) -OpenKeychain is an OpenPGP implementation for Android. +OpenKeychain is an OpenPGP implementation for Android. For a more detailed description and installation instructions go to http://www.openkeychain.org . ### Travis CI Build Status @@ -31,9 +31,9 @@ Development mailinglist at http://groups.google.com/d/forum/openpgp-keychain-dev ### Build with Gradle 1. Have Android SDK "tools", "platform-tools", and "build-tools" directories in your PATH (http://developer.android.com/sdk/index.html) -2. Open the Android SDK Manager (shell command: ``android``). -Expand the Tools directory and select "Android SDK Build-tools (Version 19.0.3)". -Expand the Extras directory and install "Android Support Repository" +2. Open the Android SDK Manager (shell command: ``android``). +Expand the Tools directory and select "Android SDK Build-tools (Version 19.0.3)". +Expand the Extras directory and install "Android Support Repository" Select everything for the newest SDK (API-Level 19) 3. Export ANDROID_HOME pointing to your Android SDK 4. Execute ``./gradlew build`` @@ -59,11 +59,11 @@ I am using the newest [Android Studio](http://developer.android.com/sdk/installi OpenKeychain provides two APIs, namely the Intent API and the Remote OpenPGP API. The Intent API can be used without permissions to start OpenKeychain's activities for cryptographic operations, import of keys, etc. -However, it always requires user input, so that no malicious application can use this API without user intervention. +However, it always requires user input, so that no malicious application can use this API without user intervention. The Remote OpenPGP API is more sophisticated and allows to to operations without user interaction in the background. When utilizing this API, OpenKeychain asks the user on first use to grant access for the calling client application. -More technical information and examples about these APIs can be found in the project's wiki: +More technical information and examples about these APIs can be found in the project's wiki: * [Intent API](https://github.com/openpgp-keychain/openpgp-keychain/wiki/Intent-API) * [Remote OpenPGP API](https://github.com/openpgp-keychain/openpgp-keychain/wiki/OpenPGP-API) @@ -110,7 +110,7 @@ see ### Gradle Build System -We try to make our builds as [reproducible/deterministic](https://blog.torproject.org/blog/deterministic-builds-part-one-cyberwar-and-global-compromise) as possible. +We try to make our builds as [reproducible/deterministic](https://blog.torproject.org/blog/deterministic-builds-part-one-cyberwar-and-global-compromise) as possible. When changing build files or dependencies, respect the following requirements: * No precompiled libraries. All libraries should be provided as sourcecode in "libraries" folder (you never know what pre-compiled jar files really contain! The library files are currently directly commited, because git submodules/git subtree are too much of a hassle for new contributors. This could change in the future!) * No dependencies from Maven (also a soft requirement for inclusion in [F-Droid](https://f-droid.org)) @@ -180,55 +180,59 @@ Some parts (older parts and some libraries are Apache License v2, MIT X11 Licens > it under the terms of the GNU General Public License as published by > the Free Software Foundation, either version 3 of the License, or > (at your option) any later version. -> +> > This program is distributed in the hope that it will be useful, > but WITHOUT ANY WARRANTY; without even the implied warranty of > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > GNU General Public License for more details. -> +> > You should have received a copy of the GNU General Public License > along with this program. If not, see . ### Libraries -* SpongyCastle - https://github.com/rtyley/spongycastle +* SpongyCastle + https://github.com/rtyley/spongycastle MIT X11 License -* Android Support Library v4 - http://developer.android.com/tools/support-library/index.html +* Android Support Library v4 + http://developer.android.com/tools/support-library/index.html Apache License v2 - -* Android Support Library v7 'appcompat' - http://developer.android.com/tools/support-library/index.html + +* Android Support Library v7 'appcompat' + http://developer.android.com/tools/support-library/index.html Apache License v2 -* HtmlTextView - https://github.com/dschuermann/html-textview +* HtmlTextView + https://github.com/dschuermann/html-textview Apache License v2 -* ZXing - https://github.com/zxing/zxing +* ZXing + https://github.com/zxing/zxing Apache License v2 - -* StickyListHeaders - https://github.com/emilsjolander/StickyListHeaders + +* StickyListHeaders + https://github.com/emilsjolander/StickyListHeaders Apache License v2 - -* Android-Bootstrap - https://github.com/Bearded-Hen/Android-Bootstrap + +* Android-Bootstrap + https://github.com/Bearded-Hen/Android-Bootstrap MIT License -* Android AppMsg - https://github.com/johnkil/Android-AppMsg +* Android AppMsg + https://github.com/johnkil/Android-AppMsg Apache License v2 ### Images -* icon.svg +* icon.svg modified version of kgpg_key2_kopete.svgz -* Menu icons +* key.svg + http://rrze-icon-set.berlios.de/ + Creative Commons Attribution Share-Alike licence 3.0 + +* Menu icons http://developer.android.com/design/downloads/index.html#action-bar-icon-pack -- cgit v1.2.3 From e5fe4245bf4ab247a8caa5e89a710a8b3269ece6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 13:39:30 +0100 Subject: remove old icon entry --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 8954bdcda..8c813a4e0 100644 --- a/README.md +++ b/README.md @@ -227,10 +227,6 @@ Some parts (older parts and some libraries are Apache License v2, MIT X11 Licens ### Images * icon.svg modified version of kgpg_key2_kopete.svgz - -* key.svg - http://rrze-icon-set.berlios.de/ - Creative Commons Attribution Share-Alike licence 3.0 * Menu icons http://developer.android.com/design/downloads/index.html#action-bar-icon-pack -- cgit v1.2.3 From 0d5e99e1f04d6fd24aa66eea987f9e4178731736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 13:42:16 +0100 Subject: Coding style --- README.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8c813a4e0..474bf180b 100644 --- a/README.md +++ b/README.md @@ -145,15 +145,9 @@ see http://help.transifex.net/features/client/index.html#user-client * Opening braces don't go on their own line * Field names: Non-public, non-static fields start with m. * Acronyms are words: Treat acronyms as words in names, yielding !XmlHttpRequest, getUrl(), etc. +* Fully Qualify Imports: Do *not* use wildcard-imports such as ``import foo.*;`` -See http://source.android.com/source/code-style.html - -### XML Eclipse Settings -* XML Maximum line width 999 -* XML: Split multiple attributes each on a new line (Eclipse: Properties -> XML -> XML Files -> Editor) -* XML: Indent using spaces with Indention size 4 (Eclipse: Properties -> XML -> XML Files -> Editor) - -See http://www.androidpolice.com/2009/11/04/auto-formatting-android-xml-files-with-eclipse/ +The full coding style can be found at http://source.android.com/source/code-style.html ### Automated syntax check with CheckStyle -- cgit v1.2.3 From c8b77171051a4b7403c3a62e526798a40e250898 Mon Sep 17 00:00:00 2001 From: uberspot Date: Wed, 26 Mar 2014 14:45:56 +0200 Subject: fix capability icons and remove red text for revoked keys --- .../keychain/ui/adapter/ViewKeyKeysAdapter.java | 4 --- .../src/main/res/layout/view_key_keys_item.xml | 33 ++++++++++++---------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java index ed4113fb8..9d60c1530 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java @@ -131,10 +131,6 @@ public class ViewKeyKeysAdapter extends CursorAdapter { if (cursor.getInt(mIndexRevokedKey) > 0) { revokedKeyIcon.setVisibility(View.VISIBLE); - keyId.setTextColor(Color.RED); - keyDetails.setTextColor(Color.RED); - keyExpiry.setTextColor(Color.RED); - valid = false; } else { keyId.setTextColor(mDefaultTextColor); diff --git a/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml b/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml index 13813f7e7..aecedc39b 100644 --- a/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml +++ b/OpenPGP-Keychain/src/main/res/layout/view_key_keys_item.xml @@ -14,21 +14,24 @@ android:paddingRight="6dip" android:src="@drawable/key_small" /> - - + + - + -- cgit v1.2.3 From ec3459733180a5d83805b6fe9ddf5571f7b0380f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 14:11:28 +0100 Subject: Make PendingIntents with FLAG_CANCEL_CURRENT and FLAG_ONE_SHOT --- OpenPGP-Keychain/src/main/AndroidManifest.xml | 6 +-- .../keychain/remote/OpenPgpService.java | 29 ++++++------- .../keychain/remote/RemoteService.java | 24 ++++++----- .../keychain/remote/ui/AppSettingsFragment.java | 47 ++++++++++------------ .../keychain/remote/ui/RemoteServiceActivity.java | 1 + 5 files changed, 53 insertions(+), 54 deletions(-) diff --git a/OpenPGP-Keychain/src/main/AndroidManifest.xml b/OpenPGP-Keychain/src/main/AndroidManifest.xml index 142174749..e6a082743 100644 --- a/OpenPGP-Keychain/src/main/AndroidManifest.xml +++ b/OpenPGP-Keychain/src/main/AndroidManifest.xml @@ -384,9 +384,9 @@ - - + android:label="@string/app_name" + android:launchMode="singleTop" + android:process=":remote_api" /> allowedPkgs = ProviderHelper.getRegisteredApiApps(this); Log.d(Constants.TAG, "allowed: " + allowedPkgs); @@ -246,6 +247,7 @@ public abstract class RemoteService extends Service { } } + Log.d(Constants.TAG, "Package is NOT allowed! packageName: " + packageName); return false; } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsFragment.java index 5a6151d88..a6db02708 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsFragment.java @@ -55,20 +55,7 @@ public class AppSettingsFragment extends Fragment { public void setAppSettings(AppSettings appSettings) { this.mAppSettings = appSettings; - setPackage(appSettings.getPackageName()); - mPackageName.setText(appSettings.getPackageName()); - - try { - MessageDigest md = MessageDigest.getInstance("SHA-256"); - md.update(appSettings.getPackageSignature()); - byte[] digest = md.digest(); - String signature = new String(Hex.encode(digest)); - - mPackageSignature.setText(signature); - } catch (NoSuchAlgorithmException e) { - Log.e(Constants.TAG, "Should not happen!", e); - } - + updateView(appSettings); } /** @@ -77,36 +64,44 @@ public class AppSettingsFragment extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.api_app_settings_fragment, container, false); - initView(view); - return view; - } - - - private void initView(View view) { mAppNameView = (TextView) view.findViewById(R.id.api_app_settings_app_name); mAppIconView = (ImageView) view.findViewById(R.id.api_app_settings_app_icon); - mPackageName = (TextView) view.findViewById(R.id.api_app_settings_package_name); mPackageSignature = (TextView) view.findViewById(R.id.api_app_settings_package_signature); + return view; } - private void setPackage(String packageName) { - PackageManager pm = getActivity().getApplicationContext().getPackageManager(); - + private void updateView(AppSettings appSettings) { // get application name and icon from package manager String appName; Drawable appIcon = null; + PackageManager pm = getActivity().getApplicationContext().getPackageManager(); try { - ApplicationInfo ai = pm.getApplicationInfo(packageName, 0); + ApplicationInfo ai = pm.getApplicationInfo(appSettings.getPackageName(), 0); appName = (String) pm.getApplicationLabel(ai); appIcon = pm.getApplicationIcon(ai); } catch (NameNotFoundException e) { // fallback - appName = packageName; + appName = appSettings.getPackageName(); } mAppNameView.setText(appName); mAppIconView.setImageDrawable(appIcon); + + // advanced info: package name + mPackageName.setText(appSettings.getPackageName()); + + // advanced info: package signature SHA-256 + try { + MessageDigest md = MessageDigest.getInstance("SHA-256"); + md.update(appSettings.getPackageSignature()); + byte[] digest = md.digest(); + String signature = new String(Hex.encode(digest)); + + mPackageSignature.setText(signature); + } catch (NoSuchAlgorithmException e) { + Log.e(Constants.TAG, "Should not happen!", e); + } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java index d3ac5cade..ba0d4d088 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java @@ -95,6 +95,7 @@ public class RemoteServiceActivity extends ActionBarActivity { if (ACTION_REGISTER.equals(action)) { final String packageName = extras.getString(EXTRA_PACKAGE_NAME); final byte[] packageSignature = extras.getByteArray(EXTRA_PACKAGE_SIGNATURE); + Log.d(Constants.TAG, "ACTION_REGISTER packageName: "+packageName); // Inflate a "Done"/"Cancel" custom action bar view ActionBarHelper.setTwoButtonView(getSupportActionBar(), -- cgit v1.2.3 From 65857d2b5fea5cbb5d156b1b4ddfd68ded311624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 17:43:26 +0100 Subject: Accounts list prettified --- .../keychain/remote/ui/AccountsListFragment.java | 27 +++++++++++++++++++++ .../keychain/remote/ui/AppSettingsActivity.java | 1 - .../main/res/drawable-hdpi/ic_action_person.png | Bin 0 -> 573 bytes .../main/res/drawable-mdpi/ic_action_person.png | Bin 0 -> 468 bytes .../main/res/drawable-xhdpi/ic_action_person.png | Bin 0 -> 781 bytes .../main/res/drawable-xxhdpi/ic_action_person.png | Bin 0 -> 1004 bytes .../res/layout/api_accounts_adapter_list_item.xml | 15 ++++++++++-- .../main/res/layout/api_app_settings_activity.xml | 6 ++--- 8 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/res/drawable-hdpi/ic_action_person.png create mode 100644 OpenPGP-Keychain/src/main/res/drawable-mdpi/ic_action_person.png create mode 100644 OpenPGP-Keychain/src/main/res/drawable-xhdpi/ic_action_person.png create mode 100644 OpenPGP-Keychain/src/main/res/drawable-xxhdpi/ic_action_person.png diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java index 22ee7db76..8e65a2f04 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java @@ -32,11 +32,15 @@ import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; +import android.widget.LinearLayout; +import android.widget.ListView; import android.widget.TextView; import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.ui.widget.FixedListView; import org.sufficientlysecure.keychain.util.Log; public class AccountsListFragment extends ListFragment implements @@ -63,6 +67,29 @@ public class AccountsListFragment extends ListFragment implements return frag; } + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, + Bundle savedInstanceState) { + View layout = super.onCreateView(inflater, container, + savedInstanceState); + ListView lv = (ListView) layout.findViewById(android.R.id.list); + ViewGroup parent = (ViewGroup) lv.getParent(); + + /* + * http://stackoverflow.com/a/15880684 + * Remove ListView and add FixedListView in its place. + * This is done here programatically to be still able to use the progressBar of ListFragment. + * + * We want FixedListView to be able to put this ListFragment inside a ScrollView + */ + int lvIndex = parent.indexOfChild(lv); + parent.removeViewAt(lvIndex); + FixedListView newLv = new FixedListView(getActivity()); + newLv.setId(android.R.id.list); + parent.addView(newLv, lvIndex, lv.getLayoutParams()); + return layout; + } + @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java index e4b943734..9e0ba49eb 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppSettingsActivity.java @@ -103,7 +103,6 @@ public class AppSettingsActivity extends ActionBarActivity { } setTitle(appName); - Uri accountsUri = appUri.buildUpon().appendPath(KeychainContract.PATH_ACCOUNTS).build(); Log.d(Constants.TAG, "accountsUri: " + accountsUri); startListFragment(savedInstanceState, accountsUri); diff --git a/OpenPGP-Keychain/src/main/res/drawable-hdpi/ic_action_person.png b/OpenPGP-Keychain/src/main/res/drawable-hdpi/ic_action_person.png new file mode 100644 index 000000000..9fd81097b Binary files /dev/null and b/OpenPGP-Keychain/src/main/res/drawable-hdpi/ic_action_person.png differ diff --git a/OpenPGP-Keychain/src/main/res/drawable-mdpi/ic_action_person.png b/OpenPGP-Keychain/src/main/res/drawable-mdpi/ic_action_person.png new file mode 100644 index 000000000..359da1c12 Binary files /dev/null and b/OpenPGP-Keychain/src/main/res/drawable-mdpi/ic_action_person.png differ diff --git a/OpenPGP-Keychain/src/main/res/drawable-xhdpi/ic_action_person.png b/OpenPGP-Keychain/src/main/res/drawable-xhdpi/ic_action_person.png new file mode 100644 index 000000000..03eeb8d6a Binary files /dev/null and b/OpenPGP-Keychain/src/main/res/drawable-xhdpi/ic_action_person.png differ diff --git a/OpenPGP-Keychain/src/main/res/drawable-xxhdpi/ic_action_person.png b/OpenPGP-Keychain/src/main/res/drawable-xxhdpi/ic_action_person.png new file mode 100644 index 000000000..fd1bcdd45 Binary files /dev/null and b/OpenPGP-Keychain/src/main/res/drawable-xxhdpi/ic_action_person.png differ diff --git a/OpenPGP-Keychain/src/main/res/layout/api_accounts_adapter_list_item.xml b/OpenPGP-Keychain/src/main/res/layout/api_accounts_adapter_list_item.xml index bbe6bc2ef..d31ae52d7 100644 --- a/OpenPGP-Keychain/src/main/res/layout/api_accounts_adapter_list_item.xml +++ b/OpenPGP-Keychain/src/main/res/layout/api_accounts_adapter_list_item.xml @@ -2,8 +2,19 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="?android:attr/listPreferredItemHeight" - android:paddingTop="4dp" - android:paddingBottom="4dp"> + android:gravity="center_vertical" + android:singleLine="true" + android:orientation="horizontal"> + + @@ -27,9 +27,7 @@ android:id="@+id/api_accounts_list_fragment" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical" - android:paddingLeft="4dp" - android:paddingRight="4dp" /> + android:orientation="vertical" /> -- cgit v1.2.3 From ba37fc254d53d27403226771060a2c235a264c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 17:50:16 +0100 Subject: Accounts activity prettified --- .../res/layout/api_account_settings_fragment.xml | 36 +++++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/layout/api_account_settings_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/api_account_settings_fragment.xml index de58b6d19..32843eb29 100644 --- a/OpenPGP-Keychain/src/main/res/layout/api_account_settings_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/api_account_settings_fragment.xml @@ -7,14 +7,34 @@ android:layout_height="wrap_content" android:orientation="vertical"> - + + + + + + Date: Wed, 26 Mar 2014 17:55:48 +0100 Subject: Fix provider for API_ACCOUNTS --- .../keychain/provider/KeychainContract.java | 2 +- .../keychain/provider/KeychainDatabase.java | 6 +++--- .../keychain/provider/KeychainProvider.java | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java index 6e4899fc2..e7b31bf65 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java @@ -65,7 +65,7 @@ public class KeychainContract { String ENCRYPTION_ALGORITHM = "encryption_algorithm"; String HASH_ALORITHM = "hash_algorithm"; String COMPRESSION = "compression"; - String PACKAGE_NAME_FK = "package_name"; // foreign key to api_apps.package_name + String PACKAGE_NAME = "package_name"; // foreign key to api_apps.package_name } public static final class KeyTypes { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java index 4abcec435..8c33844b2 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java @@ -88,10 +88,10 @@ public class KeychainDatabase extends SQLiteOpenHelper { + ApiAppsAccountsColumns.ENCRYPTION_ALGORITHM + " INTEGER, " + ApiAppsAccountsColumns.HASH_ALORITHM + " INTEGER, " + ApiAppsAccountsColumns.COMPRESSION + " INTEGER, " - + ApiAppsAccountsColumns.PACKAGE_NAME_FK + " TEXT NOT NULL, " + + ApiAppsAccountsColumns.PACKAGE_NAME + " TEXT NOT NULL, " + "UNIQUE(" + ApiAppsAccountsColumns.ACCOUNT_NAME + ", " - + ApiAppsAccountsColumns.PACKAGE_NAME_FK + "), " - + "FOREIGN KEY(" + ApiAppsAccountsColumns.PACKAGE_NAME_FK + ") REFERENCES " + + ApiAppsAccountsColumns.PACKAGE_NAME + "), " + + "FOREIGN KEY(" + ApiAppsAccountsColumns.PACKAGE_NAME + ") REFERENCES " + Tables.API_APPS + "(" + ApiAppsColumns.PACKAGE_NAME + ") ON DELETE CASCADE)"; KeychainDatabase(Context context) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java index 6469da978..1c5e3ab36 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java @@ -687,13 +687,13 @@ public class KeychainProvider extends ContentProvider { break; case API_ACCOUNTS: qb.setTables(Tables.API_ACCOUNTS); + qb.appendWhere(Tables.API_ACCOUNTS + "." + ApiAccounts.PACKAGE_NAME + " = "); + qb.appendWhereEscapeString(uri.getPathSegments().get(1)); break; case API_ACCOUNTS_BY_ACCOUNT_NAME: - qb.setTables(Tables.API_ACCOUNTS + " INNER JOIN " + Tables.API_APPS + " ON " + "(" - + Tables.API_APPS + "." + ApiApps.PACKAGE_NAME + " = " + Tables.API_ACCOUNTS + "." - + ApiAccounts.PACKAGE_NAME_FK + " )"); - qb.appendWhere(Tables.API_APPS + "." + ApiApps.PACKAGE_NAME + " = "); + qb.setTables(Tables.API_ACCOUNTS); + qb.appendWhere(Tables.API_ACCOUNTS + "." + ApiAccounts.PACKAGE_NAME + " = "); qb.appendWhereEscapeString(uri.getPathSegments().get(1)); qb.appendWhere(" AND " + Tables.API_ACCOUNTS + "." + ApiAccounts.ACCOUNT_NAME + " = "); @@ -800,7 +800,7 @@ public class KeychainProvider extends ContentProvider { // set foreign key automatically based on given uri // e.g., api_apps/com.example.app/accounts/ String packageName = uri.getPathSegments().get(1); - values.put(ApiAccounts.PACKAGE_NAME_FK, packageName); + values.put(ApiAccounts.PACKAGE_NAME, packageName); Log.d(Constants.TAG, "provider packageName: " + packageName); @@ -1061,7 +1061,7 @@ public class KeychainProvider extends ContentProvider { andSelection = " AND (" + selection + ")"; } - return ApiAccounts.PACKAGE_NAME_FK + "=" + packageName + " AND " + return ApiAccounts.PACKAGE_NAME + "=" + packageName + " AND " + ApiAccounts.ACCOUNT_NAME + "=" + accountName + andSelection; } -- cgit v1.2.3 From aba6a44a0a830136577d98f07e01db89f639fdfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 18:13:48 +0100 Subject: Improve demo for API accounts --- .../keychain/demo/OpenPgpProviderActivity.java | 18 +++++++++++------- .../src/main/res/layout/openpgp_provider.xml | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java index a660b1c9a..42722c5e1 100644 --- a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java +++ b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java @@ -48,6 +48,7 @@ public class OpenPgpProviderActivity extends Activity { private Button mEncrypt; private Button mSignAndEncrypt; private Button mDecryptAndVerify; + private EditText mAccount; private OpenPgpServiceConnection mServiceConnection; @@ -68,6 +69,7 @@ public class OpenPgpProviderActivity extends Activity { mEncrypt = (Button) findViewById(R.id.crypto_provider_demo_encrypt); mSignAndEncrypt = (Button) findViewById(R.id.crypto_provider_demo_sign_and_encrypt); mDecryptAndVerify = (Button) findViewById(R.id.crypto_provider_demo_decrypt_and_verify); + mAccount = (EditText) findViewById(R.id.crypto_provider_demo_account); mSign.setOnClickListener(new View.OnClickListener() { @Override @@ -142,7 +144,7 @@ public class OpenPgpProviderActivity extends Activity { private InputStream getInputstream(boolean ciphertext) { InputStream is = null; try { - String inputStr = null; + String inputStr; if (ciphertext) { inputStr = mCiphertext.getText().toString(); } else { @@ -213,6 +215,7 @@ public class OpenPgpProviderActivity extends Activity { public void sign(Intent data) { data.setAction(OpenPgpApi.ACTION_SIGN); data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); + data.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, mAccount.getText().toString()); InputStream is = getInputstream(false); final ByteArrayOutputStream os = new ByteArrayOutputStream(); @@ -225,6 +228,7 @@ public class OpenPgpProviderActivity extends Activity { data.setAction(OpenPgpApi.ACTION_ENCRYPT); data.putExtra(OpenPgpApi.EXTRA_USER_IDS, mEncryptUserIds.getText().toString().split(",")); data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); + data.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, mAccount.getText().toString()); InputStream is = getInputstream(false); final ByteArrayOutputStream os = new ByteArrayOutputStream(); @@ -237,6 +241,7 @@ public class OpenPgpProviderActivity extends Activity { data.setAction(OpenPgpApi.ACTION_SIGN_AND_ENCRYPT); data.putExtra(OpenPgpApi.EXTRA_USER_IDS, mEncryptUserIds.getText().toString().split(",")); data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); + data.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, mAccount.getText().toString()); InputStream is = getInputstream(false); final ByteArrayOutputStream os = new ByteArrayOutputStream(); @@ -248,6 +253,7 @@ public class OpenPgpProviderActivity extends Activity { public void decryptAndVerify(Intent data) { data.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY); data.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); + data.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, mAccount.getText().toString()); InputStream is = getInputstream(true); final ByteArrayOutputStream os = new ByteArrayOutputStream(); @@ -264,13 +270,11 @@ public class OpenPgpProviderActivity extends Activity { // try again after user interaction if (resultCode == RESULT_OK) { /* - * The data originally given to the pgp method are are again - * returned here to be used when calling again after user interaction. - * - * They also contain results from the user interaction which happened, - * for example selected key ids. + * The data originally given to one of the methods above, is again + * returned here to be used when calling the method again after user + * interaction. The Intent now also contains results from the user + * interaction, for example selected key ids. */ - switch (requestCode) { case REQUEST_CODE_SIGN: { sign(data); diff --git a/OpenPGP-Keychain-API/example-app/src/main/res/layout/openpgp_provider.xml b/OpenPGP-Keychain-API/example-app/src/main/res/layout/openpgp_provider.xml index 6c2ce1a7c..2b8e8016a 100644 --- a/OpenPGP-Keychain-API/example-app/src/main/res/layout/openpgp_provider.xml +++ b/OpenPGP-Keychain-API/example-app/src/main/res/layout/openpgp_provider.xml @@ -46,6 +46,7 @@ android:scrollHorizontally="true" android:scrollbars="vertical" android:text="message" + android:hint="cleartext message" android:textAppearance="@android:style/TextAppearance.Small" /> @@ -66,6 +67,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:text="ciphertext" + android:hint="ciphertext" android:textAppearance="@android:style/TextAppearance.Small" /> @@ -104,5 +106,18 @@ android:layout_height="wrap_content" android:text="Decrypt and Verify" /> + + + + \ No newline at end of file -- cgit v1.2.3 From 399106015e6d4a8d08385f9d5d360fe634e5cc56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 18:18:00 +0100 Subject: Rename layouts for remote activity --- .../keychain/remote/ui/RemoteServiceActivity.java | 8 +++--- .../res/layout/api_account_create_activity.xml | 21 ---------------- .../src/main/res/layout/api_app_error_message.xml | 16 ------------ .../main/res/layout/api_app_register_activity.xml | 29 ---------------------- .../layout/api_app_select_pub_keys_activity.xml | 21 ---------------- .../main/res/layout/api_remote_create_account.xml | 21 ++++++++++++++++ .../main/res/layout/api_remote_error_message.xml | 16 ++++++++++++ .../main/res/layout/api_remote_register_app.xml | 29 ++++++++++++++++++++++ .../main/res/layout/api_remote_select_pub_keys.xml | 21 ++++++++++++++++ 9 files changed, 91 insertions(+), 91 deletions(-) delete mode 100644 OpenPGP-Keychain/src/main/res/layout/api_account_create_activity.xml delete mode 100644 OpenPGP-Keychain/src/main/res/layout/api_app_error_message.xml delete mode 100644 OpenPGP-Keychain/src/main/res/layout/api_app_register_activity.xml delete mode 100644 OpenPGP-Keychain/src/main/res/layout/api_app_select_pub_keys_activity.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout/api_remote_create_account.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout/api_remote_error_message.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout/api_remote_register_app.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout/api_remote_select_pub_keys.xml diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java index ba0d4d088..a894da448 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java @@ -124,7 +124,7 @@ public class RemoteServiceActivity extends ActionBarActivity { } ); - setContentView(R.layout.api_app_register_activity); + setContentView(R.layout.api_remote_register_app); mAppSettingsFragment = (AppSettingsFragment) getSupportFragmentManager().findFragmentById( R.id.api_app_settings_fragment); @@ -169,7 +169,7 @@ public class RemoteServiceActivity extends ActionBarActivity { } ); - setContentView(R.layout.api_account_create_activity); + setContentView(R.layout.api_remote_create_account); mAccSettingsFragment = (AccountSettingsFragment) getSupportFragmentManager().findFragmentById( R.id.api_account_settings_fragment); @@ -235,7 +235,7 @@ public class RemoteServiceActivity extends ActionBarActivity { } ); - setContentView(R.layout.api_app_select_pub_keys_activity); + setContentView(R.layout.api_remote_select_pub_keys); // set text on view HtmlTextView textView = (HtmlTextView) findViewById(R.id.api_select_pub_keys_text); @@ -277,7 +277,7 @@ public class RemoteServiceActivity extends ActionBarActivity { } }); - setContentView(R.layout.api_app_error_message); + setContentView(R.layout.api_remote_error_message); // set text on view HtmlTextView textView = (HtmlTextView) findViewById(R.id.api_app_error_message_text); diff --git a/OpenPGP-Keychain/src/main/res/layout/api_account_create_activity.xml b/OpenPGP-Keychain/src/main/res/layout/api_account_create_activity.xml deleted file mode 100644 index ead336dbb..000000000 --- a/OpenPGP-Keychain/src/main/res/layout/api_account_create_activity.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - diff --git a/OpenPGP-Keychain/src/main/res/layout/api_app_error_message.xml b/OpenPGP-Keychain/src/main/res/layout/api_app_error_message.xml deleted file mode 100644 index 48aa89d4f..000000000 --- a/OpenPGP-Keychain/src/main/res/layout/api_app_error_message.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/api_app_register_activity.xml b/OpenPGP-Keychain/src/main/res/layout/api_app_register_activity.xml deleted file mode 100644 index f85f3b8f7..000000000 --- a/OpenPGP-Keychain/src/main/res/layout/api_app_register_activity.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - diff --git a/OpenPGP-Keychain/src/main/res/layout/api_app_select_pub_keys_activity.xml b/OpenPGP-Keychain/src/main/res/layout/api_app_select_pub_keys_activity.xml deleted file mode 100644 index a10592607..000000000 --- a/OpenPGP-Keychain/src/main/res/layout/api_app_select_pub_keys_activity.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/api_remote_create_account.xml b/OpenPGP-Keychain/src/main/res/layout/api_remote_create_account.xml new file mode 100644 index 000000000..ead336dbb --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/api_remote_create_account.xml @@ -0,0 +1,21 @@ + + + + + + + + + diff --git a/OpenPGP-Keychain/src/main/res/layout/api_remote_error_message.xml b/OpenPGP-Keychain/src/main/res/layout/api_remote_error_message.xml new file mode 100644 index 000000000..48aa89d4f --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/api_remote_error_message.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/api_remote_register_app.xml b/OpenPGP-Keychain/src/main/res/layout/api_remote_register_app.xml new file mode 100644 index 000000000..f85f3b8f7 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/api_remote_register_app.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + diff --git a/OpenPGP-Keychain/src/main/res/layout/api_remote_select_pub_keys.xml b/OpenPGP-Keychain/src/main/res/layout/api_remote_select_pub_keys.xml new file mode 100644 index 000000000..a10592607 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/api_remote_select_pub_keys.xml @@ -0,0 +1,21 @@ + + + + + + + + \ No newline at end of file -- cgit v1.2.3 From ac134790a0e2fef7a6c5cb44818d58deeaec0b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 18:23:48 +0100 Subject: Text for creation of new api accounts --- .../src/main/res/layout/api_remote_create_account.xml | 8 ++++++++ OpenPGP-Keychain/src/main/res/values/strings.xml | 1 + 2 files changed, 9 insertions(+) diff --git a/OpenPGP-Keychain/src/main/res/layout/api_remote_create_account.xml b/OpenPGP-Keychain/src/main/res/layout/api_remote_create_account.xml index ead336dbb..3aee9094f 100644 --- a/OpenPGP-Keychain/src/main/res/layout/api_remote_create_account.xml +++ b/OpenPGP-Keychain/src/main/res/layout/api_remote_create_account.xml @@ -10,6 +10,14 @@ android:padding="16dp" android:orientation="vertical"> + + SHA-256 of Package Signature
    Accounts No accounts attached to this application. + The application requests the creation of a new account. Please select an existing private key or create a new one.\nApplications are restricted to the usage of keys you select here! The displayed application requests access to OpenKeychain.\nAllow access?\n\nWARNING: If you do not know why this screen appeared, disallow access! You can revoke access later using the \'Registered Applications\' screen. Allow access Disallow access -- cgit v1.2.3 From cc8fd35137d1c8e78727a76a5cceb5f92b234a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 18:34:48 +0100 Subject: Show divider only when used --- .../java/org/sufficientlysecure/keychain/ui/KeyListFragment.java | 6 ++++++ OpenPGP-Keychain/src/main/res/layout/key_list_item.xml | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index daf455c03..957c822d2 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -498,11 +498,15 @@ public class KeyListFragment extends Fragment } { // set edit button and revoked info, specific by key type + View statusDivider = (View) view.findViewById(R.id.status_divider); + FrameLayout statusLayout = (FrameLayout) view.findViewById(R.id.status_layout); Button button = (Button) view.findViewById(R.id.edit); TextView revoked = (TextView) view.findViewById(R.id.revoked); if (cursor.getInt(KeyListFragment.INDEX_TYPE) == KeyTypes.SECRET) { // this is a secret key - show the edit button + statusDivider.setVisibility(View.VISIBLE); + statusLayout.setVisibility(View.VISIBLE); revoked.setVisibility(View.GONE); button.setVisibility(View.VISIBLE); @@ -519,9 +523,11 @@ public class KeyListFragment extends Fragment }); } else { // this is a public key - hide the edit button, show if it's revoked + statusDivider.setVisibility(View.GONE); button.setVisibility(View.GONE); boolean isRevoked = cursor.getInt(INDEX_IS_REVOKED) > 0; + statusLayout.setVisibility(isRevoked ? View.VISIBLE : View.GONE); revoked.setVisibility(isRevoked ? View.VISIBLE : View.GONE); } } diff --git a/OpenPGP-Keychain/src/main/res/layout/key_list_item.xml b/OpenPGP-Keychain/src/main/res/layout/key_list_item.xml index bee56ddfe..0abae8bbb 100644 --- a/OpenPGP-Keychain/src/main/res/layout/key_list_item.xml +++ b/OpenPGP-Keychain/src/main/res/layout/key_list_item.xml @@ -39,6 +39,7 @@ @@ -55,7 +57,6 @@ android:layout_height="match_parent" android:id="@+id/edit" android:focusable="false" - android:visibility="visible" android:enabled="true" android:textAppearance="?android:attr/textAppearanceSmall" android:textColor="@color/black" @@ -71,7 +72,6 @@ android:textAppearance="?android:attr/textAppearanceSmall" android:text="@string/revoked" android:textColor="#e00" - android:visibility="visible" android:layout_gravity="center" /> -- cgit v1.2.3 From 19bbaecf32e7c2f7a99bf0bafd4d78f6094c788b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 22:20:23 +0100 Subject: Update from transifex --- .../src/main/res/raw-cs-rCZ/help_about.html | 4 +- .../src/main/res/raw-de/help_about.html | 2 +- .../src/main/res/raw-es/help_start.html | 2 +- .../src/main/res/raw-et/help_about.html | 48 ++++++++ .../src/main/res/raw-et/help_changelog.html | 108 ++++++++++++++++++ .../src/main/res/raw-et/help_nfc_beam.html | 12 ++ .../src/main/res/raw-et/help_start.html | 19 ++++ .../src/main/res/raw-et/nfc_beam_share.html | 11 ++ .../src/main/res/raw-fa-rIR/help_start.html | 2 +- .../src/main/res/raw-fr/help_about.html | 2 +- .../src/main/res/raw-fr/help_start.html | 2 +- .../src/main/res/raw-it-rIT/help_about.html | 2 +- .../src/main/res/raw-it-rIT/help_start.html | 2 +- .../src/main/res/raw-ja/help_start.html | 2 +- .../src/main/res/raw-pl/help_about.html | 2 +- .../src/main/res/raw-pl/help_start.html | 2 +- .../src/main/res/raw-ru/help_about.html | 2 +- .../src/main/res/raw-ru/help_start.html | 2 +- .../src/main/res/raw-tr/help_about.html | 2 +- .../src/main/res/raw-uk/help_about.html | 12 +- .../src/main/res/raw-uk/help_start.html | 2 +- .../src/main/res/raw-zh/help_start.html | 2 +- .../src/main/res/values-cs-rCZ/strings.xml | 22 ++++ .../src/main/res/values-es/strings.xml | 7 ++ .../src/main/res/values-et/strings.xml | 123 +++++++++++++++++++++ .../src/main/res/values-fr/strings.xml | 7 ++ .../src/main/res/values-it-rIT/strings.xml | 3 + .../src/main/res/values-ja/strings.xml | 3 + .../src/main/res/values-pl/strings.xml | 7 ++ .../src/main/res/values-ru/strings.xml | 22 ++++ .../src/main/res/values-uk/strings.xml | 7 ++ 31 files changed, 422 insertions(+), 23 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/res/raw-et/help_about.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-et/help_changelog.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-et/help_nfc_beam.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-et/help_start.html create mode 100644 OpenPGP-Keychain/src/main/res/raw-et/nfc_beam_share.html create mode 100644 OpenPGP-Keychain/src/main/res/values-et/strings.xml diff --git a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html index d9150a5e8..066e53a89 100644 --- a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html @@ -3,11 +3,11 @@

    http://www.openkeychain.org

    OpenKeychain is an OpenPGP implementation for Android.

    -

    License: GPLv3+

    +

    Licence: GPLv3+

    Developers OpenKeychain

      -
    • Dominik Schürmann (Lead developer)
    • +
    • Dominik Schürmann (Hlavní vývojář)
    • Ash Hughes (crypto patches)
    • Brian C. Barnes
    • Bahtiar 'kalkin' Gadimov (UI)
    • diff --git a/OpenPGP-Keychain/src/main/res/raw-de/help_about.html b/OpenPGP-Keychain/src/main/res/raw-de/help_about.html index 676c2bdd2..9115ba9c5 100644 --- a/OpenPGP-Keychain/src/main/res/raw-de/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-de/help_about.html @@ -21,7 +21,7 @@

    Entwickler APG 1.x

      -
    • Thialfihar (Leitender Entwickler)
    • +
    • Thialfihar (Lead developer)
    • 'Senecaso' (QR-Code, Schlüssel signtieren, Schlüssel hochladen)
    • Markus Doits
    diff --git a/OpenPGP-Keychain/src/main/res/raw-es/help_start.html b/OpenPGP-Keychain/src/main/res/raw-es/help_start.html index 895b52469..d56399ef0 100644 --- a/OpenPGP-Keychain/src/main/res/raw-es/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-es/help_start.html @@ -2,7 +2,7 @@

    Primeros pasos

    -

    Primero necesitas un par de claves personales. Crea una a través del menú "Contactos" o importa un par de claves ya existentes a través de "Importar claves". Después, puedes descargar las claves de tus amigos o intercambiarlas a través de códigos QR o NFC.

    +

    Primero necesitas un par de claves personales. Crea una a través de las opciones del menú "Contactos" o importa un par de claves ya existentes a través de "Importar claves". Después, puedes descargar las claves de tus amigos o intercambiarlas a través de códigos QR o NFC.

    Es recomendable que instales OI File Manager para una mejor selección de archivos y Barcode Scanner para escanear los códigos QR generados. Pulsando en los enlaces se abrirá Google Play o F-Droid.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-et/help_about.html b/OpenPGP-Keychain/src/main/res/raw-et/help_about.html new file mode 100644 index 000000000..d9150a5e8 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-et/help_about.html @@ -0,0 +1,48 @@ + + + +

    http://www.openkeychain.org

    +

    OpenKeychain is an OpenPGP implementation for Android.

    +

    License: GPLv3+

    + +

    Developers OpenKeychain

    +
      +
    • Dominik Schürmann (Lead developer)
    • +
    • Ash Hughes (crypto patches)
    • +
    • Brian C. Barnes
    • +
    • Bahtiar 'kalkin' Gadimov (UI)
    • +
    • Daniel Hammann
    • +
    • Daniel Haß
    • +
    • Greg Witczak
    • +
    • Miroojin Bakshi
    • +
    • Paul Sarbinowski
    • +
    • Vincent Breitmoser
    • + +
    +

    Developers APG 1.x

    +
      +
    • Thialfihar (Lead developer)
    • +
    • 'Senecaso' (QRCode, sign key, upload key)
    • +
    • Markus Doits
    • +
    +

    Libraries

    + + + diff --git a/OpenPGP-Keychain/src/main/res/raw-et/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-et/help_changelog.html new file mode 100644 index 000000000..abf660ba8 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-et/help_changelog.html @@ -0,0 +1,108 @@ + + + +

    2.3

    +
      +
    • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
    • +
    • fix setting expiry dates on keys (thanks to Ash Hughes)
    • +
    • more internal fixes when editing keys (thanks to Ash Hughes)
    • +
    • querying keyservers directly from the import screen
    • +
    • fix layout and dialog style on Android 2.2-3.0
    • +
    • fix crash on keys with empty user ids
    • +
    • fix crash and empty lists when coming back from signing screen
    • +
    • Bouncy Castle (cryptography library) updated from 1.47 to 1.50 and build from source
    • +
    • fix upload of key from signing screen
    • +
    +

    2.2

    +
      +
    • new design with navigation drawer
    • +
    • new public key list design
    • +
    • new public key view
    • +
    • bug fixes for importing of keys
    • +
    • key cross-certification (thanks to Ash Hughes)
    • +
    • handle UTF-8 passwords properly (thanks to Ash Hughes)
    • +
    • first version with new languages (thanks to the contributors on Transifex)
    • +
    • sharing of keys via QR Codes fixed and improved
    • +
    • package signature verification for API
    • +
    +

    2.1.1

    +
      +
    • API Updates, preparation for K-9 Mail integration
    • +
    +

    2.1

    +
      +
    • lots of bug fixes
    • +
    • new API for developers
    • +
    • PRNG bug fix by Google
    • +
    +

    2.0

    +
      +
    • complete redesign
    • +
    • share public keys via qr codes, nfc beam
    • +
    • sign keys
    • +
    • upload keys to server
    • +
    • fixes import issues
    • +
    • new AIDL API
    • +
    +

    1.0.8

    +
      +
    • basic keyserver support
    • +
    • app2sd
    • +
    • more choices for pass phrase cache: 1, 2, 4, 8, hours
    • +
    • translations: Norwegian (thanks, Sander Danielsen), Chinese (thanks, Zhang Fredrick)
    • +
    • bugfixes
    • +
    • optimizations
    • +
    +

    1.0.7

    +
      +
    • fixed problem with signature verification of texts with trailing newline
    • +
    • more options for pass phrase cache time to live (20, 40, 60 mins)
    • +
    +

    1.0.6

    +
      +
    • account adding crash on Froyo fixed
    • +
    • secure file deletion
    • +
    • option to delete key file after import
    • +
    • stream encryption/decryption (gallery, etc.)
    • +
    • new options (language, force v3 signatures)
    • +
    • interface changes
    • +
    • bugfixes
    • +
    +

    1.0.5

    +
      +
    • German and Italian translation
    • +
    • much smaller package, due to reduced BC sources
    • +
    • new preferences GUI
    • +
    • layout adjustment for localization
    • +
    • signature bugfix
    • +
    +

    1.0.4

    +
      +
    • fixed another crash caused by some SDK bug with query builder
    • +
    +

    1.0.3

    +
      +
    • fixed crashes during encryption/signing and possibly key export
    • +
    +

    1.0.2

    +
      +
    • filterable key lists
    • +
    • smarter pre-selection of encryption keys
    • +
    • new Intent handling for VIEW and SEND, allows files to be encrypted/decrypted out of file managers
    • +
    • fixes and additional features (key preselection) for K-9 Mail, new beta build available
    • +
    +

    1.0.1

    +
      +
    • GMail account listing was broken in 1.0.0, fixed again
    • +
    +

    1.0.0

    +
      +
    • K-9 Mail integration, APG supporting beta build of K-9 Mail
    • +
    • support of more file managers (including ASTRO)
    • +
    • Slovenian translation
    • +
    • new database, much faster, less memory usage
    • +
    • defined Intents and content provider for other apps
    • +
    • bugfixes
    • +
    + + diff --git a/OpenPGP-Keychain/src/main/res/raw-et/help_nfc_beam.html b/OpenPGP-Keychain/src/main/res/raw-et/help_nfc_beam.html new file mode 100644 index 000000000..88492731c --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-et/help_nfc_beam.html @@ -0,0 +1,12 @@ + + + +

    How to receive keys

    +
      +
    1. Go to your partners contacts and open the contact you want to share.
    2. +
    3. Hold the two devices back to back (they have to be almost touching) and you’ll feel a vibration.
    4. +
    5. After it vibrates you’ll see the content on your partners device turn into a card-like object with Star Trek warp speed-looking animation in the background.
    6. +
    7. Tap the card and the content will then load on the your device.
    8. +
    + + diff --git a/OpenPGP-Keychain/src/main/res/raw-et/help_start.html b/OpenPGP-Keychain/src/main/res/raw-et/help_start.html new file mode 100644 index 000000000..0e60c17a7 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-et/help_start.html @@ -0,0 +1,19 @@ + + + +

    Getting started

    +

    First you need a personal key pair. Create one via the option menus in "Contacts" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    + +

    It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

    + +

    I found a bug in OpenKeychain!

    +

    Please report the bug using the issue tracker of OpenKeychain.

    + +

    Contribute

    +

    If you want to help us developing OpenKeychain by contributing code follow our small guide on Github.

    + +

    Translations

    +

    Help translating OpenKeychain! Everybody can participate at OpenKeychain on Transifex.

    + + + diff --git a/OpenPGP-Keychain/src/main/res/raw-et/nfc_beam_share.html b/OpenPGP-Keychain/src/main/res/raw-et/nfc_beam_share.html new file mode 100644 index 000000000..083e055c7 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-et/nfc_beam_share.html @@ -0,0 +1,11 @@ + + + +
      +
    1. Make sure that NFC is turned on in Settings > More > NFC and make sure that Android Beam is also on in the same section.
    2. +
    3. Hold the two devices back to back (they have to be almost touching) and you'll feel a vibration.
    4. +
    5. After it vibrates you'll see the content on your device turn into a card-like object with Star Trek warp speed-looking animation in the background.
    6. +
    7. Tap the card and the content will then load on the other person’s device.
    8. +
    + + diff --git a/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_start.html b/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_start.html index f8c255232..93a305796 100644 --- a/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_start.html @@ -2,7 +2,7 @@

    شروع کار

    -

    اول شما نیاز به یک جفت کلید شخصی دارید. از طریق منوها در "کلیدهای من" بسازید و یا از طریق"واردات کلیدهای" جفت کلیدهای موجود را وارد کنید. پس از آن، شما می توانید کلید های دوستان خود را دانلود کنید و یا آنها را از طریق کدهای QR یا NFC رد و بدل کنید.

    +

    First you need a personal key pair. Create one via the option menus in "Contacts" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html b/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html index 43094ce9d..afafe0cef 100644 --- a/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html @@ -21,7 +21,7 @@

    Les développeurs d'APG 1.x

      -
    • Thialfihar (développeur principal)
    • +
    • Thialfihar (développeur principal)
    • « Senecaso » (Code QR, signer/téléverser la clef)
    • Markus Doits
    diff --git a/OpenPGP-Keychain/src/main/res/raw-fr/help_start.html b/OpenPGP-Keychain/src/main/res/raw-fr/help_start.html index 962c33d86..ddaac44b1 100644 --- a/OpenPGP-Keychain/src/main/res/raw-fr/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-fr/help_start.html @@ -2,7 +2,7 @@

    Commencer

    -

    Vous avez d'abord besoin d'une paire de clefs personelles. Créez-en une avec l'option du menu « Contacts » ou importez des paires de clefs existantes avec « Importer des clefs ». Ensuite vous pouvez télécharger les clefs de vos amis, ou les échanger par codes QR ou NFC.

    +

    Il vous faut d'abord une paire de clefs personnelles. Créez-en une avec le menu des options dans « Contacts » ou importez des paires de clefs existantes avec « Importer des clefs ». Ensuite vous pouvez télécharger les clefs de vos amis, ou les échanger par codes QR ou NFC.

    Il vous est recommendé d'installer le gestionnaire de fichiers OI pour sa fonction améliorée de séléction des fichiers et le lecteur de codes à barres pour balayer les codes QR générés. Cliquer sur les liens ouvrira Google Play Store ou F-Droid pour l'installation.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html b/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html index 2d17e1882..10f4bba90 100644 --- a/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html @@ -21,7 +21,7 @@

    Sviluppatori APG 1.x

      -
    • Thialfihar (Capo Sviluppatore)
    • +
    • Thialfihar (Lead developer)
    • 'Senecaso' (QRCode, firma chiavi, caricamento chiavi)
    • Markus Doits
    diff --git a/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_start.html b/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_start.html index 1a4a7303e..7255d70bb 100644 --- a/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_start.html @@ -2,7 +2,7 @@

    Per iniziare

    -

    Per prima cosa hai bisogno di un paio di chiavi personali. Creane una tramite i menu di opzione sotto 'Contatti' o importane di esistenti attraverso "Importa Chiavi". Dopodiche' puoi scaricare le chiavi dei tuoi amici o scambiarle tramite Codici QR o NFC.

    +

    First you need a personal key pair. Create one via the option menus in "Contacts" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    Si raccomanda di installare OI File Manager per una migliore selezione dei file e Barcode Scanner per scansionare i codici QR. I collegamenti verranno aperti in Google Play Store o F-Droid per l'installazione.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-ja/help_start.html b/OpenPGP-Keychain/src/main/res/raw-ja/help_start.html index 04ad31352..0a92042b1 100644 --- a/OpenPGP-Keychain/src/main/res/raw-ja/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-ja/help_start.html @@ -2,7 +2,7 @@

    入門

    -

    最初にあなたの個人用鍵ペアが必要になります。オプションメニューの"連絡先"で生成するか、"鍵のインポート"から既存の鍵ペアをインポートします。その後、あなたの友人の鍵をダウンロード、もしくはQRコードやNFCで交換します。

    +

    First you need a personal key pair. Create one via the option menus in "Contacts" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    ファイルの選択を拡張するにはOI File ManagerBarcode Scannerを生成したQRコードのスキャンのため、それぞれのインストールを必要とします。 リンクをクリックして、Google Play Store上かF-Droidからインストールしてください。

    diff --git a/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html b/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html index c41859b60..04e2a727c 100644 --- a/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html @@ -21,7 +21,7 @@

    Deweloperzy APG 1.x

      -
    • Thialfihar (Wiodacy deweloper)
    • +
    • Thialfihar (Wiodący deweloper)
    • 'Senecaso' (kody QR, podpisy kluczy, wysyłanie kluczy)
    • Markus Doits
    diff --git a/OpenPGP-Keychain/src/main/res/raw-pl/help_start.html b/OpenPGP-Keychain/src/main/res/raw-pl/help_start.html index d2faa2db9..e88a1ad6d 100644 --- a/OpenPGP-Keychain/src/main/res/raw-pl/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-pl/help_start.html @@ -2,7 +2,7 @@

    Pierwsze kroki

    -

    Po pierwsze potrzebujesz swoją osobistą parę kluczy. Stwórz ją, korzystając z odpowiedniej opcji w sekcji "Kontakty" lub też zaimportuj istniejącą parę korzystając z sekcji "Importuj klucze". Następnie możesz pobrać klucze Twoich znajomych lub wymieniać się z nimi za pośrednictwem kodów QR lub technologii NFC.

    +

    Po pierwsze potrzebujesz swoją osobistą parę kluczy. Stwórz ją, korzystając z odpowiedniej opcji w sekcji "Kontakty" albo zainportuj istniejącą parę korzystając z sekcji "Inportuj klucze". Następnie możesz porać klucze Twoich znajomych lub wymieniać się z nimi za pośrednictwem kodów QR lub technologii NFC.

    Zalecana jest instalacja menadżera plików OI File Manager w celu zapewnienia wygodniejszego wyboru plików oraz programu Barcode Scanner, który jest w stanie skanować wygenerowane kody QR. Kliknięcie na powyższe linki przekieruje Cię do sklepu Google Play / F-Droid.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html b/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html index 63335110e..0178a8985 100644 --- a/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html @@ -21,7 +21,7 @@

    Разработчики APG 1.x

      -
    • Thialfihar (главный разработчик)
    • +
    • Thialfihar (Lead developer)
    • 'Senecaso' (QR коды, подписание и загрузка ключей)
    • Markus Doits
    diff --git a/OpenPGP-Keychain/src/main/res/raw-ru/help_start.html b/OpenPGP-Keychain/src/main/res/raw-ru/help_start.html index bc9dade67..4188f6d5f 100644 --- a/OpenPGP-Keychain/src/main/res/raw-ru/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-ru/help_start.html @@ -2,7 +2,7 @@

    Приступая

    -

    Для начала вам понадобится своя пара ключей. Воспользуйтесь меню в разделе "Контакты", что бы создать новую, или добавьте ранее созданную пару в разделе "Импорт ключей". После этого вы сможете скачать ключи ваших друзей или обменяться ключами посредством QR кодов или NFC.

    +

    First you need a personal key pair. Create one via the option menus in "Contacts" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    Рекомендуется установить OI File Manager для удобного выбора файлов и Barcode Scanner для распознавания QR кодов. Перейдите по ссылкам на соответствующие страницы Google Play или F-Droid для дальнейшей установки.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html b/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html index d50154765..7c8b8662f 100644 --- a/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html @@ -21,7 +21,7 @@

    Geliştiriciler APG 1.x

      -
    • Thialfihar (Baş geliştirici)
    • +
    • Thialfihar (Lead developer)
    • 'Senecaso' (QR Kodu, anahtar imzalama, anahtar yükleme)
    • Markus Doits
    diff --git a/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html b/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html index 4e6bb02dd..df08ac72a 100644 --- a/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html @@ -11,12 +11,12 @@
  • Аш Гюдж (латки шифрування)
  • Браян С. Барнс
  • Бахтіяр 'kalkin' Ґадімов (інтерфейс)
  • -
  • Daniel Hammann
  • -
  • Daniel Haß
  • -
  • Greg Witczak
  • -
  • Miroojin Bakshi
  • -
  • Paul Sarbinowski
  • -
  • Vincent Breitmoser
  • +
  • Даніель Гаман
  • +
  • Даніель Габ
  • +
  • Ґреґ Вітчак
  • +
  • Міроджін Бакші
  • +
  • Пауль Сарбіновський
  • +
  • Вінсент Брейтмозер
  • Розробники APG 1.x

    diff --git a/OpenPGP-Keychain/src/main/res/raw-uk/help_start.html b/OpenPGP-Keychain/src/main/res/raw-uk/help_start.html index 78443070d..45a3edb6a 100644 --- a/OpenPGP-Keychain/src/main/res/raw-uk/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-uk/help_start.html @@ -2,7 +2,7 @@

    Приступаючи до роботи

    -

    Спершу вам потрібна персональна в'язка ключів. Створіть одну через меню параметрів у "Контакти" або імпортуйте наявні в'язки ключів через "Імпорт ключів". Після цього ви зможете завантажувати ключі ваших друзів чи обміняти їх через штрих-коди або NFC.

    +

    Спершу вам потрібна персональна в'язка ключів. Створіть одну через меню параметрів у "Контактах" або імпортуйте наявні в'язки ключів через "Імпорт ключів". Після цього ви зможете завантажувати ключі ваших друзів чи обміняти їх через штрих-коди або NFC.

    Рекомендуємо вам встановити OI File Manager для поліпшеного виділення файлів та Barcode Scanner для сканування згенерованих штрих-кодів. Натискання посилань відкриє Google Play або F-Droid для встановлення.

    diff --git a/OpenPGP-Keychain/src/main/res/raw-zh/help_start.html b/OpenPGP-Keychain/src/main/res/raw-zh/help_start.html index 104bdd545..22ac99882 100644 --- a/OpenPGP-Keychain/src/main/res/raw-zh/help_start.html +++ b/OpenPGP-Keychain/src/main/res/raw-zh/help_start.html @@ -2,7 +2,7 @@

    快速上手

    -

    首先你需要屬於你個人的金鑰對,從〝我的金鑰〞選單中建立一個或是使用〝匯入金鑰〞匯入現有的金鑰對。在這之後,你可以下載你朋友的公鑰或者是透過二維條碼或NFC和他交換公鑰。

    +

    First you need a personal key pair. Create one via the option menus in "Contacts" or import existing key pairs via "Import Keys". Afterwards, you can download your friends' keys or exchange them via QR Codes or NFC.

    It is recommended that you install OI File Manager for enhanced file selection and Barcode Scanner to scan generated QR Codes. Clicking on the links will open Google Play Store or F-Droid for installation.

    diff --git a/OpenPGP-Keychain/src/main/res/values-cs-rCZ/strings.xml b/OpenPGP-Keychain/src/main/res/values-cs-rCZ/strings.xml index 3d00a143f..9207318d3 100644 --- a/OpenPGP-Keychain/src/main/res/values-cs-rCZ/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-cs-rCZ/strings.xml @@ -1,8 +1,30 @@ + Kontakty + Tajné klíče + Zvolit veřejný klíč + Zvolit tajný klíč + Zašifrovat + Dešifrovat + Heslo + Vytvořit klíč + Upravit klíč + Nastavení + Registrované aplikace + Nastavení serveru s klíči + Zadat heslo + Poslat zprávu... + Importovat klíče + Exportovat klíč + Exportovat klíče + Klíč nenalezen + Nahrát na server s klíči + Nápověda + Klíče + Podepsat diff --git a/OpenPGP-Keychain/src/main/res/values-es/strings.xml b/OpenPGP-Keychain/src/main/res/values-es/strings.xml index 85c77b0da..d7436e02d 100644 --- a/OpenPGP-Keychain/src/main/res/values-es/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-es/strings.xml @@ -208,6 +208,8 @@ ¿Quieres realmente borrar la clave \'%s\'?\n¡No podrás deshacerlo! ¿Quieres realmente borrar todas las claves seleccionadas?\n¡No podrás deshacerlo! ¿Quieres realmente borrar la clave SECRETA \'%s\'?\n¡No podrás deshacerlo! + ¿Quieres realmente borrar la clave PÚBLICA \'%s\'?\n¡No podrás deshacerlo! + ¿Borrar claves secretas? ¿Exportar también las claves secretas? %d clave añadida satisfactoriamente @@ -376,6 +378,8 @@ Descifrar con OpenKeychain ¡No hay aplicaciones registradas!\n\nLas aplicaciones de terceros pueden pedir permiso de acceso a OpenKeychain. Después de obtener acceso, serán enumeradas aquí. + Mostrar información avanzada + Ocultar información avanzada Mostrar la configuración avanzada Ocultar la configuración avanzada No se ha seleccionado ninguna clave @@ -385,6 +389,8 @@ Revocar acceso Nombre de paquete SHA-256 de firma de paquete + Cuentas + No hay cuentas asociadas a esta aplicación. La aplicación mostrada solicita acceso a OpenKeychain.\n¿Permitir el acceso?\n\nAVISO: Si no sabes por qué aparece esta pantalla, ¡deniega el acceso! Puedes revocarlo después usando la pantalla \'Aplicaciones registradas\'. Permitir el acceso Denegar el acceso @@ -432,4 +438,5 @@ IDs de usuario para firmar Nueva aplicación de certificados + Escribe aquí el mensaje que quieras cifrar... diff --git a/OpenPGP-Keychain/src/main/res/values-et/strings.xml b/OpenPGP-Keychain/src/main/res/values-et/strings.xml new file mode 100644 index 000000000..04570b4b6 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/values-et/strings.xml @@ -0,0 +1,123 @@ + + + + Kontaktid + Salajased võtmed + Vali avalik võti + Vali salajane võti + Krüpteeri + Dekrüpteeri + Salasõne + Loo võti + Muuda võtit + Seaded + Registreeritud rakendused + Võtmeserveri seaded + Määra salasõne + Saada kiri... + Impordi võtmeid + Ekspordi võti + Ekspordi võtmed + Võtit ei leitud + Päri võtmeserverist + Lae võtmeserverisse + Võõras allkirjastamise võti + Abi + + Kasutaja ID-d + Võtmed + Üldine + Vaikeseaded + + Allkirjasta + Dekrüpteeri + Vali saajad + Salvesta + Katkesta + Kustuta + Määra salasõne + Otsi + Saada võtmeserverisse + Järgmine + Tagasi + + Seaded + Kustuta võti + Loo võti + Otsi + Võtmeserver... + Uuenda võtmeserverist + Saada võtmeserverisse + Jaga... + Allkirjasta võti + + Allkirjasta + Sõnum + Fail + Salasõnet pole + Salasõne + Uuesti + Algoritm + Saajad + Kustuta peale šifreerimist + Räsialgoritm + Avalik võti + Salasõne + Salasõne puhverdus + Võtmeserverid + Loodud + Aegub + Kasutusvaldkond + Võtmepikkus + Nimi + Kommentaar + E-mail + + aegunud + Sõrmejälg: + Salajane võti: + + Ainult allkirjastamine + Ainult krüpteerimine + Allkirjastamine ja krüpteerimine + 15 sekundit + 1 minut + 3 minutit + 5 minutit + 10 minutit + 20 minutit + 40 minutit + 1 tund + 2 tundi + 4 tundi + 8 tundi + DSA + ElGamal + RSA + Ava... + Hoiatus + Viga + Viga: %s + + Vale salasõne + Määra enne salasõne. + Salasõned ei ühti. + Tühi salasõne pole lubatud. + Sümmeetriline krüpteering + + + + + + + + + + + + + + + diff --git a/OpenPGP-Keychain/src/main/res/values-fr/strings.xml b/OpenPGP-Keychain/src/main/res/values-fr/strings.xml index 4f92f7855..6c0d526d4 100644 --- a/OpenPGP-Keychain/src/main/res/values-fr/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-fr/strings.xml @@ -208,6 +208,8 @@ Voulez-vous vraiment supprimer la clef %s ?\nVous ne pourrez pas la restituer ! Voulez-vous vraiment supprimer toutes les clefs choisies ?\nCeci est irréversible ! Voulez-vous vraiment supprimer la clef SECRÈTE %s ?\nVous ne pourrez pas la restituer ! + Voulez-vous vraiment supprimer la clef PUBLIQUE « %s » ?\nVous ne pourrez pas la restituer ! + Supprimer les clefs privées ? Exporter aussi les clefs secrètes? %d clef ajoutée avec succès @@ -376,6 +378,8 @@ Déchiffrer avec OpenKeychain Aucune application enregistrée !\n\nLes applications tierces peuvent demander l\'accès à OpenKeychain. Après avoir autorisé l\'accès, elles seront listées ici. + Afficher les informations avancées + Masquer les informations avancées Afficher les paramètres avancés Masquer les paramètres avancés Aucune clef choisie @@ -385,6 +389,8 @@ Révoquer l\'accès Nom du paquet SHA-256 de la signature du paquet + Comptes + Aucun compte n\'est attaché à cette application. L\'application affichée demande l\'accès à OpenKeychain.\nPermettre l\'accès ?\n\nAvertissement : si vous ne savez pas pourquoi cet écran est apparu, refusez l\'accès ! Vous pourrez révoquer l\'accès plus tard en utilisant l\'écran « Applications enregistrées ». Permettre l\'accès Enlever l\'accès @@ -432,4 +438,5 @@ ID utilisateur pour signer Nouvel application des certificats + Écrire le message à chiffrer ici... diff --git a/OpenPGP-Keychain/src/main/res/values-it-rIT/strings.xml b/OpenPGP-Keychain/src/main/res/values-it-rIT/strings.xml index b125de448..23dd432a4 100644 --- a/OpenPGP-Keychain/src/main/res/values-it-rIT/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-it-rIT/strings.xml @@ -208,6 +208,8 @@ Vuoi veramente eliminare la chiave \'%s\'?\nNon potrai annullare! Vuoi veramente eliminare le chiavi selezionate?\nNon potrai annullare! Vuoi veramente eliminare la chiave PRIVATA \'%s\'?\nNon potrai annullare! + Vuoi veramente eliminare la chiave PUBBLICA \'%s\'?\nNon potrai annullare! + Eliminare le Chiavi Segrete? Esportare anche le chiavi segrete? %d chiave aggiunta correttamente @@ -432,4 +434,5 @@ ID Utente da firmare Riapplicazione certificati + Scrivi qui il messaggio da codificare... diff --git a/OpenPGP-Keychain/src/main/res/values-ja/strings.xml b/OpenPGP-Keychain/src/main/res/values-ja/strings.xml index 97f0c6eed..f28f73262 100644 --- a/OpenPGP-Keychain/src/main/res/values-ja/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-ja/strings.xml @@ -205,6 +205,8 @@ 鍵\'%s\'を本当に削除してもよいですか?\nこれは元に戻せません! 選択したすべての鍵を本当に削除してよいですか?\nこれは元に戻せません。 秘密鍵\'%s\'を本当に削除してもよいですか?\nこれは元に戻せません! + 公開鍵\'%s\'を本当に削除してもよいですか?\nこれは元に戻せません! + 秘密鍵を削除しますか? 秘密鍵もエクスポートしますか? %d の鍵を追加しました @@ -417,4 +419,5 @@ 署名に使うユーザーID 検証を再適用する + ここに書いたメッセージを暗号化.. diff --git a/OpenPGP-Keychain/src/main/res/values-pl/strings.xml b/OpenPGP-Keychain/src/main/res/values-pl/strings.xml index afdf72223..e31216176 100644 --- a/OpenPGP-Keychain/src/main/res/values-pl/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-pl/strings.xml @@ -211,6 +211,8 @@ Czy na pewno chcesz usunąć klucz \'%s\'?\nNie można cofnąć tej operacji! Czy na pewno chcesz usunąć wszystkie zaznaczone klucze?\nTej operacji nie można cofnąć! Czy na pewno chcesz usunąć klucz prywatny \'%s\'?\nNie można cofnąć tej operacji! + Czy na pewno chcesz usunąć klucz publiczny \'%s\'?\nNie można cofnąć tej operacji! + Usunąć klucze prywatne? Czy wyeksportować również klucze prywatne? Pomyślnie dodano %d klucz @@ -390,6 +392,8 @@ Deszyfruj korzystając z OpenKeychain Brak zarejestrowanych aplikacji!\n\nZewnętrzne aplikacje mogą żądać dostępu do OpenKeychain. Po przyznaniu dostępu, będa wyświetlone tutaj. + Pokaż zaawansowane informacje + Ukryj zaawansowane informacje Pokaż zaawanowane ustawienia Ukryj zaawansowane ustawienia Nie wybrano klucza @@ -399,6 +403,8 @@ Odwołaj dostęp Nazwa paczki Skrót SHA-256 podpisu paczki + Konta + Nie przypisano żadnych kont do tej aplikacji Wyświetlona aplikacja prosi o dostęp do OpenKeychain.\nZezwolić?\n\nOSTRZEZENIE: Jeżeli nie wiesz, czemu wyświetlił się ten komunikat, nie zezwalaj na dostęp! Możesz to również zrobić później, korzystając z ekranu \'Zarejestrowane aplikacje\'. Zezwól na dostęp Odmów dostępu @@ -447,4 +453,5 @@ Identyfikator użytkownika do podpisu Ponowne stosowanie certyfikatów + Wpisz tutaj wiadomość do zaszyfrowania... diff --git a/OpenPGP-Keychain/src/main/res/values-ru/strings.xml b/OpenPGP-Keychain/src/main/res/values-ru/strings.xml index 55e778bee..88a529b66 100644 --- a/OpenPGP-Keychain/src/main/res/values-ru/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-ru/strings.xml @@ -74,13 +74,17 @@ Импорт Импорт из NFC Экспорт всех ключей + Экспорт всех секретных ключей Экспорт в файл Удалить ключ Создать ключ Создать ключ (эксперт) Поиск + Сервер ключей + Сервер ключей... Обновить с сервера ключей Загрузить на сервер ключей + Отправить... Отправить отпечаток... Отправить ключ... Отправить @@ -143,6 +147,12 @@ подпись просрочен отозван + ID пользователя + + 1 контакт + %d контактов + %d контактов + %d сервер ключей %d серверов ключей @@ -199,6 +209,9 @@ Вы уверены, что ходите удалить ключ \'%s\'?\nЭто действие нельзя отменить! Вы уверены, что хотите удалить ВСЕ выбранные ключи?\nЭто действие нельзя отменить! Вы уверены, что ходите удалить СЕКРЕТНЫЙ ключ \'%s\'?\nЭто действие нельзя отменить! + Вы правда хотите удалить ПУБЛИЧНЫЙ ключ \'%s\'?\nЭто нельзя отменить! + Удалить секретные ключи? + Экспортировать секретные ключи? Успешно добавлено %d ключ Успешно добавлено %d ключей @@ -224,6 +237,7 @@ Экспортировано %d ключей. Ключи не были экспортированы. Инфо: ElGamal подходит только для дополнительных ключей. При создании ключа будет использован ближайший из размеров: 1536, 2048, 3072, 4096, или 8192. + Внимание: создание ключей RSA длиной 1024 бита и менее признано небезопасным. Данная возможность отключена. Не удается найти ключ %08X. Найден %d ключ. @@ -347,6 +361,7 @@ очень медленно Начать + ЧаВо NFC Beam Изменения О программе @@ -410,6 +425,7 @@ создать свой ключ Импортировать ключи + Изменить ключ Зашифровать для этого получателя Сертифицировать ключ этого контакта Информация @@ -423,5 +439,11 @@ Связанные приложения Открыть панель навигации Закрыть панель навигации + Изменить + Мои ключи + Секретный ключ + доступен + не доступен + Напишите сообщение здесь, что бы зашифровать... diff --git a/OpenPGP-Keychain/src/main/res/values-uk/strings.xml b/OpenPGP-Keychain/src/main/res/values-uk/strings.xml index 58ac643af..00655fc53 100644 --- a/OpenPGP-Keychain/src/main/res/values-uk/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-uk/strings.xml @@ -211,6 +211,8 @@ Ви справді хочете вилучити ключ \'%s\'?\nВи не зможете це відмінити! Ви справді хочете вилучити усі вибрані ключі?\nВи не зможете це відмінити! Ви справді хочете вилучити секретний ключ \'%s\'?\nВи не зможете це відмінити! + Справді волієте вилучити ВІДКРИТИЙ ключ \'%s\'?\nВи е зможете відмінити цю дію! + Видалити секретні ключі? Також експортувати секретні ключі? Успішно додано %d ключ @@ -390,6 +392,8 @@ Розшифрувати з OpenKeychain Нема зареєстрованих програм!\n\nСтороні програми можуть вимагати доступ до OpenPGP Keychain. Після надання доступу вони будуть наведені тут. + Показати додаткову інформацію + Приховати додаткову інформацію Показати додаткові налаштування Приховати додаткові налаштування Не вибрано ключа @@ -399,6 +403,8 @@ Відкликати доступ Назва пакунку SHA-256 підписку пакунку + Облікові записи + Немає облікового запису приєднаного до цієї програми. Показана програма запитує доступ до OpenPGP Keychain.\nДозволити доступ?\n\nУВАГА: якщо ви не знаєте, чому цей екран появився, не дозволяйте доступ! Ви можете відкликати доступ пізніше, використовуючи екран \'Зареєстровані програми\'. Дозволити доступ Не дозволити доступ @@ -447,4 +453,5 @@ ІД користувача для реєстрації Перезастосування сертифікатів + Напишіть повідомлення для шифрування… -- cgit v1.2.3 From 8e9ceffae3a2c89063a3e3073c7d6424388275e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 22:45:35 +0100 Subject: Changelog for 2.4 --- .../src/main/res/raw-de/help_changelog.html | 108 --------------------- OpenPGP-Keychain/src/main/res/raw/help_about.html | 4 +- .../src/main/res/raw/help_changelog.html | 18 ++++ 3 files changed, 21 insertions(+), 109 deletions(-) delete mode 100644 OpenPGP-Keychain/src/main/res/raw-de/help_changelog.html diff --git a/OpenPGP-Keychain/src/main/res/raw-de/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-de/help_changelog.html deleted file mode 100644 index e414324d0..000000000 --- a/OpenPGP-Keychain/src/main/res/raw-de/help_changelog.html +++ /dev/null @@ -1,108 +0,0 @@ - - - -

    2.3

    -
      -
    • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
    • -
    • fix setting expiry dates on keys (thanks to Ash Hughes)
    • -
    • more internal fixes when editing keys (thanks to Ash Hughes)
    • -
    • querying keyservers directly from the import screen
    • -
    • fix layout and dialog style on Android 2.2-3.0
    • -
    • Absturz bei leeren Nutzer IDs behoben
    • -
    • fix crash and empty lists when coming back from signing screen
    • -
    • Bouncy Castle (cryptography library) updated from 1.47 to 1.50 and build from source
    • -
    • fix upload of key from signing screen
    • -
    -

    2.2

    -
      -
    • new design with navigation drawer
    • -
    • Neus Design für die Liste der öffentlichen Schlüssel
    • -
    • new public key view
    • -
    • Fehler beim Schlüsselimport behoben
    • -
    • key cross-certification (thanks to Ash Hughes)
    • -
    • handle UTF-8 passwords properly (thanks to Ash Hughes)
    • -
    • Erste Version mit neuen Sprachen (Danke an die Mitwirkenden bei Transifex)
    • -
    • sharing of keys via QR Codes fixed and improved
    • -
    • package signature verification for API
    • -
    -

    2.1.1

    -
      -
    • API Updates, preparation for K-9 Mail integration
    • -
    -

    2.1

    -
      -
    • Viele Fehler behoben
    • -
    • Neue API für Entwickler
    • -
    • PRNG Bugfix von Google
    • -
    -

    2.0

    -
      -
    • Komlett neu designd
    • -
    • Öffentliche Schlüssel teilen via QR Code, NFC Beam
    • -
    • Schlüssel signieren
    • -
    • Schlüssel auf den Server hochladen
    • -
    • Importprobleme behoben
    • -
    • new AIDL API
    • -
    -

    1.0.8

    -
      -
    • Grundlegende Schlüsselserverunterstützung
    • -
    • app2sd
    • -
    • mehr Auswahlmöglichkeiten für den Passwortcache: 1, 2, 4, 8, Stunden
    • -
    • Übersetzungen: norwegisch (Danke, Sander Danielsen), chinesisch (danke, Zhang Fredrick)
    • -
    • Fehlerbehebungen
    • -
    • Optimierungen
    • -
    -

    1.0.7

    -
      -
    • fixed problem with signature verification of texts with trailing newline
    • -
    • weitere Optionen für die Time-to-live des Passphrasencaches (20, 40, 60 mins)
    • -
    -

    1.0.6

    -
      -
    • crash beim Hinzufügen eines Kontos auf Froyo repariert
    • -
    • sichere Dateilöschung
    • -
    • Option, um Schlüsseldatei nach dem Import zu löschen
    • -
    • Streamverschlüsselung/-entschlüsselung (Galerie, etc.)
    • -
    • neue Optionen (Sprache, v3-Unterschriften erzwingen)
    • -
    • Interfaceänderungen
    • -
    • Fehlerbehebungen
    • -
    -

    1.0.5

    -
      -
    • Deutsche und Italienische Übersetzung
    • -
    • viel kleineres Paket, dank reduzierter BC Quellen
    • -
    • Neues Einstellungs-GUI
    • -
    • Lay-Out-Anpassung für die Lokalisierung
    • -
    • Fehler bei Signatur behoben
    • -
    -

    1.0.4

    -
      -
    • fixed another crash caused by some SDK bug with query builder
    • -
    -

    1.0.3

    -
      -
    • Absturz während der Verschlüsselung/Signierung und möglicherweise Schlüsselexport behoben.
    • -
    -

    1.0.2

    -
      -
    • Filterbare Schlüsselliste
    • -
    • smarter pre-selection of encryption keys
    • -
    • new Intent handling for VIEW and SEND, allows files to be encrypted/decrypted out of file managers
    • -
    • fixes and additional features (key preselection) for K-9 Mail, new beta build available
    • -
    -

    1.0.1

    -
      -
    • GMail account listing was broken in 1.0.0, fixed again
    • -
    -

    1.0.0

    -
      -
    • K-9 Mail integration, APG supporting beta build of K-9 Mail
    • -
    • Unterstützung von mehr Filemanagern (einschließlich ASTRO)
    • -
    • Slowenische Übersetzung
    • -
    • Neue Datenbank, viel schneller, weniger Speicherbedarf
    • -
    • defined Intents and content provider for other apps
    • -
    • Fehlerbehebungen
    • -
    - - diff --git a/OpenPGP-Keychain/src/main/res/raw/help_about.html b/OpenPGP-Keychain/src/main/res/raw/help_about.html index 2ffbb47a6..847168446 100644 --- a/OpenPGP-Keychain/src/main/res/raw/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw/help_about.html @@ -19,10 +19,12 @@ And don't add newlines before or after p tags because of transifex -->
  • Daniel Haß
  • Greg Witczak
  • Miroojin Bakshi
  • +
  • Nikhil Peter Raj
  • Paul Sarbinowski
  • +
  • Sreeram Boyapati
  • Vincent Breitmoser
  • - +

    Developers APG 1.x

    • Thialfihar (Lead developer)
    • diff --git a/OpenPGP-Keychain/src/main/res/raw/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw/help_changelog.html index 17ad853de..0e7c4d212 100644 --- a/OpenPGP-Keychain/src/main/res/raw/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw/help_changelog.html @@ -5,6 +5,24 @@ And don't add newlines before or after p tags because of transifex --> +

      2.4

      +

      Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

      +
        +
      • new unified key list
      • +
      • colorized key fingerprint
      • +
      • support for keyserver ports
      • +
      • deactivate possibility to generate weak keys
      • +
      • much more internal work on the API
      • +
      • certify user ids
      • +
      • keyserver query based on machine-readable output
      • +
      • lock navigation drawer on tablets
      • +
      • suggestions for emails on creation of keys
      • +
      • search in public key lists
      • +
      • and much more improvements and fixes…
      • +
      +

      2.3

      • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
      • -- cgit v1.2.3 From a589b6e7fe204e832df3c52dd387aa8c30a79b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 22:48:23 +0100 Subject: Changelog for 2.4 --- CHANGELOG | 16 ++++++++++++++++ OpenPGP-Keychain/src/main/res/raw/help_changelog.html | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 548dd1289..e7f4c567a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,19 @@ +2.4 +Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser. +* new unified key list +* colorized key fingerprint +* support for keyserver ports +* deactivate possibility to generate weak keys +* much more internal work on the API +* certify user ids +* keyserver query based on machine-readable output +* lock navigation drawer on tablets +* suggestions for emails on creation of keys +* search in public key lists +* and much more improvements and fixes… + 2.3.1 * hotfix for crash when upgrading from old versions diff --git a/OpenPGP-Keychain/src/main/res/raw/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw/help_changelog.html index 0e7c4d212..595878fe7 100644 --- a/OpenPGP-Keychain/src/main/res/raw/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw/help_changelog.html @@ -23,6 +23,11 @@ Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Pa
      • and much more improvements and fixes…
      +

      2.3.1

      +
        +
      • hotfix for crash when upgrading from old versions
      • +
      +

      2.3

      • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
      • -- cgit v1.2.3 From 619c079f008dc214639d1988757e66b03b32c661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 22:55:33 +0100 Subject: Sync changelog and about with transifex --- .../src/main/res/raw-cs-rCZ/help_about.html | 3 +- .../src/main/res/raw-cs-rCZ/help_changelog.html | 21 ++++ .../src/main/res/raw-de/help_about.html | 3 +- .../src/main/res/raw-de/help_changelog.html | 129 +++++++++++++++++++++ .../src/main/res/raw-el/help_about.html | 3 +- .../src/main/res/raw-el/help_changelog.html | 21 ++++ .../src/main/res/raw-es-rCO/help_about.html | 3 +- .../src/main/res/raw-es-rCO/help_changelog.html | 21 ++++ .../src/main/res/raw-es/help_about.html | 3 +- .../src/main/res/raw-es/help_changelog.html | 21 ++++ .../src/main/res/raw-et/help_about.html | 3 +- .../src/main/res/raw-et/help_changelog.html | 21 ++++ .../src/main/res/raw-fa-rIR/help_about.html | 3 +- .../src/main/res/raw-fa-rIR/help_changelog.html | 21 ++++ .../src/main/res/raw-fr/help_about.html | 3 +- .../src/main/res/raw-fr/help_changelog.html | 21 ++++ .../src/main/res/raw-it-rIT/help_about.html | 3 +- .../src/main/res/raw-it-rIT/help_changelog.html | 21 ++++ .../src/main/res/raw-ja/help_about.html | 3 +- .../src/main/res/raw-ja/help_changelog.html | 21 ++++ .../src/main/res/raw-nl-rNL/help_about.html | 3 +- .../src/main/res/raw-nl-rNL/help_changelog.html | 21 ++++ .../src/main/res/raw-pl/help_about.html | 3 +- .../src/main/res/raw-pl/help_changelog.html | 21 ++++ .../src/main/res/raw-pt-rBR/help_about.html | 3 +- .../src/main/res/raw-pt-rBR/help_changelog.html | 21 ++++ .../src/main/res/raw-ru/help_about.html | 3 +- .../src/main/res/raw-ru/help_changelog.html | 21 ++++ .../src/main/res/raw-sl-rSI/help_about.html | 3 +- .../src/main/res/raw-sl-rSI/help_changelog.html | 21 ++++ .../src/main/res/raw-tr/help_about.html | 3 +- .../src/main/res/raw-tr/help_changelog.html | 21 ++++ .../src/main/res/raw-uk/help_about.html | 3 +- .../src/main/res/raw-uk/help_changelog.html | 21 ++++ .../src/main/res/raw-zh-rTW/help_about.html | 3 +- .../src/main/res/raw-zh-rTW/help_changelog.html | 21 ++++ .../src/main/res/raw-zh/help_about.html | 3 +- .../src/main/res/raw-zh/help_changelog.html | 21 ++++ 38 files changed, 545 insertions(+), 19 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/res/raw-de/help_changelog.html diff --git a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html index 066e53a89..99977f75d 100644 --- a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_about.html @@ -15,9 +15,10 @@
      • Daniel Haß
      • Greg Witczak
      • Miroojin Bakshi
      • +
      • Nikhil Peter Raj
      • Paul Sarbinowski
      • +
      • Sreeram Boyapati
      • Vincent Breitmoser
      • -

      Developers APG 1.x

        diff --git a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_changelog.html index abf660ba8..1136deba6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_changelog.html @@ -1,6 +1,27 @@ +

        2.4

        +

        Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

        +
          +
        • new unified key list
        • +
        • colorized key fingerprint
        • +
        • support for keyserver ports
        • +
        • deactivate possibility to generate weak keys
        • +
        • much more internal work on the API
        • +
        • certify user ids
        • +
        • keyserver query based on machine-readable output
        • +
        • lock navigation drawer on tablets
        • +
        • suggestions for emails on creation of keys
        • +
        • search in public key lists
        • +
        • and much more improvements and fixes…
        • +
        +

        2.3.1

        +
          +
        • hotfix for crash when upgrading from old versions
        • +

        2.3

        • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
        • diff --git a/OpenPGP-Keychain/src/main/res/raw-de/help_about.html b/OpenPGP-Keychain/src/main/res/raw-de/help_about.html index 9115ba9c5..7dc0ee7d9 100644 --- a/OpenPGP-Keychain/src/main/res/raw-de/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-de/help_about.html @@ -15,9 +15,10 @@
        • Daniel Haß
        • Greg Witczak
        • Miroojin Bakshi
        • +
        • Nikhil Peter Raj
        • Paul Sarbinowski
        • +
        • Sreeram Boyapati
        • Vincent Breitmoser
        • -

        Entwickler APG 1.x

          diff --git a/OpenPGP-Keychain/src/main/res/raw-de/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-de/help_changelog.html new file mode 100644 index 000000000..13b210fcd --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/raw-de/help_changelog.html @@ -0,0 +1,129 @@ + + + +

          2.4

          +

          Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

          +
            +
          • new unified key list
          • +
          • colorized key fingerprint
          • +
          • support for keyserver ports
          • +
          • deactivate possibility to generate weak keys
          • +
          • much more internal work on the API
          • +
          • certify user ids
          • +
          • keyserver query based on machine-readable output
          • +
          • lock navigation drawer on tablets
          • +
          • suggestions for emails on creation of keys
          • +
          • search in public key lists
          • +
          • and much more improvements and fixes…
          • +
          +

          2.3.1

          +
            +
          • hotfix for crash when upgrading from old versions
          • +
          +

          2.3

          +
            +
          • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
          • +
          • fix setting expiry dates on keys (thanks to Ash Hughes)
          • +
          • more internal fixes when editing keys (thanks to Ash Hughes)
          • +
          • querying keyservers directly from the import screen
          • +
          • fix layout and dialog style on Android 2.2-3.0
          • +
          • Absturz bei leeren Nutzer IDs behoben
          • +
          • fix crash and empty lists when coming back from signing screen
          • +
          • Bouncy Castle (cryptography library) updated from 1.47 to 1.50 and build from source
          • +
          • fix upload of key from signing screen
          • +
          +

          2.2

          +
            +
          • new design with navigation drawer
          • +
          • Neus Design für die Liste der öffentlichen Schlüssel
          • +
          • new public key view
          • +
          • Fehler beim Schlüsselimport behoben
          • +
          • key cross-certification (thanks to Ash Hughes)
          • +
          • handle UTF-8 passwords properly (thanks to Ash Hughes)
          • +
          • Erste Version mit neuen Sprachen (Danke an die Mitwirkenden bei Transifex)
          • +
          • sharing of keys via QR Codes fixed and improved
          • +
          • package signature verification for API
          • +
          +

          2.1.1

          +
            +
          • API Updates, preparation for K-9 Mail integration
          • +
          +

          2.1

          +
            +
          • Viele Fehler behoben
          • +
          • Neue API für Entwickler
          • +
          • PRNG Bugfix von Google
          • +
          +

          2.0

          +
            +
          • Komlett neu designd
          • +
          • Öffentliche Schlüssel teilen via QR Code, NFC Beam
          • +
          • Schlüssel signieren
          • +
          • Schlüssel auf den Server hochladen
          • +
          • Importprobleme behoben
          • +
          • new AIDL API
          • +
          +

          1.0.8

          +
            +
          • Grundlegende Schlüsselserverunterstützung
          • +
          • app2sd
          • +
          • mehr Auswahlmöglichkeiten für den Passwortcache: 1, 2, 4, 8, Stunden
          • +
          • Übersetzungen: norwegisch (Danke, Sander Danielsen), chinesisch (danke, Zhang Fredrick)
          • +
          • Fehlerbehebungen
          • +
          • Optimierungen
          • +
          +

          1.0.7

          +
            +
          • fixed problem with signature verification of texts with trailing newline
          • +
          • weitere Optionen für die Time-to-live des Passphrasencaches (20, 40, 60 mins)
          • +
          +

          1.0.6

          +
            +
          • crash beim Hinzufügen eines Kontos auf Froyo repariert
          • +
          • sichere Dateilöschung
          • +
          • Option, um Schlüsseldatei nach dem Import zu löschen
          • +
          • Streamverschlüsselung/-entschlüsselung (Galerie, etc.)
          • +
          • neue Optionen (Sprache, v3-Unterschriften erzwingen)
          • +
          • Interfaceänderungen
          • +
          • Fehlerbehebungen
          • +
          +

          1.0.5

          +
            +
          • Deutsche und Italienische Übersetzung
          • +
          • viel kleineres Paket, dank reduzierter BC Quellen
          • +
          • Neues Einstellungs-GUI
          • +
          • Lay-Out-Anpassung für die Lokalisierung
          • +
          • Fehler bei Signatur behoben
          • +
          +

          1.0.4

          +
            +
          • fixed another crash caused by some SDK bug with query builder
          • +
          +

          1.0.3

          +
            +
          • Absturz während der Verschlüsselung/Signierung und möglicherweise Schlüsselexport behoben.
          • +
          +

          1.0.2

          +
            +
          • Filterbare Schlüsselliste
          • +
          • smarter pre-selection of encryption keys
          • +
          • new Intent handling for VIEW and SEND, allows files to be encrypted/decrypted out of file managers
          • +
          • fixes and additional features (key preselection) for K-9 Mail, new beta build available
          • +
          +

          1.0.1

          +
            +
          • GMail account listing was broken in 1.0.0, fixed again
          • +
          +

          1.0.0

          +
            +
          • K-9 Mail integration, APG supporting beta build of K-9 Mail
          • +
          • Unterstützung von mehr Filemanagern (einschließlich ASTRO)
          • +
          • Slowenische Übersetzung
          • +
          • Neue Datenbank, viel schneller, weniger Speicherbedarf
          • +
          • defined Intents and content provider for other apps
          • +
          • Fehlerbehebungen
          • +
          + + diff --git a/OpenPGP-Keychain/src/main/res/raw-el/help_about.html b/OpenPGP-Keychain/src/main/res/raw-el/help_about.html index d9150a5e8..ae7e16aae 100644 --- a/OpenPGP-Keychain/src/main/res/raw-el/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-el/help_about.html @@ -15,9 +15,10 @@
        • Daniel Haß
        • Greg Witczak
        • Miroojin Bakshi
        • +
        • Nikhil Peter Raj
        • Paul Sarbinowski
        • +
        • Sreeram Boyapati
        • Vincent Breitmoser
        • -

        Developers APG 1.x

          diff --git a/OpenPGP-Keychain/src/main/res/raw-el/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-el/help_changelog.html index abf660ba8..1136deba6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-el/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-el/help_changelog.html @@ -1,6 +1,27 @@ +

          2.4

          +

          Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

          +
            +
          • new unified key list
          • +
          • colorized key fingerprint
          • +
          • support for keyserver ports
          • +
          • deactivate possibility to generate weak keys
          • +
          • much more internal work on the API
          • +
          • certify user ids
          • +
          • keyserver query based on machine-readable output
          • +
          • lock navigation drawer on tablets
          • +
          • suggestions for emails on creation of keys
          • +
          • search in public key lists
          • +
          • and much more improvements and fixes…
          • +
          +

          2.3.1

          +
            +
          • hotfix for crash when upgrading from old versions
          • +

          2.3

          • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
          • diff --git a/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html b/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html index d9150a5e8..ae7e16aae 100644 --- a/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_about.html @@ -15,9 +15,10 @@
          • Daniel Haß
          • Greg Witczak
          • Miroojin Bakshi
          • +
          • Nikhil Peter Raj
          • Paul Sarbinowski
          • +
          • Sreeram Boyapati
          • Vincent Breitmoser
          • -

          Developers APG 1.x

            diff --git a/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_changelog.html index abf660ba8..1136deba6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_changelog.html @@ -1,6 +1,27 @@ +

            2.4

            +

            Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

            +
              +
            • new unified key list
            • +
            • colorized key fingerprint
            • +
            • support for keyserver ports
            • +
            • deactivate possibility to generate weak keys
            • +
            • much more internal work on the API
            • +
            • certify user ids
            • +
            • keyserver query based on machine-readable output
            • +
            • lock navigation drawer on tablets
            • +
            • suggestions for emails on creation of keys
            • +
            • search in public key lists
            • +
            • and much more improvements and fixes…
            • +
            +

            2.3.1

            +
              +
            • hotfix for crash when upgrading from old versions
            • +

            2.3

            • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
            • diff --git a/OpenPGP-Keychain/src/main/res/raw-es/help_about.html b/OpenPGP-Keychain/src/main/res/raw-es/help_about.html index 552155d68..7a4f61127 100644 --- a/OpenPGP-Keychain/src/main/res/raw-es/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-es/help_about.html @@ -15,9 +15,10 @@
            • Daniel Haß
            • Greg Witczak
            • Miroojin Bakshi
            • +
            • Nikhil Peter Raj
            • Paul Sarbinowski
            • +
            • Sreeram Boyapati
            • Vincent Breitmoser
            • -

            Desarrolladores de APG 1.x

              diff --git a/OpenPGP-Keychain/src/main/res/raw-es/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-es/help_changelog.html index dfb51dc81..b776b3534 100644 --- a/OpenPGP-Keychain/src/main/res/raw-es/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-es/help_changelog.html @@ -1,6 +1,27 @@ +

              2.4

              +

              Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

              +
                +
              • new unified key list
              • +
              • colorized key fingerprint
              • +
              • support for keyserver ports
              • +
              • deactivate possibility to generate weak keys
              • +
              • much more internal work on the API
              • +
              • certify user ids
              • +
              • keyserver query based on machine-readable output
              • +
              • lock navigation drawer on tablets
              • +
              • suggestions for emails on creation of keys
              • +
              • search in public key lists
              • +
              • and much more improvements and fixes…
              • +
              +

              2.3.1

              +
                +
              • hotfix for crash when upgrading from old versions
              • +

              2.3

              • elimina la exportación innecesaria de claves públicas cuando se exporta la clave secreta (gracias a Ash Hughes)
              • diff --git a/OpenPGP-Keychain/src/main/res/raw-et/help_about.html b/OpenPGP-Keychain/src/main/res/raw-et/help_about.html index d9150a5e8..ae7e16aae 100644 --- a/OpenPGP-Keychain/src/main/res/raw-et/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-et/help_about.html @@ -15,9 +15,10 @@
              • Daniel Haß
              • Greg Witczak
              • Miroojin Bakshi
              • +
              • Nikhil Peter Raj
              • Paul Sarbinowski
              • +
              • Sreeram Boyapati
              • Vincent Breitmoser
              • -

              Developers APG 1.x

                diff --git a/OpenPGP-Keychain/src/main/res/raw-et/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-et/help_changelog.html index abf660ba8..1136deba6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-et/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-et/help_changelog.html @@ -1,6 +1,27 @@ +

                2.4

                +

                Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

                +
                  +
                • new unified key list
                • +
                • colorized key fingerprint
                • +
                • support for keyserver ports
                • +
                • deactivate possibility to generate weak keys
                • +
                • much more internal work on the API
                • +
                • certify user ids
                • +
                • keyserver query based on machine-readable output
                • +
                • lock navigation drawer on tablets
                • +
                • suggestions for emails on creation of keys
                • +
                • search in public key lists
                • +
                • and much more improvements and fixes…
                • +
                +

                2.3.1

                +
                  +
                • hotfix for crash when upgrading from old versions
                • +

                2.3

                • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
                • diff --git a/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html b/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html index d9150a5e8..ae7e16aae 100644 --- a/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_about.html @@ -15,9 +15,10 @@
                • Daniel Haß
                • Greg Witczak
                • Miroojin Bakshi
                • +
                • Nikhil Peter Raj
                • Paul Sarbinowski
                • +
                • Sreeram Boyapati
                • Vincent Breitmoser
                • -

                Developers APG 1.x

                  diff --git a/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_changelog.html index abf660ba8..1136deba6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_changelog.html @@ -1,6 +1,27 @@ +

                  2.4

                  +

                  Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

                  +
                    +
                  • new unified key list
                  • +
                  • colorized key fingerprint
                  • +
                  • support for keyserver ports
                  • +
                  • deactivate possibility to generate weak keys
                  • +
                  • much more internal work on the API
                  • +
                  • certify user ids
                  • +
                  • keyserver query based on machine-readable output
                  • +
                  • lock navigation drawer on tablets
                  • +
                  • suggestions for emails on creation of keys
                  • +
                  • search in public key lists
                  • +
                  • and much more improvements and fixes…
                  • +
                  +

                  2.3.1

                  +
                    +
                  • hotfix for crash when upgrading from old versions
                  • +

                  2.3

                  • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
                  • diff --git a/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html b/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html index afafe0cef..00370c77e 100644 --- a/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-fr/help_about.html @@ -15,9 +15,10 @@
                  • Daniel Haß
                  • Greg Witczak
                  • Miroojin Bakshi
                  • +
                  • Nikhil Peter Raj
                  • Paul Sarbinowski
                  • +
                  • Sreeram Boyapati
                  • Vincent Breitmoser
                  • -

                  Les développeurs d'APG 1.x

                    diff --git a/OpenPGP-Keychain/src/main/res/raw-fr/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-fr/help_changelog.html index c86c4a465..56a35d70e 100644 --- a/OpenPGP-Keychain/src/main/res/raw-fr/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-fr/help_changelog.html @@ -1,6 +1,27 @@ +

                    2.4

                    +

                    Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

                    +
                      +
                    • new unified key list
                    • +
                    • colorized key fingerprint
                    • +
                    • support for keyserver ports
                    • +
                    • deactivate possibility to generate weak keys
                    • +
                    • much more internal work on the API
                    • +
                    • certify user ids
                    • +
                    • keyserver query based on machine-readable output
                    • +
                    • lock navigation drawer on tablets
                    • +
                    • suggestions for emails on creation of keys
                    • +
                    • search in public key lists
                    • +
                    • and much more improvements and fixes…
                    • +
                    +

                    2.3.1

                    +
                      +
                    • hotfix for crash when upgrading from old versions
                    • +

                    2.3

                    • supprimer l'exportation non nécessaire des clefs publiques lors de l'exportation d'une clef secrète
                    • diff --git a/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html b/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html index 10f4bba90..917c7cc49 100644 --- a/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_about.html @@ -15,9 +15,10 @@
                    • Daniel Haß
                    • Greg Witczak
                    • Miroojin Bakshi
                    • +
                    • Nikhil Peter Raj
                    • Paul Sarbinowski
                    • +
                    • Sreeram Boyapati
                    • Vincent Breitmoser
                    • -

                    Sviluppatori APG 1.x

                      diff --git a/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_changelog.html index 050d2c9ef..de167f870 100644 --- a/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_changelog.html @@ -1,6 +1,27 @@ +

                      2.4

                      +

                      Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

                      +
                        +
                      • new unified key list
                      • +
                      • colorized key fingerprint
                      • +
                      • support for keyserver ports
                      • +
                      • deactivate possibility to generate weak keys
                      • +
                      • much more internal work on the API
                      • +
                      • certify user ids
                      • +
                      • keyserver query based on machine-readable output
                      • +
                      • lock navigation drawer on tablets
                      • +
                      • suggestions for emails on creation of keys
                      • +
                      • search in public key lists
                      • +
                      • and much more improvements and fixes…
                      • +
                      +

                      2.3.1

                      +
                        +
                      • hotfix for crash when upgrading from old versions
                      • +

                      2.3

                      • rimossa esportazione non necessaria delle chiavi pubbliche quando si esportano le chiavi private (grazie a Ash Hughes)
                      • diff --git a/OpenPGP-Keychain/src/main/res/raw-ja/help_about.html b/OpenPGP-Keychain/src/main/res/raw-ja/help_about.html index 3f630264c..e60add867 100644 --- a/OpenPGP-Keychain/src/main/res/raw-ja/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-ja/help_about.html @@ -15,9 +15,10 @@
                      • Daniel Haß
                      • Greg Witczak
                      • Miroojin Bakshi
                      • +
                      • Nikhil Peter Raj
                      • Paul Sarbinowski
                      • +
                      • Sreeram Boyapati
                      • Vincent Breitmoser
                      • -

                      APG 1.xの開発者達

                        diff --git a/OpenPGP-Keychain/src/main/res/raw-ja/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-ja/help_changelog.html index 4878a3b55..e60c7f63f 100644 --- a/OpenPGP-Keychain/src/main/res/raw-ja/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-ja/help_changelog.html @@ -1,6 +1,27 @@ +

                        2.4

                        +

                        Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

                        +
                          +
                        • new unified key list
                        • +
                        • colorized key fingerprint
                        • +
                        • support for keyserver ports
                        • +
                        • deactivate possibility to generate weak keys
                        • +
                        • much more internal work on the API
                        • +
                        • certify user ids
                        • +
                        • keyserver query based on machine-readable output
                        • +
                        • lock navigation drawer on tablets
                        • +
                        • suggestions for emails on creation of keys
                        • +
                        • search in public key lists
                        • +
                        • and much more improvements and fixes…
                        • +
                        +

                        2.3.1

                        +
                          +
                        • hotfix for crash when upgrading from old versions
                        • +

                        2.3

                        • 秘密鍵のエクスポート時における必要でない公開鍵のエクスポートの削除 (thanks to Ash Hughes)
                        • diff --git a/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html b/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html index d9150a5e8..ae7e16aae 100644 --- a/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_about.html @@ -15,9 +15,10 @@
                        • Daniel Haß
                        • Greg Witczak
                        • Miroojin Bakshi
                        • +
                        • Nikhil Peter Raj
                        • Paul Sarbinowski
                        • +
                        • Sreeram Boyapati
                        • Vincent Breitmoser
                        • -

                        Developers APG 1.x

                          diff --git a/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_changelog.html index abf660ba8..1136deba6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_changelog.html @@ -1,6 +1,27 @@ +

                          2.4

                          +

                          Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

                          +
                            +
                          • new unified key list
                          • +
                          • colorized key fingerprint
                          • +
                          • support for keyserver ports
                          • +
                          • deactivate possibility to generate weak keys
                          • +
                          • much more internal work on the API
                          • +
                          • certify user ids
                          • +
                          • keyserver query based on machine-readable output
                          • +
                          • lock navigation drawer on tablets
                          • +
                          • suggestions for emails on creation of keys
                          • +
                          • search in public key lists
                          • +
                          • and much more improvements and fixes…
                          • +
                          +

                          2.3.1

                          +
                            +
                          • hotfix for crash when upgrading from old versions
                          • +

                          2.3

                          • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
                          • diff --git a/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html b/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html index 04e2a727c..a033c084a 100644 --- a/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-pl/help_about.html @@ -15,9 +15,10 @@
                          • Daniel Haß
                          • Greg Witczak
                          • Miroojin Bakshi
                          • +
                          • Nikhil Peter Raj
                          • Paul Sarbinowski
                          • +
                          • Sreeram Boyapati
                          • Vincent Breitmoser
                          • -

                          Deweloperzy APG 1.x

                            diff --git a/OpenPGP-Keychain/src/main/res/raw-pl/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-pl/help_changelog.html index cdf124d3a..18ea0735e 100644 --- a/OpenPGP-Keychain/src/main/res/raw-pl/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-pl/help_changelog.html @@ -1,6 +1,27 @@ +

                            2.4

                            +

                            Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

                            +
                              +
                            • new unified key list
                            • +
                            • colorized key fingerprint
                            • +
                            • support for keyserver ports
                            • +
                            • deactivate possibility to generate weak keys
                            • +
                            • much more internal work on the API
                            • +
                            • certify user ids
                            • +
                            • keyserver query based on machine-readable output
                            • +
                            • lock navigation drawer on tablets
                            • +
                            • suggestions for emails on creation of keys
                            • +
                            • search in public key lists
                            • +
                            • and much more improvements and fixes…
                            • +
                            +

                            2.3.1

                            +
                              +
                            • hotfix for crash when upgrading from old versions
                            • +

                            2.3

                            • usunięto zbędne eksportowanie kluczy publicznych przy eksportowaniu kluczy prywatnych (podziękowania dla Ash Hughes)
                            • diff --git a/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html b/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html index d9150a5e8..ae7e16aae 100644 --- a/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_about.html @@ -15,9 +15,10 @@
                            • Daniel Haß
                            • Greg Witczak
                            • Miroojin Bakshi
                            • +
                            • Nikhil Peter Raj
                            • Paul Sarbinowski
                            • +
                            • Sreeram Boyapati
                            • Vincent Breitmoser
                            • -

                            Developers APG 1.x

                              diff --git a/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_changelog.html index abf660ba8..1136deba6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_changelog.html @@ -1,6 +1,27 @@ +

                              2.4

                              +

                              Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

                              +
                                +
                              • new unified key list
                              • +
                              • colorized key fingerprint
                              • +
                              • support for keyserver ports
                              • +
                              • deactivate possibility to generate weak keys
                              • +
                              • much more internal work on the API
                              • +
                              • certify user ids
                              • +
                              • keyserver query based on machine-readable output
                              • +
                              • lock navigation drawer on tablets
                              • +
                              • suggestions for emails on creation of keys
                              • +
                              • search in public key lists
                              • +
                              • and much more improvements and fixes…
                              • +
                              +

                              2.3.1

                              +
                                +
                              • hotfix for crash when upgrading from old versions
                              • +

                              2.3

                              • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
                              • diff --git a/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html b/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html index 0178a8985..9a8e5a413 100644 --- a/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-ru/help_about.html @@ -15,9 +15,10 @@
                              • Daniel Haß
                              • Greg Witczak
                              • Miroojin Bakshi
                              • +
                              • Nikhil Peter Raj
                              • Paul Sarbinowski
                              • +
                              • Sreeram Boyapati
                              • Vincent Breitmoser
                              • -

                              Разработчики APG 1.x

                                diff --git a/OpenPGP-Keychain/src/main/res/raw-ru/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-ru/help_changelog.html index 2a324202f..447c04f17 100644 --- a/OpenPGP-Keychain/src/main/res/raw-ru/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-ru/help_changelog.html @@ -1,6 +1,27 @@ +

                                2.4

                                +

                                Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

                                +
                                  +
                                • new unified key list
                                • +
                                • colorized key fingerprint
                                • +
                                • support for keyserver ports
                                • +
                                • deactivate possibility to generate weak keys
                                • +
                                • much more internal work on the API
                                • +
                                • certify user ids
                                • +
                                • keyserver query based on machine-readable output
                                • +
                                • lock navigation drawer on tablets
                                • +
                                • suggestions for emails on creation of keys
                                • +
                                • search in public key lists
                                • +
                                • and much more improvements and fixes…
                                • +
                                +

                                2.3.1

                                +
                                  +
                                • hotfix for crash when upgrading from old versions
                                • +

                                2.3

                                • удален не требующийся экспорт публичного ключа при экспорте секретного ключа (спасибо, Ash Hughes)
                                • diff --git a/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html b/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html index d9150a5e8..ae7e16aae 100644 --- a/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_about.html @@ -15,9 +15,10 @@
                                • Daniel Haß
                                • Greg Witczak
                                • Miroojin Bakshi
                                • +
                                • Nikhil Peter Raj
                                • Paul Sarbinowski
                                • +
                                • Sreeram Boyapati
                                • Vincent Breitmoser
                                • -

                                Developers APG 1.x

                                  diff --git a/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_changelog.html index abf660ba8..1136deba6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_changelog.html @@ -1,6 +1,27 @@ +

                                  2.4

                                  +

                                  Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

                                  +
                                    +
                                  • new unified key list
                                  • +
                                  • colorized key fingerprint
                                  • +
                                  • support for keyserver ports
                                  • +
                                  • deactivate possibility to generate weak keys
                                  • +
                                  • much more internal work on the API
                                  • +
                                  • certify user ids
                                  • +
                                  • keyserver query based on machine-readable output
                                  • +
                                  • lock navigation drawer on tablets
                                  • +
                                  • suggestions for emails on creation of keys
                                  • +
                                  • search in public key lists
                                  • +
                                  • and much more improvements and fixes…
                                  • +
                                  +

                                  2.3.1

                                  +
                                    +
                                  • hotfix for crash when upgrading from old versions
                                  • +

                                  2.3

                                  • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
                                  • diff --git a/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html b/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html index 7c8b8662f..7d2c24f9c 100644 --- a/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-tr/help_about.html @@ -15,9 +15,10 @@
                                  • Daniel Haß
                                  • Greg Witczak
                                  • Miroojin Bakshi
                                  • +
                                  • Nikhil Peter Raj
                                  • Paul Sarbinowski
                                  • +
                                  • Sreeram Boyapati
                                  • Vincent Breitmoser
                                  • -

                                  Geliştiriciler APG 1.x

                                    diff --git a/OpenPGP-Keychain/src/main/res/raw-tr/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-tr/help_changelog.html index abf660ba8..1136deba6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-tr/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-tr/help_changelog.html @@ -1,6 +1,27 @@ +

                                    2.4

                                    +

                                    Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

                                    +
                                      +
                                    • new unified key list
                                    • +
                                    • colorized key fingerprint
                                    • +
                                    • support for keyserver ports
                                    • +
                                    • deactivate possibility to generate weak keys
                                    • +
                                    • much more internal work on the API
                                    • +
                                    • certify user ids
                                    • +
                                    • keyserver query based on machine-readable output
                                    • +
                                    • lock navigation drawer on tablets
                                    • +
                                    • suggestions for emails on creation of keys
                                    • +
                                    • search in public key lists
                                    • +
                                    • and much more improvements and fixes…
                                    • +
                                    +

                                    2.3.1

                                    +
                                      +
                                    • hotfix for crash when upgrading from old versions
                                    • +

                                    2.3

                                    • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
                                    • diff --git a/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html b/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html index df08ac72a..b839b50e1 100644 --- a/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-uk/help_about.html @@ -15,9 +15,10 @@
                                    • Даніель Габ
                                    • Ґреґ Вітчак
                                    • Міроджін Бакші
                                    • +
                                    • Nikhil Peter Raj
                                    • Пауль Сарбіновський
                                    • +
                                    • Sreeram Boyapati
                                    • Вінсент Брейтмозер
                                    • -

                                    Розробники APG 1.x

                                      diff --git a/OpenPGP-Keychain/src/main/res/raw-uk/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-uk/help_changelog.html index 0b67fa3a9..826638e75 100644 --- a/OpenPGP-Keychain/src/main/res/raw-uk/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-uk/help_changelog.html @@ -1,6 +1,27 @@ +

                                      2.4

                                      +

                                      Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

                                      +
                                        +
                                      • new unified key list
                                      • +
                                      • colorized key fingerprint
                                      • +
                                      • support for keyserver ports
                                      • +
                                      • deactivate possibility to generate weak keys
                                      • +
                                      • much more internal work on the API
                                      • +
                                      • certify user ids
                                      • +
                                      • keyserver query based on machine-readable output
                                      • +
                                      • lock navigation drawer on tablets
                                      • +
                                      • suggestions for emails on creation of keys
                                      • +
                                      • search in public key lists
                                      • +
                                      • and much more improvements and fixes…
                                      • +
                                      +

                                      2.3.1

                                      +
                                        +
                                      • hotfix for crash when upgrading from old versions
                                      • +

                                      2.3

                                      • видалений непотрібний експорт публічного ключа при експорті секретного ключа (завдяки Ash Hughes)
                                      • diff --git a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html index d9150a5e8..ae7e16aae 100644 --- a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_about.html @@ -15,9 +15,10 @@
                                      • Daniel Haß
                                      • Greg Witczak
                                      • Miroojin Bakshi
                                      • +
                                      • Nikhil Peter Raj
                                      • Paul Sarbinowski
                                      • +
                                      • Sreeram Boyapati
                                      • Vincent Breitmoser
                                      • -

                                      Developers APG 1.x

                                        diff --git a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_changelog.html index abf660ba8..1136deba6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_changelog.html @@ -1,6 +1,27 @@ +

                                        2.4

                                        +

                                        Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

                                        +
                                          +
                                        • new unified key list
                                        • +
                                        • colorized key fingerprint
                                        • +
                                        • support for keyserver ports
                                        • +
                                        • deactivate possibility to generate weak keys
                                        • +
                                        • much more internal work on the API
                                        • +
                                        • certify user ids
                                        • +
                                        • keyserver query based on machine-readable output
                                        • +
                                        • lock navigation drawer on tablets
                                        • +
                                        • suggestions for emails on creation of keys
                                        • +
                                        • search in public key lists
                                        • +
                                        • and much more improvements and fixes…
                                        • +
                                        +

                                        2.3.1

                                        +
                                          +
                                        • hotfix for crash when upgrading from old versions
                                        • +

                                        2.3

                                        • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
                                        • diff --git a/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html b/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html index 1eec8bdbf..813676ea2 100644 --- a/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html +++ b/OpenPGP-Keychain/src/main/res/raw-zh/help_about.html @@ -15,9 +15,10 @@
                                        • Daniel Haß
                                        • Greg Witczak
                                        • Miroojin Bakshi
                                        • +
                                        • Nikhil Peter Raj
                                        • Paul Sarbinowski
                                        • +
                                        • Sreeram Boyapati
                                        • Vincent Breitmoser
                                        • -

                                        Developers APG 1.x

                                          diff --git a/OpenPGP-Keychain/src/main/res/raw-zh/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-zh/help_changelog.html index abf660ba8..1136deba6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-zh/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-zh/help_changelog.html @@ -1,6 +1,27 @@ +

                                          2.4

                                          +

                                          Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! +Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): +Daniel Hammann, Daniel Haß, Greg Witczak, Miroojin Bakshi, Nikhil Peter Raj, Paul Sarbinowski, Sreeram Boyapati, Vincent Breitmoser.

                                          +
                                            +
                                          • new unified key list
                                          • +
                                          • colorized key fingerprint
                                          • +
                                          • support for keyserver ports
                                          • +
                                          • deactivate possibility to generate weak keys
                                          • +
                                          • much more internal work on the API
                                          • +
                                          • certify user ids
                                          • +
                                          • keyserver query based on machine-readable output
                                          • +
                                          • lock navigation drawer on tablets
                                          • +
                                          • suggestions for emails on creation of keys
                                          • +
                                          • search in public key lists
                                          • +
                                          • and much more improvements and fixes…
                                          • +
                                          +

                                          2.3.1

                                          +
                                            +
                                          • hotfix for crash when upgrading from old versions
                                          • +

                                          2.3

                                          • remove unnecessary export of public keys when exporting secret key (thanks to Ash Hughes)
                                          • -- cgit v1.2.3 From 68668fd444b973502b91b7cbe0cf7dbdd8a8b5c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 26 Mar 2014 22:56:51 +0100 Subject: Version 2.4 --- OpenPGP-Keychain/src/main/AndroidManifest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/AndroidManifest.xml b/OpenPGP-Keychain/src/main/AndroidManifest.xml index e6a082743..10505248f 100644 --- a/OpenPGP-Keychain/src/main/AndroidManifest.xml +++ b/OpenPGP-Keychain/src/main/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="24000" + android:versionName="2.4"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml index f221ff8de..7347d222c 100644 --- a/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml @@ -1,14 +1,19 @@ - + android:orientation="horizontal" + android:layout_alignParentTop="true" + android:id="@+id/linearLayout"> - - \ No newline at end of file + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_message_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_message_fragment.xml index 3deee0eca..f11f79c1e 100644 --- a/OpenPGP-Keychain/src/main/res/layout/decrypt_message_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_message_fragment.xml @@ -1,15 +1,64 @@ - + android:layout_height="match_parent" + android:fillViewport="true"> - - + android:paddingTop="4dp" + android:paddingLeft="10dp" + android:paddingRight="10dp" + android:orientation="vertical"> + + + + + + + + + + + + + diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index 2e88062b7..5d325d5ec 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -51,6 +51,7 @@ Certify Decrypt Decrypt and Verify + From Clipboard Select Recipients Encrypt File Save -- cgit v1.2.3 From ccce28acdbba740389b56c2ff0fccdf1b9304604 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 30 Mar 2014 19:35:35 +0200 Subject: compiles again --- .../org/sufficientlysecure/keychain/ui/DecryptActivity.java | 4 ++-- .../sufficientlysecure/keychain/ui/DecryptFileFragment.java | 12 +++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java index 21e51dcd9..2ffed07ff 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java @@ -313,7 +313,7 @@ public class DecryptActivity extends DrawerActivity implements DecryptSignatureR if (path != null) { mInputFilename = path; mFilename.setText(mInputFilename); - guessOutputFilename(); +// guessOutputFilename(); // mSource.setInAnimation(null); // mSource.setOutAnimation(null); // while (mSource.getCurrentView().getId() != R.id.sourceFile) { @@ -356,7 +356,7 @@ public class DecryptActivity extends DrawerActivity implements DecryptSignatureR if (mDecryptTarget == Id.target.file) { String currentFilename = mFilename.getText().toString(); if (mInputFilename == null || !mInputFilename.equals(currentFilename)) { - guessOutputFilename(); +// guessOutputFilename(); } if (mInputFilename.equals("")) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java index 3d40eaf09..6646be8ee 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java @@ -49,6 +49,8 @@ public class DecryptFileFragment extends Fragment { private String mInputFilename = null; private String mOutputFilename = null; + private FileDialogFragment mFileDialog; + private static final int RESULT_CODE_FILE = 0x00007003; @@ -71,15 +73,15 @@ public class DecryptFileFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.decrypt_file_fragment, container, false); - mFilename = (EditText) findViewById(R.id.filename); - mBrowse = (BootstrapButton) findViewById(R.id.btn_browse); + mFilename = (EditText) view.findViewById(R.id.filename); + mBrowse = (BootstrapButton) view.findViewById(R.id.btn_browse); mBrowse.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { - FileHelper.openFile(DecryptActivity.this, mFilename.getText().toString(), "*/*", + FileHelper.openFile(getActivity(), mFilename.getText().toString(), "*/*", RESULT_CODE_FILE); } }); - mDeleteAfter = (CheckBox) findViewById(R.id.deleteAfterDecryption); + mDeleteAfter = (CheckBox) view.findViewById(R.id.deleteAfterDecryption); mDecryptButton = (BootstrapButton) view.findViewById(R.id.action_decrypt); mDecryptButton.setOnClickListener(new View.OnClickListener() { @Override @@ -152,7 +154,7 @@ public class DecryptFileFragment extends Fragment { getString(R.string.title_decrypt_to_file), getString(R.string.specify_file_to_decrypt_to), mOutputFilename, null); - mFileDialog.show(getSupportFragmentManager(), "fileDialog"); + mFileDialog.show(getActivity().getSupportFragmentManager(), "fileDialog"); } } -- cgit v1.2.3 From 55a2cbe9c311ec7ed12d07491e34a48c60bc0ae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Sun, 30 Mar 2014 20:53:16 +0200 Subject: Decrypt mostly works again --- .../keychain/service/KeychainIntentService.java | 57 +-- .../keychain/ui/DecryptActivity.java | 555 ++------------------- .../keychain/ui/DecryptFileFragment.java | 180 ++++++- .../keychain/ui/DecryptMessageFragment.java | 16 +- .../keychain/ui/adapter/PageTabStripAdapter.java | 74 --- .../keychain/ui/adapter/PagerTabStripAdapter.java | 74 +++ .../src/main/res/layout/decrypt_content.xml | 129 +---- .../src/main/res/layout/decrypt_file_fragment.xml | 14 +- 8 files changed, 327 insertions(+), 772 deletions(-) delete mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PageTabStripAdapter.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PagerTabStripAdapter.java diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 2cc3798e0..7ac1747b7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -428,29 +428,30 @@ public class KeychainIntentService extends IntentService break; - case TARGET_STREAM: /* decrypting stream from content uri */ - Uri providerUri = (Uri) data.getParcelable(ENCRYPT_PROVIDER_URI); - - // InputStream - InputStream in = getContentResolver().openInputStream(providerUri); - inLength = PgpHelper.getLengthOfStream(in); - inputData = new InputData(in, inLength); - - // OutputStream - try { - while (true) { - streamFilename = PgpHelper.generateRandomFilename(32); - if (streamFilename == null) { - throw new PgpGeneralException("couldn't generate random file name"); - } - openFileInput(streamFilename).close(); - } - } catch (FileNotFoundException e) { - // found a name that isn't used yet - } - outStream = openFileOutput(streamFilename, Context.MODE_PRIVATE); - - break; + // TODO: not used, maybe contains code useful for new decrypt method for files? +// case TARGET_STREAM: /* decrypting stream from content uri */ +// Uri providerUri = (Uri) data.getParcelable(ENCRYPT_PROVIDER_URI); +// +// // InputStream +// InputStream in = getContentResolver().openInputStream(providerUri); +// inLength = PgpHelper.getLengthOfStream(in); +// inputData = new InputData(in, inLength); +// +// // OutputStream +// try { +// while (true) { +// streamFilename = PgpHelper.generateRandomFilename(32); +// if (streamFilename == null) { +// throw new PgpGeneralException("couldn't generate random file name"); +// } +// openFileInput(streamFilename).close(); +// } +// } catch (FileNotFoundException e) { +// // found a name that isn't used yet +// } +// outStream = openFileOutput(streamFilename, Context.MODE_PRIVATE); +// +// break; default: throw new PgpGeneralException("No target choosen!"); @@ -486,11 +487,11 @@ public class KeychainIntentService extends IntentService // nothing, file was written, just send okay and verification bundle break; - case TARGET_STREAM: - String uri = DataStream.buildDataStreamUri(streamFilename).toString(); - resultData.putString(RESULT_URI, uri); - - break; +// case TARGET_STREAM: +// String uri = DataStream.buildDataStreamUri(streamFilename).toString(); +// resultData.putString(RESULT_URI, uri); +// +// break; } OtherHelper.logDebugBundle(resultData, "resultData"); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java index 2ffed07ff..3e153a71b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 Dominik Schürmann + * Copyright (C) 2012-2014 Dominik Schürmann * Copyright (C) 2010 Thialfihar * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,45 +20,32 @@ package org.sufficientlysecure.keychain.ui; import android.content.Intent; import android.net.Uri; import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.os.Messenger; -import android.support.v4.app.Fragment; import android.support.v4.view.PagerTabStrip; import android.support.v4.view.ViewPager; import android.view.View; import android.view.View.OnClickListener; -import android.widget.*; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; +import android.widget.Toast; import com.beardedhen.androidbootstrap.BootstrapButton; import com.devspark.appmsg.AppMsg; import org.openintents.openpgp.OpenPgpSignatureResult; -import org.spongycastle.openpgp.PGPPublicKeyRing; import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.ActionBarHelper; import org.sufficientlysecure.keychain.helper.FileHelper; -import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify; import org.sufficientlysecure.keychain.pgp.PgpHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; -import org.sufficientlysecure.keychain.pgp.exception.NoAsymmetricEncryptionException; -import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; -import org.sufficientlysecure.keychain.provider.ProviderHelper; -import org.sufficientlysecure.keychain.service.PassphraseCacheService; -import org.sufficientlysecure.keychain.ui.adapter.PageTabStripAdapter; -import org.sufficientlysecure.keychain.ui.dialog.FileDialogFragment; -import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; +import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter; import org.sufficientlysecure.keychain.util.Log; -import java.io.*; import java.util.regex.Matcher; -//@SuppressLint("NewApi") public class DecryptActivity extends DrawerActivity implements DecryptSignatureResultDisplay { - /* Intents */ // without permission public static final String ACTION_DECRYPT = Constants.INTENT_PREFIX + "DECRYPT"; @@ -66,56 +53,24 @@ public class DecryptActivity extends DrawerActivity implements DecryptSignatureR /* EXTRA keys for input */ public static final String EXTRA_TEXT = "text"; - public static final String EXTRA_SELECTED_TAB = "selected_tab"; - private static final int RESULT_CODE_LOOKUP_KEY = 0x00007006; - private static final int RESULT_CODE_FILE = 0x00007003; private long mSignatureKeyId = 0; -// private boolean mReturnResult = false; - - // TODO: replace signed only checks with something more intelligent - // PgpDecryptVerify should handle all automatically!!! - private boolean mSignedOnly = false; - private boolean mAssumeSymmetricEncryption = false; - - // private EditText mMessage = null; private RelativeLayout mSignatureLayout = null; private ImageView mSignatureStatusImage = null; private TextView mUserId = null; private TextView mUserIdRest = null; -// private ViewFlipper mSource = null; -// private TextView mSourceLabel = null; -// private ImageView mSourcePrevious = null; -// private ImageView mSourceNext = null; - - private int mDecryptTarget; - - private EditText mFilename = null; - private CheckBox mDeleteAfter = null; - private BootstrapButton mBrowse = null; private BootstrapButton mLookupKey = null; - private String mInputFilename = null; - private String mOutputFilename = null; - - private Uri mContentUri = null; - private boolean mReturnBinary = false; - - private long mSecretKeyId = Id.key.none; - - private FileDialogFragment mFileDialog; - -// private boolean mDecryptImmediately = false; - - private BootstrapButton mDecryptButton; - ViewPager mViewPager; PagerTabStrip mPagerTabStrip; - PageTabStripAdapter mTabsAdapter; + PagerTabStripAdapter mTabsAdapter; + Bundle mMessageFragmentBundle = new Bundle(); + Bundle mFileFragmentBundle = new Bundle(); + int mSwitchToTab = PAGER_TAB_MESSAGE; private static final int PAGER_TAB_MESSAGE = 0; private static final int PAGER_TAB_FILE = 1; @@ -126,75 +81,20 @@ public class DecryptActivity extends DrawerActivity implements DecryptSignatureR mSignatureStatusImage = (ImageView) findViewById(R.id.ic_signature_status); mUserId = (TextView) findViewById(R.id.mainUserId); mUserIdRest = (TextView) findViewById(R.id.mainUserIdRest); - - // measure the height of the source_file view and set the message view's min height to that, - // so it fills mSource fully... bit of a hack. -// View tmp = findViewById(R.id.sourceFile); -// tmp.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); -// int height = tmp.getMeasuredHeight(); -// mMessage.setMinimumHeight(height); - -// mFilename = (EditText) findViewById(R.id.filename); -// mBrowse = (BootstrapButton) findViewById(R.id.btn_browse); -// mBrowse.setOnClickListener(new View.OnClickListener() { -// public void onClick(View v) { -// FileHelper.openFile(DecryptActivity.this, mFilename.getText().toString(), "*/*", -// RESULT_CODE_FILE); -// } -// }); -// -// mLookupKey = (BootstrapButton) findViewById(R.id.lookup_key); -// mLookupKey.setOnClickListener(new OnClickListener() { -// @Override -// public void onClick(View v) { -// lookupUnknownKey(mSignatureKeyId); -// } -// }); -// -// mDeleteAfter = (CheckBox) findViewById(R.id.deleteAfterDecryption); - - // default: message source -// mSource.setInAnimation(null); -// mSource.setOutAnimation(null); -// while (mSource.getCurrentView().getId() != R.id.sourceMessage) { -// mSource.showNext(); -// } - -// mDecryptButton = (BootstrapButton) findViewById(R.id.action_decrypt); -// mDecryptButton.setOnClickListener(new OnClickListener() { -// @Override -// public void onClick(View v) { -// decryptClicked(); -// } -// }); - + mLookupKey = (BootstrapButton) findViewById(R.id.lookup_key); + mLookupKey.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + lookupUnknownKey(mSignatureKeyId); + } + }); // Pager mViewPager = (ViewPager) findViewById(R.id.decrypt_pager); mPagerTabStrip = (PagerTabStrip) findViewById(R.id.decrypt_pager_tab_strip); - mTabsAdapter = new PageTabStripAdapter(this); + mTabsAdapter = new PagerTabStripAdapter(this); mViewPager.setAdapter(mTabsAdapter); - - Bundle messageBundle = new Bundle(); - mTabsAdapter.addTab(DecryptMessageFragment.class, messageBundle, getString(R.string.label_message)); - - Bundle fileBundle = new Bundle(); - mTabsAdapter.addTab(DecryptFileFragment.class, fileBundle, getString(R.string.label_file)); - } - - - /** - * find fragment - * - * @param pos - * @return - */ - public Fragment getFragmentByPosition(int pos) { - // based on FragmentPagerAdapter.makeFragmentName() - String tag = "android:switcher:" + mViewPager.getId() + ":" + pos; - Log.d(Constants.TAG, "findFragmentByTag: "+tag); - return getSupportFragmentManager().findFragmentByTag(tag); } @Override @@ -210,23 +110,17 @@ public class DecryptActivity extends DrawerActivity implements DecryptSignatureR setupDrawerNavigation(savedInstanceState); - // Handle intent actions + // Handle intent actions, maybe changes the bundles handleActions(getIntent()); + mTabsAdapter.addTab(DecryptMessageFragment.class, mMessageFragmentBundle, getString(R.string.label_message)); + mTabsAdapter.addTab(DecryptFileFragment.class, mFileFragmentBundle, getString(R.string.label_file)); + mViewPager.setCurrentItem(mSwitchToTab); + mSignatureLayout.setVisibility(View.GONE); mSignatureLayout.setOnClickListener(new OnClickListener() { public void onClick(View v) { - if (mSignatureKeyId == 0) { - return; - } - PGPPublicKeyRing key = ProviderHelper.getPGPPublicKeyRingByKeyId( - DecryptActivity.this, mSignatureKeyId); - if (key != null) { - Intent intent = new Intent(DecryptActivity.this, ImportKeysActivity.class); - intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER); - intent.putExtra(ImportKeysActivity.EXTRA_KEY_ID, mSignatureKeyId); - startActivity(intent); - } + lookupUnknownKey(mSignatureKeyId); } }); } @@ -288,9 +182,8 @@ public class DecryptActivity extends DrawerActivity implements DecryptSignatureR // replace non breakable spaces textData = textData.replaceAll("\\xa0", " "); -// mViewPager.setCurrentItem(PAGER_TAB_MESSAGE, false); -// mMessageFragment.setText(textData); -// mMessage.setText(textData); + mMessageFragmentBundle.putString(DecryptMessageFragment.ARG_CIPHERTEXT, textData); + mSwitchToTab = PAGER_TAB_MESSAGE; } else { matcher = PgpHelper.PGP_CLEARTEXT_SIGNATURE.matcher(textData); if (matcher.matches()) { @@ -298,10 +191,9 @@ public class DecryptActivity extends DrawerActivity implements DecryptSignatureR textData = matcher.group(1); // replace non breakable spaces textData = textData.replaceAll("\\xa0", " "); -// mMessage.setText(textData); -// mViewPager.setCurrentItem(PAGER_TAB_MESSAGE, false); -// mMessageFragment = (DecryptMessageFragment) getFragmentByPosition(mViewPager.getCurrentItem()); -// mMessageFragment.setText(textData); + + mMessageFragmentBundle.putString(DecryptMessageFragment.ARG_CIPHERTEXT, textData); + mSwitchToTab = PAGER_TAB_MESSAGE; } else { Log.d(Constants.TAG, "Nothing matched!"); } @@ -311,14 +203,8 @@ public class DecryptActivity extends DrawerActivity implements DecryptSignatureR String path = FileHelper.getPath(this, uri); if (path != null) { - mInputFilename = path; - mFilename.setText(mInputFilename); -// guessOutputFilename(); -// mSource.setInAnimation(null); -// mSource.setOutAnimation(null); -// while (mSource.getCurrentView().getId() != R.id.sourceFile) { -// mSource.showNext(); -// } + mFileFragmentBundle.putString(DecryptFileFragment.ARG_FILENAME, path); + mSwitchToTab = PAGER_TAB_FILE; } else { Log.e(Constants.TAG, "Direct binary data without actual file in filesystem is not supported. Please use the Remote Service API!"); @@ -333,198 +219,6 @@ public class DecryptActivity extends DrawerActivity implements DecryptSignatureR } } -// private void guessOutputFilename() { -// mInputFilename = mFilename.getText().toString(); -// File file = new File(mInputFilename); -// String filename = file.getName(); -// if (filename.endsWith(".asc") || filename.endsWith(".gpg") || filename.endsWith(".pgp")) { -// filename = filename.substring(0, filename.length() - 4); -// } -// mOutputFilename = Constants.Path.APP_DIR + "/" + filename; -// } - - private void decryptClicked() { - if (mViewPager.getCurrentItem() == PAGER_TAB_FILE) { - mDecryptTarget = Id.target.file; - } else { - mDecryptTarget = Id.target.message; - } - initiateDecryption(); - } - - private void initiateDecryption() { - if (mDecryptTarget == Id.target.file) { - String currentFilename = mFilename.getText().toString(); - if (mInputFilename == null || !mInputFilename.equals(currentFilename)) { -// guessOutputFilename(); - } - - if (mInputFilename.equals("")) { - AppMsg.makeText(this, R.string.no_file_selected, AppMsg.STYLE_ALERT).show(); - return; - } - - if (mInputFilename.startsWith("file")) { - File file = new File(mInputFilename); - if (!file.exists() || !file.isFile()) { - AppMsg.makeText( - this, - getString(R.string.error_message, - getString(R.string.error_file_not_found)), AppMsg.STYLE_ALERT) - .show(); - return; - } - } - } - - if (mDecryptTarget == Id.target.message) { -// String messageData = mMessage.getText().toString(); -// Matcher matcher = PgpHelper.PGP_CLEARTEXT_SIGNATURE.matcher(messageData); -// if (matcher.matches()) { -// mSignedOnly = true; -// decryptStart(); -// return; -// } - } - - // else treat it as an decrypted message/file - mSignedOnly = false; - - getDecryptionKeyFromInputStream(); - - // if we need a symmetric passphrase or a passphrase to use a secret key ask for it - if (mAssumeSymmetricEncryption || PassphraseCacheService.getCachedPassphrase(this, mSecretKeyId) == null) { - showPassphraseDialog(); - } else { - if (mDecryptTarget == Id.target.file) { - askForOutputFilename(); - } else { // mDecryptTarget == Id.target.message -// decryptStart(); - } - } - } - - /** - * Shows passphrase dialog to cache a new passphrase the user enters for using it later for - * encryption. Based on mSecretKeyId it asks for a passphrase to open a private key or it asks - * for a symmetric passphrase - */ - private void showPassphraseDialog() { - // Message is received after passphrase is cached - Handler returnHandler = new Handler() { - @Override - public void handleMessage(Message message) { - if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) { - if (mDecryptTarget == Id.target.file) { - askForOutputFilename(); - } else { -// decryptStart(); - } - } - } - }; - - // Create a new Messenger for the communication back - Messenger messenger = new Messenger(returnHandler); - - try { - PassphraseDialogFragment passphraseDialog = PassphraseDialogFragment.newInstance(this, - messenger, mSecretKeyId); - - passphraseDialog.show(getSupportFragmentManager(), "passphraseDialog"); - } catch (PgpGeneralException e) { - Log.d(Constants.TAG, "No passphrase for this secret key, encrypt directly!"); - // send message to handler to start encryption directly - returnHandler.sendEmptyMessage(PassphraseDialogFragment.MESSAGE_OKAY); - } - } - - /** - * TODO: Rework function, remove global variables - */ - private void getDecryptionKeyFromInputStream() { - mAssumeSymmetricEncryption = false; - InputStream inStream = null; - if (mContentUri != null) { - try { - inStream = getContentResolver().openInputStream(mContentUri); - } catch (FileNotFoundException e) { - Log.e(Constants.TAG, "File not found!", e); - AppMsg.makeText(this, getString(R.string.error_file_not_found, e.getMessage()), - AppMsg.STYLE_ALERT).show(); - } - } else if (mDecryptTarget == Id.target.file) { - // check if storage is ready - if (!FileHelper.isStorageMounted(mInputFilename)) { - AppMsg.makeText(this, getString(R.string.error_external_storage_not_ready), - AppMsg.STYLE_ALERT).show(); - return; - } - - try { - inStream = new BufferedInputStream(new FileInputStream(mInputFilename)); - } catch (FileNotFoundException e) { - Log.e(Constants.TAG, "File not found!", e); - AppMsg.makeText(this, getString(R.string.error_file_not_found, e.getMessage()), - AppMsg.STYLE_ALERT).show(); - } - } else { - -// inStream = new ByteArrayInputStream(mMessage.getText().toString().getBytes()); - } - - // get decryption key for this inStream - try { - try { - if (inStream.markSupported()) { - inStream.mark(200); // should probably set this to the max size of two pgpF - // objects, if it even needs to be anything other than 0. - } - mSecretKeyId = PgpHelper.getDecryptionKeyId(this, inStream); - if (mSecretKeyId == Id.key.none) { - throw new PgpGeneralException(getString(R.string.error_no_secret_key_found)); - } - } catch (NoAsymmetricEncryptionException e) { - if (inStream.markSupported()) { - inStream.reset(); - } - mSecretKeyId = Id.key.symmetric; - if (!PgpDecryptVerify.hasSymmetricEncryption(this, inStream)) { - throw new PgpGeneralException( - getString(R.string.error_no_known_encryption_found)); - } - mAssumeSymmetricEncryption = true; - } - } catch (Exception e) { - Log.e(Constants.TAG, "error while reading decryption key from input stream", e); - AppMsg.makeText(this, getString(R.string.error_message, e.getMessage()), - AppMsg.STYLE_ALERT).show(); - } - } - - private void askForOutputFilename() { - // Message is received after passphrase is cached - Handler returnHandler = new Handler() { - @Override - public void handleMessage(Message message) { - if (message.what == FileDialogFragment.MESSAGE_OKAY) { - Bundle data = message.getData(); - mOutputFilename = data.getString(FileDialogFragment.MESSAGE_DATA_FILENAME); -// decryptStart(); - } - } - }; - - // Create a new Messenger for the communication back - Messenger messenger = new Messenger(returnHandler); - - mFileDialog = FileDialogFragment.newInstance(messenger, - getString(R.string.title_decrypt_to_file), - getString(R.string.specify_file_to_decrypt_to), mOutputFilename, null); - - mFileDialog.show(getSupportFragmentManager(), "fileDialog"); - } - private void lookupUnknownKey(long unknownKeyId) { Intent intent = new Intent(this, ImportKeysActivity.class); intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER); @@ -532,173 +226,9 @@ public class DecryptActivity extends DrawerActivity implements DecryptSignatureR startActivityForResult(intent, RESULT_CODE_LOOKUP_KEY); } -// private void decryptStart() { -// Log.d(Constants.TAG, "decryptStart"); -// -// // Send all information needed to service to decrypt in other thread -// Intent intent = new Intent(this, KeychainIntentService.class); -// -// // fill values for this action -// Bundle data = new Bundle(); -// -// intent.setAction(KeychainIntentService.ACTION_DECRYPT_VERIFY); -// -// // choose action based on input: decrypt stream, file or bytes -// if (mContentUri != null) { -// data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_STREAM); -// -// data.putParcelable(KeychainIntentService.ENCRYPT_PROVIDER_URI, mContentUri); -// } else if (mDecryptTarget == Id.target.file) { -// data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_URI); -// -// Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename=" -// + mOutputFilename); -// -// data.putString(KeychainIntentService.ENCRYPT_INPUT_FILE, mInputFilename); -// data.putString(KeychainIntentService.ENCRYPT_OUTPUT_FILE, mOutputFilename); -// } else { -// data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_BYTES); -// -//// String message = mMessage.getText().toString(); -//// data.putByteArray(KeychainIntentService.DECRYPT_CIPHERTEXT_BYTES, message.getBytes()); -// } -// -// data.putLong(KeychainIntentService.ENCRYPT_SECRET_KEY_ID, mSecretKeyId); -// -// data.putBoolean(KeychainIntentService.DECRYPT_RETURN_BYTES, mReturnBinary); -// data.putBoolean(KeychainIntentService.DECRYPT_ASSUME_SYMMETRIC, mAssumeSymmetricEncryption); -// -// intent.putExtra(KeychainIntentService.EXTRA_DATA, data); -// -// // Message is received after encrypting is done in KeychainIntentService -// KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(this, -// getString(R.string.progress_decrypting), ProgressDialog.STYLE_HORIZONTAL) { -// public void handleMessage(Message message) { -// // handle messages by standard KeychainIntentServiceHandler first -// super.handleMessage(message); -// -// if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { -// // get returned data bundle -// Bundle returnData = message.getData(); -// -// mSignatureKeyId = 0; -// mSignatureLayout.setVisibility(View.GONE); -// -// AppMsg.makeText(DecryptActivity.this, R.string.decryption_successful, -// AppMsg.STYLE_INFO).show(); -//// if (mReturnResult) { -//// Intent intent = new Intent(); -//// intent.putExtras(returnData); -//// setResult(RESULT_OK, intent); -//// finish(); -//// return; -//// } -// -// switch (mDecryptTarget) { -// case Id.target.message: -// String decryptedMessage = returnData -// .getString(KeychainIntentService.RESULT_DECRYPTED_STRING); -//// mMessage.setText(decryptedMessage); -//// mMessage.setHorizontallyScrolling(false); -// -// break; -// -// case Id.target.file: -// if (mDeleteAfter.isChecked()) { -// // Create and show dialog to delete original file -// DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment -// .newInstance(mInputFilename); -// deleteFileDialog.show(getSupportFragmentManager(), "deleteDialog"); -// } -// break; -// -// default: -// // shouldn't happen -// break; -// -// } -// -// PgpDecryptVerifyResult decryptVerifyResult = -// returnData.getParcelable(KeychainIntentService.RESULT_DECRYPT_VERIFY_RESULT); -// -// OpenPgpSignatureResult signatureResult = decryptVerifyResult.getSignatureResult(); -// -// if (signatureResult != null) { -// -// String userId = signatureResult.getUserId(); -// mSignatureKeyId = signatureResult.getKeyId(); -// mUserIdRest.setText("id: " -// + PgpKeyHelper.convertKeyIdToHex(mSignatureKeyId)); -// if (userId == null) { -// userId = getResources().getString(R.string.user_id_no_name); -// } -// String chunks[] = userId.split(" <", 2); -// userId = chunks[0]; -// if (chunks.length > 1) { -// mUserIdRest.setText("<" + chunks[1]); -// } -// mUserId.setText(userId); -// -// switch (signatureResult.getStatus()) { -// case OpenPgpSignatureResult.SIGNATURE_SUCCESS_UNCERTIFIED: { -// mSignatureStatusImage.setImageResource(R.drawable.overlay_ok); -// mLookupKey.setVisibility(View.GONE); -// break; -// } -// -// // TODO! -//// case OpenPgpSignatureResult.SIGNATURE_SUCCESS_CERTIFIED: { -//// break; -//// } -// -// case OpenPgpSignatureResult.SIGNATURE_UNKNOWN_PUB_KEY: { -// mSignatureStatusImage.setImageResource(R.drawable.overlay_error); -// mLookupKey.setVisibility(View.VISIBLE); -// AppMsg.makeText(DecryptActivity.this, -// R.string.unknown_signature, -// AppMsg.STYLE_ALERT).show(); -// break; -// } -// -// default: { -// mSignatureStatusImage.setImageResource(R.drawable.overlay_error); -// mLookupKey.setVisibility(View.GONE); -// break; -// } -// } -// mSignatureLayout.setVisibility(View.VISIBLE); -// } -// } -// } -// }; -// -// // Create a new Messenger for the communication back -// Messenger messenger = new Messenger(saveHandler); -// intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger); -// -// // show progress dialog -// saveHandler.showProgressDialog(this); -// -// // start service with intent -// startService(intent); -// } - @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { - case RESULT_CODE_FILE: { - if (resultCode == RESULT_OK && data != null) { - try { - String path = FileHelper.getPath(this, data.getData()); - Log.d(Constants.TAG, "path=" + path); - - mFilename.setText(path); - } catch (NullPointerException e) { - Log.e(Constants.TAG, "Nullpointer while retrieving path!"); - } - } - return; - } // this request is returned after LookupUnknownKeyDialogFragment started // ImportKeysActivity and user looked uo key @@ -721,24 +251,25 @@ public class DecryptActivity extends DrawerActivity implements DecryptSignatureR @Override public void onSignatureResult(OpenPgpSignatureResult signatureResult) { - mSignatureKeyId = 0; mSignatureLayout.setVisibility(View.GONE); if (signatureResult != null) { - String userId = signatureResult.getUserId(); mSignatureKeyId = signatureResult.getKeyId(); - mUserIdRest.setText("id: " - + PgpKeyHelper.convertKeyIdToHex(mSignatureKeyId)); - if (userId == null) { - userId = getResources().getString(R.string.user_id_no_name); + + String userId = signatureResult.getUserId(); + String[] userIdSplit = PgpKeyHelper.splitUserId(userId); + if (userIdSplit[0] != null) { + mUserId.setText(userId); + } else { + mUserId.setText(R.string.user_id_no_name); } - String chunks[] = userId.split(" <", 2); - userId = chunks[0]; - if (chunks.length > 1) { - mUserIdRest.setText("<" + chunks[1]); + if (userIdSplit[1] != null) { + mUserIdRest.setText(userIdSplit[1]); + } else { + mUserIdRest.setText(getString(R.string.label_key_id) + ": " + + PgpKeyHelper.convertKeyIdToHex(mSignatureKeyId)); } - mUserId.setText(userId); switch (signatureResult.getStatus()) { case OpenPgpSignatureResult.SIGNATURE_SUCCESS_UNCERTIFIED: { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java index 6646be8ee..cef960df2 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java @@ -17,6 +17,9 @@ package org.sufficientlysecure.keychain.ui; +import android.app.Activity; +import android.app.ProgressDialog; +import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.Message; @@ -31,14 +34,25 @@ import android.widget.EditText; import com.beardedhen.androidbootstrap.BootstrapButton; import com.devspark.appmsg.AppMsg; +import org.openintents.openpgp.OpenPgpSignatureResult; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.FileHelper; +import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult; +import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; +import org.sufficientlysecure.keychain.service.KeychainIntentService; +import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; +import org.sufficientlysecure.keychain.ui.dialog.DeleteFileDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.FileDialogFragment; +import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; +import org.sufficientlysecure.keychain.util.Log; import java.io.File; public class DecryptFileFragment extends Fragment { + public static final String ARG_FILENAME = "filename"; + + DecryptSignatureResultDisplay mSignatureResultDisplay; private EditText mFilename; private CheckBox mDeleteAfter; @@ -54,18 +68,6 @@ public class DecryptFileFragment extends Fragment { private static final int RESULT_CODE_FILE = 0x00007003; - /** - * Creates new instance of this fragment - */ - public static DecryptFileFragment newInstance() { - DecryptFileFragment frag = new DecryptFileFragment(); - - Bundle args = new Bundle(); - frag.setArguments(args); - - return frag; - } - /** * Inflate the layout for this fragment */ @@ -73,16 +75,16 @@ public class DecryptFileFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.decrypt_file_fragment, container, false); - mFilename = (EditText) view.findViewById(R.id.filename); - mBrowse = (BootstrapButton) view.findViewById(R.id.btn_browse); + mFilename = (EditText) view.findViewById(R.id.decrypt_file_filename); + mBrowse = (BootstrapButton) view.findViewById(R.id.decrypt_file_browse); mBrowse.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { - FileHelper.openFile(getActivity(), mFilename.getText().toString(), "*/*", + FileHelper.openFile(DecryptFileFragment.this, mFilename.getText().toString(), "*/*", RESULT_CODE_FILE); } }); - mDeleteAfter = (CheckBox) view.findViewById(R.id.deleteAfterDecryption); - mDecryptButton = (BootstrapButton) view.findViewById(R.id.action_decrypt); + mDeleteAfter = (CheckBox) view.findViewById(R.id.decrypt_file_delete_after_decryption); + mDecryptButton = (BootstrapButton) view.findViewById(R.id.decrypt_file_action_decrypt); mDecryptButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -90,9 +92,24 @@ public class DecryptFileFragment extends Fragment { } }); + String filename = getArguments().getString(ARG_FILENAME); + if (filename != null) { + mFilename.setText(filename); + } + return view; } + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + try { + mSignatureResultDisplay = (DecryptSignatureResultDisplay) activity; + } catch (ClassCastException e) { + throw new ClassCastException(activity.toString() + " must implement DecryptSignatureResultDisplay"); + } + } + private void guessOutputFilename() { mInputFilename = mFilename.getText().toString(); File file = new File(mInputFilename); @@ -142,7 +159,7 @@ public class DecryptFileFragment extends Fragment { if (message.what == FileDialogFragment.MESSAGE_OKAY) { Bundle data = message.getData(); mOutputFilename = data.getString(FileDialogFragment.MESSAGE_DATA_FILENAME); -// decryptStart(); + decryptStart(null); } } }; @@ -157,4 +174,131 @@ public class DecryptFileFragment extends Fragment { mFileDialog.show(getActivity().getSupportFragmentManager(), "fileDialog"); } + private void decryptStart(String passphrase) { + Log.d(Constants.TAG, "decryptStart"); + + // Send all information needed to service to decrypt in other thread + Intent intent = new Intent(getActivity(), KeychainIntentService.class); + + // fill values for this action + Bundle data = new Bundle(); + + intent.setAction(KeychainIntentService.ACTION_DECRYPT_VERIFY); + + // data + data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_URI); + + Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename=" + + mOutputFilename); + + data.putString(KeychainIntentService.ENCRYPT_INPUT_FILE, mInputFilename); + data.putString(KeychainIntentService.ENCRYPT_OUTPUT_FILE, mOutputFilename); + + data.putString(KeychainIntentService.DECRYPT_PASSPHRASE, passphrase); + + // TODO + data.putBoolean(KeychainIntentService.DECRYPT_ASSUME_SYMMETRIC, false); + + intent.putExtra(KeychainIntentService.EXTRA_DATA, data); + + // Message is received after encrypting is done in KeychainIntentService + KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(getActivity(), + getString(R.string.progress_decrypting), ProgressDialog.STYLE_HORIZONTAL) { + public void handleMessage(Message message) { + // handle messages by standard KeychainIntentServiceHandler first + super.handleMessage(message); + + if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { + // get returned data bundle + Bundle returnData = message.getData(); + + + PgpDecryptVerifyResult decryptVerifyResult = + returnData.getParcelable(KeychainIntentService.RESULT_DECRYPT_VERIFY_RESULT); + + if (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) { + showPassphraseDialog(decryptVerifyResult.getKeyIdPassphraseNeeded()); + } else { + + if (mDeleteAfter.isChecked()) { + // Create and show dialog to delete original file + DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment + .newInstance(mInputFilename); + deleteFileDialog.show(getActivity().getSupportFragmentManager(), "deleteDialog"); + } + + + OpenPgpSignatureResult signatureResult = decryptVerifyResult.getSignatureResult(); + + // display signature result in activity + mSignatureResultDisplay.onSignatureResult(signatureResult); + } + + } + } + }; + + // Create a new Messenger for the communication back + Messenger messenger = new Messenger(saveHandler); + intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger); + + // show progress dialog + saveHandler.showProgressDialog(getActivity()); + + // start service with intent + getActivity().startService(intent); + } + + private void showPassphraseDialog(long keyId) { + // Message is received after passphrase is cached + Handler returnHandler = new Handler() { + @Override + public void handleMessage(Message message) { + if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) { + String passphrase = + message.getData().getString(PassphraseDialogFragment.MESSAGE_DATA_PASSPHRASE); + decryptStart(passphrase); + } + } + }; + + // Create a new Messenger for the communication back + Messenger messenger = new Messenger(returnHandler); + + try { + PassphraseDialogFragment passphraseDialog = PassphraseDialogFragment.newInstance(getActivity(), + messenger, keyId); + + passphraseDialog.show(getActivity().getSupportFragmentManager(), "passphraseDialog"); + } catch (PgpGeneralException e) { + Log.d(Constants.TAG, "No passphrase for this secret key, encrypt directly!"); + // send message to handler to start encryption directly + returnHandler.sendEmptyMessage(PassphraseDialogFragment.MESSAGE_OKAY); + } + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + switch (requestCode) { + case RESULT_CODE_FILE: { + if (resultCode == Activity.RESULT_OK && data != null) { + try { + String path = FileHelper.getPath(getActivity(), data.getData()); + Log.d(Constants.TAG, "path=" + path); + + mFilename.setText(path); + } catch (NullPointerException e) { + Log.e(Constants.TAG, "Nullpointer while retrieving path!"); + } + } + return; + } + + default: { + super.onActivityResult(requestCode, resultCode, data); + + break; + } + } + } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java index c6724f6d1..a50f080ab 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java @@ -49,13 +49,14 @@ import org.sufficientlysecure.keychain.util.Log; import java.util.regex.Matcher; public class DecryptMessageFragment extends Fragment { + public static final String ARG_CIPHERTEXT = "ciphertext"; + DecryptSignatureResultDisplay mSignatureResultDisplay; private EditText mMessage; private BootstrapButton mDecryptButton; private BootstrapButton mDecryptFromCLipboardButton; - public static final String EXTRA_CIPHERTEXT = "ciphertext"; /** * Inflate the layout for this fragment @@ -68,11 +69,6 @@ public class DecryptMessageFragment extends Fragment { mDecryptButton = (BootstrapButton) view.findViewById(R.id.action_decrypt); mDecryptFromCLipboardButton = (BootstrapButton) view.findViewById(R.id.action_decrypt_from_clipboard); - String ciphertext = getArguments().getString(EXTRA_CIPHERTEXT); - if (ciphertext != null) { - mMessage.setText(ciphertext); - } - mDecryptButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { @@ -105,9 +101,11 @@ public class DecryptMessageFragment extends Fragment { public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); - Log.d(Constants.TAG, "onActivityCreated tag: " + getTag()); - - + String ciphertext = getArguments().getString(ARG_CIPHERTEXT); + if (ciphertext != null) { + mMessage.setText(ciphertext); + decryptStart(null); + } } private void decryptFromClipboard() { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PageTabStripAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PageTabStripAdapter.java deleted file mode 100644 index 402699623..000000000 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PageTabStripAdapter.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2014 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.ui.adapter; - -import android.content.Context; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.app.FragmentStatePagerAdapter; -import android.support.v4.app.FragmentTransaction; -import android.support.v4.view.ViewPager; -import android.support.v7.app.ActionBar; -import android.support.v7.app.ActionBarActivity; - -import java.util.ArrayList; - -public class PageTabStripAdapter extends FragmentPagerAdapter { - private final Context mContext; - private final ArrayList mTabs = new ArrayList(); - - static final class TabInfo { - private final Class clss; - private final Bundle args; - private final String title; - - TabInfo(Class clss, Bundle args, String title) { - this.clss = clss; - this.args = args; - this.title = title; - } - } - - public PageTabStripAdapter(ActionBarActivity activity) { - super(activity.getSupportFragmentManager()); - mContext = activity; - } - - public void addTab(Class clss, Bundle args, String title) { - TabInfo info = new TabInfo(clss, args, title); - mTabs.add(info); - notifyDataSetChanged(); - } - - @Override - public int getCount() { - return mTabs.size(); - } - - @Override - public Fragment getItem(int position) { - TabInfo info = mTabs.get(position); - return Fragment.instantiate(mContext, info.clss.getName(), info.args); - } - - @Override - public CharSequence getPageTitle(int position) { - return mTabs.get(position).title; - } -} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PagerTabStripAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PagerTabStripAdapter.java new file mode 100644 index 000000000..3e7952beb --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PagerTabStripAdapter.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui.adapter; + +import android.content.Context; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.app.FragmentStatePagerAdapter; +import android.support.v4.app.FragmentTransaction; +import android.support.v4.view.ViewPager; +import android.support.v7.app.ActionBar; +import android.support.v7.app.ActionBarActivity; + +import java.util.ArrayList; + +public class PagerTabStripAdapter extends FragmentPagerAdapter { + private final Context mContext; + private final ArrayList mTabs = new ArrayList(); + + static final class TabInfo { + private final Class clss; + private final Bundle args; + private final String title; + + TabInfo(Class clss, Bundle args, String title) { + this.clss = clss; + this.args = args; + this.title = title; + } + } + + public PagerTabStripAdapter(ActionBarActivity activity) { + super(activity.getSupportFragmentManager()); + mContext = activity; + } + + public void addTab(Class clss, Bundle args, String title) { + TabInfo info = new TabInfo(clss, args, title); + mTabs.add(info); + notifyDataSetChanged(); + } + + @Override + public int getCount() { + return mTabs.size(); + } + + @Override + public Fragment getItem(int position) { + TabInfo info = mTabs.get(position); + return Fragment.instantiate(mContext, info.clss.getName(), info.args); + } + + @Override + public CharSequence getPageTitle(int position) { + return mTabs.get(position).title; + } +} diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_content.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_content.xml index 4ba379c2e..b6cb24b01 100644 --- a/OpenPGP-Keychain/src/main/res/layout/decrypt_content.xml +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_content.xml @@ -1,10 +1,13 @@ + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml index 7347d222c..7d3ebbc06 100644 --- a/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml @@ -16,7 +16,7 @@ android:id="@+id/linearLayout"> + android:layout_above="@+id/decrypt_file_action_decrypt" + android:layout_alignParentRight="true" + android:layout_alignParentEnd="true" /> Date: Sun, 30 Mar 2014 21:33:00 +0200 Subject: Include signature result in fragments --- .../keychain/ui/DecryptActivity.java | 114 +----------- .../keychain/ui/DecryptFileFragment.java | 55 +----- .../keychain/ui/DecryptFragment.java | 194 +++++++++++++++++++++ .../keychain/ui/DecryptMessageFragment.java | 59 +------ .../keychain/ui/DecryptSignatureResultDisplay.java | 27 --- .../src/main/res/layout/decrypt_content.xml | 2 - .../src/main/res/layout/decrypt_file_fragment.xml | 67 ++++--- .../main/res/layout/decrypt_message_fragment.xml | 14 +- 8 files changed, 242 insertions(+), 290 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java delete mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptSignatureResultDisplay.java diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java index 3e153a71b..d6dad424e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java @@ -44,7 +44,7 @@ import org.sufficientlysecure.keychain.util.Log; import java.util.regex.Matcher; -public class DecryptActivity extends DrawerActivity implements DecryptSignatureResultDisplay { +public class DecryptActivity extends DrawerActivity { /* Intents */ // without permission @@ -53,17 +53,6 @@ public class DecryptActivity extends DrawerActivity implements DecryptSignatureR /* EXTRA keys for input */ public static final String EXTRA_TEXT = "text"; - private static final int RESULT_CODE_LOOKUP_KEY = 0x00007006; - - private long mSignatureKeyId = 0; - - private RelativeLayout mSignatureLayout = null; - private ImageView mSignatureStatusImage = null; - private TextView mUserId = null; - private TextView mUserIdRest = null; - - private BootstrapButton mLookupKey = null; - ViewPager mViewPager; PagerTabStrip mPagerTabStrip; PagerTabStripAdapter mTabsAdapter; @@ -77,18 +66,6 @@ public class DecryptActivity extends DrawerActivity implements DecryptSignatureR private void initView() { - mSignatureLayout = (RelativeLayout) findViewById(R.id.signature); - mSignatureStatusImage = (ImageView) findViewById(R.id.ic_signature_status); - mUserId = (TextView) findViewById(R.id.mainUserId); - mUserIdRest = (TextView) findViewById(R.id.mainUserIdRest); - mLookupKey = (BootstrapButton) findViewById(R.id.lookup_key); - mLookupKey.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - lookupUnknownKey(mSignatureKeyId); - } - }); - // Pager mViewPager = (ViewPager) findViewById(R.id.decrypt_pager); mPagerTabStrip = (PagerTabStrip) findViewById(R.id.decrypt_pager_tab_strip); @@ -116,13 +93,6 @@ public class DecryptActivity extends DrawerActivity implements DecryptSignatureR mTabsAdapter.addTab(DecryptMessageFragment.class, mMessageFragmentBundle, getString(R.string.label_message)); mTabsAdapter.addTab(DecryptFileFragment.class, mFileFragmentBundle, getString(R.string.label_file)); mViewPager.setCurrentItem(mSwitchToTab); - - mSignatureLayout.setVisibility(View.GONE); - mSignatureLayout.setOnClickListener(new OnClickListener() { - public void onClick(View v) { - lookupUnknownKey(mSignatureKeyId); - } - }); } @@ -219,86 +189,4 @@ public class DecryptActivity extends DrawerActivity implements DecryptSignatureR } } - private void lookupUnknownKey(long unknownKeyId) { - Intent intent = new Intent(this, ImportKeysActivity.class); - intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER); - intent.putExtra(ImportKeysActivity.EXTRA_KEY_ID, unknownKeyId); - startActivityForResult(intent, RESULT_CODE_LOOKUP_KEY); - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - switch (requestCode) { - - // this request is returned after LookupUnknownKeyDialogFragment started - // ImportKeysActivity and user looked uo key - case RESULT_CODE_LOOKUP_KEY: { - Log.d(Constants.TAG, "Returning from Lookup Key..."); - if (resultCode == RESULT_OK) { - // decrypt again -// decryptStart(); - } - return; - } - - default: { - super.onActivityResult(requestCode, resultCode, data); - - break; - } - } - } - - @Override - public void onSignatureResult(OpenPgpSignatureResult signatureResult) { - mSignatureKeyId = 0; - mSignatureLayout.setVisibility(View.GONE); - if (signatureResult != null) { - - mSignatureKeyId = signatureResult.getKeyId(); - - String userId = signatureResult.getUserId(); - String[] userIdSplit = PgpKeyHelper.splitUserId(userId); - if (userIdSplit[0] != null) { - mUserId.setText(userId); - } else { - mUserId.setText(R.string.user_id_no_name); - } - if (userIdSplit[1] != null) { - mUserIdRest.setText(userIdSplit[1]); - } else { - mUserIdRest.setText(getString(R.string.label_key_id) + ": " - + PgpKeyHelper.convertKeyIdToHex(mSignatureKeyId)); - } - - switch (signatureResult.getStatus()) { - case OpenPgpSignatureResult.SIGNATURE_SUCCESS_UNCERTIFIED: { - mSignatureStatusImage.setImageResource(R.drawable.overlay_ok); - mLookupKey.setVisibility(View.GONE); - break; - } - - // TODO! -// case OpenPgpSignatureResult.SIGNATURE_SUCCESS_CERTIFIED: { -// break; -// } - - case OpenPgpSignatureResult.SIGNATURE_UNKNOWN_PUB_KEY: { - mSignatureStatusImage.setImageResource(R.drawable.overlay_error); - mLookupKey.setVisibility(View.VISIBLE); - AppMsg.makeText(DecryptActivity.this, - R.string.unknown_signature, - AppMsg.STYLE_ALERT).show(); - break; - } - - default: { - mSignatureStatusImage.setImageResource(R.drawable.overlay_error); - mLookupKey.setVisibility(View.GONE); - break; - } - } - mSignatureLayout.setVisibility(View.VISIBLE); - } - } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java index cef960df2..069a5a584 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java @@ -24,7 +24,6 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.os.Messenger; -import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -39,21 +38,17 @@ import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.FileHelper; import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult; -import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; import org.sufficientlysecure.keychain.ui.dialog.DeleteFileDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.FileDialogFragment; -import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; import org.sufficientlysecure.keychain.util.Log; import java.io.File; -public class DecryptFileFragment extends Fragment { +public class DecryptFileFragment extends DecryptFragment { public static final String ARG_FILENAME = "filename"; - DecryptSignatureResultDisplay mSignatureResultDisplay; - private EditText mFilename; private CheckBox mDeleteAfter; private BootstrapButton mBrowse; @@ -100,16 +95,6 @@ public class DecryptFileFragment extends Fragment { return view; } - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - try { - mSignatureResultDisplay = (DecryptSignatureResultDisplay) activity; - } catch (ClassCastException e) { - throw new ClassCastException(activity.toString() + " must implement DecryptSignatureResultDisplay"); - } - } - private void guessOutputFilename() { mInputFilename = mFilename.getText().toString(); File file = new File(mInputFilename); @@ -120,11 +105,6 @@ public class DecryptFileFragment extends Fragment { mOutputFilename = Constants.Path.APP_DIR + "/" + filename; } - @Override - public void onActivityCreated(Bundle savedInstanceState) { - super.onActivityCreated(savedInstanceState); - } - private void decryptAction() { String currentFilename = mFilename.getText().toString(); if (mInputFilename == null || !mInputFilename.equals(currentFilename)) { @@ -174,7 +154,8 @@ public class DecryptFileFragment extends Fragment { mFileDialog.show(getActivity().getSupportFragmentManager(), "fileDialog"); } - private void decryptStart(String passphrase) { + @Override + protected void decryptStart(String passphrase) { Log.d(Constants.TAG, "decryptStart"); // Send all information needed to service to decrypt in other thread @@ -231,7 +212,7 @@ public class DecryptFileFragment extends Fragment { OpenPgpSignatureResult signatureResult = decryptVerifyResult.getSignatureResult(); // display signature result in activity - mSignatureResultDisplay.onSignatureResult(signatureResult); + onSignatureResult(signatureResult); } } @@ -249,34 +230,6 @@ public class DecryptFileFragment extends Fragment { getActivity().startService(intent); } - private void showPassphraseDialog(long keyId) { - // Message is received after passphrase is cached - Handler returnHandler = new Handler() { - @Override - public void handleMessage(Message message) { - if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) { - String passphrase = - message.getData().getString(PassphraseDialogFragment.MESSAGE_DATA_PASSPHRASE); - decryptStart(passphrase); - } - } - }; - - // Create a new Messenger for the communication back - Messenger messenger = new Messenger(returnHandler); - - try { - PassphraseDialogFragment passphraseDialog = PassphraseDialogFragment.newInstance(getActivity(), - messenger, keyId); - - passphraseDialog.show(getActivity().getSupportFragmentManager(), "passphraseDialog"); - } catch (PgpGeneralException e) { - Log.d(Constants.TAG, "No passphrase for this secret key, encrypt directly!"); - // send message to handler to start encryption directly - returnHandler.sendEmptyMessage(PassphraseDialogFragment.MESSAGE_OKAY); - } - } - @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java new file mode 100644 index 000000000..4c0c80742 --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java @@ -0,0 +1,194 @@ +/* + * Copyright (C) 2013 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui; + +import android.app.Activity; +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.os.Messenger; +import android.support.v4.app.Fragment; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.ImageView; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import com.beardedhen.androidbootstrap.BootstrapButton; +import com.devspark.appmsg.AppMsg; + +import org.openintents.openpgp.OpenPgpSignatureResult; +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; +import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; +import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; +import org.sufficientlysecure.keychain.util.Log; + +public class DecryptFragment extends Fragment { + private static final int RESULT_CODE_LOOKUP_KEY = 0x00007006; + + protected long mSignatureKeyId = 0; + + protected RelativeLayout mSignatureLayout = null; + protected ImageView mSignatureStatusImage = null; + protected TextView mUserId = null; + protected TextView mUserIdRest = null; + + protected BootstrapButton mLookupKey = null; + + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + mSignatureLayout = (RelativeLayout) getView().findViewById(R.id.signature); + mSignatureStatusImage = (ImageView) getView().findViewById(R.id.ic_signature_status); + mUserId = (TextView) getView().findViewById(R.id.mainUserId); + mUserIdRest = (TextView) getView().findViewById(R.id.mainUserIdRest); + mLookupKey = (BootstrapButton) getView().findViewById(R.id.lookup_key); + mLookupKey.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + lookupUnknownKey(mSignatureKeyId); + } + }); + mSignatureLayout.setVisibility(View.GONE); + mSignatureLayout.setOnClickListener(new OnClickListener() { + public void onClick(View v) { + lookupUnknownKey(mSignatureKeyId); + } + }); + } + + private void lookupUnknownKey(long unknownKeyId) { + Intent intent = new Intent(getActivity(), ImportKeysActivity.class); + intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER); + intent.putExtra(ImportKeysActivity.EXTRA_KEY_ID, unknownKeyId); + startActivityForResult(intent, RESULT_CODE_LOOKUP_KEY); + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + switch (requestCode) { + + // this request is returned after LookupUnknownKeyDialogFragment started + // ImportKeysActivity and user looked uo key + case RESULT_CODE_LOOKUP_KEY: { + Log.d(Constants.TAG, "Returning from Lookup Key..."); + if (resultCode == Activity.RESULT_OK) { + // decrypt again +// decryptStart(); + } + return; + } + + default: { + super.onActivityResult(requestCode, resultCode, data); + + break; + } + } + } + + protected void onSignatureResult(OpenPgpSignatureResult signatureResult) { + mSignatureKeyId = 0; + mSignatureLayout.setVisibility(View.GONE); + if (signatureResult != null) { + + mSignatureKeyId = signatureResult.getKeyId(); + + String userId = signatureResult.getUserId(); + String[] userIdSplit = PgpKeyHelper.splitUserId(userId); + if (userIdSplit[0] != null) { + mUserId.setText(userId); + } else { + mUserId.setText(R.string.user_id_no_name); + } + if (userIdSplit[1] != null) { + mUserIdRest.setText(userIdSplit[1]); + } else { + mUserIdRest.setText(getString(R.string.label_key_id) + ": " + + PgpKeyHelper.convertKeyIdToHex(mSignatureKeyId)); + } + + switch (signatureResult.getStatus()) { + case OpenPgpSignatureResult.SIGNATURE_SUCCESS_UNCERTIFIED: { + mSignatureStatusImage.setImageResource(R.drawable.overlay_ok); + mLookupKey.setVisibility(View.GONE); + break; + } + + // TODO! +// case OpenPgpSignatureResult.SIGNATURE_SUCCESS_CERTIFIED: { +// break; +// } + + case OpenPgpSignatureResult.SIGNATURE_UNKNOWN_PUB_KEY: { + mSignatureStatusImage.setImageResource(R.drawable.overlay_error); + mLookupKey.setVisibility(View.VISIBLE); + AppMsg.makeText(getActivity(), + R.string.unknown_signature, + AppMsg.STYLE_ALERT).show(); + break; + } + + default: { + mSignatureStatusImage.setImageResource(R.drawable.overlay_error); + mLookupKey.setVisibility(View.GONE); + break; + } + } + mSignatureLayout.setVisibility(View.VISIBLE); + } + } + + protected void showPassphraseDialog(long keyId) { + // Message is received after passphrase is cached + Handler returnHandler = new Handler() { + @Override + public void handleMessage(Message message) { + if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) { + String passphrase = + message.getData().getString(PassphraseDialogFragment.MESSAGE_DATA_PASSPHRASE); + decryptStart(passphrase); + } + } + }; + + // Create a new Messenger for the communication back + Messenger messenger = new Messenger(returnHandler); + + try { + PassphraseDialogFragment passphraseDialog = PassphraseDialogFragment.newInstance(getActivity(), + messenger, keyId); + + passphraseDialog.show(getActivity().getSupportFragmentManager(), "passphraseDialog"); + } catch (PgpGeneralException e) { + Log.d(Constants.TAG, "No passphrase for this secret key, encrypt directly!"); + // send message to handler to start encryption directly + returnHandler.sendEmptyMessage(PassphraseDialogFragment.MESSAGE_OKAY); + } + } + + protected void decryptStart(String passphrase) { + + } + +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java index a50f080ab..3a8aaec42 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java @@ -17,14 +17,11 @@ package org.sufficientlysecure.keychain.ui; -import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.os.Bundle; -import android.os.Handler; import android.os.Message; import android.os.Messenger; -import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.View.OnClickListener; @@ -40,19 +37,15 @@ import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.ClipboardReflection; import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult; import org.sufficientlysecure.keychain.pgp.PgpHelper; -import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; -import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; import org.sufficientlysecure.keychain.util.Log; import java.util.regex.Matcher; -public class DecryptMessageFragment extends Fragment { +public class DecryptMessageFragment extends DecryptFragment { public static final String ARG_CIPHERTEXT = "ciphertext"; - DecryptSignatureResultDisplay mSignatureResultDisplay; - private EditText mMessage; private BootstrapButton mDecryptButton; private BootstrapButton mDecryptFromCLipboardButton; @@ -72,7 +65,7 @@ public class DecryptMessageFragment extends Fragment { mDecryptButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - decryptAction(); + decryptStart(null); } }); @@ -86,17 +79,6 @@ public class DecryptMessageFragment extends Fragment { return view; } - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - try { - mSignatureResultDisplay = (DecryptSignatureResultDisplay) activity; - } catch (ClassCastException e) { - throw new ClassCastException(activity.toString() + " must implement DecryptSignatureResultDisplay"); - } - } - - @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); @@ -130,11 +112,8 @@ public class DecryptMessageFragment extends Fragment { } } - private void decryptAction() { - decryptStart(null); - } - - private void decryptStart(String passphrase) { + @Override + protected void decryptStart(String passphrase) { Log.d(Constants.TAG, "decryptStart"); // Send all information needed to service to decrypt in other thread @@ -187,7 +166,7 @@ public class DecryptMessageFragment extends Fragment { OpenPgpSignatureResult signatureResult = decryptVerifyResult.getSignatureResult(); // display signature result in activity - mSignatureResultDisplay.onSignatureResult(signatureResult); + onSignatureResult(signatureResult); } } @@ -205,33 +184,5 @@ public class DecryptMessageFragment extends Fragment { getActivity().startService(intent); } - private void showPassphraseDialog(long keyId) { - // Message is received after passphrase is cached - Handler returnHandler = new Handler() { - @Override - public void handleMessage(Message message) { - if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) { - String passphrase = - message.getData().getString(PassphraseDialogFragment.MESSAGE_DATA_PASSPHRASE); - decryptStart(passphrase); - } - } - }; - - // Create a new Messenger for the communication back - Messenger messenger = new Messenger(returnHandler); - - try { - PassphraseDialogFragment passphraseDialog = PassphraseDialogFragment.newInstance(getActivity(), - messenger, keyId); - - passphraseDialog.show(getActivity().getSupportFragmentManager(), "passphraseDialog"); - } catch (PgpGeneralException e) { - Log.d(Constants.TAG, "No passphrase for this secret key, encrypt directly!"); - // send message to handler to start encryption directly - returnHandler.sendEmptyMessage(PassphraseDialogFragment.MESSAGE_OKAY); - } - } - } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptSignatureResultDisplay.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptSignatureResultDisplay.java deleted file mode 100644 index e167064ec..000000000 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptSignatureResultDisplay.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (C) 2013 Dominik Schürmann - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package org.sufficientlysecure.keychain.ui; - -import org.openintents.openpgp.OpenPgpSignatureResult; - -public interface DecryptSignatureResultDisplay { - - public void onSignatureResult(OpenPgpSignatureResult result); - -} - diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_content.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_content.xml index b6cb24b01..a496d8b9d 100644 --- a/OpenPGP-Keychain/src/main/res/layout/decrypt_content.xml +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_content.xml @@ -6,8 +6,6 @@ android:layout_height="match_parent" android:orientation="vertical"> - - - + + - + android:text="@string/label_delete_after_decryption" /> - + android:layout_height="match_parent"> - + - + - - \ No newline at end of file + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_message_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_message_fragment.xml index f11f79c1e..23ae95660 100644 --- a/OpenPGP-Keychain/src/main/res/layout/decrypt_message_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_message_fragment.xml @@ -5,7 +5,7 @@ android:layout_height="match_parent" android:fillViewport="true"> - + + + android:layout_weight="1" /> + android:padding="4dp"> - + -- cgit v1.2.3 From 8f2abf36f8c4ad00ee16e546b800aaa52792c8e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 31 Mar 2014 20:04:05 +0200 Subject: Layouts for new encrypt design --- .../src/main/res/layout/decrypt_file_fragment.xml | 12 +--- .../main/res/layout/decrypt_message_fragment.xml | 4 +- .../res/layout/encrypt_asymmetric_fragment.xml | 78 ++++++++++++++++++++++ .../src/main/res/layout/encrypt_file_fragment.xml | 77 +++++++++++++++++++++ .../main/res/layout/encrypt_message_fragment.xml | 60 +++++++++++++++++ .../main/res/layout/encrypt_symmetric_fragment.xml | 44 ++++++++++++ 6 files changed, 263 insertions(+), 12 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/res/layout/encrypt_asymmetric_fragment.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout/encrypt_file_fragment.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout/encrypt_message_fragment.xml create mode 100644 OpenPGP-Keychain/src/main/res/layout/encrypt_symmetric_fragment.xml diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml index 132313ca8..e7d08f0fa 100644 --- a/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml @@ -39,13 +39,6 @@ bootstrapbutton:bb_type="default" /> - - - - + android:layout_height="match_parent" + android:padding="4dp"> - - \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_message_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_message_fragment.xml index 23ae95660..bfcc42da5 100644 --- a/OpenPGP-Keychain/src/main/res/layout/decrypt_message_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_message_fragment.xml @@ -7,7 +7,7 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_file_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_file_fragment.xml new file mode 100644 index 000000000..24a67acb7 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_file_fragment.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_message_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_message_fragment.xml new file mode 100644 index 000000000..bc2a2b4a6 --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_message_fragment.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_symmetric_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_symmetric_fragment.xml new file mode 100644 index 000000000..019c1cddf --- /dev/null +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_symmetric_fragment.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3 From 47b23a90d5bf395685ae4bdb75ae74f3047a02ab Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Mon, 31 Mar 2014 22:42:24 +0100 Subject: change how new default keys are passed back, fix showing their usage flags --- .../keychain/service/KeychainIntentService.java | 15 ++++++++---- .../keychain/ui/EditKeyActivity.java | 28 ++++++++++------------ .../keychain/ui/widget/KeyEditor.java | 10 ++++---- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 7ac1747b7..3bb2280c1 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -26,6 +26,7 @@ import android.os.Message; import android.os.Messenger; import android.os.RemoteException; +import org.spongycastle.bcpg.sig.KeyFlags; import org.spongycastle.openpgp.*; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; @@ -145,7 +146,7 @@ public class KeychainIntentService extends IntentService */ // keys public static final String RESULT_NEW_KEY = "new_key"; - public static final String RESULT_NEW_KEY2 = "new_key2"; + public static final String RESULT_KEY_USAGES = "new_key_usages"; // encrypt public static final String RESULT_SIGNATURE_BYTES = "signature_data"; @@ -563,6 +564,8 @@ public class KeychainIntentService extends IntentService try { /* Input */ String passphrase = data.getString(GENERATE_KEY_SYMMETRIC_PASSPHRASE); + ArrayList newKeys = new ArrayList(); + ArrayList keyUsageList = new ArrayList(); /* Operation */ int keysTotal = 2; @@ -576,11 +579,15 @@ public class KeychainIntentService extends IntentService PGPSecretKey masterKey = keyOperations.createKey(Id.choice.algorithm.rsa, 4096, passphrase, true); + newKeys.add(masterKey); + keyUsageList.add(KeyFlags.CERTIFY_OTHER); keysCreated++; setProgress(keysCreated, keysTotal); PGPSecretKey subKey = keyOperations.createKey(Id.choice.algorithm.rsa, 4096, passphrase, false); + newKeys.add(subKey); + keyUsageList.add(KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE); keysCreated++; setProgress(keysCreated, keysTotal); @@ -588,11 +595,11 @@ public class KeychainIntentService extends IntentService // for sign /* Output */ + Bundle resultData = new Bundle(); resultData.putByteArray(RESULT_NEW_KEY, - PgpConversionHelper.PGPSecretKeyToBytes(masterKey)); - resultData.putByteArray(RESULT_NEW_KEY2, - PgpConversionHelper.PGPSecretKeyToBytes(subKey)); + PgpConversionHelper.PGPSecretKeyArrayListToBytes(newKeys)); + resultData.putIntegerArrayList(RESULT_KEY_USAGES, keyUsageList); OtherHelper.logDebugBundle(resultData, "resultData"); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index b7fffc7ff..db0fae9b3 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -235,22 +235,20 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { // get new key from data bundle returned from service Bundle data = message.getData(); - PGPSecretKey masterKey = PgpConversionHelper - .BytesToPGPSecretKey(data + + ArrayList newKeys = + PgpConversionHelper.BytesToPGPSecretKeyList(data .getByteArray(KeychainIntentService.RESULT_NEW_KEY)); - PGPSecretKey subKey = PgpConversionHelper - .BytesToPGPSecretKey(data - .getByteArray(KeychainIntentService.RESULT_NEW_KEY2)); - - //We must set the key flags here as they are not set when we make the - //key pair. Because we are not generating hashed packets there... - // add master key - mKeys.add(masterKey); - mKeysUsages.add(KeyFlags.CERTIFY_OTHER); - - // add sub key - mKeys.add(subKey); - mKeysUsages.add(KeyFlags.ENCRYPT_COMMS + KeyFlags.ENCRYPT_STORAGE); + + ArrayList keyUsageFlags = data.getIntegerArrayList( + KeychainIntentService.RESULT_KEY_USAGES); + + if (newKeys.size() == keyUsageFlags.size()) { + for (int i = 0; i < newKeys.size(); ++i) { + mKeys.add(newKeys.get(i)); + mKeysUsages.add(keyUsageFlags.get(i)); + } + } buildLayout(true); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 0dfc6dc5e..038f8507e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -252,11 +252,11 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { mIsNewKey = isNewKey; if (isNewKey) { mUsage = usage; - mChkCertify.setChecked((usage &= KeyFlags.CERTIFY_OTHER) == KeyFlags.CERTIFY_OTHER); - mChkSign.setChecked((usage &= KeyFlags.SIGN_DATA) == KeyFlags.SIGN_DATA); - mChkEncrypt.setChecked(((usage &= KeyFlags.ENCRYPT_COMMS) == KeyFlags.ENCRYPT_COMMS) || - ((usage &= KeyFlags.ENCRYPT_STORAGE) == KeyFlags.ENCRYPT_STORAGE)); - mChkAuthenticate.setChecked((usage &= KeyFlags.AUTHENTICATION) == KeyFlags.AUTHENTICATION); + mChkCertify.setChecked((usage & KeyFlags.CERTIFY_OTHER) == KeyFlags.CERTIFY_OTHER); + mChkSign.setChecked((usage & KeyFlags.SIGN_DATA) == KeyFlags.SIGN_DATA); + mChkEncrypt.setChecked(((usage & KeyFlags.ENCRYPT_COMMS) == KeyFlags.ENCRYPT_COMMS) || + ((usage & KeyFlags.ENCRYPT_STORAGE) == KeyFlags.ENCRYPT_STORAGE)); + mChkAuthenticate.setChecked((usage & KeyFlags.AUTHENTICATION) == KeyFlags.AUTHENTICATION); } else { mUsage = PgpKeyHelper.getKeyUsage(key); mOriginalUsage = mUsage; -- cgit v1.2.3 From 5bc902dbb1834cc07e9f6712d7a43450028ef459 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Mon, 31 Mar 2014 23:23:51 +0100 Subject: create three keys by default --- .../keychain/service/KeychainIntentService.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 3bb2280c1..f616f7300 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -568,7 +568,7 @@ public class KeychainIntentService extends IntentService ArrayList keyUsageList = new ArrayList(); /* Operation */ - int keysTotal = 2; + int keysTotal = 3; int keysCreated = 0; setProgress( getApplicationContext().getResources(). @@ -591,6 +591,13 @@ public class KeychainIntentService extends IntentService keysCreated++; setProgress(keysCreated, keysTotal); + subKey = keyOperations.createKey(Id.choice.algorithm.rsa, + 4096, passphrase, false); + newKeys.add(subKey); + keyUsageList.add(KeyFlags.SIGN_DATA); + keysCreated++; + setProgress(keysCreated, keysTotal); + // TODO: default to one master for cert, one sub for encrypt and one sub // for sign -- cgit v1.2.3 From 9283205ea8a0dfb57320ec0387bc9c9f89f03dc2 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Tue, 1 Apr 2014 00:37:18 +0100 Subject: don't disable save button, show message if nothing needs to be done --- .../java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java | 7 ++++--- OpenPGP-Keychain/src/main/res/values/strings.xml | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index db0fae9b3..9df84065f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -42,6 +42,8 @@ import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.LinearLayout; import android.widget.Toast; import com.beardedhen.androidbootstrap.BootstrapButton; +import com.devspark.appmsg.AppMsg; + import org.spongycastle.openpgp.PGPSecretKey; import org.spongycastle.openpgp.PGPSecretKeyRing; import org.sufficientlysecure.keychain.Constants; @@ -105,7 +107,6 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener private boolean mIsPassPhraseSet; private boolean mNeedsSaving; private boolean mIsBrandNewKeyring = false; - private MenuItem mSaveButton; private BootstrapButton mChangePassphrase; @@ -323,8 +324,6 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); getMenuInflater().inflate(R.menu.key_edit, menu); - mSaveButton = menu.findItem(R.id.menu_key_edit_save); - mSaveButton.setEnabled(needsSaving()); //totally get rid of some actions for new keys if (mDataUri == null) { MenuItem mButton = menu.findItem(R.id.menu_key_edit_export_file); @@ -569,6 +568,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener Toast.makeText(this, getString(R.string.error_message, e.getMessage()), Toast.LENGTH_SHORT).show(); } + } else { + AppMsg.makeText(this, R.string.error_change_something_first, AppMsg.STYLE_ALERT).show(); } } diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index 5d325d5ec..cbfd0a194 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -327,6 +327,7 @@ part of the loaded file is a valid OpenPGP object but not a OpenPGP key parts of the loaded file are valid OpenPGP objects but not OpenPGP keys + You must make changes to the keyring before you can save it Done. -- cgit v1.2.3 From 4c3506f4b1878bd785df9f8a639275bba243d945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 13:25:44 +0200 Subject: Experimental work on a fragment-based encrypt activity --- .../keychain/ui/DecryptActivity.java | 13 - .../keychain/ui/DecryptFileFragment.java | 26 +- .../keychain/ui/DecryptFragment.java | 6 +- .../keychain/ui/DecryptMessageFragment.java | 11 +- .../keychain/ui/EncryptActivity.java | 969 ++++----------------- .../keychain/ui/EncryptActivityInterface.java | 14 + .../keychain/ui/EncryptAsymmetricFragment.java | 283 ++++++ .../keychain/ui/EncryptFileFragment.java | 415 +++++++++ .../keychain/ui/EncryptMessageFragment.java | 289 ++++++ .../keychain/ui/EncryptSymmetricFragment.java | 96 ++ .../src/main/res/layout/decrypt_file_fragment.xml | 3 +- .../res/layout/encrypt_asymmetric_fragment.xml | 4 +- .../src/main/res/layout/encrypt_content.xml | 339 +------ .../src/main/res/layout/encrypt_file_fragment.xml | 8 +- OpenPGP-Keychain/src/main/res/values/strings.xml | 2 - 15 files changed, 1302 insertions(+), 1176 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivityInterface.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptSymmetricFragment.java diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java index d6dad424e..046d80b72 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java @@ -22,23 +22,13 @@ import android.net.Uri; import android.os.Bundle; import android.support.v4.view.PagerTabStrip; import android.support.v4.view.ViewPager; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.ImageView; -import android.widget.RelativeLayout; -import android.widget.TextView; import android.widget.Toast; -import com.beardedhen.androidbootstrap.BootstrapButton; -import com.devspark.appmsg.AppMsg; - -import org.openintents.openpgp.OpenPgpSignatureResult; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.ActionBarHelper; import org.sufficientlysecure.keychain.helper.FileHelper; import org.sufficientlysecure.keychain.pgp.PgpHelper; -import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter; import org.sufficientlysecure.keychain.util.Log; @@ -47,7 +37,6 @@ import java.util.regex.Matcher; public class DecryptActivity extends DrawerActivity { /* Intents */ - // without permission public static final String ACTION_DECRYPT = Constants.INTENT_PREFIX + "DECRYPT"; /* EXTRA keys for input */ @@ -64,9 +53,7 @@ public class DecryptActivity extends DrawerActivity { private static final int PAGER_TAB_MESSAGE = 0; private static final int PAGER_TAB_FILE = 1; - private void initView() { - // Pager mViewPager = (ViewPager) findViewById(R.id.decrypt_pager); mPagerTabStrip = (PagerTabStrip) findViewById(R.id.decrypt_pager_tab_strip); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java index 069a5a584..a929047b8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Dominik Schürmann + * Copyright (C) 2014 Dominik Schürmann * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,20 +49,19 @@ import java.io.File; public class DecryptFileFragment extends DecryptFragment { public static final String ARG_FILENAME = "filename"; + private static final int RESULT_CODE_FILE = 0x00007003; + + // view private EditText mFilename; private CheckBox mDeleteAfter; private BootstrapButton mBrowse; private BootstrapButton mDecryptButton; - private String mInputFilename = null; private String mOutputFilename = null; private FileDialogFragment mFileDialog; - private static final int RESULT_CODE_FILE = 0x00007003; - - /** * Inflate the layout for this fragment */ @@ -72,14 +71,14 @@ public class DecryptFileFragment extends DecryptFragment { mFilename = (EditText) view.findViewById(R.id.decrypt_file_filename); mBrowse = (BootstrapButton) view.findViewById(R.id.decrypt_file_browse); + mDeleteAfter = (CheckBox) view.findViewById(R.id.decrypt_file_delete_after_decryption); + mDecryptButton = (BootstrapButton) view.findViewById(R.id.decrypt_file_action_decrypt); mBrowse.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { FileHelper.openFile(DecryptFileFragment.this, mFilename.getText().toString(), "*/*", RESULT_CODE_FILE); } }); - mDeleteAfter = (CheckBox) view.findViewById(R.id.decrypt_file_delete_after_decryption); - mDecryptButton = (BootstrapButton) view.findViewById(R.id.decrypt_file_action_decrypt); mDecryptButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -87,12 +86,17 @@ public class DecryptFileFragment extends DecryptFragment { } }); + return view; + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + String filename = getArguments().getString(ARG_FILENAME); if (filename != null) { mFilename.setText(filename); } - - return view; } private void guessOutputFilename() { @@ -193,14 +197,12 @@ public class DecryptFileFragment extends DecryptFragment { // get returned data bundle Bundle returnData = message.getData(); - PgpDecryptVerifyResult decryptVerifyResult = returnData.getParcelable(KeychainIntentService.RESULT_DECRYPT_VERIFY_RESULT); if (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) { showPassphraseDialog(decryptVerifyResult.getKeyIdPassphraseNeeded()); } else { - if (mDeleteAfter.isChecked()) { // Create and show dialog to delete original file DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment @@ -208,13 +210,11 @@ public class DecryptFileFragment extends DecryptFragment { deleteFileDialog.show(getActivity().getSupportFragmentManager(), "deleteDialog"); } - OpenPgpSignatureResult signatureResult = decryptVerifyResult.getSignatureResult(); // display signature result in activity onSignatureResult(signatureResult); } - } } }; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java index 4c0c80742..fd7aef353 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Dominik Schürmann + * Copyright (C) 2014 Dominik Schürmann * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -187,6 +187,10 @@ public class DecryptFragment extends Fragment { } } + /** + * Should be overridden by MessageFragment and FileFragment to start actual decryption + * @param passphrase + */ protected void decryptStart(String passphrase) { } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java index 3a8aaec42..94034b356 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Dominik Schürmann + * Copyright (C) 2014 Dominik Schürmann * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -50,7 +50,6 @@ public class DecryptMessageFragment extends DecryptFragment { private BootstrapButton mDecryptButton; private BootstrapButton mDecryptFromCLipboardButton; - /** * Inflate the layout for this fragment */ @@ -61,14 +60,12 @@ public class DecryptMessageFragment extends DecryptFragment { mMessage = (EditText) view.findViewById(R.id.message); mDecryptButton = (BootstrapButton) view.findViewById(R.id.action_decrypt); mDecryptFromCLipboardButton = (BootstrapButton) view.findViewById(R.id.action_decrypt_from_clipboard); - mDecryptButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { decryptStart(null); } }); - mDecryptFromCLipboardButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { @@ -93,6 +90,7 @@ public class DecryptMessageFragment extends DecryptFragment { private void decryptFromClipboard() { CharSequence clipboardText = ClipboardReflection.getClipboardText(getActivity()); + // only decrypt if clipboard content is available and a pgp message or cleartext signature if (clipboardText != null) { Matcher matcher = PgpHelper.PGP_MESSAGE.matcher(clipboardText); if (!matcher.matches()) { @@ -146,14 +144,12 @@ public class DecryptMessageFragment extends DecryptFragment { // get returned data bundle Bundle returnData = message.getData(); - PgpDecryptVerifyResult decryptVerifyResult = returnData.getParcelable(KeychainIntentService.RESULT_DECRYPT_VERIFY_RESULT); if (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) { showPassphraseDialog(decryptVerifyResult.getKeyIdPassphraseNeeded()); } else { - AppMsg.makeText(getActivity(), R.string.decryption_successful, AppMsg.STYLE_INFO).show(); @@ -162,13 +158,11 @@ public class DecryptMessageFragment extends DecryptFragment { mMessage.setText(new String(decryptedMessage)); mMessage.setHorizontallyScrolling(false); - OpenPgpSignatureResult signatureResult = decryptVerifyResult.getSignatureResult(); // display signature result in activity onSignatureResult(signatureResult); } - } } }; @@ -184,5 +178,4 @@ public class DecryptMessageFragment extends DecryptFragment { getActivity().startService(intent); } - } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java index cc8224f06..47c4347f6 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java @@ -17,49 +17,25 @@ package org.sufficientlysecure.keychain.ui; -import android.app.ProgressDialog; import android.content.Intent; import android.net.Uri; import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.os.Messenger; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.animation.AlphaAnimation; -import android.view.animation.Animation; -import android.view.animation.AnimationUtils; -import android.widget.*; -import com.beardedhen.androidbootstrap.BootstrapButton; -import com.beardedhen.androidbootstrap.FontAwesomeText; -import com.devspark.appmsg.AppMsg; -import org.spongycastle.openpgp.PGPPublicKey; -import org.spongycastle.openpgp.PGPPublicKeyRing; -import org.spongycastle.openpgp.PGPSecretKey; -import org.spongycastle.openpgp.PGPSecretKeyRing; +import android.support.v4.view.PagerTabStrip; +import android.support.v4.view.ViewPager; +import android.widget.Toast; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.compatibility.ClipboardReflection; import org.sufficientlysecure.keychain.helper.ActionBarHelper; import org.sufficientlysecure.keychain.helper.FileHelper; -import org.sufficientlysecure.keychain.helper.Preferences; -import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; -import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; -import org.sufficientlysecure.keychain.provider.ProviderHelper; -import org.sufficientlysecure.keychain.service.KeychainIntentService; -import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; -import org.sufficientlysecure.keychain.service.PassphraseCacheService; -import org.sufficientlysecure.keychain.ui.dialog.DeleteFileDialogFragment; -import org.sufficientlysecure.keychain.ui.dialog.FileDialogFragment; -import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; -import org.sufficientlysecure.keychain.util.Choice; +import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter; import org.sufficientlysecure.keychain.util.Log; -import java.io.File; -import java.util.Vector; - -public class EncryptActivity extends DrawerActivity { +public class EncryptActivity extends DrawerActivity implements + EncryptSymmetricFragment.OnSymmetricKeySelection, + EncryptAsymmetricFragment.OnAsymmetricKeySelection, + EncryptActivityInterface { /* Intents */ public static final String ACTION_ENCRYPT = Constants.INTENT_PREFIX + "ENCRYPT"; @@ -74,52 +50,100 @@ public class EncryptActivity extends DrawerActivity { public static final String EXTRA_SIGNATURE_KEY_ID = "signature_key_id"; public static final String EXTRA_ENCRYPTION_KEY_IDS = "encryption_key_ids"; + // view + ViewPager mViewPagerMode; + PagerTabStrip mPagerTabStripMode; + PagerTabStripAdapter mTabsAdapterMode; + ViewPager mViewPagerContent; + PagerTabStrip mPagerTabStripContent; + PagerTabStripAdapter mTabsAdapterContent; + + // tabs + Bundle mAsymmetricFragmentBundle = new Bundle(); + Bundle mSymmetricFragmentBundle = new Bundle(); + Bundle mMessageFragmentBundle = new Bundle(); + Bundle mFileFragmentBundle = new Bundle(); + int mSwitchToMode = PAGER_MODE_ASYMMETRIC; + int mSwitchToContent = PAGER_CONTENT_MESSAGE; + + private static final int PAGER_MODE_ASYMMETRIC = 0; + private static final int PAGER_MODE_SYMMETRIC = 1; + private static final int PAGER_CONTENT_MESSAGE = 0; + private static final int PAGER_CONTENT_FILE = 1; + + // model private long mEncryptionKeyIds[] = null; + private long mSigningKeyId = Id.key.none; + private String mPassphrase; + private String mPassphraseAgain; - private EditText mMessage = null; - private BootstrapButton mSelectKeysButton = null; + private boolean mAsciiArmorDemand = false; + private boolean mOverrideAsciiArmor = false; - private CheckBox mSign = null; - private TextView mMainUserId = null; - private TextView mMainUserIdRest = null; + private boolean mGenerateSignature = false; - private ViewFlipper mSource = null; - private TextView mSourceLabel = null; - private ImageView mSourcePrevious = null; - private ImageView mSourceNext = null; - private ViewFlipper mMode = null; - private TextView mModeLabel = null; - private ImageView mModePrevious = null; - private ImageView mModeNext = null; + @Override + public void onSigningKeySelected(long signingKeyId) { + mSigningKeyId = signingKeyId; + } - private int mEncryptTarget; + @Override + public void onEncryptionKeysSelected(long[] encryptionKeyIds) { + mEncryptionKeyIds = encryptionKeyIds; + } - private EditText mPassphrase = null; - private EditText mPassphraseAgain = null; - private CheckBox mAsciiArmor = null; - private Spinner mFileCompression = null; + @Override + public void onPassphraseUpdate(String passphrase) { + mPassphrase = passphrase; + } - private EditText mFilename = null; - private CheckBox mDeleteAfter = null; - private CheckBox mShareAfter = null; - private BootstrapButton mBrowse = null; + @Override + public void onPassphraseAgainUpdate(String passphrase) { + mPassphraseAgain = passphrase; + } - private String mInputFilename = null; - private String mOutputFilename = null; + @Override + public boolean isModeSymmetric() { + if (PAGER_MODE_SYMMETRIC == mViewPagerMode.getCurrentItem()) { + return true; + } else { + return false; + } + } - private boolean mAsciiArmorDemand = false; - private boolean mOverrideAsciiArmor = false; + @Override + public long getSignatureKey() { + return mSigningKeyId; + } - private boolean mGenerateSignature = false; + @Override + public long[] getEncryptionKeys() { + return mEncryptionKeyIds; + } - private long mSecretKeyId = Id.key.none; + @Override + public String getPassphrase() { + return mPassphrase; + } - private FileDialogFragment mFileDialog; + @Override + public String getPassphraseAgain() { + return mPassphraseAgain; + } - private BootstrapButton mEncryptShare; - private BootstrapButton mEncryptClipboard; - private BootstrapButton mEncryptFile; + + private void initView() { + mViewPagerMode = (ViewPager) findViewById(R.id.encrypt_pager_mode); + mPagerTabStripMode = (PagerTabStrip) findViewById(R.id.encrypt_pager_tab_strip_mode); + mViewPagerContent = (ViewPager) findViewById(R.id.encrypt_pager_content); + mPagerTabStripContent = (PagerTabStrip) findViewById(R.id.encrypt_pager_tab_strip_content); + + mTabsAdapterMode = new PagerTabStripAdapter(this); + mViewPagerMode.setAdapter(mTabsAdapterMode); + mTabsAdapterContent = new PagerTabStripAdapter(this); + mViewPagerContent.setAdapter(mTabsAdapterContent); + } @Override public void onCreate(Bundle savedInstanceState) { @@ -137,11 +161,13 @@ public class EncryptActivity extends DrawerActivity { // Handle intent actions handleActions(getIntent()); - updateView(); - updateSource(); - updateMode(); + mTabsAdapterMode.addTab(EncryptAsymmetricFragment.class, mAsymmetricFragmentBundle, getString(R.string.label_asymmetric)); + mTabsAdapterMode.addTab(EncryptSymmetricFragment.class, mSymmetricFragmentBundle, getString(R.string.label_symmetric)); + mViewPagerMode.setCurrentItem(mSwitchToMode); - updateActionBarButtons(); + mTabsAdapterContent.addTab(EncryptMessageFragment.class, mMessageFragmentBundle, getString(R.string.label_message)); + mTabsAdapterContent.addTab(EncryptFileFragment.class, mFileFragmentBundle, getString(R.string.label_file)); + mViewPagerContent.setCurrentItem(mSwitchToContent); } /** @@ -183,8 +209,7 @@ public class EncryptActivity extends DrawerActivity { if (extras.containsKey(EXTRA_ASCII_ARMOR)) { mAsciiArmorDemand = extras.getBoolean(EXTRA_ASCII_ARMOR, true); - mOverrideAsciiArmor = true; - mAsciiArmor.setChecked(mAsciiArmorDemand); + mFileFragmentBundle.putBoolean(EncryptFileFragment.ARG_ASCII_ARMOR, mAsciiArmorDemand); } String textData = extras.getString(EXTRA_TEXT); @@ -193,20 +218,17 @@ public class EncryptActivity extends DrawerActivity { long[] encryptionKeyIds = extras.getLongArray(EXTRA_ENCRYPTION_KEY_IDS); // preselect keys given by intent - preselectKeys(signatureKeyId, encryptionKeyIds); + mAsymmetricFragmentBundle.putLongArray(EncryptAsymmetricFragment.ARG_ENCRYPTION_KEY_IDS, encryptionKeyIds); + mAsymmetricFragmentBundle.putLong(EncryptAsymmetricFragment.ARG_SIGNATURE_KEY_ID, signatureKeyId); + mSwitchToMode = PAGER_MODE_ASYMMETRIC; /** * Main Actions */ if (ACTION_ENCRYPT.equals(action) && textData != null) { // encrypt text based on given extra - - mMessage.setText(textData); - mSource.setInAnimation(null); - mSource.setOutAnimation(null); - while (mSource.getCurrentView().getId() != R.id.sourceMessage) { - mSource.showNext(); - } + mMessageFragmentBundle.putString(EncryptMessageFragment.ARG_TEXT, textData); + mSwitchToContent = PAGER_CONTENT_MESSAGE; } else if (ACTION_ENCRYPT.equals(action) && uri != null) { // encrypt file based on Uri @@ -214,14 +236,8 @@ public class EncryptActivity extends DrawerActivity { String path = FileHelper.getPath(this, uri); if (path != null) { - mInputFilename = path; - mFilename.setText(mInputFilename); - - mSource.setInAnimation(null); - mSource.setOutAnimation(null); - while (mSource.getCurrentView().getId() != R.id.sourceFile) { - mSource.showNext(); - } + mFileFragmentBundle.putString(EncryptFileFragment.ARG_FILENAME, path); + mSwitchToContent = PAGER_CONTENT_FILE; } else { Log.e(Constants.TAG, "Direct binary data without actual file in filesystem is not supported by Intents. Please use the Remote Service API!"); @@ -236,740 +252,51 @@ public class EncryptActivity extends DrawerActivity { } } - /** - * If an Intent gives a signatureKeyId and/or encryptionKeyIds, preselect those! - * - * @param preselectedSignatureKeyId - * @param preselectedEncryptionKeyIds - */ - private void preselectKeys(long preselectedSignatureKeyId, long[] preselectedEncryptionKeyIds) { - if (preselectedSignatureKeyId != 0) { - PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(this, - preselectedSignatureKeyId); - PGPSecretKey masterKey = null; - if (keyRing != null) { - masterKey = PgpKeyHelper.getMasterKey(keyRing); - if (masterKey != null) { - Vector signKeys = PgpKeyHelper.getUsableSigningKeys(keyRing); - if (signKeys.size() > 0) { - mSecretKeyId = masterKey.getKeyID(); - } - } - } - } - - if (preselectedEncryptionKeyIds != null) { - Vector goodIds = new Vector(); - for (int i = 0; i < preselectedEncryptionKeyIds.length; ++i) { - PGPPublicKeyRing keyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(this, - preselectedEncryptionKeyIds[i]); - PGPPublicKey masterKey = null; - if (keyRing == null) { - continue; - } - masterKey = PgpKeyHelper.getMasterKey(keyRing); - if (masterKey == null) { - continue; - } - Vector encryptKeys = PgpKeyHelper.getUsableEncryptKeys(keyRing); - if (encryptKeys.size() == 0) { - continue; - } - goodIds.add(masterKey.getKeyID()); - } - if (goodIds.size() > 0) { - mEncryptionKeyIds = new long[goodIds.size()]; - for (int i = 0; i < goodIds.size(); ++i) { - mEncryptionKeyIds[i] = goodIds.get(i); - } - } - } - } - - /** - * Guess output filename based on input path - * - * @param path - * @return Suggestion for output filename - */ - private String guessOutputFilename(String path) { - // output in the same directory but with additional ending - File file = new File(path); - String ending = (mAsciiArmor.isChecked() ? ".asc" : ".gpg"); - String outputFilename = file.getParent() + File.separator + file.getName() + ending; - - return outputFilename; - } - - private void updateSource() { - switch (mSource.getCurrentView().getId()) { - case R.id.sourceFile: { - mSourceLabel.setText(R.string.label_file); - break; - } - - case R.id.sourceMessage: { - mSourceLabel.setText(R.string.label_message); - break; - } - - default: { - break; - } - } - updateActionBarButtons(); - } - - /** - * Update ActionBar buttons based on current selection in view - */ - private void updateActionBarButtons() { - switch (mSource.getCurrentView().getId()) { - case R.id.sourceFile: { - mEncryptShare.setVisibility(View.GONE); - mEncryptClipboard.setVisibility(View.GONE); - mEncryptFile.setVisibility(View.VISIBLE); - break; - } - - case R.id.sourceMessage: { - mSourceLabel.setText(R.string.label_message); - - mEncryptShare.setVisibility(View.VISIBLE); - mEncryptClipboard.setVisibility(View.VISIBLE); - mEncryptFile.setVisibility(View.GONE); - - if (mMode.getCurrentView().getId() == R.id.modeSymmetric) { - mEncryptShare.setEnabled(true); - mEncryptClipboard.setEnabled(true); - } else { - if (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0) { - if (mSecretKeyId == 0) { - mEncryptShare.setEnabled(false); - mEncryptClipboard.setEnabled(false); - } else { - mEncryptShare.setEnabled(true); - mEncryptClipboard.setEnabled(true); - } - } else { - mEncryptShare.setEnabled(true); - mEncryptClipboard.setEnabled(true); - } - } - break; - } - - default: { - break; - } - } - - } - - private void updateMode() { - switch (mMode.getCurrentView().getId()) { - case R.id.modeAsymmetric: { - mModeLabel.setText(R.string.label_asymmetric); - break; - } - - case R.id.modeSymmetric: { - mModeLabel.setText(R.string.label_symmetric); - break; - } - - default: { - break; - } - } - updateActionBarButtons(); - } - - private void encryptToClipboardClicked() { - mEncryptTarget = Id.target.clipboard; - initiateEncryption(); - } - - private void encryptClicked() { - Log.d(Constants.TAG, "encryptClicked invoked!"); - - if (mSource.getCurrentView().getId() == R.id.sourceFile) { - mEncryptTarget = Id.target.file; - } else { - mEncryptTarget = Id.target.email; - } - initiateEncryption(); - } - - private void initiateEncryption() { - if (mEncryptTarget == Id.target.file) { - String currentFilename = mFilename.getText().toString(); - if (mInputFilename == null || !mInputFilename.equals(currentFilename)) { - mInputFilename = mFilename.getText().toString(); - } - - mOutputFilename = guessOutputFilename(mInputFilename); - - if (mInputFilename.equals("")) { - AppMsg.makeText(this, R.string.no_file_selected, AppMsg.STYLE_ALERT).show(); - return; - } - - if (!mInputFilename.startsWith("content")) { - File file = new File(mInputFilename); - if (!file.exists() || !file.isFile()) { - AppMsg.makeText( - this, - getString(R.string.error_message, - getString(R.string.error_file_not_found)), AppMsg.STYLE_ALERT) - .show(); - return; - } - } - } - - // symmetric encryption - if (mMode.getCurrentView().getId() == R.id.modeSymmetric) { - boolean gotPassPhrase = false; - String passphrase = mPassphrase.getText().toString(); - String passphraseAgain = mPassphraseAgain.getText().toString(); - if (!passphrase.equals(passphraseAgain)) { - AppMsg.makeText(this, R.string.passphrases_do_not_match, AppMsg.STYLE_ALERT).show(); - return; - } - - gotPassPhrase = (passphrase.length() != 0); - if (!gotPassPhrase) { - AppMsg.makeText(this, R.string.passphrase_must_not_be_empty, AppMsg.STYLE_ALERT) - .show(); - return; - } - } else { - boolean encryptIt = (mEncryptionKeyIds != null && mEncryptionKeyIds.length > 0); - // for now require at least one form of encryption for files - if (!encryptIt && mEncryptTarget == Id.target.file) { - AppMsg.makeText(this, R.string.select_encryption_key, AppMsg.STYLE_ALERT).show(); - return; - } - - if (!encryptIt && mSecretKeyId == 0) { - AppMsg.makeText(this, R.string.select_encryption_or_signature_key, - AppMsg.STYLE_ALERT).show(); - return; - } - - if (mSecretKeyId != 0 - && PassphraseCacheService.getCachedPassphrase(this, mSecretKeyId) == null) { - showPassphraseDialog(); - - return; - } - } - - if (mEncryptTarget == Id.target.file) { - showOutputFileDialog(); - } else { - encryptStart(); - } - } - - /** - * Shows passphrase dialog to cache a new passphrase the user enters for using it later for - * encryption - */ - private void showPassphraseDialog() { - // Message is received after passphrase is cached - Handler returnHandler = new Handler() { - @Override - public void handleMessage(Message message) { - if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) { - if (mEncryptTarget == Id.target.file) { - showOutputFileDialog(); - } else { - encryptStart(); - } - } - } - }; - - // Create a new Messenger for the communication back - Messenger messenger = new Messenger(returnHandler); - - try { - PassphraseDialogFragment passphraseDialog = PassphraseDialogFragment.newInstance( - EncryptActivity.this, messenger, mSecretKeyId); - - passphraseDialog.show(getSupportFragmentManager(), "passphraseDialog"); - } catch (PgpGeneralException e) { - Log.d(Constants.TAG, "No passphrase for this secret key, encrypt directly!"); - // send message to handler to start encryption directly - returnHandler.sendEmptyMessage(PassphraseDialogFragment.MESSAGE_OKAY); - } - } - - private void showOutputFileDialog() { - // Message is received after file is selected - Handler returnHandler = new Handler() { - @Override - public void handleMessage(Message message) { - if (message.what == FileDialogFragment.MESSAGE_OKAY) { - Bundle data = message.getData(); - mOutputFilename = data.getString(FileDialogFragment.MESSAGE_DATA_FILENAME); - encryptStart(); - } - } - }; - - // Create a new Messenger for the communication back - Messenger messenger = new Messenger(returnHandler); - - mFileDialog = FileDialogFragment.newInstance(messenger, - getString(R.string.title_encrypt_to_file), - getString(R.string.specify_file_to_encrypt_to), mOutputFilename, null); - - mFileDialog.show(getSupportFragmentManager(), "fileDialog"); - } - - private void encryptStart() { - // Send all information needed to service to edit key in other thread - Intent intent = new Intent(this, KeychainIntentService.class); - - // fill values for this action - Bundle data = new Bundle(); - - boolean useAsciiArmor = true; - long encryptionKeyIds[] = null; - int compressionId = 0; - boolean signOnly = false; - long mSecretKeyIdToPass = 0; - - if (mMode.getCurrentView().getId() == R.id.modeSymmetric) { - Log.d(Constants.TAG, "Symmetric encryption enabled!"); - String passphrase = mPassphrase.getText().toString(); - if (passphrase.length() == 0) { - passphrase = null; - } - data.putString(KeychainIntentService.GENERATE_KEY_SYMMETRIC_PASSPHRASE, passphrase); - } else { - mSecretKeyIdToPass = mSecretKeyId; - encryptionKeyIds = mEncryptionKeyIds; - signOnly = (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0); - } - - intent.setAction(KeychainIntentService.ACTION_ENCRYPT_SIGN); - // choose default settings, target and data bundle by target - if (mEncryptTarget == Id.target.file) { - useAsciiArmor = mAsciiArmor.isChecked(); - compressionId = ((Choice) mFileCompression.getSelectedItem()).getId(); - - data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_URI); - - Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename=" - + mOutputFilename); - - data.putString(KeychainIntentService.ENCRYPT_INPUT_FILE, mInputFilename); - data.putString(KeychainIntentService.ENCRYPT_OUTPUT_FILE, mOutputFilename); - - } else { - useAsciiArmor = true; - compressionId = Preferences.getPreferences(this).getDefaultMessageCompression(); - - data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_BYTES); - - String message = mMessage.getText().toString(); - if (signOnly) { - message = fixBadCharactersForGmail(message); - } - data.putByteArray(KeychainIntentService.ENCRYPT_MESSAGE_BYTES, message.getBytes()); - } - - if (mOverrideAsciiArmor) { - useAsciiArmor = mAsciiArmorDemand; - } - - data.putLong(KeychainIntentService.ENCRYPT_SECRET_KEY_ID, mSecretKeyIdToPass); - data.putBoolean(KeychainIntentService.ENCRYPT_USE_ASCII_ARMOR, useAsciiArmor); - data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, encryptionKeyIds); - data.putInt(KeychainIntentService.ENCRYPT_COMPRESSION_ID, compressionId); - data.putBoolean(KeychainIntentService.ENCRYPT_GENERATE_SIGNATURE, mGenerateSignature); - data.putBoolean(KeychainIntentService.ENCRYPT_SIGN_ONLY, signOnly); - - intent.putExtra(KeychainIntentService.EXTRA_DATA, data); - - // Message is received after encrypting is done in KeychainIntentService - KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(this, - getString(R.string.progress_encrypting), ProgressDialog.STYLE_HORIZONTAL) { - public void handleMessage(Message message) { - // handle messages by standard KeychainIntentServiceHandler first - super.handleMessage(message); - - if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { - // get returned data bundle - Bundle data = message.getData(); - - String output; - switch (mEncryptTarget) { - case Id.target.clipboard: - output = data.getString(KeychainIntentService.RESULT_ENCRYPTED_STRING); - Log.d(Constants.TAG, "output: " + output); - ClipboardReflection.copyToClipboard(EncryptActivity.this, output); - AppMsg.makeText(EncryptActivity.this, - R.string.encryption_to_clipboard_successful, AppMsg.STYLE_INFO) - .show(); - break; - - case Id.target.email: - - output = data.getString(KeychainIntentService.RESULT_ENCRYPTED_STRING); - Log.d(Constants.TAG, "output: " + output); - - Intent sendIntent = new Intent(Intent.ACTION_SEND); - - // Type is set to text/plain so that encrypted messages can - // be sent with Whatsapp, Hangouts, SMS etc... - sendIntent.setType("text/plain"); - - sendIntent.putExtra(Intent.EXTRA_TEXT, output); - startActivity(Intent.createChooser(sendIntent, - getString(R.string.title_send_email))); - break; - - case Id.target.file: - AppMsg.makeText(EncryptActivity.this, R.string.encryption_successful, - AppMsg.STYLE_INFO).show(); - - if (mDeleteAfter.isChecked()) { - // Create and show dialog to delete original file - DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment - .newInstance(mInputFilename); - deleteFileDialog.show(getSupportFragmentManager(), "deleteDialog"); - } - - if (mShareAfter.isChecked()) { - // Share encrypted file - Intent sendFileIntent = new Intent(Intent.ACTION_SEND); - sendFileIntent.setType("*/*"); - sendFileIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(mOutputFilename)); - startActivity(Intent.createChooser(sendFileIntent, - getString(R.string.title_send_file))); - } - break; - - default: - // shouldn't happen - break; - - } - } - } - }; - - // Create a new Messenger for the communication back - Messenger messenger = new Messenger(saveHandler); - intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger); - - // show progress dialog - saveHandler.showProgressDialog(this); - - // start service with intent - startService(intent); - } - - /** - * Fixes bad message characters for gmail - * - * @param message - * @return - */ - private String fixBadCharactersForGmail(String message) { - // fix the message a bit, trailing spaces and newlines break stuff, - // because GMail sends as HTML and such things fuck up the - // signature, - // TODO: things like "<" and ">" also fuck up the signature - message = message.replaceAll(" +\n", "\n"); - message = message.replaceAll("\n\n+", "\n\n"); - message = message.replaceFirst("^\n+", ""); - // make sure there'll be exactly one newline at the end - message = message.replaceFirst("\n*$", "\n"); - - return message; - } - - private void initView() { - mSource = (ViewFlipper) findViewById(R.id.source); - mSourceLabel = (TextView) findViewById(R.id.sourceLabel); - mSourcePrevious = (ImageView) findViewById(R.id.sourcePrevious); - mSourceNext = (ImageView) findViewById(R.id.sourceNext); - - mSourcePrevious.setClickable(true); - mSourcePrevious.setOnClickListener(new OnClickListener() { - public void onClick(View v) { - mSource.setInAnimation(AnimationUtils.loadAnimation(EncryptActivity.this, - R.anim.push_right_in)); - mSource.setOutAnimation(AnimationUtils.loadAnimation(EncryptActivity.this, - R.anim.push_right_out)); - mSource.showPrevious(); - updateSource(); - } - }); - - mSourceNext.setClickable(true); - OnClickListener nextSourceClickListener = new OnClickListener() { - public void onClick(View v) { - mSource.setInAnimation(AnimationUtils.loadAnimation(EncryptActivity.this, - R.anim.push_left_in)); - mSource.setOutAnimation(AnimationUtils.loadAnimation(EncryptActivity.this, - R.anim.push_left_out)); - mSource.showNext(); - updateSource(); - } - }; - mSourceNext.setOnClickListener(nextSourceClickListener); - - mSourceLabel.setClickable(true); - mSourceLabel.setOnClickListener(nextSourceClickListener); - - mMode = (ViewFlipper) findViewById(R.id.mode); - mModeLabel = (TextView) findViewById(R.id.modeLabel); - mModePrevious = (ImageView) findViewById(R.id.modePrevious); - mModeNext = (ImageView) findViewById(R.id.modeNext); - - mModePrevious.setClickable(true); - mModePrevious.setOnClickListener(new OnClickListener() { - public void onClick(View v) { - mMode.setInAnimation(AnimationUtils.loadAnimation(EncryptActivity.this, - R.anim.push_right_in)); - mMode.setOutAnimation(AnimationUtils.loadAnimation(EncryptActivity.this, - R.anim.push_right_out)); - mMode.showPrevious(); - updateMode(); - } - }); - - OnClickListener nextModeClickListener = new OnClickListener() { - public void onClick(View v) { - mMode.setInAnimation(AnimationUtils.loadAnimation(EncryptActivity.this, - R.anim.push_left_in)); - mMode.setOutAnimation(AnimationUtils.loadAnimation(EncryptActivity.this, - R.anim.push_left_out)); - mMode.showNext(); - updateMode(); - } - }; - mModeNext.setOnClickListener(nextModeClickListener); - - mModeLabel.setClickable(true); - mModeLabel.setOnClickListener(nextModeClickListener); - - mMessage = (EditText) findViewById(R.id.message); - mSelectKeysButton = (BootstrapButton) findViewById(R.id.btn_selectEncryptKeys); - mSign = (CheckBox) findViewById(R.id.sign); - mMainUserId = (TextView) findViewById(R.id.mainUserId); - mMainUserIdRest = (TextView) findViewById(R.id.mainUserIdRest); - - mPassphrase = (EditText) findViewById(R.id.passphrase); - mPassphraseAgain = (EditText) findViewById(R.id.passphraseAgain); - - // measure the height of the source_file view and set the message view's min height to that, - // so it fills mSource fully... bit of a hack. - View tmp = findViewById(R.id.sourceFile); - tmp.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); - int height = tmp.getMeasuredHeight(); - mMessage.setMinimumHeight(height); - - mFilename = (EditText) findViewById(R.id.filename); - mBrowse = (BootstrapButton) findViewById(R.id.btn_browse); - mBrowse.setOnClickListener(new View.OnClickListener() { - public void onClick(View v) { - FileHelper.openFile(EncryptActivity.this, mFilename.getText().toString(), "*/*", - Id.request.filename); - } - }); - - - - - - - mFileCompression = (Spinner) findViewById(R.id.fileCompression); - Choice[] choices = new Choice[]{ - new Choice(Id.choice.compression.none, getString(R.string.choice_none) + " (" - + getString(R.string.compression_fast) + ")"), - new Choice(Id.choice.compression.zip, "ZIP (" - + getString(R.string.compression_fast) + ")"), - new Choice(Id.choice.compression.zlib, "ZLIB (" - + getString(R.string.compression_fast) + ")"), - new Choice(Id.choice.compression.bzip2, "BZIP2 (" - + getString(R.string.compression_very_slow) + ")"), }; - ArrayAdapter adapter = new ArrayAdapter(this, - android.R.layout.simple_spinner_item, choices); - adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - mFileCompression.setAdapter(adapter); - - int defaultFileCompression = Preferences.getPreferences(this).getDefaultFileCompression(); - for (int i = 0; i < choices.length; ++i) { - if (choices[i].getId() == defaultFileCompression) { - mFileCompression.setSelection(i); - break; - } - } - - mDeleteAfter = (CheckBox) findViewById(R.id.deleteAfterEncryption); - mShareAfter = (CheckBox) findViewById(R.id.shareAfterEncryption); - - mAsciiArmor = (CheckBox) findViewById(R.id.asciiArmour); - mAsciiArmor.setChecked(Preferences.getPreferences(this).getDefaultAsciiArmour()); - - mSelectKeysButton.setOnClickListener(new OnClickListener() { - public void onClick(View v) { - selectPublicKeys(); - } - }); - - mSign.setOnClickListener(new OnClickListener() { - public void onClick(View v) { - CheckBox checkBox = (CheckBox) v; - if (checkBox.isChecked()) { - selectSecretKey(); - } else { - mSecretKeyId = Id.key.none; - updateView(); - } - } - }); - - mEncryptClipboard = (BootstrapButton) findViewById(R.id.action_encrypt_clipboard); - mEncryptClipboard.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - encryptToClipboardClicked(); - } - }); - mEncryptShare = (BootstrapButton) findViewById(R.id.action_encrypt_share); - mEncryptShare.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - encryptClicked(); - } - }); - mEncryptFile = (BootstrapButton) findViewById(R.id.action_encrypt_file); - mEncryptFile.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - encryptClicked(); - } - }); - } - - private void updateView() { - if (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0) { - mSelectKeysButton.setText(getString(R.string.select_keys_button_default)); - } else { - mSelectKeysButton.setText(getResources().getQuantityString( - R.plurals.select_keys_button, mEncryptionKeyIds.length, - mEncryptionKeyIds.length)); - } - - if (mSecretKeyId == Id.key.none) { - mSign.setChecked(false); - mMainUserId.setText(""); - mMainUserIdRest.setText(""); - } else { - String uid = getResources().getString(R.string.user_id_no_name); - String uidExtra = ""; - PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(this, - mSecretKeyId); - if (keyRing != null) { - PGPSecretKey key = PgpKeyHelper.getMasterKey(keyRing); - if (key != null) { - String userId = PgpKeyHelper.getMainUserIdSafe(this, key); - String chunks[] = userId.split(" <", 2); - uid = chunks[0]; - if (chunks.length > 1) { - uidExtra = "<" + chunks[1]; - } - } - } - mMainUserId.setText(uid); - mMainUserIdRest.setText(uidExtra); - mSign.setChecked(true); - } - - updateActionBarButtons(); - } - - private void selectPublicKeys() { - Intent intent = new Intent(this, SelectPublicKeyActivity.class); - Vector keyIds = new Vector(); - if (mSecretKeyId != 0) { - keyIds.add(mSecretKeyId); - } - if (mEncryptionKeyIds != null && mEncryptionKeyIds.length > 0) { - for (int i = 0; i < mEncryptionKeyIds.length; ++i) { - keyIds.add(mEncryptionKeyIds[i]); - } - } - long[] initialKeyIds = null; - if (keyIds.size() > 0) { - initialKeyIds = new long[keyIds.size()]; - for (int i = 0; i < keyIds.size(); ++i) { - initialKeyIds[i] = keyIds.get(i); - } - } - intent.putExtra(SelectPublicKeyActivity.EXTRA_SELECTED_MASTER_KEY_IDS, initialKeyIds); - startActivityForResult(intent, Id.request.public_keys); - } - - private void selectSecretKey() { - Intent intent = new Intent(this, SelectSecretKeyActivity.class); - startActivityForResult(intent, Id.request.secret_keys); - } - - @Override - protected void onActivityResult(int requestCode, int resultCode, Intent data) { - switch (requestCode) { - case Id.request.filename: { - if (resultCode == RESULT_OK && data != null) { - try { - String path = FileHelper.getPath(this, data.getData()); - Log.d(Constants.TAG, "path=" + path); - - mFilename.setText(path); - } catch (NullPointerException e) { - Log.e(Constants.TAG, "Nullpointer while retrieving path!"); - } - } - return; - } - - case Id.request.public_keys: { - if (resultCode == RESULT_OK) { - Bundle bundle = data.getExtras(); - mEncryptionKeyIds = bundle - .getLongArray(SelectPublicKeyActivity.RESULT_EXTRA_MASTER_KEY_IDS); - } - updateView(); - break; - } - - case Id.request.secret_keys: { - if (resultCode == RESULT_OK) { - Uri uri_master_key = data.getData(); - mSecretKeyId = Long.valueOf(uri_master_key.getLastPathSegment()); - } else { - mSecretKeyId = Id.key.none; - } - updateView(); - break; - } - - default: { - break; - } - } - - super.onActivityResult(requestCode, resultCode, data); - } +// /** +// * Update ActionBar buttons based on current selection in view +// */ +// private void updateActionBarButtons() { +// switch (mSource.getCurrentView().getId()) { +// case R.id.sourceFile: { +// mEncryptShare.setVisibility(View.GONE); +// mEncryptClipboard.setVisibility(View.GONE); +// mEncryptFile.setVisibility(View.VISIBLE); +// break; +// } +// +// case R.id.sourceMessage: { +// mSourceLabel.setText(R.string.label_message); +// +// mEncryptShare.setVisibility(View.VISIBLE); +// mEncryptClipboard.setVisibility(View.VISIBLE); +// mEncryptFile.setVisibility(View.GONE); +// +// if (mMode.getCurrentView().getId() == R.id.modeSymmetric) { +// mEncryptShare.setEnabled(true); +// mEncryptClipboard.setEnabled(true); +// } else { +// if (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0) { +// if (mSecretKeyId == 0) { +// mEncryptShare.setEnabled(false); +// mEncryptClipboard.setEnabled(false); +// } else { +// mEncryptShare.setEnabled(true); +// mEncryptClipboard.setEnabled(true); +// } +// } else { +// mEncryptShare.setEnabled(true); +// mEncryptClipboard.setEnabled(true); +// } +// } +// break; +// } +// +// default: { +// break; +// } +// } +// +// } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivityInterface.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivityInterface.java new file mode 100644 index 000000000..8fbabe9c0 --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivityInterface.java @@ -0,0 +1,14 @@ +package org.sufficientlysecure.keychain.ui; + + +public interface EncryptActivityInterface { + + public boolean isModeSymmetric(); + + public long getSignatureKey(); + public long[] getEncryptionKeys(); + + public String getPassphrase(); + public String getPassphraseAgain(); + +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java new file mode 100644 index 000000000..b88dafd4a --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java @@ -0,0 +1,283 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui; + +import android.app.Activity; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.CheckBox; +import android.widget.TextView; + +import com.beardedhen.androidbootstrap.BootstrapButton; + +import org.spongycastle.openpgp.PGPPublicKey; +import org.spongycastle.openpgp.PGPPublicKeyRing; +import org.spongycastle.openpgp.PGPSecretKey; +import org.spongycastle.openpgp.PGPSecretKeyRing; +import org.sufficientlysecure.keychain.Id; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; +import org.sufficientlysecure.keychain.provider.ProviderHelper; + +import java.util.Vector; + +public class EncryptAsymmetricFragment extends Fragment { + public static final String ARG_SIGNATURE_KEY_ID = "signature_key_id"; + public static final String ARG_ENCRYPTION_KEY_IDS = "encryption_key_ids"; + + public static final int RESULT_CODE_PUBLIC_KEYS = 0x00007001; + public static final int RESULT_CODE_SECRET_KEYS = 0x00007002; + + OnAsymmetricKeySelection mKeySelectionListener; + + // view + private BootstrapButton mSelectKeysButton; + private CheckBox mSign; + private TextView mMainUserId; + private TextView mMainUserIdRest; + + // model + private long mSecretKeyId = Id.key.none; + private long mEncryptionKeyIds[] = null; + + // Container Activity must implement this interface + public interface OnAsymmetricKeySelection { + public void onSigningKeySelected(long signingKeyId); + + public void onEncryptionKeysSelected(long[] encryptionKeyIds); + } + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + try { + mKeySelectionListener = (OnAsymmetricKeySelection) activity; + } catch (ClassCastException e) { + throw new ClassCastException(activity.toString() + " must implement OnAsymmetricKeySelection"); + } + } + + private void setSignatureKeyId(long signatureKeyId) { + mSecretKeyId = signatureKeyId; + mKeySelectionListener.onSigningKeySelected(signatureKeyId); + } + + private void setEncryptionKeyIds(long[] encryptionKeyIds) { + mEncryptionKeyIds = encryptionKeyIds; + mKeySelectionListener.onEncryptionKeysSelected(encryptionKeyIds); + } + + + /** + * Inflate the layout for this fragment + */ + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.encrypt_asymmetric_fragment, container, false); + + mSelectKeysButton = (BootstrapButton) view.findViewById(R.id.btn_selectEncryptKeys); + mSign = (CheckBox) view.findViewById(R.id.sign); + mMainUserId = (TextView) view.findViewById(R.id.mainUserId); + mMainUserIdRest = (TextView) view.findViewById(R.id.mainUserIdRest); + mSelectKeysButton.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + selectPublicKeys(); + } + }); + mSign.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + CheckBox checkBox = (CheckBox) v; + if (checkBox.isChecked()) { + selectSecretKey(); + } else { + setSignatureKeyId(Id.key.none); + updateView(); + } + } + }); + + return view; + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + long signatureKeyId = getArguments().getLong(ARG_SIGNATURE_KEY_ID); + long[] encryptionKeyIds = getArguments().getLongArray(ARG_ENCRYPTION_KEY_IDS); + + // preselect keys given by arguments (given by Intent to EncryptActivity) + preselectKeys(signatureKeyId, encryptionKeyIds); + } + + /** + * If an Intent gives a signatureKeyId and/or encryptionKeyIds, preselect those! + * + * @param preselectedSignatureKeyId + * @param preselectedEncryptionKeyIds + */ + private void preselectKeys(long preselectedSignatureKeyId, long[] preselectedEncryptionKeyIds) { + if (preselectedSignatureKeyId != 0) { + PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(getActivity(), + preselectedSignatureKeyId); + PGPSecretKey masterKey; + if (keyRing != null) { + masterKey = PgpKeyHelper.getMasterKey(keyRing); + if (masterKey != null) { + Vector signKeys = PgpKeyHelper.getUsableSigningKeys(keyRing); + if (signKeys.size() > 0) { + setSignatureKeyId(masterKey.getKeyID()); + } + } + } + } + + if (preselectedEncryptionKeyIds != null) { + Vector goodIds = new Vector(); + for (int i = 0; i < preselectedEncryptionKeyIds.length; ++i) { + PGPPublicKeyRing keyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(getActivity(), + preselectedEncryptionKeyIds[i]); + PGPPublicKey masterKey; + if (keyRing == null) { + continue; + } + masterKey = PgpKeyHelper.getMasterKey(keyRing); + if (masterKey == null) { + continue; + } + Vector encryptKeys = PgpKeyHelper.getUsableEncryptKeys(keyRing); + if (encryptKeys.size() == 0) { + continue; + } + goodIds.add(masterKey.getKeyID()); + } + if (goodIds.size() > 0) { + long[] keyIds = new long[goodIds.size()]; + for (int i = 0; i < goodIds.size(); ++i) { + keyIds[i] = goodIds.get(i); + } + setEncryptionKeyIds(keyIds); + } + } + } + + private void updateView() { + if (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0) { + mSelectKeysButton.setText(getString(R.string.select_keys_button_default)); + } else { + mSelectKeysButton.setText(getResources().getQuantityString( + R.plurals.select_keys_button, mEncryptionKeyIds.length, + mEncryptionKeyIds.length)); + } + + if (mSecretKeyId == Id.key.none) { + mSign.setChecked(false); + mMainUserId.setText(""); + mMainUserIdRest.setText(""); + } else { + String uid = getResources().getString(R.string.user_id_no_name); + String uidExtra = ""; + // TODO: make it nice and use helper! + PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(getActivity(), + mSecretKeyId); + if (keyRing != null) { + PGPSecretKey key = PgpKeyHelper.getMasterKey(keyRing); + if (key != null) { + String userId = PgpKeyHelper.getMainUserIdSafe(getActivity(), key); + String chunks[] = userId.split(" <", 2); + uid = chunks[0]; + if (chunks.length > 1) { + uidExtra = "<" + chunks[1]; + } + } + } + mMainUserId.setText(uid); + mMainUserIdRest.setText(uidExtra); + mSign.setChecked(true); + } + +//TODO +// updateActionBarButtons(); + } + + private void selectPublicKeys() { + Intent intent = new Intent(getActivity(), SelectPublicKeyActivity.class); + Vector keyIds = new Vector(); + if (mSecretKeyId != 0) { + keyIds.add(mSecretKeyId); + } + if (mEncryptionKeyIds != null && mEncryptionKeyIds.length > 0) { + for (int i = 0; i < mEncryptionKeyIds.length; ++i) { + keyIds.add(mEncryptionKeyIds[i]); + } + } + long[] initialKeyIds = null; + if (keyIds.size() > 0) { + initialKeyIds = new long[keyIds.size()]; + for (int i = 0; i < keyIds.size(); ++i) { + initialKeyIds[i] = keyIds.get(i); + } + } + intent.putExtra(SelectPublicKeyActivity.EXTRA_SELECTED_MASTER_KEY_IDS, initialKeyIds); + startActivityForResult(intent, Id.request.public_keys); + } + + private void selectSecretKey() { + Intent intent = new Intent(getActivity(), SelectSecretKeyActivity.class); + startActivityForResult(intent, Id.request.secret_keys); + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + switch (requestCode) { + + case RESULT_CODE_PUBLIC_KEYS: { + if (resultCode == Activity.RESULT_OK) { + Bundle bundle = data.getExtras(); + setEncryptionKeyIds(bundle + .getLongArray(SelectPublicKeyActivity.RESULT_EXTRA_MASTER_KEY_IDS)); + } + updateView(); + break; + } + + case RESULT_CODE_SECRET_KEYS: { + if (resultCode == Activity.RESULT_OK) { + Uri uri_master_key = data.getData(); + setSignatureKeyId(Long.valueOf(uri_master_key.getLastPathSegment())); + } else { + setSignatureKeyId(Id.key.none); + } + updateView(); + break; + } + + default: { + break; + } + } + + super.onActivityResult(requestCode, resultCode, data); + } + +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java new file mode 100644 index 000000000..734941ca7 --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java @@ -0,0 +1,415 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui; + +import android.app.Activity; +import android.app.ProgressDialog; +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.os.Messenger; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.Spinner; + +import com.beardedhen.androidbootstrap.BootstrapButton; +import com.devspark.appmsg.AppMsg; + +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.Id; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.helper.FileHelper; +import org.sufficientlysecure.keychain.helper.Preferences; +import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; +import org.sufficientlysecure.keychain.service.KeychainIntentService; +import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; +import org.sufficientlysecure.keychain.service.PassphraseCacheService; +import org.sufficientlysecure.keychain.ui.dialog.DeleteFileDialogFragment; +import org.sufficientlysecure.keychain.ui.dialog.FileDialogFragment; +import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; +import org.sufficientlysecure.keychain.util.Choice; +import org.sufficientlysecure.keychain.util.Log; + +import java.io.File; + +public class EncryptFileFragment extends Fragment { + public static final String ARG_FILENAME = "filename"; + public static final String ARG_ASCII_ARMOR = "ascii_armor"; + + private static final int RESULT_CODE_FILE = 0x00007003; + + private EncryptActivityInterface mEncryptInterface; + + // view + private CheckBox mAsciiArmor = null; + private Spinner mFileCompression = null; + private EditText mFilename = null; + private CheckBox mDeleteAfter = null; + private CheckBox mShareAfter = null; + private BootstrapButton mBrowse = null; + private BootstrapButton mEncryptFile; + + private FileDialogFragment mFileDialog; + + // model + private String mInputFilename = null; + private String mOutputFilename = null; + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + try { + mEncryptInterface = (EncryptActivityInterface) activity; + } catch (ClassCastException e) { + throw new ClassCastException(activity.toString() + " must implement EncryptActivityInterface"); + } + } + + /** + * Inflate the layout for this fragment + */ + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.encrypt_file_fragment, container, false); + + mEncryptFile = (BootstrapButton) view.findViewById(R.id.action_encrypt_file); + mEncryptFile.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + encryptClicked(); + } + }); + + mFilename = (EditText) view.findViewById(R.id.filename); + mBrowse = (BootstrapButton) view.findViewById(R.id.btn_browse); + mBrowse.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + FileHelper.openFile(EncryptFileFragment.this, mFilename.getText().toString(), "*/*", + Id.request.filename); + } + }); + + mFileCompression = (Spinner) view.findViewById(R.id.fileCompression); + Choice[] choices = new Choice[]{ + new Choice(Id.choice.compression.none, getString(R.string.choice_none) + " (" + + getString(R.string.compression_fast) + ")"), + new Choice(Id.choice.compression.zip, "ZIP (" + + getString(R.string.compression_fast) + ")"), + new Choice(Id.choice.compression.zlib, "ZLIB (" + + getString(R.string.compression_fast) + ")"), + new Choice(Id.choice.compression.bzip2, "BZIP2 (" + + getString(R.string.compression_very_slow) + ")"),}; + ArrayAdapter adapter = new ArrayAdapter(getActivity(), + android.R.layout.simple_spinner_item, choices); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + mFileCompression.setAdapter(adapter); + + int defaultFileCompression = Preferences.getPreferences(getActivity()).getDefaultFileCompression(); + for (int i = 0; i < choices.length; ++i) { + if (choices[i].getId() == defaultFileCompression) { + mFileCompression.setSelection(i); + break; + } + } + + mDeleteAfter = (CheckBox) view.findViewById(R.id.deleteAfterEncryption); + mShareAfter = (CheckBox) view.findViewById(R.id.shareAfterEncryption); + + mAsciiArmor = (CheckBox) view.findViewById(R.id.asciiArmour); + mAsciiArmor.setChecked(Preferences.getPreferences(getActivity()).getDefaultAsciiArmour()); + + return view; + } + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + String filename = getArguments().getString(ARG_FILENAME); + if (filename != null) { + mFilename.setText(filename); + } + boolean asciiArmor = getArguments().getBoolean(ARG_ASCII_ARMOR); + if (asciiArmor) { + mAsciiArmor.setChecked(asciiArmor); + } + } + + /** + * Guess output filename based on input path + * + * @param path + * @return Suggestion for output filename + */ + private String guessOutputFilename(String path) { + // output in the same directory but with additional ending + File file = new File(path); + String ending = (mAsciiArmor.isChecked() ? ".asc" : ".gpg"); + String outputFilename = file.getParent() + File.separator + file.getName() + ending; + + return outputFilename; + } + + private void showOutputFileDialog() { + // Message is received after file is selected + Handler returnHandler = new Handler() { + @Override + public void handleMessage(Message message) { + if (message.what == FileDialogFragment.MESSAGE_OKAY) { + Bundle data = message.getData(); + mOutputFilename = data.getString(FileDialogFragment.MESSAGE_DATA_FILENAME); + encryptStart(); + } + } + }; + + // Create a new Messenger for the communication back + Messenger messenger = new Messenger(returnHandler); + + mFileDialog = FileDialogFragment.newInstance(messenger, + getString(R.string.title_encrypt_to_file), + getString(R.string.specify_file_to_encrypt_to), mOutputFilename, null); + + mFileDialog.show(getActivity().getSupportFragmentManager(), "fileDialog"); + } + + private void encryptClicked() { + String currentFilename = mFilename.getText().toString(); + if (mInputFilename == null || !mInputFilename.equals(currentFilename)) { + mInputFilename = mFilename.getText().toString(); + } + + mOutputFilename = guessOutputFilename(mInputFilename); + + if (mInputFilename.equals("")) { + AppMsg.makeText(getActivity(), R.string.no_file_selected, AppMsg.STYLE_ALERT).show(); + return; + } + + if (!mInputFilename.startsWith("content")) { + File file = new File(mInputFilename); + if (!file.exists() || !file.isFile()) { + AppMsg.makeText( + getActivity(), + getString(R.string.error_message, + getString(R.string.error_file_not_found)), AppMsg.STYLE_ALERT) + .show(); + return; + } + } + + if (mEncryptInterface.isModeSymmetric()) { + // symmetric encryption + + if (!mEncryptInterface.getPassphrase().equals(mEncryptInterface.getPassphraseAgain())) { + AppMsg.makeText(getActivity(), R.string.passphrases_do_not_match, AppMsg.STYLE_ALERT).show(); + return; + } + + boolean gotPassPhrase = (mEncryptInterface.getPassphrase().length() != 0); + if (!gotPassPhrase) { + AppMsg.makeText(getActivity(), R.string.passphrase_must_not_be_empty, AppMsg.STYLE_ALERT) + .show(); + return; + } + } else { + // asymmetric encryption + + boolean encryptIt = (mEncryptInterface.getEncryptionKeys() != null + && mEncryptInterface.getEncryptionKeys().length > 0); + // for now require at least one form of encryption for files + if (!encryptIt) { + AppMsg.makeText(getActivity(), R.string.select_encryption_key, AppMsg.STYLE_ALERT).show(); + return; + } + + if (!encryptIt && mEncryptInterface.getSignatureKey() == 0) { + AppMsg.makeText(getActivity(), R.string.select_encryption_or_signature_key, + AppMsg.STYLE_ALERT).show(); + return; + } + + if (mEncryptInterface.getSignatureKey() != 0 + && PassphraseCacheService.getCachedPassphrase(getActivity(), mEncryptInterface.getSignatureKey()) == null) { + showPassphraseDialog(); + + return; + } + } + + showOutputFileDialog(); + } + + private void encryptStart() { + // Send all information needed to service to edit key in other thread + Intent intent = new Intent(getActivity(), KeychainIntentService.class); + + // fill values for this action + Bundle data = new Bundle(); + + boolean useAsciiArmor = true; + long encryptionKeyIds[] = null; + int compressionId = 0; + boolean signOnly = false; + long mSecretKeyIdToPass = 0; + + if (mEncryptInterface.isModeSymmetric()) { + Log.d(Constants.TAG, "Symmetric encryption enabled!"); + String passphrase = mEncryptInterface.getPassphrase(); + if (passphrase.length() == 0) { + passphrase = null; + } + data.putString(KeychainIntentService.GENERATE_KEY_SYMMETRIC_PASSPHRASE, passphrase); + } else { + mSecretKeyIdToPass = mEncryptInterface.getSignatureKey(); + encryptionKeyIds = mEncryptInterface.getEncryptionKeys(); + signOnly = (mEncryptInterface.getEncryptionKeys() == null + || mEncryptInterface.getEncryptionKeys().length == 0); + } + + intent.setAction(KeychainIntentService.ACTION_ENCRYPT_SIGN); + + // choose default settings, target and data bundle by target + useAsciiArmor = mAsciiArmor.isChecked(); + compressionId = ((Choice) mFileCompression.getSelectedItem()).getId(); + + data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_URI); + + Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename=" + + mOutputFilename); + + data.putString(KeychainIntentService.ENCRYPT_INPUT_FILE, mInputFilename); + data.putString(KeychainIntentService.ENCRYPT_OUTPUT_FILE, mOutputFilename); + + + data.putLong(KeychainIntentService.ENCRYPT_SECRET_KEY_ID, mSecretKeyIdToPass); + data.putBoolean(KeychainIntentService.ENCRYPT_USE_ASCII_ARMOR, useAsciiArmor); + data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, encryptionKeyIds); + data.putInt(KeychainIntentService.ENCRYPT_COMPRESSION_ID, compressionId); +// data.putBoolean(KeychainIntentService.ENCRYPT_GENERATE_SIGNATURE, mGenerateSignature); + data.putBoolean(KeychainIntentService.ENCRYPT_SIGN_ONLY, signOnly); + + intent.putExtra(KeychainIntentService.EXTRA_DATA, data); + + // Message is received after encrypting is done in KeychainIntentService + KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(getActivity(), + getString(R.string.progress_encrypting), ProgressDialog.STYLE_HORIZONTAL) { + public void handleMessage(Message message) { + // handle messages by standard KeychainIntentServiceHandler first + super.handleMessage(message); + + if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { + // get returned data bundle + Bundle data = message.getData(); + + String output; + AppMsg.makeText(getActivity(), R.string.encryption_successful, + AppMsg.STYLE_INFO).show(); + + if (mDeleteAfter.isChecked()) { + // Create and show dialog to delete original file + DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment + .newInstance(mInputFilename); + deleteFileDialog.show(getActivity().getSupportFragmentManager(), "deleteDialog"); + } + + if (mShareAfter.isChecked()) { + // Share encrypted file + Intent sendFileIntent = new Intent(Intent.ACTION_SEND); + sendFileIntent.setType("*/*"); + sendFileIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(mOutputFilename)); + startActivity(Intent.createChooser(sendFileIntent, + getString(R.string.title_send_file))); + } + } + } + }; + + // Create a new Messenger for the communication back + Messenger messenger = new Messenger(saveHandler); + intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger); + + // show progress dialog + saveHandler.showProgressDialog(getActivity()); + + // start service with intent + getActivity().startService(intent); + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + switch (requestCode) { + case RESULT_CODE_FILE: { + if (resultCode == Activity.RESULT_OK && data != null) { + try { + String path = FileHelper.getPath(getActivity(), data.getData()); + Log.d(Constants.TAG, "path=" + path); + + mFilename.setText(path); + } catch (NullPointerException e) { + Log.e(Constants.TAG, "Nullpointer while retrieving path!"); + } + } + return; + } + + default: { + super.onActivityResult(requestCode, resultCode, data); + + break; + } + } + } + + /** + * Shows passphrase dialog to cache a new passphrase the user enters for using it later for + * encryption + */ + private void showPassphraseDialog() { + // Message is received after passphrase is cached + Handler returnHandler = new Handler() { + @Override + public void handleMessage(Message message) { + if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) { + showOutputFileDialog(); + } + } + }; + + // Create a new Messenger for the communication back + Messenger messenger = new Messenger(returnHandler); + + try { + PassphraseDialogFragment passphraseDialog = PassphraseDialogFragment.newInstance( + getActivity(), messenger, mEncryptInterface.getSignatureKey()); + + passphraseDialog.show(getActivity().getSupportFragmentManager(), "passphraseDialog"); + } catch (PgpGeneralException e) { + Log.d(Constants.TAG, "No passphrase for this secret key, encrypt directly!"); + // send message to handler to start encryption directly + returnHandler.sendEmptyMessage(PassphraseDialogFragment.MESSAGE_OKAY); + } + } +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java new file mode 100644 index 000000000..7f1d7311d --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java @@ -0,0 +1,289 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui; + +import android.app.Activity; +import android.app.ProgressDialog; +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.os.Messenger; +import android.support.v4.app.Fragment; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.EditText; + +import com.beardedhen.androidbootstrap.BootstrapButton; +import com.devspark.appmsg.AppMsg; + +import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.compatibility.ClipboardReflection; +import org.sufficientlysecure.keychain.helper.Preferences; +import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; +import org.sufficientlysecure.keychain.service.KeychainIntentService; +import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; +import org.sufficientlysecure.keychain.service.PassphraseCacheService; +import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; +import org.sufficientlysecure.keychain.util.Log; + +public class EncryptMessageFragment extends Fragment { + public static final String ARG_TEXT = "text"; + + private EditText mMessage = null; + private BootstrapButton mEncryptShare; + private BootstrapButton mEncryptClipboard; + + private EncryptActivityInterface mEncryptInterface; + + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + try { + mEncryptInterface = (EncryptActivityInterface) activity; + } catch (ClassCastException e) { + throw new ClassCastException(activity.toString() + " must implement EncryptActivityInterface"); + } + } + + /** + * Inflate the layout for this fragment + */ + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.encrypt_message_fragment, container, false); + + mMessage = (EditText) view.findViewById(R.id.message); + mEncryptClipboard = (BootstrapButton) view.findViewById(R.id.action_encrypt_clipboard); + mEncryptShare = (BootstrapButton) view.findViewById(R.id.action_encrypt_share); + mEncryptClipboard.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + encryptClicked(true); + } + }); + mEncryptShare.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + encryptClicked(false); + } + }); + + return view; + } + + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + String text = getArguments().getString(ARG_TEXT); + if (text != null) { + mMessage.setText(text); + } + } + + /** + * Fixes bad message characters for gmail + * + * @param message + * @return + */ + private String fixBadCharactersForGmail(String message) { + // fix the message a bit, trailing spaces and newlines break stuff, + // because GMail sends as HTML and such things fuck up the + // signature, + // TODO: things like "<" and ">" also fuck up the signature + message = message.replaceAll(" +\n", "\n"); + message = message.replaceAll("\n\n+", "\n\n"); + message = message.replaceFirst("^\n+", ""); + // make sure there'll be exactly one newline at the end + message = message.replaceFirst("\n*$", "\n"); + + return message; + } + + private void encryptClicked(boolean toClipboard) { + if (mEncryptInterface.isModeSymmetric()) { + // symmetric encryption + + boolean gotPassPhrase = false; + if (!mEncryptInterface.getPassphrase().equals(mEncryptInterface.getPassphraseAgain())) { + AppMsg.makeText(getActivity(), R.string.passphrases_do_not_match, AppMsg.STYLE_ALERT).show(); + return; + } + + gotPassPhrase = (mEncryptInterface.getPassphrase().length() != 0); + if (!gotPassPhrase) { + AppMsg.makeText(getActivity(), R.string.passphrase_must_not_be_empty, AppMsg.STYLE_ALERT) + .show(); + return; + } + } else { + // asymmetric encryption + + boolean encryptIt = (mEncryptInterface.getEncryptionKeys() != null + && mEncryptInterface.getEncryptionKeys().length > 0); + + if (!encryptIt && mEncryptInterface.getSignatureKey() == 0) { + AppMsg.makeText(getActivity(), R.string.select_encryption_or_signature_key, + AppMsg.STYLE_ALERT).show(); + return; + } + + if (mEncryptInterface.getSignatureKey() != 0 + && PassphraseCacheService.getCachedPassphrase(getActivity(), mEncryptInterface.getSignatureKey()) == null) { + showPassphraseDialog(toClipboard); + + return; + } + } + + encryptStart(toClipboard); + } + + private void encryptStart(final boolean toClipboard) { + // Send all information needed to service to edit key in other thread + Intent intent = new Intent(getActivity(), KeychainIntentService.class); + + // fill values for this action + Bundle data = new Bundle(); + + long encryptionKeyIds[] = null; + int compressionId = 0; + boolean signOnly = false; + long mSecretKeyIdToPass = 0; + + if (mEncryptInterface.isModeSymmetric()) { + Log.d(Constants.TAG, "Symmetric encryption enabled!"); + String passphrase = mEncryptInterface.getPassphrase(); + if (passphrase.length() == 0) { + passphrase = null; + } + data.putString(KeychainIntentService.GENERATE_KEY_SYMMETRIC_PASSPHRASE, passphrase); + } else { + mSecretKeyIdToPass = mEncryptInterface.getSignatureKey(); + encryptionKeyIds = mEncryptInterface.getEncryptionKeys(); + signOnly = (mEncryptInterface.getEncryptionKeys() == null + || mEncryptInterface.getEncryptionKeys().length == 0); + } + + intent.setAction(KeychainIntentService.ACTION_ENCRYPT_SIGN); + + // choose default settings, target and data bundle by target + compressionId = Preferences.getPreferences(getActivity()).getDefaultMessageCompression(); + + data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_BYTES); + + String message = mMessage.getText().toString(); + if (signOnly) { + message = fixBadCharactersForGmail(message); + } + data.putByteArray(KeychainIntentService.ENCRYPT_MESSAGE_BYTES, message.getBytes()); + + data.putLong(KeychainIntentService.ENCRYPT_SECRET_KEY_ID, mSecretKeyIdToPass); + data.putBoolean(KeychainIntentService.ENCRYPT_USE_ASCII_ARMOR, true); + data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, encryptionKeyIds); + data.putInt(KeychainIntentService.ENCRYPT_COMPRESSION_ID, compressionId); +// data.putBoolean(KeychainIntentService.ENCRYPT_GENERATE_SIGNATURE, mGenerateSignature); + data.putBoolean(KeychainIntentService.ENCRYPT_SIGN_ONLY, signOnly); + + intent.putExtra(KeychainIntentService.EXTRA_DATA, data); + + // Message is received after encrypting is done in KeychainIntentService + KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(getActivity(), + getString(R.string.progress_encrypting), ProgressDialog.STYLE_HORIZONTAL) { + public void handleMessage(Message message) { + // handle messages by standard KeychainIntentServiceHandler first + super.handleMessage(message); + + if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { + // get returned data bundle + Bundle data = message.getData(); + + String output; + if (toClipboard) { + output = data.getString(KeychainIntentService.RESULT_ENCRYPTED_STRING); + Log.d(Constants.TAG, "output: " + output); + ClipboardReflection.copyToClipboard(getActivity(), output); + AppMsg.makeText(getActivity(), + R.string.encryption_to_clipboard_successful, AppMsg.STYLE_INFO) + .show(); + } else { + output = data.getString(KeychainIntentService.RESULT_ENCRYPTED_STRING); + Log.d(Constants.TAG, "output: " + output); + + Intent sendIntent = new Intent(Intent.ACTION_SEND); + + // Type is set to text/plain so that encrypted messages can + // be sent with Whatsapp, Hangouts, SMS etc... + sendIntent.setType("text/plain"); + + sendIntent.putExtra(Intent.EXTRA_TEXT, output); + startActivity(Intent.createChooser(sendIntent, + getString(R.string.title_send_email))); + } + } + } + }; + + // Create a new Messenger for the communication back + Messenger messenger = new Messenger(saveHandler); + intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger); + + // show progress dialog + saveHandler.showProgressDialog(getActivity()); + + // start service with intent + getActivity().startService(intent); + } + + /** + * Shows passphrase dialog to cache a new passphrase the user enters for using it later for + * encryption + */ + private void showPassphraseDialog(final boolean toClipboard) { + // Message is received after passphrase is cached + Handler returnHandler = new Handler() { + @Override + public void handleMessage(Message message) { + if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) { + encryptStart(toClipboard); + } + } + }; + + // Create a new Messenger for the communication back + Messenger messenger = new Messenger(returnHandler); + + try { + PassphraseDialogFragment passphraseDialog = PassphraseDialogFragment.newInstance( + getActivity(), messenger, mEncryptInterface.getSignatureKey()); + + passphraseDialog.show(getActivity().getSupportFragmentManager(), "passphraseDialog"); + } catch (PgpGeneralException e) { + Log.d(Constants.TAG, "No passphrase for this secret key, encrypt directly!"); + // send message to handler to start encryption directly + returnHandler.sendEmptyMessage(PassphraseDialogFragment.MESSAGE_OKAY); + } + } + +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptSymmetricFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptSymmetricFragment.java new file mode 100644 index 000000000..f23cc565a --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptSymmetricFragment.java @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2014 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.ui; + +import android.app.Activity; +import android.os.Bundle; +import android.support.v4.app.Fragment; +import android.text.Editable; +import android.text.TextWatcher; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.EditText; + +import org.sufficientlysecure.keychain.R; + +public class EncryptSymmetricFragment extends Fragment { + + OnSymmetricKeySelection mPassphraseUpdateListener; + + private EditText mPassphrase; + private EditText mPassphraseAgain; + + // Container Activity must implement this interface + public interface OnSymmetricKeySelection { + public void onPassphraseUpdate(String passphrase); + + public void onPassphraseAgainUpdate(String passphrase); + } + + @Override + public void onAttach(Activity activity) { + super.onAttach(activity); + try { + mPassphraseUpdateListener = (OnSymmetricKeySelection) activity; + } catch (ClassCastException e) { + throw new ClassCastException(activity.toString() + " must implement OnSymmetricKeySelection"); + } + } + + /** + * Inflate the layout for this fragment + */ + @Override + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.encrypt_symmetric_fragment, container, false); + + mPassphrase = (EditText) view.findViewById(R.id.passphrase); + mPassphraseAgain = (EditText) view.findViewById(R.id.passphraseAgain); + mPassphrase.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + } + + @Override + public void afterTextChanged(Editable s) { + mPassphraseUpdateListener.onPassphraseUpdate(s.toString()); + } + }); + mPassphraseAgain.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + } + + @Override + public void afterTextChanged(Editable s) { + mPassphraseUpdateListener.onPassphraseAgainUpdate(s.toString()); + } + }); + + return view; + } +} diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml index e7d08f0fa..4515c8092 100644 --- a/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml @@ -13,8 +13,7 @@ + android:orientation="horizontal"> diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml index 1dba66cfa..e719d07e1 100644 --- a/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_content.xml @@ -1,318 +1,37 @@ - + + + android:layout_height="150dp"> - + android:layout_gravity="top" + android:background="@color/emphasis" + android:textColor="#fff" /> + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + - - - - + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_file_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_file_fragment.xml index 24a67acb7..09df8ae28 100644 --- a/OpenPGP-Keychain/src/main/res/layout/encrypt_file_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_file_fragment.xml @@ -59,7 +59,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/section_encrypt_and_or_sign" - android:layout_above="@+id/decrypt_file_action_decrypt" + android:layout_above="@+id/action_encrypt_file" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" /> @@ -68,10 +68,12 @@ android:layout_width="match_parent" android:layout_height="60dp" android:padding="4dp" - android:visibility="gone" android:text="@string/btn_encrypt_file" bootstrapbutton:bb_icon_left="fa-lock" - bootstrapbutton:bb_type="info" /> + bootstrapbutton:bb_type="info" + android:layout_alignParentBottom="true" + android:layout_alignParentLeft="true" + android:layout_alignParentStart="true" /> \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index 5d325d5ec..8ae43c8ea 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -135,8 +135,6 @@ Name Comment Email - Sign User Id - Sign email Upload key to selected keyserver after certification Fingerprint Select -- cgit v1.2.3 From 6a617e0bf85ba6e7a3616b3942a143aae2ac87c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 13:31:49 +0200 Subject: Small layout fix (more to come) --- OpenPGP-Keychain/src/main/res/layout/encrypt_file_fragment.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_file_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_file_fragment.xml index 09df8ae28..bdca11423 100644 --- a/OpenPGP-Keychain/src/main/res/layout/encrypt_file_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_file_fragment.xml @@ -39,7 +39,7 @@ Date: Tue, 1 Apr 2014 14:10:32 +0200 Subject: Fix symmetric encryption and cleanup --- .../keychain/pgp/PgpSignEncrypt.java | 20 ++++---- .../keychain/service/KeychainIntentService.java | 6 +-- .../keychain/ui/EncryptActivity.java | 59 ++-------------------- .../keychain/ui/EncryptActivityInterface.java | 18 ++++++- .../keychain/ui/EncryptAsymmetricFragment.java | 11 ++-- .../keychain/ui/EncryptFileFragment.java | 54 +++++++++----------- .../keychain/ui/EncryptMessageFragment.java | 57 ++++++++++----------- .../keychain/ui/EncryptSymmetricFragment.java | 2 + 8 files changed, 91 insertions(+), 136 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java index 737e9c75d..6d80c154b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java @@ -18,6 +18,7 @@ package org.sufficientlysecure.keychain.pgp; import android.content.Context; + import org.spongycastle.bcpg.ArmoredOutputStream; import org.spongycastle.bcpg.BCPGOutputStream; import org.spongycastle.openpgp.*; @@ -50,7 +51,7 @@ public class PgpSignEncrypt { private boolean mEnableAsciiArmorOutput; private int mCompressionId; private long[] mEncryptionKeyIds; - private String mEncryptionPassphrase; + private String mSymmetricPassphrase; private int mSymmetricEncryptionAlgorithm; private long mSignatureKeyId; private int mSignatureHashAlgorithm; @@ -67,7 +68,7 @@ public class PgpSignEncrypt { this.mEnableAsciiArmorOutput = builder.mEnableAsciiArmorOutput; this.mCompressionId = builder.mCompressionId; this.mEncryptionKeyIds = builder.mEncryptionKeyIds; - this.mEncryptionPassphrase = builder.mEncryptionPassphrase; + this.mSymmetricPassphrase = builder.mSymmetricPassphrase; this.mSymmetricEncryptionAlgorithm = builder.mSymmetricEncryptionAlgorithm; this.mSignatureKeyId = builder.mSignatureKeyId; this.mSignatureHashAlgorithm = builder.mSignatureHashAlgorithm; @@ -85,8 +86,8 @@ public class PgpSignEncrypt { private ProgressDialogUpdater mProgress = null; private boolean mEnableAsciiArmorOutput = false; private int mCompressionId = Id.choice.compression.none; - private long[] mEncryptionKeyIds = new long[0]; - private String mEncryptionPassphrase = null; + private long[] mEncryptionKeyIds = null; + private String mSymmetricPassphrase = null; private int mSymmetricEncryptionAlgorithm = 0; private long mSignatureKeyId = Id.key.none; private int mSignatureHashAlgorithm = 0; @@ -119,8 +120,8 @@ public class PgpSignEncrypt { return this; } - public Builder encryptionPassphrase(String encryptionPassphrase) { - this.mEncryptionPassphrase = encryptionPassphrase; + public Builder symmetricPassphrase(String symmetricPassphrase) { + this.mSymmetricPassphrase = symmetricPassphrase; return this; } @@ -181,7 +182,8 @@ public class PgpSignEncrypt { NoSuchAlgorithmException, SignatureException { boolean enableSignature = mSignatureKeyId != Id.key.none; - boolean enableEncryption = (mEncryptionKeyIds.length != 0 || mEncryptionPassphrase != null); + boolean enableEncryption = ((mEncryptionKeyIds != null && mEncryptionKeyIds.length > 0) + || mSymmetricPassphrase != null); boolean enableCompression = (enableEncryption && mCompressionId != Id.choice.compression.none); Log.d(Constants.TAG, "enableSignature:" + enableSignature @@ -246,12 +248,12 @@ public class PgpSignEncrypt { cPk = new PGPEncryptedDataGenerator(encryptorBuilder); - if (mEncryptionKeyIds.length == 0) { + if (mSymmetricPassphrase != null) { // Symmetric encryption Log.d(Constants.TAG, "encryptionKeyIds length is 0 -> symmetric encryption"); JcePBEKeyEncryptionMethodGenerator symmetricEncryptionGenerator = - new JcePBEKeyEncryptionMethodGenerator(mEncryptionPassphrase.toCharArray()); + new JcePBEKeyEncryptionMethodGenerator(mSymmetricPassphrase.toCharArray()); cPk.addMethod(symmetricEncryptionGenerator); } else { // Asymmetric encryption diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index f616f7300..46033d094 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -43,7 +43,6 @@ import org.sufficientlysecure.keychain.util.*; import java.io.*; import java.util.ArrayList; -import java.util.GregorianCalendar; import java.util.List; /** @@ -99,6 +98,7 @@ public class KeychainIntentService extends IntentService public static final String ENCRYPT_INPUT_FILE = "input_file"; public static final String ENCRYPT_OUTPUT_FILE = "output_file"; public static final String ENCRYPT_PROVIDER_URI = "provider_uri"; + public static final String ENCRYPT_SYMMETRIC_PASSPHRASE = "passphrase"; // decrypt/verify public static final String DECRYPT_CIPHERTEXT_BYTES = "ciphertext_bytes"; @@ -221,7 +221,7 @@ public class KeychainIntentService extends IntentService int target = data.getInt(TARGET); long secretKeyId = data.getLong(ENCRYPT_SECRET_KEY_ID); - String encryptionPassphrase = data.getString(GENERATE_KEY_SYMMETRIC_PASSPHRASE); + String symmetricPassphrase = data.getString(ENCRYPT_SYMMETRIC_PASSPHRASE); boolean useAsciiArmor = data.getBoolean(ENCRYPT_USE_ASCII_ARMOR); long encryptionKeyIds[] = data.getLongArray(ENCRYPT_ENCRYPTION_KEYS_IDS); @@ -329,7 +329,7 @@ public class KeychainIntentService extends IntentService Preferences.getPreferences(this).getDefaultEncryptionAlgorithm()) .signatureForceV3(Preferences.getPreferences(this).getForceV3Signatures()) .encryptionKeyIds(encryptionKeyIds) - .encryptionPassphrase(encryptionPassphrase) + .symmetricPassphrase(symmetricPassphrase) .signatureKeyId(secretKeyId) .signatureHashAlgorithm( Preferences.getPreferences(this).getDefaultHashAlgorithm()) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java index 47c4347f6..db35b7c28 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java @@ -71,18 +71,12 @@ public class EncryptActivity extends DrawerActivity implements private static final int PAGER_CONTENT_MESSAGE = 0; private static final int PAGER_CONTENT_FILE = 1; - // model + // model useb by message and file fragment private long mEncryptionKeyIds[] = null; private long mSigningKeyId = Id.key.none; private String mPassphrase; private String mPassphraseAgain; - private boolean mAsciiArmorDemand = false; - private boolean mOverrideAsciiArmor = false; - - private boolean mGenerateSignature = false; - - @Override public void onSigningKeySelected(long signingKeyId) { mSigningKeyId = signingKeyId; @@ -208,8 +202,8 @@ public class EncryptActivity extends DrawerActivity implements } if (extras.containsKey(EXTRA_ASCII_ARMOR)) { - mAsciiArmorDemand = extras.getBoolean(EXTRA_ASCII_ARMOR, true); - mFileFragmentBundle.putBoolean(EncryptFileFragment.ARG_ASCII_ARMOR, mAsciiArmorDemand); + boolean requestAsciiArmor = extras.getBoolean(EXTRA_ASCII_ARMOR, true); + mFileFragmentBundle.putBoolean(EncryptFileFragment.ARG_ASCII_ARMOR, requestAsciiArmor); } String textData = extras.getString(EXTRA_TEXT); @@ -252,51 +246,4 @@ public class EncryptActivity extends DrawerActivity implements } } - -// /** -// * Update ActionBar buttons based on current selection in view -// */ -// private void updateActionBarButtons() { -// switch (mSource.getCurrentView().getId()) { -// case R.id.sourceFile: { -// mEncryptShare.setVisibility(View.GONE); -// mEncryptClipboard.setVisibility(View.GONE); -// mEncryptFile.setVisibility(View.VISIBLE); -// break; -// } -// -// case R.id.sourceMessage: { -// mSourceLabel.setText(R.string.label_message); -// -// mEncryptShare.setVisibility(View.VISIBLE); -// mEncryptClipboard.setVisibility(View.VISIBLE); -// mEncryptFile.setVisibility(View.GONE); -// -// if (mMode.getCurrentView().getId() == R.id.modeSymmetric) { -// mEncryptShare.setEnabled(true); -// mEncryptClipboard.setEnabled(true); -// } else { -// if (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0) { -// if (mSecretKeyId == 0) { -// mEncryptShare.setEnabled(false); -// mEncryptClipboard.setEnabled(false); -// } else { -// mEncryptShare.setEnabled(true); -// mEncryptClipboard.setEnabled(true); -// } -// } else { -// mEncryptShare.setEnabled(true); -// mEncryptClipboard.setEnabled(true); -// } -// } -// break; -// } -// -// default: { -// break; -// } -// } -// -// } - } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivityInterface.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivityInterface.java index 8fbabe9c0..0786b3a16 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivityInterface.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivityInterface.java @@ -1,5 +1,21 @@ -package org.sufficientlysecure.keychain.ui; +/* + * Copyright (C) 2014 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.sufficientlysecure.keychain.ui; public interface EncryptActivityInterface { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java index b88dafd4a..72087f9bd 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java @@ -79,15 +79,16 @@ public class EncryptAsymmetricFragment extends Fragment { private void setSignatureKeyId(long signatureKeyId) { mSecretKeyId = signatureKeyId; + // update key selection in EncryptActivity mKeySelectionListener.onSigningKeySelected(signatureKeyId); } private void setEncryptionKeyIds(long[] encryptionKeyIds) { mEncryptionKeyIds = encryptionKeyIds; + // update key selection in EncryptActivity mKeySelectionListener.onEncryptionKeysSelected(encryptionKeyIds); } - /** * Inflate the layout for this fragment */ @@ -138,6 +139,7 @@ public class EncryptAsymmetricFragment extends Fragment { */ private void preselectKeys(long preselectedSignatureKeyId, long[] preselectedEncryptionKeyIds) { if (preselectedSignatureKeyId != 0) { + // TODO: don't use bouncy castle objects! PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(getActivity(), preselectedSignatureKeyId); PGPSecretKey masterKey; @@ -155,6 +157,8 @@ public class EncryptAsymmetricFragment extends Fragment { if (preselectedEncryptionKeyIds != null) { Vector goodIds = new Vector(); for (int i = 0; i < preselectedEncryptionKeyIds.length; ++i) { + // TODO: don't use bouncy castle objects! + PGPPublicKeyRing keyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(getActivity(), preselectedEncryptionKeyIds[i]); PGPPublicKey masterKey; @@ -197,7 +201,7 @@ public class EncryptAsymmetricFragment extends Fragment { } else { String uid = getResources().getString(R.string.user_id_no_name); String uidExtra = ""; - // TODO: make it nice and use helper! + // TODO: don't use bouncy castle objects! PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(getActivity(), mSecretKeyId); if (keyRing != null) { @@ -215,9 +219,6 @@ public class EncryptAsymmetricFragment extends Fragment { mMainUserIdRest.setText(uidExtra); mSign.setChecked(true); } - -//TODO -// updateActionBarButtons(); } private void selectPublicKeys() { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java index 734941ca7..a2cd74378 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java @@ -223,29 +223,30 @@ public class EncryptFileFragment extends Fragment { if (mEncryptInterface.isModeSymmetric()) { // symmetric encryption - if (!mEncryptInterface.getPassphrase().equals(mEncryptInterface.getPassphraseAgain())) { - AppMsg.makeText(getActivity(), R.string.passphrases_do_not_match, AppMsg.STYLE_ALERT).show(); - return; - } - - boolean gotPassPhrase = (mEncryptInterface.getPassphrase().length() != 0); + boolean gotPassPhrase = (mEncryptInterface.getPassphrase() != null + && mEncryptInterface.getPassphrase().length() != 0); if (!gotPassPhrase) { AppMsg.makeText(getActivity(), R.string.passphrase_must_not_be_empty, AppMsg.STYLE_ALERT) .show(); return; } + + if (!mEncryptInterface.getPassphrase().equals(mEncryptInterface.getPassphraseAgain())) { + AppMsg.makeText(getActivity(), R.string.passphrases_do_not_match, AppMsg.STYLE_ALERT).show(); + return; + } } else { // asymmetric encryption - boolean encryptIt = (mEncryptInterface.getEncryptionKeys() != null + boolean gotEncryptionKeys = (mEncryptInterface.getEncryptionKeys() != null && mEncryptInterface.getEncryptionKeys().length > 0); - // for now require at least one form of encryption for files - if (!encryptIt) { + + if (!gotEncryptionKeys) { AppMsg.makeText(getActivity(), R.string.select_encryption_key, AppMsg.STYLE_ALERT).show(); return; } - if (!encryptIt && mEncryptInterface.getSignatureKey() == 0) { + if (!gotEncryptionKeys && mEncryptInterface.getSignatureKey() == 0) { AppMsg.makeText(getActivity(), R.string.select_encryption_or_signature_key, AppMsg.STYLE_ALERT).show(); return; @@ -266,14 +267,12 @@ public class EncryptFileFragment extends Fragment { // Send all information needed to service to edit key in other thread Intent intent = new Intent(getActivity(), KeychainIntentService.class); + intent.setAction(KeychainIntentService.ACTION_ENCRYPT_SIGN); + // fill values for this action Bundle data = new Bundle(); - boolean useAsciiArmor = true; - long encryptionKeyIds[] = null; - int compressionId = 0; - boolean signOnly = false; - long mSecretKeyIdToPass = 0; + data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_URI); if (mEncryptInterface.isModeSymmetric()) { Log.d(Constants.TAG, "Symmetric encryption enabled!"); @@ -281,35 +280,28 @@ public class EncryptFileFragment extends Fragment { if (passphrase.length() == 0) { passphrase = null; } - data.putString(KeychainIntentService.GENERATE_KEY_SYMMETRIC_PASSPHRASE, passphrase); + data.putString(KeychainIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase); } else { - mSecretKeyIdToPass = mEncryptInterface.getSignatureKey(); - encryptionKeyIds = mEncryptInterface.getEncryptionKeys(); - signOnly = (mEncryptInterface.getEncryptionKeys() == null + data.putLong(KeychainIntentService.ENCRYPT_SECRET_KEY_ID, mEncryptInterface.getSignatureKey()); + data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, mEncryptInterface.getEncryptionKeys()); + + boolean signOnly = (mEncryptInterface.getEncryptionKeys() == null || mEncryptInterface.getEncryptionKeys().length == 0); + data.putBoolean(KeychainIntentService.ENCRYPT_SIGN_ONLY, signOnly); } - intent.setAction(KeychainIntentService.ACTION_ENCRYPT_SIGN); - - // choose default settings, target and data bundle by target - useAsciiArmor = mAsciiArmor.isChecked(); - compressionId = ((Choice) mFileCompression.getSelectedItem()).getId(); - - data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_URI); - Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename=" + mOutputFilename); data.putString(KeychainIntentService.ENCRYPT_INPUT_FILE, mInputFilename); data.putString(KeychainIntentService.ENCRYPT_OUTPUT_FILE, mOutputFilename); - - data.putLong(KeychainIntentService.ENCRYPT_SECRET_KEY_ID, mSecretKeyIdToPass); + boolean useAsciiArmor = mAsciiArmor.isChecked(); data.putBoolean(KeychainIntentService.ENCRYPT_USE_ASCII_ARMOR, useAsciiArmor); - data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, encryptionKeyIds); + + int compressionId = ((Choice) mFileCompression.getSelectedItem()).getId(); data.putInt(KeychainIntentService.ENCRYPT_COMPRESSION_ID, compressionId); // data.putBoolean(KeychainIntentService.ENCRYPT_GENERATE_SIGNATURE, mGenerateSignature); - data.putBoolean(KeychainIntentService.ENCRYPT_SIGN_ONLY, signOnly); intent.putExtra(KeychainIntentService.EXTRA_DATA, data); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java index 7f1d7311d..6fdf9c034 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java @@ -125,25 +125,26 @@ public class EncryptMessageFragment extends Fragment { if (mEncryptInterface.isModeSymmetric()) { // symmetric encryption - boolean gotPassPhrase = false; - if (!mEncryptInterface.getPassphrase().equals(mEncryptInterface.getPassphraseAgain())) { - AppMsg.makeText(getActivity(), R.string.passphrases_do_not_match, AppMsg.STYLE_ALERT).show(); - return; - } - - gotPassPhrase = (mEncryptInterface.getPassphrase().length() != 0); + boolean gotPassPhrase = (mEncryptInterface.getPassphrase() != null + && mEncryptInterface.getPassphrase().length() != 0); if (!gotPassPhrase) { AppMsg.makeText(getActivity(), R.string.passphrase_must_not_be_empty, AppMsg.STYLE_ALERT) .show(); return; } + + if (!mEncryptInterface.getPassphrase().equals(mEncryptInterface.getPassphraseAgain())) { + AppMsg.makeText(getActivity(), R.string.passphrases_do_not_match, AppMsg.STYLE_ALERT).show(); + return; + } + } else { // asymmetric encryption - boolean encryptIt = (mEncryptInterface.getEncryptionKeys() != null + boolean gotEncryptionKeys = (mEncryptInterface.getEncryptionKeys() != null && mEncryptInterface.getEncryptionKeys().length > 0); - if (!encryptIt && mEncryptInterface.getSignatureKey() == 0) { + if (!gotEncryptionKeys && mEncryptInterface.getSignatureKey() == 0) { AppMsg.makeText(getActivity(), R.string.select_encryption_or_signature_key, AppMsg.STYLE_ALERT).show(); return; @@ -164,13 +165,14 @@ public class EncryptMessageFragment extends Fragment { // Send all information needed to service to edit key in other thread Intent intent = new Intent(getActivity(), KeychainIntentService.class); + intent.setAction(KeychainIntentService.ACTION_ENCRYPT_SIGN); + // fill values for this action Bundle data = new Bundle(); - long encryptionKeyIds[] = null; - int compressionId = 0; - boolean signOnly = false; - long mSecretKeyIdToPass = 0; + data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_BYTES); + + String message = mMessage.getText().toString(); if (mEncryptInterface.isModeSymmetric()) { Log.d(Constants.TAG, "Symmetric encryption enabled!"); @@ -178,33 +180,26 @@ public class EncryptMessageFragment extends Fragment { if (passphrase.length() == 0) { passphrase = null; } - data.putString(KeychainIntentService.GENERATE_KEY_SYMMETRIC_PASSPHRASE, passphrase); + data.putString(KeychainIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase); } else { - mSecretKeyIdToPass = mEncryptInterface.getSignatureKey(); - encryptionKeyIds = mEncryptInterface.getEncryptionKeys(); - signOnly = (mEncryptInterface.getEncryptionKeys() == null + data.putLong(KeychainIntentService.ENCRYPT_SECRET_KEY_ID, mEncryptInterface.getSignatureKey()); + data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, mEncryptInterface.getEncryptionKeys()); + + boolean signOnly = (mEncryptInterface.getEncryptionKeys() == null || mEncryptInterface.getEncryptionKeys().length == 0); + data.putBoolean(KeychainIntentService.ENCRYPT_SIGN_ONLY, signOnly); + if (signOnly) { + message = fixBadCharactersForGmail(message); + } } - intent.setAction(KeychainIntentService.ACTION_ENCRYPT_SIGN); - - // choose default settings, target and data bundle by target - compressionId = Preferences.getPreferences(getActivity()).getDefaultMessageCompression(); - - data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_BYTES); - - String message = mMessage.getText().toString(); - if (signOnly) { - message = fixBadCharactersForGmail(message); - } data.putByteArray(KeychainIntentService.ENCRYPT_MESSAGE_BYTES, message.getBytes()); - data.putLong(KeychainIntentService.ENCRYPT_SECRET_KEY_ID, mSecretKeyIdToPass); data.putBoolean(KeychainIntentService.ENCRYPT_USE_ASCII_ARMOR, true); - data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, encryptionKeyIds); + + int compressionId = Preferences.getPreferences(getActivity()).getDefaultMessageCompression(); data.putInt(KeychainIntentService.ENCRYPT_COMPRESSION_ID, compressionId); // data.putBoolean(KeychainIntentService.ENCRYPT_GENERATE_SIGNATURE, mGenerateSignature); - data.putBoolean(KeychainIntentService.ENCRYPT_SIGN_ONLY, signOnly); intent.putExtra(KeychainIntentService.EXTRA_DATA, data); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptSymmetricFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptSymmetricFragment.java index f23cc565a..8efa07953 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptSymmetricFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptSymmetricFragment.java @@ -73,6 +73,7 @@ public class EncryptSymmetricFragment extends Fragment { @Override public void afterTextChanged(Editable s) { + // update passphrase in EncryptActivity mPassphraseUpdateListener.onPassphraseUpdate(s.toString()); } }); @@ -87,6 +88,7 @@ public class EncryptSymmetricFragment extends Fragment { @Override public void afterTextChanged(Editable s) { + // update passphrase in EncryptActivity mPassphraseUpdateListener.onPassphraseAgainUpdate(s.toString()); } }); -- cgit v1.2.3 From 866d2d28cc225389a6ff6ef78616b72926d41a7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 14:25:37 +0200 Subject: Simplify encrypt and sign backend --- .../keychain/service/KeychainIntentService.java | 152 ++++++++------------- .../keychain/ui/EncryptFileFragment.java | 10 +- .../keychain/ui/EncryptMessageFragment.java | 12 +- 3 files changed, 59 insertions(+), 115 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 46033d094..2ad7e348b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -18,7 +18,6 @@ package org.sufficientlysecure.keychain.service; import android.app.IntentService; -import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -36,7 +35,6 @@ import org.sufficientlysecure.keychain.helper.OtherHelper; import org.sufficientlysecure.keychain.helper.Preferences; import org.sufficientlysecure.keychain.pgp.*; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; -import org.sufficientlysecure.keychain.provider.KeychainContract.DataStream; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; import org.sufficientlysecure.keychain.util.*; @@ -88,12 +86,10 @@ public class KeychainIntentService extends IntentService public static final int TARGET_STREAM = 3; // encrypt - public static final String ENCRYPT_SECRET_KEY_ID = "secret_key_id"; + public static final String ENCRYPT_SIGNATURE_KEY_ID = "secret_key_id"; public static final String ENCRYPT_USE_ASCII_ARMOR = "use_ascii_armor"; public static final String ENCRYPT_ENCRYPTION_KEYS_IDS = "encryption_keys_ids"; public static final String ENCRYPT_COMPRESSION_ID = "compression_id"; - public static final String ENCRYPT_GENERATE_SIGNATURE = "generate_signature"; - public static final String ENCRYPT_SIGN_ONLY = "sign_only"; public static final String ENCRYPT_MESSAGE_BYTES = "message_bytes"; public static final String ENCRYPT_INPUT_FILE = "input_file"; public static final String ENCRYPT_OUTPUT_FILE = "output_file"; @@ -152,7 +148,7 @@ public class KeychainIntentService extends IntentService public static final String RESULT_SIGNATURE_BYTES = "signature_data"; public static final String RESULT_SIGNATURE_STRING = "signature_text"; public static final String RESULT_ENCRYPTED_STRING = "encrypted_message"; - public static final String RESULT_ENCRYPTED_BYTES = "encrypted_data"; + public static final String RESULT_BYTES = "encrypted_data"; public static final String RESULT_URI = "result_uri"; // decrypt/verify @@ -220,20 +216,17 @@ public class KeychainIntentService extends IntentService /* Input */ int target = data.getInt(TARGET); - long secretKeyId = data.getLong(ENCRYPT_SECRET_KEY_ID); + long signatureKeyId = data.getLong(ENCRYPT_SIGNATURE_KEY_ID); String symmetricPassphrase = data.getString(ENCRYPT_SYMMETRIC_PASSPHRASE); boolean useAsciiArmor = data.getBoolean(ENCRYPT_USE_ASCII_ARMOR); long encryptionKeyIds[] = data.getLongArray(ENCRYPT_ENCRYPTION_KEYS_IDS); int compressionId = data.getInt(ENCRYPT_COMPRESSION_ID); - boolean generateSignature = data.getBoolean(ENCRYPT_GENERATE_SIGNATURE); - boolean signOnly = data.getBoolean(ENCRYPT_SIGN_ONLY); - - InputStream inStream = null; - long inLength = -1; - InputData inputData = null; - OutputStream outStream = null; - String streamFilename = null; + InputStream inStream; + long inLength; + InputData inputData; + OutputStream outStream; +// String streamFilename = null; switch (target) { case TARGET_BYTES: /* encrypting bytes directly */ byte[] bytes = data.getByteArray(ENCRYPT_MESSAGE_BYTES); @@ -265,29 +258,30 @@ public class KeychainIntentService extends IntentService break; - case TARGET_STREAM: /* Encrypting stream from content uri */ - Uri providerUri = (Uri) data.getParcelable(ENCRYPT_PROVIDER_URI); - - // InputStream - InputStream in = getContentResolver().openInputStream(providerUri); - inLength = PgpHelper.getLengthOfStream(in); - inputData = new InputData(in, inLength); - - // OutputStream - try { - while (true) { - streamFilename = PgpHelper.generateRandomFilename(32); - if (streamFilename == null) { - throw new PgpGeneralException("couldn't generate random file name"); - } - openFileInput(streamFilename).close(); - } - } catch (FileNotFoundException e) { - // found a name that isn't used yet - } - outStream = openFileOutput(streamFilename, Context.MODE_PRIVATE); - - break; + // TODO: not used currently +// case TARGET_STREAM: /* Encrypting stream from content uri */ +// Uri providerUri = (Uri) data.getParcelable(ENCRYPT_PROVIDER_URI); +// +// // InputStream +// InputStream in = getContentResolver().openInputStream(providerUri); +// inLength = PgpHelper.getLengthOfStream(in); +// inputData = new InputData(in, inLength); +// +// // OutputStream +// try { +// while (true) { +// streamFilename = PgpHelper.generateRandomFilename(32); +// if (streamFilename == null) { +// throw new PgpGeneralException("couldn't generate random file name"); +// } +// openFileInput(streamFilename).close(); +// } +// } catch (FileNotFoundException e) { +// // found a name that isn't used yet +// } +// outStream = openFileOutput(streamFilename, Context.MODE_PRIVATE); +// +// break; default: throw new PgpGeneralException("No target choosen!"); @@ -299,45 +293,20 @@ public class KeychainIntentService extends IntentService new PgpSignEncrypt.Builder(this, inputData, outStream); builder.progress(this); - if (generateSignature) { - Log.d(Constants.TAG, "generating signature..."); - builder.enableAsciiArmorOutput(useAsciiArmor) - .signatureForceV3(Preferences.getPreferences(this).getForceV3Signatures()) - .signatureKeyId(secretKeyId) - .signatureHashAlgorithm( - Preferences.getPreferences(this).getDefaultHashAlgorithm()) - .signaturePassphrase( - PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); - - builder.build().generateSignature(); - } else if (signOnly) { - Log.d(Constants.TAG, "sign only..."); - builder.enableAsciiArmorOutput(useAsciiArmor) - .signatureForceV3(Preferences.getPreferences(this).getForceV3Signatures()) - .signatureKeyId(secretKeyId) - .signatureHashAlgorithm( - Preferences.getPreferences(this).getDefaultHashAlgorithm()) - .signaturePassphrase( - PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); - - builder.build().execute(); - } else { - Log.d(Constants.TAG, "encrypt..."); - builder.enableAsciiArmorOutput(useAsciiArmor) - .compressionId(compressionId) - .symmetricEncryptionAlgorithm( - Preferences.getPreferences(this).getDefaultEncryptionAlgorithm()) - .signatureForceV3(Preferences.getPreferences(this).getForceV3Signatures()) - .encryptionKeyIds(encryptionKeyIds) - .symmetricPassphrase(symmetricPassphrase) - .signatureKeyId(secretKeyId) - .signatureHashAlgorithm( - Preferences.getPreferences(this).getDefaultHashAlgorithm()) - .signaturePassphrase( - PassphraseCacheService.getCachedPassphrase(this, secretKeyId)); - - builder.build().execute(); - } + builder.enableAsciiArmorOutput(useAsciiArmor) + .compressionId(compressionId) + .symmetricEncryptionAlgorithm( + Preferences.getPreferences(this).getDefaultEncryptionAlgorithm()) + .signatureForceV3(Preferences.getPreferences(this).getForceV3Signatures()) + .encryptionKeyIds(encryptionKeyIds) + .symmetricPassphrase(symmetricPassphrase) + .signatureKeyId(signatureKeyId) + .signatureHashAlgorithm( + Preferences.getPreferences(this).getDefaultHashAlgorithm()) + .signaturePassphrase( + PassphraseCacheService.getCachedPassphrase(this, signatureKeyId)); + + builder.build().execute(); outStream.close(); @@ -347,33 +316,20 @@ public class KeychainIntentService extends IntentService switch (target) { case TARGET_BYTES: - if (useAsciiArmor) { - String output = new String( - ((ByteArrayOutputStream) outStream).toByteArray()); - if (generateSignature) { - resultData.putString(RESULT_SIGNATURE_STRING, output); - } else { - resultData.putString(RESULT_ENCRYPTED_STRING, output); - } - } else { - byte output[] = ((ByteArrayOutputStream) outStream).toByteArray(); - if (generateSignature) { - resultData.putByteArray(RESULT_SIGNATURE_BYTES, output); - } else { - resultData.putByteArray(RESULT_ENCRYPTED_BYTES, output); - } - } + byte output[] = ((ByteArrayOutputStream) outStream).toByteArray(); + + resultData.putByteArray(RESULT_BYTES, output); break; case TARGET_URI: // nothing, file was written, just send okay break; - case TARGET_STREAM: - String uri = DataStream.buildDataStreamUri(streamFilename).toString(); - resultData.putString(RESULT_URI, uri); - - break; +// case TARGET_STREAM: +// String uri = DataStream.buildDataStreamUri(streamFilename).toString(); +// resultData.putString(RESULT_URI, uri); +// +// break; } OtherHelper.logDebugBundle(resultData, "resultData"); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java index a2cd74378..fb727d297 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java @@ -282,12 +282,8 @@ public class EncryptFileFragment extends Fragment { } data.putString(KeychainIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase); } else { - data.putLong(KeychainIntentService.ENCRYPT_SECRET_KEY_ID, mEncryptInterface.getSignatureKey()); + data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_KEY_ID, mEncryptInterface.getSignatureKey()); data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, mEncryptInterface.getEncryptionKeys()); - - boolean signOnly = (mEncryptInterface.getEncryptionKeys() == null - || mEncryptInterface.getEncryptionKeys().length == 0); - data.putBoolean(KeychainIntentService.ENCRYPT_SIGN_ONLY, signOnly); } Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename=" @@ -313,10 +309,6 @@ public class EncryptFileFragment extends Fragment { super.handleMessage(message); if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { - // get returned data bundle - Bundle data = message.getData(); - - String output; AppMsg.makeText(getActivity(), R.string.encryption_successful, AppMsg.STYLE_INFO).show(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java index 6fdf9c034..f2187dac3 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java @@ -182,12 +182,11 @@ public class EncryptMessageFragment extends Fragment { } data.putString(KeychainIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase); } else { - data.putLong(KeychainIntentService.ENCRYPT_SECRET_KEY_ID, mEncryptInterface.getSignatureKey()); + data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_KEY_ID, mEncryptInterface.getSignatureKey()); data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, mEncryptInterface.getEncryptionKeys()); boolean signOnly = (mEncryptInterface.getEncryptionKeys() == null || mEncryptInterface.getEncryptionKeys().length == 0); - data.putBoolean(KeychainIntentService.ENCRYPT_SIGN_ONLY, signOnly); if (signOnly) { message = fixBadCharactersForGmail(message); } @@ -214,18 +213,15 @@ public class EncryptMessageFragment extends Fragment { // get returned data bundle Bundle data = message.getData(); - String output; + String output = new String(data.getByteArray(KeychainIntentService.RESULT_BYTES)); + Log.d(Constants.TAG, "output: " + output); + if (toClipboard) { - output = data.getString(KeychainIntentService.RESULT_ENCRYPTED_STRING); - Log.d(Constants.TAG, "output: " + output); ClipboardReflection.copyToClipboard(getActivity(), output); AppMsg.makeText(getActivity(), R.string.encryption_to_clipboard_successful, AppMsg.STYLE_INFO) .show(); } else { - output = data.getString(KeychainIntentService.RESULT_ENCRYPTED_STRING); - Log.d(Constants.TAG, "output: " + output); - Intent sendIntent = new Intent(Intent.ACTION_SEND); // Type is set to text/plain so that encrypted messages can -- cgit v1.2.3 From ef562b5e202470022b78e3ba72997ebbc90171fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 15:04:54 +0200 Subject: Fix layouts --- .../keychain/ui/EncryptAsymmetricFragment.java | 1 + .../src/main/res/layout/decrypt_file_fragment.xml | 13 ++-- .../main/res/layout/decrypt_message_fragment.xml | 19 ++--- .../res/layout/encrypt_asymmetric_fragment.xml | 13 ++-- .../src/main/res/layout/encrypt_file_fragment.xml | 13 ++-- .../main/res/layout/encrypt_message_fragment.xml | 20 +++--- .../main/res/layout/encrypt_symmetric_fragment.xml | 9 ++- .../src/main/res/layout/import_keys_activity.xml | 1 - .../src/main/res/layout/import_keys_content.xml | 82 ++++++++++------------ .../main/res/layout/view_key_certs_fragment.xml | 6 +- .../src/main/res/layout/view_key_main_fragment.xml | 20 +++--- 11 files changed, 100 insertions(+), 97 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java index 72087f9bd..b38369dcc 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java @@ -26,6 +26,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CheckBox; +import android.widget.LinearLayout; import android.widget.TextView; import com.beardedhen.androidbootstrap.BootstrapButton; diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml index 4515c8092..040a05dc3 100644 --- a/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml @@ -4,8 +4,8 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="4dp" - android:paddingLeft="10dp" - android:paddingRight="10dp" + android:paddingLeft="16dp" + android:paddingRight="16dp" android:orientation="vertical"> @@ -46,13 +46,13 @@ + android:layout_height="match_parent"> @@ -35,15 +35,16 @@ android:id="@+id/decrypt_buttons" android:layout_width="match_parent" android:layout_height="wrap_content" - android:orientation="horizontal" - android:padding="4dp"> + android:orientation="horizontal"> @@ -51,9 +52,11 @@ diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_asymmetric_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_asymmetric_fragment.xml index 95ed5afa4..5041b5fa6 100644 --- a/OpenPGP-Keychain/src/main/res/layout/encrypt_asymmetric_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_asymmetric_fragment.xml @@ -2,11 +2,13 @@ + android:paddingTop="4dp" + android:paddingBottom="4dp" + android:paddingRight="16dp" + android:paddingLeft="16dp"> @@ -52,8 +54,7 @@ + android:orientation="horizontal"> + android:layout_height="match_parent"> + android:orientation="horizontal"> @@ -13,7 +16,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:paddingRight="10dip" + android:paddingRight="8dp" android:text="@string/label_passphrase" android:textAppearance="?android:attr/textAppearanceMedium" /> @@ -31,7 +34,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:paddingRight="10dip" + android:paddingRight="8dp" android:text="@string/label_passphrase_again" android:textAppearance="?android:attr/textAppearanceMedium" /> diff --git a/OpenPGP-Keychain/src/main/res/layout/import_keys_activity.xml b/OpenPGP-Keychain/src/main/res/layout/import_keys_activity.xml index b11f99757..c82607a33 100644 --- a/OpenPGP-Keychain/src/main/res/layout/import_keys_activity.xml +++ b/OpenPGP-Keychain/src/main/res/layout/import_keys_activity.xml @@ -1,6 +1,5 @@ diff --git a/OpenPGP-Keychain/src/main/res/layout/import_keys_content.xml b/OpenPGP-Keychain/src/main/res/layout/import_keys_content.xml index fae8147e5..eb1333704 100644 --- a/OpenPGP-Keychain/src/main/res/layout/import_keys_content.xml +++ b/OpenPGP-Keychain/src/main/res/layout/import_keys_content.xml @@ -1,56 +1,50 @@ - + + android:id="@+id/import_navigation_fragment" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentTop="true" + android:orientation="vertical" + android:paddingLeft="4dp" + android:paddingRight="4dp" /> + android:id="@+id/import_footer" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_alignParentBottom="true" + android:orientation="vertical" + android:paddingLeft="16dp" + android:paddingRight="16dp"> + android:id="@+id/import_import" + android:layout_width="match_parent" + android:layout_height="50dp" + android:layout_marginTop="4dp" + android:layout_marginBottom="4dp" + android:text="@string/import_import" + bootstrapbutton:bb_icon_left="fa-download" + bootstrapbutton:bb_type="info" /> - - - - - - - + android:id="@+id/import_keys_list_container" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_above="@+id/import_footer" + android:layout_alignParentLeft="true" + android:layout_below="@+id/import_navigation_fragment" + android:orientation="vertical" + android:paddingLeft="4dp" + android:paddingRight="4dp" /> \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/view_key_certs_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/view_key_certs_fragment.xml index 299471c66..9c0ecb15d 100644 --- a/OpenPGP-Keychain/src/main/res/layout/view_key_certs_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/view_key_certs_fragment.xml @@ -21,15 +21,15 @@ style="@style/SectionHeader" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginBottom="4dp" android:layout_marginTop="14dp" android:text="@string/section_actions" /> diff --git a/OpenPGP-Keychain/src/main/res/layout/view_key_main_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/view_key_main_fragment.xml index adbdb98dd..6d2bc8874 100644 --- a/OpenPGP-Keychain/src/main/res/layout/view_key_main_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/view_key_main_fragment.xml @@ -226,16 +226,15 @@ style="@style/SectionHeader" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginBottom="4dp" android:layout_marginTop="14dp" android:text="@string/section_actions" /> - -- cgit v1.2.3 From 6e705e5519df52b9cb706de3c0661addbc6309e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 15:19:12 +0200 Subject: Language clarifications --- .../src/main/res/layout/decrypt_message_fragment.xml | 3 ++- .../src/main/res/layout/encrypt_asymmetric_fragment.xml | 2 +- OpenPGP-Keychain/src/main/res/values/strings.xml | 15 ++++++++------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_message_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_message_fragment.xml index 6960532df..dfe1bf64a 100644 --- a/OpenPGP-Keychain/src/main/res/layout/decrypt_message_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_message_fragment.xml @@ -20,6 +20,7 @@ android:layout_width="match_parent" android:layout_height="0dip" android:gravity="top" + android:hint="@string/decrypt_content_edit_text_hint" android:inputType="text|textCapSentences|textMultiLine|textLongMessage" android:scrollHorizontally="true" android:layout_weight="1" /> @@ -58,7 +59,7 @@ android:layout_marginBottom="4dp" android:layout_weight="1" android:text="@string/btn_decrypt_verify_clipboard" - bootstrapbutton:bb_icon_left="fa-unlock" + bootstrapbutton:bb_icon_left="fa-clipboard" bootstrapbutton:bb_type="info" /> diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_asymmetric_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_asymmetric_fragment.xml index 5041b5fa6..fa1b03889 100644 --- a/OpenPGP-Keychain/src/main/res/layout/encrypt_asymmetric_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_asymmetric_fragment.xml @@ -71,7 +71,7 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_margin="4dp" - android:text="@string/btn_select_encrypt_keys" + android:text="@string/select_keys_button_default" bootstrapbutton:bb_icon_left="fa-user" bootstrapbutton:bb_size="default" bootstrapbutton:bb_type="default" /> diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index bb6db01d8..709e9b37d 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -203,15 +203,15 @@ Set a passphrase first. No compatible file manager installed. The passphrases didn\'t match. - Empty passphrases are not allowed. + Please enter a passphrase. Symmetric encryption. Enter passphrase for \'%s\' Are you sure you want to delete\n%s? Successfully deleted. Select a file first. - Successfully decrypted. - Successfully encrypted. - Successfully encrypted to clipboard. + Successfully decrypted and/or verified. + Successfully encrypted and/or signed. + Successfully encrypted and/or signed to clipboard. Enter the passphrase twice. Select at least one encryption key. Select at least one encryption key or a signature key. @@ -470,8 +470,8 @@ Contacts - Encrypt - Decrypt + Sign and Encrypt + Decrypt and Verify Import Keys My Keys Registered Apps @@ -486,6 +486,7 @@ Reapplying certificates - Write message here to encrypt… + Write message here to encrypt and/or sign… + Enter ciphertext here to decrypt and/or verify… -- cgit v1.2.3 From ab8031fb527f767b254cc7a7c61a2ac4d60455f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 15:32:14 +0200 Subject: More layout fixes --- .../src/main/res/layout/encrypt_file_fragment.xml | 128 +++++++++++---------- .../main/res/layout/encrypt_symmetric_fragment.xml | 77 +++++++------ 2 files changed, 108 insertions(+), 97 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_file_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_file_fragment.xml index fe0b28a27..efc4b4641 100644 --- a/OpenPGP-Keychain/src/main/res/layout/encrypt_file_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_file_fragment.xml @@ -1,80 +1,86 @@ - + android:fillViewport="true"> + android:paddingTop="4dp" + android:paddingLeft="16dp" + android:paddingRight="16dp" + android:orientation="vertical"> - + android:orientation="horizontal"> - - + - - - + + - + - + - + - + android:layout_height="match_parent"> - - \ No newline at end of file + + + + + + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_symmetric_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_symmetric_fragment.xml index 0d07e9e72..89381e499 100644 --- a/OpenPGP-Keychain/src/main/res/layout/encrypt_symmetric_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_symmetric_fragment.xml @@ -1,47 +1,52 @@ - + android:paddingRight="16dp" + android:orientation="vertical"> + + - + - + - - + + - + - + - - - \ No newline at end of file + + + + \ No newline at end of file -- cgit v1.2.3 From ba81869038eb3b408ef0f925ebd674bd703211f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 15:33:56 +0200 Subject: More layout fixes --- .../src/main/res/layout/decrypt_file_fragment.xml | 118 +++++++++++---------- 1 file changed, 62 insertions(+), 56 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml index 040a05dc3..633c9c832 100644 --- a/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_file_fragment.xml @@ -1,75 +1,81 @@ - - - + android:fillViewport="true"> + android:paddingTop="4dp" + android:paddingLeft="16dp" + android:paddingRight="16dp" + android:orientation="vertical"> - + - - + android:orientation="horizontal"> - + - + + - + android:text="@string/label_delete_after_decryption" /> - + android:layout_height="match_parent"> + + - - \ No newline at end of file + + + + + \ No newline at end of file -- cgit v1.2.3 From 19e5a3815aab5ab73d365c805f75e6f694d703f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 15:36:27 +0200 Subject: language --- OpenPGP-Keychain/src/main/res/values/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index 709e9b37d..645d7941a 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -210,8 +210,8 @@ Successfully deleted. Select a file first. Successfully decrypted and/or verified. - Successfully encrypted and/or signed. - Successfully encrypted and/or signed to clipboard. + Successfully signed and/or encrypted. + Successfully signed and/or encrypted to clipboard. Enter the passphrase twice. Select at least one encryption key. Select at least one encryption key or a signature key. -- cgit v1.2.3 From fadc08480fdad9bfa672ef4821af4d0c82ef076b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 15:40:07 +0200 Subject: Fix pre-selection for encrypt --- .../sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java index b38369dcc..5b7f9e4cc 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java @@ -26,7 +26,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CheckBox; -import android.widget.LinearLayout; import android.widget.TextView; import com.beardedhen.androidbootstrap.BootstrapButton; @@ -82,12 +81,14 @@ public class EncryptAsymmetricFragment extends Fragment { mSecretKeyId = signatureKeyId; // update key selection in EncryptActivity mKeySelectionListener.onSigningKeySelected(signatureKeyId); + updateView(); } private void setEncryptionKeyIds(long[] encryptionKeyIds) { mEncryptionKeyIds = encryptionKeyIds; // update key selection in EncryptActivity mKeySelectionListener.onEncryptionKeysSelected(encryptionKeyIds); + updateView(); } /** @@ -113,7 +114,6 @@ public class EncryptAsymmetricFragment extends Fragment { selectSecretKey(); } else { setSignatureKeyId(Id.key.none); - updateView(); } } }); @@ -259,7 +259,6 @@ public class EncryptAsymmetricFragment extends Fragment { setEncryptionKeyIds(bundle .getLongArray(SelectPublicKeyActivity.RESULT_EXTRA_MASTER_KEY_IDS)); } - updateView(); break; } @@ -270,7 +269,6 @@ public class EncryptAsymmetricFragment extends Fragment { } else { setSignatureKeyId(Id.key.none); } - updateView(); break; } -- cgit v1.2.3 From ebb7f559216fd2f4d82f824e4fa7ceddbfa7cd1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 16:08:40 +0200 Subject: Fix symmetric decryption --- .../keychain/pgp/PgpDecryptVerify.java | 219 ++++++++++----------- .../keychain/remote/OpenPgpService.java | 5 +- .../keychain/service/KeychainIntentService.java | 4 +- .../keychain/ui/DecryptFileFragment.java | 3 + .../keychain/ui/DecryptMessageFragment.java | 3 + 5 files changed, 117 insertions(+), 117 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java index d06898c89..741c1323a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java @@ -18,16 +18,38 @@ package org.sufficientlysecure.keychain.pgp; import android.content.Context; + import org.openintents.openpgp.OpenPgpSignatureResult; import org.spongycastle.bcpg.ArmoredInputStream; import org.spongycastle.bcpg.SignatureSubpacketTags; -import org.spongycastle.openpgp.*; +import org.spongycastle.openpgp.PGPCompressedData; +import org.spongycastle.openpgp.PGPEncryptedData; +import org.spongycastle.openpgp.PGPEncryptedDataList; +import org.spongycastle.openpgp.PGPException; +import org.spongycastle.openpgp.PGPLiteralData; +import org.spongycastle.openpgp.PGPObjectFactory; +import org.spongycastle.openpgp.PGPOnePassSignature; +import org.spongycastle.openpgp.PGPOnePassSignatureList; +import org.spongycastle.openpgp.PGPPBEEncryptedData; +import org.spongycastle.openpgp.PGPPrivateKey; +import org.spongycastle.openpgp.PGPPublicKey; +import org.spongycastle.openpgp.PGPPublicKeyEncryptedData; +import org.spongycastle.openpgp.PGPPublicKeyRing; +import org.spongycastle.openpgp.PGPSecretKey; +import org.spongycastle.openpgp.PGPSecretKeyRing; +import org.spongycastle.openpgp.PGPSignature; +import org.spongycastle.openpgp.PGPSignatureList; +import org.spongycastle.openpgp.PGPSignatureSubpacketVector; import org.spongycastle.openpgp.PGPUtil; import org.spongycastle.openpgp.operator.PBEDataDecryptorFactory; import org.spongycastle.openpgp.operator.PBESecretKeyDecryptor; import org.spongycastle.openpgp.operator.PGPDigestCalculatorProvider; import org.spongycastle.openpgp.operator.PublicKeyDataDecryptorFactory; -import org.spongycastle.openpgp.operator.jcajce.*; +import org.spongycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProvider; +import org.spongycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBuilder; +import org.spongycastle.openpgp.operator.jcajce.JcePBEDataDecryptorFactoryBuilder; +import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder; +import org.spongycastle.openpgp.operator.jcajce.JcePublicKeyDataDecryptorFactoryBuilder; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; @@ -37,7 +59,12 @@ import org.sufficientlysecure.keychain.util.InputData; import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ProgressDialogUpdater; -import java.io.*; +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.security.SignatureException; import java.util.Iterator; @@ -50,7 +77,7 @@ public class PgpDecryptVerify { private OutputStream mOutStream; private ProgressDialogUpdater mProgressDialogUpdater; - private boolean mAssumeSymmetric; + private boolean mAllowSymmetricDecryption; private String mPassphrase; private long mEnforcedKeyId; @@ -61,7 +88,7 @@ public class PgpDecryptVerify { this.mOutStream = builder.mOutStream; this.mProgressDialogUpdater = builder.mProgressDialogUpdater; - this.mAssumeSymmetric = builder.mAssumeSymmetric; + this.mAllowSymmetricDecryption = builder.mAllowSymmetricDecryption; this.mPassphrase = builder.mPassphrase; this.mEnforcedKeyId = builder.mEnforcedKeyId; } @@ -74,7 +101,7 @@ public class PgpDecryptVerify { // optional private ProgressDialogUpdater mProgressDialogUpdater = null; - private boolean mAssumeSymmetric = false; + private boolean mAllowSymmetricDecryption = false; private String mPassphrase = null; private long mEnforcedKeyId = 0; @@ -89,8 +116,8 @@ public class PgpDecryptVerify { return this; } - public Builder assumeSymmetric(boolean assumeSymmetric) { - this.mAssumeSymmetric = assumeSymmetric; + public Builder allowSymmetricDecryption(boolean allowSymmetricDecryption) { + this.mAllowSymmetricDecryption = allowSymmetricDecryption; return this; } @@ -128,35 +155,6 @@ public class PgpDecryptVerify { } } - public static boolean hasSymmetricEncryption(Context context, InputStream inputStream) - throws PgpGeneralException, IOException { - InputStream in = PGPUtil.getDecoderStream(inputStream); - PGPObjectFactory pgpF = new PGPObjectFactory(in); - PGPEncryptedDataList enc; - Object o = pgpF.nextObject(); - - // the first object might be a PGP marker packet. - if (o instanceof PGPEncryptedDataList) { - enc = (PGPEncryptedDataList) o; - } else { - enc = (PGPEncryptedDataList) pgpF.nextObject(); - } - - if (enc == null) { - throw new PgpGeneralException(context.getString(R.string.error_invalid_data)); - } - - Iterator it = enc.getEncryptedDataObjects(); - while (it.hasNext()) { - Object obj = it.next(); - if (obj instanceof PGPPBEEncryptedData) { - return true; - } - } - - return false; - } - /** * Decrypts and/or verifies data based on parameters of class * @@ -221,25 +219,78 @@ public class PgpDecryptVerify { currentProgress += 5; - // TODO: currently we always only look at the first known key or symmetric encryption, - // there might be more... - if (mAssumeSymmetric) { - PGPPBEEncryptedData pbe = null; - Iterator it = enc.getEncryptedDataObjects(); - // find secret key - while (it.hasNext()) { - Object obj = it.next(); - if (obj instanceof PGPPBEEncryptedData) { - pbe = (PGPPBEEncryptedData) obj; + PGPPublicKeyEncryptedData encryptedDataAsymmetric = null; + PGPPBEEncryptedData encryptedDataSymmetric = null; + PGPSecretKey secretKey = null; + Iterator it = enc.getEncryptedDataObjects(); + boolean symmetricPacketFound = false; + // find secret key + while (it.hasNext()) { + Object obj = it.next(); + if (obj instanceof PGPPublicKeyEncryptedData) { + updateProgress(R.string.progress_finding_key, currentProgress, 100); + + PGPPublicKeyEncryptedData encData = (PGPPublicKeyEncryptedData) obj; + secretKey = ProviderHelper.getPGPSecretKeyByKeyId(mContext, encData.getKeyID()); + if (secretKey != null) { + // secret key exists in database + + // allow only a specific key for decryption? + if (mEnforcedKeyId != 0) { + // TODO: improve this code! get master key directly! + PGPSecretKeyRing secretKeyRing = + ProviderHelper.getPGPSecretKeyRingByKeyId(mContext, encData.getKeyID()); + long masterKeyId = PgpKeyHelper.getMasterKey(secretKeyRing).getKeyID(); + Log.d(Constants.TAG, "encData.getKeyID():" + encData.getKeyID()); + Log.d(Constants.TAG, "enforcedKeyId: " + mEnforcedKeyId); + Log.d(Constants.TAG, "masterKeyId: " + masterKeyId); + + if (mEnforcedKeyId != masterKeyId) { + throw new PgpGeneralException( + mContext.getString(R.string.error_no_secret_key_found)); + } + } + + encryptedDataAsymmetric = encData; + + // if no passphrase was explicitly set try to get it from the cache service + if (mPassphrase == null) { + // returns "" if key has no passphrase + mPassphrase = + PassphraseCacheService.getCachedPassphrase(mContext, encData.getKeyID()); + + // if passphrase was not cached, return here + // indicating that a passphrase is missing! + if (mPassphrase == null) { + returnData.setKeyIdPassphraseNeeded(encData.getKeyID()); + returnData.setStatus(PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED); + return returnData; + } + } + + // break out of while, only get first object here + // TODO???: There could be more pgp objects, which are not decrypted! break; } - } + } else if (mAllowSymmetricDecryption && obj instanceof PGPPBEEncryptedData) { + symmetricPacketFound = true; - if (pbe == null) { - throw new PgpGeneralException( - mContext.getString(R.string.error_no_symmetric_encryption_packet)); + encryptedDataSymmetric = (PGPPBEEncryptedData) obj; + + // if no passphrase is given, return here + // indicating that a passphrase is missing! + if (mPassphrase == null) { + returnData.setStatus(PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED); + return returnData; + } + + // break out of while, only get first object here + // TODO???: There could be more pgp objects, which are not decrypted! + break; } + } + if (symmetricPacketFound) { updateProgress(R.string.progress_preparing_streams, currentProgress, 100); PGPDigestCalculatorProvider digestCalcProvider = new JcaPGPDigestCalculatorProviderBuilder() @@ -248,65 +299,11 @@ public class PgpDecryptVerify { digestCalcProvider).setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( mPassphrase.toCharArray()); - clear = pbe.getDataStream(decryptorFactory); + clear = encryptedDataSymmetric.getDataStream(decryptorFactory); - encryptedData = pbe; + encryptedData = encryptedDataSymmetric; currentProgress += 5; } else { - PGPPublicKeyEncryptedData pbe = null; - PGPSecretKey secretKey = null; - Iterator it = enc.getEncryptedDataObjects(); - // find secret key - while (it.hasNext()) { - Object obj = it.next(); - if (obj instanceof PGPPublicKeyEncryptedData) { - updateProgress(R.string.progress_finding_key, currentProgress, 100); - - PGPPublicKeyEncryptedData encData = (PGPPublicKeyEncryptedData) obj; - secretKey = ProviderHelper.getPGPSecretKeyByKeyId(mContext, encData.getKeyID()); - if (secretKey != null) { - // secret key exists in database - - // allow only a specific key for decryption? - if (mEnforcedKeyId != 0) { - // TODO: improve this code! get master key directly! - PGPSecretKeyRing secretKeyRing = - ProviderHelper.getPGPSecretKeyRingByKeyId(mContext, encData.getKeyID()); - long masterKeyId = PgpKeyHelper.getMasterKey(secretKeyRing).getKeyID(); - Log.d(Constants.TAG, "encData.getKeyID():" + encData.getKeyID()); - Log.d(Constants.TAG, "enforcedKeyId: " + mEnforcedKeyId); - Log.d(Constants.TAG, "masterKeyId: " + masterKeyId); - - if (mEnforcedKeyId != masterKeyId) { - throw new PgpGeneralException( - mContext.getString(R.string.error_no_secret_key_found)); - } - } - - pbe = encData; - - // if no passphrase was explicitly set try to get it from the cache service - if (mPassphrase == null) { - // returns "" if key has no passphrase - mPassphrase = - PassphraseCacheService.getCachedPassphrase(mContext, encData.getKeyID()); - - // if passphrase was not cached, return here - // indicating that a passphrase is missing! - if (mPassphrase == null) { - returnData.setKeyIdPassphraseNeeded(encData.getKeyID()); - returnData.setStatus(PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED); - return returnData; - } - } - - break; - } - } else if (obj instanceof PGPPBEEncryptedData) { - - } - } - if (secretKey == null) { throw new PgpGeneralException(mContext.getString(R.string.error_no_secret_key_found)); } @@ -332,9 +329,9 @@ public class PgpDecryptVerify { PublicKeyDataDecryptorFactory decryptorFactory = new JcePublicKeyDataDecryptorFactoryBuilder() .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(privateKey); - clear = pbe.getDataStream(decryptorFactory); + clear = encryptedDataAsymmetric.getDataStream(decryptorFactory); - encryptedData = pbe; + encryptedData = encryptedDataAsymmetric; currentProgress += 5; } @@ -389,7 +386,7 @@ public class PgpDecryptVerify { if (signature != null) { JcaPGPContentVerifierBuilderProvider contentVerifierBuilderProvider = new JcaPGPContentVerifierBuilderProvider() - .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME); + .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME); signature.init(contentVerifierBuilderProvider, signatureKey); } else { @@ -686,7 +683,7 @@ public class PgpDecryptVerify { } private static boolean verifyPrimaryKeyBinding(PGPSignatureSubpacketVector pkts, - PGPPublicKey masterPublicKey, PGPPublicKey signingPublicKey) { + PGPPublicKey masterPublicKey, PGPPublicKey signingPublicKey) { boolean validPrimaryKeyBinding = false; JcaPGPContentVerifierBuilderProvider contentVerifierBuilderProvider = new JcaPGPContentVerifierBuilderProvider() diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java index 1d3bb88df..1cd5862e7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -290,9 +290,8 @@ public class OpenPgpService extends RemoteService { InputData inputData = new InputData(is, inputLength); PgpDecryptVerify.Builder builder = new PgpDecryptVerify.Builder(this, inputData, os); - builder.assumeSymmetric(false) // no support for symmetric encryption - // allow only the private key for this app for decryption - .enforcedKeyId(accSettings.getKeyId()) + builder.allowSymmetricDecryption(false) // no support for symmetric encryption + .enforcedKeyId(accSettings.getKeyId()) // allow only the private key for this app for decryption .passphrase(passphrase); // TODO: currently does not support binary signed-only content diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 2ad7e348b..2060c6f61 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -98,7 +98,6 @@ public class KeychainIntentService extends IntentService // decrypt/verify public static final String DECRYPT_CIPHERTEXT_BYTES = "ciphertext_bytes"; - public static final String DECRYPT_ASSUME_SYMMETRIC = "assume_symmetric"; public static final String DECRYPT_PASSPHRASE = "passphrase"; // save keyring @@ -344,7 +343,6 @@ public class KeychainIntentService extends IntentService int target = data.getInt(TARGET); byte[] bytes = data.getByteArray(DECRYPT_CIPHERTEXT_BYTES); - boolean assumeSymmetricEncryption = data.getBoolean(DECRYPT_ASSUME_SYMMETRIC); String passphrase = data.getString(DECRYPT_PASSPHRASE); InputStream inStream; @@ -424,7 +422,7 @@ public class KeychainIntentService extends IntentService PgpDecryptVerify.Builder builder = new PgpDecryptVerify.Builder(this, inputData, outStream); builder.progressDialogUpdater(this); - builder.assumeSymmetric(assumeSymmetricEncryption) + builder.allowSymmetricDecryption(true) .passphrase(passphrase); PgpDecryptVerifyResult decryptVerifyResult = builder.build().execute(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java index a929047b8..cec6d7a59 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java @@ -35,6 +35,7 @@ import com.devspark.appmsg.AppMsg; import org.openintents.openpgp.OpenPgpSignatureResult; import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.FileHelper; import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult; @@ -202,6 +203,8 @@ public class DecryptFileFragment extends DecryptFragment { if (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) { showPassphraseDialog(decryptVerifyResult.getKeyIdPassphraseNeeded()); + } else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) { + showPassphraseDialog(Id.key.symmetric); } else { if (mDeleteAfter.isChecked()) { // Create and show dialog to delete original file diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java index 94034b356..197a2af04 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java @@ -33,6 +33,7 @@ import com.devspark.appmsg.AppMsg; import org.openintents.openpgp.OpenPgpSignatureResult; import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.ClipboardReflection; import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult; @@ -149,6 +150,8 @@ public class DecryptMessageFragment extends DecryptFragment { if (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) { showPassphraseDialog(decryptVerifyResult.getKeyIdPassphraseNeeded()); + } else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) { + showPassphraseDialog(Id.key.symmetric); } else { AppMsg.makeText(getActivity(), R.string.decryption_successful, AppMsg.STYLE_INFO).show(); -- cgit v1.2.3 From 6f36b72eee8ed2a0baa768e696bbb6e9632ed795 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 22 Mar 2014 13:04:31 +0100 Subject: PgpKeyOperation: factor out all android dependencies Conflicts: OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java --- .../keychain/pgp/PgpKeyOperation.java | 216 +++++++++++---------- .../pgp/exception/PgpGeneralException.java | 3 + .../pgp/exception/PgpGeneralMsgIdException.java | 35 ++++ .../keychain/service/KeychainIntentService.java | 47 ++++- .../keychain/util/ProgressScaler.java | 50 +++++ 5 files changed, 235 insertions(+), 116 deletions(-) create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/exception/PgpGeneralMsgIdException.java create mode 100644 OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/ProgressScaler.java diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 592bdec73..520189448 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -17,20 +17,6 @@ package org.sufficientlysecure.keychain.pgp; -import java.io.IOException; -import java.math.BigInteger; -import java.security.InvalidAlgorithmParameterException; -import java.security.KeyPairGenerator; -import java.security.NoSuchAlgorithmException; -import java.security.NoSuchProviderException; -import java.security.SecureRandom; -import java.security.SignatureException; -import java.util.ArrayList; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.Iterator; -import java.util.TimeZone; -import android.content.Context; import org.spongycastle.bcpg.CompressionAlgorithmTags; import org.spongycastle.bcpg.HashAlgorithmTags; import org.spongycastle.bcpg.SymmetricKeyAlgorithmTags; @@ -46,18 +32,11 @@ import org.spongycastle.openpgp.operator.jcajce.*; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; -import org.sufficientlysecure.keychain.provider.ProviderHelper; +import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralMsgIdException; import org.sufficientlysecure.keychain.service.SaveKeyringParcel; import org.sufficientlysecure.keychain.util.Primes; import org.sufficientlysecure.keychain.util.ProgressDialogUpdater; - -import android.content.Context; -import android.util.Pair; import org.sufficientlysecure.keychain.util.IterableIterator; -import org.sufficientlysecure.keychain.util.Log; -import org.sufficientlysecure.keychain.util.Primes; -import org.sufficientlysecure.keychain.util.ProgressDialogUpdater; import java.io.IOException; import java.math.BigInteger; @@ -69,9 +48,17 @@ import java.util.Iterator; import java.util.List; import java.util.TimeZone; +/** This class is the single place where ALL operations that actually modify a PGP public or secret + * key take place. + * + * Note that no android specific stuff should be done here, ie no imports from com.android. + * + * All operations support progress reporting to a ProgressDialogUpdater passed on initialization. + * This indicator may be null. + * + */ public class PgpKeyOperation { - private final Context mContext; - private final ProgressDialogUpdater mProgress; + private ProgressDialogUpdater mProgress; private static final int[] PREFERRED_SYMMETRIC_ALGORITHMS = new int[]{ SymmetricKeyAlgorithmTags.AES_256, SymmetricKeyAlgorithmTags.AES_192, @@ -83,9 +70,8 @@ public class PgpKeyOperation { CompressionAlgorithmTags.ZLIB, CompressionAlgorithmTags.BZIP2, CompressionAlgorithmTags.ZIP}; - public PgpKeyOperation(Context context, ProgressDialogUpdater progress) { + public PgpKeyOperation(ProgressDialogUpdater progress) { super(); - this.mContext = context; this.mProgress = progress; } @@ -101,13 +87,29 @@ public class PgpKeyOperation { } } + /** + * Creates new secret key. + * + * @param algorithmChoice + * @param keySize + * @param passphrase + * @param isMasterKey + * @return A newly created PGPSecretKey + * @throws NoSuchAlgorithmException + * @throws PGPException + * @throws NoSuchProviderException + * @throws PgpGeneralMsgIdException + * @throws InvalidAlgorithmParameterException + */ + + // TODO: key flags? public PGPSecretKey createKey(int algorithmChoice, int keySize, String passphrase, boolean isMasterKey) throws NoSuchAlgorithmException, PGPException, NoSuchProviderException, - PgpGeneralException, InvalidAlgorithmParameterException { + PgpGeneralMsgIdException, InvalidAlgorithmParameterException { if (keySize < 512) { - throw new PgpGeneralException(mContext.getString(R.string.error_key_size_minimum512bit)); + throw new PgpGeneralMsgIdException(R.string.error_key_size_minimum512bit); } if (passphrase == null) { @@ -127,8 +129,7 @@ public class PgpKeyOperation { case Id.choice.algorithm.elgamal: { if (isMasterKey) { - throw new PgpGeneralException( - mContext.getString(R.string.error_master_key_must_not_be_el_gamal)); + throw new PgpGeneralMsgIdException(R.string.error_master_key_must_not_be_el_gamal); } keyGen = KeyPairGenerator.getInstance("ElGamal", Constants.BOUNCY_CASTLE_PROVIDER_NAME); BigInteger p = Primes.getBestPrime(keySize); @@ -150,8 +151,7 @@ public class PgpKeyOperation { } default: { - throw new PgpGeneralException( - mContext.getString(R.string.error_unknown_algorithm_choice)); + throw new PgpGeneralMsgIdException(R.string.error_unknown_algorithm_choice); } } @@ -171,8 +171,9 @@ public class PgpKeyOperation { sha1Calc, isMasterKey, keyEncryptor); } - public void changeSecretKeyPassphrase(PGPSecretKeyRing keyRing, String oldPassPhrase, - String newPassPhrase) throws IOException, PGPException { + public PGPSecretKeyRing changeSecretKeyPassphrase(PGPSecretKeyRing keyRing, String oldPassPhrase, + String newPassPhrase) throws IOException, PGPException, + NoSuchProviderException { updateProgress(R.string.progress_building_key, 0, 100); if (oldPassPhrase == null) { @@ -190,16 +191,16 @@ public class PgpKeyOperation { new JcePBESecretKeyEncryptorBuilder(keyRing.getSecretKey() .getKeyEncryptionAlgorithm()).build(newPassPhrase.toCharArray())); - updateProgress(R.string.progress_saving_key_ring, 50, 100); - - ProviderHelper.saveKeyRing(mContext, newKeyRing); - - updateProgress(R.string.progress_done, 100, 100); + return newKeyRing; } - private void buildNewSecretKey(ArrayList userIds, ArrayList keys, ArrayList keysExpiryDates, ArrayList keysUsages, String newPassPhrase, String oldPassPhrase) throws PgpGeneralException, - PGPException, SignatureException, IOException { + private Pair buildNewSecretKey( + ArrayList userIds, ArrayList keys, + ArrayList keysExpiryDates, + ArrayList keysUsages, + String newPassPhrase, String oldPassPhrase) + throws PgpGeneralMsgIdException, PGPException, SignatureException, IOException { int usageId = keysUsages.get(0); boolean canSign; @@ -210,8 +211,6 @@ public class PgpKeyOperation { // this removes all userIds and certifications previously attached to the masterPublicKey PGPPublicKey masterPublicKey = masterKey.getPublicKey(); - PGPSecretKeyRing mKR = ProviderHelper.getPGPSecretKeyRingByKeyId(mContext, masterKey.getKeyID()); - PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider( Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassPhrase.toCharArray()); PGPPrivateKey masterPrivateKey = masterKey.extractPrivateKey(keyDecryptor); @@ -249,7 +248,7 @@ public class PgpKeyOperation { //here we purposefully ignore partial days in each date - long type has no fractional part! long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000); if (numDays <= 0) - throw new PgpGeneralException(mContext.getString(R.string.error_expiry_must_come_after_creation)); + throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation); hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400); } else { hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding, @@ -319,9 +318,11 @@ public class PgpKeyOperation { GregorianCalendar expiryDate = keysExpiryDates.get(i); //note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c //here we purposefully ignore partial days in each date - long type has no fractional part! - long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000); - if (numDays <= 0) - throw new PgpGeneralException(mContext.getString(R.string.error_expiry_must_come_after_creation)); + long numDays = + (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000); + if (numDays <= 0) { + throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation); + } hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400); } else { hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding, @@ -334,23 +335,18 @@ public class PgpKeyOperation { PGPSecretKeyRing secretKeyRing = keyGen.generateSecretKeyRing(); PGPPublicKeyRing publicKeyRing = keyGen.generatePublicKeyRing(); - updateProgress(R.string.progress_saving_key_ring, 90, 100); - - ProviderHelper.saveKeyRing(mContext, secretKeyRing); - ProviderHelper.saveKeyRing(mContext, publicKeyRing); + return new Pair(secretKeyRing, publicKeyRing); - updateProgress(R.string.progress_done, 100, 100); } - public void buildSecretKey (SaveKeyringParcel saveParcel)throws PgpGeneralException, - PGPException, SignatureException, IOException { + public Pair buildSecretKey (PGPSecretKeyRing mKR, + PGPPublicKeyRing pKR, + SaveKeyringParcel saveParcel) + throws PgpGeneralMsgIdException, PGPException, SignatureException, IOException { updateProgress(R.string.progress_building_key, 0, 100); PGPSecretKey masterKey = saveParcel.keys.get(0); - PGPSecretKeyRing mKR = ProviderHelper.getPGPSecretKeyRingByKeyId(mContext, masterKey.getKeyID()); - PGPPublicKeyRing pKR = ProviderHelper.getPGPPublicKeyRingByKeyId(mContext, masterKey.getKeyID()); - if (saveParcel.oldPassPhrase == null) { saveParcel.oldPassPhrase = ""; } @@ -359,9 +355,8 @@ public class PgpKeyOperation { } if (mKR == null) { - buildNewSecretKey(saveParcel.userIDs, saveParcel.keys, saveParcel.keysExpiryDates, + return buildNewSecretKey(saveParcel.userIDs, saveParcel.keys, saveParcel.keysExpiryDates, saveParcel.keysUsages, saveParcel.newPassPhrase, saveParcel.oldPassPhrase); //new Keyring - return; } /* @@ -430,7 +425,7 @@ public class PgpKeyOperation { //here we purposefully ignore partial days in each date - long type has no fractional part! long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000); if (numDays <= 0) - throw new PgpGeneralException(mContext.getString(R.string.error_expiry_must_come_after_creation)); + throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation); hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400); } else { hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding, @@ -592,7 +587,7 @@ public class PgpKeyOperation { //here we purposefully ignore partial days in each date - long type has no fractional part! long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000); if (numDays <= 0) - throw new PgpGeneralException(mContext.getString(R.string.error_expiry_must_come_after_creation)); + throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation); hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400); } else { hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding, @@ -637,7 +632,6 @@ public class PgpKeyOperation { //update the passphrase mKR = PGPSecretKeyRing.copyWithNewPassword(mKR, keyDecryptor, keyEncryptorNew); - updateProgress(R.string.progress_saving_key_ring, 90, 100); /* additional handy debug info @@ -660,62 +654,72 @@ public class PgpKeyOperation { */ + return new Pair(mKR, pKR); - ProviderHelper.saveKeyRing(mContext, mKR); - ProviderHelper.saveKeyRing(mContext, pKR); - - updateProgress(R.string.progress_done, 100, 100); } - public PGPPublicKeyRing certifyKey(long masterKeyId, long pubKeyId, List userIds, String passphrase) - throws PgpGeneralException, NoSuchAlgorithmException, NoSuchProviderException, + /** + * Certify the given pubkeyid with the given masterkeyid. + * + * @param certificationKey Certifying key + * @param publicKey public key to certify + * @param userIds User IDs to certify, must not be null or empty + * @param passphrase Passphrase of the secret key + * @return A keyring with added certifications + */ + public PGPPublicKey certifyKey(PGPSecretKey certificationKey, PGPPublicKey publicKey, List userIds, String passphrase) + throws PgpGeneralMsgIdException, NoSuchAlgorithmException, NoSuchProviderException, PGPException, SignatureException { - if (passphrase == null) { - throw new PgpGeneralException("Unable to obtain passphrase"); - } else { - // create a signatureGenerator from the supplied masterKeyId and passphrase - PGPSignatureGenerator signatureGenerator; { + // create a signatureGenerator from the supplied masterKeyId and passphrase + PGPSignatureGenerator signatureGenerator; { - PGPSecretKey certificationKey = PgpKeyHelper.getCertificationKey(mContext, masterKeyId); - if (certificationKey == null) { - throw new PgpGeneralException(mContext.getString(R.string.error_signature_failed)); - } + if (certificationKey == null) { + throw new PgpGeneralMsgIdException(R.string.error_signature_failed); + } - PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider( - Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(passphrase.toCharArray()); - PGPPrivateKey signaturePrivateKey = certificationKey.extractPrivateKey(keyDecryptor); - if (signaturePrivateKey == null) { - throw new PgpGeneralException( - mContext.getString(R.string.error_could_not_extract_private_key)); - } + PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider( + Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(passphrase.toCharArray()); + PGPPrivateKey signaturePrivateKey = certificationKey.extractPrivateKey(keyDecryptor); + if (signaturePrivateKey == null) { + throw new PgpGeneralMsgIdException(R.string.error_could_not_extract_private_key); + } - // TODO: SHA256 fixed? - JcaPGPContentSignerBuilder contentSignerBuilder = new JcaPGPContentSignerBuilder( - certificationKey.getPublicKey().getAlgorithm(), PGPUtil.SHA256) - .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME); + // TODO: SHA256 fixed? + JcaPGPContentSignerBuilder contentSignerBuilder = new JcaPGPContentSignerBuilder( + certificationKey.getPublicKey().getAlgorithm(), PGPUtil.SHA256) + .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME); - signatureGenerator = new PGPSignatureGenerator(contentSignerBuilder); - signatureGenerator.init(PGPSignature.DEFAULT_CERTIFICATION, signaturePrivateKey); - } + signatureGenerator = new PGPSignatureGenerator(contentSignerBuilder); + signatureGenerator.init(PGPSignature.DEFAULT_CERTIFICATION, signaturePrivateKey); + } - { // supply signatureGenerator with a SubpacketVector - PGPSignatureSubpacketGenerator spGen = new PGPSignatureSubpacketGenerator(); - PGPSignatureSubpacketVector packetVector = spGen.generate(); - signatureGenerator.setHashedSubpackets(packetVector); - } + { // supply signatureGenerator with a SubpacketVector + PGPSignatureSubpacketGenerator spGen = new PGPSignatureSubpacketGenerator(); + PGPSignatureSubpacketVector packetVector = spGen.generate(); + signatureGenerator.setHashedSubpackets(packetVector); + } - // fetch public key ring, add the certification and return it - PGPPublicKeyRing pubring = ProviderHelper - .getPGPPublicKeyRingByKeyId(mContext, pubKeyId); - PGPPublicKey signedKey = pubring.getPublicKey(pubKeyId); - for(String userId : new IterableIterator(userIds.iterator())) { - PGPSignature sig = signatureGenerator.generateCertification(userId, signedKey); - signedKey = PGPPublicKey.addCertification(signedKey, userId, sig); - } - pubring = PGPPublicKeyRing.insertPublicKey(pubring, signedKey); + // fetch public key ring, add the certification and return it + for(String userId : new IterableIterator(userIds.iterator())) { + PGPSignature sig = signatureGenerator.generateCertification(userId, publicKey); + publicKey = PGPPublicKey.addCertification(publicKey, userId, sig); + } + + return publicKey; + } - return pubring; + /** Simple static subclass that stores two values. + * + * This is only used to return a pair of values in one function above. We specifically don't use + * com.android.Pair to keep this class free from android dependencies. + */ + public static class Pair { + public final K first; + public final V second; + public Pair(K first, V second) { + this.first = first; + this.second = second; } } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/exception/PgpGeneralException.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/exception/PgpGeneralException.java index bb80d27ee..418445367 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/exception/PgpGeneralException.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/exception/PgpGeneralException.java @@ -23,4 +23,7 @@ public class PgpGeneralException extends Exception { public PgpGeneralException(String message) { super(message); } + public PgpGeneralException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/exception/PgpGeneralMsgIdException.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/exception/PgpGeneralMsgIdException.java new file mode 100644 index 000000000..3df85cfc8 --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/exception/PgpGeneralMsgIdException.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2012-2013 Dominik Schürmann + * Copyright (C) 2010 Thialfihar + * + * 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.sufficientlysecure.keychain.pgp.exception; + +import android.content.Context; + +public class PgpGeneralMsgIdException extends Exception { + static final long serialVersionUID = 0xf812773343L; + + private final int msgId; + + public PgpGeneralMsgIdException(int msgId) { + super("msg[" + msgId + "]"); + this.msgId = msgId; + } + + public PgpGeneralException getContextualized(Context context) { + return new PgpGeneralException(context.getString(msgId), this); + } +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 2060c6f61..f82e5e619 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -35,6 +35,8 @@ import org.sufficientlysecure.keychain.helper.OtherHelper; import org.sufficientlysecure.keychain.helper.Preferences; import org.sufficientlysecure.keychain.pgp.*; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; +import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralMsgIdException; +import org.sufficientlysecure.keychain.provider.KeychainContract.DataStream; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; import org.sufficientlysecure.keychain.util.*; @@ -473,14 +475,26 @@ public class KeychainIntentService extends IntentService long masterKeyId = saveParams.keys.get(0).getKeyID(); - PgpKeyOperation keyOperations = new PgpKeyOperation(this, this); /* Operation */ if (!canSign) { - keyOperations.changeSecretKeyPassphrase( - ProviderHelper.getPGPSecretKeyRingByKeyId(this, masterKeyId), + PgpKeyOperation keyOperations = new PgpKeyOperation(new ProgressScaler(this, 0, 50, 100)); + PGPSecretKeyRing keyRing = ProviderHelper + .getPGPSecretKeyRingByKeyId(this, masterKeyId); + keyRing = keyOperations.changeSecretKeyPassphrase(keyRing, oldPassPhrase, newPassPhrase); + setProgress(R.string.progress_saving_key_ring, 50, 100); + ProviderHelper.saveKeyRing(this, keyRing); + setProgress(R.string.progress_done, 100, 100); } else { - keyOperations.buildSecretKey(saveParams); + PgpKeyOperation keyOperations = new PgpKeyOperation(new ProgressScaler(this, 0, 90, 100)); + PGPSecretKeyRing privkey = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(this, masterKeyId); + PGPPublicKeyRing pubkey = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(this, masterKeyId); + PgpKeyOperation.Pair pair = + keyOperations.buildSecretKey(privkey, pubkey, saveParams); + setProgress(R.string.progress_saving_key_ring, 90, 100); + ProviderHelper.saveKeyRing(this, pair.first); + ProviderHelper.saveKeyRing(this, pair.second); + setProgress(R.string.progress_done, 100, 100); } PassphraseCacheService.addCachedPassphrase(this, masterKeyId, newPassPhrase); @@ -498,7 +512,7 @@ public class KeychainIntentService extends IntentService boolean masterKey = data.getBoolean(GENERATE_KEY_MASTER_KEY); /* Operation */ - PgpKeyOperation keyOperations = new PgpKeyOperation(this, this); + PgpKeyOperation keyOperations = new PgpKeyOperation(new ProgressScaler(this, 0, 100, 100)); PGPSecretKey newKey = keyOperations.createKey(algorithm, keysize, passphrase, masterKey); @@ -529,7 +543,7 @@ public class KeychainIntentService extends IntentService getQuantityString(R.plurals.progress_generating, keysTotal), keysCreated, keysTotal); - PgpKeyOperation keyOperations = new PgpKeyOperation(this, this); + PgpKeyOperation keyOperations = new PgpKeyOperation(new ProgressScaler(this, 0, 100, 100)); PGPSecretKey masterKey = keyOperations.createKey(Id.choice.algorithm.rsa, 4096, passphrase, true); @@ -771,14 +785,23 @@ public class KeychainIntentService extends IntentService /* Operation */ String signaturePassPhrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId); + if (signaturePassPhrase == null) { + throw new PgpGeneralException("Unable to obtain passphrase"); + } - PgpKeyOperation keyOperation = new PgpKeyOperation(this, this); - PGPPublicKeyRing signedPubKeyRing = keyOperation.certifyKey(masterKeyId, pubKeyId, + PgpKeyOperation keyOperation = new PgpKeyOperation(new ProgressScaler(this, 0, 100, 100)); + PGPPublicKeyRing publicRing = ProviderHelper + .getPGPPublicKeyRingByKeyId(this, pubKeyId); + PGPPublicKey publicKey = publicRing.getPublicKey(pubKeyId); + PGPSecretKey certificationKey = PgpKeyHelper.getCertificationKey(this, + masterKeyId); + publicKey = keyOperation.certifyKey(certificationKey, publicKey, userIds, signaturePassPhrase); + publicRing = PGPPublicKeyRing.insertPublicKey(publicRing, publicKey); // store the signed key in our local cache PgpImportExport pgpImportExport = new PgpImportExport(this, null); - int retval = pgpImportExport.storeKeyRingInCache(signedPubKeyRing); + int retval = pgpImportExport.storeKeyRingInCache(publicRing); if (retval != Id.return_value.ok && retval != Id.return_value.updated) { throw new PgpGeneralException("Failed to store signed key in local cache"); } @@ -795,7 +818,11 @@ public class KeychainIntentService extends IntentService if (this.mIsCanceled) { return; } - Log.e(Constants.TAG, "KeychainIntentService Exception: ", e); + // contextualize the exception, if necessary + if(e instanceof PgpGeneralMsgIdException) { + e = ((PgpGeneralMsgIdException) e).getContextualized(this); + } + Log.e(Constants.TAG, "ApgService Exception: ", e); e.printStackTrace(); Bundle data = new Bundle(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/ProgressScaler.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/ProgressScaler.java new file mode 100644 index 000000000..15b70e22e --- /dev/null +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/ProgressScaler.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2012-2014 Dominik Schürmann + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package org.sufficientlysecure.keychain.util; + +/** This is a simple class that wraps a ProgressDialogUpdater, scaling the progress + * values into a specified range. + */ +public class ProgressScaler implements ProgressDialogUpdater { + + final ProgressDialogUpdater mWrapped; + final int mFrom, mTo, mMax; + + public ProgressScaler(ProgressDialogUpdater wrapped, int from, int to, int max) { + this.mWrapped = wrapped; + this.mFrom = from; + this.mTo = to; + this.mMax = max; + } + + /** + * Set progressDialogUpdater of ProgressDialog by sending message to handler on UI thread + */ + public void setProgress(String message, int progress, int max) { + mWrapped.setProgress(message, mFrom+ progress*(mTo-mFrom)/max, mMax); + } + + public void setProgress(int resourceId, int progress, int max) { + mWrapped.setProgress(resourceId, progress, mMax); + } + + public void setProgress(int progress, int max) { + mWrapped.setProgress(progress, max); + } + +} -- cgit v1.2.3 From 62388e3fdbe4ade7628ed938c4f91a4f39654c4e Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 22 Mar 2014 14:57:08 +0100 Subject: test: add junit+robolectric to buildfiles and stub test file --- OpenPGP-Keychain/build.gradle | 42 ++++++++++++++++++++ .../src/main/res/layout/key_server_preference.xml | 2 +- .../keychain/PgpKeyOperationTest.java | 46 ++++++++++++++++++++++ .../keychain/RobolectricGradleTestRunner.java | 23 +++++++++++ 4 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 OpenPGP-Keychain/src/test/java/org/sufficientlysecure/keychain/PgpKeyOperationTest.java create mode 100644 OpenPGP-Keychain/src/test/java/org/sufficientlysecure/keychain/RobolectricGradleTestRunner.java diff --git a/OpenPGP-Keychain/build.gradle b/OpenPGP-Keychain/build.gradle index 04ee46715..7fd1fecce 100644 --- a/OpenPGP-Keychain/build.gradle +++ b/OpenPGP-Keychain/build.gradle @@ -1,5 +1,12 @@ apply plugin: 'android' +sourceSets { + testLocal { + java.srcDir file('src/test/java') + resources.srcDir file('src/test/resources') + } +} + dependencies { compile 'com.android.support:support-v4:19.0.1' compile 'com.android.support:appcompat-v7:19.0.1' @@ -15,6 +22,25 @@ dependencies { compile project(':libraries:spongycastle:pkix') compile project(':libraries:spongycastle:prov') compile project(':libraries:Android-AppMsg:library') + + // Dependencies for the `testLocal` task, make sure to list all your global dependencies here as well + testLocalCompile 'junit:junit:4.11' + testLocalCompile 'org.robolectric:robolectric:2.1.+' + testLocalCompile 'com.google.android:android:4.1.1.4' + testLocalCompile 'com.android.support:support-v4:19.0.1' + testLocalCompile 'com.android.support:appcompat-v7:19.0.1' + testLocalCompile project(':OpenPGP-Keychain-API:libraries:openpgp-api-library') + testLocalCompile project(':OpenPGP-Keychain-API:libraries:openkeychain-api-library') + testLocalCompile project(':libraries:HtmlTextView') + testLocalCompile project(':libraries:StickyListHeaders:library') + testLocalCompile project(':libraries:AndroidBootstrap') + testLocalCompile project(':libraries:zxing') + testLocalCompile project(':libraries:zxing-android-integration') + testLocalCompile project(':libraries:spongycastle:core') + testLocalCompile project(':libraries:spongycastle:pg') + testLocalCompile project(':libraries:spongycastle:pkix') + testLocalCompile project(':libraries:spongycastle:prov') + testLocalCompile project(':libraries:Android-AppMsg:library') } android { @@ -61,3 +87,19 @@ android { htmlOutput file("lint-report.html") } } + +task localTest(type: Test, dependsOn: assemble) { + testClassesDir = sourceSets.testLocal.output.classesDir + + android.sourceSets.main.java.srcDirs.each { dir -> + def buildDir = dir.getAbsolutePath().split('/') + buildDir = (buildDir[0..(buildDir.length - 4)] + ['build', 'classes', 'debug']).join('/') + + sourceSets.testLocal.compileClasspath += files(buildDir) + sourceSets.testLocal.runtimeClasspath += files(buildDir) + } + + classpath = sourceSets.testLocal.runtimeClasspath +} + +check.dependsOn localTest diff --git a/OpenPGP-Keychain/src/main/res/layout/key_server_preference.xml b/OpenPGP-Keychain/src/main/res/layout/key_server_preference.xml index eddbe3cbf..b8897a7b3 100644 --- a/OpenPGP-Keychain/src/main/res/layout/key_server_preference.xml +++ b/OpenPGP-Keychain/src/main/res/layout/key_server_preference.xml @@ -6,7 +6,7 @@ android:orientation="vertical" > testClass) throws InitializationError { + super(testClass); + } + + @Override protected AndroidManifest getAppManifest(Config config) { + String myAppPath = KeychainApplication.class.getProtectionDomain().getCodeSource().getLocation().getPath(); + String manifestPath = myAppPath + "../../../src/main/AndroidManifest.xml"; + return createAppManifest(Fs.fileFromPath(manifestPath)); + } +} + -- cgit v1.2.3 From 7000ab37fda358b93ec89dd77b5b2b42c5ec6420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 16:15:50 +0200 Subject: default to allow symmetric decryption --- .../main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java index 741c1323a..29255fbbe 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java @@ -101,7 +101,7 @@ public class PgpDecryptVerify { // optional private ProgressDialogUpdater mProgressDialogUpdater = null; - private boolean mAllowSymmetricDecryption = false; + private boolean mAllowSymmetricDecryption = true; private String mPassphrase = null; private long mEnforcedKeyId = 0; -- cgit v1.2.3 From acc2e208cf0ac4ecd5daaddfe844b37fa8057432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 16:18:16 +0200 Subject: Remove DECRYPT_ASSUME_SYMMETRIC --- .../java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java | 3 --- .../org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java | 3 --- 2 files changed, 6 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java index cec6d7a59..8a89ad240 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java @@ -182,9 +182,6 @@ public class DecryptFileFragment extends DecryptFragment { data.putString(KeychainIntentService.DECRYPT_PASSPHRASE, passphrase); - // TODO - data.putBoolean(KeychainIntentService.DECRYPT_ASSUME_SYMMETRIC, false); - intent.putExtra(KeychainIntentService.EXTRA_DATA, data); // Message is received after encrypting is done in KeychainIntentService diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java index 197a2af04..d7a22038d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java @@ -129,9 +129,6 @@ public class DecryptMessageFragment extends DecryptFragment { data.putByteArray(KeychainIntentService.DECRYPT_CIPHERTEXT_BYTES, message.getBytes()); data.putString(KeychainIntentService.DECRYPT_PASSPHRASE, passphrase); - // TODO - data.putBoolean(KeychainIntentService.DECRYPT_ASSUME_SYMMETRIC, false); - intent.putExtra(KeychainIntentService.EXTRA_DATA, data); // Message is received after encrypting is done in KeychainIntentService -- cgit v1.2.3 From ddfb7e10e866379bf56ea9ad983fb2ca32c1dee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 16:39:18 +0200 Subject: Fully qualified imports --- .../sufficientlysecure/keychain/pgp/PgpHelper.java | 8 +++++- .../keychain/pgp/PgpImportExport.java | 15 ++++++++--- .../keychain/pgp/PgpKeyHelper.java | 13 ++++++++-- .../keychain/pgp/PgpKeyOperation.java | 29 +++++++++++++++++++--- .../keychain/pgp/PgpSignEncrypt.java | 26 ++++++++++++++++--- .../sufficientlysecure/keychain/pgp/PgpToX509.java | 24 +++++++++++++----- .../keychain/ui/DecryptFileFragment.java | 3 +++ 7 files changed, 99 insertions(+), 19 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java index cc40afbac..7a3338c7c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java @@ -21,7 +21,13 @@ import android.content.Context; import android.content.pm.PackageInfo; import android.content.pm.PackageManager.NameNotFoundException; -import org.spongycastle.openpgp.*; +import org.spongycastle.openpgp.PGPEncryptedDataList; +import org.spongycastle.openpgp.PGPObjectFactory; +import org.spongycastle.openpgp.PGPPublicKeyEncryptedData; +import org.spongycastle.openpgp.PGPPublicKeyRing; +import org.spongycastle.openpgp.PGPSecretKey; +import org.spongycastle.openpgp.PGPSecretKeyRing; +import org.spongycastle.openpgp.PGPUtil; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java index 0e0fdec83..de405d132 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java @@ -20,8 +20,14 @@ package org.sufficientlysecure.keychain.pgp; import android.content.Context; import android.os.Bundle; import android.os.Environment; + import org.spongycastle.bcpg.ArmoredOutputStream; -import org.spongycastle.openpgp.*; +import org.spongycastle.openpgp.PGPException; +import org.spongycastle.openpgp.PGPKeyRing; +import org.spongycastle.openpgp.PGPPublicKey; +import org.spongycastle.openpgp.PGPPublicKeyRing; +import org.spongycastle.openpgp.PGPSecretKey; +import org.spongycastle.openpgp.PGPSecretKeyRing; import org.spongycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; @@ -30,13 +36,16 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; -import org.sufficientlysecure.keychain.util.*; +import org.sufficientlysecure.keychain.util.HkpKeyServer; +import org.sufficientlysecure.keychain.util.IterableIterator; import org.sufficientlysecure.keychain.util.KeyServer.AddKeyException; +import org.sufficientlysecure.keychain.util.KeychainServiceListener; +import org.sufficientlysecure.keychain.util.Log; +import org.sufficientlysecure.keychain.util.ProgressDialogUpdater; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; -import java.security.Provider; import java.util.ArrayList; import java.util.List; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index b4bf0747f..89352ef31 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -24,7 +24,12 @@ import android.text.SpannableStringBuilder; import android.text.style.ForegroundColorSpan; import org.spongycastle.bcpg.sig.KeyFlags; -import org.spongycastle.openpgp.*; +import org.spongycastle.openpgp.PGPPublicKey; +import org.spongycastle.openpgp.PGPPublicKeyRing; +import org.spongycastle.openpgp.PGPSecretKey; +import org.spongycastle.openpgp.PGPSecretKeyRing; +import org.spongycastle.openpgp.PGPSignature; +import org.spongycastle.openpgp.PGPSignatureSubpacketVector; import org.spongycastle.util.encoders.Hex; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; @@ -35,7 +40,11 @@ import org.sufficientlysecure.keychain.util.Log; import java.security.DigestException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; -import java.util.*; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.Vector; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 520189448..0e828d859 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -22,25 +22,46 @@ import org.spongycastle.bcpg.HashAlgorithmTags; import org.spongycastle.bcpg.SymmetricKeyAlgorithmTags; import org.spongycastle.bcpg.sig.KeyFlags; import org.spongycastle.jce.spec.ElGamalParameterSpec; -import org.spongycastle.openpgp.*; +import org.spongycastle.openpgp.PGPEncryptedData; +import org.spongycastle.openpgp.PGPException; +import org.spongycastle.openpgp.PGPKeyPair; +import org.spongycastle.openpgp.PGPKeyRingGenerator; +import org.spongycastle.openpgp.PGPPrivateKey; +import org.spongycastle.openpgp.PGPPublicKey; +import org.spongycastle.openpgp.PGPPublicKeyRing; +import org.spongycastle.openpgp.PGPSecretKey; +import org.spongycastle.openpgp.PGPSecretKeyRing; +import org.spongycastle.openpgp.PGPSignature; +import org.spongycastle.openpgp.PGPSignatureGenerator; +import org.spongycastle.openpgp.PGPSignatureSubpacketGenerator; +import org.spongycastle.openpgp.PGPSignatureSubpacketVector; import org.spongycastle.openpgp.PGPUtil; import org.spongycastle.openpgp.operator.PBESecretKeyDecryptor; import org.spongycastle.openpgp.operator.PBESecretKeyEncryptor; import org.spongycastle.openpgp.operator.PGPContentSignerBuilder; import org.spongycastle.openpgp.operator.PGPDigestCalculator; -import org.spongycastle.openpgp.operator.jcajce.*; +import org.spongycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder; +import org.spongycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBuilder; +import org.spongycastle.openpgp.operator.jcajce.JcaPGPKeyPair; +import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder; +import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralMsgIdException; import org.sufficientlysecure.keychain.service.SaveKeyringParcel; +import org.sufficientlysecure.keychain.util.IterableIterator; import org.sufficientlysecure.keychain.util.Primes; import org.sufficientlysecure.keychain.util.ProgressDialogUpdater; -import org.sufficientlysecure.keychain.util.IterableIterator; import java.io.IOException; import java.math.BigInteger; -import java.security.*; +import java.security.InvalidAlgorithmParameterException; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.SecureRandom; +import java.security.SignatureException; import java.util.ArrayList; import java.util.Date; import java.util.GregorianCalendar; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java index 6d80c154b..f4fa95fca 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java @@ -21,9 +21,25 @@ import android.content.Context; import org.spongycastle.bcpg.ArmoredOutputStream; import org.spongycastle.bcpg.BCPGOutputStream; -import org.spongycastle.openpgp.*; +import org.spongycastle.openpgp.PGPCompressedDataGenerator; +import org.spongycastle.openpgp.PGPEncryptedDataGenerator; +import org.spongycastle.openpgp.PGPException; +import org.spongycastle.openpgp.PGPLiteralData; +import org.spongycastle.openpgp.PGPLiteralDataGenerator; +import org.spongycastle.openpgp.PGPPrivateKey; +import org.spongycastle.openpgp.PGPPublicKey; +import org.spongycastle.openpgp.PGPSecretKey; +import org.spongycastle.openpgp.PGPSecretKeyRing; +import org.spongycastle.openpgp.PGPSignature; +import org.spongycastle.openpgp.PGPSignatureGenerator; +import org.spongycastle.openpgp.PGPSignatureSubpacketGenerator; +import org.spongycastle.openpgp.PGPV3SignatureGenerator; import org.spongycastle.openpgp.operator.PBESecretKeyDecryptor; -import org.spongycastle.openpgp.operator.jcajce.*; +import org.spongycastle.openpgp.operator.jcajce.JcaPGPContentSignerBuilder; +import org.spongycastle.openpgp.operator.jcajce.JcePBEKeyEncryptionMethodGenerator; +import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder; +import org.spongycastle.openpgp.operator.jcajce.JcePGPDataEncryptorBuilder; +import org.spongycastle.openpgp.operator.jcajce.JcePublicKeyKeyEncryptionMethodGenerator; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; @@ -33,7 +49,11 @@ import org.sufficientlysecure.keychain.util.InputData; import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ProgressDialogUpdater; -import java.io.*; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.SignatureException; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpToX509.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpToX509.java index 54601173d..fa54afa86 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpToX509.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpToX509.java @@ -18,7 +18,13 @@ package org.sufficientlysecure.keychain.pgp; import org.spongycastle.asn1.DERObjectIdentifier; -import org.spongycastle.asn1.x509.*; +import org.spongycastle.asn1.x509.AuthorityKeyIdentifier; +import org.spongycastle.asn1.x509.BasicConstraints; +import org.spongycastle.asn1.x509.GeneralName; +import org.spongycastle.asn1.x509.GeneralNames; +import org.spongycastle.asn1.x509.SubjectKeyIdentifier; +import org.spongycastle.asn1.x509.X509Extensions; +import org.spongycastle.asn1.x509.X509Name; import org.spongycastle.openpgp.PGPException; import org.spongycastle.openpgp.PGPPrivateKey; import org.spongycastle.openpgp.PGPPublicKey; @@ -29,13 +35,14 @@ import org.spongycastle.x509.extension.SubjectKeyIdentifierStructure; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.util.Log; -import javax.security.auth.callback.Callback; -import javax.security.auth.callback.CallbackHandler; -import javax.security.auth.callback.PasswordCallback; -import javax.security.auth.callback.UnsupportedCallbackException; import java.io.IOException; import java.math.BigInteger; -import java.security.*; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.SignatureException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; import java.text.DateFormat; @@ -43,6 +50,11 @@ import java.util.Date; import java.util.Iterator; import java.util.Vector; +import javax.security.auth.callback.Callback; +import javax.security.auth.callback.CallbackHandler; +import javax.security.auth.callback.PasswordCallback; +import javax.security.auth.callback.UnsupportedCallbackException; + public class PgpToX509 { public static final String DN_COMMON_PART_O = "OpenPGP to X.509 Bridge"; public static final String DN_COMMON_PART_OU = "OpenPGP Keychain cert"; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java index 8a89ad240..ed6366353 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java @@ -203,6 +203,9 @@ public class DecryptFileFragment extends DecryptFragment { } else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) { showPassphraseDialog(Id.key.symmetric); } else { + AppMsg.makeText(getActivity(), R.string.decryption_successful, + AppMsg.STYLE_INFO).show(); + if (mDeleteAfter.isChecked()) { // Create and show dialog to delete original file DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment -- cgit v1.2.3 From ecca54d4d5df452fccbdd092a4671ef04cad8157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 17:08:56 +0200 Subject: Automatically select newly created key in api accounts --- .../remote/ui/AccountSettingsFragment.java | 29 ++++++++++++++++++++-- .../keychain/service/KeychainIntentService.java | 1 + .../keychain/ui/EditKeyActivity.java | 8 ++++++ .../keychain/ui/SelectSecretKeyLayoutFragment.java | 27 ++++++++------------ 4 files changed, 47 insertions(+), 18 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java index 0931e6e31..eec54b4cc 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java @@ -17,7 +17,9 @@ package org.sufficientlysecure.keychain.remote.ui; +import android.app.Activity; import android.content.Intent; +import android.net.Uri; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; @@ -31,6 +33,7 @@ import android.widget.TextView; import com.beardedhen.androidbootstrap.BootstrapButton; import org.sufficientlysecure.keychain.R; +import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.remote.AccountSettings; import org.sufficientlysecure.keychain.ui.EditKeyActivity; import org.sufficientlysecure.keychain.ui.SelectSecretKeyLayoutFragment; @@ -40,6 +43,8 @@ import org.sufficientlysecure.keychain.util.AlgorithmNames; public class AccountSettingsFragment extends Fragment implements SelectSecretKeyLayoutFragment.SelectSecretKeyCallback { + private static final int REQUEST_CODE_CREATE_KEY = 0x00008884; + // model private AccountSettings mAccSettings; @@ -64,7 +69,8 @@ public class AccountSettingsFragment extends Fragment implements this.mAccSettings = accountSettings; mAccNameView.setText(accountSettings.getAccountName()); - mSelectKeyFragment.selectKey(accountSettings.getKeyId()); + Uri keyUri = KeychainContract.KeyRings.buildSecretKeyRingsByMasterKeyIdUri(String.valueOf(accountSettings.getKeyId())); + mSelectKeyFragment.selectKey(keyUri); mEncryptionAlgorithm.setSelection(mEncryptionAdapter.getPosition(accountSettings .getEncryptionAlgorithm())); mHashAlgorithm.setSelection(mHashAdapter.getPosition(accountSettings.getHashAlgorithm())); @@ -162,7 +168,26 @@ public class AccountSettingsFragment extends Fragment implements intent.putExtra(EditKeyActivity.EXTRA_GENERATE_DEFAULT_KEYS, true); // set default user id to account name TODO: not working currently in EditKey intent.putExtra(EditKeyActivity.EXTRA_USER_IDS, mAccSettings.getAccountName()); - startActivityForResult(intent, 0); + startActivityForResult(intent, REQUEST_CODE_CREATE_KEY); + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent data) { + switch (requestCode) { + case REQUEST_CODE_CREATE_KEY: { + if (resultCode == Activity.RESULT_OK) { + // select newly created key + Uri newKeyUri = data.getData(); + mSelectKeyFragment.selectKey(newKeyUri); + } + break; + } + + default: + super.onActivityResult(requestCode, resultCode, data); + + break; + } } /** diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index f82e5e619..110f06634 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -36,6 +36,7 @@ import org.sufficientlysecure.keychain.helper.Preferences; import org.sufficientlysecure.keychain.pgp.*; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralMsgIdException; +import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract.DataStream; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 9df84065f..a17cfaafc 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -621,7 +621,15 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { Intent data = new Intent(); + + // TODO: remove, now using uri! data.putExtra(RESULT_EXTRA_MASTER_KEY_ID, getMasterKeyId()); + + // return uri pointing to new created key + Uri uri = KeychainContract.KeyRings.buildPublicKeyRingsByKeyIdUri( + String.valueOf(getMasterKeyId())); + data.setData(uri); + ArrayList userIds = null; try { userIds = getUserIds(mUserIdsView); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java index cbc0f4c5c..d0abe0f6f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java @@ -40,6 +40,8 @@ import org.sufficientlysecure.keychain.provider.KeychainContract; public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderManager.LoaderCallbacks { + private static final int REQUEST_CODE_SELECT_KEY = 0x00008882; + private TextView mKeyUserId; private TextView mKeyUserIdRest; private TextView mKeyMasterKeyIdHex; @@ -51,14 +53,10 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan private SelectSecretKeyCallback mCallback; - private static final int REQUEST_CODE_SELECT_KEY = 8882; - - private static final int LOADER_ID = 0; - - //The Projection we will retrieve, Master Key ID is for convenience sake, - //to avoid having to pass the Key Around - final String[] PROJECTION = new String[]{KeychainContract.UserIds.USER_ID - , KeychainContract.KeyRings.MASTER_KEY_ID}; + final String[] PROJECTION = new String[]{ + KeychainContract.UserIds.USER_ID, + KeychainContract.KeyRings.MASTER_KEY_ID + }; final int INDEX_USER_ID = 0; final int INDEX_MASTER_KEY_ID = 1; @@ -82,7 +80,6 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan } public void setSelectedKeyData(String userName, String email, String masterKeyHex) { - mNoKeySelected.setVisibility(View.GONE); mKeyUserId.setText(userName); @@ -124,11 +121,9 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan return view; } - //For AppSettingsFragment - public void selectKey(long masterKeyId) { - Uri buildUri = KeychainContract.KeyRings.buildSecretKeyRingsByMasterKeyIdUri(String.valueOf(masterKeyId)); - mReceivedUri = buildUri; - getActivity().getSupportLoaderManager().restartLoader(LOADER_ID, null, this); + public void selectKey(Uri keyUri) { + mReceivedUri = keyUri; + getActivity().getSupportLoaderManager().restartLoader(0, null, this); } private void startSelectKeyActivity() { @@ -188,13 +183,13 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan // Secret Key Fragment.Intent contains the passed Uri @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { - switch (requestCode & 0xFFFF) { + switch (requestCode) { case REQUEST_CODE_SELECT_KEY: { if (resultCode == Activity.RESULT_OK) { mReceivedUri = data.getData(); //Must be restartLoader() or the data will not be updated on selecting a new key - getActivity().getSupportLoaderManager().restartLoader(LOADER_ID, null, this); + getActivity().getSupportLoaderManager().restartLoader(0, null, this); mKeyUserId.setError(null); -- cgit v1.2.3 From 2f9cb69a1e10bff580abb909614662fd6de69255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 17:13:53 +0200 Subject: Cleanup --- .../keychain/ui/EditKeyActivity.java | 129 +++++++++------------ .../keychain/ui/SelectSecretKeyLayoutFragment.java | 5 - 2 files changed, 55 insertions(+), 79 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index a17cfaafc..2cdd64f4a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012-2013 Dominik Schürmann + * Copyright (C) 2012-2014 Dominik Schürmann * Copyright (C) 2010 Thialfihar * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,13 +17,8 @@ package org.sufficientlysecure.keychain.ui; -import java.util.ArrayList; -import java.util.GregorianCalendar; -import java.util.List; -import java.util.Vector; - -import org.spongycastle.bcpg.sig.KeyFlags; import android.app.Activity; +import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; @@ -33,14 +28,20 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.os.Messenger; +import android.support.v4.app.ActivityCompat; import android.support.v7.app.ActionBarActivity; -import android.view.*; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; import android.view.View.OnClickListener; +import android.view.ViewGroup; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.LinearLayout; import android.widget.Toast; + import com.beardedhen.androidbootstrap.BootstrapButton; import com.devspark.appmsg.AppMsg; @@ -63,20 +64,17 @@ import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.SetPassphraseDialogFragment; import org.sufficientlysecure.keychain.ui.widget.Editor; +import org.sufficientlysecure.keychain.ui.widget.Editor.EditorListener; import org.sufficientlysecure.keychain.ui.widget.KeyEditor; import org.sufficientlysecure.keychain.ui.widget.SectionView; import org.sufficientlysecure.keychain.ui.widget.UserIdEditor; -import org.sufficientlysecure.keychain.ui.widget.Editor.EditorListener; import org.sufficientlysecure.keychain.util.IterableIterator; import org.sufficientlysecure.keychain.util.Log; -import android.app.AlertDialog; -import android.support.v4.app.ActivityCompat; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; +import java.util.ArrayList; +import java.util.GregorianCalendar; +import java.util.List; +import java.util.Vector; public class EditKeyActivity extends ActionBarActivity implements EditorListener { @@ -89,10 +87,6 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener public static final String EXTRA_NO_PASSPHRASE = "no_passphrase"; public static final String EXTRA_GENERATE_DEFAULT_KEYS = "generate_default_keys"; - // results when saving key - public static final String RESULT_EXTRA_MASTER_KEY_ID = "master_key_id"; - public static final String RESULT_EXTRA_USER_ID = "user_id"; - // EDIT private Uri mDataUri; @@ -119,8 +113,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener ExportHelper mExportHelper; - public boolean needsSaving() - { + public boolean needsSaving() { mNeedsSaving = (mUserIdsView == null) ? false : mUserIdsView.needsSaving(); mNeedsSaving |= (mKeysView == null) ? false : mKeysView.needsSaving(); mNeedsSaving |= hasPassphraseChanged(); @@ -129,19 +122,16 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } - public void somethingChanged() - { + public void somethingChanged() { ActivityCompat.invalidateOptionsMenu(this); //Toast.makeText(this, "Needs saving: " + Boolean.toString(mNeedsSaving) + "(" + Boolean.toString(mUserIdsView.needsSaving()) + ", " + Boolean.toString(mKeysView.needsSaving()) + ")", Toast.LENGTH_LONG).show(); } - public void onDeleted(Editor e, boolean wasNewItem) - { + public void onDeleted(Editor e, boolean wasNewItem) { somethingChanged(); } - public void onEdited() - { + public void onEdited() { somethingChanged(); } @@ -337,41 +327,42 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { - case android.R.id.home: - cancelClicked(); //TODO: why isn't this triggered on my tablet - one of many ui problems I've had with this device. A code compatibility issue or a Samsung fail? - return true; - case R.id.menu_key_edit_cancel: - cancelClicked(); - return true; - case R.id.menu_key_edit_export_file: - if (needsSaving()) { - Toast.makeText(this, R.string.error_save_first, Toast.LENGTH_LONG).show(); - } else { - long masterKeyId = ProviderHelper.getMasterKeyId(this, mDataUri); - long[] ids = new long[]{masterKeyId}; - mExportHelper.showExportKeysDialog(ids, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC, - null); + case android.R.id.home: + cancelClicked(); //TODO: why isn't this triggered on my tablet - one of many ui problems I've had with this device. A code compatibility issue or a Samsung fail? return true; - } - return true; - case R.id.menu_key_edit_delete: - long rowId= ProviderHelper.getRowId(this,mDataUri); - Uri convertUri = KeychainContract.KeyRings.buildSecretKeyRingsUri(Long.toString(rowId)); - // Message is received after key is deleted - Handler returnHandler = new Handler() { - @Override - public void handleMessage(Message message) { - if (message.what == DeleteKeyDialogFragment.MESSAGE_OKAY) { - setResult(RESULT_CANCELED); - finish(); + case R.id.menu_key_edit_cancel: + cancelClicked(); + return true; + case R.id.menu_key_edit_export_file: + if (needsSaving()) { + Toast.makeText(this, R.string.error_save_first, Toast.LENGTH_LONG).show(); + } else { + long masterKeyId = ProviderHelper.getMasterKeyId(this, mDataUri); + long[] ids = new long[]{masterKeyId}; + mExportHelper.showExportKeysDialog(ids, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC, + null); + return true; + } + return true; + case R.id.menu_key_edit_delete: + long rowId = ProviderHelper.getRowId(this, mDataUri); + Uri convertUri = KeychainContract.KeyRings.buildSecretKeyRingsUri(Long.toString(rowId)); + // Message is received after key is deleted + Handler returnHandler = new Handler() { + @Override + public void handleMessage(Message message) { + if (message.what == DeleteKeyDialogFragment.MESSAGE_OKAY) { + setResult(RESULT_CANCELED); + finish(); + } } - }}; - mExportHelper.deleteKey(convertUri, returnHandler); - return true; + }; + mExportHelper.deleteKey(convertUri, returnHandler); + return true; - case R.id.menu_key_edit_save: - saveClicked(); - return true; + case R.id.menu_key_edit_save: + saveClicked(); + return true; } return super.onOptionsItemSelected(item); } @@ -458,6 +449,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener /** * Build layout based on mUserId, mKeys and mKeysUsages Vectors. It creates Views for every user * id and key. + * * @param newKeys */ private void buildLayout(boolean newKeys) { @@ -471,7 +463,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout container = (LinearLayout) findViewById(R.id.edit_key_container); - if(mIsPassPhraseSet){ + if (mIsPassPhraseSet) { mChangePassphrase.setText(getString(R.string.btn_change_passphrase)); } mUserIdsView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false); @@ -532,15 +524,14 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } } - public boolean hasPassphraseChanged() - { + public boolean hasPassphraseChanged() { if (mNoPassphrase != null) { if (mNoPassphrase.isChecked()) { return mIsPassPhraseSet; } else { return (mNewPassPhrase != null && !mNewPassPhrase.equals("")); } - }else { + } else { return false; } } @@ -622,21 +613,11 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { Intent data = new Intent(); - // TODO: remove, now using uri! - data.putExtra(RESULT_EXTRA_MASTER_KEY_ID, getMasterKeyId()); - // return uri pointing to new created key Uri uri = KeychainContract.KeyRings.buildPublicKeyRingsByKeyIdUri( String.valueOf(getMasterKeyId())); data.setData(uri); - ArrayList userIds = null; - try { - userIds = getUserIds(mUserIdsView); - } catch (PgpGeneralException e) { - Log.e(Constants.TAG, "exception while getting user ids", e); - } - data.putExtra(RESULT_EXTRA_USER_ID, userIds.get(0)); setResult(RESULT_OK, data); finish(); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java index d0abe0f6f..d1ba431d6 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java @@ -89,7 +89,6 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan mKeyUserId.setVisibility(View.VISIBLE); mKeyUserIdRest.setVisibility(View.VISIBLE); mKeyMasterKeyIdHex.setVisibility(View.VISIBLE); - } public void setError(String error) { @@ -134,7 +133,6 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan @Override public Loader onCreateLoader(int id, Bundle args) { - //We don't care about the Loader id return new CursorLoader(getActivity(), mReceivedUri, PROJECTION, null, null, null); } @@ -179,8 +177,6 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan return; } - // Select Secret Key Activity delivers the intent which was sent by it using interface to Select - // Secret Key Fragment.Intent contains the passed Uri @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { @@ -192,7 +188,6 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan getActivity().getSupportLoaderManager().restartLoader(0, null, this); mKeyUserId.setError(null); - } break; } -- cgit v1.2.3 From 2c5991b19933cbb984db58b3e64db538e6782c28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 17:19:51 +0200 Subject: Add API image --- Resources/docs/openpgp_api_1.jpg | Bin 0 -> 2092770 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Resources/docs/openpgp_api_1.jpg diff --git a/Resources/docs/openpgp_api_1.jpg b/Resources/docs/openpgp_api_1.jpg new file mode 100644 index 000000000..3582abb8f Binary files /dev/null and b/Resources/docs/openpgp_api_1.jpg differ -- cgit v1.2.3 From d0947e8377283f8780b5e7555dd321950a2de147 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 18:44:36 +0200 Subject: Only allow private keys associated to accounts of an app --- .../keychain/pgp/PgpDecryptVerify.java | 23 +++++++++++----------- .../keychain/provider/ProviderHelper.java | 20 +++++++++++++++++-- .../keychain/remote/OpenPgpService.java | 12 +++++++---- .../keychain/remote/RemoteService.java | 2 +- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java index 29255fbbe..003db632d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java @@ -67,6 +67,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.security.SignatureException; import java.util.Iterator; +import java.util.Set; /** * This class uses a Builder pattern! @@ -79,7 +80,7 @@ public class PgpDecryptVerify { private ProgressDialogUpdater mProgressDialogUpdater; private boolean mAllowSymmetricDecryption; private String mPassphrase; - private long mEnforcedKeyId; + private Set mAllowedKeyIds; private PgpDecryptVerify(Builder builder) { // private Constructor can only be called from Builder @@ -90,7 +91,7 @@ public class PgpDecryptVerify { this.mProgressDialogUpdater = builder.mProgressDialogUpdater; this.mAllowSymmetricDecryption = builder.mAllowSymmetricDecryption; this.mPassphrase = builder.mPassphrase; - this.mEnforcedKeyId = builder.mEnforcedKeyId; + this.mAllowedKeyIds = builder.mAllowedKeyIds; } public static class Builder { @@ -103,7 +104,7 @@ public class PgpDecryptVerify { private ProgressDialogUpdater mProgressDialogUpdater = null; private boolean mAllowSymmetricDecryption = true; private String mPassphrase = null; - private long mEnforcedKeyId = 0; + private Set mAllowedKeyIds = null; public Builder(Context context, InputData data, OutputStream outStream) { this.mContext = context; @@ -127,14 +128,14 @@ public class PgpDecryptVerify { } /** - * Allow this key id alone for decryption. - * This means only ciphertexts encrypted for this private key can be decrypted. + * Allow these key ids alone for decryption. + * This means only ciphertexts encrypted for one of these private key can be decrypted. * - * @param enforcedKeyId + * @param allowedKeyIds * @return */ - public Builder enforcedKeyId(long enforcedKeyId) { - this.mEnforcedKeyId = enforcedKeyId; + public Builder allowedKeyIds(Set allowedKeyIds) { + this.mAllowedKeyIds = allowedKeyIds; return this; } @@ -236,16 +237,16 @@ public class PgpDecryptVerify { // secret key exists in database // allow only a specific key for decryption? - if (mEnforcedKeyId != 0) { + if (mAllowedKeyIds != null) { // TODO: improve this code! get master key directly! PGPSecretKeyRing secretKeyRing = ProviderHelper.getPGPSecretKeyRingByKeyId(mContext, encData.getKeyID()); long masterKeyId = PgpKeyHelper.getMasterKey(secretKeyRing).getKeyID(); Log.d(Constants.TAG, "encData.getKeyID():" + encData.getKeyID()); - Log.d(Constants.TAG, "enforcedKeyId: " + mEnforcedKeyId); + Log.d(Constants.TAG, "allowedKeyIds: " + mAllowedKeyIds); Log.d(Constants.TAG, "masterKeyId: " + masterKeyId); - if (mEnforcedKeyId != masterKeyId) { + if (!mAllowedKeyIds.contains(masterKeyId)) { throw new PgpGeneralException( mContext.getString(R.string.error_no_secret_key_found)); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java index b971143ae..13dc2af2b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -48,6 +48,8 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.ArrayList; import java.util.Date; +import java.util.HashSet; +import java.util.Set; public class ProviderHelper { @@ -867,10 +869,10 @@ public class ProviderHelper { return settings; } - public static AccountSettings getApiAccountSettings(Context context, Uri uri) { + public static AccountSettings getApiAccountSettings(Context context, Uri accountUri) { AccountSettings settings = null; - Cursor cur = context.getContentResolver().query(uri, null, null, null, null); + Cursor cur = context.getContentResolver().query(accountUri, null, null, null, null); if (cur != null && cur.moveToFirst()) { settings = new AccountSettings(); @@ -889,6 +891,20 @@ public class ProviderHelper { return settings; } + public static Set getAllKeyIdsForApp(Context context, Uri uri) { + Set keyIds = new HashSet(); + + Cursor cursor = context.getContentResolver().query(uri, null, null, null, null); + if (cursor != null) { + int keyIdColumn = cursor.getColumnIndex(KeychainContract.ApiAccounts.KEY_ID); + while (cursor.moveToNext()) { + keyIds.add(cursor.getLong(keyIdColumn)); + } + } + + return keyIds; + } + public static byte[] getApiAppSignature(Context context, String packageName) { Uri queryUri = ApiApps.buildByPackageNameUri(packageName); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java index 1cd5862e7..b00c012b8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -45,6 +45,7 @@ import org.sufficientlysecure.keychain.util.Log; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; +import java.util.Set; public class OpenPgpService extends RemoteService { @@ -276,7 +277,7 @@ public class OpenPgpService extends RemoteService { } private Intent decryptAndVerifyImpl(Intent data, ParcelFileDescriptor input, - ParcelFileDescriptor output, AccountSettings accSettings) { + ParcelFileDescriptor output, Set allowedKeyIds) { try { // Get Input- and OutputStream from ParcelFileDescriptor InputStream is = new ParcelFileDescriptor.AutoCloseInputStream(input); @@ -291,7 +292,7 @@ public class OpenPgpService extends RemoteService { PgpDecryptVerify.Builder builder = new PgpDecryptVerify.Builder(this, inputData, os); builder.allowSymmetricDecryption(false) // no support for symmetric encryption - .enforcedKeyId(accSettings.getKeyId()) // allow only the private key for this app for decryption + .allowedKeyIds(allowedKeyIds) // allow only private keys associated with accounts of this app .passphrase(passphrase); // TODO: currently does not support binary signed-only content @@ -299,7 +300,7 @@ public class OpenPgpService extends RemoteService { if (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) { // get PendingIntent for passphrase input, add it to given params and return to client - Intent passphraseBundle = getPassphraseBundleIntent(data, accSettings.getKeyId()); + Intent passphraseBundle = getPassphraseBundleIntent(data, decryptVerifyResult.getKeyIdPassphraseNeeded()); return passphraseBundle; } else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) { throw new PgpGeneralException("Decryption of symmetric content not supported by API!"); @@ -452,7 +453,10 @@ public class OpenPgpService extends RemoteService { } else if (OpenPgpApi.ACTION_SIGN_AND_ENCRYPT.equals(action)) { return encryptAndSignImpl(data, input, output, accSettings, true); } else if (OpenPgpApi.ACTION_DECRYPT_VERIFY.equals(action)) { - return decryptAndVerifyImpl(data, input, output, accSettings); + String currentPkg = getCurrentCallingPackage(); + Set allowedKeyIds = + ProviderHelper.getAllKeyIdsForApp(mContext, KeychainContract.ApiAccounts.buildBaseUri(currentPkg)); + return decryptAndVerifyImpl(data, input, output, allowedKeyIds); } else if (OpenPgpApi.ACTION_GET_KEY.equals(action)) { return getKeyImpl(data); } else if (OpenPgpApi.ACTION_GET_KEY_IDS.equals(action)) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java index 59a04a10e..3e72eec17 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java @@ -127,7 +127,7 @@ public abstract class RemoteService extends Service { * * @return package name */ - private String getCurrentCallingPackage() { + protected String getCurrentCallingPackage() { // TODO: // callingPackages contains more than one entry when sharedUserId has been used... String[] callingPackages = getPackageManager().getPackagesForUid(Binder.getCallingUid()); -- cgit v1.2.3 From 07fdd6363f06b59aeb9206d64ed719a97a87ff99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 18:49:19 +0200 Subject: Change path to OpenKeychain --- .../main/java/org/sufficientlysecure/keychain/Constants.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java index f9a7962ec..5062800db 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java @@ -47,7 +47,7 @@ public final class Constants { public static final class Path { public static final String APP_DIR = Environment.getExternalStorageDirectory() - + "/OpenPGP-Keychain"; + + "/OpenKeychain"; public static final String APP_DIR_FILE_SEC = APP_DIR + "/secexport.asc"; public static final String APP_DIR_FILE_PUB = APP_DIR + "/pubexport.asc"; } @@ -74,7 +74,12 @@ public final class Constants { public static final Class DECRYPT = DecryptActivity.class; public static final Class IMPORT_KEYS = ImportKeysActivity.class; public static final Class REGISTERED_APPS_LIST = AppsListActivity.class; - public static final Class[] ARRAY = new Class[]{KEY_LIST, ENCRYPT, DECRYPT, - IMPORT_KEYS, REGISTERED_APPS_LIST}; + public static final Class[] ARRAY = new Class[]{ + KEY_LIST, + ENCRYPT, + DECRYPT, + IMPORT_KEYS, + REGISTERED_APPS_LIST + }; } } -- cgit v1.2.3 From c414dd2fe94575deb157504fb0445df26b02feec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 19:00:14 +0200 Subject: Dont show encrypted data before decryption from clipboard --- .../keychain/ui/DecryptMessageFragment.java | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java index d7a22038d..c7a56449b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java @@ -47,10 +47,14 @@ import java.util.regex.Matcher; public class DecryptMessageFragment extends DecryptFragment { public static final String ARG_CIPHERTEXT = "ciphertext"; + // view private EditText mMessage; private BootstrapButton mDecryptButton; private BootstrapButton mDecryptFromCLipboardButton; + // model + private String mCiphertext; + /** * Inflate the layout for this fragment */ @@ -64,13 +68,13 @@ public class DecryptMessageFragment extends DecryptFragment { mDecryptButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - decryptStart(null); + decryptClicked(); } }); mDecryptFromCLipboardButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - decryptFromClipboard(); + decryptFromClipboardClicked(); } }); @@ -88,7 +92,12 @@ public class DecryptMessageFragment extends DecryptFragment { } } - private void decryptFromClipboard() { + private void decryptClicked() { + mCiphertext = mMessage.getText().toString(); + decryptStart(null); + } + + private void decryptFromClipboardClicked() { CharSequence clipboardText = ClipboardReflection.getClipboardText(getActivity()); // only decrypt if clipboard content is available and a pgp message or cleartext signature @@ -98,8 +107,7 @@ public class DecryptMessageFragment extends DecryptFragment { matcher = PgpHelper.PGP_CLEARTEXT_SIGNATURE.matcher(clipboardText); } if (matcher.matches()) { - String data = matcher.group(1); - mMessage.setText(data); + mCiphertext = matcher.group(1); decryptStart(null); } else { AppMsg.makeText(getActivity(), R.string.error_invalid_data, AppMsg.STYLE_INFO) @@ -125,8 +133,7 @@ public class DecryptMessageFragment extends DecryptFragment { // data data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_BYTES); - String message = mMessage.getText().toString(); - data.putByteArray(KeychainIntentService.DECRYPT_CIPHERTEXT_BYTES, message.getBytes()); + data.putByteArray(KeychainIntentService.DECRYPT_CIPHERTEXT_BYTES, mCiphertext.getBytes()); data.putString(KeychainIntentService.DECRYPT_PASSPHRASE, passphrase); intent.putExtra(KeychainIntentService.EXTRA_DATA, data); -- cgit v1.2.3 From d8001f9bbd83207922903f6a99872be5c2bac659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 1 Apr 2014 19:31:36 +0200 Subject: Menu cleanup --- .../keychain/ui/KeyListActivity.java | 9 ++-- OpenPGP-Keychain/src/main/res/menu/key_list.xml | 52 ++++++++++++++-------- .../src/main/res/menu/key_list_multi.xml | 8 ++-- OpenPGP-Keychain/src/main/res/values/strings.xml | 6 ++- 4 files changed, 47 insertions(+), 28 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java index 06df6f12d..27d3bbbb0 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java @@ -21,6 +21,7 @@ import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; @@ -55,10 +56,6 @@ public class KeyListActivity extends DrawerActivity { case R.id.menu_key_list_import: callIntentForDrawerItem(Constants.DrawerItems.IMPORT_KEYS); - return true; - case R.id.menu_key_list_export: - mExportHelper.showExportKeysDialog(null, Id.type.public_key, Constants.Path.APP_DIR_FILE_PUB, null); - return true; case R.id.menu_key_list_create: createKey(); @@ -67,6 +64,10 @@ public class KeyListActivity extends DrawerActivity { case R.id.menu_key_list_create_expert: createKeyExpert(); + return true; + case R.id.menu_key_list_export_public: + mExportHelper.showExportKeysDialog(null, Id.type.public_key, Constants.Path.APP_DIR_FILE_PUB, null); + return true; case R.id.menu_key_list_secret_export: mExportHelper.showExportKeysDialog(null, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC, null); diff --git a/OpenPGP-Keychain/src/main/res/menu/key_list.xml b/OpenPGP-Keychain/src/main/res/menu/key_list.xml index 10223522c..bcb2a4b99 100644 --- a/OpenPGP-Keychain/src/main/res/menu/key_list.xml +++ b/OpenPGP-Keychain/src/main/res/menu/key_list.xml @@ -2,11 +2,6 @@ - + android:id="@+id/menu_key_list_add" + app:showAsAction="ifRoom|withText" + android:icon="@drawable/ic_action_add_person" + android:title="@string/menu_add_keys"> + + - + + + + + + app:showAsAction="ifRoom|withText" + android:icon="@drawable/ic_action_import_export" + android:title="@string/menu_export_keys"> + + - + + + diff --git a/OpenPGP-Keychain/src/main/res/menu/key_list_multi.xml b/OpenPGP-Keychain/src/main/res/menu/key_list_multi.xml index db709052f..50f83026c 100644 --- a/OpenPGP-Keychain/src/main/res/menu/key_list_multi.xml +++ b/OpenPGP-Keychain/src/main/res/menu/key_list_multi.xml @@ -1,10 +1,6 @@ - + diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index 645d7941a..c9ef6a135 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -78,7 +78,7 @@ Import from QR Code Import Import from NFC - Export all keys + Export all public keys Export all secret keys Export to file Delete key @@ -103,6 +103,8 @@ Cancel Encrypt to… Select all + Add keys + Export keys Sign @@ -469,7 +471,7 @@ Certifications - Contacts + Keys Sign and Encrypt Decrypt and Verify Import Keys -- cgit v1.2.3 From abfe416503517ca6eaa1569818154fb498ec1741 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Tue, 1 Apr 2014 23:02:35 +0100 Subject: sort out saving empty string IDs --- .../org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 0e828d859..0aa8b7410 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -478,9 +478,7 @@ public class PgpKeyOperation { PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); sigList.add(new Pair(userId, certification)); } - if (!origID.equals("")) { - masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); - } + masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); userIDIndex++; } for (Pair toAdd : sigList) { @@ -502,9 +500,7 @@ public class PgpKeyOperation { sGen.setUnhashedSubpackets(unhashedPacketsGen.generate()); } PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); - if (!origID.equals("")) { - masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); - } + masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification); } userIDIndex++; @@ -523,9 +519,7 @@ public class PgpKeyOperation { sigList.add(new Pair(userId, sig)); } } - if (!userId.equals("")) { - masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, userId); - } + masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, userId); userIDIndex++; } anyIDChanged = true; -- cgit v1.2.3 From 2ad616ed3f8a801c34da8b10f38103afc0cfe436 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Tue, 1 Apr 2014 23:37:13 +0100 Subject: pass through info that keys are new without relying on new keys orginally being empty --- .../org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 8 ++++++-- .../sufficientlysecure/keychain/service/SaveKeyringParcel.java | 3 +++ .../org/sufficientlysecure/keychain/ui/EditKeyActivity.java | 1 + .../org/sufficientlysecure/keychain/ui/widget/SectionView.java | 10 ++++++++++ .../sufficientlysecure/keychain/ui/widget/UserIdEditor.java | 2 ++ 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 0aa8b7410..66f1f3f01 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -478,7 +478,9 @@ public class PgpKeyOperation { PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); sigList.add(new Pair(userId, certification)); } - masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); + if (!saveParcel.newIDs[userIDIndex]) { + masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); + } userIDIndex++; } for (Pair toAdd : sigList) { @@ -500,7 +502,9 @@ public class PgpKeyOperation { sGen.setUnhashedSubpackets(unhashedPacketsGen.generate()); } PGPSignature certification = sGen.generateCertification(userId, masterPublicKey); - masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); + if (!saveParcel.newIDs[userIDIndex]) { + masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); + } masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification); } userIDIndex++; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java index c99284847..b7ae4e1f1 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java @@ -32,6 +32,7 @@ public class SaveKeyringParcel implements Parcelable { public ArrayList userIDs; public ArrayList originalIDs; public ArrayList deletedIDs; + public boolean[] newIDs; public boolean primaryIDChanged; public boolean[] moddedKeys; public ArrayList deletedKeys; @@ -50,6 +51,7 @@ public class SaveKeyringParcel implements Parcelable { userIDs = (ArrayList)source.readSerializable(); originalIDs = (ArrayList)source.readSerializable(); deletedIDs = (ArrayList)source.readSerializable(); + newIDs = source.createBooleanArray(); primaryIDChanged = source.readByte() != 0; moddedKeys = source.createBooleanArray(); byte[] tmp = source.createByteArray(); @@ -72,6 +74,7 @@ public class SaveKeyringParcel implements Parcelable { destination.writeSerializable(userIDs); //might not be the best method to store. destination.writeSerializable(originalIDs); destination.writeSerializable(deletedIDs); + destination.writeBooleanArray(newIDs); destination.writeByte((byte) (primaryIDChanged ? 1 : 0)); destination.writeBooleanArray(moddedKeys); byte[] tmp = null; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 2cdd64f4a..a9ab49c76 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -584,6 +584,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener saveParams.userIDs = getUserIds(mUserIdsView); saveParams.originalIDs = mUserIdsView.getOriginalIDs(); saveParams.deletedIDs = mUserIdsView.getDeletedIDs(); + saveParams.newIDs = toPrimitiveArray(mUserIdsView.getNewIDFlags()); saveParams.primaryIDChanged = mUserIdsView.primaryChanged(); saveParams.moddedKeys = toPrimitiveArray(mKeysView.getNeedsSavingArray()); saveParams.deletedKeys = mKeysView.getDeletedKeys(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 6c7737e6d..e99a4ef04 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -252,6 +252,16 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor return mList; } + public List getNewIDFlags() + { + ArrayList mList = new ArrayList(); + for (int i = 0; i < mEditors.getChildCount(); ++i) { + Editor editor = (Editor) mEditors.getChildAt(i); + mList.add(((UserIdEditor)editor).getIsNewID()); + } + return mList; + } + public List getNewKeysArray() { ArrayList mList = new ArrayList(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index d4b15613a..cf0cb6d44 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -261,4 +261,6 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene { return mOriginalID; } + + public boolean getIsNewID() { return mIsNewId; } } -- cgit v1.2.3 From 6d4a09f9890d152db32ce72c58a7a60d44a4ecae Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Wed, 2 Apr 2014 00:00:24 +0100 Subject: allow blank IDs, allow adding new IDs and let them be master --- .../java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 6 +++--- .../org/sufficientlysecure/keychain/ui/widget/SectionView.java | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 66f1f3f01..871b5b18b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -458,7 +458,7 @@ public class PgpKeyOperation { ArrayList> sigList = new ArrayList>(); for (String userId : saveParcel.userIDs) { String origID = saveParcel.originalIDs.get(userIDIndex); - if (origID.equals(userId) && !userId.equals(saveParcel.originalPrimaryID) && userIDIndex != 0) { + if ((origID.equals(userId) && !saveParcel.newIDs[userIDIndex]) && !userId.equals(saveParcel.originalPrimaryID) && userIDIndex != 0) { Iterator origSigs = masterPublicKey.getSignaturesForID(origID); //TODO: make sure this iterator only has signatures we are interested in while (origSigs.hasNext()) { PGPSignature origSig = origSigs.next(); @@ -489,7 +489,7 @@ public class PgpKeyOperation { } else { for (String userId : saveParcel.userIDs) { String origID = saveParcel.originalIDs.get(userIDIndex); - if (!origID.equals(userId)) { + if (!origID.equals(userId) || saveParcel.newIDs[userIDIndex]) { anyIDChanged = true; PGPContentSignerBuilder signerBuilder = new JcaPGPContentSignerBuilder( masterPublicKey.getAlgorithm(), HashAlgorithmTags.SHA1) @@ -516,7 +516,7 @@ public class PgpKeyOperation { userIDIndex = 0; for (String userId : saveParcel.userIDs) { String origID = saveParcel.originalIDs.get(userIDIndex); - if (!(origID.equals(saveParcel.originalPrimaryID) && !saveParcel.primaryIDChanged)) { + if (!(origID.equals(saveParcel.originalPrimaryID) && !saveParcel.primaryIDChanged) || !saveParcel.newIDs[userIDIndex]) { Iterator sigs = masterPublicKey.getSignaturesForID(userId); //TODO: make sure this iterator only has signatures we are interested in while (sigs.hasNext()) { PGPSignature sig = sigs.next(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index e99a4ef04..e6b22957b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -256,8 +256,11 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor { ArrayList mList = new ArrayList(); for (int i = 0; i < mEditors.getChildCount(); ++i) { - Editor editor = (Editor) mEditors.getChildAt(i); - mList.add(((UserIdEditor)editor).getIsNewID()); + UserIdEditor editor = (UserIdEditor) mEditors.getChildAt(i); + if (editor.isMainUserId()) + mList.add(0, editor.getIsNewID()); + else + mList.add(editor.getIsNewID()); } return mList; } -- cgit v1.2.3 From a38d22757c423bf182afaae2e5bce1d865e4f959 Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Wed, 2 Apr 2014 00:08:36 +0100 Subject: new ID sigs already added, so do save them --- .../main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index 871b5b18b..ebed02d1b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -516,7 +516,7 @@ public class PgpKeyOperation { userIDIndex = 0; for (String userId : saveParcel.userIDs) { String origID = saveParcel.originalIDs.get(userIDIndex); - if (!(origID.equals(saveParcel.originalPrimaryID) && !saveParcel.primaryIDChanged) || !saveParcel.newIDs[userIDIndex]) { + if (!(origID.equals(saveParcel.originalPrimaryID) && !saveParcel.primaryIDChanged)) { Iterator sigs = masterPublicKey.getSignaturesForID(userId); //TODO: make sure this iterator only has signatures we are interested in while (sigs.hasNext()) { PGPSignature sig = sigs.next(); -- cgit v1.2.3 From 9764d3fcb98c782a9a16cb090eb019bd8e5e595e Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Wed, 2 Apr 2014 01:26:51 +0100 Subject: confirm that empty IDs are really wanted --- .../keychain/ui/EditKeyActivity.java | 47 +++++++++++++++++++++- OpenPGP-Keychain/src/main/res/values/strings.xml | 1 + 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index a9ab49c76..633249d15 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -553,7 +553,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener showPassphraseDialog(masterKeyId); } else { mCurrentPassphrase = passphrase; - finallySaveClicked(); + checkEmptyIDsWanted(); } } catch (PgpGeneralException e) { Toast.makeText(this, getString(R.string.error_message, e.getMessage()), @@ -564,6 +564,51 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } } + private void checkEmptyIDsWanted() + { + try { + ArrayList userIDs = getUserIds(mUserIdsView); + List newIDs = mUserIdsView.getNewIDFlags(); + ArrayList originalIDs = mUserIdsView.getOriginalIDs(); + int curID = 0; + for (String userID : userIDs) { + if ( userID.equals("") && (!userID.equals(originalIDs.get(curID)) || newIDs.get(curID) ) ) { + AlertDialog.Builder alert = new AlertDialog.Builder( + EditKeyActivity.this); + + alert.setIcon(android.R.drawable.ic_dialog_alert); + alert.setTitle(R.string.warning); + alert.setMessage(EditKeyActivity.this.getString(R.string.ask_empty_id_ok)); + + alert.setPositiveButton(EditKeyActivity.this.getString(android.R.string.yes), + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.dismiss(); + finallySaveClicked(); + } + } + ); + alert.setNegativeButton(this.getString(android.R.string.no), + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + dialog.dismiss(); + } + } + ); + alert.setCancelable(false); + alert.create().show(); + return; + } + curID++; + } + } catch (PgpGeneralException e) { + Log.e(Constants.TAG, getString(R.string.error_message, e.getMessage())); + Toast.makeText(this, getString(R.string.error_message, e.getMessage()), + Toast.LENGTH_SHORT).show(); + } + finallySaveClicked(); + } + private boolean[] toPrimitiveArray(final List booleanList) { final boolean[] primitives = new boolean[booleanList.size()]; int index = 0; diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index c9ef6a135..54db372ab 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -225,6 +225,7 @@ Do you really want to delete all selected keys?\nYou can\'t undo this! Do you really want to delete the SECRET key \'%s\'?\nYou can\'t undo this! You have made changes to the keyring, would you like to save it? + "You have added an empty user ID, are you sure you want to continue?" Do you really want to delete the PUBLIC key \'%s\'?\nYou can\'t undo this! Delete Secret Keys ? Also export secret keys? -- cgit v1.2.3 From 5583fd513ee134cb5fbe4e96e6d9a1c823c3010f Mon Sep 17 00:00:00 2001 From: Ashley Hughes Date: Wed, 2 Apr 2014 01:28:53 +0100 Subject: always ask --- .../main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 633249d15..d1507fe34 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -290,7 +290,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener if (message.what == PassphraseDialogFragment.MESSAGE_OKAY) { mCurrentPassphrase = PassphraseCacheService.getCachedPassphrase( EditKeyActivity.this, masterKeyId); - finallySaveClicked(); + checkEmptyIDsWanted(); } } }; -- cgit v1.2.3 From e92658f44d8ee5ca7d04c3dbb313150a7f33d6c3 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 2 Apr 2014 01:34:24 +0200 Subject: Adjust import order --- .../keychain/KeychainApplication.java | 11 +++++----- .../compatibility/ClipboardReflection.java | 4 ++-- .../keychain/helper/ExportHelper.java | 6 ------ .../keychain/pgp/PgpKeyOperation.java | 3 +++ .../keychain/provider/KeychainDatabase.java | 2 +- .../keychain/remote/AppSettings.java | 4 ---- .../keychain/remote/ui/AccountsListFragment.java | 2 -- .../keychain/remote/ui/AppsListFragment.java | 2 -- .../keychain/service/KeychainIntentService.java | 2 -- .../keychain/service/PassphraseCacheService.java | 4 +++- .../keychain/ui/CertifyKeyActivity.java | 1 - .../keychain/ui/EditKeyActivity.java | 1 + .../keychain/ui/ImportKeysQrCodeFragment.java | 5 ++++- .../keychain/ui/ViewKeyActivity.java | 1 - .../keychain/ui/ViewKeyMainFragment.java | 1 - .../keychain/ui/adapter/ImportKeysAdapter.java | 1 - .../keychain/ui/adapter/PagerTabStripAdapter.java | 4 ---- .../keychain/ui/adapter/ViewKeyKeysAdapter.java | 1 - .../keychain/ui/widget/KeyEditor.java | 25 ++++++++-------------- .../keychain/ui/widget/SectionView.java | 24 ++++++--------------- .../keychain/ui/widget/UserIdEditor.java | 9 ++++---- .../keychain/util/HkpKeyServer.java | 5 +---- .../keychain/util/IntentIntegratorSupportV4.java | 3 ++- .../keychain/util/QrCodeUtils.java | 6 ++++-- 24 files changed, 46 insertions(+), 81 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java index 98b827542..e4ce6c373 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java @@ -17,16 +17,17 @@ package org.sufficientlysecure.keychain; -import java.io.File; -import java.security.Provider; -import java.security.Security; +import android.app.Application; +import android.os.Environment; import org.spongycastle.jce.provider.BouncyCastleProvider; + import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.PRNGFixes; -import android.app.Application; -import android.os.Environment; +import java.io.File; +import java.security.Provider; +import java.security.Security; public class KeychainApplication extends Application { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/compatibility/ClipboardReflection.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/compatibility/ClipboardReflection.java index 3164de7d1..10bb8cf5d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/compatibility/ClipboardReflection.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/compatibility/ClipboardReflection.java @@ -17,13 +17,13 @@ package org.sufficientlysecure.keychain.compatibility; -import java.lang.reflect.Method; - import android.content.Context; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.util.Log; +import java.lang.reflect.Method; + public class ClipboardReflection { private static final String clipboardLabel = "Keychain"; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java index cc240a67b..00a62ce58 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java @@ -30,18 +30,12 @@ import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround; -import org.sufficientlysecure.keychain.provider.KeychainContract; -import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.FileDialogFragment; import org.sufficientlysecure.keychain.util.Log; -import java.lang.reflect.Array; -import java.security.Provider; -import java.util.ArrayList; - public class ExportHelper { protected FileDialogFragment mFileDialog; protected String mExportFilename; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index ebed02d1b..c91a932c5 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -17,6 +17,8 @@ package org.sufficientlysecure.keychain.pgp; +import android.util.Pair; + import org.spongycastle.bcpg.CompressionAlgorithmTags; import org.spongycastle.bcpg.HashAlgorithmTags; import org.spongycastle.bcpg.SymmetricKeyAlgorithmTags; @@ -45,6 +47,7 @@ import org.spongycastle.openpgp.operator.jcajce.JcaPGPDigestCalculatorProviderBu import org.spongycastle.openpgp.operator.jcajce.JcaPGPKeyPair; import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder; import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyEncryptorBuilder; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java index 8c33844b2..807444d78 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java @@ -23,8 +23,8 @@ import android.database.sqlite.SQLiteOpenHelper; import android.provider.BaseColumns; import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsColumns; import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsAccountsColumns; +import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsColumns; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingsColumns; import org.sufficientlysecure.keychain.provider.KeychainContract.KeysColumns; import org.sufficientlysecure.keychain.provider.KeychainContract.UserIdsColumns; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/AppSettings.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/AppSettings.java index 6c7e51bf0..a3f9f84c9 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/AppSettings.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/AppSettings.java @@ -17,10 +17,6 @@ package org.sufficientlysecure.keychain.remote; -import org.spongycastle.bcpg.HashAlgorithmTags; -import org.spongycastle.openpgp.PGPEncryptedData; -import org.sufficientlysecure.keychain.Id; - public class AppSettings { private String mPackageName; private byte[] mPackageSignature; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java index 8e65a2f04..cfc9c92ad 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountsListFragment.java @@ -32,12 +32,10 @@ import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; -import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; import org.sufficientlysecure.keychain.Constants; -import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.ui.widget.FixedListView; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java index f3fa6e7c6..22082e913 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AppsListFragment.java @@ -37,11 +37,9 @@ import android.widget.AdapterView.OnItemClickListener; import android.widget.ImageView; import android.widget.TextView; -import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.KeychainContract.ApiApps; -import org.sufficientlysecure.keychain.util.Log; public class AppsListFragment extends ListFragment implements LoaderManager.LoaderCallbacks { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 110f06634..bdd50c98d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -36,8 +36,6 @@ import org.sufficientlysecure.keychain.helper.Preferences; import org.sufficientlysecure.keychain.pgp.*; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralMsgIdException; -import org.sufficientlysecure.keychain.provider.KeychainContract; -import org.sufficientlysecure.keychain.provider.KeychainContract.DataStream; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; import org.sufficientlysecure.keychain.util.*; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java index 5825db01b..7ab40491f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java @@ -25,14 +25,16 @@ import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.os.*; -import android.util.Log; import android.support.v4.util.LongSparseArray; +import android.util.Log; + import org.spongycastle.openpgp.PGPException; import org.spongycastle.openpgp.PGPPrivateKey; import org.spongycastle.openpgp.PGPSecretKey; import org.spongycastle.openpgp.PGPSecretKeyRing; import org.spongycastle.openpgp.operator.PBESecretKeyDecryptor; import org.spongycastle.openpgp.operator.jcajce.JcePBESecretKeyDecryptorBuilder; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.helper.Preferences; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java index 5dc06c16d..9e32fead0 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java @@ -38,7 +38,6 @@ import com.beardedhen.androidbootstrap.BootstrapButton; import org.spongycastle.openpgp.PGPPublicKeyRing; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.helper.OtherHelper; import org.sufficientlysecure.keychain.helper.Preferences; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index d1507fe34..bab1e6f5f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -47,6 +47,7 @@ import com.devspark.appmsg.AppMsg; import org.spongycastle.openpgp.PGPSecretKey; import org.spongycastle.openpgp.PGPSecretKeyRing; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysQrCodeFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysQrCodeFragment.java index 10c0752b1..8b553d273 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysQrCodeFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysQrCodeFragment.java @@ -17,6 +17,8 @@ package org.sufficientlysecure.keychain.ui; +import com.google.zxing.integration.android.IntentResult; + import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -28,8 +30,9 @@ import android.view.ViewGroup; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; + import com.beardedhen.androidbootstrap.BootstrapButton; -import com.google.zxing.integration.android.IntentResult; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.util.IntentIntegratorSupportV4; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index 3e7e6d7ce..b9dcd2e21 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -38,7 +38,6 @@ import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.ui.adapter.TabsAdapter; -import org.sufficientlysecure.keychain.ui.dialog.DeleteKeyDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.ShareNfcDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.ShareQrCodeDialogFragment; import org.sufficientlysecure.keychain.util.Log; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index 691be5fa9..8670241f6 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -37,7 +37,6 @@ import com.beardedhen.androidbootstrap.BootstrapButton; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.helper.OtherHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.ProviderHelper; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java index 7d3166af9..8cb321109 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java @@ -32,7 +32,6 @@ import android.widget.LinearLayout.LayoutParams; import android.widget.TextView; import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.helper.OtherHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import java.util.ArrayList; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PagerTabStripAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PagerTabStripAdapter.java index 3e7952beb..4a3796f01 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PagerTabStripAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PagerTabStripAdapter.java @@ -21,10 +21,6 @@ import android.content.Context; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentPagerAdapter; -import android.support.v4.app.FragmentStatePagerAdapter; -import android.support.v4.app.FragmentTransaction; -import android.support.v4.view.ViewPager; -import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import java.util.ArrayList; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java index 9d60c1530..cf7ed670d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java @@ -20,7 +20,6 @@ package org.sufficientlysecure.keychain.ui.adapter; import android.content.Context; import android.content.res.ColorStateList; import android.database.Cursor; -import android.graphics.Color; import android.support.v4.widget.CursorAdapter; import android.text.format.DateFormat; import android.view.LayoutInflater; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 038f8507e..f4dad3edf 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -16,20 +16,6 @@ package org.sufficientlysecure.keychain.ui.widget; -import java.text.DateFormat; -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.TimeZone; -import java.util.Vector; - -import org.spongycastle.bcpg.sig.KeyFlags; -import org.spongycastle.openpgp.PGPKeyFlags; -import org.spongycastle.openpgp.PGPPublicKey; -import org.spongycastle.openpgp.PGPSecretKey; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; -import org.sufficientlysecure.keychain.util.Choice; import android.annotation.TargetApi; import android.app.DatePickerDialog; import android.app.Dialog; @@ -47,16 +33,23 @@ import android.widget.LinearLayout; import android.widget.TableLayout; import android.widget.TableRow; import android.widget.TextView; + import com.beardedhen.androidbootstrap.BootstrapButton; + +import org.spongycastle.bcpg.sig.KeyFlags; import org.spongycastle.openpgp.PGPPublicKey; import org.spongycastle.openpgp.PGPSecretKey; -import org.sufficientlysecure.keychain.Id; + import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.util.Choice; import java.text.DateFormat; -import java.util.*; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; +import java.util.Vector; public class KeyEditor extends LinearLayout implements Editor, OnClickListener { private PGPSecretKey mKey; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index e6b22957b..c04cc7674 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -16,23 +16,6 @@ package org.sufficientlysecure.keychain.ui.widget; -import java.util.ArrayList; -import java.util.List; -import java.util.Vector; - -import org.spongycastle.openpgp.PGPKeyFlags; -import org.spongycastle.openpgp.PGPSecretKey; -import org.sufficientlysecure.keychain.Id; -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.pgp.PgpConversionHelper; -import org.sufficientlysecure.keychain.service.KeychainIntentService; -import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; -import org.sufficientlysecure.keychain.service.PassphraseCacheService; -import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment; -import org.sufficientlysecure.keychain.ui.widget.Editor.EditorListener; -import org.sufficientlysecure.keychain.util.Choice; - -import android.app.AlertDialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; @@ -49,7 +32,10 @@ import android.view.ViewGroup; import android.widget.LinearLayout; import android.widget.TextView; import com.beardedhen.androidbootstrap.BootstrapButton; + +import org.spongycastle.openpgp.PGPKeyFlags; import org.spongycastle.openpgp.PGPSecretKey; + import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.PgpConversionHelper; @@ -61,7 +47,9 @@ import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment; import org.sufficientlysecure.keychain.ui.widget.Editor.EditorListener; import org.sufficientlysecure.keychain.util.Choice; - +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; public class SectionView extends LinearLayout implements OnClickListener, EditorListener, Editor { private LayoutInflater mInflater; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index cf0cb6d44..52a78f9ad 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -16,11 +16,6 @@ package org.sufficientlysecure.keychain.ui.widget; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.sufficientlysecure.keychain.R; -import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import android.content.Context; import android.text.Editable; import android.text.TextWatcher; @@ -31,8 +26,12 @@ import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.*; import com.beardedhen.androidbootstrap.BootstrapButton; + +import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.ContactHelper; +import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; +import java.util.regex.Matcher; public class UserIdEditor extends LinearLayout implements Editor, OnClickListener { private EditorListener mEditorListener = null; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java index b987e1533..e4171cfae 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java @@ -31,7 +31,6 @@ import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.pgp.PgpHelper; -import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; import java.io.ByteArrayOutputStream; @@ -43,8 +42,6 @@ import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; -import static org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry.getAlgorithmFromId; - public class HkpKeyServer extends KeyServer { private static class HttpError extends Exception { private static final long serialVersionUID = 1718783705229428893L; @@ -244,7 +241,7 @@ public class HkpKeyServer extends KeyServer { entry.setBitStrength(Integer.parseInt(matcher.group(3))); final int algorithmId = Integer.decode(matcher.group(2)); - entry.setAlgorithm(getAlgorithmFromId(algorithmId)); + entry.setAlgorithm(ImportKeysListEntry.getAlgorithmFromId(algorithmId)); // group 1 contains the full fingerprint (v4) or the long key id if available // see https://bitbucket.org/skskeyserver/sks-keyserver/pull-request/12/fixes-for-machine-readable-indexes/diff diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/IntentIntegratorSupportV4.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/IntentIntegratorSupportV4.java index b95b3ee6a..ae87deb31 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/IntentIntegratorSupportV4.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/IntentIntegratorSupportV4.java @@ -16,9 +16,10 @@ package org.sufficientlysecure.keychain.util; +import com.google.zxing.integration.android.IntentIntegrator; + import android.content.Intent; import android.support.v4.app.Fragment; -import com.google.zxing.integration.android.IntentIntegrator; /** * IntentIntegrator for the V4 Android compatibility package. diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/QrCodeUtils.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/QrCodeUtils.java index 8c3367bea..af9034aa7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/QrCodeUtils.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/QrCodeUtils.java @@ -18,14 +18,16 @@ package org.sufficientlysecure.keychain.util; -import android.graphics.Bitmap; -import android.graphics.Color; import com.google.zxing.BarcodeFormat; import com.google.zxing.EncodeHintType; import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix; import com.google.zxing.qrcode.QRCodeWriter; import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel; + +import android.graphics.Bitmap; +import android.graphics.Color; + import org.sufficientlysecure.keychain.Constants; import java.util.Hashtable; -- cgit v1.2.3 From 8e503bd263d451234f92b843987cb0d12cfbee3a Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 2 Apr 2014 01:36:13 +0200 Subject: Adjust copyright headers --- .../keychain/helper/Preferences.java | 2 +- .../keychain/ui/CertifyKeyActivity.java | 2 +- .../keychain/ui/ImportKeysActivity.java | 2 +- .../keychain/util/InputData.java | 2 ++ .../keychain/util/KeychainServiceListener.java | 22 +++++++++++++--------- .../keychain/util/PositionAwareInputStream.java | 2 ++ 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java index 515201b92..a9b773371 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java @@ -1,7 +1,7 @@ /* * Copyright (C) 2012 Dominik Schürmann * Copyright (C) 2010 Thialfihar - * + * * 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 diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java index 9e32fead0..f551ee5c1 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java @@ -1,7 +1,7 @@ /* * Copyright (C) 2014 Dominik Schürmann * Copyright (C) 2011 Senecaso - * + * * 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 diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java index 834509f53..b73510e38 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java @@ -1,7 +1,7 @@ /* * Copyright (C) 2012-2014 Dominik Schürmann * Copyright (C) 2011 Senecaso - * + * * 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 diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/InputData.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/InputData.java index 092c14e00..28cfa11f2 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/InputData.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/InputData.java @@ -1,4 +1,6 @@ /* + * Copyright (C) 2010-2014 Thialfihar + * * 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 diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/KeychainServiceListener.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/KeychainServiceListener.java index 14b2a2211..b205bd556 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/KeychainServiceListener.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/KeychainServiceListener.java @@ -1,16 +1,20 @@ /* - * 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 + * Copyright (C) 2014 Dominik Schürmann * - * http://www.apache.org/licenses/LICENSE-2.0 + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. * - * 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. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ + package org.sufficientlysecure.keychain.util; public interface KeychainServiceListener { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/PositionAwareInputStream.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/PositionAwareInputStream.java index a783d7820..4fcd3047f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/PositionAwareInputStream.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/PositionAwareInputStream.java @@ -1,4 +1,6 @@ /* + * Copyright (C) 2010-2014 Thialfihar + * * 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 -- cgit v1.2.3 From dd4a1e3f5239cc35a1abdc625238361350155191 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 2 Apr 2014 01:43:40 +0200 Subject: Trivial spacing changes to conform to style guide --- .../sufficientlysecure/keychain/KeychainApplication.java | 4 ++-- .../keychain/compatibility/ClipboardReflection.java | 4 ++-- .../sufficientlysecure/keychain/helper/ExportHelper.java | 2 +- .../keychain/pgp/PgpConversionHelper.java | 10 ++++++---- .../sufficientlysecure/keychain/pgp/PgpKeyOperation.java | 10 +++++----- .../keychain/provider/ProviderHelper.java | 5 +++-- .../keychain/remote/ui/RemoteServiceActivity.java | 2 +- .../keychain/service/KeychainIntentService.java | 2 +- .../keychain/service/SaveKeyringParcel.java | 16 ++++++++-------- .../keychain/ui/CertifyKeyActivity.java | 2 +- .../keychain/ui/DecryptFileFragment.java | 2 +- .../sufficientlysecure/keychain/ui/DrawerActivity.java | 10 +++++----- .../sufficientlysecure/keychain/ui/EditKeyActivity.java | 2 +- .../keychain/ui/EncryptFileFragment.java | 5 +++-- .../keychain/ui/ImportKeysClipboardFragment.java | 2 +- .../sufficientlysecure/keychain/ui/KeyListFragment.java | 2 +- .../keychain/ui/SelectSecretKeyFragment.java | 3 ++- .../keychain/ui/SelectSecretKeyLayoutFragment.java | 10 +++++----- .../sufficientlysecure/keychain/ui/ViewKeyActivity.java | 2 +- .../keychain/ui/adapter/ViewKeyKeysAdapter.java | 3 +-- .../keychain/ui/adapter/ViewKeyUserIdsAdapter.java | 14 ++++++++------ .../keychain/ui/dialog/CreateKeyDialogFragment.java | 7 ++++--- .../keychain/ui/dialog/DeleteKeyDialogFragment.java | 9 ++------- .../keychain/ui/widget/FoldableLinearLayout.java | 14 +++++++------- .../sufficientlysecure/keychain/ui/widget/KeyEditor.java | 16 ++++++++-------- .../keychain/ui/widget/SectionView.java | 4 ++-- .../keychain/ui/widget/UserIdEditor.java | 6 +++--- .../keychain/util/IterableIterator.java | 2 +- .../sufficientlysecure/keychain/util/ProgressScaler.java | 2 +- 29 files changed, 87 insertions(+), 85 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java index e4ce6c373..9b80e76f3 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/KeychainApplication.java @@ -41,14 +41,14 @@ public class KeychainApplication extends Application { /* * Sets Bouncy (Spongy) Castle as preferred security provider - * + * * insertProviderAt() position starts from 1 */ Security.insertProviderAt(new BouncyCastleProvider(), 1); /* * apply RNG fixes - * + * * among other things, executes Security.insertProviderAt(new * LinuxPRNGSecureRandomProvider(), 1) for Android <= SDK 17 */ diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/compatibility/ClipboardReflection.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/compatibility/ClipboardReflection.java index 10bb8cf5d..1cac5762d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/compatibility/ClipboardReflection.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/compatibility/ClipboardReflection.java @@ -30,7 +30,7 @@ public class ClipboardReflection { /** * Wrapper around ClipboardManager based on Android version using Reflection API - * + * * @param context * @param text */ @@ -57,7 +57,7 @@ public class ClipboardReflection { /** * Wrapper around ClipboardManager based on Android version using Reflection API - * + * * @param context */ public static CharSequence getClipboardText(Context context) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java index 00a62ce58..43fdc7751 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/ExportHelper.java @@ -75,7 +75,7 @@ public class ExportHelper { int type = keyType; mExportFilename = data.getString(FileDialogFragment.MESSAGE_DATA_FILENAME); - if( data.getBoolean(FileDialogFragment.MESSAGE_DATA_CHECKED) ) { + if (data.getBoolean(FileDialogFragment.MESSAGE_DATA_CHECKED)) { type = Id.type.public_secret_key; } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java index 1f8dec7a1..7c25c2c2a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpConversionHelper.java @@ -65,14 +65,16 @@ public class PgpConversionHelper { try { while ((obj = factory.nextObject()) != null) { PGPSecretKey secKey = null; - if(obj instanceof PGPSecretKey) { - if ((secKey = (PGPSecretKey)obj ) == null) { + if (obj instanceof PGPSecretKey) { + secKey = (PGPSecretKey) obj; + if (secKey == null) { Log.e(Constants.TAG, "No keys given!"); } keys.add(secKey); - } else if(obj instanceof PGPSecretKeyRing) { //master keys are sent as keyrings + } else if (obj instanceof PGPSecretKeyRing) { //master keys are sent as keyrings PGPSecretKeyRing keyRing = null; - if ((keyRing = (PGPSecretKeyRing)obj) == null) { + keyRing = (PGPSecretKeyRing) obj; + if (keyRing == null) { Log.e(Constants.TAG, "No keys given!"); } @SuppressWarnings("unchecked") diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index c91a932c5..d4fba68ff 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -219,7 +219,7 @@ public class PgpKeyOperation { } - private Pair buildNewSecretKey( + private Pair buildNewSecretKey( ArrayList userIds, ArrayList keys, ArrayList keysExpiryDates, ArrayList keysUsages, @@ -359,11 +359,11 @@ public class PgpKeyOperation { PGPSecretKeyRing secretKeyRing = keyGen.generateSecretKeyRing(); PGPPublicKeyRing publicKeyRing = keyGen.generatePublicKeyRing(); - return new Pair(secretKeyRing, publicKeyRing); + return new Pair(secretKeyRing, publicKeyRing); } - public Pair buildSecretKey (PGPSecretKeyRing mKR, + public Pair buildSecretKey(PGPSecretKeyRing mKR, PGPPublicKeyRing pKR, SaveKeyringParcel saveParcel) throws PgpGeneralMsgIdException, PGPException, SignatureException, IOException { @@ -676,7 +676,7 @@ public class PgpKeyOperation { */ - return new Pair(mKR, pKR); + return new Pair(mKR, pKR); } @@ -723,7 +723,7 @@ public class PgpKeyOperation { } // fetch public key ring, add the certification and return it - for(String userId : new IterableIterator(userIds.iterator())) { + for (String userId : new IterableIterator(userIds.iterator())) { PGPSignature sig = signatureGenerator.generateCertification(userId, publicKey); publicKey = PGPPublicKey.addCertification(publicKey, userId, sig); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java index 13dc2af2b..c88e3e22f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -508,13 +508,14 @@ public class ProviderHelper { */ public static boolean getMasterKeyCanCertify(Context context, Uri queryUri) { - String[] projection = new String[]{ + String[] projection = new String[] { KeyRings.MASTER_KEY_ID, "(SELECT COUNT(sign_keys." + Keys._ID + ") FROM " + Tables.KEYS + " AS sign_keys WHERE sign_keys." + Keys.KEY_RING_ROW_ID + " = " + KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings._ID + " AND sign_keys." + Keys.CAN_CERTIFY + " = '1' AND " + Keys.IS_MASTER_KEY - + " = 1) AS sign",}; + + " = 1) AS sign", + }; ContentResolver cr = context.getContentResolver(); Cursor cursor = cr.query(queryUri, projection, null, null, null); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java index a894da448..b2ab75cea 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/RemoteServiceActivity.java @@ -95,7 +95,7 @@ public class RemoteServiceActivity extends ActionBarActivity { if (ACTION_REGISTER.equals(action)) { final String packageName = extras.getString(EXTRA_PACKAGE_NAME); final byte[] packageSignature = extras.getByteArray(EXTRA_PACKAGE_SIGNATURE); - Log.d(Constants.TAG, "ACTION_REGISTER packageName: "+packageName); + Log.d(Constants.TAG, "ACTION_REGISTER packageName: " + packageName); // Inflate a "Done"/"Cancel" custom action bar view ActionBarHelper.setTwoButtonView(getSupportActionBar(), diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index bdd50c98d..14beae40c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -818,7 +818,7 @@ public class KeychainIntentService extends IntentService return; } // contextualize the exception, if necessary - if(e instanceof PgpGeneralMsgIdException) { + if (e instanceof PgpGeneralMsgIdException) { e = ((PgpGeneralMsgIdException) e).getContextualized(this); } Log.e(Constants.TAG, "ApgService Exception: ", e); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java index b7ae4e1f1..cc0f94b9b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java @@ -46,20 +46,20 @@ public class SaveKeyringParcel implements Parcelable { public SaveKeyringParcel() {} - private SaveKeyringParcel(Parcel source) - { - userIDs = (ArrayList)source.readSerializable(); - originalIDs = (ArrayList)source.readSerializable(); - deletedIDs = (ArrayList)source.readSerializable(); + private SaveKeyringParcel(Parcel source) { + userIDs = (ArrayList) source.readSerializable(); + originalIDs = (ArrayList) source.readSerializable(); + deletedIDs = (ArrayList) source.readSerializable(); newIDs = source.createBooleanArray(); primaryIDChanged = source.readByte() != 0; moddedKeys = source.createBooleanArray(); byte[] tmp = source.createByteArray(); - if (tmp == null) + if (tmp == null) { deletedKeys = null; - else + } else { deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(tmp); - keysExpiryDates = (ArrayList)source.readSerializable(); + } + keysExpiryDates = (ArrayList) source.readSerializable(); keysUsages = source.readArrayList(Integer.class.getClassLoader()); newPassPhrase = source.readString(); oldPassPhrase = source.readString(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java index f551ee5c1..d041bc35e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java @@ -306,7 +306,7 @@ public class CertifyKeyActivity extends ActionBarActivity implements // Bail out if there is not at least one user id selected ArrayList userIds = mUserIdsAdapter.getSelectedUserIds(); - if(userIds.isEmpty()) { + if (userIds.isEmpty()) { Toast.makeText(CertifyKeyActivity.this, "No User IDs to sign selected!", Toast.LENGTH_SHORT).show(); return; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java index ed6366353..67cf8d3e3 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java @@ -205,7 +205,7 @@ public class DecryptFileFragment extends DecryptFragment { } else { AppMsg.makeText(getActivity(), R.string.decryption_successful, AppMsg.STYLE_INFO).show(); - + if (mDeleteAfter.isChecked()) { // Create and show dialog to delete original file DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java index f01e67449..e5a8fa8bc 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java @@ -58,7 +58,7 @@ public class DrawerActivity extends ActionBarActivity { // if the left margin of the loaded layout is close to the // one used in tablets then set drawer as open and locked - if( Math.abs(leftMarginLoaded - leftMarginInTablets) < errorInMarginAllowed) { + if (Math.abs(leftMarginLoaded - leftMarginInTablets) < errorInMarginAllowed) { mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerList); mDrawerLayout.setScrimColor(Color.TRANSPARENT); mIsDrawerLocked = true; @@ -82,7 +82,7 @@ public class DrawerActivity extends ActionBarActivity { // enable ActionBar app icon to behave as action to toggle nav drawer // if the drawer is not locked - if ( !mIsDrawerLocked ) { + if (!mIsDrawerLocked) { getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); } @@ -109,7 +109,7 @@ public class DrawerActivity extends ActionBarActivity { } }; - if ( !mIsDrawerLocked ) { + if (!mIsDrawerLocked) { mDrawerLayout.setDrawerListener(mDrawerToggle); } else { // If the drawer is locked open make it un-focusable @@ -218,9 +218,9 @@ public class DrawerActivity extends ActionBarActivity { // setTitle(mDrawerTitles[position]); // If drawer isn't locked just close the drawer and // it will move to the selected item by itself (via drawer toggle listener) - if ( !mIsDrawerLocked ) { + if (!mIsDrawerLocked) { mDrawerLayout.closeDrawer(mDrawerList); - // else move to the selected item yourself + // else move to the selected item yourself } else { callIntentForDrawerItem(mSelectedItem); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index bab1e6f5f..8ef4631dc 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -339,7 +339,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener Toast.makeText(this, R.string.error_save_first, Toast.LENGTH_LONG).show(); } else { long masterKeyId = ProviderHelper.getMasterKeyId(this, mDataUri); - long[] ids = new long[]{masterKeyId}; + long[] ids = new long[] {masterKeyId}; mExportHelper.showExportKeysDialog(ids, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC, null); return true; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java index fb727d297..cee7dae87 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java @@ -112,7 +112,7 @@ public class EncryptFileFragment extends Fragment { }); mFileCompression = (Spinner) view.findViewById(R.id.fileCompression); - Choice[] choices = new Choice[]{ + Choice[] choices = new Choice[] { new Choice(Id.choice.compression.none, getString(R.string.choice_none) + " (" + getString(R.string.compression_fast) + ")"), new Choice(Id.choice.compression.zip, "ZIP (" @@ -120,7 +120,8 @@ public class EncryptFileFragment extends Fragment { new Choice(Id.choice.compression.zlib, "ZLIB (" + getString(R.string.compression_fast) + ")"), new Choice(Id.choice.compression.bzip2, "BZIP2 (" - + getString(R.string.compression_very_slow) + ")"),}; + + getString(R.string.compression_very_slow) + ")"), + }; ArrayAdapter adapter = new ArrayAdapter(getActivity(), android.R.layout.simple_spinner_item, choices); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysClipboardFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysClipboardFragment.java index e53762580..28e2091a9 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysClipboardFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysClipboardFragment.java @@ -65,7 +65,7 @@ public class ImportKeysClipboardFragment extends Fragment { String sendText = ""; if (clipboardText != null) { sendText = clipboardText.toString(); - if(sendText.toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) { + if (sendText.toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) { mImportActivity.loadFromFingerprintUri(null, Uri.parse(sendText)); return; } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 957c822d2..6da8a0262 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -185,7 +185,7 @@ public class KeyListFragment extends Fragment } case R.id.menu_key_list_multi_export: { ids = mStickyList.getWrappedList().getCheckedItemIds(); - long[] masterKeyIds = new long[2*ids.length]; + long[] masterKeyIds = new long[2 * ids.length]; ArrayList allPubRowIds = ProviderHelper.getPublicKeyRingsRowIds(getActivity()); for (int i = 0; i < ids.length; i++) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java index 2efa7d33a..1f0a1a197 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java @@ -141,7 +141,8 @@ public class SelectSecretKeyFragment extends ListFragment implements + Keys.IS_REVOKED + " = '0' AND valid_keys." + Keys.CAN_SIGN + " = '1' AND valid_keys." + Keys.CREATION + " <= '" + now + "' AND " + "(valid_keys." + Keys.EXPIRY + " IS NULL OR valid_keys." + Keys.EXPIRY - + " >= '" + now + "')) AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID,}; + + " >= '" + now + "')) AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID, + }; String orderBy = UserIds.USER_ID + " ASC"; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java index d1ba431d6..f0704bb0f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java @@ -53,12 +53,12 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan private SelectSecretKeyCallback mCallback; - final String[] PROJECTION = new String[]{ - KeychainContract.UserIds.USER_ID, - KeychainContract.KeyRings.MASTER_KEY_ID + private static final String[] PROJECTION = new String[] { + KeychainContract.UserIds.USER_ID, + KeychainContract.KeyRings.MASTER_KEY_ID, }; - final int INDEX_USER_ID = 0; - final int INDEX_MASTER_KEY_ID = 1; + private static final int INDEX_USER_ID = 0; + private static final int INDEX_MASTER_KEY_ID = 1; public interface SelectSecretKeyCallback { void onKeySelected(long secretKeyId); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index b9dcd2e21..b86c20880 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -125,7 +125,7 @@ public class ViewKeyActivity extends ActionBarActivity { case R.id.menu_key_view_export_file: long masterKeyId = ProviderHelper.getPublicMasterKeyId(this, Long.valueOf(mDataUri.getLastPathSegment())); - long[] ids = new long[]{masterKeyId}; + long[] ids = new long[] {masterKeyId}; mExportHelper.showExportKeysDialog(ids, Id.type.public_key, Constants.Path.APP_DIR_FILE_PUB, null); return true; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java index cf7ed670d..99a4d38e9 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java @@ -148,8 +148,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter { DateFormat.getDateFormat(context).format(expiryDate) + ")"); keyExpiry.setVisibility(View.VISIBLE); - } - else { + } else { keyExpiry.setVisibility(View.GONE); } // if key is expired or revoked, strike through text diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java index 61572b9ce..21a150606 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java @@ -55,14 +55,15 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter { @Override public Cursor swapCursor(Cursor newCursor) { initIndex(newCursor); - if(mCheckStates != null) { + if (mCheckStates != null) { mCheckStates.clear(); - if(newCursor != null) { + if (newCursor != null) { int count = newCursor.getCount(); mCheckStates.ensureCapacity(count); // initialize to true (use case knowledge: we usually want to sign all uids) - for(int i = 0; i < count; i++) + for (int i = 0; i < count; i++) { mCheckStates.add(true); + } } } @@ -100,8 +101,9 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter { vAddress.setText(userId[1]); // don't care further if checkboxes aren't shown - if(mCheckStates == null) + if (mCheckStates == null) { return; + } final CheckBox vCheckBox = (CheckBox) view.findViewById(R.id.checkBox); final int position = cursor.getPosition(); @@ -124,8 +126,8 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter { public ArrayList getSelectedUserIds() { ArrayList result = new ArrayList(); - for(int i = 0; i < mCheckStates.size(); i++) { - if(mCheckStates.get(i)) { + for (int i = 0; i < mCheckStates.size(); i++) { + if (mCheckStates.get(i)) { mCursor.moveToPosition(i); result.add(mCursor.getString(mIndexUserId)); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java index ffb45afc5..ad558a81e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/CreateKeyDialogFragment.java @@ -138,9 +138,10 @@ public class CreateKeyDialogFragment extends DialogFragment { final AdapterView.OnItemSelectedListener weakRsaListener = new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { - final Choice selectedAlgorithm = (Choice)algorithm.getSelectedItem(); - final int selectedKeySize = Integer.parseInt((String)keySize.getSelectedItem()); - final boolean isWeakRsa = (selectedAlgorithm.getId() == Id.choice.algorithm.rsa && selectedKeySize <= 1024); + final Choice selectedAlgorithm = (Choice) algorithm.getSelectedItem(); + final int selectedKeySize = Integer.parseInt((String) keySize.getSelectedItem()); + final boolean isWeakRsa = (selectedAlgorithm.getId() == Id.choice.algorithm.rsa && + selectedKeySize <= 1024); alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(!isWeakRsa); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java index 3ff88aa2b..60dea2a41 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java @@ -184,12 +184,10 @@ public class DeleteKeyDialogFragment extends DialogFragment { if (cursor == null || cursor.getCount() == 0 || !checkDeleteSecret.isChecked()) { isSuccessfullyDeleted = true; } - } finally { if (cursor != null) { cursor.close(); } - } dismiss(); @@ -200,9 +198,7 @@ public class DeleteKeyDialogFragment extends DialogFragment { sendMessageToHandler(MESSAGE_ERROR, null); } } - - } - ); + }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override @@ -232,5 +228,4 @@ public class DeleteKeyDialogFragment extends DialogFragment { Log.w(Constants.TAG, "Messenger is null!", e); } } - -} \ No newline at end of file +} diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FoldableLinearLayout.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FoldableLinearLayout.java index f9a5b92f3..6b2f3bf06 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FoldableLinearLayout.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/FoldableLinearLayout.java @@ -82,7 +82,7 @@ public class FoldableLinearLayout extends LinearLayout { * @param attrs */ private void processAttributes(Context context, AttributeSet attrs) { - if(attrs != null) { + if (attrs != null) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FoldableLinearLayout, 0, 0); mFoldedIconName = a.getString(R.styleable.FoldableLinearLayout_foldedIcon); @@ -102,7 +102,7 @@ public class FoldableLinearLayout extends LinearLayout { protected void onFinishInflate() { // if the migration has already happened // there is no need to move any children - if(!mHasMigrated) { + if (!mHasMigrated) { migrateChildrenToContainer(); mHasMigrated = true; } @@ -120,10 +120,10 @@ public class FoldableLinearLayout extends LinearLayout { int childNum = getChildCount(); View[] children = new View[childNum]; - for(int i = 0; i < childNum; i++) { + for (int i = 0; i < childNum; i++) { children[i] = getChildAt(i); } - if(children[0].getId() == R.id.foldableControl) { + if (children[0].getId() == R.id.foldableControl) { } @@ -131,14 +131,14 @@ public class FoldableLinearLayout extends LinearLayout { detachAllViewsFromParent(); // Inflate the inner foldable_linearlayout.xml - LayoutInflater inflator = (LayoutInflater)getContext().getSystemService( + LayoutInflater inflator = (LayoutInflater) getContext().getSystemService( Context.LAYOUT_INFLATER_SERVICE); mFoldableLayout = inflator.inflate(R.layout.foldable_linearlayout, this, true); mFoldableContainer = (LinearLayout) mFoldableLayout.findViewById(R.id.foldableContainer); // Push previously collected children into foldableContainer. - for(int i = 0; i < childNum; i++) { + for (int i = 0; i < childNum; i++) { addView(children[i]); } } @@ -196,7 +196,7 @@ public class FoldableLinearLayout extends LinearLayout { */ @Override public void addView(View child) { - if(mFoldableContainer != null) { + if (mFoldableContainer != null) { mFoldableContainer.addView(child); } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index f4dad3edf..1f5b13c83 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -148,7 +148,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { date = new GregorianCalendar(TimeZone.getTimeZone("UTC")); } /* - * Using custom DatePickerDialog which overrides the setTitle because + * Using custom DatePickerDialog which overrides the setTitle because * the DatePickerDialog title is buggy (unix warparound bug). * See: https://code.google.com/p/android/issues/detail?id=49066 */ @@ -221,23 +221,23 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { boolean isDSAKey = (key.getPublicKey().getAlgorithm() == PGPPublicKey.DSA); if (isElGamalKey) { mChkSign.setVisibility(View.INVISIBLE); - TableLayout table = (TableLayout)findViewById(R.id.table_keylayout); - TableRow row = (TableRow)findViewById(R.id.row_sign); + TableLayout table = (TableLayout) findViewById(R.id.table_keylayout); + TableRow row = (TableRow) findViewById(R.id.row_sign); table.removeView(row); } if (isDSAKey) { mChkEncrypt.setVisibility(View.INVISIBLE); - TableLayout table = (TableLayout)findViewById(R.id.table_keylayout); - TableRow row = (TableRow)findViewById(R.id.row_encrypt); + TableLayout table = (TableLayout) findViewById(R.id.table_keylayout); + TableRow row = (TableRow) findViewById(R.id.row_encrypt); table.removeView(row); } if (!mIsMasterKey) { mChkCertify.setVisibility(View.INVISIBLE); - TableLayout table = (TableLayout)findViewById(R.id.table_keylayout); - TableRow row = (TableRow)findViewById(R.id.row_certify); + TableLayout table = (TableLayout) findViewById(R.id.table_keylayout); + TableRow row = (TableRow) findViewById(R.id.row_certify); table.removeView(row); } else { - TextView mLabelUsage2= (TextView) findViewById(R.id.label_usage2); + TextView mLabelUsage2 = (TextView) findViewById(R.id.label_usage2); mLabelUsage2.setVisibility(View.INVISIBLE); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index c04cc7674..272f43915 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -195,8 +195,8 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor for (int i = 0; i < mEditors.getChildCount(); ++i) { Editor editor = (Editor) mEditors.getChildAt(i); if (mType == Id.type.user_id) { - if(((UserIdEditor)editor).getIsOriginallyMainUserID()) { - return ((UserIdEditor)editor).getOriginalID(); + if (((UserIdEditor) editor).getIsOriginallyMainUserID()) { + return ((UserIdEditor) editor).getOriginalID(); } } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index 52a78f9ad..71f5f0d86 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -239,9 +239,9 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene @Override public boolean needsSaving() { boolean retval = false; //(mOriginallyMainUserID != isMainUserId()); - retval |= !(mOriginalName.equals( ("" + mName.getText()).trim() ) ); - retval |= !(mOriginalEmail.equals( ("" + mEmail.getText()).trim() ) ); - retval |= !(mOriginalComment.equals( ("" + mComment.getText()).trim() ) ); + retval |= !(mOriginalName.equals(("" + mName.getText()).trim())); + retval |= !(mOriginalEmail.equals(("" + mEmail.getText()).trim())); + retval |= !(mOriginalComment.equals(("" + mComment.getText()).trim())); retval |= mIsNewId; return retval; } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/IterableIterator.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/IterableIterator.java index 40105df4f..3af674526 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/IterableIterator.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/IterableIterator.java @@ -24,7 +24,7 @@ public class IterableIterator implements Iterable { public IterableIterator(Iterator iter, boolean failsafe) { mIter = iter; - if(failsafe && mIter == null) { + if (failsafe && mIter == null) { // is there a better way? mIter = new ArrayList().iterator(); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/ProgressScaler.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/ProgressScaler.java index 15b70e22e..23961c05f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/ProgressScaler.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/ProgressScaler.java @@ -36,7 +36,7 @@ public class ProgressScaler implements ProgressDialogUpdater { * Set progressDialogUpdater of ProgressDialog by sending message to handler on UI thread */ public void setProgress(String message, int progress, int max) { - mWrapped.setProgress(message, mFrom+ progress*(mTo-mFrom)/max, mMax); + mWrapped.setProgress(message, mFrom + progress * (mTo - mFrom) / max, mMax); } public void setProgress(int resourceId, int progress, int max) { -- cgit v1.2.3 From d5983b324f107ef274d1af774787d0d5acf50131 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 2 Apr 2014 01:51:02 +0200 Subject: Adjust variable/member naming to conform to style guide In some cases change member accessibility, so the naming matches. Also, some key words were reordered to comply with JLS suggestions. --- .../keychain/helper/Preferences.java | 8 ++-- .../pgp/exception/PgpGeneralMsgIdException.java | 10 ++--- .../keychain/ui/EncryptAsymmetricFragment.java | 4 +- .../keychain/ui/PreferencesActivity.java | 44 +++++++++---------- .../keychain/ui/adapter/ImportKeysAdapter.java | 12 ++--- .../keychain/ui/adapter/ImportKeysListEntry.java | 2 +- .../keychain/ui/adapter/PagerTabStripAdapter.java | 6 +-- .../keychain/ui/adapter/TabsAdapter.java | 4 +- .../keychain/ui/adapter/ViewKeyUserIdsAdapter.java | 2 +- .../ui/dialog/DeleteKeyDialogFragment.java | 51 ++++++++++++---------- .../keychain/ui/widget/SectionView.java | 18 ++++---- 11 files changed, 82 insertions(+), 79 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java index a9b773371..13b1df4d4 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java @@ -30,7 +30,7 @@ import java.util.Vector; * Singleton Implementation of a Preference Helper */ public class Preferences { - private static Preferences mPreferences; + private static Preferences sPreferences; private SharedPreferences mSharedPreferences; public static synchronized Preferences getPreferences(Context context) { @@ -38,10 +38,10 @@ public class Preferences { } public static synchronized Preferences getPreferences(Context context, boolean forceNew) { - if (mPreferences == null || forceNew) { - mPreferences = new Preferences(context); + if (sPreferences == null || forceNew) { + sPreferences = new Preferences(context); } - return mPreferences; + return sPreferences; } private Preferences(Context context) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/exception/PgpGeneralMsgIdException.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/exception/PgpGeneralMsgIdException.java index 3df85cfc8..caa7842db 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/exception/PgpGeneralMsgIdException.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/exception/PgpGeneralMsgIdException.java @@ -22,14 +22,14 @@ import android.content.Context; public class PgpGeneralMsgIdException extends Exception { static final long serialVersionUID = 0xf812773343L; - private final int msgId; + private final int mMessageId; - public PgpGeneralMsgIdException(int msgId) { - super("msg[" + msgId + "]"); - this.msgId = msgId; + public PgpGeneralMsgIdException(int messageId) { + super("msg[" + messageId + "]"); + mMessageId = messageId; } public PgpGeneralException getContextualized(Context context) { - return new PgpGeneralException(context.getString(msgId), this); + return new PgpGeneralException(context.getString(mMessageId), this); } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java index 5b7f9e4cc..4387f3d53 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java @@ -264,8 +264,8 @@ public class EncryptAsymmetricFragment extends Fragment { case RESULT_CODE_SECRET_KEYS: { if (resultCode == Activity.RESULT_OK) { - Uri uri_master_key = data.getData(); - setSignatureKeyId(Long.valueOf(uri_master_key.getLastPathSegment())); + Uri uriMasterKey = data.getData(); + setSignatureKeyId(Long.valueOf(uriMasterKey.getLastPathSegment())); } else { setSignatureKeyId(Id.key.none); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java index 04179cb80..c541e8a23 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java @@ -38,11 +38,11 @@ public class PreferencesActivity extends PreferenceActivity { public static final String ACTION_PREFS_ADV = "org.sufficientlysecure.keychain.ui.PREFS_ADV"; private PreferenceScreen mKeyServerPreference = null; - private static Preferences mPreferences; + private static Preferences sPreferences; @Override protected void onCreate(Bundle savedInstanceState) { - mPreferences = Preferences.getPreferences(this); + sPreferences = Preferences.getPreferences(this); super.onCreate(savedInstanceState); // final ActionBar actionBar = getSupportActionBar(); @@ -59,7 +59,7 @@ public class PreferencesActivity extends PreferenceActivity { (IntegerListPreference) findPreference(Constants.Pref.PASS_PHRASE_CACHE_TTL)); mKeyServerPreference = (PreferenceScreen) findPreference(Constants.Pref.KEY_SERVERS); - String servers[] = mPreferences.getKeyServers(); + String servers[] = sPreferences.getKeyServers(); mKeyServerPreference.setSummary(getResources().getQuantityString(R.plurals.n_key_servers, servers.length, servers.length)); mKeyServerPreference @@ -68,7 +68,7 @@ public class PreferencesActivity extends PreferenceActivity { Intent intent = new Intent(PreferencesActivity.this, PreferencesKeyServerActivity.class); intent.putExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS, - mPreferences.getKeyServers()); + sPreferences.getKeyServers()); startActivityForResult(intent, Id.request.key_server_preference); return false; } @@ -125,7 +125,7 @@ public class PreferencesActivity extends PreferenceActivity { } String servers[] = data .getStringArrayExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS); - mPreferences.setKeyServers(servers); + sPreferences.setKeyServers(servers); mKeyServerPreference.setSummary(getResources().getQuantityString( R.plurals.n_key_servers, servers.length, servers.length)); break; @@ -163,7 +163,7 @@ public class PreferencesActivity extends PreferenceActivity { (IntegerListPreference) findPreference(Constants.Pref.PASS_PHRASE_CACHE_TTL)); mKeyServerPreference = (PreferenceScreen) findPreference(Constants.Pref.KEY_SERVERS); - String servers[] = mPreferences.getKeyServers(); + String servers[] = sPreferences.getKeyServers(); mKeyServerPreference.setSummary(getResources().getQuantityString(R.plurals.n_key_servers, servers.length, servers.length)); mKeyServerPreference @@ -172,7 +172,7 @@ public class PreferencesActivity extends PreferenceActivity { Intent intent = new Intent(getActivity(), PreferencesKeyServerActivity.class); intent.putExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS, - mPreferences.getKeyServers()); + sPreferences.getKeyServers()); startActivityForResult(intent, Id.request.key_server_preference); return false; } @@ -188,7 +188,7 @@ public class PreferencesActivity extends PreferenceActivity { } String servers[] = data .getStringArrayExtra(PreferencesKeyServerActivity.EXTRA_KEY_SERVERS); - mPreferences.setKeyServers(servers); + sPreferences.setKeyServers(servers); mKeyServerPreference.setSummary(getResources().getQuantityString( R.plurals.n_key_servers, servers.length, servers.length)); break; @@ -256,14 +256,14 @@ public class PreferencesActivity extends PreferenceActivity { } private static void initializePassPassPhraceCacheTtl(final IntegerListPreference mPassphraseCacheTtl) { - mPassphraseCacheTtl.setValue("" + mPreferences.getPassPhraseCacheTtl()); + mPassphraseCacheTtl.setValue("" + sPreferences.getPassPhraseCacheTtl()); mPassphraseCacheTtl.setSummary(mPassphraseCacheTtl.getEntry()); mPassphraseCacheTtl .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { mPassphraseCacheTtl.setValue(newValue.toString()); mPassphraseCacheTtl.setSummary(mPassphraseCacheTtl.getEntry()); - mPreferences.setPassPhraseCacheTtl(Integer.parseInt(newValue.toString())); + sPreferences.setPassPhraseCacheTtl(Integer.parseInt(newValue.toString())); return false; } }); @@ -282,14 +282,14 @@ public class PreferencesActivity extends PreferenceActivity { } mEncryptionAlgorithm.setEntries(entries); mEncryptionAlgorithm.setEntryValues(values); - mEncryptionAlgorithm.setValue("" + mPreferences.getDefaultEncryptionAlgorithm()); + mEncryptionAlgorithm.setValue("" + sPreferences.getDefaultEncryptionAlgorithm()); mEncryptionAlgorithm.setSummary(mEncryptionAlgorithm.getEntry()); mEncryptionAlgorithm .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { mEncryptionAlgorithm.setValue(newValue.toString()); mEncryptionAlgorithm.setSummary(mEncryptionAlgorithm.getEntry()); - mPreferences.setDefaultEncryptionAlgorithm(Integer.parseInt(newValue + sPreferences.setDefaultEncryptionAlgorithm(Integer.parseInt(newValue .toString())); return false; } @@ -309,13 +309,13 @@ public class PreferencesActivity extends PreferenceActivity { } mHashAlgorithm.setEntries(entries); mHashAlgorithm.setEntryValues(values); - mHashAlgorithm.setValue("" + mPreferences.getDefaultHashAlgorithm()); + mHashAlgorithm.setValue("" + sPreferences.getDefaultHashAlgorithm()); mHashAlgorithm.setSummary(mHashAlgorithm.getEntry()); mHashAlgorithm.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { mHashAlgorithm.setValue(newValue.toString()); mHashAlgorithm.setSummary(mHashAlgorithm.getEntry()); - mPreferences.setDefaultHashAlgorithm(Integer.parseInt(newValue.toString())); + sPreferences.setDefaultHashAlgorithm(Integer.parseInt(newValue.toString())); return false; } }); @@ -326,14 +326,14 @@ public class PreferencesActivity extends PreferenceActivity { int[] valueIds, String[] entries, String[] values) { mMessageCompression.setEntries(entries); mMessageCompression.setEntryValues(values); - mMessageCompression.setValue("" + mPreferences.getDefaultMessageCompression()); + mMessageCompression.setValue("" + sPreferences.getDefaultMessageCompression()); mMessageCompression.setSummary(mMessageCompression.getEntry()); mMessageCompression .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { mMessageCompression.setValue(newValue.toString()); mMessageCompression.setSummary(mMessageCompression.getEntry()); - mPreferences.setDefaultMessageCompression(Integer.parseInt(newValue + sPreferences.setDefaultMessageCompression(Integer.parseInt(newValue .toString())); return false; } @@ -344,36 +344,36 @@ public class PreferencesActivity extends PreferenceActivity { (final IntegerListPreference mFileCompression, String[] entries, String[] values) { mFileCompression.setEntries(entries); mFileCompression.setEntryValues(values); - mFileCompression.setValue("" + mPreferences.getDefaultFileCompression()); + mFileCompression.setValue("" + sPreferences.getDefaultFileCompression()); mFileCompression.setSummary(mFileCompression.getEntry()); mFileCompression.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { mFileCompression.setValue(newValue.toString()); mFileCompression.setSummary(mFileCompression.getEntry()); - mPreferences.setDefaultFileCompression(Integer.parseInt(newValue.toString())); + sPreferences.setDefaultFileCompression(Integer.parseInt(newValue.toString())); return false; } }); } private static void initializeAsciiArmour(final CheckBoxPreference mAsciiArmour) { - mAsciiArmour.setChecked(mPreferences.getDefaultAsciiArmour()); + mAsciiArmour.setChecked(sPreferences.getDefaultAsciiArmour()); mAsciiArmour.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { mAsciiArmour.setChecked((Boolean) newValue); - mPreferences.setDefaultAsciiArmour((Boolean) newValue); + sPreferences.setDefaultAsciiArmour((Boolean) newValue); return false; } }); } private static void initializeForceV3Signatures(final CheckBoxPreference mForceV3Signatures) { - mForceV3Signatures.setChecked(mPreferences.getForceV3Signatures()); + mForceV3Signatures.setChecked(sPreferences.getForceV3Signatures()); mForceV3Signatures .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { mForceV3Signatures.setChecked((Boolean) newValue); - mPreferences.setForceV3Signatures((Boolean) newValue); + sPreferences.setForceV3Signatures((Boolean) newValue); return false; } }); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java index 8cb321109..f322ea980 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysAdapter.java @@ -44,12 +44,12 @@ public class ImportKeysAdapter extends ArrayAdapter { protected List mData; static class ViewHolder { - private TextView mainUserId; - private TextView mainUserIdRest; - private TextView keyId; - private TextView fingerprint; - private TextView algorithm; - private TextView status; + public TextView mainUserId; + public TextView mainUserIdRest; + public TextView keyId; + public TextView fingerprint; + public TextView algorithm; + public TextView status; } public ImportKeysAdapter(Activity activity) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java index 9b20effc2..4fccadf30 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java @@ -249,7 +249,7 @@ public class ImportKeysListEntry implements Serializable, Parcelable { /** * Based on OpenPGP Message Format */ - private final static SparseArray ALGORITHM_IDS = new SparseArray() {{ + private static final SparseArray ALGORITHM_IDS = new SparseArray() {{ put(-1, "unknown"); // TODO: with resources put(0, "unencrypted"); put(PGPPublicKey.RSA_GENERAL, "RSA"); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PagerTabStripAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PagerTabStripAdapter.java index 4a3796f01..fd864eb09 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PagerTabStripAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/PagerTabStripAdapter.java @@ -30,9 +30,9 @@ public class PagerTabStripAdapter extends FragmentPagerAdapter { private final ArrayList mTabs = new ArrayList(); static final class TabInfo { - private final Class clss; - private final Bundle args; - private final String title; + public final Class clss; + public final Bundle args; + public final String title; TabInfo(Class clss, Bundle args, String title) { this.clss = clss; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/TabsAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/TabsAdapter.java index 6dbea61dc..9ddfa90be 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/TabsAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/TabsAdapter.java @@ -36,8 +36,8 @@ public class TabsAdapter extends FragmentStatePagerAdapter implements ActionBar. private final ArrayList mTabs = new ArrayList(); static final class TabInfo { - private final Class clss; - private final Bundle args; + public final Class clss; + public final Bundle args; TabInfo(Class clss, Bundle args) { this.clss = clss; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java index 21a150606..fcaa6a940 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyUserIdsAdapter.java @@ -37,7 +37,7 @@ public class ViewKeyUserIdsAdapter extends CursorAdapter { private int mIndexUserId, mIndexRank; - final private ArrayList mCheckStates; + private final ArrayList mCheckStates; public ViewKeyUserIdsAdapter(Context context, Cursor c, int flags, boolean showCheckBoxes) { super(context, c, flags); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java index 60dea2a41..02ebde1c8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java @@ -51,12 +51,12 @@ public class DeleteKeyDialogFragment extends DialogFragment { public static final int MESSAGE_OKAY = 1; public static final int MESSAGE_ERROR = 0; - private boolean isSingleSelection = false; + private boolean mIsSingleSelection = false; - private TextView mainMessage; - private CheckBox checkDeleteSecret; - private LinearLayout deleteSecretKeyView; - private View inflateView; + private TextView mMainMessage; + private CheckBox mCheckDeleteSecret; + private LinearLayout mDeleteSecretKeyView; + private View mInflateView; private Messenger mMessenger; @@ -90,12 +90,12 @@ public class DeleteKeyDialogFragment extends DialogFragment { //Setup custom View to display in AlertDialog LayoutInflater inflater = activity.getLayoutInflater(); - inflateView = inflater.inflate(R.layout.view_key_delete_fragment, null); - builder.setView(inflateView); + mInflateView = inflater.inflate(R.layout.view_key_delete_fragment, null); + builder.setView(mInflateView); - deleteSecretKeyView = (LinearLayout) inflateView.findViewById(R.id.deleteSecretKeyView); - mainMessage = (TextView) inflateView.findViewById(R.id.mainMessage); - checkDeleteSecret = (CheckBox) inflateView.findViewById(R.id.checkDeleteSecret); + mDeleteSecretKeyView = (LinearLayout) mInflateView.findViewById(R.id.deleteSecretKeyView); + mMainMessage = (TextView) mInflateView.findViewById(R.id.mainMessage); + mCheckDeleteSecret = (CheckBox) mInflateView.findViewById(R.id.checkDeleteSecret); builder.setTitle(R.string.warning); @@ -103,7 +103,7 @@ public class DeleteKeyDialogFragment extends DialogFragment { if (keyRingRowIds.length == 1) { Uri dataUri; ArrayList publicKeyRings; //Any one will do - isSingleSelection = true; + mIsSingleSelection = true; long selectedRow = keyRingRowIds[0]; long keyType; @@ -119,16 +119,16 @@ public class DeleteKeyDialogFragment extends DialogFragment { } String userId = ProviderHelper.getUserId(activity, dataUri); - //Hide the Checkbox and TextView since this is a single selection,user will be notified thru message - deleteSecretKeyView.setVisibility(View.GONE); - //Set message depending on which key it is. - mainMessage.setText(getString(keyType == Id.type.secret_key ? R.string.secret_key_deletion_confirmation - : R.string.public_key_deletetion_confirmation, userId)); - - + // Hide the Checkbox and TextView since this is a single selection, + // user will be notified thru message + mDeleteSecretKeyView.setVisibility(View.GONE); + // Set message depending on which key it is. + mMainMessage.setText(getString(keyType == Id.type.secret_key ? + R.string.secret_key_deletion_confirmation : + R.string.public_key_deletetion_confirmation, userId)); } else { - deleteSecretKeyView.setVisibility(View.VISIBLE); - mainMessage.setText(R.string.key_deletion_confirmation_multi); + mDeleteSecretKeyView.setVisibility(View.VISIBLE); + mMainMessage.setText(R.string.key_deletion_confirmation_multi); } @@ -171,8 +171,9 @@ public class DeleteKeyDialogFragment extends DialogFragment { if (keyType == KeychainContract.KeyTypes.SECRET) { - if (checkDeleteSecret.isChecked() || isSingleSelection) { - ProviderHelper.deleteUnifiedKeyRing(activity, String.valueOf(masterKeyId), true); + if (mCheckDeleteSecret.isChecked() || mIsSingleSelection) { + ProviderHelper.deleteUnifiedKeyRing(activity, + String.valueOf(masterKeyId), true); } } else { ProviderHelper.deleteUnifiedKeyRing(activity, String.valueOf(masterKeyId), false); @@ -180,8 +181,10 @@ public class DeleteKeyDialogFragment extends DialogFragment { } //Check if the selected rows have actually been deleted - cursor = activity.getContentResolver().query(queryUri, projection, selection, null, null); - if (cursor == null || cursor.getCount() == 0 || !checkDeleteSecret.isChecked()) { + cursor = activity.getContentResolver().query( + queryUri, projection, selection, null, null); + if (cursor == null || cursor.getCount() == 0 || + !mCheckDeleteSecret.isChecked()) { isSuccessfullyDeleted = true; } } finally { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 272f43915..150f6e221 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -61,7 +61,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor private Choice mNewKeyAlgorithmChoice; private int mNewKeySize; - private boolean oldItemDeleted = false; + private boolean mOldItemDeleted = false; private ArrayList mDeletedIDs = new ArrayList(); private ArrayList mDeletedKeys = new ArrayList(); private boolean mCanEdit = true; @@ -138,13 +138,13 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor * {@inheritDoc} */ public void onDeleted(Editor editor, boolean wasNewItem) { - oldItemDeleted |= !wasNewItem; - if (oldItemDeleted) { - if (mType == Id.type.user_id) - mDeletedIDs.add(((UserIdEditor)editor).getOriginalID()); - else if (mType == Id.type.key) - mDeletedKeys.add(((KeyEditor)editor).getValue()); - + mOldItemDeleted |= !wasNewItem; + if (mOldItemDeleted) { + if (mType == Id.type.user_id) { + mDeletedIDs.add(((UserIdEditor) editor).getOriginalID()); + } else if (mType == Id.type.key) { + mDeletedKeys.add(((KeyEditor) editor).getValue()); + } } this.updateEditorsVisible(); if (mEditorListener != null) { @@ -167,7 +167,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor public boolean needsSaving() { //check each view for needs saving, take account of deleted items - boolean ret = oldItemDeleted; + boolean ret = mOldItemDeleted; for (int i = 0; i < mEditors.getChildCount(); ++i) { Editor editor = (Editor) mEditors.getChildAt(i); ret |= editor.needsSaving(); -- cgit v1.2.3 From 82e5d14fb1b14906a59a6b1bd61faec74514efc0 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 2 Apr 2014 01:56:58 +0200 Subject: Rearrange too long lines --- .../keychain/pgp/PgpDecryptVerify.java | 3 +- .../sufficientlysecure/keychain/pgp/PgpHelper.java | 6 +- .../keychain/pgp/PgpImportExport.java | 3 +- .../keychain/pgp/PgpKeyOperation.java | 96 +++++++++++++--------- .../sufficientlysecure/keychain/pgp/PgpToX509.java | 21 ++--- .../keychain/provider/KeychainContract.java | 6 +- .../keychain/provider/ProviderHelper.java | 16 ++-- .../keychain/remote/OpenPgpService.java | 15 ++-- .../keychain/remote/RemoteService.java | 3 +- .../remote/ui/AccountSettingsFragment.java | 3 +- .../keychain/service/KeychainIntentService.java | 20 +++-- .../keychain/ui/CertifyKeyActivity.java | 3 +- .../keychain/ui/DecryptActivity.java | 9 +- .../keychain/ui/DecryptFileFragment.java | 3 +- .../keychain/ui/DecryptMessageFragment.java | 3 +- .../keychain/ui/EditKeyActivity.java | 9 +- .../keychain/ui/EncryptActivity.java | 21 +++-- .../keychain/ui/EncryptFileFragment.java | 11 ++- .../keychain/ui/EncryptMessageFragment.java | 11 ++- .../keychain/ui/ImportKeysActivity.java | 8 +- .../keychain/ui/KeyListActivity.java | 6 +- .../keychain/ui/KeyListFragment.java | 9 +- .../keychain/ui/ViewKeyActivity.java | 3 +- .../keychain/ui/adapter/ImportKeysListEntry.java | 4 +- .../ui/dialog/DeleteKeyDialogFragment.java | 10 ++- .../ui/dialog/ShareQrCodeDialogFragment.java | 2 +- .../keychain/ui/widget/KeyEditor.java | 23 ++++-- .../keychain/util/HkpKeyServer.java | 46 ++++++----- 28 files changed, 228 insertions(+), 145 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java index 003db632d..90b48e017 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java @@ -684,7 +684,8 @@ public class PgpDecryptVerify { } private static boolean verifyPrimaryKeyBinding(PGPSignatureSubpacketVector pkts, - PGPPublicKey masterPublicKey, PGPPublicKey signingPublicKey) { + PGPPublicKey masterPublicKey, + PGPPublicKey signingPublicKey) { boolean validPrimaryKeyBinding = false; JcaPGPContentVerifierBuilderProvider contentVerifierBuilderProvider = new JcaPGPContentVerifierBuilderProvider() diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java index 7a3338c7c..7a2cb0d96 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java @@ -51,9 +51,9 @@ public class PgpHelper { ".*?(-----BEGIN PGP MESSAGE-----.*?-----END PGP MESSAGE-----).*", Pattern.DOTALL); public static final Pattern PGP_CLEARTEXT_SIGNATURE = Pattern - .compile( - ".*?(-----BEGIN PGP SIGNED MESSAGE-----.*?-----BEGIN PGP SIGNATURE-----.*?-----END PGP SIGNATURE-----).*", - Pattern.DOTALL); + .compile(".*?(-----BEGIN PGP SIGNED MESSAGE-----.*?-----" + + "BEGIN PGP SIGNATURE-----.*?-----END PGP SIGNATURE-----).*", + Pattern.DOTALL); public static final Pattern PGP_PUBLIC_KEY = Pattern.compile( ".*?(-----BEGIN PGP PUBLIC KEY BLOCK-----.*?-----END PGP PUBLIC KEY BLOCK-----).*", diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java index de405d132..69c2c8bf2 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java @@ -168,7 +168,8 @@ public class PgpImportExport { return returnData; } - public Bundle exportKeyRings(ArrayList publicKeyRingMasterIds, ArrayList secretKeyRingMasterIds, + public Bundle exportKeyRings(ArrayList publicKeyRingMasterIds, + ArrayList secretKeyRingMasterIds, OutputStream outStream) throws PgpGeneralException, PGPException, IOException { Bundle returnData = new Bundle(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index d4fba68ff..ceccf7a70 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -196,8 +196,8 @@ public class PgpKeyOperation { } public PGPSecretKeyRing changeSecretKeyPassphrase(PGPSecretKeyRing keyRing, String oldPassPhrase, - String newPassPhrase) throws IOException, PGPException, - NoSuchProviderException { + String newPassPhrase) + throws IOException, PGPException, NoSuchProviderException { updateProgress(R.string.progress_building_key, 0, 100); if (oldPassPhrase == null) { @@ -270,13 +270,16 @@ public class PgpKeyOperation { GregorianCalendar expiryDate = keysExpiryDates.get(0); //note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c //here we purposefully ignore partial days in each date - long type has no fractional part! - long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000); - if (numDays <= 0) + long numDays = (expiryDate.getTimeInMillis() / 86400000) - + (creationDate.getTimeInMillis() / 86400000); + if (numDays <= 0) { throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation); + } hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400); } else { - hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding, - //this happens anyway + hashedPacketsGen.setKeyExpirationTime(false, 0); + // do this explicitly, although since we're rebuilding, + // this happens anyway } updateProgress(R.string.progress_building_master_key, 30, 100); @@ -342,15 +345,16 @@ public class PgpKeyOperation { GregorianCalendar expiryDate = keysExpiryDates.get(i); //note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c //here we purposefully ignore partial days in each date - long type has no fractional part! - long numDays = - (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000); + long numDays = (expiryDate.getTimeInMillis() / 86400000) - + (creationDate.getTimeInMillis() / 86400000); if (numDays <= 0) { throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation); } hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400); } else { - hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding, - //this happens anyway + hashedPacketsGen.setKeyExpirationTime(false, 0); + // do this explicitly, although since we're rebuilding, + // this happens anyway } keyGen.addSubKey(subKeyPair, hashedPacketsGen.generate(), unhashedPacketsGen.generate()); @@ -447,22 +451,28 @@ public class PgpKeyOperation { GregorianCalendar expiryDate = saveParcel.keysExpiryDates.get(0); //note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c //here we purposefully ignore partial days in each date - long type has no fractional part! - long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000); - if (numDays <= 0) + long numDays = (expiryDate.getTimeInMillis() / 86400000) - + (creationDate.getTimeInMillis() / 86400000); + if (numDays <= 0) { throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation); + } hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400); } else { - hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding, - //this happens anyway + hashedPacketsGen.setKeyExpirationTime(false, 0); + // do this explicitly, although since we're rebuilding, + // this happens anyway } - if (saveParcel.primaryIDChanged || !saveParcel.originalIDs.get(0).equals(saveParcel.userIDs.get(0))) { + if (saveParcel.primaryIDChanged || + !saveParcel.originalIDs.get(0).equals(saveParcel.userIDs.get(0))) { anyIDChanged = true; ArrayList> sigList = new ArrayList>(); for (String userId : saveParcel.userIDs) { String origID = saveParcel.originalIDs.get(userIDIndex); - if ((origID.equals(userId) && !saveParcel.newIDs[userIDIndex]) && !userId.equals(saveParcel.originalPrimaryID) && userIDIndex != 0) { - Iterator origSigs = masterPublicKey.getSignaturesForID(origID); //TODO: make sure this iterator only has signatures we are interested in + if (origID.equals(userId) && !saveParcel.newIDs[userIDIndex] && + !userId.equals(saveParcel.originalPrimaryID) && userIDIndex != 0) { + Iterator origSigs = masterPublicKey.getSignaturesForID(origID); + // TODO: make sure this iterator only has signatures we are interested in while (origSigs.hasNext()) { PGPSignature origSig = origSigs.next(); sigList.add(new Pair(origID, origSig)); @@ -487,7 +497,8 @@ public class PgpKeyOperation { userIDIndex++; } for (Pair toAdd : sigList) { - masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, toAdd.first, toAdd.second); + masterPublicKey = + PGPPublicKey.addCertification(masterPublicKey, toAdd.first, toAdd.second); } } else { for (String userId : saveParcel.userIDs) { @@ -508,7 +519,8 @@ public class PgpKeyOperation { if (!saveParcel.newIDs[userIDIndex]) { masterPublicKey = PGPPublicKey.removeCertification(masterPublicKey, origID); } - masterPublicKey = PGPPublicKey.addCertification(masterPublicKey, userId, certification); + masterPublicKey = + PGPPublicKey.addCertification(masterPublicKey, userId, certification); } userIDIndex++; } @@ -520,7 +532,8 @@ public class PgpKeyOperation { for (String userId : saveParcel.userIDs) { String origID = saveParcel.originalIDs.get(userIDIndex); if (!(origID.equals(saveParcel.originalPrimaryID) && !saveParcel.primaryIDChanged)) { - Iterator sigs = masterPublicKey.getSignaturesForID(userId); //TODO: make sure this iterator only has signatures we are interested in + Iterator sigs = masterPublicKey.getSignaturesForID(userId); + // TODO: make sure this iterator only has signatures we are interested in while (sigs.hasNext()) { PGPSignature sig = sigs.next(); sigList.add(new Pair(userId, sig)); @@ -605,23 +618,27 @@ public class PgpKeyOperation { GregorianCalendar creationDate = new GregorianCalendar(TimeZone.getTimeZone("UTC")); creationDate.setTime(subPublicKey.getCreationTime()); GregorianCalendar expiryDate = saveParcel.keysExpiryDates.get(i); - //note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c - //here we purposefully ignore partial days in each date - long type has no fractional part! - long numDays = (expiryDate.getTimeInMillis() / 86400000) - (creationDate.getTimeInMillis() / 86400000); - if (numDays <= 0) + // note that the below, (a/c) - (b/c) is *not* the same as (a - b) /c + // here we purposefully ignore partial days in each date - long type has + // no fractional part! + long numDays = (expiryDate.getTimeInMillis() / 86400000) - + (creationDate.getTimeInMillis() / 86400000); + if (numDays <= 0) { throw new PgpGeneralMsgIdException(R.string.error_expiry_must_come_after_creation); + } hashedPacketsGen.setKeyExpirationTime(false, numDays * 86400); } else { - hashedPacketsGen.setKeyExpirationTime(false, 0); //do this explicitly, although since we're rebuilding, - //this happens anyway + hashedPacketsGen.setKeyExpirationTime(false, 0); + // do this explicitly, although since we're rebuilding, + // this happens anyway } keyGen.addSubKey(subKeyPair, hashedPacketsGen.generate(), unhashedPacketsGen.generate()); - //certifications will be discarded if the key is changed, because I think, for a start, - //they will be invalid. Binding certs are regenerated anyway, and other certs which - //need to be kept are on IDs and attributes - //TODO: don't let revoked keys be edited, other than removed - changing one would result in the - //revocation being wrong? + // certifications will be discarded if the key is changed, because I think, for a start, + // they will be invalid. Binding certs are regenerated anyway, and other certs which + // need to be kept are on IDs and attributes + // TODO: don't let revoked keys be edited, other than removed - changing one would + // result in the revocation being wrong? } } @@ -660,8 +677,10 @@ public class PgpKeyOperation { Log.d(Constants.TAG, " ------- in private key -------"); for(String uid : new IterableIterator(secretKeyRing.getPublicKey().getUserIDs())) { - for(PGPSignature sig : new IterableIterator(secretKeyRing.getPublicKey().getSignaturesForID(uid))) { - Log.d(Constants.TAG, "sig: " + PgpKeyHelper.convertKeyIdToHex(sig.getKeyID()) + " for " + uid); + for(PGPSignature sig : new IterableIterator( + secretKeyRing.getPublicKey().getSignaturesForID(uid))) { + Log.d(Constants.TAG, "sig: " + + PgpKeyHelper.convertKeyIdToHex(sig.getKeyID()) + " for " + uid); } } @@ -669,8 +688,10 @@ public class PgpKeyOperation { Log.d(Constants.TAG, " ------- in public key -------"); for(String uid : new IterableIterator(publicKeyRing.getPublicKey().getUserIDs())) { - for(PGPSignature sig : new IterableIterator(publicKeyRing.getPublicKey().getSignaturesForID(uid))) { - Log.d(Constants.TAG, "sig: " + PgpKeyHelper.convertKeyIdToHex(sig.getKeyID()) + " for " + uid); + for(PGPSignature sig : new IterableIterator( + publicKeyRing.getPublicKey().getSignaturesForID(uid))) { + Log.d(Constants.TAG, "sig: " + + PgpKeyHelper.convertKeyIdToHex(sig.getKeyID()) + " for " + uid); } } @@ -689,9 +710,10 @@ public class PgpKeyOperation { * @param passphrase Passphrase of the secret key * @return A keyring with added certifications */ - public PGPPublicKey certifyKey(PGPSecretKey certificationKey, PGPPublicKey publicKey, List userIds, String passphrase) + public PGPPublicKey certifyKey(PGPSecretKey certificationKey, PGPPublicKey publicKey, + List userIds, String passphrase) throws PgpGeneralMsgIdException, NoSuchAlgorithmException, NoSuchProviderException, - PGPException, SignatureException { + PGPException, SignatureException { // create a signatureGenerator from the supplied masterKeyId and passphrase PGPSignatureGenerator signatureGenerator; { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpToX509.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpToX509.java index fa54afa86..5bb1665b6 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpToX509.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpToX509.java @@ -83,9 +83,10 @@ public class PgpToX509 { * @throws Exception * @author Bruno Harbulot */ - public static X509Certificate createSelfSignedCert(PublicKey pubKey, PrivateKey privKey, - X509Name subject, Date startDate, Date endDate, String subjAltNameURI) - throws InvalidKeyException, IllegalStateException, NoSuchAlgorithmException, + public static X509Certificate createSelfSignedCert( + PublicKey pubKey, PrivateKey privKey, X509Name subject, Date startDate, Date endDate, + String subjAltNameURI) + throws InvalidKeyException, IllegalStateException, NoSuchAlgorithmException, SignatureException, CertificateException, NoSuchProviderException { X509V3CertificateGenerator certGenerator = new X509V3CertificateGenerator(); @@ -182,10 +183,10 @@ public class PgpToX509 { /** * Creates a self-signed certificate from a PGP Secret Key. * - * @param pgpSecKey PGP Secret Key (from which one can extract the public and private keys and other - * attributes). - * @param pgpPrivKey PGP Private Key corresponding to the Secret Key (password callbacks should be done - * before calling this method) + * @param pgpSecKey PGP Secret Key (from which one can extract the public and private + * keys and other attributes). + * @param pgpPrivKey PGP Private Key corresponding to the Secret Key (password callbacks + * should be done before calling this method) * @param subjAltNameURI optional URI to embed in the subject alternative-name * @return self-signed certificate * @throws PGPException @@ -196,9 +197,9 @@ public class PgpToX509 { * @throws CertificateException * @author Bruno Harbulot */ - public static X509Certificate createSelfSignedCert(PGPSecretKey pgpSecKey, - PGPPrivateKey pgpPrivKey, String subjAltNameURI) throws PGPException, - NoSuchProviderException, InvalidKeyException, NoSuchAlgorithmException, + public static X509Certificate createSelfSignedCert( + PGPSecretKey pgpSecKey, PGPPrivateKey pgpPrivKey, String subjAltNameURI) + throws PGPException, NoSuchProviderException, InvalidKeyException, NoSuchAlgorithmException, SignatureException, CertificateException { // get public key from secret key PGPPublicKey pgpPubKey = pgpSecKey.getPublicKey(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java index e7b31bf65..1a9b67261 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java @@ -283,12 +283,14 @@ public class KeychainContract { /** * Use if multiple items get returned */ - public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.api_app.accounts"; + public static final String CONTENT_TYPE = + "vnd.android.cursor.dir/vnd.thialfihar.apg.api_app.accounts"; /** * Use if a single item is returned */ - public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.api_app.account"; + public static final String CONTENT_ITEM_TYPE = + "vnd.android.cursor.item/vnd.thialfihar.apg.api_app.account"; public static Uri buildBaseUri(String packageName) { return CONTENT_URI.buildUpon().appendEncodedPath(packageName).appendPath(PATH_ACCOUNTS) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java index c88e3e22f..6882b6925 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -296,8 +296,8 @@ public class ProviderHelper { /** * Build ContentProviderOperation to add PGPPublicKey to database corresponding to a keyRing */ - private static ContentProviderOperation buildPublicKeyOperations(Context context, - long keyRingRowId, PGPPublicKey key, int rank) throws IOException { + private static ContentProviderOperation buildPublicKeyOperations( + Context context, long keyRingRowId, PGPPublicKey key, int rank) throws IOException { ContentValues values = new ContentValues(); values.put(Keys.KEY_ID, key.getKeyID()); values.put(Keys.IS_MASTER_KEY, key.isMasterKey()); @@ -324,8 +324,8 @@ public class ProviderHelper { /** * Build ContentProviderOperation to add PublicUserIds to database corresponding to a keyRing */ - private static ContentProviderOperation buildPublicUserIdOperations(Context context, - long keyRingRowId, String userId, int rank) { + private static ContentProviderOperation buildPublicUserIdOperations( + Context context, long keyRingRowId, String userId, int rank) { ContentValues values = new ContentValues(); values.put(UserIds.KEY_RING_ROW_ID, keyRingRowId); values.put(UserIds.USER_ID, userId); @@ -339,8 +339,8 @@ public class ProviderHelper { /** * Build ContentProviderOperation to add PGPSecretKey to database corresponding to a keyRing */ - private static ContentProviderOperation buildSecretKeyOperations(Context context, - long keyRingRowId, PGPSecretKey key, int rank) throws IOException { + private static ContentProviderOperation buildSecretKeyOperations( + Context context, long keyRingRowId, PGPSecretKey key, int rank) throws IOException { ContentValues values = new ContentValues(); boolean hasPrivate = true; @@ -376,8 +376,8 @@ public class ProviderHelper { /** * Build ContentProviderOperation to add SecretUserIds to database corresponding to a keyRing */ - private static ContentProviderOperation buildSecretUserIdOperations(Context context, - long keyRingRowId, String userId, int rank) { + private static ContentProviderOperation buildSecretUserIdOperations( + Context context, long keyRingRowId, String userId, int rank) { ContentValues values = new ContentValues(); values.put(UserIds.KEY_RING_ROW_ID, keyRingRowId); values.put(UserIds.USER_ID, userId); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java index b00c012b8..18bb92552 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -188,7 +188,8 @@ public class OpenPgpService extends RemoteService { } private Intent encryptAndSignImpl(Intent data, ParcelFileDescriptor input, - ParcelFileDescriptor output, AccountSettings accSettings, boolean sign) { + ParcelFileDescriptor output, AccountSettings accSettings, + boolean sign) { try { boolean asciiArmor = data.getBooleanExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true); @@ -292,7 +293,8 @@ public class OpenPgpService extends RemoteService { PgpDecryptVerify.Builder builder = new PgpDecryptVerify.Builder(this, inputData, os); builder.allowSymmetricDecryption(false) // no support for symmetric encryption - .allowedKeyIds(allowedKeyIds) // allow only private keys associated with accounts of this app + .allowedKeyIds(allowedKeyIds) // allow only private keys associated with + // accounts of this app .passphrase(passphrase); // TODO: currently does not support binary signed-only content @@ -300,9 +302,11 @@ public class OpenPgpService extends RemoteService { if (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) { // get PendingIntent for passphrase input, add it to given params and return to client - Intent passphraseBundle = getPassphraseBundleIntent(data, decryptVerifyResult.getKeyIdPassphraseNeeded()); + Intent passphraseBundle = + getPassphraseBundleIntent(data, decryptVerifyResult.getKeyIdPassphraseNeeded()); return passphraseBundle; - } else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) { + } else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED == + decryptVerifyResult.getStatus()) { throw new PgpGeneralException("Decryption of symmetric content not supported by API!"); } @@ -455,7 +459,8 @@ public class OpenPgpService extends RemoteService { } else if (OpenPgpApi.ACTION_DECRYPT_VERIFY.equals(action)) { String currentPkg = getCurrentCallingPackage(); Set allowedKeyIds = - ProviderHelper.getAllKeyIdsForApp(mContext, KeychainContract.ApiAccounts.buildBaseUri(currentPkg)); + ProviderHelper.getAllKeyIdsForApp(mContext, + KeychainContract.ApiAccounts.buildBaseUri(currentPkg)); return decryptAndVerifyImpl(data, input, output, allowedKeyIds); } else if (OpenPgpApi.ACTION_GET_KEY.equals(action)) { return getKeyImpl(data); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java index 3e72eec17..16a800022 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/RemoteService.java @@ -243,7 +243,8 @@ public abstract class RemoteService extends Service { return true; } else { throw new WrongPackageSignatureException( - "PACKAGE NOT ALLOWED! Signature wrong! (Signature not equals signature from database)"); + "PACKAGE NOT ALLOWED! Signature wrong! (Signature not " + + "equals signature from database)"); } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java index eec54b4cc..150cf2897 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/ui/AccountSettingsFragment.java @@ -69,7 +69,8 @@ public class AccountSettingsFragment extends Fragment implements this.mAccSettings = accountSettings; mAccNameView.setText(accountSettings.getAccountName()); - Uri keyUri = KeychainContract.KeyRings.buildSecretKeyRingsByMasterKeyIdUri(String.valueOf(accountSettings.getKeyId())); + Uri keyUri = KeychainContract.KeyRings.buildSecretKeyRingsByMasterKeyIdUri( + String.valueOf(accountSettings.getKeyId())); mSelectKeyFragment.selectKey(keyUri); mEncryptionAlgorithm.setSelection(mEncryptionAdapter.getPosition(accountSettings .getEncryptionAlgorithm())); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 14beae40c..487da80ca 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -485,10 +485,13 @@ public class KeychainIntentService extends IntentService ProviderHelper.saveKeyRing(this, keyRing); setProgress(R.string.progress_done, 100, 100); } else { - PgpKeyOperation keyOperations = new PgpKeyOperation(new ProgressScaler(this, 0, 90, 100)); - PGPSecretKeyRing privkey = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(this, masterKeyId); - PGPPublicKeyRing pubkey = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(this, masterKeyId); - PgpKeyOperation.Pair pair = + PgpKeyOperation keyOperations = + new PgpKeyOperation(new ProgressScaler(this, 0, 90, 100)); + PGPSecretKeyRing privkey = + ProviderHelper.getPGPSecretKeyRingByMasterKeyId(this, masterKeyId); + PGPPublicKeyRing pubkey = + ProviderHelper.getPGPPublicKeyRingByMasterKeyId(this, masterKeyId); + PgpKeyOperation.Pair pair = keyOperations.buildSecretKey(privkey, pubkey, saveParams); setProgress(R.string.progress_saving_key_ring, 90, 100); ProviderHelper.saveKeyRing(this, pair.first); @@ -745,11 +748,14 @@ public class KeychainIntentService extends IntentService // verify downloaded key by comparing fingerprints if (entry.getFingerPrintHex() != null) { - String downloadedKeyFp = PgpKeyHelper.convertFingerprintToHex(downloadedKey.getPublicKey().getFingerprint()); + String downloadedKeyFp = PgpKeyHelper.convertFingerprintToHex( + downloadedKey.getPublicKey().getFingerprint()); if (downloadedKeyFp.equals(entry.getFingerPrintHex())) { - Log.d(Constants.TAG, "fingerprint of downloaded key is the same as the requested fingerprint!"); + Log.d(Constants.TAG, "fingerprint of downloaded key is the same as " + + "the requested fingerprint!"); } else { - throw new PgpGeneralException("fingerprint of downloaded key is NOT the same as the requested fingerprint!"); + throw new PgpGeneralException("fingerprint of downloaded key is " + + "NOT the same as the requested fingerprint!"); } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java index d041bc35e..e7da531e1 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java @@ -212,7 +212,8 @@ public class CertifyKeyActivity extends ActionBarActivity implements fingerprintBlob = ProviderHelper.getFingerprint(this, mDataUri); } String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob); - ((TextView) findViewById(R.id.fingerprint)).setText(PgpKeyHelper.colorizeFingerprint(fingerprint)); + ((TextView) findViewById(R.id.fingerprint)) + .setText(PgpKeyHelper.colorizeFingerprint(fingerprint)); } break; case LOADER_ID_USER_IDS: diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java index 046d80b72..8533e9072 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptActivity.java @@ -77,8 +77,10 @@ public class DecryptActivity extends DrawerActivity { // Handle intent actions, maybe changes the bundles handleActions(getIntent()); - mTabsAdapter.addTab(DecryptMessageFragment.class, mMessageFragmentBundle, getString(R.string.label_message)); - mTabsAdapter.addTab(DecryptFileFragment.class, mFileFragmentBundle, getString(R.string.label_file)); + mTabsAdapter.addTab(DecryptMessageFragment.class, + mMessageFragmentBundle, getString(R.string.label_message)); + mTabsAdapter.addTab(DecryptFileFragment.class, + mFileFragmentBundle, getString(R.string.label_file)); mViewPager.setCurrentItem(mSwitchToTab); } @@ -164,7 +166,8 @@ public class DecryptActivity extends DrawerActivity { mSwitchToTab = PAGER_TAB_FILE; } else { Log.e(Constants.TAG, - "Direct binary data without actual file in filesystem is not supported. Please use the Remote Service API!"); + "Direct binary data without actual file in filesystem is not supported. " + + "Please use the Remote Service API!"); Toast.makeText(this, R.string.error_only_files_are_supported, Toast.LENGTH_LONG) .show(); // end activity diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java index 67cf8d3e3..492c0cf29 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFileFragment.java @@ -200,7 +200,8 @@ public class DecryptFileFragment extends DecryptFragment { if (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) { showPassphraseDialog(decryptVerifyResult.getKeyIdPassphraseNeeded()); - } else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) { + } else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED == + decryptVerifyResult.getStatus()) { showPassphraseDialog(Id.key.symmetric); } else { AppMsg.makeText(getActivity(), R.string.decryption_successful, diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java index c7a56449b..2169bbd77 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptMessageFragment.java @@ -154,7 +154,8 @@ public class DecryptMessageFragment extends DecryptFragment { if (PgpDecryptVerifyResult.KEY_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) { showPassphraseDialog(decryptVerifyResult.getKeyIdPassphraseNeeded()); - } else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED == decryptVerifyResult.getStatus()) { + } else if (PgpDecryptVerifyResult.SYMMETRIC_PASSHRASE_NEEDED == + decryptVerifyResult.getStatus()) { showPassphraseDialog(Id.key.symmetric); } else { AppMsg.makeText(getActivity(), R.string.decryption_successful, diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 8ef4631dc..a8b3e29ed 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -125,7 +125,6 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener public void somethingChanged() { ActivityCompat.invalidateOptionsMenu(this); - //Toast.makeText(this, "Needs saving: " + Boolean.toString(mNeedsSaving) + "(" + Boolean.toString(mUserIdsView.needsSaving()) + ", " + Boolean.toString(mKeysView.needsSaving()) + ")", Toast.LENGTH_LONG).show(); } public void onDeleted(Editor e, boolean wasNewItem) { @@ -329,7 +328,9 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: - cancelClicked(); //TODO: why isn't this triggered on my tablet - one of many ui problems I've had with this device. A code compatibility issue or a Samsung fail? + cancelClicked(); + // TODO: why isn't this triggered on my tablet - one of many ui problems + // I've had with this device. A code compatibility issue or a Samsung fail? return true; case R.id.menu_key_edit_cancel: cancelClicked(); @@ -340,8 +341,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } else { long masterKeyId = ProviderHelper.getMasterKeyId(this, mDataUri); long[] ids = new long[] {masterKeyId}; - mExportHelper.showExportKeysDialog(ids, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC, - null); + mExportHelper.showExportKeysDialog( + ids, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC, null); return true; } return true; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java index db35b7c28..a03c7d797 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptActivity.java @@ -155,12 +155,16 @@ public class EncryptActivity extends DrawerActivity implements // Handle intent actions handleActions(getIntent()); - mTabsAdapterMode.addTab(EncryptAsymmetricFragment.class, mAsymmetricFragmentBundle, getString(R.string.label_asymmetric)); - mTabsAdapterMode.addTab(EncryptSymmetricFragment.class, mSymmetricFragmentBundle, getString(R.string.label_symmetric)); + mTabsAdapterMode.addTab(EncryptAsymmetricFragment.class, + mAsymmetricFragmentBundle, getString(R.string.label_asymmetric)); + mTabsAdapterMode.addTab(EncryptSymmetricFragment.class, + mSymmetricFragmentBundle, getString(R.string.label_symmetric)); mViewPagerMode.setCurrentItem(mSwitchToMode); - mTabsAdapterContent.addTab(EncryptMessageFragment.class, mMessageFragmentBundle, getString(R.string.label_message)); - mTabsAdapterContent.addTab(EncryptFileFragment.class, mFileFragmentBundle, getString(R.string.label_file)); + mTabsAdapterContent.addTab(EncryptMessageFragment.class, + mMessageFragmentBundle, getString(R.string.label_message)); + mTabsAdapterContent.addTab(EncryptFileFragment.class, + mFileFragmentBundle, getString(R.string.label_file)); mViewPagerContent.setCurrentItem(mSwitchToContent); } @@ -212,8 +216,10 @@ public class EncryptActivity extends DrawerActivity implements long[] encryptionKeyIds = extras.getLongArray(EXTRA_ENCRYPTION_KEY_IDS); // preselect keys given by intent - mAsymmetricFragmentBundle.putLongArray(EncryptAsymmetricFragment.ARG_ENCRYPTION_KEY_IDS, encryptionKeyIds); - mAsymmetricFragmentBundle.putLong(EncryptAsymmetricFragment.ARG_SIGNATURE_KEY_ID, signatureKeyId); + mAsymmetricFragmentBundle.putLongArray(EncryptAsymmetricFragment.ARG_ENCRYPTION_KEY_IDS, + encryptionKeyIds); + mAsymmetricFragmentBundle.putLong(EncryptAsymmetricFragment.ARG_SIGNATURE_KEY_ID, + signatureKeyId); mSwitchToMode = PAGER_MODE_ASYMMETRIC; /** @@ -234,7 +240,8 @@ public class EncryptActivity extends DrawerActivity implements mSwitchToContent = PAGER_CONTENT_FILE; } else { Log.e(Constants.TAG, - "Direct binary data without actual file in filesystem is not supported by Intents. Please use the Remote Service API!"); + "Direct binary data without actual file in filesystem is not supported " + + "by Intents. Please use the Remote Service API!"); Toast.makeText(this, R.string.error_only_files_are_supported, Toast.LENGTH_LONG) .show(); // end activity diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java index cee7dae87..c8ea6ffb7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java @@ -253,8 +253,9 @@ public class EncryptFileFragment extends Fragment { return; } - if (mEncryptInterface.getSignatureKey() != 0 - && PassphraseCacheService.getCachedPassphrase(getActivity(), mEncryptInterface.getSignatureKey()) == null) { + if (mEncryptInterface.getSignatureKey() != 0 && + PassphraseCacheService.getCachedPassphrase(getActivity(), + mEncryptInterface.getSignatureKey()) == null) { showPassphraseDialog(); return; @@ -283,8 +284,10 @@ public class EncryptFileFragment extends Fragment { } data.putString(KeychainIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase); } else { - data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_KEY_ID, mEncryptInterface.getSignatureKey()); - data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, mEncryptInterface.getEncryptionKeys()); + data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_KEY_ID, + mEncryptInterface.getSignatureKey()); + data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, + mEncryptInterface.getEncryptionKeys()); } Log.d(Constants.TAG, "mInputFilename=" + mInputFilename + ", mOutputFilename=" diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java index f2187dac3..4522acf4e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java @@ -150,8 +150,9 @@ public class EncryptMessageFragment extends Fragment { return; } - if (mEncryptInterface.getSignatureKey() != 0 - && PassphraseCacheService.getCachedPassphrase(getActivity(), mEncryptInterface.getSignatureKey()) == null) { + if (mEncryptInterface.getSignatureKey() != 0 && + PassphraseCacheService.getCachedPassphrase(getActivity(), + mEncryptInterface.getSignatureKey()) == null) { showPassphraseDialog(toClipboard); return; @@ -182,8 +183,10 @@ public class EncryptMessageFragment extends Fragment { } data.putString(KeychainIntentService.ENCRYPT_SYMMETRIC_PASSPHRASE, passphrase); } else { - data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_KEY_ID, mEncryptInterface.getSignatureKey()); - data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, mEncryptInterface.getEncryptionKeys()); + data.putLong(KeychainIntentService.ENCRYPT_SIGNATURE_KEY_ID, + mEncryptInterface.getSignatureKey()); + data.putLongArray(KeychainIntentService.ENCRYPT_ENCRYPTION_KEYS_IDS, + mEncryptInterface.getEncryptionKeys()); boolean signOnly = (mEncryptInterface.getEncryptionKeys() == null || mEncryptInterface.getEncryptionKeys().length == 0); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java index b73510e38..b09fa4a4d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java @@ -168,7 +168,8 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa } } else { Log.e(Constants.TAG, - "IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', 'key_id', or 'fingerprint' extra!"); + "IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', 'key_id', or " + + "'fingerprint' extra!"); return; } @@ -233,7 +234,7 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa * onNavigationItemSelected() should check whether the Fragment is already in existence * inside your Activity." *

                                            - * from http://stackoverflow.com/questions/10983396/fragment-oncreateview-and-onactivitycreated-called-twice/14295474#14295474 + * from http://bit.ly/1dBYThO *

                                            * In our case, if we start ImportKeysActivity with parameters to directly search using a fingerprint, * the fragment would be loaded twice resulting in the query being empty after the second load. @@ -337,7 +338,8 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa // } else { // status.putString( // EXTRA_ERROR, - // "Scanned fingerprint does NOT match the fingerprint of the received key. You shouldnt trust this key."); + // "Scanned fingerprint does NOT match the fingerprint of the received key. " + + // "You shouldnt trust this key."); // } // } // } catch (QueryException e) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java index 27d3bbbb0..1f884d7e3 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListActivity.java @@ -66,11 +66,13 @@ public class KeyListActivity extends DrawerActivity { return true; case R.id.menu_key_list_export_public: - mExportHelper.showExportKeysDialog(null, Id.type.public_key, Constants.Path.APP_DIR_FILE_PUB, null); + mExportHelper.showExportKeysDialog(null, + Id.type.public_key, Constants.Path.APP_DIR_FILE_PUB, null); return true; case R.id.menu_key_list_secret_export: - mExportHelper.showExportKeysDialog(null, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC, null); + mExportHelper.showExportKeysDialog(null, Id.type.secret_key, + Constants.Path.APP_DIR_FILE_SEC, null); return true; default: diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 6da8a0262..3beb95108 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -190,12 +190,15 @@ public class KeyListFragment extends Fragment ProviderHelper.getPublicKeyRingsRowIds(getActivity()); for (int i = 0; i < ids.length; i++) { if (allPubRowIds.contains(ids[i])) { - masterKeyIds[i] = ProviderHelper.getPublicMasterKeyId(getActivity(), ids[i]); + masterKeyIds[i] = + ProviderHelper.getPublicMasterKeyId(getActivity(), ids[i]); } else { - masterKeyIds[i] = ProviderHelper.getSecretMasterKeyId(getActivity(), ids[i]); + masterKeyIds[i] = + ProviderHelper.getSecretMasterKeyId(getActivity(), ids[i]); } } - ExportHelper mExportHelper = new ExportHelper((ActionBarActivity) getActivity()); + ExportHelper mExportHelper = + new ExportHelper((ActionBarActivity) getActivity()); mExportHelper .showExportKeysDialog(masterKeyIds, Id.type.public_key, Constants.Path.APP_DIR_FILE_PUB, diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index b86c20880..b8b2e271f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -124,7 +124,8 @@ public class ViewKeyActivity extends ActionBarActivity { return true; case R.id.menu_key_view_export_file: long masterKeyId = - ProviderHelper.getPublicMasterKeyId(this, Long.valueOf(mDataUri.getLastPathSegment())); + ProviderHelper.getPublicMasterKeyId(this, + Long.valueOf(mDataUri.getLastPathSegment())); long[] ids = new long[] {masterKeyId}; mExportHelper.showExportKeysDialog(ids, Id.type.public_key, Constants.Path.APP_DIR_FILE_PUB, null); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java index 4fccadf30..5631d40ea 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListEntry.java @@ -267,6 +267,8 @@ public class ImportKeysListEntry implements Serializable, Parcelable { * Based on OpenPGP Message Format */ public static String getAlgorithmFromId(int algorithmId) { - return (ALGORITHM_IDS.get(algorithmId) != null ? ALGORITHM_IDS.get(algorithmId) : ALGORITHM_IDS.get(-1)); + return (ALGORITHM_IDS.get(algorithmId) != null ? + ALGORITHM_IDS.get(algorithmId) : + ALGORITHM_IDS.get(-1)); } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java index 02ebde1c8..a467c779c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java @@ -166,9 +166,10 @@ public class DeleteKeyDialogFragment extends DialogFragment { masterKeyId = cursor.getLong(0); keyType = cursor.getLong(1); - Log.d(Constants.TAG, "masterKeyId: " + masterKeyId - + ", keyType:" + (keyType == KeychainContract.KeyTypes.PUBLIC ? "Public" : "Private")); - + Log.d(Constants.TAG, "masterKeyId: " + masterKeyId + + ", keyType:" + + (keyType == KeychainContract.KeyTypes.PUBLIC ? + "Public" : "Private")); if (keyType == KeychainContract.KeyTypes.SECRET) { if (mCheckDeleteSecret.isChecked() || mIsSingleSelection) { @@ -176,7 +177,8 @@ public class DeleteKeyDialogFragment extends DialogFragment { String.valueOf(masterKeyId), true); } } else { - ProviderHelper.deleteUnifiedKeyRing(activity, String.valueOf(masterKeyId), false); + ProviderHelper.deleteUnifiedKeyRing(activity, + String.valueOf(masterKeyId), false); } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java index 94586810e..18403837a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ShareQrCodeDialogFragment.java @@ -111,7 +111,7 @@ public class ShareQrCodeDialogFragment extends DialogFragment { content = keyringArmored.get(0); // OnClickListener are set in onResume to prevent automatic dismissing of Dialogs - // http://stackoverflow.com/questions/2620444/how-to-prevent-a-dialog-from-closing-when-a-button-is-clicked + // http://bit.ly/O5vfaR alert.setPositiveButton(R.string.btn_next, null); alert.setNegativeButton(android.R.string.cancel, null); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 1f5b13c83..de26e20a3 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -94,11 +94,13 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { GregorianCalendar date = new GregorianCalendar(TimeZone.getTimeZone("UTC")); date.set(year, monthOfYear, dayOfMonth); if (mOriginalExpiryDate != null) { - long numDays = (date.getTimeInMillis() / 86400000) - (mOriginalExpiryDate.getTimeInMillis() / 86400000); - if (numDays == 0) + long numDays = (date.getTimeInMillis() / 86400000) - + (mOriginalExpiryDate.getTimeInMillis() / 86400000); + if (numDays == 0) { setExpiryDate(mOriginalExpiryDate); - else + } else { setExpiryDate(date); + } } else { setExpiryDate(date); } @@ -316,11 +318,16 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { } public int getUsage() { - mUsage = (mUsage & ~KeyFlags.CERTIFY_OTHER) | (mChkCertify.isChecked() ? KeyFlags.CERTIFY_OTHER : 0); - mUsage = (mUsage & ~KeyFlags.SIGN_DATA) | (mChkSign.isChecked() ? KeyFlags.SIGN_DATA : 0); - mUsage = (mUsage & ~KeyFlags.ENCRYPT_COMMS) | (mChkEncrypt.isChecked() ? KeyFlags.ENCRYPT_COMMS : 0); - mUsage = (mUsage & ~KeyFlags.ENCRYPT_STORAGE) | (mChkEncrypt.isChecked() ? KeyFlags.ENCRYPT_STORAGE : 0); - mUsage = (mUsage & ~KeyFlags.AUTHENTICATION) | (mChkAuthenticate.isChecked() ? KeyFlags.AUTHENTICATION : 0); + mUsage = (mUsage & ~KeyFlags.CERTIFY_OTHER) | + (mChkCertify.isChecked() ? KeyFlags.CERTIFY_OTHER : 0); + mUsage = (mUsage & ~KeyFlags.SIGN_DATA) | + (mChkSign.isChecked() ? KeyFlags.SIGN_DATA : 0); + mUsage = (mUsage & ~KeyFlags.ENCRYPT_COMMS) | + (mChkEncrypt.isChecked() ? KeyFlags.ENCRYPT_COMMS : 0); + mUsage = (mUsage & ~KeyFlags.ENCRYPT_STORAGE) | + (mChkEncrypt.isChecked() ? KeyFlags.ENCRYPT_STORAGE : 0); + mUsage = (mUsage & ~KeyFlags.AUTHENTICATION) | + (mChkAuthenticate.isChecked() ? KeyFlags.AUTHENTICATION : 0); return mUsage; } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java index e4171cfae..fbf93aeda 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java @@ -69,20 +69,22 @@ public class HkpKeyServer extends KeyServer { /** * pub:%keyid%:%algo%:%keylen%:%creationdate%:%expirationdate%:%flags% *

                                              - *
                                            • %keyid% = this is either the fingerprint or the key ID of the key. Either the 16-digit or 8-digit - * key IDs are acceptable, but obviously the fingerprint is best.
                                            • + *
                                            • %keyid% = this is either the fingerprint or the key ID of the key. + * Either the 16-digit or 8-digit key IDs are acceptable, but obviously the fingerprint is best. + *
                                            • *
                                            • %algo% = the algorithm number, (i.e. 1==RSA, 17==DSA, etc). * See RFC-2440
                                            • *
                                            • %keylen% = the key length (i.e. 1024, 2048, 4096, etc.)
                                            • *
                                            • %creationdate% = creation date of the key in standard - * RFC-2440 form (i.e. number of seconds since - * 1/1/1970 UTC time)
                                            • + * RFC-2440 form (i.e. number of + * seconds since 1/1/1970 UTC time) *
                                            • %expirationdate% = expiration date of the key in standard - * RFC-2440 form (i.e. number of seconds since - * 1/1/1970 UTC time)
                                            • - *
                                            • %flags% = letter codes to indicate details of the key, if any. Flags may be in any order. The - * meaning of "disabled" is implementation-specific. Note that individual flags may be unimplemented, so - * the absence of a given flag does not necessarily mean the absence of the detail. + * RFC-2440 form (i.e. number of + * seconds since 1/1/1970 UTC time)
                                            • + *
                                            • %flags% = letter codes to indicate details of the key, if any. Flags may be in any + * order. The meaning of "disabled" is implementation-specific. Note that individual flags may + * be unimplemented, so the absence of a given flag does not necessarily mean the absence of the + * detail. *
                                                *
                                              • r == revoked
                                              • *
                                              • d == disabled
                                              • @@ -91,7 +93,8 @@ public class HkpKeyServer extends KeyServer { * *
                                              * - * @see 5.2. Machine Readable Indexes + * @see + * 5.2. Machine Readable Indexes * in Internet-Draft OpenPGP HTTP Keyserver Protocol Document */ public static final Pattern PUB_KEY_LINE = Pattern @@ -102,17 +105,19 @@ public class HkpKeyServer extends KeyServer { /** * uid:%escaped uid string%:%creationdate%:%expirationdate%:%flags% *
                                                - *
                                              • %escaped uid string% = the user ID string, with HTTP %-escaping for anything that isn't 7-bit - * safe as well as for the ":" character. Any other characters may be escaped, as desired.
                                              • + *
                                              • %escaped uid string% = the user ID string, with HTTP %-escaping for anything that + * isn't 7-bit safe as well as for the ":" character. Any other characters may be escaped, as + * desired.
                                              • *
                                              • %creationdate% = creation date of the key in standard - * RFC-2440 form (i.e. number of seconds since - * 1/1/1970 UTC time)
                                              • + * RFC-2440 form (i.e. number of + * seconds since 1/1/1970 UTC time) *
                                              • %expirationdate% = expiration date of the key in standard - * RFC-2440 form (i.e. number of seconds since - * 1/1/1970 UTC time)
                                              • - *
                                              • %flags% = letter codes to indicate details of the key, if any. Flags may be in any order. The - * meaning of "disabled" is implementation-specific. Note that individual flags may be unimplemented, so - * the absence of a given flag does not necessarily mean the absence of the detail. + * RFC-2440 form (i.e. number of + * seconds since 1/1/1970 UTC time)
                                              • + *
                                              • %flags% = letter codes to indicate details of the key, if any. Flags may be in any + * order. The meaning of "disabled" is implementation-specific. Note that individual flags may + * be unimplemented, so the absence of a given flag does not necessarily mean the absence of + * the detail. *
                                                  *
                                                • r == revoked
                                                • *
                                                • d == disabled
                                                • @@ -244,8 +249,7 @@ public class HkpKeyServer extends KeyServer { entry.setAlgorithm(ImportKeysListEntry.getAlgorithmFromId(algorithmId)); // group 1 contains the full fingerprint (v4) or the long key id if available - // see https://bitbucket.org/skskeyserver/sks-keyserver/pull-request/12/fixes-for-machine-readable-indexes/diff - // and https://github.com/openpgp-keychain/openpgp-keychain/issues/259#issuecomment-38168176 + // see http://bit.ly/1d4bxbk and http://bit.ly/1gD1wwr String fingerprintOrKeyId = matcher.group(1); if (fingerprintOrKeyId.length() > 16) { entry.setFingerPrintHex(fingerprintOrKeyId.toLowerCase(Locale.US)); -- cgit v1.2.3 From 592ab31d866c9b58ce6e831b184301f665558e11 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 2 Apr 2014 01:58:31 +0200 Subject: Add missing and curly brackets and fix others Style guide demands them even for single-line blocks, and opening curly brackets never appear on a line on their own. --- .../keychain/pgp/PgpKeyHelper.java | 15 ++++-- .../keychain/service/SaveKeyringParcel.java | 9 ++-- .../keychain/ui/EditKeyActivity.java | 8 ++-- .../ui/dialog/DeleteKeyDialogFragment.java | 3 +- .../keychain/ui/widget/KeyEditor.java | 19 ++++---- .../keychain/ui/widget/SectionView.java | 55 ++++++++++------------ .../keychain/ui/widget/UserIdEditor.java | 12 ++--- 7 files changed, 61 insertions(+), 60 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index 89352ef31..f4a5b8d4e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -300,8 +300,7 @@ public class PgpKeyHelper { return userId; } - public static int getKeyUsage(PGPSecretKey key) - { + public static int getKeyUsage(PGPSecretKey key) { return getKeyUsage(key.getPublicKey()); } @@ -310,13 +309,19 @@ public class PgpKeyHelper { int usage = 0; if (key.getVersion() >= 4) { for (PGPSignature sig : new IterableIterator(key.getSignatures())) { - if (key.isMasterKey() && sig.getKeyID() != key.getKeyID()) continue; + if (key.isMasterKey() && sig.getKeyID() != key.getKeyID()) { + continue; + } PGPSignatureSubpacketVector hashed = sig.getHashedSubPackets(); - if (hashed != null) usage |= hashed.getKeyFlags(); + if (hashed != null) { + usage |= hashed.getKeyFlags(); + } PGPSignatureSubpacketVector unhashed = sig.getUnhashedSubPackets(); - if (unhashed != null) usage |= unhashed.getKeyFlags(); + if (unhashed != null) { + usage |= unhashed.getKeyFlags(); + } } } return usage; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java index cc0f94b9b..7012bfafd 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java @@ -69,8 +69,7 @@ public class SaveKeyringParcel implements Parcelable { } @Override - public void writeToParcel(Parcel destination, int flags) - { + public void writeToParcel(Parcel destination, int flags) { destination.writeSerializable(userIDs); //might not be the best method to store. destination.writeSerializable(originalIDs); destination.writeSerializable(deletedIDs); @@ -78,8 +77,9 @@ public class SaveKeyringParcel implements Parcelable { destination.writeByte((byte) (primaryIDChanged ? 1 : 0)); destination.writeBooleanArray(moddedKeys); byte[] tmp = null; - if (deletedKeys.size() != 0) + if (deletedKeys.size() != 0) { tmp = PgpConversionHelper.PGPSecretKeyArrayListToBytes(deletedKeys); + } destination.writeByteArray(tmp); destination.writeSerializable(keysExpiryDates); destination.writeList(keysUsages); @@ -101,8 +101,7 @@ public class SaveKeyringParcel implements Parcelable { }; @Override - public int describeContents() - { + public int describeContents() { return 0; } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index a8b3e29ed..d0a0d20ad 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -391,8 +391,9 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener if (!isSet) { isSet = true; String[] parts = PgpKeyHelper.splitUserId(userId); - if (parts[0] != null) + if (parts[0] != null) { setTitle(parts[0]); + } } mUserIds.add(userId); } @@ -547,10 +548,11 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } String passphrase; - if (mIsPassPhraseSet) + if (mIsPassPhraseSet) { passphrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId); - else + } else { passphrase = ""; + } if (passphrase == null) { showPassphraseDialog(masterKeyId); } else { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java index a467c779c..4de332d3c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java @@ -148,8 +148,9 @@ public class DeleteKeyDialogFragment extends DialogFragment { String selectionIDs = ""; for (int i = 0; i < keyRingRowIds.length; i++) { selectionIDs += "'" + String.valueOf(keyRingRowIds[i]) + "'"; - if (i + 1 < keyRingRowIds.length) + if (i + 1 < keyRingRowIds.length) { selectionIDs += ","; + } } selection += selectionIDs + ")"; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index de26e20a3..5fd06f4fc 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -255,8 +255,9 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { } else { mUsage = PgpKeyHelper.getKeyUsage(key); mOriginalUsage = mUsage; - if (key.isMasterKey()) + if (key.isMasterKey()) { mChkCertify.setChecked(PgpKeyHelper.isCertificationKey(key)); + } mChkSign.setChecked(PgpKeyHelper.isSigningKey(key)); mChkEncrypt.setChecked(PgpKeyHelper.isEncryptionKey(key)); mChkAuthenticate.setChecked(PgpKeyHelper.isAuthenticationKey(key)); @@ -332,10 +333,10 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { return mUsage; } - public boolean needsSaving() - { - if (mIsNewKey) + public boolean needsSaving() { + if (mIsNewKey) { return true; + } boolean retval = (getUsage() != mOriginalUsage); @@ -345,21 +346,21 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { if (mOEDNull != mEDNull) { dateChanged = true; } else { - if(mOEDNull) //both null, no change + if (mOEDNull) { + //both null, no change dateChanged = false; - else + } else { dateChanged = ((mExpiryDate.compareTo(mOriginalExpiryDate)) != 0); + } } retval |= dateChanged; return retval; } - public boolean getIsNewKey() - { + public boolean getIsNewKey() { return mIsNewKey; } - } class ExpiryDatePickerDialog extends DatePickerDialog { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 150f6e221..1f388e865 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -164,34 +164,34 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor mEditors.setVisibility(hasChildren ? View.VISIBLE : View.GONE); } - public boolean needsSaving() - { + public boolean needsSaving() { //check each view for needs saving, take account of deleted items boolean ret = mOldItemDeleted; for (int i = 0; i < mEditors.getChildCount(); ++i) { Editor editor = (Editor) mEditors.getChildAt(i); ret |= editor.needsSaving(); - if (mType == Id.type.user_id) - ret |= ((UserIdEditor)editor).primarySwapped(); + if (mType == Id.type.user_id) { + ret |= ((UserIdEditor) editor).primarySwapped(); + } } return ret; } - public boolean primaryChanged() - { + public boolean primaryChanged() { boolean ret = false; for (int i = 0; i < mEditors.getChildCount(); ++i) { Editor editor = (Editor) mEditors.getChildAt(i); - if (mType == Id.type.user_id) - ret |= ((UserIdEditor)editor).primarySwapped(); + if (mType == Id.type.user_id) { + ret |= ((UserIdEditor) editor).primarySwapped(); + } } return ret; } - public String getOriginalPrimaryID() - { //NB: this will have to change when we change how Primary IDs are chosen, and so we need to be - // careful about where Master key capabilities are stored... multiple primaries and - // revoked ones make this harder than the simple case we are continuing to assume here + public String getOriginalPrimaryID() { + //NB: this will have to change when we change how Primary IDs are chosen, and so we need to be + // careful about where Master key capabilities are stored... multiple primaries and + // revoked ones make this harder than the simple case we are continuing to assume here for (int i = 0; i < mEditors.getChildCount(); ++i) { Editor editor = (Editor) mEditors.getChildAt(i); if (mType == Id.type.user_id) { @@ -203,16 +203,16 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor return null; } - public ArrayList getOriginalIDs() - { + public ArrayList getOriginalIDs() { ArrayList orig = new ArrayList(); if (mType == Id.type.user_id) { for (int i = 0; i < mEditors.getChildCount(); ++i) { UserIdEditor editor = (UserIdEditor) mEditors.getChildAt(i); - if (editor.isMainUserId()) + if (editor.isMainUserId()) { orig.add(0, editor.getOriginalID()); - else + } else { orig.add(editor.getOriginalID()); + } } return orig; } else { @@ -220,18 +220,15 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor } } - public ArrayList getDeletedIDs() - { + public ArrayList getDeletedIDs() { return mDeletedIDs; } - public ArrayList getDeletedKeys() - { + public ArrayList getDeletedKeys() { return mDeletedKeys; } - public List getNeedsSavingArray() - { + public List getNeedsSavingArray() { ArrayList mList = new ArrayList(); for (int i = 0; i < mEditors.getChildCount(); ++i) { Editor editor = (Editor) mEditors.getChildAt(i); @@ -240,21 +237,20 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor return mList; } - public List getNewIDFlags() - { + public List getNewIDFlags() { ArrayList mList = new ArrayList(); for (int i = 0; i < mEditors.getChildCount(); ++i) { UserIdEditor editor = (UserIdEditor) mEditors.getChildAt(i); - if (editor.isMainUserId()) + if (editor.isMainUserId()) { mList.add(0, editor.getIsNewID()); - else + } else { mList.add(editor.getIsNewID()); + } } return mList; } - public List getNewKeysArray() - { + public List getNewKeysArray() { ArrayList mList = new ArrayList(); if (mType == Id.type.key) { for (int i = 0; i < mEditors.getChildCount(); ++i) { @@ -420,8 +416,9 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor mEditors, false); view.setEditorListener(SectionView.this); int usage = 0; - if (mEditors.getChildCount() == 0) + if (mEditors.getChildCount() == 0) { usage = PGPKeyFlags.CAN_CERTIFY; + } view.setValue(newKey, newKey.isMasterKey(), usage, true); mEditors.addView(view); SectionView.this.updateEditorsVisible(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index 71f5f0d86..b21b99254 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -84,8 +84,7 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene } @Override - public void afterTextChanged(Editable s) - { + public void afterTextChanged(Editable s) { if (mEditorListener != null) { mEditorListener.onEdited(); } @@ -246,18 +245,15 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene return retval; } - public boolean getIsOriginallyMainUserID() - { + public boolean getIsOriginallyMainUserID() { return mOriginallyMainUserID; } - public boolean primarySwapped() - { + public boolean primarySwapped() { return (mOriginallyMainUserID != isMainUserId()); } - public String getOriginalID() - { + public String getOriginalID() { return mOriginalID; } -- cgit v1.2.3 From 22fe3832ba0cf1102d7a2c8d53ad101464bccaff Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 2 Apr 2014 01:58:54 +0200 Subject: Suppress checkstyle for some files --- tools/checkstyle.xml | 4 ++-- tools/suppressions.xml | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 tools/suppressions.xml diff --git a/tools/checkstyle.xml b/tools/checkstyle.xml index 26a3f8c02..95ef07a90 100644 --- a/tools/checkstyle.xml +++ b/tools/checkstyle.xml @@ -9,9 +9,9 @@ page at http://checkstyle.sourceforge.net/config.html --> - + + Keine - Nur Signieren - Nur Verschlüsseln - Signieren und Verschlüsseln 15 s 1 min 3 min @@ -183,21 +175,18 @@ Warnung Fehler Fehler: %s + Falsches Passwort. Verwende Inhalt der Zwischenablage. Zuerst ein Passwort setzen. Kein passender Dateimanager installiert. Die Passwörter stimmten nicht überein. - Leere Passwörter sind nicht erlaubt. Symmetrische Verschlüsselung. Passwort für \'%s\' eingeben %s\nwirklich löschen? Erfolgreich gelöscht. Zuerst eine Datei auswählen. - Erfolgreich entschlüsselt. - Erfolgreich verschlüsselt. - Erfolgreich in die Zwischenablage verschlüsselt. Passwort zweimal eingeben. Mindestens einen Schlüssel zum verschlüsseln auswählen. Mindestens einen Schlüssel zum Verschlüsseln oder einen zum Signieren auswählen. @@ -416,9 +405,6 @@ Info Zertifikationen - Kontakte - Verschlüsseln - Entschlüsseln Schlüssel Importieren Meine Schlüssel Registrierte Anwendungen diff --git a/OpenPGP-Keychain/src/main/res/values-el/strings.xml b/OpenPGP-Keychain/src/main/res/values-el/strings.xml index 094dfe28a..824399722 100644 --- a/OpenPGP-Keychain/src/main/res/values-el/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-el/strings.xml @@ -15,8 +15,6 @@ Διαγραφή Κανένα ΟΚ - Αλλαγή κωδικού - Επέλεξε Κωδικό Διαγραφής κλειδιού Δημιουργίας κλειδιού @@ -34,6 +32,7 @@ Ηλεκτρονικό ταχυδρομίο + + Ninguna - Solo firmar - Solo cifrar - Firmar y cifrar 15 segs 1 min 3 mins @@ -183,21 +178,22 @@ Advertencia Error Error: %s + + Certificar + Firmar + Cifrar + Autentificar Frase de contraseña incorrecta. Usando el contenido del portapapeles. Establece una frase de contraseña antes. No hay un gestor de archivos compatible instalado. Las frases de contraseña no coinciden. - Las frases de contraseña no pueden estar vacías. Cifrado simétrico. Introducir la frase de contraseña para \'%s\' ¿Estás seguro de que quieres borrar\n%s? Borrado satisfactoriamente. Selecciona un archivo antes. - Descifrado satisfactoriamente. - Cifrado satisfactoriamente. - Cifrado satisfactoriamente al portapapeles. Introduce la frase de contraseña dos veces. Selecciona al menos una clave de cifrado. Selecciona al menos una clave de cifrado o de firma. @@ -208,6 +204,7 @@ ¿Quieres realmente borrar la clave \'%s\'?\n¡No podrás deshacerlo! ¿Quieres realmente borrar todas las claves seleccionadas?\n¡No podrás deshacerlo! ¿Quieres realmente borrar la clave SECRETA \'%s\'?\n¡No podrás deshacerlo! + Has hecho cambios en el almacén de claves, ¿quieres guardarlos? ¿Quieres realmente borrar la clave PÚBLICA \'%s\'?\n¡No podrás deshacerlo! ¿Borrar claves secretas? ¿Exportar también las claves secretas? @@ -285,6 +282,7 @@ ¡NFC no está disponible en tu dispositivo! ¡Nada que importar! la fecha de caducidad debe ser posterior a la fecha de creación + Por favor, guarda el almacén de claves antes no puedes eliminar este contacto porque eres tú mismo. no puedes eliminar los siguientes contactos porque son tú mismo:\n%s Consulta al servidor insuficiente @@ -384,13 +382,16 @@ Ocultar la configuración avanzada No se ha seleccionado ninguna clave Seleccionar clave + Crear una nueva clave para esta cuenta Guardar Cancelar Revocar acceso + Borrar cuenta Nombre de paquete SHA-256 de firma de paquete Cuentas No hay cuentas asociadas a esta aplicación. + La aplicación solicita la creación de una nueva cuenta. Por favor, selecciona una clave privada que ya exista o crea una nueva.\n¡Las aplicaciones tienen restringido el uso de claves a las que tú selecciones aquí! La aplicación mostrada solicita acceso a OpenKeychain.\n¿Permitir el acceso?\n\nAVISO: Si no sabes por qué aparece esta pantalla, ¡deniega el acceso! Puedes revocarlo después usando la pantalla \'Aplicaciones registradas\'. Permitir el acceso Denegar el acceso @@ -422,9 +423,6 @@ Información Certificaciones - Contactos - Cifrar - Descifrar Importar claves Mis claves Aplicaciones registradas @@ -438,5 +436,4 @@ IDs de usuario para firmar Nueva aplicación de certificados - Escribe aquí el mensaje que quieras cifrar... diff --git a/OpenPGP-Keychain/src/main/res/values-et/strings.xml b/OpenPGP-Keychain/src/main/res/values-et/strings.xml index 04570b4b6..62741da09 100644 --- a/OpenPGP-Keychain/src/main/res/values-et/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-et/strings.xml @@ -35,7 +35,6 @@ Salvesta Katkesta Kustuta - Määra salasõne Otsi Saada võtmeserverisse Järgmine @@ -77,9 +76,6 @@ Sõrmejälg: Salajane võti: - Ainult allkirjastamine - Ainult krüpteerimine - Allkirjastamine ja krüpteerimine 15 sekundit 1 minut 3 minutit @@ -98,11 +94,11 @@ Hoiatus Viga Viga: %s + Vale salasõne Määra enne salasõne. Salasõned ei ühti. - Tühi salasõne pole lubatud. Sümmeetriline krüpteering + Aucune - Signer seulement - Chiffrer seulement - Signer et chiffrer 15 s 1 min 3 min @@ -183,21 +178,22 @@ Avertissement Erreur Erreur : %s + + Certifier + Signer + Chiffrer + Authentifier Phrase de passe erronée Utiliser le contenu du presse-papiers. Définir d\'abord une phrase de passe. Aucun gestionnaire de fichiers compatible installé. Les phrases de passe ne correspondent pas. - Les phrases de passe vides ne sont pas autorisées. Chriffrement symétrique. Saisir une phrase de passe pour « %s » Êtes-vous sûr de vouloir supprimer\n%s ? Supprimé avec succès. Choisir d\'abord un fichier. - Déchiffré avec succès. - Chiffré avec succès. - Chiffré vers le presse-papiers avec succès. Saisir la phrase de passe deux fois. Choisir au moins une clef de chiffrement. Choisir au moins une clef de chiffrement ou de signature. @@ -208,6 +204,7 @@ Voulez-vous vraiment supprimer la clef %s ?\nVous ne pourrez pas la restituer ! Voulez-vous vraiment supprimer toutes les clefs choisies ?\nCeci est irréversible ! Voulez-vous vraiment supprimer la clef SECRÈTE %s ?\nVous ne pourrez pas la restituer ! + Vous avez apporté des changements au trousseau, voulez-vous l\'enregistrer ? Voulez-vous vraiment supprimer la clef PUBLIQUE « %s » ?\nVous ne pourrez pas la restituer ! Supprimer les clefs privées ? Exporter aussi les clefs secrètes? @@ -285,6 +282,7 @@ NFC n\'est pas disponible sur votre appareil ! Rien à importer ! la date d\'expiration doit venir après la date de création + veuillez d\'abord enregistrer le trousseau vous ne pouvez pas supprimer ce contact car c\'est le vôtre. vous ne pouvez pas supprimer les contacts suivants car c\'est les vôtres.\n%s Requête serveur insuffisante @@ -300,6 +298,7 @@ une partie du fichier chargé est un objet OpenPGP valide mais pas une clef OpenPGP certaines parties du fichier chargé sont des objets OpenPGP valides mais pas des clefs OpenPGP + Vous devez apporter des changements au trousseau avant de pouvoir l\'enregistrer Terminé. Annuler @@ -384,13 +383,16 @@ Masquer les paramètres avancés Aucune clef choisie Choisir une clef + Créer une nouvelle clef pour ce compte Enregistrer Annuler Révoquer l\'accès + Supprimer le compte Nom du paquet SHA-256 de la signature du paquet Comptes Aucun compte n\'est attaché à cette application. + L\'application demande la création d\'un nouveau compte. Veuillez choisir un clef privée existante ou en créer une.\nLes applications sont restreintes à l\'utilisation de clefs choisies ici. L\'application affichée demande l\'accès à OpenKeychain.\nPermettre l\'accès ?\n\nAvertissement : si vous ne savez pas pourquoi cet écran est apparu, refusez l\'accès ! Vous pourrez révoquer l\'accès plus tard en utilisant l\'écran « Applications enregistrées ». Permettre l\'accès Enlever l\'accès @@ -422,9 +424,6 @@ Infos Certifications - Contacts - Chiffrer - Déchiffrer Importer les clefs Mes clefs Applis enregistrées @@ -438,5 +437,4 @@ ID utilisateur pour signer Nouvel application des certificats - Écrire le message à chiffrer ici... diff --git a/OpenPGP-Keychain/src/main/res/values-it-rIT/strings.xml b/OpenPGP-Keychain/src/main/res/values-it-rIT/strings.xml index 23dd432a4..ff46c9606 100644 --- a/OpenPGP-Keychain/src/main/res/values-it-rIT/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-it-rIT/strings.xml @@ -48,6 +48,7 @@ Certifica Decodifica Decodifica e Verifica + Dagli Appunti Seleziona Destinatari Codifica File Salva @@ -55,8 +56,8 @@ Elimina Nessuno Okay - Cambia Frase Di Accesso - Imposta Frase di Accesso + Cambia Nuova Frase di Accesso + Imposta Nuova Frase di Accesso Cerca Carica sul Server delle Chiavi Prossimo @@ -73,12 +74,11 @@ Importa da Codice QR Importa Importa tramite NFC - Esporta tutte le chiavi Esporta tutte le chiavi segrete Esporta su un file Cancella chiave Crea chiave - Crea chiave (esperto) + Crea chiave (avanzato) Cerca Server delle Chiavi Server delle Chiavi... @@ -104,7 +104,7 @@ File Nessuna Frase di Accesso Frase di Accesso - Ancora + Di nuovo Algortimo Armatura ASCII Destinatari @@ -129,8 +129,6 @@ Nome Commento Email - Firma ID Utente - Firma email Carica chiave nel server delle chiavi selezionati dopo la certificazione Impronta Seleziona @@ -161,9 +159,6 @@ Chiave Privata: Nessuno - Firma soltanto - Codifica soltanto - Firma e Codifica 15 sec 1 min 3 min @@ -183,21 +178,22 @@ Attenzione Errore Errore: %s + + Certifica + Firma + Codifica + Convalida Frase di Accesso errata Utilizzo il contenuto degli appunti. Imposta prima una frase di accesso. Nessun gestore file compatibile installato. Le frasi di accesso non corrispondono. - Frasi di accesso vuote non consentite. Codifica Simmetrica. Inserisci la frase di accesso per \'%s\' Sei sicuro di voler cancellare\n%s? Eliminato correttamente. Seleziona un file prima. - Decodificato correttamente. - Codificato correttamente. - Codificato correttamente negli appunti. Inserisci la frase di accesso due volte. Seleziona almeno una chiave di codifica. Seleziona almeno una chiave di codifica o di firma. @@ -208,6 +204,7 @@ Vuoi veramente eliminare la chiave \'%s\'?\nNon potrai annullare! Vuoi veramente eliminare le chiavi selezionate?\nNon potrai annullare! Vuoi veramente eliminare la chiave PRIVATA \'%s\'?\nNon potrai annullare! + Hai apportato modifiche al tuo portachiavi, vuoi salvarlo? Vuoi veramente eliminare la chiave PUBBLICA \'%s\'?\nNon potrai annullare! Eliminare le Chiavi Segrete? Esportare anche le chiavi segrete? @@ -285,6 +282,7 @@ NFC non disponibile nel tuo dispositivo! Niente da importare! La data di scadenza deve essere postuma quella di creazione + si prega di salvare il portachiavi primo Non è possibile eliminare questo contatto, perché è il proprio. Non è possibile eliminare i seguenti contatti perché sono i propri:\n%s Query di server insufficiente @@ -377,16 +375,23 @@ Codifica con OpenKeychain Decodifica con OpenKeychain - Nessuna app registrata!\n\nApp di terza parti possono richiedere accesso a OpenKeychain. Dopo aver concesso l\'accesso, saranno elencate qui. + Nessuna app registrata!\n\nApp di terze parti possono richiedere l\'accesso a OpenKeychain. Dopo aver concesso l\'accesso, le app saranno elencate qui. + Mostra informazioni dettagliate + Nascondi informazioni dettagliate Mostra impostazioni avanzate Nascondi impostazioni avanzate Nessuna chiave selezionata Seleziona chiave + Crea una nuova chiave per questo account Salva Annulla Revoca accesso + Cancella account Nome Pacchetto SHA-256 della Firma del Pacchetto + Account + Nessun account collegato a questa applicazione + L\'applicazione richiede la creazione di un nuovo account. Si prega di selezionare una chiave privata esistente o crearne una nuova.\nLe applicazioni sono limitate all\'utilizzo delle chiavi selezionate qui! Le app visualizzate hanno richiesto l\'accesso a OpenKeychain.\nPermetti accesso?\n\nATTENZIONE: Se non sai perche\' questo schermata e\' apparsa, nega l\'accesso! Puoi revocare l\'accesso dopo, usando la schermata \'App Registrate\'. Permetti accesso Nega accesso @@ -418,10 +423,7 @@ Info Certificazioni - Contatti - Codifica - Decodifica - Importare Chiavi + Importa Chiavi Le Mie Chiavi App Registrate Apri drawer di navigazione @@ -434,5 +436,4 @@ ID Utente da firmare Riapplicazione certificati - Scrivi qui il messaggio da codificare... diff --git a/OpenPGP-Keychain/src/main/res/values-ja/strings.xml b/OpenPGP-Keychain/src/main/res/values-ja/strings.xml index f28f73262..d501d0b9b 100644 --- a/OpenPGP-Keychain/src/main/res/values-ja/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-ja/strings.xml @@ -48,6 +48,7 @@ 検証 復号化 復号化と検証 + クリップボードから 受信者の選択 ファイル暗号化 保存 @@ -55,8 +56,8 @@ 削除 無し OK - パスフレーズの変更 - パスフレーズの設定 + 新しいパスフレーズに変更 + 新しいパスフレーズを設定 検索 鍵サーバへアップロード @@ -73,7 +74,6 @@ QRコードからインポート インポート NFCからインポート - すべての鍵のエクスポート すべての秘密鍵のエクスポート ファイルへのエクスポート 鍵の削除 @@ -129,8 +129,6 @@ 名前 コメント Eメールアドレス - 署名ユーザーID - メールを署名 証明後選択した鍵サーバに鍵をアップロード 指紋 選択 @@ -158,9 +156,6 @@ 秘密鍵: 無し - 署名のみ - 暗号化のみ - 署名と暗号化 15秒 1分 3分 @@ -180,21 +175,22 @@ 注意 エラー エラー: %s + + 検証 + 署名 + 暗号化 + 証明 良くないパスフレーズ クリップボードの内容を使う。 最初にパスフレーズを設定してください。 互換性のないファイルマネージャがインストールされています。 パスフレーズが一致しません。 - 空のパスフレーズは受け付けません。 対称暗号。 \'%s\' にパスフレーズを入れてください。 %s を削除してもかまいませんか? 削除に成功しました。 最初にファイルを選択してください。 - 復号化に成功しました。 - 暗号化に成功しました。 - クリップボードの中身の暗号化に成功しました。 もう一度パスフレーズを入れてください。 少なくとも1つの暗号化鍵を選択して下さい。 少なくとも1つの暗号化鍵か署名鍵を選択して下さい。 @@ -205,6 +201,7 @@ 鍵\'%s\'を本当に削除してもよいですか?\nこれは元に戻せません! 選択したすべての鍵を本当に削除してよいですか?\nこれは元に戻せません。 秘密鍵\'%s\'を本当に削除してもよいですか?\nこれは元に戻せません! + あなたは鍵輪に変更を加えました、これを保存しますか? 公開鍵\'%s\'を本当に削除してもよいですか?\nこれは元に戻せません! 秘密鍵を削除しますか? 秘密鍵もエクスポートしますか? @@ -276,6 +273,7 @@ あなたのデバイスにはNFCが存在しません! インポートするものがありません! 期限日時は生成日時より後である必要があります + まず鍵輪を保存してください この連絡先はあなたなので削除できません。 この連絡先はあなたなので削除できません。:\n%s サーバへのクエリーが不足しています @@ -289,6 +287,7 @@ 読み込んだファイルのOpenPGPオブジェクト部分は正しいですが、OpenPGPの鍵ではありません + あなたは鍵輪を保存する前に変更を加えなくてはなりません 完了。 キャンセル @@ -364,15 +363,22 @@ OpenKeychainで復号化 登録されていないアプリケーション!\n\nサードパーティアプリケーションはOpenKeychainにアクセスを要求できます。アクセスを与えた後、それらはここにリストされます。 + 詳細情報を表示 + 詳細情報を非表示 拡張設定を表示 拡張設定を隠す 鍵が選択されていない 鍵の選択 + このアカウントで新しい鍵を生成 保存 キャンセル 破棄されたアクセス + アカウントを削除 パッケージ名 パッケージの署名 SHA-256 + アカウント + このアプリケーションに接続されてるアカウントはありません。 + このアプリケーションは新しいアカウントの生成を要求しています。すでにある秘密鍵を選択するか、新しく生成してください。\nここであなたが選択する鍵の使い道についてアプリケーションには制約があります! 表示されているアプリケーションはOpenKeychainへのアクセスを要求しています。\nアクセスを許可しますか?\n\n注意: もしなぜスクリーンに表れたかわからないなら、アクセスを許可しないでください! あなたは\'登録済みアプリケーション\'スクリーンを使って、以降のアクセスを破棄するこもできます。 許可されたアクセス 許可されないアクセス @@ -403,9 +409,6 @@ 情報 証明 - 連絡先 - 暗号化 - 復号化 鍵のインポート 自分の鍵 登録済みのアプリ @@ -419,5 +422,4 @@ 署名に使うユーザーID 検証を再適用する - ここに書いたメッセージを暗号化.. diff --git a/OpenPGP-Keychain/src/main/res/values-nl-rNL/strings.xml b/OpenPGP-Keychain/src/main/res/values-nl-rNL/strings.xml index a7f674ea0..9cb9a4756 100644 --- a/OpenPGP-Keychain/src/main/res/values-nl-rNL/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-nl-rNL/strings.xml @@ -36,8 +36,6 @@ Verwijderen Geen OK - Wachtwoord wijzigen - Wachtwoord instellen Zoeken Volgende Terug @@ -46,7 +44,6 @@ Importeren uit bestand Importeren met QR-code Importeren met NFC - Alle sleutels exporteren Exporteren naar bestand Sleutel verwijderen Sleutel aanmaken @@ -91,9 +88,6 @@ Privésleutel: Geen - Alleen ondertekenen - Alleen versleutelen - Ondertekenen en versleutelen 15 sec. 1 min. 3 min. @@ -112,21 +106,18 @@ Waarschuwing Fout Fout: %s + Wachtwoord verkeerd. Gebruikmaken van klembordinhoud. Stel eerst een wachtwoord in. Geen compatibele bestandsbeheerder geïnstalleerd. De wachtwoorden komen niet overeen. - Lege wachtwoorden zijn niet toegestaand. Symmetrische versleuteling. Voer het wachtwoord in voor \'%s\' Weer u zeker dat u het volgende wilt verwijderen:\n%s? Succesvol verwijderd. Selecteer eerst een bestand. - Succesvol ontsleuteld. - Succesvol versleuteld. - Succesvol versleuteld naar klembord. Voer het wachtwoord tweemaal in. Selecteer ten minste één versleutelingssleutel. Selecter ten minste één versleutelings-/ondertekeningssleutel. diff --git a/OpenPGP-Keychain/src/main/res/values-pl/strings.xml b/OpenPGP-Keychain/src/main/res/values-pl/strings.xml index e31216176..428ca203e 100644 --- a/OpenPGP-Keychain/src/main/res/values-pl/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-pl/strings.xml @@ -55,8 +55,6 @@ Usuń Żaden Ok - Zmień hasło - Ustaw hasło Wyszukaj Wyślij do serwera kluczy Dalej @@ -73,8 +71,7 @@ Zaimportuj z kodu QR Import Zaimportuj przy użyciu NFC - Eksportuj wszystkie klucze - Eksportuj wszystkie klucze prywatne + Eksportuj wszystkie prywatne klucze Eksportuj do pliku Usuń klucz Stwórz klucz @@ -129,8 +126,6 @@ Imię Komentarz Adres email - Identyfikator użytkownika podpisu (sign user id) - Podpisz e-mail Wyślij klucz do serwera kluczy po certyfikacji Odcisk Wybierz @@ -163,10 +158,7 @@ Odcisk: Klucz prywatny: - Żaden - Tylko podpisz - Tylko zaszyfruj - Podpisz i zaszyfruj + Brak 15 sekund 1 minuta 3 minuty @@ -186,21 +178,18 @@ Ostrzeżenie Błąd Błąd: %s + Nieprawidłowe hasło. Użycie zawartości schowka. Najpierw ustaw hasło. Nie zainstalowano żadnego kompatybilnego menadżera plików. Hasła nie pasują do siebie - Puste hasła nie są dozwolone. Szyfrowanie symetryczne. Podaj hasło dla \'%s\' Czy jesteś pewien że chcesz usunąć\n%s? Usunięto pomyślnie. Najpierw wskaż plik. - Odszyfrowano pomyślnie. - Zaszyfrowano pomyślnie. - Pomyślnie zaszyfrowano do schowka. Podaj hasło dwukrotnie. Wybierz co najmniej jeden klucz szyfrujący. Wybierz co najmniej jeden klucz szyfrujący lub klucz podpisujący. @@ -398,13 +387,16 @@ Ukryj zaawansowane ustawienia Nie wybrano klucza Wybierz klucz + Utwórz nowy klucz dla tego konta Zapisz Anuluj Odwołaj dostęp + Usuń konto Nazwa paczki Skrót SHA-256 podpisu paczki Konta Nie przypisano żadnych kont do tej aplikacji + Aplikacja prosi o zgodę na utworzenie nowego konta. Wskaż istniejący klucz prywatny lub wygeneruj nowy.\nAplikacje mogą używać wyłącznie klucze które tutaj wskażesz! Wyświetlona aplikacja prosi o dostęp do OpenKeychain.\nZezwolić?\n\nOSTRZEZENIE: Jeżeli nie wiesz, czemu wyświetlił się ten komunikat, nie zezwalaj na dostęp! Możesz to również zrobić później, korzystając z ekranu \'Zarejestrowane aplikacje\'. Zezwól na dostęp Odmów dostępu @@ -437,10 +429,7 @@ Informacje Certyfikaty - Kontakty - Zaszyfruj - Deszyfruj - importuj klucze + Importuj klucze Moje klucze Zarejestrowane aplikacje Otwórz panel nawigacji @@ -453,5 +442,4 @@ Identyfikator użytkownika do podpisu Ponowne stosowanie certyfikatów - Wpisz tutaj wiadomość do zaszyfrowania... diff --git a/OpenPGP-Keychain/src/main/res/values-pt-rBR/strings.xml b/OpenPGP-Keychain/src/main/res/values-pt-rBR/strings.xml index 3d00a143f..7b71d3ecf 100644 --- a/OpenPGP-Keychain/src/main/res/values-pt-rBR/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-pt-rBR/strings.xml @@ -7,6 +7,7 @@ + Нет - Только подпись - Только шифрование - Шифрование и подпись 15 секунд 1 минуту 3 минуты @@ -184,21 +181,21 @@ Внимание Ошибка Ошибка: %s + + Сертифицировать + Подписать + Зашифровать Неправ. пароль Следить за буфером обмена Сначала задайте пароль Нет совместимого менеджера файлов. Пароли не совпадают. - Пустой пароль недопустим. Симметричное шифрование. Введите пароль для\n\'%s\' Вы уверены, что хотите удалить\n%s ? Удалено. Сначала выберите файл. - Расшифровано. - Зашифровано. - Зашифровано в буфер обмена. Дважды введите пароль. Укажите хотя бы один ключ. Выберите хотя бы один ключ для шифрования или подписи. @@ -390,6 +387,8 @@ OpenKeychain: Расшифровать Нет связанных программ!\n\nСторонние программы могут запросить доступ к OpenKeychain, после чего они будут отражаться здесь. + Показать подробную информацию + Скрыть подробную информацию Показать расширенные настройки Скрыть расширенные настройки Ключ не выбран @@ -431,9 +430,6 @@ Информация Сертификация - Контакты - Зашифровать - Расшифровать Импорт ключей Мои ключи Связанные приложения @@ -444,6 +440,6 @@ Секретный ключ доступен не доступен + Подписываемые ID пользователя - Напишите сообщение здесь, что бы зашифровать... diff --git a/OpenPGP-Keychain/src/main/res/values-sl-rSI/strings.xml b/OpenPGP-Keychain/src/main/res/values-sl-rSI/strings.xml index 3d00a143f..7b71d3ecf 100644 --- a/OpenPGP-Keychain/src/main/res/values-sl-rSI/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-sl-rSI/strings.xml @@ -7,6 +7,7 @@ + Başarıyla silindi. Önce bir dosya seçin. - Başarıyla şifrelendi. Anahtar %08X bulunamadı. Anahtar başarıyla imzalandı Liste boş! diff --git a/OpenPGP-Keychain/src/main/res/values-uk/strings.xml b/OpenPGP-Keychain/src/main/res/values-uk/strings.xml index 00655fc53..6329439d3 100644 --- a/OpenPGP-Keychain/src/main/res/values-uk/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-uk/strings.xml @@ -48,6 +48,7 @@ Сертифікувати Розшифрувати Розшифрувати і Перевірити + З буфера обміну Вибрати одержувачів Шифрувати файл Зберегти @@ -55,8 +56,8 @@ Вилучити Жоден Гаразд - Змінити парольну фразу - Задати парольну фразу + Змінити нову парольну фразу + Задати нову парольну фразу Пошук Завантажити на сервер ключів Далі @@ -73,7 +74,6 @@ Імпорт з штрих-коду Імпорт Імпорт з NFC - Експортувати усі ключі Експортувати усі секретні ключі Експорт до файлу Вилучити ключ @@ -129,8 +129,6 @@ Назва Коментар Ел. пошта - Ід підпису користувача - Підписати листа Завантажити ключ до вибраного сервера ключів після сертифікації Відбиток Вибрати @@ -164,9 +162,6 @@ Секретний ключ: Жоден - Підписати лише - Шифрувати тільки - Шифрувати і розшифрувати 15 секунд 1 хв 3 хв @@ -186,21 +181,22 @@ Попередження Помилка Помилка: %s + + Сертифікувати + Підписати + Зашифрувати + Перевірити справжність Невірна парольна фраза. Використання вмісту буфера обміну. Спершу задайте парольну фразу. Нема встановленого сумісного менеджера файлів. Парольні фрази не збігаються. - Порожні парольні фрази не дозволені. Симетричне шифрування. Введіть парольну фразу для \'%s\' Ви справді хочете вилучити\n%s? Успішно вилучено. Виберіть спершу файл. - Успішно розшифровано. - Успішно зашифровано. - Успішно зашифровано до буфера обміну. Введіть двічі парольну фразу. Виберіть принаймні один ключ шифрування. Виберіть принаймні один ключ шифрування або ключ підпису. @@ -211,6 +207,7 @@ Ви справді хочете вилучити ключ \'%s\'?\nВи не зможете це відмінити! Ви справді хочете вилучити усі вибрані ключі?\nВи не зможете це відмінити! Ви справді хочете вилучити секретний ключ \'%s\'?\nВи не зможете це відмінити! + Ви внесли зміни до в\'язки ключів, ви б хотіли. Волієте їх зберегти? Справді волієте вилучити ВІДКРИТИЙ ключ \'%s\'?\nВи е зможете відмінити цю дію! Видалити секретні ключі? Також експортувати секретні ключі? @@ -294,6 +291,7 @@ NFC недоступний на вашому пристрої! Нема що імпортувати! дата завершення дії має йти після дати створення + спершу збережіть в\'язку ключів ви не можете вилучити цей контакт, тому що він ваш власний. ви не можете вилучити наступні контакти, тому що вони - ваші власні:\n%s Запит обмеженого сервера @@ -311,6 +309,7 @@ частини завантаженого файлу є вірним об\'єктом OpenPGP, але не ключем OpenPGP частин завантаженого файлу є вірним об\'єктом OpenPGP, але не ключем OpenPGP + Вам потрібно внести зміни до в\'язки ключів перед тим, як зможете їх зберегти. Готово. Скасувати @@ -398,13 +397,16 @@ Приховати додаткові налаштування Не вибрано ключа Вибрати ключ + Створити новий ключ для цього профілю Зберегти Скасувати Відкликати доступ + Видалити профіль Назва пакунку SHA-256 підписку пакунку Облікові записи Немає облікового запису приєднаного до цієї програми. + Ця програма вимагає створення нового профілю. Будь ласка, виберіть наявний приватний ключ або створіть інший.\nПрограми обмежені використання ключів, які ви тут оберете! Показана програма запитує доступ до OpenPGP Keychain.\nДозволити доступ?\n\nУВАГА: якщо ви не знаєте, чому цей екран появився, не дозволяйте доступ! Ви можете відкликати доступ пізніше, використовуючи екран \'Зареєстровані програми\'. Дозволити доступ Не дозволити доступ @@ -437,9 +439,6 @@ Інформація Сертифікати - Контакти - Зашифрувати - Розшифрувати Імпортувати ключі Мої ключі Зареєстровані програми @@ -453,5 +452,4 @@ ІД користувача для реєстрації Перезастосування сертифікатів - Напишіть повідомлення для шифрування… diff --git a/OpenPGP-Keychain/src/main/res/values-zh-rTW/strings.xml b/OpenPGP-Keychain/src/main/res/values-zh-rTW/strings.xml index 3d00a143f..7b71d3ecf 100644 --- a/OpenPGP-Keychain/src/main/res/values-zh-rTW/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-zh-rTW/strings.xml @@ -7,6 +7,7 @@ + 没有 - 仅签署 - 仅加密 - 签署并加密 15秒 1分钟 3分钟 @@ -97,17 +94,14 @@ 打开... 警告 错误 + 先设置密钥 安装了不匹配的文件管理器 密钥不匹配 - 不允许空的密钥 对称加密 删除成功 先选择一个文件 - 解密成功 - 加密成功 - 成功地加密到了剪贴板 输入两次密钥 选择至少一个加密密钥 选择至少一个加密密钥或者签名密钥 @@ -182,8 +176,6 @@ 或者 - 加密 - 解密 导入密钥 我的密钥 -- cgit v1.2.3 From a3a5085afb4ffa07093139176795d878a474f8d6 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 2 Apr 2014 13:21:11 +0200 Subject: Spacing corrections --- .../java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index d0a0d20ad..e0286b566 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -568,15 +568,14 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } } - private void checkEmptyIDsWanted() - { + private void checkEmptyIDsWanted() { try { ArrayList userIDs = getUserIds(mUserIdsView); List newIDs = mUserIdsView.getNewIDFlags(); ArrayList originalIDs = mUserIdsView.getOriginalIDs(); int curID = 0; for (String userID : userIDs) { - if ( userID.equals("") && (!userID.equals(originalIDs.get(curID)) || newIDs.get(curID) ) ) { + if (userID.equals("") && (!userID.equals(originalIDs.get(curID)) || newIDs.get(curID))) { AlertDialog.Builder alert = new AlertDialog.Builder( EditKeyActivity.this); -- cgit v1.2.3 From 77a6c509f70d7c7fb78e22573dd5785ec3895eeb Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 2 Apr 2014 13:34:42 +0200 Subject: Replace wildcard imports with explicit imports --- .../keychain/provider/ProviderHelper.java | 6 +++- .../keychain/service/KeychainIntentService.java | 36 +++++++++++++++++++--- .../keychain/service/PassphraseCacheService.java | 9 +++++- .../keychain/ui/CertifyKeyActivity.java | 8 ++++- .../keychain/ui/DrawerActivity.java | 13 ++++++-- .../keychain/ui/ImportKeysListFragment.java | 6 +++- .../keychain/ui/KeyListFragment.java | 20 ++++++++++-- .../keychain/ui/PreferencesActivity.java | 8 ++++- .../keychain/ui/SelectPublicKeyFragment.java | 8 ++++- .../ui/adapter/KeyValueSpinnerAdapter.java | 6 +++- .../keychain/ui/widget/UserIdEditor.java | 6 +++- .../keychain/util/HkpKeyServer.java | 15 +++++++-- .../keychain/util/PausableThreadPoolExecutor.java | 6 +++- 13 files changed, 126 insertions(+), 21 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java index 6882b6925..133b4e7f7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -17,7 +17,11 @@ package org.sufficientlysecure.keychain.provider; -import android.content.*; +import android.content.ContentProviderOperation; +import android.content.ContentResolver; +import android.content.ContentValues; +import android.content.Context; +import android.content.OperationApplicationException; import android.database.Cursor; import android.database.DatabaseUtils; import android.net.Uri; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 487da80ca..2a1b0be2e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -26,21 +26,47 @@ import android.os.Messenger; import android.os.RemoteException; import org.spongycastle.bcpg.sig.KeyFlags; -import org.spongycastle.openpgp.*; +import org.spongycastle.openpgp.PGPKeyRing; +import org.spongycastle.openpgp.PGPObjectFactory; +import org.spongycastle.openpgp.PGPPublicKey; +import org.spongycastle.openpgp.PGPPublicKeyRing; +import org.spongycastle.openpgp.PGPSecretKey; +import org.spongycastle.openpgp.PGPSecretKeyRing; +import org.spongycastle.openpgp.PGPUtil; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.FileHelper; import org.sufficientlysecure.keychain.helper.OtherHelper; import org.sufficientlysecure.keychain.helper.Preferences; -import org.sufficientlysecure.keychain.pgp.*; +import org.sufficientlysecure.keychain.pgp.PgpConversionHelper; +import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult; +import org.sufficientlysecure.keychain.pgp.PgpHelper; +import org.sufficientlysecure.keychain.pgp.PgpImportExport; +import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; +import org.sufficientlysecure.keychain.pgp.PgpKeyOperation; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralMsgIdException; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; -import org.sufficientlysecure.keychain.util.*; - -import java.io.*; +import org.sufficientlysecure.keychain.util.HkpKeyServer; +import org.sufficientlysecure.keychain.util.InputData; +import org.sufficientlysecure.keychain.util.KeychainServiceListener; +import org.sufficientlysecure.keychain.util.Log; +import org.sufficientlysecure.keychain.util.ProgressDialogUpdater; +import org.sufficientlysecure.keychain.util.ProgressScaler; + +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.util.ArrayList; import java.util.List; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java index 7ab40491f..bdce9069e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java @@ -24,7 +24,14 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.os.*; +import android.os.Binder; +import android.os.Bundle; +import android.os.Handler; +import android.os.HandlerThread; +import android.os.IBinder; +import android.os.Message; +import android.os.Messenger; +import android.os.RemoteException; import android.support.v4.util.LongSparseArray; import android.util.Log; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java index e7da531e1..8f7c82e8f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java @@ -32,8 +32,14 @@ import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.view.View; import android.view.View.OnClickListener; -import android.widget.*; +import android.widget.ArrayAdapter; +import android.widget.CheckBox; +import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; +import android.widget.ListView; +import android.widget.Spinner; +import android.widget.TextView; +import android.widget.Toast; import com.beardedhen.androidbootstrap.BootstrapButton; import org.spongycastle.openpgp.PGPPublicKeyRing; import org.sufficientlysecure.keychain.Constants; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java index e5a8fa8bc..17dce0221 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java @@ -27,9 +27,18 @@ import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.view.GravityCompat; import android.support.v4.widget.DrawerLayout; import android.support.v7.app.ActionBarActivity; -import android.view.*; -import android.widget.*; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; +import android.view.View; +import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.ListView; +import android.widget.TextView; + import com.beardedhen.androidbootstrap.FontAwesomeText; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysListFragment.java index 9e8506193..077fa0cab 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysListFragment.java @@ -29,7 +29,11 @@ import com.devspark.appmsg.AppMsg; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.helper.Preferences; -import org.sufficientlysecure.keychain.ui.adapter.*; +import org.sufficientlysecure.keychain.ui.adapter.AsyncTaskResultWrapper; +import org.sufficientlysecure.keychain.ui.adapter.ImportKeysAdapter; +import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; +import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListLoader; +import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListServerLoader; import org.sufficientlysecure.keychain.util.InputData; import org.sufficientlysecure.keychain.util.KeyServer; import org.sufficientlysecure.keychain.util.Log; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 3beb95108..1428a51f5 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -24,7 +24,11 @@ import android.content.Intent; import android.database.Cursor; import android.graphics.Color; import android.net.Uri; -import android.os.*; +import android.os.Build; +import android.os.Bundle; +import android.os.Handler; +import android.os.Message; +import android.os.Messenger; import android.support.v4.app.Fragment; import android.support.v4.app.LoaderManager; import android.support.v4.content.CursorLoader; @@ -33,11 +37,21 @@ import android.support.v4.view.MenuItemCompat; import android.support.v7.app.ActionBarActivity; import android.support.v7.widget.SearchView; import android.text.TextUtils; -import android.view.*; +import android.view.ActionMode; +import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; +import android.view.MenuItem; +import android.view.View; import android.view.View.OnClickListener; +import android.view.ViewGroup; import android.view.animation.AnimationUtils; -import android.widget.*; import android.widget.AbsListView.MultiChoiceModeListener; +import android.widget.AdapterView; +import android.widget.Button; +import android.widget.FrameLayout; +import android.widget.ListView; +import android.widget.TextView; import com.beardedhen.androidbootstrap.BootstrapButton; import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java index c541e8a23..54d37c72f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java @@ -20,9 +20,15 @@ import android.annotation.SuppressLint; import android.content.Intent; import android.os.Build; import android.os.Bundle; -import android.preference.*; +import android.preference.CheckBoxPreference; +import android.preference.Preference; +import android.preference.PreferenceActivity; +import android.preference.PreferenceFragment; +import android.preference.PreferenceScreen; + import org.spongycastle.bcpg.HashAlgorithmTags; import org.spongycastle.openpgp.PGPEncryptedData; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java index 6ab9f1c6e..2be5c12c3 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java @@ -32,7 +32,13 @@ import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.*; +import android.widget.EditText; +import android.widget.FrameLayout; +import android.widget.LinearLayout; +import android.widget.ListView; +import android.widget.ProgressBar; +import android.widget.TextView; + import org.sufficientlysecure.keychain.Id; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.compatibility.ListFragmentWorkaround; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyValueSpinnerAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyValueSpinnerAdapter.java index c997599bd..5b5d316b6 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyValueSpinnerAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/KeyValueSpinnerAdapter.java @@ -20,7 +20,11 @@ package org.sufficientlysecure.keychain.ui.adapter; import android.content.Context; import android.widget.ArrayAdapter; -import java.util.*; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; +import java.util.SortedSet; +import java.util.TreeSet; public class KeyValueSpinnerAdapter extends ArrayAdapter { private final HashMap mData; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index b21b99254..4b2387afb 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -24,7 +24,11 @@ import android.util.Patterns; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; -import android.widget.*; +import android.widget.ArrayAdapter; +import android.widget.AutoCompleteTextView; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.RadioButton; import com.beardedhen.androidbootstrap.BootstrapButton; import org.sufficientlysecure.keychain.R; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java index fbf93aeda..5efc732e4 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/HkpKeyServer.java @@ -29,6 +29,7 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.pgp.PgpHelper; import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; @@ -37,8 +38,18 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; -import java.net.*; -import java.util.*; +import java.net.HttpURLConnection; +import java.net.InetAddress; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLDecoder; +import java.net.URLEncoder; +import java.net.UnknownHostException; +import java.util.ArrayList; +import java.util.GregorianCalendar; +import java.util.List; +import java.util.Locale; +import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/PausableThreadPoolExecutor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/PausableThreadPoolExecutor.java index 377a8d5d6..5ec915810 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/PausableThreadPoolExecutor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/util/PausableThreadPoolExecutor.java @@ -17,7 +17,11 @@ package org.sufficientlysecure.keychain.util; -import java.util.concurrent.*; +import java.util.concurrent.BlockingQueue; +import java.util.concurrent.RejectedExecutionHandler; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.ReentrantLock; -- cgit v1.2.3 From c45c0f4a92750422dda762c70956a7a6fe0b556f Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 2 Apr 2014 13:35:16 +0200 Subject: Add wildcard import warning to checkstyle configuration --- tools/checkstyle.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/checkstyle.xml b/tools/checkstyle.xml index 95ef07a90..c99f858ab 100644 --- a/tools/checkstyle.xml +++ b/tools/checkstyle.xml @@ -12,7 +12,6 @@ page at http://checkstyle.sourceforge.net/config.html --> - + + + + + + + -- cgit v1.2.3 From fc29fadd51da5bed9c8c1841f65bb20aacd9c5e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 2 Apr 2014 13:54:38 +0200 Subject: Fix build --- .../org/sufficientlysecure/keychain/service/KeychainIntentService.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 2a1b0be2e..1c334e6d6 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -41,11 +41,13 @@ import org.sufficientlysecure.keychain.helper.FileHelper; import org.sufficientlysecure.keychain.helper.OtherHelper; import org.sufficientlysecure.keychain.helper.Preferences; import org.sufficientlysecure.keychain.pgp.PgpConversionHelper; +import org.sufficientlysecure.keychain.pgp.PgpDecryptVerify; import org.sufficientlysecure.keychain.pgp.PgpDecryptVerifyResult; import org.sufficientlysecure.keychain.pgp.PgpHelper; import org.sufficientlysecure.keychain.pgp.PgpImportExport; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyOperation; +import org.sufficientlysecure.keychain.pgp.PgpSignEncrypt; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralMsgIdException; import org.sufficientlysecure.keychain.provider.ProviderHelper; -- cgit v1.2.3 From 26837f2a8024a8f6934c15c05be22a737153908c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 2 Apr 2014 14:00:46 +0200 Subject: Started changelog for 2.5 --- OpenPGP-Keychain/src/main/res/raw/help_changelog.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/OpenPGP-Keychain/src/main/res/raw/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw/help_changelog.html index 595878fe7..8138fd0bd 100644 --- a/OpenPGP-Keychain/src/main/res/raw/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw/help_changelog.html @@ -5,6 +5,14 @@ And don't add newlines before or after p tags because of transifex --> +

                                                  2.5

                                                  +
                                                    +
                                                  • fix decryption of symmetric pgp messages/files
                                                  • +
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • new modern design for encrypt/decrypt screens
                                                  • +
                                                  +

                                                  2.4

                                                  Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): -- cgit v1.2.3 From 62bd817f862dc71239419597920ecb1df41c4c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Wed, 2 Apr 2014 15:19:51 +0200 Subject: Cleanup example code --- .../keychain/demo/OpenPgpProviderActivity.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java index 42722c5e1..345d63eef 100644 --- a/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java +++ b/OpenPGP-Keychain-API/example-app/src/main/java/org/sufficientlysecure/keychain/demo/OpenPgpProviderActivity.java @@ -58,8 +58,8 @@ public class OpenPgpProviderActivity extends Activity { public static final int REQUEST_CODE_DECRYPT_AND_VERIFY = 9913; @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); setContentView(R.layout.openpgp_provider); mMessage = (EditText) findViewById(R.id.crypto_provider_demo_message); @@ -171,7 +171,7 @@ public class OpenPgpProviderActivity extends Activity { @Override public void onReturn(Intent result) { - switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, 0)) { + switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) { case OpenPgpApi.RESULT_CODE_SUCCESS: { try { Log.d(OpenPgpApi.TAG, "result: " + os.toByteArray().length @@ -218,7 +218,7 @@ public class OpenPgpProviderActivity extends Activity { data.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, mAccount.getText().toString()); InputStream is = getInputstream(false); - final ByteArrayOutputStream os = new ByteArrayOutputStream(); + ByteArrayOutputStream os = new ByteArrayOutputStream(); OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); api.executeApiAsync(data, is, os, new MyCallback(true, os, REQUEST_CODE_SIGN)); @@ -231,7 +231,7 @@ public class OpenPgpProviderActivity extends Activity { data.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, mAccount.getText().toString()); InputStream is = getInputstream(false); - final ByteArrayOutputStream os = new ByteArrayOutputStream(); + ByteArrayOutputStream os = new ByteArrayOutputStream(); OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); api.executeApiAsync(data, is, os, new MyCallback(true, os, REQUEST_CODE_ENCRYPT)); @@ -244,7 +244,7 @@ public class OpenPgpProviderActivity extends Activity { data.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, mAccount.getText().toString()); InputStream is = getInputstream(false); - final ByteArrayOutputStream os = new ByteArrayOutputStream(); + ByteArrayOutputStream os = new ByteArrayOutputStream(); OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); api.executeApiAsync(data, is, os, new MyCallback(true, os, REQUEST_CODE_SIGN_AND_ENCRYPT)); @@ -256,7 +256,7 @@ public class OpenPgpProviderActivity extends Activity { data.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, mAccount.getText().toString()); InputStream is = getInputstream(true); - final ByteArrayOutputStream os = new ByteArrayOutputStream(); + ByteArrayOutputStream os = new ByteArrayOutputStream(); OpenPgpApi api = new OpenPgpApi(this, mServiceConnection.getService()); api.executeApiAsync(data, is, os, new MyCallback(false, os, REQUEST_CODE_DECRYPT_AND_VERIFY)); -- cgit v1.2.3 From 6ac13d9f6933bf72950910b0e2831761dd8c434b Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 2 Apr 2014 15:31:03 +0200 Subject: Rename "pass phrase" to "passphrase" --- .../org/sufficientlysecure/keychain/Constants.java | 2 +- .../keychain/helper/Preferences.java | 8 ++--- .../keychain/pgp/PgpKeyOperation.java | 42 +++++++++++----------- .../keychain/service/KeychainIntentService.java | 18 +++++----- .../keychain/service/PassphraseCacheService.java | 2 +- .../keychain/service/SaveKeyringParcel.java | 12 +++---- .../keychain/ui/EditKeyActivity.java | 40 ++++++++++----------- .../keychain/ui/EncryptFileFragment.java | 4 +-- .../keychain/ui/EncryptMessageFragment.java | 4 +-- .../keychain/ui/PreferencesActivity.java | 14 ++++---- 10 files changed, 73 insertions(+), 73 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java index 5062800db..84c7f0f41 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java @@ -58,7 +58,7 @@ public final class Constants { public static final String DEFAULT_ASCII_ARMOUR = "defaultAsciiArmour"; public static final String DEFAULT_MESSAGE_COMPRESSION = "defaultMessageCompression"; public static final String DEFAULT_FILE_COMPRESSION = "defaultFileCompression"; - public static final String PASS_PHRASE_CACHE_TTL = "passphraseCacheTtl"; + public static final String PASSPHRASE_CACHE_TTL = "passphraseCacheTtl"; public static final String LANGUAGE = "language"; public static final String FORCE_V3_SIGNATURES = "forceV3Signatures"; public static final String KEY_SERVERS = "keyServers"; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java index 13b1df4d4..e91572ade 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java @@ -58,8 +58,8 @@ public class Preferences { editor.commit(); } - public long getPassPhraseCacheTtl() { - int ttl = mSharedPreferences.getInt(Constants.Pref.PASS_PHRASE_CACHE_TTL, 180); + public long getPassphraseCacheTtl() { + int ttl = mSharedPreferences.getInt(Constants.Pref.PASSPHRASE_CACHE_TTL, 180); // fix the value if it was set to "never" in previous versions, which currently is not // supported if (ttl == 0) { @@ -68,9 +68,9 @@ public class Preferences { return (long) ttl; } - public void setPassPhraseCacheTtl(int value) { + public void setPassphraseCacheTtl(int value) { SharedPreferences.Editor editor = mSharedPreferences.edit(); - editor.putInt(Constants.Pref.PASS_PHRASE_CACHE_TTL, value); + editor.putInt(Constants.Pref.PASSPHRASE_CACHE_TTL, value); editor.commit(); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java index ceccf7a70..48b959738 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java @@ -195,25 +195,25 @@ public class PgpKeyOperation { sha1Calc, isMasterKey, keyEncryptor); } - public PGPSecretKeyRing changeSecretKeyPassphrase(PGPSecretKeyRing keyRing, String oldPassPhrase, - String newPassPhrase) + public PGPSecretKeyRing changeSecretKeyPassphrase(PGPSecretKeyRing keyRing, String oldPassphrase, + String newPassphrase) throws IOException, PGPException, NoSuchProviderException { updateProgress(R.string.progress_building_key, 0, 100); - if (oldPassPhrase == null) { - oldPassPhrase = ""; + if (oldPassphrase == null) { + oldPassphrase = ""; } - if (newPassPhrase == null) { - newPassPhrase = ""; + if (newPassphrase == null) { + newPassphrase = ""; } PGPSecretKeyRing newKeyRing = PGPSecretKeyRing.copyWithNewPassword( keyRing, new JcePBESecretKeyDecryptorBuilder(new JcaPGPDigestCalculatorProviderBuilder() .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build()).setProvider( - Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassPhrase.toCharArray()), + Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassphrase.toCharArray()), new JcePBESecretKeyEncryptorBuilder(keyRing.getSecretKey() - .getKeyEncryptionAlgorithm()).build(newPassPhrase.toCharArray())); + .getKeyEncryptionAlgorithm()).build(newPassphrase.toCharArray())); return newKeyRing; @@ -223,7 +223,7 @@ public class PgpKeyOperation { ArrayList userIds, ArrayList keys, ArrayList keysExpiryDates, ArrayList keysUsages, - String newPassPhrase, String oldPassPhrase) + String newPassphrase, String oldPassphrase) throws PgpGeneralMsgIdException, PGPException, SignatureException, IOException { int usageId = keysUsages.get(0); @@ -236,7 +236,7 @@ public class PgpKeyOperation { PGPPublicKey masterPublicKey = masterKey.getPublicKey(); PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider( - Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassPhrase.toCharArray()); + Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(oldPassphrase.toCharArray()); PGPPrivateKey masterPrivateKey = masterKey.extractPrivateKey(keyDecryptor); updateProgress(R.string.progress_certifying_master_key, 20, 100); @@ -294,7 +294,7 @@ public class PgpKeyOperation { PBESecretKeyEncryptor keyEncryptor = new JcePBESecretKeyEncryptorBuilder( PGPEncryptedData.CAST5, sha1Calc) .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( - newPassPhrase.toCharArray()); + newPassphrase.toCharArray()); PGPKeyRingGenerator keyGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, masterKeyPair, mainUserId, sha1Calc, hashedPacketsGen.generate(), @@ -310,7 +310,7 @@ public class PgpKeyOperation { PBESecretKeyDecryptor keyDecryptor2 = new JcePBESecretKeyDecryptorBuilder() .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( - oldPassPhrase.toCharArray()); + oldPassphrase.toCharArray()); PGPPrivateKey subPrivateKey = subKey.extractPrivateKey(keyDecryptor2); // TODO: now used without algorithm and creation time?! (APG 1) @@ -375,16 +375,16 @@ public class PgpKeyOperation { updateProgress(R.string.progress_building_key, 0, 100); PGPSecretKey masterKey = saveParcel.keys.get(0); - if (saveParcel.oldPassPhrase == null) { - saveParcel.oldPassPhrase = ""; + if (saveParcel.oldPassphrase == null) { + saveParcel.oldPassphrase = ""; } - if (saveParcel.newPassPhrase == null) { - saveParcel.newPassPhrase = ""; + if (saveParcel.newPassphrase == null) { + saveParcel.newPassphrase = ""; } if (mKR == null) { return buildNewSecretKey(saveParcel.userIDs, saveParcel.keys, saveParcel.keysExpiryDates, - saveParcel.keysUsages, saveParcel.newPassPhrase, saveParcel.oldPassPhrase); //new Keyring + saveParcel.keysUsages, saveParcel.newPassphrase, saveParcel.oldPassphrase); //new Keyring } /* @@ -423,7 +423,7 @@ public class PgpKeyOperation { String mainUserId = saveParcel.userIDs.get(0); PBESecretKeyDecryptor keyDecryptor = new JcePBESecretKeyDecryptorBuilder().setProvider( - Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(saveParcel.oldPassPhrase.toCharArray()); + Constants.BOUNCY_CASTLE_PROVIDER_NAME).build(saveParcel.oldPassphrase.toCharArray()); PGPPrivateKey masterPrivateKey = masterKey.extractPrivateKey(keyDecryptor); updateProgress(R.string.progress_certifying_master_key, 20, 100); @@ -565,7 +565,7 @@ public class PgpKeyOperation { PBESecretKeyEncryptor keyEncryptor = new JcePBESecretKeyEncryptorBuilder( PGPEncryptedData.CAST5, sha1Calc) .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( - saveParcel.oldPassPhrase.toCharArray()); + saveParcel.oldPassphrase.toCharArray()); //this generates one more signature than necessary... PGPKeyRingGenerator keyGen = new PGPKeyRingGenerator(PGPSignature.POSITIVE_CERTIFICATION, @@ -586,7 +586,7 @@ public class PgpKeyOperation { } else { keyDecryptor2 = new JcePBESecretKeyDecryptorBuilder() .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( - saveParcel.oldPassPhrase.toCharArray()); + saveParcel.oldPassphrase.toCharArray()); } PGPPrivateKey subPrivateKey = subKey.extractPrivateKey(keyDecryptor2); PGPKeyPair subKeyPair = new PGPKeyPair(subPublicKey, subPrivateKey); @@ -667,7 +667,7 @@ public class PgpKeyOperation { PBESecretKeyEncryptor keyEncryptorNew = new JcePBESecretKeyEncryptorBuilder( PGPEncryptedData.CAST5, sha1Calc) .setProvider(Constants.BOUNCY_CASTLE_PROVIDER_NAME).build( - saveParcel.newPassPhrase.toCharArray()); + saveParcel.newPassphrase.toCharArray()); //update the passphrase mKR = PGPSecretKeyRing.copyWithNewPassword(mKR, keyDecryptor, keyEncryptorNew); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 1c334e6d6..e9c949246 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -488,16 +488,16 @@ public class KeychainIntentService extends IntentService try { /* Input */ SaveKeyringParcel saveParams = data.getParcelable(SAVE_KEYRING_PARCEL); - String oldPassPhrase = saveParams.oldPassPhrase; - String newPassPhrase = saveParams.newPassPhrase; + String oldPassphrase = saveParams.oldPassphrase; + String newPassphrase = saveParams.newPassphrase; boolean canSign = true; if (data.containsKey(SAVE_KEYRING_CAN_SIGN)) { canSign = data.getBoolean(SAVE_KEYRING_CAN_SIGN); } - if (newPassPhrase == null) { - newPassPhrase = oldPassPhrase; + if (newPassphrase == null) { + newPassphrase = oldPassphrase; } long masterKeyId = saveParams.keys.get(0).getKeyID(); @@ -508,7 +508,7 @@ public class KeychainIntentService extends IntentService PGPSecretKeyRing keyRing = ProviderHelper .getPGPSecretKeyRingByKeyId(this, masterKeyId); keyRing = keyOperations.changeSecretKeyPassphrase(keyRing, - oldPassPhrase, newPassPhrase); + oldPassphrase, newPassphrase); setProgress(R.string.progress_saving_key_ring, 50, 100); ProviderHelper.saveKeyRing(this, keyRing); setProgress(R.string.progress_done, 100, 100); @@ -526,7 +526,7 @@ public class KeychainIntentService extends IntentService ProviderHelper.saveKeyRing(this, pair.second); setProgress(R.string.progress_done, 100, 100); } - PassphraseCacheService.addCachedPassphrase(this, masterKeyId, newPassPhrase); + PassphraseCacheService.addCachedPassphrase(this, masterKeyId, newPassphrase); /* Output */ sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_OKAY); @@ -816,9 +816,9 @@ public class KeychainIntentService extends IntentService ArrayList userIds = data.getStringArrayList(CERTIFY_KEY_UIDS); /* Operation */ - String signaturePassPhrase = PassphraseCacheService.getCachedPassphrase(this, + String signaturePassphrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId); - if (signaturePassPhrase == null) { + if (signaturePassphrase == null) { throw new PgpGeneralException("Unable to obtain passphrase"); } @@ -829,7 +829,7 @@ public class KeychainIntentService extends IntentService PGPSecretKey certificationKey = PgpKeyHelper.getCertificationKey(this, masterKeyId); publicKey = keyOperation.certifyKey(certificationKey, publicKey, - userIds, signaturePassPhrase); + userIds, signaturePassphrase); publicRing = PGPPublicKeyRing.insertPublicKey(publicRing, publicKey); // store the signed key in our local cache diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java index bdce9069e..a4b6ab6b9 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java @@ -95,7 +95,7 @@ public class PassphraseCacheService extends Service { Intent intent = new Intent(context, PassphraseCacheService.class); intent.setAction(ACTION_PASSPHRASE_CACHE_ADD); - intent.putExtra(EXTRA_TTL, Preferences.getPreferences(context).getPassPhraseCacheTtl()); + intent.putExtra(EXTRA_TTL, Preferences.getPreferences(context).getPassphraseCacheTtl()); intent.putExtra(EXTRA_PASSPHRASE, passphrase); intent.putExtra(EXTRA_KEY_ID, keyId); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java index 7012bfafd..7c2dcf2c1 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java @@ -38,8 +38,8 @@ public class SaveKeyringParcel implements Parcelable { public ArrayList deletedKeys; public ArrayList keysExpiryDates; public ArrayList keysUsages; - public String newPassPhrase; - public String oldPassPhrase; + public String newPassphrase; + public String oldPassphrase; public boolean[] newKeys; public ArrayList keys; public String originalPrimaryID; @@ -61,8 +61,8 @@ public class SaveKeyringParcel implements Parcelable { } keysExpiryDates = (ArrayList) source.readSerializable(); keysUsages = source.readArrayList(Integer.class.getClassLoader()); - newPassPhrase = source.readString(); - oldPassPhrase = source.readString(); + newPassphrase = source.readString(); + oldPassphrase = source.readString(); newKeys = source.createBooleanArray(); keys = PgpConversionHelper.BytesToPGPSecretKeyList(source.createByteArray()); originalPrimaryID = source.readString(); @@ -83,8 +83,8 @@ public class SaveKeyringParcel implements Parcelable { destination.writeByteArray(tmp); destination.writeSerializable(keysExpiryDates); destination.writeList(keysUsages); - destination.writeString(newPassPhrase); - destination.writeString(oldPassPhrase); + destination.writeString(newPassphrase); + destination.writeString(oldPassphrase); destination.writeBooleanArray(newKeys); destination.writeByteArray(PgpConversionHelper.PGPSecretKeyArrayListToBytes(keys)); destination.writeString(originalPrimaryID); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index e0286b566..30636f849 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -97,9 +97,9 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener private SectionView mKeysView; private String mCurrentPassphrase = null; - private String mNewPassPhrase = null; - private String mSavedNewPassPhrase = null; - private boolean mIsPassPhraseSet; + private String mNewPassphrase = null; + private String mSavedNewPassphrase = null; + private boolean mIsPassphraseSet; private boolean mNeedsSaving; private boolean mIsBrandNewKeyring = false; @@ -403,8 +403,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener mCurrentPassphrase = ""; buildLayout(false); - mIsPassPhraseSet = PassphraseCacheService.hasPassphrase(this, masterKeyId); - if (!mIsPassPhraseSet) { + mIsPassphraseSet = PassphraseCacheService.hasPassphrase(this, masterKeyId); + if (!mIsPassphraseSet) { // check "no passphrase" checkbox and remove button mNoPassphrase.setChecked(true); mChangePassphrase.setVisibility(View.GONE); @@ -423,10 +423,10 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener Bundle data = message.getData(); // set new returned passphrase! - mNewPassPhrase = data + mNewPassphrase = data .getString(SetPassphraseDialogFragment.MESSAGE_NEW_PASSPHRASE); - updatePassPhraseButtonText(); + updatePassphraseButtonText(); somethingChanged(); } } @@ -466,7 +466,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); LinearLayout container = (LinearLayout) findViewById(R.id.edit_key_container); - if (mIsPassPhraseSet) { + if (mIsPassphraseSet) { mChangePassphrase.setText(getString(R.string.btn_change_passphrase)); } mUserIdsView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false); @@ -482,7 +482,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener mKeysView.setEditorListener(this); container.addView(mKeysView); - updatePassPhraseButtonText(); + updatePassphraseButtonText(); mChangePassphrase.setOnClickListener(new OnClickListener() { public void onClick(View v) { @@ -497,11 +497,11 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { // remove passphrase - mSavedNewPassPhrase = mNewPassPhrase; - mNewPassPhrase = ""; + mSavedNewPassphrase = mNewPassphrase; + mNewPassphrase = ""; mChangePassphrase.setVisibility(View.GONE); } else { - mNewPassPhrase = mSavedNewPassPhrase; + mNewPassphrase = mSavedNewPassphrase; mChangePassphrase.setVisibility(View.VISIBLE); } somethingChanged(); @@ -519,8 +519,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener public boolean isPassphraseSet() { if (mNoPassphrase.isChecked()) { return true; - } else if ((mIsPassPhraseSet) - || (mNewPassPhrase != null && !mNewPassPhrase.equals(""))) { + } else if ((mIsPassphraseSet) + || (mNewPassphrase != null && !mNewPassphrase.equals(""))) { return true; } else { return false; @@ -530,9 +530,9 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener public boolean hasPassphraseChanged() { if (mNoPassphrase != null) { if (mNoPassphrase.isChecked()) { - return mIsPassPhraseSet; + return mIsPassphraseSet; } else { - return (mNewPassPhrase != null && !mNewPassPhrase.equals("")); + return (mNewPassphrase != null && !mNewPassphrase.equals("")); } } else { return false; @@ -548,7 +548,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } String passphrase; - if (mIsPassPhraseSet) { + if (mIsPassphraseSet) { passphrase = PassphraseCacheService.getCachedPassphrase(this, masterKeyId); } else { passphrase = ""; @@ -638,8 +638,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener saveParams.deletedKeys = mKeysView.getDeletedKeys(); saveParams.keysExpiryDates = getKeysExpiryDates(mKeysView); saveParams.keysUsages = getKeysUsages(mKeysView); - saveParams.newPassPhrase = mNewPassPhrase; - saveParams.oldPassPhrase = mCurrentPassphrase; + saveParams.newPassphrase = mNewPassphrase; + saveParams.oldPassphrase = mCurrentPassphrase; saveParams.newKeys = toPrimitiveArray(mKeysView.getNewKeysArray()); saveParams.keys = getKeys(mKeysView); saveParams.originalPrimaryID = mUserIdsView.getOriginalPrimaryID(); @@ -819,7 +819,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener return keysExpiryDates; } - private void updatePassPhraseButtonText() { + private void updatePassphraseButtonText() { mChangePassphrase.setText(isPassphraseSet() ? getString(R.string.btn_change_passphrase) : getString(R.string.btn_set_passphrase)); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java index c8ea6ffb7..8b440a552 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java @@ -224,9 +224,9 @@ public class EncryptFileFragment extends Fragment { if (mEncryptInterface.isModeSymmetric()) { // symmetric encryption - boolean gotPassPhrase = (mEncryptInterface.getPassphrase() != null + boolean gotPassphrase = (mEncryptInterface.getPassphrase() != null && mEncryptInterface.getPassphrase().length() != 0); - if (!gotPassPhrase) { + if (!gotPassphrase) { AppMsg.makeText(getActivity(), R.string.passphrase_must_not_be_empty, AppMsg.STYLE_ALERT) .show(); return; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java index 4522acf4e..a7818a1d8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptMessageFragment.java @@ -125,9 +125,9 @@ public class EncryptMessageFragment extends Fragment { if (mEncryptInterface.isModeSymmetric()) { // symmetric encryption - boolean gotPassPhrase = (mEncryptInterface.getPassphrase() != null + boolean gotPassphrase = (mEncryptInterface.getPassphrase() != null && mEncryptInterface.getPassphrase().length() != 0); - if (!gotPassPhrase) { + if (!gotPassphrase) { AppMsg.makeText(getActivity(), R.string.passphrase_must_not_be_empty, AppMsg.STYLE_ALERT) .show(); return; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java index 54d37c72f..57841edde 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java @@ -61,8 +61,8 @@ public class PreferencesActivity extends PreferenceActivity { if (action != null && action.equals(ACTION_PREFS_GEN)) { addPreferencesFromResource(R.xml.gen_preferences); - initializePassPassPhraceCacheTtl( - (IntegerListPreference) findPreference(Constants.Pref.PASS_PHRASE_CACHE_TTL)); + initializePassPassphraceCacheTtl( + (IntegerListPreference) findPreference(Constants.Pref.PASSPHRASE_CACHE_TTL)); mKeyServerPreference = (PreferenceScreen) findPreference(Constants.Pref.KEY_SERVERS); String servers[] = sPreferences.getKeyServers(); @@ -165,8 +165,8 @@ public class PreferencesActivity extends PreferenceActivity { // Load the preferences from an XML resource addPreferencesFromResource(R.xml.gen_preferences); - initializePassPassPhraceCacheTtl( - (IntegerListPreference) findPreference(Constants.Pref.PASS_PHRASE_CACHE_TTL)); + initializePassPassphraceCacheTtl( + (IntegerListPreference) findPreference(Constants.Pref.PASSPHRASE_CACHE_TTL)); mKeyServerPreference = (PreferenceScreen) findPreference(Constants.Pref.KEY_SERVERS); String servers[] = sPreferences.getKeyServers(); @@ -261,15 +261,15 @@ public class PreferencesActivity extends PreferenceActivity { || super.isValidFragment(fragmentName); } - private static void initializePassPassPhraceCacheTtl(final IntegerListPreference mPassphraseCacheTtl) { - mPassphraseCacheTtl.setValue("" + sPreferences.getPassPhraseCacheTtl()); + private static void initializePassPassphraceCacheTtl(final IntegerListPreference mPassphraseCacheTtl) { + mPassphraseCacheTtl.setValue("" + sPreferences.getPassphraseCacheTtl()); mPassphraseCacheTtl.setSummary(mPassphraseCacheTtl.getEntry()); mPassphraseCacheTtl .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { mPassphraseCacheTtl.setValue(newValue.toString()); mPassphraseCacheTtl.setSummary(mPassphraseCacheTtl.getEntry()); - sPreferences.setPassPhraseCacheTtl(Integer.parseInt(newValue.toString())); + sPreferences.setPassphraseCacheTtl(Integer.parseInt(newValue.toString())); return false; } }); -- cgit v1.2.3 From c4c9713da467d2d1f1d7d1cb50d72524d769b21b Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 2 Apr 2014 15:36:32 +0200 Subject: Rename "armour" to "armor" --- .../org/sufficientlysecure/keychain/Constants.java | 2 +- .../keychain/helper/Preferences.java | 8 ++++---- .../keychain/ui/EncryptFileFragment.java | 4 ++-- .../keychain/ui/PreferencesActivity.java | 18 +++++++++--------- .../main/res/layout/encrypt_content_adv_settings.xml | 4 ++-- OpenPGP-Keychain/src/main/res/xml/adv_preferences.xml | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java index 84c7f0f41..5b9f53b09 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/Constants.java @@ -55,7 +55,7 @@ public final class Constants { public static final class Pref { public static final String DEFAULT_ENCRYPTION_ALGORITHM = "defaultEncryptionAlgorithm"; public static final String DEFAULT_HASH_ALGORITHM = "defaultHashAlgorithm"; - public static final String DEFAULT_ASCII_ARMOUR = "defaultAsciiArmour"; + public static final String DEFAULT_ASCII_ARMOR = "defaultAsciiArmor"; public static final String DEFAULT_MESSAGE_COMPRESSION = "defaultMessageCompression"; public static final String DEFAULT_FILE_COMPRESSION = "defaultFileCompression"; public static final String PASSPHRASE_CACHE_TTL = "passphraseCacheTtl"; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java index e91572ade..ca5555fea 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/helper/Preferences.java @@ -118,13 +118,13 @@ public class Preferences { editor.commit(); } - public boolean getDefaultAsciiArmour() { - return mSharedPreferences.getBoolean(Constants.Pref.DEFAULT_ASCII_ARMOUR, false); + public boolean getDefaultAsciiArmor() { + return mSharedPreferences.getBoolean(Constants.Pref.DEFAULT_ASCII_ARMOR, false); } - public void setDefaultAsciiArmour(boolean value) { + public void setDefaultAsciiArmor(boolean value) { SharedPreferences.Editor editor = mSharedPreferences.edit(); - editor.putBoolean(Constants.Pref.DEFAULT_ASCII_ARMOUR, value); + editor.putBoolean(Constants.Pref.DEFAULT_ASCII_ARMOR, value); editor.commit(); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java index 8b440a552..01422ea13 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFileFragment.java @@ -138,8 +138,8 @@ public class EncryptFileFragment extends Fragment { mDeleteAfter = (CheckBox) view.findViewById(R.id.deleteAfterEncryption); mShareAfter = (CheckBox) view.findViewById(R.id.shareAfterEncryption); - mAsciiArmor = (CheckBox) view.findViewById(R.id.asciiArmour); - mAsciiArmor.setChecked(Preferences.getPreferences(getActivity()).getDefaultAsciiArmour()); + mAsciiArmor = (CheckBox) view.findViewById(R.id.asciiArmor); + mAsciiArmor.setChecked(Preferences.getPreferences(getActivity()).getDefaultAsciiArmor()); return view; } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java index 57841edde..265bb2139 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/PreferencesActivity.java @@ -110,8 +110,8 @@ public class PreferencesActivity extends PreferenceActivity { (IntegerListPreference) findPreference(Constants.Pref.DEFAULT_FILE_COMPRESSION), entries, values); - initializeAsciiArmour( - (CheckBoxPreference) findPreference(Constants.Pref.DEFAULT_ASCII_ARMOUR)); + initializeAsciiArmor( + (CheckBoxPreference) findPreference(Constants.Pref.DEFAULT_ASCII_ARMOR)); initializeForceV3Signatures( (CheckBoxPreference) findPreference(Constants.Pref.FORCE_V3_SIGNATURES)); @@ -247,8 +247,8 @@ public class PreferencesActivity extends PreferenceActivity { (IntegerListPreference) findPreference(Constants.Pref.DEFAULT_FILE_COMPRESSION), entries, values); - initializeAsciiArmour( - (CheckBoxPreference) findPreference(Constants.Pref.DEFAULT_ASCII_ARMOUR)); + initializeAsciiArmor( + (CheckBoxPreference) findPreference(Constants.Pref.DEFAULT_ASCII_ARMOR)); initializeForceV3Signatures( (CheckBoxPreference) findPreference(Constants.Pref.FORCE_V3_SIGNATURES)); @@ -362,12 +362,12 @@ public class PreferencesActivity extends PreferenceActivity { }); } - private static void initializeAsciiArmour(final CheckBoxPreference mAsciiArmour) { - mAsciiArmour.setChecked(sPreferences.getDefaultAsciiArmour()); - mAsciiArmour.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + private static void initializeAsciiArmor(final CheckBoxPreference mAsciiArmor) { + mAsciiArmor.setChecked(sPreferences.getDefaultAsciiArmor()); + mAsciiArmor.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { - mAsciiArmour.setChecked((Boolean) newValue); - sPreferences.setDefaultAsciiArmour((Boolean) newValue); + mAsciiArmor.setChecked((Boolean) newValue); + sPreferences.setDefaultAsciiArmor((Boolean) newValue); return false; } }); diff --git a/OpenPGP-Keychain/src/main/res/layout/encrypt_content_adv_settings.xml b/OpenPGP-Keychain/src/main/res/layout/encrypt_content_adv_settings.xml index 2281759d1..ac990653a 100644 --- a/OpenPGP-Keychain/src/main/res/layout/encrypt_content_adv_settings.xml +++ b/OpenPGP-Keychain/src/main/res/layout/encrypt_content_adv_settings.xml @@ -54,10 +54,10 @@ android:orientation="horizontal"> - \ No newline at end of file + diff --git a/OpenPGP-Keychain/src/main/res/xml/adv_preferences.xml b/OpenPGP-Keychain/src/main/res/xml/adv_preferences.xml index 2705bd22f..03f93b051 100644 --- a/OpenPGP-Keychain/src/main/res/xml/adv_preferences.xml +++ b/OpenPGP-Keychain/src/main/res/xml/adv_preferences.xml @@ -35,7 +35,7 @@ android:title="@string/label_file_compression" /> @@ -45,4 +45,4 @@ android:persistent="false" android:title="@string/label_force_v3_signature" /> - \ No newline at end of file + -- cgit v1.2.3 From 7a66ccb5ee5d3de8f3814267969139397de45e12 Mon Sep 17 00:00:00 2001 From: Thialfihar Date: Wed, 2 Apr 2014 15:43:29 +0200 Subject: Rename "canEdit" to "canBeEdited" --- .../sufficientlysecure/keychain/ui/EditKeyActivity.java | 4 ++-- .../sufficientlysecure/keychain/ui/widget/KeyEditor.java | 4 ++-- .../sufficientlysecure/keychain/ui/widget/SectionView.java | 14 +++++++------- .../keychain/ui/widget/UserIdEditor.java | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 30636f849..b0cca4a7a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -471,13 +471,13 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener } mUserIdsView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false); mUserIdsView.setType(Id.type.user_id); - mUserIdsView.setCanEdit(mMasterCanSign); + mUserIdsView.setCanBeEdited(mMasterCanSign); mUserIdsView.setUserIds(mUserIds); mUserIdsView.setEditorListener(this); container.addView(mUserIdsView); mKeysView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false); mKeysView.setType(Id.type.key); - mKeysView.setCanEdit(mMasterCanSign); + mKeysView.setCanBeEdited(mMasterCanSign); mKeysView.setKeys(mKeys, mKeysUsages, newKeys); mKeysView.setEditorListener(this); container.addView(mKeysView); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java index 5fd06f4fc..c7bd1c987 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/KeyEditor.java @@ -196,8 +196,8 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { super.onFinishInflate(); } - public void setCanEdit(boolean bCanEdit) { - if (!bCanEdit) { + public void setCanBeEdited(boolean canBeEdited) { + if (!canBeEdited) { mDeleteButton.setVisibility(View.INVISIBLE); mExpiryDateButton.setEnabled(false); mChkSign.setEnabled(false); //certify is always disabled diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java index 1f388e865..fb59cd3b7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/SectionView.java @@ -64,7 +64,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor private boolean mOldItemDeleted = false; private ArrayList mDeletedIDs = new ArrayList(); private ArrayList mDeletedKeys = new ArrayList(); - private boolean mCanEdit = true; + private boolean mCanBeEdited = true; private ActionBarActivity mActivity; @@ -107,9 +107,9 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor } } - public void setCanEdit(boolean bCanEdit) { - mCanEdit = bCanEdit; - if (!mCanEdit) { + public void setCanBeEdited(boolean canBeEdited) { + mCanBeEdited = canBeEdited; + if (!mCanBeEdited) { mPlusButton.setVisibility(View.INVISIBLE); } } @@ -265,7 +265,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor * {@inheritDoc} */ public void onClick(View v) { - if (mCanEdit) { + if (mCanBeEdited) { switch (mType) { case Id.type.user_id: { UserIdEditor view = (UserIdEditor) mInflater.inflate( @@ -315,7 +315,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor mEditors, false); view.setEditorListener(this); view.setValue(userId, mEditors.getChildCount() == 0, false); - view.setCanEdit(mCanEdit); + view.setCanBeEdited(mCanBeEdited); mEditors.addView(view); } @@ -336,7 +336,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor view.setEditorListener(this); boolean isMasterKey = (mEditors.getChildCount() == 0); view.setValue(list.get(i), isMasterKey, usages.get(i), newKeys); - view.setCanEdit(mCanEdit); + view.setCanBeEdited(mCanBeEdited); mEditors.addView(view); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java index 4b2387afb..2253872d5 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/widget/UserIdEditor.java @@ -52,8 +52,8 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene private boolean mOriginallyMainUserID; private boolean mIsNewId; - public void setCanEdit(boolean bCanEdit) { - if (!bCanEdit) { + public void setCanBeEdited(boolean canBeEdited) { + if (!canBeEdited) { mDeleteButton.setVisibility(View.INVISIBLE); mName.setEnabled(false); mIsMainUserId.setEnabled(false); -- cgit v1.2.3 From a7eff41ced8b5622f6ed96a5b834677314ae7ca8 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Thu, 3 Apr 2014 01:34:35 +0200 Subject: Break a lot of stuff. Also, database redesign. Change entire database design. This introduces a lot of changes, notably all URIs and almost all projections. Some features (like key deletion) have been simply commented out for now since they need serious reconsideration. There are a couple of new TODOs marking places where more work is needed. The migration path works fine from what I tested. The old database is not deleted for now, ie, it is reimported at every start of the application making all intermediate changes transient. Tested and working (for me): - All activities in the main drawer - Multiselect and Search - ViewKeyActivity, with and without secret key available - CertifyKeyActivity - SelectSecretKeyActivity (from CertifyKeyActivity) - SelectPublicKeyActivity (from encrypt activity) What doesn't work: - Actually certifying keys (pending a TODO in ProviderHelper) - Importing keys doesn't preserve secret keys - "Encrypt to this contact" doesn't pass key - Editing keys. All controls are disabled, I'm not sure why... (is this even my fault?) - Deleting keys What I didn't test: - Key export - API stuff - Creating keys (since editing doesn't even work) --- .../keychain/pgp/PgpDecryptVerify.java | 8 +- .../sufficientlysecure/keychain/pgp/PgpHelper.java | 2 +- .../keychain/pgp/PgpImportExport.java | 4 +- .../keychain/pgp/PgpKeyHelper.java | 25 +- .../keychain/pgp/PgpSignEncrypt.java | 4 +- .../keychain/provider/KeychainContract.java | 165 ++-- .../keychain/provider/KeychainDatabase.java | 229 ++++-- .../keychain/provider/KeychainProvider.java | 846 +++++---------------- .../provider/KeychainServiceBlobDatabase.java | 2 +- .../keychain/provider/ProviderHelper.java | 413 +++------- .../keychain/remote/OpenPgpService.java | 2 +- .../keychain/service/KeychainIntentService.java | 15 +- .../keychain/service/PassphraseCacheService.java | 5 +- .../keychain/ui/CertifyKeyActivity.java | 33 +- .../keychain/ui/EditKeyActivity.java | 4 +- .../keychain/ui/EncryptAsymmetricFragment.java | 6 +- .../keychain/ui/KeyListFragment.java | 31 +- .../keychain/ui/SelectPublicKeyFragment.java | 34 +- .../keychain/ui/SelectSecretKeyFragment.java | 52 +- .../keychain/ui/SelectSecretKeyLayoutFragment.java | 15 +- .../keychain/ui/ViewKeyActivity.java | 11 +- .../keychain/ui/ViewKeyMainFragment.java | 44 +- .../keychain/ui/adapter/ViewKeyKeysAdapter.java | 6 +- .../ui/dialog/DeleteKeyDialogFragment.java | 2 + .../ui/dialog/PassphraseDialogFragment.java | 7 +- 25 files changed, 598 insertions(+), 1367 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java index 29255fbbe..43a1d9aab 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpDecryptVerify.java @@ -239,7 +239,7 @@ public class PgpDecryptVerify { if (mEnforcedKeyId != 0) { // TODO: improve this code! get master key directly! PGPSecretKeyRing secretKeyRing = - ProviderHelper.getPGPSecretKeyRingByKeyId(mContext, encData.getKeyID()); + ProviderHelper.getPGPSecretKeyRingWithKeyId(mContext, encData.getKeyID()); long masterKeyId = PgpKeyHelper.getMasterKey(secretKeyRing).getKeyID(); Log.d(Constants.TAG, "encData.getKeyID():" + encData.getKeyID()); Log.d(Constants.TAG, "enforcedKeyId: " + mEnforcedKeyId); @@ -371,7 +371,7 @@ public class PgpDecryptVerify { signatureIndex = i; signatureKeyId = signature.getKeyID(); String userId = null; - PGPPublicKeyRing signKeyRing = ProviderHelper.getPGPPublicKeyRingByKeyId( + PGPPublicKeyRing signKeyRing = ProviderHelper.getPGPPublicKeyRingWithKeyId( mContext, signatureKeyId); if (signKeyRing != null) { userId = PgpKeyHelper.getMainUserId(PgpKeyHelper.getMasterKey(signKeyRing)); @@ -555,7 +555,7 @@ public class PgpDecryptVerify { } else { signatureKeyId = signature.getKeyID(); String userId = null; - PGPPublicKeyRing signKeyRing = ProviderHelper.getPGPPublicKeyRingByKeyId(mContext, + PGPPublicKeyRing signKeyRing = ProviderHelper.getPGPPublicKeyRingWithKeyId(mContext, signatureKeyId); if (signKeyRing != null) { userId = PgpKeyHelper.getMainUserId(PgpKeyHelper.getMasterKey(signKeyRing)); @@ -619,7 +619,7 @@ public class PgpDecryptVerify { long signatureKeyId = signature.getKeyID(); boolean validKeyBinding = false; - PGPPublicKeyRing signKeyRing = ProviderHelper.getPGPPublicKeyRingByKeyId(context, + PGPPublicKeyRing signKeyRing = ProviderHelper.getPGPPublicKeyRingWithKeyId(context, signatureKeyId); PGPPublicKey mKey = null; if (signKeyRing != null) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java index cc40afbac..60967a0d1 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpHelper.java @@ -97,7 +97,7 @@ public class PgpHelper { if (obj instanceof PGPPublicKeyEncryptedData) { gotAsymmetricEncryption = true; PGPPublicKeyEncryptedData pbe = (PGPPublicKeyEncryptedData) obj; - secretKey = ProviderHelper.getPGPSecretKeyByKeyId(context, pbe.getKeyID()); + secretKey = ProviderHelper.getPGPSecretKeyRing(context, pbe.getKeyID()).getSecretKey(); if (secretKey != null) { break; } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java index 0e0fdec83..e2ea91470 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java @@ -184,7 +184,7 @@ public class PgpImportExport { updateProgress(progress * 100 / masterKeyIdsSize, 100); PGPPublicKeyRing publicKeyRing = - ProviderHelper.getPGPPublicKeyRingByMasterKeyId(mContext, pubKeyMasterId); + ProviderHelper.getPGPPublicKeyRing(mContext, pubKeyMasterId); if (publicKeyRing != null) { publicKeyRing.encode(arOutStream); @@ -207,7 +207,7 @@ public class PgpImportExport { updateProgress(progress * 100 / masterKeyIdsSize, 100); PGPSecretKeyRing secretKeyRing = - ProviderHelper.getPGPSecretKeyRingByMasterKeyId(mContext, secretKeyMasterId); + ProviderHelper.getPGPSecretKeyRing(mContext, secretKeyMasterId); if (secretKeyRing != null) { secretKeyRing.encode(arOutStream); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index b4bf0747f..658b9460b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -219,8 +219,7 @@ public class PgpKeyHelper { } public static PGPPublicKey getEncryptPublicKey(Context context, long masterKeyId) { - PGPPublicKeyRing keyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(context, - masterKeyId); + PGPPublicKeyRing keyRing = ProviderHelper.getPGPPublicKeyRing(context, masterKeyId); if (keyRing == null) { Log.e(Constants.TAG, "keyRing is null!"); return null; @@ -234,8 +233,7 @@ public class PgpKeyHelper { } public static PGPSecretKey getCertificationKey(Context context, long masterKeyId) { - PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(context, - masterKeyId); + PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRing(context, masterKeyId); if (keyRing == null) { return null; } @@ -247,8 +245,7 @@ public class PgpKeyHelper { } public static PGPSecretKey getSigningKey(Context context, long masterKeyId) { - PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(context, - masterKeyId); + PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRing(context, masterKeyId); if (keyRing == null) { return null; } @@ -491,21 +488,6 @@ public class PgpKeyHelper { return algorithmStr + ", " + keySize + " bit"; } - public static String getFingerPrint(Context context, long keyId) { - PGPPublicKey key = ProviderHelper.getPGPPublicKeyByKeyId(context, keyId); - // if it is no public key get it from your own keys... - if (key == null) { - PGPSecretKey secretKey = ProviderHelper.getPGPSecretKeyByKeyId(context, keyId); - if (secretKey == null) { - Log.e(Constants.TAG, "Key could not be found!"); - return null; - } - key = secretKey.getPublicKey(); - } - - return convertFingerprintToHex(key.getFingerprint()); - } - /** * Converts fingerprint to hex (optional: with whitespaces after 4 characters) *

                                                  @@ -513,7 +495,6 @@ public class PgpKeyHelper { * better differentiate between numbers and letters when letters are lowercase. * * @param fingerprint - * @param split split into 4 character chunks * @return */ public static String convertFingerprintToHex(byte[] fingerprint) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java index 6d80c154b..a16ebdab8 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpSignEncrypt.java @@ -214,7 +214,7 @@ public class PgpSignEncrypt { PGPSecretKeyRing signingKeyRing = null; PGPPrivateKey signaturePrivateKey = null; if (enableSignature) { - signingKeyRing = ProviderHelper.getPGPSecretKeyRingByKeyId(mContext, mSignatureKeyId); + signingKeyRing = ProviderHelper.getPGPSecretKeyRingWithKeyId(mContext, mSignatureKeyId); signingKey = PgpKeyHelper.getSigningKey(mContext, mSignatureKeyId); if (signingKey == null) { throw new PgpGeneralException(mContext.getString(R.string.error_signature_failed)); @@ -444,7 +444,7 @@ public class PgpSignEncrypt { } PGPSecretKeyRing signingKeyRing = - ProviderHelper.getPGPSecretKeyRingByKeyId(mContext, mSignatureKeyId); + ProviderHelper.getPGPSecretKeyRingWithKeyId(mContext, mSignatureKeyId); PGPSecretKey signingKey = PgpKeyHelper.getSigningKey(mContext, mSignatureKeyId); if (signingKey == null) { throw new PgpGeneralException(mContext.getString(R.string.error_signature_failed)); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java index e7b31bf65..fcf8f7962 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainContract.java @@ -26,32 +26,32 @@ public class KeychainContract { interface KeyRingsColumns { String MASTER_KEY_ID = "master_key_id"; // not a database id - String TYPE = "type"; // see KeyTypes String KEY_RING_DATA = "key_ring_data"; // PGPPublicKeyRing / PGPSecretKeyRing blob } interface KeysColumns { + String MASTER_KEY_ID = "master_key_id"; // not a database id + String RANK = "rank"; + String KEY_ID = "key_id"; // not a database id - String TYPE = "type"; // see KeyTypes - String IS_MASTER_KEY = "is_master_key"; String ALGORITHM = "algorithm"; + String FINGERPRINT = "fingerprint"; + String KEY_SIZE = "key_size"; - String CAN_CERTIFY = "can_certify"; String CAN_SIGN = "can_sign"; String CAN_ENCRYPT = "can_encrypt"; + String CAN_CERTIFY = "can_certify"; String IS_REVOKED = "is_revoked"; + String CREATION = "creation"; String EXPIRY = "expiry"; - String KEY_RING_ROW_ID = "key_ring_row_id"; // foreign key to key_rings._ID - String KEY_DATA = "key_data"; // PGPPublicKey/PGPSecretKey blob - String RANK = "rank"; - String FINGERPRINT = "fingerprint"; } interface UserIdsColumns { - String KEY_RING_ROW_ID = "key_ring_row_id"; // foreign key to key_rings._ID + String MASTER_KEY_ID = "master_key_id"; // foreign key to key_rings._ID String USER_ID = "user_id"; // not a database id - String RANK = "rank"; + String RANK = "rank"; // ONLY used for sorting! no key, no nothing! + String IS_PRIMARY = "is_primary"; } interface ApiAppsColumns { @@ -81,14 +81,15 @@ public class KeychainContract { public static final String BASE_KEY_RINGS = "key_rings"; public static final String BASE_DATA = "data"; - public static final String PATH_PUBLIC = "public"; - public static final String PATH_SECRET = "secret"; + public static final String PATH_UNIFIED = "unified"; public static final String PATH_BY_MASTER_KEY_ID = "master_key_id"; public static final String PATH_BY_KEY_ID = "key_id"; public static final String PATH_BY_EMAILS = "emails"; public static final String PATH_BY_LIKE_EMAIL = "like_email"; + public static final String PATH_PUBLIC = "public"; + public static final String PATH_SECRET = "secret"; public static final String PATH_USER_IDS = "user_ids"; public static final String PATH_KEYS = "keys"; @@ -102,72 +103,43 @@ public class KeychainContract { /** * Use if multiple items get returned */ - public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.key_ring"; + public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.sufficientlysecure.openkeychain.key_ring"; /** * Use if a single item is returned */ - public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.key_ring"; + public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.sufficientlysecure.openkeychain.key_ring"; public static Uri buildUnifiedKeyRingsUri() { - return CONTENT_URI; - } - - public static Uri buildPublicKeyRingsUri() { - return CONTENT_URI.buildUpon().appendPath(PATH_PUBLIC).build(); - } - - public static Uri buildPublicKeyRingsUri(String keyRingRowId) { - return CONTENT_URI.buildUpon().appendPath(PATH_PUBLIC).appendPath(keyRingRowId).build(); - } - - public static Uri buildPublicKeyRingsByMasterKeyIdUri(String masterKeyId) { - return CONTENT_URI.buildUpon().appendPath(PATH_PUBLIC) - .appendPath(PATH_BY_MASTER_KEY_ID).appendPath(masterKeyId).build(); - } - - public static Uri buildPublicKeyRingsByKeyIdUri(String keyId) { - return CONTENT_URI.buildUpon().appendPath(PATH_PUBLIC).appendPath(PATH_BY_KEY_ID) - .appendPath(keyId).build(); + return CONTENT_URI.buildUpon().appendPath(PATH_UNIFIED).build(); } - - public static Uri buildPublicKeyRingsByEmailsUri(String emails) { - return CONTENT_URI.buildUpon().appendPath(PATH_PUBLIC).appendPath(PATH_BY_EMAILS) - .appendPath(emails).build(); + public static Uri buildUnifiedKeyRingsByEmailUri(String email) { + return CONTENT_URI.buildUpon().appendPath("email:" + email).build(); } - public static Uri buildPublicKeyRingsByLikeEmailUri(String emails) { - return CONTENT_URI.buildUpon().appendPath(PATH_PUBLIC).appendPath(PATH_BY_LIKE_EMAIL) - .appendPath(emails).build(); + public static Uri buildGenericKeyRingUri(String masterKeyId) { + return CONTENT_URI.buildUpon().appendPath(masterKeyId).build(); } - public static Uri buildSecretKeyRingsUri() { - return CONTENT_URI.buildUpon().appendPath(PATH_SECRET).build(); + public static Uri buildPublicKeyRingUri(String masterKeyId) { + return CONTENT_URI.buildUpon().appendPath(masterKeyId).appendPath(PATH_PUBLIC).build(); } - - public static Uri buildSecretKeyRingsUri(String keyRingRowId) { - return CONTENT_URI.buildUpon().appendPath(PATH_SECRET).appendPath(keyRingRowId).build(); + public static Uri buildPublicKeyRingUri(Uri uri) { + return CONTENT_URI.buildUpon().appendPath(uri.getPathSegments().get(1)).appendPath(PATH_PUBLIC).build(); } - public static Uri buildSecretKeyRingsByMasterKeyIdUri(String masterKeyId) { - return CONTENT_URI.buildUpon().appendPath(PATH_SECRET) - .appendPath(PATH_BY_MASTER_KEY_ID).appendPath(masterKeyId).build(); + public static Uri buildSecretKeyRingUri(String masterKeyId) { + return CONTENT_URI.buildUpon().appendPath(masterKeyId).appendPath(PATH_SECRET).build(); } - - public static Uri buildSecretKeyRingsByKeyIdUri(String keyId) { - return CONTENT_URI.buildUpon().appendPath(PATH_SECRET).appendPath(PATH_BY_KEY_ID) - .appendPath(keyId).build(); + public static Uri buildSecretKeyRingUri(Uri uri) { + return CONTENT_URI.buildUpon().appendPath(uri.getPathSegments().get(1)).appendPath(PATH_SECRET).build(); } - public static Uri buildSecretKeyRingsByEmailsUri(String emails) { - // TODO: encoded? - return CONTENT_URI.buildUpon().appendPath(PATH_SECRET).appendPath(PATH_BY_EMAILS) - .appendPath(emails).build(); + public static Uri buildUnifiedKeyRingUri(String masterKeyId) { + return CONTENT_URI.buildUpon().appendPath(masterKeyId).appendPath(PATH_UNIFIED).build(); } - - public static Uri buildSecretKeyRingsByLikeEmails(String emails) { - return CONTENT_URI.buildUpon().appendPath(PATH_SECRET).appendPath(PATH_BY_LIKE_EMAIL) - .appendPath(emails).build(); + public static Uri buildUnifiedKeyRingUri(Uri uri) { + return CONTENT_URI.buildUpon().appendPath(uri.getPathSegments().get(1)).appendPath(PATH_UNIFIED).build(); } } @@ -178,40 +150,20 @@ public class KeychainContract { /** * Use if multiple items get returned */ - public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.key"; + public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.sufficientlysecure.openkeychain.key"; /** * Use if a single item is returned */ - public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.key"; - - public static Uri buildPublicKeysUri(String keyRingRowId) { - return CONTENT_URI.buildUpon().appendPath(PATH_PUBLIC).appendPath(keyRingRowId) - .appendPath(PATH_KEYS).build(); - } - - public static Uri buildPublicKeysUri(String keyRingRowId, String keyRowId) { - return CONTENT_URI.buildUpon().appendPath(PATH_PUBLIC).appendPath(keyRingRowId) - .appendPath(PATH_KEYS).appendPath(keyRowId).build(); - } - - public static Uri buildSecretKeysUri(String keyRingRowId) { - return CONTENT_URI.buildUpon().appendPath(PATH_SECRET).appendPath(keyRingRowId) - .appendPath(PATH_KEYS).build(); - } + public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.sufficientlysecure.openkeychain.key"; - public static Uri buildSecretKeysUri(String keyRingRowId, String keyRowId) { - return CONTENT_URI.buildUpon().appendPath(PATH_SECRET).appendPath(keyRingRowId) - .appendPath(PATH_KEYS).appendPath(keyRowId).build(); + public static Uri buildKeysUri(String masterKeyId) { + return CONTENT_URI.buildUpon().appendPath(masterKeyId).appendPath(PATH_KEYS).build(); } - - public static Uri buildKeysUri(Uri keyRingUri) { - return keyRingUri.buildUpon().appendPath(PATH_KEYS).build(); + public static Uri buildKeysUri(Uri uri) { + return CONTENT_URI.buildUpon().appendPath(uri.getPathSegments().get(1)).appendPath(PATH_KEYS).build(); } - public static Uri buildKeysUri(Uri keyRingUri, String keyRowId) { - return keyRingUri.buildUpon().appendPath(PATH_KEYS).appendPath(keyRowId).build(); - } } public static class UserIds implements UserIdsColumns, BaseColumns { @@ -221,39 +173,18 @@ public class KeychainContract { /** * Use if multiple items get returned */ - public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.user_id"; + public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.sufficientlysecure.openkeychain.user_id"; /** * Use if a single item is returned */ - public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.user_id"; - - public static Uri buildPublicUserIdsUri(String keyRingRowId) { - return CONTENT_URI.buildUpon().appendPath(PATH_PUBLIC).appendPath(keyRingRowId) - .appendPath(PATH_USER_IDS).build(); - } - - public static Uri buildPublicUserIdsUri(String keyRingRowId, String userIdRowId) { - return CONTENT_URI.buildUpon().appendPath(PATH_PUBLIC).appendPath(keyRingRowId) - .appendPath(PATH_USER_IDS).appendPath(userIdRowId).build(); - } + public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.sufficientlysecure.openkeychain.user_id"; - public static Uri buildSecretUserIdsUri(String keyRingRowId) { - return CONTENT_URI.buildUpon().appendPath(PATH_SECRET).appendPath(keyRingRowId) - .appendPath(PATH_USER_IDS).build(); + public static Uri buildUserIdsUri(String masterKeyId) { + return CONTENT_URI.buildUpon().appendPath(masterKeyId).appendPath(PATH_USER_IDS).build(); } - - public static Uri buildSecretUserIdsUri(String keyRingRowId, String userIdRowId) { - return CONTENT_URI.buildUpon().appendPath(PATH_SECRET).appendPath(keyRingRowId) - .appendPath(PATH_USER_IDS).appendPath(userIdRowId).build(); - } - - public static Uri buildUserIdsUri(Uri keyRingUri) { - return keyRingUri.buildUpon().appendPath(PATH_USER_IDS).build(); - } - - public static Uri buildUserIdsUri(Uri keyRingUri, String userIdRowId) { - return keyRingUri.buildUpon().appendPath(PATH_USER_IDS).appendPath(userIdRowId).build(); + public static Uri buildUserIdsUri(Uri uri) { + return CONTENT_URI.buildUpon().appendPath(uri.getPathSegments().get(1)).appendPath(PATH_USER_IDS).build(); } } @@ -264,12 +195,12 @@ public class KeychainContract { /** * Use if multiple items get returned */ - public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.api_apps"; + public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.sufficientlysecure.openkeychain.api_apps"; /** * Use if a single item is returned */ - public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.api_app"; + public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.sufficientlysecure.openkeychain.api_app"; public static Uri buildByPackageNameUri(String packageName) { return CONTENT_URI.buildUpon().appendEncodedPath(packageName).build(); @@ -283,12 +214,12 @@ public class KeychainContract { /** * Use if multiple items get returned */ - public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.thialfihar.apg.api_app.accounts"; + public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.sufficientlysecure.openkeychain.api_app.accounts"; /** * Use if a single item is returned */ - public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.thialfihar.apg.api_app.account"; + public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.sufficientlysecure.openkeychain.api_app.account"; public static Uri buildBaseUri(String packageName) { return CONTENT_URI.buildUpon().appendEncodedPath(packageName).appendPath(PATH_ACCOUNTS) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java index 8c33844b2..055957eda 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainDatabase.java @@ -18,11 +18,16 @@ package org.sufficientlysecure.keychain.provider; import android.content.Context; +import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.provider.BaseColumns; +import org.spongycastle.openpgp.PGPKeyRing; +import org.spongycastle.openpgp.PGPPublicKeyRing; +import org.spongycastle.openpgp.PGPSecretKeyRing; import org.sufficientlysecure.keychain.Constants; +import org.sufficientlysecure.keychain.pgp.PgpConversionHelper; import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsColumns; import org.sufficientlysecure.keychain.provider.KeychainContract.ApiAppsAccountsColumns; import org.sufficientlysecure.keychain.provider.KeychainContract.KeyRingsColumns; @@ -30,51 +35,72 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.KeysColumns; import org.sufficientlysecure.keychain.provider.KeychainContract.UserIdsColumns; import org.sufficientlysecure.keychain.util.Log; +import java.io.IOException; +import java.util.Arrays; + public class KeychainDatabase extends SQLiteOpenHelper { - private static final String DATABASE_NAME = "apg.db"; - private static final int DATABASE_VERSION = 8; + private static final String DATABASE_NAME = "openkeychain.db"; + private static final int DATABASE_VERSION = 1; + static Boolean apg_hack = false; public interface Tables { - String KEY_RINGS = "key_rings"; + String KEY_RINGS_PUBLIC = "keyrings_public"; + String KEY_RINGS_SECRET = "keyrings_secret"; String KEYS = "keys"; String USER_IDS = "user_ids"; String API_APPS = "api_apps"; String API_ACCOUNTS = "api_accounts"; } - private static final String CREATE_KEY_RINGS = "CREATE TABLE IF NOT EXISTS " + Tables.KEY_RINGS - + " (" + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " - + KeyRingsColumns.MASTER_KEY_ID + " INT64, " - + KeyRingsColumns.TYPE + " INTEGER, " - + KeyRingsColumns.KEY_RING_DATA + " BLOB)"; - - private static final String CREATE_KEYS = "CREATE TABLE IF NOT EXISTS " + Tables.KEYS + " (" - + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " - + KeysColumns.KEY_ID + " INT64, " - + KeysColumns.TYPE + " INTEGER, " - + KeysColumns.IS_MASTER_KEY + " INTEGER, " - + KeysColumns.ALGORITHM + " INTEGER, " - + KeysColumns.KEY_SIZE + " INTEGER, " - + KeysColumns.CAN_CERTIFY + " INTEGER, " - + KeysColumns.CAN_SIGN + " INTEGER, " - + KeysColumns.CAN_ENCRYPT + " INTEGER, " - + KeysColumns.IS_REVOKED + " INTEGER, " - + KeysColumns.CREATION + " INTEGER, " - + KeysColumns.EXPIRY + " INTEGER, " - + KeysColumns.KEY_DATA + " BLOB," - + KeysColumns.RANK + " INTEGER, " - + KeysColumns.FINGERPRINT + " BLOB, " - + KeysColumns.KEY_RING_ROW_ID + " INTEGER NOT NULL, " - + "FOREIGN KEY(" + KeysColumns.KEY_RING_ROW_ID + ") REFERENCES " - + Tables.KEY_RINGS + "(" + BaseColumns._ID + ") ON DELETE CASCADE)"; - - private static final String CREATE_USER_IDS = "CREATE TABLE IF NOT EXISTS " + Tables.USER_IDS - + " (" + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " - + UserIdsColumns.USER_ID + " TEXT, " - + UserIdsColumns.RANK + " INTEGER, " - + UserIdsColumns.KEY_RING_ROW_ID + " INTEGER NOT NULL, " - + "FOREIGN KEY(" + UserIdsColumns.KEY_RING_ROW_ID + ") REFERENCES " - + Tables.KEY_RINGS + "(" + BaseColumns._ID + ") ON DELETE CASCADE)"; + private static final String CREATE_KEYRINGS_PUBLIC = + "CREATE TABLE IF NOT EXISTS keyrings_public (" + + KeyRingsColumns.MASTER_KEY_ID + " INTEGER PRIMARY KEY," + + KeyRingsColumns.KEY_RING_DATA + " BLOB" + + ")"; + + private static final String CREATE_KEYRINGS_SECRET = + "CREATE TABLE IF NOT EXISTS keyrings_secret (" + + KeyRingsColumns.MASTER_KEY_ID + " INTEGER PRIMARY KEY," + + KeyRingsColumns.KEY_RING_DATA + " BLOB," + + "FOREIGN KEY(" + KeyRingsColumns.MASTER_KEY_ID + ") " + + "REFERENCES keyrings_public(" + KeyRingsColumns.MASTER_KEY_ID + ") ON DELETE CASCADE" + + ")"; + + private static final String CREATE_KEYS = + "CREATE TABLE IF NOT EXISTS " + Tables.KEYS + " (" + + KeysColumns.MASTER_KEY_ID + " INTEGER, " + + KeysColumns.RANK + " INTEGER, " + + + KeysColumns.KEY_ID + " INTEGER, " + + KeysColumns.KEY_SIZE + " INTEGER, " + + KeysColumns.ALGORITHM + " INTEGER, " + + KeysColumns.FINGERPRINT + " BLOB, " + + + KeysColumns.CAN_CERTIFY + " BOOLEAN, " + + KeysColumns.CAN_SIGN + " BOOLEAN, " + + KeysColumns.CAN_ENCRYPT + " BOOLEAN, " + + KeysColumns.IS_REVOKED + " BOOLEAN, " + + + KeysColumns.CREATION + " INTEGER, " + + KeysColumns.EXPIRY + " INTEGER, " + + + "PRIMARY KEY(" + KeysColumns.MASTER_KEY_ID + ", " + KeysColumns.RANK + ")," + + "FOREIGN KEY(" + KeysColumns.MASTER_KEY_ID + ") REFERENCES " + + Tables.KEY_RINGS_PUBLIC + "(" + KeyRingsColumns.MASTER_KEY_ID + ") ON DELETE CASCADE" + + ")"; + + private static final String CREATE_USER_IDS = + "CREATE TABLE IF NOT EXISTS " + Tables.USER_IDS + "(" + + UserIdsColumns.MASTER_KEY_ID + " INTEGER, " + + UserIdsColumns.USER_ID + " CHARMANDER, " + + + UserIdsColumns.IS_PRIMARY + " BOOLEAN, " + + UserIdsColumns.RANK+ " INTEGER, " + + + "PRIMARY KEY(" + UserIdsColumns.MASTER_KEY_ID + ", " + UserIdsColumns.USER_ID + ")," + + "FOREIGN KEY(" + UserIdsColumns.MASTER_KEY_ID + ") REFERENCES " + + Tables.KEY_RINGS_PUBLIC + "(" + KeyRingsColumns.MASTER_KEY_ID + ") ON DELETE CASCADE" + + ")"; private static final String CREATE_API_APPS = "CREATE TABLE IF NOT EXISTS " + Tables.API_APPS + " (" + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " @@ -96,13 +122,27 @@ public class KeychainDatabase extends SQLiteOpenHelper { KeychainDatabase(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); + + + // make sure this is only done once, on the first instance! + boolean iAmIt = false; + synchronized(apg_hack) { + if(!apg_hack) { + iAmIt = true; + apg_hack = true; + } + } + // if it's us, do the import + if(iAmIt) + checkAndImportApg(context); } @Override public void onCreate(SQLiteDatabase db) { Log.w(Constants.TAG, "Creating database..."); - db.execSQL(CREATE_KEY_RINGS); + db.execSQL(CREATE_KEYRINGS_PUBLIC); + db.execSQL(CREATE_KEYRINGS_SECRET); db.execSQL(CREATE_KEYS); db.execSQL(CREATE_USER_IDS); db.execSQL(CREATE_API_APPS); @@ -119,44 +159,91 @@ public class KeychainDatabase extends SQLiteOpenHelper { } @Override - public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { - Log.w(Constants.TAG, "Upgrading database from version " + oldVersion + " to " + newVersion); - - // Upgrade from oldVersion through all cases to newest one - for (int version = oldVersion; version < newVersion; ++version) { - Log.w(Constants.TAG, "Upgrading database to version " + version); - - switch (version) { - case 3: - db.execSQL("ALTER TABLE " + Tables.KEYS + " ADD COLUMN " + KeysColumns.CAN_CERTIFY - + " INTEGER DEFAULT 0;"); - db.execSQL("UPDATE " + Tables.KEYS + " SET " + KeysColumns.CAN_CERTIFY - + " = 1 WHERE " + KeysColumns.IS_MASTER_KEY + "= 1;"); - break; - case 4: - db.execSQL(CREATE_API_APPS); - break; - case 5: - // new column: package_signature - db.execSQL("DROP TABLE IF EXISTS " + Tables.API_APPS); - db.execSQL(CREATE_API_APPS); - break; - case 6: - // new column: fingerprint - db.execSQL("ALTER TABLE " + Tables.KEYS + " ADD COLUMN " + KeysColumns.FINGERPRINT - + " BLOB;"); - break; - case 7: - // new db layout for api apps - db.execSQL("DROP TABLE IF EXISTS " + Tables.API_APPS); - db.execSQL(CREATE_API_APPS); - db.execSQL(CREATE_API_APPS_ACCOUNTS); - break; - default: + public void onUpgrade(SQLiteDatabase db, int old, int nu) { + // don't care (this is version 1) + } + + /** This method tries to import data from a provided database. + * + * The sole assumptions made on this db are that there is a key_rings table + * with a key_ring_data and a type column, the latter of which should be bigger + * for secret keys. + */ + public void checkAndImportApg(Context context) { + + boolean hasApgDb = false; { + // It's the Java way =( + String[] dbs = context.databaseList(); + for(String db : dbs) { + if(db.equals("apg.db")) { + hasApgDb = true; break; + } + } + } + + if(!hasApgDb) + return; + + Log.d(Constants.TAG, "apg.db exists! Importing..."); + SQLiteDatabase db = new SQLiteOpenHelper(context, "apg.db", null, 1) { + @Override + public void onCreate(SQLiteDatabase db) { + // should never happen + assert false; } + @Override + public void onDowngrade(SQLiteDatabase db, int old, int nu) { + // don't care + } + @Override + public void onUpgrade(SQLiteDatabase db, int old, int nu) { + // don't care either + } + }.getReadableDatabase(); + + // kill current! + { // TODO don't kill current. + Log.d(Constants.TAG, "Truncating db..."); + SQLiteDatabase d = getWritableDatabase(); + d.execSQL("DELETE FROM keyrings_public"); + d.close(); + Log.d(Constants.TAG, "Ok."); } + + Cursor c = db.rawQuery("SELECT key_ring_data FROM key_rings ORDER BY type ASC", null); + try { + // import from old database + Log.d(Constants.TAG, "Importing " + c.getCount() + " keyrings from apg.db..."); + for(int i = 0; i < c.getCount(); i++) { + c.moveToPosition(i); + byte[] data = c.getBlob(0); + PGPKeyRing ring = PgpConversionHelper.BytesToPGPKeyRing(data); + if(ring instanceof PGPPublicKeyRing) + ProviderHelper.saveKeyRing(context, (PGPPublicKeyRing) ring); + else if(ring instanceof PGPSecretKeyRing) + ProviderHelper.saveKeyRing(context, (PGPSecretKeyRing) ring); + else { + Log.e(Constants.TAG, "Unknown blob data type!"); + } + } + + } catch(IOException e) { + Log.e(Constants.TAG, "Error importing apg db!", e); + return; + } finally { + if(c != null) + c.close(); + if(db != null) + db.close(); + } + + // TODO delete old db, if we are sure this works + // context.deleteDatabase("apg.db"); + Log.d(Constants.TAG, "All done, (not) deleting apg.db"); + + } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java index 1c5e3ab36..39ea083fa 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainProvider.java @@ -52,40 +52,19 @@ public class KeychainProvider extends ContentProvider { // public static final String EXTRA_BROADCAST_KEY_TYPE = "key_type"; // public static final String EXTRA_BROADCAST_CONTENT_ITEM_TYPE = "contentItemType"; - private static final int PUBLIC_KEY_RING = 101; - private static final int PUBLIC_KEY_RING_BY_ROW_ID = 102; - private static final int PUBLIC_KEY_RING_BY_MASTER_KEY_ID = 103; - private static final int PUBLIC_KEY_RING_BY_KEY_ID = 104; - private static final int PUBLIC_KEY_RING_BY_EMAILS = 105; - private static final int PUBLIC_KEY_RING_BY_LIKE_EMAIL = 106; + private static final int KEY_RINGS_UNIFIED = 101; - private static final int PUBLIC_KEY_RING_KEY = 111; - private static final int PUBLIC_KEY_RING_KEY_BY_ROW_ID = 112; - - private static final int PUBLIC_KEY_RING_USER_ID = 121; - private static final int PUBLIC_KEY_RING_USER_ID_BY_ROW_ID = 122; - private static final int PUBLIC_KEY_RING_BY_MASTER_KEY_ID_USER_ID = 123; - - private static final int SECRET_KEY_RING = 201; - private static final int SECRET_KEY_RING_BY_ROW_ID = 202; - private static final int SECRET_KEY_RING_BY_MASTER_KEY_ID = 203; - private static final int SECRET_KEY_RING_BY_KEY_ID = 204; - private static final int SECRET_KEY_RING_BY_EMAILS = 205; - private static final int SECRET_KEY_RING_BY_LIKE_EMAIL = 206; - - private static final int SECRET_KEY_RING_KEY = 211; - private static final int SECRET_KEY_RING_KEY_BY_ROW_ID = 212; - - private static final int SECRET_KEY_RING_USER_ID = 221; - private static final int SECRET_KEY_RING_USER_ID_BY_ROW_ID = 222; + private static final int KEY_RING_UNIFIED = 200; + private static final int KEY_RING_KEYS = 201; + private static final int KEY_RING_USER_IDS = 202; + private static final int KEY_RING_PUBLIC = 203; + private static final int KEY_RING_SECRET = 204; private static final int API_APPS = 301; private static final int API_APPS_BY_PACKAGE_NAME = 303; private static final int API_ACCOUNTS = 304; private static final int API_ACCOUNTS_BY_ACCOUNT_NAME = 306; - private static final int UNIFIED_KEY_RING = 401; - // private static final int DATA_STREAM = 401; protected UriMatcher mUriMatcher; @@ -100,142 +79,42 @@ public class KeychainProvider extends ContentProvider { String authority = KeychainContract.CONTENT_AUTHORITY; /** - * unified key rings - * - *

                                                  -         * key_rings
                                                  -         * 
                                                  - */ - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS, UNIFIED_KEY_RING); - - /** - * public key rings - * - *
                                                  -         * key_rings/public
                                                  -         * key_rings/public/#
                                                  -         * key_rings/public/master_key_id/_
                                                  -         * key_rings/public/key_id/_
                                                  -         * key_rings/public/emails/_
                                                  -         * key_rings/public/like_email/_
                                                  -         * 
                                                  - */ - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_PUBLIC, PUBLIC_KEY_RING); - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_PUBLIC + "/#", PUBLIC_KEY_RING_BY_ROW_ID); - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_PUBLIC + "/" + KeychainContract.PATH_BY_MASTER_KEY_ID - + "/*", PUBLIC_KEY_RING_BY_MASTER_KEY_ID); - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_PUBLIC + "/" + KeychainContract.PATH_BY_KEY_ID + "/*", - PUBLIC_KEY_RING_BY_KEY_ID); - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_PUBLIC + "/" + KeychainContract.PATH_BY_EMAILS + "/*", - PUBLIC_KEY_RING_BY_EMAILS); - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_PUBLIC + "/" + KeychainContract.PATH_BY_EMAILS, - PUBLIC_KEY_RING_BY_EMAILS); // without emails specified - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_PUBLIC + "/" + KeychainContract.PATH_BY_LIKE_EMAIL + "/*", - PUBLIC_KEY_RING_BY_LIKE_EMAIL); - - /** - * public keys - * - *
                                                  -         * key_rings/public/#/keys
                                                  -         * key_rings/public/#/keys/#
                                                  -         * 
                                                  - */ - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_PUBLIC + "/#/" + KeychainContract.PATH_KEYS, - PUBLIC_KEY_RING_KEY); - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_PUBLIC + "/#/" + KeychainContract.PATH_KEYS + "/#", - PUBLIC_KEY_RING_KEY_BY_ROW_ID); - - /** - * public user ids - * - *
                                                  -         * key_rings/public/#/user_ids
                                                  -         * key_rings/public/#/user_ids/#
                                                  -         * key_rings/public/master_key_id/#/user_ids
                                                  -         * 
                                                  - */ - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_PUBLIC + "/#/" + KeychainContract.PATH_USER_IDS, - PUBLIC_KEY_RING_USER_ID); - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_PUBLIC + "/#/" + KeychainContract.PATH_USER_IDS + "/#", - PUBLIC_KEY_RING_USER_ID_BY_ROW_ID); - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_PUBLIC + "/" - + KeychainContract.PATH_BY_MASTER_KEY_ID + "/*/" + KeychainContract.PATH_USER_IDS, - PUBLIC_KEY_RING_BY_MASTER_KEY_ID_USER_ID); - - /** - * secret key rings + * select from key_ring * *
                                                  -         * key_rings/secret
                                                  -         * key_rings/secret/#
                                                  -         * key_rings/secret/master_key_id/_
                                                  -         * key_rings/secret/key_id/_
                                                  -         * key_rings/secret/emails/_
                                                  -         * key_rings/secret/like_email/_
                                                  +         * key_rings/unified
                                                            * 
                                                  */ - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_SECRET, SECRET_KEY_RING); - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_SECRET + "/#", SECRET_KEY_RING_BY_ROW_ID); - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_SECRET + "/" + KeychainContract.PATH_BY_MASTER_KEY_ID - + "/*", SECRET_KEY_RING_BY_MASTER_KEY_ID); - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_SECRET + "/" + KeychainContract.PATH_BY_KEY_ID + "/*", - SECRET_KEY_RING_BY_KEY_ID); - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_SECRET + "/" + KeychainContract.PATH_BY_EMAILS + "/*", - SECRET_KEY_RING_BY_EMAILS); - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_SECRET + "/" + KeychainContract.PATH_BY_EMAILS, - SECRET_KEY_RING_BY_EMAILS); // without emails specified - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_SECRET + "/" + KeychainContract.PATH_BY_LIKE_EMAIL + "/*", - SECRET_KEY_RING_BY_LIKE_EMAIL); + matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + + "/" + KeychainContract.PATH_UNIFIED, + KEY_RINGS_UNIFIED); /** - * secret keys + * select from key_ring * *
                                                  -         * key_rings/secret/#/keys
                                                  -         * key_rings/secret/#/keys/#
                                                  +         * key_rings/_/unified
                                                  +         * key_rings/_/keys
                                                  +         * key_rings/_/user_ids
                                                  +         * key_rings/_/public
                                                  +         * key_rings/_/secret
                                                            * 
                                                  */ - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_SECRET + "/#/" + KeychainContract.PATH_KEYS, - SECRET_KEY_RING_KEY); - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_SECRET + "/#/" + KeychainContract.PATH_KEYS + "/#", - SECRET_KEY_RING_KEY_BY_ROW_ID); - - /** - * secret user ids - * - *
                                                  -         * key_rings/secret/#/user_ids
                                                  -         * key_rings/secret/#/user_ids/#
                                                  -         * 
                                                  - */ - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_SECRET + "/#/" + KeychainContract.PATH_USER_IDS, - SECRET_KEY_RING_USER_ID); - matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/" - + KeychainContract.PATH_SECRET + "/#/" + KeychainContract.PATH_USER_IDS + "/#", - SECRET_KEY_RING_USER_ID_BY_ROW_ID); + matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/*/" + + KeychainContract.PATH_UNIFIED, + KEY_RING_UNIFIED); + matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/*/" + + KeychainContract.PATH_KEYS, + KEY_RING_KEYS); + matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/*/" + + KeychainContract.PATH_USER_IDS, + KEY_RING_USER_IDS); + matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/*/" + + KeychainContract.PATH_PUBLIC, + KEY_RING_PUBLIC); + matcher.addURI(authority, KeychainContract.BASE_KEY_RINGS + "/*/" + + KeychainContract.PATH_SECRET, + KEY_RING_SECRET); /** * API apps @@ -287,38 +166,17 @@ public class KeychainProvider extends ContentProvider { public String getType(Uri uri) { final int match = mUriMatcher.match(uri); switch (match) { - case PUBLIC_KEY_RING: - case PUBLIC_KEY_RING_BY_EMAILS: - case PUBLIC_KEY_RING_BY_LIKE_EMAIL: - case SECRET_KEY_RING: - case SECRET_KEY_RING_BY_EMAILS: - case SECRET_KEY_RING_BY_LIKE_EMAIL: - return KeyRings.CONTENT_TYPE; - - case PUBLIC_KEY_RING_BY_ROW_ID: - case PUBLIC_KEY_RING_BY_MASTER_KEY_ID: - case PUBLIC_KEY_RING_BY_KEY_ID: - case SECRET_KEY_RING_BY_ROW_ID: - case SECRET_KEY_RING_BY_MASTER_KEY_ID: - case SECRET_KEY_RING_BY_KEY_ID: + case KEY_RING_PUBLIC: return KeyRings.CONTENT_ITEM_TYPE; - case PUBLIC_KEY_RING_KEY: - case SECRET_KEY_RING_KEY: + case KEY_RING_KEYS: return Keys.CONTENT_TYPE; - case PUBLIC_KEY_RING_KEY_BY_ROW_ID: - case SECRET_KEY_RING_KEY_BY_ROW_ID: - return Keys.CONTENT_ITEM_TYPE; - - case PUBLIC_KEY_RING_USER_ID: - case PUBLIC_KEY_RING_BY_MASTER_KEY_ID_USER_ID: - case SECRET_KEY_RING_USER_ID: + case KEY_RING_USER_IDS: return UserIds.CONTENT_TYPE; - case PUBLIC_KEY_RING_USER_ID_BY_ROW_ID: - case SECRET_KEY_RING_USER_ID_BY_ROW_ID: - return UserIds.CONTENT_ITEM_TYPE; + case KEY_RING_SECRET: + return KeyRings.CONTENT_ITEM_TYPE; case API_APPS: return ApiApps.CONTENT_TYPE; @@ -337,175 +195,9 @@ public class KeychainProvider extends ContentProvider { } } - /** - * Returns type of the query (secret/public) - * - * @param match - * @return - */ - private int getKeyType(int match) { - int type; - switch (match) { - case PUBLIC_KEY_RING: - case PUBLIC_KEY_RING_BY_ROW_ID: - case PUBLIC_KEY_RING_BY_MASTER_KEY_ID: - case PUBLIC_KEY_RING_BY_KEY_ID: - case PUBLIC_KEY_RING_BY_EMAILS: - case PUBLIC_KEY_RING_BY_LIKE_EMAIL: - case PUBLIC_KEY_RING_KEY: - case PUBLIC_KEY_RING_KEY_BY_ROW_ID: - case PUBLIC_KEY_RING_USER_ID: - case PUBLIC_KEY_RING_BY_MASTER_KEY_ID_USER_ID: - case PUBLIC_KEY_RING_USER_ID_BY_ROW_ID: - type = KeyTypes.PUBLIC; - break; - - case SECRET_KEY_RING: - case SECRET_KEY_RING_BY_ROW_ID: - case SECRET_KEY_RING_BY_MASTER_KEY_ID: - case SECRET_KEY_RING_BY_KEY_ID: - case SECRET_KEY_RING_BY_EMAILS: - case SECRET_KEY_RING_BY_LIKE_EMAIL: - case SECRET_KEY_RING_KEY: - case SECRET_KEY_RING_KEY_BY_ROW_ID: - case SECRET_KEY_RING_USER_ID: - case SECRET_KEY_RING_USER_ID_BY_ROW_ID: - type = KeyTypes.SECRET; - break; - - default: - Log.e(Constants.TAG, "Unknown match " + match); - type = -1; - break; - } - - return type; - } - - /** - * Set result of query to specific columns, don't show blob column - * - * @return - */ - private HashMap getProjectionMapForKeyRings() { - HashMap projectionMap = new HashMap(); - - projectionMap.put(BaseColumns._ID, Tables.KEY_RINGS + "." + BaseColumns._ID); - projectionMap.put(KeyRingsColumns.KEY_RING_DATA, Tables.KEY_RINGS + "." - + KeyRingsColumns.KEY_RING_DATA); - projectionMap.put(KeyRingsColumns.MASTER_KEY_ID, Tables.KEY_RINGS + "." - + KeyRingsColumns.MASTER_KEY_ID); - // TODO: deprecated master key id - //projectionMap.put(KeyRingsColumns.MASTER_KEY_ID, Tables.KEYS + "." + KeysColumns.KEY_ID); - - projectionMap.put(KeysColumns.ALGORITHM, Tables.KEYS + "." + KeysColumns.ALGORITHM); - projectionMap.put(KeysColumns.KEY_SIZE, Tables.KEYS + "." + KeysColumns.KEY_SIZE); - projectionMap.put(KeysColumns.CREATION, Tables.KEYS + "." + KeysColumns.CREATION); - projectionMap.put(KeysColumns.EXPIRY, Tables.KEYS + "." + KeysColumns.EXPIRY); - projectionMap.put(KeysColumns.KEY_RING_ROW_ID, Tables.KEYS + "." + KeysColumns.KEY_RING_ROW_ID); - projectionMap.put(KeysColumns.FINGERPRINT, Tables.KEYS + "." + KeysColumns.FINGERPRINT); - projectionMap.put(KeysColumns.IS_REVOKED, Tables.KEYS + "." + KeysColumns.IS_REVOKED); - - projectionMap.put(UserIdsColumns.USER_ID, Tables.USER_IDS + "." + UserIdsColumns.USER_ID); - - // type attribute is special: if there is any grouping, choose secret over public type - projectionMap.put(KeyRingsColumns.TYPE, - "MAX(" + Tables.KEY_RINGS + "." + KeyRingsColumns.TYPE + ") AS " + KeyRingsColumns.TYPE); - - return projectionMap; - } - - /** - * Set result of query to specific columns, don't show blob column - * - * @return - */ - private HashMap getProjectionMapForKeys() { - HashMap projectionMap = new HashMap(); - - projectionMap.put(BaseColumns._ID, BaseColumns._ID); - projectionMap.put(KeysColumns.KEY_ID, KeysColumns.KEY_ID); - projectionMap.put(KeysColumns.IS_MASTER_KEY, KeysColumns.IS_MASTER_KEY); - projectionMap.put(KeysColumns.ALGORITHM, KeysColumns.ALGORITHM); - projectionMap.put(KeysColumns.KEY_SIZE, KeysColumns.KEY_SIZE); - projectionMap.put(KeysColumns.CAN_CERTIFY, KeysColumns.CAN_CERTIFY); - projectionMap.put(KeysColumns.CAN_SIGN, KeysColumns.CAN_SIGN); - projectionMap.put(KeysColumns.CAN_ENCRYPT, KeysColumns.CAN_ENCRYPT); - projectionMap.put(KeysColumns.IS_REVOKED, KeysColumns.IS_REVOKED); - projectionMap.put(KeysColumns.CREATION, KeysColumns.CREATION); - projectionMap.put(KeysColumns.EXPIRY, KeysColumns.EXPIRY); - projectionMap.put(KeysColumns.KEY_RING_ROW_ID, KeysColumns.KEY_RING_ROW_ID); - projectionMap.put(KeysColumns.KEY_DATA, KeysColumns.KEY_DATA); - projectionMap.put(KeysColumns.RANK, KeysColumns.RANK); - projectionMap.put(KeysColumns.FINGERPRINT, KeysColumns.FINGERPRINT); - - return projectionMap; - } - - private HashMap getProjectionMapForUserIds() { - HashMap projectionMap = new HashMap(); - - projectionMap.put(BaseColumns._ID, Tables.USER_IDS + "." + BaseColumns._ID); - projectionMap.put(UserIdsColumns.USER_ID, Tables.USER_IDS + "." + UserIdsColumns.USER_ID); - projectionMap.put(UserIdsColumns.RANK, Tables.USER_IDS + "." + UserIdsColumns.RANK); - projectionMap.put(KeyRingsColumns.MASTER_KEY_ID, Tables.KEY_RINGS + "." - + KeyRingsColumns.MASTER_KEY_ID); - - return projectionMap; - } - - /** - * Builds default query for keyRings: KeyRings table is joined with UserIds and Keys - */ - private SQLiteQueryBuilder buildKeyRingQuery(SQLiteQueryBuilder qb, int match) { - if (match != UNIFIED_KEY_RING) { - // public or secret keyring - qb.appendWhere(Tables.KEY_RINGS + "." + KeyRingsColumns.TYPE + " = "); - qb.appendWhereEscapeString(Integer.toString(getKeyType(match))); - } - - // join keyrings with keys and userIds - // Only get user id and key with rank 0 (main user id and main key) - qb.setTables(Tables.KEY_RINGS + " INNER JOIN " + Tables.KEYS + " ON " + "(" - + Tables.KEY_RINGS + "." + BaseColumns._ID + " = " + Tables.KEYS + "." - + KeysColumns.KEY_RING_ROW_ID + " AND " + Tables.KEYS + "." - + KeysColumns.RANK + " = '0') " + " INNER JOIN " + Tables.USER_IDS + " ON " - + "(" + Tables.KEY_RINGS + "." + BaseColumns._ID + " = " + Tables.USER_IDS + "." - + UserIdsColumns.KEY_RING_ROW_ID + " AND " + Tables.USER_IDS + "." - + UserIdsColumns.RANK + " = '0')"); - - qb.setProjectionMap(getProjectionMapForKeyRings()); - - return qb; - } - - /** - * Builds default query for keyRings: KeyRings table is joined with UserIds and Keys - *

                                                  - * Here only one key should be selected in the query to return a single keyring! - */ - private SQLiteQueryBuilder buildKeyRingQueryWithSpecificKey(SQLiteQueryBuilder qb, int match) { - // public or secret keyring - qb.appendWhere(Tables.KEY_RINGS + "." + KeyRingsColumns.TYPE + " = "); - qb.appendWhereEscapeString(Integer.toString(getKeyType(match))); - - // join keyrings with keys and userIds to every keyring - qb.setTables(Tables.KEY_RINGS + " INNER JOIN " + Tables.KEYS + " ON " + "(" - + Tables.KEY_RINGS + "." + BaseColumns._ID + " = " + Tables.KEYS + "." - + KeysColumns.KEY_RING_ROW_ID + ") " + " INNER JOIN " + Tables.USER_IDS + " ON " - + "(" + Tables.KEY_RINGS + "." + BaseColumns._ID + " = " + Tables.USER_IDS + "." - + UserIdsColumns.KEY_RING_ROW_ID + " AND " + Tables.USER_IDS + "." - + UserIdsColumns.RANK + " = '0')"); - - qb.setProjectionMap(getProjectionMapForKeyRings()); - - return qb; - } - /** * {@inheritDoc} */ - @SuppressWarnings("deprecation") @Override public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { @@ -520,64 +212,53 @@ public class KeychainProvider extends ContentProvider { String groupBy = null, having = null; switch (match) { - case UNIFIED_KEY_RING: - qb = buildKeyRingQuery(qb, match); - - // GROUP BY so we don't get duplicates - groupBy = Tables.KEY_RINGS + "." + KeyRingsColumns.MASTER_KEY_ID; - - if (TextUtils.isEmpty(sortOrder)) { - sortOrder = KeyRings.TYPE + " DESC, " + - Tables.USER_IDS + "." + UserIdsColumns.USER_ID + " ASC"; + case KEY_RING_UNIFIED: + case KEY_RINGS_UNIFIED: { + HashMap projectionMap = new HashMap(); + projectionMap.put(BaseColumns._ID, Tables.KEYS + ".oid AS _id"); + projectionMap.put(KeysColumns.MASTER_KEY_ID, Tables.KEYS + "." + KeysColumns.MASTER_KEY_ID); + projectionMap.put(KeysColumns.RANK, Tables.KEYS + "." + KeysColumns.RANK); + projectionMap.put(KeysColumns.KEY_ID, KeysColumns.KEY_ID); + projectionMap.put(KeysColumns.KEY_SIZE, KeysColumns.KEY_SIZE); + projectionMap.put(KeysColumns.IS_REVOKED, KeysColumns.IS_REVOKED); + projectionMap.put(KeysColumns.CAN_CERTIFY, KeysColumns.CAN_CERTIFY); + projectionMap.put(KeysColumns.CAN_ENCRYPT, KeysColumns.CAN_ENCRYPT); + projectionMap.put(KeysColumns.CAN_SIGN, KeysColumns.CAN_SIGN); + projectionMap.put(KeysColumns.CREATION, KeysColumns.CREATION); + projectionMap.put(KeysColumns.EXPIRY, KeysColumns.EXPIRY); + projectionMap.put(KeysColumns.ALGORITHM, KeysColumns.ALGORITHM); + projectionMap.put(KeysColumns.FINGERPRINT, KeysColumns.FINGERPRINT); + projectionMap.put(UserIdsColumns.USER_ID, UserIdsColumns.USER_ID); + projectionMap.put(Tables.KEY_RINGS_SECRET + "." + KeyRings.MASTER_KEY_ID, Tables.KEY_RINGS_SECRET + "." + KeyRingsColumns.MASTER_KEY_ID); + qb.setProjectionMap(projectionMap); + + qb.setTables( + Tables.KEYS + + " INNER JOIN " + Tables.USER_IDS + " ON (" + + Tables.KEYS + "." + KeysColumns.MASTER_KEY_ID + + " = " + + Tables.USER_IDS + "." + UserIdsColumns.MASTER_KEY_ID + + " AND " + Tables.USER_IDS + "." + UserIdsColumns.RANK + " = 0" + + ") LEFT JOIN " + Tables.KEY_RINGS_SECRET + " ON (" + + Tables.KEYS + "." + KeysColumns.MASTER_KEY_ID + + " = " + + Tables.KEY_RINGS_SECRET + "." + KeyRingsColumns.MASTER_KEY_ID + + ")" + ); + qb.appendWhere(Tables.KEYS + "." + KeysColumns.RANK + " = 0"); + + if(match == KEY_RING_UNIFIED) { + qb.appendWhere(" AND " + Tables.KEYS + "." + KeysColumns.MASTER_KEY_ID + " = "); + qb.appendWhereEscapeString(uri.getPathSegments().get(1)); + } else if (TextUtils.isEmpty(sortOrder)) { + sortOrder = + Tables.KEY_RINGS_SECRET + "." + KeyRings.MASTER_KEY_ID + " IS NULL DESC" + + Tables.USER_IDS + "." + UserIdsColumns.USER_ID + " ASC"; } break; - case PUBLIC_KEY_RING: - case SECRET_KEY_RING: - qb = buildKeyRingQuery(qb, match); - - if (TextUtils.isEmpty(sortOrder)) { - sortOrder = Tables.USER_IDS + "." + UserIdsColumns.USER_ID + " ASC"; - } - - break; - case PUBLIC_KEY_RING_BY_ROW_ID: - case SECRET_KEY_RING_BY_ROW_ID: - qb = buildKeyRingQuery(qb, match); - - qb.appendWhere(" AND " + Tables.KEY_RINGS + "." + BaseColumns._ID + " = "); - qb.appendWhereEscapeString(uri.getLastPathSegment()); - - if (TextUtils.isEmpty(sortOrder)) { - sortOrder = Tables.USER_IDS + "." + UserIdsColumns.USER_ID + " ASC"; - } - - break; - case PUBLIC_KEY_RING_BY_MASTER_KEY_ID: - case SECRET_KEY_RING_BY_MASTER_KEY_ID: - qb = buildKeyRingQuery(qb, match); - - qb.appendWhere(" AND " + Tables.KEY_RINGS + "." + KeyRingsColumns.MASTER_KEY_ID + " = "); - qb.appendWhereEscapeString(uri.getLastPathSegment()); - - if (TextUtils.isEmpty(sortOrder)) { - sortOrder = Tables.USER_IDS + "." + UserIdsColumns.USER_ID + " ASC"; - } - - break; - case SECRET_KEY_RING_BY_KEY_ID: - case PUBLIC_KEY_RING_BY_KEY_ID: - qb = buildKeyRingQueryWithSpecificKey(qb, match); - - qb.appendWhere(" AND " + Tables.KEYS + "." + KeysColumns.KEY_ID + " = "); - qb.appendWhereEscapeString(uri.getLastPathSegment()); - - if (TextUtils.isEmpty(sortOrder)) { - sortOrder = Tables.USER_IDS + "." + UserIdsColumns.USER_ID + " ASC"; - } - - break; - case SECRET_KEY_RING_BY_EMAILS: + } + /*case SECRET_KEY_RING_BY_EMAILS: case PUBLIC_KEY_RING_BY_EMAILS: qb = buildKeyRingQuery(qb, match); @@ -603,78 +284,77 @@ public class KeychainProvider extends ContentProvider { + Tables.USER_IDS + " AS tmp WHERE tmp." + UserIdsColumns.KEY_RING_ROW_ID + " = " + Tables.KEY_RINGS + "." + BaseColumns._ID + " AND (" + emailWhere + "))"); - } + }*/ + + case KEY_RING_KEYS: { + HashMap projectionMap = new HashMap(); + projectionMap.put(BaseColumns._ID, Tables.KEYS + ".oid AS _id"); + projectionMap.put(KeysColumns.MASTER_KEY_ID, Tables.KEYS + "." + KeysColumns.MASTER_KEY_ID); + projectionMap.put(KeysColumns.RANK, Tables.KEYS + "." + KeysColumns.RANK); + projectionMap.put(KeysColumns.KEY_ID, KeysColumns.KEY_ID); + projectionMap.put(KeysColumns.KEY_SIZE, KeysColumns.KEY_SIZE); + projectionMap.put(KeysColumns.IS_REVOKED, KeysColumns.IS_REVOKED); + projectionMap.put(KeysColumns.CAN_CERTIFY, KeysColumns.CAN_CERTIFY); + projectionMap.put(KeysColumns.CAN_ENCRYPT, KeysColumns.CAN_ENCRYPT); + projectionMap.put(KeysColumns.CAN_SIGN, KeysColumns.CAN_SIGN); + projectionMap.put(KeysColumns.CREATION, KeysColumns.CREATION); + projectionMap.put(KeysColumns.EXPIRY, KeysColumns.EXPIRY); + projectionMap.put(KeysColumns.ALGORITHM, KeysColumns.ALGORITHM); + projectionMap.put(KeysColumns.FINGERPRINT, KeysColumns.FINGERPRINT); + qb.setProjectionMap(projectionMap); - break; - case SECRET_KEY_RING_BY_LIKE_EMAIL: - case PUBLIC_KEY_RING_BY_LIKE_EMAIL: - qb = buildKeyRingQuery(qb, match); - - String likeEmail = uri.getLastPathSegment(); - - String likeEmailWhere = "tmp." + UserIdsColumns.USER_ID + " LIKE " - + DatabaseUtils.sqlEscapeString("%<%" + likeEmail + "%>"); - - qb.appendWhere(" AND EXISTS (SELECT tmp." + BaseColumns._ID + " FROM " - + Tables.USER_IDS + " AS tmp WHERE tmp." + UserIdsColumns.KEY_RING_ROW_ID - + " = " + Tables.KEY_RINGS + "." + BaseColumns._ID + " AND (" + likeEmailWhere - + "))"); + qb.setTables(Tables.KEYS); + qb.appendWhere(KeysColumns.MASTER_KEY_ID + " = "); + qb.appendWhereEscapeString(uri.getPathSegments().get(1)); break; - case PUBLIC_KEY_RING_KEY: - case SECRET_KEY_RING_KEY: - qb.setTables(Tables.KEYS); - qb.appendWhere(KeysColumns.TYPE + " = "); - qb.appendWhereEscapeString(Integer.toString(getKeyType(match))); + } - qb.appendWhere(" AND " + KeysColumns.KEY_RING_ROW_ID + " = "); - qb.appendWhereEscapeString(uri.getPathSegments().get(2)); + case KEY_RING_USER_IDS: { + HashMap projectionMap = new HashMap(); + projectionMap.put(BaseColumns._ID, Tables.USER_IDS + ".oid AS _id"); + projectionMap.put(UserIds.MASTER_KEY_ID, UserIds.MASTER_KEY_ID); + projectionMap.put(UserIds.USER_ID, UserIds.USER_ID); + projectionMap.put(UserIds.RANK, UserIds.RANK); + projectionMap.put(UserIds.IS_PRIMARY, UserIds.IS_PRIMARY); + qb.setProjectionMap(projectionMap); - qb.setProjectionMap(getProjectionMapForKeys()); + qb.setTables(Tables.USER_IDS); + qb.appendWhere(UserIdsColumns.MASTER_KEY_ID + " = "); + qb.appendWhereEscapeString(uri.getPathSegments().get(1)); break; - case PUBLIC_KEY_RING_KEY_BY_ROW_ID: - case SECRET_KEY_RING_KEY_BY_ROW_ID: - qb.setTables(Tables.KEYS); - qb.appendWhere(KeysColumns.TYPE + " = "); - qb.appendWhereEscapeString(Integer.toString(getKeyType(match))); - qb.appendWhere(" AND " + KeysColumns.KEY_RING_ROW_ID + " = "); - qb.appendWhereEscapeString(uri.getPathSegments().get(2)); + } - qb.appendWhere(" AND " + BaseColumns._ID + " = "); - qb.appendWhereEscapeString(uri.getLastPathSegment()); + case KEY_RING_PUBLIC: { + HashMap projectionMap = new HashMap(); + projectionMap.put(BaseColumns._ID, Tables.KEY_RINGS_PUBLIC + ".oid AS _id"); + projectionMap.put(KeyRings.MASTER_KEY_ID, KeyRings.MASTER_KEY_ID); + projectionMap.put(KeyRings.KEY_RING_DATA, KeyRings.KEY_RING_DATA); + qb.setProjectionMap(projectionMap); - qb.setProjectionMap(getProjectionMapForKeys()); + qb.setTables(Tables.KEY_RINGS_PUBLIC); + qb.appendWhere(KeyRingsColumns.MASTER_KEY_ID + " = "); + qb.appendWhereEscapeString(uri.getPathSegments().get(1)); break; - case PUBLIC_KEY_RING_BY_MASTER_KEY_ID_USER_ID: - qb.setTables(Tables.USER_IDS + " INNER JOIN " + Tables.KEY_RINGS + " ON " + "(" - + Tables.KEY_RINGS + "." + BaseColumns._ID + " = " + Tables.USER_IDS + "." - + KeysColumns.KEY_RING_ROW_ID + " )"); - qb.appendWhere(Tables.KEY_RINGS + "." + KeyRingsColumns.MASTER_KEY_ID + " = "); - qb.appendWhereEscapeString(uri.getPathSegments().get(3)); + } - qb.setProjectionMap(getProjectionMapForUserIds()); + case KEY_RING_SECRET: { + HashMap projectionMap = new HashMap(); + projectionMap.put(BaseColumns._ID, Tables.KEY_RINGS_SECRET + ".oid AS _id"); + projectionMap.put(KeyRings.MASTER_KEY_ID, KeyRings.MASTER_KEY_ID); + projectionMap.put(KeyRings.KEY_RING_DATA, KeyRings.KEY_RING_DATA); + qb.setProjectionMap(projectionMap); - break; - case PUBLIC_KEY_RING_USER_ID: - case SECRET_KEY_RING_USER_ID: - qb.setTables(Tables.USER_IDS); - qb.appendWhere(UserIdsColumns.KEY_RING_ROW_ID + " = "); - qb.appendWhereEscapeString(uri.getPathSegments().get(2)); + qb.setTables(Tables.KEY_RINGS_SECRET); + qb.appendWhere(KeyRingsColumns.MASTER_KEY_ID + " = "); + qb.appendWhereEscapeString(uri.getPathSegments().get(1)); break; - case PUBLIC_KEY_RING_USER_ID_BY_ROW_ID: - case SECRET_KEY_RING_USER_ID_BY_ROW_ID: - qb.setTables(Tables.USER_IDS); - qb.appendWhere(UserIdsColumns.KEY_RING_ROW_ID + " = "); - qb.appendWhereEscapeString(uri.getPathSegments().get(2)); - - qb.appendWhere(" AND " + BaseColumns._ID + " = "); - qb.appendWhereEscapeString(uri.getLastPathSegment()); + } - break; case API_APPS: qb.setTables(Tables.API_APPS); @@ -739,63 +419,36 @@ public class KeychainProvider extends ContentProvider { final SQLiteDatabase db = mKeychainDatabase.getWritableDatabase(); Uri rowUri = null; - long rowId = -1; + Long keyId = null; try { final int match = mUriMatcher.match(uri); switch (match) { - case PUBLIC_KEY_RING: - values.put(KeyRings.TYPE, KeyTypes.PUBLIC); - - rowId = db.insertOrThrow(Tables.KEY_RINGS, null, values); - rowUri = KeyRings.buildPublicKeyRingsUri(Long.toString(rowId)); - sendBroadcastDatabaseChange(getKeyType(match), getType(uri)); - + case KEY_RING_PUBLIC: + db.insertOrThrow(Tables.KEY_RINGS_PUBLIC, null, values); + keyId = values.getAsLong(KeyRingsColumns.MASTER_KEY_ID); break; - case PUBLIC_KEY_RING_KEY: - values.put(Keys.TYPE, KeyTypes.PUBLIC); - - rowId = db.insertOrThrow(Tables.KEYS, null, values); - // TODO: this is wrong: - rowUri = Keys.buildPublicKeysUri(Long.toString(rowId)); - sendBroadcastDatabaseChange(getKeyType(match), getType(uri)); + case KEY_RING_SECRET: + db.insertOrThrow(Tables.KEY_RINGS_SECRET, null, values); + keyId = values.getAsLong(KeyRingsColumns.MASTER_KEY_ID); break; - case PUBLIC_KEY_RING_USER_ID: - rowId = db.insertOrThrow(Tables.USER_IDS, null, values); - // TODO: this is wrong: - rowUri = UserIds.buildPublicUserIdsUri(Long.toString(rowId)); - sendBroadcastDatabaseChange(getKeyType(match), getType(uri)); + case KEY_RING_KEYS: + Log.d(Constants.TAG, "keys"); + db.insertOrThrow(Tables.KEYS, null, values); + keyId = values.getAsLong(KeysColumns.MASTER_KEY_ID); break; - case SECRET_KEY_RING: - values.put(KeyRings.TYPE, KeyTypes.SECRET); - - rowId = db.insertOrThrow(Tables.KEY_RINGS, null, values); - rowUri = KeyRings.buildSecretKeyRingsUri(Long.toString(rowId)); - sendBroadcastDatabaseChange(getKeyType(match), getType(uri)); + case KEY_RING_USER_IDS: + db.insertOrThrow(Tables.USER_IDS, null, values); + keyId = values.getAsLong(UserIdsColumns.MASTER_KEY_ID); break; - case SECRET_KEY_RING_KEY: - values.put(Keys.TYPE, KeyTypes.SECRET); - rowId = db.insertOrThrow(Tables.KEYS, null, values); - // TODO: this is wrong: - rowUri = Keys.buildSecretKeysUri(Long.toString(rowId)); - sendBroadcastDatabaseChange(getKeyType(match), getType(uri)); - - break; - case SECRET_KEY_RING_USER_ID: - rowId = db.insertOrThrow(Tables.USER_IDS, null, values); - // TODO: this is wrong: - rowUri = UserIds.buildSecretUserIdsUri(Long.toString(rowId)); - - break; case API_APPS: - rowId = db.insertOrThrow(Tables.API_APPS, null, values); -// rowUri = ApiApps.buildIdUri(Long.toString(rowId)); - + db.insertOrThrow(Tables.API_APPS, null, values); break; + case API_ACCOUNTS: // set foreign key automatically based on given uri // e.g., api_apps/com.example.app/accounts/ @@ -804,20 +457,26 @@ public class KeychainProvider extends ContentProvider { Log.d(Constants.TAG, "provider packageName: " + packageName); - rowId = db.insertOrThrow(Tables.API_ACCOUNTS, null, values); + db.insertOrThrow(Tables.API_ACCOUNTS, null, values); // TODO: this is wrong: // rowUri = ApiAccounts.buildIdUri(Long.toString(rowId)); break; + default: throw new UnsupportedOperationException("Unknown uri: " + uri); } + if(keyId != null) { + uri = KeyRings.buildGenericKeyRingUri(keyId.toString()); + rowUri = uri; + } + // notify of changes in db getContext().getContentResolver().notifyChange(uri, null); } catch (SQLiteConstraintException e) { - Log.e(Constants.TAG, "Constraint exception on insert! Entry already existing?"); + Log.e(Constants.TAG, "Constraint exception on insert! Entry already existing?", e); } return rowUri; @@ -827,7 +486,7 @@ public class KeychainProvider extends ContentProvider { * {@inheritDoc} */ @Override - public int delete(Uri uri, String selection, String[] selectionArgs) { + public int delete(Uri uri, String additionalSelection, String[] selectionArgs) { Log.v(Constants.TAG, "delete(uri=" + uri + ")"); final SQLiteDatabase db = mKeychainDatabase.getWritableDatabase(); @@ -835,43 +494,33 @@ public class KeychainProvider extends ContentProvider { int count; final int match = mUriMatcher.match(uri); - String defaultSelection = null; switch (match) { - case PUBLIC_KEY_RING_BY_ROW_ID: - case SECRET_KEY_RING_BY_ROW_ID: - defaultSelection = BaseColumns._ID + "=" + uri.getLastPathSegment(); - // corresponding keys and userIds are deleted by ON DELETE CASCADE - count = db.delete(Tables.KEY_RINGS, - buildDefaultKeyRingsSelection(defaultSelection, getKeyType(match), selection), - selectionArgs); - sendBroadcastDatabaseChange(getKeyType(match), getType(uri)); - break; - case PUBLIC_KEY_RING_BY_MASTER_KEY_ID: - case SECRET_KEY_RING_BY_MASTER_KEY_ID: - defaultSelection = KeyRings.MASTER_KEY_ID + "=" + uri.getLastPathSegment(); + case KEY_RING_PUBLIC: { + @SuppressWarnings("ConstantConditions") // ensured by uriMatcher above + String selection = KeyRings.MASTER_KEY_ID + " = " + uri.getPathSegments().get(1); + if (!TextUtils.isEmpty(additionalSelection)) { + selection += " AND (" + additionalSelection + ")"; + } // corresponding keys and userIds are deleted by ON DELETE CASCADE - count = db.delete(Tables.KEY_RINGS, - buildDefaultKeyRingsSelection(defaultSelection, getKeyType(match), selection), - selectionArgs); - sendBroadcastDatabaseChange(getKeyType(match), getType(uri)); + count = db.delete(Tables.KEY_RINGS_PUBLIC, selection, selectionArgs); break; - case PUBLIC_KEY_RING_KEY_BY_ROW_ID: - case SECRET_KEY_RING_KEY_BY_ROW_ID: - count = db.delete(Tables.KEYS, - buildDefaultKeysSelection(uri, getKeyType(match), selection), selectionArgs); - sendBroadcastDatabaseChange(getKeyType(match), getType(uri)); - break; - case PUBLIC_KEY_RING_USER_ID_BY_ROW_ID: - case SECRET_KEY_RING_USER_ID_BY_ROW_ID: - count = db.delete(Tables.KEYS, buildDefaultUserIdsSelection(uri, selection), - selectionArgs); + } + case KEY_RING_SECRET: { + @SuppressWarnings("ConstantConditions") // ensured by uriMatcher above + String selection = KeyRings.MASTER_KEY_ID + " = " + uri.getPathSegments().get(1); + if (!TextUtils.isEmpty(additionalSelection)) { + selection += " AND (" + additionalSelection + ")"; + } + count = db.delete(Tables.KEY_RINGS_SECRET, selection, selectionArgs); break; + } + case API_APPS_BY_PACKAGE_NAME: - count = db.delete(Tables.API_APPS, buildDefaultApiAppsSelection(uri, selection), + count = db.delete(Tables.API_APPS, buildDefaultApiAppsSelection(uri, additionalSelection), selectionArgs); break; case API_ACCOUNTS_BY_ACCOUNT_NAME: - count = db.delete(Tables.API_ACCOUNTS, buildDefaultApiAccountsSelection(uri, selection), + count = db.delete(Tables.API_ACCOUNTS, buildDefaultApiAccountsSelection(uri, additionalSelection), selectionArgs); break; default: @@ -898,44 +547,6 @@ public class KeychainProvider extends ContentProvider { try { final int match = mUriMatcher.match(uri); switch (match) { - case PUBLIC_KEY_RING_BY_ROW_ID: - case SECRET_KEY_RING_BY_ROW_ID: - defaultSelection = BaseColumns._ID + "=" + uri.getLastPathSegment(); - - count = db.update( - Tables.KEY_RINGS, - values, - buildDefaultKeyRingsSelection(defaultSelection, getKeyType(match), - selection), selectionArgs); - sendBroadcastDatabaseChange(getKeyType(match), getType(uri)); - - break; - case PUBLIC_KEY_RING_BY_MASTER_KEY_ID: - case SECRET_KEY_RING_BY_MASTER_KEY_ID: - defaultSelection = KeyRings.MASTER_KEY_ID + "=" + uri.getLastPathSegment(); - - count = db.update( - Tables.KEY_RINGS, - values, - buildDefaultKeyRingsSelection(defaultSelection, getKeyType(match), - selection), selectionArgs); - sendBroadcastDatabaseChange(getKeyType(match), getType(uri)); - - break; - case PUBLIC_KEY_RING_KEY_BY_ROW_ID: - case SECRET_KEY_RING_KEY_BY_ROW_ID: - count = db - .update(Tables.KEYS, values, - buildDefaultKeysSelection(uri, getKeyType(match), selection), - selectionArgs); - sendBroadcastDatabaseChange(getKeyType(match), getType(uri)); - - break; - case PUBLIC_KEY_RING_USER_ID_BY_ROW_ID: - case SECRET_KEY_RING_USER_ID_BY_ROW_ID: - count = db.update(Tables.USER_IDS, values, - buildDefaultUserIdsSelection(uri, selection), selectionArgs); - break; case API_APPS_BY_PACKAGE_NAME: count = db.update(Tables.API_APPS, values, buildDefaultApiAppsSelection(uri, selection), selectionArgs); @@ -958,81 +569,6 @@ public class KeychainProvider extends ContentProvider { return count; } - /** - * Build default selection statement for KeyRings. If no extra selection is specified only build - * where clause with rowId - * - * @param defaultSelection - * @param keyType - * @param selection - * @return - */ - private String buildDefaultKeyRingsSelection(String defaultSelection, Integer keyType, - String selection) { - String andType = ""; - if (keyType != null) { - andType = " AND " + KeyRingsColumns.TYPE + "=" + keyType; - } - - String andSelection = ""; - if (!TextUtils.isEmpty(selection)) { - andSelection = " AND (" + selection + ")"; - } - - return defaultSelection + andType + andSelection; - } - - /** - * Build default selection statement for Keys. If no extra selection is specified only build - * where clause with rowId - * - * @param uri - * @param selection - * @return - */ - private String buildDefaultKeysSelection(Uri uri, Integer keyType, String selection) { - String rowId = uri.getLastPathSegment(); - - String foreignKeyRingRowId = uri.getPathSegments().get(2); - String andForeignKeyRing = " AND " + KeysColumns.KEY_RING_ROW_ID + " = " - + foreignKeyRingRowId; - - String andType = ""; - if (keyType != null) { - andType = " AND " + KeysColumns.TYPE + "=" + keyType; - } - - String andSelection = ""; - if (!TextUtils.isEmpty(selection)) { - andSelection = " AND (" + selection + ")"; - } - - return BaseColumns._ID + "=" + rowId + andForeignKeyRing + andType + andSelection; - } - - /** - * Build default selection statement for UserIds. If no extra selection is specified only build - * where clause with rowId - * - * @param uri - * @param selection - * @return - */ - private String buildDefaultUserIdsSelection(Uri uri, String selection) { - String rowId = uri.getLastPathSegment(); - - String foreignKeyRingRowId = uri.getPathSegments().get(2); - String andForeignKeyRing = " AND " + KeysColumns.KEY_RING_ROW_ID + " = " - + foreignKeyRingRowId; - - String andSelection = ""; - if (!TextUtils.isEmpty(selection)) { - andSelection = " AND (" + selection + ")"; - } - - return BaseColumns._ID + "=" + rowId + andForeignKeyRing + andSelection; - } - /** * Build default selection statement for API apps. If no extra selection is specified only build * where clause with rowId @@ -1066,28 +602,4 @@ public class KeychainProvider extends ContentProvider { + andSelection; } - // @Override - // public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException { - // int match = mUriMatcher.match(uri); - // if (match != DATA_STREAM) { - // throw new FileNotFoundException(); - // } - // String fileName = uri.getLastPathSegment(); - // File file = new File(getContext().getFilesDir().getAbsolutePath(), fileName); - // return ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY); - // } - - /** - * This broadcast is send system wide to inform other application that a keyring was inserted, - * updated, or deleted - */ - private void sendBroadcastDatabaseChange(int keyType, String contentItemType) { - // TODO: Disabled, old API - // Intent intent = new Intent(); - // intent.setAction(ACTION_BROADCAST_DATABASE_CHANGE); - // intent.putExtra(EXTRA_BROADCAST_KEY_TYPE, keyType); - // intent.putExtra(EXTRA_BROADCAST_CONTENT_ITEM_TYPE, contentItemType); - // - // getContext().sendBroadcast(intent, Constants.PERMISSION_ACCESS_API); - } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainServiceBlobDatabase.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainServiceBlobDatabase.java index da1bcb2d9..bc7de0b37 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainServiceBlobDatabase.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/KeychainServiceBlobDatabase.java @@ -25,7 +25,7 @@ import android.provider.BaseColumns; import org.sufficientlysecure.keychain.provider.KeychainServiceBlobContract.BlobsColumns; public class KeychainServiceBlobDatabase extends SQLiteOpenHelper { - private static final String DATABASE_NAME = "apg_blob.db"; + private static final String DATABASE_NAME = "openkeychain_blob.db"; private static final int DATABASE_VERSION = 2; public static final String TABLE = "data"; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java index b971143ae..040923c33 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java @@ -75,78 +75,40 @@ public class ProviderHelper { return keyRing; } - /** - * Retrieves the actual PGPPublicKeyRing object from the database blob based on the rowId - */ - public static PGPPublicKeyRing getPGPPublicKeyRingByRowId(Context context, long rowId) { - Uri queryUri = KeyRings.buildPublicKeyRingsUri(Long.toString(rowId)); - return (PGPPublicKeyRing) getPGPKeyRing(context, queryUri); + public static PGPPublicKey getPGPPublicKeyByKeyId(Context context, long keyId) { + return getPGPPublicKeyRingWithKeyId(context, keyId).getPublicKey(keyId); } - - /** - * Retrieves the actual PGPPublicKeyRing object from the database blob based on the masterKeyId - */ - public static PGPPublicKeyRing getPGPPublicKeyRingByMasterKeyId(Context context, - long masterKeyId) { - Uri queryUri = KeyRings.buildPublicKeyRingsByMasterKeyIdUri(Long.toString(masterKeyId)); - return (PGPPublicKeyRing) getPGPKeyRing(context, queryUri); + public static PGPPublicKeyRing getPGPPublicKeyRingWithKeyId(Context context, long keyId) { + // todo do + return null; } - /** - * Retrieves the actual PGPPublicKeyRing object from the database blob associated with a key - * with this keyId - */ - public static PGPPublicKeyRing getPGPPublicKeyRingByKeyId(Context context, long keyId) { - Uri queryUri = KeyRings.buildPublicKeyRingsByKeyIdUri(Long.toString(keyId)); - return (PGPPublicKeyRing) getPGPKeyRing(context, queryUri); + public static PGPSecretKey getPGPSecretKeyByKeyId(Context context, long keyId) { + return getPGPSecretKeyRingWithKeyId(context, keyId).getSecretKey(keyId); } - - /** - * Retrieves the actual PGPPublicKey object from the database blob associated with a key with - * this keyId - */ - public static PGPPublicKey getPGPPublicKeyByKeyId(Context context, long keyId) { - PGPPublicKeyRing keyRing = getPGPPublicKeyRingByKeyId(context, keyId); - - return (keyRing == null) ? null : keyRing.getPublicKey(keyId); + public static PGPSecretKeyRing getPGPSecretKeyRingWithKeyId(Context context, long keyId) { + // todo do + return null; } /** - * Retrieves the actual PGPSecretKeyRing object from the database blob based on the rowId + * Retrieves the actual PGPPublicKeyRing object from the database blob based on the masterKeyId */ - public static PGPSecretKeyRing getPGPSecretKeyRingByRowId(Context context, long rowId) { - Uri queryUri = KeyRings.buildSecretKeyRingsUri(Long.toString(rowId)); - return (PGPSecretKeyRing) getPGPKeyRing(context, queryUri); + public static PGPPublicKeyRing getPGPPublicKeyRing(Context context, + long masterKeyId) { + Uri queryUri = KeyRings.buildPublicKeyRingUri(Long.toString(masterKeyId)); + return (PGPPublicKeyRing) getPGPKeyRing(context, queryUri); } /** * Retrieves the actual PGPSecretKeyRing object from the database blob based on the maserKeyId */ - public static PGPSecretKeyRing getPGPSecretKeyRingByMasterKeyId(Context context, + public static PGPSecretKeyRing getPGPSecretKeyRing(Context context, long masterKeyId) { - Uri queryUri = KeyRings.buildSecretKeyRingsByMasterKeyIdUri(Long.toString(masterKeyId)); - return (PGPSecretKeyRing) getPGPKeyRing(context, queryUri); - } - - /** - * Retrieves the actual PGPSecretKeyRing object from the database blob associated with a key - * with this keyId - */ - public static PGPSecretKeyRing getPGPSecretKeyRingByKeyId(Context context, long keyId) { - Uri queryUri = KeyRings.buildSecretKeyRingsByKeyIdUri(Long.toString(keyId)); + Uri queryUri = KeyRings.buildSecretKeyRingUri(Long.toString(masterKeyId)); return (PGPSecretKeyRing) getPGPKeyRing(context, queryUri); } - /** - * Retrieves the actual PGPSecretKey object from the database blob associated with a key with - * this keyId - */ - public static PGPSecretKey getPGPSecretKeyByKeyId(Context context, long keyId) { - PGPSecretKeyRing keyRing = getPGPSecretKeyRingByKeyId(context, keyId); - - return (keyRing == null) ? null : keyRing.getSecretKey(keyId); - } - /** * Saves PGPPublicKeyRing with its keys and userIds in DB */ @@ -155,21 +117,13 @@ public class ProviderHelper { PGPPublicKey masterKey = keyRing.getPublicKey(); long masterKeyId = masterKey.getKeyID(); - Uri deleteUri = KeyRings.buildPublicKeyRingsByMasterKeyIdUri(Long.toString(masterKeyId)); - - // get current _ID of key - long currentRowId = -1; - Cursor oldQuery = context.getContentResolver() - .query(deleteUri, new String[]{KeyRings._ID}, null, null, null); - if (oldQuery != null && oldQuery.moveToFirst()) { - currentRowId = oldQuery.getLong(0); - } else { - Log.e(Constants.TAG, "Key could not be found! Something wrong is happening!"); - } + // IF there is a secret key, preserve it! + // TODO This even necessary? + // PGPSecretKeyRing secretRing = ProviderHelper.getPGPSecretKeyRing(context, masterKeyId); // delete old version of this keyRing, which also deletes all keys and userIds on cascade try { - context.getContentResolver().delete(deleteUri, null, null); + context.getContentResolver().delete(KeyRings.buildPublicKeyRingUri(Long.toString(masterKeyId)), null, null); } catch (UnsupportedOperationException e) { Log.e(Constants.TAG, "Key could not be deleted! Maybe we are creating a new one!", e); } @@ -179,29 +133,25 @@ public class ProviderHelper { // NOTE: If we would not use the same _ID again, // getting back to the ViewKeyActivity would result in Nullpointer, // because the currently loaded key would be gone from the database - if (currentRowId != -1) { - values.put(KeyRings._ID, currentRowId); - } values.put(KeyRings.MASTER_KEY_ID, masterKeyId); values.put(KeyRings.KEY_RING_DATA, keyRing.getEncoded()); // insert new version of this keyRing - Uri uri = KeyRings.buildPublicKeyRingsUri(); + Uri uri = KeyRings.buildPublicKeyRingUri(Long.toString(masterKeyId)); Uri insertedUri = context.getContentResolver().insert(uri, values); - long keyRingRowId = Long.valueOf(insertedUri.getLastPathSegment()); // save all keys and userIds included in keyRing object in database ArrayList operations = new ArrayList(); int rank = 0; for (PGPPublicKey key : new IterableIterator(keyRing.getPublicKeys())) { - operations.add(buildPublicKeyOperations(context, keyRingRowId, key, rank)); + operations.add(buildPublicKeyOperations(context, masterKeyId, key, rank)); ++rank; } int userIdRank = 0; for (String userId : new IterableIterator(masterKey.getUserIDs())) { - operations.add(buildPublicUserIdOperations(context, keyRingRowId, userId, userIdRank)); + operations.add(buildUserIdOperations(context, masterKeyId, userId, userIdRank)); ++userIdRank; } @@ -214,7 +164,6 @@ public class ProviderHelper { // operations.add(buildPublicKeyOperations(context, keyRingRowId, key, rank)); } - try { context.getContentResolver().applyBatch(KeychainContract.CONTENT_AUTHORITY, operations); } catch (RemoteException e) { @@ -222,6 +171,12 @@ public class ProviderHelper { } catch (OperationApplicationException e) { Log.e(Constants.TAG, "applyBatch failed!", e); } + + // Save the saved keyring (if any) + // TODO this even necessary? see above... + // if(secretRing != null) + // saveKeyRing(context, secretRing); + } /** @@ -232,104 +187,46 @@ public class ProviderHelper { PGPSecretKey masterKey = keyRing.getSecretKey(); long masterKeyId = masterKey.getKeyID(); - Uri deleteUri = KeyRings.buildSecretKeyRingsByMasterKeyIdUri(Long.toString(masterKeyId)); - - // get current _ID of key - long currentRowId = -1; - Cursor oldQuery = context.getContentResolver() - .query(deleteUri, new String[]{KeyRings._ID}, null, null, null); - if (oldQuery != null && oldQuery.moveToFirst()) { - currentRowId = oldQuery.getLong(0); - } else { - Log.e(Constants.TAG, "Key could not be found! Something wrong is happening!"); - } + // TODO Make sure there is a public key for this secret key in the db (create one maybe) - // delete old version of this keyRing, which also deletes all keys and userIds on cascade - try { - context.getContentResolver().delete(deleteUri, null, null); - } catch (UnsupportedOperationException e) { - Log.e(Constants.TAG, "Key could not be deleted! Maybe we are creating a new one!", e); + { + ContentValues values = new ContentValues(); + values.put(KeyRings.MASTER_KEY_ID, masterKeyId); + values.put(KeyRings.KEY_RING_DATA, keyRing.getEncoded()); + // insert new version of this keyRing + Uri uri = KeyRings.buildSecretKeyRingUri(Long.toString(masterKeyId)); + context.getContentResolver().insert(uri, values); } - ContentValues values = new ContentValues(); - // use exactly the same _ID again to replace key in-place. - // NOTE: If we would not use the same _ID again, - // getting back to the ViewKeyActivity would result in Nullpointer, - // because the currently loaded key would be gone from the database - if (currentRowId != -1) { - values.put(KeyRings._ID, currentRowId); - } - values.put(KeyRings.MASTER_KEY_ID, masterKeyId); - values.put(KeyRings.KEY_RING_DATA, keyRing.getEncoded()); - - // insert new version of this keyRing - Uri uri = KeyRings.buildSecretKeyRingsUri(); - Uri insertedUri = context.getContentResolver().insert(uri, values); - long keyRingRowId = Long.valueOf(insertedUri.getLastPathSegment()); - - // save all keys and userIds included in keyRing object in database - ArrayList operations = new ArrayList(); - - int rank = 0; - for (PGPSecretKey key : new IterableIterator(keyRing.getSecretKeys())) { - operations.add(buildSecretKeyOperations(context, keyRingRowId, key, rank)); - ++rank; - } - - int userIdRank = 0; - for (String userId : new IterableIterator(masterKey.getUserIDs())) { - operations.add(buildSecretUserIdOperations(context, keyRingRowId, userId, userIdRank)); - ++userIdRank; - } - - try { - context.getContentResolver().applyBatch(KeychainContract.CONTENT_AUTHORITY, operations); - } catch (RemoteException e) { - Log.e(Constants.TAG, "applyBatch failed!", e); - } catch (OperationApplicationException e) { - Log.e(Constants.TAG, "applyBatch failed!", e); - } } /** * Build ContentProviderOperation to add PGPPublicKey to database corresponding to a keyRing */ private static ContentProviderOperation buildPublicKeyOperations(Context context, - long keyRingRowId, PGPPublicKey key, int rank) throws IOException { + long masterKeyId, PGPPublicKey key, int rank) throws IOException { + ContentValues values = new ContentValues(); + values.put(Keys.MASTER_KEY_ID, masterKeyId); + values.put(Keys.RANK, rank); + values.put(Keys.KEY_ID, key.getKeyID()); - values.put(Keys.IS_MASTER_KEY, key.isMasterKey()); - values.put(Keys.ALGORITHM, key.getAlgorithm()); values.put(Keys.KEY_SIZE, key.getBitStrength()); - values.put(Keys.CAN_SIGN, PgpKeyHelper.isSigningKey(key)); + values.put(Keys.ALGORITHM, key.getAlgorithm()); + values.put(Keys.FINGERPRINT, key.getFingerprint()); + + values.put(Keys.CAN_CERTIFY, (PgpKeyHelper.isCertificationKey(key))); + values.put(Keys.CAN_SIGN, (PgpKeyHelper.isSigningKey(key))); values.put(Keys.CAN_ENCRYPT, PgpKeyHelper.isEncryptionKey(key)); values.put(Keys.IS_REVOKED, key.isRevoked()); + values.put(Keys.CREATION, PgpKeyHelper.getCreationDate(key).getTime() / 1000); Date expiryDate = PgpKeyHelper.getExpiryDate(key); if (expiryDate != null) { values.put(Keys.EXPIRY, expiryDate.getTime() / 1000); } - values.put(Keys.KEY_RING_ROW_ID, keyRingRowId); - values.put(Keys.KEY_DATA, key.getEncoded()); - values.put(Keys.RANK, rank); - values.put(Keys.FINGERPRINT, key.getFingerprint()); - - Uri uri = Keys.buildPublicKeysUri(Long.toString(keyRingRowId)); - - return ContentProviderOperation.newInsert(uri).withValues(values).build(); - } - - /** - * Build ContentProviderOperation to add PublicUserIds to database corresponding to a keyRing - */ - private static ContentProviderOperation buildPublicUserIdOperations(Context context, - long keyRingRowId, String userId, int rank) { - ContentValues values = new ContentValues(); - values.put(UserIds.KEY_RING_ROW_ID, keyRingRowId); - values.put(UserIds.USER_ID, userId); - values.put(UserIds.RANK, rank); - Uri uri = UserIds.buildPublicUserIdsUri(Long.toString(keyRingRowId)); + Uri uri = Keys.buildKeysUri(Long.toString(masterKeyId)); return ContentProviderOperation.newInsert(uri).withValues(values).build(); } @@ -338,50 +235,21 @@ public class ProviderHelper { * Build ContentProviderOperation to add PGPSecretKey to database corresponding to a keyRing */ private static ContentProviderOperation buildSecretKeyOperations(Context context, - long keyRingRowId, PGPSecretKey key, int rank) throws IOException { - ContentValues values = new ContentValues(); - - boolean hasPrivate = true; - if (key.isMasterKey()) { - if (key.isPrivateKeyEmpty()) { - hasPrivate = false; - } - } - - values.put(Keys.KEY_ID, key.getKeyID()); - values.put(Keys.IS_MASTER_KEY, key.isMasterKey()); - values.put(Keys.ALGORITHM, key.getPublicKey().getAlgorithm()); - values.put(Keys.KEY_SIZE, key.getPublicKey().getBitStrength()); - values.put(Keys.CAN_CERTIFY, (PgpKeyHelper.isCertificationKey(key) && hasPrivate)); - values.put(Keys.CAN_SIGN, (PgpKeyHelper.isSigningKey(key) && hasPrivate)); - values.put(Keys.CAN_ENCRYPT, PgpKeyHelper.isEncryptionKey(key)); - values.put(Keys.IS_REVOKED, key.getPublicKey().isRevoked()); - values.put(Keys.CREATION, PgpKeyHelper.getCreationDate(key).getTime() / 1000); - Date expiryDate = PgpKeyHelper.getExpiryDate(key); - if (expiryDate != null) { - values.put(Keys.EXPIRY, expiryDate.getTime() / 1000); - } - values.put(Keys.KEY_RING_ROW_ID, keyRingRowId); - values.put(Keys.KEY_DATA, key.getEncoded()); - values.put(Keys.RANK, rank); - values.put(Keys.FINGERPRINT, key.getPublicKey().getFingerprint()); - - Uri uri = Keys.buildSecretKeysUri(Long.toString(keyRingRowId)); - - return ContentProviderOperation.newInsert(uri).withValues(values).build(); + long masterKeyId, PGPSecretKey key, int rank) throws IOException { + return buildPublicKeyOperations(context, masterKeyId, key.getPublicKey(), rank); } /** - * Build ContentProviderOperation to add SecretUserIds to database corresponding to a keyRing + * Build ContentProviderOperation to add PublicUserIds to database corresponding to a keyRing */ - private static ContentProviderOperation buildSecretUserIdOperations(Context context, - long keyRingRowId, String userId, int rank) { + private static ContentProviderOperation buildUserIdOperations(Context context, + long masterKeyId, String userId, int rank) { ContentValues values = new ContentValues(); - values.put(UserIds.KEY_RING_ROW_ID, keyRingRowId); + values.put(UserIds.MASTER_KEY_ID, masterKeyId); values.put(UserIds.USER_ID, userId); values.put(UserIds.RANK, rank); - Uri uri = UserIds.buildSecretUserIdsUri(Long.toString(keyRingRowId)); + Uri uri = UserIds.buildUserIdsUri(Long.toString(masterKeyId)); return ContentProviderOperation.newInsert(uri).withValues(values).build(); } @@ -410,141 +278,54 @@ public class ProviderHelper { return masterKeyIds; } - /** - * Private helper method - */ - private static ArrayList getKeyRingsRowIds(Context context, Uri queryUri) { - Cursor cursor = context.getContentResolver().query(queryUri, - new String[]{KeyRings._ID}, null, null, null); - - ArrayList rowIds = new ArrayList(); - if (cursor != null) { - int idCol = cursor.getColumnIndex(KeyRings._ID); - if (cursor.moveToFirst()) { - do { - rowIds.add(cursor.getLong(idCol)); - } while (cursor.moveToNext()); - } - } - - if (cursor != null) { - cursor.close(); - } - - return rowIds; - } - - /** - * Retrieves ids of all SecretKeyRings - */ - public static ArrayList getSecretKeyRingsMasterKeyIds(Context context) { - Uri queryUri = KeyRings.buildSecretKeyRingsUri(); - return getKeyRingsMasterKeyIds(context, queryUri); - } - - /** - * Retrieves ids of all PublicKeyRings - */ - public static ArrayList getPublicKeyRingsMasterKeyIds(Context context) { - Uri queryUri = KeyRings.buildPublicKeyRingsUri(); - return getKeyRingsMasterKeyIds(context, queryUri); - } - - /** - * Retrieves ids of all SecretKeyRings - */ - public static ArrayList getSecretKeyRingsRowIds(Context context) { - Uri queryUri = KeyRings.buildSecretKeyRingsUri(); - return getKeyRingsRowIds(context, queryUri); - } - - /** - * Retrieves ids of all PublicKeyRings - */ - public static ArrayList getPublicKeyRingsRowIds(Context context) { - Uri queryUri = KeyRings.buildPublicKeyRingsUri(); - return getKeyRingsRowIds(context, queryUri); - } - - public static void deletePublicKeyRing(Context context, long rowId) { + public static void deletePublicKeyRing(Context context, long masterKeyId) { ContentResolver cr = context.getContentResolver(); - cr.delete(KeyRings.buildPublicKeyRingsUri(Long.toString(rowId)), null, null); + cr.delete(KeyRings.buildPublicKeyRingUri(Long.toString(masterKeyId)), null, null); } - public static void deleteSecretKeyRing(Context context, long rowId) { + public static void deleteSecretKeyRing(Context context, long masterKeyId) { ContentResolver cr = context.getContentResolver(); - cr.delete(KeyRings.buildSecretKeyRingsUri(Long.toString(rowId)), null, null); - } - - public static void deleteUnifiedKeyRing(Context context, String masterKeyId, boolean isSecretKey) { - ContentResolver cr = context.getContentResolver(); - cr.delete(KeyRings.buildPublicKeyRingsByMasterKeyIdUri(masterKeyId), null, null); - if (isSecretKey) { - cr.delete(KeyRings.buildSecretKeyRingsByMasterKeyIdUri(masterKeyId), null, null); - } - + cr.delete(KeyRings.buildSecretKeyRingUri(Long.toString(masterKeyId)), null, null); } - /** - * Get master key id of keyring by its row id - */ - public static long getPublicMasterKeyId(Context context, long keyRingRowId) { - Uri queryUri = KeyRings.buildPublicKeyRingsUri(String.valueOf(keyRingRowId)); - return getMasterKeyId(context, queryUri); - } - - /** - * Get empty status of master key of keyring by its row id - */ - public static boolean getSecretMasterKeyCanCertify(Context context, long keyRingRowId) { - Uri queryUri = KeyRings.buildSecretKeyRingsUri(String.valueOf(keyRingRowId)); - return getMasterKeyCanCertify(context, queryUri); - } + public static boolean getMasterKeyCanCertify(Context context, Uri queryUri) { + // TODO redo - /** - * Private helper method to get master key private empty status of keyring by its row id - */ + return false; - public static boolean getMasterKeyCanCertify(Context context, Uri queryUri) { - String[] projection = new String[]{ - KeyRings.MASTER_KEY_ID, - "(SELECT COUNT(sign_keys." + Keys._ID + ") FROM " + Tables.KEYS - + " AS sign_keys WHERE sign_keys." + Keys.KEY_RING_ROW_ID + " = " - + KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings._ID - + " AND sign_keys." + Keys.CAN_CERTIFY + " = '1' AND " + Keys.IS_MASTER_KEY - + " = 1) AS sign",}; + /* + String[] projection = new String[]{ + KeyRings.MASTER_KEY_ID, + "(SELECT COUNT(sign_keys." + Keys._ID + ") FROM " + Tables.KEYS + + " AS sign_keys WHERE sign_keys." + Keys.KEY_RING_ROW_ID + " = " + + KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings._ID + + " AND sign_keys." + Keys.CAN_CERTIFY + " = '1' AND " + Keys.IS_MASTER_KEY + + " = 1) AS sign",}; - ContentResolver cr = context.getContentResolver(); - Cursor cursor = cr.query(queryUri, projection, null, null, null); + ContentResolver cr = context.getContentResolver(); + Cursor cursor = cr.query(queryUri, projection, null, null, null); - long masterKeyId = -1; - if (cursor != null && cursor.moveToFirst()) { - int masterKeyIdCol = cursor.getColumnIndex("sign"); + long masterKeyId = -1; + if (cursor != null && cursor.moveToFirst()) { + int masterKeyIdCol = cursor.getColumnIndex("sign"); - masterKeyId = cursor.getLong(masterKeyIdCol); - } + masterKeyId = cursor.getLong(masterKeyIdCol); + } - if (cursor != null) { - cursor.close(); - } + if (cursor != null) { + cursor.close(); + } - return (masterKeyId > 0); + return (masterKeyId > 0); + */ } public static boolean hasSecretKeyByMasterKeyId(Context context, long masterKeyId) { - Uri queryUri = KeyRings.buildSecretKeyRingsByMasterKeyIdUri(Long.toString(masterKeyId)); + Uri queryUri = KeyRings.buildSecretKeyRingUri(Long.toString(masterKeyId)); // see if we can get our master key id back from the uri return getMasterKeyId(context, queryUri) == masterKeyId; } - /** - * Get master key id of keyring by its row id - */ - public static long getSecretMasterKeyId(Context context, long keyRingRowId) { - Uri queryUri = KeyRings.buildSecretKeyRingsUri(String.valueOf(keyRingRowId)); - return getMasterKeyId(context, queryUri); - } - /** * Get master key id of key */ @@ -629,10 +410,10 @@ public class ProviderHelper { } } - PGPPublicKey key = ProviderHelper.getPGPPublicKeyByKeyId(context, masterKeyId); + PGPPublicKey key = ProviderHelper.getPGPPublicKeyRing(context, masterKeyId).getPublicKey(); // if it is no public key get it from your own keys... if (key == null) { - PGPSecretKey secretKey = ProviderHelper.getPGPSecretKeyByKeyId(context, masterKeyId); + PGPSecretKey secretKey = ProviderHelper.getPGPSecretKeyRing(context, masterKeyId).getSecretKey(); if (secretKey == null) { Log.e(Constants.TAG, "Key could not be found!"); return null; @@ -646,26 +427,6 @@ public class ProviderHelper { return fingerprint; } - public static String getUserId(Context context, Uri queryUri) { - String[] projection = new String[]{UserIds.USER_ID}; - Cursor cursor = context.getContentResolver().query(queryUri, projection, null, null, null); - - String userId = null; - try { - if (cursor != null && cursor.moveToFirst()) { - int col = cursor.getColumnIndexOrThrow(UserIds.USER_ID); - - userId = cursor.getString(col); - } - } finally { - if (cursor != null) { - cursor.close(); - } - } - - return userId; - } - public static ArrayList getKeyRingsAsArmoredString(Context context, Uri uri, long[] masterKeyIds) { ArrayList output = new ArrayList(); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java index 1cd5862e7..614fc2c00 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -64,7 +64,7 @@ public class OpenPgpService extends RemoteService { ArrayList dublicateUserIds = new ArrayList(); for (String email : encryptionUserIds) { - Uri uri = KeychainContract.KeyRings.buildPublicKeyRingsByEmailsUri(email); + Uri uri = KeychainContract.KeyRings.buildUnifiedKeyRingsByEmailUri(email); Cursor cur = getContentResolver().query(uri, null, null, null, null); if (cur.moveToFirst()) { long id = cur.getLong(cur.getColumnIndex(KeychainContract.KeyRings.MASTER_KEY_ID)); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index f82e5e619..6997a8f3e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -478,8 +478,7 @@ public class KeychainIntentService extends IntentService /* Operation */ if (!canSign) { PgpKeyOperation keyOperations = new PgpKeyOperation(new ProgressScaler(this, 0, 50, 100)); - PGPSecretKeyRing keyRing = ProviderHelper - .getPGPSecretKeyRingByKeyId(this, masterKeyId); + PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRing(this, masterKeyId); keyRing = keyOperations.changeSecretKeyPassphrase(keyRing, oldPassPhrase, newPassPhrase); setProgress(R.string.progress_saving_key_ring, 50, 100); @@ -487,8 +486,8 @@ public class KeychainIntentService extends IntentService setProgress(R.string.progress_done, 100, 100); } else { PgpKeyOperation keyOperations = new PgpKeyOperation(new ProgressScaler(this, 0, 90, 100)); - PGPSecretKeyRing privkey = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(this, masterKeyId); - PGPPublicKeyRing pubkey = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(this, masterKeyId); + PGPSecretKeyRing privkey = ProviderHelper.getPGPSecretKeyRing(this, masterKeyId); + PGPPublicKeyRing pubkey = ProviderHelper.getPGPPublicKeyRing(this, masterKeyId); PgpKeyOperation.Pair pair = keyOperations.buildSecretKey(privkey, pubkey, saveParams); setProgress(R.string.progress_saving_key_ring, 90, 100); @@ -639,8 +638,9 @@ public class KeychainIntentService extends IntentService ArrayList publicMasterKeyIds = new ArrayList(); ArrayList secretMasterKeyIds = new ArrayList(); - ArrayList allPublicMasterKeyIds = ProviderHelper.getPublicKeyRingsMasterKeyIds(this); - ArrayList allSecretMasterKeyIds = ProviderHelper.getSecretKeyRingsMasterKeyIds(this); + // TODO redo + ArrayList allPublicMasterKeyIds = null; // ProviderHelper.getPublicKeyRingsMasterKeyIds(this); + ArrayList allSecretMasterKeyIds = null; // ProviderHelper.getSecretKeyRingsMasterKeyIds(this); if (exportAll) { // get all public key ring MasterKey ids @@ -790,8 +790,7 @@ public class KeychainIntentService extends IntentService } PgpKeyOperation keyOperation = new PgpKeyOperation(new ProgressScaler(this, 0, 100, 100)); - PGPPublicKeyRing publicRing = ProviderHelper - .getPGPPublicKeyRingByKeyId(this, pubKeyId); + PGPPublicKeyRing publicRing = ProviderHelper.getPGPPublicKeyRing(this, pubKeyId); PGPPublicKey publicKey = publicRing.getPublicKey(pubKeyId); PGPSecretKey certificationKey = PgpKeyHelper.getCertificationKey(this, masterKeyId); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java index 5825db01b..f2ab049c3 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/PassphraseCacheService.java @@ -161,7 +161,7 @@ public class PassphraseCacheService extends Service { // try to get master key id which is used as an identifier for cached passphrases long masterKeyId = keyId; if (masterKeyId != Id.key.symmetric) { - PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByKeyId(this, keyId); + PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingWithKeyId(this, keyId); if (keyRing == null) { return null; } @@ -202,8 +202,7 @@ public class PassphraseCacheService extends Service { public static boolean hasPassphrase(Context context, long secretKeyId) { // check if the key has no passphrase try { - PGPSecretKeyRing secRing = ProviderHelper - .getPGPSecretKeyRingByKeyId(context, secretKeyId); + PGPSecretKeyRing secRing = ProviderHelper.getPGPSecretKeyRing(context, secretKeyId); PGPSecretKey secretKey = null; boolean foundValidKey = false; for (Iterator keys = secRing.getSecretKeys(); keys.hasNext(); ) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java index 5dc06c16d..fd6f2186c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/CertifyKeyActivity.java @@ -139,8 +139,6 @@ public class CertifyKeyActivity extends ActionBarActivity implements } Log.e(Constants.TAG, "uri: " + mDataUri); - PGPPublicKeyRing signKey = (PGPPublicKeyRing) ProviderHelper.getPGPKeyRing(this, mDataUri); - mUserIds = (ListView) findViewById(R.id.user_ids); mUserIdsAdapter = new ViewKeyUserIdsAdapter(this, null, 0, true); @@ -149,20 +147,12 @@ public class CertifyKeyActivity extends ActionBarActivity implements getSupportLoaderManager().initLoader(LOADER_ID_KEYRING, null, this); getSupportLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this); - if (signKey != null) { - mPubKeyId = PgpKeyHelper.getMasterKey(signKey).getKeyID(); - } - if (mPubKeyId == 0) { - Log.e(Constants.TAG, "this shouldn't happen. KeyId == 0!"); - finish(); - return; - } } static final String[] KEYRING_PROJECTION = new String[] { KeychainContract.KeyRings._ID, - KeychainContract.KeyRings.MASTER_KEY_ID, + KeychainContract.Keys.MASTER_KEY_ID, KeychainContract.Keys.FINGERPRINT, KeychainContract.UserIds.USER_ID }; @@ -182,11 +172,13 @@ public class CertifyKeyActivity extends ActionBarActivity implements @Override public Loader onCreateLoader(int id, Bundle args) { switch(id) { - case LOADER_ID_KEYRING: - return new CursorLoader(this, mDataUri, KEYRING_PROJECTION, null, null, null); + case LOADER_ID_KEYRING: { + Uri uri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(mDataUri); + return new CursorLoader(this, uri, KEYRING_PROJECTION, null, null, null); + } case LOADER_ID_USER_IDS: { - Uri baseUri = KeychainContract.UserIds.buildUserIdsUri(mDataUri); - return new CursorLoader(this, baseUri, USER_IDS_PROJECTION, null, null, USER_IDS_SORT_ORDER); + Uri uri = KeychainContract.UserIds.buildUserIdsUri(mDataUri); + return new CursorLoader(this, uri, USER_IDS_PROJECTION, null, null, USER_IDS_SORT_ORDER); } } return null; @@ -199,19 +191,14 @@ public class CertifyKeyActivity extends ActionBarActivity implements // the first key here is our master key if (data.moveToFirst()) { // TODO: put findViewById in onCreate! - - long keyId = data.getLong(INDEX_MASTER_KEY_ID); - String keyIdStr = PgpKeyHelper.convertKeyIdToHexShort(keyId); + mPubKeyId = data.getLong(INDEX_MASTER_KEY_ID); + String keyIdStr = PgpKeyHelper.convertKeyIdToHexShort(mPubKeyId); ((TextView) findViewById(R.id.key_id)).setText(keyIdStr); String mainUserId = data.getString(INDEX_USER_ID); ((TextView) findViewById(R.id.main_user_id)).setText(mainUserId); byte[] fingerprintBlob = data.getBlob(INDEX_FINGERPRINT); - if (fingerprintBlob == null) { - // FALLBACK for old database entries - fingerprintBlob = ProviderHelper.getFingerprint(this, mDataUri); - } String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob); ((TextView) findViewById(R.id.fingerprint)).setText(PgpKeyHelper.colorizeFingerprint(fingerprint)); } @@ -261,7 +248,7 @@ public class CertifyKeyActivity extends ActionBarActivity implements * handles the UI bits of the signing process on the UI thread */ private void initiateSigning() { - PGPPublicKeyRing pubring = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(this, mPubKeyId); + PGPPublicKeyRing pubring = ProviderHelper.getPGPPublicKeyRing(this, mPubKeyId); if (pubring != null) { // if we have already signed this key, dont bother doing it again boolean alreadySigned = false; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java index 9df84065f..0d0b7222e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EditKeyActivity.java @@ -356,7 +356,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener return true; case R.id.menu_key_edit_delete: long rowId= ProviderHelper.getRowId(this,mDataUri); - Uri convertUri = KeychainContract.KeyRings.buildSecretKeyRingsUri(Long.toString(rowId)); + Uri convertUri = KeychainContract.KeyRings.buildSecretKeyRingUri(Long.toString(rowId)); // Message is received after key is deleted Handler returnHandler = new Handler() { @Override @@ -380,7 +380,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener private void finallyEdit(final long masterKeyId) { if (masterKeyId != 0) { PGPSecretKey masterKey = null; - mKeyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(this, masterKeyId); + mKeyRing = ProviderHelper.getPGPSecretKeyRing(this, masterKeyId); if (mKeyRing != null) { masterKey = PgpKeyHelper.getMasterKey(mKeyRing); for (PGPSecretKey key : new IterableIterator(mKeyRing.getSecretKeys())) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java index 5b7f9e4cc..10508317d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java @@ -141,7 +141,7 @@ public class EncryptAsymmetricFragment extends Fragment { private void preselectKeys(long preselectedSignatureKeyId, long[] preselectedEncryptionKeyIds) { if (preselectedSignatureKeyId != 0) { // TODO: don't use bouncy castle objects! - PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(getActivity(), + PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingWithKeyId(getActivity(), preselectedSignatureKeyId); PGPSecretKey masterKey; if (keyRing != null) { @@ -160,7 +160,7 @@ public class EncryptAsymmetricFragment extends Fragment { for (int i = 0; i < preselectedEncryptionKeyIds.length; ++i) { // TODO: don't use bouncy castle objects! - PGPPublicKeyRing keyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(getActivity(), + PGPPublicKeyRing keyRing = ProviderHelper.getPGPPublicKeyRingWithKeyId(getActivity(), preselectedEncryptionKeyIds[i]); PGPPublicKey masterKey; if (keyRing == null) { @@ -203,7 +203,7 @@ public class EncryptAsymmetricFragment extends Fragment { String uid = getResources().getString(R.string.user_id_no_name); String uidExtra = ""; // TODO: don't use bouncy castle objects! - PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingByMasterKeyId(getActivity(), + PGPSecretKeyRing keyRing = ProviderHelper.getPGPSecretKeyRingWithKeyId(getActivity(), mSecretKeyId); if (keyRing != null) { PGPSecretKey key = PgpKeyHelper.getMasterKey(keyRing); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java index 957c822d2..573ddd1a7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/KeyListFragment.java @@ -186,6 +186,7 @@ public class KeyListFragment extends Fragment case R.id.menu_key_list_multi_export: { ids = mStickyList.getWrappedList().getCheckedItemIds(); long[] masterKeyIds = new long[2*ids.length]; + /* TODO! redo ArrayList allPubRowIds = ProviderHelper.getPublicKeyRingsRowIds(getActivity()); for (int i = 0; i < ids.length; i++) { @@ -194,7 +195,7 @@ public class KeyListFragment extends Fragment } else { masterKeyIds[i] = ProviderHelper.getSecretMasterKeyId(getActivity(), ids[i]); } - } + }*/ ExportHelper mExportHelper = new ExportHelper((ActionBarActivity) getActivity()); mExportHelper .showExportKeysDialog(masterKeyIds, Id.type.public_key, @@ -254,22 +255,22 @@ public class KeyListFragment extends Fragment // These are the rows that we will retrieve. static final String[] PROJECTION = new String[]{ KeychainContract.KeyRings._ID, - KeychainContract.KeyRings.TYPE, - KeychainContract.KeyRings.MASTER_KEY_ID, + KeychainContract.Keys.MASTER_KEY_ID, KeychainContract.UserIds.USER_ID, - KeychainContract.Keys.IS_REVOKED + KeychainContract.Keys.IS_REVOKED, + KeychainDatabase.Tables.KEY_RINGS_SECRET + "." + KeychainContract.KeyRings.MASTER_KEY_ID }; - static final int INDEX_TYPE = 1; - static final int INDEX_MASTER_KEY_ID = 2; - static final int INDEX_USER_ID = 3; - static final int INDEX_IS_REVOKED = 4; + static final int INDEX_MASTER_KEY_ID = 1; + static final int INDEX_USER_ID = 2; + static final int INDEX_IS_REVOKED = 3; + static final int INDEX_HAS_SECRET = 4; static final String SORT_ORDER = // show secret before public key - KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings.TYPE + " DESC, " + KeychainDatabase.Tables.KEY_RINGS_SECRET + "." + KeychainContract.KeyRings.MASTER_KEY_ID + " IS NULL ASC, " + // sort by user id otherwise - + UserIds.USER_ID + " ASC"; + UserIds.USER_ID + " ASC"; @Override public Loader onCreateLoader(int id, Bundle args) { @@ -326,7 +327,7 @@ public class KeyListFragment extends Fragment } viewIntent.setData( KeychainContract - .KeyRings.buildPublicKeyRingsByMasterKeyIdUri( + .KeyRings.buildPublicKeyRingUri( Long.toString(mAdapter.getMasterKeyId(position)))); startActivity(viewIntent); } @@ -503,7 +504,7 @@ public class KeyListFragment extends Fragment Button button = (Button) view.findViewById(R.id.edit); TextView revoked = (TextView) view.findViewById(R.id.revoked); - if (cursor.getInt(KeyListFragment.INDEX_TYPE) == KeyTypes.SECRET) { + if (!cursor.isNull(KeyListFragment.INDEX_HAS_SECRET)) { // this is a secret key - show the edit button statusDivider.setVisibility(View.VISIBLE); statusLayout.setVisibility(View.VISIBLE); @@ -516,7 +517,7 @@ public class KeyListFragment extends Fragment Intent editIntent = new Intent(getActivity(), EditKeyActivity.class); editIntent.setData( KeychainContract.KeyRings - .buildSecretKeyRingsByMasterKeyIdUri(Long.toString(id))); + .buildSecretKeyRingUri(Long.toString(id))); editIntent.setAction(EditKeyActivity.ACTION_EDIT_KEY); startActivityForResult(editIntent, 0); } @@ -577,7 +578,7 @@ public class KeyListFragment extends Fragment throw new IllegalStateException("couldn't move cursor to position " + position); } - if (mCursor.getInt(KeyListFragment.INDEX_TYPE) == KeyTypes.SECRET) { + if (!mCursor.isNull(KeyListFragment.INDEX_HAS_SECRET)) { { // set contact count int num = mCursor.getCount(); String contactsTotal = getResources().getQuantityString(R.plurals.n_contacts, num, num); @@ -617,7 +618,7 @@ public class KeyListFragment extends Fragment } // early breakout: all secret keys are assigned id 0 - if (mCursor.getInt(KeyListFragment.INDEX_TYPE) == KeyTypes.SECRET) { + if (!mCursor.isNull(KeyListFragment.INDEX_HAS_SECRET)) { return 1L; } // otherwise, return the first character of the name as ID diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java index 6ab9f1c6e..fcce39ee9 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectPublicKeyFragment.java @@ -248,9 +248,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T @Override public Loader onCreateLoader(int id, Bundle args) { - // This is called when a new Loader needs to be created. This - // sample only has one Loader, so we don't care about the ID. - Uri baseUri = KeyRings.buildPublicKeyRingsUri(); + Uri baseUri = KeyRings.buildUnifiedKeyRingsUri(); // These are the rows that we will retrieve. long now = new Date().getTime() / 1000; @@ -258,24 +256,24 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T KeyRings._ID, KeyRings.MASTER_KEY_ID, UserIds.USER_ID, - "(SELECT COUNT(available_keys." + Keys._ID + ") FROM " + Tables.KEYS - + " AS available_keys WHERE available_keys." + Keys.KEY_RING_ROW_ID + " = " - + KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings._ID - + " AND available_keys." + Keys.IS_REVOKED + " = '0' AND available_keys." - + Keys.CAN_ENCRYPT + " = '1') AS " - + SelectKeyCursorAdapter.PROJECTION_ROW_AVAILABLE, - "(SELECT COUNT(valid_keys." + Keys._ID + ") FROM " + Tables.KEYS - + " AS valid_keys WHERE valid_keys." + Keys.KEY_RING_ROW_ID + " = " - + KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings._ID - + " AND valid_keys." + Keys.IS_REVOKED + " = '0' AND valid_keys." - + Keys.CAN_ENCRYPT + " = '1' AND valid_keys." + Keys.CREATION + " <= '" - + now + "' AND " + "(valid_keys." + Keys.EXPIRY + " IS NULL OR valid_keys." - + Keys.EXPIRY + " >= '" + now + "')) AS " - + SelectKeyCursorAdapter.PROJECTION_ROW_VALID, }; + "(SELECT COUNT(*) FROM " + Tables.KEYS + " AS k" + +" WHERE k." + Keys.MASTER_KEY_ID + " = " + + KeychainDatabase.Tables.KEYS + "." + Keys.MASTER_KEY_ID + + " AND k." + Keys.IS_REVOKED + " = '0'" + + " AND k." + Keys.CAN_ENCRYPT + " = '1'" + + ") AS " + SelectKeyCursorAdapter.PROJECTION_ROW_AVAILABLE, + "(SELECT COUNT(*) FROM " + Tables.KEYS + " AS k" + + " WHERE k." + Keys.MASTER_KEY_ID + " = " + + KeychainDatabase.Tables.KEYS + "." + Keys.MASTER_KEY_ID + + " AND k." + Keys.IS_REVOKED + " = '0'" + + " AND k." + Keys.CAN_ENCRYPT + " = '1'" + + " AND k." + Keys.CREATION + " <= '" + now + "'" + + " AND ( k." + Keys.EXPIRY + " IS NULL OR k." + Keys.EXPIRY + " >= '" + now + "' )" + + ") AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID, }; String inMasterKeyList = null; if (mSelectedMasterKeyIds != null && mSelectedMasterKeyIds.length > 0) { - inMasterKeyList = KeyRings.MASTER_KEY_ID + " IN ("; + inMasterKeyList = Tables.KEYS + "." + KeyRings.MASTER_KEY_ID + " IN ("; for (int i = 0; i < mSelectedMasterKeyIds.length; ++i) { if (i != 0) { inMasterKeyList += ", "; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java index 2efa7d33a..9987facbc 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyFragment.java @@ -85,7 +85,7 @@ public class SelectSecretKeyFragment extends ListFragment implements @Override public void onItemClick(AdapterView adapterView, View view, int position, long id) { long masterKeyId = mAdapter.getMasterKeyId(position); - Uri result = KeyRings.buildSecretKeyRingsByMasterKeyIdUri(String.valueOf(masterKeyId)); + Uri result = KeyRings.buildGenericKeyRingUri(String.valueOf(masterKeyId)); // return data to activity, which results in finishing it mActivity.afterListSelection(result); @@ -112,12 +112,7 @@ public class SelectSecretKeyFragment extends ListFragment implements public Loader onCreateLoader(int id, Bundle args) { // This is called when a new Loader needs to be created. This // sample only has one Loader, so we don't care about the ID. - Uri baseUri = KeyRings.buildSecretKeyRingsUri(); - - String capFilter = null; - if (mFilterCertify) { - capFilter = "(cert > 0)"; - } + Uri baseUri = KeyRings.buildUnifiedKeyRingsUri(); // These are the rows that we will retrieve. long now = new Date().getTime() / 1000; @@ -125,29 +120,36 @@ public class SelectSecretKeyFragment extends ListFragment implements KeyRings._ID, KeyRings.MASTER_KEY_ID, UserIds.USER_ID, - "(SELECT COUNT(cert_keys." + Keys._ID + ") FROM " + Tables.KEYS - + " AS cert_keys WHERE cert_keys." + Keys.KEY_RING_ROW_ID + " = " - + KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings._ID + " AND cert_keys." - + Keys.CAN_CERTIFY + " = '1') AS cert", - "(SELECT COUNT(available_keys." + Keys._ID + ") FROM " + Tables.KEYS - + " AS available_keys WHERE available_keys." + Keys.KEY_RING_ROW_ID + " = " - + KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings._ID - + " AND available_keys." + Keys.IS_REVOKED + " = '0' AND available_keys." - + Keys.CAN_SIGN + " = '1') AS " - + SelectKeyCursorAdapter.PROJECTION_ROW_AVAILABLE, - "(SELECT COUNT(valid_keys." + Keys._ID + ") FROM " + Tables.KEYS - + " AS valid_keys WHERE valid_keys." + Keys.KEY_RING_ROW_ID + " = " - + KeychainDatabase.Tables.KEY_RINGS + "." + KeyRings._ID + " AND valid_keys." - + Keys.IS_REVOKED + " = '0' AND valid_keys." + Keys.CAN_SIGN - + " = '1' AND valid_keys." + Keys.CREATION + " <= '" + now + "' AND " - + "(valid_keys." + Keys.EXPIRY + " IS NULL OR valid_keys." + Keys.EXPIRY - + " >= '" + now + "')) AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID,}; + "(SELECT COUNT(*) FROM " + Tables.KEYS + " AS k" + + " WHERE k." + Keys.MASTER_KEY_ID + " = " + + KeychainDatabase.Tables.KEYS + "." + KeyRings.MASTER_KEY_ID + + " AND k." + Keys.CAN_CERTIFY + " = '1'" + + ") AS cert", + "(SELECT COUNT(*) FROM " + Tables.KEYS + " AS k" + +" WHERE k." + Keys.MASTER_KEY_ID + " = " + + KeychainDatabase.Tables.KEYS + "." + Keys.MASTER_KEY_ID + + " AND k." + Keys.IS_REVOKED + " = '0'" + + " AND k." + Keys.CAN_SIGN + " = '1'" + + ") AS " + SelectKeyCursorAdapter.PROJECTION_ROW_AVAILABLE, + "(SELECT COUNT(*) FROM " + Tables.KEYS + " AS k" + + " WHERE k." + Keys.MASTER_KEY_ID + " = " + + KeychainDatabase.Tables.KEYS + "." + Keys.MASTER_KEY_ID + + " AND k." + Keys.IS_REVOKED + " = '0'" + + " AND k." + Keys.CAN_SIGN + " = '1'" + + " AND k." + Keys.CREATION + " <= '" + now + "'" + + " AND ( k." + Keys.EXPIRY + " IS NULL OR k." + Keys.EXPIRY + " >= '" + now + "' )" + + ") AS " + SelectKeyCursorAdapter.PROJECTION_ROW_VALID, }; String orderBy = UserIds.USER_ID + " ASC"; + String where = Tables.KEY_RINGS_SECRET + "." + KeyRings.MASTER_KEY_ID + " IS NOT NULL"; + if (mFilterCertify) { + where += " AND (cert > 0)"; + } + // Now create and return a CursorLoader that will take care of // creating a Cursor for the data being displayed. - return new CursorLoader(getActivity(), baseUri, projection, capFilter, null, orderBy); + return new CursorLoader(getActivity(), baseUri, projection, where, null, orderBy); } @Override diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java index cbc0f4c5c..95eb4df94 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/SelectSecretKeyLayoutFragment.java @@ -57,10 +57,12 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan //The Projection we will retrieve, Master Key ID is for convenience sake, //to avoid having to pass the Key Around - final String[] PROJECTION = new String[]{KeychainContract.UserIds.USER_ID - , KeychainContract.KeyRings.MASTER_KEY_ID}; - final int INDEX_USER_ID = 0; - final int INDEX_MASTER_KEY_ID = 1; + final String[] PROJECTION = new String[] { + KeychainContract.Keys.MASTER_KEY_ID, + KeychainContract.UserIds.USER_ID + }; + final int INDEX_MASTER_KEY_ID = 0; + final int INDEX_USER_ID = 1; public interface SelectSecretKeyCallback { void onKeySelected(long secretKeyId); @@ -126,7 +128,7 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan //For AppSettingsFragment public void selectKey(long masterKeyId) { - Uri buildUri = KeychainContract.KeyRings.buildSecretKeyRingsByMasterKeyIdUri(String.valueOf(masterKeyId)); + Uri buildUri = KeychainContract.KeyRings.buildGenericKeyRingUri(String.valueOf(masterKeyId)); mReceivedUri = buildUri; getActivity().getSupportLoaderManager().restartLoader(LOADER_ID, null, this); } @@ -139,8 +141,9 @@ public class SelectSecretKeyLayoutFragment extends Fragment implements LoaderMan @Override public Loader onCreateLoader(int id, Bundle args) { + Uri uri = KeychainContract.KeyRings.buildUnifiedKeyRingUri(mReceivedUri); //We don't care about the Loader id - return new CursorLoader(getActivity(), mReceivedUri, PROJECTION, null, null, null); + return new CursorLoader(getActivity(), uri, PROJECTION, null, null, null); } @Override diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index 3e7e6d7ce..c212bea1f 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -83,13 +83,7 @@ public class ViewKeyActivity extends ActionBarActivity { selectedTab = intent.getExtras().getInt(EXTRA_SELECTED_TAB); } - { - // normalize mDataUri to a "by row id" query, to ensure it works with any - // given valid /public/ query - long rowId = ProviderHelper.getRowId(this, getIntent().getData()); - // TODO: handle (rowId == 0) with something else than a crash - mDataUri = KeychainContract.KeyRings.buildPublicKeyRingsUri(Long.toString(rowId)); - } + mDataUri = getIntent().getData(); Bundle mainBundle = new Bundle(); mainBundle.putParcelable(ViewKeyMainFragment.ARG_DATA_URI, mDataUri); @@ -124,8 +118,7 @@ public class ViewKeyActivity extends ActionBarActivity { uploadToKeyserver(mDataUri); return true; case R.id.menu_key_view_export_file: - long masterKeyId = - ProviderHelper.getPublicMasterKeyId(this, Long.valueOf(mDataUri.getLastPathSegment())); + long masterKeyId = Long.valueOf(mDataUri.getLastPathSegment()); long[] ids = new long[]{masterKeyId}; mExportHelper.showExportKeysDialog(ids, Id.type.public_key, Constants.Path.APP_DIR_FILE_PUB, null); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java index 691be5fa9..397cfafa7 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyMainFragment.java @@ -69,7 +69,6 @@ public class ViewKeyMainFragment extends Fragment implements private ListView mUserIds; private ListView mKeys; - private static final int LOADER_ID_KEYRING = 0; private static final int LOADER_ID_USER_IDS = 1; private static final int LOADER_ID_KEYS = 2; @@ -144,7 +143,7 @@ public class ViewKeyMainFragment extends Fragment implements Intent editIntent = new Intent(getActivity(), EditKeyActivity.class); editIntent.setData( KeychainContract - .KeyRings.buildSecretKeyRingsByMasterKeyIdUri( + .KeyRings.buildSecretKeyRingUri( Long.toString(masterKeyId))); editIntent.setAction(EditKeyActivity.ACTION_EDIT_KEY); startActivityForResult(editIntent, 0); @@ -163,7 +162,7 @@ public class ViewKeyMainFragment extends Fragment implements // TODO see todo note above, doing this here for now mActionCertify.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { - certifyKey(KeychainContract.KeyRings.buildPublicKeyRingsByMasterKeyIdUri( + certifyKey(KeychainContract.KeyRings.buildGenericKeyRingUri( Long.toString(masterKeyId) )); } @@ -187,39 +186,31 @@ public class ViewKeyMainFragment extends Fragment implements // Prepare the loaders. Either re-connect with an existing ones, // or start new ones. - getActivity().getSupportLoaderManager().initLoader(LOADER_ID_KEYRING, null, this); getActivity().getSupportLoaderManager().initLoader(LOADER_ID_USER_IDS, null, this); getActivity().getSupportLoaderManager().initLoader(LOADER_ID_KEYS, null, this); } - static final String[] KEYRING_PROJECTION = - new String[]{KeychainContract.KeyRings._ID, KeychainContract.KeyRings.MASTER_KEY_ID, - KeychainContract.UserIds.USER_ID}; - static final int KEYRING_INDEX_ID = 0; - static final int KEYRING_INDEX_MASTER_KEY_ID = 1; - static final int KEYRING_INDEX_USER_ID = 2; - static final String[] USER_IDS_PROJECTION = new String[]{ KeychainContract.UserIds._ID, KeychainContract.UserIds.USER_ID, KeychainContract.UserIds.RANK, }; + static final int INDEX_UID_UID = 1; static final String USER_IDS_SORT_ORDER = KeychainContract.UserIds.RANK + " COLLATE LOCALIZED ASC"; static final String[] KEYS_PROJECTION = new String[]{KeychainContract.Keys._ID, KeychainContract.Keys.KEY_ID, - KeychainContract.Keys.IS_MASTER_KEY, KeychainContract.Keys.ALGORITHM, + KeychainContract.Keys.ALGORITHM, KeychainContract.Keys.RANK, KeychainContract.Keys.KEY_SIZE, KeychainContract.Keys.CAN_CERTIFY, KeychainContract.Keys.CAN_SIGN, KeychainContract.Keys.CAN_ENCRYPT, KeychainContract.Keys.IS_REVOKED, KeychainContract.Keys.CREATION, KeychainContract.Keys.EXPIRY, KeychainContract.Keys.FINGERPRINT}; static final String KEYS_SORT_ORDER = KeychainContract.Keys.RANK + " ASC"; - static final int KEYS_INDEX_ID = 0; static final int KEYS_INDEX_KEY_ID = 1; - static final int KEYS_INDEX_IS_MASTER_KEY = 2; - static final int KEYS_INDEX_ALGORITHM = 3; + static final int KEYS_INDEX_ALGORITHM = 2; + static final int KEYS_INDEX_RANK = 3; static final int KEYS_INDEX_KEY_SIZE = 4; static final int KEYS_INDEX_CAN_CERTIFY = 5; static final int KEYS_INDEX_CAN_SIGN = 6; @@ -231,13 +222,6 @@ public class ViewKeyMainFragment extends Fragment implements public Loader onCreateLoader(int id, Bundle args) { switch (id) { - case LOADER_ID_KEYRING: { - Uri baseUri = mDataUri; - - // Now create and return a CursorLoader that will take care of - // creating a Cursor for the data being displayed. - return new CursorLoader(getActivity(), baseUri, KEYRING_PROJECTION, null, null, null); - } case LOADER_ID_USER_IDS: { Uri baseUri = KeychainContract.UserIds.buildUserIdsUri(mDataUri); @@ -263,11 +247,11 @@ public class ViewKeyMainFragment extends Fragment implements // Swap the new cursor in. (The framework will take care of closing the // old cursor once we return.) switch (loader.getId()) { - case LOADER_ID_KEYRING: + case LOADER_ID_USER_IDS: if (data.moveToFirst()) { // get name, email, and comment from USER_ID String[] mainUserId = PgpKeyHelper.splitUserId(data - .getString(KEYRING_INDEX_USER_ID)); + .getString(INDEX_UID_UID)); if (mainUserId[0] != null) { getActivity().setTitle(mainUserId[0]); mName.setText(mainUserId[0]); @@ -278,9 +262,6 @@ public class ViewKeyMainFragment extends Fragment implements mEmail.setText(mainUserId[1]); mComment.setText(mainUserId[2]); } - - break; - case LOADER_ID_USER_IDS: mUserIdsAdapter.swapCursor(data); break; case LOADER_ID_KEYS: @@ -354,9 +335,6 @@ public class ViewKeyMainFragment extends Fragment implements */ public void onLoaderReset(Loader loader) { switch (loader.getId()) { - case LOADER_ID_KEYRING: - // No resources need to be freed for this ID - break; case LOADER_ID_USER_IDS: mUserIdsAdapter.swapCursor(null); break; @@ -368,11 +346,11 @@ public class ViewKeyMainFragment extends Fragment implements } } - private void encryptToContact(Uri dataUri) { - long keyId = ProviderHelper.getMasterKeyId(getActivity(), dataUri); + // TODO preselect from uri? should be feasible without trivial query + long keyId = Long.parseLong(dataUri.getPathSegments().get(1)); - long[] encryptionKeyIds = new long[]{keyId}; + long[] encryptionKeyIds = new long[]{ keyId }; Intent intent = new Intent(getActivity(), EncryptActivity.class); intent.setAction(EncryptActivity.ACTION_ENCRYPT); intent.putExtra(EncryptActivity.EXTRA_ENCRYPTION_KEY_IDS, encryptionKeyIds); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java index 9d60c1530..adcb5619d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ViewKeyKeysAdapter.java @@ -41,7 +41,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter { private int mIndexKeyId; private int mIndexAlgorithm; private int mIndexKeySize; - private int mIndexIsMasterKey; + private int mIndexRank; private int mIndexCanCertify; private int mIndexCanEncrypt; private int mIndexCanSign; @@ -76,7 +76,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter { mIndexKeyId = cursor.getColumnIndexOrThrow(Keys.KEY_ID); mIndexAlgorithm = cursor.getColumnIndexOrThrow(Keys.ALGORITHM); mIndexKeySize = cursor.getColumnIndexOrThrow(Keys.KEY_SIZE); - mIndexIsMasterKey = cursor.getColumnIndexOrThrow(Keys.IS_MASTER_KEY); + mIndexRank = cursor.getColumnIndexOrThrow(Keys.RANK); mIndexCanCertify = cursor.getColumnIndexOrThrow(Keys.CAN_CERTIFY); mIndexCanEncrypt = cursor.getColumnIndexOrThrow(Keys.CAN_ENCRYPT); mIndexCanSign = cursor.getColumnIndexOrThrow(Keys.CAN_SIGN); @@ -103,7 +103,7 @@ public class ViewKeyKeysAdapter extends CursorAdapter { keyId.setText(keyIdStr); keyDetails.setText("(" + algorithmStr + ")"); - if (cursor.getInt(mIndexIsMasterKey) != 1) { + if (cursor.getInt(mIndexRank) == 0) { masterKeyIcon.setVisibility(View.INVISIBLE); } else { masterKeyIcon.setVisibility(View.VISIBLE); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java index 3ff88aa2b..cd15c4d2d 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/DeleteKeyDialogFragment.java @@ -98,6 +98,7 @@ public class DeleteKeyDialogFragment extends DialogFragment { checkDeleteSecret = (CheckBox) inflateView.findViewById(R.id.checkDeleteSecret); builder.setTitle(R.string.warning); + /* TODO! redo //If only a single key has been selected if (keyRingRowIds.length == 1) { @@ -210,6 +211,7 @@ public class DeleteKeyDialogFragment extends DialogFragment { dismiss(); } }); + */ return builder.create(); } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java index 3c8b872b0..b8db470b4 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/PassphraseDialogFragment.java @@ -116,10 +116,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor secretKey = null; alert.setMessage(R.string.passphrase_for_symmetric_encryption); } else { - // TODO: by master key id??? - secretKey = PgpKeyHelper.getMasterKey(ProviderHelper.getPGPSecretKeyRingByKeyId(activity, - secretKeyId)); - // secretKey = PGPHelper.getMasterKey(PGPMain.getSecretKeyRing(secretKeyId)); + secretKey = ProviderHelper.getPGPSecretKeyByKeyId(activity, secretKeyId); if (secretKey == null) { alert.setTitle(R.string.title_key_not_found); @@ -175,7 +172,7 @@ public class PassphraseDialogFragment extends DialogFragment implements OnEditor return; } else { clickSecretKey = PgpKeyHelper.getKeyNum(ProviderHelper - .getPGPSecretKeyRingByKeyId(activity, secretKeyId), + .getPGPSecretKeyRingWithKeyId(activity, secretKeyId), curKeyIndex); curKeyIndex++; // does post-increment work like C? continue; -- cgit v1.2.3 From 0b24ec04a69c8c452f4591c901651dbe112f782d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 3 Apr 2014 12:14:58 +0200 Subject: clarify readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 474bf180b..4c06ad445 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Development mailinglist at http://groups.google.com/d/forum/openpgp-keychain-dev 2. Open the Android SDK Manager (shell command: ``android``). Expand the Tools directory and select "Android SDK Build-tools (Version 19.0.3)". Expand the Extras directory and install "Android Support Repository" -Select everything for the newest SDK (API-Level 19) +Select everything for the newest SDK Platform (API-Level 19) 3. Export ANDROID_HOME pointing to your Android SDK 4. Execute ``./gradlew build`` 5. You can install the app with ``adb install -r OpenPGP-Keychain/build/apk/OpenPGP-Keychain-debug-unaligned.apk`` -- cgit v1.2.3 From 11b08c4d985854ded125d5a43e8a13207dee393d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 3 Apr 2014 12:28:30 +0200 Subject: Cleanup DrawerActivity --- .../keychain/ui/DrawerActivity.java | 35 +++------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java index 17dce0221..463c99948 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java @@ -125,13 +125,11 @@ public class DrawerActivity extends ActionBarActivity { // so that it doesn't consume all the Back button presses mDrawerLayout.setFocusableInTouchMode(false); } - // if (savedInstanceState == null) { - // selectItem(0); - // } } /** * Uses startActivity to call the Intent of the given class + * * @param drawerItem the class of the drawer item you want to load. Based on Constants.DrawerItems.* */ public void callIntentForDrawerItem(Class drawerItem) { @@ -159,16 +157,6 @@ public class DrawerActivity extends ActionBarActivity { return super.onCreateOptionsMenu(menu); } - /* Called whenever we call invalidateOptionsMenu() */ - @Override - public boolean onPrepareOptionsMenu(Menu menu) { - // If the nav drawer is open, hide action items related to the content - // view - boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList); - // menu.findItem(R.id.action_websearch).setVisible(!drawerOpen); - return super.onPrepareOptionsMenu(menu); - } - @Override public boolean onOptionsItemSelected(MenuItem item) { // The action bar home/up action should open or close the drawer. @@ -191,26 +179,11 @@ public class DrawerActivity extends ActionBarActivity { default: return super.onOptionsItemSelected(item); } - - // Handle action buttons - // switch (item.getItemId()) { - // case R.id.action_websearch: - // // create intent to perform web search for this planet - // Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); - // intent.putExtra(SearchManager.QUERY, getSupportActionBar().getTitle()); - // // catch event that there's no activity to handle intent - // if (intent.resolveActivity(getPackageManager()) != null) { - // startActivity(intent); - // } else { - // Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show(); - // } - // return true; - // default: - // return super.onOptionsItemSelected(item); - // } } - /* The click listener for ListView in the navigation drawer */ + /** + * The click listener for ListView in the navigation drawer + */ private class DrawerItemClickListener implements ListView.OnItemClickListener { @Override public void onItemClick(AdapterView parent, View view, int position, long id) { -- cgit v1.2.3 From 2df4ccafb5cab2963bde1f2d54293b6c3579d0f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 3 Apr 2014 15:02:55 +0200 Subject: Implement ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN --- .../keychain/service/KeychainIntentService.java | 13 -- .../keychain/ui/DecryptFragment.java | 9 +- .../keychain/ui/DrawerActivity.java | 16 +- .../keychain/ui/EncryptAsymmetricFragment.java | 5 +- .../keychain/ui/ImportKeysActivity.java | 166 +++++++++------------ .../keychain/ui/ImportKeysServerFragment.java | 5 + .../keychain/ui/ViewKeyActivity.java | 31 ++-- .../ui/adapter/ImportKeysListServerLoader.java | 28 +++- .../main/res/layout/decrypt_signature_include.xml | 27 ++-- OpenPGP-Keychain/src/main/res/values/strings.xml | 2 +- 10 files changed, 155 insertions(+), 147 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index e9c949246..59f2db46b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -112,7 +112,6 @@ public class KeychainIntentService extends IntentService // possible targets: public static final int TARGET_BYTES = 1; public static final int TARGET_URI = 2; - public static final int TARGET_STREAM = 3; // encrypt public static final String ENCRYPT_SIGNATURE_KEY_ID = "secret_key_id"; @@ -122,7 +121,6 @@ public class KeychainIntentService extends IntentService public static final String ENCRYPT_MESSAGE_BYTES = "message_bytes"; public static final String ENCRYPT_INPUT_FILE = "input_file"; public static final String ENCRYPT_OUTPUT_FILE = "output_file"; - public static final String ENCRYPT_PROVIDER_URI = "provider_uri"; public static final String ENCRYPT_SYMMETRIC_PASSPHRASE = "passphrase"; // decrypt/verify @@ -173,11 +171,7 @@ public class KeychainIntentService extends IntentService public static final String RESULT_KEY_USAGES = "new_key_usages"; // encrypt - public static final String RESULT_SIGNATURE_BYTES = "signature_data"; - public static final String RESULT_SIGNATURE_STRING = "signature_text"; - public static final String RESULT_ENCRYPTED_STRING = "encrypted_message"; public static final String RESULT_BYTES = "encrypted_data"; - public static final String RESULT_URI = "result_uri"; // decrypt/verify public static final String RESULT_DECRYPTED_BYTES = "decrypted_data"; @@ -191,10 +185,6 @@ public class KeychainIntentService extends IntentService // export public static final String RESULT_EXPORT = "exported"; - // query - public static final String RESULT_QUERY_KEY_DATA = "query_key_data"; - public static final String RESULT_QUERY_KEY_SEARCH_RESULT = "query_key_search_result"; - Messenger mMessenger; private boolean mIsCanceled; @@ -738,9 +728,6 @@ public class KeychainIntentService extends IntentService ArrayList entries = data.getParcelableArrayList(DOWNLOAD_KEY_LIST); String keyServer = data.getString(DOWNLOAD_KEY_SERVER); - // TODO: add extra which requires fingerprint suport and force verification! - // only supported by newer sks keyserver versions - // this downloads the keys and places them into the ImportKeysListEntry entries HkpKeyServer server = new HkpKeyServer(keyServer); diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java index fd7aef353..e7596534c 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DecryptFragment.java @@ -38,6 +38,8 @@ import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException; +import org.sufficientlysecure.keychain.provider.KeychainContract; +import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; import org.sufficientlysecure.keychain.util.Log; @@ -88,13 +90,9 @@ public class DecryptFragment extends Fragment { public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { - // this request is returned after LookupUnknownKeyDialogFragment started - // ImportKeysActivity and user looked uo key case RESULT_CODE_LOOKUP_KEY: { - Log.d(Constants.TAG, "Returning from Lookup Key..."); if (resultCode == Activity.RESULT_OK) { - // decrypt again -// decryptStart(); + // TODO: generate new OpenPgpSignatureResult and display it } return; } @@ -189,6 +187,7 @@ public class DecryptFragment extends Fragment { /** * Should be overridden by MessageFragment and FileFragment to start actual decryption + * * @param passphrase */ protected void decryptStart(String passphrase) { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java index 463c99948..f81224380 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/DrawerActivity.java @@ -151,6 +151,10 @@ public class DrawerActivity extends ActionBarActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { + if (mDrawerToggle == null) { + return super.onCreateOptionsMenu(menu); + } + menu.add(42, MENU_ID_PREFERENCE, 100, R.string.menu_preferences); menu.add(42, MENU_ID_HELP, 101, R.string.menu_help); @@ -159,6 +163,10 @@ public class DrawerActivity extends ActionBarActivity { @Override public boolean onOptionsItemSelected(MenuItem item) { + if (mDrawerToggle == null) { + return super.onOptionsItemSelected(item); + } + // The action bar home/up action should open or close the drawer. // ActionBarDrawerToggle will take care of this. if (mDrawerToggle.onOptionsItemSelected(item)) { @@ -216,14 +224,18 @@ public class DrawerActivity extends ActionBarActivity { protected void onPostCreate(Bundle savedInstanceState) { super.onPostCreate(savedInstanceState); // Sync the toggle state after onRestoreInstanceState has occurred. - mDrawerToggle.syncState(); + if (mDrawerToggle != null) { + mDrawerToggle.syncState(); + } } @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); // Pass any configuration change to the drawer toggles - mDrawerToggle.onConfigurationChanged(newConfig); + if (mDrawerToggle != null) { + mDrawerToggle.onConfigurationChanged(newConfig); + } } private class NavItem { diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java index 4387f3d53..ca97e2867 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptAsymmetricFragment.java @@ -252,7 +252,6 @@ public class EncryptAsymmetricFragment extends Fragment { @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { - case RESULT_CODE_PUBLIC_KEYS: { if (resultCode == Activity.RESULT_OK) { Bundle bundle = data.getExtras(); @@ -273,11 +272,11 @@ public class EncryptAsymmetricFragment extends Fragment { } default: { + super.onActivityResult(requestCode, resultCode, data); + break; } } - - super.onActivityResult(requestCode, resultCode, data); } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java index b09fa4a4d..14726863a 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java @@ -18,6 +18,7 @@ package org.sufficientlysecure.keychain.ui; import android.annotation.SuppressLint; +import android.app.Activity; import android.app.ProgressDialog; import android.content.Context; import android.content.Intent; @@ -34,8 +35,10 @@ import android.support.v7.app.ActionBar; import android.view.View; import android.view.View.OnClickListener; import android.widget.ArrayAdapter; + import com.beardedhen.androidbootstrap.BootstrapButton; import com.devspark.appmsg.AppMsg; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; @@ -54,7 +57,6 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa + "IMPORT_KEY_FROM_QR_CODE"; public static final String ACTION_IMPORT_KEY_FROM_KEYSERVER = Constants.INTENT_PREFIX + "IMPORT_KEY_FROM_KEYSERVER"; - // TODO: implement: public static final String ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN = Constants.INTENT_PREFIX + "IMPORT_KEY_FROM_KEY_SERVER_AND_RETURN"; @@ -86,7 +88,7 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa ImportKeysNFCFragment.class }; - private int mCurrentNavPostition = -1; + private int mCurrentNavPosition = -1; @Override protected void onCreate(Bundle savedInstanceState) { @@ -104,15 +106,20 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa getSupportActionBar().setDisplayShowTitleEnabled(false); - setupDrawerNavigation(savedInstanceState); - - // set drop down navigation mNavigationStrings = getResources().getStringArray(R.array.import_action_list); - Context context = getSupportActionBar().getThemedContext(); - ArrayAdapter navigationAdapter = ArrayAdapter.createFromResource(context, - R.array.import_action_list, android.R.layout.simple_spinner_dropdown_item); - getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); - getSupportActionBar().setListNavigationCallbacks(navigationAdapter, this); + + if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN.equals(getIntent().getAction())) { + getSupportActionBar().setTitle(R.string.nav_import); + } else { + setupDrawerNavigation(savedInstanceState); + + // set drop down navigation + Context context = getSupportActionBar().getThemedContext(); + ArrayAdapter navigationAdapter = ArrayAdapter.createFromResource(context, + R.array.import_action_list, android.R.layout.simple_spinner_dropdown_item); + getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); + getSupportActionBar().setListNavigationCallbacks(navigationAdapter, this); + } handleActions(savedInstanceState, getIntent()); } @@ -152,34 +159,47 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa // action: directly load data startListFragment(savedInstanceState, importData, null, null); } - } else if (ACTION_IMPORT_KEY_FROM_KEYSERVER.equals(action)) { - String query = null; - if (extras.containsKey(EXTRA_QUERY)) { - query = extras.getString(EXTRA_QUERY); - } else if (extras.containsKey(EXTRA_KEY_ID)) { - long keyId = intent.getLongExtra(EXTRA_KEY_ID, 0); - if (keyId != 0) { - query = PgpKeyHelper.convertKeyIdToHex(keyId); + } else if (ACTION_IMPORT_KEY_FROM_KEYSERVER.equals(action) + || ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN.equals(action)) { + if (extras.containsKey(EXTRA_QUERY) || extras.containsKey(EXTRA_KEY_ID)) { + /* simple search based on query or key id */ + + String query = null; + if (extras.containsKey(EXTRA_QUERY)) { + query = extras.getString(EXTRA_QUERY); + } else if (extras.containsKey(EXTRA_KEY_ID)) { + long keyId = intent.getLongExtra(EXTRA_KEY_ID, 0); + if (keyId != 0) { + query = PgpKeyHelper.convertKeyIdToHex(keyId); + } + } + + if (query != null && query.length() > 0) { + // display keyserver fragment with query + Bundle args = new Bundle(); + args.putString(ImportKeysServerFragment.ARG_QUERY, query); + loadNavFragment(0, args); + + // action: search immediately + startListFragment(savedInstanceState, null, null, query); + } else { + Log.e(Constants.TAG, "Query is empty!"); + return; } } else if (extras.containsKey(EXTRA_FINGERPRINT)) { + /* + * search based on fingerprint, here we can enforce a check in the end + * if the right key has been downloaded + */ + String fingerprint = intent.getStringExtra(EXTRA_FINGERPRINT); - if (fingerprint != null) { - query = "0x" + fingerprint; - } + loadFromFingerprint(savedInstanceState, fingerprint); } else { Log.e(Constants.TAG, - "IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', 'key_id', or " + - "'fingerprint' extra!"); + "IMPORT_KEY_FROM_KEYSERVER action needs to contain the 'query', 'key_id', or " + + "'fingerprint' extra!"); return; } - - // display keyserver fragment with query - Bundle args = new Bundle(); - args.putString(ImportKeysServerFragment.ARG_QUERY, query); - loadNavFragment(0, args); - - // action: search immediately - startListFragment(savedInstanceState, null, null, query); } else if (ACTION_IMPORT_KEY_FROM_FILE.equals(action)) { // NOTE: this only displays the appropriate fragment, no actions are taken @@ -234,14 +254,14 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa * onNavigationItemSelected() should check whether the Fragment is already in existence * inside your Activity." *

                                                  - * from http://bit.ly/1dBYThO + * from http://stackoverflow.com/a/14295474 *

                                                  * In our case, if we start ImportKeysActivity with parameters to directly search using a fingerprint, * the fragment would be loaded twice resulting in the query being empty after the second load. *

                                                  * Our solution: * To prevent that a fragment will be loaded again even if it was already loaded loadNavFragment - * checks against mCurrentNavPostition. + * checks against mCurrentNavPosition. * * @param itemPosition * @param itemId @@ -257,10 +277,12 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa } private void loadNavFragment(int itemPosition, Bundle args) { - if (mCurrentNavPostition != itemPosition) { - getSupportActionBar().setSelectedNavigationItem(itemPosition); + if (mCurrentNavPosition != itemPosition) { + if (ActionBar.NAVIGATION_MODE_LIST == getSupportActionBar().getNavigationMode()) { + getSupportActionBar().setSelectedNavigationItem(itemPosition); + } loadFragment(NAVIGATION_CLASSES[itemPosition], args, mNavigationStrings[itemPosition]); - mCurrentNavPostition = itemPosition; + mCurrentNavPosition = itemPosition; } } @@ -280,7 +302,11 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa Log.d(Constants.TAG, "fingerprint: " + fingerprint); - if (fingerprint.length() < 16) { + loadFromFingerprint(savedInstanceState, fingerprint); + } + + public void loadFromFingerprint(Bundle savedInstanceState, String fingerprint) { + if (fingerprint == null || fingerprint.length() < 40) { AppMsg.makeText(this, R.string.import_qr_code_too_short_fingerprint, AppMsg.STYLE_ALERT).show(); return; @@ -291,6 +317,7 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa // display keyserver fragment with query Bundle args = new Bundle(); args.putString(ImportKeysServerFragment.ARG_QUERY, query); + args.putBoolean(ImportKeysServerFragment.ARG_DISABLE_QUERY_EDIT, true); loadNavFragment(0, args); // action: search directly @@ -301,66 +328,6 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa mListFragment.loadNew(importData, dataUri, serverQuery, keyServer); } - // private void importAndSignOld(final long keyId, final String expectedFingerprint) { - // if (expectedFingerprint != null && expectedFingerprint.length() > 0) { - // - // Thread t = new Thread() { - // @Override - // public void run() { - // try { - // // TODO: display some sort of spinner here while the user waits - // - // // TODO: there should be only 1 - // HkpKeyServer server = new HkpKeyServer(mPreferences.getKeyServers()[0]); - // String encodedKey = server.get(keyId); - // - // PGPKeyRing keyring = PGPHelper.decodeKeyRing(new ByteArrayInputStream( - // encodedKey.getBytes())); - // if (keyring != null && keyring instanceof PGPPublicKeyRing) { - // PGPPublicKeyRing publicKeyRing = (PGPPublicKeyRing) keyring; - // - // // make sure the fingerprints match before we cache this thing - // String actualFingerprint = PGPHelper.convertFingerprintToHex(publicKeyRing - // .getPublicKey().getFingerprint()); - // if (expectedFingerprint.equals(actualFingerprint)) { - // // store the signed key in our local cache - // int retval = PGPMain.storeKeyRingInCache(publicKeyRing); - // if (retval != Id.return_value.ok - // && retval != Id.return_value.updated) { - // status.putString(EXTRA_ERROR, - // "Failed to store signed key in local cache"); - // } else { - // Intent intent = new Intent(ImportFromQRCodeActivity.this, - // SignKeyActivity.class); - // intent.putExtra(EXTRA_KEY_ID, keyId); - // startActivityForResult(intent, Id.request.sign_key); - // } - // } else { - // status.putString( - // EXTRA_ERROR, - // "Scanned fingerprint does NOT match the fingerprint of the received key. " + - // "You shouldnt trust this key."); - // } - // } - // } catch (QueryException e) { - // Log.e(TAG, "Failed to query KeyServer", e); - // status.putString(EXTRA_ERROR, "Failed to query KeyServer"); - // status.putInt(Constants.extras.STATUS, Id.message.done); - // } catch (IOException e) { - // Log.e(TAG, "Failed to query KeyServer", e); - // status.putString(EXTRA_ERROR, "Failed to query KeyServer"); - // status.putInt(Constants.extras.STATUS, Id.message.done); - // } - // } - // }; - // - // t.setName("KeyExchange Download Thread"); - // t.setDaemon(true); - // t.start(); - // } - // } - - /** * Import keys with mImportData */ @@ -405,6 +372,11 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa BadImportKeyDialogFragment.newInstance(bad); badImportKeyDialogFragment.show(getSupportFragmentManager(), "badKeyDialog"); } + + if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN.equals(getIntent().getAction())) { + ImportKeysActivity.this.setResult(Activity.RESULT_OK); + finish(); + } } } }; diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysServerFragment.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysServerFragment.java index 0b2fff64e..3eb463dac 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysServerFragment.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysServerFragment.java @@ -40,6 +40,7 @@ import org.sufficientlysecure.keychain.util.Log; public class ImportKeysServerFragment extends Fragment { public static final String ARG_QUERY = "query"; public static final String ARG_KEY_SERVER = "key_server"; + public static final String ARG_DISABLE_QUERY_EDIT = "disable_query_edit"; private ImportKeysActivity mImportActivity; @@ -140,6 +141,10 @@ public class ImportKeysServerFragment extends Fragment { Log.d(Constants.TAG, "keyServer: " + keyServer); } + + if (getArguments().getBoolean(ARG_DISABLE_QUERY_EDIT, false)) { + mQueryEditText.setEnabled(false); + } } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index b8b2e271f..e16ffcfdb 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -18,6 +18,7 @@ package org.sufficientlysecure.keychain.ui; +import android.app.Activity; import android.content.Intent; import android.net.Uri; import android.os.Bundle; @@ -163,18 +164,13 @@ public class ViewKeyActivity extends ActionBarActivity { } private void updateFromKeyserver(Uri dataUri) { - long updateKeyId = ProviderHelper.getMasterKeyId(ViewKeyActivity.this, dataUri); - - if (updateKeyId == 0) { - Log.e(Constants.TAG, "this shouldn't happen. KeyId == 0!"); - return; - } + byte[] fingerprintBlob = ProviderHelper.getFingerprint(this, dataUri); + String fingerprint = PgpKeyHelper.convertFingerprintToHex(fingerprintBlob); Intent queryIntent = new Intent(this, ImportKeysActivity.class); - queryIntent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER); - queryIntent.putExtra(ImportKeysActivity.EXTRA_KEY_ID, updateKeyId); + queryIntent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN); + queryIntent.putExtra(ImportKeysActivity.EXTRA_FINGERPRINT, fingerprint); - // TODO: lookup with onactivityresult! startActivityForResult(queryIntent, RESULT_CODE_LOOKUP_KEY); } @@ -245,4 +241,21 @@ public class ViewKeyActivity extends ActionBarActivity { mExportHelper.deleteKey(dataUri, returnHandler); } + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + switch (requestCode) { + case RESULT_CODE_LOOKUP_KEY: { + if (resultCode == Activity.RESULT_OK) { + // TODO: reload key??? move this into fragment? + } + break; + } + + default: { + super.onActivityResult(requestCode, resultCode, data); + + break; + } + } + } } diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListServerLoader.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListServerLoader.java index a4dd06e40..259e14319 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListServerLoader.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/adapter/ImportKeysListServerLoader.java @@ -19,6 +19,7 @@ package org.sufficientlysecure.keychain.ui.adapter; import android.content.Context; import android.support.v4.content.AsyncTaskLoader; + import org.sufficientlysecure.keychain.Constants; import org.sufficientlysecure.keychain.util.HkpKeyServer; import org.sufficientlysecure.keychain.util.KeyServer; @@ -53,7 +54,12 @@ public class ImportKeysListServerLoader return mEntryListWrapper; } - queryServer(mServerQuery, mKeyServer); + if (mServerQuery.startsWith("0x") && mServerQuery.length() == 42) { + Log.d(Constants.TAG, "This search is based on a unique fingerprint. Enforce a fingerprint check!"); + queryServer(mServerQuery, mKeyServer, true); + } else { + queryServer(mServerQuery, mKeyServer, false); + } return mEntryListWrapper; } @@ -84,14 +90,30 @@ public class ImportKeysListServerLoader /** * Query keyserver */ - private void queryServer(String query, String keyServer) { + private void queryServer(String query, String keyServer, boolean enforceFingerprint) { HkpKeyServer server = new HkpKeyServer(keyServer); try { ArrayList searchResult = server.search(query); mEntryList.clear(); // add result to data - mEntryList.addAll(searchResult); + if (enforceFingerprint) { + String fingerprint = query.substring(2); + Log.d(Constants.TAG, "fingerprint: " + fingerprint); + // query must return only one result! + if (searchResult.size() > 0) { + ImportKeysListEntry uniqueEntry = searchResult.get(0); + /* + * set fingerprint explicitly after query + * to enforce a check when the key is imported by KeychainIntentService + */ + uniqueEntry.setFingerPrintHex(fingerprint); + uniqueEntry.setSelected(true); + mEntryList.add(uniqueEntry); + } + } else { + mEntryList.addAll(searchResult); + } mEntryListWrapper = new AsyncTaskResultWrapper>(mEntryList, null); } catch (KeyServer.InsufficientQuery e) { Log.e(Constants.TAG, "InsufficientQuery", e); diff --git a/OpenPGP-Keychain/src/main/res/layout/decrypt_signature_include.xml b/OpenPGP-Keychain/src/main/res/layout/decrypt_signature_include.xml index 16234762c..3e0d35c9b 100644 --- a/OpenPGP-Keychain/src/main/res/layout/decrypt_signature_include.xml +++ b/OpenPGP-Keychain/src/main/res/layout/decrypt_signature_include.xml @@ -28,20 +28,6 @@ android:src="@drawable/overlay_error" /> - - + + \ No newline at end of file diff --git a/OpenPGP-Keychain/src/main/res/values/strings.xml b/OpenPGP-Keychain/src/main/res/values/strings.xml index 54db372ab..b9df68cb3 100644 --- a/OpenPGP-Keychain/src/main/res/values/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values/strings.xml @@ -406,7 +406,7 @@ Please start with QR Code with ID 1 QR Code malformed! Please try again! QR Code scanning finished! - Fingerprint contained in this QR Code is too short (< 16 characters) + Fingerprint is too short (< 16 characters) Scan QR Code with \'Barcode Scanner\' To receive keys via NFC, the device needs to be unlocked. Help -- cgit v1.2.3 From 09411a62fab849c345033a5d14d1e629855209df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 3 Apr 2014 15:16:13 +0200 Subject: Key lookup for API --- .../sufficientlysecure/keychain/remote/OpenPgpService.java | 10 +++++----- .../sufficientlysecure/keychain/ui/ImportKeysActivity.java | 13 +++++++++++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java index 18bb92552..9cdd16e23 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -39,6 +39,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract; import org.sufficientlysecure.keychain.provider.ProviderHelper; import org.sufficientlysecure.keychain.remote.ui.RemoteServiceActivity; import org.sufficientlysecure.keychain.service.PassphraseCacheService; +import org.sufficientlysecure.keychain.ui.ImportKeysActivity; import org.sufficientlysecure.keychain.util.InputData; import org.sufficientlysecure.keychain.util.Log; @@ -315,11 +316,10 @@ public class OpenPgpService extends RemoteService { if (signatureResult.getStatus() == OpenPgpSignatureResult.SIGNATURE_UNKNOWN_PUB_KEY) { // If signature is unknown we return an _additional_ PendingIntent // to retrieve the missing key - // TODO!!! - Intent intent = new Intent(getBaseContext(), RemoteServiceActivity.class); - intent.setAction(RemoteServiceActivity.ACTION_ERROR_MESSAGE); - intent.putExtra(RemoteServiceActivity.EXTRA_ERROR_MESSAGE, "todo"); - intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); + Intent intent = new Intent(getBaseContext(), ImportKeysActivity.class); + intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN); + intent.putExtra(ImportKeysActivity.EXTRA_KEY_ID, signatureResult.getKeyId()); + intent.putExtra(ImportKeysActivity.EXTRA_PENDING_INTENT_DATA, data); PendingIntent pi = PendingIntent.getActivity(getBaseContext(), 0, intent, diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java index 14726863a..6839d5a6e 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java @@ -74,6 +74,10 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa public static final String EXTRA_KEY_ID = "key_id"; public static final String EXTRA_FINGERPRINT = "fingerprint"; + // only used by ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN when used from OpenPgpService + public static final String EXTRA_PENDING_INTENT_DATA = "data"; + private Intent mPendingIntentData; + // view private ImportKeysListFragment mListFragment; private String[] mNavigationStrings; @@ -109,7 +113,7 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa mNavigationStrings = getResources().getStringArray(R.array.import_action_list); if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN.equals(getIntent().getAction())) { - getSupportActionBar().setTitle(R.string.nav_import); + setTitle(R.string.nav_import); } else { setupDrawerNavigation(savedInstanceState); @@ -161,6 +165,11 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa } } else if (ACTION_IMPORT_KEY_FROM_KEYSERVER.equals(action) || ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN.equals(action)) { + + // only used for OpenPgpService + if (extras.containsKey(EXTRA_PENDING_INTENT_DATA)) { + mPendingIntentData = extras.getParcelable(EXTRA_PENDING_INTENT_DATA); + } if (extras.containsKey(EXTRA_QUERY) || extras.containsKey(EXTRA_KEY_ID)) { /* simple search based on query or key id */ @@ -374,7 +383,7 @@ public class ImportKeysActivity extends DrawerActivity implements ActionBar.OnNa } if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN.equals(getIntent().getAction())) { - ImportKeysActivity.this.setResult(Activity.RESULT_OK); + ImportKeysActivity.this.setResult(Activity.RESULT_OK, mPendingIntentData); finish(); } } -- cgit v1.2.3 From 04b0425d45574cdf86219898ea25ce15c33341a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 3 Apr 2014 15:18:05 +0200 Subject: Key lookup for API --- .../sufficientlysecure/keychain/remote/OpenPgpService.java | 12 +++++++----- OpenPGP-Keychain/src/main/res/raw/help_changelog.html | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java index 9cdd16e23..dc19bc5bb 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -356,11 +356,10 @@ public class OpenPgpService extends RemoteService { // If keys are not in db we return an additional PendingIntent // to retrieve the missing key - // TODO!!! - Intent intent = new Intent(getBaseContext(), RemoteServiceActivity.class); - intent.setAction(RemoteServiceActivity.ACTION_ERROR_MESSAGE); - intent.putExtra(RemoteServiceActivity.EXTRA_ERROR_MESSAGE, "todo"); - intent.putExtra(RemoteServiceActivity.EXTRA_DATA, data); + Intent intent = new Intent(getBaseContext(), ImportKeysActivity.class); + intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN); + intent.putExtra(ImportKeysActivity.EXTRA_KEY_ID, keyId); + intent.putExtra(ImportKeysActivity.EXTRA_PENDING_INTENT_DATA, data); PendingIntent pi = PendingIntent.getActivity(getBaseContext(), 0, intent, @@ -372,6 +371,9 @@ public class OpenPgpService extends RemoteService { } else { Intent result = new Intent(); result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS); + + // TODO: also return PendingIntent that opens the key view activity + return result; } } catch (Exception e) { diff --git a/OpenPGP-Keychain/src/main/res/raw/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw/help_changelog.html index 8138fd0bd..221705579 100644 --- a/OpenPGP-Keychain/src/main/res/raw/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw/help_changelog.html @@ -9,7 +9,7 @@ And don't add newlines before or after p tags because of transifex -->

                                                  • fix decryption of symmetric pgp messages/files
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • -
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes, key lookup)
                                                  • new modern design for encrypt/decrypt screens
                                                  -- cgit v1.2.3 From c3091c2b5dbe350d7f7ed122f13ee5770efe2c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 3 Apr 2014 15:19:49 +0200 Subject: Changelog --- CHANGELOG | 6 ++++++ .../java/org/sufficientlysecure/keychain/remote/OpenPgpService.java | 2 +- OpenPGP-Keychain/src/main/res/raw/help_changelog.html | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e7f4c567a..45ad2e98c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,9 @@ +2.5 +* fix decryption of symmetric pgp messages/files +* refactored edit key screen (thanks to Ash Hughes) +* new modern design for encrypt/decrypt screens +* OpenPGP API version 3 (multiple api accounts, internal fixes, key lookup) + 2.4 Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java index dc19bc5bb..fa673f695 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/remote/OpenPgpService.java @@ -373,7 +373,7 @@ public class OpenPgpService extends RemoteService { result.putExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_SUCCESS); // TODO: also return PendingIntent that opens the key view activity - + return result; } } catch (Exception e) { diff --git a/OpenPGP-Keychain/src/main/res/raw/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw/help_changelog.html index 221705579..64a91e5f1 100644 --- a/OpenPGP-Keychain/src/main/res/raw/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw/help_changelog.html @@ -9,8 +9,8 @@ And don't add newlines before or after p tags because of transifex -->
                                                  • fix decryption of symmetric pgp messages/files
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • -
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes, key lookup)
                                                  • new modern design for encrypt/decrypt screens
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes, key lookup)

                                                  2.4

                                                  -- cgit v1.2.3 From 3b91147b49f877b6d2e796ef31f6bd836b115fba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 3 Apr 2014 15:21:14 +0200 Subject: Update from transifex --- .../src/main/res/raw-cs-rCZ/help_changelog.html | 7 +++++++ .../src/main/res/raw-de/help_changelog.html | 7 +++++++ .../src/main/res/raw-el/help_changelog.html | 7 +++++++ .../src/main/res/raw-es-rCO/help_changelog.html | 7 +++++++ .../src/main/res/raw-es/help_changelog.html | 7 +++++++ .../src/main/res/raw-et/help_changelog.html | 7 +++++++ .../src/main/res/raw-fa-rIR/help_changelog.html | 7 +++++++ .../src/main/res/raw-fr/help_changelog.html | 7 +++++++ .../src/main/res/raw-it-rIT/help_changelog.html | 7 +++++++ .../src/main/res/raw-ja/help_changelog.html | 7 +++++++ .../src/main/res/raw-nl-rNL/help_changelog.html | 7 +++++++ .../src/main/res/raw-pl/help_changelog.html | 7 +++++++ .../src/main/res/raw-pt-rBR/help_changelog.html | 7 +++++++ .../src/main/res/raw-ru/help_changelog.html | 7 +++++++ .../src/main/res/raw-sl-rSI/help_changelog.html | 7 +++++++ .../src/main/res/raw-tr/help_changelog.html | 7 +++++++ .../src/main/res/raw-uk/help_changelog.html | 7 +++++++ .../src/main/res/raw-zh-rTW/help_changelog.html | 7 +++++++ .../src/main/res/raw-zh/help_changelog.html | 7 +++++++ .../src/main/res/values-es/strings.xml | 14 +++++++++++++ .../src/main/res/values-fr/strings.xml | 13 ++++++++++++ .../src/main/res/values-ja/strings.xml | 15 +++++++++++++- .../src/main/res/values-pl/strings.xml | 23 ++++++++++++++++++++++ .../src/main/res/values-ru/strings.xml | 11 +++++++++++ .../src/main/res/values-uk/strings.xml | 13 ++++++++++++ 25 files changed, 221 insertions(+), 1 deletion(-) diff --git a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_changelog.html index 1136deba6..db65b65f6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-cs-rCZ/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • fix decryption of symmetric pgp messages/files
                                                  • +
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • new modern design for encrypt/decrypt screens
                                                  • +

                                                  2.4

                                                  Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): diff --git a/OpenPGP-Keychain/src/main/res/raw-de/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-de/help_changelog.html index 13b210fcd..dbf7afe76 100644 --- a/OpenPGP-Keychain/src/main/res/raw-de/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-de/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • fix decryption of symmetric pgp messages/files
                                                  • +
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • new modern design for encrypt/decrypt screens
                                                  • +

                                                  2.4

                                                  Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): diff --git a/OpenPGP-Keychain/src/main/res/raw-el/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-el/help_changelog.html index 1136deba6..db65b65f6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-el/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-el/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • fix decryption of symmetric pgp messages/files
                                                  • +
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • new modern design for encrypt/decrypt screens
                                                  • +

                                                  2.4

                                                  Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): diff --git a/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_changelog.html index 1136deba6..db65b65f6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-es-rCO/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • fix decryption of symmetric pgp messages/files
                                                  • +
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • new modern design for encrypt/decrypt screens
                                                  • +

                                                  2.4

                                                  Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): diff --git a/OpenPGP-Keychain/src/main/res/raw-es/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-es/help_changelog.html index ebbc8a4de..0b3db3a30 100644 --- a/OpenPGP-Keychain/src/main/res/raw-es/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-es/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • corregido descifrado de mensajes/ficheros con pgp simétrico
                                                  • +
                                                  • rediseñada la pantalla de edición de claves (gracias a Ash Hughes)
                                                  • +
                                                  • API OpenPGP versión 3 (multiples cuentas api, correcciones internas)
                                                  • +
                                                  • diseño más moderno para las pantallas de cifrado/descifrado
                                                  • +

                                                  2.4

                                                  ¡Gracias a todos los solicitantes de Google Summer of Code 2014, por hacer esta aplicación productiva y libre de errores! Además de varios parches pequeños, un notable número de correcciones fueron hechas por las siguientes personas (en orden alfabético): diff --git a/OpenPGP-Keychain/src/main/res/raw-et/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-et/help_changelog.html index 1136deba6..db65b65f6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-et/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-et/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • fix decryption of symmetric pgp messages/files
                                                  • +
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • new modern design for encrypt/decrypt screens
                                                  • +

                                                  2.4

                                                  Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): diff --git a/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_changelog.html index 1136deba6..db65b65f6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-fa-rIR/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • fix decryption of symmetric pgp messages/files
                                                  • +
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • new modern design for encrypt/decrypt screens
                                                  • +

                                                  2.4

                                                  Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): diff --git a/OpenPGP-Keychain/src/main/res/raw-fr/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-fr/help_changelog.html index 4c9daca93..08a84c5fb 100644 --- a/OpenPGP-Keychain/src/main/res/raw-fr/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-fr/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • fix decryption of symmetric pgp messages/files
                                                  • +
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • new modern design for encrypt/decrypt screens
                                                  • +

                                                  2.4

                                                  Merci à tous les participants de « Google Summer of Code 2014 » qui ont rendu cette version riche en fonctions et sans bogue ! À part plusieurs petits correctifs, un nombre notable de correctifs ont été apportés par les personnes suivantes (par ordre alphabétique) : diff --git a/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_changelog.html index b3e5170eb..abe268523 100644 --- a/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-it-rIT/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • fix decryption of symmetric pgp messages/files
                                                  • +
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • new modern design for encrypt/decrypt screens
                                                  • +

                                                  2.4

                                                  Grazie a tutti i partecipanti di Google Summer of Code 2014 che hanno reso questo rilascio ricco di caratteristiche e privo di bug! Oltre a numerose piccole correzioni, un notevole numero di patch sono fatte dalle seguenti persone (in ordine alfabetico): diff --git a/OpenPGP-Keychain/src/main/res/raw-ja/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-ja/help_changelog.html index 1eeedb4b0..f99656c1d 100644 --- a/OpenPGP-Keychain/src/main/res/raw-ja/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-ja/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • fix decryption of symmetric pgp messages/files
                                                  • +
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • new modern design for encrypt/decrypt screens
                                                  • +

                                                  2.4

                                                  このリリースにおいて適用したリッチでバグのない機能を作ってくれたGoogle Summer of Code 2014の参加者たちに感謝を! また、以下の人達(アルファベット順)の作ってくれたいくつもののさなパッチや相当数のパッチにも: diff --git a/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_changelog.html index 1136deba6..db65b65f6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-nl-rNL/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • fix decryption of symmetric pgp messages/files
                                                  • +
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • new modern design for encrypt/decrypt screens
                                                  • +

                                                  2.4

                                                  Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): diff --git a/OpenPGP-Keychain/src/main/res/raw-pl/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-pl/help_changelog.html index 7561c77bf..9d77a3e05 100644 --- a/OpenPGP-Keychain/src/main/res/raw-pl/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-pl/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • fix decryption of symmetric pgp messages/files
                                                  • +
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • new modern design for encrypt/decrypt screens
                                                  • +

                                                  2.4

                                                  Podziękowania dla wszystkich kandydatów do Google Summer of Code 2014 którzy uczynili to wydanie bogatym w nowe funkcje i pozbawione błedów! Poza kilkoma małymi poprawkami, znaczna ilość aktualizacji została wykonana przez poniższe osoby (w kolejności alfabetycznej): diff --git a/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_changelog.html index 1136deba6..db65b65f6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-pt-rBR/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • fix decryption of symmetric pgp messages/files
                                                  • +
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • new modern design for encrypt/decrypt screens
                                                  • +

                                                  2.4

                                                  Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): diff --git a/OpenPGP-Keychain/src/main/res/raw-ru/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-ru/help_changelog.html index 349d85d22..0646e7dda 100644 --- a/OpenPGP-Keychain/src/main/res/raw-ru/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-ru/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • fix decryption of symmetric pgp messages/files
                                                  • +
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • new modern design for encrypt/decrypt screens
                                                  • +

                                                  2.4

                                                  Спасибо всем участникам Google Summer of Code 2014, которые помогли сделать этот выпуск, добавив функции и исправив ошибки! Из общего числа патчей, особенный вклад внесли следующие люди (в алфавитном порядке): diff --git a/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_changelog.html index 1136deba6..db65b65f6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-sl-rSI/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • fix decryption of symmetric pgp messages/files
                                                  • +
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • new modern design for encrypt/decrypt screens
                                                  • +

                                                  2.4

                                                  Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): diff --git a/OpenPGP-Keychain/src/main/res/raw-tr/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-tr/help_changelog.html index 1136deba6..db65b65f6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-tr/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-tr/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • fix decryption of symmetric pgp messages/files
                                                  • +
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • new modern design for encrypt/decrypt screens
                                                  • +

                                                  2.4

                                                  Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): diff --git a/OpenPGP-Keychain/src/main/res/raw-uk/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-uk/help_changelog.html index f8b68c32a..77e39d434 100644 --- a/OpenPGP-Keychain/src/main/res/raw-uk/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-uk/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • виправлено опис симетричних повідомлень/файлів pgp
                                                  • +
                                                  • перероблено екран редагування ключа (завдяки Ash Hughes)
                                                  • +
                                                  • OpenPGP API версія 3 (підтримка кількох профілів, внутрішні зміни)
                                                  • +
                                                  • новий сучасний дизайн для екранів шифрування/розшифрування
                                                  • +

                                                  2.4

                                                  Дякуємо усім заявникам Google Summer of Code 2014, які зробили цю версію багатшу на функції та вільну від помилок! Крім окремих незначних латок, значне число латок зробили наступні люди (у алфавітному порядку): diff --git a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_changelog.html index 1136deba6..db65b65f6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-zh-rTW/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • fix decryption of symmetric pgp messages/files
                                                  • +
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • new modern design for encrypt/decrypt screens
                                                  • +

                                                  2.4

                                                  Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): diff --git a/OpenPGP-Keychain/src/main/res/raw-zh/help_changelog.html b/OpenPGP-Keychain/src/main/res/raw-zh/help_changelog.html index 1136deba6..db65b65f6 100644 --- a/OpenPGP-Keychain/src/main/res/raw-zh/help_changelog.html +++ b/OpenPGP-Keychain/src/main/res/raw-zh/help_changelog.html @@ -1,6 +1,13 @@ +

                                                  2.5

                                                  +
                                                    +
                                                  • fix decryption of symmetric pgp messages/files
                                                  • +
                                                  • refactored edit key screen (thanks to Ash Hughes)
                                                  • +
                                                  • OpenPGP API version 3 (multiple api accounts, internal fixes)
                                                  • +
                                                  • new modern design for encrypt/decrypt screens
                                                  • +

                                                  2.4

                                                  Thanks to all applicants of Google Summer of Code 2014 who made this release feature rich and bug free! Besides several small patches, a notable number of patches are made by the following people (in alphabetical order): diff --git a/OpenPGP-Keychain/src/main/res/values-es/strings.xml b/OpenPGP-Keychain/src/main/res/values-es/strings.xml index f8ee3c812..55136642c 100644 --- a/OpenPGP-Keychain/src/main/res/values-es/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-es/strings.xml @@ -74,6 +74,7 @@ Importar desde código QR Importar Importar desde NFC + Exportar todas las claves públicas Exportar todas las claves secretas Exportar hacia archivo Borrar clave @@ -98,6 +99,8 @@ Cancelar Cifrar hacia... Seleccionar todo + Añadir claves + Exportar claves Firmar Mensaje @@ -189,11 +192,15 @@ Establece una frase de contraseña antes. No hay un gestor de archivos compatible instalado. Las frases de contraseña no coinciden. + Por favor, introduce una frase de contraseña. Cifrado simétrico. Introducir la frase de contraseña para \'%s\' ¿Estás seguro de que quieres borrar\n%s? Borrado satisfactoriamente. Selecciona un archivo antes. + Descifrado y/o verificado satisfactoriamente. + Firmado y/o cifrado satisfactoriamente. + Firmado y/o cifrado al portapapeles satisfactoriamente. Introduce la frase de contraseña dos veces. Selecciona al menos una clave de cifrado. Selecciona al menos una clave de cifrado o de firma. @@ -205,6 +212,7 @@ ¿Quieres realmente borrar todas las claves seleccionadas?\n¡No podrás deshacerlo! ¿Quieres realmente borrar la clave SECRETA \'%s\'?\n¡No podrás deshacerlo! Has hecho cambios en el almacén de claves, ¿quieres guardarlos? + Has añadido una ID de usuario vacía, ¿Estás seguro que quieres continuar? ¿Quieres realmente borrar la clave PÚBLICA \'%s\'?\n¡No podrás deshacerlo! ¿Borrar claves secretas? ¿Exportar también las claves secretas? @@ -298,6 +306,7 @@ parte del archivo cargado es un objeto OpenPGP válido pero no una clave OpenPGP partes del archivo cargado son objetos OpenPGP válidos pero no claves OpenPGP + Debes hacer cambios en el almacén de claves antes de que puedas guardarlo Hecho. Cancelar @@ -423,6 +432,9 @@ Información Certificaciones + Claves + Firmar y cifrar + Descifrar y verificar Importar claves Mis claves Aplicaciones registradas @@ -436,4 +448,6 @@ IDs de usuario para firmar Nueva aplicación de certificados + Escribe aquí el mensaje que quieras cifrar y/o firmar... + Introduce aquí el texto cifrado para descifrarlo y/o verificarlo... diff --git a/OpenPGP-Keychain/src/main/res/values-fr/strings.xml b/OpenPGP-Keychain/src/main/res/values-fr/strings.xml index 6df2988cb..e7d8b0b7f 100644 --- a/OpenPGP-Keychain/src/main/res/values-fr/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-fr/strings.xml @@ -74,6 +74,7 @@ Importer depuis un code QR Importer Importer avec NFC + Exporter toutes les clefs publiques Exporter toutes les clefs secrètes Exporter vers un fichier Supprimer la clef @@ -98,6 +99,8 @@ Annuler Chiffrer vers... Tout sélectionner + Ajouter des clefs + Exporter des clefs Signer Message @@ -189,11 +192,15 @@ Définir d\'abord une phrase de passe. Aucun gestionnaire de fichiers compatible installé. Les phrases de passe ne correspondent pas. + Veuillez saisir une phrase de passe Chriffrement symétrique. Saisir une phrase de passe pour « %s » Êtes-vous sûr de vouloir supprimer\n%s ? Supprimé avec succès. Choisir d\'abord un fichier. + Déchiffré et/ou vérifié avec succès + Signé et/ou chiffré avec succès + Signé et/ou chiffré vers le presse-papiers avec succès Saisir la phrase de passe deux fois. Choisir au moins une clef de chiffrement. Choisir au moins une clef de chiffrement ou de signature. @@ -205,6 +212,7 @@ Voulez-vous vraiment supprimer toutes les clefs choisies ?\nCeci est irréversible ! Voulez-vous vraiment supprimer la clef SECRÈTE %s ?\nVous ne pourrez pas la restituer ! Vous avez apporté des changements au trousseau, voulez-vous l\'enregistrer ? + Vous avez ajouté un ID utilisateur vide, êtes-vous certain de vouloir continuer? Voulez-vous vraiment supprimer la clef PUBLIQUE « %s » ?\nVous ne pourrez pas la restituer ! Supprimer les clefs privées ? Exporter aussi les clefs secrètes? @@ -424,6 +432,9 @@ Infos Certifications + Clefs + Signer et chiffrer + Déchiffrer et vérifier Importer les clefs Mes clefs Applis enregistrées @@ -437,4 +448,6 @@ ID utilisateur pour signer Nouvel application des certificats + Écrire ici le message à chiffrer et/ou signer... + Saisir le cryptogramme à déchiffrer et/ou à vérifier ici... diff --git a/OpenPGP-Keychain/src/main/res/values-ja/strings.xml b/OpenPGP-Keychain/src/main/res/values-ja/strings.xml index d501d0b9b..eceefb8a3 100644 --- a/OpenPGP-Keychain/src/main/res/values-ja/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-ja/strings.xml @@ -41,7 +41,7 @@ あなたの鍵を証明に利用します 鍵のアップロード 鍵サーバ - 暗号化と/もしくは署名 + 暗号化/署名 復号化と検証 署名 @@ -74,6 +74,7 @@ QRコードからインポート インポート NFCからインポート + すべての公開鍵のエクスポート すべての秘密鍵のエクスポート ファイルへのエクスポート 鍵の削除 @@ -98,6 +99,8 @@ キャンセル 暗号化... すべて選択 + 鍵の追加 + 複数鍵のエクスポート 署名 メッセージ @@ -186,11 +189,15 @@ 最初にパスフレーズを設定してください。 互換性のないファイルマネージャがインストールされています。 パスフレーズが一致しません。 + パスフレーズを入れてください。 対称暗号。 \'%s\' にパスフレーズを入れてください。 %s を削除してもかまいませんか? 削除に成功しました。 最初にファイルを選択してください。 + 復号化/検証に成功しました。 + 署名/暗号化に成功しました。 + クリップボードの中身の署名/暗号化に成功しました。 もう一度パスフレーズを入れてください。 少なくとも1つの暗号化鍵を選択して下さい。 少なくとも1つの暗号化鍵か署名鍵を選択して下さい。 @@ -202,6 +209,7 @@ 選択したすべての鍵を本当に削除してよいですか?\nこれは元に戻せません。 秘密鍵\'%s\'を本当に削除してもよいですか?\nこれは元に戻せません! あなたは鍵輪に変更を加えました、これを保存しますか? + あなたは空のユーザーIDを追加しました、このまま続けますか? 公開鍵\'%s\'を本当に削除してもよいですか?\nこれは元に戻せません! 秘密鍵を削除しますか? 秘密鍵もエクスポートしますか? @@ -409,6 +417,9 @@ 情報 証明 + + 署名と暗号化 + 復号化と検証 鍵のインポート 自分の鍵 登録済みのアプリ @@ -422,4 +433,6 @@ 署名に使うユーザーID 検証を再適用する + ここに書いたメッセージを暗号化/署名.. + ここに入力された暗号化テキストを復号化/検証... diff --git a/OpenPGP-Keychain/src/main/res/values-pl/strings.xml b/OpenPGP-Keychain/src/main/res/values-pl/strings.xml index 428ca203e..336f0bff7 100644 --- a/OpenPGP-Keychain/src/main/res/values-pl/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-pl/strings.xml @@ -48,6 +48,7 @@ Certyfikuj Odszyfruj Deszyfruj i weryfikuj + Ze schowka Wybierz odbiorców Zaszyfruj plik Zapisz @@ -55,6 +56,8 @@ Usuń Żaden Ok + Zmień nowe hasło + Ustaw nowe hasło Wyszukaj Wyślij do serwera kluczy Dalej @@ -71,6 +74,7 @@ Zaimportuj z kodu QR Import Zaimportuj przy użyciu NFC + Eksportuj wszystkie klucze publiczne Eksportuj wszystkie prywatne klucze Eksportuj do pliku Usuń klucz @@ -95,6 +99,8 @@ Anuluj Zaszyfruj do... Wybierz wszystko + Dodaj klucze + Eksportuj klucze Podpis Wiadomość @@ -179,17 +185,25 @@ Błąd Błąd: %s + Certyfikuj + Podpisz + Zaszyfruj + Autentykuj Nieprawidłowe hasło. Użycie zawartości schowka. Najpierw ustaw hasło. Nie zainstalowano żadnego kompatybilnego menadżera plików. Hasła nie pasują do siebie + Podaj hasło. Szyfrowanie symetryczne. Podaj hasło dla \'%s\' Czy jesteś pewien że chcesz usunąć\n%s? Usunięto pomyślnie. Najpierw wskaż plik. + Pomyślnie deszyfrowano i/lub zweryfikowano. + Pomyślnie podpisano i/lub zaszyfrowano. + Pomyslnie podpisano i/lub zaszyfrowano do schowka. Podaj hasło dwukrotnie. Wybierz co najmniej jeden klucz szyfrujący. Wybierz co najmniej jeden klucz szyfrujący lub klucz podpisujący. @@ -200,6 +214,8 @@ Czy na pewno chcesz usunąć klucz \'%s\'?\nNie można cofnąć tej operacji! Czy na pewno chcesz usunąć wszystkie zaznaczone klucze?\nTej operacji nie można cofnąć! Czy na pewno chcesz usunąć klucz prywatny \'%s\'?\nNie można cofnąć tej operacji! + Zostały dokonane zmiany w pęku kluczy, czy chcesz je zachować? + Dodałeś pusty identyfikator użytkownika, czy na pewno chcesz kontynuować? Czy na pewno chcesz usunąć klucz publiczny \'%s\'?\nNie można cofnąć tej operacji! Usunąć klucze prywatne? Czy wyeksportować również klucze prywatne? @@ -283,6 +299,7 @@ NCF jest niedostępne na twoim urządzeniu Nie ma nic do zaimportowania! data wygaśnięcia musi być późniejsza niż data stworzenia + zapisz najpierw pęk kluczy nie możesz usunąć tego kontaktu, ponieważ należy do ciebie. nie możesz usunąć tych kontaktów, ponieważ należą do ciebie:\n%s Niewystarczające zapytanie do serwera @@ -300,6 +317,7 @@ Część wczytanego pliku to poprawne obiekty OpenPGP, ale nie są kluczami OpenPGP Część wczytanego pliku to poprawne obiekty OpenPGP, ale nie są kluczami OpenPGP + Musisz dokonać zmian w pęku kluczy zanim będziesz mógł go zachować Gotowe. Anuluj @@ -429,6 +447,9 @@ Informacje Certyfikaty + Klucze + Podpisz i zaszyfruj + Deszyfruj i weryfikuj Importuj klucze Moje klucze Zarejestrowane aplikacje @@ -442,4 +463,6 @@ Identyfikator użytkownika do podpisu Ponowne stosowanie certyfikatów + Wpisz tutaj wiadomość do zaszyfrowania i/lub podpisania... + Wpisz tutaj tekst do zaszyfrowania i/lub zweryfikowania... diff --git a/OpenPGP-Keychain/src/main/res/values-ru/strings.xml b/OpenPGP-Keychain/src/main/res/values-ru/strings.xml index 26ef948ba..8ee6d95ca 100644 --- a/OpenPGP-Keychain/src/main/res/values-ru/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-ru/strings.xml @@ -74,6 +74,7 @@ Импорт из QR кода Импорт Импорт из NFC + Экспорт всех открытых ключей Экспорт всех секретных ключей Экспорт в файл Удалить ключ @@ -98,6 +99,8 @@ Отмена Зашифровать.... Выбрать все + Добавить ключи + Экспорт ключей Подписать Сообщение @@ -191,11 +194,15 @@ Сначала задайте пароль Нет совместимого менеджера файлов. Пароли не совпадают. + Пожалуйста, введите пароль. Симметричное шифрование. Введите пароль для\n\'%s\' Вы уверены, что хотите удалить\n%s ? Удалено. Сначала выберите файл. + Расшифровано и/или проверено. + Подписано и/или зашифровано. + Подписано и/или зашифровано в буфер обмена. Дважды введите пароль. Укажите хотя бы один ключ. Выберите хотя бы один ключ для шифрования или подписи. @@ -430,6 +437,9 @@ Информация Сертификация + Ключи + Подписать и зашифровать + Расшифровать и проверить Импорт ключей Мои ключи Связанные приложения @@ -442,4 +452,5 @@ не доступен Подписываемые ID пользователя + Напишите сообщение здесь, что бы зашифровать и/или подписать... diff --git a/OpenPGP-Keychain/src/main/res/values-uk/strings.xml b/OpenPGP-Keychain/src/main/res/values-uk/strings.xml index 6329439d3..da9509822 100644 --- a/OpenPGP-Keychain/src/main/res/values-uk/strings.xml +++ b/OpenPGP-Keychain/src/main/res/values-uk/strings.xml @@ -74,6 +74,7 @@ Імпорт з штрих-коду Імпорт Імпорт з NFC + Експортувати усі публічні ключі Експортувати усі секретні ключі Експорт до файлу Вилучити ключ @@ -98,6 +99,8 @@ Скасувати Зашифрувати… Вибрати усе + Додати ключі + Експортувати ключі Підпис Повідомлення @@ -192,11 +195,15 @@ Спершу задайте парольну фразу. Нема встановленого сумісного менеджера файлів. Парольні фрази не збігаються. + Будь ласка, введіть парольну фразу. Симетричне шифрування. Введіть парольну фразу для \'%s\' Ви справді хочете вилучити\n%s? Успішно вилучено. Виберіть спершу файл. + Успішно розшифровано та/або перевірено. + Успішно підписано та/або перевірено. + Успішно підписано та/або зашифровано до буфера обміну. Введіть двічі парольну фразу. Виберіть принаймні один ключ шифрування. Виберіть принаймні один ключ шифрування або ключ підпису. @@ -208,6 +215,7 @@ Ви справді хочете вилучити усі вибрані ключі?\nВи не зможете це відмінити! Ви справді хочете вилучити секретний ключ \'%s\'?\nВи не зможете це відмінити! Ви внесли зміни до в\'язки ключів, ви б хотіли. Волієте їх зберегти? + Ви вже додали порожній ідентифікатор користувача. Справді хочете продовжити? Справді волієте вилучити ВІДКРИТИЙ ключ \'%s\'?\nВи е зможете відмінити цю дію! Видалити секретні ключі? Також експортувати секретні ключі? @@ -439,6 +447,9 @@ Інформація Сертифікати + Ключі + Підписати і зашифрувати + Розшифрувати і Перевірити Імпортувати ключі Мої ключі Зареєстровані програми @@ -452,4 +463,6 @@ ІД користувача для реєстрації Перезастосування сертифікатів + Напишіть повідомлення для шифрування та/або підпису… + Уведіть зашифрований текст тут для його розшифрування та/або перевірки… -- cgit v1.2.3 From 40e3b9cf79915c4a238c2413a564b372140e036e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Thu, 3 Apr 2014 15:21:34 +0200 Subject: version 2.5 --- OpenPGP-Keychain/src/main/AndroidManifest.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenPGP-Keychain/src/main/AndroidManifest.xml b/OpenPGP-Keychain/src/main/AndroidManifest.xml index 10505248f..e588817e7 100644 --- a/OpenPGP-Keychain/src/main/AndroidManifest.xml +++ b/OpenPGP-Keychain/src/main/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="25000" + android:versionName="2.5">