@@ -9059,51 +9059,6 @@ void sendAccessibilityEventTypeViewTextChanged(CharSequence beforeText,
90599059 sendAccessibilityEventUnchecked (event );
90609060 }
90619061
9062- @ Override
9063- protected void onCreateContextMenu (ContextMenu menu ) {
9064- super .onCreateContextMenu (menu );
9065- boolean added = false ;
9066- mContextMenuTriggeredByKey = mDPadCenterIsDown || mEnterKeyIsDown ;
9067- // Problem with context menu on long press: the menu appears while the key in down and when
9068- // the key is released, the view does not receive the key_up event.
9069- // We need two layers of flags: mDPadCenterIsDown and mEnterKeyIsDown are set in key down/up
9070- // events. We cannot simply clear these flags in onTextContextMenuItem since
9071- // it may not be called (if the user/ discards the context menu with the back key).
9072- // We clear these flags here and mContextMenuTriggeredByKey saves that state so that it is
9073- // available in onTextContextMenuItem.
9074- mDPadCenterIsDown = mEnterKeyIsDown = false ;
9075-
9076- MenuHandler handler = new MenuHandler ();
9077-
9078- if (mText instanceof Spanned && hasSelectionController ()) {
9079- long lastTouchOffset = getLastTouchOffsets ();
9080- final int selStart = extractRangeStartFromLong (lastTouchOffset );
9081- final int selEnd = extractRangeEndFromLong (lastTouchOffset );
9082-
9083- URLSpan [] urls = ((Spanned ) mText ).getSpans (selStart , selEnd , URLSpan .class );
9084- if (urls .length > 0 ) {
9085- menu .add (0 , ID_COPY_URL , 0 , com .android .internal .R .string .copyUrl ).
9086- setOnMenuItemClickListener (handler );
9087-
9088- added = true ;
9089- }
9090- }
9091-
9092- // The context menu is not empty, which will prevent the selection mode from starting.
9093- // Add a entry to start it in the context menu.
9094- // TODO Does not handle the case where a subclass does not call super.thisMethod or
9095- // populates the menu AFTER this call.
9096- if (menu .size () > 0 ) {
9097- menu .add (0 , ID_SELECTION_MODE , 0 , com .android .internal .R .string .selectTextMode ).
9098- setOnMenuItemClickListener (handler );
9099- added = true ;
9100- }
9101-
9102- if (added ) {
9103- menu .setHeaderTitle (com .android .internal .R .string .editTextMenuTitle );
9104- }
9105- }
9106-
91079062 /**
91089063 * Returns whether this text view is a current input method target. The
91099064 * default implementation just checks with {@link InputMethodManager}.
@@ -9118,9 +9073,6 @@ public boolean isInputMethodTarget() {
91189073 private static final int ID_CUT = android .R .id .cut ;
91199074 private static final int ID_COPY = android .R .id .copy ;
91209075 private static final int ID_PASTE = android .R .id .paste ;
9121- // Context menu entries
9122- private static final int ID_COPY_URL = android .R .id .copyUrl ;
9123- private static final int ID_SELECTION_MODE = android .R .id .selectTextMode ;
91249076
91259077 private class MenuHandler implements MenuItem .OnMenuItemClickListener {
91269078 public boolean onMenuItemClick (MenuItem item ) {
@@ -9130,9 +9082,8 @@ public boolean onMenuItemClick(MenuItem item) {
91309082
91319083 /**
91329084 * Called when a context menu option for the text view is selected. Currently
9133- * this will be {@link android.R.id#copyUrl}, {@link android.R.id#selectTextMode},
9134- * {@link android.R.id#selectAll}, {@link android.R.id#paste}, {@link android.R.id#cut}
9135- * or {@link android.R.id#copy}.
9085+ * this will be one of {@link android.R.id#selectAll}, {@link android.R.id#cut},
9086+ * {@link android.R.id#copy} or {@link android.R.id#paste}.
91369087 *
91379088 * @return true if the context menu item action was performed.
91389089 */
@@ -9149,34 +9100,6 @@ public boolean onTextContextMenuItem(int id) {
91499100 }
91509101
91519102 switch (id ) {
9152- case ID_COPY_URL :
9153- URLSpan [] urls = ((Spanned ) mText ).getSpans (min , max , URLSpan .class );
9154- if (urls .length >= 1 ) {
9155- ClipData clip = null ;
9156- for (int i =0 ; i <urls .length ; i ++) {
9157- Uri uri = Uri .parse (urls [0 ].getURL ());
9158- if (clip == null ) {
9159- clip = ClipData .newRawUri (null , uri );
9160- } else {
9161- clip .addItem (new ClipData .Item (uri ));
9162- }
9163- }
9164- if (clip != null ) {
9165- setPrimaryClip (clip );
9166- }
9167- }
9168- stopSelectionActionMode ();
9169- return true ;
9170-
9171- case ID_SELECTION_MODE :
9172- if (mSelectionActionMode != null ) {
9173- // Selection mode is already started, simply change selected part.
9174- selectCurrentWord ();
9175- } else {
9176- startSelectionActionMode ();
9177- }
9178- return true ;
9179-
91809103 case ID_SELECT_ALL :
91819104 // This does not enter text selection mode. Text is highlighted, so that it can be
91829105 // bulk edited, like selectAllOnFocus does. Returns true even if text is empty.
0 commit comments