Fixed edit text plain

pull/184/head
M66B 4 years ago
parent 661f2e3732
commit f10b2fd3c4

@ -45,13 +45,14 @@ public class EditTextPlain extends FixedEditText {
ClipboardManager cbm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); ClipboardManager cbm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
if (cbm != null && cbm.hasPrimaryClip()) { if (cbm != null && cbm.hasPrimaryClip()) {
ClipData data = cbm.getPrimaryClip(); ClipData data = cbm.getPrimaryClip();
ClipData.Item item = data.getItemAt(0); ClipData.Item item = (data == null ? null : data.getItemAt(0));
CharSequence text = (item == null ? null : item.coerceToText(context));
CharSequence text = item.coerceToText(context); if (text != null) {
data = ClipData.newPlainText("coerced_plain_text", text); data = ClipData.newPlainText("coerced_plain_text", text.toString());
cbm.setPrimaryClip(data); cbm.setPrimaryClip(data);
} }
} }
}
return super.onTextContextMenuItem(id); return super.onTextContextMenuItem(id);
} catch (Throwable ex) { } catch (Throwable ex) {

Loading…
Cancel
Save