diff --git a/Android/config.xml b/Android/config.xml deleted file mode 100644 index a2e9fde..0000000 --- a/Android/config.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - Sketchy - - Free full-featured Sketch app - - - Mahdi Dibaiee - - - - - - - - - - - - - - diff --git a/Android/index.html b/Android/index.html index abc9887..31a15dd 100644 --- a/Android/index.html +++ b/Android/index.html @@ -5,8 +5,9 @@ Sketchy + - +
diff --git a/Android/js/diff.js b/Android/js/diff.js index 9cc8a69..da656fe 100644 --- a/Android/js/diff.js +++ b/Android/js/diff.js @@ -1,123 +1,136 @@ $(document).ready(function() { - $('*').off('click mousemove mousedown mouseup mouseleave').on('click mousemove mousedown mouseup mouseleave', function(e) { - e.preventDefault; + $(document).on('resume', function() { + sizeAndPos(); }) + document.addEventListener('deviceready', function() { + sizeAndPos(); - /*$('a[href^="http"]').tap(function(e) { - e.preventDefault(); - var href = $(this).attr('href'); - var view = new MozActivity({ - name: 'view', - data: { - type: 'url', - url: href - } + $('*').off('click mousemove mousedown mouseup mouseleave').on('click mousemove mousedown mouseup mouseleave', function(e) { + e.preventDefault; }) - return false; - }).click(function(e) { - e.preventDefault(); - return false; - })*/ - /*$('a[href^="mailto"]').tap(function(e) { - e.preventDefault(); - var mail = new MozActivity({ - name: 'new', - data: { - type: 'mail', - url: $(this).attr('href') - } - }) - return false; - }).click(function(e) { - e.preventDefault(); - return false; - })*/ + /*$('a[href^="http"]').tap(function(e) { + e.preventDefault(); + var href = $(this).attr('href'); + var view = new MozActivity({ + name: 'view', + data: { + type: 'url', + url: href + } + }) - window.save = function() { - var f = c.getImageData(0, 0, width(), height()); - switch(save.background) { - case 'white': { - c.fillStyle = 'white'; - c.globalCompositeOperation = 'destination-over'; - c.fillRect(0, 0, width(), height()); - c.fillStyle = settings.color; - c.globalCompositeOperation = settings.composite; - break; - } - case 'current color': { - c.fillStyle = settings.bg; - c.globalCompositeOperation = 'destination-over'; - c.fillRect(0, 0, width(), height()); - c.globalCompositeOperation = settings.composite; - break; - } - } - var data = $c[0].toDataURL(); - if( save.type == 'sketchy project' ) { - var list = JSON.parse(localStorage.getItem('projects')); - var index; - if( list && list.some(function(a, i) { if( a.name == save['file name'] ) {index = i; return true} return false }) ) { - if( confirm('A sketch with this name already exists. Do you want to overwrite ' + save['file name'] + '?') ) { - console.log(index); - list[index] = { - name: save['file name'], - data: data, - points: window.points, - settings: settings - } - localStorage.setItem('projects', JSON.stringify(list)); + return false; + }).click(function(e) { + e.preventDefault(); + return false; + })*/ + + /*$('a[href^="mailto"]').tap(function(e) { + e.preventDefault(); + var mail = new MozActivity({ + name: 'new', + data: { + type: 'mail', + url: $(this).attr('href') + } + }) + return false; + }).click(function(e) { + e.preventDefault(); + return false; + })*/ + + + + window.save = function() { + var f = c.getImageData(0, 0, width(), height()); + switch(save.background) { + case 'white': { + c.fillStyle = 'white'; + c.globalCompositeOperation = 'destination-over'; + c.fillRect(0, 0, width(), height()); + c.fillStyle = settings.color; + c.globalCompositeOperation = settings.composite; + break; + } + case 'current color': { + c.fillStyle = settings.bg; + c.globalCompositeOperation = 'destination-over'; + c.fillRect(0, 0, width(), height()); + c.globalCompositeOperation = settings.composite; + break; } } - else { - list ? list.push({ - name: save['file name'], - data: data, - points: window.points, - settings: settings - }) : list = [{ - name: save['file name'], - data: data, - points: window.points, - settings: settings - }]; - localStorage.setItem('projects', JSON.stringify(list)); - } - } else { - var sd = window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs) { - var fdata = dataToBlob(data); - var req = fs.root.getFile(save['file name'] + '.png', {create: true}, function(file) { - file.createWriter(function(writer) { - writer.write(fdata); - alert('Your Sketch was saved successfuly: ' + this.result); - }, function() { - alert('Something bad happened trying to save your sketch ' + save['file name'] + '\n Possible reasons:\n Duplicate Name \n Not enough permission') - }) - }) - }, function(error) { - alert('Couldn\'t access filesystem\n' + error.message); - }); - } - c.putImageData(f, 0, 0); - } - window.load = function() { - var file = JSON.parse(localStorage.getItem('projects')).filter(function(a) { return a.name == load.file })[0]; - var img = document.createElement('img'); - img.src = file.data; - img.onload = function() { - c.clearRect(0, 0, width(), height()); - c.drawImage(img, 0, 0); - window.points = file.points; - window.points.history = [{ data: c.createImageData($c.width(), $c.height()), points: []}, { data: c.getImageData(0, 0, width(), height()), points: file.points}]; - $c.first().css('background', file.settings.bg); - window.settings.bg = file.settings.bg; + var data = $c[0].toDataURL(); + if( save.type == 'sketchy project' ) { + var list = JSON.parse(localStorage.getItem('projects')); + var index; + if( list && list.some(function(a, i) { if( a.name == save['file name'] ) {index = i; return true} return false }) ) { + if( confirm('A sketch with this name already exists. Do you want to overwrite ' + save['file name'] + '?') ) { + console.log(index); + list[index] = { + name: save['file name'], + data: data, + points: window.points, + settings: settings + } + localStorage.setItem('projects', JSON.stringify(list)); + } + } + else { + list ? list.push({ + name: save['file name'], + data: data, + points: window.points, + settings: settings + }) : list = [{ + name: save['file name'], + data: data, + points: window.points, + settings: settings + }]; + localStorage.setItem('projects', JSON.stringify(list)); + } + } else { + var img = dataToBlob(data); + var sd = window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs) { + window.alert('SD'); + /*var req = fs.root.getFile(save['file name'] + '.png', {create: true}, function(entry) { + alert('Entry'); + entry.createWriter(function(writer) { + writer.write(img); + alert('Your Sketch was saved successfuly'); + }, function() { + alert('Something bad happened trying to save your sketch ' + save['file name'] + '\n Possible reasons:\n Duplicate Name \n Not enough permission') + }) + })*/ + }, function(e) { + alert('SD Error') + //alert('Couldn\'t access filesystem\nERR: ' + e.code); + }); } + c.putImageData(f, 0, 0); } + window.load = function() { + var file = JSON.parse(localStorage.getItem('projects')).filter(function(a) { return a.name == load.file })[0]; + var img = document.createElement('img'); + img.src = file.data; + img.onload = function() { + c.clearRect(0, 0, width(), height()); + c.drawImage(img, 0, 0); + window.points = file.points; + window.points.history = [{ data: c.createImageData($c.width(), $c.height()), points: []}, { data: c.getImageData(0, 0, width(), height()), points: file.points}]; + $c.first().css('background', file.settings.bg); + window.settings.bg = file.settings.bg; + } + } - if( !localStorage.getItem('sawVote') ) { - $('.vote').removeClass('hidden'); - localStorage.setItem('sawVote', true); - } + if( !localStorage.getItem('sawVote') ) { + $('.vote').removeClass('hidden'); + localStorage.setItem('sawVote', true); + } + }, false) }) diff --git a/Android/res/icons/android/icon-48-mdpi.png b/Android/res/icons/android/icon-48-mdpi.png new file mode 100644 index 0000000..301142f Binary files /dev/null and b/Android/res/icons/android/icon-48-mdpi.png differ diff --git a/Android/icon.png b/Android/res/icons/android/icon-60-hdpi.png similarity index 100% rename from Android/icon.png rename to Android/res/icons/android/icon-60-hdpi.png diff --git a/Android/res/drawable/sketchy.png b/Android/res/icons/android/icon.png similarity index 100% rename from Android/res/drawable/sketchy.png rename to Android/res/icons/android/icon.png diff --git a/Gruntfile.js b/Gruntfile.js index 23a9bc9..f5735ec 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -21,6 +21,13 @@ module.exports = function(grunt) { dest: 'build/web/js', filter: 'isFile' }, + { + expand: true, + cwd: 'Shared/js', + src: '**', + dest: 'build/android/js', + filter: 'isFile' + }, { expand: true, cwd: 'Mobile/js/', @@ -79,7 +86,7 @@ module.exports = function(grunt) { { expand: true, cwd: 'Android', - src: ['index.html', 'config.xml', 'res/**', 'icon.png'], + src: ['index.html', 'config.xml', 'AndroidManifest.xml', 'res/**', 'icon.png'], dest: 'build/android' }, { diff --git a/Web/js/main.js b/Web/js/main.js index efcfdf6..0ebdb29 100644 --- a/Web/js/main.js +++ b/Web/js/main.js @@ -61,7 +61,8 @@ $(document).ready(function() { }]; localStorage.setItem('projects', JSON.stringify(list)); } else { - window.open(data, '_blank').focus(); + $('').click(); + //window.open(data, '_blank').focus(); } c.putImageData(f, 0, 0); diff --git a/build/android/AndroidManifest.xml b/build/android/AndroidManifest.xml new file mode 100644 index 0000000..f82a6bf --- /dev/null +++ b/build/android/AndroidManifest.xml @@ -0,0 +1,2 @@ + + diff --git a/build/android/config.xml b/build/android/config.xml index 33e93ba..82c31ed 100644 --- a/build/android/config.xml +++ b/build/android/config.xml @@ -13,7 +13,7 @@ - + @@ -21,7 +21,12 @@ - + + + + + + diff --git a/build/android/index.html b/build/android/index.html index abc9887..31a15dd 100644 --- a/build/android/index.html +++ b/build/android/index.html @@ -5,8 +5,9 @@ Sketchy + - +
diff --git a/build/android/js/diff.js b/build/android/js/diff.js index b5500e2..d5e6437 100644 --- a/build/android/js/diff.js +++ b/build/android/js/diff.js @@ -1 +1 @@ -$(document).ready(function(){$("*").off("click mousemove mousedown mouseup mouseleave").on("click mousemove mousedown mouseup mouseleave",function(a){a.preventDefault}),window.save=function(){var a=c.getImageData(0,0,width(),height());switch(save.background){case"white":c.fillStyle="white",c.globalCompositeOperation="destination-over",c.fillRect(0,0,width(),height()),c.fillStyle=settings.color,c.globalCompositeOperation=settings.composite;break;case"current color":c.fillStyle=settings.bg,c.globalCompositeOperation="destination-over",c.fillRect(0,0,width(),height()),c.globalCompositeOperation=settings.composite}var b=$c[0].toDataURL();if("sketchy project"==save.type){var d,e=JSON.parse(localStorage.getItem("projects"));e&&e.some(function(a,b){return a.name==save["file name"]?(d=b,!0):!1})?confirm("A sketch with this name already exists. Do you want to overwrite "+save["file name"]+"?")&&(console.log(d),e[d]={name:save["file name"],data:b,points:window.points,settings:settings},localStorage.setItem("projects",JSON.stringify(e))):(e?e.push({name:save["file name"],data:b,points:window.points,settings:settings}):e=[{name:save["file name"],data:b,points:window.points,settings:settings}],localStorage.setItem("projects",JSON.stringify(e)))}else{window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(a){{var c=dataToBlob(b);a.root.getFile(save["file name"]+".png",{create:!0},function(a){a.createWriter(function(a){a.write(c),alert("Your Sketch was saved successfuly: "+this.result)},function(){alert("Something bad happened trying to save your sketch "+save["file name"]+"\n Possible reasons:\n Duplicate Name \n Not enough permission")})})}},function(a){alert("Couldn't access filesystem\n"+a.message)})}c.putImageData(a,0,0)},window.load=function(){var a=JSON.parse(localStorage.getItem("projects")).filter(function(a){return a.name==load.file})[0],b=document.createElement("img");b.src=a.data,b.onload=function(){c.clearRect(0,0,width(),height()),c.drawImage(b,0,0),window.points=a.points,window.points.history=[{data:c.createImageData($c.width(),$c.height()),points:[]},{data:c.getImageData(0,0,width(),height()),points:a.points}],$c.first().css("background",a.settings.bg),window.settings.bg=a.settings.bg}},localStorage.getItem("sawVote")||($(".vote").removeClass("hidden"),localStorage.setItem("sawVote",!0))}); \ No newline at end of file +$(document).ready(function(){$(document).on("resume",function(){sizeAndPos()}),document.addEventListener("deviceready",function(){sizeAndPos(),$("*").off("click mousemove mousedown mouseup mouseleave").on("click mousemove mousedown mouseup mouseleave",function(a){a.preventDefault}),window.save=function(){var a=c.getImageData(0,0,width(),height());switch(save.background){case"white":c.fillStyle="white",c.globalCompositeOperation="destination-over",c.fillRect(0,0,width(),height()),c.fillStyle=settings.color,c.globalCompositeOperation=settings.composite;break;case"current color":c.fillStyle=settings.bg,c.globalCompositeOperation="destination-over",c.fillRect(0,0,width(),height()),c.globalCompositeOperation=settings.composite}var b=$c[0].toDataURL();if("sketchy project"==save.type){var d,e=JSON.parse(localStorage.getItem("projects"));e&&e.some(function(a,b){return a.name==save["file name"]?(d=b,!0):!1})?confirm("A sketch with this name already exists. Do you want to overwrite "+save["file name"]+"?")&&(console.log(d),e[d]={name:save["file name"],data:b,points:window.points,settings:settings},localStorage.setItem("projects",JSON.stringify(e))):(e?e.push({name:save["file name"],data:b,points:window.points,settings:settings}):e=[{name:save["file name"],data:b,points:window.points,settings:settings}],localStorage.setItem("projects",JSON.stringify(e)))}else{dataToBlob(b),window.requestFileSystem(LocalFileSystem.PERSISTENT,0,function(){window.alert("SD")},function(){alert("SD Error")})}c.putImageData(a,0,0)},window.load=function(){var a=JSON.parse(localStorage.getItem("projects")).filter(function(a){return a.name==load.file})[0],b=document.createElement("img");b.src=a.data,b.onload=function(){c.clearRect(0,0,width(),height()),c.drawImage(b,0,0),window.points=a.points,window.points.history=[{data:c.createImageData($c.width(),$c.height()),points:[]},{data:c.getImageData(0,0,width(),height()),points:a.points}],$c.first().css("background",a.settings.bg),window.settings.bg=a.settings.bg}},localStorage.getItem("sawVote")||($(".vote").removeClass("hidden"),localStorage.setItem("sawVote",!0))},!1)}); \ No newline at end of file diff --git a/build/android/res/icons/android/icon-48-mdpi.png b/build/android/res/icons/android/icon-48-mdpi.png new file mode 100644 index 0000000..301142f Binary files /dev/null and b/build/android/res/icons/android/icon-48-mdpi.png differ diff --git a/build/android/res/icons/android/icon-60-hdpi.png b/build/android/res/icons/android/icon-60-hdpi.png new file mode 100644 index 0000000..bac55b3 Binary files /dev/null and b/build/android/res/icons/android/icon-60-hdpi.png differ diff --git a/build/android/res/icons/android/icon.png b/build/android/res/icons/android/icon.png new file mode 100644 index 0000000..bac55b3 Binary files /dev/null and b/build/android/res/icons/android/icon.png differ diff --git a/build/android/res/icons/icon.png b/build/android/res/icons/icon.png new file mode 100644 index 0000000..bac55b3 Binary files /dev/null and b/build/android/res/icons/icon.png differ diff --git a/build/web/js/main.js b/build/web/js/main.js index fb9fc7f..4f82d55 100644 --- a/build/web/js/main.js +++ b/build/web/js/main.js @@ -1 +1 @@ -"use strict";$(document).ready(function(){function a(){var b=c.getImageData(0,0,width(),height());switch(a.background){case"white":c.fillStyle="white",c.globalCompositeOperation="destination-over",c.fillRect(0,0,width(),height()),c.fillStyle=settings.color,c.globalCompositeOperation=settings.composite;break;case"current color":c.fillStyle=settings.bg,c.globalCompositeOperation="destination-over",c.fillRect(0,0,width(),height()),c.globalCompositeOperation=settings.composite}var d=$c[0].toDataURL();if("sketchy project"==a.type){var e,f=JSON.parse(localStorage.getItem("projects"));f&&f.some(function(b,c){return b.name==a["file name"]?(e=c,!0):!1})?confirm("A sketch with this name already exists. Do you want to overwrite "+a["file name"]+"?")&&(console.log(e),f[e]={name:a["file name"],data:d,points:window.points,settings:settings},localStorage.setItem("projects",JSON.stringify(f))):f?f.push({name:a["file name"],data:d,points:window.points,settings:settings}):f=[{name:a["file name"],data:d,points:window.points,settings:settings}],localStorage.setItem("projects",JSON.stringify(f))}else window.open(d,"_blank").focus();c.putImageData(b,0,0)}function b(){var a=JSON.parse(localStorage.getItem("projects")).filter(function(a){return a.name==b.file})[0],d=document.createElement("img");d.src=a.data,d.onload=function(){c.clearRect(0,0,width(),height()),c.drawImage(d,0,0),window.points=a.points,window.points.history=[{data:c.createImageData($c.width(),$c.height()),points:[]},{data:c.getImageData(0,0,width(),height()),points:a.points}],$c.first().css("background",a.settings.bg),window.settings.bg=a.settings.bg}}yepnope({test:window.mobile,yep:["js/mobile.js","js/libs/color-picker-touch.js"],nope:["js/libs/color-picker.js"]}),$(window).resize(sizeAndPos),window.load=b,window.save=a}); \ No newline at end of file +"use strict";$(document).ready(function(){function a(){var b=c.getImageData(0,0,width(),height());switch(a.background){case"white":c.fillStyle="white",c.globalCompositeOperation="destination-over",c.fillRect(0,0,width(),height()),c.fillStyle=settings.color,c.globalCompositeOperation=settings.composite;break;case"current color":c.fillStyle=settings.bg,c.globalCompositeOperation="destination-over",c.fillRect(0,0,width(),height()),c.globalCompositeOperation=settings.composite}var d=$c[0].toDataURL();if("sketchy project"==a.type){var e,f=JSON.parse(localStorage.getItem("projects"));f&&f.some(function(b,c){return b.name==a["file name"]?(e=c,!0):!1})?confirm("A sketch with this name already exists. Do you want to overwrite "+a["file name"]+"?")&&(console.log(e),f[e]={name:a["file name"],data:d,points:window.points,settings:settings},localStorage.setItem("projects",JSON.stringify(f))):f?f.push({name:a["file name"],data:d,points:window.points,settings:settings}):f=[{name:a["file name"],data:d,points:window.points,settings:settings}],localStorage.setItem("projects",JSON.stringify(f))}else $('').click();c.putImageData(b,0,0)}function b(){var a=JSON.parse(localStorage.getItem("projects")).filter(function(a){return a.name==b.file})[0],d=document.createElement("img");d.src=a.data,d.onload=function(){c.clearRect(0,0,width(),height()),c.drawImage(d,0,0),window.points=a.points,window.points.history=[{data:c.createImageData($c.width(),$c.height()),points:[]},{data:c.getImageData(0,0,width(),height()),points:a.points}],$c.first().css("background",a.settings.bg),window.settings.bg=a.settings.bg}}yepnope({test:window.mobile,yep:["js/mobile.js","js/libs/color-picker-touch.js"],nope:["js/libs/color-picker.js"]}),$(window).resize(sizeAndPos),window.load=b,window.save=a}); \ No newline at end of file diff --git a/deploy-android b/deploy-android new file mode 100755 index 0000000..267ca83 --- /dev/null +++ b/deploy-android @@ -0,0 +1,6 @@ +#!/bin/bash + +grunt; +cp -R build/android/* ~/Documents/Workshop/Sketchy-Android/sketchy/www/ +cd ~/Documents/Workshop/Sketchy-Android/sketchy +phonegap run android diff --git a/sketchy-mobile-1.2.1.zip b/sketchy-mobile-1.2.1.zip index 9250af0..5ca503c 100644 Binary files a/sketchy-mobile-1.2.1.zip and b/sketchy-mobile-1.2.1.zip differ diff --git a/sketchy-web-1.2.1.zip b/sketchy-web-1.2.1.zip index c2c04a3..23ab678 100644 Binary files a/sketchy-web-1.2.1.zip and b/sketchy-web-1.2.1.zip differ