Permalink
Browse files

added support for rim:orientation

  • Loading branch information...
1 parent b49033a commit 0529f6dbc49d9fb2c013db23fb3b3ec2ff4449b3 Tim Neil committed with qingbiao Nov 24, 2011
View
12 framework/src/blackberry/web/widget/Widget.java
@@ -53,6 +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);
+ }
+
// Create PageManager
PageManager pageManager = new PageManager( this, (WidgetConfigImpl) _wConfig );
View
17 framework/src/blackberry/web/widget/impl/WidgetConfigImpl.java
@@ -92,6 +92,10 @@
protected int _transitionType;
protected int _transitionDuration;
protected int _transitionDirection;
+
+ // orientation configuration
+ protected int _orientation;
+ protected boolean _orientationDefined;
// caches configuration
protected boolean _cacheEnabled;
@@ -137,6 +141,10 @@ protected WidgetConfigImpl() {
_transitionType = TransitionConstants.TRANSITION_NONE;
_transitionDuration = TransitionConstants.DEFAULT_DURATION;
_transitionDirection = TransitionConstants.DIRECTION_LEFT;
+
+ // Set default orientation values
+ _orientationDefined = false;
+ _orientation = -1;
// Set default value of cache configuration
_cacheEnabled = true;
@@ -282,6 +290,15 @@ public int getTransitionDuration() {
public int getTransitionDirection() {
return _transitionDirection;
}
+
+ // Getters of orientation
+ public boolean isOrientationDefined() {
+ return _orientationDefined;
+ }
+
+ public int getOrientation() {
+ return _orientation;
+ }
// Getters of cache configuration
public boolean isCacheEnabled() {
View
19 packager/src/net/rim/tumbler/config/WidgetConfig.java
@@ -35,6 +35,9 @@
private String _name;
private String _version;
+ protected int _orientation; // Portrait 0, Landscape 1
+ protected boolean _orientationDefined;
+
private String _loadingScreenColour;
private String _backgroundImage;
private String _foregroundImage;
@@ -106,6 +109,9 @@ public WidgetConfig() {
_aggressiveCacheAge= null;
_maxCacheable = null;
_maxCacheSize = null;
+
+ _orientationDefined = false;
+ _orientation = -1;
_runOnStartup=false;
_allowInvokeParams=false;
@@ -151,6 +157,14 @@ public String getDescription() {
return _description;
}
+ public int getOrientation() {
+ return _orientation;
+ }
+
+ public boolean getOrientationDefined() {
+ return _orientationDefined;
+ }
+
public Vector<String> getHoverIconSrc() {
return _hoverIconSrc;
}
@@ -162,6 +176,11 @@ public String getDescription() {
public void setContent(String content) {
_content = content;
}
+
+ public void setOrientation(int value) {
+ _orientation = value;
+ _orientationDefined = true;
+ }
public void setAuthor(String author) {
_author = author;
View
6 packager/src/net/rim/tumbler/serialize/WidgetConfig_v1Serializer.java
@@ -135,6 +135,12 @@ public WidgetConfig_v1Serializer(WidgetConfig widgetConfig) {
if (_widgetConfig.getNavigationMode()) {
buffer.append("_widgetNavigationMode = true;").append(NL_LVL_0);
}
+
+ // Set orientation
+ if (_widgetConfig.getOrientationDefined()) {
+ buffer.append("_orientationDefined = true;").append(NL_LVL_0);
+ buffer.append("_orientation = " + Integer.toString(_widgetConfig.getOrientation()) + ";").append(NL_LVL_0);
+ }
// Add LoadingScreen configuration
if (_widgetConfig.getFirstPageLoad()) {
View
28 packager/src/net/rim/tumbler/xml/ConfigXMLParser.java
@@ -102,6 +102,8 @@ private WidgetConfig parseDocument(Document dom, WidgetArchive archive) throws E
processNavigationNode(node);
} else if (node.getNodeName().equals("rim:cache")) {
processCacheNode(node);
+ } else if (node.getNodeName().equals("rim:orientation")) {
+ processOrientationNode(node);
} else if (node.getNodeName().equals("name")) {
_widgetConfig.setName(getTextValue(node));
} else if (node.getNodeName().equals("description")) {
@@ -601,6 +603,32 @@ private void processConnectionNode(Node connectionNode) throws Exception {
_widgetConfig.setTransportOrder(transportArray);
}
}
+
+
+ // Processing for the <rim:orientation> node
+ private void processOrientationNode(Node orientationNode) throws Exception {
+
+ // get mode
+ NamedNodeMap attrs = orientationNode.getAttributes();
+ Node modeAttrNode = attrs.getNamedItem("mode");
+ if (modeAttrNode != null) {
+ try{
+ int orientation = -1;
+ if (modeAttrNode.getNodeValue().equalsIgnoreCase("portrait")) {
+ orientation = 0;
+ } else if (modeAttrNode.getNodeValue().equalsIgnoreCase("landscape")) {
+ orientation = 1;
+ }
+ // Only set the orientation if it was properly specified
+ if (orientation != -1) {
+ _widgetConfig.setOrientation(orientation);
+ }
+ }catch(Exception e){
+ // Default values are used if an error happens
+ }
+ }
+ }
+
// Processing for the <rim:cache> node
private void processCacheNode(Node cacheNode) throws Exception {

0 comments on commit 0529f6d

Please sign in to comment.