My R&D World

All Things R&D

GSoC 2012 Weekly Report on OI WebIntents Agent (Aug 14-Aug 20)

Hi there,

This is the last report for GSoC 2012.

Overview

Now OI WebIntents can do three major tasks as specified in the application proposal:

  1. Invoke both Web applications and Android Applications from a Web page
  2. Invoke both Web applications and Android Applications from an external Android application
  3. Web application management

Device Models

Now OI WebIntents can work well on both handsets and tablets with different screen design.

User Guidelines

Another blog post describe the user guidelines to use OI WebIntents Agent with screenshots.

Data Structure and Class Implementation

1. Main activities

There are two activity classes which are important for this part:

  • WebIntentsAgentActivity
  • WebAppManagementActivity

WebIntentsAgentActivity is the main activity for this application and launched when the app takes off.  It creates the navigation menu items and if necessary starts off the WebAppManagementActivity for Web application management.

2. Data Storage and Content Provider

Two classes are important for this part:

  • WebIntentsDatabase
  • WebIntentsProvider

Each database table is represented by an internal class of WebIntentsProvider with its column fields and  CONTENT_URI. For example, the database table ‘web_intents’ is represented by WebIntentsProvider.WebIntents.

3. Web page parsing, revising and loading

CustomWebView is a customized subclass of WebView for parsing, revising and loading a Web page. Its loadUrl() method has been overwritten to inject Javascript code for Web Intents support before loading a Web page. Generally, a Web page consists of a main frame and several sub frames or iframes.  Since the loading of iframes is counted as resources loading in Android Webkit, sub pages parsing and Javscript injection for them is placed in the shouldInterceptRequest() method of WebViewClient. The procedures are similar, using Jsoup to parse pages and inject Javascript support for Web Intents.

In the other hand, the native Java Code support for the injected Javascript code is implemented by an internal class of WebIntentsAgentActivity, i.e. WebIntentsAgentActivity.Navigator. It implements the interfaces which are used in the injected Javascript code.

4. Web application Registration

Since most available Web applications for Web Intents are implemented as Chrome Extensions. I modified four sample applications and included them in this application. They are:

  • Web Intents Debugger
  • Share Link to Twitter
  • Shorten with Goo.gl
  • Chromerly URL-shortener

As a result, a procedure (FileReaderThread) for registering and loading local applications was also developed. However, this application also support online app registration. webintents.org now supports some online applications. Our project is applicable for the following online application:

They can be discovered by browsing the following Web pages:

5. Web application management

The following classes are important for this part:

  • WebAppManagementActivity
  • WebAppListFragment
  • WebIntentsByAppListFragment
  • WebIntentsByAppActivity

WebAppListFragment is for displaying a list of Web application and WebIntentsByAppListFragment shows web intents for a specific web application. For a tablet, both WebAppListFragment and WebIntentsByAppListFragment will be added into  WebAppManagementActivity. However, for a handset, WebAppListFragment is contained in WebAppManagementActivity while WebIntentsByAppListFragment is loaded into WebIntentsByAppActivity. The purpose is for supporting multiple screens.

6. Invoke Web applications from external Android apps

A helper class named WebIntentsHelper is for this requirement. Any external Android application can invoke Web applications by the following step:

Install OI WebIntents Agent -> Import webintents-helper.jar into libs -> Create a application chooser by invoke WebIntentsHelper.createChooserWithWebActivities()

This method will create a chooser dialog in the context of the calling application now.

Use Cases

It is a pity that OI WenIntents now only support the http://webintents.org/share and http://webintents.org/shorten action. More action supports will be added in the future.

Failure method to report

We was trying to use Javascript and it events to support Web Intents directly. However, it seems not to work on Android. The Javascript event DOMContentLoaded or load can not be triggered in time in our early experiments and this cost us some time. The feature of slow network connection of mobile devices dooms direction of Javascript support on Android.

Cheers

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: