forked from penguin86/luna-tracker
Compare commits
2 Commits
11a4f12fbe
...
9cce54c05e
| Author | SHA1 | Date | |
|---|---|---|---|
| 9cce54c05e | |||
| c7b4e1e487 |
@@ -387,7 +387,9 @@ 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
|
||||||
@@ -426,8 +428,10 @@ 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
|
||||||
@@ -700,12 +704,6 @@ 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
|
||||||
|
|
||||||
@@ -723,59 +721,17 @@ 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 && event.quantity > 0) {
|
if (event.type == LunaEvent.TYPE_SLEEP) {
|
||||||
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()
|
||||||
|
|
||||||
datePickerHelper(event.time, dateTextView, { newTime: Long ->
|
val pickedTime = datePickerHelper(event.time, dateTextView, { newTime: Long ->
|
||||||
event.time = newTime
|
event.time = newTime
|
||||||
updateValues()
|
updateValues()
|
||||||
})
|
})
|
||||||
@@ -801,6 +757,40 @@ 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,6 +22,13 @@
|
|||||||
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"
|
||||||
@@ -43,6 +50,13 @@
|
|||||||
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,8 +132,7 @@
|
|||||||
<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">Close</string>
|
<string name="dialog_event_detail_close_button">OK</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