Showing posts with label iPhone. Show all posts
Showing posts with label iPhone. Show all posts

Friday, January 11, 2013

ADF Mobile - Device Native Database Access and Usage

This will be a third update for my sample ADF Mobile application. Read about previous versions from here - ADF Mobile - Geo Location Synchronization. This update is focused primarily on device native database access and operations. I'm using located GPS points as data source and populating on device SQL Lite database with locations retrieved from GPS. Logged data review functionality is implemented as well - user can view altitude graph and load logged path as point layer on top of Google Maps.

Added features:

1. ADF Mobile Springboard support demonstrating multiple ADF Task Flow usage and access

2. ADF Mobile UI validation behavior and conditional logic

3. Device native database access and usage

4. Data visualization with ADF DVT components

5. Multi-point layer display on top of Google Maps

6. iPhone right/left swipe actions

Download sample application code - PosLogApp.zip. This sample contains two ADF Task Flows, both of them are loaded using ADF Mobile Springboard - Tracker (logs GPS positions) and Routes (logs and displays route data):


Same as in the previous version - Tracker logs current GPS position. Once Tracker is activated it will log GPS position change continuously until it will be stopped by the user:


In the same ADF Task Flow - Tracker, we can view current GPS position on the Google Maps:


Second ADF Task Flow - Routes allows to enter new route name and date (current date by default). When Start is activated - it will log each GPS position received from the Tracker into native device database until user will stop route logging:


From this screen user have option to view a list of previously recorded routes - Show button:


List is clickable - user can click on the selected route to view information about it. Information about logged GPS position for the selected route is retrieved from database - in the first screen we can see number of GPS positions logged. 1033 positions were logged for this route (maximum is set to be 10000):


We can view logged altitude information for the route - I was driving uphill and then downhill:


Route path itself can be visualized on top of Google Maps from logged GPS points:


If you want to delete logged route, simply swipe to the right and press Delete button:


You want to know about implementation details? All right - here is ADF Task Flow view for the router part:


Page with route name and date is default, next we can view route list and remove routes with refresh through the method call. We can view details - number of logged GPS points, altitude graph and route path constructed from logged GPS points.

Here is the database structure, two tables simple master/detail - ROUTES and POINTS. This script is executed during initial application activation on the device. Basically it creates *.db file with SQL Lite database on the device:


SQL file must be loaded programmatically, from custom lifecycle listener class. We must define this class in adfmf-application.xml file:


Application lifecycle method - start(), will be executed automatically and it will load database structure initially:


Connection to the database is constructed by retrieving reference to the SQL Lite database file on device:


Here you can see code to insert information about new route - regular SQL syntax and PreparedStatement:


This code snipped shows retrieval of GPS logged positions and constructing array of such points (later displayed in altitude graph and path on top of Google Maps):


In order to be able to load Google Maps in ADF Mobile, you must set Google Maps key in adf-config.xml file. Sample application is provided with dummy key, you must set your own:


Xcode Organizer tool displays installed applications on iPhone, I can see database file for my application. Organizer gives option to download application contents together with database file:


We can extract downloaded archive and access database file:


Performance of device native database is pretty good, I recorded around 10000 GPS location points in total - browsing through this dataset and loading is smooth:


Tuesday, December 18, 2012

ADF Mobile - Geo Location Synchronization

Here you can read about ADF Mobile application enabled with geo location features - GPS and Google Maps - ADF Mobile - Geo Location and Google Maps App. I would like to post update for this application where geo location is synchronized automatically, directly updating your position on Google Maps screen. Few minor usability updates are included as well - conditional check for 3G/Wi-Fi network and GPS availability.

Download version 2 for ADF Mobile Geo Location and Google Maps application - ADFMobileGoogleMaps_v2.zip. This update contains code to check if 3G/Wi-Fi and GPS functionality is available - displayed on UI:


Show button is enabled only if 3G/Wi-Fi connection is available, otherwise Google Maps are unaccessible. Start button is enabled only if GPS is available - location will be calculated only with active GPS signal.

Initial position is retrieved from GPS, this position is displayed on the map:


You don't need to switch back and request position correction - keep Google Maps window open, when GPS data will be recalculated - position will be refreshed and displayed automatically:


Go back to initial position screen, you can review synchronized location coordinates there:


3G/Wi-Fi network status is retrieved from ADF Mobile API directly - deviceScope.hardware.networkStatus:


Similar for GPS signal status - deviceScope.hardware.hasGeolocation:


GPS position synchronization is quite straightforward - method from pageFlowScope bean updates center coordinates:


Property Change Support listener is responsible to push data changes to the UI:


Point location layer from ADF Mobile maps component is mapped directly with pageFlowScope bean coordinates data - this allows to reload location point, when location coordinares are changing:


Tuesday, December 11, 2012

ADF Mobile - Geo Location and Google Maps App

Let me describe ADF Mobile application with Google Maps and GPS support. I have implemented this application in few hours, installed on my iPhone and ready to travel - I will not be lost. So, I would like to share source code with you - you can compile and install it on iPhone, iPad or Android.

