Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

Ignore the target directory for build artifacts #105

Open
wants to merge 6 commits into
base: next
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ public Object execute( Object thiz, Object[] args ) throws Exception {
ScriptableFunction callback = (ScriptableFunction) args[ 1 ];

// create dialog
Runnable dr = DialogRunnableFactory.getColorPickerRunnable( initialColor, callback, thiz );
Runnable dr = DialogRunnableFactory.getColorPickerRunnable( initialColor, callback );

// queue
UiApplication.getUiApplication().invokeLater( dr );
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright 2010-2011 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package blackberry.ui.dialog;

import net.rim.device.api.script.Scriptable;
import net.rim.device.api.script.ScriptableFunction;
import net.rim.device.api.ui.UiApplication;
import blackberry.core.FunctionSignature;
import blackberry.core.ScriptableFunctionBase;

/**
* Implementation of asynchronous custom ask function (blackberry.ui.dialog.customAskAsync)
*
* @author dmateescu
*
*/
public class CustomAskAsyncFunction extends ScriptableFunctionBase {

public static final String NAME = "customAskAsync";

/**
* @see blackberry.core.ScriptableFunctionBase#execute(Object, Object[])
*/
public Object execute( Object thiz, Object[] args ) throws Exception {
String message;
String[] buttons;
// the default value of the default choice. The developer cannot change it.
final int defaultChoice = 0;
// callback function
ScriptableFunction callback = (ScriptableFunction) args[ 2 ];
// the default value of the global status. The developer cannot change it.
final boolean global = false;
// message
message = (String) args[ 0 ];
// choices & values
Scriptable stringArray = (Scriptable) args[ 1 ];
int count = stringArray.getElementCount();
buttons = new String[ count ];
for( int i = 0; i < count; i++ ) {
buttons[ i ] = stringArray.getElement( i ).toString();
}

Runnable dr = DialogRunnableFactory.getCustomAskRunnable( message, buttons, defaultChoice, global, callback );
// queue
UiApplication.getUiApplication().invokeLater( dr );
// return value
return Scriptable.UNDEFINED;
}


/**
* @see blackberry.core.ScriptableFunctionBase#getFunctionSignatures()
*/
protected FunctionSignature[] getFunctionSignatures() {
FunctionSignature fs = new FunctionSignature( 3 );
// message
fs.addParam( String.class, true );
// choices
fs.addParam( Scriptable.class, true );
// callback
fs.addParam( ScriptableFunction.class, true );
// filler
fs.addParam( Object.class, false );
return new FunctionSignature[] { fs };
}
}
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ public Object execute(Object thiz, Object[] args) throws Exception {
String min = (String)options.getField("min");
String max = (String)options.getField("max");

Runnable dr = DialogRunnableFactory.getDateTimeRunnable(type, value, min, max, callback, thiz);
Runnable dr = DialogRunnableFactory.getDateTimeRunnable(type, value, min, max, callback);

// queue
UiApplication.getUiApplication().invokeLater(dr);
Original file line number Diff line number Diff line change
@@ -17,7 +17,6 @@

import java.util.Hashtable;

import net.rim.device.api.script.ScriptEngine;
import net.rim.device.api.script.Scriptable;
import net.rim.device.api.ui.component.Dialog;

@@ -52,7 +51,9 @@ public DialogNamespace() {
_fields = new Hashtable();

_fields.put( StandardAskFunction.NAME, new StandardAskFunction() );
_fields.put( StandardAskAsyncFunction.NAME, new StandardAskAsyncFunction());
_fields.put( CustomAskFunction.NAME, new CustomAskFunction() );
_fields.put(CustomAskAsyncFunction.NAME, new CustomAskAsyncFunction());
_fields.put( SelectAsyncFunction.NAME, new SelectAsyncFunction() );
_fields.put( DateTimeAsyncFunction.NAME, new DateTimeAsyncFunction() );
_fields.put( ColorPickerAsyncFunction.NAME, new ColorPickerAsyncFunction() );
119 changes: 103 additions & 16 deletions api/dialog/src/main/java/blackberry/ui/dialog/DialogRunnableFactory.java
Original file line number Diff line number Diff line change
@@ -18,37 +18,92 @@

import java.util.Vector;

import net.rim.device.api.system.DeviceInfo;
import net.rim.device.api.script.ScriptableFunction;
import net.rim.device.api.script.ScriptableImpl;

import net.rim.device.api.system.DeviceInfo;
import net.rim.device.api.ui.component.Dialog;
import blackberry.ui.dialog.color.ColorPickerDialog;
import blackberry.ui.dialog.datetime.DateTimeDialog;
import blackberry.ui.dialog.IWebWorksDialog;
import blackberry.ui.dialog.select.SelectDialog;
import blackberry.ui.dialog.color.ColorPickerDialog;

/**
* Factory class for running dialogs asynchronously
*
*/
public class DialogRunnableFactory {

public static Runnable getDateTimeRunnable( String type, String value, String min, String max, ScriptableFunction callback,
Object thiz ) {
/**
* Factory method for running an asynchronous DateTime dialog
* @param type the dialog's type
* @param value the value
* @param min the minimum value
* @param max the maximum value
* @param callback the callback function
* @return the Runnable responsible for opening the dialog
*/
public static Runnable getDateTimeRunnable( String type, String value, String min, String max, ScriptableFunction callback) {
IWebWorksDialog d = new DateTimeDialog( type, value, min, max );
return new DialogRunnable( d, callback, thiz );
return new DialogRunnable( d, callback );
}

public static Runnable getColorPickerRunnable( int initialColor, ScriptableFunction callback, Object thiz ) {
/**
* Factory method for running an asynchronous ColorPicker dialog
* @param initialColor the initial color
* @param callback the callback function
* @return the Runnable responsible for opening the dialog
*/
public static Runnable getColorPickerRunnable( int initialColor, ScriptableFunction callback ) {
ColorPickerDialog d = new ColorPickerDialog( initialColor );
return new DialogRunnable( d, callback, thiz );
return new DialogRunnable( d, callback );
}

public static Runnable getSelectRunnable(boolean allowMultiple, String[] labels, boolean[] enabled, boolean[] selected, int[] types, ScriptableFunction callback, Object thiz) {
/**
* Factory method for running an asynchronous Select dialog
* @param allowMultiple flag indicating whether multiple values are allowed
* @param labels the labels
* @param enabled the enabled values
* @param selected the selected values
* @param types the types of the values
* @param callback the callback function
* @return the Runnable responsible for opening the dialog
*/
public static Runnable getSelectRunnable(boolean allowMultiple, String[] labels, boolean[] enabled, boolean[] selected, int[] types, ScriptableFunction callback) {
IWebWorksDialog d = new SelectDialog(allowMultiple, labels, enabled, selected, types);
return new DialogRunnable(d, callback, thiz);
return new DialogRunnable(d, callback);
}

/**
* Factory method for running an asynchronous CustomAsk dialog
* @param message the message to be displayed in the dialog
* @param buttons the choices presented as buttons
* @param values the values of the choices
* @param defaultChoice the default choice
* @param global the global status
* @param callback the callback function
* @return the Runnable responsible for opening the dialog
*/
public static Runnable getCustomAskRunnable(String message, String[] buttons, int defaultChoice, boolean global /* style, false */, ScriptableFunction callback) {
Dialog d = new Dialog( message, buttons, null, defaultChoice, null /* bitmap */, global ? Dialog.GLOBAL_STATUS : 0 /* style */);
return new DialogAsyncRunnable( d, callback );
}

/**
* Factory method for running an asynchronous StandardAsk dialog
* @param message the message to be displayed in the dialog
* @param type the dialog's type
* @param defaultChoice
* @param global the global status
* @param callback the callback function
* @return the Runnable responsible for running the dialog
*/
public static Runnable getStandardAskRunnable(String message, int type, int defaultChoice, boolean global /* style, false */, ScriptableFunction callback) {
Dialog d = new Dialog( type, message, defaultChoice, null /* bitmap */, global ? Dialog.GLOBAL_STATUS : 0 /* style */);
return new DialogAsyncRunnable(d, callback);
}

private static class DialogRunnable implements Runnable {
private IWebWorksDialog _dialog;
private ScriptableFunction _callback;
private Object _context;

/**
* Constructs a <code>DialogRunnable</code> object.
@@ -57,13 +112,10 @@ private static class DialogRunnable implements Runnable {
* The dialog
* @param callback
* The callback
* @param context
* The context in which the callback executes (its "this" object)
*/
DialogRunnable( IWebWorksDialog dialog, ScriptableFunction callback, Object context ) {
DialogRunnable( IWebWorksDialog dialog, ScriptableFunction callback ) {
_dialog = dialog;
_callback = callback;
_context = context;
}


@@ -106,4 +158,39 @@ public void run() {
}
}
}

private static class DialogAsyncRunnable implements Runnable {
private Dialog _dialog;
private ScriptableFunction _callback;
private Integer _dialogValue;

/**
* Constructs a <code>DialogRunnable</code> object.
*
* @param dialog
* The dialog
* @param callback
* The callback
*/
DialogAsyncRunnable( Dialog dialog, ScriptableFunction callback ) {
_dialog = dialog;
_callback = callback;
}

/**
* Run the dialog.
*
* @see java.lang.Runnable#run()
*/
public void run() {
_dialogValue = new Integer( _dialog.doModal() );
// get object's string as all ecma primitives will return a valid string representation of themselves
Object retVal = _dialogValue.toString();
try {
_callback.invoke( null, new Object[] { retVal } );
} catch( Exception e ) {
throw new RuntimeException( "Invoke callback failed: " + e.getMessage() );
}
}
}
}
Original file line number Diff line number Diff line change
@@ -15,17 +15,12 @@
*/
package blackberry.ui.dialog;

import net.rim.device.api.script.ScriptEngine;
import net.rim.device.api.script.Scriptable;
import net.rim.device.api.script.ScriptableFunction;
import net.rim.device.api.ui.UiApplication;
import blackberry.common.util.json4j.JSONArray;
import blackberry.core.FunctionSignature;
import blackberry.core.ScriptableFunctionBase;

import blackberry.ui.dialog.DialogRunnableFactory;
import blackberry.ui.dialog.select.SelectDialog;

/**
* Implementation of asynchronous selection dialog
*
@@ -56,7 +51,7 @@ public Object execute( Object thiz, Object[] args ) throws Exception {

populateChoiceStateArrays( choices, labels, enabled, selected, types, allowMultiple );

Runnable dr = DialogRunnableFactory.getSelectRunnable(allowMultiple, labels, enabled, selected, types, callback, thiz);
Runnable dr = DialogRunnableFactory.getSelectRunnable(allowMultiple, labels, enabled, selected, types, callback);

// queue
UiApplication.getUiApplication().invokeLater(dr);
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright 2010-2011 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package blackberry.ui.dialog;

import net.rim.device.api.script.Scriptable;
import net.rim.device.api.script.ScriptableFunction;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;
import blackberry.core.FunctionSignature;
import blackberry.core.ScriptableFunctionBase;

/**
* Implementation of asynchronous standard ask function (blackberry.ui.dialog.standardAskAsync)
*
* @author dmateescu
*
*/
public class StandardAskAsyncFunction extends ScriptableFunctionBase {

public static final String NAME = "standardAskAsync";

/**
* @see blackberry.core.ScriptableFunctionBase#execute(Object, Object[])
*/
public Object execute( Object thiz, Object[] args ) throws Exception {
String message;
int type;
final boolean global = false;

// message
message = (String) args[ 0 ];
// type
type = ( (Integer) args[ 1 ] ).intValue();
if( type < Dialog.D_OK || type > Dialog.D_OK_CANCEL ) {
throw new IllegalArgumentException();
}
// default choice
final int defaultChoice = DialogNamespace.getDefaultChoice( type );
//callback function
ScriptableFunction callback = (ScriptableFunction) args[ 2 ];

Runnable dr = DialogRunnableFactory.getStandardAskRunnable(message, type, defaultChoice, global, callback);
// queue
UiApplication.getUiApplication().invokeLater(dr);
// return value
return Scriptable.UNDEFINED;
}

/**
* @see blackberry.core.ScriptableFunctionBase#getFunctionSignatures()
*/
protected FunctionSignature[] getFunctionSignatures() {
FunctionSignature fs = new FunctionSignature( 3 );
// message
fs.addParam( String.class, true );
// type
fs.addParam( Integer.class, true );
// callback
fs.addParam( ScriptableFunction.class, true );
// filler
fs.addParam( Object.class, false );
return new FunctionSignature[] { fs };
}
}
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
import net.rim.device.api.system.Application;
import net.rim.device.api.system.KeyListener;
import net.rim.device.api.ui.Keypad;
import net.rim.device.api.ui.UiApplication;

/**
* Key listener implementation. Proxy for system key listener that
@@ -40,6 +41,9 @@ class KeyPressHandler {

private KeyListener _keyMonitor;

private UiApplication _app;
private boolean _dialogUp;

private boolean[] _listenerForKey = new boolean[] { false, false, false, false, false, false, false, false};

KeyPressHandler(ISystemEventListener manager) {
@@ -53,13 +57,13 @@ class KeyPressHandler {
* @param forKey the key code to listen for
*/
public void listen(String forKey) {
int keyToListenFor = Integer.parseInt(forKey);
if(keyToListenFor < 0 || keyToListenFor > _listenerForKey.length) {
throw new IllegalArgumentException("Invalid key code requested [" + keyToListenFor + "]");
int keyToListenFor = Integer.parseInt( forKey );

if( keyToListenFor < 0 || keyToListenFor > _listenerForKey.length ) {
throw new IllegalArgumentException( "Invalid key code requested [" + keyToListenFor + "]" );
}
if(_keyMonitor == null) {

if( _keyMonitor == null ) {

//Anonymous implementation of the net.rim.device.api.system.KeyListener interface
_keyMonitor = new KeyListener() {
@@ -70,7 +74,8 @@ public void listen(String forKey) {
public boolean keyDown( int keycode, int time ) {
int keyPressed = Keypad.key( keycode );
int event;

_dialogUp = false;

switch( keyPressed ) {
case Keypad.KEY_CONVENIENCE_1:
event = IKEY_CONVENIENCE_1;
@@ -80,6 +85,7 @@ public boolean keyDown( int keycode, int time ) {
break;
case Keypad.KEY_MENU:
event = IKEY_MENU;
isDialogUp();
break;
case Keypad.KEY_SEND:
event = IKEY_STARTCALL;
@@ -89,27 +95,54 @@ public boolean keyDown( int keycode, int time ) {
break;
case Keypad.KEY_ESCAPE:
event = IKEY_BACK;
isDialogUp();
break;
case Keypad.KEY_VOLUME_DOWN:
event = IKEY_VOLUME_DOWN;
isDialogUp();
break;
case Keypad.KEY_VOLUME_UP:
event = IKEY_VOLUME_UP;
isDialogUp();
break;
default:
return false;
}

//If we're listening for this hardware key, queue up an event for it
if(_listenerForKey[event]) {
_manager.onSystemEvent(_manager.EVENT_HARDWARE_KEY, String.valueOf(event));


// If we're listening for this hardware key, queue up an event for it,
// only queue if the active screen is not a dialog.
if( _listenerForKey[ event ] && !_dialogUp ) {
_manager.onSystemEvent( _manager.EVENT_HARDWARE_KEY, String.valueOf( event ) );

return true;
}

return false;
}

/*
* Checks to see if the current active screen is a Dialog.
*/
private void isDialogUp() {
_app = UiApplication.getUiApplication();
if( _app.isEventThread() ) {
isDialogUpHelper();
} else {
_app.invokeLater( new Runnable() {
public void run() {
isDialogUpHelper();
}
} );
}
}

public void isDialogUpHelper() {
if( _app.getActiveScreen().getScreenBelow() == null ) {
_dialogUp = false;
} else {
_dialogUp = true;
}
}

/**
* @see net.rim.device.api.system.KeyListener#keyChar(char, int, int)
*/
28 changes: 14 additions & 14 deletions framework/src/blackberry/web/widget/Widget.java
Original file line number Diff line number Diff line change
@@ -53,18 +53,18 @@ public Widget( WidgetConfig wConfig, String locationURI ) {
initialize();
_locationURI = locationURI;

// Set our orientation
WidgetConfigImpl configImpl = (WidgetConfigImpl) _wConfig;
if (configImpl.isOrientationDefined()) {
int direction;
if (configImpl.getOrientation() == 0) {
direction = net.rim.device.api.system.Display.DIRECTION_PORTRAIT;
} else {
direction = net.rim.device.api.system.Display.DIRECTION_LANDSCAPE;
}
net.rim.device.api.ui.Ui.getUiEngineInstance().setAcceptableDirections(direction);
}
// Set our orientation
WidgetConfigImpl configImpl = (WidgetConfigImpl) _wConfig;
if( configImpl.isOrientationDefined() ) {
int direction;
if( configImpl.getOrientation() == 0 ) {
direction = net.rim.device.api.system.Display.DIRECTION_NORTH;
} else {
direction = net.rim.device.api.system.Display.DIRECTION_LANDSCAPE;
}
net.rim.device.api.ui.Ui.getUiEngineInstance().setAcceptableDirections( direction );
}

// Create PageManager
PageManager pageManager = new PageManager( this, (WidgetConfigImpl) _wConfig );

@@ -143,9 +143,9 @@ public static void main( String[] args ) {
waitForStartupComplete();
}
Widget widget = makeWidget( args, wConfig );

widget.enterEventDispatcher();

MemoryMaid mm = MemoryMaid.getInstance();
if( mm != null ) {
mm.stop();
1,102 changes: 1,101 additions & 1 deletion framework/src/js/html5_init.js

Large diffs are not rendered by default.

1,101 changes: 0 additions & 1,101 deletions framework/src/js/html5_init_uncompressed.js

This file was deleted.

110 changes: 103 additions & 7 deletions framework/src/js/html5_worker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,103 @@
var wp=google.gears.workerPool;var mainPoolId=100;var scriptFetched=false;var workerId=-1;var __CONTEXT__=this;function runScript(sourceScript){try{eval(sourceScript);return true;}
catch(e){return false;}}
function wrapGearsErrorInHtml5(workerError){}
wp.onmessage=function(messageText,senderId,messageObject){if(scriptFetched){wp.onmessage=null;}
else{scriptFetched=runScript(messageObject.body);if(scriptFetched){wp.sendMessage({type:"ready"},mainPoolId);}}};this.postMessage=function(message){if(typeof mainPoolId!="number"||mainPoolId<0){return;}
wp.sendMessage({type:"message",content:arguments[0]},mainPoolId);};this.__defineSetter__("onmessage",function(func){wp.onmessage=function(messageText,sendId,messageObject){func.call(__CONTEXT__,{data:messageObject.body});}});this.__defineSetter__("onerror",function(func){wp.onerror=function(errorObject){var html5Error={message:errorObject.message,filename:"Not Implemented",lineno:errorObject.lineNumber,}
func.call(__CONTEXT__,html5Error);wp.sendMessage({type:"error",content:html5Error},mainPoolId);return true;};});
/**
*
* Date: 09/23/2010 Version: 1.0.0.16
*
* Copyright (c) 2010 Research In Motion Limited.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* This License shall be included in all copies or substantial portions of the
* Software.
*
* The name(s) of the above copyright holders shall not be used in advertising
* or otherwise to promote the sale, use or other dealings in this Software
* without prior written authorization.
*
*/
var wp = google.gears.workerPool;
var mainPoolId = 100; // This is hard coded because at times because
// messageObject.sender has incorrect id at times
var scriptFetched = false;
var workerId = -1;
var __CONTEXT__ = this;

function runScript(sourceScript) {
try {
eval(sourceScript);
return true;
}
catch (e) {
return false;
}
}

function wrapGearsErrorInHtml5(workerError) {

}

wp.onmessage = function(messageText, senderId, messageObject) {
if (scriptFetched) {
// if script has been successfully evaluated,
// then we would only get here if onmessage is never assigned
// in which case we can assume the user intended onmessage = null;
wp.onmessage = null;
}
else {
// Attempt to run the the script
scriptFetched = runScript(messageObject.body);
if (scriptFetched) {
wp.sendMessage({
type: "ready"
}, mainPoolId);
}
}
};

this.postMessage = function(message) {
if (typeof mainPoolId != "number" || mainPoolId < 0) {
return;
}
wp.sendMessage({
type: "message",
content: arguments[0]
}, mainPoolId);
};

this.__defineSetter__("onmessage", function(func) {
wp.onmessage = function(messageText, sendId, messageObject) {
func.call(__CONTEXT__, {
data: messageObject.body
});
}
});

this.__defineSetter__("onerror", function(func) {

wp.onerror = function(errorObject) {
var html5Error = {
message: errorObject.message,
filename: "Not Implemented",
lineno: errorObject.lineNumber,
}

func.call(__CONTEXT__, html5Error);
wp.sendMessage({
type: "error",
content: html5Error
}, mainPoolId);
return true;
};
});
103 changes: 0 additions & 103 deletions framework/src/js/html5_worker_uncompressed.js

This file was deleted.

1,452 changes: 1,451 additions & 1 deletion framework/src/js/navmode.js

Large diffs are not rendered by default.

1,451 changes: 0 additions & 1,451 deletions framework/src/js/navmode_uncompressed.js

This file was deleted.