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;
|
2023-09-19 17:37:14 +05:00
|
|
|
import android.view.SurfaceHolder;
|
|
|
|
|
|
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;
|
|
|
|
|
|
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;
|
2023-08-22 13:20:04 +02:00
|
|
|
public View contentView;
|
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-02-11 12:33:58 +01:00
|
|
|
contentView = new ViewGroup(Context.this_application);
|
|
|
|
|
contentView.setId(android.R.id.content);
|
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-07-26 21:47:08 +02:00
|
|
|
if (contentView != view) {
|
|
|
|
|
if (contentView != null)
|
|
|
|
|
contentView.onDetachedFromWindow();
|
|
|
|
|
if (view != null)
|
|
|
|
|
view.onAttachedToWindow();
|
|
|
|
|
}
|
2023-10-28 09:21:04 +02:00
|
|
|
contentView = view;
|
2024-07-26 21:47:08 +02:00
|
|
|
if (view != null) {
|
|
|
|
|
set_widget_as_root(native_window, view.widget);
|
|
|
|
|
}
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|
|
|
|
|
|
2022-10-26 18:39:04 +02:00
|
|
|
public View getDecorView() {
|
2023-11-04 17:00:12 +01:00
|
|
|
if (contentView != null)
|
|
|
|
|
return contentView;
|
2023-12-29 11:05:05 +01:00
|
|
|
return new View(Context.this_application); // FIXME: this can probably backfire
|
2022-10-26 18:39:04 +02:00
|
|
|
}
|
|
|
|
|
|
2022-10-02 23:06:56 +02:00
|
|
|
private native void set_widget_as_root(long native_window, long widget);
|
2022-11-11 19:18:21 +01:00
|
|
|
|
|
|
|
|
public native void take_input_queue(long native_window, InputQueue.Callback callback, InputQueue queue);
|
|
|
|
|
|
|
|
|
|
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-02-11 12:33:58 +01:00
|
|
|
if (contentView != null)
|
|
|
|
|
return contentView.findViewById(id);
|
|
|
|
|
else
|
|
|
|
|
return null;
|
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) {
|
|
|
|
|
/* TODO: should this be *under* the contentView background? */
|
|
|
|
|
if (contentView != null)
|
|
|
|
|
contentView.setBackgroundDrawable(drawable);
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-01 12:34:57 +02:00
|
|
|
public void setAttributes(WindowManager.LayoutParams params) {}
|
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) {}
|
|
|
|
|
|
|
|
|
|
public void setLayout(int dummy, int dummy2) {}
|
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;
|
|
|
|
|
}
|
2022-10-02 23:06:56 +02:00
|
|
|
}
|