From b9272aa1501883ec771b2d318045104df2263e5f Mon Sep 17 00:00:00 2001 From: Julian Winkler Date: Wed, 11 Dec 2024 21:42:22 +0100 Subject: [PATCH] Window: fix some regressions caused by decorView The window background is now set on the decorView and also window.set_widget_as_root() must now be called manually. --- src/api-impl/android/app/Activity.java | 7 ++----- src/api-impl/android/view/Window.java | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/api-impl/android/app/Activity.java b/src/api-impl/android/app/Activity.java index eb19e50e..7fda8cfa 100644 --- a/src/api-impl/android/app/Activity.java +++ b/src/api-impl/android/app/Activity.java @@ -172,8 +172,7 @@ public class Activity extends ContextThemeWrapper implements Window.Callback { protected void onStart() { Slog.i(TAG, "- onStart - yay!"); - if (window.contentView != null) - window.setContentView(window.contentView); + window.set_widget_as_root(window.native_window, window.getDecorView().widget); window.setTitle(title); for (Fragment fragment : fragments) { @@ -284,9 +283,7 @@ public class Activity extends ContextThemeWrapper implements Window.Callback { public T findViewById(int id) { System.out.printf(TAG, "- findViewById - asked for view with id: %x\n", id); - View view = null; - if (window.contentView != null) - view = window.contentView.findViewById(id); + View view = window.findViewById(id); Slog.i(TAG, "- findViewById - found this: " + view); return (T)view; diff --git a/src/api-impl/android/view/Window.java b/src/api-impl/android/view/Window.java index b36fe7fc..2c30a658 100644 --- a/src/api-impl/android/view/Window.java +++ b/src/api-impl/android/view/Window.java @@ -26,7 +26,6 @@ public class Window { } public long native_window; - public View contentView; private ViewGroup decorView; private Window.Callback callback; @@ -63,7 +62,7 @@ public class Window { return decorView; } - private native void set_widget_as_root(long native_window, long widget); + public native void set_widget_as_root(long native_window, long widget); private native void set_title(long native_window, String title); public native void take_input_queue(long native_window, InputQueue.Callback callback, InputQueue queue); @@ -89,9 +88,7 @@ public class Window { } public void setBackgroundDrawable(Drawable drawable) { - /* TODO: should this be *under* the contentView background? */ - if (contentView != null) - contentView.setBackgroundDrawable(drawable); + decorView.setBackgroundDrawable(drawable); } public void setAttributes(WindowManager.LayoutParams params) {}