# HG changeset patch # User Eugene Ostroukhov # Date 1274314651 25200 # Node ID afe6a53c0ed47c66dd686e0f17b663650fa4a049 # Parent 131c321bf08077d8e0412f6796a45127474018e2 Work-in-progress commit for orientation preview. API is emulated and basic work on previewer is implemented. Some display issues are remaining diff -r 131c321bf080 -r afe6a53c0ed4 org.symbian.tools.wrttools.previewer/.options --- a/org.symbian.tools.wrttools.previewer/.options Mon May 17 15:31:00 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/.options Wed May 19 17:17:31 2010 -0700 @@ -1,3 +1,4 @@ +org.symbian.tools.wrttools.previewer/dontScriptCaching=false org.symbian.tools.wrttools.previewer/debug=false org.symbian.tools.wrttools.previewer/servlet=false org.symbian.tools.wrttools.previewer/mapping=false diff -r 131c321bf080 -r afe6a53c0ed4 org.symbian.tools.wrttools.previewer/preview/data/sensor_data.js --- a/org.symbian.tools.wrttools.previewer/preview/data/sensor_data.js Mon May 17 15:31:00 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/preview/data/sensor_data.js Wed May 19 17:17:31 2010 -0700 @@ -236,8 +236,14 @@ } } }; + +var CHANNEL_ACCEL = 7; +var CHANNEL_ACCELDT = 8; +var CHANNEL_ORIENTATION = 10; +var CHANNEL_ROTATION = 11; + var data_all =[{ - "ChannelId":7, + "ChannelId":CHANNEL_ACCEL, "ContextType":2, "Quantity":10, "ChannelType":270553214, @@ -247,7 +253,7 @@ "ChannelDataTypeId":270553214 }, { - "ChannelId":8, + "ChannelId":CHANNEL_ACCELDT, "ContextType":2, "Quantity":11, "ChannelType":270553217, @@ -257,7 +263,7 @@ "ChannelDataTypeId":270553215 }, { - "ChannelId":10, + "ChannelId":CHANNEL_ORIENTATION, "ContextType":3, "Quantity":12, "ChannelType":270553224, @@ -267,7 +273,7 @@ "ChannelDataTypeId":270553224 }, { - "ChannelId":11, + "ChannelId":CHANNEL_ROTATION, "ContextType":3, "Quantity":13, "ChannelType":270553225, @@ -278,7 +284,7 @@ }]; var data_accelerometerAxis = [{ - "ChannelId":7, + "ChannelId":CHANNEL_ACCEL, "ContextType":2, "Quantity":10, "ChannelType":270553214, @@ -289,7 +295,7 @@ }]; var data_accelerometerDoubleTapping = [{ - "ChannelId":8, + "ChannelId":CHANNEL_ACCELDT, "ContextType":2, "Quantity":11, "ChannelType":270553217, @@ -300,7 +306,7 @@ }]; var data_orientation = [{ - "ChannelId":10, + "ChannelId":CHANNEL_ORIENTATION, "ContextType":3, "Quantity":12, "ChannelType":270553224, @@ -311,7 +317,7 @@ }]; var data_rotation = [{ - "ChannelId":11, + "ChannelId":CHANNEL_ROTATION, "ContextType":3, "Quantity":13, "ChannelType":270553225, diff -r 131c321bf080 -r afe6a53c0ed4 org.symbian.tools.wrttools.previewer/preview/script/lib/device.js --- a/org.symbian.tools.wrttools.previewer/preview/script/lib/device.js Mon May 17 15:31:00 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/preview/script/lib/device.js Wed May 19 17:17:31 2010 -0700 @@ -39,7 +39,7 @@ getServiceObject: function(provider, Interface){ if (!device.implementation.context) - throw 'device implementation object not instantiated!' + throw 'device implementation object not instantiated!'; if (device.implementation.options.enabled) return device.implementation.getInterface(provider, Interface); @@ -60,60 +60,10 @@ * @constructor */ device.implementation = function(version){ - this.version = version || ''; // set context to current object device.implementation.context = this; - - var libpath = 'preview/script/lib/', - datapath = 'preview/data/'; - - // load implementation files - // this is done async by the browser engine, so be aware of sync conditions!! - if (version == '1') - loadSAPI(libpath + 'sapi1/'); - else if (!version) - loadSAPI(); - else - throw 'unsuppported SAPI version!'; - - function loadSAPI(path){ - var path = path || (libpath + "sapi/"); - - // load API -// loadScript(path + "AppManager.js"); -// loadScript(path + "Calendar.js"); -// loadScript(path + "Contact.js"); -// loadScript(path + "Landmarks.js"); -// loadScript(path + "Location.js"); -// loadScript(path + "Logging.js"); -// loadScript(path + "MediaManagement.js"); -// loadScript(path + "Messaging.js"); -// loadScript(path + "Sensor.js"); -// loadScript(path + "SysInfo.js"); - - // load sample data -// loadScript(datapath + "appManager_data.js"); -// loadScript(datapath + "calendar_data.js"); -// loadScript(datapath + "contact_data.js"); -// loadScript(datapath + "landmarks_data.js"); -// loadScript(datapath + "location_data.js"); -// loadScript(datapath + "logging_data.js"); -// loadScript(datapath + "mediaManagement_data.js"); -// loadScript(datapath + "messaging_data.js"); -// loadScript(datapath + "sensor_data.js"); -// loadScript(datapath + "sysInfo_data.js"); - } - - function loadScript(src){ - var head = document.getElementsByTagName("head")[0] || document.documentElement, - script = document.createElement("script"); - - script.type = "text/javascript"; - script.src = src; - head.appendChild(script); - } }; (function(){ @@ -192,7 +142,7 @@ getNext : function(){ return index < data.length ? data[index++] : undefined; } - } + }; }, @@ -320,7 +270,7 @@ str = typeof str != 'undefined' ? String(str) : ''; return new StringEx(str); - } + } }; /** @@ -526,9 +476,7 @@ // call the provider's handler listener.handler(listener.transactionID, listener.criteria, listener.callback, data); -} - - +}; /* * ERROR CODES diff -r 131c321bf080 -r afe6a53c0ed4 org.symbian.tools.wrttools.previewer/preview/script/lib/sapi/Sensor.js --- a/org.symbian.tools.wrttools.previewer/preview/script/lib/sapi/Sensor.js Mon May 17 15:31:00 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/preview/script/lib/sapi/Sensor.js Wed May 19 17:17:31 2010 -0700 @@ -24,10 +24,24 @@ */ (function(){ + var CHANNEL_ACCEL = 7; + var CHANNEL_ACCELDT = 8; + var CHANNEL_ORIENTATION = 10; + var CHANNEL_ROTATION = 11; + var transactionToCallback = new Object(); + var nextTransactionId = 2123148; // Random seed number! (Actual number doesn't matter) + + var AccelerometerAxis = new Array(); + var AccelerometerDoubleTapping = new Array(); + var Orientation = new Array(); + var Rotation = new Array(); + var xyOrientation = 0; + var zOrientation = 0; + var provider = 'Service.Sensor', Interface = 'ISensor'; - var transID = new Array(); + /** * Sensor service */ @@ -35,7 +49,7 @@ this.FindSensorChannel = __FindSensorChannel; this.RegisterForNotification = __RegisterForNotification; this.Cancel = __Cancel; - this.GetChannelProperty = __GetChannelProperty; + this.GetChannelProperty = __GetChannelProperty; }; device.implementation.extend(provider, Interface, new SensorService() ); @@ -50,7 +64,39 @@ result = false, DBase = null; + device.implementation.setOrientation = function(xy, z) { + xyOrientation = xy; + zOrientation = z; + + for (var i = 0; i < Orientation.length; i++) { + notifyOrientationChangeListener(Orientation[i]); + } + }; + function notifyOrientationChangeListener(callback) { + var orientation; + if (xyOrientation > -45 && xyOrientation <= 45) { + orientation = "DisplayUp"; + } else if (xyOrientation > 45 && xyOrientation <= 135) { + orientation = "DisplayLeftUp"; + } else if (xyOrientation > 135 || xyOrientation <= -135) { + orientation = "DisplayDown"; + } else if (xyOrientation > -135 && xyOrientation <= -45) { + orientation = "DisplayRightUp"; + } + callback(getTransactionId(callback), 9, context.Result( { + DeviceOrientation : orientation + })); + } + + function getTransactionId(callback) { + for ( var tId in transactionToCallback) { + if (transactionToCallback[tId] == callback) { + return tId; + } + } + } + /** * Sensor: FindSensorChannel * @param {Object} criteria @@ -118,19 +164,36 @@ if(!(criteria.ListeningType== "ChannelData" )) return error(device.implementation.ERR_INVALID_SERVICE_ARGUMENT, msg.msgOutofRange); - if(typeof callback == 'function') - { - var result = context.callAsync(this, arguments.callee, criteria, callback); - transID.push(result.TransactionID); - return result; + if (typeof callback == 'function') { + var channels = criteria.ChannelInfoMap; + // for ( var channel in channels) { + var notify = null; + switch (channels.ChannelId) { + case CHANNEL_ACCEL: + AccelerometerAxis.push(callback); + break; + case CHANNEL_ACCELDT: + AccelerometerDoubleTapping.push(callback); + break; + case CHANNEL_ORIENTATION: + Orientation.push(callback); + notify = notifyOrientationChangeListener; + break; + case CHANNEL_ROTATION: + Rotation.push(callback); + break; + } + // } + var tID = nextTransactionId++; + transactionToCallback[tID] = callback; + setTimeout(notify, 20, callback); +// var result = context.callAsync(this, arguments.callee, criteria, callback); + return context.AsyncResult(tID); } - if(flag) - transID.shift(); return context.ErrorResult(); } - - + /** * Sensor: Cancel * @param {Object} criteria @@ -147,20 +210,32 @@ if (criteria.TransactionID == Infinity || criteria.TransactionID == -Infinity) return error(device.implementation.ERR_BAD_ARGUMENT_TYPE, msg.msgTransIDMissing); - if (typeof criteria.TransactionID != 'number') - return error(device.implementation.ERR_BAD_ARGUMENT_TYPE, msg.msgIncorrectTransID); + if (typeof criteria.TransactionID != 'number') + return error(device.implementation.ERR_BAD_ARGUMENT_TYPE, msg.msgIncorrectTransID); - for (var i=0; i a").trigger('click'); - } + }; a[0].appendChild(lsk); rsk.onclick = function(){ $("#RskLabel > a").trigger('click'); - } + }; a[1].appendChild(rsk); }else{ rsk.onclick = function(){ $("#RskLabel > a").trigger('click'); - } + }; a[0].appendChild(rsk); lsk.onclick = function(){ $("#LskLabel > a").trigger('click'); - } + }; a[1].appendChild(lsk); } @@ -540,9 +540,14 @@ if(mode != null) NOKIA.mode = mode; + var orientation = Number(NOKIA.helper.getPreference('__SYM_NOKIA_EMULATOR_ORIENTATION')); + if (typeof orientation == "number" && orientation >= -90 && orientation <= 180) + NOKIA.orientation = orientation; + // SAVE the device DATA NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE', NOKIA.currentDevice); NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_DEVICE_MODE', NOKIA.mode); + NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_ORIENTATION', NOKIA.orientation); this.loaded = true; @@ -562,6 +567,10 @@ } this.setStyle(); + var or = (NOKIA.mode == 'portrait') ? NOKIA.orientation : (NOKIA.orientation + 90); + var val = "rotate(" + or + "deg)"; + $("#preview-ui-top").css("-moz-transform", val); + $("#preview-ui-top").css("-webkit-transform", val); }, setMode : function(mode) @@ -574,6 +583,18 @@ NOKIA.emulator.render(); }, + toggle : function(o) + { + NOKIA.orientation = o; + NOKIA.helper.setPreference('__SYM_NOKIA_EMULATOR_ORIENTATION', NOKIA.orientation); + NOKIA.emulator.child.device.implementation.setOrientation(o, 0); + if (NOKIA.emulator.orientationSupports() && (o == 0 || o == -90)) { + NOKIA.emulator.setMode(o == 0 ? 'portrait' : 'landscape'); + } else { + NOKIA.emulator.render(); + } + }, + orientationSupports : function() { return NOKIA.deviceList[NOKIA.currentDevice]['orientation']; @@ -958,38 +979,12 @@ }, rotateCW : function() { - if (NOKIA.orientation == 0) { - this.toggle(90); - } else if (NOKIA.orientation == 90) { - this.toggle(180); - } else if (NOKIA.orientation == 180) { - this.toggle(-90); - } else { - this.toggle(0); - } + var newOrient = NOKIA.orientation + 90; + NOKIA.emulator.toggle(newOrient - (newOrient > 180 ? 360 : 0)); }, rotateCCW : function() { - if (NOKIA.orientation == 0) { - this.toggle(-90); - } else if (NOKIA.orientation == -90) { - this.toggle(180); - } else if (NOKIA.orientation == 180) { - this.toggle(90); - } else { - this.toggle(0); - } - }, - - toggle : function(o) - { - if (NOKIA.emulator.orientationSupports() && (o == 0 || o == -90)) { - NOKIA.emulator.setMode(o == 0 ? 'portrait' : 'landscape'); - } - NOKIA.orientation = o; - var or = (NOKIA.mode == 'portrait') ? o : (o + 90); - var val = "rotate(" + or + "deg)"; - $("#preview-ui-top").css("-moz-transform", val); - $("#preview-ui-top").css("-webkit-transform", val); + var newOrient = NOKIA.orientation - 90; + NOKIA.emulator.toggle(newOrient + (newOrient <= -180 ? 360 : 0)); }, version : function(ele) diff -r 131c321bf080 -r afe6a53c0ed4 org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/PreviewerPlugin.java --- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/PreviewerPlugin.java Mon May 17 15:31:00 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/PreviewerPlugin.java Wed May 19 17:17:31 2010 -0700 @@ -43,6 +43,8 @@ public static final boolean TRACE_SERVLET = DEBUG && Boolean.parseBoolean(Platform.getDebugOption(PLUGIN_ID + "/servlet")); + public static final boolean DONT_CACHE_SCRIPT = DEBUG + && Boolean.parseBoolean(Platform.getDebugOption(PLUGIN_ID + "/dontScriptCaching")); public static final boolean TRACE_MAPPING = DEBUG && Boolean.parseBoolean(Platform.getDebugOption(PLUGIN_ID + "/mapping")); diff -r 131c321bf080 -r afe6a53c0ed4 org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/MasterScriptProvider.java --- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/MasterScriptProvider.java Mon May 17 15:31:00 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/MasterScriptProvider.java Wed May 19 17:17:31 2010 -0700 @@ -54,7 +54,7 @@ public InputStream getResourceStream(IProject project, IPath resource, Map parameters) throws IOException, CoreException { synchronized (this) { - if (WRT10 == null) { + if (WRT10 == null || PreviewerPlugin.DONT_CACHE_SCRIPT) { loadCoreAPI(); loadWRT11Services(); } diff -r 131c321bf080 -r afe6a53c0ed4 org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/PreferencesResourceProvider.java --- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/PreferencesResourceProvider.java Mon May 17 15:31:00 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/handlers/PreferencesResourceProvider.java Wed May 19 17:17:31 2010 -0700 @@ -61,7 +61,10 @@ public void post(IProject project, IPath resource, Map parameterMap, JSONObject object) throws IOException, CoreException { String key = (String) object.get("key"); - String value = (String) object.get("value"); + Object value = object.get("value"); + if (value != null) { + value = value.toString(); + } Properties projectPreferences = ProjectPreferencesManager.getProjectProperties(project); String oldValue = (String) projectPreferences.get(key); if (oldValue != value && (oldValue == null || !oldValue.equals(value))) { diff -r 131c321bf080 -r afe6a53c0ed4 org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/ProjectPreferencesManager.java --- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/ProjectPreferencesManager.java Mon May 17 15:31:00 2010 -0700 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/ProjectPreferencesManager.java Wed May 19 17:17:31 2010 -0700 @@ -26,6 +26,7 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; @@ -39,6 +40,9 @@ public static synchronized Properties getProjectProperties(IProject project) throws IOException, CoreException { Properties projectPreferences = new Properties(); IFile xml = getPreferencesXml(project); + if (!xml.isSynchronized(IResource.DEPTH_ZERO)) { + xml.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor()); + } if (xml.isAccessible()) { InputStream contents = null; try { diff -r 131c321bf080 -r afe6a53c0ed4 org.symbian.tools.wrttools.product/launch/WRT IDE Product (Windows).launch --- a/org.symbian.tools.wrttools.product/launch/WRT IDE Product (Windows).launch Mon May 17 15:31:00 2010 -0700 +++ b/org.symbian.tools.wrttools.product/launch/WRT IDE Product (Windows).launch Wed May 19 17:17:31 2010 -0700 @@ -5,7 +5,7 @@ - + @@ -21,17 +21,12 @@ - - + + + - + - - - - - - @@ -86,9 +81,6 @@ - - - @@ -96,6 +88,7 @@ + @@ -129,11 +122,6 @@ - - - - - @@ -175,65 +163,15 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -243,6 +181,8 @@ + + @@ -252,6 +192,7 @@ + @@ -273,11 +214,6 @@ - - - - - @@ -289,16 +225,6 @@ - - - - - - - - - - @@ -445,6 +371,8 @@ + + @@ -488,6 +416,11 @@ + + + + +