70
App Inventor Development Karishma Chadha, Erin Davis Emily Erdman, Johanna Okerlund Wellesley Science Center Summer Research July 27, 2012 TinkerBlocks Supervised by Lyn Turbak

App Inventor Development

Embed Size (px)

Citation preview

Page 1: App Inventor Development

App Inventor

Development Karishma Chadha, Erin Davis Emily Erdman, Johanna Okerlund

Wellesley Science Center Summer Research

July 27, 2012 TinkerBlocks

Supervised by Lyn Turbak

Page 2: App Inventor Development

Our Presentation

•  Introduction to App Inventor • Posting Pictures (OAuth)- Emily • Blocks to Text- Erin •  Text to Blocks- Karishma • Data Mining- Johanna

Page 3: App Inventor Development
Page 4: App Inventor Development
Page 5: App Inventor Development

App Inventor Development Team

GSOC

MIT

Page 6: App Inventor Development

Google Hangouts

Page 7: App Inventor Development

App Inventor Summit

•  July 13-14 at MIT

•  In attendance: o  App Inventor

Users o  Teachers using

App Inventor o  Developers

•  Presented our progress so far •  Discussed the future of App Inventor

Page 8: App Inventor Development

Our Presentation

•  Introduction to App Inventor • Posting Pictures (OAuth)- Emily • Blocks to Text- Erin •  Text to Blocks- Karishma • Data Mining- Johanna

Page 9: App Inventor Development

First App Inventor Dev Team Task

•  Issues for everyone!

Show people how to use HTTP POST in the Web Component to post text and pictures to the internet.

Page 10: App Inventor Development

What about posting pictures?

Page 11: App Inventor Development
Page 12: App Inventor Development

The sun was shining on the awesome tree.

Page 13: App Inventor Development
Page 14: App Inventor Development

Photo Sharing Sites

Page 15: App Inventor Development

Where do I post?

Page 16: App Inventor Development

My Nemesis

Page 17: App Inventor Development

StoryBook App (Consumer)

Flickr (Service Provider) User

Request Token

Receive Token Step 1 (Get Request Token)

Direct user to login and authorization pages

Request Access Token

Receive Access Token

Redirect to app with

verifier token User grants access to app Step 2

(Get Verifier)

Step 3 (Get Access Token)

OAuth 1.0a

Page 18: App Inventor Development
Page 19: App Inventor Development

Itty Bitty Details (With HUGE Consequences)

•  Each request sent to the service provider must be signed with HMAC-SHA1 encryption.

Page 20: App Inventor Development

Signing a Request •  Base String = Method&RequestURL&QueryParameters(alphabetically) •  Signing Key = ConsumerSecret&TokenSecret

GET&http%3A%2F%2Fwww.flickr.com%2Fservices%2Foauth%2Faccess_token&oauth_call back%3Dhttp%253A%252F%252Fwww.google.com%26oauth_consumer_key%3Dc892f1ed 8dcd7cd39dd3ede25d261b08%26oauth_nonce%3D5154d383187181b5%26oauth_signatur e_method%3DHMAC-SHA1%26oauth_timestamp%3D1343317580%26oauth_token%3D721 57630761601954-818d6eb500c5e4a1%26oauth_verifier%3D4b4f7d3624ce5d3f%26oauth_v ersion%3D1.0

6MJLN1klR9nmIItYU4F5dkHYRco=

39215edf4e40636f&0e571aecc224a169

Page 21: App Inventor Development

Itty Bitty Details (With HUGE Consequences)

•  Each request sent to the service provider must be signed with HMAC-SHA1 encryption.

•  In Android < 2.2, HttpURLConnection sets request headers to lower case.

Page 22: App Inventor Development

Authorization: OAuth oauth_token="1%2Fab3cd9j4ks73hf7g", oauth_signature_method="RSA-SHA1", oauth_signature="wOJIO9ADvZbTSMK%2FPY%3D", oauth_consumer_key="example.com", oauth_timestamp="137131200", oauth_nonce="4572616e48616d65724c61686176", oauth_version="1.0"

Key Value

Page 23: App Inventor Development

Itty Bitty Details (With HUGE Consequences)

•  Each request sent to the service provider must be signed with HMAC-SHA1 encryption.

•  In Android < 2.2, HttpURLConnection sets request headers to lower case.

•  Formatting a multipart post body message.

Page 24: App Inventor Development

POST /services/upload/ HTTP/1.1 Content-Type: multipart/form-data; boundary=---------------------------7d44e178b0434 Host: api.flickr.com Content-Length: 35261 -----------------------------7d44e178b0434 Content-Disposition: form-data; name="api_key" 3632623532453245 -----------------------------7d44e178b0434 Content-Disposition: form-data; name="auth_token" 436436545 -----------------------------7d44e178b0434 Content-Disposition: form-data; name="api_sig" 43732850932746573245 -----------------------------7d44e178b0434 Content-Disposition: form-data; name="photo"; filename="C:\test.jpg" Content-Type: image/jpeg {RAW JFIF DATA} -----------------------------7d44e178b0434--

