Example usage for android.view.inputmethod EditorInfo IME_ACTION_NEXT

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

Introduction

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

Prototype

int IME_ACTION_NEXT

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

Click Source Link

Document

Bits of #IME_MASK_ACTION : the action key performs a "next" operation, taking the user to the next field that will accept text.

Usage

From source file:no.ntnu.idi.socialhitchhiking.map.MapActivityAddPickupAndDropoff.java

/**
 * Initialize the {@link AutoCompleteTextView}'s with an {@link ArrayAdapter} 
 * and a listener ({@link AutoCompleteTextWatcher}). The listener gets autocomplete 
 * data from the Google Places API and updates the ArrayAdapter with these.
 *///www  .j  av a  2s.  co m
private void initAutocomplete() {
    adapter = new ArrayAdapter<String>(this, R.layout.item_list);
    adapter.setNotifyOnChange(true);

    acPickup = (AutoCompleteTextView) findViewById(R.id.pickupText);
    acPickup.setAdapter(adapter);
    acPickup.addTextChangedListener(new AutoCompleteTextWatcher(this, adapter, acPickup));
    acPickup.setThreshold(1);
    acPickup.selectAll();

    acDropoff = (AutoCompleteTextView) findViewById(R.id.dropoffText);
    acDropoff.setAdapter(adapter);
    acDropoff.addTextChangedListener(new AutoCompleteTextWatcher(this, adapter, acDropoff));

    //sets the next button on the keyboard
    acPickup.setOnEditorActionListener(new EditText.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_NEXT) {
                // Sets the pickup location
                setPickupLocation();
                // Sets focus to dropoff
                acDropoff.requestFocus();
                return true;
            } else {
                return false;
            }
        }
    });

    //sets the done button on the keyboard
    acDropoff.setOnEditorActionListener(new EditText.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                // Sets the dropoff location
                setDropOffLocation();
                // Sets focus to "Comment to driver"
                ((EditText) findViewById(R.id.mapViewPickupEtComment)).requestFocus();
                return true;
            } else {
                return false;
            }
        }
    });
}

From source file:org.akop.ararat.view.CrosswordView.java

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    Log.v(LOG_TAG, "onCreateInputConnection()");

    CrosswordInputConnection inputConnection = null;
    if (mInputMode != INPUT_MODE_NONE) {
        outAttrs.actionLabel = null;//  w ww  .  j av a2 s  . c  o  m
        outAttrs.inputType = InputType.TYPE_NULL;
        outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_FULLSCREEN;
        outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_EXTRACT_UI;
        outAttrs.imeOptions &= ~EditorInfo.IME_MASK_ACTION;
        outAttrs.imeOptions |= EditorInfo.IME_ACTION_NEXT;
        outAttrs.packageName = getContext().getPackageName();

        inputConnection = new CrosswordInputConnection(this);
        inputConnection.setOnInputEventListener(mInputEventListener);
    }

    return inputConnection;
}

From source file:org.telegram.ui.TwoStepVerificationActivity.java

private void setPasswordSetState(int state) {
    if (passwordEditText == null) {
        return;//from w ww .j  av  a 2s .c o  m
    }
    passwordSetState = state;
    if (passwordSetState == 0) {
        actionBar.setTitle(LocaleController.getString("YourPassword", R.string.YourPassword));
        if (currentPassword instanceof TLRPC.TL_account_noPassword) {
            titleTextView.setText(
                    LocaleController.getString("PleaseEnterFirstPassword", R.string.PleaseEnterFirstPassword));
        } else {
            titleTextView
                    .setText(LocaleController.getString("PleaseEnterPassword", R.string.PleaseEnterPassword));
        }
        passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
        passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
        bottomTextView.setVisibility(View.INVISIBLE);
        bottomButton.setVisibility(View.INVISIBLE);
    } else if (passwordSetState == 1) {
        actionBar.setTitle(LocaleController.getString("YourPassword", R.string.YourPassword));
        titleTextView
                .setText(LocaleController.getString("PleaseReEnterPassword", R.string.PleaseReEnterPassword));
        passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
        passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
        bottomTextView.setVisibility(View.INVISIBLE);
        bottomButton.setVisibility(View.INVISIBLE);
    } else if (passwordSetState == 2) {
        actionBar.setTitle(LocaleController.getString("PasswordHint", R.string.PasswordHint));
        titleTextView.setText(LocaleController.getString("PasswordHintText", R.string.PasswordHintText));
        passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
        passwordEditText.setTransformationMethod(null);
        bottomTextView.setVisibility(View.INVISIBLE);
        bottomButton.setVisibility(View.INVISIBLE);
    } else if (passwordSetState == 3) {
        actionBar.setTitle(LocaleController.getString("RecoveryEmail", R.string.RecoveryEmail));
        titleTextView.setText(LocaleController.getString("YourEmail", R.string.YourEmail));
        passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
        passwordEditText.setTransformationMethod(null);
        passwordEditText
                .setInputType(EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
        bottomTextView.setVisibility(View.VISIBLE);
        bottomButton.setVisibility(emailOnly ? View.INVISIBLE : View.VISIBLE);
    } else if (passwordSetState == 4) {
        actionBar.setTitle(LocaleController.getString("PasswordRecovery", R.string.PasswordRecovery));
        titleTextView.setText(LocaleController.getString("PasswordCode", R.string.PasswordCode));
        bottomTextView
                .setText(LocaleController.getString("RestoreEmailSentInfo", R.string.RestoreEmailSentInfo));
        bottomButton.setText(LocaleController.formatString("RestoreEmailTrouble", R.string.RestoreEmailTrouble,
                currentPassword.email_unconfirmed_pattern));
        passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
        passwordEditText.setTransformationMethod(null);
        passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE);
        bottomTextView.setVisibility(View.VISIBLE);
        bottomButton.setVisibility(View.VISIBLE);
    }
    passwordEditText.setText("");
}

