Java Code Examples for android.text.method.ArrowKeyMovementMethod

The following are top voted examples for showing how to use android.text.method.ArrowKeyMovementMethod. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: FMTech   File: DetailsExpandedContainer.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 2
Project: RLibrary   File: ExEditText.java   Source Code and License 5 votes vote down vote up
/**
 * 为TextView设置显示@效果
 */
public static void checkMentionSpannable(TextView textView, String content, List<String> allMention) {
    if (textView == null) {
        return;
    }
    if (allMention.isEmpty() || TextUtils.isEmpty(content)) {
        textView.setText(content);
        textView.setMovementMethod(ArrowKeyMovementMethod.getInstance());
        return;
    }

    SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(content);
    int lastMentionIndex = -1;

    for (String mention : allMention) {
        Matcher matcher = Pattern.compile("\\[email protected]" + mention + "\\E").matcher(content);

        while (matcher.find()) {
            String mentionText = matcher.group();
            int start;
            if (lastMentionIndex != -1) {
                start = content.indexOf(mentionText, lastMentionIndex);
            } else {
                start = content.indexOf(mentionText);
            }
            int end = start + mentionText.length();
            spannableStringBuilder.setSpan(new MentionSpan(mentionText), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
    }
    textView.setText(spannableStringBuilder);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
}
 
Example 3
Project: LsPush   File: TagGroup.java   Source Code and License 5 votes vote down vote up
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();
}
 
Example 4
Project: FMTech   File: DetailsTextBlock.java   Source Code and License 5 votes vote down vote up
public void setBodyTextIsSelectable(boolean paramBoolean)
{
  if (Build.VERSION.SDK_INT >= 11)
  {
    this.mBodyView.setTextIsSelectable(paramBoolean);
    this.mBodyView.setAutoLinkMask(15);
    this.mBodyView.setMovementMethod(ArrowKeyMovementMethod.getInstance());
  }
}
 
Example 5
Project: FullRobolectricTestSample   File: TextViewTest.java   Source Code and License 5 votes vote down vote up
@Test
public void testMovementMethod() {
  MovementMethod movement = new ArrowKeyMovementMethod();

  assertNull(textView.getMovementMethod());
  textView.setMovementMethod(movement);
  assertThat(textView.getMovementMethod()).isSameAs(movement);
}
 
Example 6
Project: SmileEssence   File: PostFragment.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 7
Project: javaide   File: HighlightEditor.java   Source Code and License 4 votes vote down vote up
@Override
protected MovementMethod getDefaultMovementMethod() {
    return ArrowKeyMovementMethod.getInstance();
}
 
Example 8
Project: Android-Music-Player   File: FMedittext.java   Source Code and License 4 votes vote down vote up
@Override
protected MovementMethod getDefaultMovementMethod() {
    return ArrowKeyMovementMethod.getInstance();
}
 
Example 9
Project: Attendance   File: MyEditText.java   Source Code and License 4 votes vote down vote up
@Override
protected MovementMethod getDefaultMovementMethod() {
    return ArrowKeyMovementMethod.getInstance();
}
 
Example 10
Project: Android-Syntax-Highlight-Library   File: SyntaxHighlightEditor.java   Source Code and License 4 votes vote down vote up
@Override
protected MovementMethod getDefaultMovementMethod() {
    return ArrowKeyMovementMethod.getInstance();
}
 
Example 11
Project: Tada   File: TextView.java   Source Code and License 4 votes vote down vote up
/**
 * 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();
}
 
Example 12
Project: LineNumberTextView   File: LineNumberEditText.java   Source Code and License 4 votes vote down vote up
@Override
protected MovementMethod getDefaultMovementMethod() {
    return ArrowKeyMovementMethod.getInstance();
}
 
Example 13
Project: dungeon-crawl-android   File: ConfigEditor.java   Source Code and License 4 votes vote down vote up
@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);
		}
	});

}
 
Example 14
Project: dungeon-crawl-android   File: CharFileViewer.java   Source Code and License 4 votes vote down vote up
@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);
		}
	});

}
 
Example 15
Project: ingress-indonesia-dev   File: AndroidOnscreenKeyboard$1.java   Source Code and License 4 votes vote down vote up
protected final MovementMethod getDefaultMovementMethod()
{
  return ArrowKeyMovementMethod.getInstance();
}