Verified Commit 5433ba38 authored by Hussein's avatar Hussein

Merge branch 'P4A-934' into release/v1.1.200

parents 2af110df d8f4dc6c
......@@ -2,6 +2,7 @@ package com.fsck.k9.activity;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
......@@ -64,6 +65,7 @@ import com.fsck.k9.activity.compose.RecipientPresenter;
import com.fsck.k9.activity.compose.RecipientPresenter.CryptoMode;
import com.fsck.k9.activity.compose.SaveMessageTask;
import com.fsck.k9.activity.misc.Attachment;
import com.fsck.k9.activity.misc.NonConfigurationInstance;
import com.fsck.k9.controller.MessagingController;
import com.fsck.k9.controller.MessagingListener;
import com.fsck.k9.controller.SimpleMessagingListener;
......@@ -518,12 +520,7 @@ public class MessageCompose extends PepActivity implements OnClickListener,
updateMessageFormat();
setTitle();
currentMessageBuilder = (MessageBuilder) getLastCustomNonConfigurationInstance();
if (currentMessageBuilder != null) {
setProgressBarIndeterminateVisibility(true);
currentMessageBuilder.reattachCallback(this);
}
restoreMessageComposeConfigurationInstance();
Timber.e("P4A-941 builder set %d ", System.currentTimeMillis()-time);
recipientPresenter.switchPrivacyProtection(PEpProvider.ProtectionScope.ACCOUNT, account.ispEpPrivacyProtected());
......@@ -531,6 +528,23 @@ public class MessageCompose extends PepActivity implements OnClickListener,
}
private void restoreMessageComposeConfigurationInstance() {
MessageComposeNonConfigInstance messageComposeNonConfigInstance =
(MessageComposeNonConfigInstance) getLastCustomNonConfigurationInstance();
if(messageComposeNonConfigInstance != null) {
Bundle retainedState = messageComposeNonConfigInstance.retainedState;
attachmentPresenter.onRestoreInstanceState(retainedState);
recipientPresenter.onRestoreInstanceState(retainedState);
quotedMessagePresenter.onRestoreInstanceState(retainedState);
if(messageComposeNonConfigInstance.messageBuilder != null) {
currentMessageBuilder = messageComposeNonConfigInstance.messageBuilder;
setProgressBarIndeterminateVisibility(true);
currentMessageBuilder.reattachCallback(this);
}
}
}
private void startToolbar() {
setUpToolbar(true);
setUpToolbarHomeIcon(resourcesProvider.getAttributeResource(R.attr.iconActionCancel));
......@@ -706,20 +720,48 @@ public class MessageCompose extends PepActivity implements OnClickListener,
outState.putString(STATE_REFERENCES, referencedMessageIds);
outState.putBoolean(STATE_KEY_CHANGES_MADE_SINCE_LAST_SAVE, changesMadeSinceLastSave);
outState.putBoolean(STATE_ALREADY_NOTIFIED_USER_OF_EMPTY_SUBJECT, alreadyNotifiedUserOfEmptySubject);
recipientPresenter.onSaveInstanceState(outState);
quotedMessagePresenter.onSaveInstanceState(outState);
attachmentPresenter.onSaveInstanceState(outState);
// TODO: trigger pep?
}
public static class MessageComposeNonConfigInstance implements NonConfigurationInstance {
MessageBuilder messageBuilder;
Bundle retainedState;
MessageComposeNonConfigInstance(MessageBuilder messageBuilder, Bundle retainedState) {
this.messageBuilder = messageBuilder;
this.retainedState = retainedState;
}
@Override
public boolean retain() {
return true;
}
@Override
public void restore(Activity activity) {
}
}
@Override
public Object onRetainCustomNonConfigurationInstance() {
if (currentMessageBuilder != null) {
currentMessageBuilder.detachCallback();
}
return currentMessageBuilder;
Bundle retainedState = new Bundle();
if(quotedMessagePresenter != null) {
quotedMessagePresenter.onSaveInstanceState(retainedState);
}
if(recipientPresenter != null) {
recipientPresenter.onSaveInstanceState(retainedState);
}
if(attachmentPresenter != null) {
attachmentPresenter.onSaveInstanceState(retainedState);
}
MessageComposeNonConfigInstance messageComposeNonConfigInstance =
new MessageComposeNonConfigInstance(currentMessageBuilder, retainedState);
return messageComposeNonConfigInstance;
}
@Override
......@@ -728,10 +770,6 @@ public class MessageCompose extends PepActivity implements OnClickListener,
attachmentsView.removeAllViews();
recipientPresenter.onRestoreInstanceState(savedInstanceState);
quotedMessagePresenter.onRestoreInstanceState(savedInstanceState);
attachmentPresenter.onRestoreInstanceState(savedInstanceState);
draftId = savedInstanceState.getLong(STATE_KEY_DRAFT_ID);
identity = (Identity) savedInstanceState.getSerializable(STATE_IDENTITY);
identityChanged = savedInstanceState.getBoolean(STATE_IDENTITY_CHANGED);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment