Example usage for android.text InputType TYPE_CLASS_TEXT

List of usage examples for android.text InputType TYPE_CLASS_TEXT

Introduction

In this page you can find the example usage for android.text InputType TYPE_CLASS_TEXT.

Prototype

int TYPE_CLASS_TEXT

To view the source code for android.text InputType TYPE_CLASS_TEXT.

Click Source Link

Document

Class for normal text.

Usage

From source file:sharedcode.turboeditor.activity.MainActivity.java

public void onEvent(EventBusEvents.APreferenceValueWasChanged event) {

    if (event.hasType(EventBusEvents.APreferenceValueWasChanged.Type.THEME_CHANGE)) {
        ThemeUtils.setWindowsBackground(this);
    }//from   w w w  .  j a  v a  2 s .com

    if (event.hasType(WRAP_CONTENT)) {
        if (PreferenceHelper.getWrapContent(this)) {
            horizontalScroll.removeView(mEditor);
            verticalScroll.removeView(horizontalScroll);
            verticalScroll.addView(mEditor);
        } else {
            verticalScroll.removeView(mEditor);
            verticalScroll.addView(horizontalScroll);
            horizontalScroll.addView(mEditor);
        }
    } else if (event.hasType(LINE_NUMERS)) {
        mEditor.disableTextChangedListener();
        mEditor.replaceTextKeepCursor(null, true);
        mEditor.enableTextChangedListener();
        if (PreferenceHelper.getLineNumbers(this)) {
            mEditor.setPadding(
                    EditTextPadding.getPaddingWithLineNumbers(this, PreferenceHelper.getFontSize(this)),
                    EditTextPadding.getPaddingTop(this), 0, 0);
        } else {
            mEditor.setPadding(EditTextPadding.getPaddingWithoutLineNumbers(this),
                    EditTextPadding.getPaddingTop(this), 0, 0);
        }
    } else if (event.hasType(SYNTAX)) {
        mEditor.disableTextChangedListener();
        mEditor.replaceTextKeepCursor(null, true);
        mEditor.enableTextChangedListener();
    } else if (event.hasType(MONOSPACE)) {
        if (PreferenceHelper.getUseMonospace(this))
            mEditor.setTypeface(Typeface.MONOSPACE);
        else
            mEditor.setTypeface(Typeface.DEFAULT);
    } else if (event.hasType(THEME_CHANGE)) {
        if (PreferenceHelper.getLightTheme(this)) {
            mEditor.setTextColor(getResources().getColor(R.color.textColorInverted));
        } else {
            mEditor.setTextColor(getResources().getColor(R.color.textColor));
        }
    } else if (event.hasType(TEXT_SUGGESTIONS) || event.hasType(READ_ONLY)) {
        if (PreferenceHelper.getReadOnly(this)) {
            getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
            mEditor.setReadOnly(true);
        } else {
            getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED);
            mEditor.setReadOnly(false);
            if (PreferenceHelper.getSuggestionActive(this)) {
                mEditor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE
                        | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE);
            } else {
                mEditor.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE
                        | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
                        | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
                        | InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE);
            }
        }
        // sometimes it becomes monospace after setting the input type
        if (PreferenceHelper.getUseMonospace(this))
            mEditor.setTypeface(Typeface.MONOSPACE);
        else
            mEditor.setTypeface(Typeface.DEFAULT);
    } else if (event.hasType(FONT_SIZE)) {
        if (PreferenceHelper.getLineNumbers(this)) {
            mEditor.setPadding(
                    EditTextPadding.getPaddingWithLineNumbers(this, PreferenceHelper.getFontSize(this)),
                    EditTextPadding.getPaddingTop(this), 0, 0);
        } else {
            mEditor.setPadding(EditTextPadding.getPaddingWithoutLineNumbers(this),
                    EditTextPadding.getPaddingTop(this), 0, 0);
        }
        mEditor.setTextSize(PreferenceHelper.getFontSize(this));
    } else if (event.hasType(ENCODING)) {
        String oldEncoding, newEncoding;
        oldEncoding = currentEncoding;
        newEncoding = PreferenceHelper.getEncoding(this);
        try {
            final byte[] oldText = mEditor.getText().toString().getBytes(oldEncoding);
            mEditor.disableTextChangedListener();
            mEditor.replaceTextKeepCursor(new String(oldText, newEncoding), true);
            mEditor.enableTextChangedListener();
            currentEncoding = newEncoding;
        } catch (UnsupportedEncodingException ignored) {
            try {
                final byte[] oldText = mEditor.getText().toString().getBytes(oldEncoding);
                mEditor.disableTextChangedListener();
                mEditor.replaceTextKeepCursor(new String(oldText, "UTF-8"), true);
                mEditor.enableTextChangedListener();
            } catch (UnsupportedEncodingException ignored2) {
            }
        }
    }
}

