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:org.lol.reddit.activities.CaptchaActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    PrefsUtility.applyTheme(this);
    getSupportActionBar().setTitle(R.string.post_captcha_title);

    super.onCreate(savedInstanceState);

    final LoadingView loadingView = new LoadingView(this, R.string.download_waiting, true, true);
    setContentView(loadingView);//from ww w.  j av a2 s .co  m

    final RedditAccount selectedAccount = RedditAccountManager.getInstance(this)
            .getAccount(getIntent().getStringExtra("username"));

    final CacheManager cm = CacheManager.getInstance(this);

    RedditAPI.newCaptcha(cm, new APIResponseHandler.NewCaptchaResponseHandler(this) {
        @Override
        protected void onSuccess(final String captchaId) {

            final URI captchaUrl = Constants.Reddit.getUri("/captcha/" + captchaId);

            cm.makeRequest(new CacheRequest(captchaUrl, RedditAccountManager.getAnon(), null,
                    Constants.Priority.CAPTCHA, 0, CacheRequest.DownloadType.FORCE, Constants.FileType.CAPTCHA,
                    false, false, true, CaptchaActivity.this) {
                @Override
                protected void onCallbackException(Throwable t) {
                    BugReportActivity.handleGlobalError(CaptchaActivity.this, t);
                }

                @Override
                protected void onDownloadNecessary() {
                }

                @Override
                protected void onDownloadStarted() {
                    loadingView.setIndeterminate(R.string.download_downloading);
                }

                @Override
                protected void onFailure(RequestFailureType type, Throwable t, StatusLine status,
                        String readableMessage) {
                    final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type, t,
                            status, url.toString());
                    General.showResultDialog(CaptchaActivity.this, error);
                    finish();
                }

                @Override
                protected void onProgress(long bytesRead, long totalBytes) {
                    loadingView.setProgress(R.string.download_downloading,
                            (float) ((double) bytesRead / (double) totalBytes));
                }

                @Override
                protected void onSuccess(final CacheManager.ReadableCacheFile cacheFile, long timestamp,
                        UUID session, boolean fromCache, String mimetype) {

                    final Bitmap image;
                    try {
                        image = BitmapFactory.decodeStream(cacheFile.getInputStream());
                    } catch (IOException e) {
                        BugReportActivity.handleGlobalError(CaptchaActivity.this, e);
                        return;
                    }

                    General.UI_THREAD_HANDLER.post(new Runnable() {
                        public void run() {

                            final LinearLayout ll = new LinearLayout(CaptchaActivity.this);
                            ll.setOrientation(LinearLayout.VERTICAL);

                            final ImageView captchaImg = new ImageView(CaptchaActivity.this);
                            ll.addView(captchaImg);
                            final LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) captchaImg
                                    .getLayoutParams();
                            layoutParams.setMargins(20, 20, 20, 20);
                            layoutParams.height = General.dpToPixels(context, 100);
                            captchaImg.setScaleType(ImageView.ScaleType.FIT_CENTER);

                            final EditText captchaText = new EditText(CaptchaActivity.this);
                            ll.addView(captchaText);
                            ((LinearLayout.LayoutParams) captchaText.getLayoutParams()).setMargins(20, 0, 20,
                                    20);
                            captchaText.setInputType(android.text.InputType.TYPE_CLASS_TEXT
                                    | android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
                                    | InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);

                            captchaImg.setImageBitmap(image);

                            final Button submitButton = new Button(CaptchaActivity.this);
                            submitButton.setText(R.string.post_captcha_submit_button);
                            ll.addView(submitButton);
                            ((LinearLayout.LayoutParams) submitButton.getLayoutParams()).setMargins(20, 0, 20,
                                    20);
                            ((LinearLayout.LayoutParams) submitButton
                                    .getLayoutParams()).gravity = Gravity.RIGHT;
                            ((LinearLayout.LayoutParams) submitButton
                                    .getLayoutParams()).width = LinearLayout.LayoutParams.WRAP_CONTENT;

                            submitButton.setOnClickListener(new View.OnClickListener() {
                                public void onClick(View v) {
                                    final Intent result = new Intent();
                                    result.putExtra("captchaId", captchaId);
                                    result.putExtra("captchaText", captchaText.getText().toString());
                                    setResult(RESULT_OK, result);
                                    finish();
                                }
                            });

                            final ScrollView sv = new ScrollView(CaptchaActivity.this);
                            sv.addView(ll);
                            setContentView(sv);
                        }
                    });

                }
            });
        }

        @Override
        protected void onCallbackException(Throwable t) {
            BugReportActivity.handleGlobalError(CaptchaActivity.this, t);
        }

        @Override
        protected void onFailure(RequestFailureType type, Throwable t, StatusLine status,
                String readableMessage) {
            final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type, t, status,
                    null);
            General.showResultDialog(CaptchaActivity.this, error);
            finish();
        }

        @Override
        protected void onFailure(APIFailureType type) {
            final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type);
            General.showResultDialog(CaptchaActivity.this, error);
            finish();
        }
    }, selectedAccount, this);
}

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

