diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/layoutlib/bridge/src/android/view/View_Delegate.java | 31 | ||||
-rw-r--r-- | tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java | 14 | ||||
-rw-r--r-- | tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java | 13 | ||||
-rw-r--r-- | tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java | 2 | ||||
-rw-r--r-- | tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java | 3 | ||||
-rw-r--r-- | tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/TempResourceValue.java | 4 | ||||
-rw-r--r-- | tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/TestDelegates.java (renamed from tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/TestNativeDelegate.java) | 19 | ||||
-rw-r--r-- | tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java | 4 |
8 files changed, 56 insertions, 34 deletions
diff --git a/tools/layoutlib/bridge/src/android/view/View_Delegate.java b/tools/layoutlib/bridge/src/android/view/View_Delegate.java new file mode 100644 index 0000000..ee6694c --- /dev/null +++ b/tools/layoutlib/bridge/src/android/view/View_Delegate.java @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2010 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; + +/** + * Delegate used to provide new implementation of a select few methods of {@link View} + * + * Through the layoutlib_create tool, the original methods of View have been replaced + * by calls to methods of the same name in this delegate class. + * + */ +public class View_Delegate { + + /*package*/ static boolean isInEditMode(View thisView) { + return true; + } +} diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java index d2092d1..53da2ca 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/Bridge.java @@ -157,20 +157,6 @@ public final class Bridge extends LayoutBridge { }); } - // Override View.isInEditMode to return true. - // - // This allows custom views that are drawn in the Graphical Layout Editor to adapt their - // rendering for preview. Most important this let custom views know that they can't expect - // the rest of their activities to be alive. - OverrideMethod.setMethodListener("android.view.View#isInEditMode()Z", - new MethodAdapter() { - @Override - public int onInvokeI(String signature, boolean isNative, Object caller) { - return 1; - } - } - ); - // load the fonts. FontLoader fontLoader = FontLoader.create(fontOsLocation); if (fontLoader != 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 2fa97a3..79aecff 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 @@ -1111,25 +1111,20 @@ public final class BridgeContext extends Activity { } - @SuppressWarnings("unused") @Override - public FileInputStream openFileInput(String arg0) - throws FileNotFoundException { + public FileInputStream openFileInput(String arg0) throws FileNotFoundException { // TODO Auto-generated method stub return null; } - @SuppressWarnings("unused") @Override - public FileOutputStream openFileOutput(String arg0, int arg1) - throws FileNotFoundException { + public FileOutputStream openFileOutput(String arg0, int arg1) throws FileNotFoundException { // TODO Auto-generated method stub return null; } @Override - public SQLiteDatabase openOrCreateDatabase(String arg0, int arg1, - CursorFactory arg2) { + public SQLiteDatabase openOrCreateDatabase(String arg0, int arg1, CursorFactory arg2) { // TODO Auto-generated method stub return null; } @@ -1217,14 +1212,12 @@ public final class BridgeContext extends Activity { } - @SuppressWarnings("unused") @Override public void setWallpaper(Bitmap arg0) throws IOException { // TODO Auto-generated method stub } - @SuppressWarnings("unused") @Override public void setWallpaper(InputStream arg0) throws IOException { // TODO Auto-generated method stub diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java index c3ab461..c8dc9e6 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeTypedArray.java @@ -43,10 +43,8 @@ import java.util.Map; */ public final class BridgeTypedArray extends TypedArray { - @SuppressWarnings("hiding") private BridgeResources mResources; private BridgeContext mContext; - @SuppressWarnings("hiding") private IResourceValue[] mData; private String[] mNames; private final boolean mPlatformFile; diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java index c04c9e8..4a7ab58 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindow.java @@ -49,7 +49,8 @@ public final class BridgeWindow implements IWindow { // pass for now. } - public void dispatchTrackball(MotionEvent arg0, long arg1, boolean arg2) throws RemoteException { + public void dispatchTrackball(MotionEvent arg0, long arg1, boolean arg2) + throws RemoteException { // pass for now. } diff --git a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/TempResourceValue.java b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/TempResourceValue.java index 4ab98ce..a3c5826 100644 --- a/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/TempResourceValue.java +++ b/tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/TempResourceValue.java @@ -16,14 +16,14 @@ package com.android.layoutlib.bridge.impl; -import com.android.layoutlib.api.ILayoutBridge; import com.android.layoutlib.api.IResourceValue; +import com.android.layoutlib.api.LayoutBridge; /** * Basic implementation of IResourceValue for when it is needed to dynamically make a new * {@link IResourceValue} object. * - * Most of the time, implementations of IResourceValue come through the {@link ILayoutBridge} + * Most of the time, implementations of IResourceValue come through the {@link LayoutBridge} * API. */ public class TempResourceValue implements IResourceValue { diff --git a/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/TestNativeDelegate.java b/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/TestDelegates.java index a86b5c9..23b7e94 100644 --- a/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/TestNativeDelegate.java +++ b/tools/layoutlib/bridge/tests/com/android/layoutlib/bridge/TestDelegates.java @@ -37,9 +37,9 @@ import junit.framework.TestCase; * include the original class as first parameter (to access "this"). * */ -public class TestNativeDelegate extends TestCase { +public class TestDelegates extends TestCase { - public void testNativeDelegates() { + public void testNativeDelegates() { final String[] classes = CreateInfo.DELEGATE_CLASS_NATIVES; final int count = classes.length; @@ -48,10 +48,23 @@ public class TestNativeDelegate extends TestCase { } } + public void testMethodDelegates() { + final String[] methods = CreateInfo.DELEGATE_METHODS; + final int count = methods.length; + for (int i = 0 ; i < count ; i++) { + String methodName = methods[i]; + + // extract the class name + String className = methodName.substring(0, methodName.indexOf('#')); + + loadAndCompareClasses(className, className + "_Delegate"); + } + } + private void loadAndCompareClasses(String originalClassName, String delegateClassName) { // load the classes try { - ClassLoader classLoader = TestNativeDelegate.class.getClassLoader(); + ClassLoader classLoader = TestDelegates.class.getClassLoader(); Class<?> originalClass = classLoader.loadClass(originalClassName); Class<?> delegateClass = classLoader.loadClass(delegateClassName); 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 1c95400..b9c7113 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 @@ -95,8 +95,8 @@ public final class CreateInfo implements ICreateInfo { */ private final static String[] DELEGATE_METHODS = new String[] { "android.app.Fragment#instantiate", //(Landroid/content/Context;Ljava/lang/String;Landroid/os/Bundle;)Landroid/app/Fragment;", + "android.view.View#isInEditMode", // TODO: comment out once DelegateClass is working - // "android.view.View#isInEditMode", // "android.content.res.Resources$Theme#obtainStyledAttributes", }; @@ -126,7 +126,6 @@ public final class CreateInfo implements ICreateInfo { */ private final static String[] OVERRIDDEN_METHODS = new String[] { // TODO: remove once DelegateClass is working - "android.view.View#isInEditMode", "android.content.res.Resources$Theme#obtainStyledAttributes", }; @@ -141,6 +140,7 @@ public final class CreateInfo implements ICreateInfo { "android.os.ServiceManager", "android.os._Original_ServiceManager", "android.view.SurfaceView", "android.view._Original_SurfaceView", "android.view.accessibility.AccessibilityManager", "android.view.accessibility._Original_AccessibilityManager", + "android.webkit.WebView", "android.webkit._Original_WebView", }; /** |