-完成了精度报告
-进行了部分注释
guojiahao_branch
郭佳豪 3 months ago
parent 6dffe6a382
commit e3edfe568d

Binary file not shown.

@ -564,21 +564,36 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
/**
* Share note to apps that support {@link Intent#ACTION_SEND} action
* and {@text/plain} type
* {@link Intent#ACTION_SEND} {@text/plain}
*
* @param context Activity
* @param info {@link Intent#EXTRA_TEXT}
*/
private void sendTo(Context context, String info) {
// 创建一个新的 Intent设置操作为 ACTION_SEND用于分享文本信息
Intent intent = new Intent(Intent.ACTION_SEND);
// 将要分享的文本信息作为 EXTRA_TEXT 添加到 Intent 中
intent.putExtra(Intent.EXTRA_TEXT, info);
// 设置 Intent 的 MIME 类型为 text/plain表示分享的是纯文本
intent.setType("text/plain");
// 启动目标应用程序的 Activity分享文本信息
context.startActivity(intent);
}
/**
*
* NoteEditActivity
* finish()ActivityIntentNoteEditActivity
*/
private void createNewNote() {
// Firstly, save current editing notes
// 首先保存当前正在编辑的笔记,确保数据不会丢失
saveNote();
// For safety, start a new NoteEditActivity
// 结束当前Activity并启动一个新的NoteEditActivity以创建新笔记
finish();
Intent intent = new Intent(this, NoteEditActivity.class);
intent.setAction(Intent.ACTION_INSERT_OR_EDIT);
@ -586,25 +601,44 @@ public class NoteEditActivity extends Activity implements OnClickListener,
startActivity(intent);
}
/**
*
*
*
* IDID
*
*
*/
private void deleteCurrentNote() {
// 检查当前笔记是否存在于数据库中
if (mWorkingNote.existInDatabase()) {
// 创建一个HashSet来存储待删除的笔记ID
HashSet<Long> ids = new HashSet<Long>();
long id = mWorkingNote.getNoteId();
// 如果笔记ID不是根文件夹的ID则将其添加到待删除的ID集合中
if (id != Notes.ID_ROOT_FOLDER) {
ids.add(id);
} else {
// 如果笔记ID是根文件夹的ID则记录错误日志
Log.d(TAG, "Wrong note id, should not happen");
}
// 根据是否处于同步模式决定是直接删除还是移动到回收站
if (!isSyncMode()) {
// 如果不在同步模式,则尝试批量删除笔记
if (!DataUtils.batchDeleteNotes(getContentResolver(), ids)) {
Log.e(TAG, "Delete Note error");
}
} else {
// 如果在同步模式,则尝试将笔记移动到回收站
if (!DataUtils.batchMoveToFolder(getContentResolver(), ids, Notes.ID_TRASH_FOLER)) {
Log.e(TAG, "Move notes to trash folder error, should not happens");
}
}
}
// 无论笔记是否存在于数据库中,都将其标记为已删除状态
mWorkingNote.markDeleted(true);
}
@ -612,14 +646,27 @@ public class NoteEditActivity extends Activity implements OnClickListener,
return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0;
}
/**
*
*
*
*
* @param date
* @param set true false
*/
public void onClockAlertChanged(long date, boolean set) {
/**
* User could set clock to an unsaved note, so before setting the
* alert clock, we should save the note first
*
*
*/
if (!mWorkingNote.existInDatabase()) {
saveNote();
}
/**
* ID0
* 使 AlarmManager PendingIntent AlarmReceiver
*/
if (mWorkingNote.getNoteId() > 0) {
Intent intent = new Intent(this, AlarmReceiver.class);
intent.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mWorkingNote.getNoteId()));
@ -633,9 +680,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
} else {
/**
* There is the condition that user has input nothing (the note is
* not worthy saving), we have no note id, remind the user that he
* should input something
*
*
*/
Log.e(TAG, "Clock alert setting error");
showToast(R.string.error_note_empty_for_clock);
@ -646,18 +692,30 @@ public class NoteEditActivity extends Activity implements OnClickListener,
updateWidget();
}
/**
*
*
*
* @param index
* @param text
*/
public void onEditTextDelete(int index, String text) {
int childCount = mEditTextList.getChildCount();
// 如果只有一个编辑框,直接返回,不允许删除
if (childCount == 1) {
return;
}
// 调整后续编辑框的索引
for (int i = index + 1; i < childCount; i++) {
((NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text))
.setIndex(i - 1);
}
// 移除指定索引的编辑框
mEditTextList.removeViewAt(index);
// 获取前一个或后一个编辑框,并将删除的文本内容追加到其中
NoteEditText edit = null;
if(index == 0) {
edit = (NoteEditText) mEditTextList.getChildAt(0).findViewById(

@ -76,39 +76,76 @@ public class NoteItemData {
private boolean mIsOneNoteFollowingFolder;
private boolean mIsMultiNotesFollowingFolder;
public NoteItemData(Context context, Cursor cursor) {
mId = cursor.getLong(ID_COLUMN);
mAlertDate = cursor.getLong(ALERTED_DATE_COLUMN);
mBgColorId = cursor.getInt(BG_COLOR_ID_COLUMN);
mCreatedDate = cursor.getLong(CREATED_DATE_COLUMN);
mHasAttachment = (cursor.getInt(HAS_ATTACHMENT_COLUMN) > 0) ? true : false;
mModifiedDate = cursor.getLong(MODIFIED_DATE_COLUMN);
mNotesCount = cursor.getInt(NOTES_COUNT_COLUMN);
mParentId = cursor.getLong(PARENT_ID_COLUMN);
mSnippet = cursor.getString(SNIPPET_COLUMN);
mSnippet = mSnippet.replace(NoteEditActivity.TAG_CHECKED, "").replace(
NoteEditActivity.TAG_UNCHECKED, "");
mType = cursor.getInt(TYPE_COLUMN);
mWidgetId = cursor.getInt(WIDGET_ID_COLUMN);
mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN);
mPhoneNumber = "";
if (mParentId == Notes.ID_CALL_RECORD_FOLDER) {
mPhoneNumber = DataUtils.getCallNumberByNoteId(context.getContentResolver(), mId);
if (!TextUtils.isEmpty(mPhoneNumber)) {
mName = Contact.getContact(context, mPhoneNumber);
if (mName == null) {
mName = mPhoneNumber;
}
/**
* NoteItemData Cursor NoteItemData
*
* @param context
* @param cursor Cursor
*/
public NoteItemData(Context context, Cursor cursor) {
// 从 Cursor 中提取笔记的 ID
mId = cursor.getLong(ID_COLUMN);
// 从 Cursor 中提取笔记的提醒日期
mAlertDate = cursor.getLong(ALERTED_DATE_COLUMN);
// 从 Cursor 中提取笔记的背景颜色 ID
mBgColorId = cursor.getInt(BG_COLOR_ID_COLUMN);
// 从 Cursor 中提取笔记的创建日期
mCreatedDate = cursor.getLong(CREATED_DATE_COLUMN);
// 从 Cursor 中提取笔记是否包含附件的信息,并转换为布尔值
mHasAttachment = (cursor.getInt(HAS_ATTACHMENT_COLUMN) > 0) ? true : false;
// 从 Cursor 中提取笔记的最后修改日期
mModifiedDate = cursor.getLong(MODIFIED_DATE_COLUMN);
// 从 Cursor 中提取笔记下的子笔记数量
mNotesCount = cursor.getInt(NOTES_COUNT_COLUMN);
// 从 Cursor 中提取笔记的父级 ID即所属文件夹的 ID
mParentId = cursor.getLong(PARENT_ID_COLUMN);
// 从 Cursor 中提取笔记的摘要信息并移除标记符号TAG_CHECKED 和 TAG_UNCHECKED
mSnippet = cursor.getString(SNIPPET_COLUMN);
mSnippet = mSnippet.replace(NoteEditActivity.TAG_CHECKED, "").replace(NoteEditActivity.TAG_UNCHECKED, "");
// 从 Cursor 中提取笔记的类型(如普通笔记、文件夹等)
mType = cursor.getInt(TYPE_COLUMN);
// 从 Cursor 中提取笔记的小部件 ID
mWidgetId = cursor.getInt(WIDGET_ID_COLUMN);
// 从 Cursor 中提取笔记的小部件类型
mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN);
// 初始化电话号码为空字符串
mPhoneNumber = "";
// 如果笔记属于通话记录文件夹,则获取其对应的电话号码
if (mParentId == Notes.ID_CALL_RECORD_FOLDER) {
mPhoneNumber = DataUtils.getCallNumberByNoteId(context.getContentResolver(), mId);
if (!TextUtils.isEmpty(mPhoneNumber)) {
// 根据电话号码获取联系人姓名
mName = Contact.getContact(context, mPhoneNumber);
if (mName == null) {
// 如果未找到联系人姓名,则使用电话号码作为名称
mName = mPhoneNumber;
}
}
}
if (mName == null) {
mName = "";
}
checkPostion(cursor);
// 如果 mName 仍为 null则将其设置为空字符串
if (mName == null) {
mName = "";
}
// 检查笔记在 Cursor 中的位置信息(如是否为第一个、最后一个等)
checkPostion(cursor);
}
private void checkPostion(Cursor cursor) {
mIsLastItem = cursor.isLast() ? true : false;
mIsFirstItem = cursor.isFirst() ? true : false;
@ -158,61 +195,131 @@ public class NoteItemData {
return mIsOnlyOneItem;
}
public long getId() {
return mId;
}
/**
*
*
* @return ID
*/
public long getId() {
return mId;
}
public long getAlertDate() {
return mAlertDate;
}
/**
*
*
* @return 0
*/
public long getAlertDate() {
return mAlertDate;
}
public long getCreatedDate() {
return mCreatedDate;
}
/**
*
*
* @return
*/
public long getCreatedDate() {
return mCreatedDate;
}
public boolean hasAttachment() {
return mHasAttachment;
}
/**
*
*
* @return true false
*/
public boolean hasAttachment() {
return mHasAttachment;
}
public long getModifiedDate() {
return mModifiedDate;
}
/**
*
*
* @return
*/
public long getModifiedDate() {
return mModifiedDate;
}
public int getBgColorId() {
return mBgColorId;
}
/**
* ID
*
* @return ID
*/
public int getBgColorId() {
return mBgColorId;
}
public long getParentId() {
return mParentId;
}
/**
* ID ID
*
* @return ID
*/
public long getParentId() {
return mParentId;
}
public int getNotesCount() {
return mNotesCount;
}
/**
*
*
* @return
*/
public int getNotesCount() {
return mNotesCount;
}
public long getFolderId () {
return mParentId;
}
/**
* ID getParentId()
*
* @return ID
*/
public long getFolderId() {
return mParentId;
}
public int getType() {
return mType;
}
/**
*
*
* @return
*/
public int getType() {
return mType;
}
public int getWidgetType() {
return mWidgetType;
}
/**
*
*
* @return
*/
public int getWidgetType() {
return mWidgetType;
}
public int getWidgetId() {
return mWidgetId;
}
/**
* ID
*
* @return ID
*/
public int getWidgetId() {
return mWidgetId;
}
public String getSnippet() {
return mSnippet;
}
/**
*
*
* @return
*/
public String getSnippet() {
return mSnippet;
}
public boolean hasAlert() {
return (mAlertDate > 0);
}
/**
*
*
* @return true false
*/
public boolean hasAlert() {
return (mAlertDate > 0);
}
public boolean isCallRecord() {
return (mParentId == Notes.ID_CALL_RECORD_FOLDER && !TextUtils.isEmpty(mPhoneNumber));

Loading…
Cancel
Save