From f5b025db8032104d9bddc98430d5d37de5d1a486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BA=9E=E6=B5=A9?= <541476788@qq.com> Date: Wed, 12 Apr 2023 17:40:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=9E=E6=B5=A9=E7=9A=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/net/micode/notes/data/Notes.java | 141 +++++++++++------- 1 file changed, 83 insertions(+), 58 deletions(-) diff --git a/app/src/main/java/net/micode/notes/data/Notes.java b/app/src/main/java/net/micode/notes/data/Notes.java index f240604..e1fa12c 100644 --- a/app/src/main/java/net/micode/notes/data/Notes.java +++ b/app/src/main/java/net/micode/notes/data/Notes.java @@ -18,155 +18,165 @@ package net.micode.notes.data; import android.net.Uri; 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; + public static final String AUTHORITY = "micode_notes"; // 小米便签内容提供器的URI授权 + 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;// 系统便签 /** * Following IDs are system folders' identifiers - * {@link Notes#ID_ROOT_FOLDER } is default folder - * {@link Notes#ID_TEMPARAY_FOLDER } is for notes belonging no folder - * {@link Notes#ID_CALL_RECORD_FOLDER} is to store call records + * {@link Notes#ID_ROOT_FOLDER } is default folder根文件夹 + * {@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 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 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";//提醒时间的Intent extra key,用于设置笔记的提醒时间。 + public static final String INTENT_EXTRA_BACKGROUND_ID = "net.micode.notes.background_color_id";//背景颜色的Intent extra key,用于设置笔记的背景颜色。 + public static final String INTENT_EXTRA_WIDGET_ID = "net.micode.notes.widget_id";//小部件ID的Intent extra key,用于设置小部件的ID。 + public static final String INTENT_EXTRA_WIDGET_TYPE = "net.micode.notes.widget_type";//小部件类型的Intent extra key,用于设置小部件的类型。 + public static final String INTENT_EXTRA_FOLDER_ID = "net.micode.notes.folder_id";//文件夹ID的Intent extra key,用于设置笔记所属的文件夹。 + public static final String INTENT_EXTRA_CALL_DATE = "net.micode.notes.call_date";//通话时间的Intent extra key,用于设置通话笔记的通话时间。 + + public static final int TYPE_WIDGET_INVALIDE = -1;//表示无效的小部件类型,其值为-1。 + public static final int TYPE_WIDGET_2X = 0;//表示2x2大小的小部件,其值为0。 + public static final int TYPE_WIDGET_4X = 1;//表示4x4大小的小部件,其值为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;//指定通话记录笔记类型 + }//定义笔记的类型 /** - * Uri to query all notes and folders + * Uri to query all notes and folders(查询所有的笔记和文件夹) */ public static final Uri CONTENT_NOTE_URI = Uri.parse("content://" + AUTHORITY + "/note"); /** - * Uri to query data + * Uri to query data(查询数据) */ public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data"); public interface NoteColumns { /** - * The unique ID for a row + * The unique ID for a row(笔记或文件夹的唯一ID) *
Type: INTEGER (long)
*/ public static final String ID = "_id"; /** - * The parent's id for note or folder + * The parent's id for note or folder(笔记或文件夹的父级 ID) *Type: INTEGER (long)
*/ public static final String PARENT_ID = "parent_id"; /** - * Created data for note or folder + * Created data for note or folder(笔记或文件夹的创建日期) *Type: INTEGER (long)
*/ public static final String CREATED_DATE = "created_date"; /** - * Latest modified date + * Latest modified date(笔记或文件夹的最后修改日期) *Type: INTEGER (long)
*/ public static final String MODIFIED_DATE = "modified_date"; /** - * Alert date + * Alert date(笔记或文件夹的提醒日期) *Type: INTEGER (long)
*/ public static final String ALERTED_DATE = "alert_date"; /** - * Folder's name or text content of note + * Folder's name or text content of note(笔记或文件夹的文本内容或名称) *Type: TEXT
*/ public static final String SNIPPET = "snippet"; /** - * Note's widget id + * Note's widget id(笔记所对应的桌面小部件 ID) *Type: INTEGER (long)
*/ public static final String WIDGET_ID = "widget_id"; /** - * Note's widget type + * Note's widget type(笔记所对应的桌面小部件类型) *Type: INTEGER (long)
*/ public static final String WIDGET_TYPE = "widget_type"; /** - * Note's background color's id + * Note's background color's id(笔记的背景颜色 ID) *Type: INTEGER (long)
*/ public static final String BG_COLOR_ID = "bg_color_id"; /** * For text note, it doesn't has attachment, for multi-media - * note, it has at least one attachment + * note, it has at least one attachment(笔记是否包含附件) *Type: INTEGER
*/ public static final String HAS_ATTACHMENT = "has_attachment"; /** - * Folder's count of notes + * Folder's count of notes(文件夹中笔记的数量) *Type: INTEGER (long)
*/ public static final String NOTES_COUNT = "notes_count"; /** - * The file type: folder or note + * The file type: folder or note(笔记类型,可以是文件夹或笔记) *Type: INTEGER
*/ public static final String TYPE = "type"; /** - * The last sync id + * The last sync id(最后同步 ID) *Type: INTEGER (long)
*/ public static final String SYNC_ID = "sync_id"; /** - * Sign to indicate local modified or not + * Sign to indicate local modified or not(本地是否修改过) *Type: INTEGER
*/ public static final String LOCAL_MODIFIED = "local_modified"; /** - * Original parent id before moving into temporary folder + * Original parent id before moving into temporary folder(移动到临时文件夹之前的原始父级 ID) *Type : INTEGER
*/ public static final String ORIGIN_PARENT_ID = "origin_parent_id"; /** - * The gtask id + * The gtask id(Google 任务 ID) *Type : TEXT
*/ public static final String GTASK_ID = "gtask_id"; /** - * The version code + * The version code(版本号) *Type : INTEGER (long)
*/ public static final String VERSION = "version"; } + /** + * 这个接口DataColumns定义了笔记应用程序中的笔记数据表格中所有列的常量, + * 而NotesColumns定义了笔记应用程序中的笔记数据表格中的特定列的常量。 + * 因此,DataColumns更通用,而NotesColumns更具体。 + * NotesColumns接口包含笔记的标题、正文和颜色等属性, + * 而DataColumns接口包含笔记数据表格中的通用列。 + * 在许多情况下,这两个接口将一起使用。所以重复的常量就不在做解释了。 + */ public interface DataColumns { /** * The unique ID for a row @@ -175,13 +185,13 @@ public class Notes { public static final String ID = "_id"; /** - * The MIME type of the item represented by this row. + * The MIME type of the item represented by this row.(表示该行数据的MIME类型) *Type: Text
*/ public static final String MIME_TYPE = "mime_type"; /** - * The reference id to note that this data belongs to + * The reference id to note that this data belongs to(表示该行数据所属的笔记的ID) *Type: INTEGER (long)
*/ public static final String NOTE_ID = "note_id"; @@ -241,39 +251,54 @@ public class Notes { public static final String DATA5 = "data5"; } + /** + * 这是一个嵌套在NotePad类中的静态内部类TextNote。 + * 它实现了DataColumns接口,并定义了特定于文本笔记的常量和内容URI。 + * 与NotesColumns类似,TextNote还具有特定于文本笔记的常量, + * 例如MODE和MODE_CHECK_LIST,以及特定于文本笔记的内容类型和内容项类型常量。 + * 此外,TextNote还定义了用于访问文本笔记数据的内容URI,该URI指向ContentProvider的text_note表。 + */ 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
*/ - public static final String MODE = DATA1; + public static final String MODE = DATA1;//MODE字段表示文本笔记的模式,可以是正常模式或者是带有任务清单的模式,类型为整数。它使用了接口中的DATA1字段来表示其存储值的列名。 - public static final int MODE_CHECK_LIST = 1; + public static final int MODE_CHECK_LIST = 1;//MODE_CHECK_LIST字段表示任务清单模式的值,为1。 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/text_note"; - + //CONTENT_TYPE字段表示此数据的MIME类型,指示ContentProvider返回的数据类型。此处表示返回的是文本笔记列表。 public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/text_note"; - + //CONTENT_ITEM_TYPE字段表示此数据的单个项目的MIME类型。 public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note"); - } + //CONTENT_URI字段表示此数据的URI地址。 + } + /** + * 这是一个嵌套在Notes类中的静态内部类CallNote,实现了DataColumns接口。 + * CallNote定义了一些特定于电话记录的字段,如CALL_DATE(通话日期)和PHONE_NUMBER(电话号码), + * 并定义了ContentProvider使用的MIME类型和URI。 + */ public static final class CallNote implements DataColumns { /** - * Call date for this record + * Call date for this record(记录通话日期) *Type: INTEGER (long)
*/ public static final String CALL_DATE = DATA1; - + //表示通话日期的列名,数据类型为long,存储在DATA1列中。 /** - * Phone number for this record + * Phone number for this record(记录通话号码) *Type: TEXT
*/ public static final String PHONE_NUMBER = DATA3; - + //表示电话号码的列名,数据类型为String,存储在DATA3列中。 public static final String CONTENT_TYPE = "vnd.android.cursor.dir/call_note"; - + //单条通话记录,用于指定MIME类型的常量 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,用于访问通话记录。 + } }