You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
WindowManagerImpl: set view.parent
This commit is contained in:
@@ -820,7 +820,7 @@ public class View implements Drawable.Callback {
|
||||
|
||||
public int id = NO_ID;
|
||||
private int system_ui_visibility = 0;
|
||||
public ViewGroup parent;
|
||||
public ViewParent parent;
|
||||
public AttributeSet attrs;
|
||||
protected ViewGroup.LayoutParams layout_params;
|
||||
private Context context;
|
||||
@@ -1025,8 +1025,8 @@ public class View implements Drawable.Callback {
|
||||
}
|
||||
|
||||
int gravity = params.gravity;
|
||||
if (gravity == -1 && parent != null)
|
||||
gravity = parent.gravity;
|
||||
if (gravity == -1 && parent instanceof View)
|
||||
gravity = ((View)parent).gravity;
|
||||
|
||||
int leftMargin = 0;
|
||||
int topMargin = 0;
|
||||
@@ -1489,8 +1489,8 @@ public class View implements Drawable.Callback {
|
||||
|
||||
public void requestLayout() {
|
||||
layoutRequested = true;
|
||||
if (parent != null && !parent.isLayoutRequested()) {
|
||||
parent.requestLayout();
|
||||
if (parent instanceof View && !parent.isLayoutRequested()) {
|
||||
((View)parent).requestLayout();
|
||||
}
|
||||
native_requestLayout(widget);
|
||||
};
|
||||
@@ -1786,8 +1786,8 @@ public class View implements Drawable.Callback {
|
||||
|
||||
public View getRootView() {
|
||||
View view = this;
|
||||
while (view.parent != null) {
|
||||
view = view.parent;
|
||||
while (view.parent instanceof View) {
|
||||
view = (View)view.parent;
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,46 @@
|
||||
package android.view;
|
||||
|
||||
public class WindowManagerImpl implements WindowManager, ViewManager {
|
||||
|
||||
private static class WindowViewParent implements ViewParent {
|
||||
|
||||
@Override
|
||||
public android.view.ViewParent getParent() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getParent'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLayoutRequested() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'isLayoutRequested'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'requestDisallowInterceptTouchEvent'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onStartNestedScroll(View child, View target, int nestedScrollAxes) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'onStartNestedScroll'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNestedPreFling(View target, float velocityX, float velocityY) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'onNestedPreFling'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onNestedFling(View target, float velocityX, float velocityY, boolean consumed) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'onNestedFling'");
|
||||
}
|
||||
}
|
||||
|
||||
public android.view.Display getDefaultDisplay() {
|
||||
return new android.view.Display();
|
||||
}
|
||||
@@ -11,6 +51,7 @@ public class WindowManagerImpl implements WindowManager, ViewManager {
|
||||
if (params.height == 0) // FIXME: remove this hack once measurement error with composeUI popups is fixed
|
||||
params.height = 200;
|
||||
view.setLayoutParams(params);
|
||||
view.parent = new WindowViewParent();
|
||||
view.onAttachedToWindow();
|
||||
WindowManager.LayoutParams windowParams = (WindowManager.LayoutParams)params;
|
||||
native_addView(view.widget, windowParams.type, windowParams.x, windowParams.y, params.width, params.height);
|
||||
@@ -29,6 +70,7 @@ public class WindowManagerImpl implements WindowManager, ViewManager {
|
||||
@Override
|
||||
public void removeView(View view) {
|
||||
native_removeView(view.widget);
|
||||
view.parent = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user