|
|
|
|
@ -61,7 +61,7 @@ public class WorkingNote {
|
|
|
|
|
private boolean mIsDeleted;
|
|
|
|
|
|
|
|
|
|
private NoteSettingChangedListener mNoteSettingStatusListener;
|
|
|
|
|
// 声明 DATA_PROJECTION字符串数组
|
|
|
|
|
// 声明 DATA_PROJECTION字符串数组
|
|
|
|
|
public static final String[] DATA_PROJECTION = new String[] {
|
|
|
|
|
DataColumns.ID,
|
|
|
|
|
DataColumns.CONTENT,
|
|
|
|
|
@ -140,18 +140,18 @@ public class WorkingNote {
|
|
|
|
|
mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN);
|
|
|
|
|
}
|
|
|
|
|
cursor.close();
|
|
|
|
|
// 若不存在,报错
|
|
|
|
|
// 若不存在,报错
|
|
|
|
|
} else {
|
|
|
|
|
Log.e(TAG, "No note with id:" + mNoteId);
|
|
|
|
|
throw new IllegalArgumentException("Unable to find note with id " + mNoteId);
|
|
|
|
|
}
|
|
|
|
|
loadNoteData();
|
|
|
|
|
}
|
|
|
|
|
// 加载NoteData
|
|
|
|
|
// 加载NoteData
|
|
|
|
|
private void loadNoteData() {
|
|
|
|
|
Cursor cursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI, DATA_PROJECTION,
|
|
|
|
|
DataColumns.NOTE_ID + "=?", new String[] {
|
|
|
|
|
String.valueOf(mNoteId)
|
|
|
|
|
String.valueOf(mNoteId)
|
|
|
|
|
}, null);
|
|
|
|
|
|
|
|
|
|
if (cursor != null) {
|
|
|
|
|
@ -178,9 +178,9 @@ public class WorkingNote {
|
|
|
|
|
// 创建空的Note
|
|
|
|
|
// 传参:context,文件夹id,widget,背景颜色
|
|
|
|
|
public static WorkingNote createEmptyNote(Context context, long folderId, int widgetId,
|
|
|
|
|
int widgetType, int defaultBgColorId) {
|
|
|
|
|
int widgetType, int defaultBgColorId) {
|
|
|
|
|
WorkingNote note = new WorkingNote(context, folderId);
|
|
|
|
|
// 设定相关属性
|
|
|
|
|
// 设定相关属性
|
|
|
|
|
note.setBgColorId(defaultBgColorId);
|
|
|
|
|
note.setWidgetId(widgetId);
|
|
|
|
|
note.setWidgetType(widgetType);
|
|
|
|
|
@ -229,11 +229,11 @@ public class WorkingNote {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 设置mNoteSettingStatusListener
|
|
|
|
|
// 设置mNoteSettingStatusListener
|
|
|
|
|
public void setOnSettingStatusChangedListener(NoteSettingChangedListener l) {
|
|
|
|
|
mNoteSettingStatusListener = l;
|
|
|
|
|
}
|
|
|
|
|
// 设置AlertDate
|
|
|
|
|
// 设置AlertDate
|
|
|
|
|
// 若 mAlertDate与data不同,则更改mAlertDate并设定NoteValue
|
|
|
|
|
public void setAlertDate(long date, boolean set) {
|
|
|
|
|
if (date != mAlertDate) {
|
|
|
|
|
@ -244,15 +244,15 @@ public class WorkingNote {
|
|
|
|
|
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();// 调用mNoteSettingStatusListener的 onWidgetChanged方法
|
|
|
|
|
mNoteSettingStatusListener.onWidgetChanged();// 调用mNoteSettingStatusListener的 onWidgetChanged方法
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 设定背景颜色
|
|
|
|
|
// 设定背景颜色
|
|
|
|
|
public void setBgColorId(int id) {
|
|
|
|
|
if (id != mBgColorId) {//设定条件 id != mBgColorId
|
|
|
|
|
mBgColorId = id;
|
|
|
|
|
@ -262,7 +262,7 @@ public class WorkingNote {
|
|
|
|
|
mNote.setNoteValue(NoteColumns.BG_COLOR_ID, String.valueOf(id));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 设定检查列表模式
|
|
|
|
|
// 设定检查列表模式
|
|
|
|
|
// 参数:mode
|
|
|
|
|
public void setCheckListMode(int mode) {
|
|
|
|
|
if (mMode != mode) {
|
|
|
|
|
@ -273,7 +273,7 @@ public class WorkingNote {
|
|
|
|
|
mNote.setTextData(TextNote.MODE, String.valueOf(mMode));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 设定WidgetType
|
|
|
|
|
// 设定WidgetType
|
|
|
|
|
// 参数:type
|
|
|
|
|
public void setWidgetType(int type) {
|
|
|
|
|
if (type != mWidgetType) {
|
|
|
|
|
@ -281,7 +281,7 @@ public class WorkingNote {
|
|
|
|
|
mNote.setNoteValue(NoteColumns.WIDGET_TYPE, String.valueOf(mWidgetType));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 设定WidgetId
|
|
|
|
|
// 设定WidgetId
|
|
|
|
|
// 参数:id
|
|
|
|
|
public void setWidgetId(int id) {
|
|
|
|
|
if (id != mWidgetId) {
|
|
|
|
|
@ -289,7 +289,7 @@ public class WorkingNote {
|
|
|
|
|
mNote.setNoteValue(NoteColumns.WIDGET_ID, String.valueOf(mWidgetId));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 设定WorkingTex
|
|
|
|
|
// 设定WorkingTex
|
|
|
|
|
// 参数:更改的text
|
|
|
|
|
public void setWorkingText(String text) {
|
|
|
|
|
if (!TextUtils.equals(mContent, text)) {
|
|
|
|
|
@ -297,62 +297,62 @@ public class WorkingNote {
|
|
|
|
|
mNote.setTextData(DataColumns.CONTENT, mContent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 转变mNote的CallData及CallNote信息
|
|
|
|
|
// 转变mNote的CallData及CallNote信息
|
|
|
|
|
// 参数:String phoneNumber, long callDate
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
// 获取Content
|
|
|
|
|
// 获取Content
|
|
|
|
|
public String getContent() {
|
|
|
|
|
return mContent;
|
|
|
|
|
}
|
|
|
|
|
// 获取AlertDate
|
|
|
|
|
// 获取AlertDate
|
|
|
|
|
public long getAlertDate() {
|
|
|
|
|
return mAlertDate;
|
|
|
|
|
}
|
|
|
|
|
// 获取ModifiedDate
|
|
|
|
|
// 获取ModifiedDate
|
|
|
|
|
public long getModifiedDate() {
|
|
|
|
|
return mModifiedDate;
|
|
|
|
|
}
|
|
|
|
|
// 获取背景颜色来源id
|
|
|
|
|
// 获取背景颜色来源id
|
|
|
|
|
public int getBgColorResId() {
|
|
|
|
|
return NoteBgResources.getNoteBgResource(mBgColorId);
|
|
|
|
|
}
|
|
|
|
|
// 获取背景颜色id
|
|
|
|
|
// 获取背景颜色id
|
|
|
|
|
public int getBgColorId() {
|
|
|
|
|
return mBgColorId;
|
|
|
|
|
}
|
|
|
|
|
// 获取标题背景颜色id
|
|
|
|
|
// 获取标题背景颜色id
|
|
|
|
|
public int getTitleBgResId() {
|
|
|
|
|
return NoteBgResources.getNoteTitleBgResource(mBgColorId);
|
|
|
|
|
}
|
|
|
|
|
// 获取CheckListMode
|
|
|
|
|
// 获取CheckListMode
|
|
|
|
|
public int getCheckListMode() {
|
|
|
|
|
return mMode;
|
|
|
|
|
}
|
|
|
|
|
// 获取便签id
|
|
|
|
|
// 获取便签id
|
|
|
|
|
public long getNoteId() {
|
|
|
|
|
return mNoteId;
|
|
|
|
|
}
|
|
|
|
|
// 获取文件夹id
|
|
|
|
|
// 获取文件夹id
|
|
|
|
|
public long getFolderId() {
|
|
|
|
|
return mFolderId;
|
|
|
|
|
}
|
|
|
|
|
// 获取WidgetId
|
|
|
|
|
// 获取WidgetId
|
|
|
|
|
public int getWidgetId() {
|
|
|
|
|
return mWidgetId;
|
|
|
|
|
}
|
|
|
|
|
// 获取WidgetType
|
|
|
|
|
// 获取WidgetType
|
|
|
|
|
public int getWidgetType() {
|
|
|
|
|
return mWidgetType;
|
|
|
|
|
}
|
|
|
|
|
// 创建接口 NoteSettingChangedListener,便签更新监视
|
|
|
|
|
// 创建接口 NoteSettingChangedListener,便签更新监视
|
|
|
|
|
// 为NoteEditActivity提供接口
|
|
|
|
|
// 提供函数有
|
|
|
|
|
public interface NoteSettingChangedListener {
|
|
|
|
|
|