summaryrefslogtreecommitdiffstats
path: root/tools/layoutlib/bridge/src
diff options
context:
space:
mode:
authorDeepanshu Gupta <deepanshu@google.com>2013-07-12 15:24:51 -0700
committerDeepanshu Gupta <deepanshu@google.com>2014-05-05 18:17:13 -0700
commit8a39c3afb29f2540b05319042e758dd4d5f73a1e (patch)
treedb14a03054a1938c0078df9fc5b620ec468b2595 /tools/layoutlib/bridge/src
parentecb013dbff5e33b95c49015fa375579e055911ae (diff)
downloadframeworks_base-8a39c3afb29f2540b05319042e758dd4d5f73a1e.zip
frameworks_base-8a39c3afb29f2540b05319042e758dd4d5f73a1e.tar.gz
frameworks_base-8a39c3afb29f2540b05319042e758dd4d5f73a1e.tar.bz2
Add orientation to configuration for layoutlib. [DO NOT MERGE]
Update the configuration with the device orientation before rendering. Change-Id: Icd40901204fd13f90b18353e53a15e25e5b2176c (cherry picked from commit d4875e19f5b7c69226783b0a6590831466159f84)
Diffstat (limited to 'tools/layoutlib/bridge/src')
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
index 1db7994..b20f190 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderAction.java
@@ -30,6 +30,7 @@ import com.android.layoutlib.bridge.Bridge;
import com.android.layoutlib.bridge.android.BridgeContext;
import com.android.resources.Density;
import com.android.resources.ResourceType;
+import com.android.resources.ScreenOrientation;
import com.android.resources.ScreenSize;
import android.content.res.Configuration;
@@ -345,6 +346,23 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso
config.compatScreenWidthDp = config.screenWidthDp;
config.compatScreenHeightDp = config.screenHeightDp;
+ ScreenOrientation orientation = hardwareConfig.getOrientation();
+ if (orientation != null) {
+ switch (orientation) {
+ case PORTRAIT:
+ config.orientation = Configuration.ORIENTATION_PORTRAIT;
+ break;
+ case LANDSCAPE:
+ config.orientation = Configuration.ORIENTATION_LANDSCAPE;
+ break;
+ case SQUARE:
+ config.orientation = Configuration.ORIENTATION_SQUARE;
+ break;
+ }
+ } else {
+ config.orientation = Configuration.ORIENTATION_UNDEFINED;
+ }
+
// TODO: fill in more config info.
return config;