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
Drawable: minor cleanup, add support for inflating adaptive-icon
This commit is contained in:
@@ -94,6 +94,10 @@ public class Drawable {
|
|||||||
onBoundsChange(mBounds);
|
onBoundsChange(mBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setBounds(Rect bounds) {
|
||||||
|
setBounds(bounds.left, bounds.top, bounds.right, bounds.bottom);
|
||||||
|
}
|
||||||
|
|
||||||
public final Rect getBounds() {
|
public final Rect getBounds() {
|
||||||
return mBounds;
|
return mBounds;
|
||||||
}
|
}
|
||||||
@@ -169,10 +173,6 @@ public class Drawable {
|
|||||||
public final int getLevel() {return 0;}
|
public final int getLevel() {return 0;}
|
||||||
public final boolean setLevel(int level) {return false;}
|
public final boolean setLevel(int level) {return false;}
|
||||||
|
|
||||||
public void setBounds(Rect bounds) {
|
|
||||||
setBounds(bounds.left, bounds.top, bounds.right, bounds.bottom);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColorFilter(int color, PorterDuff.Mode mode) {
|
public void setColorFilter(int color, PorterDuff.Mode mode) {
|
||||||
setColorFilter(new PorterDuffColorFilter(color, mode));
|
setColorFilter(new PorterDuffColorFilter(color, mode));
|
||||||
}
|
}
|
||||||
@@ -229,36 +229,51 @@ public class Drawable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Drawable createFromXmlInner(Resources resources, XmlPullParser parser, AttributeSet attrs, Theme theme) throws XmlPullParserException, IOException {
|
public static Drawable createFromXmlInner(Resources resources, XmlPullParser parser, AttributeSet attrs, Theme theme) throws XmlPullParserException, IOException {
|
||||||
if ("selector".equals(parser.getName())) {
|
switch (parser.getName()) {
|
||||||
StateListDrawable drawable = new StateListDrawable();
|
case "selector": {
|
||||||
drawable.inflate(resources, parser, attrs, theme);
|
StateListDrawable drawable = new StateListDrawable();
|
||||||
return drawable;
|
drawable.inflate(resources, parser, attrs, theme);
|
||||||
} else if ("shape".equals(parser.getName())) {
|
return drawable;
|
||||||
GradientDrawable drawable = new GradientDrawable();
|
}
|
||||||
drawable.inflate(resources, parser, attrs, theme);
|
case "shape": {
|
||||||
return drawable;
|
GradientDrawable drawable = new GradientDrawable();
|
||||||
} else if ("bitmap".equals(parser.getName())) {
|
drawable.inflate(resources, parser, attrs, theme);
|
||||||
BitmapDrawable drawable = new BitmapDrawable();
|
return drawable;
|
||||||
drawable.inflate(resources, parser, attrs, theme);
|
} case "bitmap": {
|
||||||
return drawable;
|
BitmapDrawable drawable = new BitmapDrawable();
|
||||||
} else if ("transition".equals(parser.getName())) {
|
drawable.inflate(resources, parser, attrs, theme);
|
||||||
return new Drawable();
|
return drawable;
|
||||||
} else if ("ripple".equals(parser.getName())) {
|
}
|
||||||
// FIXME: the non-pressed state of RippleDrawable should be equivalent to this
|
case "transition": {
|
||||||
return new ColorDrawable(0);
|
return new Drawable();
|
||||||
} else if ("vector".equals(parser.getName())) {
|
}
|
||||||
VectorDrawable drawable = new VectorDrawable();
|
case "ripple": {
|
||||||
drawable.inflate(resources, parser, attrs, theme);
|
// FIXME: the non-pressed state of RippleDrawable should be equivalent to this
|
||||||
return drawable;
|
return new ColorDrawable(0);
|
||||||
} else if ("layer-list".equals(parser.getName())) {
|
}
|
||||||
LayerDrawable drawable = new LayerDrawable();
|
case "vector": {
|
||||||
drawable.inflate(resources, parser, attrs, theme);
|
VectorDrawable drawable = new VectorDrawable();
|
||||||
return drawable;
|
drawable.inflate(resources, parser, attrs, theme);
|
||||||
} else if ("nine-patch".equals(parser.getName())) {
|
return drawable;
|
||||||
return new NinePatchDrawable(resources, null, null, null, null);
|
}
|
||||||
} else if ("animation-list".equals(parser.getName())) {
|
case "layer-list": {
|
||||||
return new AnimationDrawable();
|
LayerDrawable drawable = new LayerDrawable();
|
||||||
|
drawable.inflate(resources, parser, attrs, theme);
|
||||||
|
return drawable;
|
||||||
|
}
|
||||||
|
case "nine-patch": {
|
||||||
|
return new NinePatchDrawable(resources, null, null, null, null);
|
||||||
|
}
|
||||||
|
case "animation-list": {
|
||||||
|
return new AnimationDrawable();
|
||||||
|
}
|
||||||
|
case "adaptive-icon": {
|
||||||
|
AdaptiveIconDrawable drawable = new AdaptiveIconDrawable();
|
||||||
|
drawable.inflate(resources, parser, attrs, theme);
|
||||||
|
return drawable;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user