Commit 219b3892 authored by Hussein's avatar Hussein

P4A-934 Convert InsertableHtmlContent from Serializable to Parcelable.

The transaction overflow is happening due to a serialized object due to
that we decided to move from Serializable implementation to the Parcelable
where we have more control about it.

caveat: We also save/restore the Strings builders, but doing some tests
seems not mandatory and already covered, but as we are not aware 100% of
where they are using we decided to save/restore.
parent f1fd4b0a
package com.fsck.k9.message.quote;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.Objects;
* <p>Represents an HTML document with an insertion point for placing a reply. The quoted
......@@ -12,8 +15,8 @@ import;
* TODO: This container should also have a text part, along with its insertion point. Or maybe a generic InsertableContent and maintain one each for Html and Text?
public class InsertableHtmlContent implements Serializable {
private static final long serialVersionUID = 2397327034L;
public class InsertableHtmlContent implements Parcelable {
// Default to a headerInsertionPoint at the beginning of the message.
private int headerInsertionPoint = 0;
private int footerInsertionPoint = 0;
......@@ -24,6 +27,8 @@ public class InsertableHtmlContent implements Serializable {
// Where to insert the content. Default to top posting.
private InsertionLocation insertionLocation = InsertionLocation.BEFORE_QUOTE;
public InsertableHtmlContent() { }
* Defines where user content should be inserted, either before or after quoted content.
......@@ -167,4 +172,43 @@ public class InsertableHtmlContent implements Serializable {
", compiledResult=" + toString() +
Parcelable implementation
private InsertableHtmlContent(Parcel in) {
headerInsertionPoint = in.readInt();
footerInsertionPoint = in.readInt();
// TODO: 2020-03-23 Check if it is really needed to store the Strings.
quotedContent = new StringBuilder(Objects.requireNonNull(in.readString()));
userContent = new StringBuilder(Objects.requireNonNull(in.readString()));
public static final Creator<InsertableHtmlContent> CREATOR = new Creator<InsertableHtmlContent>() {
public InsertableHtmlContent createFromParcel(Parcel in) {
return new InsertableHtmlContent(in);
public InsertableHtmlContent[] newArray(int size) {
return new InsertableHtmlContent[size];
public int describeContents() {
return 0;
public void writeToParcel(Parcel dest, int flags) {
// TODO: 2020-03-23 Check if it is really needed to store the Strings.
......@@ -153,13 +153,13 @@ public class QuotedMessagePresenter {
public void onSaveInstanceState(Bundle outState) {
outState.putSerializable(STATE_KEY_QUOTED_TEXT_MODE, quotedTextMode);
outState.putSerializable(STATE_KEY_HTML_QUOTE, quotedHtmlContent);
outState.putParcelable(STATE_KEY_HTML_QUOTE, quotedHtmlContent);
outState.putSerializable(STATE_KEY_QUOTED_TEXT_FORMAT, quotedTextFormat);
outState.putBoolean(STATE_KEY_FORCE_PLAIN_TEXT, forcePlainText);
public void onRestoreInstanceState(Bundle savedInstanceState) {
quotedHtmlContent = (InsertableHtmlContent) savedInstanceState.getSerializable(STATE_KEY_HTML_QUOTE);
quotedHtmlContent = savedInstanceState.getParcelable(STATE_KEY_HTML_QUOTE);
if (quotedHtmlContent != null && quotedHtmlContent.getQuotedContent() != null) {
// we don't have the part here, but inline-displayed images are cached by the webview
view.setQuotedHtml(quotedHtmlContent.getQuotedContent(), null);
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