From eef0f82e9679afd4d696db29948a05cab9a1d05e Mon Sep 17 00:00:00 2001 From: Vavassor Date: Tue, 4 Apr 2017 16:02:08 -0400 Subject: [PATCH] Fixes a crash when changing orientation in the composer. --- .../main/java/com/keylesspalace/tusky/ComposeActivity.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java index 22daadd0d..3bc2327ad 100644 --- a/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java +++ b/app/src/main/java/com/keylesspalace/tusky/ComposeActivity.java @@ -416,8 +416,10 @@ public class ComposeActivity extends BaseActivity { setStatusVisibility(startingVisibility); textEditor = createEditText(null); // new String[] { "image/gif", "image/webp" } + final int mentionColour = ThemeUtils.getColor(this, R.attr.compose_mention_color); if (savedInstanceState != null) { restoreTextEditorState(savedInstanceState.getParcelable("textEditorState")); + highlightSpans(textEditor.getText(), mentionColour); } RelativeLayout editArea = (RelativeLayout) findViewById(R.id.compose_edit_area); /* Adding this at index zero because it implicitly gives it the lowest input priority. So, @@ -426,7 +428,6 @@ public class ComposeActivity extends BaseActivity { editArea.addView(textEditor, 0); contentWarningEditor = (EditText) findViewById(R.id.field_content_warning); final TextView charactersLeft = (TextView) findViewById(R.id.characters_left); - final int mentionColour = ThemeUtils.getColor(this, R.attr.compose_mention_color); textEditor.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { @@ -589,7 +590,7 @@ public class ComposeActivity extends BaseActivity { private Parcelable saveTextEditorState() { Bundle bundle = new Bundle(); - bundle.putString("text", HtmlUtils.toHtml(textEditor.getText())); + bundle.putString("text", textEditor.getText().toString()); bundle.putInt("selectionStart", textEditor.getSelectionStart()); bundle.putInt("selectionEnd", textEditor.getSelectionEnd()); return bundle; @@ -597,7 +598,7 @@ public class ComposeActivity extends BaseActivity { private void restoreTextEditorState(Parcelable state) { Bundle bundle = (Bundle) state; - textEditor.setText(HtmlUtils.fromHtml(bundle.getString("text"))); + textEditor.setText(bundle.getString("text")); int start = bundle.getInt("selectionStart"); int end = bundle.getInt("selectionEnd"); if (start != -1) {