|
|
/*
|
|
|
* 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;
|
|
|
|
|
|
/**
|
|
|
* 便签应用的数据模型类,定义便签和文件夹的常量、URI及数据库表结构
|
|
|
* 包含类型标识、系统文件夹ID、 Intent 传递参数、数据列定义等
|
|
|
*/
|
|
|
public class Notes {
|
|
|
// 内容提供者的权限标识,用于URI构建
|
|
|
public static final String AUTHORITY = "micode_notes";
|
|
|
// 日志标签,用于Logcat过滤
|
|
|
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; // 系统内置类型
|
|
|
|
|
|
/**
|
|
|
* 系统文件夹ID说明:
|
|
|
* {@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传递的额外参数键名(用于Activity间数据传递)
|
|
|
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尺寸
|
|
|
|
|
|
/**
|
|
|
* 数据类型常量内部类,定义便签内容的MIME类型
|
|
|
*/
|
|
|
public static class DataConstants {
|
|
|
public static final String NOTE = TextNote.CONTENT_ITEM_TYPE; // 文本便签类型
|
|
|
public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE; // 通话记录便签类型
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 内容提供者URI:查询所有便签和文件夹
|
|
|
* 格式:content://{AUTHORITY}/note
|
|
|
*/
|
|
|
public static final Uri CONTENT_NOTE_URI = Uri.parse("content://" + AUTHORITY + "/note");
|
|
|
|
|
|
/**
|
|
|
* 内容提供者URI:查询便签附件或详细数据
|
|
|
* 格式:content://{AUTHORITY}/data
|
|
|
*/
|
|
|
public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data");
|
|
|
|
|
|
/**
|
|
|
* 便签/文件夹数据库表字段接口(Note表结构)
|
|
|
* 定义表中各列的常量名及数据类型说明
|
|
|
*/
|
|
|
public interface NoteColumns {
|
|
|
/**
|
|
|
* 行唯一ID
|
|
|
* <P> 类型:INTEGER (long) </P>
|
|
|
*/
|
|
|
public static final String ID = "_id";
|
|
|
|
|
|
/**
|
|
|
* 父级ID(便签所属文件夹ID,或文件夹的父文件夹ID)
|
|
|
* <P> 类型:INTEGER (long) </P>
|
|
|
*/
|
|
|
public static final String PARENT_ID = "parent_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";
|
|
|
|
|
|
/**
|
|
|
* 提醒日期(时间戳)
|
|
|
* <P> 类型:INTEGER (long) </P>
|
|
|
*/
|
|
|
public static final String ALERTED_DATE = "alert_date";
|
|
|
|
|
|
/**
|
|
|
* 文件夹名称或便签文本内容
|
|
|
* <P> 类型:TEXT </P>
|
|
|
*/
|
|
|
public static final String SNIPPET = "snippet";
|
|
|
|
|
|
/**
|
|
|
* 便签关联的桌面小部件ID
|
|
|
* <P> 类型:INTEGER (long) </P>
|
|
|
*/
|
|
|
public static final String WIDGET_ID = "widget_id";
|
|
|
|
|
|
/**
|
|
|
* 便签关联的桌面小部件类型
|
|
|
* <P> 类型:INTEGER (long) </P>
|
|
|
*/
|
|
|
public static final String WIDGET_TYPE = "widget_type";
|
|
|
|
|
|
/**
|
|
|
* 便签背景色ID
|
|
|
* <P> 类型:INTEGER (long) </P>
|
|
|
*/
|
|
|
public static final String BG_COLOR_ID = "bg_color_id";
|
|
|
|
|
|
/**
|
|
|
* 便签是否包含附件(1=有,0=无)
|
|
|
* <P> 类型:INTEGER </P>
|
|
|
*/
|
|
|
public static final String HAS_ATTACHMENT = "has_attachment";
|
|
|
|
|
|
/**
|
|
|
* 文件夹包含的便签数量
|
|
|
* <P> 类型:INTEGER (long) </P>
|
|
|
*/
|
|
|
public static final String NOTES_COUNT = "notes_count";
|
|
|
|
|
|
/**
|
|
|
* 数据类型(便签/文件夹/系统类型)
|
|
|
* <P> 类型:INTEGER </P>
|
|
|
*/
|
|
|
public static final String TYPE = "type";
|
|
|
|
|
|
/**
|
|
|
* 最后同步ID(用于云同步)
|
|
|
* <P> 类型:INTEGER (long) </P>
|
|
|
*/
|
|
|
public static final String SYNC_ID = "sync_id";
|
|
|
|
|
|
/**
|
|
|
* 本地修改标识(1=已修改,0=未修改)
|
|
|
* <P> 类型:INTEGER </P>
|
|
|
*/
|
|
|
public static final String LOCAL_MODIFIED = "local_modified";
|
|
|
|
|
|
/**
|
|
|
* 移动到临时文件夹前的原始父ID
|
|
|
* <P> 类型:INTEGER </P>
|
|
|
*/
|
|
|
public static final String ORIGIN_PARENT_ID = "origin_parent_id";
|
|
|
|
|
|
/**
|
|
|
* Google Task ID(用于同步谷歌任务)
|
|
|
* <P> 类型:TEXT </P>
|
|
|
*/
|
|
|
public static final String GTASK_ID = "gtask_id";
|
|
|
|
|
|
/**
|
|
|
* 数据版本号(用于版本控制)
|
|
|
* <P> 类型:INTEGER (long) </P>
|
|
|
*/
|
|
|
public static final String VERSION = "version";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 便签附件/详细数据表字段接口(Data表结构)
|
|
|
* 存储便签的多媒体附件或扩展数据
|
|
|
*/
|
|
|
public interface DataColumns {
|
|
|
/**
|
|
|
* 行唯一ID
|
|
|
* <P> 类型:INTEGER (long) </P>
|
|
|
*/
|
|
|
public static final String ID = "_id";
|
|
|
|
|
|
/**
|
|
|
* 数据项的MIME类型(如图片、音频等)
|
|
|
* <P> 类型:TEXT </P>
|
|
|
*/
|
|
|
public static final String MIME_TYPE = "mime_type";
|
|
|
|
|
|
/**
|
|
|
* 关联的便签ID(外键)
|
|
|
* <P> 类型:INTEGER (long) </P>
|
|
|
*/
|
|
|
public static final String NOTE_ID = "note_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";
|
|
|
|
|
|
/**
|
|
|
* 数据内容(文本类型,如便签富文本)
|
|
|
* <P> 类型:TEXT </P>
|
|
|
*/
|
|
|
public static final String CONTENT = "content";
|
|
|
|
|
|
/**
|
|
|
* 通用数据列1(含义由MIME类型决定,整型)
|
|
|
* <P> 类型:INTEGER </P>
|
|
|
*/
|
|
|
public static final String DATA1 = "data1";
|
|
|
|
|
|
/**
|
|
|
* 通用数据列2(含义由MIME类型决定,整型)
|
|
|
* <P> 类型:INTEGER </P>
|
|
|
*/
|
|
|
public static final String DATA2 = "data2";
|
|
|
|
|
|
/**
|
|
|
* 通用数据列3(含义由MIME类型决定,文本型)
|
|
|
* <P> 类型:TEXT </P>
|
|
|
*/
|
|
|
public static final String DATA3 = "data3";
|
|
|
|
|
|
/**
|
|
|
* 通用数据列4(含义由MIME类型决定,文本型)
|
|
|
* <P> 类型:TEXT </P>
|
|
|
*/
|
|
|
public static final String DATA4 = "data4";
|
|
|
|
|
|
/**
|
|
|
* 通用数据列5(含义由MIME类型决定,文本型)
|
|
|
* <P> 类型:TEXT </P>
|
|
|
*/
|
|
|
public static final String DATA5 = "data5";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 文本便签内部类(继承DataColumns接口)
|
|
|
* 定义文本便签的特殊字段和URI
|
|
|
*/
|
|
|
public static final class TextNote implements DataColumns {
|
|
|
/**
|
|
|
* 便签模式(清单模式/普通模式)
|
|
|
* <P> 类型:Integer(1=清单模式,0=普通模式) </P>
|
|
|
* 存储于DataColumns.DATA1列
|
|
|
*/
|
|
|
public static final String MODE = DATA1;
|
|
|
|
|
|
// 清单模式标识
|
|
|
public static final int MODE_CHECK_LIST = 1;
|
|
|
|
|
|
// 内容提供者相关URI和MIME类型
|
|
|
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"); // 文本便签URI
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 通话记录便签内部类(继承DataColumns接口)
|
|
|
* 定义通话记录便签的特殊字段和URI
|
|
|
*/
|
|
|
public static final class CallNote implements DataColumns {
|
|
|
/**
|
|
|
* 通话日期(时间戳)
|
|
|
* <P> 类型:INTEGER (long) </P>
|
|
|
* 存储于DataColumns.DATA1列
|
|
|
*/
|
|
|
public static final String CALL_DATE = DATA1;
|
|
|
|
|
|
/**
|
|
|
* 电话号码
|
|
|
* <P> 类型:TEXT </P>
|
|
|
* 存储于DataColumns.DATA3列
|
|
|
*/
|
|
|
public static final String PHONE_NUMBER = DATA3;
|
|
|
|
|
|
// 内容提供者相关URI和MIME类型
|
|
|
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"); // 通话记录URI
|
|
|
}
|
|
|
} |