Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -1723,6 +1723,7 @@ package android { field public static final int selectAll = 16908319; // 0x102001f field public static final int selectTextMode = 16908333; // 0x102002d field public static final int selectedIcon = 16908302; // 0x102000e field public static final int shareText = 16908343; // 0x1020037 field public static final int startSelectingText = 16908328; // 0x1020028 field public static final int statusBarBackground = 16908335; // 0x102002f field public static final int stopSelectingText = 16908329; // 0x1020029 api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -1800,6 +1800,7 @@ package android { field public static final int selectAll = 16908319; // 0x102001f field public static final int selectTextMode = 16908333; // 0x102002d field public static final int selectedIcon = 16908302; // 0x102000e field public static final int shareText = 16908343; // 0x1020037 field public static final int startSelectingText = 16908328; // 0x1020028 field public static final int statusBarBackground = 16908335; // 0x102002f field public static final int stopSelectingText = 16908329; // 0x1020029 core/java/android/widget/Editor.java +6 −0 Original line number Diff line number Diff line Loading @@ -3079,6 +3079,12 @@ public class Editor { MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); } if (mTextView.canShare()) { menu.add(0, TextView.ID_SHARE, 0, com.android.internal.R.string.share). setShowAsAction( MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); } menu.add(0, TextView.ID_SELECT_ALL, 0, com.android.internal.R.string.selectAll). setAlphabeticShortcut('a'). setShowAsAction( Loading core/java/android/widget/TextView.java +26 −5 Original line number Diff line number Diff line Loading @@ -8955,13 +8955,14 @@ 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_SHARE = android.R.id.shareText; static final int ID_PASTE_AS_PLAIN_TEXT = android.R.id.pasteAsPlainText; static final int ID_REPLACE = android.R.id.replaceText; /** * Called when a context menu option for the text view is selected. Currently * this will be one of {@link android.R.id#selectAll}, {@link android.R.id#cut}, * {@link android.R.id#copy} or {@link android.R.id#paste}. * {@link android.R.id#copy}, {@link android.R.id#paste} or {@link android.R.id#shareText}. * * @return true if the context menu item action was performed. */ Loading Loading @@ -9014,6 +9015,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener setPrimaryClip(ClipData.newPlainText(null, getTransformedText(min, max))); stopSelectionActionMode(); return true; case ID_SHARE: shareSelectedText(); return true; } return false; } Loading Loading @@ -9091,15 +9096,15 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * If provided, this ActionMode.Callback will be used to create the ActionMode when text * selection is initiated in this View. * * The standard implementation populates the menu with a subset of Select All, Cut, Copy and * Paste actions, depending on what this View supports. * The standard implementation populates the menu with a subset of Select All, Cut, Copy, * Paste and Share actions, depending on what this View supports. * * A custom implementation can add new entries in the default menu in its * {@link android.view.ActionMode.Callback#onPrepareActionMode(ActionMode, Menu)} method. The * default actions can also be removed from the menu using * {@link android.view.Menu#removeItem(int)} and passing {@link android.R.id#selectAll}, * {@link android.R.id#cut}, {@link android.R.id#copy} or {@link android.R.id#paste} ids as * parameters. * {@link android.R.id#cut}, {@link android.R.id#copy}, {@link android.R.id#paste} or * {@link android.R.id#shareText} ids as parameters. * * Returning false from * {@link android.view.ActionMode.Callback#onCreateActionMode(ActionMode, Menu)} will prevent Loading Loading @@ -9168,6 +9173,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return false; } boolean canShare() { return canCopy(); } boolean canPaste() { return (mText instanceof Editable && mEditor != null && mEditor.mKeyListener != null && Loading Loading @@ -9241,6 +9250,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } private void shareSelectedText() { String selectedText = getSelectedText(); if (selectedText != null && !selectedText.isEmpty()) { Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.removeExtra(android.content.Intent.EXTRA_TEXT); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, selectedText); getContext().startActivity(Intent.createChooser(sharingIntent, null)); stopSelectionActionMode(); } } private void setPrimaryClip(ClipData clip) { ClipboardManager clipboard = (ClipboardManager) getContext(). getSystemService(Context.CLIPBOARD_SERVICE); Loading core/res/res/values/ids.xml +1 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,7 @@ <item type="id" name="undo" /> <item type="id" name="redo" /> <item type="id" name="replaceText" /> <item type="id" name="shareText" /> <!-- Accessibility action identifier for {@link android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction#ACTION_SHOW_ON_SCREEN}. --> <item type="id" name="accessibilityActionShowOnScreen" /> Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -1723,6 +1723,7 @@ package android { field public static final int selectAll = 16908319; // 0x102001f field public static final int selectTextMode = 16908333; // 0x102002d field public static final int selectedIcon = 16908302; // 0x102000e field public static final int shareText = 16908343; // 0x1020037 field public static final int startSelectingText = 16908328; // 0x1020028 field public static final int statusBarBackground = 16908335; // 0x102002f field public static final int stopSelectingText = 16908329; // 0x1020029
api/system-current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -1800,6 +1800,7 @@ package android { field public static final int selectAll = 16908319; // 0x102001f field public static final int selectTextMode = 16908333; // 0x102002d field public static final int selectedIcon = 16908302; // 0x102000e field public static final int shareText = 16908343; // 0x1020037 field public static final int startSelectingText = 16908328; // 0x1020028 field public static final int statusBarBackground = 16908335; // 0x102002f field public static final int stopSelectingText = 16908329; // 0x1020029
core/java/android/widget/Editor.java +6 −0 Original line number Diff line number Diff line Loading @@ -3079,6 +3079,12 @@ public class Editor { MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); } if (mTextView.canShare()) { menu.add(0, TextView.ID_SHARE, 0, com.android.internal.R.string.share). setShowAsAction( MenuItem.SHOW_AS_ACTION_ALWAYS | MenuItem.SHOW_AS_ACTION_WITH_TEXT); } menu.add(0, TextView.ID_SELECT_ALL, 0, com.android.internal.R.string.selectAll). setAlphabeticShortcut('a'). setShowAsAction( Loading
core/java/android/widget/TextView.java +26 −5 Original line number Diff line number Diff line Loading @@ -8955,13 +8955,14 @@ 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_SHARE = android.R.id.shareText; static final int ID_PASTE_AS_PLAIN_TEXT = android.R.id.pasteAsPlainText; static final int ID_REPLACE = android.R.id.replaceText; /** * Called when a context menu option for the text view is selected. Currently * this will be one of {@link android.R.id#selectAll}, {@link android.R.id#cut}, * {@link android.R.id#copy} or {@link android.R.id#paste}. * {@link android.R.id#copy}, {@link android.R.id#paste} or {@link android.R.id#shareText}. * * @return true if the context menu item action was performed. */ Loading Loading @@ -9014,6 +9015,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener setPrimaryClip(ClipData.newPlainText(null, getTransformedText(min, max))); stopSelectionActionMode(); return true; case ID_SHARE: shareSelectedText(); return true; } return false; } Loading Loading @@ -9091,15 +9096,15 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener * If provided, this ActionMode.Callback will be used to create the ActionMode when text * selection is initiated in this View. * * The standard implementation populates the menu with a subset of Select All, Cut, Copy and * Paste actions, depending on what this View supports. * The standard implementation populates the menu with a subset of Select All, Cut, Copy, * Paste and Share actions, depending on what this View supports. * * A custom implementation can add new entries in the default menu in its * {@link android.view.ActionMode.Callback#onPrepareActionMode(ActionMode, Menu)} method. The * default actions can also be removed from the menu using * {@link android.view.Menu#removeItem(int)} and passing {@link android.R.id#selectAll}, * {@link android.R.id#cut}, {@link android.R.id#copy} or {@link android.R.id#paste} ids as * parameters. * {@link android.R.id#cut}, {@link android.R.id#copy}, {@link android.R.id#paste} or * {@link android.R.id#shareText} ids as parameters. * * Returning false from * {@link android.view.ActionMode.Callback#onCreateActionMode(ActionMode, Menu)} will prevent Loading Loading @@ -9168,6 +9173,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return false; } boolean canShare() { return canCopy(); } boolean canPaste() { return (mText instanceof Editable && mEditor != null && mEditor.mKeyListener != null && Loading Loading @@ -9241,6 +9250,18 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } } private void shareSelectedText() { String selectedText = getSelectedText(); if (selectedText != null && !selectedText.isEmpty()) { Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/plain"); sharingIntent.removeExtra(android.content.Intent.EXTRA_TEXT); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, selectedText); getContext().startActivity(Intent.createChooser(sharingIntent, null)); stopSelectionActionMode(); } } private void setPrimaryClip(ClipData clip) { ClipboardManager clipboard = (ClipboardManager) getContext(). getSystemService(Context.CLIPBOARD_SERVICE); Loading
core/res/res/values/ids.xml +1 −0 Original line number Diff line number Diff line Loading @@ -93,6 +93,7 @@ <item type="id" name="undo" /> <item type="id" name="redo" /> <item type="id" name="replaceText" /> <item type="id" name="shareText" /> <!-- Accessibility action identifier for {@link android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction#ACTION_SHOW_ON_SCREEN}. --> <item type="id" name="accessibilityActionShowOnScreen" /> Loading