Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2f41b23 authored by Deepanshu Gupta's avatar Deepanshu Gupta Committed by Android Git Automerger
Browse files

am bf8be2ee: Merge "Add orientation to configuration for layoutlib." into jb-mr2-dev

* commit 'bf8be2ee':
  Add orientation to configuration for layoutlib.
parents 0f33e44f bf8be2ee
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -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;
@@ -347,6 +348,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;