private void populateFirstForm(LinearLayout formLayout) {
    formLayout.addView(createTitle(mContext.getString(R.string.account_create_full_name_title)));

    EditText nameEditText = createEditText(mContext.getString(R.string.account_create_full_name_hint),
            InputType.TYPE_CLASS_TEXT, EditorInfo.IME_ACTION_NEXT, false, FULL_NAME_KEY);

    if (mFormData.get(FULL_NAME_KEY) != null) {
        nameEditText.setText(mFormData.get(FULL_NAME_KEY));
    }/*from   ww  w  . j a v  a 2 s .c  om*/

    formLayout.addView(nameEditText);
    formLayout.addView(createErrorView(FULL_NAME_KEY));

    formLayout.addView(createTitle(mContext.getString(R.string.account_create_email_title)));

    EditText emailEditText = createEditText(mContext.getString(R.string.account_create_email_hint),
            InputType.TYPE_CLASS_TEXT, EditorInfo.IME_ACTION_NEXT, true, EMAIL_KEY);

    if (mFormData.get(EMAIL_KEY) != null) {
        emailEditText.setText(mFormData.get(EMAIL_KEY));
    }

    formLayout.addView(emailEditText);
    formLayout.addView(createErrorView(EMAIL_KEY));
}

From source file:org.kontalk.ui.MainActivity.java

private void askForPersonalName() {
    new MaterialDialog.Builder(this).content(R.string.msg_no_name).positiveText(android.R.string.ok)
            .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME)
            .input(R.string.hint_validation_name, 0, false, new MaterialDialog.InputCallback() {
                @Override//from  w w w.  ja  va 2s.c  o  m
                public void onInput(MaterialDialog dialog, CharSequence input) {
                    // no key pair found, generate a new one
                    if (BuildConfig.DEBUG) {
                        Toast.makeText(MainActivity.this, R.string.msg_generating_keypair, Toast.LENGTH_LONG)
                                .show();
                    }

                    String name = input.toString();

                    // upgrade account
                    proceedXmppUpgrade(name);
                }
            }).onNegative(new MaterialDialog.SingleButtonCallback() {
                @Override
                public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction dialogAction) {
                    dialog.cancel();
                }
            }).negativeText(android.R.string.cancel).cancelListener(new DialogInterface.OnCancelListener() {
                public void onCancel(DialogInterface dialog) {
                    new MaterialDialog.Builder(MainActivity.this).title(R.string.title_no_personal_key)
                            .content(R.string.msg_no_personal_key).positiveText(android.R.string.ok).show();
                }
            }).show();
}

From source file:pl.wasat.smarthma.ui.frags.base.BaseCollectionDetailsFragment.java

