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:net.cloudpath.xpressconnect.screens.GetCredentials.java

public void onCheckedChanged(CompoundButton paramCompoundButton, boolean paramBoolean) {
    if (paramBoolean) {
        this.passwordEdit.setInputType(0);
        this.passwordEdit.setTransformationMethod(null);
        this.passwordEdit.invalidate();
        return;/*from  w  w  w .j av  a2 s .c om*/
    }
    this.passwordEdit.setInputType(128);
    this.passwordEdit.setTransformationMethod(PasswordTransformationMethod.getInstance());
    this.passwordEdit.invalidate();
}

From source file:org.smap.smapTask.android.activities.MainTabsActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case PROGRESS_DIALOG:
        mProgressDialog = new ProgressDialog(this);
        DialogInterface.OnClickListener loadingButtonListener = new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();/* w w w .  j ava2  s .  co m*/
                mDownloadTasks.setDownloaderListener(null, mContext);
                mDownloadTasks.cancel(true);
                // Refresh the task list
                Intent intent = new Intent("refresh");
                LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
            }
        };
        mProgressDialog.setTitle(getString(R.string.downloading_data));
        mProgressDialog.setMessage(mProgressMsg);
        mProgressDialog.setIcon(android.R.drawable.ic_dialog_info);
        mProgressDialog.setIndeterminate(true);
        mProgressDialog.setCancelable(false);
        mProgressDialog.setButton(getString(R.string.cancel), loadingButtonListener);
        return mProgressDialog;
    case ALERT_DIALOG:
        mAlertDialog = new AlertDialog.Builder(this).create();
        mAlertDialog.setMessage(mAlertMsg);
        mAlertDialog.setTitle(getString(R.string.smap_get_tasks));
        DialogInterface.OnClickListener quitListener = new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int i) {
                dialog.dismiss();
            }
        };
        mAlertDialog.setCancelable(false);
        mAlertDialog.setButton(getString(R.string.ok), quitListener);
        mAlertDialog.setIcon(android.R.drawable.ic_dialog_info);
        return mAlertDialog;
    case PASSWORD_DIALOG:

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        final AlertDialog passwordDialog = builder.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 = mAdminPreferences.getString(AdminPreferencesActivity.KEY_ADMIN_PW, "");
                        if (pw.compareTo(value) == 0) {
                            Intent i = new Intent(getApplicationContext(), AdminPreferencesActivity.class);
                            startActivity(i);
                            input.setText("");
                            passwordDialog.dismiss();
                        } else {
                            Toast.makeText(MainTabsActivity.this, getString(R.string.admin_password_incorrect),
                                    Toast.LENGTH_SHORT).show();
                            Collect.getInstance().getActivityLogger().logAction(this, "adminPasswordDialog",
                                    "PASSWORD_INCORRECT");
                        }
                    }
                });

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

                    public void onClick(DialogInterface dialog, int which) {
                        Collect.getInstance().getActivityLogger().logAction(this, "adminPasswordDialog",
                                "cancel");
                        input.setText("");
                        return;
                    }
                });

        passwordDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
        return passwordDialog;
    }
    return null;
}

From source file:org.nypl.simplified.app.MainSettingsAccountActivity.java

@Override
protected void onCreate(final @Nullable Bundle state) {
    super.onCreate(state);

    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
        this.account = new AccountsRegistry(this).getAccount(extras.getInt("selected_account"));
    } else {// w  ww  .j a va 2  s. c o  m
        this.account = Simplified.getCurrentAccount();
    }

    final ActionBar bar = this.getActionBar();
    if (android.os.Build.VERSION.SDK_INT < 21) {
        bar.setDisplayHomeAsUpEnabled(false);
        bar.setHomeButtonEnabled(true);
        bar.setIcon(R.drawable.ic_arrow_back);
    } else {
        bar.setHomeAsUpIndicator(R.drawable.ic_arrow_back);
        bar.setDisplayHomeAsUpEnabled(true);
        bar.setHomeButtonEnabled(false);
    }

    final DocumentStoreType docs = Simplified.getDocumentStore(this.account, getResources());

    final LayoutInflater inflater = NullCheck.notNull(this.getLayoutInflater());

    final FrameLayout content_area = this.getContentFrame();
    final ViewGroup layout = NullCheck
            .notNull((ViewGroup) inflater.inflate(R.layout.settings_account, content_area, false));
    content_area.addView(layout);
    content_area.requestLayout();

    final TextView in_barcode_label = NullCheck.notNull(this.findViewById(R.id.settings_barcode_label));
    final TextView in_barcode_text = NullCheck.notNull(this.findViewById(R.id.settings_barcode_text));
    final TextView in_pin_label = NullCheck.notNull(this.findViewById(R.id.settings_pin_label));
    final ImageView in_barcode_image = NullCheck.notNull(this.findViewById(R.id.settings_barcode_image));
    final TextView in_barcode_image_toggle = NullCheck
            .notNull(this.findViewById(R.id.settings_barcode_toggle_barcode));
    final TextView in_pin_text = NullCheck.notNull(this.findViewById(R.id.settings_pin_text));
    final CheckBox in_pin_reveal = NullCheck.notNull(this.findViewById(R.id.settings_reveal_password));

    if (!this.account.pinRequired()) {
        in_pin_label.setVisibility(View.INVISIBLE);
        in_pin_text.setVisibility(View.INVISIBLE);
        in_pin_reveal.setVisibility(View.INVISIBLE);
    }

    final Button in_login = NullCheck.notNull(this.findViewById(R.id.settings_login));
    final Button in_signup = NullCheck.notNull(this.findViewById(R.id.settings_signup));

    this.sync_switch = findViewById(R.id.sync_switch);
    this.sync_table_row = findViewById(R.id.sync_table_row);
    this.sync_table_row.setVisibility(View.GONE);
    this.advanced_table_row = findViewById(R.id.link_advanced);
    this.advanced_table_row.setVisibility(View.GONE);

    this.advanced_table_row.setOnClickListener(view -> {
        final FragmentManager mgr = getFragmentManager();
        final FragmentTransaction transaction = mgr.beginTransaction();
        final SettingsAccountAdvancedFragment fragment = new SettingsAccountAdvancedFragment();
        transaction.add(R.id.settings_account_container, fragment).addToBackStack("advanced").commit();
    });

    final TableRow in_privacy = findViewById(R.id.link_privacy);
    final TableRow in_license = findViewById(R.id.link_license);

    final TextView account_name = NullCheck.notNull(this.findViewById(android.R.id.text1));
    final TextView account_subtitle = NullCheck.notNull(this.findViewById(android.R.id.text2));

    final ImageView in_account_icon = NullCheck.notNull(this.findViewById(R.id.account_icon));

    in_pin_text.setTransformationMethod(PasswordTransformationMethod.getInstance());
    if (android.os.Build.VERSION.SDK_INT >= 21) {
        this.handle_pin_reveal(in_pin_text, in_pin_reveal);
    } else {
        in_pin_reveal.setVisibility(View.GONE);
    }

    final TableRow in_report_issue = findViewById(R.id.report_issue);

    if (this.account.getSupportEmail() == null) {
        in_report_issue.setVisibility(View.GONE);
    } else {
        in_report_issue.setVisibility(View.VISIBLE);
        in_report_issue.setOnClickListener(view -> {
            final Intent intent = new Intent(this, ReportIssueActivity.class);
            final Bundle b = new Bundle();
            b.putInt("selected_account", this.account.getId());
            intent.putExtras(b);
            startActivity(intent);
        });
    }

    final TableRow in_support_center = findViewById(R.id.support_center);
    if (this.account.supportsHelpCenter()) {
        in_support_center.setVisibility(View.VISIBLE);
        in_support_center.setOnClickListener(view -> {
            final HSHelpStack stack = HSHelpStack.getInstance(this);
            final HSDeskGear gear = new HSDeskGear("https://nypl.desk.com/", "4GBRmMv8ZKG8fGehhA", null);
            stack.setGear(gear);
            stack.showHelp(this);
        });
    } else {
        in_support_center.setVisibility(View.GONE);
    }

    //Get labels from the current authentication document.
    final AuthenticationDocumentType auth_doc = docs.getAuthenticationDocument();
    in_barcode_label.setText(auth_doc.getLabelLoginUserID());
    in_pin_label.setText(auth_doc.getLabelLoginPassword());

    final TableLayout in_table_with_code = NullCheck
            .notNull(this.findViewById(R.id.settings_login_table_with_code));
    in_table_with_code.setVisibility(View.GONE);
    final TableLayout in_table_signup = NullCheck.notNull(this.findViewById(R.id.settings_signup_table));

    //    boolean locationpermission = false;
    //    if (ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
    //      locationpermission = true;
    //    }
    //    else
    //    {
    //      ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
    //    }

    if (this.account.supportsCardCreator() || this.account.getCardCreatorUrl() != null) {
        in_table_signup.setVisibility(View.VISIBLE);
    } else {
        in_table_signup.setVisibility(View.GONE);
    }

    in_login.setOnClickListener(v -> this.onLoginWithBarcode());

    final CheckBox in_age13_checkbox = NullCheck.notNull(this.findViewById(R.id.age13_checkbox));

    if (Simplified.getSharedPrefs().contains("age13")) {
        in_age13_checkbox.setChecked(Simplified.getSharedPrefs().getBoolean("age13"));
    } else if (account.getId() == 2) {
        showAgeGateOptionsDialog(in_age13_checkbox);
    }

    in_age13_checkbox.setOnCheckedChangeListener(this::showAgeChangeConfirmation);

    if (this.account.needsAuth()) {
        in_login.setVisibility(View.VISIBLE);
        in_age13_checkbox.setVisibility(View.GONE);
    } else {
        in_login.setVisibility(View.GONE);
        in_age13_checkbox.setVisibility(View.VISIBLE);
    }

    if (this.account.supportsCardCreator()) {
        in_signup.setOnClickListener(v -> {
            final Intent cardcreator = new Intent(this, CardCreatorActivity.class);
            startActivity(cardcreator);
        });
        in_signup.setText(R.string.need_card_button);

    } else if (this.account.getCardCreatorUrl() != null) {
        in_signup.setOnClickListener(v -> {
            final Intent e_card = new Intent(Intent.ACTION_VIEW);
            e_card.setData(Uri.parse(this.account.getCardCreatorUrl()));
            startActivity(e_card);
        });
        in_signup.setText(R.string.need_card_button);
    }

    final boolean permission = Simplified.getSharedPrefs().getBoolean("syncPermissionGranted",
            this.account.getId());
    this.sync_switch.setChecked(permission);

    /*
    If switching on, disable user interaction until server has responded.
    If switching off, disable applicable network requests by updating shared prefs flags.
     */
    this.sync_switch.setOnCheckedChangeListener((buttonView, isChecked) -> {
        if (isChecked) {
            buttonView.setEnabled(false);
            annotationsManager.updateServerSyncPermissionStatus(true, (success) -> {
                if (success) {
                    Simplified.getSharedPrefs().putBoolean("syncPermissionGranted", this.account.getId(), true);
                    this.sync_switch.setChecked(true);
                } else {
                    Simplified.getSharedPrefs().putBoolean("syncPermissionGranted", this.account.getId(),
                            false);
                    this.sync_switch.setChecked(false);
                }
                this.sync_switch.setEnabled(true);
                return kotlin.Unit.INSTANCE;
            });
        } else {
            Simplified.getSharedPrefs().putBoolean("syncPermissionGranted", this.account.getId(), false);
            this.sync_switch.setChecked(false);
        }
    });

    if (this.account.getPrivacyPolicy() != null) {
        in_privacy.setVisibility(View.VISIBLE);
    } else {
        in_privacy.setVisibility(View.GONE);
    }
    if (this.account.getContentLicense() != null) {
        in_license.setVisibility(View.VISIBLE);
    } else {
        in_license.setVisibility(View.GONE);
    }

    in_license.setOnClickListener(view -> {
        final Intent intent = new Intent(this, WebViewActivity.class);
        final Bundle b = new Bundle();
        WebViewActivity.setActivityArguments(b, this.account.getContentLicense(), "Content Licenses",
                SimplifiedPart.PART_SETTINGS);
        intent.putExtras(b);
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivity(intent);
    });

    in_privacy.setOnClickListener(view -> {
        final Intent intent = new Intent(this, WebViewActivity.class);
        final Bundle b = new Bundle();
        WebViewActivity.setActivityArguments(b, this.account.getPrivacyPolicy(), "Privacy Policy",
                SimplifiedPart.PART_SETTINGS);
        intent.putExtras(b);
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
        startActivity(intent);
    });

    this.navigationDrawerSetActionBarTitle();

    this.account_name_text = account_name;
    this.account_subtitle_text = account_subtitle;
    this.account_icon = in_account_icon;
    this.barcode_text = in_barcode_text;
    this.pin_text = in_pin_text;
    this.barcode_image_toggle = in_barcode_image_toggle;
    this.barcode_image = in_barcode_image;
    this.login = in_login;
    this.table_with_code = in_table_with_code;
    this.table_signup = in_table_signup;

    final CheckBox in_eula_checkbox = NullCheck.notNull(this.findViewById(R.id.eula_checkbox));

    final OptionType<EULAType> eula_opt = docs.getEULA();

    if (eula_opt.isSome()) {
        final Some<EULAType> some_eula = (Some<EULAType>) eula_opt;
        final EULAType eula = some_eula.get();

        in_eula_checkbox.setChecked(eula.eulaHasAgreed());
        in_eula_checkbox.setEnabled(true);
        in_eula_checkbox.setOnCheckedChangeListener((button, checked) -> eula.eulaSetHasAgreed(checked));

        if (eula.eulaHasAgreed()) {
            LOG.debug("EULA: agreed");
        } else {
            LOG.debug("EULA: not agreed");
        }
    } else {
        LOG.debug("EULA: unavailable");
    }

    this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}

From source file:com.goftagram.telegram.ui.PasscodeActivity.java

private void updateDropDownTextView() {
    if (dropDown != null) {
        if (currentPasswordType == 0) {
            dropDown.setText(LocaleController.getString("PasscodePIN", R.string.PasscodePIN));
        } else if (currentPasswordType == 1) {
            dropDown.setText(LocaleController.getString("PasscodePassword", R.string.PasscodePassword));
        }//from   w w  w. java2s  .co  m
    }
    if (type == 1 && currentPasswordType == 0 || type == 2 && UserConfig.passcodeType == 0) {
        InputFilter[] filterArray = new InputFilter[1];
        filterArray[0] = new InputFilter.LengthFilter(4);
        passwordEditText.setFilters(filterArray);
        passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE);
        passwordEditText.setKeyListener(DigitsKeyListener.getInstance("1234567890"));
    } else if (type == 1 && currentPasswordType == 1 || type == 2 && UserConfig.passcodeType == 1) {
        passwordEditText.setFilters(new InputFilter[0]);
        passwordEditText.setKeyListener(null);
        passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    }
    passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
}

From source file:kr.wdream.ui.PasscodeActivity.java

private void updateDropDownTextView() {
    if (dropDown != null) {
        if (currentPasswordType == 0) {
            dropDown.setText(//www.ja v  a  2s.  com
                    LocaleController.getString("PasscodePIN", kr.wdream.storyshop.R.string.PasscodePIN));
        } else if (currentPasswordType == 1) {
            dropDown.setText(LocaleController.getString("PasscodePassword",
                    kr.wdream.storyshop.R.string.PasscodePassword));
        }
    }
    if (type == 1 && currentPasswordType == 0 || type == 2 && UserConfig.passcodeType == 0) {
        InputFilter[] filterArray = new InputFilter[1];
        filterArray[0] = new InputFilter.LengthFilter(4);
        passwordEditText.setFilters(filterArray);
        passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE);
        passwordEditText.setKeyListener(DigitsKeyListener.getInstance("1234567890"));
    } else if (type == 1 && currentPasswordType == 1 || type == 2 && UserConfig.passcodeType == 1) {
        passwordEditText.setFilters(new InputFilter[0]);
        passwordEditText.setKeyListener(null);
        passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    }
    passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
}

From source file:com.b44t.ui.PasscodeActivity.java

private void updateDropDownTextView() {
    if (dropDown != null) {
        if (currentPasswordType == 0) {
            dropDown.setText(LocaleController.getString("PasscodePIN", R.string.PasscodePIN));
        } else if (currentPasswordType == 1) {
            dropDown.setText(LocaleController.getString("PasscodePassword", R.string.PasscodePassword));
        }/* w  ww  . j a v  a 2 s. co  m*/
    }
    if (screen == SCREEN1_ENTER_CODE1 && currentPasswordType == 0
            || screen == SCREEN2_ENTER_CODE2 && UserConfig.passcodeType == 0) {
        InputFilter[] filterArray = new InputFilter[1];
        filterArray[0] = new InputFilter.LengthFilter(4);
        passwordEditText.setFilters(filterArray);
        passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE);
        passwordEditText.setKeyListener(DigitsKeyListener.getInstance("1234567890"));
    } else if (screen == SCREEN1_ENTER_CODE1 && currentPasswordType == 1
            || screen == SCREEN2_ENTER_CODE2 && UserConfig.passcodeType == 1) {
        passwordEditText.setFilters(new InputFilter[0]);
        passwordEditText.setKeyListener(null);
        passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    }
    passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
}

From source file:ir.besteveryeverapp.ui.PasscodeActivity.java

private void updateDropDownTextView() {
    if (dropDown != null) {
        if (currentPasswordType == 0) {
            dropDown.setText(LocaleController.getString("PasscodePIN",
                    ir.besteveryeverapp.telegram.R.string.PasscodePIN));
        } else if (currentPasswordType == 1) {
            dropDown.setText(LocaleController.getString("PasscodePassword",
                    ir.besteveryeverapp.telegram.R.string.PasscodePassword));
        }//from  w ww . j a  v a 2s .co m
    }
    if (type == 1 && currentPasswordType == 0 || type == 2 && UserConfig.passcodeType == 0) {
        InputFilter[] filterArray = new InputFilter[1];
        filterArray[0] = new InputFilter.LengthFilter(4);
        passwordEditText.setFilters(filterArray);
        passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE);
        passwordEditText.setKeyListener(DigitsKeyListener.getInstance("1234567890"));
    } else if (type == 1 && currentPasswordType == 1 || type == 2 && UserConfig.passcodeType == 1) {
        passwordEditText.setFilters(new InputFilter[0]);
        passwordEditText.setKeyListener(null);
        passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    }
    passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
}

From source file:com.b44t.ui.Components.PasscodeView.java

public void onShow() {
    Activity parentActivity = (Activity) getContext();
    if (UserConfig.passcodeType == 1) {
        if (passwordEditText != null) {
            passwordEditText.requestFocus();
            AndroidUtilities.showKeyboard(passwordEditText);
        }// ww w . jav a 2 s.  c  om
    } 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);
    backgroundDrawable = ApplicationLoader.getCachedWallpaper();
    if (backgroundDrawable != null) {
        backgroundFrameLayout.setBackgroundColor(0xb6000000);
    } else {
        backgroundFrameLayout.setBackgroundColor(Theme.ACTION_BAR_COLOR);
    }

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

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

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

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

private void setPasswordSetState(int state) {
    if (passwordEditText == null) {
        return;/*from w w  w. j a va 2 s.c  om*/
    }
    passwordSetState = state;
    if (passwordSetState == 0) {
        actionBar.setTitle(LocaleController.getString("YourPassword", R.string.YourPassword));
        if (currentPassword instanceof TLRPC.TL_account_noPassword) {
            titleTextView.setText(
                    LocaleController.getString("PleaseEnterFirstPassword", R.string.PleaseEnterFirstPassword));
        } else {
            titleTextView
                    .setText(LocaleController.getString("PleaseEnterPassword", R.string.PleaseEnterPassword));
        }
        passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
        passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
        bottomTextView.setVisibility(View.INVISIBLE);
        bottomButton.setVisibility(View.INVISIBLE);
    } else if (passwordSetState == 1) {
        actionBar.setTitle(LocaleController.getString("YourPassword", R.string.YourPassword));
        titleTextView
                .setText(LocaleController.getString("PleaseReEnterPassword", R.string.PleaseReEnterPassword));
        passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
        passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
        bottomTextView.setVisibility(View.INVISIBLE);
        bottomButton.setVisibility(View.INVISIBLE);
    } else if (passwordSetState == 2) {
        actionBar.setTitle(LocaleController.getString("PasswordHint", R.string.PasswordHint));
        titleTextView.setText(LocaleController.getString("PasswordHintText", R.string.PasswordHintText));
        passwordEditText.setImeOptions(EditorInfo.IME_ACTION_NEXT);
        passwordEditText.setTransformationMethod(null);
        bottomTextView.setVisibility(View.INVISIBLE);
        bottomButton.setVisibility(View.INVISIBLE);
    } else if (passwordSetState == 3) {
        actionBar.setTitle(LocaleController.getString("RecoveryEmail", R.string.RecoveryEmail));
        titleTextView.setText(LocaleController.getString("YourEmail", R.string.YourEmail));
        passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
        passwordEditText.setTransformationMethod(null);
        passwordEditText
                .setInputType(EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
        bottomTextView.setVisibility(View.VISIBLE);
        bottomButton.setVisibility(emailOnly ? View.INVISIBLE : View.VISIBLE);
    } else if (passwordSetState == 4) {
        actionBar.setTitle(LocaleController.getString("PasswordRecovery", R.string.PasswordRecovery));
        titleTextView.setText(LocaleController.getString("PasswordCode", R.string.PasswordCode));
        bottomTextView
                .setText(LocaleController.getString("RestoreEmailSentInfo", R.string.RestoreEmailSentInfo));
        bottomButton.setText(LocaleController.formatString("RestoreEmailTrouble", R.string.RestoreEmailTrouble,
                currentPassword.email_unconfirmed_pattern));
        passwordEditText.setImeOptions(EditorInfo.IME_ACTION_DONE);
        passwordEditText.setTransformationMethod(null);
        passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE);
        bottomTextView.setVisibility(View.VISIBLE);
        bottomButton.setVisibility(View.VISIBLE);
    }
    passwordEditText.setText("");
}

From source file:org.nypl.simplified.app.MainSettingsAccountActivity.java

@TargetApi(21)
private void handle_pin_reveal(final TextView in_pin_text, final CheckBox in_pin_reveal) {
    /*/*  ww  w .  jav a 2  s .  co m*/
     * Add a listener that reveals/hides the password field.
     */
    in_pin_reveal.setOnCheckedChangeListener((view, checked) -> {
        if (checked) {
            final KeyguardManager keyguard_manager = (KeyguardManager) getSystemService(
                    Context.KEYGUARD_SERVICE);
            if (!keyguard_manager.isKeyguardSecure()) {
                // Show a message that the user hasn't set up a lock screen.
                Toast.makeText(this, R.string.settings_screen_Lock_not_setup, Toast.LENGTH_LONG).show();
                in_pin_reveal.setChecked(false);
            } else {
                final Intent intent = keyguard_manager.createConfirmDeviceCredentialIntent(null, null);
                if (intent != null) {
                    startActivityForResult(intent, 1);
                }
            }
        } else {
            in_pin_text.setTransformationMethod(PasswordTransformationMethod.getInstance());
        }
    });
}