add Java APIs needed for WhatsApp MainActivity and ConversationActivity

This commit is contained in:
Julian Winkler
2024-08-25 11:20:01 +02:00
parent 9d8e091799
commit c492e1f03f
74 changed files with 903 additions and 69 deletions

View File

@@ -566,6 +566,10 @@ public class BitmapFactory {
}
setDensityFromOptions(bm, opts);
if (bm != null && opts != null) {
opts.outWidth = bm.getWidth();
opts.outHeight = bm.getHeight();
}
} finally {
Trace.traceEnd(Trace.TRACE_TAG_GRAPHICS);
}

View File

@@ -399,7 +399,14 @@ public class Canvas {
native_drawLine(skia_canvas, widget, startX, startY, stopX, stopY, paint.skia_paint);
}
public void setBitmap(Bitmap bitmap) {}
public void setBitmap(Bitmap bitmap) {
if (skia_canvas != 0) {
native_destroy_canvas(skia_canvas);
}
bitmap.destroyTexture(); // invalidate cached texture
this.skia_canvas = native_canvas_from_bitmap(bitmap.pixbuf);
this.widget = 0;
}
public void drawPath(Path path, Paint paint) {
native_drawPath(skia_canvas, path.mNativePath, paint.skia_paint);
@@ -445,6 +452,20 @@ public class Canvas {
public void drawColor(int dummy) {}
public void drawARGB(int a, int r, int g, int b) {}
public int saveLayer(RectF bounds, Paint paint, int flags) {
return save();
}
public void drawOval(RectF oval, Paint paint) {}
public boolean clipRect(int left, int top, int right, int bottom) {
return false;
}
public void drawColor(int color, PorterDuff.Mode mode) {}
private static native long native_canvas_from_bitmap(long pixbuf);
private static native void native_save(long skia_canvas, long widget);

View File

@@ -423,6 +423,10 @@ public class Path {
native_arcTo(mNativePath, oval, startAngle, sweepAngle, false);
}
public void arcTo(float left, float top, float right, float bottom, float startAngle, float sweepAngle, boolean forceMoveTo) {
arcTo(new RectF(left, top, right, bottom), startAngle, sweepAngle, forceMoveTo);
}
/**
* Close the current contour. If the current point is not equal to the
* first point of the contour, a line segment is automatically added.

View File

@@ -28,6 +28,11 @@ public class BitmapDrawable extends Drawable {
this.paintable = bitmap.getTexture();
}
public BitmapDrawable(Bitmap bitmap) {
this.bitmap = bitmap;
this.paintable = bitmap.getTexture();
}
public Bitmap getBitmap() {
return bitmap;
}

View File

@@ -14,6 +14,7 @@ import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.content.res.Resources.Theme;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
@@ -54,7 +55,24 @@ public class Drawable {
public void setChangingConfigurations(int bitmap) {}
public ConstantState getConstantState() {
return null;
return new ConstantState() {
@Override
public Drawable newDrawable(Resources res) {
return Drawable.this;
}
@Override
public Drawable newDrawable() {
return Drawable.this;
}
@Override
public int getChangingConfigurations() {
return Drawable.this.getChangingConfigurations();
}
};
}
public static abstract class ConstantState {
@@ -220,12 +238,17 @@ public class Drawable {
LayerDrawable drawable = new LayerDrawable();
drawable.inflate(resources, parser, attrs);
return drawable;
} else if ("nine-patch".equals(parser.getName())) {
return new NinePatchDrawable(resources, null, null, null, null);
}
return null;
}
public static Drawable createFromResourceStream(Resources resources, TypedValue value, InputStream is, String file,
Object object) {
if (!file.endsWith(".9.png")) {
return new BitmapDrawable(resources, BitmapFactory.decodeStream(is));
}
Path path = Paths.get(android.os.Environment.getExternalStorageDirectory().getPath(), file);
if (!Files.exists(path)) {
try (InputStream inputStream = ClassLoader.getSystemClassLoader().getResourceAsStream(file)) {

View File

@@ -4,14 +4,22 @@ import android.graphics.Rect;
public class InsetDrawable extends Drawable {
private Drawable drawable;
public InsetDrawable(Drawable drawable, int insetLeft, int insetTop, int insetRight, int insetBottom) {
super();
this.drawable = drawable;
}
public InsetDrawable(Drawable drawable, int inset) {
super();
this.drawable = drawable;
}
public boolean getPadding(Rect padding) { return false; }
public Drawable getDrawable() {
return drawable;
}
}

View File

@@ -0,0 +1,10 @@
package android.graphics.drawable;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Rect;
public class NinePatchDrawable extends Drawable {
public NinePatchDrawable(Resources res, Bitmap bitmap, byte[] data, Rect padding, String name) {}
}

View File

@@ -2,8 +2,10 @@ package android.graphics.drawable;
import android.content.res.ColorStateList;
public class RippleDrawable extends Drawable {
public class RippleDrawable extends LayerDrawable {
public RippleDrawable(ColorStateList colorStateList, Drawable drawable, Drawable drawable2) {}
public RippleDrawable(ColorStateList colorStateList, Drawable drawable, Drawable drawable2) {
super(new Drawable[] {drawable});
}
}

View File

@@ -1,6 +1,7 @@
package android.graphics.drawable;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.shapes.Shape;
public class ShapeDrawable extends Drawable {
@@ -8,5 +9,9 @@ public class ShapeDrawable extends Drawable {
public ShapeDrawable(Shape shape) {}
public Paint getPaint() {return new Paint();}
public void setPadding(Rect padding) {}
public void setShape(Shape shape) {}
}