九宫格加密验证密码

pull/4/head
JackyMa 3 years ago
parent 4cea143bbe
commit 70d56f03ab

@ -303,7 +303,7 @@ public class NotesProvider extends ContentProvider {
return null; return null;
} }
public static boolean isStarNote(Long id) { public static boolean isStarNoteOrLockedNote(Long id) {
SQLiteDatabase db; SQLiteDatabase db;
db = mHelper.getReadableDatabase(); db = mHelper.getReadableDatabase();
Cursor cursor = null; Cursor cursor = null;
@ -313,7 +313,7 @@ public class NotesProvider extends ContentProvider {
//遍历游标 //遍历游标
for (int index = 1; index < cursor.getCount(); index++) { for (int index = 1; index < cursor.getCount(); index++) {
cursor.moveToNext(); cursor.moveToNext();
if (cursor.getLong(SqlNote.ID_COLUMN) == id && !cursor.getString(SqlNote.STAR_COLUMN).equals("0")) { if (cursor.getLong(SqlNote.ID_COLUMN) == id && !cursor.getString(SqlNote.STAR_COLUMN).equals("0") && !cursor.getString(SqlNote.PASSCODE_COLUMN).equals("")) {
cursor.close(); cursor.close();
return true; return true;
} }

@ -49,7 +49,7 @@ public class SqlNote {
NoteColumns.NOTES_COUNT, NoteColumns.PARENT_ID, NoteColumns.SNIPPET, NoteColumns.TYPE, NoteColumns.NOTES_COUNT, NoteColumns.PARENT_ID, NoteColumns.SNIPPET, NoteColumns.TYPE,
NoteColumns.WIDGET_ID, NoteColumns.WIDGET_TYPE, NoteColumns.SYNC_ID, NoteColumns.WIDGET_ID, NoteColumns.WIDGET_TYPE, NoteColumns.SYNC_ID,
NoteColumns.LOCAL_MODIFIED, NoteColumns.ORIGIN_PARENT_ID, NoteColumns.GTASK_ID, NoteColumns.LOCAL_MODIFIED, NoteColumns.ORIGIN_PARENT_ID, NoteColumns.GTASK_ID,
NoteColumns.VERSION,NoteColumns.TOP,NoteColumns.STAR, NoteColumns.VERSION,NoteColumns.TOP,NoteColumns.STAR,NoteColumns.PASSCODE,
}; };
public static final int ID_COLUMN = 0; public static final int ID_COLUMN = 0;
@ -90,6 +90,8 @@ public class SqlNote {
public static final int STAR_COLUMN = 18; public static final int STAR_COLUMN = 18;
public static final int PASSCODE_COLUMN = 18;
private Context mContext; private Context mContext;
private ContentResolver mContentResolver; private ContentResolver mContentResolver;

@ -65,7 +65,7 @@ public class DataUtils {
/** /**
* if can delete * if can delete
*/ */
if (NotesProvider.isStarNote(id)){ if (NotesProvider.isStarNoteOrLockedNote(id)){
continue; continue;
} }
ContentProviderOperation.Builder builder = ContentProviderOperation ContentProviderOperation.Builder builder = ContentProviderOperation

@ -143,6 +143,9 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private static final int SHORTCUT_ICON_TITLE_MAX_LEN = 10; private static final int SHORTCUT_ICON_TITLE_MAX_LEN = 10;
private static final int REQUEST_SET_PASSCODE = 0;
private static final int REQUEST_UNLOCK = 1;
public static final String TAG_CHECKED = String.valueOf('\u221A'); public static final String TAG_CHECKED = String.valueOf('\u221A');
public static final String TAG_UNCHECKED = String.valueOf('\u25A1'); public static final String TAG_UNCHECKED = String.valueOf('\u25A1');
@ -151,6 +154,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private String mUserQuery; private String mUserQuery;
private Pattern mPattern; private Pattern mPattern;
private boolean Locked; /* 用以判断是否已解锁 */
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -261,6 +266,12 @@ public class NoteEditActivity extends Activity implements OnClickListener,
return false; return false;
} }
mWorkingNote.setOnSettingStatusChangedListener(this); mWorkingNote.setOnSettingStatusChangedListener(this);
Locked = mWorkingNote.hasPasscode();//设置便签解锁状态;
if (intent.hasExtra("lock")) {
Locked = false;
}
return true; return true;
} }
@ -296,6 +307,14 @@ public class NoteEditActivity extends Activity implements OnClickListener,
*/ */
showAlertHeader(); showAlertHeader();
showTopHeader(); showTopHeader();
//如果设置了密码,启动输入密码页面
if (mWorkingNote.hasPasscode() && Locked) {
saveNote();
Intent intent = new Intent(this,UnlockActivity.class);
intent.putExtra(Intent.EXTRA_UID, mWorkingNote.getNoteId());
startActivityForResult(intent,REQUEST_SET_PASSCODE);
finish();
}
} }
private void showAlertHeader() { private void showAlertHeader() {

Loading…
Cancel
Save