Commit f2e7fb9e authored by dave griffiths's avatar dave griffiths

merged

parents 651e57f3 90a6d104
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="foam.symbai"
android:versionCode="8"
android:versionCode="10"
android:versionName="1.0">
<application android:label="@string/app_name"
android:icon="@drawable/logo"
......@@ -26,7 +26,7 @@
<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.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.FriendshipActivity" android:configChanges="orientation"></activity>
<activity android:name="foam.symbai.AgreementActivity" android:configChanges="orientation"></activity>
......
Open Sauces Notebook
====================
A structured notebook for recipes
Symbai android app
==================
......@@ -17,6 +17,8 @@
(msg "dbsync.scm")
(define unset-int 2147483647)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; stuff in memory
......@@ -88,22 +90,51 @@
(define (entity-get-value key)
(ktv-get (get-current 'entity-values '()) key))
(define (check-type type value)
(cond
((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
(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)))
(if (equal? existing-type type)
(set-current!
'entity-values
(ktv-set
(get-current 'entity-values '())
(ktv key type value)))
;;
(begin
(msg "entity-set-value! - adding new " key "of type" type "to entity")
(entity-add-value-create! key type value)))
;; save straight to local db every time
(entity-update-single-value! (list key type value))
))
(cond
((equal? existing-type type)
;; save straight to local db every time (checks for modification)
(entity-update-single-value! (list key type value))
;; then save to memory
(set-current!
'entity-values
(ktv-set
(get-current 'entity-values '())
(ktv 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
(set-current!
'entity-values
(ktv-set
(get-current 'entity-values '())
(ktv key type value))))
(define (date-time->string dt)
......@@ -163,6 +194,8 @@
(table (get-current 'table #f))
(unique-id (ktv-get (get-current 'entity-values '()) "unique_id")))
(cond
((ktv-eq? (ktv-get-whole (get-current 'entity-values '()) (ktv-key ktv)) ktv)
(msg "eusv: no change for" (ktv-key ktv)))
(unique-id
(update-entity db table (entity-id-from-unique db table unique-id) (list ktv)))
(else
......@@ -455,7 +488,7 @@
(list
(network-connect
"network"
"mongoose-web"
"symbai-web"
(lambda (state)
(debug! (string-append "Raspberry Pi connection state now: " state))
(append
......@@ -575,11 +608,25 @@
(layout 'fill-parent 'wrap-content 1 'centre 0)
fn))))
(define (medit-text-large id type fn)
(linear-layout
(make-id (string-append (symbol->string id) "-container"))
'vertical
(layout 'fill-parent 'wrap-content 1 'centre 20)
(list 0 0 0 0)
(list
(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)
fn))))
(define (mspinner id types fn)
(vert
(text-view (symbol->id 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"))
(map mtext-lookup types)
(layout 'wrap-content 'wrap-content 1 'centre 0)
......@@ -650,15 +697,19 @@
(define (image-invalid? image-name)
(or (null? 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
;; dispatches based on widget type
(define (mupdate widget-type id-symbol key)
(cond
((or (eq? widget-type 'edit-text) (eq? widget-type 'text-view))
(update-widget widget-type (get-symbol-id id-symbol) 'text
(entity-get-value key)))
(let ((v (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)
(update-widget widget-type (get-symbol-id id-symbol) 'checked
(entity-get-value key)))
......@@ -779,7 +830,7 @@
;; a standard builder for list widgets of entities and a
;; 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
colour-two
(horiz
......@@ -794,7 +845,7 @@
(ktvlist-merge
(ktv-default-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
(make-id (string-append entity-type "-list"))
'vertical
......@@ -802,13 +853,28 @@
(list 0 0 0 0)
(list))))
(define (make-list-widget-title e title-ids)
(if (eqv? (length title-ids) 1)
(ktv-get e (car title-ids))
(string-append
(ktv-get e (car title-ids)) "\n"
(foldl
(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
(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
(if parent
(db-filter-only db table entity-type
(list (list "parent" "varchar" "=" parent))
(list (list "name" "varchar")))
(map
(lambda (id)
(list id "varchar"))
title-ids))
(db-all db table entity-type))))
(update-widget
'linear-layout
......@@ -820,8 +886,8 @@
(lambda (e)
(button
(make-id (string-append "list-button-" (ktv-get e "unique_id")))
(or (ktv-get e "name") "Unamed item")
40 (layout 'fill-parent 'wrap-content 1 'centre 5)
(make-list-widget-title e title-ids)
30 (layout 'fill-parent 'wrap-content 1 'centre 5)
(lambda ()
(list (start-activity edit-activity 0 (ktv-get e "unique_id"))))))
search-results)))))
......@@ -1029,13 +1095,13 @@
(msg "making village" i)
(let ((village (simpsons-village db table village-ktvlist)))
(looper!
3
15
(lambda (i)
(alog "household")
(msg "making household" i)
(let ((household (simpsons-household db table village household-ktvlist)))
(looper!
(random 10)
(+ 2 (random 5))
(lambda (i)
(msg "making individual" i)
(simpsons-individual db table household individual-ktvlist))))))))))
......
......@@ -706,7 +706,7 @@
(define (relative rules colour . l)
(relative-layout
0 (rlayout 'fill-parent 'wrap-content 20 rules)
0 (rlayout 'fill-parent 'wrap-content (list 20 20 20 20) rules)
colour
l))
......@@ -795,7 +795,8 @@
((null? w) #f)
;; drill deeper
((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)))
((eq? (update-widget-token w) 'grid-buttons)
(add-callback! (callback (update-widget-id w)
......@@ -862,6 +863,7 @@
(begin (display "no dialog called ")(display name)(newline))
(let ((events (apply (dialog-fn dialog) args)))
(update-dialogs! events)
(update-callbacks-from-update! events)
(send (scheme->json events))))))
;; called by java
......
This diff is collapsed.
test-num,1,1,1,
test-text, I am test text, I am test text, I am test text,
one, one, ,,
two, two, ,,
three, three, ,,
village, Village, ,,
household, Household, ,,
households, Households, ,,
individual, Individual, ,,
individuals, Individuals, ,,
add-item-to-list,0, ,,
default-village-name, New village, ,,
title, Symbai, Symbai, Symbai,
sync, Sync, Sync, Sync,
languages, Choose language, Choose language, Choose language,
english, English, English, English,
khasi, Khasi, Khasi, Khasi,
hindi, Hindi, Hindi, Hindi,
user-id, Your user ID, User ID, User ID,
save, Save, Save, Save,
back, Back, Back, Back,
off, Off, Off, Off,
villages, Villages, Villages, Villages,
list-empty, List empty, ,,
delete, Delete, ,,
delete-are-you-sure, Are you sure you want to delete this?, ,,
save-are-you-sure, Are you sure you want to save changes?, ,,
quick-name, New person name, ,,
quick-add, Quick add, ,,
find-individual, Find individual, ,,
filter, Filter, ,,
off, Off, Off, Off,
name, Name, ,,
sync-all, Sync me!, ,,
sync-syncall, Sync everything, ,,
export-data, Exporting data, ,,
sync-download, Download main DB, ,,
sync-export, Email main DB, ,,
email-local, Email local DB, ,,
debug, Debug, ,,
sync-back, Back, ,,
sync-prof, Profile, ,,
village-name, Village name, Village name, Village name,
block, Block, Block, Block,
district, District, District, District,
car, Accessible by car, ,,
household-list, Household list, ,,
amenities, Amenities, ,,
school, School, ,,
present, Present, ,,
closest-access, Closest place of access, ,,
house-gps, GPS, ,,
toilet-gps, GPS, ,,
school, School, ,,
school-closest-access, Closest access, ,,
school-gps, GPS, ,,
hospital, Hospital/Health care centre, ,,
hospital-closest-access, Closest access, ,,
hospital-gps, GPS, ,,
post-office, Post Office, ,,
post-office-closest-access, Closest access, ,,
post-office-gps, GPS, ,,
railway-station, Railway station, ,,
railway-station-closest-access, Closest access, ,,
railway-station-gps, GPS, ,,
state-bus-service, Inter-state bus service, ,,
state-bus-service-closest-access, Closest access, ,,
state-bus-service-gps, GPS, ,,
district-bus-service, Inter-village/district bus service, ,,
district-bus-service-closest-access, Closest access, ,,
district-bus-service-gps, GPS, ,,
panchayat, Village Panchayat Office, ,,
panchayat-closest-access, Closest access, ,,
panchayat-gps, GPS, ,,
NGO, Presence of NGO's working with them, ,,
NGO-closest-access, Closest access, ,,
NGO-gps, GPS, ,,
market, Market, ,,
market-closest-access, Closest access, ,,
market-gps, GPS, ,,
household-name, Household name, ,,
default-household-name, A household, ,,
location, House location, ,,
elevation, Elevation, ,,
toilet-location, Toilet location, ,,
children, Children, ,,
male, Male, ,,
female, Female, ,,
num-pots, Number of pots, ,,
adults, Adults, ,,
add-individual, Add individual, ,,
default-individual-name, A person, ,,
default-family-name, A family, ,,
default-photo-id, ???, ,,
name-display, Name, ,,
photo-id-display, Photo ID, ,,
family-display, Family, ,,
details-button, Details, ,,
family-button, Family, ,,
migration-button, Migration, ,,
income-button, Income, ,,
geneaology-button, Geneaology, ,,
social-button, Social, ,,
agreement-button, Agreement, ,,
is-a-child, Child, ,,
change-photo, Change photo, ,,
details-name, Name, ,,
details-photo-id, Photo ID, ,,
details-family, Family, ,,
tribe, Tribe, ,,
sub-tribe, Sub tribe, ,,
khasi, Khasi, ,,
khynriam, Khynriam, ,,
pnar, Pnar, ,,
bhoi, Bhoi, ,,
war, War, ,,
other, Other, ,,
age, Age, ,,
gender, Gender, ,,
education, Education, ,,
illiterate, Illiterate, ,,
literate, Literate, ,,
primary, Primary 1-5, ,,
middle, Middle 6-8, ,,
high, High 9-10, ,,
secondary, Higher Secondary, ,,
university, University, ,,
spouse, Spouse, ,,
change-id, Change, ,,
head-of-house, Head of house, ,,
marital-status, Marital status, ,,
ever-married, Ever married, ,,
currently-married, Currently married, ,,
currently-single, Currently single, ,,
seperated, Seperated/divorced, ,,
times-married, How many times married, ,,
change-spouse, Change/add spouse, ,,
children-living, Living, ,,
children-dead, Dead, ,,
children-together, Living together, ,,
children-apart, Living apart, ,,
residence-after-marriage, Residence after marriage, ,,
birthplace, Birthplace, ,,
spouse-village, Spouses natal village, ,,
num-siblings, Number of living siblings of the same sex born from same mother, ,,
birth-order, Birth order amoung currently living same sex siblings born from same mother, ,,
length-time, Length of time lived in this village (years), ,,
place-of-birth, Place of birth, ,,
num-residence-changes, Number of time place of residence changed since birth, ,,
village-visits-month, Number of times you have visited another village in the last month, ,,
village-visits-year, Number of times you have visited another village in the last year (i.e. betwen last summer and this summer), ,,
occupation, Occupation, ,,
occupation, Occupation, ,,
agriculture, Agriculture, ,,
gathering, Gathering, ,,
labour, Labour, ,,
cows, Cows, ,,
fishing, Fishing, ,,
num-people-in-house, People living in house, ,,
contribute, Contribute to family earnings?, ,,
own-land, Own land?, ,,
rent-land, Rent out your land?, ,,
hire-land, Hire land?, ,,
crops, Crops, ,,
unit, Unit, ,,
quantity, Quantity, ,,
used-or-eaten, Used/Eaten, ,,
sold, Sold, ,,
seed, Seed (hybrid/local), ,,
house-type, House type, ,,
concrete, Concrete, ,,
tin, Tin, ,,
thatched, Thatched, ,,
loan, Outstanding loans, ,,
earning, One day's earnings, ,,
in-the-home, In the home, ,,
radio, Radio, ,,
tv, TV, ,,
mobile, Mobile phone, ,,
visit-market, Tribal market visits, ,,
town-sell, Town or city visits, ,,
default-crop-name, A crop, ,,
crop-name, Crop name, ,,
crop-unit, Crop unit, ,,
crop-used, Used or eaten, ,,
crop-sold, Sold, ,,
crop-seed, Seed, ,,
mother, Mother, ,,
father, Father, ,,
change-mother, Change mother, ,,
change-father, Change father, ,,
alive, Alive, ,,
sex, Sex, ,,
social-type, Type, ,,
friendship, Friendship, ,,
knowledge, Knowledge, ,,
prestige, Prestige, ,,
social-one, One, ,,
social-two, Two, ,,
social-three, Three, ,,
social-four, Four, ,,
social-five, Five, ,,
social-relationship, Relationship, ,,
social-residence, Residence, ,,
social-strength, Strength, ,,
mother, Mother, ,,
father, Father, ,,
sister, Sister, ,,
brother, Brother, ,,
spouse, Spouse, ,,
children, Children, ,,
co-wife, Co-wife, ,,
spouse-mother, Spouse's mother, ,,
spouse-father, Spouse's father, ,,
spouse-brother-wife, Spouse's brother's wife, ,,
spouse-sister-husband, Spouse's sister's husband, ,,
friend, Friend, ,,
neighbour, Neighbour, ,,
same, Same, ,,
daily, Daily, ,,
weekly, Weekly, ,,
monthly, Monthly, ,,
less, Less, ,,
"Code (don't change these)","English","Khasi","Hindi",
"start","Symbai",,,
"next","Next",,,
"yes","Yes",,,
"no","No",,,
"unanswered","Unanswered",,,
"not-set","Not set",,,
"details-next","Next",,,
"family-next","Next",,,
"migration-next","Next",,,
"income-next","Next",,,
"gene-next","Next",,,
"social-next","Next",,,
"friendship-next","Next",,,
"agreement-next","Next",,,
"village"," Village"," ",,
"household"," Household"," ",,
"households"," Households"," ",,
"individual"," Individual"," ",,
"individuals"," Individuals"," ",,
"add-item-to-list",0," ",,
"default-village-name"," New village"," ",,
"title"," Symbai"," Symbai"," Symbai"," "
"sync"," Sync"," Sync"," Sync"," "
"languages"," Choose language"," Choose language"," Choose language"," "
"english"," English"," English"," English"," "
"khasi"," Khasi"," Khasi"," Khasi"," "
"hindi"," Hindi"," Hindi"," Hindi"," "
"user-id"," User ID"," User ID"," User ID"," "
"save"," Save"," Save"," Save"," "
"back"," Back"," Back"," Back"," "
"off"," Off"," Off"," Off"," "
"villages"," Villages"," Villages"," Villages"," "
"list-empty"," List empty"," ",,
"delete"," Delete"," ",,
"delete-are-you-sure"," Are you sure you want to delete this?"," ",,
"save-are-you-sure"," Are you sure you want to save changes?"," ",,
"quick-name"," New person name"," ",,
"quick-add"," Quick add"," ",,
"find-individual"," Find individual"," ",,
"filter"," Filter"," ",,
"filter-switch","Run filter",,,
"off"," Off"," Off"," Off"," "
"name"," Name","Kyrteng",,
"sync-all"," Sync me!"," ",,
"sync-syncall"," Sync everything"," ",,
"export-data"," Exporting data"," ",,
"sync-download"," Download main DB"," ",,
"sync-export"," Email main DB"," ",,
"email-local"," Email local DB"," ",,
"debug"," Debug"," ",,
"sync-back"," Back"," ",,
"sync-prof"," Profile"," ",,
"village-name"," Village name"," Village name"," Village name"," "
"block"," Block"," Block"," Block"," "
"district"," District"," District"," District"," "
"car"," Accessible by car"," ",,
"household-list"," Household list"," ",,
"amenities"," Amenities"," ",,
"school"," School"," ",,
"present"," Present"," ",,
"closest-access"," Closest place of access"," ",,
"house-gps"," GPS"," ",,
"toilet-gps"," GPS"," ",,
"school-in-village","In Village",,,
"school"," School"," ",,
"school-closest-access"," Closest access"," ",,
"school-gps"," GPS"," ",,
"hospital-in-village","In Village",,,
"hospital"," Hospital/Health care centre"," ",,
"hospital-closest-access"," Closest access"," ",,
"hospital-gps"," GPS"," ",,
"Post-office-in-village","In Village",,,
"post-office"," Post Office"," ",,
"post-office-closest-access"," Closest access"," ",,
"post-office-gps"," GPS"," ",,
"railway-station-in-village","In Village",,,
"railway-station"," Railway station"," ",,
"railway-station-closest-access"," Closest access"," ",,
"railway-station-gps"," GPS"," ",,
"State-bus-service-in-village","In Village",,,
"state-bus-service"," Inter-state bus service"," ",,
"state-bus-service-closest-access"," Closest access"," ",,
"state-bus-service-gps"," GPS"," ",,
"District-bus-service-in-village","In Village",,,
"district-bus-service"," Inter-village/district bus service"," ",,
"district-bus-service-closest-access"," Closest access"," ",,
"district-bus-service-gps"," GPS"," ",,
"Panchayat-in-village","In Village",,,
"panchayat"," Village Panchayat Office"," ",,
"panchayat-closest-access"," Closest access"," ",,
"panchayat-gps"," GPS"," ",,
"NGO-in-village","In Village",,,
"NGO"," Presence of NGO's working with them"," ",,
"NGO-closest-access"," Closest access"," ",,
"NGO-gps"," GPS"," ",,
"market-in-village","In Village",,,
"market"," Market"," ",,
"market-closest-access"," Closest access"," ",,
"market-gps"," GPS"," ",,
"household-name"," Household name"," ",,
"default-household-name"," A household"," ",,
"location"," House location"," ",,
"elevation"," Elevation"," ",,
"toilet-location"," Toilet location"," ",,
"children"," Children"," ",,
"male"," Male","Shynrang",,
"female"," Female","Kynthei",,
"num-pots"," Number of pots"," ",,
"adults"," Adults"," ",,
"add-individual"," Add individual"," ",,
"default-individual-name"," A person"," ",,