android.view.inputmethod.EditorInfo Java Examples

The following examples show how to use android.view.inputmethod.EditorInfo. 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: AccessibilityUtils.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
/**
 * Returns whether the device should obscure typed password characters.
 * Typically this means speaking "dot" in place of non-control characters.
 *
 * @return {@code true} if the device should obscure password characters.
 */
@SuppressWarnings("deprecation")
public boolean shouldObscureInput(final EditorInfo editorInfo) {
    if (editorInfo == null) return false;

    // The user can optionally force speaking passwords.
    if (SettingsSecureCompatUtils.ACCESSIBILITY_SPEAK_PASSWORD != null) {
        final boolean speakPassword = Settings.Secure.getInt(mContext.getContentResolver(),
                SettingsSecureCompatUtils.ACCESSIBILITY_SPEAK_PASSWORD, 0) != 0;
        if (speakPassword) return false;
    }

    // Always speak if the user is listening through headphones.
    if (mAudioManager.isWiredHeadsetOn() || mAudioManager.isBluetoothA2dpOn()) {
        return false;
    }

    // Don't speak if the IME is connected to a password field.
    return InputTypeUtils.isPasswordInputType(editorInfo.inputType);
}
 
Example #2
Source File: KeyboardSwitcher.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
public void loadKeyboard(final EditorInfo editorInfo, final SettingsValues settingsValues,
        final int currentAutoCapsState, final int currentRecapitalizeState) {
    final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(
            mThemeContext, editorInfo);
    final Resources res = mThemeContext.getResources();
    final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
    final int keyboardHeight = ResourceUtils.getKeyboardHeight(res, settingsValues);
    builder.setKeyboardGeometry(keyboardWidth, keyboardHeight);
    builder.setSubtype(mRichImm.getCurrentSubtype());
    builder.setVoiceInputKeyEnabled(settingsValues.mShowsVoiceInputKey);
    builder.setLanguageSwitchKeyEnabled(mLatinIME.shouldShowLanguageSwitchKey());
    builder.setSplitLayoutEnabledByUser(ProductionFlags.IS_SPLIT_KEYBOARD_SUPPORTED
            && settingsValues.mIsSplitKeyboardEnabled);
    mKeyboardLayoutSet = builder.build();
    try {
        mState.onLoadKeyboard(currentAutoCapsState, currentRecapitalizeState);
        mKeyboardTextsSet.setLocale(mRichImm.getCurrentSubtypeLocale(), mThemeContext);
    } catch (KeyboardLayoutSetException e) {
        Log.w(TAG, "loading keyboard failed: " + e.mKeyboardId, e.getCause());
    }
}
 
Example #3
Source File: ComposeText.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
public void setTransport(TransportOption transport) {
  final boolean useSystemEmoji = TextSecurePreferences.isSystemEmojiPreferred(getContext());
  final boolean isIncognito    = TextSecurePreferences.isIncognitoKeyboardEnabled(getContext());

  int imeOptions = (getImeOptions() & ~EditorInfo.IME_MASK_ACTION) | EditorInfo.IME_ACTION_SEND;
  int inputType  = getInputType();

  if (isLandscape()) setImeActionLabel(transport.getComposeHint(), EditorInfo.IME_ACTION_SEND);
  else               setImeActionLabel(null, 0);

  if (useSystemEmoji) {
    inputType = (inputType & ~InputType.TYPE_MASK_VARIATION) | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE;
  }

  setInputType(inputType);
  setImeOptions(imeOptions);
  setHint(transport.getComposeHint(),
          transport.getSimName().isPresent()
              ? getContext().getString(R.string.conversation_activity__from_sim_name, transport.getSimName().get())
              : null);
}
 
