From cde8bb13b5e1cbcaeb090689f5177a395d8fd092 Mon Sep 17 00:00:00 2001 From: Diego Perez Date: Wed, 25 May 2016 16:10:32 +0100 Subject: [PATCH] Add warning when RTL is used but not supported/enabled Change-Id: Ic01a3b276ff0ecf87ee34e164e494698ec37c1f4 --- .../layoutlib/bridge/impl/RenderSessionImpl.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java index a8077ccae01a1..c890793e290fc 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java @@ -20,6 +20,7 @@ import com.android.ide.common.rendering.api.AdapterBinding; 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 @@ public class RenderSessionImpl extends RenderAction { 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());