You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
add Java APIs needed for WhatsApp MainActivity and ConversationActivity
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {}
|
||||
}
|
||||
@@ -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});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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) {}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user