Example usage for android.view.inputmethod EditorInfo IME_ACTION_GO

List of usage examples for android.view.inputmethod EditorInfo IME_ACTION_GO

Introduction

In this page you can find the example usage for android.view.inputmethod EditorInfo IME_ACTION_GO.

Prototype

int IME_ACTION_GO

To view the source code for android.view.inputmethod EditorInfo IME_ACTION_GO.

Click Source Link

Document

Bits of #IME_MASK_ACTION : the action key performs a "go" operation to take the user to the target of the text they typed.

Usage

From source file:com.polyvi.xface.extension.inappbrowser.XInAppBrowser.java

/**
 * //from   w w  w  .  ja v  a2s . c o  m
 */
protected void buildEditText() {
    RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);
    textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1);
    textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5);
    OnKeyListener keyListener = new View.OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                navigate(mEditText.getText().toString());
                return true;
            }
            return false;
        }
    };
    mEditText = createEditText(EDITTEXT_ID, textLayoutParams, true, mUrl, InputType.TYPE_TEXT_VARIATION_URI,
            EditorInfo.IME_ACTION_GO, keyListener);
}

From source file:com.abcvoipsip.ui.dialpad.DialerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.dialer_digit, container, false);
    // Store the backgrounds objects that will be in use later
    Resources r = getResources();

    digitsBackground = r.getDrawable(R.drawable.btn_dial_textfield_active);
    digitsEmptyBackground = r.getDrawable(R.drawable.btn_dial_textfield_normal);

    // Store some object that could be useful later
    digits = (DigitsEditText) v.findViewById(R.id.digitsText);
    digitsWrapper = (LinearLayout) v.findViewById(R.id.topField);
    dialPad = (Dialpad) v.findViewById(R.id.dialPad);
    callBar = (DialerCallBar) v.findViewById(R.id.dialerCallBar);
    autoCompleteList = (ListView) v.findViewById(R.id.autoCompleteList);
    accountChooserButton = (AccountChooserButton) v.findViewById(R.id.accountChooserButton);
    switchTextView = (ImageButton) v.findViewById(R.id.switchTextView);

    // isTablet = Compatibility.isTabletScreen(getActivity());

    // Digits field setup
    isDigit = prefsWrapper.startIsDigit();
    digits.setOnEditorActionListener(new OnEditorActionListener() {
        @Override//from  ww w.  j  a v  a2  s.  c om
        public boolean onEditorAction(TextView tv, int action, KeyEvent arg2) {
            if (action == EditorInfo.IME_ACTION_GO) {
                placeCall();
                return true;
            }
            return false;
        }
    });

    // Account chooser button setup
    accountChooserButton.setShowExternals(true);
    accountChooserButton.setOnAccountChangeListener(new OnAccountChangeListener() {
        @Override
        public void onChooseAccount(SipProfile account) {
            long accId = SipProfile.INVALID_ID;
            if (account != null) {
                accId = account.id;
            }
            autoCompleteAdapter.setSelectedAccount(accId);
        }
    });

    // Dialpad
    dialPad.setOnDialKeyListener(this);

    // Auto complete list in case of text
    autoCompleteAdapter = new ContactsSearchAdapter(getActivity());

    // We only need to add the autocomplete list if we
    DialerCallBar listCallBar = new DialerCallBar(getActivity(), null);
    listCallBar.setOnDialActionListener(this);
    autoCompleteList.addFooterView(listCallBar);
    autoCompleteList.setAdapter(autoCompleteAdapter);
    autoCompleteList.setOnItemClickListener(new OnAutoCompleteListItemClicked(autoCompleteAdapter));

    // Bottom bar setup
    callBar.setOnDialActionListener(this);

    // Ensure that current mode (text/digit) is applied
    setTextDialing(!isDigit);

    // Init other buttons
    initButtons(v);

    // Apply third party theme if any
    applyTheme();

    v.setOnKeyListener(this);

    return v;
}

From source file:cx.ring.fragments.SmartListFragment.java

@Override
public void onCreateOptionsMenu(final Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.smartlist_menu, menu);
    mSearchMenuItem = menu.findItem(R.id.menu_contact_search);
    mDialpadMenuItem = menu.findItem(R.id.menu_contact_dial);
    MenuItemCompat.setOnActionExpandListener(mSearchMenuItem, new MenuItemCompat.OnActionExpandListener() {
        @Override/*from w w  w. j a  v  a2  s .  c  o m*/
        public boolean onMenuItemActionCollapse(MenuItem item) {
            mDialpadMenuItem.setVisible(false);
            displayFloatingActionButtonWithDelay(true, 50);
            setOverflowMenuVisible(menu, true);
            setLoading(false);
            return true;
        }

        @Override
        public boolean onMenuItemActionExpand(MenuItem item) {
            mDialpadMenuItem.setVisible(true);
            displayFloatingActionButtonWithDelay(false, 0);
            setOverflowMenuVisible(menu, false);
            setLoading(false);
            return true;
        }
    });

    mSearchView = (SearchView) mSearchMenuItem.getActionView();
    mSearchView.setOnQueryTextListener(this);
    mSearchView.setQueryHint(getString(R.string.searchbar_hint));
    mSearchView.setLayoutParams(
            new Toolbar.LayoutParams(Toolbar.LayoutParams.MATCH_PARENT, Toolbar.LayoutParams.MATCH_PARENT));
    mSearchView.setImeOptions(EditorInfo.IME_ACTION_GO);

    Intent i = getActivity().getIntent();
    switch (i.getAction()) {
    case Intent.ACTION_VIEW:
    case Intent.ACTION_CALL:
        mSearchView.setQuery(i.getDataString(), true);
        break;
    case Intent.ACTION_DIAL:
        mSearchMenuItem.expandActionView();
        mSearchView.setQuery(i.getDataString(), false);
        break;
    }
}

From source file:com.mishiranu.dashchan.ui.navigator.DrawerForm.java

public DrawerForm(Context context, Context unstyledContext, Callback callback,
        WatcherService.Client watcherServiceClient) {
    this.context = context;
    this.unstyledContext = unstyledContext;
    this.callback = callback;
    this.watcherServiceClient = watcherServiceClient;
    float density = ResourceUtils.obtainDensity(context);
    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setLayoutParams(new SortableListView.LayoutParams(SortableListView.LayoutParams.MATCH_PARENT,
            SortableListView.LayoutParams.WRAP_CONTENT));
    LinearLayout editTextContainer = new LinearLayout(context);
    editTextContainer.setGravity(Gravity.CENTER_VERTICAL);
    linearLayout.addView(editTextContainer);
    searchEdit = new SafePasteEditText(context);
    searchEdit.setOnKeyListener((v, keyCode, event) -> {
        if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
            v.clearFocus();//from ww  w .ja v a2 s .c  o m
        }
        return false;
    });
    searchEdit.setHint(context.getString(R.string.text_code_number_address));
    searchEdit.setOnEditorActionListener(this);
    searchEdit.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    searchEdit.setImeOptions(EditorInfo.IME_ACTION_GO | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    ImageView searchIcon = new ImageView(context, null, android.R.attr.buttonBarButtonStyle);
    searchIcon.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonForward, 0));
    searchIcon.setScaleType(ImageView.ScaleType.CENTER);
    searchIcon.setOnClickListener(this);
    editTextContainer.addView(searchEdit,
            new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1));
    editTextContainer.addView(searchIcon, (int) (40f * density), (int) (40f * density));
    if (C.API_LOLLIPOP) {
        editTextContainer.setPadding((int) (12f * density), (int) (8f * density), (int) (8f * density), 0);
    } else {
        editTextContainer.setPadding(0, (int) (2f * density), (int) (4f * density), (int) (2f * density));
    }
    LinearLayout selectorContainer = new LinearLayout(context);
    selectorContainer.setBackgroundResource(
            ResourceUtils.getResourceId(context, android.R.attr.selectableItemBackground, 0));
    selectorContainer.setOrientation(LinearLayout.HORIZONTAL);
    selectorContainer.setGravity(Gravity.CENTER_VERTICAL);
    selectorContainer.setOnClickListener(v -> {
        hideKeyboard();
        setChanSelectMode(!chanSelectMode);
    });
    linearLayout.addView(selectorContainer);
    selectorContainer.setMinimumHeight((int) (40f * density));
    if (C.API_LOLLIPOP) {
        selectorContainer.setPadding((int) (16f * density), 0, (int) (16f * density), 0);
        ((LinearLayout.LayoutParams) selectorContainer.getLayoutParams()).topMargin = (int) (4f * density);
    } else {
        selectorContainer.setPadding((int) (8f * density), 0, (int) (12f * density), 0);
    }
    chanNameView = new TextView(context, null, android.R.attr.textAppearanceListItem);
    chanNameView.setTextSize(TypedValue.COMPLEX_UNIT_SP, C.API_LOLLIPOP ? 14f : 16f);
    if (C.API_LOLLIPOP) {
        chanNameView.setTypeface(GraphicsUtils.TYPEFACE_MEDIUM);
    } else {
        chanNameView.setFilters(new InputFilter[] { new InputFilter.AllCaps() });
    }
    selectorContainer.addView(chanNameView,
            new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, 1));
    chanSelectorIcon = new ImageView(context);
    chanSelectorIcon.setImageResource(ResourceUtils.getResourceId(context, R.attr.buttonDropDownDrawer, 0));
    selectorContainer.addView(chanSelectorIcon, (int) (24f * density), (int) (24f * density));
    ((LinearLayout.LayoutParams) chanSelectorIcon.getLayoutParams()).gravity = Gravity.CENTER_VERTICAL
            | Gravity.END;
    headerView = linearLayout;
    inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    chans.add(new ListItem(ListItem.ITEM_DIVIDER, 0, 0, null));
    int color = ResourceUtils.getColor(context, R.attr.drawerIconColor);
    ChanManager manager = ChanManager.getInstance();
    Collection<String> availableChans = manager.getAvailableChanNames();
    for (String chanName : availableChans) {
        ChanConfiguration configuration = ChanConfiguration.get(chanName);
        if (configuration.getOption(ChanConfiguration.OPTION_READ_POSTS_COUNT)) {
            watcherSupportSet.add(chanName);
        }
        Drawable drawable = manager.getIcon(chanName, color);
        chanIcons.put(chanName, drawable);
        chans.add(
                new ListItem(ListItem.ITEM_CHAN, chanName, null, null, configuration.getTitle(), 0, drawable));
    }
    if (availableChans.size() == 1) {
        selectorContainer.setVisibility(View.GONE);
    }
}

From source file:org.xwalk.core.xwview.shell.XWalkViewShellActivity.java

private void initializeUrlField() {
    mUrlTextView = (EditText) findViewById(R.id.url);
    mUrlTextView.setOnEditorActionListener(new OnEditorActionListener() {
        @Override/*from   w w w .  j av a2 s . co m*/
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if ((actionId != EditorInfo.IME_ACTION_GO)
                    && (event == null || event.getKeyCode() != KeyEvent.KEYCODE_ENTER
                            || event.getAction() != KeyEvent.ACTION_DOWN)) {
                return false;
            }

            if (mActiveView == null)
                return true;
            mActiveView.load(sanitizeUrl(mUrlTextView.getText().toString()), null);
            mUrlTextView.clearFocus();
            setKeyboardVisibilityForUrl(false);
            return true;
        }
    });
    mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            setKeyboardVisibilityForUrl(hasFocus);
            mNextButton.setVisibility(hasFocus ? View.GONE : View.VISIBLE);
            mPrevButton.setVisibility(hasFocus ? View.GONE : View.VISIBLE);
            mStopButton.setVisibility(hasFocus ? View.GONE : View.VISIBLE);
            mReloadButton.setVisibility(hasFocus ? View.GONE : View.VISIBLE);
            if (!hasFocus) {
                if (mActiveView == null)
                    return;
                mUrlTextView.setText(mActiveView.getUrl());
            }
        }
    });
}

From source file:com.nbossard.packlist.gui.TripDetailFragment.java

