starwisp.scm 38.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
;; Starwisp Copyright (C) 2013 Dave Griffiths
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU Affero General Public License as
;; published by the Free Software Foundation, either version 3 of the
;; License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU Affero General Public License for more details.
;;
;; You should have received a copy of the GNU Affero General Public License
;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; strings

(define obs-gc "Group Composition")
(define obs-pf "Pup Focal")

(define (get-fragment-index name frag)
  (define (_ i l)
    (cond
     ((null? l) 0)
     ((equal? name (cadr (car l))) i)
     (else (_ (+ i 1) (cdr l)))))
  (_ 0 frag))

(define gc-fragments
  (list
   (list "Start" "gc-start")
   (list "Weights" "gc-weights")
   (list "Pregnant" "gc-preg")
35
   (list "Pup assoc" "gc-pup-assoc")
36 37 38 39
   (list "Oestrus" "gc-oestrus")
   (list "Babysit" "gc-babysitting")
   (list "End" "gc-end")))

40
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Dave Griffiths's avatar
Dave Griffiths committed
41
;; persistent database
42

Dave Griffiths's avatar
Dave Griffiths committed
43 44
(define db "/sdcard/test.db")
(db-open db)
45 46 47 48 49 50 51 52 53 54
(setup db "local")
(setup db "sync")
(setup db "stream")

(insert-entity-if-not-exists
 db "local" "app-settings" "null" 1
 (list
  (ktv "user-id" "varchar" "No name yet...")))

(display (db-all db "local" "app-settings"))(newline)
Dave Griffiths's avatar
Dave Griffiths committed
55

Dave Griffiths's avatar
Dave Griffiths committed
56 57
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; stuff in memory
Dave Griffiths's avatar
Dave Griffiths committed
58

Dave Griffiths's avatar
Dave Griffiths committed
59 60
(define (store-set store key value)
  (cond
61 62 63 64 65
   ((null? store) (list (list key value)))
   ((eq? key (car (car store)))
    (cons (list key value) (cdr store)))
   (else
    (cons (car store) (store-set (cdr store) key value)))))
Dave Griffiths's avatar
Dave Griffiths committed
66

Dave Griffiths's avatar
Dave Griffiths committed
67
(define (store-get store key default)
Dave Griffiths's avatar
Dave Griffiths committed
68
  (cond
69 70 71 72 73 74 75 76 77 78 79 80 81
   ((null? store) default)
   ((eq? key (car (car store)))
    (cadr (car store)))
   (else
    (store-get (cdr store) key default))))

