Add configurable buttons, separate settings screens and backup activity
- Add ButtonConfigActivity for customizing main screen buttons with drag-and-drop reordering and individual size options (S/M/L) - Move storage settings to separate StorageSettingsActivity - Move signature setting to storage settings (relevant for WebDAV sync) - Move data backup to separate BackupActivity with export/import - Make "more" overflow button configurable in size - Simplify SettingsActivity to 3 navigation buttons - Add logbook rename/delete functionality - Improve S/M/L button contrast with visible borders
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
package it.danieleverducci.lunatracker.entities
|
||||
|
||||
import it.danieleverducci.lunatracker.R
|
||||
import it.danieleverducci.lunatracker.repository.ButtonConfigRepository
|
||||
|
||||
/**
|
||||
* Represents a button configuration for the main screen.
|
||||
* Users can configure which buttons are visible, in what order, and at what size.
|
||||
*/
|
||||
data class ButtonConfig(
|
||||
val id: String, // Button identifier (matches LunaEvent.TYPE_*)
|
||||
val iconResId: Int, // R.string.event_*_type (emoji)
|
||||
val labelResId: Int, // R.string.event_*_desc (description)
|
||||
var visible: Boolean, // Show on main screen?
|
||||
var order: Int, // Display order (0 = first)
|
||||
var size: Int = ButtonConfigRepository.SIZE_MEDIUM // Button size (S/M/L)
|
||||
) {
|
||||
companion object {
|
||||
// Button IDs matching LunaEvent types
|
||||
const val ID_BOTTLE = "bottle"
|
||||
const val ID_BREASTFEEDING_LEFT = "breastfeeding_left"
|
||||
const val ID_BREASTFEEDING_BOTH = "breastfeeding_both"
|
||||
const val ID_BREASTFEEDING_RIGHT = "breastfeeding_right"
|
||||
const val ID_FOOD = "food"
|
||||
const val ID_DIAPER_POO = "diaper_poo"
|
||||
const val ID_DIAPER_PEE = "diaper_pee"
|
||||
const val ID_SLEEP = "sleep"
|
||||
const val ID_MEDICINE = "medicine"
|
||||
const val ID_TEMPERATURE = "temperature"
|
||||
const val ID_NOTE = "note"
|
||||
const val ID_PUKE = "puke"
|
||||
const val ID_COLIC = "colic"
|
||||
const val ID_WEIGHT = "weight"
|
||||
const val ID_BATH = "bath"
|
||||
const val ID_ENEMA = "enema"
|
||||
const val ID_MORE = "more"
|
||||
|
||||
/**
|
||||
* Returns the default button configuration.
|
||||
* First 7 buttons are visible by default, rest are hidden.
|
||||
*/
|
||||
fun getDefaultConfigs(): List<ButtonConfig> {
|
||||
return listOf(
|
||||
ButtonConfig(ID_BOTTLE, R.string.event_bottle_type, R.string.event_bottle_desc, true, 0),
|
||||
ButtonConfig(ID_BREASTFEEDING_LEFT, R.string.event_breastfeeding_left_type, R.string.event_breastfeeding_left_desc, true, 1),
|
||||
ButtonConfig(ID_BREASTFEEDING_BOTH, R.string.event_breastfeeding_both_type, R.string.event_breastfeeding_both_desc, true, 2),
|
||||
ButtonConfig(ID_BREASTFEEDING_RIGHT, R.string.event_breastfeeding_right_type, R.string.event_breastfeeding_right_desc, true, 3),
|
||||
ButtonConfig(ID_FOOD, R.string.event_food_type, R.string.event_food_desc, true, 4),
|
||||
ButtonConfig(ID_DIAPER_POO, R.string.event_diaperchange_poo_type, R.string.event_diaperchange_poo_desc, true, 5),
|
||||
ButtonConfig(ID_DIAPER_PEE, R.string.event_diaperchange_pee_type, R.string.event_diaperchange_pee_desc, true, 6),
|
||||
ButtonConfig(ID_SLEEP, R.string.event_sleep_type, R.string.event_sleep_desc, false, 7),
|
||||
ButtonConfig(ID_MEDICINE, R.string.event_medicine_type, R.string.event_medicine_desc, false, 8),
|
||||
ButtonConfig(ID_TEMPERATURE, R.string.event_temperature_type, R.string.event_temperature_desc, false, 9),
|
||||
ButtonConfig(ID_NOTE, R.string.event_note_type, R.string.event_note_desc, false, 10),
|
||||
ButtonConfig(ID_PUKE, R.string.event_puke_type, R.string.event_puke_desc, false, 11),
|
||||
ButtonConfig(ID_COLIC, R.string.event_colic_type, R.string.event_colic_desc, false, 12),
|
||||
ButtonConfig(ID_WEIGHT, R.string.event_scale_type, R.string.event_scale_desc, false, 13),
|
||||
ButtonConfig(ID_BATH, R.string.event_bath_type, R.string.event_bath_desc, false, 14),
|
||||
ButtonConfig(ID_ENEMA, R.string.event_enema_type, R.string.event_enema_desc, false, 15),
|
||||
// More button - always last, visibility controlled dynamically
|
||||
ButtonConfig(ID_MORE, R.string.event_more_type, R.string.event_more_desc, false, 16)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps button ID to LunaEvent type constant.
|
||||
*/
|
||||
fun getEventType(buttonId: String): String {
|
||||
return when (buttonId) {
|
||||
ID_BOTTLE -> LunaEvent.TYPE_BABY_BOTTLE
|
||||
ID_BREASTFEEDING_LEFT -> LunaEvent.TYPE_BREASTFEEDING_LEFT_NIPPLE
|
||||
ID_BREASTFEEDING_BOTH -> LunaEvent.TYPE_BREASTFEEDING_BOTH_NIPPLE
|
||||
ID_BREASTFEEDING_RIGHT -> LunaEvent.TYPE_BREASTFEEDING_RIGHT_NIPPLE
|
||||
ID_FOOD -> LunaEvent.TYPE_FOOD
|
||||
ID_DIAPER_POO -> LunaEvent.TYPE_DIAPERCHANGE_POO
|
||||
ID_DIAPER_PEE -> LunaEvent.TYPE_DIAPERCHANGE_PEE
|
||||
ID_SLEEP -> LunaEvent.TYPE_SLEEP
|
||||
ID_MEDICINE -> LunaEvent.TYPE_MEDICINE
|
||||
ID_TEMPERATURE -> LunaEvent.TYPE_TEMPERATURE
|
||||
ID_NOTE -> LunaEvent.TYPE_NOTE
|
||||
ID_PUKE -> LunaEvent.TYPE_PUKE
|
||||
ID_COLIC -> LunaEvent.TYPE_COLIC
|
||||
ID_WEIGHT -> LunaEvent.TYPE_WEIGHT
|
||||
ID_BATH -> LunaEvent.TYPE_BATH
|
||||
ID_ENEMA -> LunaEvent.TYPE_ENEMA
|
||||
else -> throw IllegalArgumentException("Unknown button ID: $buttonId")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user