1 copyright © 2012, oracle and/or its affiliates. all rights reserved. · html5 & javascript...

28
Copyright © 2012, Oracle and/or its affiliates. All rights reserved. 1

Upload: others

Post on 15-Sep-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.1

Page 2: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.2

Integrating Device Services with ADF Mobile

Vincent Hu

Principal Sales Consultant

Page 3: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.3

Digital Convergence

Do you still personally carry around a separate one of these?

Page 4: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.4

The World has Converged on Smartphones

Operating system

Applications

Web access

QWERTY keyboard

Email (beyond messaging)

Integrated device features

But What Makes a Smartphone "Smart"?

Operating system

Applications

Web access

QWERTY keyboard

Email (beyond messaging)

Integrated device services

Page 5: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.5

Device

Services

ADF Mobile Architecture

Cordova

Device Native Container

Web

View

Server

HTML

ADF Mobile

AMX View

Java VM

Business

Logic

ADF Model

Server-Generated HTML

Mobile

Device

SOAP & REST Services

Local

HTML

HTML5 & JavaScript Presentation

Configuration Server

ADF Controller

Encrypted

SQLite DBA

pp

Co

nfig

Server

JD

BC

SQLite

APN/GCM Push Services

Pu

sh

Ha

nd

ler

Cre

de

ntia

l Ma

na

gem

en

t,

SS

O &

Ac

ce

ss

Co

ntro

l

Page 6: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.6

Apache Cordova

ADF Mobile utilizes Cordova to access the onboard devices services

Provides access to:

– Device Properties

– SMS and Email

– Contacts

– Camera and Photo Library

– Geolocation

Page 7: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.7

Overview Accessing Device Services

2. Implicit EL Objects 3. Java APIs1. Data Controls 4. JavaScript APIs

Page 8: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.8

Overview Accessing Device Services

Found in the Data Control Palette

Drag n drop services onto a page

Take the grunt work out of coding

calls to the API and constructing

the necessary screens

2. Implicit EL Objects 3. Java APIs1. Data Controls 4. JavaScript APIs

Page 9: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.9

Overview Accessing Device Services

Provide easy access to device

properties

Referenced via the UI components

Simply type or use the Expression

Builder

#{deviceScope.device.hasCamera}

2. Implicit EL Objects 3. Java APIs1. Data Controls 4. JavaScript APIs

Page 10: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.10

Overview Accessing Device Services

Provide programmers the flexibility of accessing device services

from Java with their own Java Beans

Easier to handle error conditions and process any outputs

2. Implicit EL Objects 3. Java APIs1. Data Controls 4. JavaScript APIs

01 DeviceManager dm = DeviceManagerFactory.getDeviceManager();

02 dm.sendEmail("11112222", "A test SMS");

Page 11: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.11

Page 12: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.12

Overview Accessing Device Services

For non AMX pages (local HTML or remote URL)

Add JavaScript library to the page

Gives direct access to services

2. Implicit EL Objects 3. Java APIs1. Data Controls 4. JavaScript APIs

01 adf.mf.api.sendEmail({to: "[email protected]",

02 cc: "[email protected]",

03 subject: "Test email",

04 body: "Test email message"});

Page 13: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.13

Accessing Device Properties

Service Data Control EL Access Programmatic

Device Properties Yes Yes

Send SMS Yes Yes

Send Email Yes Yes

Create Contact

Find Contacts

Update Contact

Remove Contact

Yes

Yes

Yes

Yes

Yes

Get Picture Yes Yes

Start Location

MonitorYes Yes

Page 14: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.14

PropertyStatic/Dyna

micEL Expression Sample Value Java API

device.name Static #{deviceScope.device.name} "Joe Smith's iPhone" DeviceManager.getName()

device.platform Static #{deviceScope.device.platform} "iPhone" DeviceManager.getPlatform()

device.version Static #{deviceScope.device.version} "4.3.2", "5.0.1" DeviceManager.getVersion()

device.os Static #{deviceScope.device.os} "iOS" DeviceManager.getOs()

device.model Static #{deviceScope.device.model} "i386", "iPhone3,1" DeviceManager.getModel()

device.phonegap Static #{deviceScope.device.phonegap} "1.0.0" DeviceManager.getPhonegap()

hardware.hasCamera Static #{deviceScope.hardware.hasCamera} true, false DeviceManager.hasCamera()

hardware.hasContacts Static #{deviceScope.hardware.hasContacts} true, false DeviceManager.hasContacts()

hardware.hasTouchScreen Static #{deviceScope.hardware.hasTouchScreen} true, false DeviceManager.hasTouchScreen()

Device Properties

Some examples:

