|
|
|
@ -17,9 +17,14 @@
|
|
|
|
|
package net.micode.notes.data;
|
|
|
|
|
|
|
|
|
|
import android.net.Uri;
|
|
|
|
|
|
|
|
|
|
// Notes 类中定义了很多常量,这些常量大多是int型和string型
|
|
|
|
|
public class Notes {
|
|
|
|
|
// 权限
|
|
|
|
|
public static final String AUTHORITY = "micode_notes";
|
|
|
|
|
// 日志标签
|
|
|
|
|
public static final String TAG = "Notes";
|
|
|
|
|
// 笔记类型
|
|
|
|
|
public static final int TYPE_NOTE = 0;
|
|
|
|
|
public static final int TYPE_FOLDER = 1;
|
|
|
|
|
public static final int TYPE_SYSTEM = 2;
|
|
|
|
@ -30,60 +35,75 @@ public class Notes {
|
|
|
|
|
* {@link Notes#ID_TEMPARAY_FOLDER } is for notes belonging no folder
|
|
|
|
|
* {@link Notes#ID_CALL_RECORD_FOLDER} is to store call records
|
|
|
|
|
*/
|
|
|
|
|
public static final int ID_ROOT_FOLDER = 0;
|
|
|
|
|
public static final int ID_TEMPARAY_FOLDER = -1;
|
|
|
|
|
public static final int ID_CALL_RECORD_FOLDER = -2;
|
|
|
|
|
public static final int ID_TRASH_FOLER = -3;
|
|
|
|
|
// 系统文件夹的标识符
|
|
|
|
|
public static final int ID_ROOT_FOLDER = 0;// 默认文件夹
|
|
|
|
|
public static final int ID_TEMPARAY_FOLDER = -1;// 无文件夹的笔记
|
|
|
|
|
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_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 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 内容提供者的URI
|
|
|
|
|
/**
|
|
|
|
|
* Uri to query all notes and folders
|
|
|
|
|
*/
|
|
|
|
|
public static final Uri CONTENT_NOTE_URI = Uri.parse("content://" + AUTHORITY + "/note");
|
|
|
|
|
//定义查询便签和文件夹的指针
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Uri to query data
|
|
|
|
|
*/
|
|
|
|
|
public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data");
|
|
|
|
|
//定义查找数据的指针
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 笔记列的接口
|
|
|
|
|
// 定义NoteColumns的常量,用于后面创建数据库的表头
|
|
|
|
|
public interface NoteColumns {
|
|
|
|
|
/**
|
|
|
|
|
* The unique ID for a row
|
|
|
|
|
* <P> Type: INTEGER (long) </P>
|
|
|
|
|
*/
|
|
|
|
|
// 行的唯一ID
|
|
|
|
|
public static final String ID = "_id";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The parent's id for note or folder
|
|
|
|
|
* <P> Type: INTEGER (long) </P>
|
|
|
|
|
*/
|
|
|
|
|
// 笔记或文件夹的父ID
|
|
|
|
|
public static final String PARENT_ID = "parent_id";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Created data for note or folder
|
|
|
|
|
* <P> Type: INTEGER (long) </P>
|
|
|
|
|
*/
|
|
|
|
|
// 创建日期
|
|
|
|
|
public static final String CREATED_DATE = "created_date";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Latest modified date
|
|
|
|
|
* <P> Type: INTEGER (long) </P>
|
|
|
|
|
*/
|
|
|
|
|
// 最后修改日期
|
|
|
|
|
public static final String MODIFIED_DATE = "modified_date";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -91,30 +111,35 @@ public class Notes {
|
|
|
|
|
* Alert date
|
|
|
|
|
* <P> Type: INTEGER (long) </P>
|
|
|
|
|
*/
|
|
|
|
|
// 提醒日期
|
|
|
|
|
public static final String ALERTED_DATE = "alert_date";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Folder's name or text content of note
|
|
|
|
|
* <P> Type: TEXT </P>
|
|
|
|
|
*/
|
|
|
|
|
// 文件夹名称或笔记的文本内容
|
|
|
|
|
public static final String SNIPPET = "snippet";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Note's widget id
|
|
|
|
|
* <P> Type: INTEGER (long) </P>
|
|
|
|
|
*/
|
|
|
|
|
// 笔记的小部件ID
|
|
|
|
|
public static final String WIDGET_ID = "widget_id";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Note's widget type
|
|
|
|
|
* <P> Type: INTEGER (long) </P>
|
|
|
|
|
*/
|
|
|
|
|
// 笔记的小部件类型
|
|
|
|
|
public static final String WIDGET_TYPE = "widget_type";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Note's background color's id
|
|
|
|
|
* <P> Type: INTEGER (long) </P>
|
|
|
|
|
*/
|
|
|
|
|
// 笔记的背景颜色ID
|
|
|
|
|
public static final String BG_COLOR_ID = "bg_color_id";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -122,86 +147,102 @@ public class Notes {
|
|
|
|
|
* note, it has at least one attachment
|
|
|
|
|
* <P> Type: INTEGER </P>
|
|
|
|
|
*/
|
|
|
|
|
// 笔记是否有附件
|
|
|
|
|
public static final String HAS_ATTACHMENT = "has_attachment";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Folder's count of notes
|
|
|
|
|
* <P> Type: INTEGER (long) </P>
|
|
|
|
|
*/
|
|
|
|
|
// 文件夹中的笔记数量
|
|
|
|
|
public static final String NOTES_COUNT = "notes_count";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The file type: folder or note
|
|
|
|
|
* <P> Type: INTEGER </P>
|
|
|
|
|
*/
|
|
|
|
|
// 文件类型:文件夹或笔记
|
|
|
|
|
public static final String TYPE = "type";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The last sync id
|
|
|
|
|
* <P> Type: INTEGER (long) </P>
|
|
|
|
|
*/
|
|
|
|
|
// 最后同步ID
|
|
|
|
|
public static final String SYNC_ID = "sync_id";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sign to indicate local modified or not
|
|
|
|
|
* <P> Type: INTEGER </P>
|
|
|
|
|
*/
|
|
|
|
|
// 本地修改标志
|
|
|
|
|
public static final String LOCAL_MODIFIED = "local_modified";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Original parent id before moving into temporary folder
|
|
|
|
|
* <P> Type : INTEGER </P>
|
|
|
|
|
*/
|
|
|
|
|
// 移动到临时文件夹之前的原始父ID
|
|
|
|
|
public static final String ORIGIN_PARENT_ID = "origin_parent_id";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The gtask id
|
|
|
|
|
* <P> Type : TEXT </P>
|
|
|
|
|
*/
|
|
|
|
|
// Gtask ID
|
|
|
|
|
public static final String GTASK_ID = "gtask_id";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The version code
|
|
|
|
|
* <P> Type : INTEGER (long) </P>
|
|
|
|
|
*/
|
|
|
|
|
// 版本号
|
|
|
|
|
public static final String VERSION = "version";
|
|
|
|
|
}
|
|
|
|
|
}//这些常量主要是定义便签的属性的
|
|
|
|
|
|
|
|
|
|
// 数据列的接口
|
|
|
|
|
// 定义DataColumns的常量,用于后面创建数据库的表头
|
|
|
|
|
public interface DataColumns {
|
|
|
|
|
/**
|
|
|
|
|
* The unique ID for a row
|
|
|
|
|
* <P> Type: INTEGER (long) </P>
|
|
|
|
|
*/
|
|
|
|
|
// 行的唯一ID
|
|
|
|
|
public static final String ID = "_id";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The MIME type of the item represented by this row.
|
|
|
|
|
* <P> Type: Text </P>
|
|
|
|
|
*/
|
|
|
|
|
// 该行所代表项的MIME类型
|
|
|
|
|
public static final String MIME_TYPE = "mime_type";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The reference id to note that this data belongs to
|
|
|
|
|
* <P> Type: INTEGER (long) </P>
|
|
|
|
|
*/
|
|
|
|
|
// 该数据所属笔记的引用ID
|
|
|
|
|
public static final String NOTE_ID = "note_id";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Created data for note or folder
|
|
|
|
|
* <P> Type: INTEGER (long) </P>
|
|
|
|
|
*/
|
|
|
|
|
// 创建日期
|
|
|
|
|
public static final String CREATED_DATE = "created_date";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Latest modified date
|
|
|
|
|
* <P> Type: INTEGER (long) </P>
|
|
|
|
|
*/
|
|
|
|
|
// 最后修改日期
|
|
|
|
|
public static final String MODIFIED_DATE = "modified_date";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Data's content
|
|
|
|
|
* <P> Type: TEXT </P>
|
|
|
|
|
*/
|
|
|
|
|
// 数据内容
|
|
|
|
|
public static final String CONTENT = "content";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -210,6 +251,7 @@ public class Notes {
|
|
|
|
|
* integer data type
|
|
|
|
|
* <P> Type: INTEGER </P>
|
|
|
|
|
*/
|
|
|
|
|
// 通用数据列,意义由MIME类型决定,用于整型数据类型
|
|
|
|
|
public static final String DATA1 = "data1";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -217,6 +259,7 @@ public class Notes {
|
|
|
|
|
* integer data type
|
|
|
|
|
* <P> Type: INTEGER </P>
|
|
|
|
|
*/
|
|
|
|
|
// 通用数据列,意义由MIME类型决定,用于整型数据类型
|
|
|
|
|
public static final String DATA2 = "data2";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -224,6 +267,7 @@ public class Notes {
|
|
|
|
|
* TEXT data type
|
|
|
|
|
* <P> Type: TEXT </P>
|
|
|
|
|
*/
|
|
|
|
|
// 通用数据列,意义由MIME类型决定,用于整型数据类型
|
|
|
|
|
public static final String DATA3 = "data3";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -231,6 +275,7 @@ public class Notes {
|
|
|
|
|
* TEXT data type
|
|
|
|
|
* <P> Type: TEXT </P>
|
|
|
|
|
*/
|
|
|
|
|
// 通用数据列,意义由MIME类型决定,用于整型数据类型
|
|
|
|
|
public static final String DATA4 = "data4";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -238,14 +283,18 @@ public class Notes {
|
|
|
|
|
* TEXT data type
|
|
|
|
|
* <P> Type: TEXT </P>
|
|
|
|
|
*/
|
|
|
|
|
// 通用数据列,意义由MIME类型决定,用于整型数据类型
|
|
|
|
|
public static final String DATA5 = "data5";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 文本笔记的数据列
|
|
|
|
|
//主要是定义存储便签内容数据的
|
|
|
|
|
public static final class TextNote implements DataColumns {
|
|
|
|
|
/**
|
|
|
|
|
* Mode to indicate the text in check list mode or not
|
|
|
|
|
* <P> Type: Integer 1:check list mode 0: normal mode </P>
|
|
|
|
|
*/
|
|
|
|
|
// 表示文本为检查列表模式或非检查列表模式的模式
|
|
|
|
|
public static final String MODE = DATA1;
|
|
|
|
|
|
|
|
|
|
public static final int MODE_CHECK_LIST = 1;
|
|
|
|
@ -255,19 +304,22 @@ public class Notes {
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
}//文本内容的数据结构
|
|
|
|
|
|
|
|
|
|
// 通话笔记的数据列
|
|
|
|
|
public static final class CallNote implements DataColumns {
|
|
|
|
|
/**
|
|
|
|
|
* Call date for this record
|
|
|
|
|
* <P> Type: INTEGER (long) </P>
|
|
|
|
|
*/
|
|
|
|
|
// 记录的通话日期
|
|
|
|
|
public static final String CALL_DATE = DATA1;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Phone number for this record
|
|
|
|
|
* <P> Type: TEXT </P>
|
|
|
|
|
*/
|
|
|
|
|
// 记录的电话号码
|
|
|
|
|
public static final String PHONE_NUMBER = DATA3;
|
|
|
|
|
|
|
|
|
|
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/call_note";
|
|
|
|
@ -275,5 +327,13 @@ 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");
|
|
|
|
|
}
|
|
|
|
|
}//电话内容的数据结构
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
在这段Java代码中,我们有一个名为 Notes 的类,它包含了一些常量和内部类,用于定义笔记应用中的各种数据列、MIME类型和URI。以下是对代码中各部分的注释:
|
|
|
|
|
|
|
|
|
|
定义了一系列常量,包括权限、日志标签、笔记类型、系统文件夹的标识符等。
|
|
|
|
|
定义了 NoteColumns 和 DataColumns 接口,用于表示笔记和数据的列。
|
|
|
|
|
定义了 TextNote 和 CallNote 内部类,用于表示文本笔记和通话笔记的数据列,并包含了相应的MIME类型和内容提供者URI。
|
|
|
|
|
这个类的主要作用是定义笔记应用中的数据结构和相关常量。
|
|
|
|
|
* */
|