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 ` + + + + + +
+ + + +