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;
|
public int id = NO_ID;
|
||||||
private int system_ui_visibility = 0;
|
private int system_ui_visibility = 0;
|
||||||
public ViewGroup parent;
|
public ViewParent parent;
|
||||||
public AttributeSet attrs;
|
public AttributeSet attrs;
|
||||||
protected ViewGroup.LayoutParams layout_params;
|
protected ViewGroup.LayoutParams layout_params;
|
||||||
private Context context;
|
private Context context;
|
||||||
@@ -1025,8 +1025,8 @@ public class View implements Drawable.Callback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int gravity = params.gravity;
|
int gravity = params.gravity;
|
||||||
if (gravity == -1 && parent != null)
|
if (gravity == -1 && parent instanceof View)
|
||||||
gravity = parent.gravity;
|
gravity = ((View)parent).gravity;
|
||||||
|
|
||||||
int leftMargin = 0;
|
int leftMargin = 0;
|
||||||
int topMargin = 0;
|
int topMargin = 0;
|
||||||
@@ -1489,8 +1489,8 @@ public class View implements Drawable.Callback {
|
|||||||
|
|
||||||
public void requestLayout() {
|
public void requestLayout() {
|
||||||
layoutRequested = true;
|
layoutRequested = true;
|
||||||
if (parent != null && !parent.isLayoutRequested()) {
|
if (parent instanceof View && !parent.isLayoutRequested()) {
|
||||||
parent.requestLayout();
|
((View)parent).requestLayout();
|
||||||
}
|
}
|
||||||
native_requestLayout(widget);
|
native_requestLayout(widget);
|
||||||
};
|
};
|
||||||
@@ -1786,8 +1786,8 @@ public class View implements Drawable.Callback {
|
|||||||
|
|
||||||
public View getRootView() {
|
public View getRootView() {
|
||||||
View view = this;
|
View view = this;
|
||||||
while (view.parent != null) {
|
while (view.parent instanceof View) {
|
||||||
view = view.parent;
|
view = (View)view.parent;
|
||||||
}
|
}
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,46 @@
|
|||||||
package android.view;
|
package android.view;
|
||||||
|
|
||||||
public class WindowManagerImpl implements WindowManager, ViewManager {
|
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() {
|
public android.view.Display getDefaultDisplay() {
|
||||||
return new android.view.Display();
|
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
|
if (params.height == 0) // FIXME: remove this hack once measurement error with composeUI popups is fixed
|
||||||
params.height = 200;
|
params.height = 200;
|
||||||
view.setLayoutParams(params);
|
view.setLayoutParams(params);
|
||||||
|
view.parent = new WindowViewParent();
|
||||||
view.onAttachedToWindow();
|
view.onAttachedToWindow();
|
||||||
WindowManager.LayoutParams windowParams = (WindowManager.LayoutParams)params;
|
WindowManager.LayoutParams windowParams = (WindowManager.LayoutParams)params;
|
||||||
native_addView(view.widget, windowParams.type, windowParams.x, windowParams.y, params.width, params.height);
|
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
|
@Override
|
||||||
public void removeView(View view) {
|
public void removeView(View view) {
|
||||||
native_removeView(view.widget);
|
native_removeView(view.widget);
|
||||||
|
view.parent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user