See documentation for full list

Page 15: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.15

Working with Device Features – Java Code Samples

Page 16: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.16

01 public class MyBean {

02

03 // Called via a button

04 public void actionSendSms(ActionEvent event) {

05 DeviceManager device = DeviceManagerFactory.getDeviceManager();

06

07 boolean hasCamera = device.hasCamera();

08 }

Device Properties API Example

Page 17: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.17

01 public class MyBean {

02

03 // Called via a button

04 public void actionSendSms(ActionEvent event) {

05 DeviceManager device = DeviceManagerFactory.getDeviceManager();

06

07 String to = "11112222,33334444";

08 String body = "A test SMS";

09

10 device.sendSms(to, body);

11 }

12 }

Send SMS API Example

Page 18: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.18

01 public class MyBean {

02

03 // Called via a button

04 public void actionSendEmail(ActionEvent event) {

05 DeviceManager device = DeviceManagerFactory.getDeviceManager();

06

07 String to = "[email protected], [email protected]";

08 String cc = "[email protected]";

09 String subject = "A test email subject";

10 String body = "A test email body";

11

12 device.sendEmail(to, cc, subject, body, null, null, null);

13 }

14 }

Send Email API Example

Page 19: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.19

01 public class MyBean {

02

03 // Called via a button

04 public void actionGetPicture(ActionEvent event) {

05 DeviceManager device = DeviceManagerFactory.getDeviceManager();

06

07 String watchID = device.startUpdatingPosition(20000,

08 true, "MyGPSSubscriptionID",

09 new GeolocationCallback() {

10 public void locationUpdated(Location position) {

11 System.out.println("Location updated to: " + position);

12 }

13 });

14 device.clearWatchPosition(watchID);

15 }

16 }

Start Updating Position API Example

Page 20: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.20

01 public class oracle.adf.model.datacontrols.device.DeviceManager {

02

03 /** Provides access to the device's default camera application, which enables

04 * taking a picture or retrieving a previously-save image.

05 *

06 * @param quality – quality of save image. Range 0 to 100

07 * @param destinationType – Choose the format of the return value.

08 * - 0 – base64 encoded string – 1- URI to file:///

09 * @param sourceType - Where should the picture come from?

10 * - 0 – Library – 1 – Camera – 2 – Album

11 * @param allowEdit - Allow simple editing of image before selection

12 * @param encodingType - Encoding of saved imaged - 0 – JPG – 1 – PNG

13 * @param targetWidth - Width in pixels to scale image

14 * @param targetHeight - Height in pixels to scale image

15 * @returns - A String of either the base64 image or a file URK

16 */

17 public String getPicture(int quality, int destinationType, int sourceType,

18 boolean allowEdit, int encodingType,

19 int targetWidth, int targetHeight);

Get Picture API

Page 21: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.21

01 public class MyBean {

02

03 // Called via a button

04 public void actionGetPicture(ActionEvent event) {

05 DeviceManager device = DeviceManagerFactory.getDeviceManager();

06

07 String imageData =

08 device.getPicture(100,

09 DeviceManager.CAMERA_DESTINATIONTYPE_FILE_URL

10 DeviceManager.CAMERA_SOURCETYPE__PHOTOLIBRARY,

11 false,

12 DeviceManager.CAMERA_ENCODINGTYPE_JPEG,

13 0, 0);

14 }

Get Picture API Example

Page 22: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.22

Some Special Considerations

Page 23: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.23

Working with Contacts

Operations –

– Find Contacts

– Create Contact

– Update Contacts

– Remove Contact

Both update and remove operations use a Contact object as a

parameter

– retrieved from a findContact operation

ADF Mobile provides a contact related objects

Page 24: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.24

Working With The Camera

Pay attention to picture quality

– File size impacts memory/network traffic

To return picture to the page:

– Set destinationType to 1 (file name)

– Drop Return of getPicture as Output Text

– Drop Image component onto page

– Set source to return input value (#{bindings.Return.inputValue})

Page 25: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.25

Working with Location Services

Acquire the device's current position

One instant in time, or on a periodic basis

Uses the startLocationMonitor operation

Use a geo-decoder to get address from coordinates

Page 26: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.26

Summary

Simple device feature access

– Declarative

– Java or JavaScript API

Leverage Cordova infrastructure

Page 27: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.27

PRODUCT DEMONSTRATION

USING Device Features

Page 28: 1 Copyright © 2012, Oracle and/or its affiliates. All rights reserved. · HTML5 & JavaScript Presentation Configuration Server ADF Controller Encrypted SQLite DB p g Server C SQLite

Copyright © 2012, Oracle and/or its affiliates. All rights reserved.28