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

Commit 90c6b7e6 authored by Xavier Ducrohet's avatar Xavier Ducrohet
Browse files

LayoutLib: Use the new ninepatch API to suppor density.

LayoutLib now compiles against a prebuilt of ninepatch.

Change-Id: I0a1ca60af90933c171ab3aa456b47f0329df2f55
parent 8da36314
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
	<classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilt/common/layoutlib_api/layoutlib_api-prebuilt.jar"/>
	<classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilt/common/kxml2/kxml2-2.3.0.jar" sourcepath="/ANDROID_PLAT_SRC/dalvik/libcore/xml/src/main/java"/>
	<classpathentry kind="var" path="ANDROID_PLAT_OUT_FRAMEWORK/ninepatch.jar" sourcepath="/ANDROID_PLAT_SRC/development/tools/ninepatch/src"/>
	<classpathentry kind="var" path="ANDROID_PLAT_SRC/out/host/common/obj/JAVA_LIBRARIES/temp_layoutlib_intermediates/javalib.jar" sourcepath="/ANDROID_PLAT_SRC/frameworks/base"/>
	<classpathentry kind="var" path="ANDROID_PLAT_SRC/prebuilt/common/ninepatch/ninepatch-prebuilt.jar"/>
	<classpathentry kind="output" path="bin"/>
</classpath>
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ LOCAL_SRC_FILES := $(call all-java-files-under,src)
LOCAL_JAVA_LIBRARIES := \
	kxml2-2.3.0 \
	layoutlib_api-prebuilt \
	ninepatch
	ninepatch-prebuilt

LOCAL_STATIC_JAVA_LIBRARIES := temp_layoutlib

+1 −1
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ public class NinePatch_Delegate {

       try {
           chunkObject.draw(bitmap_delegate.getImage(), graphics,
                   left, top, right - left, bottom - top);
                   left, top, right - left, bottom - top, destDensity, srcDensity);
       } finally {
           if (paint_delegate != null) {
               graphics.dispose();
+8 −5
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Helper class to provide various convertion method used in handling android resources.
 * Helper class to provide various conversion method used in handling android resources.
 */
public final class ResourceHelper {

@@ -133,7 +133,8 @@ public final class ResourceHelper {
                // if either chunk or bitmap is null, then we reload the 9-patch file.
                if (chunk == null || bitmap == null) {
                    try {
                        NinePatch ninePatch = NinePatch.load(file.toURL(), false /* convert */);
                        NinePatch ninePatch = NinePatch.load(file.toURI().toURL(),
                                false /* convert */);
                        if (ninePatch != null) {
                            if (chunk == null) {
                                chunk = ninePatch.getChunk();
@@ -161,6 +162,7 @@ public final class ResourceHelper {
                        // URL is wrong, we'll return null below
                    } catch (IOException e) {
                        // failed to read the file, we'll return null below.
                        Bridge.getLog().error(null, e);
                    }
                }

@@ -220,7 +222,7 @@ public final class ResourceHelper {
                    return new BitmapDrawable(context.getResources(), bitmap);
                } catch (IOException e) {
                    // we'll return null below
                    // TODO: log the error.
                    Bridge.getLog().error(null, e);
                }
            } else {
                // attempt to get a color from the value
@@ -229,7 +231,8 @@ public final class ResourceHelper {
                    return new ColorDrawable(color);
                } catch (NumberFormatException e) {
                    // we'll return null below.
                    // TODO: log the error
                    Bridge.getLog().error(null,
                            "failed to convert " + stringValue + " into a drawable");
                }
            }
        }