mirror of https://github.com/M66B/FairEmail.git
parent
dcc43a1f1c
commit
d488809a69
@ -0,0 +1,25 @@
|
|||||||
|
package eu.faircode.email;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
public class ToastEx {
|
||||||
|
public static Toast makeText(Context context, int resId, int duration) throws Resources.NotFoundException {
|
||||||
|
return makeText(context, context.getText(resId), duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Toast makeText(Context context, CharSequence text, int duration) {
|
||||||
|
Toast toast = new Toast(context);
|
||||||
|
LayoutInflater inflater = LayoutInflater.from(context);
|
||||||
|
View view = inflater.inflate(R.layout.toast, null);
|
||||||
|
TextView tv = view.findViewById(android.R.id.message);
|
||||||
|
tv.setText(text);
|
||||||
|
toast.setView(view);
|
||||||
|
toast.setDuration(duration);
|
||||||
|
return toast;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
<corners android:radius="12dp" />
|
||||||
|
<stroke
|
||||||
|
android:width="1dp"
|
||||||
|
android:color="?colorPrimary" />
|
||||||
|
<solid android:color="?colorPrimary" />
|
||||||
|
</shape>
|
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/toast_background"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="9dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@android:id/message"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="Message"
|
||||||
|
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
|
||||||
|
android:textColor="@android:color/white" />
|
||||||
|
</LinearLayout>
|
Loading…
Reference in new issue