From 718398efa975e10d2530486e7a9fbc0ddabcf6f0 Mon Sep 17 00:00:00 2001 From: Ssr <2444963128> Date: Mon, 4 Mar 2024 21:54:06 +0800 Subject: [PATCH] 3 --- .../src/net/micode/notes/data/Notes.java | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/Notes-master/src/net/micode/notes/data/Notes.java b/Notes-master/src/net/micode/notes/data/Notes.java index f240604..52540d2 100644 --- a/Notes-master/src/net/micode/notes/data/Notes.java +++ b/Notes-master/src/net/micode/notes/data/Notes.java @@ -14,10 +14,11 @@ * limitations under the License. */ -package net.micode.notes.data; +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; @@ -35,17 +36,23 @@ public class Notes { public static final int ID_CALL_RECORD_FOLDER = -2; public static final int ID_TRASH_FOLER = -3; + // 用于在Intent中传递提醒日期的键 public static final String INTENT_EXTRA_ALERT_DATE = "net.micode.notes.alert_date"; + // 用于在Intent中传递背景颜色ID的键 public static final String INTENT_EXTRA_BACKGROUND_ID = "net.micode.notes.background_color_id"; + // 用于在Intent中传递小部件ID的键 public static final String INTENT_EXTRA_WIDGET_ID = "net.micode.notes.widget_id"; + // 用于在Intent中传递小部件类型的键 public static final String INTENT_EXTRA_WIDGET_TYPE = "net.micode.notes.widget_type"; + // 用于在Intent中传递文件夹ID的键 public static final String INTENT_EXTRA_FOLDER_ID = "net.micode.notes.folder_id"; + // 用于在Intent中传递通话日期的键 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; - + //这些常量提供了一种在代码中引用特定数据类型的标准化方式。通过在 DataConstants 内部定义这些常量,可以方便地在应用程序的其他地方引用它们,而不必直接使用字符串字面量,从而提高了代码的可读性和可维护性 public static class DataConstants { public static final String NOTE = TextNote.CONTENT_ITEM_TYPE; public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE; @@ -53,17 +60,22 @@ public class Notes { /** * Uri to query all notes and folders + *查询所有笔记和文件夹的Uri */ + //定义查询便签和文件夹的指针 public static final Uri CONTENT_NOTE_URI = Uri.parse("content://" + AUTHORITY + "/note"); /** * Uri to query data + *查询数据的Uri */ + //定义查找数据的指针 public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data"); - + // 定义NoteColumns的常量,用于后面创建数据库的表头 + //标准化定义一些常量便于之后的管理运用 public interface NoteColumns { /** - * The unique ID for a row + * The unique ID for a row 行 *

Type: INTEGER (long)

*/ public static final String ID = "_id"; @@ -166,7 +178,8 @@ public class Notes { */ public static final String VERSION = "version"; } - + + // 定义DataColumns的常量,用于后面创建数据库的表头 public interface DataColumns { /** * The unique ID for a row @@ -244,36 +257,44 @@ public class Notes { 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 int MODE_CHECK_LIST = 1; + // 整个文本笔记集合的内容类型 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"; + // 用于访问文本笔记集合的内容URI public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note"); } public static final class CallNote implements DataColumns { /** * Call date for this record + * 通话记录的通话日期 *

Type: INTEGER (long)

*/ public static final String CALL_DATE = DATA1; /** * Phone number for this record + *通话记录的电话号码 *

Type: TEXT

*/ public static final String PHONE_NUMBER = DATA3; + // 整个通话笔记集合的内容类型 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"; + // 用于访问通话笔记集合的内容URI public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/call_note"); } }