Type: INTEGER (long)
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String ID = "_id"; +======= + public static final String ID = "_id";// 行的唯一标识符 +>>>>>>> liuyitao-branch ======= public static final String ID = "_id";// 行的唯一标识符 >>>>>>> liuyitao-branch @@ -138,8 +164,12 @@ public class Notes { * The parent's id for note or folder *Type: INTEGER (long)
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String PARENT_ID = "parent_id"; +======= + public static final String PARENT_ID = "parent_id";// 父级的ID +>>>>>>> liuyitao-branch ======= public static final String PARENT_ID = "parent_id";// 父级的ID >>>>>>> liuyitao-branch @@ -148,8 +178,12 @@ public class Notes { * Created data for note or folder *Type: INTEGER (long)
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String CREATED_DATE = "created_date"; +======= + public static final String CREATED_DATE = "created_date";// 创建日期 +>>>>>>> liuyitao-branch ======= public static final String CREATED_DATE = "created_date";// 创建日期 >>>>>>> liuyitao-branch @@ -158,19 +192,27 @@ public class Notes { * Latest modified date *Type: INTEGER (long)
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String MODIFIED_DATE = "modified_date"; ======= public static final String MODIFIED_DATE = "modified_date";// 最后修改日期 >>>>>>> liuyitao-branch +======= + public static final String MODIFIED_DATE = "modified_date";// 最后修改日期 +>>>>>>> liuyitao-branch /** * Alert date *Type: INTEGER (long)
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String ALERTED_DATE = "alert_date"; +======= + public static final String ALERTED_DATE = "alert_date";// 提醒日期 +>>>>>>> liuyitao-branch ======= public static final String ALERTED_DATE = "alert_date";// 提醒日期 >>>>>>> liuyitao-branch @@ -179,8 +221,12 @@ public class Notes { * Folder's name or text content of note *Type: TEXT
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String SNIPPET = "snippet"; +======= + public static final String SNIPPET = "snippet";// 文件夹名称或便签的文本内容 +>>>>>>> liuyitao-branch ======= public static final String SNIPPET = "snippet";// 文件夹名称或便签的文本内容 >>>>>>> liuyitao-branch @@ -189,8 +235,12 @@ public class Notes { * Note's widget id *Type: INTEGER (long)
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String WIDGET_ID = "widget_id"; +======= + public static final String WIDGET_ID = "widget_id";// 便签的Widget ID +>>>>>>> liuyitao-branch ======= public static final String WIDGET_ID = "widget_id";// 便签的Widget ID >>>>>>> liuyitao-branch @@ -199,8 +249,12 @@ public class Notes { * Note's widget type *Type: INTEGER (long)
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String WIDGET_TYPE = "widget_type"; +======= + public static final String WIDGET_TYPE = "widget_type";// 便签的Widget类型 +>>>>>>> liuyitao-branch ======= public static final String WIDGET_TYPE = "widget_type";// 便签的Widget类型 >>>>>>> liuyitao-branch @@ -209,8 +263,12 @@ public class Notes { * Note's background color's id *Type: INTEGER (long)
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String BG_COLOR_ID = "bg_color_id"; +======= + public static final String BG_COLOR_ID = "bg_color_id";// 便签的背景颜色ID +>>>>>>> liuyitao-branch ======= public static final String BG_COLOR_ID = "bg_color_id";// 便签的背景颜色ID >>>>>>> liuyitao-branch @@ -220,8 +278,12 @@ public class Notes { * note, it has at least one attachment *Type: INTEGER
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String HAS_ATTACHMENT = "has_attachment"; +======= + public static final String HAS_ATTACHMENT = "has_attachment";// 是否有附件 +>>>>>>> liuyitao-branch ======= public static final String HAS_ATTACHMENT = "has_attachment";// 是否有附件 >>>>>>> liuyitao-branch @@ -230,8 +292,12 @@ public class Notes { * Folder's count of notes *Type: INTEGER (long)
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String NOTES_COUNT = "notes_count"; +======= + public static final String NOTES_COUNT = "notes_count";// 文件夹中的便签数量 +>>>>>>> liuyitao-branch ======= public static final String NOTES_COUNT = "notes_count";// 文件夹中的便签数量 >>>>>>> liuyitao-branch @@ -240,8 +306,12 @@ public class Notes { * The file type: folder or note *Type: INTEGER
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String TYPE = "type"; +======= + public static final String TYPE = "type";// 文件类型:文件夹或便签 +>>>>>>> liuyitao-branch ======= public static final String TYPE = "type";// 文件类型:文件夹或便签 >>>>>>> liuyitao-branch @@ -250,8 +320,12 @@ public class Notes { * The last sync id *Type: INTEGER (long)
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String SYNC_ID = "sync_id"; +======= + public static final String SYNC_ID = "sync_id";// 最后同步的ID +>>>>>>> liuyitao-branch ======= public static final String SYNC_ID = "sync_id";// 最后同步的ID >>>>>>> liuyitao-branch @@ -260,8 +334,12 @@ public class Notes { * Sign to indicate local modified or not *Type: INTEGER
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String LOCAL_MODIFIED = "local_modified"; +======= + public static final String LOCAL_MODIFIED = "local_modified";// 标识是否本地修改 +>>>>>>> liuyitao-branch ======= public static final String LOCAL_MODIFIED = "local_modified";// 标识是否本地修改 >>>>>>> liuyitao-branch @@ -270,8 +348,12 @@ public class Notes { * Original parent id before moving into temporary folder *Type : INTEGER
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String ORIGIN_PARENT_ID = "origin_parent_id"; +======= + public static final String ORIGIN_PARENT_ID = "origin_parent_id";// 移动到临时文件夹之前的原始父级ID +>>>>>>> liuyitao-branch ======= public static final String ORIGIN_PARENT_ID = "origin_parent_id";// 移动到临时文件夹之前的原始父级ID >>>>>>> liuyitao-branch @@ -280,8 +362,12 @@ public class Notes { * The gtask id *Type : TEXT
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String GTASK_ID = "gtask_id"; +======= + public static final String GTASK_ID = "gtask_id";// Google任务ID +>>>>>>> liuyitao-branch ======= public static final String GTASK_ID = "gtask_id";// Google任务ID >>>>>>> liuyitao-branch @@ -290,25 +376,35 @@ public class Notes { * The version code *Type : INTEGER (long)
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String VERSION = "version"; } ======= +======= +>>>>>>> liuyitao-branch public static final String VERSION = "version";// 版本号 } /* * 功能描述:定义DataColumns接口数据的常量,用于创建数据库表头 */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch public interface DataColumns { /** * The unique ID for a row *Type: INTEGER (long)
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String ID = "_id"; +======= + public static final String ID = "_id";// 标识符 +>>>>>>> liuyitao-branch ======= public static final String ID = "_id";// 标识符 >>>>>>> liuyitao-branch @@ -317,8 +413,12 @@ public class Notes { * The MIME type of the item represented by this row. *Type: Text
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String MIME_TYPE = "mime_type"; +======= + public static final String MIME_TYPE = "mime_type";// 数据的MIME类型 +>>>>>>> liuyitao-branch ======= public static final String MIME_TYPE = "mime_type";// 数据的MIME类型 >>>>>>> liuyitao-branch @@ -327,8 +427,12 @@ public class Notes { * The reference id to note that this data belongs to *Type: INTEGER (long)
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String NOTE_ID = "note_id"; +======= + public static final String NOTE_ID = "note_id";// 数据ID +>>>>>>> liuyitao-branch ======= public static final String NOTE_ID = "note_id";// 数据ID >>>>>>> liuyitao-branch @@ -337,8 +441,12 @@ public class Notes { * Created data for note or folder *Type: INTEGER (long)
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String CREATED_DATE = "created_date"; +======= + public static final String CREATED_DATE = "created_date";// 创建日期 +>>>>>>> liuyitao-branch ======= public static final String CREATED_DATE = "created_date";// 创建日期 >>>>>>> liuyitao-branch @@ -347,8 +455,12 @@ public class Notes { * Latest modified date *Type: INTEGER (long)
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String MODIFIED_DATE = "modified_date"; +======= + public static final String MODIFIED_DATE = "modified_date";// 最后修改日期 +>>>>>>> liuyitao-branch ======= public static final String MODIFIED_DATE = "modified_date";// 最后修改日期 >>>>>>> liuyitao-branch @@ -357,11 +469,15 @@ public class Notes { * Data's content *Type: TEXT
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String CONTENT = "content"; ======= public static final String CONTENT = "content";// 内容 >>>>>>> liuyitao-branch +======= + public static final String CONTENT = "content";// 内容 +>>>>>>> liuyitao-branch /** @@ -369,8 +485,12 @@ public class Notes { * integer data type *Type: INTEGER
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String DATA1 = "data1"; +======= + public static final String DATA1 = "data1";// 通用数据1 +>>>>>>> liuyitao-branch ======= public static final String DATA1 = "data1";// 通用数据1 >>>>>>> liuyitao-branch @@ -380,8 +500,12 @@ public class Notes { * integer data type *Type: INTEGER
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String DATA2 = "data2"; +======= + public static final String DATA2 = "data2";// 通用数据2 +>>>>>>> liuyitao-branch ======= public static final String DATA2 = "data2";// 通用数据2 >>>>>>> liuyitao-branch @@ -391,8 +515,12 @@ public class Notes { * TEXT data type *Type: TEXT
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String DATA3 = "data3"; +======= + public static final String DATA3 = "data3";// 通用数据3 +>>>>>>> liuyitao-branch ======= public static final String DATA3 = "data3";// 通用数据3 >>>>>>> liuyitao-branch @@ -402,8 +530,12 @@ public class Notes { * TEXT data type *Type: TEXT
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String DATA4 = "data4"; +======= + public static final String DATA4 = "data4";// 通用数据4 +>>>>>>> liuyitao-branch ======= public static final String DATA4 = "data4";// 通用数据4 >>>>>>> liuyitao-branch @@ -413,23 +545,30 @@ public class Notes { * TEXT data type *Type: TEXT
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String DATA5 = "data5"; } ======= +======= +>>>>>>> liuyitao-branch public static final String DATA5 = "data5";// 通用数据5 } /* * 定义了文本便签的数据结构 */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch public static final class TextNote implements DataColumns { /** * Mode to indicate the text in check list mode or not *Type: Integer 1:check list mode 0: normal mode
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String MODE = DATA1; @@ -443,6 +582,8 @@ public class Notes { } ======= +======= +>>>>>>> liuyitao-branch public static final String MODE = DATA1;// 模式 public static final int MODE_CHECK_LIST = 1;// 待办清单模式 @@ -457,14 +598,21 @@ public class Notes { /* * 定义电话便签的数据结构 */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch public static final class CallNote implements DataColumns { /** * Call date for this record *Type: INTEGER (long)
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String CALL_DATE = DATA1; +======= + public static final String CALL_DATE = DATA1;// 通话日期 +>>>>>>> liuyitao-branch ======= public static final String CALL_DATE = DATA1;// 通话日期 >>>>>>> liuyitao-branch @@ -473,6 +621,7 @@ public class Notes { * Phone number for this record *Type: TEXT
*/ +<<<<<<< HEAD <<<<<<< HEAD public static final String PHONE_NUMBER = DATA3; @@ -482,6 +631,8 @@ public class Notes { public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/call_note"); ======= +======= +>>>>>>> liuyitao-branch public static final String PHONE_NUMBER = DATA3;// 电话号码 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/call_note";// 内容类型 @@ -489,6 +640,9 @@ public class Notes { 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 +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch } } diff --git a/src/Notes-master/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java b/src/Notes-master/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java index 59ced1d..ffb00d3 100644 --- a/src/Notes-master/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java +++ b/src/Notes-master/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java @@ -16,6 +16,7 @@ package net.micode.notes.data; +<<<<<<< HEAD <<<<<<< HEAD import android.content.ContentValues; import android.content.Context; @@ -35,6 +36,8 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { public interface TABLE { ======= +======= +>>>>>>> liuyitao-branch import android.content.ContentValues;//就是用于保存一些数据(string boolean byte double float int long short ...)信息,这些信息可以被数据库操作时使用。 import android.content.Context;//加载和访问资源。(android中主要是这两个功能,但是这里具体不清楚) @@ -59,12 +62,16 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { /* * 接口,分成note和data,用于表示数据库中两种表格 * */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch public static final String NOTE = "note"; public static final String DATA = "data"; } +<<<<<<< HEAD <<<<<<< HEAD private static final String TAG = "NotesDatabaseHelper"; @@ -107,6 +114,8 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { ")"; ======= +======= +>>>>>>> liuyitao-branch private static final String TAG = "NotesDatabaseHelper";// 日志标签,用于在日志中标识数据库操作的相关信息 /* @@ -160,6 +169,9 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { /* * 创建一个名为 note_id_index 的索引,在 TABLE.DATA 表格的 DataColumns.NOTE_ID 列上创建索引,以提高查询性能 */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch private static final String CREATE_DATA_NOTE_ID_INDEX_SQL = "CREATE INDEX IF NOT EXISTS note_id_index ON " + @@ -169,12 +181,18 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { * Increase folder's note count when move note to the folder */ <<<<<<< HEAD +<<<<<<< HEAD +======= ======= +>>>>>>> liuyitao-branch /* * 在更新 TABLE.NOTE 表格的 NoteColumns.PARENT_ID 列时,增加相应文件夹的便签计数 * 通过更新 TABLE.NOTE 表格中的 NoteColumns.NOTES_COUNT 列,将其加1 */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch private static final String NOTE_INCREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER = "CREATE TRIGGER increase_folder_count_on_update "+ @@ -189,12 +207,18 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { * Decrease folder's note count when move note from folder */ <<<<<<< HEAD +<<<<<<< HEAD +======= ======= +>>>>>>> liuyitao-branch /* * 在更新 TABLE.NOTE 表格的 NoteColumns.PARENT_ID 列时,减少相应文件夹的便签计数 * 通过更新 TABLE.NOTE 表格中的 NoteColumns.NOTES_COUNT 列,将其减1 */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch private static final String NOTE_DECREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER = "CREATE TRIGGER decrease_folder_count_on_update " + @@ -210,12 +234,18 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { * Increase folder's note count when insert new note to the folder */ <<<<<<< HEAD +<<<<<<< HEAD +======= ======= +>>>>>>> liuyitao-branch /* * 在向 TABLE.NOTE 表格插入新便签时,增加相应文件夹的便签计数 * 通过更新 TABLE.NOTE 表格中的 NoteColumns.NOTES_COUNT 列,将其加1 */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch private static final String NOTE_INCREASE_FOLDER_COUNT_ON_INSERT_TRIGGER = "CREATE TRIGGER increase_folder_count_on_insert " + @@ -230,12 +260,18 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { * Decrease folder's note count when delete note from the folder */ <<<<<<< HEAD +<<<<<<< HEAD +======= ======= +>>>>>>> liuyitao-branch /* * 在从 TABLE.NOTE 表格删除便签时,减少相应文件夹的便签计数 * 通过更新 TABLE.NOTE 表格中的 NoteColumns.NOTES_COUNT 列,将其减1 */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch private static final String NOTE_DECREASE_FOLDER_COUNT_ON_DELETE_TRIGGER = "CREATE TRIGGER decrease_folder_count_on_delete " + @@ -251,12 +287,18 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { * Update note's content when insert data with type {@link DataConstants#NOTE} */ <<<<<<< HEAD +<<<<<<< HEAD +======= ======= +>>>>>>> liuyitao-branch /* * 在向 TABLE.DATA 表格插入类型为 DataConstants.NOTE 的数据时,更新对应便签的内容 * 通过更新 TABLE.NOTE 表格中的 NoteColumns.SNIPPET 列,将其设置为新插入数据的内容 */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch private static final String DATA_UPDATE_NOTE_CONTENT_ON_INSERT_TRIGGER = "CREATE TRIGGER update_note_content_on_insert " + @@ -272,12 +314,18 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { * Update note's content when data with {@link DataConstants#NOTE} type has changed */ <<<<<<< HEAD +<<<<<<< HEAD +======= ======= +>>>>>>> liuyitao-branch /* * 在更新类型为 DataConstants.NOTE 的数据时,更新对应便签的内容 * 通过触发器在 TABLE.DATA 表格上创建,在数据被更新后将新的内容更新到对应的便签中 */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch private static final String DATA_UPDATE_NOTE_CONTENT_ON_UPDATE_TRIGGER = "CREATE TRIGGER update_note_content_on_update " + @@ -293,12 +341,18 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { * Update note's content when data with {@link DataConstants#NOTE} type has deleted */ <<<<<<< HEAD +<<<<<<< HEAD +======= ======= +>>>>>>> liuyitao-branch /* * 在删除类型为 DataConstants.NOTE 的数据时,更新对应便签的内容 * 通过触发器在 TABLE.DATA 表格上创建,在数据被删除后将对应的便签内容清空 */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch private static final String DATA_UPDATE_NOTE_CONTENT_ON_DELETE_TRIGGER = "CREATE TRIGGER update_note_content_on_delete " + @@ -314,12 +368,18 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { * Delete datas belong to note which has been deleted */ <<<<<<< HEAD +<<<<<<< HEAD +======= ======= +>>>>>>> liuyitao-branch /* * 在删除便签时,同时删除该便签相关的数据 * 通过触发器在 TABLE.NOTE 表格上创建,在便签被删除后将与该便签相关的数据一并删除 */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch private static final String NOTE_DELETE_DATA_ON_DELETE_TRIGGER = "CREATE TRIGGER delete_data_on_delete " + @@ -333,12 +393,18 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { * Delete notes belong to folder which has been deleted */ <<<<<<< HEAD +<<<<<<< HEAD +======= ======= +>>>>>>> liuyitao-branch /* * 在删除文件夹时,同时删除该文件夹下的所有便签 * 通过触发器在 TABLE.NOTE 表格上创建,在文件夹被删除后将该文件夹下的所有便签一并删除。 */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch private static final String FOLDER_DELETE_NOTES_ON_DELETE_TRIGGER = "CREATE TRIGGER folder_delete_notes_on_delete " + @@ -352,12 +418,18 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { * Move notes belong to folder which has been moved to trash folder */ <<<<<<< HEAD +<<<<<<< HEAD +======= ======= +>>>>>>> liuyitao-branch /* * 在将文件夹移动到回收站时,同时将该文件夹下的所有便签一并移动到回收站 * 通过触发器在 TABLE.NOTE 表格上创建,在文件夹被移动到回收站后将该文件夹下的所有便签的父文件夹ID更新为回收站的ID */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch private static final String FOLDER_MOVE_NOTES_ON_TRASH_TRIGGER = "CREATE TRIGGER folder_move_notes_on_trash " + @@ -370,6 +442,12 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { " END"; <<<<<<< HEAD +<<<<<<< HEAD +======= + /* + * 构造函数,传入数据库的名称和版本 + */ +>>>>>>> liuyitao-branch ======= /* * 构造函数,传入数据库的名称和版本 @@ -379,7 +457,13 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { super(context, DB_NAME, null, DB_VERSION); } +<<<<<<< HEAD <<<<<<< HEAD +======= + /* + * 用于创建存储标签属性的表格 + */ +>>>>>>> liuyitao-branch ======= /* * 用于创建存储标签属性的表格 @@ -392,14 +476,20 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { Log.d(TAG, "note table has been created"); } +<<<<<<< HEAD <<<<<<< HEAD private void reCreateNoteTableTriggers(SQLiteDatabase db) { ======= +======= +>>>>>>> liuyitao-branch /* * 用于重新创建数据库中的触发器 */ private void reCreateNoteTableTriggers(SQLiteDatabase db) { // 通过执行SQL语句DROP TRIGGER IF EXISTS来删除已存在的触发器,以确保不会重复创建 +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch db.execSQL("DROP TRIGGER IF EXISTS increase_folder_count_on_update"); db.execSQL("DROP TRIGGER IF EXISTS decrease_folder_count_on_update"); @@ -408,6 +498,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { db.execSQL("DROP TRIGGER IF EXISTS increase_folder_count_on_insert"); db.execSQL("DROP TRIGGER IF EXISTS folder_delete_notes_on_delete"); db.execSQL("DROP TRIGGER IF EXISTS folder_move_notes_on_trash"); +<<<<<<< HEAD <<<<<<< HEAD db.execSQL(NOTE_INCREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER); @@ -420,6 +511,8 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { } ======= +======= +>>>>>>> liuyitao-branch // 创建新的触发器 db.execSQL(NOTE_INCREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER);// 增加文件夹计数的触发器 db.execSQL(NOTE_DECREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER);// 减少文件夹计数的触发器 @@ -433,6 +526,9 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { /* *用于创建系统文件夹,插入四个不同类型的文件夹记录到 NoteColumns 表中 */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch private void createSystemFolder(SQLiteDatabase db) { ContentValues values = new ContentValues(); @@ -441,6 +537,12 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { * call record foler for call notes */ <<<<<<< HEAD +<<<<<<< HEAD +======= + /* + * 创建通话记录文件夹 + */ +>>>>>>> liuyitao-branch ======= /* * 创建通话记录文件夹 @@ -454,6 +556,12 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { * root folder which is default folder */ <<<<<<< HEAD +<<<<<<< HEAD +======= + /* + * 根目录,即默认文件夹 + */ +>>>>>>> liuyitao-branch ======= /* * 根目录,即默认文件夹 @@ -468,6 +576,12 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { * temporary folder which is used for moving note */ <<<<<<< HEAD +<<<<<<< HEAD +======= + /* + * 临时目录,用于移动笔记 + */ +>>>>>>> liuyitao-branch ======= /* * 临时目录,用于移动笔记 @@ -482,6 +596,12 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { * create trash folder */ <<<<<<< HEAD +<<<<<<< HEAD +======= + /* + * 创建垃圾箱 + */ +>>>>>>> liuyitao-branch ======= /* * 创建垃圾箱 @@ -493,6 +613,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { db.insert(TABLE.NOTE, null, values); } +<<<<<<< HEAD <<<<<<< HEAD public void createDataTable(SQLiteDatabase db) { db.execSQL(CREATE_DATA_TABLE_SQL); @@ -502,6 +623,8 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { } ======= +======= +>>>>>>> liuyitao-branch /* * 用于创建存储标签内容的表格 */ @@ -515,6 +638,9 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { /* * 用于重新创建数据表中的触发器 */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch private void reCreateDataTableTriggers(SQLiteDatabase db) { db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_insert"); @@ -527,13 +653,19 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { } <<<<<<< HEAD +<<<<<<< HEAD +======= ======= +>>>>>>> liuyitao-branch /* * 用于获取单例的数据库帮助类对象 * 解决同一时刻只能有一个线程执行. * 在写程序库代码时,有时有一个类需要被所的其它类使用 * 但又要求这个类只能被实例化一次,是个服务类,定义一次,其它类使用同一个这个类的实例 */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch static synchronized NotesDatabaseHelper getInstance(Context context) { if (mInstance == null) { @@ -544,6 +676,12 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { @Override <<<<<<< HEAD +<<<<<<< HEAD +======= + /* + * 在数据库第一次创建时被调用,用于创建所需的表格和触发器 + */ +>>>>>>> liuyitao-branch ======= /* * 在数据库第一次创建时被调用,用于创建所需的表格和触发器 @@ -555,12 +693,15 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { } @Override +<<<<<<< HEAD <<<<<<< HEAD public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { boolean reCreateTriggers = false; boolean skipV2 = false; ======= +======= +>>>>>>> liuyitao-branch /* * 根据旧版本和新版本之间的差异来执行相应的数据库升级操作 */ @@ -570,6 +711,9 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { /* * 如果旧版本为1,则调用upgradeToV2方法 */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch if (oldVersion == 1) { upgradeToV2(db); @@ -577,7 +721,13 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { oldVersion++; } <<<<<<< HEAD +<<<<<<< HEAD +======= + /* + * 如果旧版本为2且未跳过V2升级,则调用upgradeToV3方法 + */ +>>>>>>> liuyitao-branch ======= /* * 如果旧版本为2且未跳过V2升级,则调用upgradeToV3方法 @@ -589,7 +739,13 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { oldVersion++; } <<<<<<< HEAD +<<<<<<< HEAD +======= + /* + * 如果旧版本为3,则调用upgradeToV4方法 + */ +>>>>>>> liuyitao-branch ======= /* * 如果旧版本为3,则调用upgradeToV4方法 @@ -600,7 +756,13 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { oldVersion++; } <<<<<<< HEAD +<<<<<<< HEAD +======= + /* + * 如果需要重新创建触发器,则调用reCreateNoteTableTriggers和reCreateDataTableTriggers方法重新创建触发器 + */ +>>>>>>> liuyitao-branch ======= /* * 如果需要重新创建触发器,则调用reCreateNoteTableTriggers和reCreateDataTableTriggers方法重新创建触发器 @@ -611,7 +773,13 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { reCreateDataTableTriggers(db); } <<<<<<< HEAD +<<<<<<< HEAD +======= + /* + * 如果旧版本和新版本不匹配,则抛出异常 + */ +>>>>>>> liuyitao-branch ======= /* * 如果旧版本和新版本不匹配,则抛出异常 @@ -623,6 +791,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { } } +<<<<<<< HEAD <<<<<<< HEAD private void upgradeToV2(SQLiteDatabase db) { db.execSQL("DROP TABLE IF EXISTS " + TABLE.NOTE); @@ -633,6 +802,8 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { private void upgradeToV3(SQLiteDatabase db) { ======= +======= +>>>>>>> liuyitao-branch /* * 更新到V2版本 * */ @@ -653,16 +824,22 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { /* * 执行SQL语句DROP TRIGGER IF EXISTS来移除不再使用的触发器 * */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch // 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"); db.execSQL("DROP TRIGGER IF EXISTS update_note_modified_date_on_update"); +<<<<<<< HEAD <<<<<<< HEAD // add a column for gtask id db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''"); ======= +======= +>>>>>>> liuyitao-branch /* * 执行ALTER TABLE语句向NOTE表格中添加一个新的列GTASK_ID,该列的类型是TEXT,并设置默认值为'' * */ @@ -672,6 +849,9 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { /* * 通过ContentValues对象向NOTE表格中插入一条记录,该记录代表垃圾箱系统文件夹 * */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch // add a trash system folder ContentValues values = new ContentValues(); @@ -680,17 +860,23 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { db.insert(TABLE.NOTE, null, values); } +<<<<<<< HEAD <<<<<<< HEAD private void upgradeToV4(SQLiteDatabase db) { db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0"); ======= +======= +>>>>>>> liuyitao-branch /* * 更新到V4版本 * */ private void upgradeToV4(SQLiteDatabase db) { db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0");// 通过执行ALTER TABLE语句向NOTE表格中添加一个新的列VERSION,该列的类型是INTEGER,并设置默认值为0 +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch } } diff --git a/src/Notes-master/app/src/main/java/net/micode/notes/data/NotesProvider.java b/src/Notes-master/app/src/main/java/net/micode/notes/data/NotesProvider.java index 1473b57..17b96e6 100644 --- a/src/Notes-master/app/src/main/java/net/micode/notes/data/NotesProvider.java +++ b/src/Notes-master/app/src/main/java/net/micode/notes/data/NotesProvider.java @@ -34,6 +34,7 @@ import net.micode.notes.data.Notes.DataColumns; import net.micode.notes.data.Notes.NoteColumns; import net.micode.notes.data.NotesDatabaseHelper.TABLE; +<<<<<<< HEAD <<<<<<< HEAD public class NotesProvider extends ContentProvider { @@ -45,6 +46,8 @@ public class NotesProvider extends ContentProvider { private static final int URI_NOTE = 1; ======= +======= +>>>>>>> liuyitao-branch /* * 功能描述:用于提供对便签数据的存储和获取功能,实现了创建、读取、更新、删除操作,以便其他组件可以通过 ContentResolver 访问和管理便签数据。 * */ @@ -56,6 +59,9 @@ public class NotesProvider extends ContentProvider { private static final String TAG = "NotesProvider";// 标签 private static final int URI_NOTE = 1;// Uri匹配码 +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch private static final int URI_NOTE_ITEM = 2; private static final int URI_DATA = 3; @@ -65,6 +71,7 @@ public class NotesProvider extends ContentProvider { private static final int URI_SEARCH_SUGGEST = 6; static { +<<<<<<< HEAD <<<<<<< HEAD mMatcher = new UriMatcher(UriMatcher.NO_MATCH); mMatcher.addURI(Notes.AUTHORITY, "note", URI_NOTE); @@ -75,6 +82,8 @@ public class NotesProvider extends ContentProvider { mMatcher.addURI(Notes.AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY, URI_SEARCH_SUGGEST); mMatcher.addURI(Notes.AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + "/*", URI_SEARCH_SUGGEST); ======= +======= +>>>>>>> liuyitao-branch mMatcher = new UriMatcher(UriMatcher.NO_MATCH);// 创建UriMatcher时,调用UriMatcher(UriMatcher.NO_MATCH)表示不匹配任何路径的返回码 /* * 把需要匹配Uri路径全部给注册上 @@ -86,6 +95,9 @@ public class NotesProvider extends ContentProvider { mMatcher.addURI(Notes.AUTHORITY, "search", URI_SEARCH);// 搜索的路径 mMatcher.addURI(Notes.AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY, URI_SEARCH_SUGGEST);// 搜索建议的路径 mMatcher.addURI(Notes.AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + "/*", URI_SEARCH_SUGGEST);// 带搜索关键字的搜索建议的路径 +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch } @@ -94,11 +106,17 @@ public class NotesProvider extends ContentProvider { * we will trim '\n' and white space in order to show more information. */ <<<<<<< HEAD +<<<<<<< HEAD +======= ======= +>>>>>>> liuyitao-branch /* * 查询搜索结果的投影。该投影包含了搜索结果需要的各个字段,如便签的 ID、搜索文本等 * */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch private static final String NOTES_SEARCH_PROJECTION = NoteColumns.ID + "," + NoteColumns.ID + " AS " + SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA + "," @@ -109,6 +127,12 @@ public class NotesProvider extends ContentProvider { + "'" + Notes.TextNote.CONTENT_TYPE + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_DATA; <<<<<<< HEAD +<<<<<<< HEAD +======= + /* + * 查询语句,用于查询搜索结果 + * */ +>>>>>>> liuyitao-branch ======= /* * 查询语句,用于查询搜索结果 @@ -122,6 +146,12 @@ public class NotesProvider extends ContentProvider { @Override <<<<<<< HEAD +<<<<<<< HEAD +======= + /* + *在onCreate()中初始化Context,实例化mHelper + * */ +>>>>>>> liuyitao-branch ======= /* *在onCreate()中初始化Context,实例化mHelper @@ -133,6 +163,7 @@ public class NotesProvider extends ContentProvider { } @Override +<<<<<<< HEAD <<<<<<< HEAD public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) { @@ -158,6 +189,8 @@ public class NotesProvider extends ContentProvider { c = db.query(TABLE.DATA, projection, DataColumns.ID + "=" + id + parseSelection(selection), selectionArgs, null, null, sortOrder); ======= +======= +>>>>>>> liuyitao-branch /* * 根据传入的Uri进行数据库查询操作 * */ @@ -187,14 +220,21 @@ public class NotesProvider extends ContentProvider { id = uri.getPathSegments().get(1); // 获取Uri中的ID值 c = db.query(TABLE.DATA, projection, DataColumns.ID + "=" + id + parseSelection(selection), selectionArgs, null, null, sortOrder);// 查询特定ID的数据详情 +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch break; case URI_SEARCH: case URI_SEARCH_SUGGEST: if (sortOrder != null || projection != null) { throw new IllegalArgumentException( +<<<<<<< HEAD <<<<<<< HEAD "do not specify sortOrder, selection, selectionArgs, or projection" + "with this query"); +======= + "do not specify sortOrder, selection, selectionArgs, or projection" + "with this query");// 如果存在不合法的参数则抛出异常 +>>>>>>> liuyitao-branch ======= "do not specify sortOrder, selection, selectionArgs, or projection" + "with this query");// 如果存在不合法的参数则抛出异常 >>>>>>> liuyitao-branch @@ -203,6 +243,7 @@ public class NotesProvider extends ContentProvider { String searchString = null; if (mMatcher.match(uri) == URI_SEARCH_SUGGEST) { if (uri.getPathSegments().size() > 1) { +<<<<<<< HEAD <<<<<<< HEAD searchString = uri.getPathSegments().get(1); } @@ -279,6 +320,8 @@ public class NotesProvider extends ContentProvider { case URI_NOTE_ITEM: id = uri.getPathSegments().get(1); ======= +======= +>>>>>>> liuyitao-branch searchString = uri.getPathSegments().get(1); // 获取搜索关键字 } } else { @@ -368,12 +411,16 @@ public class NotesProvider extends ContentProvider { break; case URI_NOTE_ITEM: id = uri.getPathSegments().get(1);// 获取Uri中的ID参数 +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch /** * ID that smaller than 0 is system folder which is not allowed to * trash */ long noteId = Long.valueOf(id); +<<<<<<< HEAD <<<<<<< HEAD if (noteId <= 0) { break; @@ -444,6 +491,8 @@ public class NotesProvider extends ContentProvider { } ======= +======= +>>>>>>> liuyitao-branch if (noteId <= 0) {// 如果ID小于等于0,则不允许删除 break; } @@ -522,11 +571,15 @@ public class NotesProvider extends ContentProvider { /* * 解析查询条件selection,如果selection不为空,则在其前面加上" AND ",用于拼接SQL语句 * */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch private String parseSelection(String selection) { return (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""); } +<<<<<<< HEAD <<<<<<< HEAD private void increaseNoteVersion(long id, String selection, String[] selectionArgs) { StringBuilder sql = new StringBuilder(120); @@ -555,6 +608,8 @@ public class NotesProvider extends ContentProvider { @Override ======= +======= +>>>>>>> liuyitao-branch /* * 根据传入的id和selection参数确定要更新的记录,并将版本号加1 * */ @@ -590,13 +645,19 @@ public class NotesProvider extends ContentProvider { * 输入参数:参数 uri 表示查询或操作的 URI * 函数中是环境自动生成的,也可自己改写 * */ +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch public String getType(Uri uri) { // TODO Auto-generated method stub return null; } <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> liuyitao-branch ======= >>>>>>> liuyitao-branch } diff --git a/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/MetaData.java b/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/MetaData.java index 1edcef7..f4fdcca 100644 --- a/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/MetaData.java +++ b/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/MetaData.java @@ -26,6 +26,7 @@ import org.json.JSONObject; public class MetaData extends Task { +<<<<<<< HEAD <<<<<<< HEAD /* * 功能描述:得到类的简写名称存入字符串TAG中 @@ -52,6 +53,8 @@ public class MetaData extends Task { * 输出错误信息 */ ======= +======= +>>>>>>> liuyitao-branch private final static String TAG = MetaData.class.getSimpleName(); private String mRelatedGid = null; @@ -61,11 +64,15 @@ public class MetaData extends Task { metaInfo.put(GTaskStringUtils.META_HEAD_GTASK_ID, gid); } catch (JSONException e) { Log.e(TAG, "failed to put related gid"); +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch } setNotes(metaInfo.toString()); setName(GTaskStringUtils.META_NOTE_NAME); } +<<<<<<< HEAD <<<<<<< HEAD /* * 功能描述:获取相关联的Gid @@ -77,16 +84,22 @@ public class MetaData extends Task { * 功能描述:判断当前数据是否为空,若为空则返回真即值得保存 */ ======= +======= +>>>>>>> liuyitao-branch public String getRelatedGid() { return mRelatedGid; } +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch @Override public boolean isWorthSaving() { return getNotes() != null; } +<<<<<<< HEAD <<<<<<< HEAD /* * 功能描述:使用远程json数据对象设置元数据内容 @@ -95,6 +108,9 @@ public class MetaData extends Task { */ ======= +>>>>>>> liuyitao-branch +======= + >>>>>>> liuyitao-branch @Override public void setContentByRemoteJSON(JSONObject js) { @@ -105,28 +121,36 @@ public class MetaData extends Task { mRelatedGid = metaInfo.getString(GTaskStringUtils.META_HEAD_GTASK_ID); } catch (JSONException e) { Log.w(TAG, "failed to get related gid"); +<<<<<<< HEAD <<<<<<< HEAD /* * 输出警告信息 */ ======= +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch mRelatedGid = null; } } } +<<<<<<< HEAD <<<<<<< HEAD /* * 功能描述:使用本地json数据对象设置元数据内容,一般不会用到,若用到,则抛出异常 */ ======= +>>>>>>> liuyitao-branch +======= + >>>>>>> liuyitao-branch @Override public void setContentByLocalJSON(JSONObject js) { // this function should not be called throw new IllegalAccessError("MetaData:setContentByLocalJSON should not be called"); } +<<<<<<< HEAD <<<<<<< HEAD @Override public JSONObject getLocalJSONFromContent() { @@ -146,6 +170,8 @@ public class MetaData extends Task { */ } ======= +======= +>>>>>>> liuyitao-branch @Override public JSONObject getLocalJSONFromContent() { @@ -157,5 +183,8 @@ public class MetaData extends Task { throw new IllegalAccessError("MetaData:getSyncAction should not be called"); } +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch } diff --git a/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/Node.java b/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/Node.java index 91a34fd..2fe8195 100644 --- a/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/Node.java +++ b/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/Node.java @@ -20,6 +20,7 @@ import android.database.Cursor; import org.json.JSONObject; +<<<<<<< HEAD <<<<<<< HEAD /** * 应该是同步操作的基础数据类型,定义了相关指示同步操作的常量 @@ -45,6 +46,8 @@ public abstract class Node { public static final int SYNC_ACTION_ERROR = 8;// 同步出现错误 ======= +======= +>>>>>>> liuyitao-branch public abstract class Node { public static final int SYNC_ACTION_NONE = 0; @@ -63,12 +66,16 @@ public abstract class Node { public static final int SYNC_ACTION_UPDATE_CONFLICT = 7; public static final int SYNC_ACTION_ERROR = 8; +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch private String mGid; private String mName; +<<<<<<< HEAD <<<<<<< HEAD private long mLastModified;//记录最后一次修改时间 @@ -125,6 +132,8 @@ public abstract class Node { return this.mDeleted; // 返回 mDeleted 的取值 } ======= +======= +>>>>>>> liuyitao-branch private long mLastModified; private boolean mDeleted; @@ -180,5 +189,8 @@ public abstract class Node { return this.mDeleted; } +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch } diff --git a/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/SqlData.java b/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/SqlData.java index a7c6ac0..489141e 100644 --- a/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/SqlData.java +++ b/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/SqlData.java @@ -14,6 +14,7 @@ * limitations under the License. */ +<<<<<<< HEAD <<<<<<< HEAD /* * Description:用于支持小米便签最底层的数据库相关操作,和sqlnote的关系上是子集关系,即data是note的子集(节点)。 @@ -29,6 +30,9 @@ package net.micode.notes.gtask.data; ======= package net.micode.notes.gtask.data; >>>>>>> liuyitao-branch +======= +package net.micode.notes.gtask.data; +>>>>>>> liuyitao-branch import android.content.ContentResolver; import android.content.ContentUris; @@ -50,6 +54,7 @@ import org.json.JSONObject; public class SqlData { +<<<<<<< HEAD <<<<<<< HEAD /* * 功能描述:得到类的简写名称存入字符串TAG中 @@ -65,15 +70,21 @@ public class SqlData { // 集合了interface DataColumns中所有SF常量 ======= +======= +>>>>>>> liuyitao-branch private static final String TAG = SqlData.class.getSimpleName(); private static final int INVALID_ID = -99999; +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch public static final String[] PROJECTION_DATA = new String[] { DataColumns.ID, DataColumns.MIME_TYPE, DataColumns.CONTENT, DataColumns.DATA1, DataColumns.DATA3 }; +<<<<<<< HEAD <<<<<<< HEAD /* * 以下五个变量作为sql表中5列的编号 @@ -115,6 +126,8 @@ public class SqlData { mIsCreate = true; mDataId = INVALID_ID;//mDataId置初始值-99999 ======= +======= +>>>>>>> liuyitao-branch public static final int DATA_ID_COLUMN = 0; @@ -146,6 +159,9 @@ public class SqlData { mContentResolver = context.getContentResolver(); mIsCreate = true; mDataId = INVALID_ID; +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch mDataMimeType = DataConstants.NOTE; mDataContent = ""; @@ -154,6 +170,7 @@ public class SqlData { mDiffDataValues = new ContentValues(); } +<<<<<<< HEAD <<<<<<< HEAD /* @@ -263,6 +280,8 @@ public class SqlData { } catch (NumberFormatException e) { // 如果获取ID出错则输出错误日志并抛出ActionFailureException异常 ======= +======= +>>>>>>> liuyitao-branch public SqlData(Context context, Cursor c) { mContentResolver = context.getContentResolver(); mIsCreate = false; @@ -337,6 +356,9 @@ public class SqlData { try { mDataId = Long.valueOf(uri.getPathSegments().get(1)); } catch (NumberFormatException e) { +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch Log.e(TAG, "Get note id error :" + e.toString()); throw new ActionFailureException("create note failed"); @@ -345,6 +367,7 @@ public class SqlData { if (mDiffDataValues.size() > 0) { int result = 0; if (!validateVersion) { +<<<<<<< HEAD <<<<<<< HEAD // 如果不需要验证版本,则直接通过mDataId更新mDiffDataValues到数据库中 result = mContentResolver.update(ContentUris.withAppendedId( @@ -354,11 +377,16 @@ public class SqlData { result = mContentResolver.update(ContentUris.withAppendedId( Notes.CONTENT_DATA_URI, mDataId), mDiffDataValues, ======= +======= +>>>>>>> liuyitao-branch result = mContentResolver.update(ContentUris.withAppendedId( Notes.CONTENT_DATA_URI, mDataId), mDiffDataValues, null, null); } else { result = mContentResolver.update(ContentUris.withAppendedId( Notes.CONTENT_DATA_URI, mDataId), mDiffDataValues, +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch " ? in (SELECT " + NoteColumns.ID + " FROM " + TABLE.NOTE + " WHERE " + NoteColumns.VERSION + "=?)", new String[] { @@ -366,15 +394,19 @@ public class SqlData { }); } if (result == 0) { +<<<<<<< HEAD <<<<<<< HEAD // 如果没有更新任何数据,则输出警告日志 ======= +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch Log.w(TAG, "there is no update. maybe user updates note when syncing"); } } } +<<<<<<< HEAD <<<<<<< HEAD // 清空差异数据 mDiffDataValues.clear(); @@ -390,6 +422,8 @@ public class SqlData { } ======= +======= +>>>>>>> liuyitao-branch mDiffDataValues.clear(); mIsCreate = false; } @@ -397,5 +431,8 @@ public class SqlData { public long getId() { return mDataId; } +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch } diff --git a/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/SqlNote.java b/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/SqlNote.java index 127b78a..d6db183 100644 --- a/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/SqlNote.java +++ b/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/SqlNote.java @@ -43,6 +43,7 @@ public class SqlNote { private static final int INVALID_ID = -99999; +<<<<<<< HEAD <<<<<<< HEAD // 定义查询笔记的投影,包含需要查询的列 public static final String[] PROJECTION_NOTE = new String[] { @@ -150,6 +151,8 @@ public class SqlNote { try { // 通过 ID 查询笔记数据 ======= +======= +>>>>>>> liuyitao-branch public static final String[] PROJECTION_NOTE = new String[] { NoteColumns.ID, NoteColumns.ALERTED_DATE, NoteColumns.BG_COLOR_ID, NoteColumns.CREATED_DATE, NoteColumns.HAS_ATTACHMENT, NoteColumns.MODIFIED_DATE, @@ -276,12 +279,16 @@ public class SqlNote { private void loadFromCursor(long id) { Cursor c = null; try { +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch c = mContentResolver.query(Notes.CONTENT_NOTE_URI, PROJECTION_NOTE, "(_id=?)", new String[] { String.valueOf(id) }, null); if (c != null) { +<<<<<<< HEAD <<<<<<< HEAD c.moveToNext(); // 移动到第一条数据 loadFromCursor(c); // 载入数据 @@ -292,6 +299,8 @@ public class SqlNote { if (c != null) c.close(); // 关闭游标 ======= +======= +>>>>>>> liuyitao-branch c.moveToNext(); loadFromCursor(c); } else { @@ -300,11 +309,15 @@ public class SqlNote { } finally { if (c != null) c.close(); +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch } } private void loadFromCursor(Cursor c) { +<<<<<<< HEAD <<<<<<< HEAD mId = c.getLong(ID_COLUMN); // 从游标中获取并设置 ID mAlertDate = c.getLong(ALERTED_DATE_COLUMN); // 从游标中获取并设置提醒日期 @@ -327,6 +340,8 @@ public class SqlNote { try { // 通过笔记ID查询数据内容 ======= +======= +>>>>>>> liuyitao-branch mId = c.getLong(ID_COLUMN); mAlertDate = c.getLong(ALERTED_DATE_COLUMN); mBgColorId = c.getInt(BG_COLOR_ID_COLUMN); @@ -345,6 +360,9 @@ public class SqlNote { Cursor c = null; mDataList.clear(); try { +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch c = mContentResolver.query(Notes.CONTENT_DATA_URI, SqlData.PROJECTION_DATA, "(note_id=?)", new String[] { @@ -352,6 +370,7 @@ public class SqlNote { }, null); if (c != null) { if (c.getCount() == 0) { +<<<<<<< HEAD <<<<<<< HEAD Log.w(TAG, "it seems that the note has not data");// 输出警告日志 return; @@ -367,6 +386,8 @@ public class SqlNote { if (c != null) c.close();// 关闭游标 ======= +======= +>>>>>>> liuyitao-branch Log.w(TAG, "it seems that the note has not data"); return; } @@ -380,12 +401,16 @@ public class SqlNote { } finally { if (c != null) c.close(); +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch } } public boolean setContent(JSONObject js) { try { +<<<<<<< HEAD <<<<<<< HEAD // 解析JSON对象中的note字段 JSONObject note = js.getJSONObject(GTaskStringUtils.META_HEAD_NOTE); @@ -400,6 +425,8 @@ public class SqlNote { .getString(NoteColumns.SNIPPET) : ""; // 如果正在创建一个新的note,或者之前的snippet和当前传入的snippet不相等,则更新snippet字段 ======= +======= +>>>>>>> liuyitao-branch JSONObject note = js.getJSONObject(GTaskStringUtils.META_HEAD_NOTE); if (note.getInt(NoteColumns.TYPE) == Notes.TYPE_SYSTEM) { Log.w(TAG, "cannot set system folder"); @@ -407,6 +434,9 @@ public class SqlNote { // for folder we can only update the snnipet and type String snippet = note.has(NoteColumns.SNIPPET) ? note .getString(NoteColumns.SNIPPET) : ""; +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch if (mIsCreate || !mSnippet.equals(snippet)) { mDiffNoteValues.put(NoteColumns.SNIPPET, snippet); @@ -415,14 +445,18 @@ public class SqlNote { int type = note.has(NoteColumns.TYPE) ? note.getInt(NoteColumns.TYPE) : Notes.TYPE_NOTE; +<<<<<<< HEAD <<<<<<< HEAD // 如果正在创建一个新的note,或者之前的type和当前传入的type不相等,则更新type字段 ======= +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch if (mIsCreate || mType != type) { mDiffNoteValues.put(NoteColumns.TYPE, type); } mType = type; +<<<<<<< HEAD <<<<<<< HEAD }else if (note.getInt(NoteColumns.TYPE) == Notes.TYPE_NOTE) { // 如果类型为笔记类型,则解析data数组 @@ -430,6 +464,11 @@ public class SqlNote { // 获取note的ID字段,如果没有则设置为INVALID_ID常量值 long id = note.has(NoteColumns.ID) ? note.getLong(NoteColumns.ID) : INVALID_ID; // 如果正在创建一个新的note,或者之前的id和当前传入的id不相等,则更新ID字段 +======= + } else if (note.getInt(NoteColumns.TYPE) == Notes.TYPE_NOTE) { + JSONArray dataArray = js.getJSONArray(GTaskStringUtils.META_HEAD_DATA); + long id = note.has(NoteColumns.ID) ? note.getLong(NoteColumns.ID) : INVALID_ID; +>>>>>>> liuyitao-branch ======= } else if (note.getInt(NoteColumns.TYPE) == Notes.TYPE_NOTE) { JSONArray dataArray = js.getJSONArray(GTaskStringUtils.META_HEAD_DATA); @@ -440,9 +479,14 @@ public class SqlNote { } mId = id; +<<<<<<< HEAD <<<<<<< HEAD // 解析并更新其他成员变量 long alertDate = note.has(NoteColumns.ALERTED_DATE) ? note.getLong(NoteColumns.ALERTED_DATE) : 0; +======= + long alertDate = note.has(NoteColumns.ALERTED_DATE) ? note + .getLong(NoteColumns.ALERTED_DATE) : 0; +>>>>>>> liuyitao-branch ======= long alertDate = note.has(NoteColumns.ALERTED_DATE) ? note .getLong(NoteColumns.ALERTED_DATE) : 0; @@ -452,11 +496,14 @@ public class SqlNote { } mAlertDate = alertDate; +<<<<<<< HEAD <<<<<<< HEAD // 解析snippet和type字段 String snippet = note.has(NoteColumns.SNIPPET) ? note.getString(NoteColumns.SNIPPET) : ""; // 如果正在创建一个新的note,或者之前的snippet和当前传入的snippet不相等,则更新snippet字段 ======= +======= +>>>>>>> liuyitao-branch int bgColorId = note.has(NoteColumns.BG_COLOR_ID) ? note .getInt(NoteColumns.BG_COLOR_ID) : ResourceParser.getDefaultBgId(mContext); if (mIsCreate || mBgColorId != bgColorId) { @@ -494,15 +541,23 @@ public class SqlNote { String snippet = note.has(NoteColumns.SNIPPET) ? note .getString(NoteColumns.SNIPPET) : ""; +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch if (mIsCreate || !mSnippet.equals(snippet)) { mDiffNoteValues.put(NoteColumns.SNIPPET, snippet); } mSnippet = snippet; +<<<<<<< HEAD <<<<<<< HEAD int type = note.has(NoteColumns.TYPE) ? note.getInt(NoteColumns.TYPE) : Notes.TYPE_NOTE; // 如果正在创建一个新的note,或者之前的type和当前传入的type不相等,则更新type字段 +======= + int type = note.has(NoteColumns.TYPE) ? note.getInt(NoteColumns.TYPE) + : Notes.TYPE_NOTE; +>>>>>>> liuyitao-branch ======= int type = note.has(NoteColumns.TYPE) ? note.getInt(NoteColumns.TYPE) : Notes.TYPE_NOTE; @@ -512,6 +567,7 @@ public class SqlNote { } mType = type; +<<<<<<< HEAD <<<<<<< HEAD // 遍历data数组 for (int i = 0; i < dataArray.length(); i++) { @@ -520,6 +576,8 @@ public class SqlNote { // 检查data数组中的id字段,并查找对应的SqlData对象 ======= +======= +>>>>>>> liuyitao-branch int widgetId = note.has(NoteColumns.WIDGET_ID) ? note.getInt(NoteColumns.WIDGET_ID) : AppWidgetManager.INVALID_APPWIDGET_ID; if (mIsCreate || mWidgetId != widgetId) { @@ -544,6 +602,9 @@ public class SqlNote { for (int i = 0; i < dataArray.length(); i++) { JSONObject data = dataArray.getJSONObject(i); SqlData sqlData = null; +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch if (data.has(DataColumns.ID)) { long dataId = data.getLong(DataColumns.ID); @@ -554,31 +615,41 @@ public class SqlNote { } } +<<<<<<< HEAD <<<<<<< HEAD // 如果未找到对应的SqlData对象,则创建一个新的对象并添加到数据列表中 ======= +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch if (sqlData == null) { sqlData = new SqlData(mContext); mDataList.add(sqlData); } +<<<<<<< HEAD <<<<<<< HEAD // 调用SqlData对象的setContent方法,传递JSON数据进行处理 ======= +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch sqlData.setContent(data); } } } catch (JSONException e) { +<<<<<<< HEAD <<<<<<< HEAD // 处理异常情况,打印错误信息并返回false ======= +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch Log.e(TAG, e.toString()); e.printStackTrace(); return false; } +<<<<<<< HEAD <<<<<<< HEAD // 返回true,表示设置内容成功 @@ -640,6 +711,8 @@ public class SqlNote { // 如果出现异常,则返回 null return null; // 返回null ======= +======= +>>>>>>> liuyitao-branch return true; } @@ -689,14 +762,21 @@ public class SqlNote { e.printStackTrace(); } return null; +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch } public void setParentId(long id) { mParentId = id; mDiffNoteValues.put(NoteColumns.PARENT_ID, id); +<<<<<<< HEAD <<<<<<< HEAD }//设置父节点ID +======= + } +>>>>>>> liuyitao-branch ======= } >>>>>>> liuyitao-branch @@ -704,6 +784,7 @@ public class SqlNote { public void setGtaskId(String gid) { mDiffNoteValues.put(NoteColumns.GTASK_ID, gid); } +<<<<<<< HEAD <<<<<<< HEAD //设置Google任务ID public void setSyncId(long syncId) { @@ -745,6 +826,8 @@ public class SqlNote { try { // 将Uri路径中的第二个片段转换为long类型,并赋值给mId ======= +======= +>>>>>>> liuyitao-branch public void setSyncId(long syncId) { mDiffNoteValues.put(NoteColumns.SYNC_ID, syncId); @@ -778,6 +861,9 @@ public class SqlNote { Uri uri = mContentResolver.insert(Notes.CONTENT_NOTE_URI, mDiffNoteValues); try { +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch mId = Long.valueOf(uri.getPathSegments().get(1)); } catch (NumberFormatException e) { @@ -788,9 +874,12 @@ public class SqlNote { throw new IllegalStateException("Create thread id failed"); } +<<<<<<< HEAD <<<<<<< HEAD // 如果是笔记类型,则循环提交数据内容更改 ======= +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch if (mType == Notes.TYPE_NOTE) { for (SqlData sqlData : mDataList) { @@ -798,9 +887,12 @@ public class SqlNote { } } } else { +<<<<<<< HEAD <<<<<<< HEAD // 如果不是新建笔记 ======= +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch if (mId <= 0 && mId != Notes.ID_ROOT_FOLDER && mId != Notes.ID_CALL_RECORD_FOLDER) { Log.e(TAG, "No such note"); @@ -810,6 +902,7 @@ public class SqlNote { mVersion ++; int result = 0; if (!validateVersion) { +<<<<<<< HEAD <<<<<<< HEAD // 如果不需要验证版本,则直接通过mId更新mDiffNoteValues到数据库中 result = mContentResolver.update(Notes.CONTENT_NOTE_URI, mDiffNoteValues, "(" @@ -821,6 +914,8 @@ public class SqlNote { result = mContentResolver.update(Notes.CONTENT_NOTE_URI, mDiffNoteValues, "(" + NoteColumns.ID + "=?) AND (" + NoteColumns.VERSION + "<=?)", ======= +======= +>>>>>>> liuyitao-branch result = mContentResolver.update(Notes.CONTENT_NOTE_URI, mDiffNoteValues, "(" + NoteColumns.ID + "=?)", new String[] { String.valueOf(mId) @@ -828,6 +923,9 @@ public class SqlNote { } else { result = mContentResolver.update(Notes.CONTENT_NOTE_URI, mDiffNoteValues, "(" + NoteColumns.ID + "=?) AND (" + NoteColumns.VERSION + "<=?)", +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch new String[] { String.valueOf(mId), String.valueOf(mVersion) @@ -838,9 +936,12 @@ public class SqlNote { } } +<<<<<<< HEAD <<<<<<< HEAD // 如果是笔记类型,则循环提交数据内容更改 ======= +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch if (mType == Notes.TYPE_NOTE) { for (SqlData sqlData : mDataList) { @@ -849,8 +950,12 @@ public class SqlNote { } } +<<<<<<< HEAD <<<<<<< HEAD // 刷新本地信息 +======= + // refresh local info +>>>>>>> liuyitao-branch ======= // refresh local info >>>>>>> liuyitao-branch @@ -858,9 +963,12 @@ public class SqlNote { if (mType == Notes.TYPE_NOTE) loadDataContent(); +<<<<<<< HEAD <<<<<<< HEAD // 清空mDiffNoteValues和将mIsCreate设置为false ======= +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch mDiffNoteValues.clear(); mIsCreate = false; diff --git a/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/Task.java b/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/Task.java index a896f91..36c0c17 100644 --- a/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/Task.java +++ b/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/Task.java @@ -33,6 +33,7 @@ import org.json.JSONObject; public class Task extends Node { +<<<<<<< HEAD <<<<<<< HEAD private static final String TAG = Task.class.getSimpleName(); // 定义一个私有静态常量TAG,值为Task.class.getSimpleName() @@ -146,6 +147,8 @@ public class Task extends Node { try { // 获取Google Task的ID并设置到本地笔记或任务中 ======= +======= +>>>>>>> liuyitao-branch private static final String TAG = Task.class.getSimpleName(); private boolean mCompleted; @@ -252,13 +255,20 @@ public class Task extends Node { if (js != null) { try { // id +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch if (js.has(GTaskStringUtils.GTASK_JSON_ID)) { setGid(js.getString(GTaskStringUtils.GTASK_JSON_ID)); } +<<<<<<< HEAD <<<<<<< HEAD // 获取Google Task的最后修改时间戳并设置到本地笔记或任务中 +======= + // last_modified +>>>>>>> liuyitao-branch ======= // last_modified >>>>>>> liuyitao-branch @@ -266,8 +276,12 @@ public class Task extends Node { setLastModified(js.getLong(GTaskStringUtils.GTASK_JSON_LAST_MODIFIED)); } +<<<<<<< HEAD <<<<<<< HEAD // 获取Google Task的名称并设置到本地笔记或任务中 +======= + // name +>>>>>>> liuyitao-branch ======= // name >>>>>>> liuyitao-branch @@ -275,8 +289,12 @@ public class Task extends Node { setName(js.getString(GTaskStringUtils.GTASK_JSON_NAME)); } +<<<<<<< HEAD <<<<<<< HEAD // 获取Google Task的备注信息并设置到本地笔记或任务中 +======= + // notes +>>>>>>> liuyitao-branch ======= // notes >>>>>>> liuyitao-branch @@ -284,8 +302,12 @@ public class Task extends Node { setNotes(js.getString(GTaskStringUtils.GTASK_JSON_NOTES)); } +<<<<<<< HEAD <<<<<<< HEAD // 获取Google Task的删除状态并设置到本地笔记或任务中 +======= + // deleted +>>>>>>> liuyitao-branch ======= // deleted >>>>>>> liuyitao-branch @@ -293,6 +315,7 @@ public class Task extends Node { setDeleted(js.getBoolean(GTaskStringUtils.GTASK_JSON_DELETED)); } +<<<<<<< HEAD <<<<<<< HEAD // 获取Google Task的完成状态并设置到本地笔记或任务中 if (js.has(GTaskStringUtils.GTASK_JSON_COMPLETED)) { @@ -301,11 +324,16 @@ public class Task extends Node { } catch (JSONException e) { // 如果解析过程出现异常 // 记录异常日志并抛出异常 ======= +======= +>>>>>>> liuyitao-branch // completed if (js.has(GTaskStringUtils.GTASK_JSON_COMPLETED)) { setCompleted(js.getBoolean(GTaskStringUtils.GTASK_JSON_COMPLETED)); } } catch (JSONException e) { +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch Log.e(TAG, e.toString()); e.printStackTrace(); @@ -316,6 +344,7 @@ public class Task extends Node { public void setContentByLocalJSON(JSONObject js) { if (js == null || !js.has(GTaskStringUtils.META_HEAD_NOTE) +<<<<<<< HEAD <<<<<<< HEAD || !js.has(GTaskStringUtils.META_HEAD_DATA)) { // 如果参数为空或缺少必要的数据字段 Log.w(TAG, "setContentByLocalJSON: nothing is available"); // 记录警告日志 @@ -346,6 +375,8 @@ public class Task extends Node { Log.e(TAG, e.toString()); // 记录异常日志 e.printStackTrace(); // 打印异常堆栈信息 ======= +======= +>>>>>>> liuyitao-branch || !js.has(GTaskStringUtils.META_HEAD_DATA)) { Log.w(TAG, "setContentByLocalJSON: nothing is avaiable"); } @@ -370,11 +401,15 @@ public class Task extends Node { } catch (JSONException e) { Log.e(TAG, e.toString()); e.printStackTrace(); +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch } } public JSONObject getLocalJSONFromContent() { +<<<<<<< HEAD <<<<<<< HEAD String name = getName(); // 获取名称 try { @@ -387,6 +422,8 @@ public class Task extends Node { // 创建JSON对象,并填充数据 ======= +======= +>>>>>>> liuyitao-branch String name = getName(); try { if (mMetaInfo == null) { @@ -396,13 +433,20 @@ public class Task extends Node { return null; } +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch JSONObject js = new JSONObject(); JSONObject note = new JSONObject(); JSONArray dataArray = new JSONArray(); JSONObject data = new JSONObject(); +<<<<<<< HEAD <<<<<<< HEAD data.put(DataColumns.CONTENT, name); // 设置数据内容为名称 +======= + data.put(DataColumns.CONTENT, name); +>>>>>>> liuyitao-branch ======= data.put(DataColumns.CONTENT, name); >>>>>>> liuyitao-branch @@ -410,6 +454,7 @@ public class Task extends Node { js.put(GTaskStringUtils.META_HEAD_DATA, dataArray); note.put(NoteColumns.TYPE, Notes.TYPE_NOTE); js.put(GTaskStringUtils.META_HEAD_NOTE, note); +<<<<<<< HEAD <<<<<<< HEAD return js; // 返回JSON对象 } else { @@ -425,6 +470,8 @@ public class Task extends Node { data.put(DataColumns.CONTENT, getName()); // 设置数据内容为名称 break; // 跳出循环 ======= +======= +>>>>>>> liuyitao-branch return js; } else { // synced task @@ -436,11 +483,15 @@ public class Task extends Node { if (TextUtils.equals(data.getString(DataColumns.MIME_TYPE), DataConstants.NOTE)) { data.put(DataColumns.CONTENT, getName()); break; +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch } } note.put(NoteColumns.TYPE, Notes.TYPE_NOTE); +<<<<<<< HEAD <<<<<<< HEAD return mMetaInfo; // 返回元信息对象 } @@ -449,17 +500,23 @@ public class Task extends Node { e.printStackTrace(); // 打印异常堆栈信息 return null; // 返回null ======= +======= +>>>>>>> liuyitao-branch return mMetaInfo; } } catch (JSONException e) { Log.e(TAG, e.toString()); e.printStackTrace(); return null; +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch } } public void setMetaInfo(MetaData metaData) { +<<<<<<< HEAD <<<<<<< HEAD if (metaData != null && metaData.getNotes() != null) { // 如果元数据不为空且笔记不为空 try { @@ -468,25 +525,34 @@ public class Task extends Node { Log.w(TAG, e.toString()); // 记录警告日志 mMetaInfo = null; // 设置元信息为空 ======= +======= +>>>>>>> liuyitao-branch if (metaData != null && metaData.getNotes() != null) { try { mMetaInfo = new JSONObject(metaData.getNotes()); } catch (JSONException e) { Log.w(TAG, e.toString()); mMetaInfo = null; +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch } } } +<<<<<<< HEAD <<<<<<< HEAD //获取同步操作类型 ======= +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch public int getSyncAction(Cursor c) { try { JSONObject noteInfo = null; if (mMetaInfo != null && mMetaInfo.has(GTaskStringUtils.META_HEAD_NOTE)) { +<<<<<<< HEAD <<<<<<< HEAD noteInfo = mMetaInfo.getJSONObject(GTaskStringUtils.META_HEAD_NOTE); // 获取笔记信息对象 } @@ -573,6 +639,8 @@ public class Task extends Node { return this.mParent; }//获取任务的父任务列表 ======= +======= +>>>>>>> liuyitao-branch noteInfo = mMetaInfo.getJSONObject(GTaskStringUtils.META_HEAD_NOTE); } @@ -658,6 +726,9 @@ public class Task extends Node { public TaskList getParent() { return this.mParent; } +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch } diff --git a/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/TaskList.java b/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/TaskList.java index a72fc3d..12f8ace 100644 --- a/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/TaskList.java +++ b/src/Notes-master/app/src/main/java/net/micode/notes/gtask/data/TaskList.java @@ -31,6 +31,7 @@ import java.util.ArrayList; public class TaskList extends Node { +<<<<<<< HEAD <<<<<<< HEAD private static final String TAG = TaskList.class.getSimpleName(); // TAG用于在日志中标识类名 @@ -90,6 +91,8 @@ public class TaskList extends Node { ======= +======= +>>>>>>> liuyitao-branch private static final String TAG = TaskList.class.getSimpleName(); private int mIndex; @@ -133,11 +136,15 @@ public class TaskList extends Node { return js; } +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch public JSONObject getUpdateAction(int actionId) { JSONObject js = new JSONObject(); try { +<<<<<<< HEAD <<<<<<< HEAD // 设置操作类型为更新 js.put(GTaskStringUtils.GTASK_JSON_ACTION_TYPE, GTaskStringUtils.GTASK_JSON_ACTION_TYPE_UPDATE); @@ -167,6 +174,8 @@ public class TaskList extends Node { // 抛出自定义异常 ======= +======= +>>>>>>> liuyitao-branch // action_type js.put(GTaskStringUtils.GTASK_JSON_ACTION_TYPE, GTaskStringUtils.GTASK_JSON_ACTION_TYPE_UPDATE); @@ -186,6 +195,9 @@ public class TaskList extends Node { } catch (JSONException e) { Log.e(TAG, e.toString()); e.printStackTrace(); +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch throw new ActionFailureException("fail to generate tasklist-update jsonobject"); } @@ -198,38 +210,52 @@ public class TaskList extends Node { try { // id if (js.has(GTaskStringUtils.GTASK_JSON_ID)) { +<<<<<<< HEAD <<<<<<< HEAD // 如果JSON对象包含ID字段,则将ID设置为相应的值 ======= +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch setGid(js.getString(GTaskStringUtils.GTASK_JSON_ID)); } // last_modified if (js.has(GTaskStringUtils.GTASK_JSON_LAST_MODIFIED)) { +<<<<<<< HEAD <<<<<<< HEAD // 如果JSON对象包含last_modified字段,则将last_modified设置为相应的值 ======= +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch setLastModified(js.getLong(GTaskStringUtils.GTASK_JSON_LAST_MODIFIED)); } // name if (js.has(GTaskStringUtils.GTASK_JSON_NAME)) { +<<<<<<< HEAD <<<<<<< HEAD // 如果JSON对象包含name字段,则将name设置为相应的值 ======= +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch setName(js.getString(GTaskStringUtils.GTASK_JSON_NAME)); } } catch (JSONException e) { +<<<<<<< HEAD <<<<<<< HEAD // 打印异常信息 Log.e(TAG, e.toString()); e.printStackTrace(); // 抛出自定义异常 +======= + Log.e(TAG, e.toString()); + e.printStackTrace(); +>>>>>>> liuyitao-branch ======= Log.e(TAG, e.toString()); e.printStackTrace(); @@ -240,6 +266,7 @@ public class TaskList extends Node { } public void setContentByLocalJSON(JSONObject js) { +<<<<<<< HEAD <<<<<<< HEAD // 检查传入的JSON对象是否为空或者不包含指定的字段 if (js == null || !js.has(GTaskStringUtils.META_HEAD_NOTE)) { @@ -276,6 +303,8 @@ public class TaskList extends Node { } catch (JSONException e) { // 打印异常信息 ======= +======= +>>>>>>> liuyitao-branch if (js == null || !js.has(GTaskStringUtils.META_HEAD_NOTE)) { Log.w(TAG, "setContentByLocalJSON: nothing is avaiable"); } @@ -298,12 +327,16 @@ public class TaskList extends Node { Log.e(TAG, "error type"); } } catch (JSONException e) { +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch Log.e(TAG, e.toString()); e.printStackTrace(); } } +<<<<<<< HEAD <<<<<<< HEAD /* * 从内容中获取本地JSON对象 @@ -326,6 +359,8 @@ public class TaskList extends Node { // 检查文件夹名称是否为默认文件夹或通话笔记文件夹,如果是,则设置文件夹类型为系统类型,否则设置为文件夹类型 ======= +======= +>>>>>>> liuyitao-branch public JSONObject getLocalJSONFromContent() { try { JSONObject js = new JSONObject(); @@ -336,6 +371,9 @@ public class TaskList extends Node { folderName = folderName.substring(GTaskStringUtils.MIUI_FOLDER_PREFFIX.length(), folderName.length()); folder.put(NoteColumns.SNIPPET, folderName); +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch if (folderName.equals(GTaskStringUtils.FOLDER_DEFAULT) || folderName.equals(GTaskStringUtils.FOLDER_CALL_NOTE)) @@ -343,6 +381,7 @@ public class TaskList extends Node { else folder.put(NoteColumns.TYPE, Notes.TYPE_FOLDER); +<<<<<<< HEAD <<<<<<< HEAD // 将文件夹JSON对象放入根JSON对象中的头部注释字段中 js.put(GTaskStringUtils.META_HEAD_NOTE, folder); @@ -355,17 +394,23 @@ public class TaskList extends Node { e.printStackTrace(); // 返回空值 ======= +======= +>>>>>>> liuyitao-branch js.put(GTaskStringUtils.META_HEAD_NOTE, folder); return js; } catch (JSONException e) { Log.e(TAG, e.toString()); e.printStackTrace(); +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch return null; } } +<<<<<<< HEAD <<<<<<< HEAD /* * 获取同步操作类型 @@ -386,6 +431,8 @@ public class TaskList extends Node { } else { // 验证gtask id ======= +======= +>>>>>>> liuyitao-branch public int getSyncAction(Cursor c) { try { if (c.getInt(SqlNote.LOCAL_MODIFIED_COLUMN) == 0) { @@ -399,35 +446,48 @@ public class TaskList extends Node { } } else { // validate gtask id +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch if (!c.getString(SqlNote.GTASK_ID_COLUMN).equals(getGid())) { Log.e(TAG, "gtask id doesn't match"); return SYNC_ACTION_ERROR; } if (c.getLong(SqlNote.SYNC_ID_COLUMN) == getLastModified()) { +<<<<<<< HEAD <<<<<<< HEAD // 仅有本地修改 return SYNC_ACTION_UPDATE_REMOTE; } else { // 对于文件夹冲突,只应用本地修改 ======= +======= +>>>>>>> liuyitao-branch // local modification only return SYNC_ACTION_UPDATE_REMOTE; } else { // for folder conflicts, just apply local modification +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch return SYNC_ACTION_UPDATE_REMOTE; } } } catch (Exception e) { +<<<<<<< HEAD <<<<<<< HEAD // 打印异常信息 ======= +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch Log.e(TAG, e.toString()); e.printStackTrace(); } +<<<<<<< HEAD <<<<<<< HEAD // 返回错误的同步操作类型 return SYNC_ACTION_ERROR; @@ -456,6 +516,8 @@ public class TaskList extends Node { if (ret) { // 设置子任务的前一个兄弟和父任务 ======= +======= +>>>>>>> liuyitao-branch return SYNC_ACTION_ERROR; } @@ -469,12 +531,16 @@ public class TaskList extends Node { ret = mChildren.add(task); if (ret) { // need to set prior sibling and parent +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch task.setPriorSibling(mChildren.isEmpty() ? null : mChildren .get(mChildren.size() - 1)); task.setParent(this); } } +<<<<<<< HEAD <<<<<<< HEAD // 返回是否成功添加子任务的信息 return ret; @@ -491,16 +557,22 @@ public class TaskList extends Node { if (index < 0 || index > mChildren.size()) { // 如果不合法,则记录日志,返回失败 ======= +======= +>>>>>>> liuyitao-branch return ret; } public boolean addChildTask(Task task, int index) { if (index < 0 || index > mChildren.size()) { +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch Log.e(TAG, "add child task: invalid index"); return false; } +<<<<<<< HEAD <<<<<<< HEAD // 查找子任务是否已经在列表中 int pos = mChildren.indexOf(task); @@ -511,11 +583,16 @@ public class TaskList extends Node { // 更新任务列表 ======= +======= +>>>>>>> liuyitao-branch int pos = mChildren.indexOf(task); if (task != null && pos == -1) { mChildren.add(index, task); // update the task list +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch Task preTask = null; Task afterTask = null; @@ -524,15 +601,19 @@ public class TaskList extends Node { if (index != mChildren.size() - 1) afterTask = mChildren.get(index + 1); +<<<<<<< HEAD <<<<<<< HEAD // 设置前一个兄弟和后一个兄弟 ======= +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch task.setPriorSibling(preTask); if (afterTask != null) afterTask.setPriorSibling(task); } +<<<<<<< HEAD <<<<<<< HEAD // 返回是否成功添加子任务的信息 return true; @@ -582,6 +663,8 @@ public class TaskList extends Node { int pos = mChildren.indexOf(task); // 查找子任务在列表中的位置 // 如果子任务不在列表中,则记录日志,返回失败 ======= +======= +>>>>>>> liuyitao-branch return true; } @@ -614,12 +697,16 @@ public class TaskList extends Node { } int pos = mChildren.indexOf(task); +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch if (pos == -1) { Log.e(TAG, "move child task: the task should in the list"); return false; } +<<<<<<< HEAD <<<<<<< HEAD // 如果子任务本来就在目标位置上,则直接返回成功 if (pos == index) @@ -702,6 +789,8 @@ public class TaskList extends Node { public int getIndex() { return this.mIndex; // 返回索引位置 ======= +======= +>>>>>>> liuyitao-branch if (pos == index) return true; return (removeChildTask(task) && addChildTask(task, index)); @@ -747,6 +836,9 @@ public class TaskList extends Node { public int getIndex() { return this.mIndex; +<<<<<<< HEAD +>>>>>>> liuyitao-branch +======= >>>>>>> liuyitao-branch } } diff --git a/src/Notes-master/local.properties b/src/Notes-master/local.properties index 41c8053..438588c 100644 --- a/src/Notes-master/local.properties +++ b/src/Notes-master/local.properties @@ -3,6 +3,7 @@ # # Location of the SDK. This is only used by Gradle. <<<<<<< HEAD +<<<<<<< HEAD # For customization when using a Version Control System, please read the # header note. #Thu Dec 21 01:09:02 CST 2023 @@ -12,3 +13,8 @@ sdk.dir=C\:\\Users\\lenovo\\AppData\\Local\\Android\\Sdk #Thu Nov 09 19:48:40 CST 2023 sdk.dir=D\:\\Android\\Sdk >>>>>>> liuyitao-branch +======= +# +#Thu Nov 09 19:48:40 CST 2023 +sdk.dir=D\:\\Android\\Sdk +>>>>>>> liuyitao-branch