From caf05a48998c0f66cb41f1d29f93d3c09e4be3d2 Mon Sep 17 00:00:00 2001 From: p6zpjanrb <1157949412@qq.com> Date: Wed, 17 Jan 2024 17:17:02 +0800 Subject: [PATCH] ADD file via upload --- .../SetLockActivity.java | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 src%2Fnet%2Fmicode%2Fnotes%2Fui/SetLockActivity.java diff --git a/src%2Fnet%2Fmicode%2Fnotes%2Fui/SetLockActivity.java b/src%2Fnet%2Fmicode%2Fnotes%2Fui/SetLockActivity.java new file mode 100644 index 0000000..feb2bea --- /dev/null +++ b/src%2Fnet%2Fmicode%2Fnotes%2Fui/SetLockActivity.java @@ -0,0 +1,95 @@ +package net.micode.notes.ui; + + +import android.content.Intent; +import android.os.Bundle; +import android.support.v7.app.AppCompatActivity; +import android.view.View; +import android.widget.Button; +import android.widget.TextView; +import android.widget.Toast; + +import net.micode.notes.model.WorkingNote; +import net.micode.notes.R; +import net.micode.notes.ui.LockPatternView; + +public class SetLockActivity extends AppCompatActivity { + + private TextView mTitleTv; + private LockPatternView mLockPatternView; + // private LinearLayout mBottomLayout; + private Button mClearBtn; +// private Button mConfirmBtn; + + private String mPassword; + /** + * 是否是第一次输入密码 + */ + private boolean isFirst = true; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_set_lock); + + initViews(); + initEvents(); + } + + private void initEvents() { + mLockPatternView.setLockListener(new LockPatternView.OnLockListener() { + @Override + public void getStringPassword(String password) { + if (isFirst) { + mPassword = password; + mTitleTv.setText("再次输入手势密码"); + isFirst = false; + mClearBtn.setVisibility(View.VISIBLE); + } else { + if (password.equals(mPassword)) { + Intent pre = getIntent(); + //将密码写入数据库 + long noteId = pre.getLongExtra(Intent.EXTRA_UID, 0); + WorkingNote mWorkingNote = WorkingNote.load(SetLockActivity.this,noteId); + mWorkingNote.setPasscode(password); + boolean saved = mWorkingNote.saveNote();//保存便签 + Intent intent = new Intent(SetLockActivity.this, NoteEditActivity.class); + intent.setAction(Intent.ACTION_VIEW); + intent.putExtra("lock",0); + intent.putExtra(Intent.EXTRA_UID, noteId); + startActivity(intent); + SetLockActivity.this.finish(); + }else { + Toast.makeText(SetLockActivity.this,"两次密码不一致,请重新设置",Toast.LENGTH_SHORT).show(); + mPassword = ""; + mTitleTv.setText("设置手势密码"); + isFirst = true; + mClearBtn.setVisibility(View.GONE); + } + } + } + + @Override + public boolean isPassword() { + return false; + } + }); + + mClearBtn.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + mPassword = ""; + isFirst = true; + mClearBtn.setVisibility(View.GONE); + } + }); + + } + + + private void initViews() { + mTitleTv = (TextView) findViewById(R.id.tv_activity_set_lock_title); + mLockPatternView = (LockPatternView) findViewById(R.id.lockView); + mClearBtn = (Button) findViewById(R.id.btn_password_clear); + } +}