|
|
|
@ -297,42 +297,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
* is not ready
|
|
|
|
|
*/
|
|
|
|
|
showAlertHeader();
|
|
|
|
|
//密码验证
|
|
|
|
|
final String mPassword = mWorkingNote.getmPassword();//读取数据库中的密码
|
|
|
|
|
if (mPassword!=null) {
|
|
|
|
|
//创建dialog,插入edittext,用户输入密码并做出检验。
|
|
|
|
|
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
|
View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null);
|
|
|
|
|
//编辑Text
|
|
|
|
|
final EditText etName = (EditText) view.findViewById(R.id.et_foler_name);
|
|
|
|
|
etName.setText("");
|
|
|
|
|
etName.setHint("请输入密码");
|
|
|
|
|
builder.setTitle("密码");
|
|
|
|
|
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
//获取输入的字符串
|
|
|
|
|
String password = etName.getText().toString();
|
|
|
|
|
Log.d("mPassword: ", mPassword);
|
|
|
|
|
Log.d("password: ", password);
|
|
|
|
|
//判断密码正确性
|
|
|
|
|
if (!password.equals(mPassword)) {
|
|
|
|
|
Log.d("密码不正确,正确密码是:",mPassword);
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
onBackPressed();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
builder.setNegativeButton("cancel", new DialogInterface.OnClickListener(){
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
onBackPressed();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
final Dialog dialog = builder.setView(view).show();
|
|
|
|
|
dialog.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void showAlertHeader() {
|
|
|
|
@ -490,46 +455,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|
|
|
|
|
}
|
|
|
|
|
mFontSizeSelector.setVisibility(View.GONE);
|
|
|
|
|
}
|
|
|
|
|
//添加设置密码的点击
|
|
|
|
|
if (id==R.id.m_locker){
|
|
|
|
|
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
|
|
|
|
final View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text,null);
|
|
|
|
|
//编辑Text
|
|
|
|
|
final EditText etName = (EditText)view.findViewById(R.id.et_foler_name);
|
|
|
|
|
etName.setText("");
|
|
|
|
|
etName.setHint("请输入密码");
|
|
|
|
|
builder.setTitle("为便签设置新密码");
|
|
|
|
|
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
|
|
|
|
@TargetApi(Build.VERSION_CODES.CUPCAKE)
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
//获取输入的字符串
|
|
|
|
|
String password = etName.getText().toString();
|
|
|
|
|
//设置密码
|
|
|
|
|
mWorkingNote.setPassword(password);
|
|
|
|
|
//设置密码成功提示
|
|
|
|
|
Toast.makeText(NoteEditActivity.this, "密码设置成功", Toast.LENGTH_SHORT).show();
|
|
|
|
|
//关闭软键盘
|
|
|
|
|
InputMethodManager inputMethodManager = (InputMethodManager)
|
|
|
|
|
getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
|
inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
|
|
|
|
|
//关闭dialog
|
|
|
|
|
dialog.dismiss();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
builder.setNegativeButton("cancel", new DialogInterface.OnClickListener() {
|
|
|
|
|
@TargetApi(Build.VERSION_CODES.CUPCAKE)
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
//关闭软键盘
|
|
|
|
|
InputMethodManager inputMethodManager = (InputMethodManager)
|
|
|
|
|
getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
|
inputMethodManager.hideSoftInputFromWindow(etName.getWindowToken(),0);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
final Dialog dialog = builder.setView(view).show();
|
|
|
|
|
dialog.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|