protected void onFinishInflate() { super.onFinishInflate(); this.mDetailsExpandedCallout = ((TextView)findViewById(2131755581)); this.mDetailsExpandedCallout.setMovementMethod(LinkMovementMethod.getInstance()); this.mDetailsExpandedBody1 = ((DetailsTextBlock)findViewById(2131755582)); this.mDetailsExpandedBody2 = ((DetailsTextBlock)findViewById(2131755583)); this.mDetailsExpandedExtras = ((ViewGroup)findViewById(2131755584)); if (Build.VERSION.SDK_INT >= 11) { this.mDetailsExpandedCallout.setTextIsSelectable(true); this.mDetailsExpandedCallout.setAutoLinkMask(15); this.mDetailsExpandedCallout.setMovementMethod(ArrowKeyMovementMethod.getInstance()); } this.mDetailsExpandedBody1.setBodyTextIsSelectable(true); this.mDetailsExpandedBody2.setBodyTextIsSelectable(true); }
public void setEditable(boolean editable, @Nullable CharSequence hint) { if (mEditable == editable) { return; } mEditable = editable; setFocusable(editable); setFocusableInTouchMode(editable); setHint(hint); setMovementMethod(editable ? ArrowKeyMovementMethod.getInstance() : null); resetPaint(); }
public void setBodyTextIsSelectable(boolean paramBoolean) { if (Build.VERSION.SDK_INT >= 11) { this.mBodyView.setTextIsSelectable(paramBoolean); this.mBodyView.setAutoLinkMask(15); this.mBodyView.setMovementMethod(ArrowKeyMovementMethod.getInstance()); } }
@Test public void testMovementMethod() { MovementMethod movement = new ArrowKeyMovementMethod(); assertNull(textView.getMovementMethod()); textView.setMovementMethod(movement); assertThat(textView.getMovementMethod()).isSameAs(movement); }
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Logger.debug("PostFragment CreateView"); MainActivity activity = (MainActivity) getActivity(); PostState.getState().setListener(this); UserPreferenceHelper preferenceHelper = new UserPreferenceHelper(activity); View v = inflater.inflate(R.layout.fragment_post, null); buttonTweet = getTweetButton(v); buttonTweet.setOnClickListener(this); editText = getEditText(v); textViewCount = getCountTextView(v); int textSize = preferenceHelper.getValue(R.string.key_setting_text_size, 10); editText.addTextChangedListener(this); editText.setOnFocusChangeListener(this); editText.setTextSize(textSize + 4); editText.setMovementMethod(new ArrowKeyMovementMethod() { @Override protected boolean right(TextView widget, Spannable buffer) { //Don't back to Home return widget.getSelectionEnd() == widget.length() || super.right(widget, buffer); } }); ImageButton imageButtonDeleteText = (ImageButton) v.findViewById(R.id.button_post_delete); imageButtonDeleteText.setOnClickListener(this); ImageButton imageButtonMedia = (ImageButton) v.findViewById(R.id.button_post_media); imageButtonMedia.setOnClickListener(this); ImageButton imageButtonMenu = (ImageButton) v.findViewById(R.id.button_post_menu); imageButtonMenu.setOnClickListener(this); //Reply view viewGroupReply = getReplyViewGroup(v); ImageButton imageButtonDeleteReply = (ImageButton) viewGroupReply.findViewById(R.id.button_post_reply_delete); imageButtonDeleteReply.setOnClickListener(this); //Media view viewGroupMedia = getMediaViewGroup(v); ImageView imageViewMedia = (ImageView) viewGroupMedia.findViewById(R.id.image_post_media); ImageButton imageButtonDeleteMedia = (ImageButton) viewGroupMedia.findViewById(R.id.button_post_media_delete); imageViewMedia.setOnClickListener(this); imageButtonDeleteMedia.setOnClickListener(this); editText.requestFocus(); return v; }
@Override protected MovementMethod getDefaultMovementMethod() { return ArrowKeyMovementMethod.getInstance(); }
/** * Sets whether the content of this view is selectable by the user. The default is * {@code false}, meaning that the content is not selectable. * <p> * When you use a TextView to display a useful piece of information to the user (such as a * contact's address), make it selectable, so that the user can select and copy its * content. You can also use set the XML attribute * {@link android.R.styleable#TextView_textIsSelectable} to "true". * <p> * When you call this method to set the value of {@code textIsSelectable}, it sets * the flags {@code focusable}, {@code focusableInTouchMode}, {@code clickable}, * and {@code longClickable} to the same value. These flags correspond to the attributes * {@link android.R.styleable#View_focusable android:focusable}, * {@link android.R.styleable#View_focusableInTouchMode android:focusableInTouchMode}, * {@link android.R.styleable#View_clickable android:clickable}, and * {@link android.R.styleable#View_longClickable android:longClickable}. To restore any of these * flags to a state you had set previously, call one or more of the following methods: * {@link #setFocusable(boolean) setFocusable()}, * {@link #setFocusableInTouchMode(boolean) setFocusableInTouchMode()}, * {@link #setClickable(boolean) setClickable()} or * {@link #setLongClickable(boolean) setLongClickable()}. * * @param selectable Whether the content of this TextView should be selectable. */ public void setTextIsSelectable(boolean selectable) { if (!selectable && mEditor == null) return; // false is default value with no edit data createEditorIfNeeded(); if (mEditor.mTextIsSelectable == selectable) return; mEditor.mTextIsSelectable = selectable; setFocusableInTouchMode(selectable); setFocusable(selectable); setClickable(selectable); setLongClickable(selectable); // mInputType should already be EditorInfo.TYPE_NULL and mInput should be null setMovementMethod(selectable ? ArrowKeyMovementMethod.getInstance() : null); setText(mText, selectable ? BufferType.SPANNABLE : BufferType.NORMAL); // Called by setText above, but safer in case of future code changes mEditor.prepareCursorControllers(); }
@Override protected void onResume() { super.onResume(); getNoteFromFile(); // Make sure that we don't use the link movement method. // Instead, we need a blend between the arrow key movement (for regular // navigation) and // the link movement (so the user can click on links). // TODO: Might be able to edit this, since we don't care about // linkifying text getMText().setMovementMethod(new ArrowKeyMovementMethod() { public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { // This block is copied and pasted from LinkMovementMethod's // onTouchEvent (without the part that actually changes the // selection). int action = event.getAction(); if (action == MotionEvent.ACTION_UP) { int x = (int) event.getX(); int y = (int) event.getY(); x -= widget.getTotalPaddingLeft(); y -= widget.getTotalPaddingTop(); x += widget.getScrollX(); y += widget.getScrollY(); Layout layout = widget.getLayout(); int line = layout.getLineForVertical(y); int off = layout.getOffsetForHorizontal(line, x); ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); if (link.length != 0) { link[0].onClick(widget); return true; } } return super.onTouchEvent(widget, buffer, event); } }); }
@Override protected void onResume() { super.onResume(); getNoteFromFile(); // Make sure that we don't use the link movement method. // Instead, we need a blend between the arrow key movement (for regular // navigation) and // the link movement (so the user can click on links). // TODO: Might be able to edit this, since we don't care about // linkifying text mText.setMovementMethod(new ArrowKeyMovementMethod() { public boolean onTouchEvent(TextView widget, Spannable buffer, MotionEvent event) { // This block is copied and pasted from LinkMovementMethod's // onTouchEvent (without the part that actually changes the // selection). int action = event.getAction(); if (action == MotionEvent.ACTION_UP) { int x = (int) event.getX(); int y = (int) event.getY(); x -= widget.getTotalPaddingLeft(); y -= widget.getTotalPaddingTop(); x += widget.getScrollX(); y += widget.getScrollY(); Layout layout = widget.getLayout(); int line = layout.getLineForVertical(y); int off = layout.getOffsetForHorizontal(line, x); ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class); if (link.length != 0) { link[0].onClick(widget); return true; } } return super.onTouchEvent(widget, buffer, event); } }); }
protected final MovementMethod getDefaultMovementMethod() { return ArrowKeyMovementMethod.getInstance(); }