aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2015-03-29 20:37:54 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2015-03-29 20:37:54 +0200
commit95f1527afe81c59a116cadc2ed37c065da1819ac (patch)
tree9588674a61956188add5a605e08e323d1027c9f1 /OpenKeychain
parentb82f273284b90d8ab41c806cc2858865d33b2390 (diff)
downloadopen-keychain-95f1527afe81c59a116cadc2ed37c065da1819ac.tar.gz
open-keychain-95f1527afe81c59a116cadc2ed37c065da1819ac.tar.bz2
open-keychain-95f1527afe81c59a116cadc2ed37c065da1819ac.zip
Fixing crashes with new encrypt ui
Diffstat (limited to 'OpenKeychain')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/InputPendingResult.java20
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CryptoOperationFragment.java29
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java29
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextFragment.java23
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/NfcHelper.java9
-rw-r--r--OpenKeychain/src/main/res/layout/encrypt_text_activity.xml3
-rw-r--r--OpenKeychain/src/main/res/menu/encrypt_file_fragment.xml (renamed from OpenKeychain/src/main/res/menu/encrypt_file_activity.xml)0
-rw-r--r--OpenKeychain/src/main/res/menu/encrypt_text_fragment.xml (renamed from OpenKeychain/src/main/res/menu/encrypt_text_activity.xml)0
8 files changed, 70 insertions, 43 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/InputPendingResult.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/InputPendingResult.java
index e0ba28fbe..45a6b98b8 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/InputPendingResult.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/operations/results/InputPendingResult.java
@@ -1,11 +1,27 @@
-package org.sufficientlysecure.keychain.operations.results;
+/*
+ * Copyright (C) 2015 Dominik Schürmann <dominik@dominikschuermann.de>
+ * Copyright (C) 2015 Vincent Breitmoser <v.breitmoser@mugenguild.com>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.sufficientlysecure.keychain.operations.results;
import android.os.Parcel;
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
-
public class InputPendingResult extends OperationResult {
// the fourth bit indicates a "data pending" result! (it's also a form of non-success)
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CryptoOperationFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CryptoOperationFragment.java
index 076c628b4..5227c1477 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CryptoOperationFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/CryptoOperationFragment.java
@@ -1,5 +1,22 @@
-package org.sufficientlysecure.keychain.ui;
+/*
+ * Copyright (C) 2015 Dominik Schürmann <dominik@dominikschuermann.de>
+ * Copyright (C) 2015 Vincent Breitmoser <v.breitmoser@mugenguild.com>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package org.sufficientlysecure.keychain.ui;
import android.app.Activity;
import android.content.Intent;
@@ -7,14 +24,15 @@ import android.os.Bundle;
import android.os.Message;
import android.support.v4.app.Fragment;
-import org.sufficientlysecure.keychain.operations.results.CertifyResult;
import org.sufficientlysecure.keychain.operations.results.InputPendingResult;
import org.sufficientlysecure.keychain.operations.results.OperationResult;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.service.input.CryptoInputParcel;
import org.sufficientlysecure.keychain.service.input.RequiredInputParcel;
-
+/**
+ * All fragments executing crypto operations need to extend this class.
+ */
public abstract class CryptoOperationFragment extends Fragment {
public static final int REQUEST_CODE_PASSPHRASE = 0x00008001;
@@ -40,7 +58,6 @@ public abstract class CryptoOperationFragment extends Fragment {
}
throw new RuntimeException("Unhandled pending result!");
-
}
@Override
@@ -77,8 +94,8 @@ public abstract class CryptoOperationFragment extends Fragment {
if (message.arg1 == ServiceProgressHandler.MessageStatus.OKAY.ordinal()) {
Bundle data = message.getData();
- OperationResult result = data.getParcelable(CertifyResult.EXTRA_RESULT);
- if (result == null || ! (result instanceof InputPendingResult)) {
+ OperationResult result = data.getParcelable(OperationResult.EXTRA_RESULT);
+ if (result == null || !(result instanceof InputPendingResult)) {
return false;
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java
index fb9a86b07..5af353524 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptFilesFragment.java
@@ -80,7 +80,7 @@ public class EncryptFilesFragment extends CryptoOperationFragment {
private IMode mModeInterface;
- private boolean mSymmetricMode = true;
+ private boolean mSymmetricMode = false;
private boolean mUseArmor = false;
private boolean mUseCompression = true;
private boolean mDeleteAfterEncrypt = false;
@@ -188,7 +188,7 @@ public class EncryptFilesFragment extends CryptoOperationFragment {
if (mInputUris.contains(inputUri)) {
Notify.create(getActivity(),
getActivity().getString(R.string.error_file_added_already, FileHelper.getFilename(getActivity(), inputUri)),
- Notify.Style.ERROR).show(this);
+ Notify.Style.ERROR).show();
return;
}
@@ -222,7 +222,7 @@ public class EncryptFilesFragment extends CryptoOperationFragment {
private void encryptClicked(boolean share) {
if (mInputUris.isEmpty()) {
- Notify.create(getActivity(), R.string.error_no_file_selected, Notify.Style.ERROR).show(this);
+ Notify.create(getActivity(), R.string.error_no_file_selected, Notify.Style.ERROR).show();
return;
}
if (share) {
@@ -238,7 +238,7 @@ public class EncryptFilesFragment extends CryptoOperationFragment {
startEncrypt(true);
} else {
if (mInputUris.size() > 1) {
- Notify.create(getActivity(), R.string.error_multi_not_supported, Notify.Style.ERROR).show(this);
+ Notify.create(getActivity(), R.string.error_multi_not_supported, Notify.Style.ERROR).show();
return;
}
showOutputFileDialog();
@@ -260,7 +260,7 @@ public class EncryptFilesFragment extends CryptoOperationFragment {
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
- inflater.inflate(R.menu.encrypt_file_activity, menu);
+ inflater.inflate(R.menu.encrypt_file_fragment, menu);
}
@Override
@@ -319,12 +319,14 @@ public class EncryptFilesFragment extends CryptoOperationFragment {
if (mInputUris.isEmpty()) {
Notify.create(getActivity(), R.string.no_file_selected, Notify.Style.ERROR)
- .show(this);
+ .show();
return false;
} else if (mInputUris.size() > 1 && !mShareAfterEncrypt) {
+ Log.e(Constants.TAG, "Aborting: mInputUris.size() > 1 && !mShareAfterEncrypt");
// This should be impossible...
return false;
} else if (mInputUris.size() != mOutputUris.size()) {
+ Log.e(Constants.TAG, "Aborting: mInputUris.size() != mOutputUris.size()");
// This as well
return false;
}
@@ -334,12 +336,12 @@ public class EncryptFilesFragment extends CryptoOperationFragment {
if (mPassphrase == null) {
Notify.create(getActivity(), R.string.passphrases_do_not_match, Notify.Style.ERROR)
- .show(this);
+ .show();
return false;
}
if (mPassphrase.isEmpty()) {
Notify.create(getActivity(), R.string.passphrase_must_not_be_empty, Notify.Style.ERROR)
- .show(this);
+ .show();
return false;
}
@@ -352,7 +354,7 @@ public class EncryptFilesFragment extends CryptoOperationFragment {
// Files must be encrypted, only text can be signed-only right now
if (!gotEncryptionKeys) {
Notify.create(getActivity(), R.string.select_encryption_key, Notify.Style.ERROR)
- .show(this);
+ .show();
return false;
}
}
@@ -361,7 +363,7 @@ public class EncryptFilesFragment extends CryptoOperationFragment {
public void startEncrypt(boolean share) {
mShareAfterEncrypt = share;
- startEncrypt();
+ cryptoOperation(new CryptoInputParcel());
}
public void onEncryptSuccess(final SignEncryptResult result) {
@@ -470,18 +472,15 @@ public class EncryptFilesFragment extends CryptoOperationFragment {
return sendIntent;
}
- public void startEncrypt() {
- cryptoOperation(new CryptoInputParcel());
- }
-
- // public void startEncrypt(CryptoInputParcel cryptoInput) {
@Override
protected void cryptoOperation(CryptoInputParcel cryptoInput) {
if (!inputIsValid()) {
// Notify was created by inputIsValid.
+ Log.d(Constants.TAG, "Input not valid!");
return;
}
+ Log.d(Constants.TAG, "Input valid!");
// Send all information needed to service to edit key in other thread
Intent intent = new Intent(getActivity(), KeychainIntentService.class);
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextFragment.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextFragment.java
index c71edcd22..3303b2c65 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextFragment.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/EncryptTextFragment.java
@@ -64,7 +64,7 @@ public class EncryptTextFragment extends CryptoOperationFragment {
private IMode mModeInterface;
- private boolean mSymmetricMode = true;
+ private boolean mSymmetricMode = false;
private boolean mShareAfterEncrypt = false;
private boolean mUseCompression = true;
private boolean mHiddenRecipients = false;
@@ -159,7 +159,7 @@ public class EncryptTextFragment extends CryptoOperationFragment {
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
- inflater.inflate(R.menu.encrypt_text_activity, menu);
+ inflater.inflate(R.menu.encrypt_text_fragment, menu);
}
@Override
@@ -289,7 +289,7 @@ public class EncryptTextFragment extends CryptoOperationFragment {
protected boolean inputIsValid() {
if (mMessage == null) {
Notify.create(getActivity(), R.string.error_message, Notify.Style.ERROR)
- .show(this);
+ .show();
return false;
}
@@ -298,12 +298,12 @@ public class EncryptTextFragment extends CryptoOperationFragment {
if (mPassphrase == null) {
Notify.create(getActivity(), R.string.passphrases_do_not_match, Notify.Style.ERROR)
- .show(this);
+ .show();
return false;
}
if (mPassphrase.isEmpty()) {
Notify.create(getActivity(), R.string.passphrase_must_not_be_empty, Notify.Style.ERROR)
- .show(this);
+ .show();
return false;
}
@@ -315,7 +315,7 @@ public class EncryptTextFragment extends CryptoOperationFragment {
if (!gotEncryptionKeys && mSigningKeyId == 0) {
Notify.create(getActivity(), R.string.select_encryption_or_signature_key, Notify.Style.ERROR)
- .show(this);
+ .show();
return false;
}
}
@@ -348,7 +348,7 @@ public class EncryptTextFragment extends CryptoOperationFragment {
input.setCryptoInput(cryptoInput);
}
- Bundle data = new Bundle();
+ final Bundle data = new Bundle();
data.putParcelable(KeychainIntentService.SIGN_ENCRYPT_PARCEL, input);
intent.putExtra(KeychainIntentService.EXTRA_DATA, data);
@@ -362,10 +362,11 @@ public class EncryptTextFragment extends CryptoOperationFragment {
// handle messages by standard KeychainIntentServiceHandler first
super.handleMessage(message);
- // handle pending messages
- if (handlePendingMessage(message)) {
- return;
- }
+ // TODO: We need a InputPendingResult!
+// // handle pending messages
+// if (handlePendingMessage(message)) {
+// return;
+// }
if (message.arg1 == MessageStatus.OKAY.ordinal()) {
SignEncryptResult result =
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/NfcHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/NfcHelper.java
index e4e4e4d05..2b47fd623 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/NfcHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/NfcHelper.java
@@ -191,9 +191,6 @@ public class NfcHelper {
mNfcAdapter.invokeBeam(mActivity);
}
- /**
- * A static subclass of {@link Handler} with a {@link WeakReference} to an {@link Activity} to avoid memory leaks.
- */
private static class NfcHandler extends Handler {
private final WeakReference<Activity> mActivityReference;
@@ -203,12 +200,10 @@ public class NfcHelper {
@Override
public void handleMessage(Message msg) {
- Activity activity = mActivityReference.get();
-
- if (activity != null) {
+ if (mActivityReference.get() != null) {
switch (msg.what) {
case NFC_SENT:
- Notify.create(activity, R.string.nfc_successful, Notify.Style.OK).show();
+ Notify.create(mActivityReference.get(), R.string.nfc_successful, Notify.Style.OK).show();
break;
}
}
diff --git a/OpenKeychain/src/main/res/layout/encrypt_text_activity.xml b/OpenKeychain/src/main/res/layout/encrypt_text_activity.xml
index a5082010e..64ce50b74 100644
--- a/OpenKeychain/src/main/res/layout/encrypt_text_activity.xml
+++ b/OpenKeychain/src/main/res/layout/encrypt_text_activity.xml
@@ -25,8 +25,7 @@
<FrameLayout
android:id="@+id/encrypt_mode_container"
android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" />
+ android:layout_height="wrap_content" />
<FrameLayout
android:id="@+id/encrypt_text_container"
diff --git a/OpenKeychain/src/main/res/menu/encrypt_file_activity.xml b/OpenKeychain/src/main/res/menu/encrypt_file_fragment.xml
index d6ed726fa..d6ed726fa 100644
--- a/OpenKeychain/src/main/res/menu/encrypt_file_activity.xml
+++ b/OpenKeychain/src/main/res/menu/encrypt_file_fragment.xml
diff --git a/OpenKeychain/src/main/res/menu/encrypt_text_activity.xml b/OpenKeychain/src/main/res/menu/encrypt_text_fragment.xml
index 5a262fdd8..5a262fdd8 100644
--- a/OpenKeychain/src/main/res/menu/encrypt_text_activity.xml
+++ b/OpenKeychain/src/main/res/menu/encrypt_text_fragment.xml