forked from penguin86/luna-tracker
Add dynamic header setting
This makes the 'no breastfeeding' setting irrelevant.
This commit is contained in:
@@ -15,6 +15,7 @@ import android.widget.AdapterView
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.Button
|
||||
import android.widget.EditText
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.NumberPicker
|
||||
import android.widget.PopupWindow
|
||||
import android.widget.Spinner
|
||||
@@ -53,6 +54,7 @@ class MainActivity : AppCompatActivity() {
|
||||
const val DEBUG_CHECK_LOGBOOK_CONSISTENCY = false
|
||||
// list of all events
|
||||
var allEvents = arrayListOf<LunaEvent>()
|
||||
var currentPopupItems = listOf<LunaEvent.Type>()
|
||||
}
|
||||
|
||||
var logbook: Logbook? = null
|
||||
@@ -84,31 +86,13 @@ class MainActivity : AppCompatActivity() {
|
||||
recyclerView = findViewById(R.id.list_events)
|
||||
recyclerView.setLayoutManager(LinearLayoutManager(applicationContext))
|
||||
|
||||
populateHeaderMenu()
|
||||
|
||||
// Set listeners
|
||||
findViewById<View>(R.id.logbooks_add_button).setOnClickListener {
|
||||
showAddLogbookDialog(true)
|
||||
}
|
||||
findViewById<View>(R.id.button_bottle).setOnClickListener {
|
||||
addBabyBottleEvent(LunaEvent(LunaEvent.TYPE_BABY_BOTTLE))
|
||||
}
|
||||
findViewById<View>(R.id.button_food).setOnClickListener {
|
||||
addNoteEvent(LunaEvent(LunaEvent.TYPE_FOOD))
|
||||
}
|
||||
findViewById<View>(R.id.button_nipple_left).setOnClickListener {
|
||||
addPlainEvent(LunaEvent(LunaEvent.TYPE_BREASTFEEDING_LEFT_NIPPLE))
|
||||
}
|
||||
findViewById<View>(R.id.button_nipple_both).setOnClickListener {
|
||||
addPlainEvent(LunaEvent(LunaEvent.TYPE_BREASTFEEDING_BOTH_NIPPLE))
|
||||
}
|
||||
findViewById<View>(R.id.button_nipple_right).setOnClickListener {
|
||||
addPlainEvent(LunaEvent(LunaEvent.TYPE_BREASTFEEDING_RIGHT_NIPPLE))
|
||||
}
|
||||
findViewById<View>(R.id.button_change_poo).setOnClickListener {
|
||||
addAmountEvent(LunaEvent(LunaEvent.TYPE_DIAPERCHANGE_POO))
|
||||
}
|
||||
findViewById<View>(R.id.button_change_pee).setOnClickListener {
|
||||
addAmountEvent(LunaEvent(LunaEvent.TYPE_DIAPERCHANGE_PEE))
|
||||
}
|
||||
|
||||
val moreButton = findViewById<View>(R.id.button_more)
|
||||
moreButton.setOnClickListener {
|
||||
showOverflowPopupWindow(moreButton)
|
||||
@@ -150,6 +134,82 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
allEvents = logbook?.logs ?: arrayListOf()
|
||||
setListAdapter(allEvents)
|
||||
|
||||
populateHeaderMenu()
|
||||
}
|
||||
|
||||
private fun populateHeaderMenu() {
|
||||
val settingsRepository = LocalSettingsRepository(this)
|
||||
val dynamicMenu = settingsRepository.loadDynamicMenu()
|
||||
val eventTypeStats = mutableMapOf<LunaEvent.Type, Int>()
|
||||
|
||||
if (dynamicMenu) {
|
||||
val sampleSize = 100
|
||||
// populate frequency map from first 100 events
|
||||
allEvents.take(sampleSize.coerceAtMost(allEvents.size)).forEach {
|
||||
eventTypeStats[it.type] = 1 + (eventTypeStats[it.type] ?: 0)
|
||||
}
|
||||
}
|
||||
|
||||
// sort all event types by frequency or ordinal
|
||||
val eventTypesSorted = LunaEvent.Type.entries.toList().sortedWith(
|
||||
compareBy({ -1 * (eventTypeStats[it] ?: 0) }, { it.ordinal })
|
||||
).filter { it != LunaEvent.Type.UNKNOWN }
|
||||
|
||||
fun setupMenu(maxButtonCount: Int, sortedEventTypes: List<LunaEvent.Type>): Int {
|
||||
val row1 = findViewById<View>(R.id.linear_layout_row1)
|
||||
val row1Button1 = findViewById<TextView>(R.id.button1_row1)
|
||||
val row1Button2 = findViewById<TextView>(R.id.button2_row1)
|
||||
|
||||
val row2 = findViewById<View>(R.id.linear_layout_row2)
|
||||
val row2Button1 = findViewById<TextView>(R.id.button1_row2)
|
||||
val row2Button2 = findViewById<TextView>(R.id.button2_row2)
|
||||
val row2Button3 = findViewById<TextView>(R.id.button3_row2)
|
||||
|
||||
val row3 = findViewById<View>(R.id.linear_layout_row3)
|
||||
val row3Button1 = findViewById<TextView>(R.id.button1_row3)
|
||||
val row3Button2 = findViewById<TextView>(R.id.button2_row3)
|
||||
|
||||
// hide all rows/buttons (except row 3)
|
||||
for (view in listOf(row1, row1Button1, row1Button2,
|
||||
row2, row2Button1, row2Button2, row2Button3,
|
||||
row3, row3Button1, row3Button2)) {
|
||||
view.visibility = View.GONE
|
||||
}
|
||||
row3.visibility = View.VISIBLE
|
||||
|
||||
var showCounter = 0
|
||||
|
||||
fun show(vararg tvs: TextView) {
|
||||
for (tv in tvs) {
|
||||
val type = sortedEventTypes[showCounter]
|
||||
tv.text = LunaEvent.getTypeEmoji(applicationContext, type)
|
||||
tv.setOnClickListener { showCreateDialog(type) }
|
||||
tv.visibility = View.VISIBLE
|
||||
// show parent row
|
||||
(tv.parent as View).visibility = View.VISIBLE
|
||||
showCounter += 1
|
||||
}
|
||||
}
|
||||
|
||||
when (maxButtonCount) {
|
||||
0 -> { } // ignore - show empty row3
|
||||
1 -> show(row3Button1)
|
||||
2 -> show(row3Button1, row3Button2)
|
||||
3 -> show(row1Button1, row3Button1)
|
||||
4, 5, 6 -> show(row1Button1, row1Button2, row3Button1, row3Button2)
|
||||
else -> show(row1Button1, row1Button2, row2Button1, row2Button2, row2Button3, row3Button1, row3Button2)
|
||||
}
|
||||
|
||||
return showCounter
|
||||
}
|
||||
|
||||
val usedEventCount = eventTypeStats.count { it.value > 0 }
|
||||
val maxButtonCount = if (dynamicMenu) { usedEventCount } else { 7 }
|
||||
val eventsShown = setupMenu(maxButtonCount, eventTypesSorted)
|
||||
|
||||
// store left over events for popup menu
|
||||
currentPopupItems = eventTypesSorted.subList(eventsShown, eventTypesSorted.size)
|
||||
}
|
||||
|
||||
override fun onStart() {
|
||||
@@ -172,12 +232,6 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
signature = settingsRepository.loadSignature()
|
||||
|
||||
val noBreastfeeding = settingsRepository.loadNoBreastfeeding()
|
||||
findViewById<View>(R.id.layout_nipples).visibility = when (noBreastfeeding) {
|
||||
true -> View.GONE
|
||||
false -> View.VISIBLE
|
||||
}
|
||||
|
||||
// Update list dates
|
||||
recyclerView.adapter?.notifyDataSetChanged()
|
||||
|
||||
@@ -1189,6 +1243,29 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun showCreateDialog(type: LunaEvent.Type) {
|
||||
val event = LunaEvent(type)
|
||||
when (type) {
|
||||
LunaEvent.Type.BABY_BOTTLE -> addBabyBottleEvent(event)
|
||||
LunaEvent.Type.WEIGHT -> addWeightEvent(event)
|
||||
LunaEvent.Type.BREASTFEEDING_LEFT_NIPPLE -> addPlainEvent(event)
|
||||
LunaEvent.Type.BREASTFEEDING_BOTH_NIPPLE -> addPlainEvent(event)
|
||||
LunaEvent.Type.BREASTFEEDING_RIGHT_NIPPLE -> addPlainEvent(event)
|
||||
LunaEvent.Type.DIAPERCHANGE_POO -> addAmountEvent(event)
|
||||
LunaEvent.Type.DIAPERCHANGE_PEE -> addAmountEvent(event)
|
||||
LunaEvent.Type.MEDICINE -> addNoteEvent(event)
|
||||
LunaEvent.Type.ENEMA -> addNoteEvent(event)
|
||||
LunaEvent.Type.NOTE -> addNoteEvent(event)
|
||||
LunaEvent.Type.COLIC -> addPlainEvent(event)
|
||||
LunaEvent.Type.TEMPERATURE -> addTemperatureEvent(event)
|
||||
LunaEvent.Type.FOOD -> addNoteEvent(event)
|
||||
LunaEvent.Type.PUKE -> addAmountEvent(event)
|
||||
LunaEvent.Type.BATH -> addPlainEvent(event)
|
||||
LunaEvent.Type.SLEEP -> addSleepEvent(event)
|
||||
LunaEvent.Type.UNKNOWN -> {} // ignore
|
||||
}
|
||||
}
|
||||
|
||||
private fun showOverflowPopupWindow(anchor: View) {
|
||||
if (showingOverflowPopupWindow)
|
||||
return
|
||||
@@ -1197,42 +1274,8 @@ class MainActivity : AppCompatActivity() {
|
||||
isOutsideTouchable = true
|
||||
val inflater = LayoutInflater.from(anchor.context)
|
||||
contentView = inflater.inflate(R.layout.more_events_popup, null)
|
||||
contentView.findViewById<View>(R.id.button_medicine).setOnClickListener {
|
||||
addNoteEvent(LunaEvent(LunaEvent.TYPE_MEDICINE))
|
||||
dismiss()
|
||||
}
|
||||
contentView.findViewById<View>(R.id.button_enema).setOnClickListener {
|
||||
addPlainEvent(LunaEvent(LunaEvent.TYPE_ENEMA))
|
||||
dismiss()
|
||||
}
|
||||
contentView.findViewById<View>(R.id.button_note).setOnClickListener {
|
||||
addNoteEvent(LunaEvent(LunaEvent.TYPE_NOTE))
|
||||
dismiss()
|
||||
}
|
||||
contentView.findViewById<View>(R.id.button_temperature).setOnClickListener {
|
||||
addTemperatureEvent(LunaEvent(LunaEvent.TYPE_TEMPERATURE))
|
||||
dismiss()
|
||||
}
|
||||
contentView.findViewById<View>(R.id.button_puke).setOnClickListener {
|
||||
addAmountEvent(LunaEvent(LunaEvent.TYPE_PUKE))
|
||||
dismiss()
|
||||
}
|
||||
contentView.findViewById<View>(R.id.button_sleep).setOnClickListener {
|
||||
addSleepEvent(LunaEvent(LunaEvent.TYPE_SLEEP))
|
||||
dismiss()
|
||||
}
|
||||
contentView.findViewById<View>(R.id.button_colic).setOnClickListener {
|
||||
addPlainEvent(LunaEvent(LunaEvent.TYPE_COLIC))
|
||||
dismiss()
|
||||
}
|
||||
contentView.findViewById<View>(R.id.button_scale).setOnClickListener {
|
||||
addWeightEvent(LunaEvent(LunaEvent.TYPE_WEIGHT))
|
||||
dismiss()
|
||||
}
|
||||
contentView.findViewById<View>(R.id.button_bath).setOnClickListener {
|
||||
addPlainEvent(LunaEvent(LunaEvent.TYPE_BATH))
|
||||
dismiss()
|
||||
}
|
||||
|
||||
// Add statistics (hard coded)
|
||||
contentView.findViewById<View>(R.id.button_statistics).setOnClickListener {
|
||||
if (logbook != null && !pauseLogbookUpdate) {
|
||||
val i = Intent(applicationContext, StatisticsActivity::class.java)
|
||||
@@ -1243,6 +1286,20 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
dismiss()
|
||||
}
|
||||
|
||||
val linearLayout = contentView.findViewById<LinearLayout>(R.id.layout_list)
|
||||
|
||||
// Add buttons to create other events
|
||||
for (type in currentPopupItems) {
|
||||
val view = layoutInflater.inflate(R.layout.more_events_popup_item, linearLayout, false)
|
||||
val textView = view.findViewById<TextView>(R.id.tv)
|
||||
textView.text = LunaEvent.getPopupItemTitle(applicationContext, type)
|
||||
textView.setOnClickListener {
|
||||
showCreateDialog(type)
|
||||
dismiss()
|
||||
}
|
||||
linearLayout.addView(textView)
|
||||
}
|
||||
}.also { popupWindow ->
|
||||
popupWindow.setOnDismissListener({
|
||||
Handler(mainLooper).postDelayed({
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import android.widget.RadioButton
|
||||
import android.widget.Spinner
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
@@ -24,7 +25,7 @@ open class SettingsActivity : AppCompatActivity() {
|
||||
protected lateinit var textViewWebDAVUser: TextView
|
||||
protected lateinit var textViewWebDAVPass: TextView
|
||||
protected lateinit var progressIndicator: LinearProgressIndicator
|
||||
protected lateinit var switchNoBreastfeeding: SwitchMaterial
|
||||
protected lateinit var switchDynamicMenu: SwitchMaterial
|
||||
protected lateinit var textViewSignature: EditText
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
@@ -37,7 +38,7 @@ open class SettingsActivity : AppCompatActivity() {
|
||||
textViewWebDAVUser = findViewById(R.id.settings_data_webdav_user)
|
||||
textViewWebDAVPass = findViewById(R.id.settings_data_webdav_pass)
|
||||
progressIndicator = findViewById(R.id.progress_indicator)
|
||||
switchNoBreastfeeding = findViewById(R.id.switch_no_breastfeeding)
|
||||
switchDynamicMenu = findViewById(R.id.switch_dynamic_menu)
|
||||
textViewSignature = findViewById(R.id.settings_signature)
|
||||
|
||||
findViewById<View>(R.id.settings_save).setOnClickListener({
|
||||
@@ -54,7 +55,7 @@ open class SettingsActivity : AppCompatActivity() {
|
||||
fun loadSettings() {
|
||||
val dataRepo = settingsRepository.loadDataRepository()
|
||||
val webDavCredentials = settingsRepository.loadWebdavCredentials()
|
||||
val noBreastfeeding = settingsRepository.loadNoBreastfeeding()
|
||||
val dynamicMenu = settingsRepository.loadDynamicMenu()
|
||||
val signature = settingsRepository.loadSignature()
|
||||
|
||||
when (dataRepo) {
|
||||
@@ -63,7 +64,7 @@ open class SettingsActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
textViewSignature.setText(signature)
|
||||
switchNoBreastfeeding.isChecked = noBreastfeeding
|
||||
switchDynamicMenu.isChecked = dynamicMenu
|
||||
|
||||
if (webDavCredentials != null) {
|
||||
textViewWebDAVUrl.text = webDavCredentials[0]
|
||||
@@ -160,7 +161,7 @@ open class SettingsActivity : AppCompatActivity() {
|
||||
if (radioDataWebDAV.isChecked) LocalSettingsRepository.DATA_REPO.WEBDAV
|
||||
else LocalSettingsRepository.DATA_REPO.LOCAL_FILE
|
||||
)
|
||||
settingsRepository.saveNoBreastfeeding(switchNoBreastfeeding.isChecked)
|
||||
settingsRepository.saveDynamicMenu(switchDynamicMenu.isChecked)
|
||||
settingsRepository.saveSignature(textViewSignature.text.toString())
|
||||
settingsRepository.saveWebdavCredentials(
|
||||
textViewWebDAVUrl.text.toString(),
|
||||
|
||||
@@ -33,56 +33,6 @@ class LunaEvent: Comparable<LunaEvent> {
|
||||
UNKNOWN
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getTypeEmoji(context: Context, type: Type): String {
|
||||
return context.getString(
|
||||
when (type) {
|
||||
Type.BABY_BOTTLE -> R.string.event_bottle_type
|
||||
Type.WEIGHT -> R.string.event_weight_type
|
||||
Type.BREASTFEEDING_LEFT_NIPPLE -> R.string.event_breastfeeding_left_type
|
||||
Type.BREASTFEEDING_BOTH_NIPPLE -> R.string.event_breastfeeding_both_type
|
||||
Type.BREASTFEEDING_RIGHT_NIPPLE -> R.string.event_breastfeeding_right_type
|
||||
Type.DIAPERCHANGE_POO -> R.string.event_diaperchange_poo_type
|
||||
Type.DIAPERCHANGE_PEE -> R.string.event_diaperchange_pee_type
|
||||
Type.MEDICINE -> R.string.event_medicine_type
|
||||
Type.ENEMA -> R.string.event_enema_type
|
||||
Type.NOTE -> R.string.event_note_type
|
||||
Type.TEMPERATURE -> R.string.event_temperature_type
|
||||
Type.COLIC -> R.string.event_colic_type
|
||||
Type.FOOD -> R.string.event_food_type
|
||||
Type.PUKE -> R.string.event_puke_type
|
||||
Type.BATH -> R.string.event_bath_type
|
||||
Type.SLEEP -> R.string.event_sleep_type
|
||||
Type.UNKNOWN -> R.string.event_unknown_type
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getTypeDescription(context: Context, type: Type): String {
|
||||
return context.getString(
|
||||
when (type) {
|
||||
Type.BABY_BOTTLE -> R.string.event_bottle_desc
|
||||
Type.WEIGHT -> R.string.event_weight_desc
|
||||
Type.BREASTFEEDING_LEFT_NIPPLE -> R.string.event_breastfeeding_left_desc
|
||||
Type.BREASTFEEDING_BOTH_NIPPLE -> R.string.event_breastfeeding_both_desc
|
||||
Type.BREASTFEEDING_RIGHT_NIPPLE -> R.string.event_breastfeeding_right_desc
|
||||
Type.DIAPERCHANGE_POO -> R.string.event_diaperchange_poo_desc
|
||||
Type.DIAPERCHANGE_PEE -> R.string.event_diaperchange_pee_desc
|
||||
Type.MEDICINE -> R.string.event_medicine_desc
|
||||
Type.ENEMA -> R.string.event_enema_desc
|
||||
Type.NOTE -> R.string.event_note_desc
|
||||
Type.TEMPERATURE -> R.string.event_temperature_desc
|
||||
Type.COLIC -> R.string.event_colic_desc
|
||||
Type.FOOD -> R.string.event_food_desc
|
||||
Type.PUKE -> R.string.event_puke_desc
|
||||
Type.BATH -> R.string.event_bath_desc
|
||||
Type.SLEEP -> R.string.event_sleep_desc
|
||||
Type.UNKNOWN -> R.string.event_unknown_desc
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private val jo: JSONObject
|
||||
|
||||
var time: Long // In unix time (seconds since 1970)
|
||||
@@ -158,20 +108,8 @@ class LunaEvent: Comparable<LunaEvent> {
|
||||
return getTypeDescription(context, type)
|
||||
}
|
||||
|
||||
fun getDialogMessage(context: Context): String? {
|
||||
return context.getString(
|
||||
when(type) {
|
||||
Type.BABY_BOTTLE -> R.string.log_bottle_dialog_description
|
||||
Type.MEDICINE -> R.string.log_medicine_dialog_description
|
||||
Type.TEMPERATURE -> R.string.log_temperature_dialog_description
|
||||
Type.DIAPERCHANGE_POO,
|
||||
Type.DIAPERCHANGE_PEE,
|
||||
Type.PUKE -> R.string.log_amount_dialog_description
|
||||
Type.WEIGHT -> R.string.log_weight_dialog_description
|
||||
Type.SLEEP -> R.string.log_sleep_dialog_description
|
||||
else -> R.string.log_unknown_dialog_description
|
||||
}
|
||||
)
|
||||
fun getDialogMessage(context: Context): String {
|
||||
return getDialogMessage(context, type)
|
||||
}
|
||||
|
||||
fun toJson(): JSONObject {
|
||||
@@ -185,4 +123,95 @@ class LunaEvent: Comparable<LunaEvent> {
|
||||
override fun compareTo(other: LunaEvent): Int {
|
||||
return (this.time - other.time).toInt()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun getTypeEmoji(context: Context, type: Type): String {
|
||||
return context.getString(
|
||||
when (type) {
|
||||
Type.BABY_BOTTLE -> R.string.event_bottle_type
|
||||
Type.WEIGHT -> R.string.event_weight_type
|
||||
Type.BREASTFEEDING_LEFT_NIPPLE -> R.string.event_breastfeeding_left_type
|
||||
Type.BREASTFEEDING_BOTH_NIPPLE -> R.string.event_breastfeeding_both_type
|
||||
Type.BREASTFEEDING_RIGHT_NIPPLE -> R.string.event_breastfeeding_right_type
|
||||
Type.DIAPERCHANGE_POO -> R.string.event_diaperchange_poo_type
|
||||
Type.DIAPERCHANGE_PEE -> R.string.event_diaperchange_pee_type
|
||||
Type.MEDICINE -> R.string.event_medicine_type
|
||||
Type.ENEMA -> R.string.event_enema_type
|
||||
Type.NOTE -> R.string.event_note_type
|
||||
Type.TEMPERATURE -> R.string.event_temperature_type
|
||||
Type.COLIC -> R.string.event_colic_type
|
||||
Type.FOOD -> R.string.event_food_type
|
||||
Type.PUKE -> R.string.event_puke_type
|
||||
Type.BATH -> R.string.event_bath_type
|
||||
Type.SLEEP -> R.string.event_sleep_type
|
||||
Type.UNKNOWN -> R.string.event_unknown_type
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getDialogMessage(context: Context, type: Type): String {
|
||||
return context.getString(
|
||||
when (type) {
|
||||
Type.BABY_BOTTLE -> R.string.log_bottle_dialog_description
|
||||
Type.MEDICINE -> R.string.log_medicine_dialog_description
|
||||
Type.TEMPERATURE -> R.string.log_temperature_dialog_description
|
||||
Type.DIAPERCHANGE_POO,
|
||||
Type.DIAPERCHANGE_PEE,
|
||||
Type.PUKE -> R.string.log_amount_dialog_description
|
||||
Type.WEIGHT -> R.string.log_weight_dialog_description
|
||||
Type.SLEEP -> R.string.log_sleep_dialog_description
|
||||
else -> R.string.log_unknown_dialog_description
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun getTypeDescription(context: Context, type: Type): String {
|
||||
return context.getString(
|
||||
when (type) {
|
||||
Type.BABY_BOTTLE -> R.string.event_bottle_desc
|
||||
Type.WEIGHT -> R.string.event_weight_desc
|
||||
Type.BREASTFEEDING_LEFT_NIPPLE -> R.string.event_breastfeeding_left_desc
|
||||
Type.BREASTFEEDING_BOTH_NIPPLE -> R.string.event_breastfeeding_both_desc
|
||||
Type.BREASTFEEDING_RIGHT_NIPPLE -> R.string.event_breastfeeding_right_desc
|
||||
Type.DIAPERCHANGE_POO -> R.string.event_diaperchange_poo_desc
|
||||
Type.DIAPERCHANGE_PEE -> R.string.event_diaperchange_pee_desc
|
||||
Type.MEDICINE -> R.string.event_medicine_desc
|
||||
Type.ENEMA -> R.string.event_enema_desc
|
||||
Type.NOTE -> R.string.event_note_desc
|
||||
Type.TEMPERATURE -> R.string.event_temperature_desc
|
||||
Type.COLIC -> R.string.event_colic_desc
|
||||
Type.FOOD -> R.string.event_food_desc
|
||||
Type.PUKE -> R.string.event_puke_desc
|
||||
Type.BATH -> R.string.event_bath_desc
|
||||
Type.SLEEP -> R.string.event_sleep_desc
|
||||
Type.UNKNOWN -> R.string.event_unknown_desc
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// Entries for for popup list
|
||||
fun getPopupItemTitle(context: Context, type: Type): String {
|
||||
return context.getString(
|
||||
when (type) {
|
||||
Type.BABY_BOTTLE -> R.string.event_type_item_bottle
|
||||
Type.WEIGHT -> R.string.event_type_item_weight
|
||||
Type.BREASTFEEDING_LEFT_NIPPLE -> R.string.event_type_item_breastfeeding_left
|
||||
Type.BREASTFEEDING_BOTH_NIPPLE -> R.string.event_type_item_breastfeeding_both
|
||||
Type.BREASTFEEDING_RIGHT_NIPPLE -> R.string.event_type_item_breastfeeding_right
|
||||
Type.DIAPERCHANGE_POO -> R.string.event_type_item_diaperchange_poo
|
||||
Type.DIAPERCHANGE_PEE -> R.string.event_type_item_diaperchange_pee
|
||||
Type.MEDICINE -> R.string.event_type_item_medicine
|
||||
Type.ENEMA -> R.string.event_type_item_enema
|
||||
Type.NOTE -> R.string.event_type_item_note
|
||||
Type.TEMPERATURE -> R.string.event_type_item_temperature
|
||||
Type.COLIC -> R.string.event_type_item_colic
|
||||
Type.FOOD -> R.string.event_type_item_food
|
||||
Type.PUKE -> R.string.event_type_item_puke
|
||||
Type.BATH -> R.string.event_type_item_bath
|
||||
Type.SLEEP -> R.string.event_type_item_sleep
|
||||
Type.UNKNOWN -> R.string.event_type_item_unknown
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class LocalSettingsRepository(val context: Context) {
|
||||
const val SHARED_PREFS_DAV_URL = "webdav_url"
|
||||
const val SHARED_PREFS_DAV_USER = "webdav_user"
|
||||
const val SHARED_PREFS_DAV_PASS = "webdav_password"
|
||||
const val SHARED_PREFS_NO_BREASTFEEDING = "no_breastfeeding"
|
||||
const val SHARED_PREFS_DYNAMIC_MENU = "dynamic_menu"
|
||||
const val SHARED_PREFS_SIGNATURE = "signature"
|
||||
}
|
||||
enum class DATA_REPO {LOCAL_FILE, WEBDAV}
|
||||
@@ -31,12 +31,12 @@ class LocalSettingsRepository(val context: Context) {
|
||||
return sharedPreferences.getString(SHARED_PREFS_SIGNATURE, "") ?: ""
|
||||
}
|
||||
|
||||
fun saveNoBreastfeeding(content: Boolean) {
|
||||
sharedPreferences.edit { putBoolean(SHARED_PREFS_NO_BREASTFEEDING, content) }
|
||||
fun saveDynamicMenu(content: Boolean) {
|
||||
sharedPreferences.edit { putBoolean(SHARED_PREFS_DYNAMIC_MENU, content) }
|
||||
}
|
||||
|
||||
fun loadNoBreastfeeding(): Boolean {
|
||||
return sharedPreferences.getBoolean(SHARED_PREFS_NO_BREASTFEEDING, false)
|
||||
fun loadDynamicMenu(): Boolean {
|
||||
return sharedPreferences.getBoolean(SHARED_PREFS_DYNAMIC_MENU, false)
|
||||
}
|
||||
|
||||
fun saveDataRepository(repo: DATA_REPO) {
|
||||
|
||||
@@ -86,15 +86,16 @@
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linear_layout_row1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_bottle"
|
||||
android:id="@+id/button1_row1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="2"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="5dp"
|
||||
android:background="@drawable/button_background"
|
||||
android:gravity="center_horizontal"
|
||||
@@ -102,7 +103,7 @@
|
||||
android:text="@string/event_bottle_type"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_food"
|
||||
android:id="@+id/button2_row1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
@@ -115,77 +116,73 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/layout_nipples">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_nipple_left"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/button_background"
|
||||
android:gravity="center_horizontal"
|
||||
android:textSize="30sp"
|
||||
android:text="🤱⬅️"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_nipple_both"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/button_background"
|
||||
android:gravity="center_horizontal"
|
||||
android:textSize="30sp"
|
||||
android:text="🤱↔️"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_nipple_right"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/button_background"
|
||||
android:gravity="center_horizontal"
|
||||
android:textSize="30sp"
|
||||
android:text="🤱➡️️"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linear_layout_row2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_change_poo"
|
||||
android:id="@+id/button1_row2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:layout_weight="2"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/button_background"
|
||||
android:gravity="center_horizontal"
|
||||
android:textSize="30sp"
|
||||
android:text="🚼 💩"/>
|
||||
android:textSize="30sp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_change_pee"
|
||||
android:id="@+id/button2_row2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/button_background"
|
||||
android:gravity="center_horizontal"
|
||||
android:textSize="30sp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button3_row2"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/button_background"
|
||||
android:gravity="center_horizontal"
|
||||
android:textSize="30sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linear_layout_row3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button1_row3"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:layout_weight="2"
|
||||
android:background="@drawable/button_background"
|
||||
android:gravity="center_horizontal"
|
||||
android:textSize="30sp"
|
||||
android:text="🚼 💧"/>
|
||||
android:textSize="30sp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button2_row3"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:layout_weight="2"
|
||||
android:background="@drawable/button_background"
|
||||
android:gravity="center_horizontal"
|
||||
android:textSize="30sp"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/button_more"
|
||||
android:layout_width="0dp"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="5dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_weight="0"
|
||||
android:background="@drawable/button_background"
|
||||
android:gravity="center_horizontal"
|
||||
android:src="@drawable/ic_more"
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="@string/settings_signature_desc"/>
|
||||
|
||||
@@ -149,13 +149,13 @@
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/settings_no_breastfeeding" />
|
||||
android:text="@string/settings_dynamic_menu" />
|
||||
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/switch_no_breastfeeding"
|
||||
android:id="@+id/switch_dynamic_menu"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="20dp"
|
||||
@@ -166,9 +166,9 @@
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:text="@string/settings_no_breastfeeding_desc"/>
|
||||
android:text="@string/settings_dynamic_menu_desc"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
android:background="@color/transparent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
@@ -14,102 +15,12 @@
|
||||
android:id="@+id/button_statistics"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/dropdown_list_item_background"
|
||||
style="@style/OverflowMenuText"
|
||||
android:text="📊 Statistics"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_medicine"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/dropdown_list_item_background"
|
||||
style="@style/OverflowMenuText"
|
||||
android:text="@string/overflow_event_medicine"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_note"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/dropdown_list_item_background"
|
||||
style="@style/OverflowMenuText"
|
||||
android:text="@string/overflow_event_note"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_temperature"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/dropdown_list_item_background"
|
||||
style="@style/OverflowMenuText"
|
||||
android:text="@string/overflow_event_temperature"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_puke"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/dropdown_list_item_background"
|
||||
style="@style/OverflowMenuText"
|
||||
android:text="@string/overflow_event_puke"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_sleep"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/dropdown_list_item_background"
|
||||
style="@style/OverflowMenuText"
|
||||
android:text="@string/overflow_event_sleep"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_colic"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/dropdown_list_item_background"
|
||||
style="@style/OverflowMenuText"
|
||||
android:text="@string/overflow_event_colic"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_scale"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/dropdown_list_item_background"
|
||||
style="@style/OverflowMenuText"
|
||||
android:text="@string/overflow_event_weight"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_bath"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/dropdown_list_item_background"
|
||||
style="@style/OverflowMenuText"
|
||||
android:text="@string/overflow_event_bath"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/button_enema"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/dropdown_list_item_background"
|
||||
style="@style/OverflowMenuText"
|
||||
android:text="@string/overflow_event_enema"/>
|
||||
|
||||
<!-- Other buttons are inserted dynamically -->
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
11
app/src/main/res/layout/more_events_popup_item.xml
Normal file
11
app/src/main/res/layout/more_events_popup_item.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/tv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:padding="10dp"
|
||||
android:background="@drawable/dropdown_list_item_background"
|
||||
style="@style/OverflowMenuText"
|
||||
android:text="Item Template"/>
|
||||
@@ -3,12 +3,13 @@
|
||||
<string name="title">🌜 LunaTracker 🌛</string>
|
||||
<string name="logbook">Logged events</string>
|
||||
|
||||
<!-- menu header items -->
|
||||
<string name="event_bottle_type" translatable="false">🍼</string>
|
||||
<string name="event_food_type" translatable="false">🥣</string>
|
||||
<string name="event_weight_type" translatable="false">⚖️</string>
|
||||
<string name="event_breastfeeding_left_type" translatable="false">🤱 ←</string>
|
||||
<string name="event_breastfeeding_both_type" translatable="false">🤱 ↔</string>
|
||||
<string name="event_breastfeeding_right_type" translatable="false">🤱 →</string>
|
||||
<string name="event_breastfeeding_left_type" translatable="false">🤱⬅️</string>
|
||||
<string name="event_breastfeeding_both_type" translatable="false">🤱↔️</string>
|
||||
<string name="event_breastfeeding_right_type" translatable="false">🤱➡️️</string>
|
||||
<string name="event_diaperchange_poo_type" translatable="false">🚼 💩</string>
|
||||
<string name="event_diaperchange_pee_type" translatable="false">🚼 💧</string>
|
||||
<string name="event_medicine_type" translatable="false">💊</string>
|
||||
@@ -19,16 +20,36 @@
|
||||
<string name="event_puke_type" translatable="false">🤮</string>
|
||||
<string name="event_bath_type" translatable="false">🛁</string>
|
||||
<string name="event_sleep_type" translatable="false">💤</string>
|
||||
<string name="event_unknown_type" translatable="false">\?</string>
|
||||
<string name="event_unknown_type" translatable="false">❓</string>
|
||||
|
||||
<string name="event_bottle_desc">Baby bottle</string>
|
||||
<!-- dropdown menu item -->
|
||||
<string name="event_type_item_bottle">🍼 Bottle</string>
|
||||
<string name="event_type_item_food">🥣 Food</string>
|
||||
<string name="event_type_item_weight">⚖️ Weight</string>
|
||||
<string name="event_type_item_breastfeeding_left">🤱⬅️ Nursing</string>
|
||||
<string name="event_type_item_breastfeeding_both">🤱↔️ Nursing</string>
|
||||
<string name="event_type_item_breastfeeding_right">🤱➡️️ Nursing</string>
|
||||
<string name="event_type_item_diaperchange_poo">🚼💩 Diaper</string>
|
||||
<string name="event_type_item_diaperchange_pee">🚼💧 Diaper</string>
|
||||
<string name="event_type_item_medicine">💊 Medicine</string>
|
||||
<string name="event_type_item_enema">🪠 Enema</string>
|
||||
<string name="event_type_item_note">📝 Note</string>
|
||||
<string name="event_type_item_temperature">🌡️ Temperature</string>
|
||||
<string name="event_type_item_colic">💨 Colic</string>
|
||||
<string name="event_type_item_puke">🤮 Puke</string>
|
||||
<string name="event_type_item_sleep">💤 Sleep</string>
|
||||
<string name="event_type_item_bath">🛁 Bath</string>
|
||||
<string name="event_type_item_unknown">❓ Unknown</string>
|
||||
|
||||
<!-- dialog titles -->
|
||||
<string name="event_bottle_desc">Milk Bottle</string>
|
||||
<string name="event_food_desc">Food</string>
|
||||
<string name="event_weight_desc">Weight</string>
|
||||
<string name="event_breastfeeding_left_desc">Breastfeeding (left)</string>
|
||||
<string name="event_breastfeeding_both_desc">Breastfeeding</string>
|
||||
<string name="event_breastfeeding_right_desc">Breastfeeding (right)</string>
|
||||
<string name="event_diaperchange_poo_desc">Diaper chg (poo)</string>
|
||||
<string name="event_diaperchange_pee_desc">Diaper chg (pee)</string>
|
||||
<string name="event_breastfeeding_left_desc">Nursing (left)</string>
|
||||
<string name="event_breastfeeding_both_desc">Nursing (both)</string>
|
||||
<string name="event_breastfeeding_right_desc">Nursing (right)</string>
|
||||
<string name="event_diaperchange_poo_desc">Diaper Change (poo)</string>
|
||||
<string name="event_diaperchange_pee_desc">Diaper Change (pee)</string>
|
||||
<string name="event_medicine_desc">Medicine</string>
|
||||
<string name="event_enema_desc">Enema</string>
|
||||
<string name="event_note_desc">Note</string>
|
||||
@@ -37,17 +58,7 @@
|
||||
<string name="event_puke_desc">Puke</string>
|
||||
<string name="event_bath_desc">Bath</string>
|
||||
<string name="event_sleep_desc">Sleep</string>
|
||||
<string name="event_unknown_desc"></string>
|
||||
|
||||
<string name="overflow_event_weight">⚖️ Weight</string>
|
||||
<string name="overflow_event_medicine">💊 Medicine</string>
|
||||
<string name="overflow_event_enema">🪠 Enema</string>
|
||||
<string name="overflow_event_note">📝 Note</string>
|
||||
<string name="overflow_event_temperature">🌡️ Temperature</string>
|
||||
<string name="overflow_event_colic">💨 Gaseous colic</string>
|
||||
<string name="overflow_event_puke">🤮 Puke</string>
|
||||
<string name="overflow_event_sleep">💤 Sleep</string>
|
||||
<string name="overflow_event_bath">🛁 Bath</string>
|
||||
<string name="event_unknown_desc">Unknown</string>
|
||||
|
||||
<string name="toast_event_added">Event logged</string>
|
||||
<string name="toast_logbook_saved">Logbook saved</string>
|
||||
@@ -79,6 +90,8 @@
|
||||
|
||||
<string name="statistics_title">Statistics</string>
|
||||
|
||||
<string name="settings_dynamic_menu">Dynamic Menu</string>
|
||||
<string name="settings_dynamic_menu_desc">Populate the header menu with the most used events.</string>
|
||||
<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>
|
||||
@@ -97,8 +110,6 @@
|
||||
<string name="settings_webdav_error_generic">Error while trying to access WebDAV:</string>
|
||||
<string name="settings_webdav_creation_error_generic">Unable to save a file on the WebDAV server:</string>
|
||||
<string name="settings_webdav_creation_ok">Successfully connected with the WebDAV server</string>
|
||||
<string name="settings_no_breastfeeding">No Breastfeeding</string>
|
||||
<string name="settings_no_breastfeeding_desc">Hide the Breastfeeding buttons for when they are not needed.</string>
|
||||
<string name="settings_json_error">There\'s a save file on the server, but it is corrupted or unreadable. Please delete it </string>
|
||||
<string name="settings_generic_error">Error: </string>
|
||||
<string name="settings_webdav_upload_error">Error while uploading local logbook %1$s to webdav: %2$s</string>
|
||||
|
||||
Reference in New Issue
Block a user