From 7408899004e0c695c08747ef3fcbd5a78a798491 Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Sat, 10 Mar 2012 13:33:22 -0500 Subject: [PATCH] initial playbook port --- app/appinfo.json | 2 +- app/source/Dropbox.js | 10 +++++-- app/source/TodoEdit.js | 2 +- app/source/TodoPrefs.js | 6 +++- app/source/TodoTxt.js | 64 ++++++++++++++++++++++++++++++++++++----- bbww/appindex.html | 24 ++++++++++++++++ bbww/config.xml | 49 +++++++++++++++++++++++++++++++ pkg/packageinfo.json | 2 +- 8 files changed, 146 insertions(+), 13 deletions(-) create mode 100644 bbww/appindex.html create mode 100644 bbww/config.xml diff --git a/app/appinfo.json b/app/appinfo.json index 97e0d55..05faffe 100644 --- a/app/appinfo.json +++ b/app/appinfo.json @@ -1,6 +1,6 @@ { "id": "com.monkeystew.todotxtenyo.beta", - "version": "0.1.0", + "version": "0.2.0", "vendor": "Monkeystew", "type": "web", "main": "index.html", diff --git a/app/source/Dropbox.js b/app/source/Dropbox.js index 48158bd..583c806 100644 --- a/app/source/Dropbox.js +++ b/app/source/Dropbox.js @@ -141,10 +141,16 @@ enyo.kind({ this.requestToken = tokens[1].split("=")[1]; 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", "params": {"target": url} - }); + }); + } } }, diff --git a/app/source/TodoEdit.js b/app/source/TodoEdit.js index dc7b24a..3a25ed6 100644 --- a/app/source/TodoEdit.js +++ b/app/source/TodoEdit.js @@ -24,7 +24,7 @@ enyo.kind({ components: [ {flex: 1, kind: "Scroller", components: [ - {kind: "RichText", name: "tododetail"}, + {kind: "Input", name: "tododetail"}, ]}, {name: "editToolbar", kind: "Toolbar", pack: "justify", className: "enyo-toolbar-light", components: [ diff --git a/app/source/TodoPrefs.js b/app/source/TodoPrefs.js index 8149bde..455686e 100644 --- a/app/source/TodoPrefs.js +++ b/app/source/TodoPrefs.js @@ -137,7 +137,11 @@ enyo.kind({ if (inSender.preferenceProperty == "storage") { if (value == "file") { //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.$.filepath.setValue(mypath); this.$.filepath.render(); diff --git a/app/source/TodoTxt.js b/app/source/TodoTxt.js index 90257c1..45cd30f 100644 --- a/app/source/TodoTxt.js +++ b/app/source/TodoTxt.js @@ -88,7 +88,16 @@ enyo.kind({ ], 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"); if (this.preferences == undefined) { @@ -124,7 +133,14 @@ enyo.kind({ 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.refreshTodo(); @@ -218,7 +234,11 @@ enyo.kind({ }, parseFile: function(path, file) { - var todofile = file.content.split("\n"); + if (file.content != undefined) { + todofile = file.content.split("\n"); + } else { + todofile = ""; + } this.todoList = []; for (line in todofile) { if (todofile[line]) { @@ -242,8 +262,15 @@ enyo.kind({ for (item in list) { data = data + list[item].detail + "\n"; } - this.$.writeFile.call({ - path: path, content: data }); + if (this.os == "BlackBerry") { + 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" && this.preferences["offline"] == false && @@ -285,7 +312,20 @@ enyo.kind({ }, 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) { @@ -297,15 +337,25 @@ enyo.kind({ }, resetPreferences: function() { + localStorage.clear(); this.preferences = new Object(); this.preferences["storage"] = "file"; this.preferences["offline"] = true; - this.preferences["filepath"] = "/media/internal/todo/todo.txt"; 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.$.dboxlogout.hide(); this.$.preferenceView.$.dboxpathselect.hide(); this.$.preferenceView.$.filepathselect.show(); + + // save preferences localStorage.setItem("TodoPreferences", JSON.stringify(this.preferences)); }, diff --git a/bbww/appindex.html b/bbww/appindex.html new file mode 100644 index 0000000..a0322c9 --- /dev/null +++ b/bbww/appindex.html @@ -0,0 +1,24 @@ + + + + Todo.txt Enyo + + + + + + + + diff --git a/bbww/config.xml b/bbww/config.xml new file mode 100644 index 0000000..ab7a118 --- /dev/null +++ b/bbww/config.xml @@ -0,0 +1,49 @@ + + + + + + + Todo.txt Enyo + + Morgan McMillian + + + A mobile application for managing your todo.txt file written using the EnyoJS framework. + + + + + + + + + + + + + + + + + + + + + + + + + + + access_shared + + + diff --git a/pkg/packageinfo.json b/pkg/packageinfo.json index 368be29..8f22813 100644 --- a/pkg/packageinfo.json +++ b/pkg/packageinfo.json @@ -3,7 +3,7 @@ "package_format_version": 2, "loc_name": "Todo.txt Enyo", "icon": "icon.png", - "version": "0.1.0", + "version": "0.2.0", "vendor": "Monkeystew", "app": "com.monkeystew.todotxtenyo.beta", "services": ["com.monkeystew.todotxtenyo.beta.service"]