diff --git a/src/data/Notes.java b/src/data/Notes.java index 2a5b37a..c99c394 100644 --- a/src/data/Notes.java +++ b/src/data/Notes.java @@ -36,20 +36,22 @@ public class Notes { // 定义类,给模块的其他类提供变量定义 public static final int ID_CALL_RECORD_FOLDER = -2; public static final int ID_TRASH_FOLER = -3; - public static final String INTENT_EXTRA_ALERT_DATE = "net.micode.notes.alert_date"; + public static final String INTENT_EXTRA_ALERT_DATE = "net.micode.notes.alert_date";// 设置提醒日期 public static final String INTENT_EXTRA_BACKGROUND_ID = "net.micode.notes.background_color_id"; public static final String INTENT_EXTRA_WIDGET_ID = "net.micode.notes.widget_id"; public static final String INTENT_EXTRA_WIDGET_TYPE = "net.micode.notes.widget_type"; public static final String INTENT_EXTRA_FOLDER_ID = "net.micode.notes.folder_id"; public static final String INTENT_EXTRA_CALL_DATE = "net.micode.notes.call_date"; + public static final String INTENT_EXTRA_LOCK = "net.micode.notes.lock";// 设置锁 + public static final int TYPE_WIDGET_INVALIDE = -1; public static final int TYPE_WIDGET_2X = 0; public static final int TYPE_WIDGET_4X = 1; public static class DataConstants { // 获取记录 - public static final String NOTE = TextNote.CONTENT_ITEM_TYPE; - public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE; + public static final String NOTE = TextNote.CONTENT_ITEM_TYPE; // 获取便签 + public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE; // 获取通话记录 } /** @@ -199,6 +201,23 @@ public class Notes { // 定义类,给模块的其他类提供变量定义 *

*/ public static final String VERSION = "version"; // 版本名称 + + /* + * The lock status + *

+ * Type : INTEGER (long) + *

+ */ + public static final String LOCKED = "locked"; // 锁定状态 **** + + /* + * The picture + *

+ * Type : BLOB + *

+ */ + public static final String PICTURE = "picture"; // 图片**** + } public interface DataColumns { // 定义数据变量接口 @@ -296,7 +315,7 @@ public class Notes { // 定义类,给模块的其他类提供变量定义 public static final String DATA5 = "data5"; } - public static final class TextNote implements DataColumns { + public static final class TextNote implements DataColumns {// 定义文本便签数据列 /** * Mode to indicate the text in check list mode or not *

@@ -308,14 +327,14 @@ public class Notes { // 定义类,给模块的其他类提供变量定义 public static final int MODE_CHECK_LIST = 1; // 列表检查模式 - public static final String CONTENT_TYPE = "vnd.android.cursor.dir/text_note"; + public static final String CONTENT_TYPE = "vnd.android.cursor.dir/text_note";// 访问数据表类型, - public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/text_note"; + public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/text_note";// 访问数据表类型 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note");// 访问数据表uri } - public static final class CallNote implements DataColumns { + public static final class CallNote implements DataColumns { // 定义电话记录数据列, implements是实现接口 /** * Call date for this record *

@@ -332,9 +351,9 @@ public class Notes { // 定义类,给模块的其他类提供变量定义 */ public static final String PHONE_NUMBER = DATA3; // 呼叫号码 - public static final String CONTENT_TYPE = "vnd.android.cursor.dir/call_note"; + public static final String CONTENT_TYPE = "vnd.android.cursor.dir/call_note";// 访问电话记录类型 - public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/call_note"; + public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/call_note";// 访问电话记录类型 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/call_note");// 访问电话记录uri } diff --git a/src/data/NotesDatabaseHelper.java b/src/data/NotesDatabaseHelper.java index 1552f98..41c711f 100644 --- a/src/data/NotesDatabaseHelper.java +++ b/src/data/NotesDatabaseHelper.java @@ -42,7 +42,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { // 该类为便签SQ private static NotesDatabaseHelper mInstance; // 创建NotesDatabaseHelper类对象 - private static final String CREATE_NOTE_TABLE_SQL = // SQL语句,创建便签表,包含ID、最后修改日期、背景颜色、便签数等在Notes类中的内容 + private static final String CREATE_NOTE_TABLE_SQL = // SQL语句,创建便签表,包含ID、父ID、提醒日期、背景颜色ID、创建日期、是否有附件、修改日期、便签数、便签内容、便签类型、便签小部件ID、便签小部件类型、同步ID、本地修改时间、原始ID、便签的同步状态、版本号 "CREATE TABLE " + TABLE.NOTE + "(" + NoteColumns.ID + " INTEGER PRIMARY KEY," + NoteColumns.PARENT_ID + " INTEGER NOT NULL DEFAULT 0," + @@ -61,6 +61,10 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { // 该类为便签SQ NoteColumns.ORIGIN_PARENT_ID + " INTEGER NOT NULL DEFAULT 0," + NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," + NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0" + + + NoteColumns.LOCKED + " INTEGER NOT NULL DEFAULT 0" + + NoteColumns.PICTURE_URI + " TEXT NOT NULL DEFAULT ''," + + ")"; private static final String CREATE_DATA_TABLE_SQL = // 创建数据表的SQL语句 @@ -286,14 +290,14 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { // 该类为便签SQ db.execSQL(DATA_UPDATE_NOTE_CONTENT_ON_DELETE_TRIGGER); // 重新创建被删除的触发器 } - static synchronized NotesDatabaseHelper getInstance(Context context) { + static synchronized NotesDatabaseHelper getInstance(Context context) { // synchronized是同步的意思,同步方法,用于返回NotesDatabaseHelper的对象实例mInstance if (mInstance == null) { mInstance = new NotesDatabaseHelper(context); } return mInstance; } // 静态同步方法,用于返回NotesDatabaseHelper的对象实例mInstance - @Override + @Override // 重写方法 public void onCreate(SQLiteDatabase db) { createNoteTable(db); // 创建便签表 createDataTable(db); // 创建数据表 @@ -339,7 +343,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { // 该类为便签SQ createDataTable(db); } - private void upgradeToV3(SQLiteDatabase db) { + private void upgradeToV3(SQLiteDatabase db) { // 升级版本并重建表 // drop unused triggers db.execSQL("DROP TRIGGER IF EXISTS update_note_modified_date_on_insert"); db.execSQL("DROP TRIGGER IF EXISTS update_note_modified_date_on_delete"); diff --git a/src/data/NotesProvider.java b/src/data/NotesProvider.java index 719d1c8..798c356 100644 --- a/src/data/NotesProvider.java +++ b/src/data/NotesProvider.java @@ -70,7 +70,7 @@ public class NotesProvider extends ContentProvider {// uri操作相关类,用 + "TRIM(REPLACE(" + NoteColumns.SNIPPET + ", x'0A','')) AS " + SearchManager.SUGGEST_COLUMN_TEXT_2 + "," + R.drawable.search_result + " AS " + SearchManager.SUGGEST_COLUMN_ICON_1 + "," + "'" + Intent.ACTION_VIEW + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_ACTION + "," - + "'" + Notes.TextNote.CONTENT_TYPE + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_DATA; // ... + + "'" + Notes.TextNote.CONTENT_TYPE + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_DATA; // 设置搜索结果的显示方式 private static String NOTES_SNIPPET_SEARCH_QUERY = "SELECT " + NOTES_SEARCH_PROJECTION + " FROM " + TABLE.NOTE @@ -147,7 +147,7 @@ public class NotesProvider extends ContentProvider {// uri操作相关类,用 } @Override - public Uri insert(Uri uri, ContentValues values) { // uri表示要插入的uri,values表示要插入的数据 + public Uri insert(Uri uri, ContentValues values) { // uri表示要插入的uri,values表示要插入的数据,返回插入数据的uri SQLiteDatabase db = mHelper.getWritableDatabase(); // 打开或创建一个数据库 long dataId = 0, noteId = 0, insertedId = 0; switch (mMatcher.match(uri)) { // 匹配uri @@ -181,7 +181,7 @@ public class NotesProvider extends ContentProvider {// uri操作相关类,用 } @Override - public int delete(Uri uri, String selection, String[] selectionArgs) { // 表示要删除的uri、SQL中的WHERE与参数 + public int delete(Uri uri, String selection, String[] selectionArgs) { // 表示要删除的uri、SQL中的WHERE与参数,返回删除的记录数 int count = 0; // 表示删除记录数 String id = null; SQLiteDatabase db = mHelper.getWritableDatabase(); // 打开数据库