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.
Notes-master/Notes.java

213 lines
9.7 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; // 定义了包名,表示这个类属于 net.micode.notes.data 包
import android.net.Uri; // 导入 Android 的 Uri 类,用于处理内容提供者的 URI
public class Notes { // Notes 类,主要用于定义与笔记相关的常量和 URI 配置
// 内容提供者的 authority 字符串,用于唯一标识此内容提供者
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; // 系统类型
/**
* 以下常量是系统文件夹的标识符
* {@link Notes#ID_ROOT_FOLDER} 是默认文件夹
* {@link Notes#ID_TEMPARAY_FOLDER} 是存储不属于任何文件夹的笔记
* {@link Notes#ID_CALL_RECORD_FOLDER} 用于存储通话记录
*/
public static final int ID_ROOT_FOLDER = 0; // 根文件夹的 ID
public static final int ID_TEMPARAY_FOLDER = -1; // 临时文件夹的 ID
public static final int ID_CALL_RECORD_FOLDER = -2; // 通话记录文件夹的 ID
public static final int ID_TRASH_FOLER = -3; // 垃圾桶文件夹的 ID
// Intent 中传递的额外参数常量,用于与笔记相关的操作
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"; // 背景颜色 ID
public static final String INTENT_EXTRA_WIDGET_ID = "net.micode.notes.widget_id"; // 小部件 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"; // 文件夹 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; // 2x 小部件类型
public static final int TYPE_WIDGET_4X = 1; // 4x 小部件类型
// 数据常量类,定义了笔记和通话记录的内容类型
public static class DataConstants {
public static final String NOTE = TextNote.CONTENT_ITEM_TYPE; // 笔记的内容类型
public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE; // 通话记录的内容类型
}
/**
* 用于查询所有笔记和文件夹的 URI
*/
public static final Uri CONTENT_NOTE_URI = Uri.parse("content://" + AUTHORITY + "/note"); // 查询笔记的 URI
/**
* 用于查询数据的 URI
*/
public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data"); // 查询数据的 URI
// 笔记相关的列定义接口,包含笔记的数据列
public interface NoteColumns {
/**
* 每一行的唯一 ID
* <P> 类型: INTEGER (long) </P>
*/
public static final String ID = "_id"; // 唯一标识符
/**
* 笔记或文件夹的父 ID
* <P> 类型: INTEGER (long) </P>
*/
public static final String PARENT_ID = "parent_id"; // 父级 ID
/**
* 笔记或文件夹的创建日期
* <P> 类型: INTEGER (long) </P>
*/
public static final String CREATED_DATE = "created_date"; // 创建日期
/**
* 笔记或文件夹的最后修改日期
* <P> 类型: INTEGER (long) </P>
*/
public static final String MODIFIED_DATE = "modified_date"; // 最后修改日期
}
}
/**
* The constant fields represent various columns of a note-taking application database.
* These constants are used to define column names and their data types within the database schema.
*/
public static final String ALERTED_DATE = "alert_date"; // 记录提醒日期数据类型INTEGER长整型
public static final String SNIPPET = "snippet"; // 记录文件夹名称或笔记的文本内容数据类型TEXT字符串
public static final String WIDGET_ID = "widget_id"; // 记录笔记的小部件ID数据类型INTEGER长整型
public static final String WIDGET_TYPE = "widget_type"; // 记录笔记的小部件类型数据类型INTEGER长整型
public static final String BG_COLOR_ID = "bg_color_id"; // 记录笔记的背景颜色ID数据类型INTEGER长整型
public static final String HAS_ATTACHMENT = "has_attachment"; // 标记笔记是否有附件文本笔记没有附件多媒体笔记至少有一个附件数据类型INTEGER整型
public static final String NOTES_COUNT = "notes_count"; // 文件夹中笔记的数量数据类型INTEGER长整型
public static final String TYPE = "type"; // 文件类型标识为文件夹或笔记数据类型INTEGER整型
public static final String SYNC_ID = "sync_id"; // 记录上次同步的ID数据类型INTEGER长整型
public static final String LOCAL_MODIFIED = "local_modified"; // 本地修改标识用来表示该项是否被本地修改过数据类型INTEGER整型
public static final String ORIGIN_PARENT_ID = "origin_parent_id"; // 记录笔记或文件夹在移动到临时文件夹之前的原始父级ID数据类型INTEGER整型
public static final String GTASK_ID = "gtask_id"; // 记录Google任务的ID数据类型TEXT字符串
public static final String VERSION = "version"; // 记录笔记或文件夹的版本号数据类型INTEGER长整型
/**
* DataColumns接口用于定义存储在数据表中的列字段通常用于数据相关的记录。
*/
public interface DataColumns {
public static final String ID = "_id"; // 记录行的唯一标识符数据类型INTEGER长整型
public static final String MIME_TYPE = "mime_type"; // 记录数据项的MIME类型数据类型TEXT字符串
public static final String NOTE_ID = "note_id"; // 记录数据所对应的笔记ID数据类型INTEGER长整型
public static final String CREATED_DATE = "created_date"; // 记录数据创建的日期数据类型INTEGER长整型
public static final String MODIFIED_DATE = "modified_date"; // 记录数据最后修改的日期数据类型INTEGER长整型
public static final String CONTENT = "content"; // 记录数据的具体内容数据类型TEXT字符串
public static final String DATA1 = "data1"; // 一个通用数据列具体意义根据MIME类型而定数据类型INTEGER整型
public static final String DATA2 = "data2"; // 另一个通用数据列具体意义根据MIME类型而定数据类型INTEGER整型
}
/**
* 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";
}
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;
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";
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";
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");
}
}