ComposeActivity: fix compiling

main
Alibek Omarov 5 years ago
parent 9aa29b75b4
commit 343b121d7b
  1. 10
      app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeActivity.kt
  2. 6
      app/src/main/java/com/keylesspalace/tusky/components/compose/ComposeViewModel.kt

@ -421,8 +421,8 @@ class ComposeActivity : BaseActivity(),
composeEditField.setSelection(start + text.length) composeEditField.setSelection(start + text.length)
} }
private fun toggleMarkdownMode() { private fun enableMarkdownMode(enable: Boolean) {
viewModel.toggleMarkdownMode() viewModel.markdownMode = enable
enableMarkdownWYSIWYGButtons(viewModel.markdownMode) enableMarkdownWYSIWYGButtons(viewModel.markdownMode)
@ -432,6 +432,10 @@ class ComposeActivity : BaseActivity(),
composeMarkdownButton.drawable.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN); composeMarkdownButton.drawable.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN);
} }
private fun toggleMarkdownMode() {
enableMarkdownMode(!viewModel.markdownMode)
}
private fun enableMarkdownWYSIWYGButtons(visible: Boolean) { private fun enableMarkdownWYSIWYGButtons(visible: Boolean) {
val visibility = if(visible) View.VISIBLE else View.GONE val visibility = if(visible) View.VISIBLE else View.GONE
codeButton.visibility = visibility codeButton.visibility = visibility
@ -478,7 +482,7 @@ class ComposeActivity : BaseActivity(),
currentInputContentInfo = null currentInputContentInfo = null
currentFlags = 0 currentFlags = 0
outState.putParcelable("photoUploadUri", photoUploadUri) outState.putParcelable("photoUploadUri", photoUploadUri)
outState.putParcelable("markdownMode", viewModel.markdownMode) outState.putBoolean("markdownMode", viewModel.markdownMode)
super.onSaveInstanceState(outState) super.onSaveInstanceState(outState)
} }

@ -62,7 +62,7 @@ class ComposeViewModel
private var inReplyToId: String? = null private var inReplyToId: String? = null
private var startingVisibility: Status.Visibility = Status.Visibility.UNKNOWN private var startingVisibility: Status.Visibility = Status.Visibility.UNKNOWN
private val instance: MutableLiveData<InstanceEntity?> = MutableLiveData() private val instance: MutableLiveData<InstanceEntity?> = MutableLiveData()
public val markdownMode: Boolean = false public var markdownMode: Boolean = false
val instanceParams: LiveData<ComposeInstanceParams> = instance.map { instance -> val instanceParams: LiveData<ComposeInstanceParams> = instance.map { instance ->
ComposeInstanceParams( ComposeInstanceParams(
@ -87,10 +87,6 @@ class ComposeViewModel
val poll: MutableLiveData<NewPoll?> = mutableLiveData(null) val poll: MutableLiveData<NewPoll?> = mutableLiveData(null)
val scheduledAt: MutableLiveData<String?> = mutableLiveData(null) val scheduledAt: MutableLiveData<String?> = mutableLiveData(null)
fun toggleMarkdownMode() {
this.markdownMode = !this.markdownMode!!
}
val media = mutableLiveData<List<QueuedMedia>>(listOf()) val media = mutableLiveData<List<QueuedMedia>>(listOf())
val uploadError = MutableLiveData<Throwable>() val uploadError = MutableLiveData<Throwable>()

Loading…
Cancel
Save