Merge "Add warning when RTL is used but not supported/enabled"
diff --git a/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
index a8077cc..c890793 100644
--- a/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
+++ b/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java
@@ -20,6 +20,7 @@
import com.android.ide.common.rendering.api.HardwareConfig;
import com.android.ide.common.rendering.api.IAnimationListener;
import com.android.ide.common.rendering.api.ILayoutPullParser;
+import com.android.ide.common.rendering.api.LayoutLog;
import com.android.ide.common.rendering.api.LayoutlibCallback;
import com.android.ide.common.rendering.api.RenderResources;
import com.android.ide.common.rendering.api.RenderSession;
@@ -303,6 +304,20 @@
SessionParams params = getParams();
BridgeContext context = getContext();
+ if (Bridge.isLocaleRtl(params.getLocale())) {
+ if (!params.isRtlSupported()) {
+ Bridge.getLog().warning(LayoutLog.TAG_RTL_NOT_ENABLED,
+ "You are using a right-to-left " +
+ "(RTL) locale but RTL is not enabled", null);
+ } else if (params.getSimulatedPlatformVersion() < 17) {
+ // This will render ok because we are using the latest layoutlib but at least
+ // warn the user that this might fail in a real device.
+ Bridge.getLog().warning(LayoutLog.TAG_RTL_NOT_SUPPORTED, "You are using a " +
+ "right-to-left " +
+ "(RTL) locale but RTL is not supported for API level < 17", null);
+ }
+ }
+
// Sets the project callback (custom view loader) to the fragment delegate so that
// it can instantiate the custom Fragment.
Fragment_Delegate.setLayoutlibCallback(params.getLayoutlibCallback());