Example #4
Source File: EnterPhoneNumberFragment.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
private void setUpNumberInput() {
  EditText numberInput = number.getInput();

  numberInput.addTextChangedListener(new NumberChangedListener());

  number.setOnFocusChangeListener((v, hasFocus) -> {
    if (hasFocus) {
      scrollView.postDelayed(() -> scrollView.smoothScrollTo(0, register.getBottom()), 250);
    }
  });

  numberInput.setImeOptions(EditorInfo.IME_ACTION_DONE);
  numberInput.setOnEditorActionListener((v, actionId, event) -> {
    if (actionId == EditorInfo.IME_ACTION_DONE) {
      hideKeyboard(requireContext(), v);
      handleRegister(requireContext());
      return true;
    }
    return false;
  });
}
 
Example #5
Source File: HeartRateServiceFragment.java    From ble-test-peripheral-android with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onEditorAction(TextView textView, int actionId, KeyEvent event) {
  if (actionId == EditorInfo.IME_ACTION_DONE) {
    String newEnergyExpendedString = textView.getText().toString();
    if (isValidCharacteristicValue(newEnergyExpendedString,
        EXPENDED_ENERGY_FORMAT)) {
      int newEnergyExpended = Integer.parseInt(newEnergyExpendedString);
      mHeartRateMeasurementCharacteristic.setValue(newEnergyExpended,
          EXPENDED_ENERGY_FORMAT,
          /* offset */ 2);
    } else {
      Toast.makeText(getActivity(), R.string.energyExpendedInvalid,
          Toast.LENGTH_SHORT).show();
    }
  }
  return false;
}
 
Example #6
Source File: PassphrasePromptActivity.java    From Silence with GNU General Public License v3.0 6 votes vote down vote up
private void initializeResources() {
  getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
  getSupportActionBar().setCustomView(R.layout.centered_app_title);

  ImageButton okButton = (ImageButton) findViewById(R.id.ok_button);
  passphraseText       = (EditText)    findViewById(R.id.passphrase_edit);
  SpannableString hint = new SpannableString("  " + getString(R.string.PassphrasePromptActivity_enter_passphrase));
  hint.setSpan(new RelativeSizeSpan(0.9f), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
  hint.setSpan(new TypefaceSpan("sans-serif"), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);

  passphraseText.setHint(hint);
  okButton.setOnClickListener(new OkButtonClickListener());
  passphraseText.setOnEditorActionListener(new PassphraseActionListener());
  passphraseText.setImeActionLabel(getString(R.string.prompt_passphrase_activity__unlock),
                                   EditorInfo.IME_ACTION_DONE);
}
 
Example #7
Source File: ChipsEditText.java    From quill with MIT License 6 votes vote down vote up
private void init() {
    mTokenPattern = Pattern.compile("[^,]+");
    setOnItemClickListener(this);
    addTextChangedListener(mTextWatcher);

    // regenerate chips when user taps "Done" action on the keyboard
    setOnEditorActionListener((view, actionId, event) -> {
        if (actionId == EditorInfo.IME_ACTION_DONE) {
            updateChips();
            // don't consume the event, so the keyboard can also be hidden
            // http://stackoverflow.com/questions/2342620/how-to-hide-keyboard-after-typing-in-edittext-in-android#comment20849208_10184099
            return false;
        }
        return false;
    });
}
 
Example #8
Source File: EditTextSettingsCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public EditTextSettingsCell(Context context) {
    super(context);

    textView = new EditTextBoldCursor(context);
    textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    textView.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    textView.setBackgroundDrawable(null);
    textView.setPadding(0, 0, 0, 0);
    textView.setInputType(textView.getInputType() | EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 21, 0, 21, 0));
}
 
Example #9
Source File: EditTextSettingsCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public EditTextSettingsCell(Context context) {
    super(context);

    textView = new EditText(context);
    textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    textView.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    textView.setBackgroundDrawable(null);
    textView.setPadding(0, 0, 0, 0);
    textView.setInputType(textView.getInputType() |EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 0, 17, 0));
}
 
Example #10
Source File: InputMethodService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Ask the input target to execute its default action via
 * {@link InputConnection#performEditorAction
 * InputConnection.performEditorAction()}.
 * 
 * @param fromEnterKey If true, this will be executed as if the user had
 * pressed an enter key on the keyboard, that is it will <em>not</em>
 * be done if the editor has set {@link EditorInfo#IME_FLAG_NO_ENTER_ACTION
 * EditorInfo.IME_FLAG_NO_ENTER_ACTION}.  If false, the action will be
 * sent regardless of how the editor has set that flag.
 * 
 * @return Returns a boolean indicating whether an action has been sent.
 * If false, either the editor did not specify a default action or it
 * does not want an action from the enter key.  If true, the action was
 * sent (or there was no input connection at all).
 */
public boolean sendDefaultEditorAction(boolean fromEnterKey) {
    EditorInfo ei = getCurrentInputEditorInfo();
    if (ei != null &&
            (!fromEnterKey || (ei.imeOptions &
                    EditorInfo.IME_FLAG_NO_ENTER_ACTION) == 0) &&
            (ei.imeOptions & EditorInfo.IME_MASK_ACTION) !=
                EditorInfo.IME_ACTION_NONE) {
        // If the enter key was pressed, and the editor has a default
        // action associated with pressing enter, then send it that
        // explicit action instead of the key event.
        InputConnection ic = getCurrentInputConnection();
        if (ic != null) {
            ic.performEditorAction(ei.imeOptions&EditorInfo.IME_MASK_ACTION);
        }
        return true;
    }
    
    return false;
}
 
