strongloop/loopback-android — pull request #19 by bajtos (2013-12-18 19:21:15+00:00)
Title: Simplify registration of Android Installations

The biggest complexity of GCM Android app lies in the prevention of multiple registrations. If our client SDK already had sync/offline capability, the implementation would be much easier.

The solution presented in this pull request has two important properties:
- it hides the complexity of dealing with SharedPreferences and decided when/what to re-register
- provides an API that should allow us to swap its implementation with something easier once we have sync/offline capability

### List of changes

#### Remove `Installation` & `InstallationRepository`

These classes should mirror the remotable methods available on server models (they would be auto-generated in an ideal world). It is difficult to use them effectively in the registration workflow.

An example: for the registration workflow, `getDeviceType` should be a read-only property with a constant value `android`. For `Installation` model as returned by `findAll`, the property must support all different device types including `ios`.

#### Introduce a new class `LocalInstallation`

The class provides everything to help LB applications with registering the Installation on the server.

Note that I am intentionally keeping the code with no references to GCM/Google Play Services library, because setting up an Eclipse project with Play Services is cumbersome and I don't want to impose that on all users starting with our SDK.

#### Improve unit tests

`LocalInstallation` tests use a mocked context now, which allows to supply custom version numbers and test things like auto-detected `appVersion`.

/to: @raymondfeng @Schoonology please review. The sample usage can be seen in javadoc comment, I'll submit a pull request with a full Android example client soon.