summaryrefslogtreecommitdiffstats
path: root/tools/layoutlib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/layoutlib')
-rw-r--r--tools/layoutlib/Android.mk4
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java74
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java132
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java8
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java36
-rw-r--r--tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java6
-rw-r--r--tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java46
-rw-r--r--tools/layoutlib/bridge/src/android/webkit/WebView.java16
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContentProvider.java18
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java28
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeIInputMethodManager.java8
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java13
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/view/WindowManagerImpl.java4
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java17
-rw-r--r--tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java3
-rw-r--r--tools/layoutlib/bridge/src/libcore/icu/DateIntervalFormat_Delegate.java74
-rw-r--r--tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java4
-rw-r--r--tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java1
-rw-r--r--tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java2
19 files changed, 302 insertions, 192 deletions
diff --git a/tools/layoutlib/Android.mk b/tools/layoutlib/Android.mk
index c1c450b..cb68340 100644
--- a/tools/layoutlib/Android.mk
+++ b/tools/layoutlib/Android.mk
@@ -25,8 +25,8 @@ include $(CLEAR_VARS)
# We need to process the framework classes.jar file, but we can't
# depend directly on it (private vars won't be inherited correctly).
# So, we depend on framework's BUILT file.
-built_framework_dep := $(call java-lib-deps,framework)
-built_framework_classes := $(call java-lib-files,framework)
+built_framework_dep := $(call java-lib-deps,framework-base)
+built_framework_classes := $(call java-lib-files,framework-base)
built_core_dep := $(call java-lib-deps,core)
built_core_classes := $(call java-lib-files,core)
diff --git a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java
index 5256b58..d85c3d1 100644
--- a/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java
@@ -24,10 +24,13 @@ import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
import android.content.res.BridgeResources.NinePatchInputStream;
import android.graphics.BitmapFactory.Options;
+import android.graphics.Bitmap_Delegate.BitmapCreateFlags;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InputStream;
+import java.util.EnumSet;
+import java.util.Set;
/**
* Delegate implementing the native methods of android.graphics.BitmapFactory
@@ -41,65 +44,20 @@ import java.io.InputStream;
*/
/*package*/ class BitmapFactory_Delegate {
- // ------ Java delegates ------
-
- @LayoutlibDelegate
- /*package*/ static Bitmap finishDecode(Bitmap bm, Rect outPadding, Options opts) {
- if (bm == null || opts == null) {
- return bm;
- }
-
- final int density = opts.inDensity;
- if (density == 0) {
- return bm;
- }
-
- bm.setDensity(density);
- final int targetDensity = opts.inTargetDensity;
- if (targetDensity == 0 || density == targetDensity || density == opts.inScreenDensity) {
- return bm;
- }
-
- byte[] np = bm.getNinePatchChunk();
- final boolean isNinePatch = np != null && NinePatch.isNinePatchChunk(np);
- // DELEGATE CHANGE: never scale 9-patch
- if (opts.inScaled && isNinePatch == false) {
- float scale = targetDensity / (float)density;
- // TODO: This is very inefficient and should be done in native by Skia
- final Bitmap oldBitmap = bm;
- bm = Bitmap.createScaledBitmap(oldBitmap, (int) (bm.getWidth() * scale + 0.5f),
- (int) (bm.getHeight() * scale + 0.5f), true);
- oldBitmap.recycle();
-
- if (isNinePatch) {
- np = nativeScaleNinePatch(np, scale, outPadding);
- bm.setNinePatchChunk(np);
- }
- bm.setDensity(targetDensity);
- }
-
- return bm;
- }
-
-
// ------ Native Delegates ------
@LayoutlibDelegate
/*package*/ static Bitmap nativeDecodeStream(InputStream is, byte[] storage,
Rect padding, Options opts) {
- return nativeDecodeStream(is, storage, padding, opts, false, 1.f);
- }
-
- @LayoutlibDelegate
- /*package*/ static Bitmap nativeDecodeStream(InputStream is, byte[] storage,
- Rect padding, Options opts, boolean applyScale, float scale) {
Bitmap bm = null;
- //TODO support rescaling
-
Density density = Density.MEDIUM;
+ Set<BitmapCreateFlags> bitmapCreateFlags = EnumSet.of(BitmapCreateFlags.MUTABLE);
if (opts != null) {
density = Density.getEnum(opts.inDensity);
+ if (opts.inPremultiplied) {
+ bitmapCreateFlags.add(BitmapCreateFlags.PREMULTIPLIED);
+ }
}
try {
@@ -112,7 +70,7 @@ import java.io.InputStream;
npis, true /*is9Patch*/, false /*convert*/);
// get the bitmap and chunk objects.
- bm = Bitmap_Delegate.createBitmap(ninePatch.getImage(), true /*isMutable*/,
+ bm = Bitmap_Delegate.createBitmap(ninePatch.getImage(), bitmapCreateFlags,
density);
NinePatchChunk chunk = ninePatch.getChunk();
@@ -127,7 +85,7 @@ import java.io.InputStream;
padding.bottom = paddingarray[3];
} else {
// load the bitmap directly.
- bm = Bitmap_Delegate.createBitmap(is, true, density);
+ bm = Bitmap_Delegate.createBitmap(is, bitmapCreateFlags, density);
}
} catch (IOException e) {
Bridge.getLog().error(null,"Failed to load image" , e, null);
@@ -150,13 +108,6 @@ import java.io.InputStream;
}
@LayoutlibDelegate
- /*package*/ static Bitmap nativeDecodeAsset(int asset, Rect padding, Options opts,
- boolean applyScale, float scale) {
- opts.inBitmap = null;
- return null;
- }
-
- @LayoutlibDelegate
/*package*/ static Bitmap nativeDecodeByteArray(byte[] data, int offset,
int length, Options opts) {
opts.inBitmap = null;
@@ -164,13 +115,6 @@ import java.io.InputStream;
}
@LayoutlibDelegate
- /*package*/ static byte[] nativeScaleNinePatch(byte[] chunk, float scale, Rect pad) {
- // don't scale for now. This should not be called anyway since we re-implement
- // BitmapFactory.finishDecode();
- return chunk;
- }
-
- @LayoutlibDelegate
/*package*/ static boolean nativeIsSeekable(FileDescriptor fd) {
return true;
}
diff --git a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
index 9c7a0cc..f74e4d1 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Bitmap_Delegate.java
@@ -33,6 +33,8 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.nio.Buffer;
import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.Set;
import javax.imageio.ImageIO;
@@ -51,6 +53,10 @@ import javax.imageio.ImageIO;
*/
public final class Bitmap_Delegate {
+ public enum BitmapCreateFlags {
+ PREMULTIPLIED, MUTABLE
+ }
+
// ---- delegate manager ----
private static final DelegateManager<Bitmap_Delegate> sManager =
new DelegateManager<Bitmap_Delegate>(Bitmap_Delegate.class);
@@ -93,10 +99,25 @@ public final class Bitmap_Delegate {
*/
public static Bitmap createBitmap(File input, boolean isMutable, Density density)
throws IOException {
+ return createBitmap(input, getPremultipliedBitmapCreateFlags(isMutable), density);
+ }
+
+ /**
+ * Creates and returns a {@link Bitmap} initialized with the given file content.
+ *
+ * @param input the file from which to read the bitmap content
+ * @param density the density associated with the bitmap
+ *
+ * @see Bitmap#isPremultiplied()
+ * @see Bitmap#isMutable()
+ * @see Bitmap#getDensity()
+ */
+ public static Bitmap createBitmap(File input, Set<BitmapCreateFlags> createFlags,
+ Density density) throws IOException {
// create a delegate with the content of the file.
Bitmap_Delegate delegate = new Bitmap_Delegate(ImageIO.read(input), Config.ARGB_8888);
- return createBitmap(delegate, isMutable, density.getDpiValue());
+ return createBitmap(delegate, createFlags, density.getDpiValue());
}
/**
@@ -111,10 +132,26 @@ public final class Bitmap_Delegate {
*/
public static Bitmap createBitmap(InputStream input, boolean isMutable, Density density)
throws IOException {
+ return createBitmap(input, getPremultipliedBitmapCreateFlags(isMutable), density);
+ }
+
+ /**
+ * Creates and returns a {@link Bitmap} initialized with the given stream content.
+ *
+ * @param input the stream from which to read the bitmap content
+ * @param createFlags
+ * @param density the density associated with the bitmap
+ *
+ * @see Bitmap#isPremultiplied()
+ * @see Bitmap#isMutable()
+ * @see Bitmap#getDensity()
+ */
+ public static Bitmap createBitmap(InputStream input, Set<BitmapCreateFlags> createFlags,
+ Density density) throws IOException {
// create a delegate with the content of the stream.
Bitmap_Delegate delegate = new Bitmap_Delegate(ImageIO.read(input), Config.ARGB_8888);
- return createBitmap(delegate, isMutable, density.getDpiValue());
+ return createBitmap(delegate, createFlags, density.getDpiValue());
}
/**
@@ -129,10 +166,26 @@ public final class Bitmap_Delegate {
*/
public static Bitmap createBitmap(BufferedImage image, boolean isMutable,
Density density) throws IOException {
+ return createBitmap(image, getPremultipliedBitmapCreateFlags(isMutable), density);
+ }
+
+ /**
+ * Creates and returns a {@link Bitmap} initialized with the given {@link BufferedImage}
+ *
+ * @param image the bitmap content
+ * @param createFlags
+ * @param density the density associated with the bitmap
+ *
+ * @see Bitmap#isPremultiplied()
+ * @see Bitmap#isMutable()
+ * @see Bitmap#getDensity()
+ */
+ public static Bitmap createBitmap(BufferedImage image, Set<BitmapCreateFlags> createFlags,
+ Density density) throws IOException {
// create a delegate with the given image.
Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.ARGB_8888);
- return createBitmap(delegate, isMutable, density.getDpiValue());
+ return createBitmap(delegate, createFlags, density.getDpiValue());
}
/**
@@ -203,7 +256,7 @@ public final class Bitmap_Delegate {
@LayoutlibDelegate
/*package*/ static Bitmap nativeCreate(int[] colors, int offset, int stride, int width,
- int height, int nativeConfig, boolean mutable) {
+ int height, int nativeConfig, boolean isMutable) {
int imageType = getBufferedImageType(nativeConfig);
// create the image
@@ -216,7 +269,8 @@ public final class Bitmap_Delegate {
// create a delegate with the content of the stream.
Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.nativeToConfig(nativeConfig));
- return createBitmap(delegate, mutable, Bitmap.getDefaultDensity());
+ return createBitmap(delegate, getPremultipliedBitmapCreateFlags(isMutable),
+ Bitmap.getDefaultDensity());
}
@LayoutlibDelegate
@@ -244,7 +298,8 @@ public final class Bitmap_Delegate {
// create a delegate with the content of the stream.
Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.nativeToConfig(nativeConfig));
- return createBitmap(delegate, isMutable, Bitmap.getDefaultDensity());
+ return createBitmap(delegate, getPremultipliedBitmapCreateFlags(isMutable),
+ Bitmap.getDefaultDensity());
}
@LayoutlibDelegate
@@ -259,6 +314,13 @@ public final class Bitmap_Delegate {
}
@LayoutlibDelegate
+ /*package*/ static void nativeReconfigure(int nativeBitmap, int width, int height,
+ int config, int allocSize) {
+ Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED,
+ "Bitmap.reconfigure() is not supported", null /*data*/);
+ }
+
+ @LayoutlibDelegate
/*package*/ static boolean nativeCompress(int nativeBitmap, int format, int quality,
OutputStream stream, byte[] tempStorage) {
Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED,
@@ -287,28 +349,6 @@ public final class Bitmap_Delegate {
}
@LayoutlibDelegate
- /*package*/ static int nativeWidth(int nativeBitmap) {
- // get the delegate from the native int.
- Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
- if (delegate == null) {
- return 0;
- }
-
- return delegate.mImage.getWidth();
- }
-
- @LayoutlibDelegate
- /*package*/ static int nativeHeight(int nativeBitmap) {
- // get the delegate from the native int.
- Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
- if (delegate == null) {
- return 0;
- }
-
- return delegate.mImage.getHeight();
- }
-
- @LayoutlibDelegate
/*package*/ static int nativeRowBytes(int nativeBitmap) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
@@ -353,19 +393,21 @@ public final class Bitmap_Delegate {
}
@LayoutlibDelegate
- /*package*/ static int nativeGetPixel(int nativeBitmap, int x, int y) {
+ /*package*/ static int nativeGetPixel(int nativeBitmap, int x, int y,
+ boolean isPremultiplied) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return 0;
}
+ // TODO: Support isPremultiplied.
return delegate.mImage.getRGB(x, y);
}
@LayoutlibDelegate
/*package*/ static void nativeGetPixels(int nativeBitmap, int[] pixels, int offset,
- int stride, int x, int y, int width, int height) {
+ int stride, int x, int y, int width, int height, boolean isPremultiplied) {
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return;
@@ -376,7 +418,8 @@ public final class Bitmap_Delegate {
@LayoutlibDelegate
- /*package*/ static void nativeSetPixel(int nativeBitmap, int x, int y, int color) {
+ /*package*/ static void nativeSetPixel(int nativeBitmap, int x, int y, int color,
+ boolean isPremultiplied) {
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return;
@@ -387,7 +430,7 @@ public final class Bitmap_Delegate {
@LayoutlibDelegate
/*package*/ static void nativeSetPixels(int nativeBitmap, int[] colors, int offset,
- int stride, int x, int y, int width, int height) {
+ int stride, int x, int y, int width, int height, boolean isPremultiplied) {
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
return;
@@ -465,7 +508,7 @@ public final class Bitmap_Delegate {
Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.ALPHA_8);
// the density doesn't matter, it's set by the Java method.
- return createBitmap(delegate, false /*isMutable*/,
+ return createBitmap(delegate, EnumSet.of(BitmapCreateFlags.MUTABLE),
Density.DEFAULT_DENSITY /*density*/);
}
@@ -475,7 +518,8 @@ public final class Bitmap_Delegate {
}
@LayoutlibDelegate
- /*package*/ static void nativeSetHasAlpha(int nativeBitmap, boolean hasAlpha) {
+ /*package*/ static void nativeSetAlphaAndPremultiplied(int nativeBitmap, boolean hasAlpha,
+ boolean isPremul) {
// get the delegate from the native int.
Bitmap_Delegate delegate = sManager.getDelegate(nativeBitmap);
if (delegate == null) {
@@ -547,13 +591,27 @@ public final class Bitmap_Delegate {
mConfig = config;
}
- private static Bitmap createBitmap(Bitmap_Delegate delegate, boolean isMutable, int density) {
+ private static Bitmap createBitmap(Bitmap_Delegate delegate,
+ Set<BitmapCreateFlags> createFlags, int density) {
// get its native_int
int nativeInt = sManager.addNewDelegate(delegate);
+ int width = delegate.mImage.getWidth();
+ int height = delegate.mImage.getHeight();
+ boolean isMutable = createFlags.contains(BitmapCreateFlags.MUTABLE);
+ boolean isPremultiplied = createFlags.contains(BitmapCreateFlags.PREMULTIPLIED);
+
// and create/return a new Bitmap with it
- return new Bitmap(nativeInt, null /* buffer */, isMutable, null /*ninePatchChunk*/,
- density);
+ return new Bitmap(nativeInt, null /* buffer */, width, height, density, isMutable,
+ isPremultiplied, null /*ninePatchChunk*/, null /* layoutBounds */);
+ }
+
+ private static Set<BitmapCreateFlags> getPremultipliedBitmapCreateFlags(boolean isMutable) {
+ Set<BitmapCreateFlags> createFlags = EnumSet.of(BitmapCreateFlags.PREMULTIPLIED);
+ if (isMutable) {
+ createFlags.add(BitmapCreateFlags.MUTABLE);
+ }
+ return createFlags;
}
/**
diff --git a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
index d1d0f09..10ad0a3 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Canvas_Delegate.java
@@ -1076,14 +1076,6 @@ public final class Canvas_Delegate {
}
@LayoutlibDelegate
- /*package*/ static void native_drawPicture(int nativeCanvas,
- int nativePicture) {
- // FIXME
- Bridge.getLog().fidelityWarning(LayoutLog.TAG_UNSUPPORTED,
- "Canvas.drawPicture is not supported.", null, null /*data*/);
- }
-
- @LayoutlibDelegate
/*package*/ static void finalizer(int nativeCanvas) {
// get the delegate from the native int so that it can be disposed.
Canvas_Delegate canvasDelegate = sManager.getDelegate(nativeCanvas);
diff --git a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java
index 390044a..a79ec8f 100644
--- a/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/NinePatch_Delegate.java
@@ -48,6 +48,11 @@ import java.util.Map;
*/
public final class NinePatch_Delegate {
+ // ---- delegate manager ----
+ private static final DelegateManager<NinePatch_Delegate> sManager =
+ new DelegateManager<NinePatch_Delegate>(NinePatch_Delegate.class);
+
+ // ---- delegate helper data ----
/**
* Cache map for {@link NinePatchChunk}.
* When the chunks are created they are serialized into a byte[], and both are put
@@ -60,6 +65,10 @@ public final class NinePatch_Delegate {
private final static Map<byte[], SoftReference<NinePatchChunk>> sChunkCache =
new HashMap<byte[], SoftReference<NinePatchChunk>>();
+ // ---- delegate data ----
+ private byte[] chunk;
+
+
// ---- Public Helper methods ----
/**
@@ -149,32 +158,40 @@ public final class NinePatch_Delegate {
}
@LayoutlibDelegate
- /*package*/ static void validateNinePatchChunk(int bitmap, byte[] chunk) {
+ /*package*/ static int validateNinePatchChunk(int bitmap, byte[] chunk) {
// the default JNI implementation only checks that the byte[] has the same
// size as the C struct it represent. Since we cannot do the same check (serialization
// will return different size depending on content), we do nothing.
+ NinePatch_Delegate newDelegate = new NinePatch_Delegate();
+ newDelegate.chunk = chunk;
+ return sManager.addNewDelegate(newDelegate);
+ }
+
+ @LayoutlibDelegate
+ /*package*/ static void nativeFinalize(int chunk) {
+ sManager.removeJavaReferenceFor(chunk);
}
@LayoutlibDelegate
/*package*/ static void nativeDraw(int canvas_instance, RectF loc, int bitmap_instance,
- byte[] c, int paint_instance_or_null, int destDensity, int srcDensity) {
+ int chunk, int paint_instance_or_null, int destDensity, int srcDensity) {
draw(canvas_instance,
(int) loc.left, (int) loc.top, (int) loc.right, (int) loc.bottom,
- bitmap_instance, c, paint_instance_or_null,
+ bitmap_instance, chunk, paint_instance_or_null,
destDensity, srcDensity);
}
@LayoutlibDelegate
/*package*/ static void nativeDraw(int canvas_instance, Rect loc, int bitmap_instance,
- byte[] c, int paint_instance_or_null, int destDensity, int srcDensity) {
+ int chunk, int paint_instance_or_null, int destDensity, int srcDensity) {
draw(canvas_instance,
loc.left, loc.top, loc.right, loc.bottom,
- bitmap_instance, c, paint_instance_or_null,
+ bitmap_instance, chunk, paint_instance_or_null,
destDensity, srcDensity);
}
@LayoutlibDelegate
- /*package*/ static int nativeGetTransparentRegion(int bitmap, byte[] chunk, Rect location) {
+ /*package*/ static int nativeGetTransparentRegion(int bitmap, int chunk, Rect location) {
return 0;
}
@@ -182,7 +199,7 @@ public final class NinePatch_Delegate {
private static void draw(int canvas_instance,
final int left, final int top, final int right, final int bottom,
- int bitmap_instance, byte[] c, int paint_instance_or_null,
+ int bitmap_instance, int chunk, int paint_instance_or_null,
final int destDensity, final int srcDensity) {
// get the delegate from the native int.
final Bitmap_Delegate bitmap_delegate = Bitmap_Delegate.getDelegate(bitmap_instance);
@@ -190,6 +207,11 @@ public final class NinePatch_Delegate {
return;
}
+ byte[] c = null;
+ NinePatch_Delegate delegate = sManager.getDelegate(chunk);
+ if (delegate != null) {
+ c = delegate.chunk;
+ }
if (c == null) {
// not a 9-patch?
BufferedImage image = bitmap_delegate.getImage();
diff --git a/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java b/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java
index 64f19d3..9d80be9 100644
--- a/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Path_Delegate.java
@@ -474,6 +474,12 @@ public final class Path_Delegate {
}
@LayoutlibDelegate
+ /*package*/ static boolean native_op(int nPath1, int nPath2, int op, int result) {
+ Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "Path.op() not supported", null);
+ return false;
+ }
+
+ @LayoutlibDelegate
/*package*/ static void finalizer(int nPath) {
sManager.removeJavaReferenceFor(nPath);
}
diff --git a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java
index 434b131..dd2cbc1 100644
--- a/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java
+++ b/tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java
@@ -49,15 +49,13 @@ public class IWindowManagerImpl implements IWindowManager {
private final Configuration mConfig;
private final DisplayMetrics mMetrics;
private final int mRotation;
- private final boolean mHasSystemNavBar;
private final boolean mHasNavigationBar;
public IWindowManagerImpl(Configuration config, DisplayMetrics metrics, int rotation,
- boolean hasSystemNavBar, boolean hasNavigationBar) {
+ boolean hasNavigationBar) {
mConfig = config;
mMetrics = metrics;
mRotation = rotation;
- mHasSystemNavBar = hasSystemNavBar;
mHasNavigationBar = hasNavigationBar;
}
@@ -79,16 +77,11 @@ public class IWindowManagerImpl implements IWindowManager {
return mHasNavigationBar;
}
- @Override
- public boolean hasSystemNavBar() throws RemoteException {
- return mHasSystemNavBar;
- }
-
// ---- unused implementation of IWindowManager ----
@Override
- public void addAppToken(int arg0, IApplicationToken arg1, int arg2, int arg3, boolean arg4,
- boolean arg5)
+ public void addAppToken(int arg0, IApplicationToken arg1, int arg2, int arg3, int arg4,
+ boolean arg5, boolean arg6, int arg7, int arg8)
throws RemoteException {
// TODO Auto-generated method stub
@@ -211,24 +204,6 @@ public class IWindowManagerImpl implements IWindowManager {
}
@Override
- public void moveAppToken(int arg0, IBinder arg1) throws RemoteException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void moveAppTokensToBottom(List<IBinder> arg0) throws RemoteException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void moveAppTokensToTop(List<IBinder> arg0) throws RemoteException {
- // TODO Auto-generated method stub
-
- }
-
- @Override
public IWindowSession openSession(IInputMethodClient arg0, IInputContext arg1)
throws RemoteException {
// TODO Auto-generated method stub
@@ -291,8 +266,8 @@ public class IWindowManagerImpl implements IWindowManager {
}
@Override
- public Bitmap screenshotApplications(IBinder arg0, int displayId, int arg1, int arg2)
- throws RemoteException {
+ public Bitmap screenshotApplications(IBinder arg0, int displayId, int arg1,
+ int arg2, boolean arg3) throws RemoteException {
// TODO Auto-generated method stub
return null;
}
@@ -322,7 +297,7 @@ public class IWindowManagerImpl implements IWindowManager {
@Override
public void setAppStartingWindow(IBinder arg0, String arg1, int arg2, CompatibilityInfo arg3,
- CharSequence arg4, int arg5, int arg6, int arg7, IBinder arg8, boolean arg9)
+ CharSequence arg4, int arg5, int arg6, int arg7, int arg8, IBinder arg9, boolean arg10)
throws RemoteException {
// TODO Auto-generated method stub
}
@@ -483,11 +458,6 @@ public class IWindowManagerImpl implements IWindowManager {
}
@Override
- public void showAssistant() {
-
- }
-
- @Override
public IBinder getFocusedWindowToken() {
// TODO Auto-generated method stub
return null;
@@ -524,4 +494,8 @@ public class IWindowManagerImpl implements IWindowManager {
// TODO Auto-generated method stub
return false;
}
+
+ @Override
+ public void setTouchExplorationEnabled(boolean enabled) {
+ }
}
diff --git a/tools/layoutlib/bridge/src/android/webkit/WebView.java b/tools/layoutlib/bridge/src/android/webkit/WebView.java
index 3b66188..202f204 100644
--- a/tools/layoutlib/bridge/src/android/webkit/WebView.java
+++ b/tools/layoutlib/bridge/src/android/webkit/WebView.java
@@ -99,14 +99,6 @@ public class WebView extends MockView {
public static void disablePlatformNotifications() {
}
- public WebBackForwardList saveState(Bundle outState) {
- return null;
- }
-
- public WebBackForwardList restoreState(Bundle inState) {
- return null;
- }
-
public void loadUrl(String url) {
}
@@ -213,10 +205,6 @@ public class WebView extends MockView {
public void clearSslPreferences() {
}
- public WebBackForwardList copyBackForwardList() {
- return null;
- }
-
public static String findAddress(String addr) {
return null;
}
@@ -236,10 +224,6 @@ public class WebView extends MockView {
public void addJavascriptInterface(Object obj, String interfaceName) {
}
- public WebSettings getSettings() {
- return null;
- }
-
public View getZoomControls() {
return null;
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContentProvider.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContentProvider.java
index 4aea38f..01740b1 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContentProvider.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContentProvider.java
@@ -81,14 +81,16 @@ public final class BridgeContentProvider implements IContentProvider {
}
@Override
- public AssetFileDescriptor openAssetFile(String callingPackage, Uri arg0, String arg1)
+ public AssetFileDescriptor openAssetFile(
+ String callingPackage, Uri arg0, String arg1, ICancellationSignal signal)
throws RemoteException, FileNotFoundException {
// TODO Auto-generated method stub
return null;
}
@Override
- public ParcelFileDescriptor openFile(String callingPackage, Uri arg0, String arg1)
+ public ParcelFileDescriptor openFile(
+ String callingPackage, Uri arg0, String arg1, ICancellationSignal signal)
throws RemoteException, FileNotFoundException {
// TODO Auto-generated method stub
return null;
@@ -122,7 +124,7 @@ public final class BridgeContentProvider implements IContentProvider {
@Override
public AssetFileDescriptor openTypedAssetFile(String callingPackage, Uri arg0, String arg1,
- Bundle arg2) throws RemoteException, FileNotFoundException {
+ Bundle arg2, ICancellationSignal signal) throws RemoteException, FileNotFoundException {
// TODO Auto-generated method stub
return null;
}
@@ -132,4 +134,14 @@ public final class BridgeContentProvider implements IContentProvider {
// TODO Auto-generated method stub
return null;
}
+
+ @Override
+ public Uri canonicalize(String callingPkg, Uri uri) throws RemoteException {
+ return null;
+ }
+
+ @Override
+ public Uri uncanonicalize(String callingPkg, Uri uri) throws RemoteException {
+ return null;
+ }
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
index 93a98a0..625f108 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java
@@ -68,8 +68,8 @@ import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.BridgeInflater;
-import android.view.CompatibilityInfoHolder;
import android.view.Display;
+import android.view.DisplayAdjustments;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
@@ -1104,6 +1104,12 @@ public final class BridgeContext extends Context {
}
@Override
+ public String getOpPackageName() {
+ // pass
+ return null;
+ }
+
+ @Override
public ApplicationInfo getApplicationInfo() {
return mApplicationInfo;
}
@@ -1412,7 +1418,7 @@ public final class BridgeContext extends Context {
}
@Override
- public CompatibilityInfoHolder getCompatibilityInfo(int displayId) {
+ public DisplayAdjustments getDisplayAdjustments(int displayId) {
// pass
return null;
}
@@ -1424,4 +1430,22 @@ public final class BridgeContext extends Context {
public int getUserId() {
return 0; // not used
}
+
+ @Override
+ public File[] getExternalFilesDirs(String type) {
+ // pass
+ return new File[0];
+ }
+
+ @Override
+ public File[] getObbDirs() {
+ // pass
+ return new File[0];
+ }
+
+ @Override
+ public File[] getExternalCacheDirs() {
+ // pass
+ return new File[0];
+ }
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeIInputMethodManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeIInputMethodManager.java
index d6abbaa..3cf5ed5 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeIInputMethodManager.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeIInputMethodManager.java
@@ -63,7 +63,7 @@ public class BridgeIInputMethodManager implements IInputMethodManager {
}
@Override
- public List<InputMethodSubtype> getEnabledInputMethodSubtypeList(InputMethodInfo arg0,
+ public List<InputMethodSubtype> getEnabledInputMethodSubtypeList(String arg0,
boolean arg1) throws RemoteException {
// TODO Auto-generated method stub
return null;
@@ -203,6 +203,12 @@ public class BridgeIInputMethodManager implements IInputMethodManager {
}
@Override
+ public boolean shouldOfferSwitchingToNextInputMethod(IBinder arg0) throws RemoteException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
public void updateStatusIcon(IBinder arg0, String arg1, int arg2) throws RemoteException {
// TODO Auto-generated method stub
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
index 1ccbc40..281337c 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
@@ -39,7 +39,13 @@ public class BridgePowerManager implements IPowerManager {
}
@Override
- public void acquireWakeLock(IBinder arg0, int arg1, String arg2, WorkSource arg3)
+ public void acquireWakeLock(IBinder arg0, int arg1, String arg2, String arg2_5, WorkSource arg3)
+ throws RemoteException {
+ // pass for now.
+ }
+
+ @Override
+ public void acquireWakeLockWithUid(IBinder arg0, int arg1, String arg2, String arg2_5, int arg3)
throws RemoteException {
// pass for now.
}
@@ -75,6 +81,11 @@ public class BridgePowerManager implements IPowerManager {
}
@Override
+ public void updateWakeLockUids(IBinder arg0, int[] arg1) throws RemoteException {
+ // pass for now.
+ }
+
+ @Override
public void setAttentionLight(boolean arg0, int arg1) throws RemoteException {
// pass for now.
}
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/view/WindowManagerImpl.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/view/WindowManagerImpl.java
index 9a633bf..7e5ae8d 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/view/WindowManagerImpl.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/view/WindowManagerImpl.java
@@ -17,6 +17,7 @@ package com.android.layoutlib.bridge.android.view;
import android.util.DisplayMetrics;
import android.view.Display;
+import android.view.DisplayAdjustments;
import android.view.DisplayInfo;
import android.view.View;
import android.view.WindowManager;
@@ -32,7 +33,8 @@ public class WindowManagerImpl implements WindowManager {
DisplayInfo info = new DisplayInfo();
info.logicalHeight = mMetrics.heightPixels;
info.logicalWidth = mMetrics.widthPixels;
- mDisplay = new Display(null, Display.DEFAULT_DISPLAY, info, null);
+ mDisplay = new Display(null, Display.DEFAULT_DISPLAY, info,
+ DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS);
}
@Override
diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java
index 854f3b2..0d0c80f 100644
--- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java
+++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/bars/ActionBarLayout.java
@@ -154,17 +154,16 @@ public class ActionBarLayout extends LinearLayout {
setupTabs(3);
}
- // Ideally we should get the icon from the mThemedContext using R.styleable.ActionBar_icon.
- // But for simplicity, we are using the icon passed from the session params. This has been
- // fixed in API 19.
- if (mIcon != null) {
- Drawable iconDrawable = getDrawable(mIcon, false /*isFramework*/);
- if (iconDrawable != null) {
- mActionBar.setIcon(iconDrawable);
+ if (mActionBarView != null) {
+ // If the action bar style doesn't specify an icon, set the icon obtained from the session
+ // params.
+ if (!mActionBarView.hasIcon() && mIcon != null) {
+ Drawable iconDrawable = getDrawable(mIcon, false /*isFramework*/);
+ if (iconDrawable != null) {
+ mActionBar.setIcon(iconDrawable);
+ }
}
- }
- if (mActionBarView != null) {
// Set action bar to be split, if needed.
ActionBarContainer splitView = (ActionBarContainer) findViewById(R.id.split_action_bar);
mActionBarView.setSplitView(splitView);
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 9a7fe18..bd42ca4 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
@@ -204,12 +204,11 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
findNavigationBar(resources, metrics);
// FIXME: find those out, and possibly add them to the render params
- boolean hasSystemNavBar = true;
boolean hasNavigationBar = true;
//noinspection ConstantConditions
IWindowManager iwm = new IWindowManagerImpl(getContext().getConfiguration(),
metrics, Surface.ROTATION_0,
- hasSystemNavBar, hasNavigationBar);
+ hasNavigationBar);
WindowManagerGlobal_Delegate.setWindowManagerService(iwm);
// build the inflater and parser.
diff --git a/tools/layoutlib/bridge/src/libcore/icu/DateIntervalFormat_Delegate.java b/tools/layoutlib/bridge/src/libcore/icu/DateIntervalFormat_Delegate.java
new file mode 100644
index 0000000..d94c205
--- /dev/null
+++ b/tools/layoutlib/bridge/src/libcore/icu/DateIntervalFormat_Delegate.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package libcore.icu;
+
+import java.text.FieldPosition;
+
+import com.android.ide.common.rendering.api.LayoutLog;
+import com.android.layoutlib.bridge.Bridge;
+import com.android.layoutlib.bridge.impl.DelegateManager;
+import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
+import com.ibm.icu.text.DateIntervalFormat;
+import com.ibm.icu.util.DateInterval;
+import com.ibm.icu.util.TimeZone;
+import com.ibm.icu.util.ULocale;
+
+public class DateIntervalFormat_Delegate {
+
+ // ---- delegate manager ----
+ private static final DelegateManager<DateIntervalFormat_Delegate> sManager =
+ new DelegateManager<DateIntervalFormat_Delegate>(DateIntervalFormat_Delegate.class);
+
+ // ---- delegate data ----
+ private DateIntervalFormat mFormat;
+
+
+ // ---- native methods ----
+
+ @LayoutlibDelegate
+ /*package*/static String formatDateInterval(long address, long fromDate, long toDate) {
+ DateIntervalFormat_Delegate delegate = sManager.getDelegate((int)address);
+ if (delegate == null) {
+ Bridge.getLog().error(LayoutLog.TAG_BROKEN,
+ "Unable for find native DateIntervalFormat", null);
+ return null;
+ }
+ DateInterval interval = new DateInterval(fromDate, toDate);
+ StringBuffer sb = new StringBuffer();
+ FieldPosition pos = new FieldPosition(0);
+ delegate.mFormat.format(interval, sb, pos);
+ return sb.toString();
+ }
+
+ @LayoutlibDelegate
+ /*package*/ static long createDateIntervalFormat(String skeleton, String localeName,
+ String tzName) {
+ TimeZone prevDefaultTz = TimeZone.getDefault();
+ TimeZone.setDefault(TimeZone.getTimeZone(tzName));
+ DateIntervalFormat_Delegate newDelegate = new DateIntervalFormat_Delegate();
+ newDelegate.mFormat =
+ DateIntervalFormat.getInstance(skeleton, new ULocale(localeName));
+ TimeZone.setDefault(prevDefaultTz);
+ return sManager.addNewDelegate(newDelegate);
+ }
+
+ @LayoutlibDelegate
+ /*package*/ static void destroyDateIntervalFormat(long address) {
+ sManager.removeJavaReferenceFor((int)address);
+ }
+
+}
diff --git a/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java b/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java
index 06ae804..ad4103b 100644
--- a/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java
+++ b/tools/layoutlib/bridge/src/libcore/icu/ICU_Delegate.java
@@ -46,7 +46,7 @@ public class ICU_Delegate {
// --- Native methods accessing ICU's database.
@LayoutlibDelegate
- /*package*/ static String getBestDateTimePattern(String skeleton, String localeName) {
+ /*package*/ static String getBestDateTimePatternNative(String skeleton, String localeName) {
return DateTimePatternGenerator.getInstance(new ULocale(localeName))
.getBestPattern(skeleton);
}
@@ -167,7 +167,7 @@ public class ICU_Delegate {
}
@LayoutlibDelegate
- /*package*/ static boolean initLocaleDataImpl(String locale, LocaleData result) {
+ /*package*/ static boolean initLocaleDataNative(String locale, LocaleData result) {
// Used by Calendar.
result.firstDayOfWeek = Integer.valueOf(1);
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
index 5362fd7..4705dec 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java
@@ -196,6 +196,7 @@ public final class CreateInfo implements ICreateInfo {
"android.text.format.Time",
"android.util.FloatMath",
"android.view.Display",
+ "libcore.icu.DateIntervalFormat",
"libcore.icu.ICU",
};
diff --git a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java
index bc4caf2..2e952fc 100644
--- a/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java
+++ b/tools/layoutlib/create/src/com/android/tools/layoutlib/create/Main.java
@@ -114,6 +114,8 @@ public class Main {
"android.os.*", // for android.os.Handler
"android.database.ContentObserver", // for Digital clock
"com.android.i18n.phonenumbers.*", // for TextView with autolink attribute
+ "android.app.DatePickerDialog", // b.android.com/28318
+ "android.app.TimePickerDialog", // b.android.com/61515
"com.android.internal.view.menu.ActionMenu",
},
excludeClasses,