private AutoCompleteTextView resolvePattern(AutoCompleteTextView autoTextView, String pattern) {
    if (pattern == null) {
        autoTextView.setInputType(InputType.TYPE_CLASS_TEXT);
        return autoTextView;
    } else if (pattern.equalsIgnoreCase("[0-9]+")) {
        autoTextView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
        return autoTextView;
    } else if (pattern.equalsIgnoreCase(
            "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?(Z|[\\+\\-][0-9]{2}:[0-9]{2})$")) {
        autoTextView.setInputType(InputType.TYPE_CLASS_DATETIME);
        return autoTextView;
    } else if (pattern.equalsIgnoreCase(
            "(\\[|\\])(100|[0-9]\\d?),(100|[0-9]\\d?)(\\[|\\])|(\\[|\\])?(100|[0-9]\\d?)|(100|[0-9]\\d?)(\\[|\\])?|\\{(100|[0-9]\\d?),(100|[0-9]\\d?)\\}")) {
        //autoTextView.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_NUMBER_FLAG_SIGNED);
        autoTextView.setKeyListener(new PatternNumberKeyListener());
        return autoTextView;
    } else if (pattern.equalsIgnoreCase(
            "(\\[|\\])[0-9]+,[0-9]+(\\[|\\])|(\\[|\\])?[0-9]+|[0-9]+(\\[|\\])?|\\{[0-9]+,[0-9]+\\}")) {
        autoTextView.setKeyListener(new PatternNumberKeyListener());
        return autoTextView;
    } else if (pattern.equalsIgnoreCase(
            "(\\[|\\])[0-9]+(.[0-9]+)?,[0-9]+(.[0-9]+)?(\\[|\\])|(\\[|\\])?[0-9]+(.[0-9]+)?|[0-9]+(.[0-9]+)?(\\[|\\])?|\\{[0-9]+(.[0-9]+)?,[0-9]+(.[0-9]+)?\\}")) {
        autoTextView.setKeyListener(new PatternNumberKeyListener());
        return autoTextView;
    } else if (pattern.equalsIgnoreCase(
            "(\\[|\\])[0-9]+,[0-9]+(\\[|\\])|(\\[|\\])?[0-9]+|[0-9]+(\\[|\\])?|\\{[0-9]+,[0-9]+\\}")) {
        autoTextView.setKeyListener(new PatternNumberKeyListener());
        return autoTextView;
    }/*from ww w.ja  v a  2  s  .  c  om*/
    return autoTextView;
}

From source file:ru.orangesoftware.financisto.activity.CategorySelector.java

private void initAutoCompleteFilter(final AutoCompleteTextView filterTxt) { // init only after it's toggled
    autoCompleteAdapter = TransactionUtils.createCategoryFilterAdapter(activity, db);
    filterTxt.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS
            | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_FILTER);
    filterTxt.setThreshold(1);// w  w  w.  j  ava2 s .  c om
    filterTxt.setOnFocusChangeListener((view, hasFocus) -> {
        if (hasFocus) {
            filterTxt.setAdapter(requireNonNull(autoCompleteAdapter));
            filterTxt.selectAll();
        }
    });
    filterTxt.setOnItemClickListener((parent, view, position, id) -> {
        activity.onSelectedId(R.id.category, id);
        ToggleButton toggleBtn = (ToggleButton) filterTxt.getTag();
        toggleBtn.performClick();
    });
}

From source file:com.silentcircle.accounts.AccountStep1.java

