/angular-android

Primary LanguageCSSGNU Lesser General Public License v2.1LGPL-2.1

Angular Android

This project is built as a proof of concept for the android application using html/css/javascript (angular] for UI logic. The overall application architecture follows the MVC paradigm. The application itself consists of a single Activity called MainActivity hosting a webView and a MVCControlllers class.

The UI part of the application is implemented as a self contained angular based single page application and is located in the ./Angular Android/src/main/assets/application subdirectory.

The code in the MainActivity provides hook up necessary to intercept the web api requests coming from the angular application and respond to them from the android application code. The most straight forward way to intercept http requests would be using [shouldInterceptRequest](http://developer.android.com/reference/android/webkit/WebViewClient.html#shouldInterceptRequest(android.webkit.WebView, java.lang.String)) method of the WebViewClient class. Unfortunately this method was only introduced in the API level 11.

So to support older devices (Android 2.3.*) Java object injection was chosen as the mechanism for the http interception. The actual interception is based on the angular dependency injection architecture and is done by injecting custom implementation of the $httpBackendProvider (see application.js).

The application provides examples of both pull requests (see web api implementation in the MVCControllers class) as well as push (see UpdateWatchThread internal class in the MainActivity)

To run the android application:

  1. Install Android Studio v0.5.*
  2. Make sure you have at least Android SDK Build Tools 19.0.1 installed. (otherwise update it via SDK Manager)
  3. Clone the project
  4. Import folder with project into Android Studio
  5. Run the project

To run the angular application directly:

  1. Install nodejs
  2. Install grunt cli npm install -g grunt-cli
  3. change directory to ./Angular Android/grunt
  4. Install necessary modules npm install
  5. Run the server grunt
  6. in your browser open the following URL: http://localhost:5001