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.skytree.epubtest.BookViewActivity.java

public void makeSearchBox() {
    int boxColor = Color.rgb(241, 238, 229);
    int innerBoxColor = Color.rgb(246, 244, 239);
    int inlineColor = Color.rgb(133, 105, 75);

    RelativeLayout.LayoutParams param = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT); // width,height
    searchBox = new SkyBox(this);
    searchBox.setBoxColor(boxColor);/*from w  w w.j a  va2 s  . c  o  m*/
    searchBox.setArrowHeight(ps(25));
    searchBox.setArrowDirection(false);
    param.leftMargin = ps(50);
    param.topMargin = ps(400);
    param.width = ps(400);
    param.height = ps(300);
    searchBox.setLayoutParams(param);
    searchBox.setArrowDirection(false);

    searchEditor = new EditText(this);
    this.setFrame(searchEditor, ps(20), ps(20), ps(400 - 140), ps(50));
    searchEditor.setTextSize(15f);
    searchEditor.setEllipsize(TruncateAt.END);
    searchEditor.setBackgroundColor(innerBoxColor);
    Drawable icon = getResources().getDrawable(R.drawable.search2x);

    Bitmap bitmap = ((BitmapDrawable) icon).getBitmap();
    Drawable fd = new BitmapDrawable(getResources(), Bitmap.createScaledBitmap(bitmap, ps(28), ps(28), true));
    searchEditor.setCompoundDrawablesWithIntrinsicBounds(fd, null, null, null);
    RoundRectShape rrs = new RoundRectShape(
            new float[] { ps(15), ps(15), ps(15), ps(15), ps(15), ps(15), ps(15), ps(15) }, null, null);
    SkyDrawable sd = new SkyDrawable(rrs, innerBoxColor, inlineColor, 2);
    searchEditor.setBackgroundDrawable(sd);
    searchEditor.setHint(getString(R.string.searchhint));
    searchEditor.setPadding(ps(20), ps(5), ps(10), ps(5));
    searchEditor.setLines(1);
    searchEditor.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
    searchEditor.setSingleLine();
    searchEditor.setOnEditorActionListener(new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_GO
                    || actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_ACTION_NEXT) {
                String key = searchEditor.getText().toString();
                if (key != null && key.length() > 1) {
                    showIndicator();
                    clearSearchBox(1);
                    makeFullScreen();
                    rv.searchKey(key);
                }
            }
            return false;
        }
    });
    searchBox.contentView.addView(searchEditor);

    Button cancelButton = new Button(this);
    this.setFrame(cancelButton, ps(290), ps(20), ps(90), ps(50));
    cancelButton.setText(getString(R.string.cancel));
    cancelButton.setId(3001);
    RoundRectShape crs = new RoundRectShape(
            new float[] { ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5) }, null, null);
    SkyDrawable cd = new SkyDrawable(crs, innerBoxColor, inlineColor, 2);
    cancelButton.setBackgroundDrawable(cd);
    cancelButton.setTextSize(12);
    cancelButton.setOnClickListener(listener);
    cancelButton.setOnTouchListener(new ButtonHighlighterOnTouchListener(cancelButton));

    searchBox.contentView.addView(cancelButton);

    searchScrollView = new ScrollView(this);
    RoundRectShape rvs = new RoundRectShape(
            new float[] { ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5), ps(5) }, null, null);
    SkyDrawable rd = new SkyDrawable(rvs, innerBoxColor, inlineColor, 2);
    searchScrollView.setBackgroundDrawable(rd);
    this.setFrame(searchScrollView, ps(20), ps(100), ps(360), ps(200));
    this.searchBox.contentView.addView(searchScrollView);

    searchResultView = new LinearLayout(this);
    searchResultView.setOrientation(LinearLayout.VERTICAL);
    searchScrollView.addView(searchResultView,
            new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    this.ePubView.addView(searchBox);
    this.hideSearchBox();
}

From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardViewBase.java

@NonNull
private CharSequence guessLabelForKey(int keyCode) {
    switch (keyCode) {
    case KeyCodes.ENTER:
        switch (mKeyboardActionType) {
        case EditorInfo.IME_ACTION_DONE:
            return getContext().getText(R.string.label_done_key);
        case EditorInfo.IME_ACTION_GO:
            return getContext().getText(R.string.label_go_key);
        case EditorInfo.IME_ACTION_NEXT:
            return getContext().getText(R.string.label_next_key);
        case 0x00000007:// API 11: EditorInfo.IME_ACTION_PREVIOUS:
            return getContext().getText(R.string.label_previous_key);
        case EditorInfo.IME_ACTION_SEARCH:
            return getContext().getText(R.string.label_search_key);
        case EditorInfo.IME_ACTION_SEND:
            return getContext().getText(R.string.label_send_key);
        default://from   w  w w . j  ava  2s.  c  o  m
            return "";
        }
    case KeyCodes.KEYBOARD_MODE_CHANGE:
        if (mKeyboard instanceof GenericKeyboard)
            return guessLabelForKey(KeyCodes.MODE_ALPHABET);
        else
            return guessLabelForKey(KeyCodes.MODE_SYMOBLS);
    case KeyCodes.MODE_ALPHABET:
        return mNextAlphabetKeyboardName;
    case KeyCodes.MODE_SYMOBLS:
        return mNextSymbolsKeyboardName;
    case KeyCodes.TAB:
        return getContext().getText(R.string.label_tab_key);
    case KeyCodes.MOVE_HOME:
        return getContext().getText(R.string.label_home_key);
    case KeyCodes.MOVE_END:
        return getContext().getText(R.string.label_end_key);
    case KeyCodes.ARROW_DOWN:
        return "";
    case KeyCodes.ARROW_LEFT:
        return "";
    case KeyCodes.ARROW_RIGHT:
        return "";
    case KeyCodes.ARROW_UP:
        return "";
    default:
        return "";
    }
}

From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardViewBase.java

private Drawable getIconForKeyCode(int keyCode) {
    Drawable icon = getDrawableForKeyCode(keyCode);
    // maybe a drawable state is required
    if (icon != null) {
        switch (keyCode) {
        case KeyCodes.ENTER:
            Logger.d(TAG, "Action key action ID is %d", mKeyboardActionType);
            switch (mKeyboardActionType) {
            case EditorInfo.IME_ACTION_DONE:
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_ACTION_DONE);
                break;
            case EditorInfo.IME_ACTION_GO:
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_ACTION_GO);
                break;
            case EditorInfo.IME_ACTION_SEARCH:
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_ACTION_SEARCH);
                break;
            case EditorInfo.IME_ACTION_NONE:
            case EditorInfo.IME_ACTION_UNSPECIFIED:
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_ACTION_NORMAL);
                break;
            }//from w ww  .j a v a2s . c  om
            break;
        case KeyCodes.SHIFT:
            if (mKeyboard.isShiftLocked())
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_LOCKED);
            else if (mKeyboard.isShifted())
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_PRESSED);
            else
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_NORMAL);
            break;
        case KeyCodes.CTRL:
            if (mKeyboard.isControl())
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_PRESSED);
            else
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_NORMAL);
            break;
        }
    }
    return icon;
}

From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardBaseView.java