Example #11
Source File: InputMethodService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Return a drawable resource id that can be used as a button icon for the given
 * {@link EditorInfo#imeOptions EditorInfo.imeOptions}.
 *
 * @param imeOptions The value from @link EditorInfo#imeOptions EditorInfo.imeOptions}.
 *
 * @return Returns a drawable resource id to use.
 */
@DrawableRes
private int getIconForImeAction(int imeOptions) {
    switch (imeOptions&EditorInfo.IME_MASK_ACTION) {
        case EditorInfo.IME_ACTION_GO:
            return com.android.internal.R.drawable.ic_input_extract_action_go;
        case EditorInfo.IME_ACTION_SEARCH:
            return com.android.internal.R.drawable.ic_input_extract_action_search;
        case EditorInfo.IME_ACTION_SEND:
            return com.android.internal.R.drawable.ic_input_extract_action_send;
        case EditorInfo.IME_ACTION_NEXT:
            return com.android.internal.R.drawable.ic_input_extract_action_next;
        case EditorInfo.IME_ACTION_DONE:
            return com.android.internal.R.drawable.ic_input_extract_action_done;
        case EditorInfo.IME_ACTION_PREVIOUS:
            return com.android.internal.R.drawable.ic_input_extract_action_previous;
        default:
            return com.android.internal.R.drawable.ic_input_extract_action_return;
    }
}
 
Example #12
Source File: SignUpActivity.java    From A-week-to-develop-android-app-plan with Apache License 2.0 6 votes vote down vote up
private void initViews() {

        getVerifiCodeButton = getView(R.id.btn_send_verifi_code);
        getVerifiCodeButton.setOnClickListener(this);
        phoneEdit = getView(R.id.et_phone);
        phoneEdit.setImeOptions(EditorInfo.IME_ACTION_NEXT);// 下一步
        verifyCodeEdit = getView(R.id.et_verifiCode);
        verifyCodeEdit.setImeOptions(EditorInfo.IME_ACTION_NEXT);// 下一步
        passwordEdit = getView(R.id.et_password);
        passwordEdit.setImeOptions(EditorInfo.IME_ACTION_DONE);
        passwordEdit.setImeOptions(EditorInfo.IME_ACTION_GO);
        passwordEdit.setOnEditorActionListener(new OnEditorActionListener() {

            @Override
            public boolean onEditorAction(TextView v, int actionId,
                                          KeyEvent event) {
                // 点击虚拟键盘的done
                if (actionId == EditorInfo.IME_ACTION_DONE
                        || actionId == EditorInfo.IME_ACTION_GO) {
                    commit();
                }
                return false;
            }
        });
    }
 
Example #13
Source File: TransferFragment.java    From EosCommander with MIT License 6 votes vote down vote up
@Override
protected void setUpView(View view) {

    mRootView = view;

    //  from, to, amount edit text
    AutoCompleteTextView etFrom = view.findViewById(R.id.et_from);
    AutoCompleteTextView etTo = view.findViewById(R.id.et_to);
    EditText etAmount = view.findViewById(R.id.et_amount);

    // click handler
    view.findViewById(R.id.btn_transfer).setOnClickListener(v -> onSend() );

    etAmount.setOnEditorActionListener((textView, actionId, keyEvent) -> {
        if (EditorInfo.IME_ACTION_SEND == actionId) {
            onSend();
            return true;
        }

        return false;
    });


    // account history
    UiUtils.setupAccountHistory( etFrom, etTo );
}
 
Example #14
Source File: KeyboardSwitcher.java    From Indic-Keyboard with Apache License 2.0 6 votes vote down vote up
public void loadKeyboard(final EditorInfo editorInfo, final SettingsValues settingsValues,
        final int currentAutoCapsState, final int currentRecapitalizeState) {
    final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(
            mThemeContext, editorInfo);
    final Resources res = mThemeContext.getResources();
    final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
    final int keyboardHeight = ResourceUtils.getKeyboardHeight(res, settingsValues);
    builder.setKeyboardGeometry(keyboardWidth, keyboardHeight);
    builder.setSubtype(mRichImm.getCurrentSubtype());
    builder.setVoiceInputKeyEnabled(settingsValues.mShowsVoiceInputKey);
    builder.setLanguageSwitchKeyEnabled(mLatinIME.shouldShowLanguageSwitchKey());
    builder.setEmojiSwitchKeyEnabled(mLatinIME.shouldShowEmojiSwitchKey());
    builder.setNumberRowEnabled(mLatinIME.shouldShowNumberRow());
    builder.setSplitLayoutEnabledByUser(ProductionFlags.IS_SPLIT_KEYBOARD_SUPPORTED
            && settingsValues.mIsSplitKeyboardEnabled);
    mKeyboardLayoutSet = builder.build();
    try {
        mState.onLoadKeyboard(currentAutoCapsState, currentRecapitalizeState);
        mKeyboardTextsSet.setLocale(mRichImm.getCurrentSubtypeLocale(), mThemeContext);
    } catch (KeyboardLayoutSetException e) {
        Log.w(TAG, "loading keyboard failed: " + e.mKeyboardId, e.getCause());
    }
}
 
Example #15
Source File: LatinIME.java    From openboard with GNU General Public License v3.0 6 votes vote down vote up
void onStartInputInternal(final EditorInfo editorInfo, final boolean restarting) {
    super.onStartInput(editorInfo, restarting);

    // If the primary hint language does not match the current subtype language, then try
    // to switch to the primary hint language.
    // TODO: Support all the locales in EditorInfo#hintLocales.
    final Locale primaryHintLocale = EditorInfoCompatUtils.getPrimaryHintLocale(editorInfo);
    if (primaryHintLocale == null) {
        return;
    }
    final InputMethodSubtype newSubtype = mRichImm.findSubtypeByLocale(primaryHintLocale);
    if (newSubtype == null || newSubtype.equals(mRichImm.getCurrentSubtype().getRawSubtype())) {
        return;
    }
    mHandler.postSwitchLanguage(newSubtype);
}
 
Example #16
Source File: LoginActivity.java    From Car-Pooling with MIT License 6 votes vote down vote up
/**
 * This method is used to set layout for login screen and handle login functionalities accordingly
 * @param savedInstanceState
 */
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if(getClient().user().isUserLoggedIn()){
        toMainActivity();
    }
    setContentView(R.layout.activity_login);
    defineView();
    mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == R.id.login || id == EditorInfo.IME_NULL) {
                attemptLogin();
                return true;
            }
            return false;
        }
    });


}
 
