Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
9fddd37fe9 |
@ -1,5 +1,7 @@
|
|||||||
package it.danieleverducci.lunatracker
|
package it.danieleverducci.lunatracker
|
||||||
|
|
||||||
|
import android.app.DatePickerDialog
|
||||||
|
import android.app.TimePickerDialog
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@ -40,6 +42,7 @@ import okio.IOException
|
|||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
import utils.NumericUtils
|
import utils.NumericUtils
|
||||||
import java.text.DateFormat
|
import java.text.DateFormat
|
||||||
|
import java.util.Calendar
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity() {
|
||||||
@ -311,13 +314,40 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val dialogView = layoutInflater.inflate(R.layout.dialog_event_detail, null)
|
val dialogView = layoutInflater.inflate(R.layout.dialog_event_detail, null)
|
||||||
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_emoji).setText(event.getTypeEmoji(this))
|
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_emoji).setText(event.getTypeEmoji(this))
|
||||||
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_description).setText(event.getTypeDescription(this))
|
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_description).setText(event.getTypeDescription(this))
|
||||||
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_date).setText(dateFormat.format(Date(event.time * 1000)))
|
|
||||||
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_quantity).setText(
|
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_quantity).setText(
|
||||||
NumericUtils(this).formatEventQuantity(event)
|
NumericUtils(this).formatEventQuantity(event)
|
||||||
)
|
)
|
||||||
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_notes).setText(event.notes)
|
dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_notes).setText(event.notes)
|
||||||
|
|
||||||
|
val currentDateTime = Calendar.getInstance()
|
||||||
|
currentDateTime.time = Date(event.time * 1000)
|
||||||
|
val dateTextView = dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_date)
|
||||||
|
dateTextView.text = String.format(getString(R.string.dialog_event_detail_datetime_icon), dateFormat.format(currentDateTime.time))
|
||||||
|
dateTextView.setOnClickListener({
|
||||||
|
// Show datetime picker
|
||||||
|
val startYear = currentDateTime.get(Calendar.YEAR)
|
||||||
|
val startMonth = currentDateTime.get(Calendar.MONTH)
|
||||||
|
val startDay = currentDateTime.get(Calendar.DAY_OF_MONTH)
|
||||||
|
val startHour = currentDateTime.get(Calendar.HOUR_OF_DAY)
|
||||||
|
val startMinute = currentDateTime.get(Calendar.MINUTE)
|
||||||
|
|
||||||
|
DatePickerDialog(this, DatePickerDialog.OnDateSetListener { _, year, month, day ->
|
||||||
|
TimePickerDialog(this, TimePickerDialog.OnTimeSetListener { _, hour, minute ->
|
||||||
|
val pickedDateTime = Calendar.getInstance()
|
||||||
|
pickedDateTime.set(year, month, day, hour, minute)
|
||||||
|
currentDateTime.time = pickedDateTime.time
|
||||||
|
}, startHour, startMinute, false).show()
|
||||||
|
}, startYear, startMonth, startDay).show()
|
||||||
|
})
|
||||||
|
|
||||||
d.setView(dialogView)
|
d.setView(dialogView)
|
||||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i -> dialogInterface.dismiss() }
|
d.setPositiveButton(R.string.dialog_event_detail_save_button) { dialogInterface, i -> {
|
||||||
|
// Save event
|
||||||
|
event.time = currentDateTime.time.time / 1000 // Seconds since epoch
|
||||||
|
// TODO: move event at the correct logbook position
|
||||||
|
saveLogbook()
|
||||||
|
} }
|
||||||
|
d.setNegativeButton(R.string.dialog_event_detail_cancel_button) { dialogInterface, i -> dialogInterface.dismiss() }
|
||||||
d.setNeutralButton(R.string.dialog_event_detail_delete_button) { dialogInterface, i -> deleteEvent(event) }
|
d.setNeutralButton(R.string.dialog_event_detail_delete_button) { dialogInterface, i -> deleteEvent(event) }
|
||||||
val alertDialog = d.create()
|
val alertDialog = d.create()
|
||||||
alertDialog.show()
|
alertDialog.show()
|
||||||
|
5
app/src/main/res/drawable/ic_edit.xml
Normal file
5
app/src/main/res/drawable/ic_edit.xml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||||
|
|
||||||
|
<path android:fillColor="@android:color/white" android:pathData="M3,17.25V21h3.75L17.81,9.94l-3.75,-3.75L3,17.25zM20.71,7.04c0.39,-0.39 0.39,-1.02 0,-1.41l-2.34,-2.34c-0.39,-0.39 -1.02,-0.39 -1.41,0l-1.83,1.83 3.75,3.75 1.83,-1.83z"/>
|
||||||
|
|
||||||
|
</vector>
|
@ -25,19 +25,23 @@
|
|||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/dialog_event_detail_type_date"
|
android:id="@+id/dialog_event_detail_type_date"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="40dp"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
android:gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:drawableEnd="@drawable/ic_edit"
|
||||||
|
android:drawablePadding="10dp"
|
||||||
|
android:drawableTint="@color/accent"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:text="2020"/>
|
android:text="@string/dialog_event_detail_datetime_icon"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/dialog_event_detail_type_quantity"
|
android:id="@+id/dialog_event_detail_type_quantity"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:gravity="center_horizontal"
|
android:gravity="center_horizontal"
|
||||||
android:text="2020"/>
|
android:text="Quantity"/>
|
||||||
|
|
||||||
<ScrollView
|
<ScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@ -49,7 +53,7 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textStyle="italic"
|
android:textStyle="italic"
|
||||||
android:text="Lorem ipsum"/>
|
android:text="Notes"/>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
@ -82,6 +82,7 @@
|
|||||||
|
|
||||||
<string name="dialog_event_detail_title">Dettaglio evento</string>
|
<string name="dialog_event_detail_title">Dettaglio evento</string>
|
||||||
<string name="dialog_event_detail_save_button">Salva</string>
|
<string name="dialog_event_detail_save_button">Salva</string>
|
||||||
|
<string name="dialog_event_detail_cancel_button">Annulla</string>
|
||||||
<string name="dialog_event_detail_delete_button">Elimina</string>
|
<string name="dialog_event_detail_delete_button">Elimina</string>
|
||||||
|
|
||||||
<string name="dialog_add_logbook_title">Aggiungi diario</string>
|
<string name="dialog_add_logbook_title">Aggiungi diario</string>
|
||||||
|
@ -104,7 +104,9 @@
|
|||||||
<string name="measurement_unit_temperature_base_metric" translatable="false">°C</string>
|
<string name="measurement_unit_temperature_base_metric" translatable="false">°C</string>
|
||||||
|
|
||||||
<string name="dialog_event_detail_title">Event detail</string>
|
<string name="dialog_event_detail_title">Event detail</string>
|
||||||
|
<string name="dialog_event_detail_datetime_icon" translatable="false">🕒 %s1</string>
|
||||||
<string name="dialog_event_detail_save_button">Save</string>
|
<string name="dialog_event_detail_save_button">Save</string>
|
||||||
|
<string name="dialog_event_detail_cancel_button">Cancel</string>
|
||||||
<string name="dialog_event_detail_delete_button">Delete</string>
|
<string name="dialog_event_detail_delete_button">Delete</string>
|
||||||
|
|
||||||
<string name="dialog_add_logbook_title">Add logbook</string>
|
<string name="dialog_add_logbook_title">Add logbook</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user