use of android.text.method.PasswordTransformationMethod in project Bitocle by mthli.
the class SplashActivity method showSignInDialog.
private void showSignInDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(SplashActivity.this);
LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.splash_dialog, null);
final EditText userText = (EditText) layout.findViewById(R.id.splash_sign_in_dialog_username);
final EditText passText = (EditText) layout.findViewById(R.id.splash_sign_in_dialog_password);
passText.setTypeface(Typeface.DEFAULT);
passText.setTransformationMethod(new PasswordTransformationMethod());
builder.setView(layout);
builder.setPositiveButton(getString(R.string.splash_sign_in_dialog_ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
username = userText.getText().toString();
password = passText.getText().toString();
if (username.length() == 0 || password.length() == 0) {
Toast.makeText(SplashActivity.this, R.string.splash_input_error, Toast.LENGTH_SHORT).show();
} else {
progress = new ProgressDialog(SplashActivity.this);
progress.setMessage(getString(R.string.splash_sign_in_authenticating));
progress.setCancelable(false);
progress.show();
HandlerThread thread = new HandlerThread(getString(R.string.splash_sign_in_thread));
thread.start();
Handler handler = new Handler(thread.getLooper());
handler.post(signInThread);
}
}
});
builder.setNegativeButton(getString(R.string.splash_sign_in_dialog_cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
/* Do nothing */
}
});
builder.show();
}
use of android.text.method.PasswordTransformationMethod in project Bitocle by mthli.
the class LoginActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
/*
* 检测用户登陆状态
*
* 如果SharedPreferences中存在用户信息,
* 则说明用户已经登陆,此时直接跳转到MainActivity即可;
* 否则进入登陆界面
*/
sharedPreferences = getSharedPreferences(getString(R.string.login_sp), MODE_PRIVATE);
String oAuth = sharedPreferences.getString(getString(R.string.login_sp_oauth), null);
if (oAuth != null) {
Intent intent = new Intent(LoginActivity.this, MainActivity.class);
intent.putExtra(getString(R.string.login_intent), false);
startActivity(intent);
finish();
}
getActionBar().setDisplayShowHomeEnabled(false);
final EditText userText = (EditText) findViewById(R.id.login_username);
final EditText passText = (EditText) findViewById(R.id.login_password);
/* 保持EditText字体的一致性 */
passText.setTypeface(Typeface.DEFAULT);
passText.setTransformationMethod(new PasswordTransformationMethod());
Button button = (Button) findViewById(R.id.login_button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
username = userText.getText().toString();
password = passText.getText().toString();
/* 给出相应的错误提示 */
if (username.length() == 0 && password.length() == 0) {
SuperToast.create(LoginActivity.this, getString(R.string.login_message_miss_both), SuperToast.Duration.SHORT, Style.getStyle(Style.RED)).show();
} else if (username.length() != 0 && password.length() == 0) {
SuperToast.create(LoginActivity.this, getString(R.string.login_message_miss_password), SuperToast.Duration.SHORT, Style.getStyle(Style.RED)).show();
} else if (username.length() == 0 && password.length() != 0) {
SuperToast.create(LoginActivity.this, getString(R.string.login_message_miss_username), SuperToast.Duration.SHORT, Style.getStyle(Style.RED)).show();
} else {
/* ProgressDialog显示当前正在运行的状态 */
progressDialog = new ProgressDialog(LoginActivity.this);
progressDialog.setMessage(getString(R.string.login_message_authoring));
progressDialog.setCancelable(false);
progressDialog.show();
/* 开启新的线程用于认证 */
HandlerThread handlerThread = new HandlerThread(getString(R.string.login_thread));
handlerThread.start();
Handler handler = new Handler(handlerThread.getLooper());
handler.post(authorizationThread);
}
}
});
}
Aggregations