mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
CheckmarkDialog: Format date using current locale
This commit is contained in:
@@ -8,6 +8,8 @@ import android.view.WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
|
||||
import android.widget.Button
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import org.isoron.platform.gui.toInt
|
||||
import org.isoron.platform.time.JavaLocalDateFormatter
|
||||
import org.isoron.platform.time.LocalDate
|
||||
import org.isoron.uhabits.R
|
||||
import org.isoron.uhabits.core.models.Entry.Companion.NO
|
||||
import org.isoron.uhabits.core.models.Entry.Companion.SKIP
|
||||
@@ -22,6 +24,7 @@ import org.isoron.uhabits.databinding.CheckmarkDialogBinding
|
||||
import org.isoron.uhabits.inject.ActivityContext
|
||||
import org.isoron.uhabits.utils.InterfaceUtils
|
||||
import org.isoron.uhabits.utils.StyledResources
|
||||
import java.util.Locale
|
||||
import javax.inject.Inject
|
||||
|
||||
class CheckmarkDialog
|
||||
@@ -36,9 +39,9 @@ class CheckmarkDialog
|
||||
private var selectedButton: Button? = null
|
||||
|
||||
fun create(
|
||||
value: Int,
|
||||
selectedValue: Int,
|
||||
notes: String,
|
||||
dateString: String,
|
||||
date: LocalDate,
|
||||
paletteColor: PaletteColor,
|
||||
callback: ListHabitsBehavior.CheckMarkDialogCallback,
|
||||
theme: Theme,
|
||||
@@ -46,11 +49,11 @@ class CheckmarkDialog
|
||||
binding = CheckmarkDialogBinding.inflate(LayoutInflater.from(context))
|
||||
fontAwesome = InterfaceUtils.getFontAwesome(context)!!
|
||||
binding.etNotes.append(notes)
|
||||
setUpButtons(value, theme.color(paletteColor).toInt())
|
||||
setUpButtons(selectedValue, theme.color(paletteColor).toInt())
|
||||
|
||||
val dialog = AlertDialog.Builder(context)
|
||||
.setView(binding.root)
|
||||
.setTitle(dateString)
|
||||
.setTitle(JavaLocalDateFormatter(Locale.getDefault()).longFormat(date))
|
||||
.setPositiveButton(R.string.save) { _, _ ->
|
||||
val newValue = when (selectedButton?.id) {
|
||||
R.id.yesBtn -> YES_MANUAL
|
||||
|
||||
@@ -24,6 +24,7 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import dagger.Lazy
|
||||
import org.isoron.platform.time.LocalDate
|
||||
import org.isoron.uhabits.R
|
||||
import org.isoron.uhabits.activities.common.dialogs.CheckmarkDialog
|
||||
import org.isoron.uhabits.activities.common.dialogs.ColorPickerDialogFactory
|
||||
@@ -235,16 +236,17 @@ class ListHabitsScreen
|
||||
}
|
||||
|
||||
override fun showCheckmarkDialog(
|
||||
value: Int,
|
||||
selectedValue: Int,
|
||||
notes: String,
|
||||
date: LocalDate,
|
||||
dateString: String,
|
||||
color: PaletteColor,
|
||||
callback: ListHabitsBehavior.CheckMarkDialogCallback
|
||||
) {
|
||||
checkMarkDialog.create(
|
||||
value,
|
||||
selectedValue,
|
||||
notes,
|
||||
dateString,
|
||||
date,
|
||||
color,
|
||||
callback,
|
||||
themeSwitcher.currentTheme!!,
|
||||
|
||||
@@ -27,6 +27,7 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import org.isoron.platform.time.LocalDate
|
||||
import org.isoron.uhabits.AndroidDirFinder
|
||||
import org.isoron.uhabits.HabitsApplication
|
||||
import org.isoron.uhabits.R
|
||||
@@ -174,17 +175,17 @@ class ShowHabitActivity : AppCompatActivity(), CommandRunner.Listener {
|
||||
}
|
||||
|
||||
override fun showCheckmarkDialog(
|
||||
value: Int,
|
||||
selectedValue: Int,
|
||||
notes: String,
|
||||
dateString: String,
|
||||
date: LocalDate,
|
||||
preferences: Preferences,
|
||||
color: PaletteColor,
|
||||
callback: ListHabitsBehavior.CheckMarkDialogCallback
|
||||
) {
|
||||
CheckmarkDialog(this@ShowHabitActivity, preferences).create(
|
||||
value,
|
||||
selectedValue,
|
||||
notes,
|
||||
dateString,
|
||||
date,
|
||||
color,
|
||||
callback,
|
||||
themeSwitcher.currentTheme!!,
|
||||
|
||||
Reference in New Issue
Block a user