forked from penguin86/luna-tracker
Compare commits
3 Commits
9cce54c05e
...
11a4f12fbe
| Author | SHA1 | Date | |
|---|---|---|---|
| 11a4f12fbe | |||
| 9398e5c406 | |||
| 5a9488fdb9 |
@@ -387,9 +387,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
val durationTextView = dialogView.findViewById<TextView>(R.id.dialog_date_duration)
|
val durationTextView = dialogView.findViewById<TextView>(R.id.dialog_date_duration)
|
||||||
val durationNowButton = dialogView.findViewById<Button>(R.id.dialog_date_duration_now)
|
val durationNowButton = dialogView.findViewById<Button>(R.id.dialog_date_duration_now)
|
||||||
val datePicker = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
val datePicker = dialogView.findViewById<TextView>(R.id.dialog_date_picker)
|
||||||
val durationMinus15Button = dialogView.findViewById<Button>(R.id.dialog_date_duration_minus15)
|
|
||||||
val durationMinus5Button = dialogView.findViewById<Button>(R.id.dialog_date_duration_minus5)
|
val durationMinus5Button = dialogView.findViewById<Button>(R.id.dialog_date_duration_minus5)
|
||||||
val durationPlus15Button = dialogView.findViewById<Button>(R.id.dialog_date_duration_plus15)
|
|
||||||
val durationPlus5Button = dialogView.findViewById<Button>(R.id.dialog_date_duration_plus5)
|
val durationPlus5Button = dialogView.findViewById<Button>(R.id.dialog_date_duration_plus5)
|
||||||
|
|
||||||
val currentDurationTextColor = durationTextView.currentTextColor
|
val currentDurationTextColor = durationTextView.currentTextColor
|
||||||
@@ -428,10 +426,8 @@ class MainActivity : AppCompatActivity() {
|
|||||||
onDateChange(pickedDateTime.time.time / 1000)
|
onDateChange(pickedDateTime.time.time / 1000)
|
||||||
}
|
}
|
||||||
|
|
||||||
durationMinus15Button.setOnClickListener { adjust(-15) }
|
|
||||||
durationMinus5Button.setOnClickListener { adjust(-5) }
|
durationMinus5Button.setOnClickListener { adjust(-5) }
|
||||||
durationPlus5Button.setOnClickListener { adjust(5) }
|
durationPlus5Button.setOnClickListener { adjust(5) }
|
||||||
durationPlus15Button.setOnClickListener { adjust(15) }
|
|
||||||
|
|
||||||
durationNowButton.setOnClickListener {
|
durationNowButton.setOnClickListener {
|
||||||
val now = Calendar.getInstance().time.time / 1000
|
val now = Calendar.getInstance().time.time / 1000
|
||||||
@@ -704,6 +700,12 @@ class MainActivity : AppCompatActivity() {
|
|||||||
fun showEventDetailDialog(originalEvent: LunaEvent) {
|
fun showEventDetailDialog(originalEvent: LunaEvent) {
|
||||||
val event = LunaEvent(originalEvent)
|
val event = LunaEvent(originalEvent)
|
||||||
|
|
||||||
|
fun eventValuesChanged(): Boolean {
|
||||||
|
return (event.time != originalEvent.time
|
||||||
|
|| event.quantity != originalEvent.quantity
|
||||||
|
|| event.notes != originalEvent.notes)
|
||||||
|
}
|
||||||
|
|
||||||
// Do not update list while the detail is shown, to avoid changing the object below while it is changed by the user
|
// Do not update list while the detail is shown, to avoid changing the object below while it is changed by the user
|
||||||
pauseLogbookUpdate = true
|
pauseLogbookUpdate = true
|
||||||
|
|
||||||
@@ -721,17 +723,59 @@ class MainActivity : AppCompatActivity() {
|
|||||||
emojiTextView.text = event.getTypeEmoji(this)
|
emojiTextView.text = event.getTypeEmoji(this)
|
||||||
descriptionTextView.text = event.getTypeDescription(this)
|
descriptionTextView.text = event.getTypeDescription(this)
|
||||||
|
|
||||||
|
d.setView(dialogView)
|
||||||
|
|
||||||
|
d.setNeutralButton(R.string.dialog_event_detail_delete_button) { dialogInterface, i ->
|
||||||
|
deleteEvent(originalEvent)
|
||||||
|
dialogInterface.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
d.setNegativeButton(R.string.dialog_event_detail_save_button) { dialogInterface, i ->
|
||||||
|
if (eventValuesChanged()) {
|
||||||
|
originalEvent.time = event.time
|
||||||
|
originalEvent.quantity = event.quantity
|
||||||
|
originalEvent.notes = event.notes
|
||||||
|
saveEvent(originalEvent)
|
||||||
|
}
|
||||||
|
|
||||||
|
dialogInterface.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
d.setPositiveButton(R.string.dialog_event_detail_close_button) { dialogInterface, i ->
|
||||||
|
dialogInterface.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
|
val alertDialog = d.create()
|
||||||
|
alertDialog.show()
|
||||||
|
|
||||||
|
alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL).setTextColor(
|
||||||
|
ContextCompat.getColor(this, R.color.danger)
|
||||||
|
)
|
||||||
|
|
||||||
|
alertDialog.setOnDismissListener {
|
||||||
|
// Resume logbook update
|
||||||
|
pauseLogbookUpdate = false
|
||||||
|
}
|
||||||
|
|
||||||
val updateValues = {
|
val updateValues = {
|
||||||
quantityTextView.text = NumericUtils(this).formatEventQuantity(event)
|
quantityTextView.text = NumericUtils(this).formatEventQuantity(event)
|
||||||
notesTextView.text = event.notes
|
notesTextView.text = event.notes
|
||||||
if (event.type == LunaEvent.TYPE_SLEEP) {
|
if (event.type == LunaEvent.TYPE_SLEEP && event.quantity > 0) {
|
||||||
dateEndTextView.text = DateUtils.formatDateTime(event.time + event.quantity)
|
dateEndTextView.text = DateUtils.formatDateTime(event.time + event.quantity)
|
||||||
dateEndTextView.visibility = View.VISIBLE
|
dateEndTextView.visibility = View.VISIBLE
|
||||||
|
} else {
|
||||||
|
dateEndTextView.visibility = View.GONE
|
||||||
|
}
|
||||||
|
|
||||||
|
alertDialog.getButton(DialogInterface.BUTTON_NEGATIVE).visibility = if (eventValuesChanged()) {
|
||||||
|
View.VISIBLE
|
||||||
|
} else {
|
||||||
|
View.GONE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateValues()
|
updateValues()
|
||||||
|
|
||||||
val pickedTime = datePickerHelper(event.time, dateTextView, { newTime: Long ->
|
datePickerHelper(event.time, dateTextView, { newTime: Long ->
|
||||||
event.time = newTime
|
event.time = newTime
|
||||||
updateValues()
|
updateValues()
|
||||||
})
|
})
|
||||||
@@ -757,40 +801,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d.setView(dialogView)
|
|
||||||
|
|
||||||
d.setNeutralButton(R.string.dialog_event_detail_delete_button) { dialogInterface, i ->
|
|
||||||
deleteEvent(originalEvent)
|
|
||||||
dialogInterface.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
d.setPositiveButton(R.string.dialog_event_detail_close_button) { dialogInterface, i ->
|
|
||||||
event.time = pickedTime.time.time / 1000
|
|
||||||
|
|
||||||
if (event.time != originalEvent.time
|
|
||||||
|| event.quantity != originalEvent.quantity
|
|
||||||
|| event.notes != originalEvent.notes) {
|
|
||||||
originalEvent.time = event.time
|
|
||||||
originalEvent.quantity = event.quantity
|
|
||||||
originalEvent.notes = event.notes
|
|
||||||
saveEvent(originalEvent)
|
|
||||||
}
|
|
||||||
|
|
||||||
dialogInterface.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
val alertDialog = d.create()
|
|
||||||
alertDialog.show()
|
|
||||||
|
|
||||||
alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL).setTextColor(
|
|
||||||
ContextCompat.getColor(this, R.color.danger)
|
|
||||||
)
|
|
||||||
|
|
||||||
alertDialog.setOnDismissListener {
|
|
||||||
// Resume logbook update
|
|
||||||
pauseLogbookUpdate = false
|
|
||||||
}
|
|
||||||
|
|
||||||
// show optional signature
|
// show optional signature
|
||||||
if (event.signature.isNotEmpty()) {
|
if (event.signature.isNotEmpty()) {
|
||||||
val signatureTextEdit = dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_signature)
|
val signatureTextEdit = dialogView.findViewById<TextView>(R.id.dialog_event_detail_type_signature)
|
||||||
|
|||||||
@@ -22,13 +22,6 @@
|
|||||||
android:layout_marginHorizontal="10dp"
|
android:layout_marginHorizontal="10dp"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/dialog_date_duration_minus15"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="-15"/>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/dialog_date_duration_minus5"
|
android:id="@+id/dialog_date_duration_minus5"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -50,13 +43,6 @@
|
|||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="+5"/>
|
android:text="+5"/>
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/dialog_date_duration_plus15"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:text="+15"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
|||||||
@@ -132,7 +132,8 @@
|
|||||||
<string name="row_luna_event_time">Time</string>
|
<string name="row_luna_event_time">Time</string>
|
||||||
|
|
||||||
<string name="dialog_event_detail_title">Event detail</string>
|
<string name="dialog_event_detail_title">Event detail</string>
|
||||||
<string name="dialog_event_detail_close_button">OK</string>
|
<string name="dialog_event_detail_close_button">Close</string>
|
||||||
|
<string name="dialog_event_detail_save_button">Save</string>
|
||||||
<string name="dialog_event_detail_delete_button">Delete</string>
|
<string name="dialog_event_detail_delete_button">Delete</string>
|
||||||
<string name="dialog_event_detail_quantity">Quantity</string>
|
<string name="dialog_event_detail_quantity">Quantity</string>
|
||||||
<string name="dialog_event_detail_notes">Notes</string>
|
<string name="dialog_event_detail_notes">Notes</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user