From 84632522058a47644e09f6d67250f53999729565 Mon Sep 17 00:00:00 2001 From: pypwsjf8z <3233271527@qq.com> Date: Mon, 8 Apr 2024 13:30:49 +0800 Subject: [PATCH] =?UTF-8?q?Note.java=E4=BB=A3=E7=A0=81=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Notes.java | 290 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 290 insertions(+) create mode 100644 Notes.java diff --git a/Notes.java b/Notes.java new file mode 100644 index 0000000..33380ff --- /dev/null +++ b/Notes.java @@ -0,0 +1,290 @@ +/* + * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package net.micode.notes.data;//包声明 + +import android.net.Uri;//导入Android框架中的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;//定义了公共静态常量,用于提供一些固定的值 + + /** + * 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 + */ + 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整型常量 + + 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字符串常量 + //用于在Android开发中标识Intent的额外数据 + + 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整数常量,它们很可能用于标识不同类型的小部件或视图 + + public static class DataConstants { + public static final String NOTE = TextNote.CONTENT_ITEM_TYPE; + public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE; + }//定义了一个DataConstants的静态类,该类包含两个静态的、不可变的(final)字符串常量 + + /** + * Uri to query all notes and folders + */ + public static final Uri CONTENT_NOTE_URI = Uri.parse("content://" + AUTHORITY + "/note"); +//定义了一个公共的、静态的、不可变的(final)Uri对象,名为CONTENT_NOTE_URI。这个Uri对象表示一个特定的内容URI,用于Android的内容提供者来标识和访问数据 + + /** + * Uri to query data + */ + public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data"); + + public interface NoteColumns //NoteColumns这样的接口通常用于定义数据库表的列名常量 + { + /** + * The unique ID for a row + *
Type: INTEGER (long)
+ */ + public static final String ID = "_id";//NoteColumns接口定义了一个公共的静态最终(public static final)字符串常量ID,其值为"_id" + + /** + * The parent's id for note or folder + *Type: INTEGER (long)
+ */ + public static final String PARENT_ID = "parent_id";//NoteColumns接口定义了一个公共的静态最终(public static final)字符串常量PARENT_ID,其值为"parent_id" + + /** + * Created data for note or folder + *Type: INTEGER (long)
+ */ + public static final String CREATED_DATE = "created_date";//NoteColumns接口定义了一个公共的静态最终(public static final)字符串常量CREATED_DATE,其值为"created_date" + + + /** + * Latest modified date + *Type: INTEGER (long)
+ */ + public static final String MODIFIED_DATE = "modified_date";//定义一个字符串常量,命名为modified_date + + + /** + * Alert date + *Type: INTEGER (long)
+ */ + public static final String ALERTED_DATE = "alert_date";//定义一个字符串常量,命名为alert_date + + /** + * Folder's name or text content of note + *Type: TEXT
+ */ + public static final String SNIPPET = "snippet";//定义一个字符串常量,命名为snippet + + /** + * Note's widget id + *Type: INTEGER (long)
+ */ + public static final String WIDGET_ID = "widget_id";//定义一个字符串常量,命名为widget_id + + /** + * Note's widget type + *Type: INTEGER (long)
+ */ + public static final String WIDGET_TYPE = "widget_type";//定义一个字符串常量,命名为widget_type + + /** + * Note's background color's id + *Type: INTEGER (long)
+ */ + public static final String BG_COLOR_ID = "bg_color_id";//定义一个字符串常量,命名为bg_color_id + + /** + * For text note, it doesn't has attachment, for multi-media + * note, it has at least one attachment + *Type: INTEGER
+ */ + public static final String HAS_ATTACHMENT = "has_attachment";//定义一个字符串常量,命名为has_attachment + + /** + * Folder's count of notes + *Type: INTEGER (long)
+ */ + public static final String NOTES_COUNT = "notes_count";//定义一个字符串常量,命名为notes_count + + /** + * The file type: folder or note + *Type: INTEGER
+ */ + public static final String TYPE = "type";//定义一个字符串常量,命名为type + + /** + * The last sync id + *Type: INTEGER (long)
+ */ + public static final String SYNC_ID = "sync_id";//定义一个字符串常量,命名为sync_id + + /** + * Sign to indicate local modified or not + *Type: INTEGER
+ */ + public static final String LOCAL_MODIFIED = "local_modified";//定义一个字符串常量,命名为local_modified + + /** + * Original parent id before moving into temporary folder + *Type : INTEGER
+ */ + public static final String ORIGIN_PARENT_ID = "origin_parent_id";//定义一个字符串常量,命名为origin_parent_id + + /** + * The gtask id + *Type : TEXT
+ */ + public static final String GTASK_ID = "gtask_id";//定义一个字符串常量,命名为gtask_id + + /** + * The version code + *Type : INTEGER (long)
+ */ + public static final String VERSION = "version";//定义一个字符串常量,命名为version + } + //其实质上就是对之前出现过的变量与常量进行初始化与处理, + + public interface DataColumns //同样是一个定义数据库列名常量的地方 + { + /** + * The unique ID for a row + *Type: INTEGER (long)
+ */ + public static final String ID = "_id";//定义了一个名为 ID 的常量,其值为字符串 _id + + /** + * The MIME type of the item represented by this row. + *Type: Text
+ */ + public static final String MIME_TYPE = "mime_type";//定义了一个名为MIME_TYPE的常量,其值为字符串 mime_type + + /** + * The reference id to note that this data belongs to + *Type: INTEGER (long)
+ */ + public static final String NOTE_ID = "note_id";//对其NOTE_ID进行定义与初始化 + + /** + * Created data for note or folder + *Type: INTEGER (long)
+ */ + public static final String CREATED_DATE = "created_date";//对其CREATED_DATE进行定义与初始化 + + /** + * Latest modified date + *Type: INTEGER (long)
+ */ + public static final String MODIFIED_DATE = "modified_date";//对其MODIFIED_DATE进行定义与初始化 + + /** + * Data's content + *Type: TEXT
+ */ + public static final String CONTENT = "content";//对其CONTENT进行定义与初始化 + + + /** + * Generic data column, the meaning is {@link #MIMETYPE} specific, used for + * integer data type + *Type: INTEGER
+ */ + public static final String DATA1 = "data1";//对其DATA1进行定义与初始化 + + /** + * Generic data column, the meaning is {@link #MIMETYPE} specific, used for + * integer data type + *Type: INTEGER
+ */ + public static final String DATA2 = "data2";//对其DATA2 进行定义与初始化 + + /** + * Generic data column, the meaning is {@link #MIMETYPE} specific, used for + * TEXT data type + *Type: TEXT
+ */ + public static final String DATA3 = "data3";//对其DATA3进行定义与初始化 + + /** + * Generic data column, the meaning is {@link #MIMETYPE} specific, used for + * TEXT data type + *Type: TEXT
+ */ + public static final String DATA4 = "data4";//对其 DATA4 进行定义与初始化 + + /** + * Generic data column, the meaning is {@link #MIMETYPE} specific, used for + * TEXT data type + *Type: TEXT
+ */ + public static final String DATA5 = "data5";//对其DATA5进行定义与初始化 + } + + public static final class TextNote implements DataColumns //TextNote 是一个公共的静态最终类(public static final class),它实现了 DataColumns 接口。 + //这意味着 TextNote 类将继承 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;//定义了一个名为 MODE 的公共静态最终字符串常量 + + 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类型 + + public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/text_note";//这行代码定义了一个名为 CONTENT_ITEM_TYPE 的公共静态最终字符串常量, + + public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note");//定义了一个公共的、静态的、最终的 Uri 对象 + } + + public static final class CallNote implements DataColumns //定义了一个名为CallNote的静态内部类,并且这个类实现了DataColumns接口 + { + /** + * Call date for this record + *Type: INTEGER (long)
+ */ + public static final String CALL_DATE = DATA1;//CALL_DATE是一个公共的、静态的、最终的字符串常量,它的值被设置为DATA1 + + /** + * Phone number for this record + *Type: TEXT
+ */ + public static final String PHONE_NUMBER = DATA3;//同样地,PHONE_NUMBER是一个公共的、静态的、最终的字符串常量,它的值被设置为DATA3 + + public static final String CONTENT_TYPE = "vnd.android.cursor.dir/call_note";//CONTENT_TYPE是一个表示MIME类型的常量,用于描述CallNote类型的数据集是一个目录(dir) + + public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/call_note";//CONTENT_ITEM_TYPE是一个表示MIME类型的常量,用于描述CallNote类型的数据项是一个单个项目 + + public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/call_note");//定义了一个公共的、静态的、最终的Uri对象,名为CONTENT_URI。 + } +}