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.xingjitong.ChatFragment.java

@SuppressLint("Recycle")
@SuppressWarnings("static-access")
@Override//from  w  w  w. j  a v a 2  s .co m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    SharedPreferences share = PreferenceManager.getDefaultSharedPreferences(getActivity());
    if (share.getInt(getString(R.string.setting_reg_uid), 0) == 0) {
        Toast.makeText(getActivity(), "!?,?!",
                Toast.LENGTH_LONG).show();
        getActivity().getSupportFragmentManager().popBackStack();
    }
    String displayName = getArguments().getString("DisplayName");
    String pictureUri = getArguments().getString("PictureUri");

    sipUri = getArguments().getString("SipUri");
    sipUri = sipUri.substring(sipUri.indexOf(":") + 1, sipUri.indexOf("@"));

    try {
        LinphoneAddress address = LinphoneManager.getInstance().getLc().interpretUrl(sipUri);
        sipUri = address.asString();
        sipUri = sipUri.replace("<", "").replace(">", "");
    } catch (LinphoneCoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    view = inflater.inflate(R.layout.chat, container, false);

    contactName = (TextView) view.findViewById(R.id.contactName);
    contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture);

    sendMessage = (TextView) view.findViewById(R.id.sendMessage);
    sendMessage.setOnClickListener(this);

    message = (EditText) view.findViewById(R.id.message);
    if (!getActivity().getResources().getBoolean(R.bool.allow_chat_multiline)) {
        message.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE);
        message.setMaxLines(1);
    }

    uploadLayout = (RelativeLayout) view.findViewById(R.id.uploadLayout);
    textLayout = (RelativeLayout) view.findViewById(R.id.messageLayout);

    messagesLayout = (RelativeLayout) view.findViewById(R.id.messages);
    messagesScrollView = (ScrollView) view.findViewById(R.id.chatScrollView);
    progressBar = (ProgressBar) view.findViewById(R.id.progressbar);

    sendImage = (TextView) view.findViewById(R.id.sendPicture);
    registerForContextMenu(sendImage);
    sendImage.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            pickImage();
        }
    });

    cancelUpload = (ImageView) view.findViewById(R.id.cancelUpload);
    cancelUpload.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            uploadThread.interrupt();
            uploadLayout.setVisibility(View.GONE);
            textLayout.setVisibility(View.VISIBLE);
            progressBar.setProgress(0);
        }
    });

    displayChat(displayName, pictureUri);

    LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
    if (lc != null) {
        chatRoom = lc.createChatRoom(sipUri);
    }

    // SharedPreferences prefs =
    // PreferenceManager.getDefaultSharedPreferences(LinphoneActivity.instance());
    // uploadServerUri =
    // prefs.getString(getString(R.string.pref_image_sharing_server_key),
    // getString(R.string.pref_image_sharing_server_default));
    uploadServerUri = getString(R.string.pref_image_sharing_server_default);

    textWatcher = new TextWatcher() {
        public void afterTextChanged(Editable arg0) {

        }

        public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {

        }

        public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) {
            if (message.getText().toString().equals("")) {
                sendMessage.setEnabled(false);
            } else {
                sendMessage.setEnabled(true);
            }
        }
    };

    // Force hide keyboard
    if (LinphoneActivity.isInstanciated()) {
        InputMethodManager imm = (InputMethodManager) LinphoneActivity.instance()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }

    // Workaround for SGS3 issue
    if (savedInstanceState != null) {
        fileToUploadPath = savedInstanceState.getString("fileToUploadPath");
        imageToUpload = savedInstanceState.getParcelable("imageToUpload");
    }
    if (fileToUploadPath != null || imageToUpload != null) {
        sendImage.post(new Runnable() {
            @Override
            public void run() {
                sendImage.showContextMenu();
            }
        });
    }

    return view;
}

From source file:com.github.andrewlord1990.materialandroid.component.textfield.PasswordEditText.java

private void setPasswordInputType() {
    if (passwordVisible) {
        setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
    } else {//w w  w  . ja  v a 2  s  .c o m
        setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    }
}

From source file:nl.hnogames.domoticz.NFCSettingsActivity.java

@Override
protected void onNewIntent(Intent intent) {
    if (intent.getAction().equals(NfcAdapter.ACTION_TAG_DISCOVERED) && !busyWithTag) {
        boolean newTagFound = true;
        busyWithTag = true;//from www.  ja  v  a  2s. c  om
        final String tagID = UsefulBits.ByteArrayToHexString(intent.getByteArrayExtra(NfcAdapter.EXTRA_ID));
        if (nfcList != null && nfcList.size() > 0) {
            for (NFCInfo n : nfcList) {
                if (n.getId().equals(tagID))
                    newTagFound = false;
            }
        }

        if (newTagFound) {
            UsefulBits.showSnackbar(this, coordinatorLayout, getString(R.string.nfc_tag_found) + ": " + tagID,
                    Snackbar.LENGTH_SHORT);
            new MaterialDialog.Builder(this).title(R.string.nfc_tag_found).content(R.string.nfc_tag_name)
                    .inputType(InputType.TYPE_CLASS_TEXT)
                    .input(R.string.category_nfc, 0, new MaterialDialog.InputCallback() {
                        @Override
                        public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
                            if (!UsefulBits.isEmpty(String.valueOf(input))) {
                                UsefulBits.showSnackbar(NFCSettingsActivity.this, coordinatorLayout,
                                        getString(R.string.nfc_saved) + ": " + input, Snackbar.LENGTH_SHORT);
                                NFCInfo newNFC = new NFCInfo();
                                newNFC.setId(tagID);
                                newNFC.setName(String.valueOf(input));
                                updateNFC(newNFC);
                            }
                            busyWithTag = false;
                        }
                    }).show();
        } else {
            UsefulBits.showSnackbar(NFCSettingsActivity.this, coordinatorLayout, R.string.nfc_exists,
                    Snackbar.LENGTH_SHORT);
            busyWithTag = false;
        }
    }
}

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

private void populateSecondForm(LinearLayout formLayout) {
    formLayout.addView(createTitle(mContext.getString(R.string.account_create_password_title)));
    EditText passwordEditText = createEditText(mContext.getString(R.string.account_create_password_hint),
            InputType.TYPE_CLASS_TEXT, EditorInfo.IME_ACTION_DONE, false, PASSWORD_KEY);
    passwordEditText.setTransformationMethod(new PasswordTransformationMethod());

    formLayout.addView(passwordEditText);
    formLayout.addView(createErrorView(PASSWORD_KEY));

    formLayout.addView(createTitle(mContext.getString(R.string.account_create_gender_title)));
    Spinner spinner = new Spinner(mContext);
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT);//  w  ww  .ja va2 s. co  m
    params.bottomMargin = 17;
    spinner.setLayoutParams(params);

    final ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mContext, R.array.sexes_array,
            android.R.layout.simple_spinner_item);
    spinner.setAdapter(adapter);
    spinner.setPrompt(mContext.getString(R.string.account_create_sex_spinner_prompt));
    spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {

            mFormData.put(GENDER_KEY, adapter.getItem(pos).toString());
        }

        @Override
        public void onNothingSelected(AdapterView<?> arg0) {
        }
    });

    if (mFormData.get(GENDER_KEY) != null) {
        spinner.setSelection(adapter.getPosition(mFormData.get(GENDER_KEY)));
    }

    formLayout.addView(spinner);

}

From source file:org.zeroxlab.momome.impl.MainActivity.java

private void askForPassword() {
    String msg = super.getString(R.string.main_dialog_unlock);
    if (!MomoApp.getModel().internalFileExists()) {
        Log.d(TAG, "not exist?");
        msg = super.getString(R.string.main_dialog_init);
    }/*from   w ww  . ja va  2 s  .c  o  m*/

    BasicInputDialog dialog = new BasicInputDialog(this, msg);
    dialog.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    dialog.setListener(DIALOG_PASSWORD, mDialogListener);
    dialog.show();
}

From source file:co.carlosandresjimenez.android.gotit.AddCheckInFragment.java

public void changeQuestion() {
    if (questionNumber > questionPosition) {
        currentQuestion = getQuestionAt(questionPosition);
        questionPosition++;//from w  ww . java 2s.  c o  m

        if (currentQuestion == null) {
            return;
        }

        mTvAnswer.setText("");
        mTvAnswer.setFocusableInTouchMode(true);

        if (currentQuestion.getAnswerType().equals("checkbox")) {
            mTvAnswer.setVisibility(View.GONE);
            mCbAnswer.setVisibility(View.VISIBLE);
        } else {
            mTvAnswer.setVisibility(View.VISIBLE);
            mCbAnswer.setVisibility(View.GONE);

            switch (currentQuestion.getAnswerType()) {
            case "time":
                mTvAnswer.setFocusable(false);
                Utility.hideSoftKeyboard(getActivity(), mTvAnswer);
                break;
            case "numeric":
                mTvAnswer.setInputType(InputType.TYPE_CLASS_NUMBER);
                break;
            default:
                mTvAnswer.setInputType(InputType.TYPE_CLASS_TEXT);
            }
        }

        mTvQuestion.setText(currentQuestion.getValue());

        if (questionNumber == questionPosition)
            mBtNextQuestion.setText(getString(R.string.action_save));
    } else {
        saveAnswers();
        showProgressDialog(getString(R.string.progressdialog_saving));
    }
}

From source file:prince.app.ccm.Fragment_Log.java

private void initView(View view) {
    // Set up the login form.
    mUserEditText = (EditText) view.findViewById(R.id.username);
    //   addFocusListener(mUserEditText);

    mPasswordEditText = (EditText) view.findViewById(R.id.password);
    //   addFocusListener(mPasswordEditText);

    mPasswordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
        @Override//  w  w  w.ja  va 2s .c  om
        public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == R.id.user_login || id == EditorInfo.IME_NULL) {
                if (!Tool.getInstance().isConnection())
                    Toast.makeText(getActivity(), "No network connection!", Toast.LENGTH_SHORT).show();
                else {
                    attemptLogin();
                    return true;
                }
            }
            return false;
        }
    });

    mLoginFormView = view.findViewById(R.id.login_form);
    mLoginStatusView = view.findViewById(R.id.login_progress);

    view.findViewById(R.id.sign_in_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
            attemptLogin();
        }
    });

    mRemind = (CheckBox) view.findViewById(R.id.box_remember);
    if (Tool.getInstance().getBolPref(Util.REMIND)) {
        mRemind.setChecked(true);
        mUserEditText.setText("");
        mPasswordEditText.setText("");
        mUserEditText.append(Tool.getInstance().getStringPref(Util.USER));
        mPasswordEditText.append(Tool.getInstance().getStringPref(Util.PASSWORD));
    }

    mShowPassword = (CheckBox) view.findViewById(R.id.box_reveal);
    mShowPassword.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                mPasswordEditText.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
            } else {
                mPasswordEditText
                        .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
            }

            if (mPasswordEditText.hasFocus()) {
                String temp = mPasswordEditText.getText().toString().trim();
                mPasswordEditText.setText("");
                mPasswordEditText.append(temp);
            }

        }

    });
}

From source file:com.auth0.android.lock.views.ValidatedInputView.java

private void setupInputValidation() {
    String hint = "";
    String error = "";
    input.setTransformationMethod(null);
    Log.v(TAG, "Setting up validation for field of type " + dataType);
    switch (dataType) {
    case EMAIL://from  w w w  .jav a 2 s  .c  o  m
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
        inputIcon = R.drawable.com_auth0_lock_ic_email;
        hint = getResources().getString(R.string.com_auth0_lock_hint_email);
        error = getResources().getString(R.string.com_auth0_lock_input_error_email);
        break;
    case PASSWORD:
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        input.setTransformationMethod(PasswordTransformationMethod.getInstance());
        input.setTypeface(Typeface.DEFAULT);
        inputIcon = R.drawable.com_auth0_lock_ic_password;
        hint = getResources().getString(R.string.com_auth0_lock_hint_password);
        error = getResources().getString(R.string.com_auth0_lock_input_error_password);
        break;
    case USERNAME_OR_EMAIL:
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
        inputIcon = R.drawable.com_auth0_lock_ic_username;
        hint = getResources().getString(R.string.com_auth0_lock_hint_username_or_email);
        error = getResources().getString(R.string.com_auth0_lock_input_error_username_email);
        break;
    case TEXT_NAME:
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
        inputIcon = R.drawable.com_auth0_lock_ic_username;
        hint = getResources().getString(R.string.com_auth0_lock_hint_username);
        error = getResources().getString(R.string.com_auth0_lock_input_error_empty);
        break;
    case NON_EMPTY_USERNAME:
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
        inputIcon = R.drawable.com_auth0_lock_ic_username;
        hint = getResources().getString(R.string.com_auth0_lock_hint_username);
        error = getResources().getString(R.string.com_auth0_lock_input_error_username_empty);
        break;
    case USERNAME:
        input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
        inputIcon = R.drawable.com_auth0_lock_ic_username;
        hint = getResources().getString(R.string.com_auth0_lock_hint_username);
        error = String.format(getResources().getString(R.string.com_auth0_lock_input_error_username),
                MIN_USERNAME_LENGTH, MAX_USERNAME_LENGTH);
        break;
    case NUMBER:
        input.setInputType(InputType.TYPE_CLASS_NUMBER);
        inputIcon = R.drawable.com_auth0_lock_ic_password;
        hint = getResources().getString(R.string.com_auth0_lock_hint_code);
        error = getResources().getString(R.string.com_auth0_lock_input_error_empty);
        break;
    case MFA_CODE:
        input.setInputType(InputType.TYPE_CLASS_NUMBER);
        inputIcon = R.drawable.com_auth0_lock_ic_password;
        hint = getResources().getString(R.string.com_auth0_lock_hint_code);
        error = getResources().getString(R.string.com_auth0_lock_input_error_code);
        break;
    case MOBILE_PHONE:
        input.setInputType(InputType.TYPE_CLASS_NUMBER);
        inputIcon = R.drawable.com_auth0_lock_ic_mobile;
        hint = getResources().getString(R.string.com_auth0_lock_hint_phone_number);
        error = getResources().getString(R.string.com_auth0_lock_input_error_phone_number);
        break;
    case PHONE_NUMBER:
        input.setInputType(InputType.TYPE_CLASS_PHONE);
        inputIcon = R.drawable.com_auth0_lock_ic_phone;
        hint = getResources().getString(R.string.com_auth0_lock_hint_phone_number);
        error = getResources().getString(R.string.com_auth0_lock_input_error_phone_number);
        break;
    }
    input.setHint(hint);
    errorDescription.setText(error);
    icon.setImageResource(inputIcon);
}

From source file:org.mifos.androidclient.templates.OperationFormActivity.java

public EditText addTextFormField(String fieldLabel) {
    return addFormField(fieldLabel, InputType.TYPE_CLASS_TEXT);
}