Skip to content

Commit

Permalink
HistoryCard toast location
Browse files Browse the repository at this point in the history
  • Loading branch information
Dharanish committed Jun 25, 2024
1 parent e553eee commit 9e969ba
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ package org.isoron.uhabits.activities.common.dialogs
import android.app.Dialog
import android.content.DialogInterface
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatDialogFragment
import org.isoron.platform.gui.AndroidDataView
import org.isoron.platform.time.JavaLocalDateFormatter
import org.isoron.uhabits.HabitsApplication
import org.isoron.uhabits.R
import org.isoron.uhabits.activities.AndroidThemeSwitcher
import org.isoron.uhabits.core.commands.BlockSkippedDayCommand
import org.isoron.uhabits.core.commands.Command
import org.isoron.uhabits.core.commands.CommandRunner
import org.isoron.uhabits.core.models.Habit
Expand All @@ -36,6 +38,7 @@ import org.isoron.uhabits.core.ui.views.HistoryChart
import org.isoron.uhabits.core.ui.views.LightTheme
import org.isoron.uhabits.core.ui.views.OnDateClickedListener
import org.isoron.uhabits.core.utils.DateUtils
import org.isoron.uhabits.utils.showMessage
import java.util.Locale
import kotlin.math.min

Expand Down Expand Up @@ -119,9 +122,20 @@ class HistoryEditorDialog : AppCompatDialogFragment(), CommandRunner.Listener {
}

override fun onCommandFinished(command: Command) {
val msg = getExecuteString(command)
if (msg != null) (dataView as View).showMessage(msg)
refreshData()
}

private fun getExecuteString(command: Command): String? {
return when (command) {
is BlockSkippedDayCommand -> {
getString(R.string.toast_day_auto_skip)
}
else -> null
}
}

companion object {
// HistoryEditorDialog handles multiple dialogs on its own,
// because sometimes we want it to be shown under another dialog (e.g. NumberPopup)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import org.isoron.uhabits.activities.common.dialogs.CheckmarkDialog
import org.isoron.uhabits.activities.common.dialogs.ConfirmDeleteDialog
import org.isoron.uhabits.activities.common.dialogs.HistoryEditorDialog
import org.isoron.uhabits.activities.common.dialogs.NumberDialog
import org.isoron.uhabits.core.commands.BlockSkippedDayCommand
import org.isoron.uhabits.core.commands.Command
import org.isoron.uhabits.core.commands.CommandRunner
import org.isoron.uhabits.core.models.Habit
Expand Down Expand Up @@ -140,20 +139,9 @@ class ShowHabitActivity : AppCompatActivity(), CommandRunner.Listener {
}

override fun onCommandFinished(command: Command) {
val msg = getExecuteString(command)
if (msg != null) activity.showMessage(msg)
screen.refresh()
}

private fun getExecuteString(command: Command): String? {
return when (command) {
is BlockSkippedDayCommand -> {
getString(R.string.toast_day_auto_skip)
}
else -> null
}
}

inner class Screen : ShowHabitMenuPresenter.Screen, ShowHabitPresenter.Screen {
override fun updateWidgets() {
widgetUpdater.updateWidgets()
Expand Down

0 comments on commit 9e969ba

Please sign in to comment.