From 363c39a8730f0401fc4f9dac25d8eb078f65a158 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 1 Mar 2018 11:34:42 +0100 Subject: [PATCH] fixed take photo for activties that do not get destroyed --- .../siacs/conversations/ui/ConversationActivity.java | 4 ++-- .../siacs/conversations/ui/ConversationFragment.java | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index c9874ca81..edcabac83 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -432,8 +432,8 @@ public class ConversationActivity extends XmppActivity implements OnConversation @Override public void onSaveInstanceState(Bundle savedInstanceState) { - Intent pendingIntent = pendingViewIntent.pop(); - savedInstanceState.putParcelable("intent", pendingIntent == null ? pendingIntent : getIntent()); + Intent pendingIntent = pendingViewIntent.peek(); + savedInstanceState.putParcelable("intent", pendingIntent != null ? pendingIntent : getIntent()); super.onSaveInstanceState(savedInstanceState); } diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index d8489861e..d06700612 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -1584,7 +1584,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke super.onSaveInstanceState(outState); if (conversation != null) { outState.putString(STATE_CONVERSATION_UUID, conversation.getUuid()); - final Uri uri = pendingTakePhotoUri.pop(); + final Uri uri = pendingTakePhotoUri.peek(); if (uri != null) { outState.putString(STATE_PHOTO_URI, uri.toString()); } @@ -2361,14 +2361,17 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke if (activityResult != null) { handleActivityResult(activityResult); } + clearPending(); } - public void clearPending() { + private void clearPending() { if (postponedActivityResult.pop() != null) { - Log.d(Config.LOGTAG, "cleared pending intent with unhandled result left"); + Log.e(Config.LOGTAG, "cleared pending intent with unhandled result left"); } pendingScrollState.pop(); - pendingTakePhotoUri.pop(); + if (pendingTakePhotoUri.pop() != null) { + Log.e(Config.LOGTAG,"cleared pending photo uri"); + } } public Conversation getConversation() {