Added B/W toast

pull/185/head
M66B 4 years ago
parent 2ed0472912
commit 68d1c8b03e

@ -68,6 +68,7 @@ import android.text.style.ParagraphStyle;
import android.text.style.QuoteSpan; import android.text.style.QuoteSpan;
import android.text.style.URLSpan; import android.text.style.URLSpan;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
@ -1330,6 +1331,19 @@ public class FragmentCompose extends FragmentBase {
onMenuEncrypt(); onMenuEncrypt();
} }
}); });
ib.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
int[] pos = new int[2];
ib.getLocationOnScreen(pos);
int dp24 = Helper.dp2pixels(v.getContext(), 24);
Toast toast = ToastEx.makeTextBw(getContext(), getString(R.string.title_encrypt), Toast.LENGTH_LONG);
toast.setGravity(Gravity.TOP | Gravity.START, pos[0], pos[1] + dp24);
toast.show();
return true;
}
});
super.onCreateOptionsMenu(menu, inflater); super.onCreateOptionsMenu(menu, inflater);
} }

@ -21,6 +21,7 @@ package eu.faircode.email;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Color;
import android.os.Looper; import android.os.Looper;
import android.view.Gravity; import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -54,6 +55,20 @@ public class ToastEx extends Toast {
return 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 @Override
public void show() { public void show() {
// https://developer.android.com/preview/features/toasts // https://developer.android.com/preview/features/toasts

@ -33,9 +33,10 @@ public class ViewImageHint extends AppCompatImageView implements View.OnClickLis
if (!TextUtils.isEmpty(title)) { if (!TextUtils.isEmpty(title)) {
int[] pos = new int[2]; int[] pos = new int[2];
getLocationOnScreen(pos); getLocationOnScreen(pos);
int dp6 = Helper.dp2pixels(v.getContext(), 6);
Toast toast = ToastEx.makeText(getContext(), title, Toast.LENGTH_LONG); Toast toast = ToastEx.makeTextBw(getContext(), title, Toast.LENGTH_LONG);
toast.setGravity(Gravity.TOP | Gravity.START, pos[0], pos[1]); toast.setGravity(Gravity.TOP | Gravity.START, pos[0], pos[1] + dp6);
toast.show(); toast.show();
} }
} }

Loading…
Cancel
Save