Example usage for android.text InputType TYPE_TEXT_VARIATION_PASSWORD

List of usage examples for android.text InputType TYPE_TEXT_VARIATION_PASSWORD

Introduction

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

Prototype

int TYPE_TEXT_VARIATION_PASSWORD

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

Click Source Link

Document

Variation of #TYPE_CLASS_TEXT : entering a password.

Usage

From source file:nl.hnogames.domoticz.Welcome.WelcomePage3.java

private void getLayoutReferences() {

    remote_server_input = (FloatingLabelEditText) v.findViewById(R.id.remote_server_input);
    remote_port_input = (FloatingLabelEditText) v.findViewById(R.id.remote_port_input);
    remote_username_input = (FloatingLabelEditText) v.findViewById(R.id.remote_username_input);
    remote_password_input = (FloatingLabelEditText) v.findViewById(R.id.remote_password_input);
    remote_directory_input = (FloatingLabelEditText) v.findViewById(R.id.remote_directory_input);
    remote_protocol_spinner = (Spinner) v.findViewById(R.id.remote_protocol_spinner);
    local_server_input = (FloatingLabelEditText) v.findViewById(R.id.local_server_input);
    local_port_input = (FloatingLabelEditText) v.findViewById(R.id.local_port_input);
    local_username_input = (FloatingLabelEditText) v.findViewById(R.id.local_username_input);
    local_password_input = (FloatingLabelEditText) v.findViewById(R.id.local_password_input);
    local_directory_input = (FloatingLabelEditText) v.findViewById(R.id.local_directory_input);
    local_protocol_spinner = (Spinner) v.findViewById(R.id.local_protocol_spinner);
    local_wifi_spinner = (MultiSelectionSpinner) v.findViewById(R.id.local_wifi);
    cbShowPassword = (CheckBox) v.findViewById(R.id.showpassword);
    cbShowPasswordLocal = (CheckBox) v.findViewById(R.id.showpasswordlocal);

    startScreen_spinner = (Spinner) v.findViewById(R.id.startScreen_spinner);
    btnManualSSID = (Button) v.findViewById(R.id.set_ssid);
    btnManualSSID.setOnClickListener(new View.OnClickListener() {
        @Override/* w ww .  j  av a 2  s.c o m*/
        public void onClick(View v) {
            new MaterialDialog.Builder(getContext()).title(R.string.welcome_ssid_button_prompt)
                    .content(R.string.welcome_msg_no_ssid_found)
                    .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD)
                    .input(null, null, new MaterialDialog.InputCallback() {
                        @Override
                        public void onInput(MaterialDialog dialog, CharSequence input) {
                            Set<String> ssidFromPrefs = mServerUtil.getActiveServer().getLocalServerSsid();
                            final ArrayList<String> ssidListFromPrefs = new ArrayList<>();
                            if (ssidFromPrefs != null) {
                                if (ssidFromPrefs.size() > 0) {
                                    for (String wifi : ssidFromPrefs) {
                                        ssidListFromPrefs.add(wifi);
                                    }
                                }
                            }
                            ssidListFromPrefs.add(String.valueOf(input));
                            mServerUtil.getActiveServer().setLocalServerSsid(ssidListFromPrefs);

                            setSsid_spinner();
                        }
                    }).show();
        }
    });

    if (callingInstance == SETTINGS) {
        // Hide these settings if being called by settings (instead of welcome wizard)
        startScreen_spinner.setVisibility(View.GONE);
        v.findViewById(R.id.startScreen_title).setVisibility(View.GONE);
        v.findViewById(R.id.server_settings_title).setVisibility(View.GONE);
    }

    final LinearLayout localServerSettingsLayout = (LinearLayout) v.findViewById(R.id.local_server_settings);
    localServer_switch = (Switch) v.findViewById(R.id.localServer_switch);
    localServer_switch.setChecked(mSharedPrefs.isAdvancedSettingsEnabled());

    localServer_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
            if (checked)
                localServerSettingsLayout.setVisibility(View.VISIBLE);
            else
                localServerSettingsLayout.setVisibility(View.GONE);
        }
    });

    final LinearLayout advancedSettings_layout = (LinearLayout) v.findViewById(R.id.advancedSettings_layout);

    advancedSettings_switch = (Switch) v.findViewById(R.id.advancedSettings_switch);
    advancedSettings_switch.setChecked(mSharedPrefs.isAdvancedSettingsEnabled());

    if (mSharedPrefs.isAdvancedSettingsEnabled())
        advancedSettings_layout.setVisibility(View.VISIBLE);

    advancedSettings_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mSharedPrefs.setAdvancedSettingsEnabled(isChecked);

            if (isChecked)
                advancedSettings_layout.setVisibility(View.VISIBLE);
            else
                advancedSettings_layout.setVisibility(View.GONE);
        }
    });

    cbShowPassword.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (!isChecked) {
                remote_password_input.getInputWidget()
                        .setTransformationMethod(PasswordTransformationMethod.getInstance());
            } else {
                remote_password_input.getInputWidget()
                        .setTransformationMethod(HideReturnsTransformationMethod.getInstance());
            }
        }
    });

    cbShowPasswordLocal.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (!isChecked) {
                local_password_input.getInputWidget()
                        .setTransformationMethod(PasswordTransformationMethod.getInstance());
            } else {
                local_password_input.getInputWidget()
                        .setTransformationMethod(HideReturnsTransformationMethod.getInstance());
            }
        }
    });
}