@DebugLog
@Override// w  ww .j a  va  2s  . c om
public final void onViewCreated(final View view, @Nullable final Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    // TODO old style, improve this
    mNewItemEditText = (AppCompatEditText) mRootView.findViewById(R.id.trip_detail__new_item__edit);

    mAddItemButton = (Button) mRootView.findViewById(R.id.trip_detail__new_item__button);
    mAddItemButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            onClickAddItem();
        }
    });
    mAddItemButton.setEnabled(false);
    disableButtonIfEmptyText(mAddItemButton);

    mNewItemEditText.setOnEditorActionListener(new AppCompatEditText.OnEditorActionListener() {
        @DebugLog
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            boolean handled = false;
            if (actionId == EditorInfo.IME_ACTION_GO) {
                mAddItemButton.performClick();
                handled = true;
            }
            return handled;
        }
    });

    final Button editButton = (Button) mRootView.findViewById(R.id.trip_detail__edit_button);
    editButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onClickEditTrip();
        }
    });

    populateList();
}

From source file:cx.ring.fragments.CallListFragment.java

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    inflater.inflate(R.menu.call_list_menu, menu);
    searchMenuItem = menu.findItem(R.id.menu_contact_search);
    dialpadMenuItem = menu.findItem(R.id.menu_contact_dial);
    MenuItemCompat.setOnActionExpandListener(searchMenuItem, new MenuItemCompat.OnActionExpandListener() {
        @Override//from   w  w  w  . ja v  a 2s. com
        public boolean onMenuItemActionCollapse(MenuItem item) {
            dialpadMenuItem.setVisible(false);
            list.setAdapter(mConferenceAdapter);
            //listSwitcher.setDisplayedChild(0);
            list.setVisibility(View.VISIBLE);
            contactList.setAdapter(null);
            contactList.setVisibility(View.GONE);
            return true;
        }

        @Override
        public boolean onMenuItemActionExpand(MenuItem item) {
            dialpadMenuItem.setVisible(true);
            contactList.setAdapter(mListAdapter);
            //listSwitcher.setDisplayedChild(1);
            contactList.setVisibility(View.VISIBLE);
            list.setAdapter(null);
            list.setVisibility(View.GONE);
            onLoadFinished(null, mCallbacks.getService().getSortedContacts());
            return true;
        }
    });

    searchView = (SearchView) searchMenuItem.getActionView();
    searchView.setOnQueryTextListener(this);
    searchView.setQueryHint(getString(R.string.searchbar_hint));
    searchView.setLayoutParams(
            new Toolbar.LayoutParams(Toolbar.LayoutParams.MATCH_PARENT, Toolbar.LayoutParams.MATCH_PARENT));
    searchView.setImeOptions(EditorInfo.IME_ACTION_GO);
}

From source file:com.elkriefy.android.apps.authenticationexample.fingerprintdialog.FingerprintAuthenticationDialogFragment.java

@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_GO) {
        verifyPassword();//  w w  w  .  ja v a  2  s.  c  om
        return true;
    }
    return false;
}

From source file:com.manning.androidhacks.hack017.CreateAccountAdapter.java

private void populateFourthForm(LinearLayout formLayout) {
    formLayout.addView(createTitle(mContext.getString(R.string.account_create_zip_title)));
    EditText zipEditText = createEditText(mContext.getString(R.string.account_create_zip_hint),
            InputType.TYPE_CLASS_TEXT, EditorInfo.IME_ACTION_GO, true, ZIP_KEY);

    if (mFormData.get(ZIP_KEY) != null) {
        zipEditText.setText(mFormData.get(ZIP_KEY));
    }/*from w  ww.  ja  v a 2 s  .c  o m*/

    formLayout.addView(zipEditText);
    formLayout.addView(createErrorView(ZIP_KEY));
}

