Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
robotadam authored and Adam Lowry committed Oct 29, 2010
0 parents commit 15d149f
Show file tree
Hide file tree
Showing 23 changed files with 1,953 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .classpath
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="res"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/net.rim.ejde.BlackBerryVMInstallType/BlackBerry JRE 4.6.0"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
*swp
29 changes: 29 additions & 0 deletions .project
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>UrbanAirshipPushClient4X</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>net.rim.ejde.internal.builder.BlackBerryPreprocessBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.rim.ejde.internal.builder.BlackBerryResourcesBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>net.rim.ejde.BlackBerryPreProcessNature</nature>
<nature>net.rim.ejde.BlackBerryProjectCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
24 changes: 24 additions & 0 deletions BlackBerry_App_Descriptor.xml
@@ -0,0 +1,24 @@
<Properties ModelVersion="1.1.2">
<General Title="Urban Airship Push Client" Version="1.0.0" Vendor="Urban Airship" Description="Urban Airship Reference Client"/>
<Application Type="BlackBerry Application" MainMIDletName="" MainArgs="" HomeScreenPosition="0" StartupTier="7" IsSystemModule="false" IsAutostartup="false"/>
<Resources hasTitleResource="false" TitleResourceBundleName="" TitleResourceBundleRelativePath="" TitleResourceBundleClassName="" TitleResourceBundleKey="" DescriptionId="">
<Icons>
<Icon CanonicalFileName="res/img/uaicon.png" IsFocus="false"/>
</Icons>
</Resources>
<Compile OutputCompilerMessages="true" ConvertImages="true" CreateWarningForNoExportedRoutine="true" CompressResources="true" AliasList="">
<PreprocessorDefines/>
</Compile>
<Packaging OutputFileName="UrbanAirshipPushClient" OutputFolder="deliverables" PreBuildStep="" PostBuildStep="" CleanStep="" GenerateALXFile="true">
<AlxFiles/>
</Packaging>
<HiddenProperties>
<ClassProtection/>
<PackageProtection/>
</HiddenProperties>
<AlternateEntryPoints>
<AlternateEntryPoint Title="UrbanAirship_autostartup" MainMIDletName="" ArgumentsForMain="autostartup" HomeScreenPosition="0" StartupTier="7" IsSystemModule="true" IsAutostartup="true" hasTitleResource="false" TitleResourceBundleKey="" TitleResourceBundleName="" TitleResourceBundleClassName="" TitleResourceBundleRelativePath="">
<Icons/>
</AlternateEntryPoint>
</AlternateEntryPoints>
</Properties>
74 changes: 74 additions & 0 deletions README.rst
@@ -0,0 +1,74 @@
Urban Airship Push Client for BB OS 4.X
=======================================

Urban Airship Push Client for BB OS 4.X is a sample application designed to
quickly get you up and running with Urban Airship Push Notifications, and to
provide an example for how you might integrate push inside of your RIM
Blackberry OS 4.X application.

Requirements
------------

BlackBerry JDE 4.6+

Notable Components
------------------

Keys.java
The class where all of your application settings are stored. These include:

