forked from penguin86/luna-tracker
Compare commits
3 Commits
note_defau
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 5eeb462836 | |||
| 5b777c0b88 | |||
| 6f3061974d |
@@ -12,8 +12,8 @@ android {
|
|||||||
applicationId = "it.danieleverducci.lunatracker"
|
applicationId = "it.danieleverducci.lunatracker"
|
||||||
minSdk = 21
|
minSdk = 21
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = 6
|
versionCode = 7
|
||||||
versionName = "0.8"
|
versionName = "0.9"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,10 +128,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAllEvents(): ArrayList<LunaEvent> {
|
|
||||||
return logbook?.logs ?: arrayListOf()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setListAdapter(items: ArrayList<LunaEvent>) {
|
private fun setListAdapter(items: ArrayList<LunaEvent>) {
|
||||||
val adapter = LunaEventRecyclerAdapter(this, items)
|
val adapter = LunaEventRecyclerAdapter(this, items)
|
||||||
adapter.onItemClickListener = object: LunaEventRecyclerAdapter.OnItemClickListener {
|
adapter.onItemClickListener = object: LunaEventRecyclerAdapter.OnItemClickListener {
|
||||||
@@ -279,7 +275,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
||||||
val pos = spinner.selectedItemPosition
|
val pos = spinner.selectedItemPosition
|
||||||
logEvent(LunaEvent(LunaEvent.TYPE_PUKE, pos))
|
logEvent(LunaEvent(LunaEvent.TYPE_PUKE, pos + 1))
|
||||||
}
|
}
|
||||||
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() }
|
d.setNegativeButton(android.R.string.cancel) { dialogInterface, i -> dialogInterface.dismiss() }
|
||||||
val alertDialog = d.create()
|
val alertDialog = d.create()
|
||||||
@@ -287,9 +283,6 @@ class MainActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun askNotes(lunaEvent: LunaEvent) {
|
fun askNotes(lunaEvent: LunaEvent) {
|
||||||
val allEvents = getAllEvents()
|
|
||||||
val useQuantity = (lunaEvent.type != LunaEvent.TYPE_NOTE && lunaEvent.type != LunaEvent.TYPE_CUSTOM)
|
|
||||||
|
|
||||||
val d = AlertDialog.Builder(this)
|
val d = AlertDialog.Builder(this)
|
||||||
val dialogView = layoutInflater.inflate(R.layout.dialog_notes, null)
|
val dialogView = layoutInflater.inflate(R.layout.dialog_notes, null)
|
||||||
d.setTitle(lunaEvent.getTypeDescription(this))
|
d.setTitle(lunaEvent.getTypeDescription(this))
|
||||||
@@ -297,66 +290,11 @@ class MainActivity : AppCompatActivity() {
|
|||||||
d.setView(dialogView)
|
d.setView(dialogView)
|
||||||
val notesET = dialogView.findViewById<EditText>(R.id.notes_edittext)
|
val notesET = dialogView.findViewById<EditText>(R.id.notes_edittext)
|
||||||
val qtyET = dialogView.findViewById<EditText>(R.id.notes_qty_edittext)
|
val qtyET = dialogView.findViewById<EditText>(R.id.notes_qty_edittext)
|
||||||
|
if (lunaEvent.type == LunaEvent.TYPE_NOTE || lunaEvent.type == LunaEvent.TYPE_CUSTOM)
|
||||||
val nextTextView = dialogView.findViewById<TextView>(R.id.notes_template_next)
|
|
||||||
val clearTextView = dialogView.findViewById<TextView>(R.id.notes_clear)
|
|
||||||
val prevTextView = dialogView.findViewById<TextView>(R.id.notes_template_prev)
|
|
||||||
|
|
||||||
fun updateContent(current: LunaEvent) {
|
|
||||||
val prevEvent = getPreviousSameEvent(current, allEvents)
|
|
||||||
val nextEvent = getNextSameEvent(current, allEvents)
|
|
||||||
|
|
||||||
notesET.setText(current.notes)
|
|
||||||
if (useQuantity) {
|
|
||||||
qtyET.setText(current.quantity.toString())
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nextEvent != null) {
|
|
||||||
nextTextView.setOnClickListener {
|
|
||||||
notesET.setText(nextEvent.notes)
|
|
||||||
if (useQuantity) {
|
|
||||||
qtyET.setText(nextEvent.quantity.toString())
|
|
||||||
}
|
|
||||||
updateContent(nextEvent)
|
|
||||||
}
|
|
||||||
nextTextView.alpha = 1.0f
|
|
||||||
} else {
|
|
||||||
nextTextView.setOnClickListener {}
|
|
||||||
nextTextView.alpha = 0.5f
|
|
||||||
}
|
|
||||||
|
|
||||||
if (prevEvent != null) {
|
|
||||||
prevTextView.setOnClickListener {
|
|
||||||
notesET.setText(prevEvent.notes)
|
|
||||||
if (useQuantity) {
|
|
||||||
qtyET.setText(prevEvent.quantity.toString())
|
|
||||||
}
|
|
||||||
updateContent(prevEvent)
|
|
||||||
}
|
|
||||||
prevTextView.alpha = 1.0f
|
|
||||||
} else {
|
|
||||||
prevTextView.setOnClickListener {}
|
|
||||||
prevTextView.alpha = 0.5f
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
clearTextView.setOnClickListener {
|
|
||||||
notesET.setText("")
|
|
||||||
if (useQuantity) {
|
|
||||||
qtyET.setText("")
|
|
||||||
}
|
|
||||||
updateContent(lunaEvent)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!useQuantity) {
|
|
||||||
qtyET.visibility = View.GONE
|
qtyET.visibility = View.GONE
|
||||||
}
|
|
||||||
|
|
||||||
updateContent(lunaEvent)
|
|
||||||
|
|
||||||
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
d.setPositiveButton(android.R.string.ok) { dialogInterface, i ->
|
||||||
val qtyStr = qtyET.text.toString()
|
val qtyStr = qtyET.text.toString()
|
||||||
if (qtyStr.isNotEmpty() && useQuantity) {
|
if (qtyStr.isNotEmpty()) {
|
||||||
val qty = qtyStr.toIntOrNull()
|
val qty = qtyStr.toIntOrNull()
|
||||||
if (qty == null) {
|
if (qty == null) {
|
||||||
Toast.makeText(this, R.string.toast_integer_error, Toast.LENGTH_SHORT).show()
|
Toast.makeText(this, R.string.toast_integer_error, Toast.LENGTH_SHORT).show()
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class NumericUtils (val context: Context) {
|
|||||||
LunaEvent.TYPE_TEMPERATURE ->
|
LunaEvent.TYPE_TEMPERATURE ->
|
||||||
(item.quantity / 10.0f).toString()
|
(item.quantity / 10.0f).toString()
|
||||||
LunaEvent.TYPE_PUKE ->
|
LunaEvent.TYPE_PUKE ->
|
||||||
context.resources.getStringArray(R.array.AmountLabels)[item.quantity]
|
context.resources.getStringArray(R.array.AmountLabels)[item.quantity - 1]
|
||||||
else ->
|
else ->
|
||||||
item.quantity
|
item.quantity
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -24,33 +24,4 @@
|
|||||||
android:hint="@string/log_notes_dialog_note_hint"
|
android:hint="@string/log_notes_dialog_note_hint"
|
||||||
android:background="@drawable/textview_background"/>
|
android:background="@drawable/textview_background"/>
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:gravity="end"
|
|
||||||
android:orientation="horizontal">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/notes_template_prev"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="18dp"
|
|
||||||
android:text="⬅️"/>
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/notes_clear"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="5dp"
|
|
||||||
android:textSize="18dp"
|
|
||||||
android:text="🚫"/>
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/notes_template_next"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="18dp"
|
|
||||||
android:text="➡️"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
Reference in New Issue
Block a user