diff --git a/app/src/main/java/it/danieleverducci/lunatracker/MainActivity.kt b/app/src/main/java/it/danieleverducci/lunatracker/MainActivity.kt
index 5cd47be..5136186 100644
--- a/app/src/main/java/it/danieleverducci/lunatracker/MainActivity.kt
+++ b/app/src/main/java/it/danieleverducci/lunatracker/MainActivity.kt
@@ -373,9 +373,48 @@ class MainActivity : AppCompatActivity() {
}
fun addLogbook(logbookName: String) {
- this.logbook = Logbook(logbookName)
- saveLogbook()
- loadLogbookList() // TODO: Does not reload logbooks buttons on top, why?
+ val newLogbook = Logbook(logbookName)
+ setLoading(true)
+ logbookRepo?.saveLogbook(this, newLogbook, object: LogbookSavedListener{
+ override fun onLogbookSaved() {
+ Log.d(TAG, "Logbook $logbookName created")
+ runOnUiThread({
+ setLoading(false)
+ loadLogbookList()
+ Toast.makeText(this@MainActivity, getString(R.string.logbook_created) + logbookName, Toast.LENGTH_SHORT).show()
+ })
+ }
+
+ override fun onIOError(error: IOException) {
+ runOnUiThread({
+ onRepoError(getString(R.string.settings_network_error) + error.toString())
+ })
+ }
+
+ override fun onWebDAVError(error: SardineException) {
+ runOnUiThread({
+ onRepoError(
+ if(error.toString().contains("401")) {
+ getString(R.string.settings_webdav_error_denied)
+ } else {
+ getString(R.string.settings_webdav_error_generic) + error.toString()
+ }
+ )
+ })
+ }
+
+ override fun onJSONError(error: JSONException) {
+ runOnUiThread({
+ onRepoError(getString(R.string.settings_json_error) + error.toString())
+ })
+ }
+
+ override fun onError(error: Exception) {
+ runOnUiThread({
+ onRepoError(getString(R.string.settings_generic_error) + error.toString())
+ })
+ }
+ })
}
fun loadLogbook(name: String) {
diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml
index 848aa0d..71cb441 100644
--- a/app/src/main/res/values-it/strings.xml
+++ b/app/src/main/res/values-it/strings.xml
@@ -81,9 +81,10 @@
Dettaglio evento
Aggiungi diario
- Nome del diario
- 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.
+ 👶 Nome del diario
+ 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.\nSe vuoi un\'icona, inserisci una emoji!
👶 Il mio primo diario
+ Creato nuovo diario:
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index fa31134..66fa8bc 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -104,9 +104,10 @@
Event detail
Add logbook
- Logbook name
+ 👶 Logbook name
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.
👶 My first logbook
+ New logbook created:
\ No newline at end of file