android.text.method.ArrowKeyMovementMethod Java Examples

The following examples show how to use android.text.method.ArrowKeyMovementMethod. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MongolInputMethodManager.java    From mongol-library with MIT License 6 votes vote down vote up
private void setAllowSystemKeyboardOnEditText(EditText editText, boolean allowSystemKeyboard) {
    // TODO this needs to be tested on lower versions!
    // https://stackoverflow.com/a/45229457

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // api 21+
        editText.setShowSoftInputOnFocus(allowSystemKeyboard);
    } else { // api 11+
        if (allowSystemKeyboard) {
            // re-enable keyboard (see https://stackoverflow.com/a/45228867)
            // FIXME this does not necessarily always work
            editText.setTextIsSelectable(false);
            editText.setFocusable(true);
            editText.setFocusableInTouchMode(true);
            editText.setClickable(true);
            editText.setLongClickable(true);
            editText.setMovementMethod(ArrowKeyMovementMethod.getInstance());
            editText.setText(editText.getText(), TextView.BufferType.SPANNABLE);
        } else {
            // disable keyboard
            editText.setTextIsSelectable(true);
        }
    }
}
 
Example #2
Source File: TextInputSpecTest.java    From litho with Apache License 2.0 5 votes vote down vote up
@Test
public void testDefaultMovementMethod() {
  Component.Builder component = TextInput.create(mContext);
  final android.widget.EditText editText = getEditText(component);
  assertThat(editText.getMovementMethod()).isInstanceOf(ArrowKeyMovementMethod.class);
  assertThat(new EditText(getApplicationContext()).getMovementMethod())
      .isInstanceOf(ArrowKeyMovementMethod.class);
}
 
Example #3
Source File: PostFragment.java    From SmileEssence with MIT 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 #4
Source File: EditText.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
protected MovementMethod getDefaultMovementMethod() {
    return ArrowKeyMovementMethod.getInstance();
}
 
Example #5
Source File: HighlightEditor.java    From java-n-IDE-for-Android with Apache License 2.0 4 votes vote down vote up
@Override
protected MovementMethod getDefaultMovementMethod() {
    return ArrowKeyMovementMethod.getInstance();
}
 
Example #6
Source File: FMedittext.java    From Android-Music-Player with MIT License 4 votes vote down vote up
@Override
protected MovementMethod getDefaultMovementMethod() {
    return ArrowKeyMovementMethod.getInstance();
}