List of usage examples for android.text.method SingleLineTransformationMethod SingleLineTransformationMethod
SingleLineTransformationMethod
From source file:org.brandroid.openmanager.activities.OpenExplorer.java
private void handleNetworking() { FileManager.DefaultUserInfo = new SimpleUserInfo(); final Context c = this; Preferences.Warn_Networking = getPreferences().getSetting("warn", "networking", false); SimpleUserInfo.setInteractionCallback(new UserInfoInteractionCallback() { public boolean promptPassword(String message) { String mPassword = null; View view = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.prompt_password, null); TextView tv = (TextView) view.findViewById(android.R.id.message); tv.setText(message);/*from ww w.ja va 2s . co m*/ final EditText text1 = ((EditText) view.findViewById(android.R.id.text1)); final CheckBox checkpw = (CheckBox) view.findViewById(android.R.id.checkbox); checkpw.setOnCheckedChangeListener(new OnCheckedChangeListener() { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { text1.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); text1.setTransformationMethod(new SingleLineTransformationMethod()); } else { text1.setRawInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD); text1.setTransformationMethod(new PasswordTransformationMethod()); } } }); AlertDialog dlg = new AlertDialog.Builder(c).setTitle(R.string.s_prompt_password).setView(view) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String mPassword = text1.getText().toString(); onPasswordEntered(mPassword); onYesNoAnswered(true); } }).setNegativeButton(android.R.string.no, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onYesNoAnswered(false); } }).create(); dlg.show(); return true; } @Override public void onYesNoAnswered(boolean yes) { } @Override public void onPasswordEntered(String password) { } @Override public boolean promptYesNo(final String message) { runOnUiThread(new Runnable() { @Override public void run() { AlertDialog dlg = new AlertDialog.Builder(c).setMessage(message) .setPositiveButton(android.R.string.yes, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onYesNoAnswered(true); } }).setNegativeButton(android.R.string.no, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { onYesNoAnswered(false); } }).create(); dlg.show(); } }); return true; } }); try { OpenSFTP.DefaultJSch.setHostKeyRepository(new SimpleHostKeyRepo(OpenSFTP.DefaultJSch, FileManager.DefaultUserInfo, Preferences.getPreferences(getApplicationContext(), "hosts"))); OpenNetworkPath.Timeout = getPreferences().getSetting("global", "server_timeout", 20) * 1000; } catch (JSchException e) { Logger.LogWarning("Couldn't set Preference-backed Host Key Repository", e); } }