private void updateVisibility() {
    if (loginSso) {
        mPasswordLayout.setVisibility(View.INVISIBLE);
        mShowPassword.setVisibility(View.INVISIBLE);
        mForgotPassword.setVisibility(View.INVISIBLE);
        mRegisterNew.setVisibility(View.GONE);
        mLoginExisting.setText("Login SSO");
        mUsernameInput.setImeOptions(EditorInfo.IME_ACTION_DONE);
    } else {/*from  w w  w .  ja va 2 s .  c o  m*/
        mPasswordLayout.setVisibility(View.VISIBLE);
        mShowPassword.setVisibility(View.VISIBLE);
        mForgotPassword.setVisibility(View.VISIBLE);
        // FIXME: Uncomment when account creation is enabled
        // mRegisterNew.setVisibility(View.VISIBLE);
        mLoginExisting.setText(mLoginSavedText);
        mUsernameInput.setImeOptions(EditorInfo.IME_ACTION_NEXT);
    }
    // setting input type refreshes keyboard display
    mUsernameInput.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
}

From source file:com.ryan.ryanreader.activities.CaptchaActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    PrefsUtility.applyTheme(this);
    getSupportActionBar().setTitle(R.string.post_captcha_title);

    super.onCreate(savedInstanceState);

    final LoadingView loadingView = new LoadingView(this, R.string.download_waiting, true, true);
    setContentView(loadingView);//from  w ww  . ja  va 2s.c  o  m

    final RedditAccount selectedAccount = RedditAccountManager.getInstance(this)
            .getAccount(getIntent().getStringExtra("username"));

    final CacheManager cm = CacheManager.getInstance(this);

    RedditAPI.newCaptcha(cm, new APIResponseHandler.NewCaptchaResponseHandler(this) {
        @Override
        protected void onSuccess(final String captchaId) {

            final URI captchaUrl = Constants.Reddit.getUri("/captcha/" + captchaId);

            cm.makeRequest(new CacheRequest(captchaUrl, RedditAccountManager.getAnon(), null,
                    Constants.Priority.CAPTCHA, 0, CacheRequest.DownloadType.FORCE, Constants.FileType.CAPTCHA,
                    false, false, true, CaptchaActivity.this) {
                @Override
                protected void onCallbackException(Throwable t) {
                    BugReportActivity.handleGlobalError(CaptchaActivity.this, t);
                }

                @Override
                protected void onDownloadNecessary() {
                }

                @Override
                protected void onDownloadStarted() {
                    loadingView.setIndeterminate(R.string.download_downloading);
                }

                @Override
                protected void onFailure(RequestFailureType type, Throwable t, StatusLine status,
                        String readableMessage) {
                    final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type, t,
                            status);
                    General.showResultDialog(CaptchaActivity.this, error);
                    finish();
                }

                @Override
                protected void onProgress(long bytesRead, long totalBytes) {
                    loadingView.setProgress(R.string.download_downloading,
                            (float) ((double) bytesRead / (double) totalBytes));
                }

                @Override
                protected void onSuccess(final CacheManager.ReadableCacheFile cacheFile, long timestamp,
                        UUID session, boolean fromCache, String mimetype) {

                    final Bitmap image;
                    try {
                        image = BitmapFactory.decodeStream(cacheFile.getInputStream());
                    } catch (IOException e) {
                        BugReportActivity.handleGlobalError(CaptchaActivity.this, e);
                        return;
                    }

                    new Handler(Looper.getMainLooper()).post(new Runnable() {
                        public void run() {

                            final LinearLayout ll = new LinearLayout(CaptchaActivity.this);
                            ll.setOrientation(LinearLayout.VERTICAL);

                            final ImageView captchaImg = new ImageView(CaptchaActivity.this);
                            ll.addView(captchaImg);
                            final LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) captchaImg
                                    .getLayoutParams();
                            layoutParams.setMargins(20, 20, 20, 20);
                            layoutParams.height = General.dpToPixels(context, 100);
                            captchaImg.setScaleType(ImageView.ScaleType.FIT_CENTER);

                            final EditText captchaText = new EditText(CaptchaActivity.this);
                            ll.addView(captchaText);
                            ((LinearLayout.LayoutParams) captchaText.getLayoutParams()).setMargins(20, 0, 20,
                                    20);
                            captchaText.setInputType(android.text.InputType.TYPE_CLASS_TEXT
                                    | android.text.InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
                                    | InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS);

                            captchaImg.setImageBitmap(image);

                            final Button submitButton = new Button(CaptchaActivity.this);
                            submitButton.setText(R.string.post_captcha_submit_button);
                            ll.addView(submitButton);
                            ((LinearLayout.LayoutParams) submitButton.getLayoutParams()).setMargins(20, 0, 20,
                                    20);
                            ((LinearLayout.LayoutParams) submitButton
                                    .getLayoutParams()).gravity = Gravity.RIGHT;
                            ((LinearLayout.LayoutParams) submitButton
                                    .getLayoutParams()).width = LinearLayout.LayoutParams.WRAP_CONTENT;

                            submitButton.setOnClickListener(new View.OnClickListener() {
                                public void onClick(View v) {
                                    final Intent result = new Intent();
                                    result.putExtra("captchaId", captchaId);
                                    result.putExtra("captchaText", captchaText.getText().toString());
                                    setResult(RESULT_OK, result);
                                    finish();
                                }
                            });

                            final ScrollView sv = new ScrollView(CaptchaActivity.this);
                            sv.addView(ll);
                            setContentView(sv);
                        }
                    });

                }
            });
        }

        @Override
        protected void onCallbackException(Throwable t) {
            BugReportActivity.handleGlobalError(CaptchaActivity.this, t);
        }

        @Override
        protected void onFailure(RequestFailureType type, Throwable t, StatusLine status,
                String readableMessage) {
            final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type, t, status);
            General.showResultDialog(CaptchaActivity.this, error);
            finish();
        }

        @Override
        protected void onFailure(APIFailureType type) {
            final RRError error = General.getGeneralErrorForFailure(CaptchaActivity.this, type);
            General.showResultDialog(CaptchaActivity.this, error);
            finish();
        }
    }, selectedAccount, this);
}

