From f1f854157c1714704e1b2e3c979ec263721fdc03 Mon Sep 17 00:00:00 2001
From: JackyMa <2433069615@qq.com>
Date: Thu, 4 Nov 2021 19:46:38 +0800
Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=AF=86=E7=A0=81=E6=97=B6?=
=?UTF-8?q?=E9=AA=8C=E8=AF=81=E5=AF=86=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/AndroidManifest.xml | 151 ++++++++++++++++++
.../net/micode/notes/data/NotesProvider.java | 24 ++-
.../net/micode/notes/gtask/data/SqlNote.java | 12 +-
.../net/micode/notes/model/WorkingNote.java | 1 +
src/java/net/micode/notes/tool/DataUtils.java | 2 +-
.../notes/ui/DeletePasscodeActivity.java | 52 ++++++
.../net/micode/notes/ui/NoteEditActivity.java | 28 +++-
.../net/micode/notes/ui/UnlockActivity.java | 1 -
src/res/values-zh-rCN/strings.xml | 1 +
src/res/values-zh-rTW/strings.xml | 1 +
src/res/values/strings.xml | 1 +
11 files changed, 263 insertions(+), 11 deletions(-)
create mode 100644 src/AndroidManifest.xml
create mode 100644 src/java/net/micode/notes/ui/DeletePasscodeActivity.java
diff --git a/src/AndroidManifest.xml b/src/AndroidManifest.xml
new file mode 100644
index 00000000..7ff62108
--- /dev/null
+++ b/src/AndroidManifest.xml
@@ -0,0 +1,151 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/java/net/micode/notes/data/NotesProvider.java b/src/java/net/micode/notes/data/NotesProvider.java
index db332530..908409ee 100644
--- a/src/java/net/micode/notes/data/NotesProvider.java
+++ b/src/java/net/micode/notes/data/NotesProvider.java
@@ -303,7 +303,7 @@ public class NotesProvider extends ContentProvider {
return null;
}
- public static boolean isStarNoteOrLockedNote(Long id) {
+ public static boolean isStarNote(Long id) {
SQLiteDatabase db;
db = mHelper.getReadableDatabase();
Cursor cursor = null;
@@ -313,7 +313,27 @@ public class NotesProvider extends ContentProvider {
//遍历游标
for (int index = 1; index < cursor.getCount(); index++) {
cursor.moveToNext();
- if (cursor.getLong(SqlNote.ID_COLUMN) == id && !cursor.getString(SqlNote.STAR_COLUMN).equals("0") && !cursor.getString(SqlNote.PASSCODE_COLUMN).equals("")) {
+ if (cursor.getLong(SqlNote.ID_COLUMN) == id && !cursor.getString(SqlNote.STAR_COLUMN).equals("0")) {
+ cursor.close();
+ return true;
+ }
+ }
+ }
+ cursor.close();
+ return false;
+ }
+
+ public static boolean isLockedNote(Long id) {
+ SQLiteDatabase db;
+ db = mHelper.getReadableDatabase();
+ Cursor cursor = null;
+ cursor = db.query(NotesDatabaseHelper.TABLE.NOTE, null, null, null, null, null, null);
+ //判断游标是否为空
+ if (cursor.moveToFirst()) {
+ //遍历游标
+ for (int index = 1; index < cursor.getCount(); index++) {
+ cursor.moveToNext();
+ if (cursor.getLong(SqlNote.ID_COLUMN) == id && !cursor.getString(SqlNote.PASSCODE_COLUMN).equals("")) {
cursor.close();
return true;
}
diff --git a/src/java/net/micode/notes/gtask/data/SqlNote.java b/src/java/net/micode/notes/gtask/data/SqlNote.java
index 4bcc3120..652de79a 100644
--- a/src/java/net/micode/notes/gtask/data/SqlNote.java
+++ b/src/java/net/micode/notes/gtask/data/SqlNote.java
@@ -90,7 +90,7 @@ public class SqlNote {
public static final int STAR_COLUMN = 18;
- public static final int PASSCODE_COLUMN = 18;
+ public static final int PASSCODE_COLUMN = 19;
private Context mContext;
@@ -128,6 +128,8 @@ public class SqlNote {
private String mStar;
+ private String mPasscode;
+
private ContentValues mDiffNoteValues;
private ArrayList mDataList;
@@ -151,6 +153,7 @@ public class SqlNote {
mVersion = 0;
mTop = getmTop();
mStar = getmStar();
+ mPasscode = getmPasscode();
mDiffNoteValues = new ContentValues();
mDataList = new ArrayList();
}
@@ -166,6 +169,7 @@ public class SqlNote {
mDiffNoteValues = new ContentValues();
mTop = getmTop();
mStar = getmStar();
+ mPasscode = getmPasscode();
}
public SqlNote(Context context, long id) {
@@ -179,6 +183,7 @@ public class SqlNote {
mDiffNoteValues = new ContentValues();
mTop = getmTop();
mStar = getmStar();
+ mPasscode = getmPasscode();
}
public String getmTop(){
@@ -189,6 +194,10 @@ public class SqlNote {
return mStar;
}
+ public String getmPasscode(){
+ return mPasscode;
+ }
+
private void loadFromCursor(long id) {
Cursor c = null;
try {
@@ -223,6 +232,7 @@ public class SqlNote {
mVersion = c.getLong(VERSION_COLUMN);
mTop = c.getString(Top_COLUMN);
mStar = c.getString(STAR_COLUMN);
+ mPasscode = c.getString(PASSCODE_COLUMN);
}
private void loadDataContent() {
diff --git a/src/java/net/micode/notes/model/WorkingNote.java b/src/java/net/micode/notes/model/WorkingNote.java
index df3de87a..028fc76e 100644
--- a/src/java/net/micode/notes/model/WorkingNote.java
+++ b/src/java/net/micode/notes/model/WorkingNote.java
@@ -70,6 +70,7 @@ public class WorkingNote {
/**记录便签所属类别*/
private int mClass;
+
private String mStar = "0";
private NoteSettingChangedListener mNoteSettingStatusListener;
diff --git a/src/java/net/micode/notes/tool/DataUtils.java b/src/java/net/micode/notes/tool/DataUtils.java
index 09609052..c99538b2 100644
--- a/src/java/net/micode/notes/tool/DataUtils.java
+++ b/src/java/net/micode/notes/tool/DataUtils.java
@@ -65,7 +65,7 @@ public class DataUtils {
/**
* if can delete
*/
- if (NotesProvider.isStarNoteOrLockedNote(id)){
+ if (NotesProvider.isStarNote(id) || NotesProvider.isLockedNote(id)){
continue;
}
ContentProviderOperation.Builder builder = ContentProviderOperation
diff --git a/src/java/net/micode/notes/ui/DeletePasscodeActivity.java b/src/java/net/micode/notes/ui/DeletePasscodeActivity.java
new file mode 100644
index 00000000..ad2c6ba1
--- /dev/null
+++ b/src/java/net/micode/notes/ui/DeletePasscodeActivity.java
@@ -0,0 +1,52 @@
+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();
+ 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;
+ }
+ });
+
+ }
+}
diff --git a/src/java/net/micode/notes/ui/NoteEditActivity.java b/src/java/net/micode/notes/ui/NoteEditActivity.java
index f27560fe..ffad76f3 100644
--- a/src/java/net/micode/notes/ui/NoteEditActivity.java
+++ b/src/java/net/micode/notes/ui/NoteEditActivity.java
@@ -155,6 +155,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private Pattern mPattern;
private boolean Locked; /* 用以判断是否已解锁 */
+ private boolean verified = false;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -271,6 +273,9 @@ public class NoteEditActivity extends Activity implements OnClickListener,
if (intent.hasExtra("lock")) {
Locked = false;
}
+ if (intent.hasExtra("verified")){
+ verified = true;
+ }
return true;
}
@@ -307,6 +312,10 @@ public class NoteEditActivity extends Activity implements OnClickListener,
*/
showAlertHeader();
showTopHeader();
+ unlockNote();
+ }
+
+ private void unlockNote(){
//如果设置了密码,启动输入密码页面
if (mWorkingNote.hasPasscode() && Locked) {
saveNote();
@@ -317,6 +326,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
}
+
private void showAlertHeader() {
if (mWorkingNote.hasClockAlert()) {
long time = System.currentTimeMillis();
@@ -582,13 +592,13 @@ public class NoteEditActivity extends Activity implements OnClickListener,
builder.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
- if(mWorkingNote.getStarId()==0) {
- System.out.println(mWorkingNote.getStarId());
+ if(mWorkingNote.getStarId()==0 && !mWorkingNote.hasPasscode()) {
deleteCurrentNote();
finish();
- System.out.println(mWorkingNote.getStarId());
- } else{
+ } else if(mWorkingNote.getStarId()==1){
showToast(R.string.error_delete_star_note);
+ } else if(mWorkingNote.hasPasscode()){
+ showToast(R.string.error_delete_locked_note);
}
//finish();
}
@@ -937,9 +947,15 @@ public class NoteEditActivity extends Activity implements OnClickListener,
* 删除便签密码
*/
private void deletePasscode() {
- mWorkingNote.setPasscode("");
+ //验证密码
+ if (mWorkingNote.hasPasscode()) {
+ saveNote();
+ Intent intent = new Intent(this,DeletePasscodeActivity.class);
+ intent.putExtra(Intent.EXTRA_UID, mWorkingNote.getNoteId());
+ startActivity(intent);
+ finish();
+ }
saveNote();
- Toast.makeText(NoteEditActivity.this,R.string.note_passcode_deleted,Toast.LENGTH_SHORT).show();
}
private void sendToDesktop() {
diff --git a/src/java/net/micode/notes/ui/UnlockActivity.java b/src/java/net/micode/notes/ui/UnlockActivity.java
index 4ff18475..48be72fb 100644
--- a/src/java/net/micode/notes/ui/UnlockActivity.java
+++ b/src/java/net/micode/notes/ui/UnlockActivity.java
@@ -11,7 +11,6 @@ import net.micode.notes.R;
import net.micode.notes.ui.LockPatternView;
public class UnlockActivity extends AppCompatActivity {
-
private LockPatternView mLockPatternView;
private String mPasswordStr;
diff --git a/src/res/values-zh-rCN/strings.xml b/src/res/values-zh-rCN/strings.xml
index b6c50509..b17a129c 100644
--- a/src/res/values-zh-rCN/strings.xml
+++ b/src/res/values-zh-rCN/strings.xml
@@ -86,6 +86,7 @@
不能置顶空便签
不能将空便签发送到桌面
不能删除星标便签
+ 不能删除加密便签
导出成功
导出失败
已将文本文件(%1$s)输出至SD卡(%2$s)目录
diff --git a/src/res/values-zh-rTW/strings.xml b/src/res/values-zh-rTW/strings.xml
index feb70a24..e0028409 100644
--- a/src/res/values-zh-rTW/strings.xml
+++ b/src/res/values-zh-rTW/strings.xml
@@ -85,6 +85,7 @@
不能爲空便籤設置鬧鐘提醒
不能將空便籤發送到桌面
不能删除星标便签
+ 不能删除加密便签
導出成功
導出失敗
已將文本文件(%1$s)導出至SD(%2$s)目錄
diff --git a/src/res/values/strings.xml b/src/res/values/strings.xml
index 7250ff55..2c92f247 100644
--- a/src/res/values/strings.xml
+++ b/src/res/values/strings.xml
@@ -92,6 +92,7 @@
Sorry, can not set top on empty note
Sorry, can not send and empty note to home
Sorry, can not delete star note
+ Sorry, can not delete locked note
Export successful
Export fail
Export text file (%1$s) to SD (%2$s) directory