Make some methods/fields package private so that layoutlib can access them.
Change-Id: I4aeadfbaf8a4f6a459fa19937c21ac23d9e5fb64
This commit is contained in:
@ -54,8 +54,8 @@ public class ValueAnimator extends Animator {
|
||||
* Messages sent to timing handler: START is sent when an animation first begins, FRAME is sent
|
||||
* by the handler to itself to process the next animation frame
|
||||
*/
|
||||
private static final int ANIMATION_START = 0;
|
||||
private static final int ANIMATION_FRAME = 1;
|
||||
static final int ANIMATION_START = 0;
|
||||
static final int ANIMATION_FRAME = 1;
|
||||
|
||||
/**
|
||||
* Values used with internal variable mPlayingState to indicate the current state of an
|
||||
|
@ -62,7 +62,7 @@ public final class AssetManager {
|
||||
private static final boolean DEBUG_REFS = false;
|
||||
|
||||
private static final Object sSync = new Object();
|
||||
private static AssetManager sSystem = null;
|
||||
/*package*/ static AssetManager sSystem = null;
|
||||
|
||||
private final TypedValue mValue = new TypedValue();
|
||||
private final long[] mOffsets = new long[2];
|
||||
@ -252,7 +252,7 @@ public final class AssetManager {
|
||||
}
|
||||
}
|
||||
|
||||
private final void makeStringBlocks(boolean copyFromSystem) {
|
||||
/*package*/ final void makeStringBlocks(boolean copyFromSystem) {
|
||||
final int sysNum = copyFromSystem ? sSystem.mStringBlocks.length : 0;
|
||||
final int num = getStringBlockCount();
|
||||
mStringBlocks = new StringBlock[num];
|
||||
|
@ -77,7 +77,7 @@ public class Resources {
|
||||
private static final int ID_OTHER = 0x01000004;
|
||||
|
||||
private static final Object mSync = new Object();
|
||||
private static Resources mSystem = null;
|
||||
/*package*/ static Resources mSystem = null;
|
||||
|
||||
// Information about preloaded resources. Note that they are not
|
||||
// protected by a lock, because while preloading in zygote we are all
|
||||
|
@ -42,7 +42,7 @@ public class TypedArray {
|
||||
/*package*/ int[] mData;
|
||||
/*package*/ int[] mIndices;
|
||||
/*package*/ int mLength;
|
||||
private TypedValue mValue = new TypedValue();
|
||||
/*package*/ TypedValue mValue = new TypedValue();
|
||||
|
||||
/**
|
||||
* Return the number of values in this array.
|
||||
|
@ -21,9 +21,9 @@ package android.os;
|
||||
* used to create handler classes. Note that start() must still be called.
|
||||
*/
|
||||
public class HandlerThread extends Thread {
|
||||
private int mPriority;
|
||||
private int mTid = -1;
|
||||
private Looper mLooper;
|
||||
int mPriority;
|
||||
int mTid = -1;
|
||||
Looper mLooper;
|
||||
|
||||
public HandlerThread(String name) {
|
||||
super(name);
|
||||
|
@ -54,7 +54,7 @@ public class Looper {
|
||||
private static final String TAG = "Looper";
|
||||
|
||||
// sThreadLocal.get() will return null unless you've called prepare().
|
||||
private static final ThreadLocal<Looper> sThreadLocal = new ThreadLocal<Looper>();
|
||||
static final ThreadLocal<Looper> sThreadLocal = new ThreadLocal<Looper>();
|
||||
|
||||
final MessageQueue mQueue;
|
||||
final Thread mThread;
|
||||
|
@ -143,5 +143,5 @@ class XmlPullAttributes implements AttributeSet {
|
||||
return getAttributeResourceValue(null, "style", 0);
|
||||
}
|
||||
|
||||
private XmlPullParser mParser;
|
||||
/*package*/ XmlPullParser mParser;
|
||||
}
|
||||
|
@ -366,9 +366,9 @@ public class Display {
|
||||
// Following fields are initialized from native code
|
||||
private int mPixelFormat;
|
||||
private float mRefreshRate;
|
||||
private float mDensity;
|
||||
private float mDpiX;
|
||||
private float mDpiY;
|
||||
/*package*/ float mDensity;
|
||||
/*package*/ float mDpiX;
|
||||
/*package*/ float mDpiY;
|
||||
|
||||
private final Point mTmpPoint = new Point();
|
||||
private final DisplayMetrics mTmpMetrics = new DisplayMetrics();
|
||||
|
@ -75,9 +75,9 @@ public abstract class LayoutInflater {
|
||||
private Factory2 mPrivateFactory;
|
||||
private Filter mFilter;
|
||||
|
||||
private final Object[] mConstructorArgs = new Object[2];
|
||||
final Object[] mConstructorArgs = new Object[2];
|
||||
|
||||
private static final Class<?>[] mConstructorSignature = new Class[] {
|
||||
static final Class<?>[] mConstructorSignature = new Class[] {
|
||||
Context.class, AttributeSet.class};
|
||||
|
||||
private static final HashMap<String, Constructor<? extends View>> sConstructorMap =
|
||||
@ -705,7 +705,7 @@ public abstract class LayoutInflater {
|
||||
* Recursive method used to descend down the xml hierarchy and instantiate
|
||||
* views, instantiate their children, and then call onFinishInflate().
|
||||
*/
|
||||
private void rInflate(XmlPullParser parser, View parent, final AttributeSet attrs,
|
||||
void rInflate(XmlPullParser parser, View parent, final AttributeSet attrs,
|
||||
boolean finishInflate) throws XmlPullParserException, IOException {
|
||||
|
||||
final int depth = parser.getDepth();
|
||||
|
@ -225,7 +225,7 @@ public class ViewConfiguration {
|
||||
private boolean sHasPermanentMenuKey;
|
||||
private boolean sHasPermanentMenuKeySet;
|
||||
|
||||
private static final SparseArray<ViewConfiguration> sConfigurations =
|
||||
static final SparseArray<ViewConfiguration> sConfigurations =
|
||||
new SparseArray<ViewConfiguration>(2);
|
||||
|
||||
/**
|
||||
|
@ -93,7 +93,7 @@ public final class Bitmap implements Parcelable {
|
||||
|
||||
This can be called from JNI code.
|
||||
*/
|
||||
private Bitmap(int nativeBitmap, byte[] buffer, boolean isMutable, byte[] ninePatchChunk,
|
||||
/*package*/ Bitmap(int nativeBitmap, byte[] buffer, boolean isMutable, byte[] ninePatchChunk,
|
||||
int density) {
|
||||
if (nativeBitmap == 0) {
|
||||
throw new RuntimeException("internal error: native bitmap is 0");
|
||||
|
@ -70,16 +70,16 @@ public class Paint {
|
||||
*/
|
||||
public int mBidiFlags = BIDI_DEFAULT_LTR;
|
||||
|
||||
private static final Style[] sStyleArray = {
|
||||
static final Style[] sStyleArray = {
|
||||
Style.FILL, Style.STROKE, Style.FILL_AND_STROKE
|
||||
};
|
||||
private static final Cap[] sCapArray = {
|
||||
static final Cap[] sCapArray = {
|
||||
Cap.BUTT, Cap.ROUND, Cap.SQUARE
|
||||
};
|
||||
private static final Join[] sJoinArray = {
|
||||
static final Join[] sJoinArray = {
|
||||
Join.MITER, Join.ROUND, Join.BEVEL
|
||||
};
|
||||
private static final Align[] sAlignArray = {
|
||||
static final Align[] sAlignArray = {
|
||||
Align.LEFT, Align.CENTER, Align.RIGHT
|
||||
};
|
||||
|
||||
@ -103,7 +103,7 @@ public class Paint {
|
||||
public static final int DEV_KERN_TEXT_FLAG = 0x100;
|
||||
|
||||
// we use this when we first create a paint
|
||||
private static final int DEFAULT_PAINT_FLAGS = DEV_KERN_TEXT_FLAG;
|
||||
static final int DEFAULT_PAINT_FLAGS = DEV_KERN_TEXT_FLAG;
|
||||
|
||||
/**
|
||||
* Bidi flag to set LTR paragraph direction.
|
||||
|
@ -115,7 +115,7 @@ public class Path {
|
||||
}
|
||||
|
||||
// these must be in the same order as their native values
|
||||
private static final FillType[] sFillTypeArray = {
|
||||
static final FillType[] sFillTypeArray = {
|
||||
FillType.WINDING,
|
||||
FillType.EVEN_ODD,
|
||||
FillType.INVERSE_WINDING,
|
||||
|
@ -43,7 +43,7 @@ public class Typeface {
|
||||
/** The NORMAL style of the default monospace typeface. */
|
||||
public static final Typeface MONOSPACE;
|
||||
|
||||
private static Typeface[] sDefaults;
|
||||
/* package */ static Typeface[] sDefaults;
|
||||
|
||||
/* package */ int native_instance;
|
||||
|
||||
|
@ -14,13 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.layoutlib.bridge.impl;
|
||||
package android.animation;
|
||||
|
||||
import com.android.ide.common.rendering.api.IAnimationListener;
|
||||
import com.android.ide.common.rendering.api.RenderSession;
|
||||
import com.android.ide.common.rendering.api.Result;
|
||||
import com.android.ide.common.rendering.api.Result.Status;
|
||||
import com.android.layoutlib.bridge.Bridge;
|
||||
import com.android.layoutlib.bridge.impl.RenderSessionImpl;
|
||||
|
||||
import android.animation.ValueAnimator;
|
||||
import android.os.Handler;
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.layoutlib.bridge.android;
|
||||
package android.content.res;
|
||||
|
||||
import com.android.layoutlib.bridge.Bridge;
|
||||
|
||||
@ -30,7 +30,7 @@ public class BridgeAssetManager extends AssetManager {
|
||||
* <p/>
|
||||
* {@link Bridge} calls this method after setting up a new bridge.
|
||||
*/
|
||||
/*package*/ public static AssetManager initSystem() {
|
||||
public static AssetManager initSystem() {
|
||||
if (!(AssetManager.sSystem instanceof BridgeAssetManager)) {
|
||||
// Note that AssetManager() creates a system AssetManager and we override it
|
||||
// with our BridgeAssetManager.
|
@ -214,7 +214,15 @@ public final class BridgeResources extends Resources {
|
||||
Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
|
||||
|
||||
if (value != null) {
|
||||
return value.getSecond().getValue();
|
||||
ResourceValue resValue = value.getSecond();
|
||||
|
||||
assert resValue != null;
|
||||
if (resValue != null) {
|
||||
String v = resValue.getValue();
|
||||
if (v != null) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// id was not found or not resolved. Throw a NotFoundException.
|
||||
@ -318,8 +326,11 @@ public final class BridgeResources extends Resources {
|
||||
Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
|
||||
|
||||
if (value != null) {
|
||||
String v = value.getSecond().getValue();
|
||||
ResourceValue resValue = value.getSecond();
|
||||
|
||||
assert resValue != null;
|
||||
if (resValue != null) {
|
||||
String v = resValue.getValue();
|
||||
if (v != null) {
|
||||
if (v.equals(BridgeConstants.MATCH_PARENT) ||
|
||||
v.equals(BridgeConstants.FILL_PARENT)) {
|
||||
@ -335,6 +346,7 @@ public final class BridgeResources extends Resources {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// id was not found or not resolved. Throw a NotFoundException.
|
||||
throwException(id);
|
||||
@ -348,8 +360,11 @@ public final class BridgeResources extends Resources {
|
||||
Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
|
||||
|
||||
if (value != null) {
|
||||
String v = value.getSecond().getValue();
|
||||
ResourceValue resValue = value.getSecond();
|
||||
|
||||
assert resValue != null;
|
||||
if (resValue != null) {
|
||||
String v = resValue.getValue();
|
||||
if (v != null) {
|
||||
if (ResourceHelper.parseFloatAttribute(
|
||||
value.getFirst(), v, mTmpValue, true /*requireUnit*/) &&
|
||||
@ -359,6 +374,7 @@ public final class BridgeResources extends Resources {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// id was not found or not resolved. Throw a NotFoundException.
|
||||
throwException(id);
|
||||
@ -372,8 +388,11 @@ public final class BridgeResources extends Resources {
|
||||
Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
|
||||
|
||||
if (value != null) {
|
||||
String v = value.getSecond().getValue();
|
||||
ResourceValue resValue = value.getSecond();
|
||||
|
||||
assert resValue != null;
|
||||
if (resValue != null) {
|
||||
String v = resValue.getValue();
|
||||
if (v != null) {
|
||||
if (ResourceHelper.parseFloatAttribute(
|
||||
value.getFirst(), v, mTmpValue, true /*requireUnit*/) &&
|
||||
@ -383,6 +402,7 @@ public final class BridgeResources extends Resources {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// id was not found or not resolved. Throw a NotFoundException.
|
||||
throwException(id);
|
||||
@ -395,8 +415,13 @@ public final class BridgeResources extends Resources {
|
||||
public int getInteger(int id) throws NotFoundException {
|
||||
Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
|
||||
|
||||
if (value != null && value.getSecond().getValue() != null) {
|
||||
String v = value.getSecond().getValue();
|
||||
if (value != null) {
|
||||
ResourceValue resValue = value.getSecond();
|
||||
|
||||
assert resValue != null;
|
||||
if (resValue != null) {
|
||||
String v = resValue.getValue();
|
||||
if (v != null) {
|
||||
int radix = 10;
|
||||
if (v.startsWith("0x")) {
|
||||
v = v.substring(2);
|
||||
@ -408,6 +433,8 @@ public final class BridgeResources extends Resources {
|
||||
// return exception below
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// id was not found or not resolved. Throw a NotFoundException.
|
||||
throwException(id);
|
||||
@ -420,10 +447,17 @@ public final class BridgeResources extends Resources {
|
||||
public boolean getBoolean(int id) throws NotFoundException {
|
||||
Pair<String, ResourceValue> value = getResourceValue(id, mPlatformResourceFlag);
|
||||
|
||||
if (value != null && value.getSecond().getValue() != null) {
|
||||
String v = value.getSecond().getValue();
|
||||
if (value != null) {
|
||||
ResourceValue resValue = value.getSecond();
|
||||
|
||||
assert resValue != null;
|
||||
if (resValue != null) {
|
||||
String v = resValue.getValue();
|
||||
if (v != null) {
|
||||
return Boolean.parseBoolean(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// id was not found or not resolved. Throw a NotFoundException.
|
||||
throwException(id);
|
||||
|
@ -33,9 +33,6 @@ import com.android.resources.ResourceType;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
@ -896,12 +893,6 @@ public final class BridgeTypedArray extends TypedArray {
|
||||
// pass
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getValueAt(int index, TypedValue outValue) {
|
||||
// pass
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Arrays.toString(mResourceData);
|
||||
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2011 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 android.content.res;
|
||||
|
||||
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
|
||||
|
||||
import android.util.TypedValue;
|
||||
|
||||
public class TypedArray_Delegate {
|
||||
|
||||
@LayoutlibDelegate
|
||||
public static boolean getValueAt(TypedArray theTypedArray, int index, TypedValue outValue) {
|
||||
// pass
|
||||
return false;
|
||||
}
|
||||
}
|
@ -22,7 +22,6 @@ import com.android.layoutlib.bridge.impl.DelegateManager;
|
||||
import com.android.resources.Density;
|
||||
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.os.Parcel;
|
||||
|
||||
@ -149,7 +148,7 @@ public final class Bitmap_Delegate {
|
||||
}
|
||||
|
||||
public static int getBufferedImageType(int nativeBitmapConfig) {
|
||||
switch (Config.sConfigs[nativeBitmapConfig]) {
|
||||
switch (Config.nativeToConfig(nativeBitmapConfig)) {
|
||||
case ALPHA_8:
|
||||
return BufferedImage.TYPE_INT_ARGB;
|
||||
case RGB_565:
|
||||
@ -210,7 +209,7 @@ public final class Bitmap_Delegate {
|
||||
}
|
||||
|
||||
// create a delegate with the content of the stream.
|
||||
Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.sConfigs[nativeConfig]);
|
||||
Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.nativeToConfig(nativeConfig));
|
||||
|
||||
return createBitmap(delegate, mutable, Bitmap.getDefaultDensity());
|
||||
}
|
||||
@ -238,7 +237,7 @@ public final class Bitmap_Delegate {
|
||||
image.setRGB(0, 0, width, height, argb, 0, width);
|
||||
|
||||
// create a delegate with the content of the stream.
|
||||
Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.sConfigs[nativeConfig]);
|
||||
Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.nativeToConfig(nativeConfig));
|
||||
|
||||
return createBitmap(delegate, isMutable, Bitmap.getDefaultDensity());
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2011 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 android.graphics;
|
||||
|
||||
public class Typeface_Accessor {
|
||||
|
||||
public static void resetDefaults() {
|
||||
Typeface.sDefaults = null;
|
||||
}
|
||||
}
|
24
tools/layoutlib/bridge/src/android/os/Looper_Accessor.java
Normal file
24
tools/layoutlib/bridge/src/android/os/Looper_Accessor.java
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2011 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 android.os;
|
||||
|
||||
public class Looper_Accessor {
|
||||
|
||||
public static void cleanupThread() {
|
||||
// clean up the looper
|
||||
Looper.sThreadLocal.remove();
|
||||
}
|
||||
}
|
@ -68,4 +68,28 @@ public class SystemClock_Delegate {
|
||||
/*package*/ static long currentThreadTimeMillis() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns microseconds running in the current thread.
|
||||
*
|
||||
* @return elapsed microseconds in the thread
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static long currentThreadTimeMicro() {
|
||||
return System.currentTimeMillis() * 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current wall time in microseconds.
|
||||
*
|
||||
* @return elapsed microseconds in wall time
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@LayoutlibDelegate
|
||||
/*package*/ static long currentTimeMicro() {
|
||||
return elapsedRealtime() * 1000;
|
||||
}
|
||||
}
|
||||
|
@ -14,12 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.layoutlib.bridge.android;
|
||||
package android.util;
|
||||
|
||||
import com.android.ide.common.rendering.api.RenderResources;
|
||||
import com.android.ide.common.rendering.api.ResourceValue;
|
||||
import com.android.layoutlib.bridge.Bridge;
|
||||
import com.android.layoutlib.bridge.BridgeConstants;
|
||||
import com.android.layoutlib.bridge.android.BridgeContext;
|
||||
import com.android.resources.ResourceType;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2011 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 android.view;
|
||||
|
||||
import com.android.layoutlib.bridge.android.BridgeWindow;
|
||||
import com.android.layoutlib.bridge.android.BridgeWindowSession;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.view.View.AttachInfo;
|
||||
|
||||
public class AttachInfo_Accessor {
|
||||
|
||||
public static void setAttachInfo(View view) {
|
||||
AttachInfo info = new AttachInfo(new BridgeWindowSession(), new BridgeWindow(),
|
||||
new Handler(), null);
|
||||
info.mHasWindowFocus = true;
|
||||
info.mWindowVisibility = View.VISIBLE;
|
||||
info.mInTouchMode = false; // this is so that we can display selections.
|
||||
info.mHardwareAccelerated = false;
|
||||
view.dispatchAttachedToWindow(info, 0);
|
||||
}
|
||||
|
||||
public static void dispatchOnPreDraw(View view) {
|
||||
view.mAttachInfo.mTreeObserver.dispatchOnPreDraw();
|
||||
}
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.layoutlib.bridge.android;
|
||||
package android.view;
|
||||
|
||||
import com.android.ide.common.rendering.api.IProjectCallback;
|
||||
import com.android.ide.common.rendering.api.LayoutLog;
|
||||
@ -22,6 +22,8 @@ import com.android.ide.common.rendering.api.MergeCookie;
|
||||
import com.android.ide.common.rendering.api.ResourceReference;
|
||||
import com.android.ide.common.rendering.api.ResourceValue;
|
||||
import com.android.layoutlib.bridge.Bridge;
|
||||
import com.android.layoutlib.bridge.android.BridgeContext;
|
||||
import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
|
||||
import com.android.layoutlib.bridge.impl.ParserFactory;
|
||||
import com.android.resources.ResourceType;
|
||||
import com.android.util.Pair;
|
@ -45,32 +45,18 @@ public class Display_Delegate {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/** @hide Returns the actual screen size, not including any decor. */
|
||||
/*package*/ static int getRealWidth(Display theDisplay) {
|
||||
// always dynamically query for the current window manager
|
||||
return RenderAction.getCurrentContext().getIWindowManager().getMetrics().widthPixels;
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/** @hide Returns the actual screen size, not including any decor. */
|
||||
/*package*/ static int getRealHeight(Display theDisplay) {
|
||||
// always dynamically query for the current window manager
|
||||
return RenderAction.getCurrentContext().getIWindowManager().getMetrics().heightPixels;
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/** @hide special for when we are faking the screen size. */
|
||||
/*package*/ static int getRawWidth(Display theDisplay) {
|
||||
// same as real since we're not faking compatibility mode.
|
||||
return getRealWidth(theDisplay);
|
||||
return RenderAction.getCurrentContext().getIWindowManager().getMetrics().widthPixels;
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
/** @hide special for when we are faking the screen size. */
|
||||
/*package*/ static int getRawHeight(Display theDisplay) {
|
||||
// same as real since we're not faking compatibility mode.
|
||||
return getRealHeight(theDisplay);
|
||||
return RenderAction.getCurrentContext().getIWindowManager().getMetrics().heightPixels;
|
||||
}
|
||||
|
||||
@LayoutlibDelegate
|
||||
|
@ -16,7 +16,6 @@
|
||||
|
||||
package android.view;
|
||||
|
||||
import com.android.layoutlib.bridge.android.BridgeInflater;
|
||||
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright (C) 2011 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 android.view;
|
||||
|
||||
public class ViewConfiguration_Accessor {
|
||||
|
||||
public static void clearConfigurations() {
|
||||
// clear the stored ViewConfiguration since the map is per density and not per context.
|
||||
ViewConfiguration.sConfigurations.clear();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright (C) 2011 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 android.view.inputmethod;
|
||||
|
||||
public class InputMethodManager_Accessor {
|
||||
|
||||
public static void resetInstance() {
|
||||
InputMethodManager.mInstance = null;
|
||||
}
|
||||
}
|
@ -26,7 +26,6 @@ import com.android.ide.common.rendering.api.RenderSession;
|
||||
import com.android.ide.common.rendering.api.Result;
|
||||
import com.android.ide.common.rendering.api.SessionParams;
|
||||
import com.android.ide.common.rendering.api.Result.Status;
|
||||
import com.android.layoutlib.bridge.android.BridgeAssetManager;
|
||||
import com.android.layoutlib.bridge.impl.FontLoader;
|
||||
import com.android.layoutlib.bridge.impl.RenderDrawable;
|
||||
import com.android.layoutlib.bridge.impl.RenderSessionImpl;
|
||||
@ -36,10 +35,12 @@ import com.android.tools.layoutlib.create.MethodAdapter;
|
||||
import com.android.tools.layoutlib.create.OverrideMethod;
|
||||
import com.android.util.Pair;
|
||||
|
||||
import android.content.res.BridgeAssetManager;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.Typeface_Accessor;
|
||||
import android.graphics.Typeface_Delegate;
|
||||
import android.os.Looper;
|
||||
import android.os.Looper_Accessor;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewParent;
|
||||
@ -295,7 +296,7 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
|
||||
BridgeAssetManager.clearSystem();
|
||||
|
||||
// dispose of the default typeface.
|
||||
Typeface.sDefaults = null;
|
||||
Typeface_Accessor.resetDefaults();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -429,7 +430,7 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
|
||||
*/
|
||||
public static void cleanupThread() {
|
||||
// clean up the looper
|
||||
Looper.sThreadLocal.remove();
|
||||
Looper_Accessor.cleanupThread();
|
||||
}
|
||||
|
||||
public static LayoutLog getLog() {
|
||||
|
@ -33,8 +33,6 @@ import com.android.util.Pair;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
@ -65,7 +63,7 @@ import android.os.Looper;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.BridgeInflater;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@ -87,7 +85,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
/**
|
||||
* Custom implementation of Context/Activity to handle non compiled resources.
|
||||
*/
|
||||
public final class BridgeContext extends Activity {
|
||||
public final class BridgeContext extends Context {
|
||||
|
||||
private Resources mSystemResources;
|
||||
private final HashMap<View, Object> mViewKeyMap = new HashMap<View, Object>();
|
||||
@ -97,9 +95,10 @@ public final class BridgeContext extends Activity {
|
||||
private final Configuration mConfig;
|
||||
private final ApplicationInfo mApplicationInfo;
|
||||
private final IProjectCallback mProjectCallback;
|
||||
|
||||
private final BridgeWindowManager mIWindowManager;
|
||||
|
||||
private Resources.Theme mTheme;
|
||||
|
||||
private final Map<Object, Map<String, String>> mDefaultPropMaps =
|
||||
new IdentityHashMap<Object, Map<String,String>>();
|
||||
|
||||
@ -139,9 +138,6 @@ public final class BridgeContext extends Activity {
|
||||
|
||||
mIWindowManager = new BridgeWindowManager(mConfig, metrics, Surface.ROTATION_0);
|
||||
|
||||
mFragments.mCurState = Fragment.CREATED;
|
||||
mFragments.mActivity = this;
|
||||
|
||||
mApplicationInfo = new ApplicationInfo();
|
||||
mApplicationInfo.targetSdkVersion = targetSdkVersion;
|
||||
}
|
||||
@ -395,13 +391,6 @@ public final class BridgeContext extends Activity {
|
||||
return Pair.of(null, false);
|
||||
}
|
||||
|
||||
// ------------- Activity Methods
|
||||
|
||||
@Override
|
||||
public LayoutInflater getLayoutInflater() {
|
||||
return mBridgeInflater;
|
||||
}
|
||||
|
||||
// ------------ Context methods
|
||||
|
||||
@Override
|
||||
@ -1275,7 +1264,7 @@ public final class BridgeContext extends Activity {
|
||||
|
||||
@Override
|
||||
public Context getApplicationContext() {
|
||||
throw new UnsupportedOperationException();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1288,4 +1277,10 @@ public final class BridgeContext extends Activity {
|
||||
public boolean isRestricted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getObbDir() {
|
||||
Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED, "OBB not supported", null);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -26,10 +26,9 @@ import android.view.DragEvent;
|
||||
import android.view.IWindow;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View.AttachInfo;
|
||||
|
||||
/**
|
||||
* Implementation of {@link IWindow} to pass to the {@link AttachInfo}.
|
||||
* Implementation of {@link IWindow} to pass to the AttachInfo.
|
||||
*/
|
||||
public final class BridgeWindow implements IWindow {
|
||||
|
||||
|
@ -456,9 +456,7 @@ public class BridgeWindowManager implements IWindowManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferredOptionsPanelGravity() throws RemoteException {
|
||||
return Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.XmlPullAttributes;
|
||||
import android.util.BridgeXmlPullAttributes;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -34,12 +34,12 @@ import java.io.Reader;
|
||||
/**
|
||||
* {@link BridgeXmlBlockParser} reimplements most of android.xml.XmlBlock.Parser.
|
||||
* It delegates to both an instance of {@link XmlPullParser} and an instance of
|
||||
* {@link XmlPullAttributes} (for the {@link AttributeSet} part).
|
||||
* XmlPullAttributes (for the {@link AttributeSet} part).
|
||||
*/
|
||||
public class BridgeXmlBlockParser implements XmlResourceParser {
|
||||
|
||||
private final XmlPullParser mParser;
|
||||
private final XmlPullAttributes mAttrib;
|
||||
private final BridgeXmlPullAttributes mAttrib;
|
||||
private final BridgeContext mContext;
|
||||
private final boolean mPlatformFile;
|
||||
|
||||
|
@ -32,7 +32,8 @@ public class PhoneSystemBar extends CustomBar {
|
||||
public PhoneSystemBar(Context context, Density density) throws XmlPullParserException {
|
||||
super(context, density, "/bars/phone_system_bar.xml", "phone_system_bar.xml");
|
||||
|
||||
setGravity(mGravity | Gravity.RIGHT);
|
||||
// FIXME: use FILL_H?
|
||||
setGravity(Gravity.START | Gravity.TOP | Gravity.RIGHT);
|
||||
setBackgroundColor(0xFF000000);
|
||||
|
||||
// Cannot access the inside items through id because no R.id values have been
|
||||
|
@ -20,6 +20,7 @@ import com.android.ide.common.rendering.api.IAnimationListener;
|
||||
import com.android.ide.common.rendering.api.Result;
|
||||
import com.android.ide.common.rendering.api.Result.Status;
|
||||
|
||||
import android.animation.AnimationThread;
|
||||
import android.animation.Animator;
|
||||
|
||||
public class PlayAnimationThread extends AnimationThread {
|
||||
|
@ -35,8 +35,9 @@ import android.content.res.Configuration;
|
||||
import android.os.HandlerThread_Delegate;
|
||||
import android.os.Looper;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewConfiguration_Accessor;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.view.inputmethod.InputMethodManager_Accessor;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
@ -248,10 +249,10 @@ public abstract class RenderAction<T extends RenderParams> extends FrameworkReso
|
||||
HandlerThread_Delegate.cleanUp(sCurrentContext);
|
||||
|
||||
// clear the stored ViewConfiguration since the map is per density and not per context.
|
||||
ViewConfiguration.sConfigurations.clear();
|
||||
ViewConfiguration_Accessor.clearConfigurations();
|
||||
|
||||
// remove the InputMethodManager
|
||||
InputMethodManager.mInstance = null;
|
||||
InputMethodManager_Accessor.resetInstance();
|
||||
|
||||
sCurrentContext = null;
|
||||
|
||||
|
@ -23,17 +23,13 @@ import com.android.ide.common.rendering.api.ResourceValue;
|
||||
import com.android.ide.common.rendering.api.Result;
|
||||
import com.android.ide.common.rendering.api.Result.Status;
|
||||
import com.android.layoutlib.bridge.android.BridgeContext;
|
||||
import com.android.layoutlib.bridge.android.BridgeWindow;
|
||||
import com.android.layoutlib.bridge.android.BridgeWindowSession;
|
||||
import com.android.resources.ResourceType;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap_Delegate;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.view.View.AttachInfo;
|
||||
import android.view.AttachInfo_Accessor;
|
||||
import android.view.View.MeasureSpec;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
@ -82,13 +78,7 @@ public class RenderDrawable extends RenderAction<DrawableParams> {
|
||||
content.setBackgroundDrawable(d);
|
||||
|
||||
// set the AttachInfo on the root view.
|
||||
AttachInfo info = new AttachInfo(new BridgeWindowSession(), new BridgeWindow(),
|
||||
new Handler(), null);
|
||||
info.mHasWindowFocus = true;
|
||||
info.mWindowVisibility = View.VISIBLE;
|
||||
info.mInTouchMode = false; // this is so that we can display selections.
|
||||
info.mHardwareAccelerated = false;
|
||||
content.dispatchAttachedToWindow(info, 0);
|
||||
AttachInfo_Accessor.setAttachInfo(content);
|
||||
|
||||
|
||||
// measure
|
||||
@ -102,7 +92,7 @@ public class RenderDrawable extends RenderAction<DrawableParams> {
|
||||
content.layout(0, 0, w, h);
|
||||
|
||||
// preDraw setup
|
||||
content.mAttachInfo.mTreeObserver.dispatchOnPreDraw();
|
||||
AttachInfo_Accessor.dispatchOnPreDraw(content);
|
||||
|
||||
// draw into a new image
|
||||
BufferedImage image = getImage(w, h);
|
||||
|
@ -40,10 +40,7 @@ import com.android.ide.common.rendering.api.SessionParams.RenderingMode;
|
||||
import com.android.internal.util.XmlUtils;
|
||||
import com.android.layoutlib.bridge.Bridge;
|
||||
import com.android.layoutlib.bridge.android.BridgeContext;
|
||||
import com.android.layoutlib.bridge.android.BridgeInflater;
|
||||
import com.android.layoutlib.bridge.android.BridgeLayoutParamsMapAttributes;
|
||||
import com.android.layoutlib.bridge.android.BridgeWindow;
|
||||
import com.android.layoutlib.bridge.android.BridgeWindowSession;
|
||||
import com.android.layoutlib.bridge.android.BridgeXmlBlockParser;
|
||||
import com.android.layoutlib.bridge.bars.FakeActionBar;
|
||||
import com.android.layoutlib.bridge.bars.PhoneSystemBar;
|
||||
@ -57,6 +54,7 @@ import com.android.util.Pair;
|
||||
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import android.animation.AnimationThread;
|
||||
import android.animation.Animator;
|
||||
import android.animation.AnimatorInflater;
|
||||
import android.animation.LayoutTransition;
|
||||
@ -66,12 +64,12 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.Bitmap_Delegate;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.AttachInfo_Accessor;
|
||||
import android.view.BridgeInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.View.AttachInfo;
|
||||
import android.view.View.MeasureSpec;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.ViewGroup.MarginLayoutParams;
|
||||
@ -190,7 +188,6 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
||||
// build the inflater and parser.
|
||||
mInflater = new BridgeInflater(context, params.getProjectCallback());
|
||||
context.setBridgeInflater(mInflater);
|
||||
mInflater.setFactory2(context);
|
||||
|
||||
mBlockParser = new BridgeXmlBlockParser(
|
||||
params.getLayoutDescription(), context, false /* platformResourceFlag */);
|
||||
@ -329,13 +326,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
||||
Fragment_Delegate.setProjectCallback(null);
|
||||
|
||||
// set the AttachInfo on the root view.
|
||||
AttachInfo info = new AttachInfo(new BridgeWindowSession(), new BridgeWindow(),
|
||||
new Handler(), null);
|
||||
info.mHasWindowFocus = true;
|
||||
info.mWindowVisibility = View.VISIBLE;
|
||||
info.mInTouchMode = false; // this is so that we can display selections.
|
||||
info.mHardwareAccelerated = false;
|
||||
mViewRoot.dispatchAttachedToWindow(info, 0);
|
||||
AttachInfo_Accessor.setAttachInfo(mViewRoot);
|
||||
|
||||
// post-inflate process. For now this supports TabHost/TabWidget
|
||||
postInflateProcess(view, params.getProjectCallback());
|
||||
@ -462,7 +453,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
|
||||
mImage = null;
|
||||
mCanvas = null;
|
||||
} else {
|
||||
mViewRoot.mAttachInfo.mTreeObserver.dispatchOnPreDraw();
|
||||
AttachInfo_Accessor.dispatchOnPreDraw(mViewRoot);
|
||||
|
||||
// draw the views
|
||||
// create the BufferedImage into which the layout will be rendered.
|
||||
|
@ -95,10 +95,11 @@ public final class CreateInfo implements ICreateInfo {
|
||||
/**
|
||||
* The list of methods to rewrite as delegates.
|
||||
*/
|
||||
private final static String[] DELEGATE_METHODS = new String[] {
|
||||
public final static String[] DELEGATE_METHODS = new String[] {
|
||||
"android.app.Fragment#instantiate", //(Landroid/content/Context;Ljava/lang/String;Landroid/os/Bundle;)Landroid/app/Fragment;",
|
||||
"android.content.res.Resources$Theme#obtainStyledAttributes",
|
||||
"android.content.res.Resources$Theme#resolveAttribute",
|
||||
"android.content.res.TypedArray#getValueAt",
|
||||
"android.graphics.BitmapFactory#finishDecode",
|
||||
"android.os.Handler#sendMessageAtTime",
|
||||
"android.os.HandlerThread#run",
|
||||
@ -116,7 +117,7 @@ public final class CreateInfo implements ICreateInfo {
|
||||
/**
|
||||
* The list of classes on which to delegate all native methods.
|
||||
*/
|
||||
private final static String[] DELEGATE_CLASS_NATIVES = new String[] {
|
||||
public final static String[] DELEGATE_CLASS_NATIVES = new String[] {
|
||||
"android.animation.PropertyValuesHolder",
|
||||
"android.graphics.AvoidXfermode",
|
||||
"android.graphics.Bitmap",
|
||||
|
@ -165,6 +165,8 @@ public class Main {
|
||||
return false;
|
||||
}
|
||||
|
||||
sOptions.generatePublicAccess = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user