Commit f2e7fb9e authored by dave griffiths's avatar dave griffiths


parents 651e57f3 90a6d104
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="" <manifest xmlns:android=""
package="foam.symbai" package="foam.symbai"
android:versionCode="8" android:versionCode="10"
android:versionName="1.0"> android:versionName="1.0">
<application android:label="@string/app_name" <application android:label="@string/app_name"
android:icon="@drawable/logo" android:icon="@drawable/logo"
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<activity android:name="foam.symbai.FamilyActivity" android:configChanges="orientation"></activity> <activity android:name="foam.symbai.FamilyActivity" android:configChanges="orientation"></activity>
<activity android:name="foam.symbai.MigrationActivity" android:configChanges="orientation"></activity> <activity android:name="foam.symbai.MigrationActivity" android:configChanges="orientation"></activity>
<activity android:name="foam.symbai.IncomeActivity" android:configChanges="orientation"></activity> <activity android:name="foam.symbai.IncomeActivity" android:configChanges="orientation"></activity>
<activity android:name="foam.symbai.GeneaologyActivity" android:configChanges="orientation"></activity> <activity android:name="foam.symbai.GenealogyActivity" android:configChanges="orientation"></activity>
<activity android:name="foam.symbai.SocialActivity" android:configChanges="orientation"></activity> <activity android:name="foam.symbai.SocialActivity" android:configChanges="orientation"></activity>
<activity android:name="foam.symbai.FriendshipActivity" android:configChanges="orientation"></activity> <activity android:name="foam.symbai.FriendshipActivity" android:configChanges="orientation"></activity>
<activity android:name="foam.symbai.AgreementActivity" android:configChanges="orientation"></activity> <activity android:name="foam.symbai.AgreementActivity" android:configChanges="orientation"></activity>
Open Sauces Notebook Symbai android app
==================== ==================
A structured notebook for recipes
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
(msg "dbsync.scm") (msg "dbsync.scm")
(define unset-int 2147483647)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; stuff in memory ;; stuff in memory
...@@ -88,22 +90,51 @@ ...@@ -88,22 +90,51 @@
(define (entity-get-value key) (define (entity-get-value key)
(ktv-get (get-current 'entity-values '()) key)) (ktv-get (get-current 'entity-values '()) key))
(define (check-type type value)
((equal? type "varchar")
(string? value))
((equal? type "file")
(string? value))
((equal? type "int")
(number? value))
((equal? type "real")
(number? value))))
;; version to check the entity has the key ;; version to check the entity has the key
(define (entity-set-value! key type value) (define (entity-set-value! key type value)
(when (not (check-type type value))
(msg "INCORRECT TYPE FOR" key ":" type ":" value))
(let ((existing-type (ktv-get-type (get-current 'entity-values '()) key))) (let ((existing-type (ktv-get-type (get-current 'entity-values '()) key)))
(if (equal? existing-type type) (cond
(set-current! ((equal? existing-type type)
'entity-values ;; save straight to local db every time (checks for modification)
(ktv-set (entity-update-single-value! (list key type value))
(get-current 'entity-values '()) ;; then save to memory
(ktv key type value))) (set-current!
;; 'entity-values
(begin (ktv-set
(msg "entity-set-value! - adding new " key "of type" type "to entity") (get-current 'entity-values '())
(entity-add-value-create! key type value))) (ktv key type value))))
;; save straight to local db every time ;;
(entity-update-single-value! (list key type value)) (else
)) (msg "entity-set-value! - adding new " key "of type" type "to entity")
(entity-add-value-create! key type value))
;; version to check the entity has the key
(define (entity-set-value-mem! key type value)
(when (not (check-type type value))
(msg "INCORRECT TYPE FOR" key ":" type ":" value))
;; then save to memory
(get-current 'entity-values '())
(ktv key type value))))
(define (date-time->string dt) (define (date-time->string dt)
...@@ -163,6 +194,8 @@ ...@@ -163,6 +194,8 @@
(table (get-current 'table #f)) (table (get-current 'table #f))
(unique-id (ktv-get (get-current 'entity-values '()) "unique_id"))) (unique-id (ktv-get (get-current 'entity-values '()) "unique_id")))
(cond (cond
((ktv-eq? (ktv-get-whole (get-current 'entity-values '()) (ktv-key ktv)) ktv)
(msg "eusv: no change for" (ktv-key ktv)))
(unique-id (unique-id
(update-entity db table (entity-id-from-unique db table unique-id) (list ktv))) (update-entity db table (entity-id-from-unique db table unique-id) (list ktv)))
(else (else
...@@ -455,7 +488,7 @@ ...@@ -455,7 +488,7 @@
(list (list
(network-connect (network-connect
"network" "network"
"mongoose-web" "symbai-web"
(lambda (state) (lambda (state)
(debug! (string-append "Raspberry Pi connection state now: " state)) (debug! (string-append "Raspberry Pi connection state now: " state))
(append (append
...@@ -575,11 +608,25 @@ ...@@ -575,11 +608,25 @@
(layout 'fill-parent 'wrap-content 1 'centre 0) (layout 'fill-parent 'wrap-content 1 'centre 0)
fn)))) fn))))
(define (medit-text-large id type fn)
(make-id (string-append (symbol->string id) "-container"))
(layout 'fill-parent 'wrap-content 1 'centre 20)
(list 0 0 0 0)
(text-view 0 (mtext-lookup id)
30 (layout 'wrap-content 'wrap-content -1 'centre 0))
(edit-text (symbol->id id) "" 30 type
(layout 'fill-parent 300 -1 'left 0)
(define (mspinner id types fn) (define (mspinner id types fn)
(vert (vert
(text-view (symbol->id id) (text-view (symbol->id id)
(mtext-lookup id) (mtext-lookup id)
30 (layout 'wrap-content 'wrap-content 1 'centre 10)) 30 (layout 'wrap-content 'wrap-content 1 'centre 0))
(spinner (make-id (string-append (symbol->string id) "-spinner")) (spinner (make-id (string-append (symbol->string id) "-spinner"))
(map mtext-lookup types) (map mtext-lookup types)
(layout 'wrap-content 'wrap-content 1 'centre 0) (layout 'wrap-content 'wrap-content 1 'centre 0)
...@@ -650,15 +697,19 @@ ...@@ -650,15 +697,19 @@
(define (image-invalid? image-name) (define (image-invalid? image-name)
(or (null? image-name) (or (null? image-name)
(not image-name) (not image-name)
(equal? image-name "none"))) (equal? image-name "none")
(equal? image-name "")))
;; fill out the widget from the current entity in the memory store ;; fill out the widget from the current entity in the memory store
;; dispatches based on widget type ;; dispatches based on widget type
(define (mupdate widget-type id-symbol key) (define (mupdate widget-type id-symbol key)
(cond (cond
((or (eq? widget-type 'edit-text) (eq? widget-type 'text-view)) ((or (eq? widget-type 'edit-text) (eq? widget-type 'text-view))
(update-widget widget-type (get-symbol-id id-symbol) 'text (let ((v (entity-get-value key)))
(entity-get-value key))) (update-widget widget-type (get-symbol-id id-symbol) 'text
;; hide -1 as it represents unset
(if (and (number? v) (eqv? v -1))
"" v))))
((eq? widget-type 'toggle-button) ((eq? widget-type 'toggle-button)
(update-widget widget-type (get-symbol-id id-symbol) 'checked (update-widget widget-type (get-symbol-id id-symbol) 'checked
(entity-get-value key))) (entity-get-value key)))
...@@ -779,7 +830,7 @@ ...@@ -779,7 +830,7 @@
;; a standard builder for list widgets of entities and a ;; a standard builder for list widgets of entities and a
;; make new button, to add defaults to the list ;; make new button, to add defaults to the list
(define (build-list-widget db table title entity-type edit-activity parent-fn ktv-default-fn) (define (build-list-widget db table title title-ids entity-type edit-activity parent-fn ktv-default-fn)
(vert-colour (vert-colour
colour-two colour-two
(horiz (horiz
...@@ -794,7 +845,7 @@ ...@@ -794,7 +845,7 @@
(ktvlist-merge (ktvlist-merge
(ktv-default-fn) (ktv-default-fn)
(list (ktv "parent" "varchar" (parent-fn))))) (list (ktv "parent" "varchar" (parent-fn)))))
(list (update-list-widget db table entity-type edit-activity (parent-fn)))))) (list (update-list-widget db table title-ids entity-type edit-activity (parent-fn))))))
(linear-layout (linear-layout
(make-id (string-append entity-type "-list")) (make-id (string-append entity-type "-list"))
'vertical 'vertical
...@@ -802,13 +853,28 @@ ...@@ -802,13 +853,28 @@
(list 0 0 0 0) (list 0 0 0 0)
(list)))) (list))))
(define (make-list-widget-title e title-ids)
(if (eqv? (length title-ids) 1)
(ktv-get e (car title-ids))
(ktv-get e (car title-ids)) "\n"
(lambda (id r)
(if (equal? r "")
(ktv-get e id)
(string-append r " " (ktv-get e id))))
"" (cdr title-ids)))))
;; pull db data into list of button widgets ;; pull db data into list of button widgets
(define (update-list-widget db table entity-type edit-activity parent) (define (update-list-widget db table title-ids entity-type edit-activity parent)
(let ((search-results (let ((search-results
(if parent (if parent
(db-filter-only db table entity-type (db-filter-only db table entity-type
(list (list "parent" "varchar" "=" parent)) (list (list "parent" "varchar" "=" parent))
(list (list "name" "varchar"))) (map
(lambda (id)
(list id "varchar"))
(db-all db table entity-type)))) (db-all db table entity-type))))
(update-widget (update-widget
'linear-layout 'linear-layout
...@@ -820,8 +886,8 @@ ...@@ -820,8 +886,8 @@
(lambda (e) (lambda (e)
(button (button
(make-id (string-append "list-button-" (ktv-get e "unique_id"))) (make-id (string-append "list-button-" (ktv-get e "unique_id")))
(or (ktv-get e "name") "Unamed item") (make-list-widget-title e title-ids)
40 (layout 'fill-parent 'wrap-content 1 'centre 5) 30 (layout 'fill-parent 'wrap-content 1 'centre 5)
(lambda () (lambda ()
(list (start-activity edit-activity 0 (ktv-get e "unique_id")))))) (list (start-activity edit-activity 0 (ktv-get e "unique_id"))))))
search-results))))) search-results)))))
...@@ -1029,13 +1095,13 @@ ...@@ -1029,13 +1095,13 @@
(msg "making village" i) (msg "making village" i)
(let ((village (simpsons-village db table village-ktvlist))) (let ((village (simpsons-village db table village-ktvlist)))
(looper! (looper!
3 15
(lambda (i) (lambda (i)
(alog "household") (alog "household")
(msg "making household" i) (msg "making household" i)
(let ((household (simpsons-household db table village household-ktvlist))) (let ((household (simpsons-household db table village household-ktvlist)))
(looper! (looper!
(random 10) (+ 2 (random 5))
(lambda (i) (lambda (i)
(msg "making individual" i) (msg "making individual" i)
(simpsons-individual db table household individual-ktvlist)))))))))) (simpsons-individual db table household individual-ktvlist))))))))))
...@@ -706,7 +706,7 @@ ...@@ -706,7 +706,7 @@
(define (relative rules colour . l) (define (relative rules colour . l)
(relative-layout (relative-layout
0 (rlayout 'fill-parent 'wrap-content 20 rules) 0 (rlayout 'fill-parent 'wrap-content (list 20 20 20 20) rules)
colour colour
l)) l))
...@@ -795,7 +795,8 @@ ...@@ -795,7 +795,8 @@
((null? w) #f) ((null? w) #f)
;; drill deeper ;; drill deeper
((eq? (update-widget-token w) 'contents) ((eq? (update-widget-token w) 'contents)
(msg "updateing contents from callback") (update-callbacks! (update-widget-value w)))
((eq? (update-widget-token w) 'contents-add)
(update-callbacks! (update-widget-value w))) (update-callbacks! (update-widget-value w)))
((eq? (update-widget-token w) 'grid-buttons) ((eq? (update-widget-token w) 'grid-buttons)
(add-callback! (callback (update-widget-id w) (add-callback! (callback (update-widget-id w)
...@@ -862,6 +863,7 @@ ...@@ -862,6 +863,7 @@
(begin (display "no dialog called ")(display name)(newline)) (begin (display "no dialog called ")(display name)(newline))
(let ((events (apply (dialog-fn dialog) args))) (let ((events (apply (dialog-fn dialog) args)))
(update-dialogs! events) (update-dialogs! events)
(update-callbacks-from-update! events)
(send (scheme->json events)))))) (send (scheme->json events))))))
;; called by java ;; called by java
This diff is collapsed.
test-num,1,1,1, "Code (don't change these)","English","Khasi","Hindi",
test-text, I am test text, I am test text, I am test text, "start","Symbai",,,
one, one, ,, "next","Next",,,
two, two, ,, "yes","Yes",,,
three, three, ,, "no","No",,,
village, Village, ,, "unanswered","Unanswered",,,
household, Household, ,, "not-set","Not set",,,
households, Households, ,, "details-next","Next",,,
individual, Individual, ,, "family-next","Next",,,
individuals, Individuals, ,, "migration-next","Next",,,
add-item-to-list,0, ,, "income-next","Next",,,
default-village-name, New village, ,, "gene-next","Next",,,
title, Symbai, Symbai, Symbai, "social-next","Next",,,
sync, Sync, Sync, Sync, "friendship-next","Next",,,
languages, Choose language, Choose language, Choose language, "agreement-next","Next",,,
english, English, English, English, "village"," Village"," ",,
khasi, Khasi, Khasi, Khasi, "household"," Household"," ",,
hindi, Hindi, Hindi, Hindi, "households"," Households"," ",,
user-id, Your user ID, User ID, User ID, "individual"," Individual"," ",,
save, Save, Save, Save, "individuals"," Individuals"," ",,
back, Back, Back, Back, "add-item-to-list",0," ",,
off, Off, Off, Off, "default-village-name"," New village"," ",,
villages, Villages, Villages, Villages, "title"," Symbai"," Symbai"," Symbai"," "
list-empty, List empty, ,, "sync"," Sync"," Sync"," Sync"," "
delete, Delete, ,, "languages"," Choose language"," Choose language"," Choose language"," "
delete-are-you-sure, Are you sure you want to delete this?, ,, "english"," English"," English"," English"," "
save-are-you-sure, Are you sure you want to save changes?, ,, "khasi"," Khasi"," Khasi"," Khasi"," "
quick-name, New person name, ,, "hindi"," Hindi"," Hindi"," Hindi"," "
quick-add, Quick add, ,, "user-id"," User ID"," User ID"," User ID"," "
find-individual, Find individual, ,, "save"," Save"," Save"," Save"," "
filter, Filter, ,, "back"," Back"," Back"," Back"," "
off, Off, Off, Off, "off"," Off"," Off"," Off"," "
name, Name, ,, "villages"," Villages"," Villages"," Villages"," "
sync-all, Sync me!, ,, "list-empty"," List empty"," ",,
sync-syncall, Sync everything, ,, "delete"," Delete"," ",,
export-data, Exporting data, ,, "delete-are-you-sure"," Are you sure you want to delete this?"," ",,
sync-download, Download main DB, ,, "save-are-you-sure"," Are you sure you want to save changes?"," ",,
sync-export, Email main DB, ,, "quick-name"," New person name"," ",,
email-local, Email local DB, ,, "quick-add"," Quick add"," ",,
debug, Debug, ,, "find-individual"," Find individual"," ",,
sync-back, Back, ,, "filter"," Filter"," ",,
sync-prof, Profile, ,, "filter-switch","Run filter",,,
village-name, Village name, Village name, Village name, "off"," Off"," Off"," Off"," "
block, Block, Block, Block, "name"," Name","Kyrteng",,
district, District, District, District, "sync-all"," Sync me!"," ",,
car, Accessible by car, ,, "sync-syncall"," Sync everything"," ",,
household-list, Household list, ,, "export-data"," Exporting data"," ",,
amenities, Amenities, ,, "sync-download"," Download main DB"," ",,
school, School, ,, "sync-export"," Email main DB"," ",,
present, Present, ,, "email-local"," Email local DB"," ",,
closest-access, Closest place of access, ,, "debug"," Debug"," ",,
house-gps, GPS, ,, "sync-back"," Back"," ",,
toilet-gps, GPS, ,, "sync-prof"," Profile"," ",,
school, School, ,, "village-name"," Village name"," Village name"," Village name"," "
school-closest-access, Closest access, ,, "block"," Block"," Block"," Block"," "
school-gps, GPS, ,, "district"," District"," District"," District"," "
hospital, Hospital/Health care centre, ,, "car"," Accessible by car"," ",,
hospital-closest-access, Closest access, ,, "household-list"," Household list"," ",,
hospital-gps, GPS, ,, "amenities"," Amenities"," ",,
post-office, Post Office, ,, "school"," School"," ",,
post-office-closest-access, Closest access, ,, "present"," Present"," ",,
post-office-gps, GPS, ,, "closest-access"," Closest place of access"," ",,
railway-station, Railway station, ,, "house-gps"," GPS"," ",,
railway-station-closest-access, Closest access, ,, "toilet-gps"," GPS"," ",,
railway-station-gps, GPS, ,, "school-in-village","In Village",,,
state-bus-service, Inter-state bus service, ,, "school"," School"," ",,
state-bus-service-closest-access, Closest access, ,, "school-closest-access"," Closest access"," ",,
state-bus-service-gps, GPS, ,, "school-gps"," GPS"," ",,
district-bus-service, Inter-village/district bus service, ,, "hospital-in-village","In Village",,,
district-bus-service-closest-access, Closest access, ,, "hospital"," Hospital/Health care centre"," ",,
district-bus-service-gps, GPS, ,, "hospital-closest-access"," Closest access"," ",,
panchayat, Village Panchayat Office, ,, "hospital-gps"," GPS"," ",,
panchayat-closest-access, Closest access, ,, "Post-office-in-village","In Village",,,
panchayat-gps, GPS, ,, "post-office"," Post Office"," ",,
NGO, Presence of NGO's working with them, ,, "post-office-closest-access"," Closest access"," ",,
NGO-closest-access, Closest access, ,, "post-office-gps"," GPS"," ",,
NGO-gps, GPS, ,, "railway-station-in-village","In Village",,,
market, Market, ,, "railway-station"," Railway station"," ",,
market-closest-access, Closest access, ,, "railway-station-closest-access"," Closest access"," ",,
market-gps, GPS, ,, "railway-station-gps"," GPS"," ",,
household-name, Household name, ,, "State-bus-service-in-village","In Village",,,
default-household-name, A household, ,, "state-bus-service"," Inter-state bus service"," ",,
location, House location, ,, "state-bus-service-closest-access"," Closest access"," ",,
elevation, Elevation, ,, "state-bus-service-gps"," GPS"," ",,
toilet-location, Toilet location, ,, "District-bus-service-in-village","In Village",,,
children, Children, ,, "district-bus-service"," Inter-village/district bus service"," ",,
male, Male, ,, "district-bus-service-closest-access"," Closest access"," ",,
female, Female, ,, "district-bus-service-gps"," GPS"," ",,
num-pots, Number of pots, ,, "Panchayat-in-village","In Village",,,
adults, Adults, ,, "panchayat"," Village Panchayat Office"," ",,
add-individual, Add individual, ,, "panchayat-closest-access"," Closest access"," ",,
default-individual-name, A person, ,, "panchayat-gps"," GPS"," ",,
default-family-name, A family, ,, "NGO-in-village","In Village",,,
default-photo-id, ???, ,, "NGO"," Presence of NGO's working with them"," ",,
name-display, Name, ,, "NGO-closest-access"," Closest access"," ",,
photo-id-display, Photo ID, ,, "NGO-gps"," GPS"," ",,
family-display, Family, ,, "market-in-village","In Village",,,
details-button, Details, ,, "market"," Market"," ",,
family-button, Family, ,, "market-closest-access"," Closest access"," ",,
migration-button, Migration, ,, "market-gps"," GPS"," ",,
income-button, Income, ,, "household-name"," Household name"," ",,
geneaology-button, Geneaology, ,, "default-household-name"," A household"," ",,
social-button, Social, ,, "location"," House location"," ",,
agreement-button, Agreement, ,, "elevation"," Elevation"," ",,
is-a-child, Child, ,, "toilet-location"," Toilet location"," ",,
change-photo, Change photo, ,, "children"," Children"," ",,
details-name, Name, ,, "male"," Male","Shynrang",,
details-photo-id, Photo ID, ,, "female"," Female","Kynthei",,
details-family, Family, ,, "num-pots"," Number of pots"," ",,
tribe, Tribe, ,, "adults"," Adults"," ",,
sub-tribe, Sub tribe, ,, "add-individual"," Add individual"," ",,
khasi, Khasi, ,, "default-individual-name"," A person"," ",,
khynriam, Khynriam, ,, "default-family-name"," A family"," ",,
pnar, Pnar, ,, "default-photo-id"," ???"," ",,
bhoi, Bhoi, ,, "name-display"," Name","Kyrteng",,
war, War, ,, "photo-id-display"," Photo ID","Nombor dur ID",,
other, Other, ,, "family-display"," Family","Family/Clan",,
age, Age, ,, "details-button"," Details"," ",,
gender, Gender, ,, "family-button"," Family","Family/Clan",,
education, Education, ,, "migration-button"," Migration"," ",,
illiterate, Illiterate, ,, "friendship-button","Friendship",,,
literate, Literate, ,, "income-button"," Income"," ",,
primary, Primary 1-5, ,, "genealogy-button"," Genealogy"," ",,
middle, Middle 6-8, ,, "social-button"," Social"," ",,
high, High 9-10, ,, "agreement-button"," Agreement"," ",,
secondary, Higher Secondary, ,, "is-a-child"," Child"," ",,
university, University, ,, "change-photo"," Change photo"," ",,
spouse, Spouse, ,, "details-name"," Name","Kyrteng",,
change-id, Change, ,, "details-first-name","Name","Kyrteng",,
head-of-house, Head of house, ,, "details-photo-id"," Photo ID","Nombor dur ID",,
marital-status, Marital status, ,, "details-family"," Family"," ",,
ever-married, Ever married, ,, "tribe"," Tribe","Jaidbynriew:",,
currently-married, Currently married, ,,