Compare commits
7 Commits
d204b877f5
...
7ec5e48b12
Author | SHA1 | Date | |
---|---|---|---|
7ec5e48b12 | |||
f2e0e26c11 | |||
9e4b767450 | |||
19c93e8aa9 | |||
16ffe671b9 | |||
471aac0ce2 | |||
14a3322ebc |
@@ -263,6 +263,26 @@ class MainActivity : AppCompatActivity() {
|
||||
alertDialog.show()
|
||||
}
|
||||
|
||||
fun askPukeValue() {
|
||||
val d = AlertDialog.Builder(this)
|
||||
val dialogView = layoutInflater.inflate(R.layout.puke_dialog, null)
|
||||
d.setTitle(R.string.log_puke_dialog_title)
|
||||
d.setMessage(R.string.log_puke_dialog_description)
|
||||
d.setView(dialogView)
|
||||
|
||||
val spinner = dialogView.findViewById<Spinner>(R.id.dialog_puke_value)
|
||||
spinner.adapter = ArrayAdapter.createFromResource(this, R.array.AmountLabels, android.R.layout.simple_spinner_dropdown_item)
|
||||
spinner.setSelection(1)
|
||||
|
||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
||||
val pos = spinner.selectedItemPosition
|
||||
logEvent(LunaEvent(LunaEvent.TYPE_PUKE, signature, pos))
|
||||
}
|
||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() }
|
||||
val alertDialog = d.create()
|
||||
alertDialog.show()
|
||||
}
|
||||
|
||||
fun askNotes(lunaEvent: LunaEvent) {
|
||||
val d = AlertDialog.Builder(this)
|
||||
val dialogView = layoutInflater.inflate(R.layout.dialog_notes, null)
|
||||
@@ -781,15 +801,15 @@ class MainActivity : AppCompatActivity() {
|
||||
val inflater = LayoutInflater.from(anchor.context)
|
||||
contentView = inflater.inflate(R.layout.more_events_popup, null)
|
||||
contentView.findViewById<View>(R.id.button_medicine).setOnClickListener {
|
||||
askNotes(LunaEvent(LunaEvent.TYPE_MEDICINE, signature))
|
||||
askNotes(LunaEvent(LunaEvent.TYPE_MEDICINE))
|
||||
dismiss()
|
||||
}
|
||||
contentView.findViewById<View>(R.id.button_enema).setOnClickListener({
|
||||
logEvent(LunaEvent(LunaEvent.TYPE_ENEMA, signature))
|
||||
logEvent(LunaEvent(LunaEvent.TYPE_ENEMA))
|
||||
dismiss()
|
||||
})
|
||||
contentView.findViewById<View>(R.id.button_note).setOnClickListener({
|
||||
askNotes(LunaEvent(LunaEvent.TYPE_NOTE, signature))
|
||||
askNotes(LunaEvent(LunaEvent.TYPE_NOTE))
|
||||
dismiss()
|
||||
})
|
||||
contentView.findViewById<View>(R.id.button_temperature).setOnClickListener({
|
||||
@@ -797,14 +817,12 @@ class MainActivity : AppCompatActivity() {
|
||||
dismiss()
|
||||
})
|
||||
contentView.findViewById<View>(R.id.button_puke).setOnClickListener({
|
||||
logEvent(
|
||||
LunaEvent(LunaEvent.TYPE_PUKE, signature)
|
||||
)
|
||||
askPukeValue()
|
||||
dismiss()
|
||||
})
|
||||
contentView.findViewById<View>(R.id.button_colic).setOnClickListener({
|
||||
logEvent(
|
||||
LunaEvent(LunaEvent.TYPE_COLIC, signature)
|
||||
LunaEvent(LunaEvent.TYPE_COLIC)
|
||||
)
|
||||
dismiss()
|
||||
})
|
||||
@@ -814,7 +832,7 @@ class MainActivity : AppCompatActivity() {
|
||||
})
|
||||
contentView.findViewById<View>(R.id.button_bath).setOnClickListener({
|
||||
logEvent(
|
||||
LunaEvent(LunaEvent.TYPE_BATH, signature)
|
||||
LunaEvent(LunaEvent.TYPE_BATH)
|
||||
)
|
||||
dismiss()
|
||||
})
|
||||
|
@@ -69,10 +69,9 @@ class LunaEvent: Comparable<LunaEvent> {
|
||||
throw IllegalArgumentException("JSONObject is not a LunaEvent")
|
||||
}
|
||||
|
||||
constructor(type: String, signature: String) {
|
||||
constructor(type: String) {
|
||||
this.jo = JSONObject()
|
||||
this.time = System.currentTimeMillis() / 1000
|
||||
this.signature = signature
|
||||
this.type = type
|
||||
}
|
||||
|
||||
|
@@ -66,6 +66,8 @@ class NumericUtils (val context: Context) {
|
||||
formatted.append(when (item.type) {
|
||||
LunaEvent.TYPE_TEMPERATURE ->
|
||||
(item.quantity / 10.0f).toString()
|
||||
LunaEvent.TYPE_PUKE ->
|
||||
context.resources.getStringArray(R.array.AmountLabels)[item.quantity]
|
||||
else ->
|
||||
item.quantity
|
||||
})
|
||||
|
17
app/src/main/res/layout/puke_dialog.xml
Normal file
17
app/src/main/res/layout/puke_dialog.xml
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/dialog_puke_value"
|
||||
android:layout_width="250dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="8dp"/>
|
||||
|
||||
</LinearLayout>
|
8
app/src/main/res/values/arrays.xml
Normal file
8
app/src/main/res/values/arrays.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="AmountLabels">
|
||||
<item>@string/amount_low</item>
|
||||
<item>@string/amount_normal</item>
|
||||
<item>@string/amount_high</item>
|
||||
</string-array>
|
||||
</resources>
|
@@ -12,6 +12,9 @@
|
||||
<string name="log_temperature_dialog_title">Temperature</string>
|
||||
<string name="log_temperature_dialog_description">Insert the temperature</string>
|
||||
|
||||
<string name="log_puke_dialog_title">Puke</string>
|
||||
<string name="log_puke_dialog_description">Select the amount</string>
|
||||
|
||||
<string name="event_bottle_type" translatable="false">🍼</string>
|
||||
<string name="event_food_type" translatable="false">🥣</string>
|
||||
<string name="event_scale_type" translatable="false">⚖️</string>
|
||||
@@ -72,6 +75,10 @@
|
||||
<string name="year_ago">year</string>
|
||||
<string name="years_ago">years</string>
|
||||
|
||||
<string name="amount_low">Low</string>
|
||||
<string name="amount_normal">Normal</string>
|
||||
<string name="amount_high">High</string>
|
||||
|
||||
<string name="no_connection">No connection</string>
|
||||
<string name="no_connection_explain">Unable to reach WebDAV service</string>
|
||||
<string name="no_connection_go_to_settings">Settings</string>
|
||||
|
Reference in New Issue
Block a user