diff --git a/doc/小米便签开源代码的泛读报告 - 副本.docx b/doc/小米便签开源代码的泛读报告 - 副本.docx deleted file mode 100644 index 92cdf69..0000000 Binary files a/doc/小米便签开源代码的泛读报告 - 副本.docx and /dev/null differ diff --git a/doc/示例:小米便签开源代码的质量分析报告 - 副本.docx b/doc/示例:小米便签开源代码的质量分析报告 - 副本.docx deleted file mode 100644 index 45f911a..0000000 Binary files a/doc/示例:小米便签开源代码的质量分析报告 - 副本.docx and /dev/null differ diff --git a/src/Notes-master/src/net/micode/notes/data/Notes.java b/src/Notes-master/src/net/micode/notes/data/Notes.java index 166444b..da15e51 100644 --- a/src/Notes-master/src/net/micode/notes/data/Notes.java +++ b/src/Notes-master/src/net/micode/notes/data/Notes.java @@ -17,263 +17,288 @@ package net.micode.notes.data; import android.net.Uri; +// 定义一个名为Notes的公共类,用于管理笔记相关的常量和接口 public class Notes { + // 内容提供者的权限名称,用于在应用内标识该内容提供者 public static final String AUTHORITY = "micode_notes"; + // 日志标签,用于在日志输出中标识该类相关的日志信息 public static final String TAG = "Notes"; - public static final int TYPE_NOTE = 0; - public static final int TYPE_FOLDER = 1; - public static final int TYPE_SYSTEM = 2; + // 表示笔记类型的常量 + public static final int TYPE_NOTE = 0; + // 表示文件夹类型的常量 + public static final int TYPE_FOLDER = 1; + // 表示系统类型的常量 + public static final int TYPE_SYSTEM = 2; /** - * Following IDs are system folders' identifiers - * {@link Notes#ID_ROOT_FOLDER } is default folder - * {@link Notes#ID_TEMPARAY_FOLDER } is for notes belonging no folder - * {@link Notes#ID_CALL_RECORD_FOLDER} is to store call records + * 以下ID是系统文件夹的标识符 + * {@link Notes#ID_ROOT_FOLDER } 是默认文件夹 + * {@link Notes#ID_TEMPARAY_FOLDER } 用于存放不属于任何文件夹的笔记 + * {@link Notes#ID_CALL_RECORD_FOLDER} 用于存储通话记录 */ + // 根文件夹的ID public static final int ID_ROOT_FOLDER = 0; + // 临时文件夹的ID,用于存放不属于任何文件夹的笔记 public static final int ID_TEMPARAY_FOLDER = -1; + // 通话记录文件夹的ID public static final int ID_CALL_RECORD_FOLDER = -2; + // 回收站文件夹的ID public static final int ID_TRASH_FOLER = -3; + // 用于在Intent中传递提醒日期的额外字段名称 public static final String INTENT_EXTRA_ALERT_DATE = "net.micode.notes.alert_date"; + // 用于在Intent中传递背景颜色ID的额外字段名称 public static final String INTENT_EXTRA_BACKGROUND_ID = "net.micode.notes.background_color_id"; + // 用于在Intent中传递小部件ID的额外字段名称 public static final String INTENT_EXTRA_WIDGET_ID = "net.micode.notes.widget_id"; + // 用于在Intent中传递小部件类型的额外字段名称 public static final String INTENT_EXTRA_WIDGET_TYPE = "net.micode.notes.widget_type"; + // 用于在Intent中传递文件夹ID的额外字段名称 public static final String INTENT_EXTRA_FOLDER_ID = "net.micode.notes.folder_id"; + // 用于在Intent中传递通话日期的额外字段名称 public static final String INTENT_EXTRA_CALL_DATE = "net.micode.notes.call_date"; - public static final int TYPE_WIDGET_INVALIDE = -1; - public static final int TYPE_WIDGET_2X = 0; - public static final int TYPE_WIDGET_4X = 1; + // 无效的小部件类型 + public static final int TYPE_WIDGET_INVALIDE = -1; + // 2x尺寸的小部件类型 + public static final int TYPE_WIDGET_2X = 0; + // 4x尺寸的小部件类型 + public static final int TYPE_WIDGET_4X = 1; + // 数据常量的内部类,用于存储不同类型数据的相关常量 public static class DataConstants { + // 文本笔记的内容类型 public static final String NOTE = TextNote.CONTENT_ITEM_TYPE; + // 通话笔记的内容类型 public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE; } /** - * Uri to query all notes and folders + * 用于查询所有笔记和文件夹的Uri */ public static final Uri CONTENT_NOTE_URI = Uri.parse("content://" + AUTHORITY + "/note"); /** - * Uri to query data + * 用于查询数据的Uri */ public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data"); + // 笔记列的接口,定义了与笔记相关的数据库列名 public interface NoteColumns { /** - * The unique ID for a row - *
Type: INTEGER (long)
+ * 行的唯一ID + *类型: INTEGER (long)
*/ public static final String ID = "_id"; /** - * The parent's id for note or folder - *Type: INTEGER (long)
+ * 笔记或文件夹的父级ID + *类型: INTEGER (long)
*/ public static final String PARENT_ID = "parent_id"; /** - * Created data for note or folder - *Type: INTEGER (long)
+ * 笔记或文件夹的创建日期 + *类型: INTEGER (long)
*/ public static final String CREATED_DATE = "created_date"; /** - * Latest modified date - *Type: INTEGER (long)
+ * 最新修改日期 + *类型: INTEGER (long)
*/ public static final String MODIFIED_DATE = "modified_date"; - /** - * Alert date - *Type: INTEGER (long)
+ * 提醒日期 + *类型: INTEGER (long)
*/ public static final String ALERTED_DATE = "alert_date"; /** - * Folder's name or text content of note - *Type: TEXT
+ * 文件夹的名称或笔记的文本内容 + *类型: TEXT
*/ public static final String SNIPPET = "snippet"; /** - * Note's widget id - *Type: INTEGER (long)
+ * 笔记的小部件ID + *类型: INTEGER (long)
*/ public static final String WIDGET_ID = "widget_id"; /** - * Note's widget type - *Type: INTEGER (long)
+ * 笔记的小部件类型 + *类型: INTEGER (long)
*/ public static final String WIDGET_TYPE = "widget_type"; /** - * Note's background color's id - *Type: INTEGER (long)
+ * 笔记的背景颜色ID + *类型: INTEGER (long)
*/ public static final String BG_COLOR_ID = "bg_color_id"; /** - * For text note, it doesn't has attachment, for multi-media - * note, it has at least one attachment - *Type: INTEGER
+ * 对于文本笔记,它没有附件;对于多媒体笔记,它至少有一个附件 + *类型: INTEGER
*/ public static final String HAS_ATTACHMENT = "has_attachment"; /** - * Folder's count of notes - *Type: INTEGER (long)
+ * 文件夹中的笔记数量 + *类型: INTEGER (long)
*/ public static final String NOTES_COUNT = "notes_count"; /** - * The file type: folder or note - *Type: INTEGER
+ * 文件类型:文件夹或笔记 + *类型: INTEGER
*/ public static final String TYPE = "type"; /** - * The last sync id - *Type: INTEGER (long)
+ * 最后同步ID + *类型: INTEGER (long)
*/ public static final String SYNC_ID = "sync_id"; /** - * Sign to indicate local modified or not - *Type: INTEGER
+ * 表示是否本地修改的标志 + *类型: INTEGER
*/ public static final String LOCAL_MODIFIED = "local_modified"; /** - * Original parent id before moving into temporary folder - *Type : INTEGER
+ * 移动到临时文件夹之前的原始父级ID + *类型 : INTEGER
*/ public static final String ORIGIN_PARENT_ID = "origin_parent_id"; /** - * The gtask id - *Type : TEXT
+ * gtask的ID + *类型 : TEXT
*/ public static final String GTASK_ID = "gtask_id"; /** - * The version code - *Type : INTEGER (long)
+ * 版本号 + *类型 : INTEGER (long)
*/ public static final String VERSION = "version"; } + // 数据列的接口,定义了与数据相关的数据库列名 public interface DataColumns { /** - * The unique ID for a row - *Type: INTEGER (long)
+ * 行的唯一ID + *类型: INTEGER (long)
*/ public static final String ID = "_id"; /** - * The MIME type of the item represented by this row. - *Type: Text
+ * 此行表示的项目的MIME类型 + *类型: Text
*/ public static final String MIME_TYPE = "mime_type"; /** - * The reference id to note that this data belongs to - *Type: INTEGER (long)
+ * 此数据所属笔记的引用ID + *类型: INTEGER (long)
*/ public static final String NOTE_ID = "note_id"; /** - * Created data for note or folder - *Type: INTEGER (long)
+ * 笔记或文件夹的创建日期 + *类型: INTEGER (long)
*/ public static final String CREATED_DATE = "created_date"; /** - * Latest modified date - *Type: INTEGER (long)
+ * 最新修改日期 + *类型: INTEGER (long)
*/ public static final String MODIFIED_DATE = "modified_date"; /** - * Data's content - *Type: TEXT
+ * 数据的内容 + *类型: TEXT
*/ public static final String CONTENT = "content"; - /** - * Generic data column, the meaning is {@link #MIMETYPE} specific, used for - * integer data type - *Type: INTEGER
+ * 通用数据列,含义与{@link #MIMETYPE}相关,用于整数数据类型 + *类型: INTEGER
*/ public static final String DATA1 = "data1"; /** - * Generic data column, the meaning is {@link #MIMETYPE} specific, used for - * integer data type - *Type: INTEGER
+ * 通用数据列,含义与{@link #MIMETYPE}相关,用于整数数据类型 + *类型: INTEGER
*/ public static final String DATA2 = "data2"; /** - * Generic data column, the meaning is {@link #MIMETYPE} specific, used for - * TEXT data type - *Type: TEXT
+ * 通用数据列,含义与{@link #MIMETYPE}相关,用于文本数据类型 + *类型: TEXT
*/ public static final String DATA3 = "data3"; /** - * Generic data column, the meaning is {@link #MIMETYPE} specific, used for - * TEXT data type - *Type: TEXT
+ * 通用数据列,含义与{@link #MIMETYPE}相关,用于文本数据类型 + *类型: TEXT
*/ public static final String DATA4 = "data4"; /** - * Generic data column, the meaning is {@link #MIMETYPE} specific, used for - * TEXT data type - *Type: TEXT
+ * 通用数据列,含义与{@link #MIMETYPE}相关,用于文本数据类型 + *类型: TEXT
*/ public static final String DATA5 = "data5"; } + // 文本笔记的静态内部类,实现了DataColumns接口,定义了文本笔记相关的常量 public static final class TextNote implements DataColumns { /** - * Mode to indicate the text in check list mode or not - *Type: Integer 1:check list mode 0: normal mode
+ * 模式,用于指示文本是否处于复选框列表模式 + *类型: Integer 1:复选框列表模式 0: 正常模式
*/ public static final String MODE = DATA1; + // 复选框列表模式的模式值 public static final int MODE_CHECK_LIST = 1; + // 文本笔记的内容类型(目录类型) public static final String CONTENT_TYPE = "vnd.android.cursor.dir/text_note"; + // 文本笔记的内容类型(项目类型) public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/text_note"; + // 文本笔记的内容Uri public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note"); } + // 通话笔记的静态内部类,实现了DataColumns接口,定义了通话笔记相关的常量 public static final class CallNote implements DataColumns { /** - * Call date for this record - *Type: INTEGER (long)
+ * 此通话记录的通话日期 + *类型: INTEGER (long)
*/ public static final String CALL_DATE = DATA1; /** - * Phone number for this record - *Type: TEXT
+ * 此通话记录的电话号码 + *类型: TEXT
*/ public static final String PHONE_NUMBER = DATA3; + // 通话笔记的内容类型(目录类型) public static final String CONTENT_TYPE = "vnd.android.cursor.dir/call_note"; + // 通话笔记的内容类型(项目类型) public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/call_note"; + // 通话笔记的内容Uri public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/call_note"); } } diff --git a/src/Notes-master/src/net/micode/notes/gtask/data/SqlNote.java b/src/Notes-master/src/net/micode/notes/gtask/data/SqlNote.java index a8b4da9..68fe0a6 100644 --- a/src/Notes-master/src/net/micode/notes/gtask/data/SqlNote.java +++ b/src/Notes-master/src/net/micode/notes/gtask/data/SqlNote.java @@ -38,11 +38,37 @@ import org.json.JSONObject; import java.util.ArrayList; -public class SqlNote {//sqlnot用法修改 +import android.content.ContentResolver; +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import android.net.Uri; +import android.widget.RemoteViews; + +import com.google.gson.JsonObject; + +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatDrawableManager; +import androidx.cursoradapter.widget.SimpleCursorAdapter; + +// SqlNote类用于处理与笔记数据的SQL相关操作,包括从数据库加载、保存、更新笔记信息等 +public class SqlNote { + // 日志标签,用于标识该类相关的日志信息 private static final String TAG = SqlNote.class.getSimpleName(); + // 无效的ID值 private static final int INVALID_ID = -99999; + // 用于查询笔记时的投影列,指定要从数据库中获取的列 public static final String[] PROJECTION_NOTE = new String[] { NoteColumns.ID, NoteColumns.ALERTED_DATE, NoteColumns.BG_COLOR_ID, NoteColumns.CREATED_DATE, NoteColumns.HAS_ATTACHMENT, NoteColumns.MODIFIED_DATE, @@ -52,76 +78,79 @@ public class SqlNote {//sqlnot用法修改 NoteColumns.VERSION }; + // 投影列中ID列的索引 public static final int ID_COLUMN = 0; - + // 投影列中提醒日期列的索引 public static final int ALERTED_DATE_COLUMN = 1; - + // 投影列中背景颜色ID列的索引 public static final int BG_COLOR_ID_COLUMN = 2; - + // 投影列中创建日期列的索引 public static final int CREATED_DATE_COLUMN = 3; - + // 投影列中是否有附件列的索引 public static final int HAS_ATTACHMENT_COLUMN = 4; - + // 投影列中修改日期列的索引 public static final int MODIFIED_DATE_COLUMN = 5; - + // 投影列中文件夹内笔记数量列的索引 public static final int NOTES_COUNT_COLUMN = 6; - + // 投影列中父级ID列的索引 public static final int PARENT_ID_COLUMN = 7; - + // 投影列中文本内容或文件夹名称列的索引 public static final int SNIPPET_COLUMN = 8; - + // 投影列中类型列的索引 public static final int TYPE_COLUMN = 9; - + // 投影列中小部件ID列的索引 public static final int WIDGET_ID_COLUMN = 10; - + // 投影列中小部件类型列的索引 public static final int WIDGET_TYPE_COLUMN = 11; - + // 投影列中同步ID列的索引 public static final int SYNC_ID_COLUMN = 12; - + // 投影列中本地修改标志列的索引 public static final int LOCAL_MODIFIED_COLUMN = 13; - + // 投影列中原始父级ID列的索引 public static final int ORIGIN_PARENT_ID_COLUMN = 14; - + // 投影列中gtask ID列的索引 public static final int GTASK_ID_COLUMN = 15; - + // 投影列中版本号列的索引 public static final int VERSION_COLUMN = 16; + // 应用上下文 private Context mContext; - + // 内容解析器,用于与内容提供者进行交互 private ContentResolver mContentResolver; - + // 标识该笔记是否为新创建的 private boolean mIsCreate; - + // 笔记的ID private long mId; - + // 提醒日期 private long mAlertDate; - + // 背景颜色ID private int mBgColorId; - + // 创建日期 private long mCreatedDate; - + // 是否有附件的标志 private int mHasAttachment; - + // 修改日期 private long mModifiedDate; - + // 父级ID private long mParentId; - + // 文本内容或文件夹名称 private String mSnippet; - + // 类型(笔记、文件夹或系统类型) private int mType; - + // 小部件ID private int mWidgetId; - + // 小部件类型 private int mWidgetType; - + // 原始父级ID private long mOriginParent; - + // 版本号 private long mVersion; - + // 用于存储笔记数据差异的ContentValues,用于更新操作 private ContentValues mDiffNoteValues; - + // 存储与该笔记相关的SqlData对象列表 private ArrayList