Commit aa4dd550 by Ben Getsug

updating android plugin to reflect changes made in dart

parent eb80de17
......@@ -37,17 +37,20 @@ public class FluttertoastPlugin implements MethodCallHandler {
String msg = call.argument("msg").toString();
String length = call.argument("length").toString();
String gravity = call.argument("gravity").toString();
Integer bgcolor = call.argument("bgcolor");
Integer textcolor = call.argument("textcolor");
Long bgcolor = call.argument("bgcolor");
Long textcolor = call.argument("textcolor");
Toast toast = Toast.makeText(ctx, msg, Toast.LENGTH_SHORT);
toast.setText(msg);
if(length.equals("long")) {
toast.setDuration(Toast.LENGTH_LONG);
} else {
toast.setDuration(Toast.LENGTH_SHORT);
}
switch (gravity) {
case "top":
toast.setGravity(Gravity.TOP, 0, 100);
......@@ -58,18 +61,18 @@ public class FluttertoastPlugin implements MethodCallHandler {
default:
toast.setGravity(Gravity.BOTTOM, 0, 100);
}
TextView text = toast.getView().findViewById(android.R.id.message);
if (defaultTextColor == 0) {
defaultTextColor = text.getCurrentTextColor();
}
if (!bgcolor.equals("null")) {
try {
RoundRectShape rectShape = new RoundRectShape(new float[] {100f, 100f, 100f, 100f, 100f, 100f, 100f, 100f}, null, null);
ShapeDrawable shapeDrawable = new ShapeDrawable(rectShape);
shapeDrawable.getPaint().setColor(bgcolor);
shapeDrawable.getPaint().setColor(bgcolor != null ? bgcolor.intValue() : Color.BLACK);
shapeDrawable.getPaint().setStyle(Paint.Style.FILL);
shapeDrawable.getPaint().setAntiAlias(true);
shapeDrawable.getPaint().setFlags(Paint.ANTI_ALIAS_FLAG);
......@@ -82,17 +85,12 @@ public class FluttertoastPlugin implements MethodCallHandler {
} catch (Exception e) {
e.printStackTrace();
}
}
if (!textcolor.equals("null")) {
try {
text.setTextColor(textcolor);
text.setTextColor(textcolor != null ? textcolor.intValue() : defaultTextColor);
} catch (Exception e) {
e.printStackTrace();
}
} else {
text.setTextColor(defaultTextColor);
}
toast.show();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment