Retain content of compose view on orientation change

This commit is contained in:
2018-02-24 07:39:06 +01:00
parent e3c7c4d557
commit fb72356467
3 changed files with 42 additions and 14 deletions

View File

@@ -63,6 +63,7 @@ class ComposeMessageFragment : Fragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
retainInstance = true
arguments?.apply {
val draft = getSerializable(EXTRA_DRAFT) as Plaintext?
if (draft != null) {
@@ -266,6 +267,14 @@ class ComposeMessageFragment : Fragment() {
super.onPause()
}
override fun onDestroyView() {
identity = sender_input.selectedItem as BitmessageAddress
// recipient is set when one is selected
subject = subject_input.text?.toString() ?: ""
content = body_input.text?.toString() ?: ""
super.onDestroyView()
}
private fun send() {
val ctx = activity ?: throw IllegalStateException("Fragment is not attached to an activity")
if (recipient == null) {