From c2582930a75aa7564290d7ba6e1a7e5f93e73ffb Mon Sep 17 00:00:00 2001 From: Gubolin Date: Sat, 6 Sep 2014 14:34:29 +0200 Subject: prepare for packaging for android using cordova --- mobile.sh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 mobile.sh (limited to 'mobile.sh') diff --git a/mobile.sh b/mobile.sh new file mode 100644 index 0000000..b794b52 --- /dev/null +++ b/mobile.sh @@ -0,0 +1,9 @@ +#!/bin/bash +cordova create Snap-Mobile edu.berkeley.snap "Snap\!" +cd Snap-Mobile +rm -rf www config.xml +git clone https://github.com/Gubolin/snap.git www +cd www +git checkout mobileapp +cordova platform add android +cordova build android -- cgit v1.3.1 From e010c3ba9a58219ff0fdc92349d70d0feea715f2 Mon Sep 17 00:00:00 2001 From: Gubolin Date: Sat, 6 Sep 2014 15:14:42 +0200 Subject: add notes to dependencies and binaries --- mobile.sh | 7 +++++++ 1 file changed, 7 insertions(+) mode change 100644 => 100755 mobile.sh (limited to 'mobile.sh') diff --git a/mobile.sh b/mobile.sh old mode 100644 new mode 100755 index b794b52..0f660d1 --- a/mobile.sh +++ b/mobile.sh @@ -1,4 +1,11 @@ #!/bin/bash + +# Requirements: +# git, nodejs, android SDK / other platform(s) +# cordova (https://cordova.apache.org/) + +# binaries are in platform/android/ant-build/Snap-debug.apk + cordova create Snap-Mobile edu.berkeley.snap "Snap\!" cd Snap-Mobile rm -rf www config.xml -- cgit v1.3.1 From 5bd357806fb0f3d0a9556dfb718f53bfb6af4fbb Mon Sep 17 00:00:00 2001 From: Gubolin Date: Sat, 6 Sep 2014 15:52:50 +0200 Subject: add vibrate block --- mobile.sh | 1 + objects.js | 7 +++++++ threads.js | 6 ++++++ 3 files changed, 14 insertions(+) (limited to 'mobile.sh') diff --git a/mobile.sh b/mobile.sh index 0f660d1..b1fb9de 100755 --- a/mobile.sh +++ b/mobile.sh @@ -13,4 +13,5 @@ git clone https://github.com/Gubolin/snap.git www cd www git checkout mobileapp cordova platform add android +cordova plugin add org.apache.cordova.vibration cordova build android diff --git a/objects.js b/objects.js index fbb9e84..9dadfb3 100644 --- a/objects.js +++ b/objects.js @@ -878,6 +878,11 @@ SpriteMorph.prototype.initBlocks = function () { category: 'sensing', spec: 'current %dates' }, + doVibrate: { + type: 'command', + category: 'sensing', + spec: 'vibrate %n seconds' + }, // Operators reifyScript: { @@ -4991,6 +4996,8 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push(block('doSetFastTracking')); blocks.push('-'); blocks.push(block('reportDate')); + blocks.push('-'); + blocks.push(block('doVibrate')); // for debugging: /////////////// diff --git a/threads.js b/threads.js index 335b5d0..c796642 100644 --- a/threads.js +++ b/threads.js @@ -2601,6 +2601,12 @@ Process.prototype.reportDate = function (datefn) { return result; }; +Process.prototype.doVibrate = function (seconds) { + if ("vibrate" in navigator) { + window.navigator.vibrate(seconds * 1000); + } +}; + // Process code mapping /* -- cgit v1.3.1 From d5363e2cf35d69215904b1c899e4cafd0f1c632f Mon Sep 17 00:00:00 2001 From: Gubolin Date: Sun, 7 Sep 2014 09:12:00 +0200 Subject: show virtual keyboard in Android (offline app only) (fix #81) --- mobile.sh | 1 + morphic.js | 5 +++++ snap.html | 4 ++++ 3 files changed, 10 insertions(+) (limited to 'mobile.sh') diff --git a/mobile.sh b/mobile.sh index b1fb9de..212f711 100755 --- a/mobile.sh +++ b/mobile.sh @@ -13,5 +13,6 @@ git clone https://github.com/Gubolin/snap.git www cd www git checkout mobileapp cordova platform add android +cordova plugin add org.apache.cordova.plugin.softkeyboard cordova plugin add org.apache.cordova.vibration cordova build android diff --git a/morphic.js b/morphic.js index 2a242f2..efdf139 100644 --- a/morphic.js +++ b/morphic.js @@ -10778,6 +10778,11 @@ WorldMorph.prototype.edit = function (aStringOrTextMorph) { this.virtualKeyboard.style.top = this.cursor.top() + pos.y + "px"; this.virtualKeyboard.style.left = this.cursor.left() + pos.x + "px"; this.virtualKeyboard.focus(); + if (cordova) { + if (cordova.plugins.SoftKeyboard) { // Android only + cordova.plugins.SoftKeyboard.show(); // Issue #81 + } + } } if (MorphicPreferences.useSliderForInput) { diff --git a/snap.html b/snap.html index 904aba8..8e8e919 100755 --- a/snap.html +++ b/snap.html @@ -18,6 +18,10 @@ + + + + ' snap.html + +cordova platform add "$1" cordova plugin add org.apache.cordova.plugin.softkeyboard cordova plugin add org.apache.cordova.vibration cordova plugin add org.apache.cordova.device-motion cordova plugin add org.apache.cordova.device-orientation cordova plugin add org.apache.cordova.geolocation -cordova build android +cordova build "$1" diff --git a/snap.html b/snap.html index 8e8e919..d197b08 100755 --- a/snap.html +++ b/snap.html @@ -19,15 +19,13 @@ - - - ' snap.html + + echo "var code =" > code.js + echo "'$content'" >> code.js + echo ";" >> code.js + sed -i "/ide\.openIn/a\ - ide.droppedText(\'$content\'); " snap.html + ide.droppedText(code); " snap.html fi +# compress all js files find . -name '*.js' | xargs -I {} uglifyjs {} -o {} -c -find . \( \! -name '*.js' \! -name 'snap.html' \! -name 'mobile.sh' \! -name 'desktop.sh' \! -name 'snap_logo_sm.png' \! -name 'config.xml' \! -name 'package.json' -type f \) -print0 | xargs -0 rm +# delete everything that is not html/js/logo/config +find . \( \! -name '*.js' \! -name 'snap.html' \! -name 'snap_logo_sm.png' \! -name 'config.xml' \! -name 'package.json' -type f \) -print0 | xargs -0 rm find . -type d -empty -print0 | xargs -0 rm -r -cd .. +# return to the directory where the script was called from +cd "$scriptdir" + +# run helper scripts for building if [[ $1 == "-m" ]] then - ./mobile.sh "$2" "snap" + ./mobile.sh "$2" "$buildsource" else - ./desktop.sh "$2" "snap" + ./desktop.sh "$2" "$buildsource" fi diff --git a/desktop.sh b/desktop.sh index a572b4f..8b0e21c 100755 --- a/desktop.sh +++ b/desktop.sh @@ -6,20 +6,27 @@ then exit 0 fi +scriptdir=$(readlink -e ".") + # Requirements: # git, zip, nodejs # node-webkit (https://github.com/rogerwang/node-webkit), node-webkit-builder (https://github.com/mllrsohn/node-webkit-builder) -# binaries are in snap/build/Snap! +builddir=$(mktemp -d) if [[ $2 == "" ]] then - git clone https://github.com/Gubolin/snap.git www - cd www/ + git clone https://github.com/Gubolin/snap.git $builddir + cd $builddir/ git checkout mobileapp else - cp -R "$2" www - cd www/ + mv "$2" $builddir + cd $builddir/ fi +# remove mobile config +rm config.xml + nwbuild -p "$1" . + +mv build/* $scriptdir/ diff --git a/mobile.sh b/mobile.sh index 789925a..15b1c9c 100755 --- a/mobile.sh +++ b/mobile.sh @@ -6,19 +6,21 @@ then exit 0 fi +scriptdir=$(readlink -e ".") + # Requirements: # git, nodejs, android SDK / other platform(s) # cordova (https://cordova.apache.org/) -# binaries are in platform/android/ant-build/Snap-debug.apk - if [[ $2 != "" ]] then - copyfrom=$(readlink -e "$2") + buildsource=$(readlink -e "$2") fi -cordova create Snap-Mobile edu.berkeley.snap "Snap\!" -cd Snap-Mobile +builddir=$(mktemp -d) + +cordova create $builddir edu.berkeley.snap "Snap\!" +cd $builddir rm -rf www config.xml if [[ $2 == "" ]] @@ -27,14 +29,18 @@ then cd www/ git checkout mobileapp else - cp -R "$copyfrom/" . - mv "$copyfrom" www + mv "$buildsource" www cd www fi +# remove configs for desktop, it is not needed +rm package.json + +# add mobile-specific library; it's made available at runtime sed -i '/link rel="shortcut icon"/a\ ' snap.html +# add everything needed and build for $device cordova platform add "$1" cordova plugin add org.apache.cordova.plugin.softkeyboard cordova plugin add org.apache.cordova.vibration @@ -42,3 +48,7 @@ cordova plugin add org.apache.cordova.device-motion cordova plugin add org.apache.cordova.device-orientation cordova plugin add org.apache.cordova.geolocation cordova build "$1" + +cd $builddir +# TODO other platforms +find -name '*.apk' | xargs -I {} mv {} $scriptdir -- cgit v1.3.1 From 8433b79d9363dea79e139cbdc3a9811495694753 Mon Sep 17 00:00:00 2001 From: Gubolin Date: Mon, 8 Sep 2014 11:44:59 +0200 Subject: use the Snap-icon instead of the default one --- binary.sh | 2 ++ mobile.sh | 8 ++++++++ 2 files changed, 10 insertions(+) (limited to 'mobile.sh') diff --git a/binary.sh b/binary.sh index 489e6ed..6f267d0 100755 --- a/binary.sh +++ b/binary.sh @@ -67,6 +67,8 @@ then sed -i "/ide\.openIn/a\ ide.droppedText(code); " snap.html +else + rm binary.js fi # compress all js files diff --git a/mobile.sh b/mobile.sh index 15b1c9c..81fa6f3 100755 --- a/mobile.sh +++ b/mobile.sh @@ -47,6 +47,14 @@ cordova plugin add org.apache.cordova.vibration cordova plugin add org.apache.cordova.device-motion cordova plugin add org.apache.cordova.device-orientation cordova plugin add org.apache.cordova.geolocation + +if [[ $1 == "android" ]] +then + # Remove default icons + cd "$builddir/platforms/android" + find -name '*.png' | xargs rm +fi + cordova build "$1" cd $builddir -- cgit v1.3.1 From a7b3c537edf83b8415716f930fd3fe518638c4db Mon Sep 17 00:00:00 2001 From: Gubolin Date: Mon, 8 Sep 2014 12:27:01 +0200 Subject: add notification blocks --- mobile.sh | 1 + objects.js | 9 +++++++++ threads.js | 14 ++++++++++++++ 3 files changed, 24 insertions(+) (limited to 'mobile.sh') diff --git a/mobile.sh b/mobile.sh index 81fa6f3..909f7e5 100755 --- a/mobile.sh +++ b/mobile.sh @@ -47,6 +47,7 @@ cordova plugin add org.apache.cordova.vibration cordova plugin add org.apache.cordova.device-motion cordova plugin add org.apache.cordova.device-orientation cordova plugin add org.apache.cordova.geolocation +cordova plugin add de.appplant.cordova.plugin.local-notification if [[ $1 == "android" ]] then diff --git a/objects.js b/objects.js index 49fafb5..100bd67 100644 --- a/objects.js +++ b/objects.js @@ -415,6 +415,11 @@ SpriteMorph.prototype.initBlocks = function () { spec: 'go back %n layers', defaults: [1] }, + doNotify: { + type: 'command', + category: 'looks', + spec: 'notification with title %s and content %s' + }, doScreenshot: { type: 'command', category: 'looks', @@ -1762,6 +1767,8 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('comeToFront')); blocks.push(block('goBack')); + blocks.push('-'); + blocks.push(block('doNotify')); // for debugging: /////////////// @@ -4905,6 +4912,8 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('show')); blocks.push(block('hide')); + blocks.push('-'); + blocks.push(block('doNotify')); // for debugging: /////////////// diff --git a/threads.js b/threads.js index 3e50686..7616b88 100644 --- a/threads.js +++ b/threads.js @@ -2189,6 +2189,20 @@ Process.prototype.reportTextSplit = function (string, delimiter) { return new List(str.split(del)); }; +// Process notification operations + +Process.prototype.doNotify = function (title, content) { + // TODO webkitNotification + if (window.plugin) { + if (window.plugin.notification) { + window.plugin.notification.local.add({ + message: content, + title: title + }); + } + } +}; + // Process debugging Process.prototype.alert = function (data) { -- cgit v1.3.1 From 478f3d4c387d67cb54a02ba373bfb4655d7a19f7 Mon Sep 17 00:00:00 2001 From: Gubolin Date: Tue, 9 Sep 2014 11:51:31 +0200 Subject: add file blocks --- blocks.js | 12 ++++ mobile.sh | 1 + objects.js | 44 +++++++++++++++ threads.js | 183 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 240 insertions(+) (limited to 'mobile.sh') diff --git a/blocks.js b/blocks.js index 735d36b..9aec7f4 100644 --- a/blocks.js +++ b/blocks.js @@ -844,6 +844,18 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { ); part.setContents(['date']); break; + case '%fileOrDir': + part = new InputSlotMorph( + null, // text + false, // non-numeric + { + 'file': ['file'], + 'directory': ['directory'] + }, + true // read-only + ); + part.setContents(['file']); + break; case '%locations': part = new InputSlotMorph( null, // text diff --git a/mobile.sh b/mobile.sh index 909f7e5..b0bcc5d 100755 --- a/mobile.sh +++ b/mobile.sh @@ -48,6 +48,7 @@ cordova plugin add org.apache.cordova.device-motion cordova plugin add org.apache.cordova.device-orientation cordova plugin add org.apache.cordova.geolocation cordova plugin add de.appplant.cordova.plugin.local-notification +cordova plugin add org.apache.cordova.file if [[ $1 == "android" ]] then diff --git a/objects.js b/objects.js index 100bd67..d432dcb 100644 --- a/objects.js +++ b/objects.js @@ -883,6 +883,36 @@ SpriteMorph.prototype.initBlocks = function () { category: 'sensing', spec: 'current %dates' }, + reportFileOrDirectoryContent: { + type: 'reporter', + category: 'sensing', + spec: 'content of the %fileOrDir %s' + }, + doSetFileContent: { + type: 'command', + category: 'sensing', + spec: 'write %s to the file %s' + }, + doCreateFileOrDirectory: { + type: 'command', + category: 'sensing', + spec: 'create %fileOrDir %s' + }, + reportFileOrDirectoryExists: { + type: 'predicate', + category: 'sensing', + spec: '%fileOrDir %s exists' + }, + doDeleteFileOrDirectory: { + type: 'command', + category: 'sensing', + spec: 'delete the %fileOrDir %s' + }, + reportHomeDirectory: { + type: 'reporter', + category: 'sensing', + spec: 'home directory' + }, doVibrate: { type: 'command', category: 'sensing', @@ -1927,6 +1957,13 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('reportDate')); blocks.push('-'); + blocks.push(block('reportFileOrDirectoryContent')); + blocks.push(block('doSetFileContent')); + blocks.push(block('doCreateFileOrDirectory')); + blocks.push(block('reportFileOrDirectoryExists')); + blocks.push(block('doDeleteFileOrDirectory')); + blocks.push(block('reportHomeDirectory')); + blocks.push('-'); blocks.push(block('reportLanguage')); blocks.push(block('reportLocation')); blocks.push('-'); @@ -5049,6 +5086,13 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('reportDate')); blocks.push('-'); + blocks.push(block('reportFileOrDirectoryContent')); + blocks.push(block('doSetFileContent')); + blocks.push(block('doCreateFileOrDirectory')); + blocks.push(block('reportFileOrDirectoryExists')); + blocks.push(block('doDeleteFileOrDirectory')); + blocks.push(block('reportHomeDirectory')); + blocks.push('-'); blocks.push(block('reportLanguage')); blocks.push(block('reportLocation')); blocks.push('-'); diff --git a/threads.js b/threads.js index 7616b88..37db5cd 100644 --- a/threads.js +++ b/threads.js @@ -2687,6 +2687,189 @@ Process.prototype.reportDate = function (datefn) { return result; }; +// Process File access +Process.prototype.reportFileOrDirectoryContent = function (typeInput, filepath) { + var myself = this; + var type = myself.inputOption(typeInput); + + if (myself.context.result == null) { + myself.context.result = 'wait'; + + if (window.resolveLocalFileSystemURL) { + window.resolveLocalFileSystemURL(filepath, + function (entry) { + if (type === 'file') { + entry.file( + function (file) { + var reader = new FileReader(); + + reader.onloadend = function (e) { + myself.context.result = this.result; + }; + + reader.readAsText(file); + }, + function (error) { + myself.context.result = error.toString(); + } + ); + } else { + var dirReader = entry.createReader(); + dirReader.readEntries( + function (results) { + var items = []; + results.forEach( + function (item) { + items.push(item.name); + } + ); + myself.context.result = new List(items); + }, + function (error) { + myself.context.result = error.toString(); + } + ); + } + }, + function (error) { + myself.context.result = error.toString(); + } + ); + } + } else { + if (myself.context.result !== 'wait') { + return myself.context.result; + } + } + + this.pushContext('doYield'); + this.pushContext(); +}; + +Process.prototype.doSetFileContent = function (content, filepath) { + var dirpath = filepath.substring(0, + filepath.lastIndexOf('/')); + var filename = filepath.substring( + filepath.lastIndexOf('/') + 1); + + if (window.resolveLocalFileSystemURL) { + window.resolveLocalFileSystemURL(dirpath, + function (dirEntry) { + dirEntry.getFile(filename, + {create: true, exclusive: false}, + function (fileEntry) { + fileEntry.createWriter( + function (fileWriter) { + var blob; + + try { + blob = new Blob([content], + {type: 'text/plain'}); + // No `new Blob` for Android + } catch (e) { + window.BlobBuilder = + window.BlobBuilder || + window.WebKitBlobBuilder || + window.MozBlobBuilder || + window.MSBlobBuilder; + + if (e.name == 'TypeError' + && window.BlobBuilder) { + var bb = new BlobBuilder(); + bb.append(content); + blob = bb.getBlob('text/plain'); + } + } + + fileWriter.write(blob); + } + ); + } + ); + } + ); + } +}; + +Process.prototype.createFileOrDirectory = function (typeInput, filepath) { + var myself = this; + var type = myself.inputOption(typeInput); + + function createDir(rootDirEntry, folders) { + rootDirEntry.getDirectory(folders[0], {create: true}, + function (dirEntry) { + if (folders.length === 1) { + if (type === 'file') { + dirEntry.getFile(folders.slice(1), + {create: true, exclusive: false}); + return; + } + } + + if (folders.length) { + createDir(dirEntry, folders.slice(1)); + } + } + ); + }; + + window.requestFileSystem(window.PERSISTENT, 0, + function (fileSystem) { + createDir(fileSystem.root, path.split('/')); + } + ); +}; + +Process.prototype.reportFileOrDirectoryExists = function (typeInput, filepath) { + var myself = this; + var type = myself.inputOption(typeInput); + + if (myself.context.result == null) { + myself.context.result = 'wait'; + + if (window.resolveLocalFileSystemURL) { + window.resolveLocalFileSystemURL(filepath, + function (entry) { + if (type === 'file') { + myself.context.result = !entry.isDirectory; + } else { + myself.context.result = entry.isDirectory; + } + }, + function (error) { + myself.context.result = false; + } + ); + } + } else { + if (myself.context.result !== 'wait') { + return myself.context.result; + } + } + + this.pushContext('doYield'); + this.pushContext(); +}; + +Process.prototype.doDeleteFileOrDirectory = function (typeInput, filepath) { + if (window.resolveLocalFileSystemURL) { + window.resolveLocalFileSystemURL(filepath, + function (entry) { + entry.remove(); + } + ); + } +}; + +Process.prototype.reportHomeDirectory = function () { + if (cordova) { + if (cordova.file) { + return cordova.file.dataDirectory; + } + } + return ''; +}; + Process.prototype.getCompassHeading = function (dest) { var stage = this.homeContext.receiver.parentThatIsA(StageMorph); -- cgit v1.3.1 From 45033e2101a5d5d0929dd28205f3177059ad865d Mon Sep 17 00:00:00 2001 From: Gubolin Date: Sat, 3 Jan 2015 10:59:47 +0100 Subject: allow setting the Snap! source in a variable --- binary.sh | 7 ++++++- desktop.sh | 7 ++++++- mobile.sh | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) (limited to 'mobile.sh') diff --git a/binary.sh b/binary.sh index 6f267d0..c1a481e 100755 --- a/binary.sh +++ b/binary.sh @@ -1,5 +1,10 @@ #!/bin/bash +if [[ "$snapsource" == "" ]] +then + export snapsource="https://github.com/Gubolin/snap.git" +fi + if [[ $# < 2 ]] then echo "Usage: binary.sh OPTION PLATFORM [FILE]" @@ -42,7 +47,7 @@ then fi buildsource=$(mktemp -d) -git clone "https://github.com/Gubolin/snap.git" $buildsource +git clone $snapsource $buildsource cd "$buildsource" git checkout mobileapp diff --git a/desktop.sh b/desktop.sh index 8b0e21c..53ec24b 100755 --- a/desktop.sh +++ b/desktop.sh @@ -1,5 +1,10 @@ #!/bin/bash +if [[ "$snapsource" == "" ]] +then + export snapsource="https://github.com/Gubolin/snap.git" +fi + if [[ $1 = "" ]] then echo "Usage: desktop.sh PLATFORM [BUILDSOURCE]" @@ -16,7 +21,7 @@ builddir=$(mktemp -d) if [[ $2 == "" ]] then - git clone https://github.com/Gubolin/snap.git $builddir + git clone "$snapsource" $builddir cd $builddir/ git checkout mobileapp else diff --git a/mobile.sh b/mobile.sh index b0bcc5d..59e5da8 100755 --- a/mobile.sh +++ b/mobile.sh @@ -1,5 +1,10 @@ #!/bin/bash +if [[ "$snapsource" == "" ]] +then + export snapsource="https://github.com/Gubolin/snap.git" +fi + if [[ $1 = "" ]] then echo "Usage: mobile.sh PLATFORM [BUILDSOURCE]" @@ -25,7 +30,7 @@ rm -rf www config.xml if [[ $2 == "" ]] then - git clone https://github.com/Gubolin/snap.git www + git clone "$snapsource" www cd www/ git checkout mobileapp else -- cgit v1.3.1 From 618e034eb86b3ad7e7f4955b900862a27a0ce44c Mon Sep 17 00:00:00 2001 From: Gubolin Date: Sat, 3 Jan 2015 11:23:07 +0100 Subject: remove file blocks --- blocks.js | 12 ---- mobile.sh | 1 - objects.js | 44 ------------- threads.js | 215 ------------------------------------------------------------- 4 files changed, 272 deletions(-) (limited to 'mobile.sh') diff --git a/blocks.js b/blocks.js index 9aec7f4..735d36b 100644 --- a/blocks.js +++ b/blocks.js @@ -844,18 +844,6 @@ SyntaxElementMorph.prototype.labelPart = function (spec) { ); part.setContents(['date']); break; - case '%fileOrDir': - part = new InputSlotMorph( - null, // text - false, // non-numeric - { - 'file': ['file'], - 'directory': ['directory'] - }, - true // read-only - ); - part.setContents(['file']); - break; case '%locations': part = new InputSlotMorph( null, // text diff --git a/mobile.sh b/mobile.sh index 59e5da8..4b5dc48 100755 --- a/mobile.sh +++ b/mobile.sh @@ -53,7 +53,6 @@ cordova plugin add org.apache.cordova.device-motion cordova plugin add org.apache.cordova.device-orientation cordova plugin add org.apache.cordova.geolocation cordova plugin add de.appplant.cordova.plugin.local-notification -cordova plugin add org.apache.cordova.file if [[ $1 == "android" ]] then diff --git a/objects.js b/objects.js index cf7a191..d1a07ab 100644 --- a/objects.js +++ b/objects.js @@ -910,36 +910,6 @@ SpriteMorph.prototype.initBlocks = function () { category: 'sensing', spec: 'current %dates' }, - reportFileOrDirectoryContent: { - type: 'reporter', - category: 'sensing', - spec: 'content of the %fileOrDir %s' - }, - doSetFileContent: { - type: 'command', - category: 'sensing', - spec: 'write %s to the file %s' - }, - doCreateFileOrDirectory: { - type: 'command', - category: 'sensing', - spec: 'create %fileOrDir %s' - }, - reportFileOrDirectoryExists: { - type: 'predicate', - category: 'sensing', - spec: '%fileOrDir %s exists' - }, - doDeleteFileOrDirectory: { - type: 'command', - category: 'sensing', - spec: 'delete the %fileOrDir %s' - }, - reportHomeDirectory: { - type: 'reporter', - category: 'sensing', - spec: 'home directory' - }, doVibrate: { type: 'command', category: 'sensing', @@ -1988,13 +1958,6 @@ SpriteMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('reportDate')); blocks.push('-'); - blocks.push(block('reportFileOrDirectoryContent')); - blocks.push(block('doSetFileContent')); - blocks.push(block('doCreateFileOrDirectory')); - blocks.push(block('reportFileOrDirectoryExists')); - blocks.push(block('doDeleteFileOrDirectory')); - blocks.push(block('reportHomeDirectory')); - blocks.push('-'); blocks.push(block('reportLanguage')); blocks.push(block('reportLocation')); blocks.push('-'); @@ -5125,13 +5088,6 @@ StageMorph.prototype.blockTemplates = function (category) { blocks.push('-'); blocks.push(block('reportDate')); blocks.push('-'); - blocks.push(block('reportFileOrDirectoryContent')); - blocks.push(block('doSetFileContent')); - blocks.push(block('doCreateFileOrDirectory')); - blocks.push(block('reportFileOrDirectoryExists')); - blocks.push(block('doDeleteFileOrDirectory')); - blocks.push(block('reportHomeDirectory')); - blocks.push('-'); blocks.push(block('reportLanguage')); blocks.push(block('reportLocation')); blocks.push('-'); diff --git a/threads.js b/threads.js index 8fbd587..5d6020e 100644 --- a/threads.js +++ b/threads.js @@ -2716,221 +2716,6 @@ Process.prototype.reportDate = function (datefn) { return result; }; -// Process File access -// http://www.html5rocks.com/en/tutorials/file/filesystem/ -Process.prototype.fileErrorHandler = function (e) { - var msg = ''; - - switch (e.code) { - case FileError.QUOTA_EXCEEDED_ERR: - msg = localize('no space left'); - break; - case FileError.NOT_FOUND_ERR: - msg = localize('not found'); - break; - case FileError.SECURITY_ERR: - msg = localize('access denied'); - break; - case FileError.INVALID_MODIFICATION_ERR: - msg = 'INVALID_MODIFICATION_ERR'; - break; - case FileError.INVALID_STATE_ERR: - msg = 'INVALID_STATE_ERR'; - break; - default: - msg = localize('unknown error'); - break; - } - - this.handleError(msg); -}; - -Process.prototype.reportFileOrDirectoryContent = function (typeInput, filepath) { - var myself = this; - var type = myself.inputOption(typeInput); - - if (myself.context.result === null) { - myself.context.result = false; - - if (window.resolveLocalFileSystemURL) { - window.resolveLocalFileSystemURL(filepath, - function (entry) { - if (type === 'file') { - entry.file( - function (file) { - var reader = new FileReader(); - - reader.onloadend = function (e) { - myself.context.result = this.result; - }; - - reader.readAsText(file); - }, - myself.fileErrorHandler - ); - } else { - var dirReader = entry.createReader(); - dirReader.readEntries( - function (results) { - var items = []; - results.forEach( - function (item) { - items.push(item.name); - } - ); - myself.context.result = new List(items); - }, - myself.fileErrorHandler - ); - } - }, - myself.fileErrorHandler - ); - } - } else { - if (myself.context.result !== false) { - return myself.context.result; - } - } - - this.pushContext('doYield'); - this.pushContext(); -}; - -Process.prototype.doSetFileContent = function (content, filepath) { - var dirpath = filepath.substring(0, - filepath.lastIndexOf('/')); - var filename = filepath.substring( - filepath.lastIndexOf('/') + 1); - - if (window.resolveLocalFileSystemURL) { - window.resolveLocalFileSystemURL(dirpath, - function (dirEntry) { - dirEntry.getFile(filename, - {create: true, exclusive: false}, - function (fileEntry) { - fileEntry.createWriter( - function (fileWriter) { - var blob; - - try { - blob = new Blob([content], - {type: 'text/plain'}); - // No `new Blob` for Android - } catch (e) { - window.BlobBuilder = - window.BlobBuilder || - window.WebKitBlobBuilder || - window.MozBlobBuilder || - window.MSBlobBuilder; - - if (e.name == 'TypeError' - && window.BlobBuilder) { - var bb = new BlobBuilder(); - bb.append(content); - blob = bb.getBlob('text/plain'); - } - } - - fileWriter.write(blob); - }, - myself.fileErrorHandler - ); - }, - myself.fileErrorHandler - ); - }, - myself.fileErrorHandler - ); - } -}; - -Process.prototype.createFileOrDirectory = function (typeInput, filepath) { - var myself = this; - var type = myself.inputOption(typeInput); - - function createDir(rootDirEntry, folders) { - rootDirEntry.getDirectory(folders[0], {create: true}, - function (dirEntry) { - if (folders.length === 1) { - if (type === 'file') { - dirEntry.getFile(folders.slice(1), - {create: true, exclusive: false}, - function (fileEntry) { - return; - }, - myself.fileErrorHandler - ); - - return; - } - } - - if (folders.length) { - createDir(dirEntry, folders.slice(1)); - } - }, - myself.fileErrorHandler - ); - } - - window.requestFileSystem(window.PERSISTENT, 0, - function (fileSystem) { - createDir(fileSystem.root, path.split('/')); - }, - myself.fileErrorHandler - ); -}; - -Process.prototype.reportFileOrDirectoryExists = function (typeInput, filepath) { - var myself = this; - var type = myself.inputOption(typeInput); - - if (myself.context.result === null) { - myself.context.result = 'wait'; - - if (window.resolveLocalFileSystemURL) { - window.resolveLocalFileSystemURL(filepath, - function (entry) { - if (type === 'file') { - myself.context.result = !entry.isDirectory; - } else { - myself.context.result = entry.isDirectory; - } - }, - myself.fileErrorHandler - ); - } - } else { - if (myself.context.result !== 'wait') { - return myself.context.result; - } - } - - this.pushContext('doYield'); - this.pushContext(); -}; - -Process.prototype.doDeleteFileOrDirectory = function (typeInput, filepath) { - if (window.resolveLocalFileSystemURL) { - window.resolveLocalFileSystemURL(filepath, - function (entry) { - entry.remove(); - }, - myself.fileErrorHandler - ); - } -}; - -Process.prototype.reportHomeDirectory = function () { - if (cordova) { - if (cordova.file) { - return cordova.file.dataDirectory; - } - } - return ''; -}; - Process.prototype.getCompassHeading = function () { var stage = this.homeContext.receiver.parentThatIsA(StageMorph); -- cgit v1.3.1 From 3c03814833a272b305cbac5ad7f70190ec2a8926 Mon Sep 17 00:00:00 2001 From: Gubolin Date: Sat, 10 Jan 2015 11:28:48 +0100 Subject: don't delete files from helpers --- desktop.sh | 3 --- mobile.sh | 3 --- 2 files changed, 6 deletions(-) (limited to 'mobile.sh') diff --git a/desktop.sh b/desktop.sh index 53ec24b..72b0786 100755 --- a/desktop.sh +++ b/desktop.sh @@ -29,9 +29,6 @@ else cd $builddir/ fi -# remove mobile config -rm config.xml - nwbuild -p "$1" . mv build/* $scriptdir/ diff --git a/mobile.sh b/mobile.sh index 4b5dc48..6ec8a0e 100755 --- a/mobile.sh +++ b/mobile.sh @@ -38,9 +38,6 @@ else cd www fi -# remove configs for desktop, it is not needed -rm package.json - # add mobile-specific library; it's made available at runtime sed -i '/link rel="shortcut icon"/a\ ' snap.html -- cgit v1.3.1