From 8be3becb769e4c7ddd77ca8efe1a2e7d6ad624d9 Mon Sep 17 00:00:00 2001 From: Ashish Yadav <48384865+criticalAY@users.noreply.github.com> Date: Sat, 8 Feb 2025 02:13:34 +0530 Subject: [PATCH] fix: instant note editor to restore text when orientation changes --- .../instantnoteeditor/InstantNoteEditorActivity.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/instantnoteeditor/InstantNoteEditorActivity.kt b/AnkiDroid/src/main/java/com/ichi2/anki/instantnoteeditor/InstantNoteEditorActivity.kt index 063320fcdc04..9a44ccc1ab9d 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/instantnoteeditor/InstantNoteEditorActivity.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/instantnoteeditor/InstantNoteEditorActivity.kt @@ -84,6 +84,9 @@ class InstantNoteEditorActivity : private var dialogView: View? = null + /** Saves the cloze text in case of orientation change */ + private val configChangedKey = "actualClozeFieldText" + private var editMode = EditMode.ADVANCED private lateinit var editModeButton: MaterialButton @@ -127,7 +130,10 @@ class InstantNoteEditorActivity : return } - handleSharedText(intent) + if (savedInstanceState == null) { + handleSharedText(intent) + } + setupErrorListeners() prepareEditorDialog() } @@ -248,6 +254,11 @@ class InstantNoteEditorActivity : ) } + override fun onSaveInstanceState(outState: Bundle) { + super.onSaveInstanceState(outState) + if (intentTextChanged()) outState.putBoolean(configChangedKey, true) + } + @KotlinCleanup("notetypeJson -> non-null") private fun createEditFields( context: Context,