Commit d8230d01 authored by Dave Griffiths's avatar Dave Griffiths
Browse files

sync loop and new sound

parent 870a616c
...@@ -303,7 +303,9 @@ ...@@ -303,7 +303,9 @@
(debug! (string-append (debug! (string-append
"Requesting " "Requesting "
(number->string (length r)) " entities")) (number->string (length r)) " entities"))
r))))))) (cons
(play-sound "active")
r))))))))
(define (build-dirty) (define (build-dirty)
(let ((sync (get-dirty-stats db "sync")) (let ((sync (get-dirty-stats db "sync"))
...@@ -320,7 +322,8 @@ ...@@ -320,7 +322,8 @@
((> (length r) 0) ((> (length r) 0)
(debug! (string-append "Uploading " (number->string (length r)) " items...")) (debug! (string-append "Uploading " (number->string (length r)) " items..."))
(list (list
(toast "Uploading data..."))) (toast "Uploading data...")
(play-sound "active")))
(else (else
(debug! "No data changed to upload") (debug! "No data changed to upload")
(set-current! 'upload 1) (set-current! 'upload 1)
...@@ -517,9 +520,21 @@ ...@@ -517,9 +520,21 @@
(get-current 'debug-text ""))) (get-current 'debug-text "")))
(define (debug-timer-cb) (define (debug-timer-cb)
(list (append
(delayed "debug-timer" 1000 debug-timer-cb) (cond
(update-debug))) ((get-current 'sync-on #f)
(set-current! 'upload 0)
(set-current! 'download 0)
(connect-to-net
(lambda ()
(append
(list (toast "sync-cb"))
(upload-dirty db)
(suck-new db "sync")))))
(else '()))
(list
(delayed "debug-timer" (+ 5000 (random 5000)) debug-timer-cb)
(update-debug))))
(define pf-length 20) ;; minutes... (define pf-length 20) ;; minutes...
...@@ -1826,16 +1841,7 @@ ...@@ -1826,16 +1841,7 @@
(text-view (make-id "sync-title") "Sync database" 40 fillwrap) (text-view (make-id "sync-title") "Sync database" 40 fillwrap)
(mtext "sync-dirty" "...") (mtext "sync-dirty" "...")
(horiz (horiz
(mbutton2 "sync-all" "Sync me" (mtoggle-button2 "sync-all" "Sync me" (lambda (v) (set-current! 'sync-on v)))
(lambda ()
(set-current! 'upload 0)
(set-current! 'download 0)
(connect-to-net
(lambda ()
(append
(upload-dirty db)
(suck-new db "sync"))))))
(mbutton2 "sync-syncall" "Push all" (mbutton2 "sync-syncall" "Push all"
(lambda () (lambda ()
(let ((r (append (let ((r (append
...@@ -1903,6 +1909,7 @@ ...@@ -1903,6 +1909,7 @@
(lambda (activity arg) (lambda (activity arg)
(activity-layout activity)) (activity-layout activity))
(lambda (activity arg) (lambda (activity arg)
(set-current! 'sync-on #f)
(append (append
(debug-timer-cb) (debug-timer-cb)
(list (list
......
...@@ -690,8 +690,16 @@ public class StarwispBuilder ...@@ -690,8 +690,16 @@ public class StarwispBuilder
} }
if (token.equals("play-sound")) { if (token.equals("play-sound")) {
MediaPlayer mp = MediaPlayer.create(ctx, R.raw.ping); String name = arr.getString(3);
mp.start();
if (name.equals("ping")) {
MediaPlayer mp = MediaPlayer.create(ctx, R.raw.ping);
mp.start();
}
if (name.equals("active")) {
MediaPlayer mp = MediaPlayer.create(ctx, R.raw.active);
mp.start();
}
} }
if (token.equals("vibrate")) { if (token.equals("vibrate")) {
......
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