You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

305 lines
13 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

/*
* 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;
public class Notes {
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存放通话记录的文件夹
*/
// 小米便签内置的四个特殊文件夹
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;//指定通话记录笔记类型
}//定义笔记的类型
/**
* 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");
public interface NoteColumns {
/**
* The unique ID for a row笔记或文件夹的唯一ID
* <P> Type: INTEGER (long) </P>
*/
public static final String ID = "_id";
/**
* The parent's id for note or folder笔记或文件夹的父级 ID
* <P> Type: INTEGER (long) </P>
*/
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";
/**
* 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笔记所对应的桌面小部件 ID
* <P> Type: INTEGER (long) </P>
*/
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笔记的背景颜色 ID
* <P> Type: INTEGER (long) </P>
*/
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笔记是否包含附件
* <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最后同步 ID
* <P> Type: INTEGER (long) </P>
*/
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移动到临时文件夹之前的原始父级 ID
* <P> Type : INTEGER </P>
*/
public static final String ORIGIN_PARENT_ID = "origin_parent_id";
/**
* The gtask idGoogle 任务 ID
* <P> Type : TEXT </P>
*/
public static final String GTASK_ID = "gtask_id";
/**
* The version code版本号
* <P> Type : INTEGER (long) </P>
*/
public static final String VERSION = "version";
}
/**
* 这个接口DataColumns定义了笔记应用程序中的笔记数据表格中所有列的常量
* 而NotesColumns定义了笔记应用程序中的笔记数据表格中的特定列的常量。
* 因此DataColumns更通用而NotesColumns更具体。
* NotesColumns接口包含笔记的标题、正文和颜色等属性
* 而DataColumns接口包含笔记数据表格中的通用列。
* 在许多情况下,这两个接口将一起使用。所以重复的常量就不在做解释了。
*/
public interface DataColumns {
/**
* The unique ID for a row
* <P> Type: INTEGER (long) </P>
*/
public static final String ID = "_id";
/**
* The MIME type of the item represented by this row.表示该行数据的MIME类型
* <P> Type: Text </P>
*/
public static final String MIME_TYPE = "mime_type";
/**
* The reference id to note that this data belongs to表示该行数据所属的笔记的ID
* <P> Type: INTEGER (long) </P>
*/
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";
/**
* Generic data column, the meaning is {@link #MIMETYPE} specific, used for
* integer data type
* <P> Type: INTEGER </P>
*/
public static final String DATA1 = "data1";
/**
* Generic data column, the meaning is {@link #MIMETYPE} specific, used for
* integer data type
* <P> Type: INTEGER </P>
*/
public static final String DATA2 = "data2";
/**
* Generic data column, the meaning is {@link #MIMETYPE} specific, used for
* TEXT data type
* <P> Type: TEXT </P>
*/
public static final String DATA3 = "data3";
/**
* Generic data column, the meaning is {@link #MIMETYPE} specific, used for
* TEXT data type
* <P> Type: TEXT </P>
*/
public static final String DATA4 = "data4";
/**
* Generic data column, the meaning is {@link #MIMETYPE} specific, used for
* TEXT data type
* <P> Type: TEXT </P>
*/
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
* <P> Type: Integer 1:check list mode 0: normal mode </P>
*/
public static final String MODE = DATA1;//MODE字段表示文本笔记的模式可以是正常模式或者是带有任务清单的模式类型为整数。它使用了接口中的DATA1字段来表示其存储值的列名。
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记录通话日期
* <P> Type: INTEGER (long) </P>
*/
public static final String CALL_DATE = DATA1;
//表示通话日期的列名数据类型为long存储在DATA1列中。
/**
* Phone number for this record记录通话号码
* <P> Type: TEXT </P>
*/
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用于访问通话记录。
}
}