aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-12-01 14:18:07 +0100
committerDaniel Gultsch <daniel@gultsch.de>2015-12-01 14:18:07 +0100
commit2cd43f704215f963200249c0771362ce2bcf4768 (patch)
tree9ed3683e17375d3c9f3b3b3cff305547c16e935c /src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
parentd42c82abf21d92ae1e8c7d12510d376800a2b363 (diff)
fixed crashes when activity got destroyed when selecting pgp key
Diffstat (limited to 'src/main/java/eu/siacs/conversations/ui/ConversationActivity.java')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index 5c7722200..5ac2b1b4e 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -17,6 +17,7 @@ import android.provider.MediaStore;
import android.support.v4.widget.SlidingPaneLayout;
import android.support.v4.widget.SlidingPaneLayout.PanelSlideListener;
import android.util.Log;
+import android.util.Pair;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
@@ -109,6 +110,7 @@ public class ConversationActivity extends XmppActivity
private boolean mActivityPaused = false;
private AtomicBoolean mRedirected = new AtomicBoolean(false);
+ private Pair<Integer, Intent> mPostponedActivityResult;
public Conversation getSelectedConversation() {
return this.mSelectedConversation;
@@ -1101,6 +1103,7 @@ public class ConversationActivity extends XmppActivity
mPendingFileUris.clear();
mPendingGeoUri = null;
setSelectedConversation(conversationList.get(0));
+ mPostponedActivityResult = null;
this.mConversationFragment.reInit(getSelectedConversation());
} else {
this.mConversationFragment.messageListAdapter.updatePreferences();
@@ -1108,6 +1111,10 @@ public class ConversationActivity extends XmppActivity
this.mConversationFragment.setupIme();
}
+ if (this.mPostponedActivityResult != null) {
+ this.onActivityResult(mPostponedActivityResult.first, RESULT_OK, mPostponedActivityResult.second);
+ }
+
if(!forbidProcessingPendings) {
for (Iterator<Uri> i = mPendingImageUris.iterator(); i.hasNext(); i.remove()) {
Uri foo = i.next();
@@ -1208,14 +1215,24 @@ public class ConversationActivity extends XmppActivity
if (requestCode == REQUEST_DECRYPT_PGP) {
mConversationFragment.onActivityResult(requestCode, resultCode, data);
} else if (requestCode == REQUEST_CHOOSE_PGP_ID) {
- if (data.getExtras().containsKey(OpenPgpApi.EXTRA_SIGN_KEY_ID)) {
- mSelectedConversation.getAccount().setPgpSignId(data.getExtras().getLong(OpenPgpApi.EXTRA_SIGN_KEY_ID));
- announcePgp(mSelectedConversation.getAccount(), null);
+ if (xmppConnectionServiceBound) {
+ if (data.getExtras().containsKey(OpenPgpApi.EXTRA_SIGN_KEY_ID)) {
+ mSelectedConversation.getAccount().setPgpSignId(data.getExtras().getLong(OpenPgpApi.EXTRA_SIGN_KEY_ID));
+ announcePgp(mSelectedConversation.getAccount(), null);
+ } else {
+ choosePgpSignId(mSelectedConversation.getAccount());
+ }
+ this.mPostponedActivityResult = null;
} else {
- choosePgpSignId(mSelectedConversation.getAccount());
+ this.mPostponedActivityResult = new Pair<>(requestCode, data);
}
} else if (requestCode == REQUEST_ANNOUNCE_PGP) {
- announcePgp(mSelectedConversation.getAccount(), null);
+ if (xmppConnectionServiceBound) {
+ announcePgp(mSelectedConversation.getAccount(), null);
+ this.mPostponedActivityResult = null;
+ } else {
+ this.mPostponedActivityResult = new Pair<>(requestCode, data);
+ }
} else if (requestCode == ATTACHMENT_CHOICE_CHOOSE_IMAGE) {
mPendingImageUris.clear();
mPendingImageUris.addAll(extractUriFromIntent(data));