Page 25: App Inventor Development

OAuth 2.0

Page 26: App Inventor Development

StoryBook App (Consumer)

Picasa via Google (Service Provider) User

Direct user to login and authorization pages

Redirect to app with

token

User grants access to app

Page 27: App Inventor Development
Page 28: App Inventor Development

10 weeks for this:

Page 29: App Inventor Development

What's Next?

•  Finish up the PostPicture block for Flickr, Picasa, Facebook, and Imgur.

•  Write documentation on how to use the block.

•  OAuth Component

Page 30: App Inventor Development

Our Presentation

•  Introduction to App Inventor • Posting Pictures (OAuth)- Emily • Blocks to Text- Erin •  Text to Blocks- Karishma • Data Mining- Johanna

Page 31: App Inventor Development

Blocks Text

Erin Davis

Page 32: App Inventor Development

Motivation

•  Blocks-based programming is fun and easy, but as programs get larger...

Page 33: App Inventor Development
Page 34: App Inventor Development

Sample blocks from Sonali Sastry's Tanner Connect Project for CS 117

Page 35: App Inventor Development

Who wants to read this?? -Sonali -Her partner -Her teacher -Other people who want to recreate her code

Page 36: App Inventor Development

height = 45 when Button1.Click():

Screen1.BackgroundColor = color.red when Screen1.Initialize():

Screen1.BackgroundColor = color.blue fun average(x, y)=

(x+y)/2

Our Solution

TEXT

more concise searchable

Page 37: App Inventor Development

What should Our Text Language Be?

express all of the functionality of AppInventor

Python-esque syntax -originally proposed by Philip Guo at MIT -fewer syntactic markers -indentation used

could be the first of many textual representations of App Inventor

height = 45 when Button1.Click():

Screen1.BackgroundColor = color.red when Screen1.Initialize():

Screen1.BackgroundColor = color.blue fun average(x, y)=

(x+y)/2

Venthon App Inventor + Python

Page 38: App Inventor Development

Expressiveness

Usa

bilit

y

Raw Android

Java Bridge

App Inventor

App Inventor plus Venthon

Android Application Creation Languages

Page 39: App Inventor Development

From Blocks to Text

height = 45 when Button1.Click():

Screen1.BackgroundColor = color.red when Screen1.Initialize():

Screen1.BackgroundColor = color.blue fun average(x, y)=

(x+y)/2

Blocks

Java Tree Object

Venthon