From source file:org.cocos2dx.lib.Cocos2dxEditBoxDialog.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    getWindow().setBackgroundDrawable(new ColorDrawable(0x80000000));

    LinearLayout layout = new LinearLayout(mParentActivity);
    layout.setOrientation(LinearLayout.VERTICAL);

    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.FILL_PARENT);

    mTextViewTitle = new TextView(mParentActivity);
    LinearLayout.LayoutParams textviewParams = new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    textviewParams.leftMargin = textviewParams.rightMargin = convertDipsToPixels(10);
    mTextViewTitle.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
    layout.addView(mTextViewTitle, textviewParams);

    mInputEditText = new EditText(mParentActivity);
    LinearLayout.LayoutParams editTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    editTextParams.leftMargin = editTextParams.rightMargin = convertDipsToPixels(10);

    layout.addView(mInputEditText, editTextParams);

    setContentView(layout, layoutParams);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

    mInputMode = mMsg.inputMode;/*from   ww  w. ja v a 2 s .  c om*/
    mInputFlag = mMsg.inputFlag;
    mReturnType = mMsg.returnType;
    mMaxLength = mMsg.maxLength;

    mTextViewTitle.setText(mMsg.title);
    mInputEditText.setText(mMsg.content);

    int oldImeOptions = mInputEditText.getImeOptions();
    mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    oldImeOptions = mInputEditText.getImeOptions();

    switch (mInputMode) {
    case kEditBoxInputModeAny:
        mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE;
        break;
    case kEditBoxInputModeEmailAddr:
        mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
        break;
    case kEditBoxInputModeNumeric:
        mInputModeContraints = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED;
        break;
    case kEditBoxInputModePhoneNumber:
        mInputModeContraints = InputType.TYPE_CLASS_PHONE;
        break;
    case kEditBoxInputModeUrl:
        mInputModeContraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
        break;
    case kEditBoxInputModeDecimal:
        mInputModeContraints = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL
                | InputType.TYPE_NUMBER_FLAG_SIGNED;
        break;
    case kEditBoxInputModeSingleLine:
        mInputModeContraints = InputType.TYPE_CLASS_TEXT;
        break;
    default:

        break;
    }

    if (mIsMultiline) {
        mInputModeContraints |= InputType.TYPE_TEXT_FLAG_MULTI_LINE;
    }

    mInputEditText.setInputType(mInputModeContraints | mInputFlagConstraints);

    switch (mInputFlag) {
    case kEditBoxInputFlagPassword:
        mInputFlagConstraints = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
        break;
    case kEditBoxInputFlagSensitive:
        mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        break;
    case kEditBoxInputFlagInitialCapsWord:
        mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_WORDS;
        break;
    case kEditBoxInputFlagInitialCapsSentence:
        mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_SENTENCES;
        break;
    case kEditBoxInputFlagInitialCapsAllCharacters:
        mInputFlagConstraints = InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS;
        break;
    default:
        break;
    }
    mInputEditText.setInputType(mInputFlagConstraints | mInputModeContraints);

    switch (mReturnType) {
    case kKeyboardReturnTypeDefault:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE);
        break;
    case kKeyboardReturnTypeDone:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_DONE);
        break;
    case kKeyboardReturnTypeSend:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEND);
        break;
    case kKeyboardReturnTypeSearch:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_SEARCH);
        break;
    case kKeyboardReturnTypeGo:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_GO);
        break;
    default:
        mInputEditText.setImeOptions(oldImeOptions | EditorInfo.IME_ACTION_NONE);
        break;
    }

    if (mMaxLength > 0) {
        mInputEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(mMaxLength) });
    }

    Handler initHandler = new Handler();
    initHandler.postDelayed(new Runnable() {
        public void run() {
            mInputEditText.requestFocus();
            mInputEditText.setSelection(mInputEditText.length());
            openKeyboard();
        }
    }, 200);

    mInputEditText.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            // if user didn't set keyboard type,
            // this callback will be invoked twice with 'KeyEvent.ACTION_DOWN' and 'KeyEvent.ACTION_UP'
            if (actionId != EditorInfo.IME_NULL || (actionId == EditorInfo.IME_NULL && event != null
                    && event.getAction() == KeyEvent.ACTION_DOWN)) {
                //Log.d("EditBox", "actionId: "+actionId +",event: "+event);
                mParentActivity.setEditBoxResult(mInputEditText.getText().toString());
                closeKeyboard();
                dismiss();
                return true;
            }
            return false;
        }
    });
}