From source file:android.support.v17.leanback.widget.GuidedActionsStylist.java

private void setupNextImeOptions(EditText edit) {
    if (edit != null) {
        edit.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    }
}

From source file:org.de.jmg.learn._MainActivity.java

public void getVokabel(final boolean showBeds, boolean LoadNext, boolean requestFocusEdWord, boolean DontPrompt)
        throws Exception {

    if (iv != null) {
        iv.setVisibility(View.GONE);
    }/*from w w w.  j a v  a  2  s  .  co  m*/
    if (iv2 != null)
        iv2.setVisibility(View.GONE);
    try {
        if (_btnRight == null)
            return;
        EndEdit(DontPrompt);
        setBtnsEnabled(true);
        if (showBeds && _vok.getIndex() >= 1) {
            _btnRight.setEnabled(true);
            _btnWrong.setEnabled(true);
            _btnEdit.setEnabled(true);
            _btnSkip.setEnabled(true);
            _btnView.setEnabled(true);
        } else {
            _btnRight.setEnabled(false);
            _btnWrong.setEnabled(false);
            if (_vok.getIndex() < 1) {
                _btnEdit.setEnabled(false);
                _btnSkip.setEnabled(false);
                _btnView.setEnabled(false);
            }
        }
        if (LoadNext)
            _vok.setLernIndex((short) (_vok.getLernIndex() + 1));

        View v;
        TextView t;
        String txtBed = getString(R.string.cloze);

        if (showBeds) {
            v = findViewById(R.id.txtMeaning1);
            t = (TextView) v;
            assert t != null;
            t.setText(lib.getSpanableString(_vok.getBedeutung1()));
            txtBed = t.getText().toString();
        }

        v = findViewById(R.id.word);
        t = (TextView) v;
        assert t != null;
        String txtWord = getString(R.string.cloze);
        if (!_vok.reverse || showBeds) {
            t.setText(lib.getSpanableString(_vok.getWort()), TextView.BufferType.SPANNABLE);
            txtWord = t.getText().toString();
            txtWord = replaceClozes(txtWord, txtBed);
            speak(txtWord, _vok.getLangWord(), "word", true);
        } else {
            t.setText("");
        }

        if (_vok.getSprache() == EnumSprachen.Hebrew || _vok.getSprache() == EnumSprachen.Griechisch
                || (_vok.getFontWort().getName().equalsIgnoreCase("Cardo"))) {
            t.setTypeface(_vok.TypefaceCardo);
            _txtedWord.setTypeface(_vok.TypefaceCardo);
        } else {
            t.setTypeface(Typeface.DEFAULT);
            _txtedWord.setTypeface(Typeface.DEFAULT);
        }
        t.scrollTo(0, 0);

        v = findViewById(R.id.Comment);
        t = (TextView) v;
        assert t != null;
        t.setVisibility(View.VISIBLE);

        SpannableString tspanKom = lib.getSpanableString(_vok.getKommentar());
        URLSpan[] urlSpans = tspanKom.getSpans(0, tspanKom.length(), URLSpan.class);
        for (final URLSpan span : urlSpans) {
            int start = tspanKom.getSpanStart(span);
            int end = tspanKom.getSpanEnd(span);
            String txt = tspanKom.toString().substring(start, end);
            if (txtIsPicture(txt)) {
                tspanKom.removeSpan(span);
                tspanKom.setSpan(new urlclickablespan(span.getURL()) {
                    @Override
                    public void onClick(View widget) {
                        Bitmap b;
                        try {
                            b = lib.downloadpicture(this.url);
                        } catch (Exception ex) {
                            b = null;
                        }
                        if (b != null) {
                            if (iv == null) {
                                iv = new ImageView(context);
                                SetTouchListener(iv);
                            }
                            b = resizeBM(b);
                            iv.setImageBitmap(b);
                            if (iv.getParent() == null) {
                                try {
                                    LayoutParams p = _txtMeaning1.getLayoutParams();
                                    //p.width = LayoutParams.WRAP_CONTENT;
                                    //p.height = LayoutParams.WRAP_CONTENT;
                                    rellayoutMain.addView(iv, p);
                                } catch (Exception ex) {
                                    Log.e("addImageView", ex.getMessage(), ex);
                                }
                            } else {
                                Log.d("ImageView", "exists");
                            }
                            _txtMeaning1.setVisibility(View.GONE);
                            iv.setVisibility(View.VISIBLE);
                        }
                    }
                }, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
            }
        }
        t.setText(tspanKom, TextView.BufferType.SPANNABLE);

        if (_vok.getSprache() == EnumSprachen.Hebrew || _vok.getSprache() == EnumSprachen.Griechisch
                || (_vok.getFontKom().getName().equalsIgnoreCase("Cardo"))) {
            t.setTypeface(_vok.TypefaceCardo);
            _txtedKom.setTypeface(_vok.TypefaceCardo);
        } else {
            t.setTypeface(Typeface.DEFAULT);
            _txtedKom.setTypeface(Typeface.DEFAULT);
        }
        if (_isSmallDevice && libString.IsNullOrEmpty(t.getText().toString())) {
            t.setVisibility(View.GONE);
        } else {
            t.setVisibility(View.VISIBLE);
        }
        t.scrollTo(0, 0);

        v = findViewById(R.id.txtMeaning1);
        t = (TextView) v;
        assert t != null;
        if (!libString.IsNullOrEmpty(_vok.getBedeutung2())) {
            t.setImeOptions(EditorInfo.IME_ACTION_NEXT);
        }
        if (_vok.reverse || showBeds) {
            SpannableString tspan = lib.getSpanableString(_vok.getBedeutung1());
            //final String picname = _main.getString(R.string.picture);
            t.setVisibility(View.VISIBLE);
            if (txtIsPicture(tspan.toString())) {
                URLSpan urlspn[] = tspan.getSpans(0, tspan.length(), URLSpan.class);
                for (URLSpan url : urlspn) {
                    Bitmap b;
                    try {
                        b = lib.downloadpicture(url.getURL());
                    } catch (Exception ex) {
                        b = null;
                    }
                    if (b != null) {
                        if (iv == null) {
                            iv = new ImageView(context);
                            SetTouchListener(iv);
                        }
                        b = resizeBM(b);
                        iv.setImageBitmap(b);
                        if (iv.getParent() == null) {
                            try {
                                LayoutParams p = t.getLayoutParams();
                                //p.width = LayoutParams.WRAP_CONTENT;
                                //p.height = LayoutParams.WRAP_CONTENT;
                                rellayoutMain.addView(iv, p);
                            } catch (Exception ex) {
                                Log.e("Imagview", ex.getMessage(), ex);
                            }
                        } else {
                            Log.d("ImageView", "exists");
                        }
                        t.setVisibility(View.GONE);
                        iv.setVisibility(View.VISIBLE);
                    }
                }

            } else {
                // iv.setVisibility(View.GONE);
                t.setVisibility(View.VISIBLE);
            }

            t.setText(tspan);
        } else {
            t.setText(Vokabel.getComment(_vok.getBedeutung1()));
        }
        if (_vok.reverse || showBeds) {
            String txt = t.getText().toString();
            txt = replaceClozes(txt, txtWord);
            speak(txt, _vok.getLangMeaning(), "meaning1", _vok.reverse);
        }
        if (_vok.getFontBed().getName().equalsIgnoreCase("Cardo")) {
            t.setTypeface(_vok.TypefaceCardo);
        } else {
            t.setTypeface(Typeface.DEFAULT);
        }
        t.setOnFocusChangeListener(FocusListenerMeaning1);
        t.scrollTo(0, 0);

        v = findViewById(R.id.txtMeaning2);
        t = (TextView) v;
        assert t != null;
        t.setText((_vok.reverse || showBeds ? _vok.getBedeutung2() : Vokabel.getComment(_vok.getBedeutung2())));
        if (_vok.getFontBed().getName().equalsIgnoreCase("Cardo")) {
            t.setTypeface(_vok.TypefaceCardo);
        } else {
            t.setTypeface(Typeface.DEFAULT);
        }
        if (libString.IsNullOrEmpty(_vok.getBedeutung2()) || _vok.getCardMode()) {
            t.setVisibility(View.GONE);
            _txtMeaning1.setImeOptions(EditorInfo.IME_ACTION_DONE);
        } else {
            t.setVisibility(View.VISIBLE);
            _txtMeaning1.setImeOptions(EditorInfo.IME_ACTION_NEXT);
            if (_vok.reverse || showBeds) {
                String txt = t.getText().toString();
                //if (txtWord != null)
                //   txt = txt.replaceAll("_{2,}", txtWord).replaceAll("\\.{4,}", txtWord);
                speak(txt, _vok.getLangMeaning(), "meaning2");
            }
        }

        v = findViewById(R.id.txtMeaning3);
        t = (TextView) v;
        assert t != null;
        t.setText((_vok.reverse || showBeds ? _vok.getBedeutung3() : Vokabel.getComment(_vok.getBedeutung3())));
        if (_vok.getFontBed().getName().equalsIgnoreCase("Cardo")) {
            t.setTypeface(_vok.TypefaceCardo);
        } else {
            t.setTypeface(Typeface.DEFAULT);
        }
        if (libString.IsNullOrEmpty(_vok.getBedeutung3()) || _vok.getCardMode()) {
            t.setVisibility(View.GONE);
            _txtMeaning2.setImeOptions(EditorInfo.IME_ACTION_DONE);
        } else {
            t.setVisibility(View.VISIBLE);
            _txtMeaning2.setImeOptions(EditorInfo.IME_ACTION_NEXT);
            _txtMeaning3.setImeOptions(EditorInfo.IME_ACTION_DONE);
            if (_vok.reverse || showBeds) {
                String txt = t.getText().toString();
                //if (txtWord != null)
                //   txt = txt.replaceAll("_{2,}", txtWord).replaceAll("\\.{4,}", txtWord);
                speak(txt, _vok.getLangMeaning(), "meaning3");
            }
        }

        if (_vok.reverse && showBeds)
            speak(txtWord, _vok.getLangWord(), "word");

        lib.setBgEditText(_txtMeaning1, _MeaningBG);
        lib.setBgEditText(_txtMeaning2, _MeaningBG);
        lib.setBgEditText(_txtMeaning3, _MeaningBG);
        if (!_isSmallDevice && !requestFocusEdWord) {
            _txtMeaning1.requestFocus();
        } else {
            if (!requestFocusEdWord)
                _txtWord.requestFocus();
            else
                _txtedWord.requestFocus();
        }
        SetActionBarTitle();

        _scrollView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

            @Override
            public void onGlobalLayout() {

                lib.removeLayoutListener(_scrollView.getViewTreeObserver(), this);
                hideKeyboard();
                if (showBeds) {
                    _scrollView.scrollTo(0, _txtMeaning1.getTop());
                } else {
                    _txtWord.requestFocus();
                    _scrollView.fullScroll(View.FOCUS_UP);
                }
            }
        });

    } catch (Exception e) {

        lib.ShowException(_main, e);
    }

}

