Skip to content

Commit 97583c3

Browse files
committed
Fixed methods
1 parent 3c47240 commit 97583c3

File tree

7 files changed

+253
-285
lines changed

7 files changed

+253
-285
lines changed

.idea/workspace.xml

Lines changed: 106 additions & 229 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/github/pierry/simpletoast/SimpleToast.java

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@
22

33
import android.annotation.TargetApi;
44
import android.content.Context;
5-
import android.graphics.drawable.GradientDrawable;
6-
import android.graphics.drawable.ShapeDrawable;
75
import android.os.Build;
86
import android.view.LayoutInflater;
97
import android.view.View;
108
import android.widget.Button;
119
import android.widget.IconTextView;
12-
import android.widget.ImageView;
1310
import android.widget.LinearLayout;
1411
import android.widget.Toast;
15-
import com.joanzapata.android.iconify.IconDrawable;
16-
import com.joanzapata.android.iconify.Iconify;
1712

1813
/*
1914
* Copyright (C) 2015 Pierry Borges
@@ -52,16 +47,17 @@ public static void ok(Context context, String msg) {
5247
mytoast.show();
5348
}
5449

55-
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void ok(Context context, String msg, Iconify.IconValue iconValue) {
50+
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void ok(Context context, String msg,
51+
String icon) {
5652
LayoutInflater myInflater = LayoutInflater.from(context);
5753
View view = myInflater.inflate(R.layout.toast_ok_icon, null);
5854

5955
Button button = (Button) view.findViewById(R.id.button);
6056
button.setText(msg);
6157

6258
IconTextView img = (IconTextView) view.findViewById(R.id.img);
63-
img.setBackground(new IconDrawable(context, iconValue)
64-
.colorRes(R.color.white).actionBarSize());
59+
img.setText(icon);
60+
img.setTextSize(20);
6561

6662
Toast mytoast = new Toast(context);
6763

@@ -84,16 +80,17 @@ public static void error(Context context, String msg) {
8480
mytoast.show();
8581
}
8682

87-
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void error(Context context, String msg, Iconify.IconValue iconValue) {
83+
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void error(Context context, String msg,
84+
String icon) {
8885
LayoutInflater myInflater = LayoutInflater.from(context);
8986
View view = myInflater.inflate(R.layout.toast_error_icon, null);
9087

9188
Button button = (Button) view.findViewById(R.id.button);
9289
button.setText(msg);
9390

9491
IconTextView img = (IconTextView) view.findViewById(R.id.img);
95-
img.setBackground(new IconDrawable(context, iconValue)
96-
.colorRes(R.color.white).actionBarSize());
92+
img.setText(icon);
93+
img.setTextSize(20);
9794

9895
Toast mytoast = new Toast(context);
9996

@@ -116,16 +113,50 @@ public static void info(Context context, String msg) {
116113
mytoast.show();
117114
}
118115

119-
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void info(Context context, String msg, Iconify.IconValue iconValue) {
116+
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void info(Context context, String msg,
117+
String icon) {
120118
LayoutInflater myInflater = LayoutInflater.from(context);
121119
View view = myInflater.inflate(R.layout.toast_info_icon, null);
122120

123121
Button button = (Button) view.findViewById(R.id.button);
124122
button.setText(msg);
125123

126124
IconTextView img = (IconTextView) view.findViewById(R.id.img);
127-
img.setBackground(new IconDrawable(context, iconValue)
128-
.colorRes(R.color.white).actionBarSize());
125+
img.setText(icon);
126+
img.setTextSize(20);
127+
128+
Toast mytoast = new Toast(context);
129+
130+
mytoast.setView(view);
131+
mytoast.setDuration(Toast.LENGTH_SHORT);
132+
mytoast.show();
133+
}
134+
135+
public static void muted(Context context, String msg) {
136+
LayoutInflater myInflater = LayoutInflater.from(context);
137+
View view = myInflater.inflate(R.layout.toast_muted, null);
138+
139+
Button button = (Button) view.findViewById(R.id.button);
140+
button.setText(msg);
141+
142+
Toast mytoast = new Toast(context);
143+
144+
mytoast.setView(view);
145+
mytoast.setDuration(Toast.LENGTH_SHORT);
146+
mytoast.show();
147+
}
148+
149+
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void muted(Context context, String msg,
150+
String icon) {
151+
LayoutInflater myInflater = LayoutInflater.from(context);
152+
View view = myInflater.inflate(R.layout.toast_muted_icon, null);
153+
154+
Button button = (Button) view.findViewById(R.id.button);
155+
button.setText(msg);
156+
157+
IconTextView img = (IconTextView) view.findViewById(R.id.img);
158+
img.setText(icon);
159+
img.setTextSize(20);
129160

130161
Toast mytoast = new Toast(context);
131162

app/src/main/res/layout/toast_error_icon.xml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,16 @@
33
android:id="@+id/layout"
44
android:layout_width="wrap_content"
55
android:layout_height="wrap_content"
6-
android:background="@drawable/list_border_back_red"
7-
>
6+
android:background="@drawable/list_border_back_red" >
87

98
<IconTextView
10-
android:layout_height="wrap_content"
9+
android:layout_height="fill_parent"
1110
android:layout_width="wrap_content"
1211
android:id="@+id/img"
13-
android:layout_marginBottom="4dp"
14-
android:layout_marginLeft="4dp"
15-
android:layout_marginTop="4dp"
16-
android:textSize="40dp"
12+
android:layout_marginBottom="15dp"
13+
android:layout_marginLeft="10dp"
1714
android:textColor="@color/white"
18-
/>
15+
android:layout_marginTop="15dp" />
1916

2017
<Button
2118
android:id="@+id/button"
@@ -32,7 +29,6 @@
3229
android:paddingTop="10dp"
3330
android:text="Texto"
3431
android:textColor="#FFFFFF"
35-
android:textSize="14sp"
36-
/>
32+
android:textSize="14sp" />
3733

3834
</LinearLayout>

app/src/main/res/layout/toast_info_icon.xml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,16 @@
33
android:id="@+id/layout"
44
android:layout_width="wrap_content"
55
android:layout_height="wrap_content"
6-
android:background="@drawable/list_border_back_green"
7-
>
6+
android:background="@drawable/list_border_back_green" >
87

98
<IconTextView
10-
android:layout_height="wrap_content"
9+
android:layout_height="fill_parent"
1110
android:layout_width="wrap_content"
1211
android:id="@+id/img"
13-
android:layout_marginBottom="4dp"
14-
android:layout_marginLeft="4dp"
15-
android:layout_marginTop="4dp"
16-
android:textSize="40dp"
12+
android:layout_marginBottom="15dp"
13+
android:layout_marginLeft="10dp"
1714
android:textColor="@color/white"
18-
/>
15+
android:layout_marginTop="15dp" />
1916

2017
<Button
2118
android:id="@+id/button"
@@ -32,7 +29,6 @@
3229
android:paddingTop="10dp"
3330
android:text="Texto"
3431
android:textColor="#FFFFFF"
35-
android:textSize="14sp"
36-
/>
32+
android:textSize="14sp" />
3733

3834
</LinearLayout>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:id="@+id/layout"
4+
android:layout_width="wrap_content"
5+
android:layout_height="wrap_content"
6+
android:background="@drawable/list_border_back_gray" >
7+
8+
<ImageView
9+
android:id="@+id/img"
10+
android:layout_width="wrap_content"
11+
android:layout_height="wrap_content"
12+
android:layout_marginBottom="4dp"
13+
android:layout_marginLeft="4dp"
14+
android:layout_marginTop="4dp"
15+
android:background="@drawable/ok"
16+
android:src="@drawable/ok" />
17+
18+
<Button
19+
android:id="@+id/button"
20+
android:layout_width="wrap_content"
21+
android:layout_height="wrap_content"
22+
android:layout_gravity="center_vertical"
23+
android:layout_marginLeft="8dp"
24+
android:layout_marginRight="13dp"
25+
android:layout_toRightOf="@+id/img"
26+
android:background="@android:color/transparent"
27+
android:paddingBottom="10dp"
28+
android:paddingLeft="10sp"
29+
android:paddingRight="10sp"
30+
android:paddingTop="10dp"
31+
android:text="Texto"
32+
android:textColor="#FFFFFF"
33+
android:textSize="14sp" />
34+
35+
</LinearLayout>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:id="@+id/layout"
4+
android:layout_width="wrap_content"
5+
android:layout_height="wrap_content"
6+
android:background="@drawable/list_border_back_gray" >
7+
8+
<IconTextView
9+
android:layout_height="fill_parent"
10+
android:layout_width="wrap_content"
11+
android:id="@+id/img"
12+
android:layout_marginBottom="15dp"
13+
android:layout_marginLeft="10dp"
14+
android:textColor="@color/white"
15+
android:layout_marginTop="15dp" />
16+
17+
<Button
18+
android:id="@+id/button"
19+
android:layout_width="wrap_content"
20+
android:layout_height="wrap_content"
21+
android:layout_gravity="center_vertical"
22+
android:layout_marginLeft="8dp"
23+
android:layout_marginRight="13dp"
24+
android:layout_toRightOf="@+id/img"
25+
android:background="@android:color/transparent"
26+
android:paddingBottom="10dp"
27+
android:paddingLeft="10sp"
28+
android:paddingRight="10sp"
29+
android:paddingTop="10dp"
30+
android:text="Texto"
31+
android:textColor="#FFFFFF"
32+
android:textSize="14sp" />
33+
34+
</LinearLayout>

app/src/main/res/layout/toast_ok_icon.xml

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,29 @@
66
android:background="@drawable/list_border_back_blue" >
77

88
<IconTextView
9-
android:layout_height="wrap_content"
9+
android:layout_height="fill_parent"
1010
android:layout_width="wrap_content"
1111
android:id="@+id/img"
12-
android:layout_marginBottom="4dp"
13-
android:layout_marginLeft="4dp"
14-
android:layout_marginTop="4dp"
15-
android:textSize="40dp"
16-
android:textColor="@color/white" />
12+
android:layout_marginBottom="15dp"
13+
android:layout_marginLeft="10dp"
14+
android:textColor="@color/white"
15+
android:layout_marginTop="15dp" />
1716

18-
<Button
19-
android:id="@+id/button"
20-
android:layout_width="wrap_content"
21-
android:layout_height="wrap_content"
22-
android:layout_gravity="center_vertical"
23-
android:layout_marginLeft="8dp"
24-
android:layout_marginRight="13dp"
25-
android:layout_toRightOf="@+id/img"
26-
android:background="@android:color/transparent"
27-
android:paddingBottom="10dp"
28-
android:paddingLeft="10sp"
29-
android:paddingRight="10sp"
30-
android:paddingTop="10dp"
31-
android:text="Texto"
32-
android:textColor="#FFFFFF"
33-
android:textSize="14sp" />
17+
<Button
18+
android:id="@+id/button"
19+
android:layout_width="wrap_content"
20+
android:layout_height="wrap_content"
21+
android:layout_gravity="center_vertical"
22+
android:layout_marginLeft="8dp"
23+
android:layout_marginRight="13dp"
24+
android:layout_toRightOf="@+id/img"
25+
android:background="@android:color/transparent"
26+
android:paddingBottom="10dp"
27+
android:paddingLeft="10sp"
28+
android:paddingRight="10sp"
29+
android:paddingTop="10dp"
30+
android:text="Texto"
31+
android:textColor="#FFFFFF"
32+
android:textSize="14sp" />
3433

3534
</LinearLayout>

0 commit comments

Comments
 (0)