Compare commits

...

21 Commits

Author SHA1 Message Date
ln ab6a782298 清理分支,删除无关目录,仅保留WorkingNote.java
7 days ago
ln dea20e73c1 feat: 清理个人分支,仅保留WorkingNote.java
7 days ago
ln 5e92e89a78 刘楠:完成WorkingNote.java文件注释并上传到个人分支
2 weeks ago
ln 795029aa66 add: 提交 Notemaster 源代码到 master 分支
2 weeks ago
zhangsiyi 78d8ca886b Merge branch 'master' of https://bdgit.educoder.net/p2feyuxrl/touge
2 weeks ago
zhangsiyi 1006d40da5 remove: 删除 master 分支中不需要的 Notemaster 文件夹
2 weeks ago
lh b8b79840e8 刘慧:同步liuhui_branch分支的NotesListActivity.java文件
2 weeks ago
zhangsiyi df39fa0d8e Merge branch 'master' of https://bdgit.educoder.net/p2feyuxrl/touge
2 weeks ago
lh a02a97e510 完成合并,解决冲突
2 weeks ago
zhangsiyi 80ee4ccde3 remove: 彻底删除 note_list.xml 和 strings.xml
2 weeks ago
zhangsiyi 84f47b9999 remove: 删除不需要的文件(NotesListActivity.java、note_list.xml、strings.xml)
2 weeks ago
zhangsiyi 9225318b1b Merge branch 'master' into zhangsiyi_branch
2 weeks ago
zhangsiyi d8ac5a0d80 feat: 优化小米便签搜索功能
2 weeks ago
zhangsiyi ef32f00fd9 张思怡: 合并NoteEditActivity.java注释到master
2 weeks ago
zhangsiyi 9bdcc6eace 张思怡:完成NoteEditActivity注释,上传到个人分支
2 weeks ago
zhangsiyi 66dac88973 move NoteEditActivity.java to src/ folder
2 weeks ago
zhangsiyi 03de5fc872 feat: 为NoteEditActivity类添加注释(作者:张思怡)
2 weeks ago
lh ed586ee646 刘慧:完成NotesListActivity.java文件注释,提交到个人分支
2 weeks ago
zhangsiyi a41f7b79d0 Merge branch 'master' of https://bdgit.educoder.net/p2feyuxrl/touge
2 weeks ago
p9zkfnvhs eb474fe17c ADD file via upload
2 weeks ago
lh 77f4e43c52 master分支:上传小米便签完整源码到src目录
2 weeks ago

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="NONE" />
</component>
<component name="ChangeListManager">
<list default="true" id="606cc245-8f21-4609-be65-29a63871258f" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/NotesMaster1/app/src/main/java/net/micode/notes/data/Notes.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/NotesMaster1/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/NotesMaster1/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/NotesMaster1/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/NotesMaster1/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/NotesMaster1/app/src/main/java/net/micode/notes/tool/BackupUtils.java" beforeDir="false" afterPath="$PROJECT_DIR$/NotesMaster1/app/src/main/java/net/micode/notes/tool/BackupUtils.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/NotesMaster1/app/src/main/res/values-zh-rCN/strings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/NotesMaster1/app/src/main/res/values-zh-rCN/strings.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/NotesMaster1/app/src/main/res/values/strings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/NotesMaster1/app/src/main/res/values/strings.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="ClangdSettings">
<option name="formatViaClangd" value="false" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
</component>
<component name="ProjectColorInfo"><![CDATA[{
"customColor": "",
"associatedIndex": 0
}]]></component>
<component name="ProjectId" id="3DFsSbnVWbtO3iXObN0wTVNe0SM" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ModuleVcsDetector.initialDetectionPerformed": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.cidr.known.project.marker": "true",
"RunOnceActivity.git.unshallow": "true",
"RunOnceActivity.readMode.enableVisualFormatting": "true",
"cf.first.check.clang-format": "false",
"cidr.known.project.marker": "true",
"git-widget-placeholder": "my-upload",
"kotlin-language-version-configured": "true"
}
}]]></component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="606cc245-8f21-4609-be65-29a63871258f" name="Changes" comment="" />
<created>1777889154023</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1777889154023</updated>
</task>
<servers />
</component>
</project>

