mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-04-14 19:56:32 +00:00
Merge pull request #1862 from Hafizzle/Hafiz/task-link-updates
Notes and checklist item link fixes
This commit is contained in:
commit
8ebb743b10
2 changed files with 24 additions and 2 deletions
|
|
@ -8,6 +8,11 @@ import android.graphics.drawable.ColorDrawable
|
|||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.text.Spannable
|
||||
import android.text.SpannableString
|
||||
import android.text.TextUtils
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.text.util.Linkify
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.MotionEvent
|
||||
|
|
@ -237,6 +242,7 @@ class TaskFormActivity : BaseActivity() {
|
|||
binding.notesEditText.onFocusChangeListener = View.OnFocusChangeListener { _, isFocused ->
|
||||
binding.notesInputLayout.alpha = if (isFocused) 0.8f else 0.6f
|
||||
}
|
||||
binding.notesEditText.movementMethod = LinkMovementMethod.getInstance()
|
||||
binding.scrollView.setOnTouchListener { view, event ->
|
||||
userScrolled =
|
||||
view == binding.scrollView && (event.action == MotionEvent.ACTION_SCROLL || event.action == MotionEvent.ACTION_MOVE)
|
||||
|
|
@ -535,7 +541,12 @@ class TaskFormActivity : BaseActivity() {
|
|||
}
|
||||
canSave = true
|
||||
binding.textEditText.setText(task.text)
|
||||
binding.notesEditText.setText(task.notes)
|
||||
val spannable: Spannable = SpannableString(task.notes)
|
||||
Linkify.addLinks(spannable, Linkify.WEB_URLS)
|
||||
//Append a zero-width space to the Spannable to allow clicking
|
||||
//on the open spaces (and prevent links from opening)
|
||||
val text: CharSequence = TextUtils.concat(spannable, "\u200B")
|
||||
binding.notesEditText.setText(text)
|
||||
viewModel.taskDifficulty.value = TaskDifficulty.valueOf(task.priority)
|
||||
when (taskType) {
|
||||
TaskType.HABIT -> {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
package com.habitrpg.android.habitica.ui.views.tasks.form
|
||||
|
||||
import android.content.Context
|
||||
import android.text.Spannable
|
||||
import android.text.SpannableString
|
||||
import android.text.TextUtils
|
||||
import android.text.method.LinkMovementMethod
|
||||
import android.text.util.Linkify
|
||||
import android.util.AttributeSet
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
|
|
@ -30,7 +35,12 @@ class ChecklistItemFormView @JvmOverloads constructor(
|
|||
var item: ChecklistItem = ChecklistItem()
|
||||
set(value) {
|
||||
field = value
|
||||
binding.editText.setText(item.text)
|
||||
val spannable: Spannable = SpannableString(item.text)
|
||||
Linkify.addLinks(spannable, Linkify.WEB_URLS)
|
||||
//Append a zero-width space to the Spannable to allow clicking
|
||||
//on the open spaces (and prevent the link from opening)
|
||||
val text: CharSequence = TextUtils.concat(spannable, "\u200B")
|
||||
binding.editText.setText(text)
|
||||
}
|
||||
|
||||
var tintColor: Int = context.getThemeColor(R.attr.taskFormTint)
|
||||
|
|
@ -89,6 +99,7 @@ class ChecklistItemFormView @JvmOverloads constructor(
|
|||
// a plus button we set it as 'unimportant for accessibility' so it can't be focused.
|
||||
binding.button.contentDescription = context.getString(R.string.delete_checklist_entry)
|
||||
binding.button.drawable.mutate().setTint(tintColor)
|
||||
binding.editText.movementMethod = LinkMovementMethod.getInstance()
|
||||
|
||||
binding.editText.addTextChangedListener(
|
||||
OnChangeTextWatcher { s, _, _, _ ->
|
||||
|
|
|
|||
Loading…
Reference in a new issue