diff --git a/demos/mobile/android/.gitignore b/demos/mobile/android/.gitignore new file mode 100644 index 000000000..0d7a3d8a8 --- /dev/null +++ b/demos/mobile/android/.gitignore @@ -0,0 +1,27 @@ +/build +/captures +/app/src/main/assets/blockly/msg +.settings +.project + +# Local Settings +local.properties + +# Project files +*.komodoproject +.gradle +*.iml +.idea + +# Build files +*.pyc +*.apk +*.ap_ +*.class +*.dex + +# OSX Files +.DS_Store + +# Windows Files +Thumb.db diff --git a/demos/mobile/android/README.md b/demos/mobile/android/README.md new file mode 100644 index 000000000..b03837ecf --- /dev/null +++ b/demos/mobile/android/README.md @@ -0,0 +1,45 @@ +# Blockly in an Android WebView + +This code demonstrates how to get Blockly running in an Android app by +embedding it in a WebView. + +### BlocklyWebViewFragment + +Most of the work is done within the fragment class `BlocklyWebViewFragment`. +This fragment instantiates the WebView, loads the HTML +(`assets/blockly/webview.html`), and provides a few helper methods. + +### Copying web assets with gradle + +This android project copies the necessary files from the main Blockly +repository (i.e., parent directory). In `app/build.gradle`, note the +`copyBlocklyWebFiles` task and `preBuild.dependsOn copyBlocklyWebFiles` line. + +In your own project, these files can be placed directly in the `assets/blockly` +directory without the copy step. However, if you do use the copy step, make +sure you adapt the copy paths appropriately. Additionally, you may want to +update your `.gitignore` or similar file. + +### Loading Block Definitions and Generator functions + +The `webview.html` loads the block definitions and generator functions directly +into the page, without support or coordination with the Android classes. This +assumes the app will always utilize the same blocks. This does not mean all +blocks are visible to the user all the time; that is controlled by the toolbox +and workspace files. This should accommodate almost all applications. + +This does mean loading your own block definitions and generators will involve +editing the HTML, adding you own ` + + + + + + +
+ + + \ No newline at end of file diff --git a/demos/mobile/ios/.gitignore b/demos/mobile/ios/.gitignore new file mode 100644 index 000000000..d6ce9d3ab --- /dev/null +++ b/demos/mobile/ios/.gitignore @@ -0,0 +1,29 @@ +# Files copied by cp_resources.sh +/Resources/Non-Localized/Blockly/blockly_compressed.js +/Resources/Non-Localized/Blockly/blocks_compressed.js +/Resources/Non-Localized/Blockly/media +/Resources/Non-Localized/Blockly/msg +/Resources/Non-Localized/Blockly/webview.html + + +# Xcode.gitignore + +## User settings +xcuserdata/ + +## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) +*.xcscmblueprint +*.xccheckout + +## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) +build/ +DerivedData/ +*.moved-aside +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 diff --git a/demos/mobile/ios/Blockly WebView.xcodeproj/project.pbxproj b/demos/mobile/ios/Blockly WebView.xcodeproj/project.pbxproj new file mode 100644 index 000000000..a3f72fcd4 --- /dev/null +++ b/demos/mobile/ios/Blockly WebView.xcodeproj/project.pbxproj @@ -0,0 +1,390 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 50; + objects = { + +/* Begin PBXBuildFile section */ + AB036C55211B89D600CCC9D8 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB036C54211B89D600CCC9D8 /* WebKit.framework */; }; + AB980111211A37B50025AFF2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB980110211A37B50025AFF2 /* AppDelegate.swift */; }; + AB980113211A37B50025AFF2 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB980112211A37B50025AFF2 /* ViewController.swift */; }; + AB980116211A37B50025AFF2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AB980114211A37B50025AFF2 /* Main.storyboard */; }; + AB980118211A37B70025AFF2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AB980117211A37B70025AFF2 /* Assets.xcassets */; }; + AB98011B211A37B70025AFF2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = AB980119211A37B70025AFF2 /* LaunchScreen.storyboard */; }; + ABA1B7FC212214E7000D3CC5 /* Blockly in Resources */ = {isa = PBXBuildFile; fileRef = ABA1B7FB212214E7000D3CC5 /* Blockly */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + AB036C54211B89D600CCC9D8 /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; + AB98010D211A37B50025AFF2 /* Blockly WebView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Blockly WebView.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + AB980110211A37B50025AFF2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + AB980112211A37B50025AFF2 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + AB980115211A37B50025AFF2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + AB980117211A37B70025AFF2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + AB98011A211A37B70025AFF2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + AB98011C211A37B70025AFF2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + ABA1B7FB212214E7000D3CC5 /* Blockly */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Blockly; path = "Resources/Non-Localized/Blockly"; sourceTree = SOURCE_ROOT; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + AB98010A211A37B50025AFF2 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + AB036C55211B89D600CCC9D8 /* WebKit.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + AB036C53211B89D500CCC9D8 /* Frameworks */ = { + isa = PBXGroup; + children = ( + AB036C54211B89D600CCC9D8 /* WebKit.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + AB980104211A37B50025AFF2 = { + isa = PBXGroup; + children = ( + AB98010F211A37B50025AFF2 /* Blockly WebView */, + AB98010E211A37B50025AFF2 /* Products */, + AB036C53211B89D500CCC9D8 /* Frameworks */, + ); + sourceTree = ""; + }; + AB98010E211A37B50025AFF2 /* Products */ = { + isa = PBXGroup; + children = ( + AB98010D211A37B50025AFF2 /* Blockly WebView.app */, + ); + name = Products; + sourceTree = ""; + }; + AB98010F211A37B50025AFF2 /* Blockly WebView */ = { + isa = PBXGroup; + children = ( + ABA1B7F9212214B9000D3CC5 /* Resources */, + AB980110211A37B50025AFF2 /* AppDelegate.swift */, + AB980112211A37B50025AFF2 /* ViewController.swift */, + AB980114211A37B50025AFF2 /* Main.storyboard */, + AB980117211A37B70025AFF2 /* Assets.xcassets */, + AB980119211A37B70025AFF2 /* LaunchScreen.storyboard */, + AB98011C211A37B70025AFF2 /* Info.plist */, + ); + path = "Blockly WebView"; + sourceTree = ""; + }; + ABA1B7F9212214B9000D3CC5 /* Resources */ = { + isa = PBXGroup; + children = ( + ABA1B7FA212214C6000D3CC5 /* Non-Localized */, + ); + path = Resources; + sourceTree = ""; + }; + ABA1B7FA212214C6000D3CC5 /* Non-Localized */ = { + isa = PBXGroup; + children = ( + ABA1B7FB212214E7000D3CC5 /* Blockly */, + ); + path = "Non-Localized"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + AB98010C211A37B50025AFF2 /* Blockly WebView */ = { + isa = PBXNativeTarget; + buildConfigurationList = AB98011F211A37B70025AFF2 /* Build configuration list for PBXNativeTarget "Blockly WebView" */; + buildPhases = ( + AB980109211A37B50025AFF2 /* Sources */, + AB98010A211A37B50025AFF2 /* Frameworks */, + ABEDABD1212372E700A66667 /* ShellScript */, + AB98010B211A37B50025AFF2 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Blockly WebView"; + productName = "Blockly WebView"; + productReference = AB98010D211A37B50025AFF2 /* Blockly WebView.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + AB980105211A37B50025AFF2 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0940; + LastUpgradeCheck = 0940; + ORGANIZATIONNAME = Google; + TargetAttributes = { + AB98010C211A37B50025AFF2 = { + CreatedOnToolsVersion = 9.4.1; + }; + }; + }; + buildConfigurationList = AB980108211A37B50025AFF2 /* Build configuration list for PBXProject "Blockly WebView" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = AB980104211A37B50025AFF2; + productRefGroup = AB98010E211A37B50025AFF2 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + AB98010C211A37B50025AFF2 /* Blockly WebView */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + AB98010B211A37B50025AFF2 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + AB98011B211A37B70025AFF2 /* LaunchScreen.storyboard in Resources */, + AB980118211A37B70025AFF2 /* Assets.xcassets in Resources */, + AB980116211A37B50025AFF2 /* Main.storyboard in Resources */, + ABA1B7FC212214E7000D3CC5 /* Blockly in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + ABEDABD1212372E700A66667 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = ./cp_resources.sh; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + AB980109211A37B50025AFF2 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + AB980113211A37B50025AFF2 /* ViewController.swift in Sources */, + AB980111211A37B50025AFF2 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + AB980114211A37B50025AFF2 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + AB980115211A37B50025AFF2 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + AB980119211A37B70025AFF2 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + AB98011A211A37B70025AFF2 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + AB98011D211A37B70025AFF2 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.4; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + AB98011E211A37B70025AFF2 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.4; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + AB980120211A37B70025AFF2 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 3KZF7Q7Q49; + INFOPLIST_FILE = "Blockly WebView/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.google.kidscoding.Blockly-WebView"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + AB980121211A37B70025AFF2 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = 3KZF7Q7Q49; + INFOPLIST_FILE = "Blockly WebView/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "com.google.kidscoding.Blockly-WebView"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + AB980108211A37B50025AFF2 /* Build configuration list for PBXProject "Blockly WebView" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + AB98011D211A37B70025AFF2 /* Debug */, + AB98011E211A37B70025AFF2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + AB98011F211A37B70025AFF2 /* Build configuration list for PBXNativeTarget "Blockly WebView" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + AB980120211A37B70025AFF2 /* Debug */, + AB980121211A37B70025AFF2 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = AB980105211A37B50025AFF2 /* Project object */; +} diff --git a/demos/mobile/ios/Blockly WebView.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/demos/mobile/ios/Blockly WebView.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..2a4f4ae83 --- /dev/null +++ b/demos/mobile/ios/Blockly WebView.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/demos/mobile/ios/Blockly WebView.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/demos/mobile/ios/Blockly WebView.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/demos/mobile/ios/Blockly WebView.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/demos/mobile/ios/Blockly WebView.xcodeproj/xcuserdata/marshalla.xcuserdatad/xcschemes/xcschememanagement.plist b/demos/mobile/ios/Blockly WebView.xcodeproj/xcuserdata/marshalla.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 000000000..7cbeeade6 --- /dev/null +++ b/demos/mobile/ios/Blockly WebView.xcodeproj/xcuserdata/marshalla.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,14 @@ + + + + + SchemeUserState + + Blockly WebView.xcscheme + + orderHint + 0 + + + + diff --git a/demos/mobile/ios/Blockly WebView/AppDelegate.swift b/demos/mobile/ios/Blockly WebView/AppDelegate.swift new file mode 100644 index 000000000..1f2bf6eed --- /dev/null +++ b/demos/mobile/ios/Blockly WebView/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// Blockly WebView +// +// Created by Andrew Marshall on 8/7/18. +// Copyright © 2018 Google. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/demos/mobile/ios/Blockly WebView/Assets.xcassets/AppIcon.appiconset/Contents.json b/demos/mobile/ios/Blockly WebView/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..d8db8d65f --- /dev/null +++ b/demos/mobile/ios/Blockly WebView/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/demos/mobile/ios/Blockly WebView/Assets.xcassets/Contents.json b/demos/mobile/ios/Blockly WebView/Assets.xcassets/Contents.json new file mode 100644 index 000000000..da4a164c9 --- /dev/null +++ b/demos/mobile/ios/Blockly WebView/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/demos/mobile/ios/Blockly WebView/Base.lproj/LaunchScreen.storyboard b/demos/mobile/ios/Blockly WebView/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 000000000..f83f6fd58 --- /dev/null +++ b/demos/mobile/ios/Blockly WebView/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/mobile/ios/Blockly WebView/Base.lproj/Main.storyboard b/demos/mobile/ios/Blockly WebView/Base.lproj/Main.storyboard new file mode 100644 index 000000000..35c8fdddf --- /dev/null +++ b/demos/mobile/ios/Blockly WebView/Base.lproj/Main.storyboard @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demos/mobile/ios/Blockly WebView/Info.plist b/demos/mobile/ios/Blockly WebView/Info.plist new file mode 100644 index 000000000..16be3b681 --- /dev/null +++ b/demos/mobile/ios/Blockly WebView/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/demos/mobile/ios/Blockly WebView/ViewController.swift b/demos/mobile/ios/Blockly WebView/ViewController.swift new file mode 100644 index 000000000..6a8f2418d --- /dev/null +++ b/demos/mobile/ios/Blockly WebView/ViewController.swift @@ -0,0 +1,38 @@ +// +// ViewController.swift +// Blockly WebView +// +// Created by Andrew Marshall on 8/7/18. +// Copyright © 2018 Google. All rights reserved. +// + +import UIKit +import WebKit + +class ViewController: UIViewController { + /// The name used to reference this iOS object when executing callbacks from the JS code. + /// If this value is changed, it should also be changed in the `CODE_GENERATOR_BRIDGE_JS` file. + fileprivate static let HOST_HTML = "Blockly/webview.html" + + @IBOutlet weak var webView: WKWebView! + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. + loadWebView() + } + + func loadWebView() { + if let htmlUrl = Bundle.main.url(forResource: "webview", withExtension: "html", subdirectory: "Blockly") { + webView.load(URLRequest.init(url: htmlUrl)) + } + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + +} + diff --git a/demos/mobile/ios/Resources/Non-Localized/Blockly/toolbox_standard.js b/demos/mobile/ios/Resources/Non-Localized/Blockly/toolbox_standard.js new file mode 100644 index 000000000..77e1a6863 --- /dev/null +++ b/demos/mobile/ios/Resources/Non-Localized/Blockly/toolbox_standard.js @@ -0,0 +1,333 @@ + +var BLOCKLY_TOOLBOX_XML = BLOCKLY_TOOLBOX_XML || Object.create(null); + +/* BEGINNING BLOCKLY_TOOLBOX_XML ASSIGNMENT. DO NOT EDIT. USE BLOCKLY DEVTOOLS. */ +BLOCKLY_TOOLBOX_XML['standard'] = +// From XML string/file, replace ^\s?(\s*)?(<.*>)$ with \+$1'$2' +// Tweak first and last line. +'' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '10' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '1' ++ '' ++ '' ++ '' ++ '' ++ '10' ++ '' ++ '' ++ '' ++ '' ++ '1' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '123' ++ '' ++ '' ++ '' ++ '' ++ '1' ++ '' ++ '' ++ '' ++ '' ++ '1' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '9' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '45' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '0' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '3.1' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '64' ++ '' ++ '' ++ '' ++ '' ++ '10' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '50' ++ '' ++ '' ++ '' ++ '' ++ '1' ++ '' ++ '' ++ '' ++ '' ++ '100' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '1' ++ '' ++ '' ++ '' ++ '' ++ '100' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ 'abc' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ 'text' ++ '' ++ '' ++ '' ++ '' ++ 'abc' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ 'text' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ 'text' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ 'abc' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ 'abc' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ 'abc' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ 'abc' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '5' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ 'list' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ 'list' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ 'list' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ 'list' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ ',' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '100' ++ '' ++ '' ++ '' ++ '' ++ '50' ++ '' ++ '' ++ '' ++ '' ++ '0' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '#ff0000' ++ '' ++ '' ++ '' ++ '' ++ '#3333ff' ++ '' ++ '' ++ '' ++ '' ++ '0.5' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ '' ++ ''; +/* END BLOCKLY_TOOLBOX_XML ASSIGNMENT. DO NOT EDIT. */ diff --git a/demos/mobile/ios/cp_resources.sh b/demos/mobile/ios/cp_resources.sh new file mode 100755 index 000000000..0221c9290 --- /dev/null +++ b/demos/mobile/ios/cp_resources.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -eux + +BLOCKLY_ROOT=../../.. +IOS_RESOURCES=Resources/Non-Localized/Blockly + +MORE_FILES_TO_COPY=( + "blockly_compressed.js" + "blocks_compressed.js" + "media" + "msg/js" + ) + +mkdir -p $IOS_RESOURCES/media +mkdir -p $IOS_RESOURCES/msg/js +rsync -rp ../html/index.html $IOS_RESOURCES/webview.html +for i in "${MORE_FILES_TO_COPY[@]}"; do # The quotes are necessary here + TARGET_DIR=$(dirname $IOS_RESOURCES/$i) + rsync -rp $BLOCKLY_ROOT/$i $TARGET_DIR +done