From 69ede62db3e7e3b22fba634b43662cc006865cd0 Mon Sep 17 00:00:00 2001 From: hyf <2173636536@qq.com> Date: Wed, 25 Dec 2024 18:24:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=83=A1=E4=BA=91=E9=A3=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../micode/notes/tool/GTaskStringUtils.java | 99 ++++++++++--------- .../net/micode/notes/tool/ResourceParser.java | 52 +++++----- 2 files changed, 81 insertions(+), 70 deletions(-) diff --git a/src/Notes-master/src/net/micode/notes/tool/GTaskStringUtils.java b/src/Notes-master/src/net/micode/notes/tool/GTaskStringUtils.java index 666b729..e64b580 100644 --- a/src/Notes-master/src/net/micode/notes/tool/GTaskStringUtils.java +++ b/src/Notes-master/src/net/micode/notes/tool/GTaskStringUtils.java @@ -13,101 +13,104 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +// 该类属于 net.micode.notes.tool 包 package net.micode.notes.tool; - +// 定义了一个公共类 GTaskStringUtils public class GTaskStringUtils { - + // 以下是一系列公共的静态常量字符串,它们很可能是用于 JSON 数据处理或数据交互时的键(Key) + // 表示操作的 ID public final static String GTASK_JSON_ACTION_ID = "action_id"; - + // 表示操作列表 public final static String GTASK_JSON_ACTION_LIST = "action_list"; - + // 表示操作类型 public final static String GTASK_JSON_ACTION_TYPE = "action_type"; - + // 操作类型为创建 public final static String GTASK_JSON_ACTION_TYPE_CREATE = "create"; - + // 操作类型为获取全部 public final static String GTASK_JSON_ACTION_TYPE_GETALL = "get_all"; - + // 操作类型为移动 public final static String GTASK_JSON_ACTION_TYPE_MOVE = "move"; - + // 操作类型为更新 public final static String GTASK_JSON_ACTION_TYPE_UPDATE = "update"; - + // 表示创建者的 ID public final static String GTASK_JSON_CREATOR_ID = "creator_id"; - + // 表示子实体 public final static String GTASK_JSON_CHILD_ENTITY = "child_entity"; - + // 表示客户端版本 public final static String GTASK_JSON_CLIENT_VERSION = "client_version"; - + // 表示完成状态 public final static String GTASK_JSON_COMPLETED = "completed"; - + // 表示当前列表的 ID public final static String GTASK_JSON_CURRENT_LIST_ID = "current_list_id"; - + // 表示默认列表的 ID public final static String GTASK_JSON_DEFAULT_LIST_ID = "default_list_id"; - + // 表示已删除状态 public final static String GTASK_JSON_DELETED = "deleted"; - + // 表示目标列表 public final static String GTASK_JSON_DEST_LIST = "dest_list"; - + // 表示目标父级 public final static String GTASK_JSON_DEST_PARENT = "dest_parent"; - + // 表示目标父级的类型 public final static String GTASK_JSON_DEST_PARENT_TYPE = "dest_parent_type"; - + // 表示实体的增量 public final static String GTASK_JSON_ENTITY_DELTA = "entity_delta"; - + // 表示实体类型 public final static String GTASK_JSON_ENTITY_TYPE = "entity_type"; - + // 表示获取已删除的内容 public final static String GTASK_JSON_GET_DELETED = "get_deleted"; - + // 表示 ID public final static String GTASK_JSON_ID = "id"; - + // 表示索引 public final static String GTASK_JSON_INDEX = "index"; - + // 表示最后修改时间 public final static String GTASK_JSON_LAST_MODIFIED = "last_modified"; - + // 表示最新的同步点 public final static String GTASK_JSON_LATEST_SYNC_POINT = "latest_sync_point"; - + // 表示列表的 ID public final static String GTASK_JSON_LIST_ID = "list_id"; - + // 表示列表 public final static String GTASK_JSON_LISTS = "lists"; - + // 表示名称 public final static String GTASK_JSON_NAME = "name"; - + // 表示新的 ID public final static String GTASK_JSON_NEW_ID = "new_id"; - + // 表示笔记 public final static String GTASK_JSON_NOTES = "notes"; - + // 表示父级的 ID public final static String GTASK_JSON_PARENT_ID = "parent_id"; - + // 表示前一个兄弟节点的 ID public final static String GTASK_JSON_PRIOR_SIBLING_ID = "prior_sibling_id"; - + // 表示结果 public final static String GTASK_JSON_RESULTS = "results"; - + // 表示源列表 public final static String GTASK_JSON_SOURCE_LIST = "source_list"; - + // 表示任务 public final static String GTASK_JSON_TASKS = "tasks"; - + // 表示类型 public final static String GTASK_JSON_TYPE = "type"; - + // 类型为组 public final static String GTASK_JSON_TYPE_GROUP = "GROUP"; - + // 类型为任务 public final static String GTASK_JSON_TYPE_TASK = "TASK"; - + // 表示用户 public final static String GTASK_JSON_USER = "user"; - + // 以下可能是一些应用相关的常量,可能用于文件或文件夹的名称或前缀 + // MIUI 笔记的文件夹前缀 public final static String MIUI_FOLDER_PREFFIX = "[MIUI_Notes]"; - + // 默认文件夹 public final static String FOLDER_DEFAULT = "Default"; - + // 呼叫笔记的文件夹 public final static String FOLDER_CALL_NOTE = "Call_Note"; - + // 元数据文件夹 public final static String FOLDER_META = "METADATA"; - + // 以下是一些元数据的头部信息,可能用于存储一些特殊的元数据 + // 元数据的 GTask ID 头部 public final static String META_HEAD_GTASK_ID = "meta_gid"; - + // 元数据的笔记头部 public final static String META_HEAD_NOTE = "meta_note"; - + // 元数据的数据头部 public final static String META_HEAD_DATA = "meta_data"; - + // 元数据的笔记名称 public final static String META_NOTE_NAME = "[META INFO] DON'T UPDATE AND DELETE"; } diff --git a/src/Notes-master/src/net/micode/notes/tool/ResourceParser.java b/src/Notes-master/src/net/micode/notes/tool/ResourceParser.java index 1ad3ad6..309e587 100644 --- a/src/Notes-master/src/net/micode/notes/tool/ResourceParser.java +++ b/src/Notes-master/src/net/micode/notes/tool/ResourceParser.java @@ -21,25 +21,26 @@ import android.preference.PreferenceManager; import net.micode.notes.R; import net.micode.notes.ui.NotesPreferenceActivity; - +// 资源解析器类,用于管理笔记应用中的各种资源 public class ResourceParser { - + // 定义背景颜色的常量,使用整数表示不同颜色 public static final int YELLOW = 0; public static final int BLUE = 1; public static final int WHITE = 2; public static final int GREEN = 3; public static final int RED = 4; - + // 默认的背景颜色为黄色 public static final int BG_DEFAULT_COLOR = YELLOW; - + // 定义字体大小的常量,使用整数表示不同大小 public static final int TEXT_SMALL = 0; public static final int TEXT_MEDIUM = 1; public static final int TEXT_LARGE = 2; public static final int TEXT_SUPER = 3; - + // 默认的字体大小为中等 public static final int BG_DEFAULT_FONT_SIZE = TEXT_MEDIUM; - + // 内部类 NoteBgResources 用于管理笔记编辑界面的背景资源 public static class NoteBgResources { + // 存储笔记编辑界面背景的资源 ID 数组,分别对应不同颜色的背景 private final static int [] BG_EDIT_RESOURCES = new int [] { R.drawable.edit_yellow, R.drawable.edit_blue, @@ -47,7 +48,7 @@ public class ResourceParser { R.drawable.edit_green, R.drawable.edit_red }; - + // 存储笔记编辑界面标题背景的资源 ID 数组,分别对应不同颜色的标题背景 private final static int [] BG_EDIT_TITLE_RESOURCES = new int [] { R.drawable.edit_title_yellow, R.drawable.edit_title_blue, @@ -55,26 +56,30 @@ public class ResourceParser { R.drawable.edit_title_green, R.drawable.edit_title_red }; - + // 根据传入的颜色 ID 获取笔记编辑界面的背景资源 ID public static int getNoteBgResource(int id) { return BG_EDIT_RESOURCES[id]; } - + // 根据传入的颜色 ID 获取笔记编辑界面的标题背景资源 ID public static int getNoteTitleBgResource(int id) { return BG_EDIT_TITLE_RESOURCES[id]; } } - + // 根据上下文获取默认的背景 ID public static int getDefaultBgId(Context context) { + // 检查用户偏好设置中是否设置了背景颜色 if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean( NotesPreferenceActivity.PREFERENCE_SET_BG_COLOR_KEY, false)) { + // 如果设置了,随机选择一个背景颜色 return (int) (Math.random() * NoteBgResources.BG_EDIT_RESOURCES.length); } else { + // 否则使用默认的背景颜色 return BG_DEFAULT_COLOR; } } - + // 内部类 NoteItemBgResources 用于管理笔记列表项的背景资源 public static class NoteItemBgResources { + // 存储笔记列表项的不同状态(如第一个、正常、最后一个、单个)的背景资源 ID 数组,分别对应不同颜色 private final static int [] BG_FIRST_RESOURCES = new int [] { R.drawable.list_yellow_up, R.drawable.list_blue_up, @@ -106,29 +111,30 @@ public class ResourceParser { R.drawable.list_green_single, R.drawable.list_red_single }; - + // 根据传入的颜色 ID 获取笔记列表项第一个元素的背景资源 ID public static int getNoteBgFirstRes(int id) { return BG_FIRST_RESOURCES[id]; } - + // 根据传入的颜色 ID 获取笔记列表项最后一个元素的背景资源 ID public static int getNoteBgLastRes(int id) { return BG_LAST_RESOURCES[id]; } - + // 根据传入的颜色 ID 获取笔记列表项单个元素的背景资源 ID public static int getNoteBgSingleRes(int id) { return BG_SINGLE_RESOURCES[id]; } - + // 根据传入的颜色 ID 获取笔记列表项正常元素的背景资源 ID public static int getNoteBgNormalRes(int id) { return BG_NORMAL_RESOURCES[id]; } - + // 获取文件夹的背景资源 ID public static int getFolderBgRes() { return R.drawable.list_folder; } } - + // 内部类 WidgetBgResources 用于管理小部件的背景资源 public static class WidgetBgResources { + // 存储 2x 小部件的不同颜色的背景资源 ID 数组 private final static int [] BG_2X_RESOURCES = new int [] { R.drawable.widget_2x_yellow, R.drawable.widget_2x_blue, @@ -136,11 +142,11 @@ public class ResourceParser { R.drawable.widget_2x_green, R.drawable.widget_2x_red, }; - + // 根据传入的颜色 ID 获取 2x 小部件的背景资源 ID public static int getWidget2xBgResource(int id) { return BG_2X_RESOURCES[id]; } - + // 存储 4x 小部件的不同颜色的背景资源 ID 数组 private final static int [] BG_4X_RESOURCES = new int [] { R.drawable.widget_4x_yellow, R.drawable.widget_4x_blue, @@ -148,20 +154,21 @@ public class ResourceParser { R.drawable.widget_4x_green, R.drawable.widget_4x_red }; - + // 根据传入的颜色 ID 获取 4x 小部件的背景资源 ID public static int getWidget4xBgResource(int id) { return BG_4X_RESOURCES[id]; } } - + // 内部类 TextAppearanceResources 用于管理文本外观资源 public static class TextAppearanceResources { + // 存储不同字体大小的文本外观资源 ID 数组 private final static int [] TEXTAPPEARANCE_RESOURCES = new int [] { R.style.TextAppearanceNormal, R.style.TextAppearanceMedium, R.style.TextAppearanceLarge, R.style.TextAppearanceSuper }; - + // 根据传入的字体大小 ID 获取文本外观资源 ID public static int getTexAppearanceResource(int id) { /** * HACKME: Fix bug of store the resource id in shared preference. @@ -173,6 +180,7 @@ public class ResourceParser { } return TEXTAPPEARANCE_RESOURCES[id]; } + // 获取文本外观资源的数量 public static int getResourcesSize() { return TEXTAPPEARANCE_RESOURCES.length;