From source file:edu.usf.cutr.opentripplanner.android.fragments.MainFragment.java

private void addInterfaceListeners() {

    final OnMapClickListener onMapClickListener = new OnMapClickListener() {
        @Override//from  www. j a  v a  2  s.c o  m
        public void onMapClick(LatLng latlng) {
            InputMethodManager imm = (InputMethodManager) MainFragment.this.getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(mTbEndLocation.getWindowToken(), 0);
            imm.hideSoftInputFromWindow(mTbStartLocation.getWindowToken(), 0);

            if (mTbStartLocation.hasFocus()) {
                setMarker(true, latlng, true);
            } else {
                setMarker(false, latlng, true);
            }
        }
    };
    mMap.setOnMapClickListener(onMapClickListener);

    OnMarkerDragListener onMarkerDragListener = new OnMarkerDragListener() {

        @Override
        public void onMarkerDrag(Marker marker) {
        }

        @Override
        public void onMarkerDragEnd(Marker marker) {
            LatLng markerLatlng = marker.getPosition();

            if (((mOTPApp.getSelectedServer() != null) && LocationUtil.checkPointInBoundingBox(markerLatlng,
                    mOTPApp.getSelectedServer(), OTPApp.CHECK_BOUNDS_ACCEPTABLE_ERROR))
                    || (mOTPApp.getSelectedServer() == null)) {
                if ((mStartMarker != null) && (marker.hashCode() == mStartMarker.hashCode())) {
                    if (mPrefs.getBoolean(OTPApp.PREFERENCE_KEY_USE_INTELLIGENT_MARKERS, true)) {
                        updateMarkerPosition(markerLatlng, true);
                    } else {
                        mIsStartLocationGeocodingCompleted = true;
                        removeFocus(true);
                        setMarker(true, markerLatlng, false);
                    }
                    mStartMarkerPosition = markerLatlng;
                } else if ((mEndMarker != null) && (marker.hashCode() == mEndMarker.hashCode())) {
                    if (mPrefs.getBoolean(OTPApp.PREFERENCE_KEY_USE_INTELLIGENT_MARKERS, true)) {
                        updateMarkerPosition(markerLatlng, false);
                    } else {
                        mIsEndLocationGeocodingCompleted = true;
                        removeFocus(false);
                        setMarker(false, markerLatlng, false);
                    }
                    mEndMarkerPosition = markerLatlng;
                }
            } else {

                if ((mStartMarker != null) && (marker.hashCode() == mStartMarker.hashCode())) {
                    marker.setPosition(mStartMarkerPosition);
                } else {
                    marker.setPosition(mEndMarkerPosition);
                }
                Toast.makeText(mApplicationContext,
                        mApplicationContext.getResources().getString(
                                R.string.toast_map_markers_marker_out_of_boundaries),
                        Toast.LENGTH_SHORT).show();
            }
        }

        @Override
        public void onMarkerDragStart(Marker marker) {
            InputMethodManager imm = (InputMethodManager) MainFragment.this.getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(mTbEndLocation.getWindowToken(), 0);
            imm.hideSoftInputFromWindow(mTbStartLocation.getWindowToken(), 0);
        }
    };
    mMap.setOnMarkerDragListener(onMarkerDragListener);

    OnMapLongClickListener onMapLongClickListener = new OnMapLongClickListener() {
        @Override
        public void onMapLongClick(LatLng latlng) {
            InputMethodManager imm = (InputMethodManager) MainFragment.this.getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(mTbEndLocation.getWindowToken(), 0);
            imm.hideSoftInputFromWindow(mTbStartLocation.getWindowToken(), 0);

            final LatLng latLngFinal = latlng;
            final CharSequence[] items = {
                    mApplicationContext.getResources()
                            .getString(R.string.point_type_selector_start_marker_option),
                    mApplicationContext.getResources()
                            .getString(R.string.point_type_selector_end_marker_option) };

            AlertDialog.Builder builder = new AlertDialog.Builder(MainFragment.this.getActivity());
            builder.setTitle(getResources().getString(R.string.point_type_selector_title));
            builder.setItems(items, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int item) {
                    if (item == 0) {
                        setMarker(true, latLngFinal, true);
                    } else {
                        setMarker(false, latLngFinal, true);
                    }
                }
            });
            AlertDialog alert = builder.create();
            alert.show();
        }
    };
    mMap.setOnMapLongClickListener(onMapLongClickListener);

    OnClickListener onClickListener = new OnClickListener() {

        @Override
        public void onClick(View v) {
            mDrawerLayout.openDrawer(Gravity.LEFT);
        }
    };
    mBtnHandle.setOnClickListener(onClickListener);

    OnInfoWindowClickListener onInfoWindowClickListener = new OnInfoWindowClickListener() {

        @Override
        public void onInfoWindowClick(Marker modeMarker) {
            saveOTPBundle();
            OTPBundle otpBundle = getFragmentListener().getOTPBundle();
            Matcher matcher = Pattern.compile("\\d+").matcher(modeMarker.getTitle());
            if (matcher.find()) {
                String numberString = modeMarker.getTitle().substring(0, matcher.end());
                //Step indexes shown to the user are in a scale starting by 1 but instructions steps internally start by 0
                int currentStepIndex = Integer.parseInt(numberString) - 1;
                otpBundle.setCurrentStepIndex(currentStepIndex);
                otpBundle.setFromInfoWindow(true);
                getFragmentListener().setOTPBundle(otpBundle);
                getFragmentListener().onSwitchedToDirectionFragment();
            }

        }
    };
    mMap.setOnInfoWindowClickListener(onInfoWindowClickListener);

    DrawerListener dl = new DrawerListener() {
        @Override
        public void onDrawerStateChanged(int arg0) {
        }

        @Override
        public void onDrawerSlide(View arg0, float arg1) {

            InputMethodManager imm = (InputMethodManager) MainFragment.this.getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(mTbEndLocation.getWindowToken(), 0);
            imm.hideSoftInputFromWindow(mTbStartLocation.getWindowToken(), 0);
        }

        @Override
        public void onDrawerOpened(View arg0) {
        }

        @Override
        public void onDrawerClosed(View arg0) {
        }
    };
    mDrawerLayout.setDrawerListener(dl);

    OnTouchListener otlStart = new RightDrawableOnTouchListener(mTbStartLocation) {
        @Override
        public boolean onDrawableTouch(final MotionEvent event) {

            final CharSequence[] items = {
                    getResources().getString(R.string.text_box_dialog_location_type_current_location),
                    getResources().getString(R.string.text_box_dialog_location_type_contact),
                    getResources().getString(R.string.text_box_dialog_location_type_map_point) };

            AlertDialog.Builder builder = new AlertDialog.Builder(MainFragment.this.getActivity());
            builder.setTitle(getResources().getString(R.string.text_box_dialog_choose_location_type_start));
            builder.setItems(items, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int item) {
                    if (items[item].equals(getResources()
                            .getString(R.string.text_box_dialog_location_type_current_location))) {
                        LatLng mCurrentLatLng = getLastLocation();
                        if (mCurrentLatLng != null) {
                            SharedPreferences.Editor prefsEditor = mPrefs.edit();
                            setTextBoxLocation(getResources().getString(R.string.text_box_my_location), true);
                            prefsEditor.putBoolean(OTPApp.PREFERENCE_KEY_ORIGIN_IS_MY_LOCATION, true);

                            if (mStartMarker != null) {
                                mStartMarker.remove();
                                mStartMarker = null;
                            }

                            prefsEditor.commit();
                        } else {
                            Toast.makeText(MainFragment.this.mApplicationContext,
                                    mApplicationContext.getResources()
                                            .getString(R.string.toast_tripplanner_current_location_error),
                                    Toast.LENGTH_LONG).show();
                        }

                    } else if (items[item]
                            .equals(getResources().getString(R.string.text_box_dialog_location_type_contact))) {
                        Intent intent = new Intent(Intent.ACTION_PICK);
                        intent.setType(ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_TYPE);
                        ((MyActivity) MainFragment.this.getActivity()).setButtonStartLocation(true);

                        MainFragment.this.getActivity().startActivityForResult(intent,
                                OTPApp.CHOOSE_CONTACT_REQUEST_CODE);

                    } else { // Point on Map
                        if (mStartMarker != null) {
                            updateMarkerPosition(mStartMarker.getPosition(), true);
                        } else {
                            setTextBoxLocation("", true);
                            mTbStartLocation
                                    .setHint(getResources().getString(R.string.text_box_need_to_place_marker));
                            mTbStartLocation.requestFocus();
                        }
                    }
                }
            });
            AlertDialog alert = builder.create();
            alert.show();
            return true;
        }

    };

    mTbStartLocation.setOnTouchListener(otlStart);

    OnTouchListener otlEnd = new RightDrawableOnTouchListener(mTbEndLocation) {
        @Override
        public boolean onDrawableTouch(final MotionEvent event) {

            final CharSequence[] items = {
                    getResources().getString(R.string.text_box_dialog_location_type_current_location),
                    getResources().getString(R.string.text_box_dialog_location_type_contact),
                    getResources().getString(R.string.text_box_dialog_location_type_map_point) };

            AlertDialog.Builder builder = new AlertDialog.Builder(MainFragment.this.getActivity());
            builder.setTitle(getResources().getString(R.string.text_box_dialog_choose_location_type_end));
            builder.setItems(items, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int item) {
                    if (items[item].equals(getResources()
                            .getString(R.string.text_box_dialog_location_type_current_location))) {
                        LatLng mCurrentLatLng = getLastLocation();
                        if (mCurrentLatLng != null) {
                            SharedPreferences.Editor prefsEditor = mPrefs.edit();
                            setTextBoxLocation(getResources().getString(R.string.text_box_my_location), false);
                            prefsEditor.putBoolean(OTPApp.PREFERENCE_KEY_DESTINATION_IS_MY_LOCATION, true);

                            if (mEndMarker != null) {
                                mEndMarker.remove();
                                mEndMarker = null;
                            }

                            prefsEditor.commit();
                        } else {
                            Toast.makeText(MainFragment.this.mApplicationContext,
                                    mApplicationContext.getResources()
                                            .getString(R.string.toast_tripplanner_current_location_error),
                                    Toast.LENGTH_LONG).show();
                        }

                    } else if (items[item]
                            .equals(getResources().getString(R.string.text_box_dialog_location_type_contact))) {
                        Intent intent = new Intent(Intent.ACTION_PICK);
                        intent.setType(ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_TYPE);
                        ((MyActivity) MainFragment.this.getActivity()).setButtonStartLocation(false);

                        MainFragment.this.getActivity().startActivityForResult(intent,
                                OTPApp.CHOOSE_CONTACT_REQUEST_CODE);

                    } else { // Point on Map
                        if (mEndMarker != null) {
                            updateMarkerPosition(mEndMarker.getPosition(), false);
                        } else {
                            setTextBoxLocation("", false);
                            mTbEndLocation
                                    .setHint(getResources().getString(R.string.text_box_need_to_place_marker));
                            mTbEndLocation.requestFocus();
                        }
                    }
                }
            });
            AlertDialog alert = builder.create();
            alert.show();
            return true;
        }

    };

    mTbEndLocation.setOnTouchListener(otlEnd);

    mBtnPlanTrip.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            processRequestTrip();
        }
    });

    OnFocusChangeListener tbLocationOnFocusChangeListener = new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {

            if (hasFocus) {
                mMap.setOnMapClickListener(onMapClickListener);
            }

            TextView tv = (TextView) v;
            if (!hasFocus) {
                CharSequence tvCharSequence = tv.getText();

                if (tvCharSequence != null) {
                    String text = tvCharSequence.toString();

                    if (!TextUtils.isEmpty(text)) {
                        if (v.getId() == R.id.tbStartLocation && !mIsStartLocationGeocodingCompleted
                                && !mPrefs.getBoolean(OTPApp.PREFERENCE_KEY_ORIGIN_IS_MY_LOCATION, true)) {
                            processAddress(true, text, false);
                        } else if (v.getId() == R.id.tbEndLocation && !mIsEndLocationGeocodingCompleted
                                && !mPrefs.getBoolean(OTPApp.PREFERENCE_KEY_DESTINATION_IS_MY_LOCATION, true)) {
                            processAddress(false, text, false);
                        }
                    } else {
                        if (v.getId() == R.id.tbStartLocation) {
                            tv.setHint(getResources().getString(R.string.text_box_start_location_hint));
                        } else if (v.getId() == R.id.tbEndLocation) {
                            tv.setHint(getResources().getString(R.string.text_box_end_location_hint));
                        }
                    }
                } else {
                    Log.w(OTPApp.TAG,
                            "Focus has changed, but was not possible to obtain start/end" + " textbox text");
                }
            }
        }
    };
    mTbStartLocation.setOnFocusChangeListener(tbLocationOnFocusChangeListener);
    mTbEndLocation.setOnFocusChangeListener(tbLocationOnFocusChangeListener);

    TextWatcher textWatcherStart = new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (mIsStartLocationChangedByUser) {
                SharedPreferences.Editor prefsEditor = mPrefs.edit();
                prefsEditor.putBoolean(OTPApp.PREFERENCE_KEY_ORIGIN_IS_MY_LOCATION, false);
                prefsEditor.commit();
                mIsStartLocationGeocodingCompleted = false;
            } else {
                mIsStartLocationChangedByUser = true;
            }
        }
    };

    TextWatcher textWatcherEnd = new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable s) {
            if (mIsEndLocationChangedByUser) {
                SharedPreferences.Editor prefsEditor = mPrefs.edit();
                prefsEditor.putBoolean(OTPApp.PREFERENCE_KEY_DESTINATION_IS_MY_LOCATION, false);
                prefsEditor.commit();
                mIsEndLocationGeocodingCompleted = false;
            } else {
                mIsEndLocationChangedByUser = true;
            }
        }
    };

    mTbStartLocation.addTextChangedListener(textWatcherStart);
    mTbEndLocation.addTextChangedListener(textWatcherEnd);

    OnEditorActionListener tbLocationOnEditorActionListener = new OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (v.getId() == R.id.tbStartLocation) {
                if (actionId == EditorInfo.IME_ACTION_NEXT
                        || (event != null && event.getAction() == KeyEvent.ACTION_DOWN
                                && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
                    if (!mIsStartLocationGeocodingCompleted
                            && !mPrefs.getBoolean(OTPApp.PREFERENCE_KEY_ORIGIN_IS_MY_LOCATION, true)) {
                        CharSequence tvCharSequence = v.getText();
                        if (tvCharSequence != null) {
                            processAddress(true, tvCharSequence.toString(), false);
                        } else {
                            Log.w(OTPApp.TAG, "User switched to next input, but was not possible to"
                                    + "obtain start/end textbox text");
                        }
                    }
                }
            } else if (v.getId() == R.id.tbEndLocation) {
                if (actionId == EditorInfo.IME_ACTION_DONE
                        || (event != null && event.getAction() == KeyEvent.ACTION_DOWN
                                && event.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
                    processRequestTrip();
                }
            }
            return false;
        }
    };

    mTbStartLocation.setOnEditorActionListener(tbLocationOnEditorActionListener);
    mTbEndLocation.setOnEditorActionListener(tbLocationOnEditorActionListener);

    OnClickListener oclDisplayDirection = new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            saveOTPBundle();
            getFragmentListener().onSwitchedToDirectionFragment();
        }
    };
    mBtnDisplayDirection.setOnClickListener(oclDisplayDirection);

    // Do NOT show direction icon if there is no direction yet
    toggleItinerarySelectionSpinner(!getFragmentListener().getCurrentItinerary().isEmpty());

    OnClickListener oclMyLocation = new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            LatLng mCurrentLatLng = getLastLocation();

            if (mCurrentLatLng == null) {
                Toast.makeText(mApplicationContext, mApplicationContext.getResources()
                        .getString(R.string.toast_tripplanner_current_location_error), Toast.LENGTH_LONG)
                        .show();
            } else {
                if (mMap.getCameraPosition().zoom < OTPApp.defaultMyLocationZoomLevel) {
                    mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mCurrentLatLng,
                            OTPApp.defaultMyLocationZoomLevel));
                } else {
                    mMap.animateCamera(CameraUpdateFactory.newLatLng(getLastLocation()));
                }
            }
        }
    };
    mBtnMyLocation.setOnClickListener(oclMyLocation);

    OnClickListener oclDateDialog = new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            FragmentTransaction ft = MainFragment.this.getActivity().getSupportFragmentManager()
                    .beginTransaction();
            Fragment prev = MainFragment.this.getActivity().getSupportFragmentManager()
                    .findFragmentByTag(OTPApp.TAG_FRAGMENT_DATE_TIME_DIALOG);
            if (prev != null) {
                ft.remove(prev);
            }
            ft.addToBackStack(null);

            // Create and show the dialog.
            DateTimeDialog newFragment = new DateTimeDialog();

            Date dateDialogDate;
            if (mTripDate == null) {
                dateDialogDate = Calendar.getInstance().getTime();
            } else {
                dateDialogDate = mTripDate;
            }

            Bundle bundle = new Bundle();
            bundle.putSerializable(OTPApp.BUNDLE_KEY_TRIP_DATE, dateDialogDate);
            bundle.putBoolean(OTPApp.BUNDLE_KEY_ARRIVE_BY, mArriveBy);
            newFragment.setArguments(bundle);
            ft.commit();

            newFragment.show(MainFragment.this.getActivity().getSupportFragmentManager(),
                    OTPApp.TAG_FRAGMENT_DATE_TIME_DIALOG);
        }
    };
    mBtnDateDialog.setOnClickListener(oclDateDialog);

    AdapterView.OnItemSelectedListener itinerarySpinnerListener = new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            mFragmentListener.onItinerarySelected(position);

            if (!mAppResumed) {
                showRouteOnMap(mFragmentListener.getCurrentItinerary(), true);
            } else {
                showRouteOnMap(mFragmentListener.getCurrentItinerary(), false);
                mAppResumed = false;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    };
    int currentItineraryIndex = mFragmentListener.getCurrentItineraryIndex();

    mItinerarySelectionSpinner.setSelection(currentItineraryIndex);
    mItinerarySelectionSpinner.setOnItemSelectedListener(itinerarySpinnerListener);

    mBikeTriangleParameters.setOnRangeSeekBarChangeListener(new OnRangeSeekBarChangeListener<Double>() {
        @Override
        public void onRangeSeekBarValuesChanged(RangeSeekBar<?> rangeSeekBar, Double minValue,
                Double maxValue) {
            // handle changed range values
            Log.i(OTPApp.TAG, "User selected new range values: MIN=" + minValue + ", MAX=" + maxValue);
        }

    });

    mDdlTravelMode.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            TraverseModeSpinnerItem traverseModeSpinnerItem = (TraverseModeSpinnerItem) mDdlTravelMode
                    .getItemAtPosition(position);
            if (traverseModeSpinnerItem != null) {
                if (traverseModeSpinnerItem.getTraverseModeSet().contains(TraverseMode.BICYCLE)) {
                    setBikeOptimizationAdapter(true);
                    showBikeParameters(true);
                } else {
                    setBikeOptimizationAdapter(false);
                    showBikeParameters(false);
                }

                mBtnPlanTrip.setImageBitmap(BitmapFactory.decodeResource(getResources(),
                        DirectionsGenerator.getModeIcon(traverseModeSpinnerItem.getTraverseModeSet())));
            }
            Log.e(OTPApp.TAG, "Not possible to change travel mode because traverse mode is unknown"
                    + "for selected transport medium");
        }
    });

    mDdlOptimization.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            OptimizeSpinnerItem optimizeSpinnerItem = (OptimizeSpinnerItem) mDdlOptimization
                    .getItemAtPosition(position);
            if (optimizeSpinnerItem != null) {
                showBikeParameters(optimizeSpinnerItem.getOptimizeType().equals(OptimizeType.TRIANGLE));
            } else {
                Log.e(OTPApp.TAG, "Not possible to change optimization mode because selected"
                        + "optimization is unknown");
            }
        }
    });

    mBikeTriangleParameters.setOnRangeSeekBarChangeListener(this);
}

