api-impl,libandroid: Add some stubs, mostly

This commit is contained in:
Nikita Travkin
2023-09-19 17:37:14 +05:00
committed by Mis012
parent a32961891d
commit d3e5c6ee70
8 changed files with 102 additions and 2 deletions

View File

@@ -14,6 +14,10 @@ public class AlertDialog extends Dialog implements DialogInterface {
super(context, 0);
}
public AlertDialog(Context context, int themeResId) {
super(context, themeResId);
}
public void setMessage(CharSequence message) {
System.out.println("AlertDialog setMessage called with: '" + message + "'");
nativeSetMessage(nativePtr, String.valueOf(message));
@@ -41,6 +45,12 @@ public class AlertDialog extends Dialog implements DialogInterface {
return this;
}
public AlertDialog.Builder setNegativeButton (CharSequence text, DialogInterface.OnClickListener listener) {
System.out.println("AlertDialog.Builder setNegativeButton called with text: '" + text + "'");
return this;
}
public AlertDialog.Builder setCancelable(boolean cancelable) {
return this;
}

View File

@@ -38,6 +38,10 @@ public class Dialog {
nativeSetTitle(nativePtr, String.valueOf(title));
}
public void setTitle(int titleId) {
nativeSetTitle(nativePtr, context.getString(titleId));
}
public void setOwnerActivity(Activity activity) {}
public void setCancelable(boolean cancelable) {}

View File

@@ -2,9 +2,15 @@ package android.app;
import android.content.Context;
public class ProgressDialog extends Dialog {
public class ProgressDialog extends AlertDialog {
public ProgressDialog(Context context) {
super(context, 0);
}
public ProgressDialog(Context context, int themeResId) {
super(context, themeResId);
}
public void setIndeterminate(boolean indeterminate) {}
}

View File

@@ -164,6 +164,18 @@ public class Intent {
return this;
}
public Intent putExtras (Intent src) {
// FIXME HACK
this.extras = src.getExtras();
return this;
}
public Intent putExtras (Bundle extras) {
// FIXME HACK
this.extras = extras;
return this;
}
public Intent setClass(Context packageContext, Class<?> cls) {
setComponent(new ComponentName(packageContext, cls));
return this;
@@ -177,6 +189,13 @@ public class Intent {
return data;
}
public String getDataString () {
if (data == null)
return "";
return data.toString();
}
public boolean getBooleanExtra(String name, boolean defaultValue) {
return defaultValue;
}

View File

@@ -1,6 +1,7 @@
package android.hardware.input;
import android.os.Handler;
import android.view.InputDevice;
public class InputManager {
public static interface InputDeviceListener {
@@ -11,4 +12,13 @@ public class InputManager {
public void registerInputDeviceListener(InputManager.InputDeviceListener listener, Handler handler) {
}
public int[] getInputDeviceIds () {
return InputDevice.getDeviceIds();
}
public InputDevice getInputDevice (int id) {
return InputDevice.getDevice(id);
}
}

View File

@@ -1,15 +1,55 @@
package android.view;
import java.util.List;
import java.util.ArrayList;
public class InputDevice {
public static final int SOURCE_CLASS_BUTTON = 0x00000001;
public static final int SOURCE_CLASS_JOYSTICK = 0x00000010;
public static final int SOURCE_CLASS_GAMEPAD = 0x00000400 | SOURCE_CLASS_BUTTON;
public static final int SOURCE_KEYBOARD = 0x00000100 | SOURCE_CLASS_BUTTON;
public static int[] getDeviceIds() {
return new int[] {0}; // might work?
}
public static InputDevice getDevice(int id) {
return null;
return new InputDevice();
}
/*
* FIXME: We pretend we can do literally everything here...
*/
public boolean[] hasKeys(int... keys) {
boolean[] ret = new boolean[keys.length];
for (int i = 0; i < keys.length; i++) {
ret[i] = true;
}
return ret;
}
public List<InputDevice.MotionRange>getMotionRanges() {
MotionRange[] ranges = new MotionRange[32];
for (int i = 0; i < ranges.length; i++) {
ranges[i] = new MotionRange(i);
}
return new ArrayList<InputDevice.MotionRange>();
}
public class MotionRange {
int axis;
public MotionRange(int axis) {
this.axis = axis;
}
public int getAxis() {
return this.axis;
}
};
}

View File

@@ -1,5 +1,7 @@
package android.view;
import android.view.SurfaceHolder;
public class Window {
public static final int FEATURE_OPTIONS_PANEL = 0;
@@ -72,4 +74,6 @@ public class Window {
}
public void setAttributes(WindowManager.LayoutParams params) {}
public void takeSurface(SurfaceHolder.Callback2 callback) {}
}

View File

@@ -538,3 +538,10 @@ XrResult bionic_xrCreateInstance(XrInstanceCreateInfo *createInfo, XrInstance *i
createInfo->enabledExtensionNames = enabled_exts;
return xr_lazy_call("xrCreateInstance", createInfo, instance);
}
typedef void* ANativeActivity;
void ANativeActivity_setWindowFormat(ANativeActivity *activity, int32_t format)
{
printf("STUB: %s called\n", __func__);
}