initial playbook port

This commit is contained in:
Morgan McMillian 2012-03-10 13:33:22 -05:00
parent 47c6f6f7b6
commit 7408899004
8 changed files with 146 additions and 13 deletions

View file

@ -1,6 +1,6 @@
{ {
"id": "com.monkeystew.todotxtenyo.beta", "id": "com.monkeystew.todotxtenyo.beta",
"version": "0.1.0", "version": "0.2.0",
"vendor": "Monkeystew", "vendor": "Monkeystew",
"type": "web", "type": "web",
"main": "index.html", "main": "index.html",

View file

@ -141,10 +141,16 @@ enyo.kind({
this.requestToken = tokens[1].split("=")[1]; this.requestToken = tokens[1].split("=")[1];
console.log("...launching browser window..."); console.log("...launching browser window...");
this.$.launch.call({ if (this.owner.os == "BlackBerry") {
var args = new blackberry.invoke.BrowserArguments(url);
blackberry.invoke.invoke(
blackberry.invoke.APP_BROWSER, args);
} else {
this.$.launch.call({
"id": "com.palm.app.browser", "id": "com.palm.app.browser",
"params": {"target": url} "params": {"target": url}
}); });
}
} }
}, },

View file

@ -24,7 +24,7 @@ enyo.kind({
components: [ components: [
{flex: 1, kind: "Scroller", components: [ {flex: 1, kind: "Scroller", components: [
{kind: "RichText", name: "tododetail"}, {kind: "Input", name: "tododetail"},
]}, ]},
{name: "editToolbar", kind: "Toolbar", pack: "justify", className: "enyo-toolbar-light", {name: "editToolbar", kind: "Toolbar", pack: "justify", className: "enyo-toolbar-light",
components: [ components: [

View file

@ -137,7 +137,11 @@ enyo.kind({
if (inSender.preferenceProperty == "storage") { if (inSender.preferenceProperty == "storage") {
if (value == "file") { if (value == "file") {
//this.$.todoFilePicker.pickFile(); //this.$.todoFilePicker.pickFile();
var mypath = "/media/internal/todo/todo.txt" if (this.owner.os == "BlackBerry") {
var mypath = this.owner.dirs.shared.documents.path + "/todo/todo.txt";
} else {
var mypath = "/media/internal/todo/todo.txt"
}
this.owner.preferences["filepath"] = mypath; this.owner.preferences["filepath"] = mypath;
this.$.filepath.setValue(mypath); this.$.filepath.setValue(mypath);
this.$.filepath.render(); this.$.filepath.render();

View file

@ -88,7 +88,16 @@ enyo.kind({
], ],
ready: function() { ready: function() {
this.$.getConn.call();
if (window.PalmSystem) {
this.$.getConn.call();
this.os = "webOS";
} else if (window.blackberry) {
this.os = "BlackBerry";
this.dirs = blackberry.io.dir.appDirs;
} else {
this.os = "unknown";
}
this.preferences = localStorage.getItem("TodoPreferences"); this.preferences = localStorage.getItem("TodoPreferences");
if (this.preferences == undefined) { if (this.preferences == undefined) {
@ -124,7 +133,14 @@ enyo.kind({
this.$.viewTitle.setContent("[offline]"); this.$.viewTitle.setContent("[offline]");
} }
this.$.makeDir.call({ path: "/media/internal/todo" }); if (this.os == "BlackBerry") {
var path = this.dirs.shared.documents.path + "/todo";
if (!blackberry.io.dir.exists(path)) {
blackberry.io.dir.createNewDir(path);
}
} else {
this.$.makeDir.call({ path: "/media/internal/todo" });
}
this.todoList = []; this.todoList = [];
this.refreshTodo(); this.refreshTodo();
@ -218,7 +234,11 @@ enyo.kind({
}, },
parseFile: function(path, file) { parseFile: function(path, file) {
var todofile = file.content.split("\n"); if (file.content != undefined) {
todofile = file.content.split("\n");
} else {
todofile = "";
}
this.todoList = []; this.todoList = [];
for (line in todofile) { for (line in todofile) {
if (todofile[line]) { if (todofile[line]) {
@ -242,8 +262,15 @@ enyo.kind({
for (item in list) { for (item in list) {
data = data + list[item].detail + "\n"; data = data + list[item].detail + "\n";
} }
this.$.writeFile.call({ if (this.os == "BlackBerry") {
path: path, content: data }); if (blackberry.io.file.exists(path)) {
blackberry.io.file.deleteFile(path);
}
blackberry.io.file.saveFile(path,
blackberry.utils.stringToBlob(data));
} else {
this.$.writeFile.call({ path: path, content: data });
}
if (this.preferences["storage"] == "dropbox" && if (this.preferences["storage"] == "dropbox" &&
this.preferences["offline"] == false && this.preferences["offline"] == false &&
@ -285,7 +312,20 @@ enyo.kind({
}, },
getLocalFile: function() { getLocalFile: function() {
this.$.readFile.call({ path: this.preferences["filepath"] }); var path = this.preferences["filepath"];
if (this.os == "BlackBerry") {
if (blackberry.io.file.exists(path)) {
blackberry.io.file.readFile(path,
function(fpath, blob) {
var data = blackberry.utils.blobToString(blob);
appInstance.parseFile(null, {content: data});
}
);
}
} else {
this.$.readFile.call({ path: path });
//this.$.readFile.call({ path: this.preferences["filepath"] });
}
}, },
loadDropbox: function(inSender, inResponse, inRequest) { loadDropbox: function(inSender, inResponse, inRequest) {
@ -297,15 +337,25 @@ enyo.kind({
}, },
resetPreferences: function() { resetPreferences: function() {
localStorage.clear();
this.preferences = new Object(); this.preferences = new Object();
this.preferences["storage"] = "file"; this.preferences["storage"] = "file";
this.preferences["offline"] = true; this.preferences["offline"] = true;
this.preferences["filepath"] = "/media/internal/todo/todo.txt";
this.preferences["dboxpath"] = "/todo"; this.preferences["dboxpath"] = "/todo";
if (this.os == "BlackBerry") {
var path = this.dirs.shared.documents.path + "/todo/todo.txt";
this.preferences["filepath"] = path;
} else {
this.preferences["filepath"] = "/media/internal/todo/todo.txt";
}
// reset the preferences pane
this.$.preferenceView.$.offline.setChecked(true); this.$.preferenceView.$.offline.setChecked(true);
this.$.preferenceView.$.dboxlogout.hide(); this.$.preferenceView.$.dboxlogout.hide();
this.$.preferenceView.$.dboxpathselect.hide(); this.$.preferenceView.$.dboxpathselect.hide();
this.$.preferenceView.$.filepathselect.show(); this.$.preferenceView.$.filepathselect.show();
// save preferences
localStorage.setItem("TodoPreferences", JSON.stringify(this.preferences)); localStorage.setItem("TodoPreferences", JSON.stringify(this.preferences));
}, },

24
bbww/appindex.html Normal file
View file

@ -0,0 +1,24 @@
<!doctype html>
<html>
<head>
<title>Todo.txt Enyo</title>
<meta name="viewport" content="height=device-height,width=device-width">
<script src="enyo-1.0-r1/framework/enyo.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
var appInstance = enyo.create({kind: "TodoTxt"});
if (window.PalmSystem && enyo.windowParams) {
appInstance.setLaunchParams(enyo.windowParams);
}
appInstance.renderInto(document.body);
</script>
<div id="history" style="display: none">
<div class="version">0.1.0</div>
<ul>
<li>Initial open source and beta release.</li>
</ul>
</div>
</body>
</html>

49
bbww/config.xml Normal file
View file

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Widget Configuration Reference:
http://docs.blackberry.com/en/developers/deliverables/15274/
-->
<widget xmlns="http://www.w3.org/ns/widgets"
xmlns:rim="http://www.blackberry.com/ns/widgets"
version="0.1.0">
<name>Todo.txt Enyo</name>
<author href="http://monkeystew.org" rim:copyright="Copyright 2012 Morgan McMillian">Morgan McMillian</author>
<description>
A mobile application for managing your todo.txt file written using the EnyoJS framework.
</description>
<license href="http://www.apache.org/licenses/LICENSE-2.0">
</license>
<feature id="blackberry.io.dir" required="true" version="1.0.0.0" />
<feature id="blackberry.io.file" required="true" version="1.0.0.0" />
<feature id="blackberry.utils" required="true" version="1.0.0.0" />
<feature id="blackberry.invoke" required="true" version="1.0.0.0" />
<!-- PhoneGap API -->
<access subdomains="true" uri="file:///store/home" />
<access subdomains="true" uri="file:///SDCard" />
<!-- Expose access to all URIs, including the file and http protocols -->
<access subdomains="true" uri="*" />
<icon src="icon.png" />
<rim:loadingScreen backgroundColor="#000000"
foregroundImage="icon.png"
onFirstLaunch="true">
<rim:transitionEffect type="fadeOut" />
</rim:loadingScreen>
<content src="index.html" />
<rim:permissions>
<rim:permit>access_shared</rim:permit>
</rim:permissions>
</widget>

View file

@ -3,7 +3,7 @@
"package_format_version": 2, "package_format_version": 2,
"loc_name": "Todo.txt Enyo", "loc_name": "Todo.txt Enyo",
"icon": "icon.png", "icon": "icon.png",
"version": "0.1.0", "version": "0.2.0",
"vendor": "Monkeystew", "vendor": "Monkeystew",
"app": "com.monkeystew.todotxtenyo.beta", "app": "com.monkeystew.todotxtenyo.beta",
"services": ["com.monkeystew.todotxtenyo.beta.service"] "services": ["com.monkeystew.todotxtenyo.beta.service"]