private CharSequence guessLabelForKey(int keyCode) {
    switch (keyCode) {
    case KeyCodes.ENTER:
        switch (mKeyboardActionType) {
        case EditorInfo.IME_ACTION_DONE:
            return getContext().getText(R.string.label_done_key);
        case EditorInfo.IME_ACTION_GO:
            return getContext().getText(R.string.label_go_key);
        case EditorInfo.IME_ACTION_NEXT:
            return getContext().getText(R.string.label_next_key);
        case 0x00000007:// API 11: EditorInfo.IME_ACTION_PREVIOUS:
            return getContext().getText(R.string.label_previous_key);
        case EditorInfo.IME_ACTION_SEARCH:
            return getContext().getText(R.string.label_search_key);
        case EditorInfo.IME_ACTION_SEND:
            return getContext().getText(R.string.label_send_key);
        default://from ww w .  j  av a2  s. c o m
            return "";
        }
    case KeyCodes.KEYBOARD_MODE_CHANGE:
        if (mSwitcher.isAlphabetMode())
            return guessLabelForKey(KeyCodes.MODE_SYMOBLS);
        else
            return guessLabelForKey(KeyCodes.MODE_ALPHABET);
    case KeyCodes.MODE_ALPHABET:
        String langKeyText = null;
        if (mSwitcher != null)//should show the next keyboard label, not a generic one.
            langKeyText = mSwitcher.peekNextAlphabetKeyboard();
        if (langKeyText == null)
            return getResources().getString(R.string.change_lang_regular);
        else
            return langKeyText;
    case KeyCodes.MODE_SYMOBLS:
        String symKeyText = null;
        if (mSwitcher != null)//should show the next keyboard label, not a generic one.
            symKeyText = mSwitcher.peekNextSymbolsKeyboard();
        if (symKeyText == null)
            return getResources().getString(R.string.change_symbols_regular);
        else
            return symKeyText;
    case KeyCodes.TAB:
        return getContext().getText(R.string.label_tab_key);
    case KeyCodes.MOVE_HOME:
        return getContext().getText(R.string.label_home_key);
    case KeyCodes.MOVE_END:
        return getContext().getText(R.string.label_end_key);
    case KeyCodes.ARROW_DOWN:
        return "\u2193";
    case KeyCodes.ARROW_LEFT:
        return "\u2190";
    case KeyCodes.ARROW_RIGHT:
        return "\u2192";
    case KeyCodes.ARROW_UP:
        return "\u2191";
    default:
        return null;
    }
}

From source file:com.anysoftkeyboard.keyboards.views.AnyKeyboardBaseView.java

private Drawable getIconForKeyCode(int keyCode) {
    Drawable icon = mKeysIcons.get(keyCode);

    if (icon == null) {
        // building needed icon
        Log.d(TAG, "Building icon for key-code %d", keyCode);
        DrawableBuilder builder = mKeysIconBuilders.get(keyCode);
        if (builder == null)
            return null;
        icon = builder.buildDrawable();/* w  w  w  .  j  av a 2 s  .  c o m*/
        mKeysIcons.put(keyCode, icon);
        Log.d(TAG, "Current drawable cache size is %d", mKeysIcons.size());
    }
    // maybe a drawable state is required
    if (icon != null) {
        switch (keyCode) {
        case KeyCodes.ENTER:
            Log.d(TAG, "Action key action ID is %d", mKeyboardActionType);
            switch (mKeyboardActionType) {
            case EditorInfo.IME_ACTION_DONE:
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_ACTION_DONE);
                break;
            case EditorInfo.IME_ACTION_GO:
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_ACTION_GO);
                break;
            case EditorInfo.IME_ACTION_SEARCH:
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_ACTION_SEARCH);
                break;
            case EditorInfo.IME_ACTION_NONE:
            case EditorInfo.IME_ACTION_UNSPECIFIED:
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_ACTION_NORMAL);
                break;
            }
            break;
        case KeyCodes.SHIFT:
            if (mKeyboard.isShiftLocked())
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_LOCKED);
            else if (mKeyboard.isShifted())
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_PRESSED);
            else
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_NORMAL);
            break;
        case KeyCodes.CTRL:
            if (mKeyboard.isControl())
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_PRESSED);
            else
                icon.setState(mDrawableStatesProvider.DRAWABLE_STATE_MODIFIER_NORMAL);
            break;
        }
    }
    return icon;
}