mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-05 16:58:52 -06:00
Show message after archiving/unarchiving habits
This commit is contained in:
@@ -203,7 +203,8 @@ class ShowHabitActivity : AppCompatActivity(), CommandRunner.Listener {
|
||||
}
|
||||
|
||||
private fun getPopupAnchor(): View? {
|
||||
val dialog = supportFragmentManager.findFragmentByTag("historyEditor") as HistoryEditorDialog?
|
||||
val dialog =
|
||||
supportFragmentManager.findFragmentByTag("historyEditor") as HistoryEditorDialog?
|
||||
return dialog?.dataView
|
||||
}
|
||||
|
||||
@@ -216,6 +217,25 @@ class ShowHabitActivity : AppCompatActivity(), CommandRunner.Listener {
|
||||
ShowHabitMenuPresenter.Message.COULD_NOT_EXPORT -> {
|
||||
showMessage(resources.getString(R.string.could_not_export))
|
||||
}
|
||||
|
||||
ShowHabitMenuPresenter.Message.HABIT_ARCHIVED -> {
|
||||
showMessage(
|
||||
resources.getQuantityString(
|
||||
R.plurals.toast_habits_archived,
|
||||
1
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
ShowHabitMenuPresenter.Message.HABIT_UNARCHIVED -> {
|
||||
showMessage(
|
||||
resources.getQuantityString(
|
||||
R.plurals.toast_habits_unarchived,
|
||||
1
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
*/
|
||||
package org.isoron.uhabits.core.ui.screens.habits.show
|
||||
|
||||
import org.isoron.uhabits.core.commands.CommandRunner
|
||||
import org.isoron.uhabits.core.commands.ArchiveHabitsCommand
|
||||
import org.isoron.uhabits.core.commands.UnarchiveHabitsCommand
|
||||
import org.isoron.uhabits.core.commands.CommandRunner
|
||||
import org.isoron.uhabits.core.commands.DeleteHabitsCommand
|
||||
import org.isoron.uhabits.core.commands.UnarchiveHabitsCommand
|
||||
import org.isoron.uhabits.core.models.Entry
|
||||
import org.isoron.uhabits.core.models.Habit
|
||||
import org.isoron.uhabits.core.models.HabitList
|
||||
@@ -56,7 +56,8 @@ class ShowHabitMenuPresenter(
|
||||
}
|
||||
|
||||
fun onArchiveHabits() {
|
||||
commandRunner.run(ArchiveHabitsCommand(habitList,listOf(habit)))
|
||||
commandRunner.run(ArchiveHabitsCommand(habitList, listOf(habit)))
|
||||
screen.showMessage(Message.HABIT_ARCHIVED)
|
||||
}
|
||||
|
||||
fun onExportCSV() {
|
||||
@@ -80,7 +81,8 @@ class ShowHabitMenuPresenter(
|
||||
}
|
||||
|
||||
fun onUnarchiveHabits() {
|
||||
commandRunner.run(UnarchiveHabitsCommand(habitList,listOf(habit)))
|
||||
commandRunner.run(UnarchiveHabitsCommand(habitList, listOf(habit)))
|
||||
screen.showMessage(Message.HABIT_UNARCHIVED)
|
||||
}
|
||||
|
||||
fun onRandomize() {
|
||||
@@ -91,7 +93,10 @@ class ShowHabitMenuPresenter(
|
||||
if (i % 7 == 0) strength = max(0.0, min(100.0, strength + 10 * random.nextGaussian()))
|
||||
if (random.nextInt(100) > strength) continue
|
||||
var value = Entry.YES_MANUAL
|
||||
if (habit.isNumerical) value = (1000 + 250 * random.nextGaussian() * strength / 100).toInt() * 1000
|
||||
if (habit.isNumerical) {
|
||||
value =
|
||||
(1000 + 250 * random.nextGaussian() * strength / 100).toInt() * 1000
|
||||
}
|
||||
habit.originalEntries.add(Entry(DateUtils.getToday().minus(i), value))
|
||||
}
|
||||
habit.recompute()
|
||||
@@ -99,7 +104,9 @@ class ShowHabitMenuPresenter(
|
||||
}
|
||||
|
||||
enum class Message {
|
||||
COULD_NOT_EXPORT
|
||||
COULD_NOT_EXPORT,
|
||||
HABIT_ARCHIVED,
|
||||
HABIT_UNARCHIVED
|
||||
}
|
||||
|
||||
interface Screen {
|
||||
|
||||
Reference in New Issue
Block a user