(define (store-exists? store key)
  (cond
   ((null? store) #f)
   ((eq? key (car (car store)))
    #t)
   (else
    (store-exists? (cdr store) key))))
Dave Griffiths's avatar
Dave Griffiths committed
82 83


Dave Griffiths's avatar
Dave Griffiths committed
84
(define store '())
Dave Griffiths's avatar
Dave Griffiths committed
85

Dave Griffiths's avatar
Dave Griffiths committed
86 87
(define (set-current! key value)
  (set! store (store-set store key value)))
Dave Griffiths's avatar
Dave Griffiths committed
88

Dave Griffiths's avatar
Dave Griffiths committed
89 90
(define (get-current key default)
  (store-get store key default))
Dave Griffiths's avatar
Dave Griffiths committed
91

92 93 94
(define (current-exists? key)
  (store-exists? store key))

Dave Griffiths's avatar
Dave Griffiths committed
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; syncing code

(define url "http://192.168.2.1:8888/mongoose?")

(define (build-url-from-ktv ktv)
  (string-append "&" (ktv-key ktv) ":" (ktv-type ktv) "=" (stringify-value-url ktv)))

(define (build-url-from-ktvlist ktvlist)
  (foldl
   (lambda (ktv r)
     (string-append r (build-url-from-ktv ktv)))
   "" ktvlist))

(define (build-url-from-entity table e)
  (string-append
   url
   "fn=sync"
   "&table=" table
   "&entity-type=" (list-ref (car e) 0)
   "&unique-id=" (list-ref (car e) 1)
Dave Griffiths's avatar
Dave Griffiths committed
116 117
   "&dirty=" (number->string (list-ref (car e) 2))
   "&version=" (number->string (list-ref (car e) 3))
Dave Griffiths's avatar
Dave Griffiths committed
118 119 120 121 122 123 124 125 126 127 128 129
   (build-url-from-ktvlist (cadr e))))

;; spit all dirty entities to server
(define (spit-dirty db table)
  (map
   (lambda (e)
     (http-request
      (string-append "req-" (list-ref (car e) 1))
      (build-url-from-entity table e)
      (lambda (v)
        (display v)(newline)
        (if (equal? (car v) "inserted")
Dave Griffiths's avatar
Dave Griffiths committed
130 131 132 133
            (begin
              (update-entity-clean db table (cadr v))
              (toast "Uploaded " (ktv-get (cadr e) "name")))
            (toast "Problem uploading " (ktv-get (cadr e) "name"))))))
134
   (dirty-entities db table)))
Dave Griffiths's avatar
Dave Griffiths committed
135

136
(define (suck-entity-from-server db table unique-id exists)
Dave Griffiths's avatar
Dave Griffiths committed
137 138 139 140 141 142 143
  ;; ask for the current version
  (http-request
   (string-append unique-id "-update-new")
   (string-append url "fn=entity&table=" table "&unique-id=" unique-id)
   (lambda (data)
     (msg "data from server request" data)
     ;; check "sync-insert" in sync.ss raspberry pi-side for the contents of 'entity'
144 145
     (let ((entity (list-ref data 0))
           (ktvlist (list-ref data 1)))
Dave Griffiths's avatar
Dave Griffiths committed
146
       (if (not exists)
147 148 149 150 151 152 153 154
           (begin
             (insert-entity-wholesale
              db table
              (list-ref entity 0) ;; entity-type
              (list-ref entity 1) ;; unique-id
              0 ;; dirty
              (list-ref entity 2) ;; version
              ktvlist))
Dave Griffiths's avatar
Dave Griffiths committed
155 156
           (update-to-version
            db table (get-entity-id db table unique-id)
Dave Griffiths's avatar
Dave Griffiths committed
157 158 159 160
            (list-ref entity 4) ktvlist))
       (list
        (update-widget 'text-view (get-id "sync-dirty") 'text (build-dirty))
        (toast (string-append "Downloaded " (ktv-get ktvlist "name"))))))))
Dave Griffiths's avatar
Dave Griffiths committed
161

Dave Griffiths's avatar
Dave Griffiths committed
162
;; repeatedly read version and request updates
Dave Griffiths's avatar
Dave Griffiths committed
163
(define (suck-new db table)
Dave Griffiths's avatar
Dave Griffiths committed
164 165 166
  (list
   (http-request
    "new-entities-req"
167
    (string-append url "fn=entity-versions&table=" table)
Dave Griffiths's avatar
Dave Griffiths committed
168
    (lambda (data)
Dave Griffiths's avatar
Dave Griffiths committed
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
      (let ((r (foldl
                (lambda (i r)
                  (let* ((unique-id (car i))
                         (version (cadr i))
                         (exists (entity-exists? db table unique-id))
                         (old
                          (if exists
                              (> version (get-entity-version
                                          db table
                                          (get-entity-id db table unique-id)))
                              #f)))
                    ;; if we don't have this entity or the version on the server is newer
                    (if (or (not exists) old)
                        (cons (suck-entity-from-server db table unique-id exists) r)
                        r)))
                '()
                data)))
        (if (null? r)
            (cons (toast "All files up to date") r)
            (cons (toast "Requesting " (length r) " entities") r)))))))
Dave Griffiths's avatar
Dave Griffiths committed
189

190 191 192 193 194 195 196 197 198
(define (build-dirty)
  (let ((sync (get-dirty-stats db "sync"))
        (stream (get-dirty-stats db "stream")))
    (msg sync stream)
    (string-append
     "Pack data: " (number->string (car sync)) "/" (number->string (cadr sync)) " "
     "Focal data: " (number->string (car stream)) "/" (number->string (cadr stream)))))


Dave Griffiths's avatar
Dave Griffiths committed
199
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
200
;; user interface abstraction
Dave Griffiths's avatar
Dave Griffiths committed
201

Dave Griffiths's avatar
Dave Griffiths committed
202 203 204
(define (mbutton id title fn)
  (button (make-id id) title 20 fillwrap fn))

205
(define (mbutton2 id title fn)
206
  (button (make-id id) title 20 (layout 100 100 1 'centre) fn))
207

208 209 210
(define (mtoggle-button id title fn)
  (toggle-button (make-id id) title 20 fillwrap fn))

211 212 213
(define (mtoggle-button2 id title fn)
  (toggle-button (make-id id) title 20 (layout 100 100 1 'centre) fn))

Dave Griffiths's avatar
Dave Griffiths committed
214 215
(define (mtext id text)
  (text-view (make-id id) text 20 fillwrap))
216

217 218 219
(define (mtitle id text)
  (text-view (make-id id) text 40 fillwrap))

220 221
(define (medit-text id text type fn)
  (vert
222 223
   (mtext (string-append id "-title") text)
   (edit-text (make-id id) "" 20 type fillwrap fn)))
224 225 226 227 228 229 230

(define (mclear-toggles id-list)
  (map
   (lambda (id)
     (update-widget 'toggle-button (get-id id) 'checked 0))
   id-list))

231 232 233 234 235 236 237
(define (mclear-toggles-not-me me id-list)
  (foldl
   (lambda (id r)
     (if (equal? me id)
         r (cons (update-widget 'toggle-button (get-id id) 'checked 0) r)))
   '() id-list))

238 239 240 241 242 243 244 245 246 247
(define (xwise n l)
  (define (_ c l)
    (cond
      ((null? l) (if (null? c) '() (list c)))
      ((eqv? (length c) (- n 1))
       (cons (append c (list (car l))) (_ '() (cdr l))))
      (else
       (_ (append c (list (car l))) (cdr l)))))
  (_ '() l))

248
(define (build-grid-selector name type title)
249
  (vert
250
   (mtext "title" title)
251 252 253 254 255 256 257 258
   (horiz
    (image-view (make-id "im") "arrow_left" (layout 100 'fill-parent 1 'left))
    (scroll-view
     (make-id "scroller")
     (layout 'wrap-content 'wrap-content 1 'left)
     (list
      (linear-layout
       (make-id name) 'horizontal
259 260 261 262
       (layout 'wrap-content 'wrap-content 1 'centre)
       (list
        (button-grid (make-id name) type 3 20 (layout 100 40 1 'left)
                     (list) (lambda (v) '()))))))
263 264
    (image-view (make-id "im") "arrow_right" (layout 100 'fill-parent 1 'right)))))

265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
(define (fast-get-name item)
  (list-ref (list-ref item 1) 2))

(define (populate-grid-selector name type items fn)
  (let ((id->items
         (map
          (lambda (item)
            (let ((item-name (fast-get-name item)))
              (list (make-id (string-append name item-name))
                           item
                           item-name)))
          items)))
    (update-widget
     'button-grid (get-id name) 'grid-buttons
     (list
      type 3 20 (layout 100 40 1 'left)
      (map
       (lambda (ii)
         (list (car ii) (caddr ii)))
       id->items)
      (lambda (v)
        (fn (cadr (findv v id->items))))))))
287 288 289

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
Dave Griffiths's avatar
Dave Griffiths committed
290

291 292
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; fragments
Dave Griffiths's avatar
Dave Griffiths committed
293 294 295

(define-fragment-list

296 297 298 299 300 301
  (fragment
   "pf-timer"
   (linear-layout
    (make-id "") 'vertical fillwrap
    (list
     (mtitle "title" "Time left: 20 mins")
302
     (mtitle "title" "Next scan: 60 secs")
303
     (mbutton "pft-trigger" "NN scan"
304
              (lambda () (list (replace-fragment (get-id "pf-top") "pf-scan1"))))))
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331
   (lambda (fragment arg)
     (activity-layout fragment))
   (lambda (fragment arg)
     (list))
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '()))


  (fragment
   "pf-events"
   (linear-layout
    (make-id "") 'vertical fillwrap
    (list
     (mtext "text" "Pup Focal Events")
     (horiz
      (mbutton2 "evb-pupfeed" "Pup Feed" (lambda () (list (replace-fragment (get-id "pf-bot") "ev-pupfeed"))))
      (mbutton2 "evb-pupfind" "Pup Find" (lambda () (list (replace-fragment (get-id "pf-bot") "ev-pupfind"))))
      (mbutton2 "evb-pupcare" "Pup Care" (lambda () (list (replace-fragment (get-id "pf-bot") "ev-pupcare"))))
      (mbutton2 "evb-pupagg" "Pup Aggression" (lambda () (list (replace-fragment (get-id "pf-bot") "ev-pupaggr")))))
     (mtext "text" "Group Events")
     (horiz
      (mbutton2 "evb-grpint" "Interaction" (lambda () (list (replace-fragment (get-id "pf-bot") "ev-grpint"))))
      (mbutton2 "evb-grpalarm" "Pup Find" (lambda () (list (replace-fragment (get-id "pf-bot") "ev-grpalarm"))))
      (mbutton2 "evb-grpmov" "Pup Care" (lambda () (list (replace-fragment (get-id "pf-bot") "ev-grpmov")))))
     ))
332 333 334 335 336 337 338 339
   (lambda (fragment arg)
     (activity-layout fragment))
   (lambda (fragment arg)
     (list))
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '()))
340

341 342 343 344 345 346 347 348
  (fragment
   "pf-scan1"
   (linear-layout
    (make-id "") 'vertical fillwrap
    (list
     (build-grid-selector "pf-scan-nearest" "single" "Nearest neighbour scan: Closest Mongoose")
     (build-grid-selector "pf-scan-close" "toggle" "Nearest neighbour scan: Mongooses within 2m")
     (mbutton "pf-scan-done" "Done" (lambda () (list (replace-fragment (get-id "pf-top") "pf-timer"))))))
349 350 351 352

   (lambda (fragment arg)
     (activity-layout fragment))
   (lambda (fragment arg)
353 354 355 356 357 358 359 360 361 362 363 364 365 366
     (list
      (populate-grid-selector
       "pf-scan-nearest" "single"
       (db-all-where db "sync" "mongoose"
                     (list "pack-id" (ktv-get (get-current 'pack '()) "unique_id")))
       (lambda (individual)
         (list)))
      (populate-grid-selector
       "pf-scan-close" "toggle"
       (db-all-where db "sync" "mongoose"
                     (list "pack-id" (ktv-get (get-current 'pack '()) "unique_id")))
       (lambda (individual)
         (list)))
      ))
367 368 369 370 371 372
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '()))


373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
  (fragment
   "ev-pupfeed"
   (linear-layout
    (make-id "") 'vertical fillwrap
    (list
     (build-grid-selector "pf-pupfeed-who" "single" "Who fed the pup?")
     (mtext "text" "Food size")
     (horiz
      (spinner (make-id "pf-pupfeed-size") (list "Small" "Medium" "Large") fillwrap (lambda (v) '()))
      (mbutton "pf-scan-done" "Done" (lambda () (list (replace-fragment (get-id "pf-bot") "pf-events")))))))

   (lambda (fragment arg)
     (activity-layout fragment))
   (lambda (fragment arg)
     (list
      (populate-grid-selector
       "pf-pupfeed-who" "single"
       (db-all-where db "sync" "mongoose"
                     (list "pack-id" (ktv-get (get-current 'pack '()) "unique_id")))
       (lambda (individual)
         (list)))
      ))
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '()))



402

Dave Griffiths's avatar
Dave Griffiths committed
403
  (fragment
404
   "gc-start"
405 406 407 408 409 410 411
   (linear-layout
    (make-id "") 'vertical fillwrap
    (list
     (mtitle "title" "Start")
     (mtoggle-button "gc-start-main-obs" "Main observer" (lambda (v) '()))
     (mtext "" "Code")
     (edit-text (make-id "gc-start-code") "" 20 "numeric" fillwrap (lambda (v) '()))
412
     (build-grid-selector "gc-start-present" "toggle" "Who's present?")))
413 414 415 416 417 418

   (lambda (fragment arg)
     (activity-layout fragment))
   (lambda (fragment arg)
     (list
      (populate-grid-selector
419
       "gc-start-present" "toggle"
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435
       (db-all-where db "sync" "mongoose"
                     (list "pack-id" (ktv-get (get-current 'pack '()) "unique_id")))
       (lambda (individual)
         (list)))
      ))
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '()))

  (fragment
   "gc-weights"
   (linear-layout
    (make-id "") 'vertical fillwrap
    (list
     (mtitle "title" "Weights")
436
     (build-grid-selector "gc-weigh-choose" "toggle" "Choose mongoose")
437
     (edit-text (make-id "gc-weigh-weight") "" 20 "numeric" fillwrap (lambda (v) '()))
438
     (mtoggle-button "gc-weigh-accurate" "Accurate?" (lambda (v) '()))))
439 440 441 442 443 444

   (lambda (fragment arg)
     (activity-layout fragment))
   (lambda (fragment arg)
     (list
      (populate-grid-selector
445
       "gc-weigh-choose" "toggle"
446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
       (db-all-where
        db "sync" "mongoose"
        (list "pack-id" (ktv-get (get-current 'pack '()) "unique_id")))
       (lambda (individual)
         (list)))
      ))
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '()))

  (fragment
   "gc-preg"
   (linear-layout
    (make-id "") 'vertical fillwrap
    (list
     (mtitle "title" "Pregnant females")
463
     (build-grid-selector "gc-preg-choose" "toggle" "Choose")))
464 465 466 467 468

   (lambda (fragment arg)
     (activity-layout fragment))
   (lambda (fragment arg)
     (list
469 470
      (populate-grid-selector
       "gc-preg-choose" "toggle"
471 472 473 474 475 476 477 478 479 480 481
       (db-all-where
        db "sync" "mongoose"
        (list "pack-id" (ktv-get (get-current 'pack '()) "unique_id")))
       (lambda (individual)
         (list)))
      ))
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '()))

482

483 484 485 486 487 488
  (fragment
   "gc-pup-assoc"
   (linear-layout
    (make-id "") 'vertical fillwrap
    (list
     (mtitle "title" "Pregnant females")
489 490
     (build-grid-selector "gc-pup-choose" "toggle" "Choose pup")
     (build-grid-selector "gc-pup-escort" "toggle" "Escort")))
491 492 493 494 495

   (lambda (fragment arg)
     (activity-layout fragment))
   (lambda (fragment arg)
     (list
496 497
      (populate-grid-selector
       "gc-pup-choose" "toggle"
498 499 500 501 502
       (db-all-where
        db "sync" "mongoose"
        (list "pack-id" (ktv-get (get-current 'pack '()) "unique_id")))
       (lambda (individual)
         (list)))
503 504
      (populate-grid-selector
       "gc-pup-escort" "toggle"
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544
       (db-all-where
        db "sync" "mongoose"
        (list "pack-id" (ktv-get (get-current 'pack '()) "unique_id")))
       (lambda (individual)
         (list)))
      ))
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '()))

  (fragment
   "gc-oestrus"
   (linear-layout
    (make-id "") 'vertical fillwrap
    (list
     (mtext "" "Oestrus...")))
   (lambda (fragment arg)
     (activity-layout fragment))
   (lambda (fragment arg)
     (list))
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '()))

  (fragment
   "gc-babysitting"
   (linear-layout
    (make-id "") 'vertical fillwrap
    (list
     (mtext "" "Babysittings...")))
   (lambda (fragment arg)
     (activity-layout fragment))
   (lambda (fragment arg)
     (list))
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '()))
545

546 547 548 549 550 551
  (fragment
   "gc-end"
   (linear-layout
    (make-id "") 'vertical fillwrap
    (list
     (mtext "" "end!...")))
Dave Griffiths's avatar
Dave Griffiths committed
552 553
   (lambda (fragment arg)
     (activity-layout fragment))
554 555
   (lambda (fragment arg)
     (list))
Dave Griffiths's avatar
Dave Griffiths committed
556 557 558 559 560
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '())
   (lambda (fragment) '()))

561 562


Dave Griffiths's avatar
Dave Griffiths committed
563 564
  )

565 566 567 568
(msg "one")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; activities
Dave Griffiths's avatar
Dave Griffiths committed
569

570 571 572 573 574
(define-activity-list
  (activity
   "splash"
   (vert
    (text-view (make-id "splash-title") "Mongoose 2000" 40 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
575
    (mtext "splash-about" "Advanced mongoose technology")
576
    (spacer 20)
577
    (mbutton "f2" "Get started!" (lambda () (list (start-activity-goto "main" 2 ""))))
578
    (button-grid (make-id "bg") "toggle" 3 20 (layout 100 40 1 'left)
579 580
                 (list) (lambda (v) (msg v) '()))
    )
Dave Griffiths's avatar
Dave Griffiths committed
581

582 583
   (lambda (activity arg)
     (activity-layout activity))
584 585 586 587 588
   (lambda (activity arg)
     (list
      (update-widget
       'button-grid (get-id "bg") 'grid-buttons
       (list
589
        "toggle" 3 20 (layout 100 40 1 'left)
590 591 592 593 594 595 596 597 598 599 600 601 602 603
        (list
         (list (make-id "1") "one")
         (list (make-id "2") "two")
         (list (make-id "3") "three")
         (list (make-id "4") "four")
         (list (make-id "5") "five")
         (list (make-id "6") "six")
         (list (make-id "7") "seven")
         (list (make-id "8") "eight")
         (list (make-id "9") "nine")
         (list (make-id "10") "ten")
         )
        (lambda (v) (msg "updated" v) '())))
     ))
604 605 606 607 608 609
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity requestcode resultcode) '()))

Dave Griffiths's avatar
Dave Griffiths committed
610

611 612 613
  (activity
   "main"
   (vert
Dave Griffiths's avatar
Dave Griffiths committed
614 615
    (text-view (make-id "main-title") "Mongoose 2000" 40 fillwrap)
    (text-view (make-id "main-about") "Advanced mongoose technology" 20 fillwrap)
616
    (spacer 10)
617 618 619 620
    (horiz
     (mbutton2 "main-observations" "Observations" (lambda () (list (start-activity "observations" 2 ""))))
     (mbutton2 "main-manage" "Manage Packs" (lambda () (list (start-activity "manage-packs" 2 ""))))
     (mbutton2 "main-tag" "Tag Location" (lambda () (list (start-activity "tag-location" 2 "")))))
621
    (mtext "foo" "Your ID")
Dave Griffiths's avatar
Dave Griffiths committed
622
    (edit-text (make-id "main-id-text") "" 30 "text" fillwrap
623 624 625 626
               (lambda (v)
                 (set-current! 'user-id v)
                 (update-entity
                  db "local" 1 (list (ktv "user-id" "varchar" v)))))
Dave Griffiths's avatar
Dave Griffiths committed
627 628
    (mtext "foo" "Database")
    (horiz
629 630
     (mbutton2 "main-send" "Email" (lambda () (list)))
     (mbutton2 "main-sync" "Sync" (lambda () (list (start-activity "sync" 0 ""))))))
Dave Griffiths's avatar
Dave Griffiths committed
631 632
   (lambda (activity arg)
     (activity-layout activity))
633 634 635 636 637
   (lambda (activity arg)
     (let ((user-id (ktv-get (get-entity db "local" 1) "user-id")))
       (set-current! 'user-id user-id)
       (list
        (update-widget 'edit-text (get-id "main-id-text") 'text user-id))))
Dave Griffiths's avatar
Dave Griffiths committed
638 639 640 641 642 643 644
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity requestcode resultcode) '()))

  (activity
645
   "observations"
Dave Griffiths's avatar
Dave Griffiths committed
646
   (vert
647 648 649
    (text-view (make-id "title") "Start Observation" 40 fillwrap)
    (vert
     (mtext "type" "Choose observation type")
650 651 652 653 654 655 656 657 658
     (horiz
      (mtoggle-button2 "choose-obs-gc" obs-gc
                       (lambda (v)
                         (set-current! 'observation obs-gc)
                         (mclear-toggles (list "choose-obs-pf"))))
      (mtoggle-button2 "choose-obs-pf" obs-pf
                       (lambda (v)
                         (set-current! 'observation obs-pf)
                         (mclear-toggles (list "choose-obs-gc"))))))
659
    (build-grid-selector "choose-obs-pack-selector" "single" "Choose pack")
660 661 662
    (mbutton
     "choose-obs-start" "Start"
     (lambda ()
663 664 665 666 667 668 669
       ;; set up the observation fragments
       (let ((obs (get-current 'observation "none")))
         (when (not (equal? obs "none"))
           (set-current!
            'observation-fragments
            (cond
             ((equal? obs obs-gc) gc-fragments)
670
             ((equal? obs obs-pf) '())))))
671 672

       ;; go to observation
673 674
       (if (and (current-exists? 'pack)
                (current-exists? 'observation))
675 676 677
           (if (eq? (get-current 'observation "none") obs-pf)
               (list (start-activity "individual-select" 2 ""))
               (list (start-activity "observation" 2 "")))
678 679 680 681 682
           (list
            (alert-dialog
             "choose-obs-finish"
             "Need to specify a pack and an observation"
             (lambda () '()))))))
Dave Griffiths's avatar
Dave Griffiths committed
683 684 685
    )
   (lambda (activity arg)
     (activity-layout activity))
686 687
   (lambda (activity arg)
     (list
688 689 690
      (populate-grid-selector
       "choose-obs-pack-selector" "single"
       (db-all db "sync" "pack")
691
       (lambda (pack)
692 693 694
         (msg "in selector" pack)
         (set-current! 'pack pack)
         '()))))
Dave Griffiths's avatar
Dave Griffiths committed
695 696 697 698 699 700
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity requestcode resultcode) '()))

701 702


Dave Griffiths's avatar
Dave Griffiths committed
703
  (activity
704
   "observation"
Dave Griffiths's avatar
Dave Griffiths committed
705
   (vert
706
    (text-view (make-id "obs-title") "" 40 fillwrap)
707 708 709 710 711
    (linear-layout
     (make-id "obs-buttons-bar") 'horizontal fillwrap '())
    (view-pager
     (make-id "obs-container") (layout 'wrap-content 700 1 'left) '())
    (mbutton "obs-done" "Done" (lambda () '())))
Dave Griffiths's avatar
Dave Griffiths committed
712 713 714

   (lambda (activity arg)
     (activity-layout activity))
715 716
   (lambda (activity arg)
     (list
717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736
      (update-widget 'linear-layout (get-id "obs-buttons-bar") 'contents
                     (let ((all-toggles
                            (map
                             (lambda (i) (string-append "obs-bar-" (cadr i)))
                             (get-current 'observation-fragments '()))))
                       (map
                        (lambda (frag)
                          (let ((id (string-append "obs-bar-" (cadr frag))))
                            (toggle-button
                             (make-id id) (car frag) 12 fillwrap
                             (lambda (v)
                               (append
                                (mclear-toggles-not-me id all-toggles)
                                (list
                                 (update-widget
                                  'view-pager (get-id "obs-container") 'switch
                                  (get-fragment-index
                                   (cadr frag)
                                   (get-current 'observation-fragments '())))))))))
                        (get-current 'observation-fragments '()))))
737 738 739 740
      (update-widget 'text-view (get-id "obs-title") 'text
                     (string-append
                      (get-current 'observation "No observation")
                      " with " (ktv-get (get-current 'pack '()) "name")))
741 742 743 744 745
      (update-widget 'view-pager (get-id "obs-container") 'contents
                     (map
                      (lambda (frag)
                        (cadr frag))
                      (get-current 'observation-fragments '())))
746
      ))
Dave Griffiths's avatar
Dave Griffiths committed
747 748 749 750 751 752 753
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity requestcode resultcode) '()))

  (activity
754
   "individual-select" ;; pup focal #1
Dave Griffiths's avatar
Dave Griffiths committed
755
   (vert
756 757 758 759 760 761 762 763 764 765
    (mtitle "" "Pup focal setup")
    (mtext "pf1-pack" "Pack")
    (build-grid-selector "pf1-grid" "single" "Select pup")
    (horiz
     (medit-text "pf1-width" "Pack width" 20 "numeric" (lambda (v) '()))
     (medit-text "pf1-height" "Pack height" 20 "numeric" (lambda (v) '())))
    (medit-text "pf1-count" "How many mongooses present?" 20 "numeric" (lambda (v) '()))
    (mbutton "pf1-done" "Done"
             (lambda ()
               (list (start-activity "pup-focal" 2 ""))))
Dave Griffiths's avatar
Dave Griffiths committed
766
    )
767

Dave Griffiths's avatar
Dave Griffiths committed
768 769
   (lambda (activity arg)
     (activity-layout activity))
770 771
   (lambda (activity arg)
     (list
772 773 774 775 776
      (populate-grid-selector
       "pf1-grid" "single"
       (db-all-where db "sync" "mongoose" (list "pack-id" (ktv-get (get-current 'pack '()) "unique_id")))
       (lambda (individual)
         '()))))
Dave Griffiths's avatar
Dave Griffiths committed
777 778 779 780 781 782 783
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity requestcode resultcode) '()))

  (activity
784
   "pup-focal" ;; pup focal #2
Dave Griffiths's avatar
Dave Griffiths committed
785
   (vert
786 787 788 789
    (horiz
     (mtitle "title" "Pup Focal")
     (mtext "pf-details" "")
     (mtoggle-button "pf-pause" "Pause" (lambda (v) '())))
790
    (build-fragment "pf-timer" (make-id "pf-top") (layout 580 400 1 'left))
791
    (mtitle "title" "Events")
792
    (build-fragment "pf-events" (make-id "pf-bot") (layout 580 400 1 'left))
793 794
    (mbutton "pf-done" "Done" (lambda () (list (start-activity-goto "observations" 2 "")))))

Dave Griffiths's avatar
Dave Griffiths committed
795 796
   (lambda (activity arg)
     (activity-layout activity))
797 798 799 800 801 802 803
   (lambda (activity arg)
     (list
      (update-widget 'text-view (get-id "pf-details") 'text
                     (string-append
                      "Pack: " (ktv-get (get-current 'pack '()) "name") " "
                      "Pup: " (ktv-get (get-current 'individual '()) "name")))
      ))
Dave Griffiths's avatar
Dave Griffiths committed
804 805 806 807 808 809
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity requestcode resultcode) '()))

810

Dave Griffiths's avatar
Dave Griffiths committed
811 812 813
  (activity
   "event-self"
   (vert
Dave Griffiths's avatar
Dave Griffiths committed
814
    (text-view (make-id "main-title") "Self feeding event" 40 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842
    (spacer 10)
    (toggle-button (make-id "event-self-found") "Found item?" 20 fillwrap
                   (lambda (v) '()))
    (toggle-button (make-id "event-self-kept") "Kept item?" 20 fillwrap
                   (lambda (v) '()))

    (text-view (make-id "event-self-type-text") "Food type" 20 fillwrap)
    (spinner (make-id "event-self-type") (list "Beetle" "Millipede") fillwrap (lambda (v) '()))

    (text-view (make-id "event-self-type-text") "Food size" 20 fillwrap)
    (spinner (make-id "event-self-type") (list "Small" "Medium" "Large") fillwrap (lambda (v) '()))
    (spacer 10)
    (horiz
     (button (make-id "event-self-cancel") "Cancel" 20 fillwrap (lambda () (list (finish-activity 0))))
     (button (make-id "event-self-done") "Done" 20 fillwrap (lambda () (list (finish-activity 0)))))
    )
   (lambda (activity arg)
     (activity-layout activity))
   (lambda (activity arg) (list))
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity requestcode resultcode) '()))

  (activity
   "event-fed"
   (vert
Dave Griffiths's avatar
Dave Griffiths committed
843
    (text-view (make-id "main-title") "Being fed event" 40 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874
    (spacer 10)
    (text-view (make-id "event-fed-who-text") "Who by" 20 fillwrap)
    (spinner (make-id "event-fed-who") (list "Mongoose 1" "Mongoose 2" "Mongoose 3") fillwrap (lambda (v) '()))
    (toggle-button (make-id "event-fed-closest") "Closest to feeder?" 20 fillwrap
                   (lambda (v) '()))

    (text-view (make-id "event-self-type-text") "Who moved?" 20 fillwrap)
    (spinner (make-id "event-self-type") (list "Pup" "Feeder") fillwrap (lambda (v) '()))

    (text-view (make-id "event-fed-type-text") "Food type" 20 fillwrap)
    (spinner (make-id "event-fed-type") (list "Beetle" "Millipede") fillwrap (lambda (v) '()))

    (text-view (make-id "event-fed-type-text") "Food size" 20 fillwrap)
    (spinner (make-id "event-fed-type") (list "Small" "Medium" "Large") fillwrap (lambda (v) '()))
    (spacer 10)
    (horiz
     (button (make-id "event-fed-cancel") "Cancel" 20 fillwrap (lambda () (list (finish-activity 0))))
     (button (make-id "event-fed-done") "Done" 20 fillwrap (lambda () (list (finish-activity 0)))))
    )
   (lambda (activity arg)
     (activity-layout activity))
   (lambda (activity arg) (list))
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity requestcode resultcode) '()))

  (activity
   "event-aggression"
   (vert
Dave Griffiths's avatar
Dave Griffiths committed
875
    (text-view (make-id "main-title") "Aggression event" 40 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901
    (spacer 10)
    (text-view (make-id "event-agg-who-text") "Other individual" 20 fillwrap)
    (spinner (make-id "event-agg-who") (list "Mongoose 1" "Mongoose 2" "Mongoose 3") fillwrap (lambda (v) '()))
    (text-view (make-id "event-agg-severity-text") "Severity" 20 fillwrap)
    (seek-bar (make-id "event-agg-severity") 100 fillwrap (lambda (v) '()))
    (spacer 10)
    (horiz
     (button (make-id "event-agg-cancel") "Cancel" 20 fillwrap (lambda () (list (finish-activity 0))))
     (button (make-id "event-agg-done") "Done" 20 fillwrap (lambda () (list (finish-activity 0)))))
    )
   (lambda (activity arg)
     (activity-layout activity))
   (lambda (activity arg) (list))
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity requestcode resultcode) '()))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

  (activity
   "manage-packs"
   (vert
    (text-view (make-id "title") "Manage packs" 40 fillwrap)
902
    (build-grid-selector "manage-packs-list" "button" "Choose pack")
Dave Griffiths's avatar
Dave Griffiths committed
903
    (button (make-id "manage-packs-new") "New pack" 20 fillwrap (lambda () (list (start-activity "new-pack" 2 ""))))
Dave Griffiths's avatar
Dave Griffiths committed
904 905 906
    )
   (lambda (activity arg)
     (activity-layout activity))
Dave Griffiths's avatar
Dave Griffiths committed
907 908
   (lambda (activity arg)
     (list
909
      (populate-grid-selector
910
       "manage-packs-list" "button" (db-all db "sync" "pack")
911 912 913
       (lambda (pack)
         (set-current! 'pack pack)
         (list (start-activity "manage-individual" 2 ""))))
Dave Griffiths's avatar
Dave Griffiths committed
914
      ))
Dave Griffiths's avatar
Dave Griffiths committed
915 916 917 918
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
919
   (lambda (activity requestcode resultcode) '()))
Dave Griffiths's avatar
Dave Griffiths committed
920 921 922 923 924 925

  (activity
   "new-pack"
   (vert
    (text-view (make-id "title") "New pack" 40 fillwrap)
    (spacer 10)
Dave Griffiths's avatar
Dave Griffiths committed
926
    (text-view (make-id "new-pack-name-text") "Pack name" 20 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
927
    (edit-text (make-id "new-pack-name") "" 30 "text" fillwrap
928
               (lambda (v) (set-current! 'pack-name v) '()))
Dave Griffiths's avatar
Dave Griffiths committed
929
    (spacer 10)
Dave Griffiths's avatar
Dave Griffiths committed
930 931 932 933 934
    (horiz
     (button (make-id "new-pack-cancel") "Cancel" 20 fillwrap (lambda () (list (finish-activity 2))))
     (button (make-id "new-pack-done") "Done" 20 fillwrap
             (lambda ()
               (insert-entity
Dave Griffiths's avatar
Dave Griffiths committed
935
                db "sync" "pack" (get-current 'user-id "no id")
936
                (list
Dave Griffiths's avatar
Dave Griffiths committed
937
                 (ktv "name" "varchar" (get-current 'pack-name "no name"))))
Dave Griffiths's avatar
Dave Griffiths committed
938
               (list (finish-activity 2)))))
Dave Griffiths's avatar
Dave Griffiths committed
939 940 941 942 943 944 945 946 947 948 949
    )
   (lambda (activity arg)
     (activity-layout activity))
   (lambda (activity arg) (list))
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity requestcode resultcode) '()))

  (activity
Dave Griffiths's avatar
Dave Griffiths committed
950
   "manage-individual"
Dave Griffiths's avatar
Dave Griffiths committed
951 952
   (vert
    (text-view (make-id "title") "Manage individuals" 40 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
953
    (text-view (make-id "manage-individual-pack-name") "Pack:" 20 fillwrap)
954
    (build-grid-selector "manage-individuals-list" "button" "Choose individual")
Dave Griffiths's avatar
Dave Griffiths committed
955
    (button (make-id "manage-individuals-new") "New individual" 20 fillwrap (lambda () (list (start-activity "new-individual" 2 ""))))
Dave Griffiths's avatar
Dave Griffiths committed
956 957 958
    )
   (lambda (activity arg)
     (activity-layout activity))
Dave Griffiths's avatar
Dave Griffiths committed
959 960
   (lambda (activity arg)
     (list
961
      (populate-grid-selector
962
       "manage-individuals-list" "button"
963 964 965
       (db-all-where db "sync" "mongoose" (list "pack-id" (ktv-get (get-current 'pack '()) "unique_id")))
       (lambda (individual)
         (list (start-activity "manage-individual" 2 ""))))
Dave Griffiths's avatar
Dave Griffiths committed
966
      (update-widget 'text-view (get-id "manage-individual-pack-name") 'text
Dave Griffiths's avatar
Dave Griffiths committed
967
                     (string-append "Pack: " (ktv-get (get-current 'pack '()) "name")))
Dave Griffiths's avatar
Dave Griffiths committed
968
      ))
Dave Griffiths's avatar
Dave Griffiths committed
969 970 971 972
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
973
   (lambda (activity requestcode resultcode) '()))
Dave Griffiths's avatar
Dave Griffiths committed
974 975 976 977 978

  (activity
   "new-individual"
   (vert
    (text-view (make-id "title") "New Mongoose" 40 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
979
    (text-view (make-id "new-individual-pack-name") "Pack:" 20 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
980
    (text-view (make-id "new-individual-name-text") "Name" 20 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
981
    (edit-text (make-id "new-individual-name") "" 30 "text" fillwrap
Dave Griffiths's avatar
Dave Griffiths committed
982
               (lambda (v) (set-current! 'individual-name v) '()))
Dave Griffiths's avatar
Dave Griffiths committed
983
    (text-view (make-id "new-individual-name-text") "Gender" 20 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
984 985
    (spinner (make-id "new-individual-gender") (list "Female" "Male") fillwrap
             (lambda (v) (set-current! 'individual-gender v) '()))
Dave Griffiths's avatar
Dave Griffiths committed
986
    (text-view (make-id "new-individual-dob-text") "Date of Birth" 20 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
987 988 989
    (horiz
     (text-view (make-id "new-individual-dob") "00/00/00" 25 fillwrap)
     (button (make-id "date") "Set date" 20 fillwrap (lambda () '())))
Dave Griffiths's avatar
Dave Griffiths committed
990
    (text-view (make-id "new-individual-litter-text") "Litter code" 20 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
991
    (edit-text (make-id "new-individual-litter-code") "" 30 "text" fillwrap
Dave Griffiths's avatar
Dave Griffiths committed
992
               (lambda (v) (set-current! 'individual-litter-code v) '()))
Dave Griffiths's avatar
Dave Griffiths committed
993
    (text-view (make-id "new-individual-chip-text") "Chip code" 20 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
994
    (edit-text (make-id "new-individual-chip-code") "" 30 "text" fillwrap
Dave Griffiths's avatar
Dave Griffiths committed
995 996 997 998 999 1000
               (lambda (v) (set-current! 'individual-chip-code v) '()))
    (horiz
     (button (make-id "new-individual-cancel") "Cancel" 20 fillwrap (lambda () (list (finish-activity 2))))
     (button (make-id "new-individual-done") "Done" 20 fillwrap
             (lambda ()
               (insert-entity
Dave Griffiths's avatar
Dave Griffiths committed
1001
                db "sync" "mongoose" (get-current 'user-id "no id")
1002
                (list
Dave Griffiths's avatar
Dave Griffiths committed
1003 1004 1005 1006 1007
                 (ktv "name" "varchar" (get-current 'individual-name "no name"))
                 (ktv "gender" "varchar" (get-current 'individual-gender "Female"))
                 (ktv "litter-code" "varchar" (get-current 'individual-litter-code ""))
                 (ktv "chip-code" "varchar" (get-current 'individual-chip-code ""))
                 (ktv "pack-id" "varchar" (ktv-get (get-current 'pack '()) "unique_id"))
1008
                 ))
Dave Griffiths's avatar
Dave Griffiths committed
1009
               (list (finish-activity 2)))))
1010 1011 1012
    )
   (lambda (activity arg)
     (activity-layout activity))
Dave Griffiths's avatar
Dave Griffiths committed
1013 1014 1015
   (lambda (activity arg)
     (list
      (update-widget 'text-view (get-id "new-individual-pack-name") 'text
Dave Griffiths's avatar
Dave Griffiths committed
1016
                     (string-append "Pack: " (ktv-get (get-current 'pack '()) "name")))))
1017 1018 1019 1020
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
Dave Griffiths's avatar
Dave Griffiths committed
1021 1022 1023 1024 1025 1026 1027
   (lambda (activity requestcode resultcode) '()))

  (activity
   "update-individual"
   (vert
    (text-view (make-id "title") "Update Mongoose" 40 fillwrap)
    (spacer 10)
Dave Griffiths's avatar
Dave Griffiths committed
1028
    (text-view (make-id "update-individual-name-text") "Name" 20 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
1029
    (edit-text (make-id "update-individual-name") "" 30 "text" fillwrap (lambda (v) '()))
Dave Griffiths's avatar
Dave Griffiths committed
1030
    (text-view (make-id "update-individual-name-text") "Gender" 20 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
1031
    (spinner (make-id "update-individual-gender") (list "Female" "Male") fillwrap (lambda (v) '()))
Dave Griffiths's avatar
Dave Griffiths committed
1032
    (text-view (make-id "update-individual-dob-text") "Date of Birth" 20 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
1033 1034 1035
    (horiz
     (text-view (make-id "update-individual-dob") "00/00/00" 25 fillwrap)
     (button (make-id "date") "Set date" 20 fillwrap (lambda () '())))
Dave Griffiths's avatar
Dave Griffiths committed
1036
    (text-view (make-id "update-individual-litter-text") "Litter code" 20 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
1037
    (edit-text (make-id "update-individual-litter-code") "" 30 "text" fillwrap (lambda (v) '()))
Dave Griffiths's avatar
Dave Griffiths committed
1038
    (text-view (make-id "update-individual-chip-text") "Chip code" 20 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
1039
    (edit-text (make-id "update-individual-chip-code") "" 30 "text" fillwrap (lambda (v) '()))
Dave Griffiths's avatar
Dave Griffiths committed
1040 1041
    (spacer 10)
    (horiz
Dave Griffiths's avatar
Dave Griffiths committed
1042 1043
     (button (make-id "update-individual-delete") "Delete" 20 fillwrap (lambda () (list (finish-activity 2))))
     (button (make-id "update-individual-died") "Died" 20 fillwrap (lambda () (list (finish-activity 2)))))
Dave Griffiths's avatar
Dave Griffiths committed
1044
    (horiz
Dave Griffiths's avatar
Dave Griffiths committed
1045 1046
     (button (make-id "update-individual-cancel") "Cancel" 20 fillwrap (lambda () (list (finish-activity 2))))
     (button (make-id "update-individual-done") "Done" 20 fillwrap (lambda () (list (finish-activity 2)))))
Dave Griffiths's avatar
Dave Griffiths committed
1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061
    )
   (lambda (activity arg)
     (activity-layout activity))
   (lambda (activity arg) (list))
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity requestcode resultcode) '()))


  (activity
   "tag-location"
   (vert
    (text-view (make-id "title") "Tag Location" 40 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
1062
    (text-view (make-id "tag-location-gps-text") "GPS" 20 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
1063
    (horiz
Dave Griffiths's avatar
Dave Griffiths committed
1064 1065
     (text-view (make-id "tag-location-gps-lat") "LAT" 20 fillwrap)
     (text-view (make-id "tag-location-gps-lng") "LNG" 20 fillwrap))
Dave Griffiths's avatar
Dave Griffiths committed
1066

Dave Griffiths's avatar
Dave Griffiths committed
1067
    (text-view (make-id "tag-location-name-text") "Name" 20 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
1068
    (edit-text (make-id "tag-location-name") "" 30 "text" fillwrap (lambda (v) '()))
Dave Griffiths's avatar
Dave Griffiths committed
1069

Dave Griffiths's avatar
Dave Griffiths committed
1070
    (text-view (make-id "tag-location-pack-text") "Associated pack" 20 fillwrap)
Dave Griffiths's avatar
Dave Griffiths committed
1071 1072 1073 1074 1075 1076 1077
    (spinner (make-id "tag-location-pack") (list "Pack 1" "Pack 2") fillwrap (lambda (v) '()))

    (text-view (make-id "tag-location-radius-text") "Approx radius of area" 20 fillwrap)
    (seek-bar (make-id "tag-location-radius") 100 fillwrap (lambda (v) '()))
    (text-view (make-id "tag-location-radius-value") "10m" 20 fillwrap)

    (horiz
Dave Griffiths's avatar
Dave Griffiths committed
1078 1079
     (button (make-id "tag-location-cancel") "Cancel" 20 fillwrap (lambda () (list (finish-activity 2))))
     (button (make-id "tag-location-done") "Done" 20 fillwrap (lambda () (list (finish-activity 2)))))
Dave Griffiths's avatar
Dave Griffiths committed
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091

    )
   (lambda (activity arg)
     (activity-layout activity))
   (lambda (activity arg) (list))
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity) '())
   (lambda (activity requestcode resultcode) '()))