Skip to content

Commit

Permalink
fix: instant note editor to restore text when orientation changes
Browse files Browse the repository at this point in the history
  • Loading branch information
criticalAY committed Feb 7, 2025
1 parent 74b6d46 commit 8be3bec
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -127,7 +130,10 @@ class InstantNoteEditorActivity :
return
}

handleSharedText(intent)
if (savedInstanceState == null) {
handleSharedText(intent)
}

setupErrorListeners()
prepareEditorDialog()
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8be3bec

Please sign in to comment.