Compare commits
4 Commits
32fbeac079
...
e23ab77274
Author | SHA1 | Date | |
---|---|---|---|
e23ab77274 | |||
e3aceaf133 | |||
0494a11538 | |||
ecbde64ca1 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -106,3 +106,4 @@ app/release/output-metadata.json
|
||||
|
||||
# Other
|
||||
app/src/main/java/it/danieleverducci/lunatracker/TemporaryHardcodedCredentials.kt
|
||||
.kotlin/sessions/*
|
||||
|
@ -7,13 +7,18 @@ import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.AdapterView
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.EditText
|
||||
import android.widget.NumberPicker
|
||||
import android.widget.PopupWindow
|
||||
import android.widget.Spinner
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.children
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.progressindicator.LinearProgressIndicator
|
||||
@ -78,6 +83,7 @@ class MainActivity : AppCompatActivity() {
|
||||
recyclerView.adapter = adapter
|
||||
|
||||
// Set listeners
|
||||
findViewById<View>(R.id.logbooks_add_button).setOnClickListener { showAddLogbookDialog() }
|
||||
findViewById<View>(R.id.button_bottle).setOnClickListener { askBabyBottleContent() }
|
||||
findViewById<View>(R.id.button_scale).setOnClickListener { askWeightValue() }
|
||||
findViewById<View>(R.id.button_nipple_left).setOnClickListener { logEvent(
|
||||
@ -322,36 +328,33 @@ class MainActivity : AppCompatActivity() {
|
||||
logbookRepo?.listLogbooks(this, object: LogbookListObtainedListener {
|
||||
override fun onLogbookListObtained(logbooksNames: ArrayList<String>) {
|
||||
runOnUiThread({
|
||||
// Show logbooks buttons
|
||||
val logbooksButtonsContainer =
|
||||
findViewById<ViewGroup>(R.id.logbooks_buttons_container)
|
||||
logbooksButtonsContainer.removeAllViews()
|
||||
for (lbn in logbooksNames) {
|
||||
val lbnButton = layoutInflater.inflate(
|
||||
R.layout.logbook_button,
|
||||
logbooksButtonsContainer,
|
||||
false
|
||||
) as TextView
|
||||
lbnButton.setText(
|
||||
if (lbn.isEmpty()) getString(R.string.default_logbook_name) else lbn
|
||||
// Show logbooks dropdown
|
||||
val spinner = findViewById<Spinner>(R.id.logbooks_spinner)
|
||||
val sAdapter = ArrayAdapter<String>(this@MainActivity, android.R.layout.simple_spinner_item)
|
||||
sAdapter.setDropDownViewResource(R.layout.row_logbook_spinner)
|
||||
for (ln in logbooksNames) {
|
||||
sAdapter.add(
|
||||
if (ln.isEmpty()) getString(R.string.default_logbook_name) else ln
|
||||
)
|
||||
lbnButton.setOnClickListener({
|
||||
loadLogbook(lbn)
|
||||
})
|
||||
logbooksButtonsContainer.addView(lbnButton)
|
||||
}
|
||||
// Show "Add logbook" button
|
||||
val addLogbookButton = layoutInflater.inflate(
|
||||
R.layout.logbook_button,
|
||||
logbooksButtonsContainer,
|
||||
false
|
||||
) as TextView
|
||||
addLogbookButton.setText("+")
|
||||
addLogbookButton.setOnClickListener({showAddLogbookDialog()})
|
||||
logbooksButtonsContainer.addView(addLogbookButton)
|
||||
spinner.adapter = sAdapter
|
||||
spinner.onItemSelectedListener = object: AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(
|
||||
parent: AdapterView<*>?,
|
||||
view: View?,
|
||||
position: Int,
|
||||
id: Long
|
||||
) {
|
||||
// Changed logbook: empty list
|
||||
adapter.items.clear()
|
||||
adapter.notifyDataSetChanged()
|
||||
// Load logbook
|
||||
loadLogbook(logbooksNames.get(position))
|
||||
}
|
||||
|
||||
// Load logbook
|
||||
loadLogbook()
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {}
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -372,15 +375,13 @@ class MainActivity : AppCompatActivity() {
|
||||
fun addLogbook(logbookName: String) {
|
||||
this.logbook = Logbook(logbookName)
|
||||
saveLogbook()
|
||||
loadLogbookList()
|
||||
loadLogbookList() // TODO: Does not reload logbooks buttons on top, why?
|
||||
}
|
||||
|
||||
fun loadLogbook(name: String = LogbookRepository.DEFAULT_LOGBOOK_NAME) {
|
||||
if (savingEvent)
|
||||
return
|
||||
|
||||
// TODO: Highlight logbook button
|
||||
|
||||
// Reset time counter
|
||||
handler.removeCallbacks(updateListRunnable)
|
||||
handler.postDelayed(updateListRunnable, UPDATE_EVERY_SECS*1000)
|
||||
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@drawable/dropdown_list_item_background_pressed"/>
|
||||
<item android:drawable="@drawable/dropdown_list_item_background_released"/>
|
||||
</selector>
|
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="@color/grey" />
|
||||
<solid
|
||||
android:color="@color/grey" />
|
||||
<corners android:radius="15dp" />
|
||||
<padding
|
||||
android:bottom="5dp"
|
||||
android:left="5dp"
|
||||
android:right="5dp"
|
||||
android:top="5dp" />
|
||||
</shape>
|
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<stroke
|
||||
android:width="2dp"
|
||||
android:color="@color/grey" />
|
||||
<solid
|
||||
android:color="@color/cardview_dark_background"/>
|
||||
<corners android:radius="15dp" />
|
||||
<padding
|
||||
android:bottom="5dp"
|
||||
android:left="5dp"
|
||||
android:right="5dp"
|
||||
android:top="5dp" />
|
||||
</shape>
|
@ -7,32 +7,77 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="30dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingLeft="15dp"
|
||||
android:paddingRight="15dp">
|
||||
|
||||
<TextView
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/title"
|
||||
android:textSize="30dp"
|
||||
android:gravity="center_horizontal"/>
|
||||
|
||||
<HorizontalScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginBottom="10dp">
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/logbooks_buttons_container"
|
||||
<ImageView
|
||||
android:id="@+id/button_settings"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
android:padding="10dp"
|
||||
android:layout_gravity="end"
|
||||
android:src="@drawable/ic_settings"
|
||||
app:tint="@color/grey"/>
|
||||
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/title"
|
||||
android:textSize="26dp"
|
||||
android:gravity="center"/>
|
||||
|
||||
</HorizontalScrollView>
|
||||
<ImageView
|
||||
android:id="@+id/button_sync"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:layout_gravity="start"
|
||||
android:src="@drawable/ic_sync"
|
||||
app:tint="@color/grey"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="38dp"
|
||||
android:layout_margin="10dp"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/button_background">
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/logbooks_spinner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/logbooks_add_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/accent"
|
||||
android:textSize="20dp"
|
||||
android:text="+"
|
||||
android:background="@drawable/button_background"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
@ -180,24 +225,6 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/button_settings"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:layout_gravity="end"
|
||||
android:src="@drawable/ic_settings"
|
||||
app:tint="@color/grey"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/button_sync"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="10dp"
|
||||
android:layout_gravity="start"
|
||||
android:src="@drawable/ic_sync"
|
||||
app:tint="@color/grey"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/no_connection_screen"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingLeft="20dp"
|
||||
android:paddingRight="20dp"
|
||||
android:background="@drawable/button_background"
|
||||
android:textStyle="bold"
|
||||
android:textColor="@color/accent"/>
|
@ -15,7 +15,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="20dp"
|
||||
android:background="@drawable/button_background"
|
||||
android:background="@drawable/dropdown_list_item_background"
|
||||
style="@style/OverflowMenuText"
|
||||
android:text="@string/overflow_event_medicine"/>
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:padding="20dp"
|
||||
android:background="@drawable/button_background"
|
||||
android:background="@drawable/dropdown_list_item_background"
|
||||
style="@style/OverflowMenuText"
|
||||
android:text="@string/overflow_event_enema"/>
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:padding="20dp"
|
||||
android:background="@drawable/button_background"
|
||||
android:background="@drawable/dropdown_list_item_background"
|
||||
style="@style/OverflowMenuText"
|
||||
android:text="@string/overflow_event_note"/>
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:padding="20dp"
|
||||
android:background="@drawable/button_background"
|
||||
android:background="@drawable/dropdown_list_item_background"
|
||||
style="@style/OverflowMenuText"
|
||||
android:text="@string/overflow_event_temperature"/>
|
||||
|
||||
@ -55,7 +55,7 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="10dp"
|
||||
android:padding="20dp"
|
||||
android:background="@drawable/button_background"
|
||||
android:background="@drawable/dropdown_list_item_background"
|
||||
style="@style/OverflowMenuText"
|
||||
android:text="@string/overflow_event_colic"/>
|
||||
|
||||
|
11
app/src/main/res/layout/row_logbook_spinner.xml
Normal file
11
app/src/main/res/layout/row_logbook_spinner.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="@android:id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="20dp"
|
||||
android:paddingEnd="20dp"
|
||||
android:paddingTop="20dp"
|
||||
android:paddingBottom="20dp"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="end"/>
|
@ -84,6 +84,6 @@
|
||||
<string name="dialog_add_logbook_logbookname">Nome del diario</string>
|
||||
<string name="dialog_add_logbook_message">Scrivi un nome per identificare questo diario. Comparirà in cima allo schermo, e se usi WebDAV sarà incluso anche nel nome del file di salvataggio.</string>
|
||||
|
||||
<string name="default_logbook_name">Senza nome</string>
|
||||
<string name="default_logbook_name">👶 Il mio primo diario</string>
|
||||
|
||||
</resources>
|
@ -107,6 +107,6 @@
|
||||
<string name="dialog_add_logbook_logbookname">Logbook name</string>
|
||||
<string name="dialog_add_logbook_message">Write a name to identify this logbook. This name will appear on top of the screen and, if you use WebDAV, will be in the save file name as well.</string>
|
||||
|
||||
<string name="default_logbook_name">Unnamed</string>
|
||||
<string name="default_logbook_name">👶 My first logbook</string>
|
||||
|
||||
</resources>
|
Loading…
x
Reference in New Issue
Block a user