diff --git a/Android/config.xml b/Android/config.xml new file mode 100644 index 0000000..c49e637 --- /dev/null +++ b/Android/config.xml @@ -0,0 +1,20 @@ + + + Sketchy + + Free full-featured Sketch app + + + Mahdi Dibaiee + + + + + + + + + + + + diff --git a/Android/index.html b/Android/index.html new file mode 100644 index 0000000..abc9887 --- /dev/null +++ b/Android/index.html @@ -0,0 +1,275 @@ + + + + + Sketchy + + + + + + +
+ + +

Sketchy

+ + + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Android/js/diff.js b/Android/js/diff.js new file mode 100644 index 0000000..9cc8a69 --- /dev/null +++ b/Android/js/diff.js @@ -0,0 +1,123 @@ +$(document).ready(function() { + + $('*').off('click mousemove mousedown mouseup mouseleave').on('click mousemove mousedown mouseup mouseleave', function(e) { + e.preventDefault; + }) + + /*$('a[href^="http"]').tap(function(e) { + e.preventDefault(); + var href = $(this).attr('href'); + var view = new MozActivity({ + name: 'view', + data: { + type: 'url', + url: href + } + }) + 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; + } + } + 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 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; + } + } + + if( !localStorage.getItem('sawVote') ) { + $('.vote').removeClass('hidden'); + localStorage.setItem('sawVote', true); + } + +}) diff --git a/Android/res/drawable/sketchy.png b/Android/res/drawable/sketchy.png new file mode 100644 index 0000000..bac55b3 Binary files /dev/null and b/Android/res/drawable/sketchy.png differ diff --git a/Gruntfile.js b/Gruntfile.js index dc0e553..095ded9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -28,6 +28,13 @@ module.exports = function(grunt) { dest: 'build/mobile/js', filter: 'isFile' }, + { + expand: true, + cwd: 'Android/js/', + src: '*', + dest: 'build/android/js', + filter: 'isFile' + }, { expand: true, cwd: 'Web/js/', @@ -42,6 +49,7 @@ module.exports = function(grunt) { production: { files: { 'build/mobile/css/main.css': 'Shared/css/main.less', + 'build/android/css/main.css': 'Shared/css/main.less', 'build/web/css/main.css': 'Shared/css/main.less' }, compress: true @@ -68,6 +76,12 @@ module.exports = function(grunt) { src: ['index.html', 'manifest.webapp'], dest: 'build/mobile' }, + { + expand: true, + cwd: 'Android', + src: ['index.html', 'config.xml', 'res'], + dest: 'build/android' + }, { expand: true, cwd: 'Web', @@ -84,6 +98,12 @@ module.exports = function(grunt) { src: '*/**', dest: 'build/mobile/css' }, + { + expand: true, + cwd: 'Shared/css', + src: '*/**', + dest: 'build/android/css' + }, { expand: true, cwd: 'Shared/css', diff --git a/Ideas b/Ideas old mode 100755 new mode 100644 diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 diff --git a/Mobile/index.html b/Mobile/index.html old mode 100755 new mode 100644 index 563345e..abc9887 --- a/Mobile/index.html +++ b/Mobile/index.html @@ -238,6 +238,19 @@ + + + +