@ -0,0 +1,498 @@
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;
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;
public class WorkingNote {
// 工作便签的笔记对象
private Note mNote;
// 便签ID
private long mNoteId;
// 便签内容
private String mContent;
// 便签模式(普通模式或清单模式)
private int mMode;
// 提醒日期(时间戳)
private long mAlertDate;
// 最后修改日期(时间戳)
private long mModifiedDate;
// 背景颜色ID
private int mBgColorId;
// 桌面小部件ID
private int mWidgetId;
// 桌面小部件类型2x或4x
private int mWidgetType;
// 所属文件夹ID
private long mFolderId;
// Android上下文对象
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
};
// 数据ID列在查询结果中的索引位置
private static final int DATA_ID_COLUMN = 0;
// 数据内容列在查询结果中的索引位置
private static final int DATA_CONTENT_COLUMN = 1;
// 数据类型MIME列在查询结果中的索引位置
private static final int DATA_MIME_TYPE_COLUMN = 2;
// 数据模式列在查询结果中的索引位置
private static final int DATA_MODE_COLUMN = 3;
// 父级文件夹ID列在查询结果中的索引位置
private static final int NOTE_PARENT_ID_COLUMN = 0;
// 提醒日期列在查询结果中的索引位置
private static final int NOTE_ALERTED_DATE_COLUMN = 1;
// 背景颜色ID列在查询结果中的索引位置
private static final int NOTE_BG_COLOR_ID_COLUMN = 2;
// 小部件ID列在查询结果中的索引位置
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();
mFolderId = folderId;
mNote = new Note();
mNoteId = 0;
mIsDeleted = false;
mMode = 0;
mWidgetType = Notes.TYPE_WIDGET_INVALIDE;
}
// 现有便签构造函数 - 从数据库加载已存在的便签
private WorkingNote(Context context, long noteId, long folderId) {
mContext = context;
mNoteId = noteId;
mFolderId = folderId;
mIsDeleted = false;
mNote = new Note();
loadNote();
}
/**
* 便
*/
private void loadNote() {
Cursor cursor = mContext.getContentResolver().query(
ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mNoteId), NOTE_PROJECTION, null,
null, null);
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);
}
}
/**
* 便
* @param context Android
* @param folderId ID
* @param widgetId ID
* @param widgetType
* @param defaultBgColorId ID
* @return 便
*/
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;
}
/**
* ID便
* @param context Android
* @param id 便ID
* @return 便
*/
public static WorkingNote load(Context context, long id) {
return new WorkingNote(context, id, 0);
}
/**
* 便
* @return truefalse
*/
public synchronized boolean saveNote() {
if (isWorthSaving()) {
if (!existInDatabase()) {
if ((mNoteId = Note.getNewNoteId(mContext, mFolderId)) == 0) {
Log.e(TAG, "Create new note fail with id:" + mNoteId);
return false;
}
}
mNote.syncNote(mContext, mNoteId);
/**
* 便
*/
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
&& mWidgetType != Notes.TYPE_WIDGET_INVALIDE
&& mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onWidgetChanged();
}
return true;
} else {
return false;
}
}
/**
* 便ID
* @return truefalse
*/
public boolean existInDatabase() {
return mNoteId > 0;
}
/**
* 便
* @return truefalse
*/
private boolean isWorthSaving() {
if (mIsDeleted || (!existInDatabase() && TextUtils.isEmpty(mContent))
|| (existInDatabase() && !mNote.isLocalModified())) {
return false;
} else {
return true;
}
}
/**
* 便
* @param l
*/
public void setOnSettingStatusChangedListener(NoteSettingChangedListener l) {
mNoteSettingStatusListener = l;
}
/**
*
* @param date
* @param set
*/
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);
}
}
/**
* 便
* @param mark truefalse
*/
public void markDeleted(boolean mark) {
mIsDeleted = mark;
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
&& mWidgetType != Notes.TYPE_WIDGET_INVALIDE && mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onWidgetChanged();
}
}
/**
* 便
* @param id 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));
}
}
/**
* 便
* @param mode 01
*/
public void setCheckListMode(int mode) {
if (mMode != mode) {
if (mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onCheckListModeChanged(mMode, mode);
}
mMode = mode;
mNote.setTextData(TextNote.MODE, String.valueOf(mMode));
}
}
/**
*
* @param type 2x4x
*/
public void setWidgetType(int type) {
if (type != mWidgetType) {
mWidgetType = type;
mNote.setNoteValue(NoteColumns.WIDGET_TYPE, String.valueOf(mWidgetType));
}
}
/**
* ID
* @param id ID
*/
public void setWidgetId(int id) {
if (id != mWidgetId) {
mWidgetId = id;
mNote.setNoteValue(NoteColumns.WIDGET_ID, String.valueOf(mWidgetId));
}
}
/**
* 便
* @param text 便
*/
public void setWorkingText(String text) {
if (!TextUtils.equals(mContent, text)) {
mContent = text;
mNote.setTextData(DataColumns.CONTENT, mContent);
}
}
/**
* 便便
* @param phoneNumber
* @param 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));
}
/**
* 便
* @return truefalse
*/
public boolean hasClockAlert() {
return (mAlertDate > 0 ? true : false);
}
/**
* 便
* @return 便
*/
public String getContent() {
return mContent;
}
/**
*
* @return 0
*/
public long getAlertDate() {
return mAlertDate;
}
/**
* 便
* @return
*/
public long getModifiedDate() {
return mModifiedDate;
}
/**
* IDUI
* @return ID
*/
public int getBgColorResId() {
return NoteBgResources.getNoteBgResource(mBgColorId);
}
/**
* ID
* @return ID
*/
public int getBgColorId() {
return mBgColorId;
}
/**
* IDUI
* @return ID
*/
public int getTitleBgResId() {
return NoteBgResources.getNoteTitleBgResource(mBgColorId);
}
/**
* 便
* @return 01
*/
public int getCheckListMode() {
return mMode;
}
/**
* 便ID
* @return 便ID便0
*/
public long getNoteId() {
return mNoteId;
}
/**
* 便ID
* @return ID
*/
public long getFolderId() {
return mFolderId;
}
/**
* ID
* @return ID
*/
public int getWidgetId() {
return mWidgetId;
}
/**
*
* @return 2x4x
*/
public int getWidgetType() {
return mWidgetType;
}
/**
* 便 - UI便
*/
public interface NoteSettingChangedListener {
/**
* 便
*/
void onBackgroundColorChanged();
/**
*
* @param date
* @param set truefalse
*/
void onClockAlertChanged(long date, boolean set);
/**
* 便
*/
void onWidgetChanged();
/**
*
* @param oldMode
* @param newMode
*/
void onCheckListModeChanged(int oldMode, int newMode);
}
}
Loading…
Cancel
Save