From source file:com.nickandjerry.dynamiclayoutinflator.DynamicLayoutInflator.java

public static void createViewRunnables() {
    viewRunnables = new HashMap<>(30);
    viewRunnables.put("scaleType", new ViewParamRunnable() {
        @Override//from  w  ww . jav a 2 s .  co m
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof ImageView) {
                ImageView.ScaleType scaleType = ((ImageView) view).getScaleType();
                switch (value.toLowerCase()) {
                case "center":
                    scaleType = ImageView.ScaleType.CENTER;
                    break;
                case "center_crop":
                    scaleType = ImageView.ScaleType.CENTER_CROP;
                    break;
                case "center_inside":
                    scaleType = ImageView.ScaleType.CENTER_INSIDE;
                    break;
                case "fit_center":
                    scaleType = ImageView.ScaleType.FIT_CENTER;
                    break;
                case "fit_end":
                    scaleType = ImageView.ScaleType.FIT_END;
                    break;
                case "fit_start":
                    scaleType = ImageView.ScaleType.FIT_START;
                    break;
                case "fit_xy":
                    scaleType = ImageView.ScaleType.FIT_XY;
                    break;
                case "matrix":
                    scaleType = ImageView.ScaleType.MATRIX;
                    break;
                }
                ((ImageView) view).setScaleType(scaleType);
            }
        }
    });
    viewRunnables.put("orientation", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof LinearLayout) {
                ((LinearLayout) view).setOrientation(
                        value.equals("vertical") ? LinearLayout.VERTICAL : LinearLayout.HORIZONTAL);
            }
        }
    });
    viewRunnables.put("text", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                ((TextView) view).setText(value);
            }
        }
    });
    viewRunnables.put("textSize", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                ((TextView) view).setTextSize(TypedValue.COMPLEX_UNIT_PX,
                        DimensionConverter.stringToDimension(value, view.getResources().getDisplayMetrics()));
            }
        }
    });
    viewRunnables.put("textColor", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                ((TextView) view).setTextColor(parseColor(view, value));
            }
        }
    });
    viewRunnables.put("textStyle", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                int typeFace = Typeface.NORMAL;
                if (value.contains("bold"))
                    typeFace |= Typeface.BOLD;
                else if (value.contains("italic"))
                    typeFace |= Typeface.ITALIC;
                ((TextView) view).setTypeface(null, typeFace);
            }
        }
    });
    viewRunnables.put("textAlignment", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
                int alignment = View.TEXT_ALIGNMENT_TEXT_START;
                switch (value) {
                case "center":
                    alignment = View.TEXT_ALIGNMENT_CENTER;
                    break;
                case "left":
                case "textStart":
                    break;
                case "right":
                case "textEnd":
                    alignment = View.TEXT_ALIGNMENT_TEXT_END;
                    break;
                }
                view.setTextAlignment(alignment);
            } else {
                int gravity = Gravity.LEFT;
                switch (value) {
                case "center":
                    gravity = Gravity.CENTER;
                    break;
                case "left":
                case "textStart":
                    break;
                case "right":
                case "textEnd":
                    gravity = Gravity.RIGHT;
                    break;
                }
                ((TextView) view).setGravity(gravity);
            }
        }
    });
    viewRunnables.put("ellipsize", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                TextUtils.TruncateAt where = TextUtils.TruncateAt.END;
                switch (value) {
                case "start":
                    where = TextUtils.TruncateAt.START;
                    break;
                case "middle":
                    where = TextUtils.TruncateAt.MIDDLE;
                    break;
                case "marquee":
                    where = TextUtils.TruncateAt.MARQUEE;
                    break;
                case "end":
                    break;
                }
                ((TextView) view).setEllipsize(where);
            }
        }
    });
    viewRunnables.put("singleLine", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                ((TextView) view).setSingleLine();
            }
        }
    });
    viewRunnables.put("hint", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof EditText) {
                ((EditText) view).setHint(value);
            }
        }
    });
    viewRunnables.put("inputType", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof TextView) {
                int inputType = 0;
                switch (value) {
                case "textEmailAddress":
                    inputType |= InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
                    break;
                case "number":
                    inputType |= InputType.TYPE_CLASS_NUMBER;
                    break;
                case "phone":
                    inputType |= InputType.TYPE_CLASS_PHONE;
                    break;
                }
                if (inputType > 0)
                    ((TextView) view).setInputType(inputType);
            }
        }
    });
    viewRunnables.put("gravity", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            int gravity = parseGravity(value);
            if (view instanceof TextView) {
                ((TextView) view).setGravity(gravity);
            } else if (view instanceof LinearLayout) {
                ((LinearLayout) view).setGravity(gravity);
            } else if (view instanceof RelativeLayout) {
                ((RelativeLayout) view).setGravity(gravity);
            }
        }
    });
    viewRunnables.put("src", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            if (view instanceof ImageView) {
                String imageName = value;
                if (imageName.startsWith("//"))
                    imageName = "http:" + imageName;
                if (imageName.startsWith("http")) {
                    if (imageLoader != null) {
                        if (attrs.containsKey("cornerRadius")) {
                            int radius = DimensionConverter.stringToDimensionPixelSize(
                                    attrs.get("cornerRadius"), view.getResources().getDisplayMetrics());
                            imageLoader.loadRoundedImage((ImageView) view, imageName, radius);
                        } else {
                            imageLoader.loadImage((ImageView) view, imageName);
                        }
                    }
                } else if (imageName.startsWith("@drawable/")) {
                    imageName = imageName.substring("@drawable/".length());
                    ((ImageView) view).setImageDrawable(getDrawableByName(view, imageName));
                }
            }
        }
    });
    viewRunnables.put("visibility", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            int visibility = View.VISIBLE;
            String visValue = value.toLowerCase();
            if (visValue.equals("gone"))
                visibility = View.GONE;
            else if (visValue.equals("invisible"))
                visibility = View.INVISIBLE;
            view.setVisibility(visibility);
        }
    });
    viewRunnables.put("clickable", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            view.setClickable(value.equals("true"));
        }
    });
    viewRunnables.put("tag", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            // Sigh, this is dangerous because we use tags for other purposes
            if (view.getTag() == null)
                view.setTag(value);
        }
    });
    viewRunnables.put("onClick", new ViewParamRunnable() {
        @Override
        public void apply(View view, String value, ViewGroup parent, Map<String, String> attrs) {
            view.setOnClickListener(getClickListener(parent, value));
        }
    });
}

