2022-10-02 23:06:56 +02:00
|
|
|
package android.view;
|
|
|
|
|
|
2023-12-29 11:05:05 +01:00
|
|
|
import android.content.Context;
|
2024-03-16 15:03:06 +01:00
|
|
|
import android.graphics.drawable.Drawable;
|
2025-01-11 18:01:43 +01:00
|
|
|
import android.transition.Transition;
|
2023-09-19 17:37:14 +05:00
|
|
|
import android.view.SurfaceHolder;
|
2024-11-27 15:00:25 +01:00
|
|
|
import android.widget.FrameLayout;
|
2023-09-19 17:37:14 +05:00
|
|
|
|
2022-10-02 23:06:56 +02:00
|
|
|
public class Window {
|
2023-09-01 12:34:57 +02:00
|
|
|
public static final int FEATURE_OPTIONS_PANEL = 0;
|
2024-10-12 14:53:30 +03:00
|
|
|
public static final int FEATURE_NO_TITLE = 1;
|
2023-09-01 12:34:57 +02:00
|
|
|
|
2023-08-17 10:46:24 +02:00
|
|
|
public static interface Callback {
|
|
|
|
|
public void onContentChanged();
|
|
|
|
|
|
|
|
|
|
public abstract boolean onCreatePanelMenu(int featureId, Menu menu);
|
2023-08-22 14:41:01 +02:00
|
|
|
|
|
|
|
|
public View onCreatePanelView(int featureId);
|
2023-08-17 10:46:24 +02:00
|
|
|
|
2023-09-01 12:34:57 +02:00
|
|
|
public boolean onPreparePanel(int featureId, View view, Menu menu);
|
2023-08-17 10:46:24 +02:00
|
|
|
|
2023-09-01 12:34:57 +02:00
|
|
|
public boolean onMenuItemSelected(int featureId, MenuItem item);
|
2023-08-22 14:41:01 +02:00
|
|
|
|
2023-09-01 12:34:57 +02:00
|
|
|
public void onPanelClosed(int featureId, Menu menu);
|
2024-02-17 15:15:05 +01:00
|
|
|
|
|
|
|
|
public boolean onMenuOpened(int featureId, Menu menu);
|
2023-08-17 10:46:24 +02:00
|
|
|
}
|
2022-10-02 23:06:56 +02:00
|
|
|
|
|
|
|
|
public long native_window;
|
2024-11-27 15:00:25 +01:00
|
|
|
private ViewGroup decorView;
|
2022-10-02 23:06:56 +02:00
|
|
|
|
|
|
|
|
private Window.Callback callback;
|
2024-08-25 11:20:01 +02:00
|
|
|
private Context context;
|
2022-10-02 23:06:56 +02:00
|
|
|
|
2024-08-25 11:20:01 +02:00
|
|
|
public Window(Context context, Window.Callback callback) {
|
2023-09-01 12:34:57 +02:00
|
|
|
this.callback = callback;
|
2024-08-25 11:20:01 +02:00
|
|
|
this.context = context;
|
2024-11-27 15:00:25 +01:00
|
|
|
decorView = new FrameLayout(context);
|
|
|
|
|
decorView.setId(android.R.id.content);
|
2024-12-02 22:03:26 +01:00
|
|
|
decorView.onAttachedToWindow();
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void addFlags(int flags) {}
|
|
|
|
|
public void setFlags(int flags, int mask) {}
|
|
|
|
|
public void clearFlags(int flags) {}
|
|
|
|
|
|
|
|
|
|
public final Callback getCallback() {
|
|
|
|
|
return this.callback;
|
|
|
|
|
}
|
|
|
|
|
public void setCallback(Window.Callback callback) {
|
|
|
|
|
this.callback = callback;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setContentView(View view) {
|
2024-11-27 15:00:25 +01:00
|
|
|
decorView.removeAllViews();
|
|
|
|
|
decorView.addView(view);
|
2024-07-26 21:47:08 +02:00
|
|
|
if (view != null) {
|
2024-11-27 15:00:25 +01:00
|
|
|
set_widget_as_root(native_window, decorView.widget);
|
2024-07-26 21:47:08 +02:00
|
|
|
}
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
2022-10-26 18:39:04 +02:00
|
|
|
public View getDecorView() {
|
2024-11-27 15:00:25 +01:00
|
|
|
return decorView;
|
2022-10-26 18:39:04 +02:00
|
|
|
}
|
|
|
|
|
|
2024-12-11 21:42:22 +01:00
|
|
|
public native void set_widget_as_root(long native_window, long widget);
|
2024-11-03 08:26:11 +01:00
|
|
|
private native void set_title(long native_window, String title);
|
2022-11-11 19:18:21 +01:00
|
|
|
|
|
|
|
|
public native void take_input_queue(long native_window, InputQueue.Callback callback, InputQueue queue);
|
2024-12-10 23:47:52 +01:00
|
|
|
public native void set_layout(long native_window, int width, int height);
|
2022-11-11 19:18:21 +01:00
|
|
|
|
|
|
|
|
public void takeInputQueue(InputQueue.Callback callback) {
|
|
|
|
|
take_input_queue(native_window, callback, new InputQueue());
|
|
|
|
|
}
|
2023-06-18 11:03:43 +02:00
|
|
|
|
|
|
|
|
public boolean requestFeature(int featureId) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2023-08-17 10:46:24 +02:00
|
|
|
|
|
|
|
|
public View findViewById(int id) {
|
2024-11-27 15:00:25 +01:00
|
|
|
return decorView.findViewById(id);
|
2023-08-17 10:46:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public View peekDecorView() {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2023-09-01 12:34:57 +02:00
|
|
|
|
|
|
|
|
public WindowManager.LayoutParams getAttributes() {
|
|
|
|
|
return new WindowManager.LayoutParams();
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-16 15:03:06 +01:00
|
|
|
public void setBackgroundDrawable(Drawable drawable) {
|
2024-12-11 21:42:22 +01:00
|
|
|
decorView.setBackgroundDrawable(drawable);
|
2024-03-16 15:03:06 +01:00
|
|
|
}
|
|
|
|
|
|
2024-12-10 23:47:52 +01:00
|
|
|
public void setAttributes(WindowManager.LayoutParams params) {
|
2024-12-14 23:37:37 +01:00
|
|
|
setLayout(params.width, params.height);
|
2024-12-10 23:47:52 +01:00
|
|
|
}
|
2023-09-19 17:37:14 +05:00
|
|
|
|
|
|
|
|
public void takeSurface(SurfaceHolder.Callback2 callback) {}
|
2023-09-21 22:49:36 +02:00
|
|
|
|
|
|
|
|
public void setStatusBarColor(int color) {}
|
|
|
|
|
|
|
|
|
|
public void setNavigationBarColor(int color) {}
|
2024-03-15 21:22:46 +00:00
|
|
|
|
2024-04-14 15:15:37 +02:00
|
|
|
public void setFormat(int format) {}
|
|
|
|
|
|
2024-12-10 23:47:52 +01:00
|
|
|
public void setLayout(int width, int height) {
|
2024-12-14 23:37:37 +01:00
|
|
|
if (height == 0) // FIXME: remove this hack once measurement error with composeUI dialogs is fixed
|
|
|
|
|
height = 500;
|
2024-12-10 23:47:52 +01:00
|
|
|
set_layout(native_window, width, height);
|
|
|
|
|
}
|
2024-05-19 12:52:47 +05:00
|
|
|
|
|
|
|
|
public WindowManager getWindowManager() {
|
|
|
|
|
return new WindowManagerImpl();
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-13 21:00:06 +02:00
|
|
|
public void setSoftInputMode(int dummy) {}
|
2024-06-15 22:32:01 +02:00
|
|
|
|
|
|
|
|
public int getNavigationBarColor() {
|
|
|
|
|
return 0xFF888888; // gray
|
|
|
|
|
}
|
2024-06-24 18:44:31 +02:00
|
|
|
|
|
|
|
|
public void setBackgroundDrawableResource(int resId) {}
|
|
|
|
|
|
|
|
|
|
public int getStatusBarColor() { return 0xFFFF0000; }
|
2024-08-25 11:20:01 +02:00
|
|
|
|
|
|
|
|
public Context getContext() {
|
|
|
|
|
return context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean hasFeature(int featureId) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2024-11-03 08:26:11 +01:00
|
|
|
|
|
|
|
|
public void setTitle(CharSequence title) {
|
|
|
|
|
set_title(native_window, title != null ? title.toString() : context.getPackageName());
|
|
|
|
|
}
|
2025-01-11 18:01:43 +01:00
|
|
|
|
|
|
|
|
public Transition getSharedElementEnterTransition() {
|
|
|
|
|
return new Transition();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setSharedElementExitTransition(Transition transition) {}
|
|
|
|
|
|
|
|
|
|
public void setSharedElementReenterTransition(Transition transition) {}
|
|
|
|
|
|
|
|
|
|
public void setSharedElementReturnTransition(Transition transition) {}
|
|
|
|
|
|
|
|
|
|
public Transition getSharedElementExitTransition() {
|
|
|
|
|
return new Transition();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Transition getSharedElementReenterTransition() {
|
|
|
|
|
return new Transition();
|
|
|
|
|
}
|
2025-04-21 10:19:48 +02:00
|
|
|
|
|
|
|
|
public void setReturnTransition(Transition transition) {}
|
|
|
|
|
|
|
|
|
|
public void setEnterTransition(Transition transition) {}
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|