Example #17
Source File: QiscusEditText.java    From qiscus-sdk-android with Apache License 2.0 6 votes vote down vote up
@Override
public InputConnection onCreateInputConnection(final EditorInfo info) {
    final InputConnection ic = super.onCreateInputConnection(info);
    EditorInfoCompat.setContentMimeTypes(info, new String[]{"image/gif"});
    final InputConnectionCompat.OnCommitContentListener callback = (info1, flags, opts) -> {
        if (BuildVersionUtil.isAtLeastNMR1() && (flags & InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION) != 0) {
            try {
                info1.requestPermission();
            } catch (Exception e) {
                return false;
            }
        }
        if (commitListener != null) {
            commitListener.onCommitContent(info1);
        }
        return true;
    };
    return InputConnectionCompat.createWrapper(ic, info, callback);
}
 
Example #18
Source File: CreateAccountActivity.java    From particle-android with Apache License 2.0 6 votes vote down vote up
@OnCheckedChanged(R2.id.companyAccount)
protected void onCompanyCheckedChange(boolean isChecked) {
    if (isChecked) {
        int backgroundDefault = ContextCompat.getColor(CreateAccountActivity.this,
                R.color.register_field_background_color_enabled);
        verifyPasswordView.setImeOptions(EditorInfo.IME_ACTION_NEXT);
        companyNameView.setBackgroundColor(backgroundDefault);
        companyChoiceView.setText(R.string.prompt_company_account_enabled);
    } else {
        verifyPasswordView.setImeOptions(EditorInfo.IME_ACTION_DONE);
        companyNameView.setBackgroundColor(ContextCompat.getColor(CreateAccountActivity.this,
                R.color.register_field_background_color_disabled));
        companyChoiceView.setText(R.string.prompt_company_account_disabled);
    }
    companyNameView.setEnabled(isChecked);
}
 
Example #19
Source File: RegisterServiceActivity.java    From BonjourBrowser with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (getView() == null || actionId != EditorInfo.IME_ACTION_DONE) {
        return false;
    }
    switch (v.getId()) {
        case R.id.service_name:
            regTypeEditText.requestFocus();
            return true;
        case R.id.reg_type:
            portEditText.requestFocus();
            return true;
        case R.id.port:
            InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(getView().getWindowToken(), 0);
            return true;
    }
    return false;
}
 
Example #20
Source File: OnTouchPasswordListener.java    From openshop.io-android with MIT License 6 votes vote down vote up
@Override
public boolean onTouch(View v, MotionEvent event) {
    final int action = event.getAction();
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            mPreviousInputType = passwordET.getInputType();
            setInputType(EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD, true);
            break;

        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            setInputType(mPreviousInputType, true);
            mPreviousInputType = -1;
            break;
    }

    return false;
}
 
Example #21
Source File: TextInputAutoCompleteTextView.java    From SimpleDialogFragments with Apache License 2.0 6 votes vote down vote up
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    final InputConnection ic = super.onCreateInputConnection(outAttrs);
    if (ic != null && outAttrs.hintText == null) {
        // If we don't have a hint and our parent is a TextInputLayout, use it's hint for the
        // EditorInfo. This allows us to display a hint in 'extract mode'.
        ViewParent parent = getParent();
        while (parent instanceof View) {
            if (parent instanceof TextInputLayout) {
                outAttrs.hintText = ((TextInputLayout) parent).getHint();
                break;
            }
            parent = parent.getParent();
        }
    }
    return ic;
}
 
Example #22
Source File: EditTextUtil.java    From MVPAndroidBootstrap with Apache License 2.0 5 votes vote down vote up
public static OnEditorActionListener getSoftInputHideEditorActionListener(final Context context, final EditText editText) {
    OnEditorActionListener hideEditorListener = new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                EditTextUtil.hideSoftInPut(editText, context);
                return true;
            }
            return false;
        }
    };

    return hideEditorListener;
}
 
