Skip to content
This repository was archived by the owner on Aug 12, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions android/ScratchJr/.idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions android/ScratchJr/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ private void receiveProject(Uri projectUri) {
}
// We send the project Base64-encoded to JavaScript where it's processed and unpacked
String base64Project = Base64.encodeToString(projectData.toByteArray(), Base64.DEFAULT);
runJavaScript("iOS.loadProjectFromSjr('" + base64Project + "');");
runJavaScript("OS.loadProjectFromSjr('" + base64Project + "');");
}

public RelativeLayout getContainer() {
Expand Down
Binary file modified editions/free/ios-resources/Default-Landscape@2x~ipad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified editions/free/ios-resources/Default-Landscape~ipad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ios/ScratchJr.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "EDITION=free;\n\n../bin/bundle-compile.sh;\n\nrsync -pvtrlL --cvs-exclude \\\n ../editions/$EDITION/ios-resources/* \\\n \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/\";\n\nrsync -pvtrlL --cvs-exclude \\\n ../editions/$EDITION/src/* \\\n \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/HTML5\";\n \nmkdir -p \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/HTML5/pnglibrary\";\n\n../bin/convert-svg-to-png.py -i \"../editions/$EDITION/src/svglibrary/\" -o \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/HTML5/pnglibrary\";";
shellScript = "EDITION=free;\n\n../bin/bundle-compile.sh;\n\nrsync -pvtrlL --cvs-exclude \\\n ../editions/$EDITION/ios-resources/* \\\n \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/\";\n\nrsync -pvtrlL --cvs-exclude \\\n ../editions/$EDITION/src/* \\\n \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/HTML5\";\n \nmkdir -p \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/HTML5/pnglibrary\";\n\n../bin/convert-svg-to-png.py -i \"../editions/$EDITION/src/svglibrary/\" -o \"$BUILT_PRODUCTS_DIR/$CONTENTS_FOLDER_PATH/HTML5/pnglibrary\";\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
2 changes: 1 addition & 1 deletion ios/ScratchJr/src/IO.m
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ + (NSString *)playSound :(NSString*)name {
+ (void)soundEnded:(NSTimer*)timer {
NSString *soundName = [[timer userInfo] objectForKey:@"soundName"];
if (sounds[soundName] == nil) return;
NSString *callback = [NSString stringWithFormat:@"iOS.soundDone('%@');", soundName];
NSString *callback = [NSString stringWithFormat:@"OS.soundDone('%@');", soundName];
UIWebView *webview = [ViewController webview];
dispatch_async(dispatch_get_main_queue(), ^{
[webview stringByEvaluatingJavaScriptFromString:callback];
Expand Down
6 changes: 3 additions & 3 deletions ios/ScratchJr/src/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{
NSLog(@"could not load the website caused by error DESC: %@", error);
NSDictionary *userInfo = [error userInfo];
NSString *desc = [NSString stringWithFormat:@"%@", ([userInfo objectForKey: @"NSLocalizedDescription"] == NULL)? [error localizedDescription]: [userInfo objectForKey: @"NSLocalizedDescription"]];
NSString *callback = [NSString stringWithFormat: @"iOS.pageError('%@');",desc];
NSString *callback = [NSString stringWithFormat: @"OS.pageError('%@');",desc];
UIWebView *webview = [ViewController webview];
dispatch_async(dispatch_get_main_queue(), ^{
[webview stringByEvaluatingJavaScriptFromString: callback];
});
}

- (void) receiveProject:(NSString *)project{
NSString *callback = [NSString stringWithFormat:@"iOS.loadProjectFromSjr('%@');", project];
NSString *callback = [NSString stringWithFormat:@"OS.loadProjectFromSjr('%@');", project];
UIWebView *webview = [ViewController webview];
dispatch_async(dispatch_get_main_queue(), ^{
NSString *res = [webview stringByEvaluatingJavaScriptFromString:callback];
Expand Down Expand Up @@ -310,7 +310,7 @@ -(NSString*) scratchjr_captureimage: (NSString*)onCameraCaptureComplete {
return [ScratchJr captureimage:onCameraCaptureComplete];
}

//iOS.sendSjrToShareDialog = function(fileName, emailSubject, emailBody, shareType, b64data) {
//OS.sendSjrToShareDialog = function(fileName, emailSubject, emailBody, shareType, b64data) {

-(NSString*) sendSjrUsingShareDialog:(NSString*) fileName :(NSString*) emailSubject :(NSString*) emailBody :(int) shareType :(NSString*) b64data {
return [IO sendSjrUsingShareDialog:fileName :emailSubject :emailBody :shareType : b64data];
Expand Down
38 changes: 9 additions & 29 deletions src/editor/ScratchJr.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import Undo from './ui/Undo';
import Alert from './ui/Alert';
import Palette from './ui/Palette';
import Record from './ui/Record';
import IO from '../iPad/IO';
import iOS from '../iPad/iOS';
import IO from '../tablet/IO';
import OS from '../tablet/OS';
import UI from './ui/UI';
import Menu from './blocks/Menu';
import Library from './ui/Library';
Expand Down Expand Up @@ -183,7 +183,7 @@ export default class ScratchJr {
document.body.scrollTop = 0;
time = (new Date()) - 0;
var urlvars = getUrlVars();
iOS.hascamera();
OS.hascamera();
ScratchJr.log('starting the app');
BlockSpecs.initBlocks();
Project.loadIcon = document.createElement('img');
Expand Down Expand Up @@ -345,7 +345,7 @@ export default class ScratchJr {

static saveProject (e, onDone) {
if (ScratchJr.isEditable() && editmode == 'storyStarter' && storyStarted && !Project.error) {
iOS.analyticsEvent('samples', 'story_starter_edited', Project.metadata.name);
OS.analyticsEvent('samples', 'story_starter_edited', Project.metadata.name);
// Localize sample project names
var sampleName = Localization.localize('SAMPLE_' + Project.metadata.name);
// Get the new project name
Expand Down Expand Up @@ -381,14 +381,14 @@ export default class ScratchJr {
ScratchJr.stopStripsFromTop(e);
ScratchJr.unfocus(e);
ScratchJr.saveProject(e, ScratchJr.flippage);
iOS.analyticsEvent('editor', 'project_editor_close');
OS.analyticsEvent('editor', 'project_editor_close');
}

static flippage () {
Alert.close();
iOS.cleanassets('wav', doNext);
OS.cleanassets('wav', doNext);
function doNext () {
iOS.cleanassets('svg', ScratchJr.switchPage);
OS.cleanassets('svg', ScratchJr.switchPage);
}
}

Expand Down Expand Up @@ -525,7 +525,7 @@ export default class ScratchJr {
ScratchJr.displayStatus('none');
inFullscreen = true;
UI.enterFullScreen();
iOS.analyticsEvent('editor', 'full_screen_entered');
OS.analyticsEvent('editor', 'full_screen_entered');
document.body.style.background = 'black';
}

Expand All @@ -537,7 +537,7 @@ export default class ScratchJr {
inFullscreen = false;
UI.quitFullScreen();
onBackButtonCallback.pop();
iOS.analyticsEvent('editor', 'full_screen_exited');
OS.analyticsEvent('editor', 'full_screen_exited');
document.body.style.background = 'white';
}

Expand Down Expand Up @@ -905,26 +905,6 @@ export default class ScratchJr {
/////////////////
//Application on the background


// XXX: does this ever happen?
// I'm pretty sure this is dead code -TM
static saveProjectState () {
ScratchAudio.sndFX('tap.wav');
if (frame.style.display == 'none') {
Paint.saveEditState(ScratchJr.stopServer);
} else {
ScratchJr.unfocus();
ScratchJr.stopStrips();
if (ScratchJr.isEditable() && currentProject && !Project.error && changed) {
Project.save(currentProject, ScratchJr.stopServer);
}
}
}

static stopServer () {
iOS.stopserver(iOS.trace);
}

/**
* The functions that are invokved when the Android back button is clicked.
* Methods are called from the rear and popped off after each invocation.
Expand Down
2 changes: 1 addition & 1 deletion src/editor/blocks/BlockSpecs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Localization from '../../utils/Localization';
import IO from '../../iPad/IO';
import IO from '../../tablet/IO';

let loadCount = 0;

Expand Down
14 changes: 8 additions & 6 deletions src/editor/engine/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import UI from '../ui/UI';
import Sprite from './Sprite';
import Palette from '../ui/Palette';
import BlockSpecs from '../blocks/BlockSpecs';
import iOS from '../../iPad/iOS';
import IO from '../../iPad/IO';
import MediaLib from '../../iPad/MediaLib';
import OS from '../../tablet/OS';
import IO from '../../tablet/IO';
import MediaLib from '../../tablet/MediaLib';
import Undo from '../ui/Undo';
import Matrix from '../../geom/Matrix';
import Vector from '../../geom/Vector';
Expand Down Expand Up @@ -125,7 +125,9 @@ export default class Page {
return;
}
var me = this;
var url = (MediaLib.keys[name]) ? MediaLib.path + name : (name.indexOf('/') < 0) ? iOS.path + name : name;
var url = (MediaLib.keys[name]) ?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was just fixing a lint error

MediaLib.path + name :
(name.indexOf('/') < 0) ? OS.path + name : name;
var md5 = (MediaLib.keys[name]) ? MediaLib.path + name : name;

if (md5.substr(md5.length - 3) == 'png') {
Expand All @@ -137,15 +139,15 @@ export default class Page {
if (md5.indexOf('/') > -1) {
IO.requestFromServer(md5, doNext);
} else {
iOS.getmedia(md5, nextStep);
OS.getmedia(md5, nextStep);
}
function nextStep (base64) {
doNext(atob(base64));
}
function doNext (str) {
str = str.replace(/>\s*</g, '><');
me.setSVG(str);
if ((str.indexOf('xlink:href') < 0) && iOS.path) {
if ((str.indexOf('xlink:href') < 0) && OS.path) {
me.setBackgroundImage(url, fcn); // does not have embedded images
} else {
var base64 = IO.getImageDataURL(me.md5, btoa(str));
Expand Down
Loading