diff options
author | Jay Freeman <saurik@saurik.com> | 2008-01-22 14:21:14 +0000 |
---|---|---|
committer | Jay Freeman <saurik@saurik.com> | 2008-01-22 14:21:14 +0000 |
commit | 5f88bb5700e49555f7e4a59ecee7e308c4b068e0 (patch) | |
tree | 4bfc2d24fa02f870c2cabd48a72cc4633ae212ff /data/iphone-java/HelloScript.app | |
parent | 794dacec5420b1fb65fdef0cd3e7f0208b9bdafa (diff) |
Added iPhone/Java, fixing dependencies and providing full support for the iPod touch.
git-svn-id: http://svn.telesphoreo.org/trunk@17 514c082c-b64e-11dc-b46d-3d985efe055d
Diffstat (limited to 'data/iphone-java/HelloScript.app')
-rw-r--r-- | data/iphone-java/HelloScript.app/Default.png | bin | 0 -> 590265 bytes | |||
-rwxr-xr-x | data/iphone-java/HelloScript.app/HelloScript | 5 | ||||
-rw-r--r-- | data/iphone-java/HelloScript.app/HelloScript.js | 115 | ||||
-rw-r--r-- | data/iphone-java/HelloScript.app/Info.plist | 34 | ||||
l--------- | data/iphone-java/HelloScript.app/Java | 1 | ||||
-rw-r--r-- | data/iphone-java/HelloScript.app/icon.png | bin | 0 -> 2925 bytes | |||
-rw-r--r-- | data/iphone-java/HelloScript.app/start.wav | bin | 0 -> 80856 bytes |
7 files changed, 155 insertions, 0 deletions
diff --git a/data/iphone-java/HelloScript.app/Default.png b/data/iphone-java/HelloScript.app/Default.png Binary files differnew file mode 100644 index 000000000..f475d4db7 --- /dev/null +++ b/data/iphone-java/HelloScript.app/Default.png diff --git a/data/iphone-java/HelloScript.app/HelloScript b/data/iphone-java/HelloScript.app/HelloScript new file mode 100755 index 000000000..2b4460d41 --- /dev/null +++ b/data/iphone-java/HelloScript.app/HelloScript @@ -0,0 +1,5 @@ +#!/bin/bash +# XXX: -Xbootclasspath is used as JamVM runs 3x faster +# XXX: Java is symlink'd to here so the home button works +cd "$(dirname "$0")" +exec "$(dirname "$0")"/Java -Xmx8M -Xss256K -Xbootclasspath/p:/usr/share/java/jocstrap.jar:/usr/share/java/js.jar -cp /usr/share/java/sqlite.jar:/usr/share/java/uicaboodle.jar com.saurik.uicaboodle.Main com.saurik.uicaboodle.ScriptApplication HelloScript.js "$@" diff --git a/data/iphone-java/HelloScript.app/HelloScript.js b/data/iphone-java/HelloScript.app/HelloScript.js new file mode 100644 index 000000000..976868ec2 --- /dev/null +++ b/data/iphone-java/HelloScript.app/HelloScript.js @@ -0,0 +1,115 @@ +var println = function(s) { java.lang.System.out.println(s); } +var sql = Packages.SQLite; + +var contacts = []; +var sections = []; + +var ab = new sql.Database(); +ab.open("/var/root/Library/AddressBook/AddressBook.sqlitedb", 0666); try { + var st = ab.prepare("select first, last from ABPerson where first is not null order by first"); try { + while (st.step()) + contacts.push({ + first: st.column_string(0), + last: st.column_string(1), + cell: null + }); + } finally { st.close(); } +} finally { ab.close(); } + +function getName(contact) { + var name = contact.first; + if (contact.last != null) + name += " " + contact.last; + return name; +} + +var outer = obc.UIHardware.fullScreenApplicationContentRect(); +var inner = outer.clone(); +inner.origin.x = inner.origin.y = 0; + +var window = new obc.UIWindow().initWithContentRect$(inner); +window.orderFront$(application); +window.makeKey$(application); +window._setHidden$(NO); + +var navsize = obc.UINavigationBar().defaultSize(); +var navbar = new obc.UINavigationBar().initWithFrame$(new obc.CGRect(0, 0, inner.size.width, navsize.height)); +navbar.setBarStyle$(1); +navbar.showButtonsWithLeftTitle$rightTitle$leftBack$("Run GC", null, YES); + +navbar.setDelegate$({ + navigationBar$buttonClicked$: function(navbar, button) { + Packages.java.lang.Runtime.getRuntime().gc(); + } +}); + +var navitem = new obc.UINavigationItem().initWithTitle$("Contact List"); +navbar.pushNavigationItem$(navitem); + +var letter = null; +for (var i = 0; i != contacts.length; ++i) { + var name = getName(contacts[i]); + var now = name[0].toUpperCase(); + if (letter != now) { + letter = now; + sections.push({ + row: i, + title: now + }); + } +} + +var seclist = new obc.UISectionList().initWithFrame$(new obc.CGRect(0, navsize.height, inner.size.width, inner.size.height - navsize.height)); + +seclist.setDataSource$({ + numberOfSectionsInSectionList$: function(list) { + return sections.length; + }, + + sectionList$titleForSection$: function(list, section) { + return sections[section].title; + }, + + sectionList$rowForSection$: function(list, section) { + return sections[section].row; + }, + + numberOfRowsInTable$: function(table) { + return contacts.length; + }, + + table$cellForRow$column$: function(table, row, col) { + var contact = contacts[row]; + if (contact.cell != null) + return contact.cell; + var cell = new obc.UIImageAndTextTableCell().init(); + cell.setTitle$(getName(contact)); + contact.cell = cell; + return cell; + } +}); + +seclist.reloadData(); + +var col = new obc.UITableColumn().initWithTitle$identifier$width$("Name", "name", 320); + +var table = seclist.table(); +table.setSeparatorStyle$(1); +table.addTableColumn$(col); + +var view = new obc.UIView().initWithFrame$(inner); +view.addSubview$(navbar); +view.addSubview$(seclist); + +window.setContentView$(view); + +/* XXX: this works around a VM bug and will be removed */ +java.lang.Class.forName("osx.Celestial"); + +var controller = new obc.AVController().init(); +var wavfile = obc.NSBundle().mainBundle().pathForResource$ofType$("start", "wav") +var wavitem = new obc.AVItem().initWithPath$error$(wavfile, null); +wavitem.setVolume$(100); +controller.setCurrentItem$(wavitem); +controller.setCurrentTime$(0); +controller.play$(null); diff --git a/data/iphone-java/HelloScript.app/Info.plist b/data/iphone-java/HelloScript.app/Info.plist new file mode 100644 index 000000000..75b62f58e --- /dev/null +++ b/data/iphone-java/HelloScript.app/Info.plist @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> + +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>en</string> + + <key>CFBundleExecutable</key> + <string>HelloScript</string> + + <key>CFBundleIdentifier</key> + <string>com.saurik.HelloScript</string> + + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + + <key>CFBundleName</key> + <string>HelloScript</string> + + <key>CFBundlePackageType</key> + <string>APPL</string> + + <key>CFBundleShortVersionString</key> + <string>1.0</string> + + <key>CFBundleSignature</key> + <string>????</string> + + <key>CFBundleVersion</key> + <string>1.0</string> +</dict> + +</plist> diff --git a/data/iphone-java/HelloScript.app/Java b/data/iphone-java/HelloScript.app/Java new file mode 120000 index 000000000..33b0c18fb --- /dev/null +++ b/data/iphone-java/HelloScript.app/Java @@ -0,0 +1 @@ +/usr/bin/java
\ No newline at end of file diff --git a/data/iphone-java/HelloScript.app/icon.png b/data/iphone-java/HelloScript.app/icon.png Binary files differnew file mode 100644 index 000000000..306d0d729 --- /dev/null +++ b/data/iphone-java/HelloScript.app/icon.png diff --git a/data/iphone-java/HelloScript.app/start.wav b/data/iphone-java/HelloScript.app/start.wav Binary files differnew file mode 100644 index 000000000..91a65a3f5 --- /dev/null +++ b/data/iphone-java/HelloScript.app/start.wav |