Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -1710,6 +1710,7 @@ package android { field public static final int message = 16908299; // 0x102000b field public static final int navigationBarBackground = 16908336; // 0x1020030 field public static final int paste = 16908322; // 0x1020022 field public static final int pasteAsPlainText = 16908339; // 0x1020033 field public static final int primary = 16908300; // 0x102000c field public static final int progress = 16908301; // 0x102000d field public static final int redo = 16908338; // 0x1020032 api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -1786,6 +1786,7 @@ package android { field public static final int message = 16908299; // 0x102000b field public static final int navigationBarBackground = 16908336; // 0x1020030 field public static final int paste = 16908322; // 0x1020022 field public static final int pasteAsPlainText = 16908339; // 0x1020033 field public static final int primary = 16908300; // 0x102000c field public static final int progress = 16908301; // 0x102000d field public static final int redo = 16908338; // 0x1020032 core/java/android/widget/TextView.java +20 −4 Original line number Diff line number Diff line Loading @@ -8412,6 +8412,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return onTextContextMenuItem(ID_REDO); } break; case KeyEvent.KEYCODE_V: if (canPaste()) { return onTextContextMenuItem(ID_PASTE_AS_PLAIN_TEXT); } } } return super.onKeyShortcut(keyCode, event); Loading Loading @@ -8794,6 +8798,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener static final int ID_CUT = android.R.id.cut; static final int ID_COPY = android.R.id.copy; static final int ID_PASTE = android.R.id.paste; static final int ID_PASTE_AS_PLAIN_TEXT = android.R.id.pasteAsPlainText; /** * Called when a context menu option for the text view is selected. Currently Loading Loading @@ -8834,7 +8839,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return true; // Returns true even if nothing was undone. case ID_PASTE: paste(min, max); paste(min, max, true /* withFormatting */); return true; case ID_PASTE_AS_PLAIN_TEXT: paste(min, max, false /* withFormatting */); return true; case ID_CUT: Loading Loading @@ -9018,14 +9027,21 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /** * Paste clipboard content between min and max positions. */ private void paste(int min, int max) { private void paste(int min, int max, boolean withFormatting) { ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = clipboard.getPrimaryClip(); if (clip != null) { boolean didFirst = false; for (int i=0; i<clip.getItemCount(); i++) { CharSequence paste = clip.getItemAt(i).coerceToStyledText(getContext()); final CharSequence paste; if (withFormatting) { paste = clip.getItemAt(i).coerceToStyledText(getContext()); } else { // Get an item as text and remove all spans by toString(). final CharSequence text = clip.getItemAt(i).coerceToText(getContext()); paste = (text instanceof Spanned) ? text.toString() : text; } if (paste != null) { if (!didFirst) { Selection.setSelection((Spannable) mText, max); Loading core/res/res/values/ids.xml +1 −0 Original line number Diff line number Diff line Loading @@ -91,4 +91,5 @@ <item type="id" name="navigationBarBackground" /> <item type="id" name="undo" /> <item type="id" name="redo" /> <item type="id" name="pasteAsPlainText" /> </resources> core/res/res/values/public.xml +3 −0 Original line number Diff line number Diff line Loading @@ -2639,5 +2639,8 @@ <public type="id" name="undo" /> <!-- Context menu ID for the "Redo" menu item to redo the last text edit operation. --> <public type="id" name="redo" /> <!-- Context menu ID for the "Paste as plain text" menu item to to copy the current contents of the clipboard into the text view without formatting. --> <public type="id" name="pasteAsPlainText" /> </resources> Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -1710,6 +1710,7 @@ package android { field public static final int message = 16908299; // 0x102000b field public static final int navigationBarBackground = 16908336; // 0x1020030 field public static final int paste = 16908322; // 0x1020022 field public static final int pasteAsPlainText = 16908339; // 0x1020033 field public static final int primary = 16908300; // 0x102000c field public static final int progress = 16908301; // 0x102000d field public static final int redo = 16908338; // 0x1020032
api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -1786,6 +1786,7 @@ package android { field public static final int message = 16908299; // 0x102000b field public static final int navigationBarBackground = 16908336; // 0x1020030 field public static final int paste = 16908322; // 0x1020022 field public static final int pasteAsPlainText = 16908339; // 0x1020033 field public static final int primary = 16908300; // 0x102000c field public static final int progress = 16908301; // 0x102000d field public static final int redo = 16908338; // 0x1020032
core/java/android/widget/TextView.java +20 −4 Original line number Diff line number Diff line Loading @@ -8412,6 +8412,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return onTextContextMenuItem(ID_REDO); } break; case KeyEvent.KEYCODE_V: if (canPaste()) { return onTextContextMenuItem(ID_PASTE_AS_PLAIN_TEXT); } } } return super.onKeyShortcut(keyCode, event); Loading Loading @@ -8794,6 +8798,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener static final int ID_CUT = android.R.id.cut; static final int ID_COPY = android.R.id.copy; static final int ID_PASTE = android.R.id.paste; static final int ID_PASTE_AS_PLAIN_TEXT = android.R.id.pasteAsPlainText; /** * Called when a context menu option for the text view is selected. Currently Loading Loading @@ -8834,7 +8839,11 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return true; // Returns true even if nothing was undone. case ID_PASTE: paste(min, max); paste(min, max, true /* withFormatting */); return true; case ID_PASTE_AS_PLAIN_TEXT: paste(min, max, false /* withFormatting */); return true; case ID_CUT: Loading Loading @@ -9018,14 +9027,21 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener /** * Paste clipboard content between min and max positions. */ private void paste(int min, int max) { private void paste(int min, int max, boolean withFormatting) { ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = clipboard.getPrimaryClip(); if (clip != null) { boolean didFirst = false; for (int i=0; i<clip.getItemCount(); i++) { CharSequence paste = clip.getItemAt(i).coerceToStyledText(getContext()); final CharSequence paste; if (withFormatting) { paste = clip.getItemAt(i).coerceToStyledText(getContext()); } else { // Get an item as text and remove all spans by toString(). final CharSequence text = clip.getItemAt(i).coerceToText(getContext()); paste = (text instanceof Spanned) ? text.toString() : text; } if (paste != null) { if (!didFirst) { Selection.setSelection((Spannable) mText, max); Loading
core/res/res/values/ids.xml +1 −0 Original line number Diff line number Diff line Loading @@ -91,4 +91,5 @@ <item type="id" name="navigationBarBackground" /> <item type="id" name="undo" /> <item type="id" name="redo" /> <item type="id" name="pasteAsPlainText" /> </resources>
core/res/res/values/public.xml +3 −0 Original line number Diff line number Diff line Loading @@ -2639,5 +2639,8 @@ <public type="id" name="undo" /> <!-- Context menu ID for the "Redo" menu item to redo the last text edit operation. --> <public type="id" name="redo" /> <!-- Context menu ID for the "Paste as plain text" menu item to to copy the current contents of the clipboard into the text view without formatting. --> <public type="id" name="pasteAsPlainText" /> </resources>