@ -1,113 +0,0 @@
|
|||||||
package net.micode.notes.tool;
|
|
||||||
|
|
||||||
public class Point {
|
|
||||||
public static int BITMAP_NORMAL = 0; // 正常
|
|
||||||
public static int BITMAP_ERROR = 1; // 错误
|
|
||||||
public static int BITMAP_PRESS = 2; // 按下
|
|
||||||
|
|
||||||
//九宫格中的点的下标(即每个点代表一个值)
|
|
||||||
private String index;
|
|
||||||
//点的状态
|
|
||||||
private int state;
|
|
||||||
//点的坐标
|
|
||||||
private float x;
|
|
||||||
private float y;
|
|
||||||
|
|
||||||
public Point() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Point(int x, int y) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIndex() {
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getState() {
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIndex(String index) {
|
|
||||||
this.index = index;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setState(int state) {
|
|
||||||
this.state = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setX(float x) {
|
|
||||||
this.x = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setY(float y) {
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 判断屏幕上的九宫格中的点能否可以进行连线
|
|
||||||
*
|
|
||||||
* @param a
|
|
||||||
* @param moveX
|
|
||||||
* @param moveY
|
|
||||||
* @param radius 点bitmap的半径
|
|
||||||
* @return 布尔型
|
|
||||||
*/
|
|
||||||
public boolean isWith(Point a, float moveX, float moveY, float radius) {
|
|
||||||
float result = (float) Math.sqrt((a.getX() - moveX)
|
|
||||||
* (a.getX() - moveX) + (a.getY() - moveY)
|
|
||||||
* (a.getY() - moveY));
|
|
||||||
if (result < 5 * radius / 4) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float getDegrees(Point a, Point b) {
|
|
||||||
float degrees = 0;
|
|
||||||
float ax = a.getX();
|
|
||||||
float ay = a.getY();
|
|
||||||
float bx = b.getX();
|
|
||||||
float by = b.getY();
|
|
||||||
|
|
||||||
if (ax == bx) {
|
|
||||||
if (by > ay) {
|
|
||||||
degrees = 90;
|
|
||||||
} else {
|
|
||||||
degrees = 270;
|
|
||||||
}
|
|
||||||
} else if (by == ay) {
|
|
||||||
if (ax > bx) {
|
|
||||||
degrees = 180;
|
|
||||||
} else {
|
|
||||||
degrees = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (ax > bx) {
|
|
||||||
if (ay > by) { // 第三象限
|
|
||||||
degrees = 180 + (float) (Math.atan2(ay - by, ax - bx) * 180 / Math.PI);
|
|
||||||
} else { // 第二象限
|
|
||||||
degrees = 180 - (float) (Math.atan2(by - ay, ax - bx) * 180 / Math.PI);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (ay > by) { // 第四象限
|
|
||||||
degrees = 360 - (float) (Math.atan2(ay - by, bx - ax) * 180 / Math.PI);
|
|
||||||
} else { // 第一象限
|
|
||||||
degrees = (float) (Math.atan2(by - ay, bx - ax) * 180 / Math.PI);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return degrees;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
|||||||
package net.micode.notes.ui;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
import net.micode.notes.R;
|
|
||||||
import net.micode.notes.model.WorkingNote;
|
|
||||||
|
|
||||||
public class DeletePasscodeActivity extends AppCompatActivity {
|
|
||||||
private LockPatternView mLockPatternView;
|
|
||||||
private String mPasswordStr;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_lock);
|
|
||||||
|
|
||||||
mLockPatternView = (LockPatternView) findViewById(R.id.lockView);
|
|
||||||
Intent pre = getIntent();
|
|
||||||
final Long noteId = pre.getLongExtra(Intent.EXTRA_UID, 0);
|
|
||||||
|
|
||||||
mLockPatternView.setLockListener(new LockPatternView.OnLockListener() {
|
|
||||||
WorkingNote mWorkingNote = WorkingNote.load(DeletePasscodeActivity.this,noteId);
|
|
||||||
String password = mWorkingNote.getPasscode();
|
|
||||||
@Override
|
|
||||||
public void getStringPassword(String password) {
|
|
||||||
mPasswordStr = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPassword() {
|
|
||||||
if (mPasswordStr.equals(password)) {
|
|
||||||
Toast.makeText(DeletePasscodeActivity.this, R.string.note_passcode_deleted, Toast.LENGTH_SHORT).show();
|
|
||||||
mWorkingNote.setPasscode("");
|
|
||||||
mWorkingNote.saveNote();
|
|
||||||
NoteEditActivity Activity = new NoteEditActivity();
|
|
||||||
Activity.NoteEditActivity.finish();
|
|
||||||
Intent intent = new Intent(DeletePasscodeActivity.this, NoteEditActivity.class);
|
|
||||||
intent.setAction(Intent.ACTION_VIEW);
|
|
||||||
intent.putExtra(Intent.EXTRA_UID, noteId);
|
|
||||||
startActivity(intent);
|
|
||||||
DeletePasscodeActivity.this.finish();
|
|
||||||
} else {
|
|
||||||
Toast.makeText(DeletePasscodeActivity.this, "密码不正确", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,106 +0,0 @@
|
|||||||
package net.micode.notes.ui;
|
|
||||||
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import androidx.appcompat.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();
|
|
||||||
}
|
|
||||||
public void onBackPressed() {
|
|
||||||
super.onBackPressed();//注释掉这行,back键不退出activity
|
|
||||||
Intent pre = getIntent();
|
|
||||||
//将密码写入数据库
|
|
||||||
long noteId = pre.getLongExtra(Intent.EXTRA_UID, 0);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
package net.micode.notes.ui;
|
|
||||||
|
|
||||||
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import net.micode.notes.model.WorkingNote;
|
|
||||||
import net.micode.notes.R;
|
|
||||||
import net.micode.notes.ui.LockPatternView;
|
|
||||||
|
|
||||||
public class UnlockActivity extends AppCompatActivity {
|
|
||||||
private LockPatternView mLockPatternView;
|
|
||||||
private String mPasswordStr;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_lock);
|
|
||||||
|
|
||||||
mLockPatternView = (LockPatternView) findViewById(R.id.lockView);
|
|
||||||
Intent pre = getIntent();
|
|
||||||
final Long noteId = pre.getLongExtra(Intent.EXTRA_UID, 0);
|
|
||||||
|
|
||||||
mLockPatternView.setLockListener(new LockPatternView.OnLockListener() {
|
|
||||||
WorkingNote mWorkingNote = WorkingNote.load(UnlockActivity.this,noteId);
|
|
||||||
String password = mWorkingNote.getPasscode();
|
|
||||||
@Override
|
|
||||||
public void getStringPassword(String password) {
|
|
||||||
mPasswordStr = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isPassword() {
|
|
||||||
if (mPasswordStr.equals(password)) {
|
|
||||||
Toast.makeText(UnlockActivity.this, "密码正确", Toast.LENGTH_SHORT).show();
|
|
||||||
Intent intent = new Intent(UnlockActivity.this,NoteEditActivity.class);
|
|
||||||
intent.setAction(Intent.ACTION_VIEW);
|
|
||||||
intent.putExtra("lock",0);
|
|
||||||
intent.putExtra(Intent.EXTRA_UID, noteId);
|
|
||||||
startActivity(intent);
|
|
||||||
UnlockActivity.this.finish();
|
|
||||||
//TODO comment or not
|
|
||||||
//return true;
|
|
||||||
} else {
|
|
||||||
Toast.makeText(UnlockActivity.this, "密码不正确", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 245 B After Width: | Height: | Size: 245 B |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 3.9 KiB After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 443 B After Width: | Height: | Size: 443 B |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 5.0 KiB After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 1.9 MiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 554 KiB After Width: | Height: | Size: 554 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
After Width: | Height: | Size: 1.4 MiB |
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |