|
|
@ -31,7 +31,10 @@ import net.micode.notes.data.Notes.NoteColumns;
|
|
|
|
import net.micode.notes.data.Notes.TextNote;
|
|
|
|
import net.micode.notes.data.Notes.TextNote;
|
|
|
|
import net.micode.notes.tool.ResourceParser.NoteBgResources;
|
|
|
|
import net.micode.notes.tool.ResourceParser.NoteBgResources;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* WorkingNote 类代表一个正在编辑的笔记对象
|
|
|
|
|
|
|
|
* 它负责管理笔记的内容、状态和与数据库的交互
|
|
|
|
|
|
|
|
*/
|
|
|
|
public class WorkingNote {
|
|
|
|
public class WorkingNote {
|
|
|
|
// Note for the working note
|
|
|
|
// Note for the working note
|
|
|
|
private Note mNote;
|
|
|
|
private Note mNote;
|
|
|
@ -42,26 +45,18 @@ public class WorkingNote {
|
|
|
|
// Note mode
|
|
|
|
// Note mode
|
|
|
|
private int mMode;
|
|
|
|
private int mMode;
|
|
|
|
|
|
|
|
|
|
|
|
private long mAlertDate;
|
|
|
|
private long mAlertDate; // 提醒时间
|
|
|
|
|
|
|
|
private long mModifiedDate; // 修改时间
|
|
|
|
private long mModifiedDate;
|
|
|
|
private int mBgColorId; // 背景颜色ID
|
|
|
|
|
|
|
|
private int mWidgetId; // 小部件ID
|
|
|
|
private int mBgColorId;
|
|
|
|
private int mWidgetType; // 小部件类型
|
|
|
|
|
|
|
|
private long mFolderId; // 文件夹ID
|
|
|
|
private int mWidgetId;
|
|
|
|
private Context mContext; // 上下文
|
|
|
|
|
|
|
|
private boolean mIsDeleted; // 是否已删除
|
|
|
|
private int mWidgetType;
|
|
|
|
private NoteSettingChangedListener mNoteSettingStatusListener; // 笔记设置变化监听器
|
|
|
|
|
|
|
|
|
|
|
|
private long mFolderId;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Context mContext;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final String TAG = "WorkingNote";
|
|
|
|
private static final String TAG = "WorkingNote";
|
|
|
|
|
|
|
|
|
|
|
|
private boolean mIsDeleted;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
@ -174,6 +169,15 @@ public class WorkingNote {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 创建新的空笔记
|
|
|
|
|
|
|
|
* @param context 上下文
|
|
|
|
|
|
|
|
* @param folderId 文件夹ID
|
|
|
|
|
|
|
|
* @param widgetId 小部件ID
|
|
|
|
|
|
|
|
* @param widgetType 小部件类型
|
|
|
|
|
|
|
|
* @param defaultBgColorId 默认背景颜色ID
|
|
|
|
|
|
|
|
* @return 新创建的WorkingNote对象
|
|
|
|
|
|
|
|
*/
|
|
|
|
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,10 +187,20 @@ public class WorkingNote {
|
|
|
|
return note;
|
|
|
|
return note;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 从数据库加载笔记
|
|
|
|
|
|
|
|
* @param context 上下文
|
|
|
|
|
|
|
|
* @param id 笔记ID
|
|
|
|
|
|
|
|
* @return 加载的WorkingNote对象
|
|
|
|
|
|
|
|
*/
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 保存笔记到数据库
|
|
|
|
|
|
|
|
* @return 是否保存成功
|
|
|
|
|
|
|
|
*/
|
|
|
|
public synchronized boolean saveNote() {
|
|
|
|
public synchronized boolean saveNote() {
|
|
|
|
if (isWorthSaving()) {
|
|
|
|
if (isWorthSaving()) {
|
|
|
|
if (!existInDatabase()) {
|
|
|
|
if (!existInDatabase()) {
|
|
|
@ -199,7 +213,7 @@ public class WorkingNote {
|
|
|
|
mNote.syncNote(mContext, mNoteId);
|
|
|
|
mNote.syncNote(mContext, mNoteId);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Update widget content if there exist any widget of this note
|
|
|
|
* 如果笔记有关联的小部件,更新小部件内容
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
|
|
|
|
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
|
|
|
|
&& mWidgetType != Notes.TYPE_WIDGET_INVALIDE
|
|
|
|
&& mWidgetType != Notes.TYPE_WIDGET_INVALIDE
|
|
|
@ -229,6 +243,11 @@ public class WorkingNote {
|
|
|
|
mNoteSettingStatusListener = l;
|
|
|
|
mNoteSettingStatusListener = l;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 设置提醒时间
|
|
|
|
|
|
|
|
* @param date 提醒时间戳
|
|
|
|
|
|
|
|
* @param set 是否设置提醒
|
|
|
|
|
|
|
|
*/
|
|
|
|
public void setAlertDate(long date, boolean set) {
|
|
|
|
public void setAlertDate(long date, boolean set) {
|
|
|
|
if (date != mAlertDate) {
|
|
|
|
if (date != mAlertDate) {
|
|
|
|
mAlertDate = date;
|
|
|
|
mAlertDate = date;
|
|
|
@ -288,6 +307,11 @@ public class WorkingNote {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 将笔记转换为通话记录笔记
|
|
|
|
|
|
|
|
* @param phoneNumber 电话号码
|
|
|
|
|
|
|
|
* @param callDate 通话时间
|
|
|
|
|
|
|
|
*/
|
|
|
|
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);
|
|
|
|