Commit 380a56e3 authored by Dave Griffiths's avatar Dave Griffiths

sync fixes and defaults, minor tweaks and audio working as advertised

parent 1aad5d5d
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="foam.symbai"
android:versionCode="11"
android:versionCode="13"
android:versionName="1.0">
<application android:label="@string/app_name"
android:icon="@drawable/logo"
......
......@@ -431,7 +431,8 @@
(lambda (data)
(let ((new-entity-requests (build-entity-requests db table data)))
(alog "suck-new: marking dirty")
(mark-unlisted-entities-dirty! db table data)
;; now doing this first!...
;;(mark-unlisted-entities-dirty! db table data)
(alog "suck-new: done marking dirty")
(cond
((null? new-entity-requests)
......@@ -453,30 +454,41 @@
(msg "build-dirty defined...")
(define (build-dirty db)
(let ((sync (get-dirty-stats db "sync"))
(stream (get-dirty-stats db "stream")))
(let ((sync (get-dirty-stats db "sync")))
(string-append
"Sync data: " (number->string (car sync)) "/" (number->string (cadr sync)) " "
"Stream data: " (number->string (car stream)) "/" (number->string (cadr stream)))))
"Sync data: " (number->string (car sync)) "/" (number->string (cadr sync)))))
(define (upload-dirty db)
(let ((r (append
(spit db "sync" (dirty-entities db "sync"))
(spit db "stream" (dirty-entities db "stream")))))
(append (cond
((> (length r) 0)
(debug! (string-append "Uploading " (number->string (length r)) " items..."))
(list
(toast "Uploading data...")
(play-sound "active")))
(else
(debug! "No data changed to upload")
(set-current! 'upload 1)
(append
(if (eqv? (get-current 'download 0) 1)
(list (play-sound "ping")) '())
(list
(toast "No data changed to upload"))))) r)))
(list
;; first check server for entities it doesn't have at all
;; (they need all attr marked as dirty
(http-request
"upload-precheck-req"
(string-append url "fn=entity-versions&table=sync")
(lambda (data)
;; todo - this is really slow and we're doing it all the time
;; if there are loads to do it's bad
(msg "checking for unlisted")
(mark-unlisted-entities-dirty! db "sync" data)
(let ((r (append
(spit db "sync" (dirty-entities db "sync"))
(spit db "stream" (dirty-entities db "stream")))))
(append (cond
((> (length r) 0)
(debug! (string-append "Uploading " (number->string (length r)) " items..."))
(list
(toast "Uploading data...")
(play-sound "active")))
(else
(debug! "No data changed to upload")
(set-current! 'upload 1)
(append
(if (eqv? (get-current 'download 0) 1)
(list (play-sound "ping")) '())
(list
(toast "No data changed to upload"))))) r))))))
(define (connect-to-net fn)
(list
......
......@@ -96,17 +96,17 @@
(ktv "name" "varchar" "")
(ktv "notes" "varchar" "")
(ktv "agreement" "file" "")
(ktv "num-pots" "int" 0)
(ktv "num-male-children" "int" 0)
(ktv "num-female-children" "int" 0)
(ktv "num-male-adults" "int" 0)
(ktv "num-female-adults" "int" 0)
(ktv "num-pots" "int" -1)
(ktv "num-male-children" "int" -1)
(ktv "num-female-children" "int" -1)
(ktv "num-male-adults" "int" -1)
(ktv "num-female-adults" "int" -1)
(ktv "house-lat" "real" 0) ;; get from current location?
(ktv "house-lon" "real" 0)
(ktv "radio" "varchar" "not-set")
(ktv "tv" "varchar" "not-set")
(ktv "mobile" "varchar" "not-set")
(ktv "locality" "varchar" "not-set")
(ktv "locality" "varchar" "")
(ktv "house-type" "varchar" "not-set")
(ktv "toilet-lat" "real" 0)
(ktv "toilet-lon" "real" 0)))
......@@ -217,8 +217,8 @@
(ktv "name" "varchar" (mtext-lookup 'default-crop-name))
(ktv "notes" "varchar" "")
(ktv "unit" "varchar" "unit")
(ktv "used" "real" -1)
(ktv "sold" "real" -1)
(ktv "used" "real" 0)
(ktv "sold" "real" 0)
(ktv "seed" "varchar" "")))
(define child-ktvlist
......@@ -1558,7 +1558,7 @@
(mspinner 'child-gender gender-list (lambda (v) (entity-set-value! "gender" "varchar" (spinner-choice gender-list v)) '()))
(medit-text 'child-age "numeric" (lambda (v) (entity-set-value! "age" "int" (string->number v)) '())))
(horiz
(mspinner-other 'child-alive yesno-list (lambda (v) (entity-set-value! "alive" "varchar" (spinner-choice yesno-list v)) '()))
(mspinner 'child-alive yesno-list (lambda (v) (entity-set-value! "alive" "varchar" (spinner-choice yesno-list v)) '()))
(mspinner-other 'child-home yesno-list (lambda (v) (entity-set-value! "living-at-home" "varchar" (spinner-choice yesno-list v)) '())))
(medit-text-large 'child-notes "normal" (lambda (v) (entity-set-value! "notes" "varchar" v) '()))
(delete-button)))
......@@ -1576,7 +1576,7 @@
(mupdate 'edit-text 'child-age "age")
(mupdate 'edit-text 'child-notes "notes")
(mupdate-spinner 'child-alive "alive" yesno-list)
(mupdate-spnner 'child-home "living-at-home" yesno-list)
(mupdate-spinner-other 'child-home "living-at-home" yesno-list)
)))
(lambda (activity) '())
......@@ -1715,7 +1715,6 @@
(social-connection-return requestcode "friendship-five" social-request-code-five)
'()))
;; todo: stop/rec/play on exit
(activity
"agreement"
(build-activity
......@@ -1727,11 +1726,9 @@
(horiz
(image-button (make-id "agree-record") "record" (layout 'wrap-content 'wrap-content 1 'centre 0)
(lambda ()
(let ((filename (string-append
"sdcard/symbai/files/"
(entity-get-value "unique_id") "-" (get-unique (get-current 'agreement-key "")) "-record.3gp")))
(let ((filename (entity-get-value "unique_id") "-" (get-unique (get-current 'agreement-key "")) "-record.3gp"))
(entity-set-value! (get-current 'agreement-key "") "file" filename)
(list (soundfile-start-recording filename)
(list (soundfile-start-recording (string-append "sdcard/symbai/files/" filename))
(update-widget 'text-view (get-id "agreement-state") 'text "RECORDING")
))))
......@@ -1739,7 +1736,7 @@
(lambda ()
(if (equal? (entity-get-value (get-current 'agreement-key "")) "")
'()
(list (soundfile-start-playback (entity-get-value (get-current 'agreement-key "")))
(list (soundfile-start-playback (string-append "sdcard/symbai/files/" (entity-get-value (get-current 'agreement-key ""))))
(update-widget 'text-view (get-id "agreement-state") 'text "Playing recording")
))))
......@@ -1783,8 +1780,14 @@
))
(lambda (activity) '())
(lambda (activity) '())
(lambda (activity) '())
(lambda (activity)
(list
(soundfile-stop-playback)
(soundfile-stop-recording)))
(lambda (activity)
(list
(soundfile-stop-playback)
(soundfile-stop-recording)))
(lambda (activity) '())
(lambda (activity requestcode resultcode)
'()))
......
......@@ -112,16 +112,18 @@
(define (all-entities db table type)
(msg "all-entities" type)
(let ((s (db-select
db (string-append "select e.entity_id from " table "_entity as e "
db (dbg (string-append "select e.entity_id from " table "_entity as e "
"join " table "_value_varchar "
" as n on n.entity_id = e.entity_id and n.attribute_id = ?"
" as n on n.entity_id = e.entity_id and n.attribute_id = ? "
"left join " table "_value_int "
"as d on d.entity_id = e.entity_id and d.attribute_id = ? "
"where e.entity_type = ? "
"and (d.value='NULL' or d.value is NULL or d.value = 0) "
"order by n.value")
"order by n.value"))
"name" "deleted" type)))
(msg s)
(msg (db-status db))
(if (null? s)
'()
......
......@@ -66,6 +66,8 @@
(define (dirtify-entity-values db table entity-id)
;;(msg "clean-entity-values")
(semaphore-wait entity-sema)
(db-exec db "begin transaction")
(let* ((entity-type (get-entity-type db table entity-id)))
(cond
((null? entity-type)
......@@ -74,7 +76,9 @@
(for-each
(lambda (kt)
(dirtify-value db table entity-id (list (ktv-key kt) (ktv-type kt))))
(get-attribute-ids/types db table entity-type))))))
(get-attribute-ids/types db table entity-type)))))
(db-exec db "end transaction")
(semaphore-post entity-sema))
;; update an entity, via a (possibly partial) list of key/value pairs
;; if dirty is not true, this is coming from a sync
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment