mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-27 11:25:13 +01:00
Override default copy to copy HTML
This commit is contained in:
@@ -75,7 +75,27 @@ public class EditTextCompose extends FixedEditText {
|
||||
@Override
|
||||
public boolean onTextContextMenuItem(int id) {
|
||||
try {
|
||||
if (id == android.R.id.paste) {
|
||||
if (id == android.R.id.copy) {
|
||||
int start = getSelectionStart();
|
||||
int end = getSelectionEnd();
|
||||
if (start > end) {
|
||||
int s = start;
|
||||
start = end;
|
||||
end = s;
|
||||
}
|
||||
|
||||
Context context = getContext();
|
||||
ClipboardManager cbm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
if (start != end && cbm != null) {
|
||||
CharSequence selected = getEditableText().subSequence(start, end);
|
||||
if (selected instanceof Spanned) {
|
||||
String html = HtmlHelper.toHtml((Spanned) selected, context);
|
||||
cbm.setPrimaryClip(ClipData.newHtmlText(context.getString(R.string.app_name), selected, html));
|
||||
setSelection(end);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else if (id == android.R.id.paste) {
|
||||
Context context = getContext();
|
||||
ClipboardManager cbm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
if (cbm != null && cbm.hasPrimaryClip()) {
|
||||
|
||||
Reference in New Issue
Block a user