- Blackberry Application ID (obtained from RIM)
- Blackberry Push URL (Obtained from RIM); in development/evaluation mode
this is http://pushapi.eval.blackberry.com, in production it usually
http://pushapi.na.blackberry.com
- Blackberry Push Port (Obtained from RIM)
- Urban Airship Application Key (Obtained from http://go.urbanairship.com)
- Urban Airship Application Secret (Obtained from http://go.urbanairship.com)

PushConnector.java
The helper class that sets up listening to events and notifications in the
background.

UrbanAirshipAPI.java
The API class that handles communication between UA and your app.

- urbanAirshipRegisterPIN: registers your device PIN with Urban Airship for
notifications.
- urbanAirshipUnRegisterPIN: un-registers your device PIN with Urban
Airship, marking that the PIN should not receive any other notifications
until registered again.
- urbanAirshipRegisterPINWithAlias: allows you to register your device PIN
and associate an Alias with the device.

UrbanAirshipMain.java
The main application entry point. The application is designed to have an
alternate entry point for starting background listening for notifications on
device reset.

OKButton.java, TabletLayoutManager.java, UAHomeScreen.java, UrbanAirshipDialog.java, Util.java
Classes used for presenting UI for the sample app.

UrbanAirshipStore
Singleton class for providing persistent application storage, for keeping
track of whether push services are enabled or disabled for the device.

Usage
-----

- Import the project into Eclipse or your favorite IDE.
- Open the Keys.java file and enter your application's unique RIM / UA
information.
- Compile the app.
- Using the application dashboard at go.urbanairship.com, send test messages to
your application.


Integrating it into your application
------------------------------------

- Copy the Keys.java module to your app.
- Copy the UrbanAirshipAPI.java module to your app.
- Copy the Util.java module to your app.
- Copy the PushConnector.java module to your app.
- Follow the model of the code in UrbanAirshipMain for implementing
GlobalEventListener.
13 changes: 13 additions & 0 deletions com/urbanairship/pushclient/Keys.java
@@ -0,0 +1,13 @@
package com.urbanairship.pushclient;

public class Keys {
// Blackberry Push Settings. Please enter your information here.
public static final String BLACKBERRY_PUSH_APPLICATION_ID = //"your blackberry application id goes here";
public static final String BLACKBERRY_PUSH_URL = //"http://pushapi.eval.blackberry.com";
public static final int BLACKBERRY_PUSH_PORT = //port, as an integer;

// Urban Airship Push Settings for your application. From the Details tab
// for your application @ http://go.urbanairship.com
public static final String URBAN_AIRSHIP_APPID = //"your urban airship app id goes here";
public static final String URBAN_AIRSHIP_APPSECRET = //"your urban airship app secret goes here";
}
117 changes: 117 additions & 0 deletions com/urbanairship/pushclient/OKButton.java
@@ -0,0 +1,117 @@
/**
* PictureBackgroundButtonField.java
*
* Copyright © 1998-2009 Research In Motion Ltd.
*
* Note: For the sake of simplicity, this sample application may not leverage
* resource bundles and resource strings. However, it is STRONGLY recommended
* that application developers make use of the localization features available
* within the BlackBerry development platform to ensure a seamless application
* experience across a variety of languages and geographies. For more information
* on localizing your application, please refer to the BlackBerry Java Development
* Environment Development Guide associated with this release.
*/

package com.urbanairship.pushclient;

import net.rim.device.api.ui.*;
import net.rim.device.api.system.*;

/**
* Custom button field that shows how to use images as button backgrounds.
*/
public class OKButton extends Field
{
private Bitmap _currentPicture;
private Bitmap _onPicture = Bitmap.getBitmapResource("btn_ok_alt.png");
private Bitmap _offPicture = Bitmap.getBitmapResource("btn_ok.png");

/**
* Constructor.
* @param text The text to be displayed on the button
* @param style Combination of field style bits to specify display attributes
*/
public OKButton(long style)
{
super(style);
_currentPicture = _offPicture;
}

/**
* Field implementation.
* @see net.rim.device.api.ui.Field#getPreferredHeight()
*/
public int getPreferredHeight()
{
return _onPicture.getHeight() + 5;
}

/**
* Field implementation.
* @see net.rim.device.api.ui.Field#getPreferredWidth()
*/
public int getPreferredWidth()
{
return _onPicture.getWidth();
}

/**
* Field implementation. Changes the picture when focus is gained.
* @see net.rim.device.api.ui.Field#onFocus(int)
*/
protected void onFocus(int direction)
{
_currentPicture = _onPicture;
invalidate();
}

/**
* Field implementation. Changes picture back when focus is lost.
* @see net.rim.device.api.ui.Field#onUnfocus()
*/
protected void onUnfocus()
{
_currentPicture = _offPicture;
invalidate();
}

/**
* Field implementation.
* @see net.rim.device.api.ui.Field#drawFocus(Graphics, boolean)
*/
protected void drawFocus(Graphics graphics, boolean on)
{
// Do nothing
}

/**
* Field implementation.
* @see net.rim.device.api.ui.Field#layout(int, int)
*/
protected void layout(int width, int height)
{
setExtent(Math.min( width, getPreferredWidth()),
Math.min( height, getPreferredHeight()));
}

/**
* Field implementation.
* @see net.rim.device.api.ui.Field#paint(Graphics)
*/
protected void paint(Graphics graphics)
{
graphics.drawBitmap(0, 5, getWidth(), getHeight(), _currentPicture, 0, 0);
}

/**
* Overridden so that the Event Dispatch thread can catch this event
* instead of having it be caught here..
* @see net.rim.device.api.ui.Field#navigationClick(int, int)
*/
protected boolean navigationClick(int status, int time)
{
fieldChangeNotify(1);
return true;
}

}

0 comments on commit 15d149f

Please sign in to comment.