|
|
@ -33,35 +33,36 @@ import net.micode.notes.tool.ResourceParser.NoteBgResources;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class WorkingNote {
|
|
|
|
public class WorkingNote {
|
|
|
|
// Note for the working note
|
|
|
|
// 存储工作笔记的信息,Note 类可能包含笔记的更多细节
|
|
|
|
private Note mNote;
|
|
|
|
private Note mNote;
|
|
|
|
// Note Id
|
|
|
|
// 笔记的唯一标识符
|
|
|
|
private long mNoteId;
|
|
|
|
private long mNoteId;
|
|
|
|
// Note content
|
|
|
|
// 笔记的内容
|
|
|
|
private String mContent;
|
|
|
|
private String mContent;
|
|
|
|
// Note mode
|
|
|
|
// 笔记的模式
|
|
|
|
private int mMode;
|
|
|
|
private int mMode;
|
|
|
|
|
|
|
|
// 提醒日期
|
|
|
|
private long mAlertDate;
|
|
|
|
private long mAlertDate;
|
|
|
|
|
|
|
|
// 笔记的修改日期
|
|
|
|
private long mModifiedDate;
|
|
|
|
private long mModifiedDate;
|
|
|
|
|
|
|
|
// 笔记的背景颜色标识符
|
|
|
|
private int mBgColorId;
|
|
|
|
private int mBgColorId;
|
|
|
|
|
|
|
|
// 小部件的标识符
|
|
|
|
private int mWidgetId;
|
|
|
|
private int mWidgetId;
|
|
|
|
|
|
|
|
// 小部件的类型
|
|
|
|
private int mWidgetType;
|
|
|
|
private int mWidgetType;
|
|
|
|
|
|
|
|
// 文件夹的标识符
|
|
|
|
private long mFolderId;
|
|
|
|
private long mFolderId;
|
|
|
|
|
|
|
|
// 上下文,可能用于资源访问、数据库操作等
|
|
|
|
private Context mContext;
|
|
|
|
private Context mContext;
|
|
|
|
|
|
|
|
// 用于日志输出的标记
|
|
|
|
private static final String TAG = "WorkingNote";
|
|
|
|
private static final String TAG = "WorkingNote";
|
|
|
|
|
|
|
|
// 标记笔记是否已删除
|
|
|
|
private boolean mIsDeleted;
|
|
|
|
private boolean mIsDeleted;
|
|
|
|
|
|
|
|
// 笔记设置更改的监听器,当笔记的设置发生变化时,会通知监听器
|
|
|
|
private NoteSettingChangedListener mNoteSettingStatusListener;
|
|
|
|
private NoteSettingChangedListener mNoteSettingStatusListener;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 用于查询笔记数据的投影,指定了需要从数据库中查询的列
|
|
|
|
public static final String[] DATA_PROJECTION = new String[] {
|
|
|
|
public static final String[] DATA_PROJECTION = new String[] {
|
|
|
|
DataColumns.ID,
|
|
|
|
DataColumns.ID,
|
|
|
|
DataColumns.CONTENT,
|
|
|
|
DataColumns.CONTENT,
|
|
|
@ -72,6 +73,7 @@ public class WorkingNote {
|
|
|
|
DataColumns.DATA4,
|
|
|
|
DataColumns.DATA4,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 用于查询笔记信息的投影,指定了需要从数据库中查询的列
|
|
|
|
public static final String[] NOTE_PROJECTION = new String[] {
|
|
|
|
public static final String[] NOTE_PROJECTION = new String[] {
|
|
|
|
NoteColumns.PARENT_ID,
|
|
|
|
NoteColumns.PARENT_ID,
|
|
|
|
NoteColumns.ALERTED_DATE,
|
|
|
|
NoteColumns.ALERTED_DATE,
|
|
|
@ -81,27 +83,21 @@ public class WorkingNote {
|
|
|
|
NoteColumns.MODIFIED_DATE
|
|
|
|
NoteColumns.MODIFIED_DATE
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 数据投影中各列的索引,方便从 Cursor 中获取数据
|
|
|
|
private static final int DATA_ID_COLUMN = 0;
|
|
|
|
private static final int DATA_ID_COLUMN = 0;
|
|
|
|
|
|
|
|
|
|
|
|
private static final int DATA_CONTENT_COLUMN = 1;
|
|
|
|
private static final int DATA_CONTENT_COLUMN = 1;
|
|
|
|
|
|
|
|
|
|
|
|
private static final int DATA_MIME_TYPE_COLUMN = 2;
|
|
|
|
private static final int DATA_MIME_TYPE_COLUMN = 2;
|
|
|
|
|
|
|
|
|
|
|
|
private static final int DATA_MODE_COLUMN = 3;
|
|
|
|
private static final int DATA_MODE_COLUMN = 3;
|
|
|
|
|
|
|
|
// 笔记投影中各列的索引,方便从 Cursor 中获取数据
|
|
|
|
private static final int NOTE_PARENT_ID_COLUMN = 0;
|
|
|
|
private static final int NOTE_PARENT_ID_COLUMN = 0;
|
|
|
|
|
|
|
|
|
|
|
|
private static final int NOTE_ALERTED_DATE_COLUMN = 1;
|
|
|
|
private static final int NOTE_ALERTED_DATE_COLUMN = 1;
|
|
|
|
|
|
|
|
|
|
|
|
private static final int NOTE_BG_COLOR_ID_COLUMN = 2;
|
|
|
|
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_ID_COLUMN = 3;
|
|
|
|
|
|
|
|
|
|
|
|
private static final int NOTE_WIDGET_TYPE_COLUMN = 4;
|
|
|
|
private static final int NOTE_WIDGET_TYPE_COLUMN = 4;
|
|
|
|
|
|
|
|
|
|
|
|
private static final int NOTE_MODIFIED_DATE_COLUMN = 5;
|
|
|
|
private static final int NOTE_MODIFIED_DATE_COLUMN = 5;
|
|
|
|
|
|
|
|
|
|
|
|
// New note construct
|
|
|
|
// 私有构造函数,用于创建新的笔记
|
|
|
|
|
|
|
|
// 初始化笔记的一些基本信息,如修改日期、文件夹 ID、创建 Note 对象、标记为未删除等
|
|
|
|
private WorkingNote(Context context, long folderId) {
|
|
|
|
private WorkingNote(Context context, long folderId) {
|
|
|
|
mContext = context;
|
|
|
|
mContext = context;
|
|
|
|
mAlertDate = 0;
|
|
|
|
mAlertDate = 0;
|
|
|
@ -114,7 +110,8 @@ public class WorkingNote {
|
|
|
|
mWidgetType = Notes.TYPE_WIDGET_INVALIDE;
|
|
|
|
mWidgetType = Notes.TYPE_WIDGET_INVALIDE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Existing note construct
|
|
|
|
// 私有构造函数,用于加载已存在的笔记
|
|
|
|
|
|
|
|
// 根据笔记 ID 和文件夹 ID 加载笔记信息
|
|
|
|
private WorkingNote(Context context, long noteId, long folderId) {
|
|
|
|
private WorkingNote(Context context, long noteId, long folderId) {
|
|
|
|
mContext = context;
|
|
|
|
mContext = context;
|
|
|
|
mNoteId = noteId;
|
|
|
|
mNoteId = noteId;
|
|
|
@ -124,13 +121,16 @@ public class WorkingNote {
|
|
|
|
loadNote();
|
|
|
|
loadNote();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 从数据库中加载笔记信息
|
|
|
|
private void loadNote() {
|
|
|
|
private void loadNote() {
|
|
|
|
|
|
|
|
// 使用 ContentResolver 查询笔记信息
|
|
|
|
Cursor cursor = mContext.getContentResolver().query(
|
|
|
|
Cursor cursor = mContext.getContentResolver().query(
|
|
|
|
ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mNoteId), NOTE_PROJECTION, null,
|
|
|
|
ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mNoteId), NOTE_PROJECTION, null,
|
|
|
|
null, null);
|
|
|
|
null, null);
|
|
|
|
|
|
|
|
|
|
|
|
if (cursor != null) {
|
|
|
|
if (cursor!= null) {
|
|
|
|
if (cursor.moveToFirst()) {
|
|
|
|
if (cursor.moveToFirst()) {
|
|
|
|
|
|
|
|
// 从 Cursor 中获取笔记的各项信息
|
|
|
|
mFolderId = cursor.getLong(NOTE_PARENT_ID_COLUMN);
|
|
|
|
mFolderId = cursor.getLong(NOTE_PARENT_ID_COLUMN);
|
|
|
|
mBgColorId = cursor.getInt(NOTE_BG_COLOR_ID_COLUMN);
|
|
|
|
mBgColorId = cursor.getInt(NOTE_BG_COLOR_ID_COLUMN);
|
|
|
|
mWidgetId = cursor.getInt(NOTE_WIDGET_ID_COLUMN);
|
|
|
|
mWidgetId = cursor.getInt(NOTE_WIDGET_ID_COLUMN);
|
|
|
@ -140,22 +140,26 @@ public class WorkingNote {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cursor.close();
|
|
|
|
cursor.close();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 日志输出错误信息并抛出异常,如果没有找到相应的笔记
|
|
|
|
Log.e(TAG, "No note with id:" + mNoteId);
|
|
|
|
Log.e(TAG, "No note with id:" + mNoteId);
|
|
|
|
throw new IllegalArgumentException("Unable to find note with id " + mNoteId);
|
|
|
|
throw new IllegalArgumentException("Unable to find note with id " + mNoteId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
loadNoteData();
|
|
|
|
loadNoteData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 从数据库中加载笔记的数据
|
|
|
|
private void loadNoteData() {
|
|
|
|
private void loadNoteData() {
|
|
|
|
|
|
|
|
// 使用 ContentResolver 查询笔记的数据信息
|
|
|
|
Cursor cursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI, DATA_PROJECTION,
|
|
|
|
Cursor cursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI, DATA_PROJECTION,
|
|
|
|
DataColumns.NOTE_ID + "=?", new String[] {
|
|
|
|
DataColumns.NOTE_ID + "=?", new String[] {
|
|
|
|
String.valueOf(mNoteId)
|
|
|
|
String.valueOf(mNoteId)
|
|
|
|
}, null);
|
|
|
|
}, null);
|
|
|
|
|
|
|
|
|
|
|
|
if (cursor != null) {
|
|
|
|
if (cursor!= null) {
|
|
|
|
if (cursor.moveToFirst()) {
|
|
|
|
if (cursor.moveToFirst()) {
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|
String type = cursor.getString(DATA_MIME_TYPE_COLUMN);
|
|
|
|
String type = cursor.getString(DATA_MIME_TYPE_COLUMN);
|
|
|
|
|
|
|
|
// 根据不同的数据类型,处理不同的数据
|
|
|
|
if (DataConstants.NOTE.equals(type)) {
|
|
|
|
if (DataConstants.NOTE.equals(type)) {
|
|
|
|
mContent = cursor.getString(DATA_CONTENT_COLUMN);
|
|
|
|
mContent = cursor.getString(DATA_CONTENT_COLUMN);
|
|
|
|
mMode = cursor.getInt(DATA_MODE_COLUMN);
|
|
|
|
mMode = cursor.getInt(DATA_MODE_COLUMN);
|
|
|
@ -169,11 +173,13 @@ public class WorkingNote {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cursor.close();
|
|
|
|
cursor.close();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 日志输出错误信息并抛出异常,如果没有找到相应的笔记数据
|
|
|
|
Log.e(TAG, "No data with id:" + mNoteId);
|
|
|
|
Log.e(TAG, "No data with id:" + mNoteId);
|
|
|
|
throw new IllegalArgumentException("Unable to find note's 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,
|
|
|
|
public static WorkingNote createEmptyNote(Context context, long folderId, int widgetId,
|
|
|
|
int widgetType, int defaultBgColorId) {
|
|
|
|
int widgetType, int defaultBgColorId) {
|
|
|
|
WorkingNote note = new WorkingNote(context, folderId);
|
|
|
|
WorkingNote note = new WorkingNote(context, folderId);
|
|
|
@ -183,27 +189,27 @@ public class WorkingNote {
|
|
|
|
return note;
|
|
|
|
return note;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 加载已存在的笔记
|
|
|
|
public static WorkingNote load(Context context, long id) {
|
|
|
|
public static WorkingNote load(Context context, long id) {
|
|
|
|
return new WorkingNote(context, id, 0);
|
|
|
|
return new WorkingNote(context, id, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 保存笔记到数据库
|
|
|
|
public synchronized boolean saveNote() {
|
|
|
|
public synchronized boolean saveNote() {
|
|
|
|
if (isWorthSaving()) {
|
|
|
|
if (isWorthSaving()) {
|
|
|
|
if (!existInDatabase()) {
|
|
|
|
if (!existInDatabase()) {
|
|
|
|
|
|
|
|
// 获取新的笔记 ID,如果获取失败,记录错误日志
|
|
|
|
if ((mNoteId = Note.getNewNoteId(mContext, mFolderId)) == 0) {
|
|
|
|
if ((mNoteId = Note.getNewNoteId(mContext, mFolderId)) == 0) {
|
|
|
|
Log.e(TAG, "Create new note fail with id:" + mNoteId);
|
|
|
|
Log.e(TAG, "Create new note fail with id:" + mNoteId);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 同步笔记信息到数据库
|
|
|
|
mNote.syncNote(mContext, mNoteId);
|
|
|
|
mNote.syncNote(mContext, mNoteId);
|
|
|
|
|
|
|
|
// 如果笔记关联了小部件且设置监听器存在,通知小部件更新
|
|
|
|
/**
|
|
|
|
if (mWidgetId!= AppWidgetManager.INVALID_APPWIDGET_ID
|
|
|
|
* Update widget content if there exist any widget of this note
|
|
|
|
&& mWidgetType!= Notes.TYPE_WIDGET_INVALIDE
|
|
|
|
*/
|
|
|
|
&& mNoteSettingStatusListener!= null) {
|
|
|
|
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
|
|
|
|
|
|
|
|
&& mWidgetType != Notes.TYPE_WIDGET_INVALIDE
|
|
|
|
|
|
|
|
&& mNoteSettingStatusListener != null) {
|
|
|
|
|
|
|
|
mNoteSettingStatusListener.onWidgetChanged();
|
|
|
|
mNoteSettingStatusListener.onWidgetChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -212,54 +218,62 @@ public class WorkingNote {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 检查笔记是否已存在于数据库中
|
|
|
|
public boolean existInDatabase() {
|
|
|
|
public boolean existInDatabase() {
|
|
|
|
return mNoteId > 0;
|
|
|
|
return mNoteId > 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断笔记是否值得保存
|
|
|
|
private boolean isWorthSaving() {
|
|
|
|
private boolean isWorthSaving() {
|
|
|
|
|
|
|
|
// 如果笔记已删除、不存在且内容为空或者已存在但未被本地修改,则不值得保存
|
|
|
|
if (mIsDeleted || (!existInDatabase() && TextUtils.isEmpty(mContent))
|
|
|
|
if (mIsDeleted || (!existInDatabase() && TextUtils.isEmpty(mContent))
|
|
|
|
|| (existInDatabase() && !mNote.isLocalModified())) {
|
|
|
|
|| (existInDatabase() &&!mNote.isLocalModified())) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置笔记设置更改的监听器
|
|
|
|
public void setOnSettingStatusChangedListener(NoteSettingChangedListener l) {
|
|
|
|
public void setOnSettingStatusChangedListener(NoteSettingChangedListener l) {
|
|
|
|
mNoteSettingStatusListener = l;
|
|
|
|
mNoteSettingStatusListener = l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置提醒日期,并通知监听器
|
|
|
|
public void setAlertDate(long date, boolean set) {
|
|
|
|
public void setAlertDate(long date, boolean set) {
|
|
|
|
if (date != mAlertDate) {
|
|
|
|
if (date!= mAlertDate) {
|
|
|
|
mAlertDate = date;
|
|
|
|
mAlertDate = date;
|
|
|
|
mNote.setNoteValue(NoteColumns.ALERTED_DATE, String.valueOf(mAlertDate));
|
|
|
|
mNote.setNoteValue(NoteColumns.ALERTED_DATE, String.valueOf(mAlertDate));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (mNoteSettingStatusListener != null) {
|
|
|
|
if (mNoteSettingStatusListener!= null) {
|
|
|
|
mNoteSettingStatusListener.onClockAlertChanged(date, set);
|
|
|
|
mNoteSettingStatusListener.onClockAlertChanged(date, set);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 标记笔记是否已删除,并通知监听器
|
|
|
|
public void markDeleted(boolean mark) {
|
|
|
|
public void markDeleted(boolean mark) {
|
|
|
|
mIsDeleted = mark;
|
|
|
|
mIsDeleted = mark;
|
|
|
|
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
|
|
|
|
if (mWidgetId!= AppWidgetManager.INVALID_APPWIDGET_ID
|
|
|
|
&& mWidgetType != Notes.TYPE_WIDGET_INVALIDE && mNoteSettingStatusListener != null) {
|
|
|
|
&& mWidgetType!= Notes.TYPE_WIDGET_INVALIDE && mNoteSettingStatusListener!= null) {
|
|
|
|
mNoteSettingStatusListener.onWidgetChanged();
|
|
|
|
mNoteSettingStatusListener.onWidgetChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置背景颜色标识符,并通知监听器
|
|
|
|
public void setBgColorId(int id) {
|
|
|
|
public void setBgColorId(int id) {
|
|
|
|
if (id != mBgColorId) {
|
|
|
|
if (id!= mBgColorId) {
|
|
|
|
mBgColorId = id;
|
|
|
|
mBgColorId = id;
|
|
|
|
if (mNoteSettingStatusListener != null) {
|
|
|
|
if (mNoteSettingStatusListener!= null) {
|
|
|
|
mNoteSettingStatusListener.onBackgroundColorChanged();
|
|
|
|
mNoteSettingStatusListener.onBackgroundColorChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mNote.setNoteValue(NoteColumns.BG_COLOR_ID, String.valueOf(id));
|
|
|
|
mNote.setNoteValue(NoteColumns.BG_COLOR_ID, String.valueOf(id));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置清单模式,并通知监听器
|
|
|
|
public void setCheckListMode(int mode) {
|
|
|
|
public void setCheckListMode(int mode) {
|
|
|
|
if (mMode != mode) {
|
|
|
|
if (mMode!= mode) {
|
|
|
|
if (mNoteSettingStatusListener != null) {
|
|
|
|
if (mNoteSettingStatusListener!= null) {
|
|
|
|
mNoteSettingStatusListener.onCheckListModeChanged(mMode, mode);
|
|
|
|
mNoteSettingStatusListener.onCheckListModeChanged(mMode, mode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mMode = mode;
|
|
|
|
mMode = mode;
|
|
|
@ -267,20 +281,23 @@ public class WorkingNote {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置小部件类型
|
|
|
|
public void setWidgetType(int type) {
|
|
|
|
public void setWidgetType(int type) {
|
|
|
|
if (type != mWidgetType) {
|
|
|
|
if (type!= mWidgetType) {
|
|
|
|
mWidgetType = type;
|
|
|
|
mWidgetType = type;
|
|
|
|
mNote.setNoteValue(NoteColumns.WIDGET_TYPE, String.valueOf(mWidgetType));
|
|
|
|
mNote.setNoteValue(NoteColumns.WIDGET_TYPE, String.valueOf(mWidgetType));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置小部件标识符
|
|
|
|
public void setWidgetId(int id) {
|
|
|
|
public void setWidgetId(int id) {
|
|
|
|
if (id != mWidgetId) {
|
|
|
|
if (id!= mWidgetId) {
|
|
|
|
mWidgetId = id;
|
|
|
|
mWidgetId = id;
|
|
|
|
mNote.setNoteValue(NoteColumns.WIDGET_ID, String.valueOf(mWidgetId));
|
|
|
|
mNote.setNoteValue(NoteColumns.WIDGET_ID, String.valueOf(mWidgetId));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置笔记的工作文本
|
|
|
|
public void setWorkingText(String text) {
|
|
|
|
public void setWorkingText(String text) {
|
|
|
|
if (!TextUtils.equals(mContent, text)) {
|
|
|
|
if (!TextUtils.equals(mContent, text)) {
|
|
|
|
mContent = text;
|
|
|
|
mContent = text;
|
|
|
@ -288,81 +305,82 @@ public class WorkingNote {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将笔记转换为通话笔记
|
|
|
|
public void convertToCallNote(String phoneNumber, long callDate) {
|
|
|
|
public void convertToCallNote(String phoneNumber, long callDate) {
|
|
|
|
mNote.setCallData(CallNote.CALL_DATE, String.valueOf(callDate));
|
|
|
|
mNote.setCallData(CallNote.CALL_DATE, String.valueOf(callDate));
|
|
|
|
mNote.setCallData(CallNote.PHONE_NUMBER, phoneNumber);
|
|
|
|
mNote.setCallData(CallNote.PHONE_NUMBER, phoneNumber);
|
|
|
|
mNote.setNoteValue(NoteColumns.PARENT_ID, String.valueOf(Notes.ID_CALL_RECORD_FOLDER));
|
|
|
|
mNote.setNoteValue(NoteColumns.PARENT_ID, String.valueOf(Notes.ID_CALL_RECORD_FOLDER));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否设置了时钟提醒
|
|
|
|
public boolean hasClockAlert() {
|
|
|
|
public boolean hasClockAlert() {
|
|
|
|
return (mAlertDate > 0 ? true : false);
|
|
|
|
return (mAlertDate > 0? true : false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取笔记的内容
|
|
|
|
public String getContent() {
|
|
|
|
public String getContent() {
|
|
|
|
return mContent;
|
|
|
|
return mContent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取提醒日期
|
|
|
|
public long getAlertDate() {
|
|
|
|
public long getAlertDate() {
|
|
|
|
return mAlertDate;
|
|
|
|
return mAlertDate;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取修改日期
|
|
|
|
public long getModifiedDate() {
|
|
|
|
public long getModifiedDate() {
|
|
|
|
return mModifiedDate;
|
|
|
|
return mModifiedDate;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取背景颜色资源标识符
|
|
|
|
public int getBgColorResId() {
|
|
|
|
public int getBgColorResId() {
|
|
|
|
return NoteBgResources.getNoteBgResource(mBgColorId);
|
|
|
|
return NoteBgResources.getNoteBgResource(mBgColorId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取背景颜色标识符
|
|
|
|
public int getBgColorId() {
|
|
|
|
public int getBgColorId() {
|
|
|
|
return mBgColorId;
|
|
|
|
return mBgColorId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取标题背景资源标识符
|
|
|
|
public int getTitleBgResId() {
|
|
|
|
public int getTitleBgResId() {
|
|
|
|
return NoteBgResources.getNoteTitleBgResource(mBgColorId);
|
|
|
|
return NoteBgResources.getNoteTitleBgResource(mBgColorId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取清单模式
|
|
|
|
public int getCheckListMode() {
|
|
|
|
public int getCheckListMode() {
|
|
|
|
return mMode;
|
|
|
|
return mMode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取笔记的 ID
|
|
|
|
public long getNoteId() {
|
|
|
|
public long getNoteId() {
|
|
|
|
return mNoteId;
|
|
|
|
return mNoteId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取文件夹的 ID
|
|
|
|
public long getFolderId() {
|
|
|
|
public long getFolderId() {
|
|
|
|
return mFolderId;
|
|
|
|
return mFolderId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取小部件的 ID
|
|
|
|
public int getWidgetId() {
|
|
|
|
public int getWidgetId() {
|
|
|
|
return mWidgetId;
|
|
|
|
return mWidgetId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取小部件的类型
|
|
|
|
public int getWidgetType() {
|
|
|
|
public int getWidgetType() {
|
|
|
|
return mWidgetType;
|
|
|
|
return mWidgetType;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 定义一个接口,用于监听笔记设置的更改
|
|
|
|
public interface NoteSettingChangedListener {
|
|
|
|
public interface NoteSettingChangedListener {
|
|
|
|
/**
|
|
|
|
// 当背景颜色改变时调用
|
|
|
|
* Called when the background color of current note has just changed
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void onBackgroundColorChanged();
|
|
|
|
void onBackgroundColorChanged();
|
|
|
|
|
|
|
|
// 当设置时钟提醒时调用
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Called when user set clock
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void onClockAlertChanged(long date, boolean set);
|
|
|
|
void onClockAlertChanged(long date, boolean set);
|
|
|
|
|
|
|
|
// 当小部件改变时调用
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Call when user create note from widget
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
void onWidgetChanged();
|
|
|
|
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);
|
|
|
|
void onCheckListModeChanged(int oldMode, int newMode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|