From 6a2c9bdbe401f527d19fc4611c827bdf36b6506b Mon Sep 17 00:00:00 2001 From: Levi Bard Date: Mon, 13 Jan 2020 15:18:55 +0100 Subject: [PATCH] Don't drop content warning when replying (#1631) --- .../tusky/components/compose/ComposeActivity.kt | 7 +++++-- .../tusky/components/compose/ComposeViewModel.kt | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt index 99d43c655..2fa54b05a 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt @@ -166,8 +166,7 @@ class ComposeActivity : BaseActivity(), setupContentWarningField(composeOptions?.contentWarning) setupPollView() applyShareIntent(intent, savedInstanceState) - - composeEditField.requestFocus() + viewModel.setupComplete.value = true } private fun applyShareIntent(intent: Intent?, savedInstanceState: Bundle?) { @@ -331,6 +330,10 @@ class ComposeActivity : BaseActivity(), viewModel.uploadError.observe { displayTransientError(R.string.error_media_upload_sending) } + viewModel.setupComplete.observe { + // Focus may have changed during view model setup, ensure initial focus is on the edit field + composeEditField.requestFocus() + } } } diff --git a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt index b4901669e..159738538 100644 --- a/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt +++ b/app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt @@ -82,6 +82,7 @@ class ComposeViewModel val statusVisibility = mutableLiveData(Status.Visibility.UNKNOWN) val showContentWarning = mutableLiveData(false) + val setupComplete = mutableLiveData(false) val poll: MutableLiveData = mutableLiveData(null) val scheduledAt: MutableLiveData = mutableLiveData(null) @@ -367,6 +368,7 @@ class ComposeViewModel if (contentWarning != null) { startingContentWarning = contentWarning } + showContentWarning.value = !contentWarning.isNullOrBlank() // recreate media list // when coming from SavedTootActivity