Added B/W toast

This commit is contained in:
M66B
2020-09-22 19:44:53 +02:00
parent 2ed0472912
commit 68d1c8b03e
3 changed files with 32 additions and 2 deletions

View File

@@ -21,6 +21,7 @@ package eu.faircode.email;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Looper;
import android.view.Gravity;
import android.view.LayoutInflater;
@@ -54,6 +55,20 @@ public class ToastEx extends Toast {
return toast;
}
public static ToastEx makeTextBw(Context context, CharSequence text, int duration) {
ToastEx toast = new ToastEx(context);
LayoutInflater inflater = LayoutInflater.from(context);
View view = inflater.inflate(R.layout.toast, null);
view.setBackground(context.getDrawable(android.R.drawable.toast_frame));
TextView tv = view.findViewById(android.R.id.message);
tv.setTextColor(Color.parseColor("#de000000")); // primary_text_default_material_light
tv.setText(text);
toast.setView(view);
toast.setDuration(duration);
return toast;
}
@Override
public void show() {
// https://developer.android.com/preview/features/toasts