diff options
Diffstat (limited to 'data/iphone-java')
24 files changed, 357 insertions, 0 deletions
diff --git a/data/iphone-java/HelloJava.app/Default.png b/data/iphone-java/HelloJava.app/Default.png Binary files differnew file mode 100644 index 000000000..f475d4db7 --- /dev/null +++ b/data/iphone-java/HelloJava.app/Default.png diff --git a/data/iphone-java/HelloJava.app/HelloJava b/data/iphone-java/HelloJava.app/HelloJava new file mode 100755 index 000000000..88d801cdb --- /dev/null +++ b/data/iphone-java/HelloJava.app/HelloJava @@ -0,0 +1,4 @@ +#!/bin/bash +# XXX: -Xbootclasspath is used as JamVM runs 3x faster +# XXX: Java is symlink'd to here so the home button works +exec "$(dirname "$0")"/Java -Xmx8M -Xss256K -Xbootclasspath/p:/usr/share/java/sqlite.jar:/usr/share/java/jocstrap.jar -cp /usr/share/java/uicaboodle.jar:"$(dirname "$0")" com.saurik.uicaboodle.Main HelloJava "$@" diff --git a/data/iphone-java/HelloJava.app/HelloJava.java b/data/iphone-java/HelloJava.app/HelloJava.java new file mode 100644 index 000000000..8b8f7ce37 --- /dev/null +++ b/data/iphone-java/HelloJava.app/HelloJava.java @@ -0,0 +1,149 @@ +import obc.*; +import joc.*; + +import joc.Message; + +import static joc.Pointer.*; +import static joc.Static.*; + +import java.util.ArrayList; +import java.util.Date; + +public class HelloJava + extends UIApplication +{ + +private UIWindow window; + +private static class Contact { + public String first; + public String last; + public UITableCell cell; + + public Contact(String first, String last) { + this.first = first; + this.last = last; + this.cell = null; + } + + public String getName() { + String name = first; + if (last != null) + name += " " + last; + return name; + } +} + +public static class Section { + public int row; + public String title; + + public Section(int row, String title) { + this.row = row; + this.title = title; + } +} + +private ArrayList<Contact> contacts_ = new ArrayList<Contact>(); +private ArrayList<Section> sections_ = new ArrayList<Section>(); + +@Message public void applicationDidFinishLaunching$(Object unused) + throws Exception +{ + SQLite.Database ab = new SQLite.Database(); + ab.open("/var/root/Library/AddressBook/AddressBook.sqlitedb", 0666); try { + SQLite.Stmt st = ab.prepare("select first, last from ABPerson where first is not null order by first"); try { + while (st.step()) + contacts_.add(new Contact(st.column_string(0), st.column_string(1))); + } finally { st.close(); } + } finally { ab.close(); } + + CGRect outer = UIHardware.fullScreenApplicationContentRect(); + CGRect inner = outer.clone(); + inner.origin.x = inner.origin.y = 0; + + window = new UIWindow().initWithContentRect$(inner); + window.orderFront$(this); + window.makeKey$(this); + window._setHidden$(NO); + + CGSize navsize = UINavigationBar.defaultSize(); + UINavigationBar navbar = new UINavigationBar().initWithFrame$(new CGRect(0, 0, inner.size.width, navsize.height)); + navbar.setBarStyle$(1); + navbar.showButtonsWithLeftTitle$rightTitle$leftBack$("Run GC", null, YES); + + navbar.setDelegate$(new NSObject() { + @Message void navigationBar$buttonClicked$(UINavigationBar navbar, int button) { + java.lang.Runtime.getRuntime().gc(); + } + }.init()); + + UINavigationItem navitem = new UINavigationItem().initWithTitle$("Contact List"); + navbar.pushNavigationItem$(navitem); + + char letter = 0; + for (int i = 0; i != contacts_.size(); ++i) { + String name = contacts_.get(i).getName(); + char now = name.charAt(0); + if (letter != now) { + letter = now; + sections_.add(new Section( + i, new String(new char[] {now}) + )); + } + } + + UISectionList seclist = new UISectionList().initWithFrame$(new CGRect(0, navsize.height, inner.size.width, inner.size.height - navsize.height)); + + seclist.setDataSource$(new NSObject() { + @Message int numberOfSectionsInSectionList$(UISectionList list) { + return sections_.size(); + } + + @Message String sectionList$titleForSection$(UISectionList list, int section) { + return sections_.get(section).title; + } + + @Message int sectionList$rowForSection$(UISectionList list, int section) { + return sections_.get(section).row; + } + + @Message int numberOfRowsInTable$(UITable table) { + return contacts_.size(); + } + + @Message UITableCell table$cellForRow$column$(UITable table, int row, UITableColumn col) { + Contact contact = contacts_.get(row); + if (contact.cell != null) + return contact.cell; + UIImageAndTextTableCell cell = (UIImageAndTextTableCell) new UIImageAndTextTableCell().init(); + cell.setTitle$(contact.getName()); + contact.cell = cell; + return cell; + } + }.init()); + + seclist.reloadData(); + + UITableColumn col = new UITableColumn().initWithTitle$identifier$width$("Name", "name", 320.0f); + + UITable table = (UITable) seclist.table(); + table.setSeparatorStyle$(1); + table.addTableColumn$(col); + + UIView view = new UIView().initWithFrame$(inner); + view.addSubview$(navbar); + view.addSubview$(seclist); + + window.setContentView$(view); + + AVController controller = new AVController().init(); + CharSequence wavfile = (CharSequence) ((NSBundle) NSBundle.mainBundle()).pathForResource$ofType$("start", "wav"); + AVItem wavitem = new AVItem().initWithPath$error$(wavfile, null); + wavitem.setVolume$(100); + controller.setCurrentItem$(wavitem); + controller.setCurrentTime$(0); + controller.play$(null); +} + +} diff --git a/data/iphone-java/HelloJava.app/Info.plist b/data/iphone-java/HelloJava.app/Info.plist new file mode 100644 index 000000000..37e19d19e --- /dev/null +++ b/data/iphone-java/HelloJava.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>HelloJava</string> + + <key>CFBundleIdentifier</key> + <string>com.saurik.HelloJava</string> + + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + + <key>CFBundleName</key> + <string>HelloJava</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/HelloJava.app/Java b/data/iphone-java/HelloJava.app/Java new file mode 120000 index 000000000..33b0c18fb --- /dev/null +++ b/data/iphone-java/HelloJava.app/Java @@ -0,0 +1 @@ +/usr/bin/java
\ No newline at end of file diff --git a/data/iphone-java/HelloJava.app/icon.png b/data/iphone-java/HelloJava.app/icon.png Binary files differnew file mode 100644 index 000000000..09b57dc6c --- /dev/null +++ b/data/iphone-java/HelloJava.app/icon.png diff --git a/data/iphone-java/HelloJava.app/start.wav b/data/iphone-java/HelloJava.app/start.wav Binary files differnew file mode 100644 index 000000000..91a65a3f5 --- /dev/null +++ b/data/iphone-java/HelloJava.app/start.wav 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 diff --git a/data/iphone-java/_metadata/description b/data/iphone-java/_metadata/description new file mode 100644 index 000000000..005d9a0c9 --- /dev/null +++ b/data/iphone-java/_metadata/description @@ -0,0 +1,2 @@ +this package isn't described yet +This package, which I'm certain is incredibly interesting, has yet to be described. This is probably because Jay has spent days getting all kinds of bookkeeping issues, like copyright notifications, all in their correct places, and descriptions just aren't the most important thing he could be working on. If this is a problem, please come back later. diff --git a/data/iphone-java/_metadata/javasqlite.dep b/data/iphone-java/_metadata/javasqlite.dep new file mode 120000 index 000000000..eef2c7782 --- /dev/null +++ b/data/iphone-java/_metadata/javasqlite.dep @@ -0,0 +1 @@ +../../javasqlite
\ No newline at end of file diff --git a/data/iphone-java/_metadata/license b/data/iphone-java/_metadata/license new file mode 120000 index 000000000..b9c4e3684 --- /dev/null +++ b/data/iphone-java/_metadata/license @@ -0,0 +1 @@ +../../../licenses/menes
\ No newline at end of file diff --git a/data/iphone-java/_metadata/maintainer b/data/iphone-java/_metadata/maintainer new file mode 120000 index 000000000..0fa66e077 --- /dev/null +++ b/data/iphone-java/_metadata/maintainer @@ -0,0 +1 @@ +../../../people/saurik
\ No newline at end of file diff --git a/data/iphone-java/_metadata/priority b/data/iphone-java/_metadata/priority new file mode 100644 index 000000000..134d9bc32 --- /dev/null +++ b/data/iphone-java/_metadata/priority @@ -0,0 +1 @@ +optional diff --git a/data/iphone-java/_metadata/rhino.dep b/data/iphone-java/_metadata/rhino.dep new file mode 120000 index 000000000..533bec3f1 --- /dev/null +++ b/data/iphone-java/_metadata/rhino.dep @@ -0,0 +1 @@ +../../rhino
\ No newline at end of file diff --git a/data/iphone-java/_metadata/section b/data/iphone-java/_metadata/section new file mode 100644 index 000000000..463a353df --- /dev/null +++ b/data/iphone-java/_metadata/section @@ -0,0 +1 @@ +programming diff --git a/data/iphone-java/_metadata/uicaboodle.dep b/data/iphone-java/_metadata/uicaboodle.dep new file mode 120000 index 000000000..4ebb39b67 --- /dev/null +++ b/data/iphone-java/_metadata/uicaboodle.dep @@ -0,0 +1 @@ +../../uicaboodle
\ No newline at end of file diff --git a/data/iphone-java/_metadata/version b/data/iphone-java/_metadata/version new file mode 100644 index 000000000..6d4f3b8cc --- /dev/null +++ b/data/iphone-java/_metadata/version @@ -0,0 +1 @@ +1.0.2274 diff --git a/data/iphone-java/make.sh b/data/iphone-java/make.sh new file mode 100644 index 000000000..0f55e5d1d --- /dev/null +++ b/data/iphone-java/make.sh @@ -0,0 +1,4 @@ +pkg: mkdir /Applications +javac -source 1.5 -d . -cp "$(PKG_DATA_ jocstrap)/jocstrap.jar:$(PKG_WORK_ javasqlite)/javasqlite-20071108/sqlite.jar" "${PKG_DATA}/HelloJava.app/HelloJava.java" +pkg: cp -a %/Hello{Java,Script}.app /Applications +cp -a *.class "${PKG_DEST}/Applications/HelloJava.app" |