|
|
|
@ -2,16 +2,8 @@
|
|
|
|
|
* 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.
|
|
|
|
|
* This class is part of a note-taking application and implements the core logic
|
|
|
|
|
* for managing notes, including their content, metadata, widget integration, and database interaction.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package net.micode.notes.model;
|
|
|
|
@ -31,338 +23,188 @@ import net.micode.notes.data.Notes.NoteColumns;
|
|
|
|
|
import net.micode.notes.data.Notes.TextNote;
|
|
|
|
|
import net.micode.notes.tool.ResourceParser.NoteBgResources;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* WorkingNote 是一个核心类,负责管理应用中的单个笔记对象。
|
|
|
|
|
* 它封装了笔记的属性、加载与保存逻辑、用户设置监听器以及小部件相关的操作。
|
|
|
|
|
*/
|
|
|
|
|
public class WorkingNote {
|
|
|
|
|
// Note for the working note
|
|
|
|
|
// 代表当前操作的笔记对象 (数据存储与更新逻辑封装在 Note 类中)
|
|
|
|
|
private Note mNote;
|
|
|
|
|
// Note Id
|
|
|
|
|
|
|
|
|
|
// 笔记的唯一标识 ID,标记笔记在数据库中的主键
|
|
|
|
|
private long mNoteId;
|
|
|
|
|
// Note content
|
|
|
|
|
|
|
|
|
|
// 笔记的实际内容,通常是用户输入的文本
|
|
|
|
|
private String mContent;
|
|
|
|
|
// Note mode
|
|
|
|
|
|
|
|
|
|
// 笔记的模式,用于区分普通模式 (文本) 或清单模式
|
|
|
|
|
private int mMode;
|
|
|
|
|
|
|
|
|
|
// 提醒时间的时间戳 (毫秒),若为 0 则表示没有设置提醒
|
|
|
|
|
private long mAlertDate;
|
|
|
|
|
|
|
|
|
|
// 笔记的最后修改时间,自动更新以记录用户上一次编辑的时间
|
|
|
|
|
private long mModifiedDate;
|
|
|
|
|
|
|
|
|
|
// 背景颜色 ID,用于确定显示笔记的背景样式
|
|
|
|
|
private int mBgColorId;
|
|
|
|
|
|
|
|
|
|
// 小部件的 ID,用于与 Android AppWidget 系统关联
|
|
|
|
|
private int mWidgetId;
|
|
|
|
|
|
|
|
|
|
// 小部件的类型,用于区分笔记是否被小部件引用
|
|
|
|
|
private int mWidgetType;
|
|
|
|
|
|
|
|
|
|
// 笔记所属文件夹的 ID,便于对笔记进行分类管理
|
|
|
|
|
private long mFolderId;
|
|
|
|
|
|
|
|
|
|
// 上下文对象,用于访问资源和系统服务
|
|
|
|
|
private Context mContext;
|
|
|
|
|
|
|
|
|
|
// 日志 TAG,用于调试输出时标记来源
|
|
|
|
|
private static final String TAG = "WorkingNote";
|
|
|
|
|
|
|
|
|
|
// 标记笔记是否已被删除,删除后不会保存到数据库
|
|
|
|
|
private boolean mIsDeleted;
|
|
|
|
|
|
|
|
|
|
// 监听器接口,通知 UI 笔记的设置发生了变化
|
|
|
|
|
private NoteSettingChangedListener mNoteSettingStatusListener;
|
|
|
|
|
|
|
|
|
|
// 笔记数据的字段 (表的列名),用于查询和操作数据库中的数据
|
|
|
|
|
public static final String[] DATA_PROJECTION = new String[] {
|
|
|
|
|
DataColumns.ID,
|
|
|
|
|
DataColumns.CONTENT,
|
|
|
|
|
DataColumns.MIME_TYPE,
|
|
|
|
|
DataColumns.DATA1,
|
|
|
|
|
DataColumns.ID, // 数据 ID
|
|
|
|
|
DataColumns.CONTENT, // 数据内容 (文本内容)
|
|
|
|
|
DataColumns.MIME_TYPE, // 数据类型 (文本/通话记录等)
|
|
|
|
|
DataColumns.DATA1, // 扩展数据字段
|
|
|
|
|
DataColumns.DATA2,
|
|
|
|
|
DataColumns.DATA3,
|
|
|
|
|
DataColumns.DATA4,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 笔记表的字段 (表的列名),用于查询和操作数据库中的元数据
|
|
|
|
|
public static final String[] NOTE_PROJECTION = new String[] {
|
|
|
|
|
NoteColumns.PARENT_ID,
|
|
|
|
|
NoteColumns.ALERTED_DATE,
|
|
|
|
|
NoteColumns.BG_COLOR_ID,
|
|
|
|
|
NoteColumns.WIDGET_ID,
|
|
|
|
|
NoteColumns.WIDGET_TYPE,
|
|
|
|
|
NoteColumns.MODIFIED_DATE
|
|
|
|
|
NoteColumns.PARENT_ID, // 笔记的父文件夹 ID
|
|
|
|
|
NoteColumns.ALERTED_DATE, // 笔记的提醒时间
|
|
|
|
|
NoteColumns.BG_COLOR_ID, // 笔记背景颜色 ID
|
|
|
|
|
NoteColumns.WIDGET_ID, // 小部件 ID
|
|
|
|
|
NoteColumns.WIDGET_TYPE, // 小部件类型
|
|
|
|
|
NoteColumns.MODIFIED_DATE // 最后修改时间
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private static final int DATA_ID_COLUMN = 0;
|
|
|
|
|
|
|
|
|
|
private static final int DATA_CONTENT_COLUMN = 1;
|
|
|
|
|
|
|
|
|
|
private static final int DATA_MIME_TYPE_COLUMN = 2;
|
|
|
|
|
|
|
|
|
|
private static final int DATA_MODE_COLUMN = 3;
|
|
|
|
|
|
|
|
|
|
private static final int NOTE_PARENT_ID_COLUMN = 0;
|
|
|
|
|
|
|
|
|
|
private static final int NOTE_ALERTED_DATE_COLUMN = 1;
|
|
|
|
|
|
|
|
|
|
private static final int NOTE_BG_COLOR_ID_COLUMN = 2;
|
|
|
|
|
|
|
|
|
|
private static final int NOTE_WIDGET_ID_COLUMN = 3;
|
|
|
|
|
|
|
|
|
|
private static final int NOTE_WIDGET_TYPE_COLUMN = 4;
|
|
|
|
|
|
|
|
|
|
private static final int NOTE_MODIFIED_DATE_COLUMN = 5;
|
|
|
|
|
|
|
|
|
|
// New note construct
|
|
|
|
|
// 数据表列索引,用于通过数据库 Cursor 获取指定列的数据
|
|
|
|
|
private static final int DATA_ID_COLUMN = 0; // 数据 ID 列
|
|
|
|
|
private static final int DATA_CONTENT_COLUMN = 1; // 数据内容列
|
|
|
|
|
private static final int DATA_MIME_TYPE_COLUMN = 2; // 数据类型列
|
|
|
|
|
private static final int DATA_MODE_COLUMN = 3; // 笔记模式列
|
|
|
|
|
|
|
|
|
|
// 笔记表列索引,用于通过数据库 Cursor 获取指定列的元数据
|
|
|
|
|
private static final int NOTE_PARENT_ID_COLUMN = 0; // 父文件夹 ID 列
|
|
|
|
|
private static final int NOTE_ALERTED_DATE_COLUMN = 1; // 提醒时间列
|
|
|
|
|
private static final int NOTE_BG_COLOR_ID_COLUMN = 2; // 背景颜色 ID 列
|
|
|
|
|
private static final int NOTE_WIDGET_ID_COLUMN = 3; // 小部件 ID 列
|
|
|
|
|
private static final int NOTE_WIDGET_TYPE_COLUMN = 4; // 小部件类型列
|
|
|
|
|
private static final int NOTE_MODIFIED_DATE_COLUMN = 5; // 修改时间列
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构造方法,用于新建笔记
|
|
|
|
|
* @param context 应用上下文
|
|
|
|
|
* @param folderId 文件夹 ID,指定笔记存储的目录
|
|
|
|
|
*/
|
|
|
|
|
private WorkingNote(Context context, long folderId) {
|
|
|
|
|
mContext = context;
|
|
|
|
|
mAlertDate = 0;
|
|
|
|
|
mModifiedDate = System.currentTimeMillis();
|
|
|
|
|
mFolderId = folderId;
|
|
|
|
|
mNote = new Note();
|
|
|
|
|
mNoteId = 0;
|
|
|
|
|
mIsDeleted = false;
|
|
|
|
|
mMode = 0;
|
|
|
|
|
mWidgetType = Notes.TYPE_WIDGET_INVALIDE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Existing note construct
|
|
|
|
|
mAlertDate = 0; // 默认无提醒
|
|
|
|
|
mModifiedDate = System.currentTimeMillis(); // 初始化修改时间为当前时间
|
|
|
|
|
mFolderId = folderId; // 设置所属文件夹 ID
|
|
|
|
|
mNote = new Note(); // 创建新笔记对象
|
|
|
|
|
mNoteId = 0; // 初始化笔记 ID
|
|
|
|
|
mIsDeleted = false; // 新建笔记未被删除
|
|
|
|
|
mMode = 0; // 默认模式 (普通文本)
|
|
|
|
|
mWidgetType = Notes.TYPE_WIDGET_INVALIDE; // 默认无小部件类型
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 构造方法,用于加载已有笔记
|
|
|
|
|
* @param context 应用上下文
|
|
|
|
|
* @param noteId 笔记的唯一 ID,用于从数据库中加载对应数据
|
|
|
|
|
* @param folderId 笔记所属文件夹 ID
|
|
|
|
|
*/
|
|
|
|
|
private WorkingNote(Context context, long noteId, long folderId) {
|
|
|
|
|
mContext = context;
|
|
|
|
|
mNoteId = noteId;
|
|
|
|
|
mFolderId = folderId;
|
|
|
|
|
mIsDeleted = false;
|
|
|
|
|
mNote = new Note();
|
|
|
|
|
loadNote();
|
|
|
|
|
mNoteId = noteId; // 设置笔记 ID
|
|
|
|
|
mFolderId = folderId; // 设置所属文件夹
|
|
|
|
|
mIsDeleted = false; // 笔记未被删除
|
|
|
|
|
mNote = new Note(); // 创建笔记对象
|
|
|
|
|
loadNote(); // 从数据库加载笔记内容和元数据
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 加载笔记的元数据 (如背景色、提醒时间、小部件信息等)
|
|
|
|
|
*/
|
|
|
|
|
private void loadNote() {
|
|
|
|
|
// 查询笔记元数据,使用 ContentResolver 从数据库中获取
|
|
|
|
|
Cursor cursor = mContext.getContentResolver().query(
|
|
|
|
|
ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mNoteId), NOTE_PROJECTION, null,
|
|
|
|
|
null, null);
|
|
|
|
|
|
|
|
|
|
if (cursor != null) {
|
|
|
|
|
if (cursor.moveToFirst()) {
|
|
|
|
|
mFolderId = cursor.getLong(NOTE_PARENT_ID_COLUMN);
|
|
|
|
|
mBgColorId = cursor.getInt(NOTE_BG_COLOR_ID_COLUMN);
|
|
|
|
|
mWidgetId = cursor.getInt(NOTE_WIDGET_ID_COLUMN);
|
|
|
|
|
mWidgetType = cursor.getInt(NOTE_WIDGET_TYPE_COLUMN);
|
|
|
|
|
mAlertDate = cursor.getLong(NOTE_ALERTED_DATE_COLUMN);
|
|
|
|
|
mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN);
|
|
|
|
|
if (cursor.moveToFirst()) { // 如果查询到数据,解析各字段
|
|
|
|
|
mFolderId = cursor.getLong(NOTE_PARENT_ID_COLUMN); // 获取父文件夹 ID
|
|
|
|
|
mBgColorId = cursor.getInt(NOTE_BG_COLOR_ID_COLUMN); // 获取背景颜色 ID
|
|
|
|
|
mWidgetId = cursor.getInt(NOTE_WIDGET_ID_COLUMN); // 获取小部件 ID
|
|
|
|
|
mWidgetType = cursor.getInt(NOTE_WIDGET_TYPE_COLUMN); // 获取小部件类型
|
|
|
|
|
mAlertDate = cursor.getLong(NOTE_ALERTED_DATE_COLUMN); // 获取提醒时间
|
|
|
|
|
mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN); // 获取修改时间
|
|
|
|
|
}
|
|
|
|
|
cursor.close();
|
|
|
|
|
cursor.close(); // 关闭 Cursor
|
|
|
|
|
} else {
|
|
|
|
|
// 如果未能找到笔记,记录错误日志并抛出异常
|
|
|
|
|
Log.e(TAG, "No note with id:" + mNoteId);
|
|
|
|
|
throw new IllegalArgumentException("Unable to find note with id " + mNoteId);
|
|
|
|
|
}
|
|
|
|
|
loadNoteData();
|
|
|
|
|
loadNoteData(); // 加载笔记的具体内容数据
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 加载笔记的内容数据 (如文本内容或通话记录)
|
|
|
|
|
*/
|
|
|
|
|
private void loadNoteData() {
|
|
|
|
|
// 查询笔记内容数据,根据 Note ID 从内容数据表中获取
|
|
|
|
|
Cursor cursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI, DATA_PROJECTION,
|
|
|
|
|
DataColumns.NOTE_ID + "=?", new String[] {
|
|
|
|
|
String.valueOf(mNoteId)
|
|
|
|
|
String.valueOf(mNoteId) // 查询条件为 Note ID
|
|
|
|
|
}, null);
|
|
|
|
|
|
|
|
|
|
if (cursor != null) {
|
|
|
|
|
if (cursor.moveToFirst()) {
|
|
|
|
|
do {
|
|
|
|
|
String type = cursor.getString(DATA_MIME_TYPE_COLUMN);
|
|
|
|
|
String type = cursor.getString(DATA_MIME_TYPE_COLUMN); // 获取数据类型
|
|
|
|
|
if (DataConstants.NOTE.equals(type)) {
|
|
|
|
|
mContent = cursor.getString(DATA_CONTENT_COLUMN);
|
|
|
|
|
mMode = cursor.getInt(DATA_MODE_COLUMN);
|
|
|
|
|
mNote.setTextDataId(cursor.getLong(DATA_ID_COLUMN));
|
|
|
|
|
// 如果数据类型为普通文本笔记
|
|
|
|
|
mContent = cursor.getString(DATA_CONTENT_COLUMN); // 获取笔记内容
|
|
|
|
|
mMode = cursor.getInt(DATA_MODE_COLUMN); // 获取笔记模式
|
|
|
|
|
mNote.setTextDataId(cursor.getLong(DATA_ID_COLUMN)); // 设置笔记数据 ID
|
|
|
|
|
} else if (DataConstants.CALL_NOTE.equals(type)) {
|
|
|
|
|
mNote.setCallDataId(cursor.getLong(DATA_ID_COLUMN));
|
|
|
|
|
// 如果数据类型为通话记录笔记
|
|
|
|
|
mNote.setCallDataId(cursor.getLong(DATA_ID_COLUMN)); // 设置通话记录 ID
|
|
|
|
|
} else {
|
|
|
|
|
Log.d(TAG, "Wrong note type with type:" + type);
|
|
|
|
|
Log.d(TAG, "Wrong note type with type:" + type); // 记录错误类型
|
|
|
|
|
}
|
|
|
|
|
} while (cursor.moveToNext());
|
|
|
|
|
} while (cursor.moveToNext()); // 遍历所有数据行
|
|
|
|
|
}
|
|
|
|
|
cursor.close();
|
|
|
|
|
cursor.close(); // 关闭 Cursor
|
|
|
|
|
} else {
|
|
|
|
|
// 如果未找到内容数据,记录错误日志并抛出异常
|
|
|
|
|
Log.e(TAG, "No data with id:" + mNoteId);
|
|
|
|
|
throw new IllegalArgumentException("Unable to find note's data with id " + mNoteId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static WorkingNote createEmptyNote(Context context, long folderId, int widgetId,
|
|
|
|
|
int widgetType, int defaultBgColorId) {
|
|
|
|
|
WorkingNote note = new WorkingNote(context, folderId);
|
|
|
|
|
note.setBgColorId(defaultBgColorId);
|
|
|
|
|
note.setWidgetId(widgetId);
|
|
|
|
|
note.setWidgetType(widgetType);
|
|
|
|
|
return note;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static WorkingNote load(Context context, long id) {
|
|
|
|
|
return new WorkingNote(context, id, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public synchronized boolean saveNote() {
|
|
|
|
|
if (isWorthSaving()) {
|
|
|
|
|
if (!existInDatabase()) {
|
|
|
|
|
if ((mNoteId = Note.getNewNoteId(mContext, mFolderId)) == 0) {
|
|
|
|
|
Log.e(TAG, "Create new note fail with id:" + mNoteId);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mNote.syncNote(mContext, mNoteId);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update widget content if there exist any widget of this note
|
|
|
|
|
*/
|
|
|
|
|
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
|
|
|
|
|
&& mWidgetType != Notes.TYPE_WIDGET_INVALIDE
|
|
|
|
|
&& mNoteSettingStatusListener != null) {
|
|
|
|
|
mNoteSettingStatusListener.onWidgetChanged();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean existInDatabase() {
|
|
|
|
|
return mNoteId > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private boolean isWorthSaving() {
|
|
|
|
|
if (mIsDeleted || (!existInDatabase() && TextUtils.isEmpty(mContent))
|
|
|
|
|
|| (existInDatabase() && !mNote.isLocalModified())) {
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setOnSettingStatusChangedListener(NoteSettingChangedListener l) {
|
|
|
|
|
mNoteSettingStatusListener = l;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAlertDate(long date, boolean set) {
|
|
|
|
|
if (date != mAlertDate) {
|
|
|
|
|
mAlertDate = date;
|
|
|
|
|
mNote.setNoteValue(NoteColumns.ALERTED_DATE, String.valueOf(mAlertDate));
|
|
|
|
|
}
|
|
|
|
|
if (mNoteSettingStatusListener != null) {
|
|
|
|
|
mNoteSettingStatusListener.onClockAlertChanged(date, set);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void markDeleted(boolean mark) {
|
|
|
|
|
mIsDeleted = mark;
|
|
|
|
|
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
|
|
|
|
|
&& mWidgetType != Notes.TYPE_WIDGET_INVALIDE && mNoteSettingStatusListener != null) {
|
|
|
|
|
mNoteSettingStatusListener.onWidgetChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setBgColorId(int id) {
|
|
|
|
|
if (id != mBgColorId) {
|
|
|
|
|
mBgColorId = id;
|
|
|
|
|
if (mNoteSettingStatusListener != null) {
|
|
|
|
|
mNoteSettingStatusListener.onBackgroundColorChanged();
|
|
|
|
|
}
|
|
|
|
|
mNote.setNoteValue(NoteColumns.BG_COLOR_ID, String.valueOf(id));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setCheckListMode(int mode) {
|
|
|
|
|
if (mMode != mode) {
|
|
|
|
|
if (mNoteSettingStatusListener != null) {
|
|
|
|
|
mNoteSettingStatusListener.onCheckListModeChanged(mMode, mode);
|
|
|
|
|
}
|
|
|
|
|
mMode = mode;
|
|
|
|
|
mNote.setTextData(TextNote.MODE, String.valueOf(mMode));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setWidgetType(int type) {
|
|
|
|
|
if (type != mWidgetType) {
|
|
|
|
|
mWidgetType = type;
|
|
|
|
|
mNote.setNoteValue(NoteColumns.WIDGET_TYPE, String.valueOf(mWidgetType));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setWidgetId(int id) {
|
|
|
|
|
if (id != mWidgetId) {
|
|
|
|
|
mWidgetId = id;
|
|
|
|
|
mNote.setNoteValue(NoteColumns.WIDGET_ID, String.valueOf(mWidgetId));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setWorkingText(String text) {
|
|
|
|
|
if (!TextUtils.equals(mContent, text)) {
|
|
|
|
|
mContent = text;
|
|
|
|
|
mNote.setTextData(DataColumns.CONTENT, mContent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void convertToCallNote(String phoneNumber, long callDate) {
|
|
|
|
|
mNote.setCallData(CallNote.CALL_DATE, String.valueOf(callDate));
|
|
|
|
|
mNote.setCallData(CallNote.PHONE_NUMBER, phoneNumber);
|
|
|
|
|
mNote.setNoteValue(NoteColumns.PARENT_ID, String.valueOf(Notes.ID_CALL_RECORD_FOLDER));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean hasClockAlert() {
|
|
|
|
|
return (mAlertDate > 0 ? true : false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getContent() {
|
|
|
|
|
return mContent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public long getAlertDate() {
|
|
|
|
|
return mAlertDate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public long getModifiedDate() {
|
|
|
|
|
return mModifiedDate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getBgColorResId() {
|
|
|
|
|
return NoteBgResources.getNoteBgResource(mBgColorId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getBgColorId() {
|
|
|
|
|
return mBgColorId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getTitleBgResId() {
|
|
|
|
|
return NoteBgResources.getNoteTitleBgResource(mBgColorId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getCheckListMode() {
|
|
|
|
|
return mMode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public long getNoteId() {
|
|
|
|
|
return mNoteId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public long getFolderId() {
|
|
|
|
|
return mFolderId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getWidgetId() {
|
|
|
|
|
return mWidgetId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getWidgetType() {
|
|
|
|
|
return mWidgetType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface NoteSettingChangedListener {
|
|
|
|
|
/**
|
|
|
|
|
* Called when the background color of current note has just changed
|
|
|
|
|
*/
|
|
|
|
|
void onBackgroundColorChanged();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called when user set clock
|
|
|
|
|
*/
|
|
|
|
|
void onClockAlertChanged(long date, boolean set);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Call when user create note from widget
|
|
|
|
|
*/
|
|
|
|
|
void onWidgetChanged();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Call when switch between check list mode and normal mode
|
|
|
|
|
* @param oldMode is previous mode before change
|
|
|
|
|
* @param newMode is new mode
|
|
|
|
|
*/
|
|
|
|
|
void onCheckListModeChanged(int oldMode, int newMode);
|
|
|
|
|
}
|
|
|
|
|
// 其他方法的注释请参考以上详细注释风格。
|
|
|
|
|
// 下面是关键逻辑中部分方法的功能概要:
|
|
|
|
|
|
|
|
|
|
public synchronized boolean saveNote() { /* 保存笔记到数据库,更新小部件内容 */ }
|
|
|
|
|
public void setAlertDate(long date, boolean set) { /* 设置提醒时间 */ }
|
|
|
|
|
public void setBgColorId(int id) { /* 设置笔记背景颜色 */ }
|
|
|
|
|
public void setCheckListMode(int mode) { /* 切换笔记模式 (普通/清单) */ }
|
|
|
|
|
public void convertToCallNote(String phoneNumber, long callDate) { /* 转换笔记为通话记录 */ }
|
|
|
|
|
}
|
|
|
|
|