|
|
|
|
@ -28,6 +28,7 @@ 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;
|
|
|
|
|
import net.micode.notes.data.Notes.TextNote;
|
|
|
|
|
import net.micode.notes.tool.ResourceParser.NoteBgResources;
|
|
|
|
|
|
|
|
|
|
@ -46,6 +47,10 @@ public class WorkingNote {
|
|
|
|
|
private int mMode;
|
|
|
|
|
|
|
|
|
|
private long mAlertDate;
|
|
|
|
|
private double mAlertLatitude;
|
|
|
|
|
private double mAlertLongitude;
|
|
|
|
|
private float mAlertRadius;
|
|
|
|
|
private String mAlertLocationName;
|
|
|
|
|
|
|
|
|
|
private long mModifiedDate;
|
|
|
|
|
|
|
|
|
|
@ -64,6 +69,7 @@ public class WorkingNote {
|
|
|
|
|
private boolean mIsDeleted;
|
|
|
|
|
|
|
|
|
|
private NoteSettingChangedListener mNoteSettingStatusListener;
|
|
|
|
|
private String mRichTextFormatInfo;
|
|
|
|
|
|
|
|
|
|
//指定查询Data表时需要返回的字段
|
|
|
|
|
public static final String[] DATA_PROJECTION = new String[] {
|
|
|
|
|
@ -74,6 +80,9 @@ public class WorkingNote {
|
|
|
|
|
DataColumns.DATA2,
|
|
|
|
|
DataColumns.DATA3,
|
|
|
|
|
DataColumns.DATA4,
|
|
|
|
|
DataColumns.DATA5,
|
|
|
|
|
DataColumns.RICH_TEXT_FORMAT,
|
|
|
|
|
DataColumns.IMAGE_PATH,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//指定查询Note表时需要返回的字段
|
|
|
|
|
@ -83,7 +92,11 @@ public class WorkingNote {
|
|
|
|
|
NoteColumns.BG_COLOR_ID,
|
|
|
|
|
NoteColumns.WIDGET_ID,
|
|
|
|
|
NoteColumns.WIDGET_TYPE,
|
|
|
|
|
NoteColumns.MODIFIED_DATE
|
|
|
|
|
NoteColumns.MODIFIED_DATE,
|
|
|
|
|
NoteColumns.ALERT_LATITUDE,
|
|
|
|
|
NoteColumns.ALERT_LONGITUDE,
|
|
|
|
|
NoteColumns.ALERT_RADIUS,
|
|
|
|
|
NoteColumns.ALERT_LOCATION_NAME
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private static final int DATA_ID_COLUMN = 0;
|
|
|
|
|
@ -94,6 +107,10 @@ public class WorkingNote {
|
|
|
|
|
|
|
|
|
|
private static final int DATA_MODE_COLUMN = 3;
|
|
|
|
|
|
|
|
|
|
private static final int DATA_RICH_TEXT_FORMAT_COLUMN = 8;
|
|
|
|
|
|
|
|
|
|
private static final int DATA_IMAGE_PATH_COLUMN = 9;
|
|
|
|
|
|
|
|
|
|
private static final int NOTE_PARENT_ID_COLUMN = 0;
|
|
|
|
|
|
|
|
|
|
private static final int NOTE_ALERTED_DATE_COLUMN = 1;
|
|
|
|
|
@ -105,11 +122,19 @@ public class WorkingNote {
|
|
|
|
|
private static final int NOTE_WIDGET_TYPE_COLUMN = 4;
|
|
|
|
|
|
|
|
|
|
private static final int NOTE_MODIFIED_DATE_COLUMN = 5;
|
|
|
|
|
private static final int NOTE_ALERT_LATITUDE_COLUMN = 6;
|
|
|
|
|
private static final int NOTE_ALERT_LONGITUDE_COLUMN = 7;
|
|
|
|
|
private static final int NOTE_ALERT_RADIUS_COLUMN = 8;
|
|
|
|
|
private static final int NOTE_ALERT_LOCATION_NAME_COLUMN = 9;
|
|
|
|
|
|
|
|
|
|
// New note construct
|
|
|
|
|
private WorkingNote(Context context, long folderId) {
|
|
|
|
|
mContext = context;
|
|
|
|
|
mAlertDate = 0;
|
|
|
|
|
mAlertLatitude = 0;
|
|
|
|
|
mAlertLongitude = 0;
|
|
|
|
|
mAlertRadius = 0;
|
|
|
|
|
mAlertLocationName = "";
|
|
|
|
|
mModifiedDate = System.currentTimeMillis();
|
|
|
|
|
mFolderId = folderId;
|
|
|
|
|
mNote = new Note();
|
|
|
|
|
@ -147,6 +172,14 @@ public class WorkingNote {
|
|
|
|
|
mWidgetType = cursor.getInt(NOTE_WIDGET_TYPE_COLUMN);
|
|
|
|
|
mAlertDate = cursor.getLong(NOTE_ALERTED_DATE_COLUMN);
|
|
|
|
|
mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN);
|
|
|
|
|
|
|
|
|
|
// 经纬度和提醒位置
|
|
|
|
|
mAlertLatitude = cursor.getDouble(NOTE_ALERT_LATITUDE_COLUMN);
|
|
|
|
|
mAlertLongitude = cursor.getDouble(NOTE_ALERT_LONGITUDE_COLUMN);
|
|
|
|
|
mAlertRadius = cursor.getFloat(NOTE_ALERT_RADIUS_COLUMN);
|
|
|
|
|
mAlertLocationName = cursor.getString(NOTE_ALERT_LOCATION_NAME_COLUMN);
|
|
|
|
|
// 加载富文本格式信息
|
|
|
|
|
mRichTextFormatInfo = cursor.getString(DATA_RICH_TEXT_FORMAT_COLUMN);
|
|
|
|
|
}
|
|
|
|
|
cursor.close();
|
|
|
|
|
} else {
|
|
|
|
|
@ -173,8 +206,15 @@ public class WorkingNote {
|
|
|
|
|
mContent = cursor.getString(DATA_CONTENT_COLUMN);
|
|
|
|
|
mMode = cursor.getInt(DATA_MODE_COLUMN);
|
|
|
|
|
mNote.setTextDataId(cursor.getLong(DATA_ID_COLUMN));
|
|
|
|
|
// 加载富文本格式信息
|
|
|
|
|
mRichTextFormatInfo = cursor.getString(DATA_RICH_TEXT_FORMAT_COLUMN);
|
|
|
|
|
}
|
|
|
|
|
//如果是图片类型
|
|
|
|
|
else if (DataConstants.IMAGE.equals(type)) {
|
|
|
|
|
// 图片数据,目前我们只是加载数据,实际图片显示在UI层处理
|
|
|
|
|
String imagePath = cursor.getString(DATA_IMAGE_PATH_COLUMN);
|
|
|
|
|
Log.d(TAG, "Loaded image data: " + imagePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//如果是通话记录类型
|
|
|
|
|
else if (DataConstants.CALL_NOTE.equals(type)) {
|
|
|
|
|
mNote.setCallDataId(cursor.getLong(DATA_ID_COLUMN));
|
|
|
|
|
@ -323,6 +363,18 @@ public class WorkingNote {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//设置富文本格式
|
|
|
|
|
public void setRichTextFormat(String formatInfo) {
|
|
|
|
|
if (!TextUtils.equals(mRichTextFormatInfo, formatInfo)) {
|
|
|
|
|
mRichTextFormatInfo = formatInfo;
|
|
|
|
|
mNote.setRichTextFormat(formatInfo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getRichTextFormat() {
|
|
|
|
|
return mRichTextFormatInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 将笔记转换为通话笔记(设置通话相关数据)
|
|
|
|
|
public void convertToCallNote(String phoneNumber, long callDate) {
|
|
|
|
|
mNote.setCallData(CallNote.CALL_DATE, String.valueOf(callDate));
|
|
|
|
|
@ -334,6 +386,47 @@ public class WorkingNote {
|
|
|
|
|
return (mAlertDate > 0 ? true : false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public boolean hasLocationAlert() {
|
|
|
|
|
return (mAlertLatitude != 0 && mAlertLongitude != 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setAlertLocation(double latitude, double longitude, float radius, String locationName, boolean set) {
|
|
|
|
|
// 有位置变化才更新
|
|
|
|
|
if (latitude != mAlertLatitude || longitude != mAlertLongitude || radius != mAlertRadius || !locationName.equals(mAlertLocationName)) {
|
|
|
|
|
mAlertLatitude = latitude;
|
|
|
|
|
mAlertLongitude = longitude;
|
|
|
|
|
mAlertRadius = radius;
|
|
|
|
|
mAlertLocationName = locationName;
|
|
|
|
|
|
|
|
|
|
mNote.setNoteValue(NoteColumns.ALERT_LATITUDE, String.valueOf(mAlertLatitude));
|
|
|
|
|
mNote.setNoteValue(NoteColumns.ALERT_LONGITUDE, String.valueOf(mAlertLongitude));
|
|
|
|
|
mNote.setNoteValue(NoteColumns.ALERT_RADIUS, String.valueOf(mAlertRadius));
|
|
|
|
|
mNote.setNoteValue(NoteColumns.ALERT_LOCATION_NAME, mAlertLocationName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 若监听器不为空,触发位置提醒变更回调
|
|
|
|
|
if (mNoteSettingStatusListener != null) {
|
|
|
|
|
mNoteSettingStatusListener.onLocationAlertChanged(latitude, longitude, radius, locationName, set);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double getAlertLatitude() {
|
|
|
|
|
return mAlertLatitude;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double getAlertLongitude() {
|
|
|
|
|
return mAlertLongitude;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public float getAlertRadius() {
|
|
|
|
|
return mAlertRadius;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getAlertLocationName() {
|
|
|
|
|
return mAlertLocationName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getContent() {
|
|
|
|
|
return mContent;
|
|
|
|
|
}
|
|
|
|
|
@ -378,6 +471,11 @@ public class WorkingNote {
|
|
|
|
|
return mWidgetType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Note getNote() {
|
|
|
|
|
return mNote;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 笔记设置变更监听器接口(定义属性变化时的回调方法)
|
|
|
|
|
public interface NoteSettingChangedListener {
|
|
|
|
|
/**
|
|
|
|
|
@ -390,6 +488,12 @@ public class WorkingNote {
|
|
|
|
|
*/
|
|
|
|
|
void onClockAlertChanged(long date, boolean set);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called when user set location alert
|
|
|
|
|
*/
|
|
|
|
|
void onLocationAlertChanged(double latitude, double longitude, float radius, String locationName, boolean set);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Call when user create note from widget
|
|
|
|
|
*/
|
|
|
|
|
|