Skip to content

Instantly share code, notes, and snippets.

@StefanKrecher
Created September 19, 2012 15:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StefanKrecher/3750305 to your computer and use it in GitHub Desktop.
Save StefanKrecher/3750305 to your computer and use it in GitHub Desktop.
simple workspace for GNU Smalltalk on Android
PackageLoader fileInPackage: 'Android'.
| layout event droid samples |
droid := Android new.
layout := '<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/background"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#ff000000">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="GNU Smalltalk 3.4.2"
android:id="@+id/textView1"
android:textAppearance="?android:attr/textAppearanceLarge" android:gravity="center_vertical|center_horizontal|center">
</TextView>
<EditText android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/editText1"
android:tag="Tag Me" android:inputType="text|textMultiLine">
android:gravity="top"
<requestFocus></requestFocus>
</EditText>
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout1">
<Button android:id="@+id/printit" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="print it"></Button>
<Button android:id="@+id/cancel" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Cancel"></Button>
</LinearLayout>
<EditText android:layout_width="match_parent"
android:layout_height="200dp"
android:id="@+id/output"
android:tag="Tag Me" android:inputType="text|textMultiLine">
android:gravity="top"
<requestFocus></requestFocus>
</EditText>
</LinearLayout>'.
samples := '| droid |
droid := Android new.
(droid cameraCapturePicture: ''/mnt/sdcard/snap.jpg'') inspect.
| droid |
droid := Android new.
droid dialogCreateAlert: (''battery level: '', (droid batteryGetLevel asString)).
droid dialogShow.
'.
droid fullShow: layout.
droid fullSetProperty: (Array with: 'editText1' with: 'text' with: (samples asString)).
" eventloop "
[
| command execute |
event := droid eventWait.
event inspect.
command := ((event at: 'result') at: 'data') at: 'id' ifAbsent: [ 'bla' ].
('EVENT: ', command) printNl.
command = 'printit'
ifTrue: [
| result |
droid fullQuery inspect.
droid getClipboard inspect.
execute := (droid getClipboard at: 'result' ifAbsent: [ 'empty' ]).
execute printNl.
result := Behavior evaluate: execute.
droid fullSetProperty: (Array with: 'output' with: 'text' with: (result asString)).
].
command = 'cancel'
ifTrue: [ 'CANCEL!' printNl. ^false ].
true.
] whileTrue.
droid fullDismiss.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment