@ -0,0 +1,113 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,95 @@
|
||||
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();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
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;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 3.7 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 105 KiB |
After Width: | Height: | Size: 1.2 KiB |
@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector
|
||||
android:height="108dp"
|
||||
android:width="108dp"
|
||||
android:viewportHeight="108"
|
||||
android:viewportWidth="108"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="#3DDC84"
|
||||
android:pathData="M0,0h108v108h-108z"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M9,0L9,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,0L19,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M29,0L29,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M39,0L39,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M49,0L49,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M59,0L59,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M69,0L69,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M79,0L79,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M89,0L89,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M99,0L99,108"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,9L108,9"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,19L108,19"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,29L108,29"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,39L108,39"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,49L108,49"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,59L108,59"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,69L108,69"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,79L108,79"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,89L108,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M0,99L108,99"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,29L89,29"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,39L89,39"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,49L89,49"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,59L89,59"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,69L89,69"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M19,79L89,79"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M29,19L29,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M39,19L39,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M49,19L49,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M59,19L59,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M69,19L69,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
|
||||
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
|
||||
</vector>
|
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context="net.micode.notes.ui.UnlockActivity">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="48dp"
|
||||
android:gravity="center"
|
||||
android:text="请输入手势密码"
|
||||
android:textSize="24sp"/>
|
||||
|
||||
<include layout="@layout/widget_lock_view"/>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context="net.micode.notes.ui.UnlockActivity">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_activity_set_lock_title"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="48dp"
|
||||
android:gravity="center"
|
||||
android:text="设置手势密码\n(至少三个点)"
|
||||
android:textSize="24sp"/>
|
||||
|
||||
<include layout="@layout/widget_lock_view"/>
|
||||
|
||||
|
||||
<Button
|
||||
android:id="@+id/btn_password_clear"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_gravity="right"
|
||||
android:layout_margin="24dp"
|
||||
android:text="重新设置"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/splash"
|
||||
android:theme="@style/ThemeOverlay.Notesmaster.FullscreenContainer"
|
||||
tools:context=".ui.SplashActivity">
|
||||
|
||||
<!-- The primary full-screen view. This can be replaced with whatever view
|
||||
is needed to present your content, e.g. VideoView, SurfaceView,
|
||||
TextureView, etc. -->
|
||||
<TextView
|
||||
android:id="@+id/fullscreen_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:keepScreenOn="true"
|
||||
android:text="@string/dummy_content"
|
||||
android:textColor="?attr/fullscreenTextColor"
|
||||
android:textSize="50sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<!-- This FrameLayout insets its children based on system windows using
|
||||
android:fitsSystemWindows. -->
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/splash"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/fullscreen_content_controls"
|
||||
style="@style/Widget.Theme.Notesmaster.ButtonBar.Fullscreen"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:orientation="horizontal"
|
||||
tools:ignore="UselessParent">
|
||||
|
||||
<Button
|
||||
android:id="@+id/dummy_button"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/dummy_button" />
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
</FrameLayout>
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<net.micode.notes.ui.LockPatternView
|
||||
android:id="@+id/lockView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
</merge>
|
@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<declare-styleable name="FullscreenAttrs">
|
||||
<attr name="fullscreenBackgroundColor" format="color" />
|
||||
<attr name="fullscreenTextColor" format="color" />
|
||||
</declare-styleable>
|
||||
</resources>
|
@ -0,0 +1,16 @@
|
||||
<resources>
|
||||
|
||||
<style name="Theme.Notesmaster" parent="Theme.AppCompat.Light" />
|
||||
|
||||
<style name="Theme.Notesmaster.Fullscreen" parent="Theme.Notesmaster">
|
||||
<item name="android:actionBarStyle">@style/Widget.Theme.Notesmaster.ActionBar.Fullscreen
|
||||
</item>
|
||||
<item name="android:windowActionBarOverlay">true</item>
|
||||
<item name="android:windowBackground">@null</item>
|
||||
</style>
|
||||
|
||||
<style name="ThemeOverlay.Notesmaster.FullscreenContainer" parent="">
|
||||
<item name="fullscreenBackgroundColor">@color/light_blue_600</item>
|
||||
<item name="fullscreenTextColor">@color/light_blue_A200</item>
|
||||
</style>
|
||||
</resources>
|