|
|
|
@ -0,0 +1,630 @@
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
// 导入必要的包和类,这些类用于处理数据存储、内容提供者操作等。
|
|
|
|
|
=======
|
|
|
|
|
/*
|
|
|
|
|
* 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.model;
|
|
|
|
|
|
|
|
|
|
import android.appwidget.AppWidgetManager;
|
|
|
|
|
import android.content.ContentUris;
|
|
|
|
|
import android.content.Context;
|
|
|
|
|
import android.database.Cursor;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
|
|
|
|
import net.micode.notes.data.Notes;
|
|
|
|
|
>>>>>>> 497ba4f7a5b11b52f3e9706151f1e2b13f56dc26
|
|
|
|
|
import net.micode.notes.data.Notes.CallNote;
|
|
|
|
|
import net.micode.notes.data.Notes.DataColumns;
|
|
|
|
|
import net.micode.notes.data.Notes.DataConstants;
|
|
|
|
|
import net.micode.notes.data.Notes.NoteColumns;
|
|
|
|
|
import net.micode.notes.data.Notes.TextNote;
|
|
|
|
|
import net.micode.notes.tool.ResourceParser.NoteBgResources;
|
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
// 定义WorkingNote类,该类负责处理工作笔记的具体逻辑。
|
|
|
|
|
public class WorkingNote {
|
|
|
|
|
// 成员变量声明,用于存储笔记的相关信息,例如:笔记对象、ID、内容、模式、提醒日期等。
|
|
|
|
|
private Note mNote; // 笔记对象
|
|
|
|
|
private long mNoteId; // 笔记ID
|
|
|
|
|
private String mContent; // 笔记内容
|
|
|
|
|
private int mMode; // 笔记模式(如普通笔记或清单模式)
|
|
|
|
|
private long mAlertDate; // 提醒时间
|
|
|
|
|
private long mModifiedDate; // 修改时间
|
|
|
|
|
private int mBgColorId; // 背景颜色ID
|
|
|
|
|
private int mWidgetId; // 小部件ID
|
|
|
|
|
private int mWidgetType; // 小部件类型
|
|
|
|
|
private long mFolderId; // 文件夹ID
|
|
|
|
|
private Context mContext; // 上下文环境
|
|
|
|
|
private static final String TAG = "WorkingNote"; // 日志标签
|
|
|
|
|
private boolean mIsDeleted; // 标记笔记是否被删除
|
|
|
|
|
private NoteSettingChangedListener mNoteSettingStatusListener; // 笔记设置状态变化监听器
|
|
|
|
|
|
|
|
|
|
// 定义列名投影数组,用于查询时指定需要获取的字段。
|
|
|
|
|
public static final String[] DATA_PROJECTION = new String[]{
|
|
|
|
|
DataColumns.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
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 定义列索引常量,方便访问查询结果中的特定列。
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
// 构造函数,用于创建新的工作笔记实例。
|
|
|
|
|
private WorkingNote(Context context, long folderId) {
|
|
|
|
|
mContext = context;
|
|
|
|
|
mAlertDate = 0;
|
|
|
|
|
mModifiedDate = System.currentTimeMillis(); // 设置当前时间为修改时间
|
|
|
|
|
=======
|
|
|
|
|
|
|
|
|
|
public class WorkingNote {
|
|
|
|
|
// Note for the working note
|
|
|
|
|
private Note mNote;
|
|
|
|
|
// Note Id
|
|
|
|
|
private long mNoteId;
|
|
|
|
|
// Note content
|
|
|
|
|
private String mContent;
|
|
|
|
|
// Note mode
|
|
|
|
|
private int mMode;
|
|
|
|
|
|
|
|
|
|
private long mAlertDate;
|
|
|
|
|
|
|
|
|
|
private long mModifiedDate;
|
|
|
|
|
|
|
|
|
|
private int mBgColorId;
|
|
|
|
|
|
|
|
|
|
private int mWidgetId;
|
|
|
|
|
|
|
|
|
|
private int mWidgetType;
|
|
|
|
|
|
|
|
|
|
private long mFolderId;
|
|
|
|
|
|
|
|
|
|
private Context mContext;
|
|
|
|
|
|
|
|
|
|
private static final String TAG = "WorkingNote";
|
|
|
|
|
|
|
|
|
|
private boolean mIsDeleted;
|
|
|
|
|
|
|
|
|
|
private NoteSettingChangedListener mNoteSettingStatusListener;
|
|
|
|
|
|
|
|
|
|
public static final String[] DATA_PROJECTION = new String[] {
|
|
|
|
|
DataColumns.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
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
private WorkingNote(Context context, long folderId) {
|
|
|
|
|
mContext = context;
|
|
|
|
|
mAlertDate = 0;
|
|
|
|
|
mModifiedDate = System.currentTimeMillis();
|
|
|
|
|
>>>>>>> 497ba4f7a5b11b52f3e9706151f1e2b13f56dc26
|
|
|
|
|
mFolderId = folderId;
|
|
|
|
|
mNote = new Note();
|
|
|
|
|
mNoteId = 0;
|
|
|
|
|
mIsDeleted = false;
|
|
|
|
|
mMode = 0;
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
mWidgetType = Notes.TYPE_WIDGET_INVALIDE; // 初始化为无效的小部件类型
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 构造函数,用于加载已有的工作笔记实例。
|
|
|
|
|
=======
|
|
|
|
|
mWidgetType = Notes.TYPE_WIDGET_INVALIDE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Existing note construct
|
|
|
|
|
>>>>>>> 497ba4f7a5b11b52f3e9706151f1e2b13f56dc26
|
|
|
|
|
private WorkingNote(Context context, long noteId, long folderId) {
|
|
|
|
|
mContext = context;
|
|
|
|
|
mNoteId = noteId;
|
|
|
|
|
mFolderId = folderId;
|
|
|
|
|
mIsDeleted = false;
|
|
|
|
|
mNote = new Note();
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
loadNote(); // 加载笔记数据
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 加载笔记的方法,从数据库中读取笔记的数据。
|
|
|
|
|
=======
|
|
|
|
|
loadNote();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
>>>>>>> 497ba4f7a5b11b52f3e9706151f1e2b13f56dc26
|
|
|
|
|
private void loadNote() {
|
|
|
|
|
Cursor cursor = mContext.getContentResolver().query(
|
|
|
|
|
ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mNoteId), NOTE_PROJECTION, null,
|
|
|
|
|
null, null);
|
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
if (cursor != null && cursor.moveToFirst()) {
|
|
|
|
|
do {
|
|
|
|
|
mNote.setNoteValue(NoteColumns.PARENT_ID, cursor.getString(NOTE_PARENT_ID_COLUMN));
|
|
|
|
|
mAlertDate = cursor.getLong(NOTE_ALERTED_DATE_COLUMN);
|
|
|
|
|
mNote.setNoteValue(NoteColumns.ALERTED_DATE, String.valueOf(mAlertDate));
|
|
|
|
|
mBgColorId = cursor.getInt(NOTE_BG_COLOR_ID_COLUMN);
|
|
|
|
|
mNote.setNoteValue(NoteColumns.BG_COLOR_ID, String.valueOf(mBgColorId));
|
|
|
|
|
mWidgetId = cursor.getInt(NOTE_WIDGET_ID_COLUMN);
|
|
|
|
|
mNote.setNoteValue(NoteColumns.WIDGET_ID, String.valueOf(mWidgetId));
|
|
|
|
|
mWidgetType = cursor.getInt(NOTE_WIDGET_TYPE_COLUMN);
|
|
|
|
|
mNote.setNoteValue(NoteColumns.WIDGET_TYPE, String.valueOf(mWidgetType));
|
|
|
|
|
mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN);
|
|
|
|
|
mNote.setNoteValue(NoteColumns.MODIFIED_DATE, String.valueOf(mModifiedDate));
|
|
|
|
|
} while (cursor.moveToNext());
|
|
|
|
|
cursor.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 其他方法...
|
|
|
|
|
|
|
|
|
|
// 创建空笔记的静态方法。
|
|
|
|
|
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); // 设置小部件ID
|
|
|
|
|
note.setWidgetType(widgetType); // 设置小部件类型
|
|
|
|
|
return note;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 从数据库加载已有笔记的静态方法。
|
|
|
|
|
=======
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
cursor.close();
|
|
|
|
|
} else {
|
|
|
|
|
Log.e(TAG, "No note with id:" + mNoteId);
|
|
|
|
|
throw new IllegalArgumentException("Unable to find note with id " + mNoteId);
|
|
|
|
|
}
|
|
|
|
|
loadNoteData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void loadNoteData() {
|
|
|
|
|
Cursor cursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI, DATA_PROJECTION,
|
|
|
|
|
DataColumns.NOTE_ID + "=?", new String[] {
|
|
|
|
|
String.valueOf(mNoteId)
|
|
|
|
|
}, null);
|
|
|
|
|
|
|
|
|
|
if (cursor != null) {
|
|
|
|
|
if (cursor.moveToFirst()) {
|
|
|
|
|
do {
|
|
|
|
|
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));
|
|
|
|
|
} else if (DataConstants.CALL_NOTE.equals(type)) {
|
|
|
|
|
mNote.setCallDataId(cursor.getLong(DATA_ID_COLUMN));
|
|
|
|
|
} else {
|
|
|
|
|
Log.d(TAG, "Wrong note type with type:" + type);
|
|
|
|
|
}
|
|
|
|
|
} while (cursor.moveToNext());
|
|
|
|
|
}
|
|
|
|
|
cursor.close();
|
|
|
|
|
} 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
>>>>>>> 497ba4f7a5b11b52f3e9706151f1e2b13f56dc26
|
|
|
|
|
public static WorkingNote load(Context context, long id) {
|
|
|
|
|
return new WorkingNote(context, id, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
// 保存笔记的方法,检查笔记是否有值得保存的内容,并更新数据库。
|
|
|
|
|
public synchronized boolean saveNote() {
|
|
|
|
|
if (isWorthSaving()) { // 检查笔记是否有值得保存的内容
|
|
|
|
|
if (!existInDatabase()) { // 如果笔记不在数据库中,则尝试创建新笔记
|
|
|
|
|
=======
|
|
|
|
|
public synchronized boolean saveNote() {
|
|
|
|
|
if (isWorthSaving()) {
|
|
|
|
|
if (!existInDatabase()) {
|
|
|
|
|
>>>>>>> 497ba4f7a5b11b52f3e9706151f1e2b13f56dc26
|
|
|
|
|
if ((mNoteId = Note.getNewNoteId(mContext, mFolderId)) == 0) {
|
|
|
|
|
Log.e(TAG, "Create new note fail with id:" + mNoteId);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
mNote.syncNote(mContext, mNoteId); // 同步笔记到数据库
|
|
|
|
|
|
|
|
|
|
// 更新关联的小部件内容(如果存在)
|
|
|
|
|
=======
|
|
|
|
|
|
|
|
|
|
mNote.syncNote(mContext, mNoteId);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update widget content if there exist any widget of this note
|
|
|
|
|
*/
|
|
|
|
|
>>>>>>> 497ba4f7a5b11b52f3e9706151f1e2b13f56dc26
|
|
|
|
|
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
|
|
|
|
|
&& mWidgetType != Notes.TYPE_WIDGET_INVALIDE
|
|
|
|
|
&& mNoteSettingStatusListener != null) {
|
|
|
|
|
mNoteSettingStatusListener.onWidgetChanged();
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
// 判断笔记是否存在数据库中的方法。
|
|
|
|
|
=======
|
|
|
|
|
>>>>>>> 497ba4f7a5b11b52f3e9706151f1e2b13f56dc26
|
|
|
|
|
public boolean existInDatabase() {
|
|
|
|
|
return mNoteId > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
// 判断笔记是否有值得保存的内容。
|
|
|
|
|
=======
|
|
|
|
|
>>>>>>> 497ba4f7a5b11b52f3e9706151f1e2b13f56dc26
|
|
|
|
|
private boolean isWorthSaving() {
|
|
|
|
|
if (mIsDeleted || (!existInDatabase() && TextUtils.isEmpty(mContent))
|
|
|
|
|
|| (existInDatabase() && !mNote.isLocalModified())) {
|
|
|
|
|
return false;
|
|
|
|
|
} else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
// 设置背景颜色ID的方法。
|
|
|
|
|
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)); // 更新笔记属性
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置小部件ID的内部方法。
|
|
|
|
|
public void setWidgetId(int id) {
|
|
|
|
|
if (id != mWidgetId) { // 只有当新旧ID不同时才更新
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取背景颜色资源ID的方法。
|
|
|
|
|
public int getBgColorResId() {
|
|
|
|
|
return NoteBgResources.getNoteBgResource(mBgColorId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取背景颜色ID的方法。
|
|
|
|
|
public int getBgColorId() {
|
|
|
|
|
return mBgColorId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取标题背景颜色资源ID的方法。
|
|
|
|
|
public int getTitleBgResId() {
|
|
|
|
|
return NoteBgResources.getNoteTitleBgResource(mBgColorId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取清单模式的方法。
|
|
|
|
|
public int getCheckListMode() {
|
|
|
|
|
return mMode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取笔记ID的方法。
|
|
|
|
|
public long getNoteId() {
|
|
|
|
|
return mNoteId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取文件夹ID的方法。
|
|
|
|
|
public long getFolderId() {
|
|
|
|
|
return mFolderId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取小部件ID的方法。
|
|
|
|
|
public int getWidgetId() {
|
|
|
|
|
return mWidgetId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取小部件类型的方法。
|
|
|
|
|
public int getWidgetType() {
|
|
|
|
|
return mWidgetType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置提醒日期的方法。
|
|
|
|
|
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 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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
>>>>>>> 497ba4f7a5b11b52f3e9706151f1e2b13f56dc26
|
|
|
|
|
public void markDeleted(boolean mark) {
|
|
|
|
|
mIsDeleted = mark;
|
|
|
|
|
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
|
|
|
|
|
&& mWidgetType != Notes.TYPE_WIDGET_INVALIDE && mNoteSettingStatusListener != null) {
|
|
|
|
|
<<<<<<< HEAD
|
|
|
|
|
mNoteSettingStatusListener.onWidgetChanged(); // 通知监听器小部件改变
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 设置设置状态变化监听器的方法。
|
|
|
|
|
public void setOnSettingStatusChangedListener(NoteSettingChangedListener l) {
|
|
|
|
|
mNoteSettingStatusListener = l;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
=======
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
>>>>>>> 497ba4f7a5b11b52f3e9706151f1e2b13f56dc26
|