From source file:com.androcast.illusion.illusionmod.MainActivity.java

/**
 * Dialog which asks the user to enter his password
 *
 * @param password current encoded password
 *///from  w  w  w. j av a 2  s .c om
private void askPassword(final String password) {
    LinearLayout linearLayout = new LinearLayout(this);
    linearLayout.setOrientation(LinearLayout.VERTICAL);
    linearLayout.setGravity(Gravity.CENTER);
    linearLayout.setPadding(30, 20, 30, 20);

    final AppCompatEditText mPassword = new AppCompatEditText(this);
    mPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    mPassword.setHint(getString(R.string.password));
    linearLayout.addView(mPassword);

    new AlertDialog.Builder(this).setView(linearLayout).setCancelable(false)
            .setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    if (mPassword.getText().toString().equals(Utils.decodeString(password)))
                        new Task().execute();
                    else {
                        Utils.toast(getString(R.string.password_wrong), MainActivity.this);
                        finish();
                    }
                }
            }).show();
}

From source file:jahirfiquitiva.iconshowcase.dialogs.FolderChooserDialog.java

private void createFolder(Context context, final MaterialDialog folderChooserDialog, final String folderPath) {
    new MaterialDialog.Builder(context).title(R.string.new_folder_title).content(R.string.new_folder_content)
            .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME
                    | InputType.TYPE_TEXT_FLAG_CAP_WORDS)
            .positiveText(android.R.string.ok).negativeText(android.R.string.cancel)
            .input(R.string.new_folder_hint, 0, false, new MaterialDialog.InputCallback() {
                @Override/*  www .ja v a  2s.  c  o m*/
                public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
                    File folder = new File(folderPath + File.separator + input.toString());
                    if (!folder.exists()) {
                        //noinspection ResultOfMethodCallIgnored
                        folder.mkdir();
                    }
                    parentContents = listFiles();
                    folderChooserDialog.setItems(getContentsArray());
                }
            }).show();

}