From source file:org.secuso.privacyfriendlypasswordgenerator.dialogs.GeneratePasswordDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    LayoutInflater inflater = getActivity().getLayoutInflater();
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    rootView = inflater.inflate(R.layout.dialog_generate_password, null);

    Bundle bundle = getArguments();//from w  w w  .j a  v a  2s .  com

    position = bundle.getInt("position");
    clipboard_enabled = bundle.getBoolean("clipboard_enabled");
    bindToDevice_enabled = bundle.getBoolean("bindToDevice_enabled");
    hashAlgorithm = bundle.getString("hash_algorithm");
    number_iterations = bundle.getInt("number_iterations");
    visibility = false;

    spinner = (ProgressBar) rootView.findViewById(R.id.progressBar);
    spinner.setVisibility(View.GONE);

    database = MetaDataSQLiteHelper.getInstance(getActivity());
    metaData = database.getMetaData(position);

    TextView domain = (TextView) rootView.findViewById(R.id.domainHeadingTextView);
    domain.setText(metaData.getDOMAIN());

    TextView username = (TextView) rootView.findViewById(R.id.domainUsernameTextView);

    username.setText(metaData.getUSERNAME());

    TextView iteration = (TextView) rootView.findViewById(R.id.textViewIteration);
    iteration.setText(String.valueOf(metaData.getITERATION()));

    builder.setView(rootView);
    builder.setIcon(R.mipmap.ic_drawer);
    builder.setTitle(getActivity().getString(R.string.generate_heading));
    builder.setPositiveButton(getActivity().getString(R.string.done), null);

    Button generateButton = (Button) rootView.findViewById(R.id.generatorButton);
    generateButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            TextView textViewPassword = (TextView) rootView.findViewById(R.id.textViewPassword);
            textViewPassword.setText("");

            InputMethodManager inputManager = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);

            inputManager.hideSoftInputFromWindow(view.getWindowToken(),
                    InputMethodManager.RESULT_UNCHANGED_SHOWN);

            editTextMasterpassword = (EditText) rootView.findViewById(R.id.editTextMasterpassword);

            if (editTextMasterpassword.getText().toString().length() == 0) {
                Toast toast = Toast.makeText(getActivity().getBaseContext(),
                        getString(R.string.enter_masterpassword), Toast.LENGTH_SHORT);
                toast.show();
            } else if (editTextMasterpassword.getText().toString().length() < 8) {
                Toast toast = Toast.makeText(getActivity().getBaseContext(),
                        getString(R.string.masterpassword_length), Toast.LENGTH_SHORT);
                toast.show();
            } else {

                spinner.setVisibility(View.VISIBLE);

                generatePassword();
            }
        }
    });

    ImageButton copyButton = (ImageButton) rootView.findViewById(R.id.copyButton);

    copyButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            TextView password = (TextView) rootView.findViewById(R.id.textViewPassword);

            if (password.getText().toString().length() > 0) {
                ClipboardManager clipboard = (ClipboardManager) getActivity()
                        .getSystemService(CLIPBOARD_SERVICE);
                ClipData clip = ClipData.newPlainText("", password.getText());
                clipboard.setPrimaryClip(clip);
                Toast.makeText(getActivity(), getActivity().getString(R.string.password_copied),
                        Toast.LENGTH_SHORT).show();
            }

        }
    });

    visibilityButton = (ImageButton) rootView.findViewById(R.id.visibilityButton);

    visibilityButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            editTextMasterpassword = (EditText) rootView.findViewById(R.id.editTextMasterpassword);

            if (!visibility) {
                visibilityButton.setImageResource(R.drawable.ic_visibility_off);
                editTextMasterpassword.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
                editTextMasterpassword.setSelection(editTextMasterpassword.getText().length());
                visibility = true;
            } else {
                visibilityButton.setImageResource(R.drawable.ic_visibility);
                editTextMasterpassword
                        .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
                editTextMasterpassword.setSelection(editTextMasterpassword.getText().length());
                visibility = false;
            }
        }
    });

    return builder.create();
}

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//from www .j a v a2  s.c o  m
        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: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);
    }// w w  w  . ja v  a  2  s .  co 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: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 {//from  w w  w  . j a  v  a2s . c o m
        setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    }
}

From source file:com.alimuzaffar.lib.widgets.PinEntryEditText.java

private void init(Context context, AttributeSet attrs) {
    float multi = context.getResources().getDisplayMetrics().density;
    mLineStroke = multi * mLineStroke;//  w  w w  .j  a  v  a2 s . c o m
    mLineStrokeSelected = multi * mLineStrokeSelected;
    mSpace = multi * mSpace; //convert to pixels for our density
    mTextBottomPadding = multi * mTextBottomPadding; //convert to pixels for our density

    TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.PinEntryEditText, 0, 0);
    try {
        TypedValue outValue = new TypedValue();
        ta.getValue(R.styleable.PinEntryEditText_pinAnimationType, outValue);
        mAnimatedType = outValue.data;
        mMask = ta.getString(R.styleable.PinEntryEditText_pinCharacterMask);
        mLineStroke = ta.getDimension(R.styleable.PinEntryEditText_pinLineStroke, mLineStroke);
        mLineStrokeSelected = ta.getDimension(R.styleable.PinEntryEditText_pinLineStrokeSelected,
                mLineStrokeSelected);
        mSpace = ta.getDimension(R.styleable.PinEntryEditText_pinCharacterSpacing, mSpace);
        mTextBottomPadding = ta.getDimension(R.styleable.PinEntryEditText_pinTextBottomPadding,
                mTextBottomPadding);
        mIsDigitSquare = ta.getBoolean(R.styleable.PinEntryEditText_pinBackgroundIsSquare, mIsDigitSquare);
        mPinBackground = ta.getDrawable(R.styleable.PinEntryEditText_pinBackgroundDrawable);
        ColorStateList colors = ta.getColorStateList(R.styleable.PinEntryEditText_pinLineColors);
        if (colors != null) {
            mColorStates = colors;
        }
    } finally {
        ta.recycle();
    }

    mCharPaint = new Paint(getPaint());
    mLastCharPaint = new Paint(getPaint());
    mLinesPaint = new Paint(getPaint());
    mLinesPaint.setStrokeWidth(mLineStroke);

    TypedValue outValue = new TypedValue();
    context.getTheme().resolveAttribute(R.attr.colorControlActivated, outValue, true);
    int colorSelected = outValue.data;
    mColors[0] = colorSelected;

    int colorFocused = isInEditMode() ? Color.GRAY : ContextCompat.getColor(context, R.color.pin_normal);
    mColors[1] = colorFocused;

    int colorUnfocused = isInEditMode() ? Color.GRAY : ContextCompat.getColor(context, R.color.pin_normal);
    mColors[2] = colorUnfocused;

    setBackgroundResource(0);

    mMaxLength = attrs.getAttributeIntValue(XML_NAMESPACE_ANDROID, "maxLength", 4);
    mNumChars = mMaxLength;

    //Disable copy paste
    super.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
        public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        public void onDestroyActionMode(ActionMode mode) {
        }

        public boolean onCreateActionMode(ActionMode mode, Menu menu) {
            return false;
        }

        public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
            return false;
        }
    });
    // When tapped, move cursor to end of text.
    super.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            setSelection(getText().length());
            if (mClickListener != null) {
                mClickListener.onClick(v);
            }
        }
    });

    super.setOnLongClickListener(new OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            setSelection(getText().length());
            return true;
        }
    });

    //If input type is password and no mask is set, use a default mask
    if ((getInputType() & InputType.TYPE_TEXT_VARIATION_PASSWORD) == InputType.TYPE_TEXT_VARIATION_PASSWORD
            && TextUtils.isEmpty(mMask)) {
        mMask = "\u25CF";
    } else if ((getInputType()
            & InputType.TYPE_NUMBER_VARIATION_PASSWORD) == InputType.TYPE_NUMBER_VARIATION_PASSWORD
            && TextUtils.isEmpty(mMask)) {
        mMask = "\u25CF";
    }

    if (!TextUtils.isEmpty(mMask)) {
        mMaskChars = getMaskChars();
    }

    //Height of the characters, used if there is a background drawable
    getPaint().getTextBounds("|", 0, 1, mTextHeight);
}

From source file:com.simplealertdialog.sample.demos.SampleSupportFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_sample_support, container, false);

    view.findViewById(R.id.btn_frag_message).setOnClickListener(new View.OnClickListener() {
        @Override/*  www .j av a2  s.co m*/
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setMessage("Hello world!")
                    .setPositiveButton(android.R.string.ok).setTargetFragment(SampleSupportFragment.this)
                    .create().show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_message_title).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            TypedArray a = getActivity().getTheme().obtainStyledAttributes(new int[] { R.attr.icon });
            int iconResId = a.getResourceId(0, 0);
            a.recycle();
            new SimpleAlertDialogSupportFragment.Builder().setTitle("Hello world!").setIcon(iconResId)
                    .setMessage("Hello world!").setPositiveButton(android.R.string.ok)
                    .setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_buttons).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setTitle("Hello world!").setMessage("Hello world!")
                    .setPositiveButton(android.R.string.ok).setNegativeButton(android.R.string.cancel)
                    .setRequestCode(REQUEST_CODE_BUTTONS).setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_3_buttons).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setTitle("Hello world!").setMessage("Hello world!")
                    .setPositiveButton(android.R.string.ok).setNeutralButton(R.string.neutral)
                    .setNegativeButton(android.R.string.cancel).setRequestCode(REQUEST_CODE_3_BUTTONS)
                    .setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_items).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setTitle("Choose one")
                    .setItems(R.array.single_choice).setRequestCode(REQUEST_CODE_ITEMS)
                    .setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_icon_items).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setTitle("Choose one")
                    .setItems(R.array.icon_items, getIcons()).setRequestCode(REQUEST_CODE_ICON_ITEMS)
                    .setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_single_choice_list).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setTitle("Choose one").setSingleChoiceCheckedItem(0)
                    .setRequestCode(REQUEST_CODE_SINGLE_CHOICE_LIST)
                    .setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_adapter).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setTitle("Choose your favorite").setUseAdapter(true)
                    .setRequestCode(REQUEST_CODE_ADAPTER).setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_view).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setTitle("Enter something").setUseView(true)
                    .setPositiveButton(android.R.string.ok).setRequestCode(REQUEST_CODE_VIEW)
                    .setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_edit_text).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setTitle("Enter password")
                    .setEditText("", InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD)
                    .setPositiveButton(android.R.string.ok).setRequestCode(REQUEST_CODE_EDIT_TEXT)
                    .setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    view.findViewById(R.id.btn_frag_themed).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(final View v) {
            new SimpleAlertDialogSupportFragment.Builder().setTheme(R.style.SimpleAlertDialogCustomTheme)
                    .setMessage("Hello world!").setPositiveButton(android.R.string.ok)
                    .setTargetFragment(SampleSupportFragment.this).create()
                    .show(getActivity().getSupportFragmentManager(), "dialog");
        }
    });

    return view;
}

From source file:co.beem.project.beem.ui.wizard.AccountConfigureFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.wizard_account_configure, container, false);

    mNextButton = (TextView) v.findViewById(R.id.next);
    mNextButton.setEnabled(false);/*from   w w  w .  ja  va2s .c  o m*/
    mNextButton.setOnClickListener(this);
    mErrorLabel = (TextView) v.findViewById(R.id.error_label);
    mSettingsWarningLabel = (TextView) v.findViewById(R.id.settings_warn_label);
    errorDivider = v.findViewById(R.id.error_divider);
    mAccountJID = (EditText) v.findViewById(R.id.account_username);
    mAccountJID.setOnFocusChangeListener(new OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            isAccountEdtFocused = hasFocus;
        }
    });
    mAccountPassword = (EditText) v.findViewById(R.id.account_password);
    mAccountPassword.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            isPasswordEdtFocused = hasFocus;
        }
    });
    //mAccountJID.setFilters(newFilters);
    mAccountJID.addTextChangedListener(mJidTextWatcher);
    mAccountPassword.addTextChangedListener(mPasswordTextWatcher);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) // true to disable the feature until ready
        v.findViewById(R.id.account_layout).setVisibility(View.GONE);
    mAccountPassword.setImeOptions(EditorInfo.IME_ACTION_DONE);
    mAccountPassword.setOnEditorActionListener(new OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (event != null) {
                if (!event.isShiftPressed()) {
                    onClick(mNextButton);
                    return true;
                }
                return false;
            }
            onClick(mNextButton);
            return true;
        }
    });
    showBtn = (TextView) v.findViewById(R.id.login_show_btn);
    showBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!isPasswordShowing) {
                showBtn.setText(getText(R.string.hide));
                mAccountPassword.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
            } else {
                showBtn.setText(getText(R.string.show));
                mAccountPassword
                        .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
            }
            mAccountPassword.setSelection(mAccountPassword.length());
            isPasswordShowing = !isPasswordShowing;
        }
    });
    createNewAccountButton = (TextView) v.findViewById(R.id.create_new_account);
    createNewAccountButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            ((Account) getActivity()).pushFragment(
                    WebViewFragment.instanciate("https://m.facebook.com/r.php?loc=bottom&refid=8"));
        }
    });
    forgotPasswordTv = (TextView) v.findViewById(R.id.forgot_password_tv);
    forgotPasswordTv.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            ((Account) getActivity()).pushFragment(
                    WebViewFragment.instanciate("https://m.facebook.com/login/identify/?ctx=recover"));

        }
    });
    helpTextview = (TextView) v.findViewById(R.id.help_tv);
    helpTextview.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            ((Account) getActivity())
                    .pushFragment(WebViewFragment.instanciate("https://m.facebook.com/help/?refid=8"));
        }
    });
    return v;
}

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.  ja va 2s  .  com*/
        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:nl.hnogames.domoticz.Welcome.SetupServerSettings.java

private void getLayoutReferences() {
    useSameAddress = (Switch) v.findViewById(R.id.localServer_switch);
    saveButton = (Button) v.findViewById(R.id.save_server);
    server_name_input = (FloatingLabelEditText) v.findViewById(R.id.server_name_input);
    remote_server_input = (FloatingLabelEditText) v.findViewById(R.id.remote_server_input);
    remote_port_input = (FloatingLabelEditText) v.findViewById(R.id.remote_port_input);
    remote_username_input = (FloatingLabelEditText) v.findViewById(R.id.remote_username_input);
    remote_password_input = (FloatingLabelEditText) v.findViewById(R.id.remote_password_input);
    remote_directory_input = (FloatingLabelEditText) v.findViewById(R.id.remote_directory_input);
    remote_protocol_spinner = (Spinner) v.findViewById(R.id.remote_protocol_spinner);
    local_server_input = (FloatingLabelEditText) v.findViewById(R.id.local_server_input);
    local_port_input = (FloatingLabelEditText) v.findViewById(R.id.local_port_input);
    local_username_input = (FloatingLabelEditText) v.findViewById(R.id.local_username_input);
    local_password_input = (FloatingLabelEditText) v.findViewById(R.id.local_password_input);
    local_directory_input = (FloatingLabelEditText) v.findViewById(R.id.local_directory_input);
    local_protocol_spinner = (Spinner) v.findViewById(R.id.local_protocol_spinner);
    local_wifi_spinner = (MultiSelectionSpinner) v.findViewById(R.id.local_wifi);
    cbShowPassword = (CheckBox) v.findViewById(R.id.showpassword);
    cbShowPasswordLocal = (CheckBox) v.findViewById(R.id.showpasswordlocal);

    startScreen_spinner = (Spinner) v.findViewById(R.id.startScreen_spinner);

    btnManualSSID = (Button) v.findViewById(R.id.set_ssid);
    btnManualSSID.setOnClickListener(new View.OnClickListener() {
        @Override/*from  w  w  w.j av  a2s  .  c om*/
        public void onClick(View v) {
            new MaterialDialog.Builder(getContext()).title(R.string.welcome_ssid_button_prompt)
                    .content(R.string.welcome_msg_no_ssid_found)
                    .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD)
                    .input(null, null, new MaterialDialog.InputCallback() {
                        @Override
                        public void onInput(MaterialDialog dialog, CharSequence input) {
                            Set<String> ssidFromPrefs = mServerUtil.getActiveServer().getLocalServerSsid();
                            final ArrayList<String> ssidListFromPrefs = new ArrayList<>();
                            if (ssidFromPrefs != null) {
                                if (ssidFromPrefs.size() > 0) {
                                    for (String wifi : ssidFromPrefs) {
                                        ssidListFromPrefs.add(wifi);
                                    }
                                }
                            }
                            ssidListFromPrefs.add(String.valueOf(input));
                            mServerUtil.getActiveServer().setLocalServerSsid(ssidListFromPrefs);

                            setSsid_spinner();
                        }
                    }).show();
        }
    });

    startScreen_spinner.setVisibility(View.GONE);
    v.findViewById(R.id.startScreen_title).setVisibility(View.GONE);
    v.findViewById(R.id.server_settings_title).setVisibility(View.GONE);

    useSameAddress.setChecked(false);
    final LinearLayout localServerSettingsLayout = (LinearLayout) v.findViewById(R.id.local_server_settings);
    localServer_switch = (Switch) v.findViewById(R.id.localServer_switch);
    localServer_switch.setChecked(false);//default setting
    localServer_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
            if (checked)
                localServerSettingsLayout.setVisibility(View.VISIBLE);
            else
                localServerSettingsLayout.setVisibility(View.GONE);
        }
    });

    final LinearLayout advancedSettings_layout = (LinearLayout) v.findViewById(R.id.advancedSettings_layout);
    advancedSettings_switch = (Switch) v.findViewById(R.id.advancedSettings_switch);
    advancedSettings_layout.setVisibility(View.INVISIBLE);
    advancedSettings_switch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mSharedPrefs.setAdvancedSettingsEnabled(isChecked);

            if (isChecked)
                advancedSettings_layout.setVisibility(View.VISIBLE);
            else
                advancedSettings_layout.setVisibility(View.GONE);
        }
    });
    advancedSettings_layout.setVisibility(View.GONE);
    advancedSettings_switch.setChecked(false);
    cbShowPassword.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (!isChecked) {
                remote_password_input.getInputWidget()
                        .setTransformationMethod(PasswordTransformationMethod.getInstance());
            } else {
                remote_password_input.getInputWidget()
                        .setTransformationMethod(HideReturnsTransformationMethod.getInstance());
            }
        }
    });
    cbShowPasswordLocal.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (!isChecked) {
                local_password_input.getInputWidget()
                        .setTransformationMethod(PasswordTransformationMethod.getInstance());
            } else {
                local_password_input.getInputWidget()
                        .setTransformationMethod(HideReturnsTransformationMethod.getInstance());
            }
        }
    });

    saveButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            checkConnectionData();
        }
    });
}