From source file:onion.chat.MainActivity.java

void changeName() {
    final FrameLayout view = new FrameLayout(this);
    final EditText editText = new EditText(this);
    editText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(32) });
    editText.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    editText.setSingleLine();/*from w  w w .j  a  va2  s .c om*/
    editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME
            | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    view.addView(editText);
    int padding = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            getResources().getDisplayMetrics());
    ;
    view.setPadding(padding, padding, padding, padding);
    editText.setText(db.getName());
    new AlertDialog.Builder(this).setTitle(R.string.title_change_alias).setView(view)
            .setPositiveButton(R.string.apply, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    db.setName(editText.getText().toString().trim());
                    update();
                    snack(getString(R.string.snack_alias_changed));
                }
            }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            }).show();
}

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

private void openThemeCreate() {
    final EditTextBoldCursor editText = new EditTextBoldCursor(getParentActivity());
    editText.setBackgroundDrawable(Theme.createEditTextDrawable(getParentActivity(), true));

    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
    builder.setTitle(LocaleController.getString("NewTheme", R.string.NewTheme));
    builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialog, which) -> {

    });//from  w ww .j a  v  a 2  s  .  c  om

    LinearLayout linearLayout = new LinearLayout(getParentActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    builder.setView(linearLayout);

    final TextView message = new TextView(getParentActivity());
    message.setText(LocaleController.formatString("EnterThemeName", R.string.EnterThemeName));
    message.setTextSize(16);
    message.setPadding(AndroidUtilities.dp(23), AndroidUtilities.dp(12), AndroidUtilities.dp(23),
            AndroidUtilities.dp(6));
    message.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    linearLayout.addView(message,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT));

    editText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    editText.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    editText.setMaxLines(1);
    editText.setLines(1);
    editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
    editText.setGravity(Gravity.LEFT | Gravity.TOP);
    editText.setSingleLine(true);
    editText.setImeOptions(EditorInfo.IME_ACTION_DONE);
    editText.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    editText.setCursorSize(AndroidUtilities.dp(20));
    editText.setCursorWidth(1.5f);
    editText.setPadding(0, AndroidUtilities.dp(4), 0, 0);
    linearLayout.addView(editText,
            LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, Gravity.TOP | Gravity.LEFT, 24, 6, 24, 0));
    editText.setOnEditorActionListener((textView, i, keyEvent) -> {
        AndroidUtilities.hideKeyboard(textView);
        return false;
    });
    final AlertDialog alertDialog = builder.create();
    alertDialog.setOnShowListener(dialog -> AndroidUtilities.runOnUIThread(() -> {
        editText.requestFocus();
        AndroidUtilities.showKeyboard(editText);
    }));
    showDialog(alertDialog);
    alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(v -> {
        if (editText.length() == 0) {
            Vibrator vibrator = (Vibrator) ApplicationLoader.applicationContext
                    .getSystemService(Context.VIBRATOR_SERVICE);
            if (vibrator != null) {
                vibrator.vibrate(200);
            }
            AndroidUtilities.shakeView(editText, 2, 0);
            return;
        }
        ThemeEditorView themeEditorView = new ThemeEditorView();
        String name = editText.getText().toString() + ".attheme";
        themeEditorView.show(getParentActivity(), name);
        Theme.saveCurrentTheme(name, true);
        updateRows();
        alertDialog.dismiss();

        SharedPreferences preferences = MessagesController.getGlobalMainSettings();
        if (preferences.getBoolean("themehint", false)) {
            return;
        }
        preferences.edit().putBoolean("themehint", true).commit();
        try {
            Toast.makeText(getParentActivity(),
                    LocaleController.getString("CreateNewThemeHelp", R.string.CreateNewThemeHelp),
                    Toast.LENGTH_LONG).show();
        } catch (Exception e) {
            FileLog.e(e);
        }
    });
}

