api-impl: misc stubs, additions and fixes

This commit is contained in:
Mis012
2024-12-20 00:11:06 +01:00
parent df5390db5e
commit 58745f23ea
9 changed files with 69 additions and 20 deletions

View File

@@ -218,10 +218,10 @@ JNIEXPORT void JNICALL Java_android_graphics_Path_native_1addArc
/* /*
* Class: android_graphics_Path * Class: android_graphics_Path
* Method: native_addRoundRect * Method: native_addRoundRect
* Signature: (JLandroid/graphics/RectF;FFI)V * Signature: (JFFFFFFI)V
*/ */
JNIEXPORT void JNICALL Java_android_graphics_Path_native_1addRoundRect__JLandroid_graphics_RectF_2FFI JNIEXPORT void JNICALL Java_android_graphics_Path_native_1addRoundRect__JFFFFFFI
(JNIEnv *, jclass, jlong, jobject, jfloat, jfloat, jint); (JNIEnv *, jclass, jlong, jfloat, jfloat, jfloat, jfloat, jfloat, jfloat, jint);
/* /*
* Class: android_graphics_Path * Class: android_graphics_Path

View File

@@ -167,6 +167,12 @@ JNIEXPORT void JNICALL Java_android_graphics_Path_native_1rMoveTo(JNIEnv *env, j
sk_path_rmove_to(path, dx, dy); sk_path_rmove_to(path, dx, dy);
} }
JNIEXPORT void JNICALL Java_android_graphics_Path_native_1addRoundRect__JFFFFFFI(JNIEnv *env, jclass class, jlong path_ptr, jfloat left, jfloat top, jfloat right, jfloat bottom, jfloat rx, jfloat ry, jint dir)
{
sk_path_t *path = (sk_path_t *)_PTR(path_ptr);
sk_path_add_rounded_rect(path, &(sk_rect_t){left, top, right, bottom}, rx, ry, (sk_path_direction_t)dir);
}
JNIEXPORT void JNICALL Java_android_graphics_Path_native_1addRoundRect__JLandroid_graphics_RectF_2_3FI(JNIEnv *env, jclass class, jlong path_ptr, jobject rect, jfloatArray radii, jint dir) JNIEXPORT void JNICALL Java_android_graphics_Path_native_1addRoundRect__JLandroid_graphics_RectF_2_3FI(JNIEnv *env, jclass class, jlong path_ptr, jobject rect, jfloatArray radii, jint dir)
{ {
sk_path_t *path = (sk_path_t *)_PTR(path_ptr); sk_path_t *path = (sk_path_t *)_PTR(path_ptr);

View File

@@ -275,6 +275,10 @@ public class Paint {
return new Shader(); return new Shader();
} }
public PathEffect getPathEffect() {
return new PathEffect();
}
public PathEffect setPathEffect(PathEffect effect) { public PathEffect setPathEffect(PathEffect effect) {
return effect; return effect;
} }

View File

@@ -534,6 +534,19 @@ public class Path {
isSimplePath = false; isSimplePath = false;
native_addArc(mNativePath, oval, startAngle, sweepAngle); native_addArc(mNativePath, oval, startAngle, sweepAngle);
} }
/**
* Add a closed round-rectangle contour to the path
*
* @param rx The x-radius of the rounded corners on the round-rectangle
* @param ry The y-radius of the rounded corners on the round-rectangle
* @param dir The direction to wind the round-rectangle's contour
*
*/
public void addRoundRect(float left, float top, float right, float bottom, float rx, float ry, Direction dir) {
native_addRoundRect(mNativePath, left, top, right, bottom, rx, ry, dir.nativeInt);
}
/** /**
* Add a closed round-rectangle contour to the path * Add a closed round-rectangle contour to the path
* *
@@ -547,7 +560,7 @@ public class Path {
throw new NullPointerException("need rect parameter"); throw new NullPointerException("need rect parameter");
} }
isSimplePath = false; isSimplePath = false;
native_addRoundRect(mNativePath, rect, rx, ry, dir.nativeInt); addRoundRect(rect.left, rect.top, rect.right, rect.bottom, rx, ry, dir);
} }
/** /**
@@ -707,7 +720,7 @@ public class Path {
private static native void native_addCircle(long nPath, float x, float y, float radius, int dir); private static native void native_addCircle(long nPath, float x, float y, float radius, int dir);
private static native void native_addArc(long nPath, RectF oval, private static native void native_addArc(long nPath, RectF oval,
float startAngle, float sweepAngle); float startAngle, float sweepAngle);
private static native void native_addRoundRect(long nPath, RectF rect, private static native void native_addRoundRect(long nPath, float left, float top, float right, float bottom,
float rx, float ry, int dir); float rx, float ry, int dir);
private static native void native_addRoundRect(long nPath, RectF r, float[] radii, int dir); private static native void native_addRoundRect(long nPath, RectF r, float[] radii, int dir);
private static native void native_addPath(long nPath, long src, float dx, float dy); private static native void native_addPath(long nPath, long src, float dx, float dy);

View File

@@ -47,7 +47,7 @@ public class Typeface {
} }
public static Typeface create(Typeface typeface, int style) { public static Typeface create(Typeface typeface, int style) {
return typeface; return typeface != null ? typeface : DEFAULT;
} }
public static Typeface createFromFile(String path) { public static Typeface createFromFile(String path) {

View File

@@ -896,12 +896,16 @@ public class View implements Drawable.Callback {
} }
public View(Context context, AttributeSet attrs, int defStyle) { public View(Context context, AttributeSet attrs, int defStyle) {
this(context, attrs, defStyle, 0);
}
public View(Context context, AttributeSet attrs, int defStyle, int defStyleRes) {
this.context = context; this.context = context;
widget = native_constructor(context, attrs); widget = native_constructor(context, attrs);
if (attrs != null) { if (attrs != null) {
TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.View, defStyle, 0); TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.View, defStyle, defStyleRes);
this.id = a.getResourceId(com.android.internal.R.styleable.View_id, View.NO_ID); this.id = a.getResourceId(com.android.internal.R.styleable.View_id, View.NO_ID);
if (a.hasValue(com.android.internal.R.styleable.View_background)) { if (a.hasValue(com.android.internal.R.styleable.View_background)) {
try { try {
@@ -2095,4 +2099,7 @@ public class View implements Drawable.Callback {
public void setPointerIcon(PointerIcon pointerIcon) {} public void setPointerIcon(PointerIcon pointerIcon) {}
public IBinder getApplicationWindowToken() {return null;} public IBinder getApplicationWindowToken() {return null;}
public int getVerticalFadingEdgeLength() {return 0;}
public int getVerticalScrollbarWidth() {return 0;}
} }

View File

@@ -6,7 +6,9 @@ import android.content.Context;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.GskCanvas; import android.graphics.GskCanvas;
import android.graphics.Rect;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.util.Slog;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.Objects; import java.util.Objects;
@@ -357,8 +359,11 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
public void setClipToPadding(boolean clipToPadding) {} public void setClipToPadding(boolean clipToPadding) {}
public View findViewById(int id) { public View findViewById(int id) {
if (this.id == id) Slog.v(TAG, "findViewById: looking for id: " + String.format("%x", id) + "(" + getResources().getResourceName(id) + ")" + " | checking: " + this + ",id: " + String.format("%x", this.getId()) + ", id_str: " + this.getIdName());
if (this.id == id) {
Slog.v(TAG, "findViewById: found: "+this+" | id: " + String.format("%x", this.getId()) + ", id_str: " + this.getIdName());
return this; return this;
}
for (View child: children) { for (View child: children) {
View result = child.findViewById(id); View result = child.findViewById(id);
if (result != null) if (result != null)
@@ -409,6 +414,14 @@ public class ViewGroup extends View implements ViewParent, ViewManager {
} }
} }
public void offsetChildrenTopAndBottom(int offset) {
// FIXME
}
public final void offsetDescendantRectToMyCoords(View descendant, Rect rect) {
// FIXME
}
public static class LayoutParams { public static class LayoutParams {
public static final int FILL_PARENT = -1; public static final int FILL_PARENT = -1;
public static final int MATCH_PARENT = -1; public static final int MATCH_PARENT = -1;

View File

@@ -2,13 +2,15 @@ package android.view.accessibility;
public class AccessibilityNodeInfo { public class AccessibilityNodeInfo {
public static final class AccessibilityAction { public static final class AccessibilityAction {
public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SHOW_ON_SCREEN = new AccessibilityAction(0, null); public static final AccessibilityAction ACTION_CONTEXT_CLICK = new AccessibilityAction(0, null);
public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_TO_POSITION = new AccessibilityAction(0, null); public static final AccessibilityAction ACTION_SET_PROGRESS = new AccessibilityAction(0, null);
public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_UP = new AccessibilityAction(0, null); public static final AccessibilityAction ACTION_SHOW_ON_SCREEN = new AccessibilityAction(0, null);
public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_LEFT = new AccessibilityAction(0, null); public static final AccessibilityAction ACTION_SCROLL_TO_POSITION = new AccessibilityAction(0, null);
public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_RIGHT = new AccessibilityAction(0, null); public static final AccessibilityAction ACTION_SCROLL_UP = new AccessibilityAction(0, null);
public static final AccessibilityNodeInfo.AccessibilityAction ACTION_SCROLL_DOWN = new AccessibilityAction(0, null); public static final AccessibilityAction ACTION_SCROLL_LEFT = new AccessibilityAction(0, null);
public static final AccessibilityNodeInfo.AccessibilityAction ACTION_CONTEXT_CLICK = new AccessibilityAction(0, null); public static final AccessibilityAction ACTION_SCROLL_RIGHT = new AccessibilityAction(0, null);
public static final AccessibilityAction ACTION_SCROLL_DOWN = new AccessibilityAction(0, null);
public AccessibilityAction(int actionId, CharSequence label) {} public AccessibilityAction(int actionId, CharSequence label) {}

View File

@@ -29,7 +29,11 @@ public class ImageView extends View {
} }
public ImageView(Context context, AttributeSet attrs, int defStyleAttr) { public ImageView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr); this(context, attrs, defStyleAttr, 0);
}
public ImageView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
haveCustomMeasure = false; haveCustomMeasure = false;
TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.ImageView, defStyleAttr, 0); TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.ImageView, defStyleAttr, 0);
@@ -65,7 +69,7 @@ public class ImageView extends View {
} }
public void setImageDrawable(Drawable drawable) { public void setImageDrawable(Drawable drawable) {
if (colorFilter != null) { if (drawable != null && colorFilter != null) {
drawable = drawable.mutate(); drawable = drawable.mutate();
drawable.setColorFilter(colorFilter); drawable.setColorFilter(colorFilter);
} }