Main features currently available:

1. Google Maps embedded using ADF Mobile Geographical Map component (8.5.14 How to Create a Geographic Map Component)

2. GPS location update (9.5.8 How to Use the startLocationMonitor Method)

3. GPS location point display

If I will have time, I plan to implement dynamic GPS location point moving on the map as you go and synchronization with on device database. You can download source code for the current version from here - ADFMobileGoogleMaps.zip.

Here is the home screen - Google Maps. Screenshots are taken directly from my iPhone:


User have two options - Reset and Position. I have noticed that sometimes, especially when network connectivity is lost - ADF Mobile application with Maps component may get unresponsive. This is the reason for Reset button - it performs logout and resets application state. Position - it flips Maps display and open GPS control view:


In this screen you can press Start and synchronize Latitude/Longitude for your current position from GPS satellite. Synchronization may take a bit of time, while it becomes accurate - this is the reason for Stop button (to stop synchronization period):


Once position is located, press Back and Google Maps will flip back with a zoom into your position displayed on the map (my real location is displayed here :):


I will walk you know through the technical things. This application contains ADF Task Flow and navigation between Google Maps page and GPS control:


The way how pages are opened on the device (slide, flip) is control by ADF Task Flow navigation case. I have set page transition behavior to be flipLeft:


Google Maps embedded using ADF Mobile Geographical Map component. It sets various properties, such as center, map type, zoom level. ADF Mobile Geographical Map is able to render data layers on top:


My application, renders single point - current position. Position is retrieved from custom bean Data Control (I have defined it myself):


Drag and drop this Data Control on top of ADF Mobile Geographic Map component, JDeveloper generates point data layer automatically from the wizard:


There is getPositions() method responsible to get data about retrieved position (initialized from custom GoogleMapsBean):


GPS action is triggered on the device and data is retrieved using built in ADF Mobile Data Control - Device Features. There is designated method available - startLocationMonitor(boolean, int, String):


GPS method is invoked from the Start button:


One of the parameters - locationListener, it points to the custom listener method. Listener is invoked each time, when GPS position synchronization happens (there is no need to use EL brackets) - method name is static text:


When position is retrieved from GPS and synchronization is stopped - custom Position bean is updated with X/Y:


There is one interesting specific thing related to ADF Mobile - value refresh on the UI. If value is changed in the background, we want to display new value on the UI (but there are no Auto Submit and Partial Triggers in ADF Mobile). Updated value is refreshed on UI using property change support listener invocation from the setter:


Property change support listener declaration:


Tuesday, December 4, 2012

ADF Mobile - Implementing Reusable Mobile Architecture

Reusability was always a strong part of ADF. The same high reusability level is supported now in ADF Mobile also. I have a blog, where ADF reusability architecture is described through ADF Libraries and ADF Task Flows - Integration in Oracle ADF Through ADF Libraries and ADF Task Flows. This blog was posted in 2009, now this architecture approach became de facto standard and is applied in every ADF project. We go mobile and apply similar architecture pattern for reusability through ADF Mobile libraries (Feature Archive Files) and ADF Mobile Feature sets. You can read more about ADF Mobile Feature Archive Files here - 5.12 Working with Feature Archive Files. Main goal of this post is to prove technically that reusable architecture concept works for ADF Mobile.

Here you can download a set of sample applications developed for this post - mobilereusable.zip. Sample use case is based on previous post - ADF Mobile - Secured Web Service Access, it contains one new application - ADFMobileEmplFar. This application implements reusable ADF Mobile artifact.

The main idea for ADF Mobile reusable architecture is to split one big block into smaller ones and allow to develop these smaller blocks separately:


To test ADF Mobile reusable functionality and Feature Archive File import into main ADF Mobile application, I decided to consume secured Web Service in my library application and import it into main ADF Mobile application. To make it more fancy, I have exposed VO through secured Web Service and implementing a list in my reusable mobile library:


VO is exposed through service interface:


Reusable mobile library contains mobile feature file, where mobile task flow is registered with employees list:


This feature is enabled with security, this will make sure it will be accessible only if user is authenticated into mobile application:


Reusable mobile library contains a list of employees, retrieved from secured Web Service:


This list is implemented using regular ADF approach - drag and drop Data Control element into ADF Mobile page:


Once we define secured Web Service connection and generated Data Control, reusable mobile library is updated with connection details for secured Web Service - connections.xml file:


You must copy connection details into main application connections.xml file manually, otherwise connection will fail.

Define ADF Mobile Feature Archive deployment profile and deploy your reusable mobile library:


Create file system connection in Resource Palette - you can browse through and see ADF Mobile features packaged into library:


Import library into main ADF Mobile application, same as you would import regular ADF library into regular ADF project and ADF Mobile feature becomes available in the main application context:


As I have said earlier - copy secured Web Service connection details into main application connections.xml file:


We are ready to test now - login into ADF Mobile application:


You can see two buttons - Home and Employees, these buttons represent ADF Mobile features we deliver with our application. Home is default feature and it loads first:


Click on Employees button - it will load feature included from reusable mobile library with Employees list: