Commit 4d8f92b9 authored by Dave Griffiths's avatar Dave Griffiths
Browse files

new font, toggle buttons, layouts

parent 07475188
......@@ -447,8 +447,8 @@
(define (edit-text-listener t) (list-ref t 6))
(define (button id text text-size layout listener) (list "button" id text text-size layout listener))
(define (button-listener t) (list-ref t 5))
(define (toggle-button id text text-size layout listener) (list "toggle-button" id text text-size layout listener))
(define (toggle-button-listener t) (list-ref t 5))
(define (toggle-button id text text-size layout style listener) (list "toggle-button" id text text-size layout style listener))
(define (toggle-button-listener t) (list-ref t 6))
(define (seek-bar id max layout listener) (list "seek-bar" id max layout listener))
(define (seek-bar-listener t) (list-ref t 4))
(define (spinner id items layout listener) (list "spinner" id items layout listener))
......
......@@ -325,10 +325,10 @@
(button (make-id id) title 20 (layout 150 100 1 'centre 0) fn))
(define (mtoggle-button id title fn)
(toggle-button (make-id id) title 20 fillwrap fn))
(toggle-button (make-id id) title 20 (layout 'fill-parent 'wrap-content 1 'centre 0) "fancy" fn))
(define (mtoggle-button2 id title fn)
(toggle-button (make-id id) title 20 (layout 150 100 1 'centre 0) fn))
(toggle-button (make-id id) title 20 (layout 150 100 1 'centre 0) "plain" fn))
(define (mtext id text)
(text-view (make-id id) text 20 fillwrap))
......@@ -1046,7 +1046,6 @@
db "local" 1 (list (ktv "user-id" "varchar" v)))))
(mtext "foo" "Database")
(horiz
(mbutton2 "main-send" "Email" (lambda () (list)))
(mbutton2 "main-sync" "Sync" (lambda () (list (start-activity "sync" 0 ""))))))
(lambda (activity arg)
(activity-layout activity))
......@@ -1090,7 +1089,7 @@
(set-current! 'observation obs-gp)
(mclear-toggles (list "choose-obs-pf" "choose-obs-gc"))))))))
(build-grid-selector "choose-obs-pack-selector" "single" "Choose pack")
(mbutton
(mbutton2
"choose-obs-start" "Start"
(lambda ()
;; set up the observation fragments
......@@ -1162,7 +1161,7 @@
(msg "button-bar" frag)
(let ((id (string-append "obs-bar-" (cadr frag))))
(toggle-button
(make-id id) (car frag) 12 fillwrap
(make-id id) (car frag) 12 fillwrap "plain"
(lambda (v)
(append
(mclear-toggles-not-me id all-toggles)
......@@ -1190,13 +1189,13 @@
(mtext "pf1-pack" "Pack")
(build-grid-selector "pf1-grid" "single" "Select pup")
(horiz
(medit-text "pf1-width" "Pack width" "numeric"
(medit-text "pf1-width" "Pack width - left to right" "numeric"
(lambda (v) (entity-add-value! "pack-width" "int" v) '()))
(medit-text "pf1-height" "Pack height" "numeric"
(lambda (v) (entity-add-value! "pack-height" "int" v) '())))
(medit-text "pf1-count" "How many mongooses present?" "numeric"
(medit-text "pf1-height" "Pack depth - front to back" "numeric"
(lambda (v) (entity-add-value! "pack-depth" "int" v) '())))
(medit-text "pf1-count" "How many mongooses can you see?" "numeric"
(lambda (v) (entity-add-value! "pack-count" "int" v) '()))
(mbutton "pf1-done" "Done"
(mbutton2 "pf1-done" "Done"
(lambda ()
(set-current! 'pup-focal-id (entity-record-values db "stream" "pup-focal"))
(set-current! 'timer-minutes 20)
......@@ -1241,7 +1240,7 @@
(mtext "title" "Next scan:")
(mtitle "pf-timer-time"
(number->string (get-current 'timer-seconds 60)))))
(mtoggle-button "pf-pause" "Pause"
(mtoggle-button "pf-pause" "Pause" "plain"
(lambda (v)
(msg "pausing")
(if v
......@@ -1293,7 +1292,7 @@
(vert
(text-view (make-id "title") "Manage packs" 40 fillwrap)
(build-grid-selector "manage-packs-list" "button" "Choose pack")
(button (make-id "manage-packs-new") "New pack" 20 fillwrap (lambda () (list (start-activity "new-pack" 2 ""))))
(mbutton2 "manage-packs-new" "New pack" (lambda () (list (start-activity "new-pack" 2 ""))))
)
(lambda (activity arg)
(activity-layout activity))
......@@ -1321,12 +1320,12 @@
(lambda (v) (entity-add-value! "name" "varchar" v) '()))
(spacer 10)
(horiz
(button (make-id "new-pack-cancel") "Cancel" 20 fillwrap
(lambda () (entity-reset!) (list (finish-activity 2))))
(button (make-id "new-pack-done") "Done" 20 fillwrap
(lambda ()
(entity-record-values db "sync" "pack")
(list (finish-activity 2)))))
(mbutton2 "new-pack-cancel" "Cancel"
(lambda () (entity-reset!) (list (finish-activity 2))))
(mbutton2 "new-pack-done" "Done"
(lambda ()
(entity-record-values db "sync" "pack")
(list (finish-activity 2)))))
)
(lambda (activity arg)
(activity-layout activity))
......@@ -1343,7 +1342,7 @@
(text-view (make-id "title") "Manage individuals" 40 fillwrap)
(text-view (make-id "manage-individual-pack-name") "Pack:" 20 fillwrap)
(build-grid-selector "manage-individuals-list" "button" "Choose individual")
(button (make-id "manage-individuals-new") "New individual" 20 fillwrap (lambda () (list (start-activity "new-individual" 2 ""))))
(mbutton2 "manage-individuals-new" "New individual" (lambda () (list (start-activity "new-individual" 2 ""))))
)
(lambda (activity arg)
(activity-layout activity))
......@@ -1396,13 +1395,13 @@
(edit-text (make-id "new-individual-chip-code") "" 30 "text" fillwrap
(lambda (v) (entity-add-value! "chip-code" "varchar" v) '()))
(horiz
(button (make-id "new-individual-cancel") "Cancel" 20 fillwrap
(lambda () (entity-reset!) (list (finish-activity 2))))
(button (make-id "new-individual-done") "Done" 20 fillwrap
(lambda ()
(entity-add-value! "pack-id" "varchar" (ktv-get (get-current 'pack '()) "unique_id"))
(entity-record-values db "sync" "mongoose")
(list (finish-activity 2)))))
(mbutton2 "new-individual-cancel" "Cancel"
(lambda () (entity-reset!) (list (finish-activity 2))))
(mbutton2 "new-individual-done" "Done"
(lambda ()
(entity-add-value! "pack-id" "varchar" (ktv-get (get-current 'pack '()) "unique_id"))
(entity-record-values db "sync" "mongoose")
(list (finish-activity 2)))))
)
(lambda (activity arg)
(activity-layout activity))
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
</selector>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:drawable="@drawable/tick">
<shape>
<gradient android:endColor="#eeffffff"
android:startColor="#eeffffff" android:angle="270" />
<corners android:radius="5dp" />
<padding android:left="4dp" android:top="4dp"
android:right="4dp" android:bottom="4dp" />
</shape>
</item>
<item android:state_pressed="true" android:drawable="@drawable/tick">
<shape>
<gradient android:endColor="#77dddddd"
android:startColor="#77dddddd" android:angle="270" />
<corners android:radius="5dp" />
<padding android:left="4dp" android:top="4dp"
android:right="4dp" android:bottom="4dp" />
</shape>
</item>
<item android:state_focused="true">
<shape>
<gradient android:endColor="#77eeeeee"
android:startColor="#77eeeeee" android:angle="270" />
<corners android:radius="5dp" />
<padding android:left="4dp" android:top="4dp"
android:right="4dp" android:bottom="4dp" />
</shape>
</item>
<item android:drawable="@drawable/cross">
<shape>
<gradient android:endColor="#77ffffff"
android:startColor="#77ffffff" android:angle="270" />
<corners android:radius="5dp" />
<padding android:left="4dp" android:top="4dp"
android:right="4dp" android:bottom="4dp" />
</shape>
</item>
</selector>
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/spinnerTarget"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:padding="10sp"
android:textSize="33sp"
/>
<?xml version="1.0" encoding="utf-8"?>
<ToggleButton xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="top|center_horizontal"
android:drawablePadding="5dp"
style="@style/StarwispFancyToggleButton"
/>
......@@ -12,6 +12,15 @@
<item name="android:layout_marginBottom">5dp</item>
</style>
<style name="StarwispFancyToggleButton" parent="android:style/Widget.Button">
<item name="android:textColor">@color/text</item>
<item name="android:textSize">50sp</item>
<item name="android:layout_margin">10dip</item>
<item name="android:drawableTop">@drawable/swarmtoggledrawable</item>
<item name="android:background">@drawable/swarmtoggle</item>
<item name="android:layout_marginBottom">5dp</item>
</style>
<style name="StarwispSpinnerItem" parent="android:Widget.TextView.SpinnerItem">
<!-- <item name="android:textAppearance">@style/StarwispTextAppearanceSpinnerItem</item> -->
<item name="android:background">@drawable/swarmspinner</item>
......
......@@ -54,8 +54,9 @@ public class StarwispActivity extends FragmentActivity
String json = m_Scheme.eval("(activity-callback 'on-create \""+m_Name+"\" (list \""+arg+"\"))");
View root = findViewById(R.id.main);
m_Typeface = Typeface.createFromAsset(getAssets(), "fonts/Pfennig.ttf");
//m_Typeface = Typeface.createFromAsset(getAssets(), "fonts/Pfennig.ttf");
//m_Typeface = Typeface.createFromAsset(getAssets(), "fonts/grstylus.ttf");
m_Typeface = Typeface.createFromAsset(getAssets(), "fonts/RobotoCondensed-Regular.ttf");
try {
m_Builder.Build(this, m_Name, new JSONArray(json), (ViewGroup) root);
......
......@@ -479,13 +479,19 @@ public class StarwispBuilder
}
if (type.equals("toggle-button")) {
ToggleButton v = new ToggleButton(ctx);
ToggleButton v;
if (arr.getString(5).equals("plain")) {
v = new ToggleButton(ctx);
} else {
v = (ToggleButton)ctx.getLayoutInflater().inflate(R.layout.toggle_button_fancy, null);
}
v.setId(arr.getInt(1));
v.setText(arr.getString(2));
v.setTextSize(arr.getInt(3));
v.setLayoutParams(BuildLayoutParams(arr.getJSONArray(4)));
v.setTypeface(((StarwispActivity)ctx).m_Typeface);
final String fn = arr.getString(5);
final String fn = arr.getString(6);
v.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String arg="#f";
......@@ -538,6 +544,8 @@ public class StarwispBuilder
}
};
spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner_layout);
v.setAdapter(spinnerArrayAdapter);
v.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> a, View v, int pos, long id) {
......
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