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
fix some Drawable related crashes in NewPipe
This commit is contained in:
@@ -923,6 +923,8 @@ public final class AssetManager {
|
||||
int[] inAttrs, int[] outValues, int[] outIndices) {
|
||||
if (defStyleRes == 0 && theme.containsKey(defStyleAttr))
|
||||
defStyleRes = theme.get(defStyleAttr).getData();
|
||||
if (defStyleRes == 0 && set != null)
|
||||
defStyleRes = set.getAttributeResourceValue(null, "style", 0);
|
||||
Map<Integer,ValueItem> defStyle = loadStyle(defStyleRes);
|
||||
|
||||
ResXmlPullParser parser = (ResXmlPullParser)set;
|
||||
|
||||
@@ -2050,8 +2050,9 @@ public class Resources {
|
||||
|
||||
if (dr == null) {
|
||||
if (value.string == null) {
|
||||
throw new NotFoundException(
|
||||
Log.w(TAG,
|
||||
"Resource is not a Drawable (color or path): " + value);
|
||||
return null;
|
||||
}
|
||||
|
||||
String file = value.string.toString();
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package android.graphics.drawable;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
|
||||
public class ColorDrawable extends Drawable {
|
||||
|
||||
private int color;
|
||||
|
||||
public ColorDrawable(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'draw'");
|
||||
public int getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -121,6 +121,8 @@ public class Drawable {
|
||||
StateListDrawable drawable = new StateListDrawable();
|
||||
drawable.inflate(resources, parser, parser, null);
|
||||
return drawable;
|
||||
} else if ("shape".equals(parser.getName())) {
|
||||
return new GradientDrawable();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -146,5 +148,11 @@ public class Drawable {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setAlpha(int alpha) {}
|
||||
|
||||
public boolean getPadding(Rect padding) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected static native long native_paintable_from_path(String path);
|
||||
}
|
||||
|
||||
@@ -844,12 +844,14 @@ public class View extends Object {
|
||||
int background = a.getResourceId(com.android.internal.R.styleable.View_background, 0);
|
||||
|
||||
if(background != 0) {
|
||||
if(context.getResources().getResourceTypeName(background).equals("color")) {// drawables not currently supported
|
||||
if(context.getResources().getResourceTypeName(background).equals("color")) {
|
||||
System.out.printf("__background__: >%x<\n", context.getResources().getColor(background));
|
||||
|
||||
final android.util.TypedValue typedValue = new android.util.TypedValue();
|
||||
|
||||
setBackgroundColor(context.getResources().getColor(background));
|
||||
} else {
|
||||
setBackgroundResource(background);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1014,7 +1016,7 @@ public class View extends Object {
|
||||
this.visibility = visibility;
|
||||
}
|
||||
public void setPadding(int left, int top, int right, int bottom) {}
|
||||
public void setBackgroundResource(int resid) throws Exception {
|
||||
public void setBackgroundResource(int resid) {
|
||||
setBackgroundDrawable(getResources().getDrawable(resid));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user