Skip to content

Commit fbd0509

Browse files
Xavier DucrohetAndroid (Google) Code Review
authored andcommitted
Merge "Add Delegate for ViewRootImpl#isInTouchMode to prevent IPC call in Eclipse."
2 parents d5f2374 + 22f700a commit fbd0509

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

tools/layoutlib/bridge/src/android/graphics/BitmapFactory_Delegate.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,18 @@
8585
// ------ Native Delegates ------
8686

8787
@LayoutlibDelegate
88-
/*package*/ static void nativeSetDefaultConfig(int nativeConfig) {
89-
// pass
88+
/*package*/ static Bitmap nativeDecodeStream(InputStream is, byte[] storage,
89+
Rect padding, Options opts) {
90+
return nativeDecodeStream(is, storage, padding, opts, false, 1.f);
9091
}
9192

9293
@LayoutlibDelegate
93-
/*package*/ static Bitmap nativeDecodeStream(InputStream is, byte[] storage,
94-
Rect padding, Options opts) {
94+
/*package*/ static Bitmap nativeDecodeStream(InputStream is, byte[] storage,
95+
Rect padding, Options opts, boolean applyScale, float scale) {
9596
Bitmap bm = null;
9697

98+
//TODO support rescaling
99+
97100
Density density = Density.MEDIUM;
98101
if (opts != null) {
99102
density = Density.getEnum(opts.inDensity);
@@ -146,6 +149,13 @@
146149
return null;
147150
}
148151

152+
@LayoutlibDelegate
153+
/*package*/ static Bitmap nativeDecodeAsset(int asset, Rect padding, Options opts,
154+
boolean applyScale, float scale) {
155+
opts.inBitmap = null;
156+
return null;
157+
}
158+
149159
@LayoutlibDelegate
150160
/*package*/ static Bitmap nativeDecodeByteArray(byte[] data, int offset,
151161
int length, Options opts) {
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (C) 2012 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package android.view;
18+
19+
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
20+
21+
/**
22+
* Delegate used to provide new implementation of a select few methods of {@link ViewRootImpl}
23+
*
24+
* Through the layoutlib_create tool, the original methods of ViewRootImpl have been replaced
25+
* by calls to methods of the same name in this delegate class.
26+
*
27+
*/
28+
public class ViewRootImpl_Delegate {
29+
30+
@LayoutlibDelegate
31+
/*package*/ static boolean isInTouchMode() {
32+
return false; // this allows displaying selection.
33+
}
34+
}

tools/layoutlib/create/src/com/android/tools/layoutlib/create/CreateInfo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ public String[] getDeleteReturns() {
114114
"android.view.LayoutInflater#rInflate",
115115
"android.view.LayoutInflater#parseInclude",
116116
"android.view.View#isInEditMode",
117+
"android.view.ViewRootImpl#isInTouchMode",
117118
"android.view.inputmethod.InputMethodManager#getInstance",
118119
"android.util.Log#println_native",
119120
"com.android.internal.util.XmlUtils#convertValueToInt",

0 commit comments

Comments
 (0)