From 596fa67272d8a34dbb9129f96f75789d39b4949e Mon Sep 17 00:00:00 2001 From: Daniele Verducci Date: Sat, 2 Nov 2024 18:31:53 +0100 Subject: [PATCH] WIP --- .idea/.gitignore | 3 + .idea/compiler.xml | 6 ++ .idea/inspectionProfiles/Project_Default.xml | 57 +++++++++++++++++++ .idea/kotlinc.xml | 6 ++ .idea/migrations.xml | 10 ++++ .idea/runConfigurations.xml | 17 ++++++ .../lunatracker/MainActivity.kt | 51 ++++++++++------- .../lunatracker/{ => entities}/LunaEvent.kt | 6 +- 8 files changed, 135 insertions(+), 21 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/kotlinc.xml create mode 100644 .idea/migrations.xml create mode 100644 .idea/runConfigurations.xml rename app/src/main/java/it/danieleverducci/lunatracker/{ => entities}/LunaEvent.kt (70%) diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..b86273d --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..cde3e19 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,57 @@ + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..6d0ee1c --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..16660f1 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,17 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/java/it/danieleverducci/lunatracker/MainActivity.kt b/app/src/main/java/it/danieleverducci/lunatracker/MainActivity.kt index 8ac8ee9..c6af54e 100644 --- a/app/src/main/java/it/danieleverducci/lunatracker/MainActivity.kt +++ b/app/src/main/java/it/danieleverducci/lunatracker/MainActivity.kt @@ -4,19 +4,10 @@ import android.os.Bundle import android.util.Log import android.view.View import android.widget.NumberPicker -import androidx.activity.ComponentActivity -import androidx.activity.compose.setContent -import androidx.activity.enableEdgeToEdge import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.padding -import androidx.compose.material3.Scaffold -import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.tooling.preview.Preview -import it.danieleverducci.lunatracker.ui.theme.LunaTrackerTheme +import it.danieleverducci.lunatracker.entities.LunaEvent +import it.danieleverducci.lunatracker.entities.LunaEventType class MainActivity : AppCompatActivity() { companion object { @@ -29,11 +20,31 @@ class MainActivity : AppCompatActivity() { setContentView(R.layout.activity_main) findViewById(R.id.button_bottle).setOnClickListener { askBabyBottleContent() } - findViewById(R.id.button_nipple_left).setOnClickListener { logEvent(LunaEvent(LunaEventType.BREASTFEEDING_LEFT_NIPPLE)) } - findViewById(R.id.button_nipple_both).setOnClickListener { logEvent(LunaEvent(LunaEventType.BREASTFEEDING_BOTH_NIPPLE)) } - findViewById(R.id.button_nipple_right).setOnClickListener { logEvent(LunaEvent(LunaEventType.BREASTFEEDING_RIGHT_NIPPLE)) } - findViewById(R.id.button_change_poo).setOnClickListener { logEvent(LunaEvent(LunaEventType.DIAPERCHANGE_POO)) } - findViewById(R.id.button_change_pee).setOnClickListener { logEvent(LunaEvent(LunaEventType.DIAPERCHANGE_PEE)) } + findViewById(R.id.button_nipple_left).setOnClickListener { logEvent( + LunaEvent( + LunaEventType.BREASTFEEDING_LEFT_NIPPLE + ) + ) } + findViewById(R.id.button_nipple_both).setOnClickListener { logEvent( + LunaEvent( + LunaEventType.BREASTFEEDING_BOTH_NIPPLE + ) + ) } + findViewById(R.id.button_nipple_right).setOnClickListener { logEvent( + LunaEvent( + LunaEventType.BREASTFEEDING_RIGHT_NIPPLE + ) + ) } + findViewById(R.id.button_change_poo).setOnClickListener { logEvent( + LunaEvent( + LunaEventType.DIAPERCHANGE_POO + ) + ) } + findViewById(R.id.button_change_pee).setOnClickListener { logEvent( + LunaEvent( + LunaEventType.DIAPERCHANGE_PEE + ) + ) } } fun askBabyBottleContent() { @@ -44,12 +55,12 @@ class MainActivity : AppCompatActivity() { d.setMessage(R.string.log_bottle_dialog_description) d.setView(dialogView) val numberPicker = dialogView.findViewById(R.id.dialog_number_picker) - numberPicker.minValue = 10 - numberPicker.maxValue = 250 - numberPicker.displayedValues = ((numberPicker.minValue..numberPicker.maxValue step 10).map { it.toString() }.toTypedArray()) + numberPicker.minValue = 1 // "10" + numberPicker.maxValue = 25 // "250 + numberPicker.displayedValues = ((10..250 step 10).map { it.toString() }.toTypedArray()) numberPicker.wrapSelectorWheel = false d.setPositiveButton(android.R.string.ok) { dialogInterface, i -> - logEvent(LunaEvent(LunaEventType.BABY_BOTTLE, numberPicker.value)) + logEvent(LunaEvent(LunaEventType.BABY_BOTTLE, numberPicker.value * 10)) } d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() } val alertDialog = d.create() diff --git a/app/src/main/java/it/danieleverducci/lunatracker/LunaEvent.kt b/app/src/main/java/it/danieleverducci/lunatracker/entities/LunaEvent.kt similarity index 70% rename from app/src/main/java/it/danieleverducci/lunatracker/LunaEvent.kt rename to app/src/main/java/it/danieleverducci/lunatracker/entities/LunaEvent.kt index 0883a27..aa852ff 100644 --- a/app/src/main/java/it/danieleverducci/lunatracker/LunaEvent.kt +++ b/app/src/main/java/it/danieleverducci/lunatracker/entities/LunaEvent.kt @@ -1,4 +1,4 @@ -package it.danieleverducci.lunatracker +package it.danieleverducci.lunatracker.entities import java.util.Date @@ -11,6 +11,10 @@ class LunaEvent( init { time = System.currentTimeMillis() / 1000 } + + override fun toString(): String { + return "${type.toString()} qty: $quantity time: ${Date(time * 1000)}" + } } enum class LunaEventType {