Add preferences.linkify

pull/1952/head
Alex Baker 2 years ago
parent 3163150e8f
commit cdd163efbf

@ -87,9 +87,6 @@ class TaskEditFragment : Fragment(), Toolbar.OnMenuItemClickListener {
@Inject lateinit var taskEditEventBus: TaskEditEventBus
@Inject lateinit var localBroadcastManager: LocalBroadcastManager
private val linkifyEnabled: Boolean
get() = preferences.getBoolean(R.string.p_linkify_task_edit, false)
val editViewModel: TaskEditViewModel by viewModels()
val subtaskViewModel: TaskListViewModel by viewModels()
lateinit var binding: FragmentTaskEditBinding
@ -137,7 +134,7 @@ class TaskEditFragment : Fragment(), Toolbar.OnMenuItemClickListener {
})
toolbar.setOnMenuItemClickListener(this)
val title = binding.title
val textWatcher = markdownProvider.markdown(linkifyEnabled).textWatcher(title)
val textWatcher = markdownProvider.markdown(preferences.linkify).textWatcher(title)
title.addTextChangedListener(
onTextChanged = { _, _, _, _ ->
editViewModel.title = title.text.toString().trim { it <= ' ' }
@ -181,7 +178,7 @@ class TaskEditFragment : Fragment(), Toolbar.OnMenuItemClickListener {
lifecycleScope.launch {
notificationManager.cancel(model.id)
}
if (linkifyEnabled) {
if (preferences.linkify) {
linkify.linkify(title)
}
}

@ -547,6 +547,9 @@ class Preferences @JvmOverloads constructor(
val desaturateDarkMode: Boolean
get() = getBoolean(R.string.p_desaturate_colors, true)
val linkify: Boolean
get() = getBoolean(R.string.p_linkify_task_edit, false)
companion object {
private const val PREF_SORT_SORT = "sort_sort" // $NON-NLS-1$

@ -19,9 +19,6 @@ class DescriptionControlSet : TaskEditControlFragment() {
@Inject lateinit var preferences: Preferences
@Inject lateinit var markdownProvider: MarkdownProvider
private val linkifyEnabled: Boolean
get() = preferences.getBoolean(R.string.p_linkify_task_edit, false)
override fun bind(parent: ViewGroup?): View =
(parent as ComposeView).apply {
setContent {
@ -29,7 +26,7 @@ class DescriptionControlSet : TaskEditControlFragment() {
DescriptionRow(
text = viewModel.description.stripCarriageReturns(),
onChanged = { text -> viewModel.description = text.toString().trim { it <= ' ' } },
linkify = if (linkifyEnabled) linkify else null,
linkify = if (preferences.linkify) linkify else null,
markdownProvider = markdownProvider,
)
}

Loading…
Cancel
Save