Example usage for android.text.method PasswordTransformationMethod getInstance

List of usage examples for android.text.method PasswordTransformationMethod getInstance

Introduction

In this page you can find the example usage for android.text.method PasswordTransformationMethod getInstance.

Prototype

public static PasswordTransformationMethod getInstance() 

Source Link

Usage

From source file:com.citrus.sample.WalletPaymentFragment.java

private void showCvvPrompt(final PaymentOption paymentOption) {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    String message = "Please enter CVV.";
    String positiveButtonText = "OK";
    alert.setTitle("CVV");
    alert.setMessage(message);/*from w  ww.j  a v  a2 s.c  o  m*/
    // Set an EditText view to get user input
    final EditText input = new EditText(getActivity());
    input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    input.setTransformationMethod(PasswordTransformationMethod.getInstance());
    InputFilter[] FilterArray = new InputFilter[1];
    FilterArray[0] = new InputFilter.LengthFilter(4);
    input.setFilters(FilterArray);
    alert.setView(input);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            String cvv = input.getText().toString();
            input.clearFocus();
            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
            otherPaymentOption = paymentOption;
            ((CardOption) otherPaymentOption).setCardCVV(cvv);
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
        }
    });

    input.requestFocus();
    alert.show();
}

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

/**
 * Show any prompts requested by the currently visible {@link TerminalView}.
 *///www  .  ja  v a 2  s  .  c  o  m
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:kr.wdream.ui.Components.PasscodeView.java

public void onShow() {
    Log.d("PassCodeView", "onShow");
    Activity parentActivity = (Activity) getContext();
    if (UserConfig.passcodeType == 1) {
        Log.d("PassCodeView", "passcodeType = 1");
        if (passwordEditText != null) {
            Log.d("PassCodeView", "EditText not null");
            passwordEditText.requestFocus();
            AndroidUtilities.showKeyboard(passwordEditText);
        }/*from   w  w  w.j  a v  a  2s.co  m*/
    } else {
        Log.d("PassCodeView", "passcodeType not 1");
        if (parentActivity != null) {
            Log.d("PassCodeView", "parentActivity not null");
            View currentFocus = parentActivity.getCurrentFocus();
            if (currentFocus != null) {
                Log.d("PassCodeView", "current focus not null");
                currentFocus.clearFocus();
                AndroidUtilities.hideKeyboard(((Activity) getContext()).getCurrentFocus());
            }
        }
    }
    checkFingerprint();
    if (getVisibility() == View.VISIBLE) {
        return;
    }
    setAlpha(1.0f);
    setTranslationY(0);
    SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig",
            Activity.MODE_PRIVATE);
    int selectedBackground = preferences.getInt("selectedBackground", 1000001);
    if (selectedBackground == 1000001) {
        backgroundFrameLayout.setBackgroundColor(0xff517c9e);
    } else {
        backgroundDrawable = ApplicationLoader.getCachedWallpaper();
        if (backgroundDrawable != null) {
            backgroundFrameLayout.setBackgroundColor(0xbf000000);
        } else {
            backgroundFrameLayout.setBackgroundColor(0xff517c9e);
        }
    }

    passcodeTextView.setText(
            LocaleController.getString("EnterYourPasscode", kr.wdream.storyshop.R.string.EnterYourPasscode));

    if (UserConfig.passcodeType == 0) {
        //InputFilter[] filterArray = new InputFilter[1];
        //filterArray[0] = new InputFilter.LengthFilter(4);
        //passwordEditText.setFilters(filterArray);
        //passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE);
        //passwordEditText.setFocusable(false);
        //passwordEditText.setFocusableInTouchMode(false);
        numbersFrameLayout.setVisibility(VISIBLE);
        passwordEditText.setVisibility(GONE);
        passwordEditText2.setVisibility(VISIBLE);
        checkImage.setVisibility(GONE);
    } else if (UserConfig.passcodeType == 1) {
        passwordEditText.setFilters(new InputFilter[0]);
        passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        numbersFrameLayout.setVisibility(GONE);
        passwordEditText.setFocusable(true);
        passwordEditText.setFocusableInTouchMode(true);
        passwordEditText.setVisibility(VISIBLE);
        passwordEditText2.setVisibility(GONE);
        checkImage.setVisibility(VISIBLE);
    }
    setVisibility(VISIBLE);
    passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
    passwordEditText.setText("");
    passwordEditText2.eraseAllCharacters(false);

    setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });
}

From source file:ir.besteveryeverapp.ui.Components.PasscodeView.java

public void onShow() {
    Activity parentActivity = (Activity) getContext();
    if (UserConfig.passcodeType == 1) {
        if (passwordEditText != null) {
            passwordEditText.requestFocus();
            AndroidUtilities.showKeyboard(passwordEditText);
        }//  w  ww  .ja  v  a2s .  c o  m
    } else {
        if (parentActivity != null) {
            View currentFocus = parentActivity.getCurrentFocus();
            if (currentFocus != null) {
                currentFocus.clearFocus();
                AndroidUtilities.hideKeyboard(((Activity) getContext()).getCurrentFocus());
            }
        }
    }
    checkFingerprint();
    if (getVisibility() == View.VISIBLE) {
        return;
    }
    setAlpha(1.0f);
    setTranslationY(0);
    SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig",
            Activity.MODE_PRIVATE);
    int selectedBackground = preferences.getInt("selectedBackground", 1000001);
    if (selectedBackground == 1000001) {
        backgroundFrameLayout.setBackgroundColor(0xff517c9e);
    } else {
        backgroundDrawable = ApplicationLoader.getCachedWallpaper();
        if (backgroundDrawable != null) {
            backgroundFrameLayout.setBackgroundColor(0xbf000000);
        } else {
            backgroundFrameLayout.setBackgroundColor(0xff517c9e);
        }
    }

    passcodeTextView.setText(LocaleController.getString("EnterYourPasscode", R.string.EnterYourPasscode));

    if (UserConfig.passcodeType == 0) {
        //InputFilter[] filterArray = new InputFilter[1];
        //filterArray[0] = new InputFilter.LengthFilter(4);
        //passwordEditText.setFilters(filterArray);
        //passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE);
        //passwordEditText.setFocusable(false);
        //passwordEditText.setFocusableInTouchMode(false);
        numbersFrameLayout.setVisibility(VISIBLE);
        passwordEditText.setVisibility(GONE);
        passwordEditText2.setVisibility(VISIBLE);
        checkImage.setVisibility(GONE);
    } else if (UserConfig.passcodeType == 1) {
        passwordEditText.setFilters(new InputFilter[0]);
        passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        numbersFrameLayout.setVisibility(GONE);
        passwordEditText.setFocusable(true);
        passwordEditText.setFocusableInTouchMode(true);
        passwordEditText.setVisibility(VISIBLE);
        passwordEditText2.setVisibility(GONE);
        checkImage.setVisibility(VISIBLE);
    }
    setVisibility(VISIBLE);
    passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
    passwordEditText.setText("");
    passwordEditText2.eraseAllCharacters(false);

    setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });
}

From source file:org.telegram.ui.Components.PasscodeView.java

public void onShow() {
    Activity parentActivity = (Activity) getContext();
    if (UserConfig.passcodeType == 1) {
        if (passwordEditText != null) {
            passwordEditText.requestFocus();
            AndroidUtilities.showKeyboard(passwordEditText);
        }/*from   w w w. j a  v a 2s.c  o m*/
    } else {
        if (parentActivity != null) {
            View currentFocus = parentActivity.getCurrentFocus();
            if (currentFocus != null) {
                currentFocus.clearFocus();
                AndroidUtilities.hideKeyboard(((Activity) getContext()).getCurrentFocus());
            }
        }
    }
    checkFingerprint();
    if (getVisibility() == View.VISIBLE) {
        return;
    }
    if (Build.VERSION.SDK_INT >= 14) {
        ViewProxy.setAlpha(this, 1.0f);
        ViewProxy.setTranslationY(this, 0);
        this.clearAnimation();
    }
    SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig",
            Activity.MODE_PRIVATE);
    int selectedBackground = preferences.getInt("selectedBackground", 1000001);
    if (selectedBackground == 1000001) {
        backgroundFrameLayout.setBackgroundColor(0xffff8542);
    } else {
        backgroundDrawable = ApplicationLoader.getCachedWallpaper();
        if (backgroundDrawable != null) {
            backgroundFrameLayout.setBackgroundColor(0xbf000000);
        } else {
            backgroundFrameLayout.setBackgroundColor(0xffff8542);
        }
    }

    passcodeTextView.setText(LocaleController.getString("EnterYourPasscode", R.string.EnterYourPasscode));

    if (UserConfig.passcodeType == 0) {
        //InputFilter[] filterArray = new InputFilter[1];
        //filterArray[0] = new InputFilter.LengthFilter(4);
        //passwordEditText.setFilters(filterArray);
        //passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE);
        //passwordEditText.setFocusable(false);
        //passwordEditText.setFocusableInTouchMode(false);
        numbersFrameLayout.setVisibility(VISIBLE);
        passwordEditText.setVisibility(GONE);
        passwordEditText2.setVisibility(VISIBLE);
        checkImage.setVisibility(GONE);
    } else if (UserConfig.passcodeType == 1) {
        passwordEditText.setFilters(new InputFilter[0]);
        passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        numbersFrameLayout.setVisibility(GONE);
        passwordEditText.setFocusable(true);
        passwordEditText.setFocusableInTouchMode(true);
        passwordEditText.setVisibility(VISIBLE);
        passwordEditText2.setVisibility(GONE);
        checkImage.setVisibility(VISIBLE);
    }
    setVisibility(VISIBLE);
    passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
    passwordEditText.setText("");
    passwordEditText2.eraseAllCharacters(false);

    setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });
}

From source file:com.goftagram.telegram.ui.Components.PasscodeView.java

public void onShow() {
    Activity parentActivity = (Activity) getContext();
    if (UserConfig.passcodeType == 1) {
        if (passwordEditText != null) {
            passwordEditText.requestFocus();
            AndroidUtilities.showKeyboard(passwordEditText);
        }/*  www.  j ava2s  .  c o  m*/
    } else {
        if (parentActivity != null) {
            View currentFocus = parentActivity.getCurrentFocus();
            if (currentFocus != null) {
                currentFocus.clearFocus();
                AndroidUtilities.hideKeyboard(((Activity) getContext()).getCurrentFocus());
            }
        }
    }
    checkFingerprint();
    if (getVisibility() == View.VISIBLE) {
        return;
    }
    if (Build.VERSION.SDK_INT >= 14) {
        ViewProxy.setAlpha(this, 1.0f);
        ViewProxy.setTranslationY(this, 0);
        this.clearAnimation();
    }
    SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig",
            Activity.MODE_PRIVATE);
    int selectedBackground = preferences.getInt("selectedBackground", 1000001);
    if (selectedBackground == 1000001) {
        backgroundFrameLayout.setBackgroundColor(0xff517c9e);
    } else {
        backgroundDrawable = ApplicationLoader.getCachedWallpaper();
        if (backgroundDrawable != null) {
            backgroundFrameLayout.setBackgroundColor(0xbf000000);
        } else {
            backgroundFrameLayout.setBackgroundColor(0xff517c9e);
        }
    }

    passcodeTextView.setText(LocaleController.getString("EnterYourPasscode", R.string.EnterYourPasscode));

    if (UserConfig.passcodeType == 0) {
        //InputFilter[] filterArray = new InputFilter[1];
        //filterArray[0] = new InputFilter.LengthFilter(4);
        //passwordEditText.setFilters(filterArray);
        //passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE);
        //passwordEditText.setFocusable(false);
        //passwordEditText.setFocusableInTouchMode(false);
        numbersFrameLayout.setVisibility(VISIBLE);
        passwordEditText.setVisibility(GONE);
        passwordEditText2.setVisibility(VISIBLE);
        checkImage.setVisibility(GONE);
    } else if (UserConfig.passcodeType == 1) {
        passwordEditText.setFilters(new InputFilter[0]);
        passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        numbersFrameLayout.setVisibility(GONE);
        passwordEditText.setFocusable(true);
        passwordEditText.setFocusableInTouchMode(true);
        passwordEditText.setVisibility(VISIBLE);
        passwordEditText2.setVisibility(GONE);
        checkImage.setVisibility(VISIBLE);
    }
    setVisibility(VISIBLE);
    passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
    passwordEditText.setText("");
    passwordEditText2.eraseAllCharacters(false);

    setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });
}

From source file:org.buffer.android.buffertextinputlayout.BufferTextInputLayout.java

/**
 * Returns whether the password visibility toggle functionality is enabled or not.
 * <p>//  w w w . j  a  v  a  2s .  c o  m
 * <p>When enabled, a button is placed at the end of the EditText which enables the user
 * to switch between the field's input being visibly disguised or not.</p>
 *
 * @param enabled true to enable the functionality
 * @attr ref android.support.design.R.styleable#TextInputLayout_passwordToggleEnabled
 */
public void setPasswordVisibilityToggleEnabled(final boolean enabled) {
    if (passwordToggleEnabled != enabled) {
        passwordToggleEnabled = enabled;
        if (!enabled && passwordToggledVisible && editText != null) {
            // If the toggle is no longer enabled, but we remove the PasswordTransformation
            // to make the password visible, add it back
            editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
        }
        // Reset the visibility tracking flag
        passwordToggledVisible = false;
        updatePasswordToggleView();
    }
}

From source file:android.support.design.widget.TextInputLayout.java

/**
 * Returns whether the password visibility toggle functionality is enabled or not.
 *
 * <p>When enabled, a button is placed at the end of the EditText which enables the user
 * to switch between the field's input being visibly disguised or not.</p>
 *
 * @param enabled true to enable the functionality
 *
 * @attr ref android.support.design.R.styleable#TextInputLayout_passwordToggleEnabled
 *///from  w w w. j  ava2s  .  c  o m
public void setPasswordVisibilityToggleEnabled(final boolean enabled) {
    if (mPasswordToggleEnabled != enabled) {
        mPasswordToggleEnabled = enabled;

        if (!enabled && mPasswordToggledVisible && mEditText != null) {
            // If the toggle is no longer enabled, but we remove the PasswordTransformation
            // to make the password visible, add it back
            mEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
        }

        // Reset the visibility tracking flag
        mPasswordToggledVisible = false;

        updatePasswordToggleView();
    }
}

From source file:org.opendatakit.survey.android.activities.MainMenuActivity.java

protected void createPasswordDialog() {
    if (mAlertDialog != null) {
        mAlertDialog.dismiss();//from  www .j  a v a  2  s.co  m
        mAlertDialog = null;
    }
    final AlertDialog passwordDialog = new AlertDialog.Builder(this).create();

    passwordDialog.setTitle(getString(R.string.enter_admin_password));
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD);
    input.setTransformationMethod(PasswordTransformationMethod.getInstance());
    passwordDialog.setView(input, 20, 10, 20, 10);

    passwordDialog.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.ok),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    String value = input.getText().toString();
                    String pw = PropertiesSingleton.getProperty(appName, AdminPreferencesActivity.KEY_ADMIN_PW);
                    if (pw != null && pw.compareTo(value) == 0) {
                        Intent i = new Intent(getApplicationContext(), AdminPreferencesActivity.class);
                        // TODO: convert this activity into a preferences fragment
                        i.putExtra(APP_NAME, getAppName());
                        startActivity(i);
                        input.setText("");
                        passwordDialog.dismiss();
                    } else {
                        Toast.makeText(MainMenuActivity.this, getString(R.string.admin_password_incorrect),
                                Toast.LENGTH_SHORT).show();
                    }
                }
            });

    passwordDialog.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.cancel),
            new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    input.setText("");
                    return;
                }
            });

    passwordDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    mAlertDialog = passwordDialog;
    mAlertDialog.show();
}

From source file:org.buffer.android.buffertextinputlayout.BufferTextInputLayout.java

void passwordVisibilityToggleRequested() {
    if (passwordToggleEnabled) {
        // Store the current cursor position
        final int selection = editText.getSelectionEnd();
        if (hasPasswordTransformation()) {
            editText.setTransformationMethod(null);
            passwordToggledVisible = true;
        } else {//w ww  .  j  a  va2 s. c  o m
            editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
            passwordToggledVisible = false;
        }
        passwordToggleView.setChecked(passwordToggledVisible);
        // And restore the cursor position
        editText.setSelection(selection);
    }
}