[{genus: componentSetter name: "Screen1.BackgroundColor" sockets:

[{genus: color-red name: "color.red"

sockets: []}]}, {genus: componentSetter name: Button1.Height sockets:

[{genus: number-plus name: "+" sockets: [{genus: number name: 45 sockets: []}, {genus: componentGetter name: Button1.Height sockets: []}]]}]

JAIL JSON App Inventor Language

Page 40: App Inventor Development

genus: componentSetter name: Screen1.BackgroundColor nodes: next:

genus: color-red name: red nodes: null next: null

genus: componentSetter name: Button1.Height nodes: next: null

genus: number-plus name: + nodes: next: null

genus: number name: 45 nodes: null next: null

genus: componentGetter name: Button1.Height nodes: null next: null ,

Page 41: App Inventor Development

JAIL JSON App Inventor Language [{genus: componentSetter name: "Screen1.BackgroundColor" sockets:

[{genus: color-red, name: "color.red", sockets: []}]},

{genus: componentSetter name: Button1.Height sockets:

[{genus: number-plus name: "+" sockets: [{genus: number name: 45 sockets: []},

{genus: componentGetter name: Button1.Height sockets: []}]]}]

Page 42: App Inventor Development

Venthon

Screen1.BackgroundColor = color.red Button1.Height = 45 + Button1.Height

Page 43: App Inventor Development

height = 45 when Button1.Click():

Screen1.BackgroundColor = color.red when Screen1.Initialize():

Screen1.BackgroundColor = color.blue fun average(x, y) =

(x + y)/2

A Small Program

Variable Declaration

Event Handlers

Procedure Declaration

Page 44: App Inventor Development

Comments

•  Each block could have a comment on it, nestable block comments.

•  We decided to mark comments by <| This is a comment. |>

•  This could come on the line before a statement block:

<| This will set the screen to red |> Screen1.BackgroundColor = color.red •  Or right after an expression block: Button1.Height = (45 + Button1.Height) <| Adding 45 to

the current height |>

Page 45: App Inventor Development

Back to Sonali's Program

Page 46: App Inventor Development

Future Steps

•  Adding component information •  Going straight to JAIL instead of

through the Java Tree Object

Page 47: App Inventor Development

Our Presentation

•  Introduction to App Inventor • Posting Pictures (OAuth)- Emily • Blocks to Text- Erin •  Text to Blocks- Karishma • Data Mining- Johanna

Page 48: App Inventor Development

Text Karishma Chadha

Blocks

Page 49: App Inventor Development

fun quadFormula(a, b, c) = (-b + sqrt (b ** 2 - 4 * a * c)) / (2*a)

Here's the situation...

Page 50: App Inventor Development
Page 51: App Inventor Development

{ "expression": { "operand 1": { "name": "12", "genus": "number" }, "operand 2": { "exponent": { "name": "4", "genus": "number" }, "base": { "name": "3", "genus": "number" }, "genus": "number-expt" }, "genus": "number-plus" }

Parsing

Lexing 12 + 3 ** 4

12 + 3 4**

12

+

4

**

3

JAIL

Page 52: App Inventor Development

ANTLR: Another Tool for Language Recognition

Page 53: App Inventor Development

Lexing with ANTLR

Page 54: App Inventor Development

Lexing: Text to Tokens height = 45 when Button1.Click():

Screen1.BackgroundColor = color.red when Screen1.Initialize():

Screen1.BackgroundColor = color.blue fun average(x, y)=

(x+y)/2

height = 45 NEWLINE when Button1 . Click ( )

INDENT : Screen1 . BackgroundColor = color NEWLINE

DEDENT red . NEWLINE NEWLINE when Screen1 .

Initialize ( ) : INDENT Screen1 . NEWLINE

BackgroundColor = blue color . DEDENT NEWLINE

fun average NEWLINE ( ) x , y = INDENT NEWLINE

( ) x + y / 2 NEWLINE DEDENT

Page 55: App Inventor Development

Parsing with ANTLR

Page 56: App Inventor Development

Parser: Tokens to Trees

Page 57: App Inventor Development

Generating JAIL with ANTLR

Page 58: App Inventor Development

Trees to JAIL { "globals": [

{ "expression": { "name": "45", "genus": "number" }, "name": "height", "genus": "global_setter" } ], "eventHandlers": [ { "component": "Button1", "event": "Click", "statements": [ { "expression": { "component": "color", "property": "red" }, "component": "Screen1", "property": "BackgroundColor", "genus": "setter" } ], "parameters": [] }, }

Page 59: App Inventor Development

Missing Step

height = 45 when Button1.Click():

Screen1.BackgroundColor = color.red when Screen1.Initialize():

Screen1.BackgroundColor = color.blue fun average(x, y)=

(x+y)/2

Blocks

Java Tree Object

Venthon

[{genus: componentSetter name: "Screen1.BackgroundColor" sockets:

[{genus: color-red name: "color.red"

sockets: []}]}, {genus: componentSetter name: Button1.Height sockets:

[{genus: number-plus name: "+" sockets: [{genus: number name: 45 sockets: []}, {genus: componentGetter name: Button1.Height sockets: []}]]}]

JAIL

Page 60: App Inventor Development

For the Future

• Converting JAIL to Blocks • Add another language o  App Inventor + Java = Venti

• App Inventor is changing o  We need to adapt to those changes

Page 61: App Inventor Development

Our Presentation

•  Introduction to App Inventor • Posting Pictures (OAuth)- Emily • Blocks to Text- Erin •  Text to Blocks- Karishma • Data Mining- Johanna

Page 62: App Inventor Development

Data Mining and Visualization Johanna's project

Page 63: App Inventor Development

App Inventor developers

Teachers Other AI users

Page 64: App Inventor Development

Jeff Schiller

Page 65: App Inventor Development

link Information to gather

Page 66: App Inventor Development

Multiple versions of an application running simultaneously share a datastore

Version 1: App Inventor

Version 2: Data collecting files

Application: app-inventor-stats

cs.wellesley.edu

Page 67: App Inventor Development

Gql query

Page 68: App Inventor Development

The future

•  Process all App Inventor files •  Allow everyone to view stats •  Instrument App Inventor so we can track the

trajectory of each project •  Allow teachers to track students' progress •  Collect demographic data •  Privacy issues

Page 69: App Inventor Development

•  Provost's Office - Faculty Research Fund for Science & Math (IBM) Brachman Hoffman Fund Faculty Small Grants

Summer Research Awards for providing funding for these projects •  Lyn Turbak for supervising

Stay tuned to www.tinkerblocks.org for updates on our projects!

Special Thanks

Page 70: App Inventor Development

Questions?