From source file:io.github.vomitcuddle.SearchViewAllowEmpty.SearchView.java

/**
 * Updates the auto-complete text view./*from ww w . j ava  2s  . com*/
 */
private void updateSearchAutoComplete() {
    mQueryTextView.setThreshold(mSearchable.getSuggestThreshold());
    mQueryTextView.setImeOptions(mSearchable.getImeOptions());
    int inputType = mSearchable.getInputType();
    // We only touch this if the input type is set up for text (which it almost certainly
    // should be, in the case of search!)
    if ((inputType & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT) {
        // The existence of a suggestions authority is the proxy for "suggestions
        // are available here"
        inputType &= ~InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
        if (mSearchable.getSuggestAuthority() != null) {
            inputType |= InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
            // TYPE_TEXT_FLAG_AUTO_COMPLETE means that the text editor is performing
            // auto-completion based on its own semantics, which it will present to the user
            // as they type. This generally means that the input method should not show its
            // own candidates, and the spell checker should not be in action. The text editor
            // supplies its candidates by calling InputMethodManager.displayCompletions(),
            // which in turn will call InputMethodSession.displayCompletions().
            inputType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        }
    }
    mQueryTextView.setInputType(inputType);
    if (mSuggestionsAdapter != null) {
        mSuggestionsAdapter.changeCursor(null);
    }
    // attach the suggestions adapter, if suggestions are available
    // The existence of a suggestions authority is the proxy for "suggestions available here"
    if (mSearchable.getSuggestAuthority() != null) {
        mSuggestionsAdapter = new SuggestionsAdapter(getContext(), this, mSearchable, mOutsideDrawablesCache);
        mQueryTextView.setAdapter(mSuggestionsAdapter);
        ((SuggestionsAdapter) mSuggestionsAdapter).setQueryRefinement(
                mQueryRefinement ? SuggestionsAdapter.REFINE_ALL : SuggestionsAdapter.REFINE_BY_ENTRY);
    }
}

From source file:cw.kop.autobackground.settings.WearSettingsFragment.java

private void showDigitalSeparatorOptions() {
    String[] titles = new String[] { "Separator", "Separator Color", "Separator Shadow Color" };
    String[] summaries = new String[] { "Text to separate time sections", "Color of separator",
            "Color of separator shadow" };
    int[] icons = new int[] { R.drawable.ic_text_format_white_24dp, R.drawable.ic_color_lens_white_24dp,
            R.drawable.ic_color_lens_white_24dp };
    ArrayList<OptionData> optionsList = new ArrayList<>();

    for (int index = 0; index < titles.length; index++) {
        optionsList.add(new OptionData(titles[index], summaries[index], icons[index]));
    }/*from ww w  . j  a v a 2s  .c o m*/

    final RecyclerViewListClickListener listener = new RecyclerViewListClickListener() {
        @Override
        public void onClick(int position, String title, int drawable) {

            switch (position) {
            case 0:
                DialogFactory.InputDialogListener separatorTextDialogListener = new DialogFactory.InputDialogListener() {
                    @Override
                    public void onClickRight(View v) {
                        AppSettings.setDigitalSeparatorText(getEditTextString());
                        redraw();
                        this.dismissDialog();
                    }
                };

                DialogFactory.showInputDialog(appContext, "Enter separator text", "",
                        AppSettings.getDigitalSeparatorText(), separatorTextDialogListener, -1,
                        R.string.cancel_button, R.string.ok_button, InputType.TYPE_CLASS_TEXT);
                break;
            case 1:
                DialogFactory.ColorDialogListener separatorColorDialogListener = new DialogFactory.ColorDialogListener() {
                    @Override
                    public void onClickRight(View v) {
                        AppSettings.setDigitalSeparatorColor(getColorPickerView().getColor());
                        redraw();
                        this.dismissDialog();
                    }
                };

                DialogFactory.showColorPickerDialog(appContext, "Enter separator color:",
                        separatorColorDialogListener, -1, R.string.cancel_button, R.string.ok_button,
                        AppSettings.getDigitalSeparatorColor());
                break;
            case 2:
                DialogFactory.ColorDialogListener separatorShadowColorDialogListener = new DialogFactory.ColorDialogListener() {
                    @Override
                    public void onClickRight(View v) {
                        AppSettings.setDigitalSeparatorShadowColor(getColorPickerView().getColor());
                        redraw();
                        this.dismissDialog();
                    }
                };

                DialogFactory.showColorPickerDialog(appContext, "Enter separator shadow color:",
                        separatorShadowColorDialogListener, -1, R.string.cancel_button, R.string.ok_button,
                        AppSettings.getDigitalSeparatorShadowColor());
                break;
            }

        }
    };

    OptionsListAdapter titlesAdapter = new OptionsListAdapter(appContext, optionsList, -1, listener);

    recyclerView.setAdapter(titlesAdapter);
}

From source file:android.support.v7.widget.SearchView.java

/**
 * Updates the auto-complete text view.//from  w ww .  j  av a  2s  . co  m
 */
@TargetApi(Build.VERSION_CODES.FROYO)
private void updateSearchAutoComplete() {
    mSearchSrcTextView.setThreshold(mSearchable.getSuggestThreshold());
    mSearchSrcTextView.setImeOptions(mSearchable.getImeOptions());
    int inputType = mSearchable.getInputType();
    // We only touch this if the input type is set up for text (which it almost certainly
    // should be, in the case of search!)
    if ((inputType & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT) {
        // The existence of a suggestions authority is the proxy for "suggestions
        // are available here"
        inputType &= ~InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
        if (mSearchable.getSuggestAuthority() != null) {
            inputType |= InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
            // TYPE_TEXT_FLAG_AUTO_COMPLETE means that the text editor is performing
            // auto-completion based on its own semantics, which it will present to the user
            // as they type. This generally means that the input method should not show its
            // own candidates, and the spell checker should not be in action. The text editor
            // supplies its candidates by calling InputMethodManager.displayCompletions(),
            // which in turn will call InputMethodSession.displayCompletions().
            inputType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        }
    }
    mSearchSrcTextView.setInputType(inputType);
    if (mSuggestionsAdapter != null) {
        mSuggestionsAdapter.changeCursor(null);
    }
    // attach the suggestions adapter, if suggestions are available
    // The existence of a suggestions authority is the proxy for "suggestions available here"
    if (mSearchable.getSuggestAuthority() != null) {
        mSuggestionsAdapter = new SuggestionsAdapter(getContext(), this, mSearchable, mOutsideDrawablesCache);
        mSearchSrcTextView.setAdapter(mSuggestionsAdapter);
        ((SuggestionsAdapter) mSuggestionsAdapter).setQueryRefinement(
                mQueryRefinement ? SuggestionsAdapter.REFINE_ALL : SuggestionsAdapter.REFINE_BY_ENTRY);
    }
}

From source file:org.woltage.irssiconnectbot.ConsoleActivity.java

/**
 * Show any prompts requested by the currently visible {@link TerminalView}.
 *//*from www . jav a 2  s .c  om*/
protected void updatePromptVisible() {
    // check if our currently-visible terminalbridge is requesting any
    // prompt services
    View view = findCurrentView(R.id.console_flip);

    // Hide all the prompts in case a prompt request was canceled
    hideAllPrompts();

    if (!(view instanceof TerminalView)) {
        // we dont have an active view, so hide any prompts
        return;
    }

    PromptHelper prompt = ((TerminalView) view).bridge.promptHelper;
    if (String.class.equals(prompt.promptRequested)) {
        stringPromptGroup.setVisibility(View.VISIBLE);

        String instructions = prompt.promptInstructions;
        boolean password = prompt.passwordRequested;
        if (instructions != null && instructions.length() > 0) {
            stringPromptInstructions.setVisibility(View.VISIBLE);
            stringPromptInstructions.setText(instructions);
        } else
            stringPromptInstructions.setVisibility(View.GONE);

        if (password) {
            stringPrompt.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
            stringPrompt.setTransformationMethod(PasswordTransformationMethod.getInstance());
        } else {
            stringPrompt.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
            stringPrompt.setTransformationMethod(SingleLineTransformationMethod.getInstance());
        }

        stringPrompt.setText("");
        stringPrompt.setHint(prompt.promptHint);
        stringPrompt.requestFocus();

    } else if (Boolean.class.equals(prompt.promptRequested)) {
        booleanPromptGroup.setVisibility(View.VISIBLE);
        booleanPrompt.setText(prompt.promptHint);
        booleanYes.requestFocus();

    } else {
        hideAllPrompts();
        view.requestFocus();
    }
}

From source file:cm.aptoide.com.actionbarsherlock.widget.SearchView.java

/**
 * Updates the auto-complete text view.//w ww.jav a2  s.  c o m
 */
private void updateSearchAutoComplete() {
    // TODO mQueryTextView.setDropDownAnimationStyle(0); // no animation
    mQueryTextView.setThreshold(mSearchable.getSuggestThreshold());
    mQueryTextView.setImeOptions(mSearchable.getImeOptions());
    int inputType = mSearchable.getInputType();
    // We only touch this if the input type is set up for text (which it almost certainly
    // should be, in the case of search!)
    if ((inputType & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT) {
        // The existence of a suggestions authority is the proxy for "suggestions
        // are available here"
        inputType &= ~InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
        if (mSearchable.getSuggestAuthority() != null) {
            inputType |= InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
            // TYPE_TEXT_FLAG_AUTO_COMPLETE means that the text editor is performing
            // auto-completion based on its own semantics, which it will present to the user
            // as they type. This generally means that the input method should not show its
            // own candidates, and the spell checker should not be in action. The text editor
            // supplies its candidates by calling InputMethodManager.displayCompletions(),
            // which in turn will call InputMethodSession.displayCompletions().
            inputType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        }
    }
    mQueryTextView.setInputType(inputType);
    if (mSuggestionsAdapter != null) {
        mSuggestionsAdapter.changeCursor(null);
    }
    // attach the suggestions adapter, if suggestions are available
    // The existence of a suggestions authority is the proxy for "suggestions available here"
    if (mSearchable.getSuggestAuthority() != null) {
        mSuggestionsAdapter = new SuggestionsAdapter(getContext(), this, mSearchable, mOutsideDrawablesCache);
        mQueryTextView.setAdapter(mSuggestionsAdapter);
        ((SuggestionsAdapter) mSuggestionsAdapter).setQueryRefinement(
                mQueryRefinement ? SuggestionsAdapter.REFINE_ALL : SuggestionsAdapter.REFINE_BY_ENTRY);
    }
}

From source file:com.example.navigationsearchview.NavigationSearchView.java

/**
 * Updates the auto-complete text view./* www  .  j  a  v a2 s .c o  m*/
 */
@TargetApi(Build.VERSION_CODES.FROYO)
private void updateSearchAutoComplete() {
    mSearchSrcTextView.setThreshold(mSearchable.getSuggestThreshold());
    mSearchSrcTextView.setImeOptions(mSearchable.getImeOptions());
    int inputType = mSearchable.getInputType();
    // We only touch this if the input type is set up for text (which it
    // almost certainly
    // should be, in the case of search!)
    if ((inputType & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT) {
        // The existence of a suggestions authority is the proxy for
        // "suggestions
        // are available here"
        inputType &= ~InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
        if (mSearchable.getSuggestAuthority() != null) {
            inputType |= InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
            // TYPE_TEXT_FLAG_AUTO_COMPLETE means that the text editor is
            // performing
            // auto-completion based on its own semantics, which it will
            // present to the user
            // as they type. This generally means that the input method
            // should not show its
            // own candidates, and the spell checker should not be in
            // action. The text editor
            // supplies its candidates by calling
            // InputMethodManager.displayCompletions(),
            // which in turn will call
            // InputMethodSession.displayCompletions().
            inputType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
        }
    }
    mSearchSrcTextView.setInputType(inputType);
    if (mSuggestionsAdapter != null) {
        mSuggestionsAdapter.changeCursor(null);
    }
    // attach the suggestions adapter, if suggestions are available
    // The existence of a suggestions authority is the proxy for
    // "suggestions available here"
    if (mSearchable.getSuggestAuthority() != null) {
        mSuggestionsAdapter = new SuggestionsAdapter(getContext(), this, mSearchable, mOutsideDrawablesCache);
        mSearchSrcTextView.setAdapter(mSuggestionsAdapter);
        ((SuggestionsAdapter) mSuggestionsAdapter).setQueryRefinement(
                mQueryRefinement ? SuggestionsAdapter.REFINE_ALL : SuggestionsAdapter.REFINE_BY_ENTRY);
    }
}