mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-25 09:17:58 +00:00
Added B/W toast
This commit is contained in:
parent
2ed0472912
commit
68d1c8b03e
3 changed files with 32 additions and 2 deletions
|
@ -68,6 +68,7 @@ import android.text.style.ParagraphStyle;
|
|||
import android.text.style.QuoteSpan;
|
||||
import android.text.style.URLSpan;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
|
@ -1330,6 +1331,19 @@ public class FragmentCompose extends FragmentBase {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -33,9 +33,10 @@ public class ViewImageHint extends AppCompatImageView implements View.OnClickLis
|
|||
if (!TextUtils.isEmpty(title)) {
|
||||
int[] pos = new int[2];
|
||||
getLocationOnScreen(pos);
|
||||
int dp6 = Helper.dp2pixels(v.getContext(), 6);
|
||||
|
||||
Toast toast = ToastEx.makeText(getContext(), title, Toast.LENGTH_LONG);
|
||||
toast.setGravity(Gravity.TOP | Gravity.START, pos[0], pos[1]);
|
||||
Toast toast = ToastEx.makeTextBw(getContext(), title, Toast.LENGTH_LONG);
|
||||
toast.setGravity(Gravity.TOP | Gravity.START, pos[0], pos[1] + dp6);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue