List of usage examples for android.text InputType TYPE_TEXT_VARIATION_PASSWORD
int TYPE_TEXT_VARIATION_PASSWORD
To view the source code for android.text InputType TYPE_TEXT_VARIATION_PASSWORD.
Click Source Link
From source file:xyz.jamescarroll.genipass.MainActivity.java
private void toggleEditTextVisibility(int view) { if (mEditTextVisible) { ((EditText) findViewById(view)).setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); } else {//from w w w .j a v a2s .c om ((EditText) findViewById(view)) .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); } }
From source file:com.example.run_tracker.ProfileFragment.java
@Override public void onClick(View arg0) { Log.v(TAG, "click"); AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle("Enter Password"); alert.setMessage("Please enter your password"); // Set an EditText view to get user input final EditText input = new EditText(getActivity()); input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); alert.setView(input);/*from w w w.ja v a 2 s .c o m*/ alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String password = input.getText().toString(); String new_password = null; if (!mPassword1.getText().toString().equals(mPassword2.getText().toString())) { Toast.makeText(getActivity(), "Passwords dont match", Toast.LENGTH_LONG).show(); } else { if (isEmpty(mPassword1) || (isEmpty(mPassword2))) { new_password = password; } else { new_password = mPassword1.getText().toString(); } Make_edit_profile_request(password, new_password); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); }
From source file:tv.piratemedia.lightcontroler.controller.java
private void listWifiNetworks(final String[] Networks) { String[] ShowNetworks = new String[Networks.length - 4]; for (int i = 2; i < Networks.length - 2; i++) { String[] NetworkInfo = Networks[i].split(","); ShowNetworks[i - 2] = NetworkInfo[1] + " - " + NetworkInfo[4] + "%"; }/*from w w w. ja v a2 s .c o m*/ // Set an EditText view to get user input final EditText input = new EditText(this); input.setHint("Password"); input.setSingleLine(true); input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); final Context _this = this; new MaterialDialog.Builder(this).title("Controller Wifi Networks").theme(Theme.DARK).items(ShowNetworks) .itemsCallbackSingleChoice(-1, new MaterialDialog.ListCallbackSingleChoice() { @Override public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { final String[] NetworkInfo = Networks[which + 2].split(","); if (NetworkInfo[3].equals("NONE")) { Controller.setWifiNetwork(NetworkInfo[1]); } else { new MaterialDialog.Builder(_this).title("Password For: " + NetworkInfo[1]) .theme(Theme.DARK).customView(input, false) .content("Please type the network password").positiveText("OK") .negativeText("Cancel").onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { Controller.setWifiNetwork(NetworkInfo[1], "WPA2PSK", "AES", input.getText().toString()); } }).build().show(); } return false; } }).positiveText("Select").negativeText("Cancel").build().show(); }
From source file:com.alimuzaffar.lib.pin.PinEntryEditText.java
private void init(Context context, AttributeSet attrs) { float multi = context.getResources().getDisplayMetrics().density; mLineStroke = multi * mLineStroke;// www. j a v a 2 s . c om 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); mSingleCharHint = ta.getString(R.styleable.PinEntryEditText_pinRepeatedHint); 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()); mSingleCharPaint = 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); mAnimate = mAnimatedType > -1; }
From source file:org.telegram.ui.TwoStepVerificationActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(false); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override//from ww w .j ava2 s.c om public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == done_button) { processDone(); } } }); fragmentView = new FrameLayout(context); FrameLayout frameLayout = (FrameLayout) fragmentView; frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background)); ActionBarMenu menu = actionBar.createMenu(); doneItem = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); scrollView = new ScrollView(context); scrollView.setFillViewport(true); frameLayout.addView(scrollView); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) scrollView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; scrollView.setLayoutParams(layoutParams); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); scrollView.addView(linearLayout); ScrollView.LayoutParams layoutParams2 = (ScrollView.LayoutParams) linearLayout.getLayoutParams(); layoutParams2.width = ScrollView.LayoutParams.MATCH_PARENT; layoutParams2.height = ScrollView.LayoutParams.WRAP_CONTENT; linearLayout.setLayoutParams(layoutParams2); titleTextView = new TextView(context); //titleTextView.setTextColor(0xff757575); titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); titleTextView.setGravity(Gravity.CENTER_HORIZONTAL); linearLayout.addView(titleTextView); LinearLayout.LayoutParams layoutParams3 = (LinearLayout.LayoutParams) titleTextView.getLayoutParams(); layoutParams3.width = LayoutHelper.WRAP_CONTENT; layoutParams3.height = LayoutHelper.WRAP_CONTENT; layoutParams3.gravity = Gravity.CENTER_HORIZONTAL; layoutParams3.topMargin = AndroidUtilities.dp(38); titleTextView.setLayoutParams(layoutParams3); passwordEditText = new EditText(context); passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20); //passwordEditText.setTextColor(0xff000000); passwordEditText.setMaxLines(1); passwordEditText.setLines(1); passwordEditText.setGravity(Gravity.CENTER_HORIZONTAL); passwordEditText.setSingleLine(true); passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance()); passwordEditText.setTypeface(Typeface.DEFAULT); AndroidUtilities.clearCursorDrawable(passwordEditText); linearLayout.addView(passwordEditText); layoutParams3 = (LinearLayout.LayoutParams) passwordEditText.getLayoutParams(); layoutParams3.topMargin = AndroidUtilities.dp(32); layoutParams3.height = AndroidUtilities.dp(36); layoutParams3.leftMargin = AndroidUtilities.dp(40); layoutParams3.rightMargin = AndroidUtilities.dp(40); layoutParams3.gravity = Gravity.TOP | Gravity.LEFT; layoutParams3.width = LayoutHelper.MATCH_PARENT; passwordEditText.setLayoutParams(layoutParams3); passwordEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if (i == EditorInfo.IME_ACTION_NEXT || i == EditorInfo.IME_ACTION_DONE) { processDone(); return true; } return false; } }); passwordEditText.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; } }); bottomTextView = new TextView(context); //bottomTextView.setTextColor(0xff757575); bottomTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); bottomTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); bottomTextView.setText(LocaleController.getString("YourEmailInfo", R.string.YourEmailInfo)); linearLayout.addView(bottomTextView); layoutParams3 = (LinearLayout.LayoutParams) bottomTextView.getLayoutParams(); layoutParams3.width = LayoutHelper.WRAP_CONTENT; layoutParams3.height = LayoutHelper.WRAP_CONTENT; layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP; layoutParams3.topMargin = AndroidUtilities.dp(30); layoutParams3.leftMargin = AndroidUtilities.dp(40); layoutParams3.rightMargin = AndroidUtilities.dp(40); bottomTextView.setLayoutParams(layoutParams3); LinearLayout linearLayout2 = new LinearLayout(context); linearLayout2.setGravity(Gravity.BOTTOM | Gravity.CENTER_VERTICAL); linearLayout.addView(linearLayout2); layoutParams3 = (LinearLayout.LayoutParams) linearLayout2.getLayoutParams(); layoutParams3.width = LayoutHelper.MATCH_PARENT; layoutParams3.height = LayoutHelper.MATCH_PARENT; linearLayout2.setLayoutParams(layoutParams3); bottomButton = new TextView(context); bottomButton.setTextColor(0xff4d83b3); bottomButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); bottomButton.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM); bottomButton.setText(LocaleController.getString("YourEmailSkip", R.string.YourEmailSkip)); bottomButton.setPadding(0, AndroidUtilities.dp(10), 0, 0); linearLayout2.addView(bottomButton); layoutParams3 = (LinearLayout.LayoutParams) bottomButton.getLayoutParams(); layoutParams3.width = LayoutHelper.WRAP_CONTENT; layoutParams3.height = LayoutHelper.WRAP_CONTENT; layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.BOTTOM; layoutParams3.bottomMargin = AndroidUtilities.dp(14); layoutParams3.leftMargin = AndroidUtilities.dp(40); layoutParams3.rightMargin = AndroidUtilities.dp(40); bottomButton.setLayoutParams(layoutParams3); bottomButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (type == 0) { if (currentPassword.has_recovery) { needShowProgress(); TLRPC.TL_auth_requestPasswordRecovery req = new TLRPC.TL_auth_requestPasswordRecovery(); ConnectionsManager.getInstance().sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, final TLRPC.TL_error error) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { needHideProgress(); if (error == null) { final TLRPC.TL_auth_passwordRecovery res = (TLRPC.TL_auth_passwordRecovery) response; AlertDialog.Builder builder = new AlertDialog.Builder( getParentActivity()); builder.setMessage(LocaleController.formatString("RestoreEmailSent", R.string.RestoreEmailSent, res.email_pattern)); builder.setTitle( LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { TwoStepVerificationActivity fragment = new TwoStepVerificationActivity( 1); fragment.currentPassword = currentPassword; fragment.currentPassword.email_unconfirmed_pattern = res.email_pattern; fragment.passwordSetState = 4; presentFragment(fragment); } }); Dialog dialog = showDialog(builder.create()); if (dialog != null) { dialog.setCanceledOnTouchOutside(false); dialog.setCancelable(false); } } else { if (error.text.startsWith("FLOOD_WAIT")) { int time = Utilities.parseInt(error.text); String timeString; if (time < 60) { timeString = LocaleController.formatPluralString("Seconds", time); } else { timeString = LocaleController.formatPluralString("Minutes", time / 60); } showAlertWithText( LocaleController.getString("AppName", R.string.AppName), LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString)); } else { showAlertWithText( LocaleController.getString("AppName", R.string.AppName), error.text); } } } }); } }, ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin); } else { showAlertWithText( LocaleController.getString("RestorePasswordNoEmailTitle", R.string.RestorePasswordNoEmailTitle), LocaleController.getString("RestorePasswordNoEmailText", R.string.RestorePasswordNoEmailText)); } } else { if (passwordSetState == 4) { showAlertWithText( LocaleController.getString("RestorePasswordNoEmailTitle", R.string.RestorePasswordNoEmailTitle), LocaleController.getString("RestoreEmailTroubleText", R.string.RestoreEmailTroubleText)); } else { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage(LocaleController.getString("YourEmailSkipWarningText", R.string.YourEmailSkipWarningText)); builder.setTitle( LocaleController.getString("YourEmailSkipWarning", R.string.YourEmailSkipWarning)); builder.setPositiveButton( LocaleController.getString("YourEmailSkip", R.string.YourEmailSkip), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { email = ""; setNewPassword(false); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } } } }); if (type == 0) { progressView = new FrameLayout(context); frameLayout.addView(progressView); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; progressView.setLayoutParams(layoutParams); progressView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); ProgressBar progressBar = new ProgressBar(context); progressView.addView(progressBar); layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams(); layoutParams.width = LayoutHelper.WRAP_CONTENT; layoutParams.height = LayoutHelper.WRAP_CONTENT; layoutParams.gravity = Gravity.CENTER; progressView.setLayoutParams(layoutParams); listView = new ListView(context); listView.setDivider(null); listView.setEmptyView(progressView); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); listView.setDrawSelectorOnTop(true); frameLayout.addView(listView); layoutParams = (FrameLayout.LayoutParams) listView.getLayoutParams(); layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = LayoutHelper.MATCH_PARENT; layoutParams.gravity = Gravity.TOP; listView.setLayoutParams(layoutParams); listView.setAdapter(listAdapter = new ListAdapter(context)); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) { if (i == setPasswordRow || i == changePasswordRow) { TwoStepVerificationActivity fragment = new TwoStepVerificationActivity(1); fragment.currentPasswordHash = currentPasswordHash; fragment.currentPassword = currentPassword; presentFragment(fragment); } else if (i == setRecoveryEmailRow || i == changeRecoveryEmailRow) { TwoStepVerificationActivity fragment = new TwoStepVerificationActivity(1); fragment.currentPasswordHash = currentPasswordHash; fragment.currentPassword = currentPassword; fragment.emailOnly = true; fragment.passwordSetState = 3; presentFragment(fragment); } else if (i == turnPasswordOffRow || i == abortPasswordRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage(LocaleController.getString("TurnPasswordOffQuestion", R.string.TurnPasswordOffQuestion)); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { setNewPassword(true); } }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showDialog(builder.create()); } } }); updateRows(); actionBar.setTitle(LocaleController.getString("TwoStepVerification", R.string.TwoStepVerification)); titleTextView.setText( LocaleController.getString("PleaseEnterCurrentPassword", R.string.PleaseEnterCurrentPassword)); } else if (type == 1) { setPasswordSetState(passwordSetState); } return fragmentView; }
From source file:org.hansel.myAlert.Rastreo.java
protected void createPasswordDialog(final Button btnPanico) { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle("Contrasea para cancelar..."); alert.setMessage("Contrasea:"); // Set an EditText view to get user input final EditText input = new EditText(getActivity()); input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); alert.setView(input);//from w w w . j av a 2 s . com alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); //encriptamos el password y lo comparamos con el guardado /* String hash = SimpleCrypto.md5(SimpleCrypto.MD5_KEY); if(hash.length()>0) { String encrypted= SimpleCrypto.encrypt(value, hash); if(encrypted.length()>0) { value = encrypted; } }*/ boolean isOK = usuarioDao.getPassword(value.trim()); if (isOK && btnPanico.getId() == R.id.IniciaTrackId) //buscar en la BD la contrasea { Log.v("Detener Rastreo"); alarmManager.cancel(getPendingAlarm()); btnPanico.setText(START_TRACK); Util.setRunningService(getActivity().getApplicationContext(), false); getActivity().stopService( new Intent(getActivity().getApplicationContext(), LocationManagement.class)); alarmManager.cancel(Util.getPendingAlarmPanicButton(getActivity().getApplicationContext())); corriendo = false; Toast.makeText(getActivity(), "Rastreo Detenido", Toast.LENGTH_SHORT).show(); PreferenciasHancel.setAlarmStartDate(getActivity(), 0); return; } else if (isOK && btnPanico.getId() == R.id.btnCancelCurrentTrack) { //cancelamos alarma para iniciar servicio //alarmManager.cancel(Util.getServicePendingIntent (getActivity())); cancelAlarms(); Toast.makeText(getActivity(), "Programacin de Rastreo Cancelado", Toast.LENGTH_SHORT).show(); showCurrentTrackInfo(false); PreferenciasHancel.setAlarmStartDate(getActivity(), 0); } else if (isOK && btnPanico.getId() == R.id.btnModifyCurrentTrack) { startActivityForResult(new Intent(getActivity(), TrackDialog.class), REQUEST_CODE); } else { Toast.makeText(getActivity(), "Contrasea Incorrecta", Toast.LENGTH_SHORT).show(); return; } } }); alert.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); alert.show(); }
From source file:com.emobc.android.activities.generators.FormActivityGenerator.java
private EditText insertPasswordField(Activity activity, FormDataItem dataItem) { EditText txt = insertTextField(activity, dataItem); txt.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); return txt;/*from w w w . j a va 2s.c o m*/ }
From source file:com.romanenco.gitt.BrowserActivity.java
/** * When pull from origin there are several case. * 1. We are in TAG (detached head): will inform user to * checkout a branch first./*from w ww . jav a 2s . co m*/ * 2. Authentication required: ask for password (no passwd save). * 3. Anonymous user: just poll. */ private void pullFromOrigin() { if (current.getUserName() == null) { //no authentication required current.setState(Repo.State.Busy); DAO dao = new DAO(BrowserActivity.this); dao.open(true); dao.update(current); dao.close(); Intent pull = new Intent(this, GitService.class); pull.putExtra(GitService.COMMAND, GitService.Command.Pull); pull.putExtra(GitService.REPO, current); startService(pull); Intent main = new Intent(this, MainActivity.class); main.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(main); } else { String req = getString(R.string.passwd_request, current.getUserName()); final EditText passwd = new EditText(this); passwd.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); AlertDialog dlg = new AlertDialog.Builder(this).setMessage(req) .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { String password = passwd.getText().toString(); if (TextUtils.isEmpty(password)) { pullFromOrigin(); } else { current.setState(Repo.State.Busy); DAO dao = new DAO(BrowserActivity.this); dao.open(true); dao.update(current); dao.close(); Intent pull = new Intent(BrowserActivity.this, GitService.class); pull.putExtra(GitService.COMMAND, GitService.Command.Pull); pull.putExtra(GitService.REPO, current); pull.putExtra(GitService.AUTH_PASSWD, password); startService(pull); Intent main = new Intent(BrowserActivity.this, MainActivity.class); main.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(main); } } }).setNegativeButton(getString(android.R.string.cancel), null).create(); dlg.setCanceledOnTouchOutside(false); dlg.setView(passwd); dlg.show(); } }
From source file:org.kontalk.ui.MainActivity.java
@Override protected Dialog onCreateDialog(int id, Bundle args) { switch (id) { case DIALOG_AUTH_ERROR_WARNING: return new MaterialDialog.Builder(this).title(R.string.title_auth_error) .content(R.string.msg_auth_error).positiveText(android.R.string.ok).build(); case DIALOG_AUTH_REQUEST_PASSWORD: return new MaterialDialog.Builder(this).title(R.string.title_passphrase_request) .inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD) .input(0, 0, true, new MaterialDialog.InputCallback() { @Override//from w w w . j ava 2 s .c o m public void onInput(@NonNull MaterialDialog dialog, CharSequence input) { String passphrase = input.toString(); // user-entered passphrase is hashed String hashed = MessageUtils.sha1(passphrase); Authenticator.setPassphrase(MainActivity.this, hashed, true); Kontalk.get(MainActivity.this).invalidatePersonalKey(); if (isPasswordValid()) { MessageCenterService.start(MainActivity.this); } else { Toast.makeText(MainActivity.this, R.string.err_invalid_passphrase, Toast.LENGTH_LONG).show(); } } }).onNegative(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { finish(); } }).negativeText(android.R.string.cancel).positiveText(android.R.string.ok).build(); } return super.onCreateDialog(id, args); }
From source file:com.doplgangr.secrecy.views.VaultsListFragment.java
void add() { final View dialogView = View.inflate(context, R.layout.new_credentials, null); final EditText password = new EditText(context); password.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); new AlertDialog.Builder(context).setTitle(getString(R.string.Vault__new)).setView(dialogView) .setPositiveButton(getString(R.string.OK), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String name = ((EditText) dialogView.findViewById(R.id.newName)).getText().toString(); String password = ((EditText) dialogView.findViewById(R.id.stealth_keycode)).getText() .toString(); String Confirmpassword = ((EditText) dialogView.findViewById(R.id.confirmPassword)) .getText().toString(); File directory = new File(Storage.getRoot().getAbsolutePath() + "/" + name); if (!password.equals(Confirmpassword) || "".equals(password)) passwordWrong(); else if (directory.mkdirs()) { // Create vault to initialize the vault header ProgressDialog progress = new ProgressDialog(context); progress.setIndeterminate(true); progress.setMessage(getString(R.string.Vault__initializing)); progress.setCancelable(false); progress.show(); createVaultInBackground(name, password, directory, dialog, progress); } else failedtocreate(); }/*from ww w. j ava 2 s . c om*/ }).setNegativeButton(getString(R.string.CANCEL), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. } }).show(); }