mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2025-08-28 22:18:54 -04:00
Split iOS and Android interfaces
Refactor the native interface in preparation for switching iOS to use WKWebview. * Finally rename the folder for device specific interfaces as `tablet` instead of `iPad` * Update `import` statements to use the new name * Create new `iOS.js` and `Android.js` based on previous `iPad/iOS.js` to separate the interfaces * Add new `OS.js` class to manage the class variables, initialize the device interface delegate methods to the correct interface. * refactor how `utils/lib` detects the current platform based on `navigtor.userAgent` based on https://stackoverflow.com/questions/37591279/detect-if-user-is-using-webview-for-android-ios-or-a-regular-browser. previous method relied on the Android interface being loaded or not. It can be difficult to detect the difference between in a browser and in a webview, but for now ScratchJr doesn’t need to worry about running in a browser
This commit is contained in:
parent
fc8fdcecf6
commit
1420a5947a
35 changed files with 1074 additions and 553 deletions
|
@ -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 */
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ NSMutableDictionary *soundtimers;
|
|||
+ (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];
|
||||
|
|
|
@ -164,7 +164,7 @@ JSContext *js;
|
|||
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];
|
||||
|
@ -172,7 +172,7 @@ JSContext *js;
|
|||
}
|
||||
|
||||
- (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];
|
||||
|
@ -310,7 +310,7 @@ JSContext *js;
|
|||
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];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue