Skip to content

Commit

Permalink
Make group tags uneditable in filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Hafizzle committed Sep 15, 2023
1 parent b81798a commit e446167
Showing 1 changed file with 40 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.graphics.Typeface
import android.graphics.drawable.Drawable
import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import android.view.WindowManager
import android.widget.RadioGroup
import android.widget.TextView
Expand Down Expand Up @@ -241,37 +242,49 @@ class TaskFilterDialog(context: Context, private val repository: TagRepository,
view.setTextColor(ContextCompat.getColor(context, R.color.text_secondary))
binding.tagsList.addView(view)
} else {
val editBinding = EditTagItemBinding.inflate(inflater, binding.tagsList, false)
editBinding.editText.setText(tag.name)
editBinding.editText.setTextColor(ContextCompat.getColor(context, R.color.text_secondary))
editBinding.editText.addTextChangedListener(
OnChangeTextWatcher { s, _, _, _ ->
if (index >= tags.size) {
return@OnChangeTextWatcher
if (tag.group != null) {
// Make Group tags uneditable
val editBinding = EditTagItemBinding.inflate(inflater, binding.tagsList, false)
editBinding.editText.setText(tag.name)
editBinding.editText.isEnabled = false
editBinding.editText.setTextColor(ContextCompat.getColor(context, R.color.disabled_background))
editBinding.deleteButton.isEnabled = false
editBinding.deleteButton.alpha = .75f
binding.tagsList.addView(editBinding.root)
} else {
// All tags (except group tags) are editable
val editBinding = EditTagItemBinding.inflate(inflater, binding.tagsList, false)
editBinding.editText.setText(tag.name)
editBinding.editText.setTextColor(ContextCompat.getColor(context, R.color.text_secondary))
editBinding.editText.addTextChangedListener(
OnChangeTextWatcher { s, _, _, _ ->
if (index >= tags.size) {
return@OnChangeTextWatcher
}
val changedTag = tags[index]
changedTag.name = s.toString()
if (createdTags.containsKey(changedTag.id)) {
createdTags[changedTag.id] = changedTag
} else {
editedTags[changedTag.id] = changedTag
}
tags[index] = changedTag
}
val changedTag = tags[index]
changedTag.name = s.toString()
if (createdTags.containsKey(changedTag.id)) {
createdTags[changedTag.id] = changedTag
} else {
editedTags[changedTag.id] = changedTag
)
editBinding.deleteButton.setOnClickListener {
deletedTags.add(tag.id)
if (createdTags.containsKey(tag.id)) {
createdTags.remove(tag.id)
}
tags[index] = changedTag
}
)
editBinding.deleteButton.setOnClickListener {
deletedTags.add(tag.id)
if (createdTags.containsKey(tag.id)) {
createdTags.remove(tag.id)
}
if (editedTags.containsKey(tag.id)) {
editedTags.remove(tag.id)
if (editedTags.containsKey(tag.id)) {
editedTags.remove(tag.id)
}
viewModel.tags.remove(tag.id)
tags.remove(tag)
binding.tagsList.removeView(editBinding.root)
}
viewModel.tags.remove(tag.id)
tags.remove(tag)
binding.tagsList.removeView(editBinding.root)
binding.tagsList.addView(editBinding.root)
}
binding.tagsList.addView(editBinding.root)
}
}

Expand Down

0 comments on commit e446167

Please sign in to comment.