Example #23
Source File: MainActivity.java    From SizeAdjustingTextView with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
	boolean handled = false;
	String incomingText = mMessageEditText.getText().toString();
	if(actionId==EditorInfo.IME_ACTION_SEND && !incomingText.isEmpty()){
		handled = true;
		moveText();
		clearEditText();
	}
	return handled;
}
 
Example #24
Source File: DatePicker.java    From ticdesign with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the IME options for a spinner based on its ordering.
 *
 * @param spinner The spinner.
 * @param spinnerCount The total spinner count.
 * @param spinnerIndex The index of the given spinner.
 */
private void setImeOptions(NumberPicker spinner, int spinnerCount, int spinnerIndex) {
    final int imeOptions;
    if (spinnerIndex < spinnerCount - 1) {
        imeOptions = EditorInfo.IME_ACTION_NEXT;
    } else {
        imeOptions = EditorInfo.IME_ACTION_DONE;
    }
    TextView input = (TextView) spinner.findViewById(R.id.numberpicker_input);
    input.setImeOptions(imeOptions);
}
 
Example #25
Source File: DownloadFragment.java    From music_player with Open Software License 3.0 5 votes vote down vote up
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_DONE) {
        searchAction();
        InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
        return true;
    }
    return false;
}
 
Example #26
Source File: EditMessage.java    From Pix-Art-Messenger with GNU General Public License v3.0 5 votes vote down vote up
@Override
public InputConnection onCreateInputConnection(EditorInfo editorInfo) {
    final InputConnection ic = super.onCreateInputConnection(editorInfo);

    if (mimeTypes != null && mCommitContentListener != null && ic != null) {
        EditorInfoCompat.setContentMimeTypes(editorInfo, mimeTypes);
        return InputConnectionCompat.createWrapper(ic, editorInfo, (inputContentInfo, flags, opts) -> EditMessage.this.mCommitContentListener.onCommitContent(inputContentInfo, flags, opts, mimeTypes));
    } else {
        return ic;
    }
}
 
Example #27
Source File: AnagramsActivity.java    From jterm-cswithandroid with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_anagrams);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    AssetManager assetManager = getAssets();
    try {
        InputStream inputStream = assetManager.open("words.txt");
        dictionary = new AnagramDictionary(inputStream);
    } catch (IOException e) {
        Toast toast = Toast.makeText(this, "Could not load dictionary", Toast.LENGTH_LONG);
        toast.show();
    }
    // Set up the EditText box to process the content of the box when the user hits 'enter'
    final EditText editText = (EditText) findViewById(R.id.editText);
    editText.setRawInputType(InputType.TYPE_CLASS_TEXT);
    editText.setImeOptions(EditorInfo.IME_ACTION_GO);
    editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_GO) {
                processWord(editText);
                handled = true;
            }
            return handled;
        }
    });
}
 
Example #28
Source File: LxxActionSendTests.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
public void testActionSend() {
    final ExpectedActionKey expectedKey = ExpectedActionKey.newIconKey(
            KeyboardIconsSet.NAME_SEND_KEY);
    for (final InputMethodSubtype subtype : getAllSubtypesList()) {
        final String tag = "send " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype);
        doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_SEND, expectedKey);
    }
}
 
Example #29
Source File: UiLogin.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
private void initListener() {
    mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == R.id.login || id == EditorInfo.IME_NULL) {
                mLoginPresenter.login();
                return true;
            }
            return false;
        }
    });
}
 
Example #30
Source File: BluetoothChatFragment.java    From android-BluetoothChat with Apache License 2.0 5 votes vote down vote up
public boolean onEditorAction(TextView view, int actionId, KeyEvent event) {
    // If the action is a key-up event on the return key, send the message
    if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_UP) {
        String message = view.getText().toString();
        sendMessage(message);
    }
    return true;
}