forked from penguin86/luna-tracker
Compare commits
7 Commits
master
...
7ec5e48b12
| Author | SHA1 | Date | |
|---|---|---|---|
| 7ec5e48b12 | |||
| f2e0e26c11 | |||
| 9e4b767450 | |||
| 19c93e8aa9 | |||
| 16ffe671b9 | |||
| 471aac0ce2 | |||
| 14a3322ebc |
@@ -13,6 +13,7 @@ import android.view.ViewGroup
|
||||
import android.widget.AdapterView
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.EditText
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.NumberPicker
|
||||
import android.widget.PopupWindow
|
||||
import android.widget.Spinner
|
||||
@@ -210,7 +211,7 @@ class MainActivity : AppCompatActivity() {
|
||||
numberPicker.wrapSelectorWheel = false
|
||||
numberPicker.value = localSettings.loadBabyBottleContent()
|
||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
||||
logEvent(LunaEvent(LunaEvent.TYPE_BABY_BOTTLE, numberPicker.value * 10))
|
||||
logEvent(LunaEvent(LunaEvent.TYPE_BABY_BOTTLE, signature, numberPicker.value * 10))
|
||||
localSettings.saveBabyBottleContent(numberPicker.value)
|
||||
}
|
||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() }
|
||||
@@ -229,7 +230,7 @@ class MainActivity : AppCompatActivity() {
|
||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
||||
val weight = weightET.text.toString().toIntOrNull()
|
||||
if (weight != null)
|
||||
logEvent(LunaEvent(LunaEvent.TYPE_WEIGHT, weight))
|
||||
logEvent(LunaEvent(LunaEvent.TYPE_WEIGHT, signature, weight))
|
||||
else
|
||||
Toast.makeText(this, R.string.toast_integer_error, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
@@ -255,7 +256,7 @@ class MainActivity : AppCompatActivity() {
|
||||
tempSlider.addOnChangeListener({s, v, b -> tempTextView.text = v.toString()})
|
||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
||||
val temperature = (tempSlider.value * 10).toInt() // In tenth of a grade
|
||||
logEvent(LunaEvent(LunaEvent.TYPE_TEMPERATURE, temperature))
|
||||
logEvent(LunaEvent(LunaEvent.TYPE_TEMPERATURE, signature, temperature))
|
||||
}
|
||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() }
|
||||
val alertDialog = d.create()
|
||||
@@ -275,7 +276,7 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
||||
val pos = spinner.selectedItemPosition
|
||||
logEvent(LunaEvent(LunaEvent.TYPE_PUKE, pos))
|
||||
logEvent(LunaEvent(LunaEvent.TYPE_PUKE, signature, pos))
|
||||
}
|
||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() }
|
||||
val alertDialog = d.create()
|
||||
@@ -410,10 +411,11 @@ class MainActivity : AppCompatActivity() {
|
||||
})
|
||||
|
||||
// show optional signature
|
||||
if (event.signature.isNotEmpty()) {
|
||||
val signatureTextEdit = dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_signature)
|
||||
signatureTextEdit.text = String.format(getString(R.string.dialog_event_detail_signature), event.signature)
|
||||
signatureTextEdit.visibility = View.VISIBLE
|
||||
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_signature).text = event.signature
|
||||
dialogView.findViewById<LinearLayout>(R.id.dialog_event_signature_layout).visibility = if (event.signature.isNotEmpty()) {
|
||||
View.VISIBLE
|
||||
} else {
|
||||
View.GONE
|
||||
}
|
||||
|
||||
// create next/previous links to events of the same type
|
||||
@@ -665,8 +667,6 @@ class MainActivity : AppCompatActivity() {
|
||||
fun logEvent(event: LunaEvent) {
|
||||
savingEvent(true)
|
||||
|
||||
event.signature = signature
|
||||
|
||||
setLoading(true)
|
||||
logbook?.logs?.add(0, event)
|
||||
recyclerView.adapter?.notifyItemInserted(0)
|
||||
|
||||
@@ -75,10 +75,11 @@ class LunaEvent: Comparable<LunaEvent> {
|
||||
this.type = type
|
||||
}
|
||||
|
||||
constructor(type: String, quantity: Int) {
|
||||
constructor(type: String, signature: String, quantity: Int) {
|
||||
this.jo = JSONObject()
|
||||
this.time = System.currentTimeMillis() / 1000
|
||||
this.type = type
|
||||
this.signature = signature
|
||||
this.quantity = quantity
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package utils
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.text.format.DateFormat
|
||||
import it.danieleverducci.lunatracker.R
|
||||
import java.util.Date
|
||||
|
||||
|
||||
class DateUtils {
|
||||
companion object {
|
||||
/**
|
||||
@@ -108,19 +108,15 @@ class DateUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Format time as localized string without seconds. E.g. "Sept 18, 2025, 03:36 PM".
|
||||
* Format time as localized string without seconds. E.g. "28 Sept 03:36:00".
|
||||
* The seconds are set to 0 since they are distracting and not relevant.
|
||||
* Used in the event detail dialog.
|
||||
*/
|
||||
fun formatDateTime(unixTime: Long): String {
|
||||
val date = Date(unixTime * 1000)
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
val dateFormat = android.icu.text.DateFormat.getDateTimeInstance(android.icu.text.DateFormat.DEFAULT, android.icu.text.DateFormat.SHORT)
|
||||
return dateFormat.format(date)
|
||||
} else {
|
||||
// fallback
|
||||
val roundedUnixTime = unixTime - (unixTime % 60)
|
||||
val date = Date(roundedUnixTime * 1000)
|
||||
val dateFormat = java.text.DateFormat.getDateTimeInstance()
|
||||
return dateFormat.format(date)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,7 +130,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:inputType="textEmailAddress"
|
||||
android:background="@drawable/textview_background"/>
|
||||
|
||||
|
||||
@@ -4,9 +4,7 @@
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingHorizontal="20dp">
|
||||
android:padding="20dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialog_event_detail_type_emoji"
|
||||
@@ -63,14 +61,6 @@
|
||||
|
||||
</ScrollView>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:id="@+id/dialog_event_detail_type_signature"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
@@ -99,4 +89,25 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dialog_event_signature_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:text="@string/dialog_event_detail_signature"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/dialog_event_detail_type_signature"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:text="" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -50,8 +50,9 @@
|
||||
<string name="no_connection_go_to_settings">Einstellungen</string>
|
||||
<string name="no_connection_retry">Erneut versuchen</string>
|
||||
|
||||
<string name="no_breastfeeding">Kein Stillen</string>
|
||||
|
||||
<string name="settings_title">Einstellungen</string>
|
||||
<string name="settings_no_breastfeeding">Kein Stillen</string>
|
||||
<string name="settings_storage">Speicherort für Daten auswählen</string>
|
||||
<string name="settings_storage_local">Auf dem Gerät</string>
|
||||
<string name="settings_storage_local_desc">Datenschutzfreundlichste Lösung: Deine Daten verlassen dein Gerät nicht</string>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="AmountLabels">
|
||||
<item>@string/amount_little</item>
|
||||
<item>@string/amount_low</item>
|
||||
<item>@string/amount_normal</item>
|
||||
<item>@string/amount_plenty</item>
|
||||
<item>@string/amount_high</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -75,9 +75,9 @@
|
||||
<string name="year_ago">year</string>
|
||||
<string name="years_ago">years</string>
|
||||
|
||||
<string name="amount_little">Little</string>
|
||||
<string name="amount_low">Low</string>
|
||||
<string name="amount_normal">Normal</string>
|
||||
<string name="amount_plenty">Plenty</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>
|
||||
@@ -86,7 +86,7 @@
|
||||
|
||||
<string name="settings_title">Settings</string>
|
||||
<string name="settings_signature">Signature</string>
|
||||
<string name="settings_signature_desc">Attach a signature to each event you create and for others to see. Useful if multiple people add events.</string>
|
||||
<string name="settings_signature_desc">Attach a signature to each event your create and for others to see. Useful if multiple people add events.</string>
|
||||
<string name="settings_storage">Choose where to save data</string>
|
||||
<string name="settings_storage_local">On device</string>
|
||||
<string name="settings_storage_local_desc">Most privacy-friendly solution: data doesn\'t leave your device</string>
|
||||
@@ -138,7 +138,7 @@
|
||||
<string name="dialog_event_detail_delete_button">Delete</string>
|
||||
<string name="dialog_event_detail_quantity">Quantity</string>
|
||||
<string name="dialog_event_detail_notes">Notes</string>
|
||||
<string name="dialog_event_detail_signature">by %s</string>
|
||||
<string name="dialog_event_detail_signature">Created By</string>
|
||||
|
||||
<string name="dialog_add_logbook_title">Add logbook</string>
|
||||
<string name="dialog_add_logbook_logbookname">👶 Logbook name</string>
|
||||
|
||||
Reference in New Issue
Block a user