From source file:org.cm.podd.report.activity.ReportActivity.java

@Override
public boolean onSoftKeyAction(TextView view, int actionId, KeyEvent event) {
    switch (actionId) {
    case EditorInfo.IME_ACTION_NEXT:
        Log.d(TAG, "action NEXT");
        View nextTextView = view.focusSearch(View.FOCUS_DOWN);
        if (nextTextView != null) {
            nextTextView.requestFocus();
            if (!(nextTextView instanceof EditText)) {
                hideKeyboard();//from  w  ww  . j av a 2  s .  c o  m
            }
            return true;
        }
    case EditorInfo.IME_ACTION_DONE:
        Log.d(TAG, "action DONE");
        nextScreen();
        hideKeyboard();
        return true;
    }
    return false;
}

From source file:org.de.jmg.learn._MainActivity.java

void StartEdit() throws Exception {
    _txtWord.setText(lib.getSpanableString(_vok.getWort()), TextView.BufferType.SPANNABLE);
    _txtWord.setVisibility(View.GONE);
    _txtKom.setVisibility(View.GONE);
    _txtedWord.setVisibility(View.VISIBLE);
    _txtedWord.setText(_txtWord.getText());
    /*//from ww  w  .  j  a v  a  2s .com
    if (_vok.getSprache() == EnumSprachen.Hebrew)
    {
       try
       {
    lib.setLocale(context, "he");
       }
       catch (Exception ex)
       {
    try
    {
       lib.setLocale(context, "iw");
    }
    catch (Exception eex)
    {
       lib.ShowException(_main,eex);
    }
       }
    }
    */
    _txtedWord.setTextSize(TypedValue.COMPLEX_UNIT_PX, _txtWord.getTextSize());
    View LayWord = findViewById(R.id.LayWord);
    assert LayWord != null;
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) LayWord.getLayoutParams();
    params.width = LayoutParams.MATCH_PARENT;
    LayWord.setLayoutParams(params);
    _txtedKom.setVisibility(View.VISIBLE);
    _txtedKom.setText(_vok.getKommentar());
    _txtedKom.setTextSize(TypedValue.COMPLEX_UNIT_PX, _txtKom.getTextSize());
    _txtedWord.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    _txtedKom.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    _txtedWord.setSingleLine(false);
    _txtedWord.setMaxLines(3);
    _txtedKom.setSingleLine(false);
    _txtedKom.setMaxLines(3);
    if (!_vok.getCardMode()) {
        _txtMeaning1.setImeOptions(EditorInfo.IME_ACTION_NEXT);
        _txtMeaning2.setVisibility(View.VISIBLE);
        _txtMeaning2.setImeOptions(EditorInfo.IME_ACTION_NEXT);
        _txtMeaning3.setVisibility(View.VISIBLE);
        _txtMeaning3.setImeOptions(EditorInfo.IME_ACTION_DONE);
        _txtMeaning2.setText(_vok.getBedeutung2());
        _txtMeaning3.setText(_vok.getBedeutung3());
        lib.setBgEditText(_txtMeaning1, _MeaningBG);
        lib.setBgEditText(_txtMeaning2, _MeaningBG);
        lib.setBgEditText(_txtMeaning3, _MeaningBG);
        _txtMeaning1.setLines(1);
        _txtMeaning1.setSingleLine();
        _txtMeaning2.setLines(1);
        _txtMeaning2.setSingleLine();
        _txtMeaning3.setLines(1);
        _txtMeaning3.setSingleLine();

    } else {
        lib.setBgEditText(_txtMeaning1, _MeaningBG);
        _txtMeaning1.setImeOptions(EditorInfo.IME_ACTION_DONE);
        //_originalMovementmethod = _txtMeaning1.getMovementMethod();
        //_txtMeaning1.setAutoLinkMask(0);
        if (_originalMovementmethod != null
                && _txtMeaning1.getMovementMethod() == LinkMovementMethod.getInstance()) {
            _txtMeaning1.setMovementMethod(_originalMovementmethod);
        }
        //_txtMeaning1.requestFocus();
        //InputMethodManager Imn = (InputMethodManager) _main.getSystemService(Context.INPUT_METHOD_SERVICE);
        //Imn.showSoftInputFromInputMethod(_txtMeaning1.getWindowToken(), 0);
    }
    //_txtMeaning1.setInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    _txtMeaning1.setText(_vok.getBedeutung1());
    setBtnsEnabled(false);
    _btnEdit.setEnabled(true);
    _txtMeaning1.clearFocus();
    _txtedWord.clearFocus();
    //_txtedWord.requestFocusFromTouch();
    _txtedWord.requestFocus();
    mainView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @Override
        public void onGlobalLayout() {
            lib.removeLayoutListener(mainView.getViewTreeObserver(), this);
            _txtedWord.requestFocus();
        }
    });
}

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 ww. j  a v a2  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:// w  w  w.java  2  s  .co  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 "";
    }
}