am 8a39c3af: Add orientation to configuration for layoutlib. [DO NOT MERGE]
* commit '8a39c3afb29f2540b05319042e758dd4d5f73a1e': Add orientation to configuration for layoutlib. [DO NOT MERGE]
This commit is contained in:
@@ -30,6 +30,7 @@ import com.android.layoutlib.bridge.Bridge;
|
|||||||
import com.android.layoutlib.bridge.android.BridgeContext;
|
import com.android.layoutlib.bridge.android.BridgeContext;
|
||||||
import com.android.resources.Density;
|
import com.android.resources.Density;
|
||||||
import com.android.resources.ResourceType;
|
import com.android.resources.ResourceType;
|
||||||
|
import com.android.resources.ScreenOrientation;
|
||||||
import com.android.resources.ScreenSize;
|
import com.android.resources.ScreenSize;
|
||||||
|
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
@@ -345,6 +346,23 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso
|
|||||||
config.compatScreenWidthDp = config.screenWidthDp;
|
config.compatScreenWidthDp = config.screenWidthDp;
|
||||||
config.compatScreenHeightDp = config.screenHeightDp;
|
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.
|
// TODO: fill in more config info.
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
|
|||||||
Reference in New Issue
Block a user