mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 12:49:02 +00:00
Finish 3.0
This commit is contained in:
parent
f2c21c0604
commit
79ff3c2414
2 changed files with 40 additions and 3 deletions
|
|
@ -483,7 +483,10 @@ class TaskFormActivity : BaseActivity() {
|
|||
}
|
||||
|
||||
private fun deleteTask() {
|
||||
if (task?.challengeID?.isNotBlank() == true) {
|
||||
if (task?.challengeBroken?.isNotBlank() == true) {
|
||||
showBrokenChallengeDialog()
|
||||
return
|
||||
} else if (task?.challengeID?.isNotBlank() == true) {
|
||||
showChallengeDeleteTask()
|
||||
return
|
||||
}
|
||||
|
|
@ -528,6 +531,31 @@ class TaskFormActivity : BaseActivity() {
|
|||
}, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
private fun showBrokenChallengeDialog() {
|
||||
val task = task ?: return
|
||||
if (!task.isValid) {
|
||||
return
|
||||
}
|
||||
compositeSubscription.add(taskRepository.getTasksForChallenge(task.challengeID).subscribe({ tasks ->
|
||||
val taskCount = tasks.size
|
||||
val dialog = HabiticaAlertDialog(this)
|
||||
dialog.setTitle(R.string.broken_challenge)
|
||||
dialog.setMessage(this.getString(R.string.broken_challenge_description, taskCount))
|
||||
dialog.addButton(this.getString(R.string.keep_x_tasks, taskCount), true) { _, _ ->
|
||||
taskRepository.unlinkAllTasks(task.challengeID, "keep-all").subscribe({
|
||||
finish()
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
}
|
||||
dialog.addButton(this.getString(R.string.delete_x_tasks, taskCount), false, true) { _, _ ->
|
||||
taskRepository.unlinkAllTasks(task.challengeID, "remove-all").subscribe({
|
||||
finish()
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
}
|
||||
dialog.setExtraCloseButtonVisibility(View.VISIBLE)
|
||||
dialog.show()
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
|
||||
override fun finish() {
|
||||
dismissKeyboard()
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import android.content.Context
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.*
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.extensions.getThemeColor
|
||||
|
|
@ -32,7 +33,7 @@ abstract class BaseTaskViewHolder constructor(itemView: View, var scoreTaskFunc:
|
|||
protected val notesTextView: EllipsisTextView? = itemView.findViewById(R.id.notesTextView)
|
||||
protected val calendarIconView: ImageView? = itemView.findViewById(R.id.iconViewCalendar)
|
||||
protected val specialTaskTextView: TextView? = itemView.findViewById(R.id.specialTaskText)
|
||||
private val iconViewChallenge: ImageView? = itemView.findViewById(R.id.iconviewChallenge)
|
||||
private val iconViewChallenge: AppCompatImageView? = itemView.findViewById(R.id.iconviewChallenge)
|
||||
private val iconViewReminder: ImageView? = itemView.findViewById(R.id.iconviewReminder)
|
||||
private val taskIconWrapper: LinearLayout? = itemView.findViewById(R.id.taskIconWrapper)
|
||||
private val approvalRequiredTextView: TextView? = itemView.findViewById(R.id.approvalRequiredTextField)
|
||||
|
|
@ -184,7 +185,15 @@ abstract class BaseTaskViewHolder constructor(itemView: View, var scoreTaskFunc:
|
|||
|
||||
iconViewChallenge?.visibility = if (task?.challengeID != null) View.VISIBLE else View.GONE
|
||||
if (task?.challengeID != null) {
|
||||
iconViewChallenge?.setImageResource(if (task?.challengeBroken?.isNotBlank() == true) R.drawable.task_broken_megaphone else R.drawable.task_megaphone)
|
||||
if (task?.challengeBroken?.isNotBlank() == true) {
|
||||
iconViewChallenge?.alpha = 1.0f
|
||||
iconViewChallenge?.imageTintList = ContextCompat.getColorStateList(context, R.color.white)
|
||||
iconViewChallenge?.setImageResource(R.drawable.task_broken_megaphone)
|
||||
} else {
|
||||
iconViewChallenge?.alpha = 0.3f
|
||||
iconViewChallenge?.imageTintList = ContextCompat.getColorStateList(context, R.color.text_ternary)
|
||||
iconViewChallenge?.setImageResource(R.drawable.task_megaphone)
|
||||
}
|
||||
}
|
||||
configureSpecialTaskTextView(data)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue