Skip to content

Commit 477687c

Browse files
Xavier DucrohetAndroid (Google) Code Review
authored andcommitted
Merge "Fix SDK layout rendering in Eclipse." into jb-mr1-dev
2 parents 11dea4d + 6dfd0b3 commit 477687c

File tree

9 files changed

+186
-28
lines changed

9 files changed

+186
-28
lines changed

tools/layoutlib/bridge/src/android/os/SystemClock_Delegate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class SystemClock_Delegate {
6666
* @return elapsed nanoseconds since boot.
6767
*/
6868
@LayoutlibDelegate
69-
/*package*/ static long elapsedRealtimeNano() {
69+
/*package*/ static long elapsedRealtimeNanos() {
7070
return System.nanoTime() - sBootTimeNano;
7171
}
7272

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
package android.view;
17+
18+
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
19+
20+
/**
21+
* Delegate used to provide new implementation of a select few methods of {@link Choreographer}
22+
*
23+
* Through the layoutlib_create tool, the original methods of Choreographer have been
24+
* replaced by calls to methods of the same name in this delegate class.
25+
*
26+
*/
27+
public class Choreographer_Delegate {
28+
29+
@LayoutlibDelegate
30+
public static float getRefreshRate() {
31+
return 60.f;
32+
}
33+
}

tools/layoutlib/bridge/src/android/view/Display_Delegate.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@
1616

1717
package android.view;
1818

19-
import com.android.layoutlib.bridge.android.BridgeWindowManager;
20-
import com.android.layoutlib.bridge.impl.RenderAction;
2119
import com.android.tools.layoutlib.annotations.LayoutlibDelegate;
2220

23-
import android.os.RemoteException;
2421

2522
/**
2623
* Delegate used to provide new implementation of a select few methods of {@link Display}
@@ -31,4 +28,9 @@
3128
*/
3229
public class Display_Delegate {
3330

31+
@LayoutlibDelegate
32+
static void updateDisplayInfoLocked(Display theDisplay) {
33+
// do nothing
34+
}
35+
3436
}

tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeWindowManager.java renamed to tools/layoutlib/bridge/src/android/view/IWindowManagerImpl.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package com.android.layoutlib.bridge.android;
17+
package android.view;
1818

1919
import com.android.internal.view.IInputContext;
2020
import com.android.internal.view.IInputMethodClient;
@@ -28,7 +28,6 @@
2828
import android.os.RemoteException;
2929
import android.util.DisplayMetrics;
3030
import android.view.Display;
31-
import android.view.Display_Delegate;
3231
import android.view.Gravity;
3332
import android.view.IApplicationToken;
3433
import android.view.IDisplayContentChangeListener;
@@ -45,16 +44,21 @@
4544
* Basic implementation of {@link IWindowManager} so that {@link Display} (and
4645
* {@link Display_Delegate}) can return a valid instance.
4746
*/
48-
public class BridgeWindowManager implements IWindowManager {
47+
public class IWindowManagerImpl implements IWindowManager {
4948

5049
private final Configuration mConfig;
5150
private final DisplayMetrics mMetrics;
5251
private final int mRotation;
52+
private final boolean mHasSystemNavBar;
53+
private final boolean mHasNavigationBar;
5354

54-
public BridgeWindowManager(Configuration config, DisplayMetrics metrics, int rotation) {
55+
public IWindowManagerImpl(Configuration config, DisplayMetrics metrics, int rotation,
56+
boolean hasSystemNavBar, boolean hasNavigationBar) {
5557
mConfig = config;
5658
mMetrics = metrics;
5759
mRotation = rotation;
60+
mHasSystemNavBar = hasSystemNavBar;
61+
mHasNavigationBar = hasNavigationBar;
5862
}
5963

6064
// custom API.
@@ -70,14 +74,18 @@ public int getRotation() throws RemoteException {
7074
return mRotation;
7175
}
7276

73-
// ---- unused implementation of IWindowManager ----
77+
@Override
78+
public boolean hasNavigationBar() {
79+
return mHasNavigationBar;
80+
}
7481

7582
@Override
7683
public boolean hasSystemNavBar() throws RemoteException {
77-
// TODO Auto-generated method stub
78-
return false;
84+
return mHasSystemNavBar;
7985
}
8086

87+
// ---- unused implementation of IWindowManager ----
88+
8189
@Override
8290
public void addAppToken(int arg0, IApplicationToken arg1, int arg2, int arg3, boolean arg4,
8391
boolean arg5)
@@ -434,11 +442,6 @@ public int getPreferredOptionsPanelGravity() throws RemoteException {
434442
public void dismissKeyguard() {
435443
}
436444

437-
@Override
438-
public boolean hasNavigationBar() {
439-
return false; // should this return something else?
440-
}
441-
442445
@Override
443446
public void lockNow(Bundle options) {
444447
// TODO Auto-generated method stub
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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
23+
* {@link WindowManagerGlobal}
24+
*
25+
* Through the layoutlib_create tool, the original methods of WindowManagerGlobal have been
26+
* replaced by calls to methods of the same name in this delegate class.
27+
*
28+
*/
29+
public class WindowManagerGlobal_Delegate {
30+
31+
private static IWindowManager sService;
32+
33+
@LayoutlibDelegate
34+
public static IWindowManager getWindowManagerService() {
35+
return sService;
36+
}
37+
38+
// ---- internal implementation stuff ----
39+
40+
public static void setWindowManagerService(IWindowManager service) {
41+
sService = service;
42+
}
43+
}

tools/layoutlib/bridge/src/com/android/layoutlib/bridge/android/BridgeContext.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.android.ide.common.rendering.api.StyleResourceValue;
2626
import com.android.layoutlib.bridge.Bridge;
2727
import com.android.layoutlib.bridge.BridgeConstants;
28+
import com.android.layoutlib.bridge.android.view.WindowManagerImpl;
2829
import com.android.layoutlib.bridge.impl.ParserFactory;
2930
import com.android.layoutlib.bridge.impl.Stack;
3031
import com.android.resources.ResourceType;
@@ -68,9 +69,9 @@
6869
import android.view.BridgeInflater;
6970
import android.view.CompatibilityInfoHolder;
7071
import android.view.Display;
71-
import android.view.Surface;
7272
import android.view.View;
7373
import android.view.ViewGroup;
74+
import android.view.WindowManager;
7475
import android.view.textservice.TextServicesManager;
7576

7677
import java.io.File;
@@ -98,7 +99,7 @@ public final class BridgeContext extends Context {
9899
private final Configuration mConfig;
99100
private final ApplicationInfo mApplicationInfo;
100101
private final IProjectCallback mProjectCallback;
101-
private final BridgeWindowManager mIWindowManager;
102+
private final WindowManager mWindowManager;
102103

103104
private Resources.Theme mTheme;
104105

@@ -139,10 +140,10 @@ public BridgeContext(Object projectKey, DisplayMetrics metrics,
139140
mRenderResources = renderResources;
140141
mConfig = config;
141142

142-
mIWindowManager = new BridgeWindowManager(mConfig, metrics, Surface.ROTATION_0);
143-
144143
mApplicationInfo = new ApplicationInfo();
145144
mApplicationInfo.targetSdkVersion = targetSdkVersion;
145+
146+
mWindowManager = new WindowManagerImpl(mMetrics);
146147
}
147148

148149
/**
@@ -198,14 +199,14 @@ public RenderResources getRenderResources() {
198199
return mRenderResources;
199200
}
200201

201-
public BridgeWindowManager getIWindowManager() {
202-
return mIWindowManager;
203-
}
204-
205202
public Map<String, String> getDefaultPropMap(Object key) {
206203
return mDefaultPropMaps.get(key);
207204
}
208205

206+
public Configuration getConfiguration() {
207+
return mConfig;
208+
}
209+
209210
/**
210211
* Adds a parser to the stack.
211212
* @param parser the parser to add.
@@ -431,10 +432,8 @@ public Object getSystemService(String service) {
431432
return TextServicesManager.getInstance();
432433
}
433434

434-
// AutoCompleteTextView and MultiAutoCompleteTextView want a window
435-
// service. We don't have any but it's not worth an exception.
436435
if (WINDOW_SERVICE.equals(service)) {
437-
return null;
436+
return mWindowManager;
438437
}
439438

440439
// needed by SearchView
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
package com.android.layoutlib.bridge.android.view;
17+
18+
import android.util.DisplayMetrics;
19+
import android.view.Display;
20+
import android.view.DisplayInfo;
21+
import android.view.View;
22+
import android.view.WindowManager;
23+
24+
public class WindowManagerImpl implements WindowManager {
25+
26+
private final DisplayMetrics mMetrics;
27+
private final Display mDisplay;
28+
29+
public WindowManagerImpl(DisplayMetrics metrics) {
30+
mMetrics = metrics;
31+
32+
DisplayInfo info = new DisplayInfo();
33+
info.logicalHeight = mMetrics.heightPixels;
34+
info.logicalWidth = mMetrics.widthPixels;
35+
mDisplay = new Display(null, Display.DEFAULT_DISPLAY, info, null);
36+
}
37+
38+
@Override
39+
public Display getDefaultDisplay() {
40+
return mDisplay;
41+
}
42+
43+
44+
@Override
45+
public void addView(View arg0, android.view.ViewGroup.LayoutParams arg1) {
46+
// pass
47+
}
48+
49+
@Override
50+
public void removeView(View arg0) {
51+
// pass
52+
}
53+
54+
@Override
55+
public void updateViewLayout(View arg0, android.view.ViewGroup.LayoutParams arg1) {
56+
// pass
57+
}
58+
59+
60+
@Override
61+
public void removeViewImmediate(View arg0) {
62+
// pass
63+
}
64+
}

tools/layoutlib/bridge/src/com/android/layoutlib/bridge/impl/RenderSessionImpl.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,15 @@
6868
import android.util.TypedValue;
6969
import android.view.AttachInfo_Accessor;
7070
import android.view.BridgeInflater;
71+
import android.view.IWindowManagerImpl;
72+
import android.view.IWindowManager;
73+
import android.view.Surface;
7174
import android.view.View;
7275
import android.view.View.MeasureSpec;
7376
import android.view.ViewGroup;
7477
import android.view.ViewGroup.LayoutParams;
7578
import android.view.ViewGroup.MarginLayoutParams;
79+
import android.view.WindowManagerGlobal_Delegate;
7680
import android.widget.AbsListView;
7781
import android.widget.AbsSpinner;
7882
import android.widget.AdapterView;
@@ -185,6 +189,14 @@ public Result init(long timeout) {
185189
findActionBar(resources, metrics);
186190
findSystemBar(resources, metrics);
187191

192+
// FIXME: find those out, and possibly add them to the render params
193+
boolean hasSystemNavBar = true;
194+
boolean hasNavigationBar = true;
195+
IWindowManager iwm = new IWindowManagerImpl(getContext().getConfiguration(),
196+
metrics, Surface.ROTATION_0,
197+
hasSystemNavBar, hasNavigationBar);
198+
WindowManagerGlobal_Delegate.setWindowManagerService(iwm);
199+
188200
// build the inflater and parser.
189201
mInflater = new BridgeInflater(context, params.getProjectCallback());
190202
context.setBridgeInflater(mInflater);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,13 @@ public String[] getDeleteReturns() {
110110
"android.os.Handler#sendMessageAtTime",
111111
"android.os.HandlerThread#run",
112112
"android.os.Build#getString",
113-
"android.view.Display#getWindowManager",
113+
"android.view.Choreographer#getRefreshRate",
114+
"android.view.Display#updateDisplayInfoLocked",
114115
"android.view.LayoutInflater#rInflate",
115116
"android.view.LayoutInflater#parseInclude",
116117
"android.view.View#isInEditMode",
117118
"android.view.ViewRootImpl#isInTouchMode",
119+
"android.view.WindowManagerGlobal#getWindowManagerService",
118120
"android.view.inputmethod.InputMethodManager#getInstance",
119121
"com.android.internal.util.XmlUtils#convertValueToInt",
120122
"com.android.internal.textservice.ITextServicesManager$Stub#asInterface",

0 commit comments

Comments
 (0)