Skip to content

Commit

Permalink
Initial FileUploader extension commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jcarty committed Sep 26, 2011
1 parent f830d31 commit 7f26e42
Show file tree
Hide file tree
Showing 6 changed files with 615 additions and 0 deletions.
87 changes: 87 additions & 0 deletions Smartphone/FileUploader/README.md
@@ -0,0 +1,87 @@
# Spinner Control
The spinner control will allow you to have a more usable interface when interacting
with <select> elements on a BlackBerry 5.0 browser. It will also allow you to keep
the same consistent feel with your UI on a BlackBerry 6.0 browser.

**Author:** [Jerome Carty](https://github.com/jcarty)

## Tested On

* BlackBerry Bold 9900 v7.0.0.353
* BlackBerry Bold 9650 v6.0.0.546
* BlackBerry Curve 9300 v5.0.0.716

**Requires BlackBerry WebWorks SDK for Smartphones v2.0 or higher**

Have a problem with this extension? [Log an Issue](https://github.com/blackberry/WebWorks-Community-APIs/issues) or contact the [Author](https://github.com/jcarty)

## How To Configure The Extension For Use

1. Locate your BlackBerry WebWorks SDK for Smartphone extensions directory using your File Explorer. Default path is _**C:\Program Files\Research In Motion\BlackBerry WebWorks Packager\ext**_

2. Create a new _**blackberry.ui.Spinner**_ directory in the _**ext**_ directory

3. Download the source from this repository and unzip it to a location on your computer

4. Using File Explorer browse to this extension's downloaded source code _**Smartphone\FileUploader**_

5. Copy the _**library.xml**_ file from the downloaded _**Smartphone\FileUploader**_ directory to your new _**ext\webworks.io.FileUploader**_ directory

6. Copy the downloaded _**Smartphone\FileUploader\src\blackberry**_ directory to your new _**ext\webworks.io.FileUploader\webworks**_ directory

**NOTE:** Be sure to back-up this _**ext\webworks.io.FileUploader**_ directory in your WebWorks SDK extensions directory before performing a WebWorks SDK upgrade. Simply copy it back into the _**ext**_ directory after you have completed your SDK upgrade.

## Required Feature ID
Whenever you use the below feature id in any of your WebWorks applications this extension will be loaded for use.

<feature id="webworks.io.FileUploader" />

## Summary


## Code Example

function foo()
{
var rowHeight;
var visibleRows;

// Populate our items
var items = new Array('Barcelona', 'Beijing', 'Brasilia', 'Melbourne', 'Moscow', 'New York', 'Paris' );

// Figure out our height and rows based on screen size
if (screen.height < 480){
rowHeight = 60;
visibleRows = 3;
}
else {
rowHeight = 75;
visibleRows = 4;
}

// Configure the options
var options = {'title': 'Choose A City:',
'rowHeight': rowHeight,
'visibleRows': visibleRows,
'selectedIndex': 2,
'items' : items};

// Open the spin dialog
blackberry.ui.Spinner.open(options, function (selectedIndex) {
alert(selectedIndex); }
);
}

## Usage Information


_**NOTE:**_ The callback is handled asynchronously, so code that is placed directly after
the "open" function call will be executed immediately while waiting for the user's
response input.

## Properties
**items:**
Is an array of string items you wish to display in the spinner control

## Change Log
_Empty_
23 changes: 23 additions & 0 deletions Smartphone/FileUploader/src/library.xml
@@ -0,0 +1,23 @@
<library isWhitelist="true">

This comment has been minimized.

Copy link
@ababut

ababut Oct 4, 2011

isWhitelist=true is no longer being used, please remove it.


<extension id="webworks.io.FileUploader">
<entryClass>webworks.io.FileUploaderExtension</entryClass>
</extension>

<platforms>
<platform value="JAVA">
<target version="default" config="JAVA" />
</platform>
</platforms>

<configurations>
<configuration name="JAVA">
<src type="text/java" path="webworks" comment="API implementation in Java" />
</configuration>
</configurations>

<features>
<feature id="webworks.io.FileUploader" version="1.0.0.0">Upload files to a remote server</feature>
</features>

</library>
36 changes: 36 additions & 0 deletions Smartphone/FileUploader/src/webworks/io/FileUploaderExtension.java
@@ -0,0 +1,36 @@
package webworks.io;

import org.w3c.dom.Document;

import net.rim.device.api.browser.field2.BrowserField;
import net.rim.device.api.script.ScriptEngine;
import net.rim.device.api.web.WidgetConfig;
import net.rim.device.api.web.WidgetExtension;

/**
*
* @author Jerome Carty
*
*/
public class FileUploaderExtension implements WidgetExtension {

public String[] getFeatureList() {
return new String[] { FileUploaderNamespace.NAME };
}

public void loadFeature(String feature, String version, Document doc,
ScriptEngine scriptEngine) throws Exception {

if (feature.equals(FileUploaderNamespace.NAME)) {
Logger.enableLogging(0xe995515474f898fbL, "webworks.io.FileUploader");
scriptEngine.addExtension(feature, new FileUploaderNamespace());
}
}

public void register(WidgetConfig arg0, BrowserField arg1) {
}

public void unloadFeatures(Document arg0) {
}

}
24 changes: 24 additions & 0 deletions Smartphone/FileUploader/src/webworks/io/FileUploaderNamespace.java
@@ -0,0 +1,24 @@
package webworks.io;

import net.rim.device.api.script.Scriptable;

public class FileUploaderNamespace extends Scriptable {

public static final String NAME = "webworks.io.FileUploader";

private static final String FIELD_UPLOAD = FunctionUpload.NAME;

private FunctionUpload _uploadFunction;

public FileUploaderNamespace() {
_uploadFunction = new FunctionUpload();
}

public Object getField(String name) throws Exception {
if (name.equals(FIELD_UPLOAD)) {
return _uploadFunction;
}
return super.getField(name);
}

}

2 comments on commit 7f26e42

@ababut
Copy link

@ababut ababut commented on 7f26e42 Oct 4, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jerome, this looks great! I made a few comments, but overall the extension is very clean. Let me know what you think.

@jcarty
Copy link
Owner Author

@jcarty jcarty commented on 7f26e42 Oct 4, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll get those changes made. Everything you suggested is either required or makes sense.

Please sign in to comment.