aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG2
-rw-r--r--OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperationTest.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ServiceProgressHandler.java6
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java25
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/CryptoOperationFragment.java1
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ProgressDialogFragment.java42
-rw-r--r--README.md2
7 files changed, 55 insertions, 25 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 21ef4ce47..78fcbf512 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1 +1 @@
-Please go to https://github.com/open-keychain/open-keychain/blob/development/OpenKeychain/src/main/res/raw/help_changelog.md \ No newline at end of file
+Please go to https://github.com/open-keychain/open-keychain/blob/master/OpenKeychain/src/main/res/raw/help_changelog.md \ No newline at end of file
diff --git a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperationTest.java b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperationTest.java
index 312875229..e74b84dfb 100644
--- a/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperationTest.java
+++ b/OpenKeychain-Test/src/test/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperationTest.java
@@ -1012,7 +1012,7 @@ public class PgpKeyOperationTest {
parcel.reset();
Random r = new Random();
- int type = r.nextInt(110)+1;
+ int type = r.nextInt(110)+2; // any type except image attribute, to avoid interpretation of these
byte[] data = new byte[r.nextInt(2000)];
new Random().nextBytes(data);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ServiceProgressHandler.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ServiceProgressHandler.java
index 430d8a49b..5b19d9e42 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ServiceProgressHandler.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/ServiceProgressHandler.java
@@ -18,16 +18,14 @@
package org.sufficientlysecure.keychain.service;
import android.app.Activity;
-import android.content.Intent;
+import android.app.FragmentManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.FragmentActivity;
-import android.support.v4.app.FragmentManager;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
-import org.sufficientlysecure.keychain.operations.results.CertifyResult;
import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment;
import org.sufficientlysecure.keychain.ui.util.Notify;
import org.sufficientlysecure.keychain.util.Log;
@@ -106,7 +104,7 @@ public class ServiceProgressHandler extends Handler {
// TODO: This is a hack!, see
// http://stackoverflow.com/questions/10114324/show-dialogfragment-from-onactivityresult
- final FragmentManager manager = activity.getSupportFragmentManager();
+ final FragmentManager manager = activity.getFragmentManager();
Handler handler = new Handler();
handler.post(new Runnable() {
public void run() {
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java
index 4ec4e2c84..4b4e71f6e 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java
@@ -45,6 +45,7 @@ import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.compatibility.DialogFragmentWorkaround;
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey;
+import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKeyRing;
import org.sufficientlysecure.keychain.pgp.KeyRing;
import org.sufficientlysecure.keychain.pgp.exception.PgpGeneralException;
@@ -52,6 +53,7 @@ import org.sufficientlysecure.keychain.pgp.exception.PgpKeyNotFoundException;
import org.sufficientlysecure.keychain.provider.CachedPublicKeyRing;
import org.sufficientlysecure.keychain.provider.KeychainContract;
import org.sufficientlysecure.keychain.provider.ProviderHelper;
+import org.sufficientlysecure.keychain.provider.ProviderHelper.NotFoundException;
import org.sufficientlysecure.keychain.remote.CryptoInputParcelCacheService;
import org.sufficientlysecure.keychain.service.PassphraseCacheService;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
@@ -102,6 +104,29 @@ public class PassphraseDialogActivity extends FragmentActivity {
break;
}
case PASSPHRASE: {
+
+ // handle empty passphrases by directly returning an empty crypto input parcel
+ try {
+ CanonicalizedSecretKeyRing pubRing =
+ new ProviderHelper(this).getCanonicalizedSecretKeyRing(
+ requiredInput.getMasterKeyId());
+ // use empty passphrase for empty passphrase
+ if (pubRing.getSecretKey(requiredInput.getSubKeyId()).getSecretKeyType() ==
+ SecretKeyType.PASSPHRASE_EMPTY) {
+ // also return passphrase back to activity
+ Intent returnIntent = new Intent();
+ returnIntent.putExtra(RESULT_CRYPTO_INPUT, new CryptoInputParcel(new Passphrase("")));
+ setResult(RESULT_OK, returnIntent);
+ finish();
+ return;
+ }
+ } catch (NotFoundException e) {
+ Log.e(Constants.TAG, "Key not found?!", e);
+ setResult(RESULT_CANCELED);
+ finish();
+ return;
+ }
+
keyId = requiredInput.getSubKeyId();
break;
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/CryptoOperationFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/CryptoOperationFragment.java
index 3b92f7208..7fc5eb1f4 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/CryptoOperationFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/CryptoOperationFragment.java
@@ -32,6 +32,7 @@ import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
import org.sufficientlysecure.keychain.ui.NfcOperationActivity;
import org.sufficientlysecure.keychain.ui.PassphraseDialogActivity;
+
/**
* All fragments executing crypto operations need to extend this class.
*/
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ProgressDialogFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ProgressDialogFragment.java
index af9d175ff..562517c12 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ProgressDialogFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/dialog/ProgressDialogFragment.java
@@ -19,13 +19,14 @@ package org.sufficientlysecure.keychain.ui.dialog;
import android.app.Activity;
import android.app.Dialog;
+import android.app.DialogFragment;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnKeyListener;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
-import android.support.v4.app.DialogFragment;
+import android.support.annotation.NonNull;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.View;
@@ -44,7 +45,7 @@ public class ProgressDialogFragment extends DialogFragment {
private static final String ARG_CANCELABLE = "cancelable";
private static final String ARG_SERVICE_TYPE = "service_class";
- public static enum ServiceType {
+ public enum ServiceType {
KEYCHAIN_INTENT,
CLOUD_IMPORT
}
@@ -59,7 +60,6 @@ public class ProgressDialogFragment extends DialogFragment {
* @param style the progress bar style, as defined in ProgressDialog (horizontal or spinner)
* @param cancelable should we let the user cancel this operation
* @param serviceType which Service this progress dialog is meant for
- * @return
*/
public static ProgressDialogFragment newInstance(String message, int style, boolean cancelable,
ServiceType serviceType) {
@@ -75,24 +75,21 @@ public class ProgressDialogFragment extends DialogFragment {
return frag;
}
- /** Updates progress of dialog */
public void setProgress(int messageId, int progress, int max) {
setProgress(getString(messageId), progress, max);
}
- /** Updates progress of dialog */
public void setProgress(int progress, int max) {
- if (mIsCancelled) {
+ ProgressDialog dialog = (ProgressDialog) getDialog();
+
+ if (mIsCancelled || dialog == null) {
return;
}
- ProgressDialog dialog = (ProgressDialog) getDialog();
-
dialog.setProgress(progress);
dialog.setMax(max);
}
- /** Updates progress of dialog */
public void setProgress(String message, int progress, int max) {
ProgressDialog dialog = (ProgressDialog) getDialog();
@@ -105,9 +102,7 @@ public class ProgressDialogFragment extends DialogFragment {
dialog.setMax(max);
}
- /**
- * Creates dialog
- */
+ @NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Activity activity = getActivity();
@@ -165,7 +160,12 @@ public class ProgressDialogFragment extends DialogFragment {
}
mPreventCancel = preventCancel;
- final Button negative = ((ProgressDialog) getDialog()).getButton(DialogInterface.BUTTON_NEGATIVE);
+ ProgressDialog dialog = (ProgressDialog) getDialog();
+ if (dialog == null) {
+ return;
+ }
+
+ final Button negative = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
negative.setEnabled(mIsCancelled && !preventCancel);
}
@@ -188,11 +188,6 @@ public class ProgressDialogFragment extends DialogFragment {
negative.setClickable(false);
negative.setTextColor(Color.GRAY);
- // Set the progress bar accordingly
- ProgressDialog dialog = (ProgressDialog) getDialog();
- dialog.setIndeterminate(true);
- dialog.setMessage(getString(R.string.progress_cancelling));
-
// send a cancel message. note that this message will be handled by
// KeychainIntentService.onStartCommand, which runs in this thread,
// not the service one, and will not queue up a command.
@@ -212,6 +207,17 @@ public class ProgressDialogFragment extends DialogFragment {
serviceIntent.setAction(KeychainIntentService.ACTION_CANCEL);
getActivity().startService(serviceIntent);
+
+ // Set the progress bar accordingly
+ ProgressDialog dialog = (ProgressDialog) getDialog();
+ if (dialog == null) {
+ return;
+ }
+
+ dialog.setIndeterminate(true);
+ dialog.setMessage(getString(R.string.progress_cancelling));
+
+
}
});
diff --git a/README.md b/README.md
index 175ee6cbb..088e032cb 100644
--- a/README.md
+++ b/README.md
@@ -193,7 +193,7 @@ Some parts and some libraries are Apache License v2, MIT X11 License (see below)
### Libraries
-See https://github.com/open-keychain/open-keychain/blob/development/OpenKeychain/src/main/res/raw/help_about.md
+See https://github.com/open-keychain/open-keychain/blob/master/OpenKeychain/src/main/res/raw/help_about.md
### Images
* icon.svg