From d2b89a6290c55c57e29df70887834825f07a112b Mon Sep 17 00:00:00 2001
From: wkf <2228796621@qq.com>
Date: Wed, 14 May 2025 23:08:47 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A41?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/misc.xml | 6 ++
.idea/modules.xml | 8 +++
.idea/vcs.xml | 6 ++
README | 3 +
miNote.iml | 11 ++++
src/net/micode/notes/data/Contact.java | 4 ++
src/net/micode/notes/gtask/data/MetaData.java | 63 ++++++++++++++-----
7 files changed, 87 insertions(+), 14 deletions(-)
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/vcs.xml
create mode 100644 miNote.iml
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..66f29f6
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..1708153
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README b/README
index fc0d824..17d5c0a 100644
--- a/README
+++ b/README
@@ -21,3 +21,6 @@
3. Regarding feature request and general discussion, please visit Micode forum,
http://micode.net/forum.php?mod=forumdisplay&fid=38
+
+
+
diff --git a/miNote.iml b/miNote.iml
new file mode 100644
index 0000000..c90834f
--- /dev/null
+++ b/miNote.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/net/micode/notes/data/Contact.java b/src/net/micode/notes/data/Contact.java
index d97ac5d..3e96108 100644
--- a/src/net/micode/notes/data/Contact.java
+++ b/src/net/micode/notes/data/Contact.java
@@ -71,3 +71,7 @@ public class Contact {
}
}
}
+//提交的代码
+//git add .
+//git commit -m "提交说明"
+//git push origin wkf
\ No newline at end of file
diff --git a/src/net/micode/notes/gtask/data/MetaData.java b/src/net/micode/notes/gtask/data/MetaData.java
index 3a2050b..9d399c2 100644
--- a/src/net/micode/notes/gtask/data/MetaData.java
+++ b/src/net/micode/notes/gtask/data/MetaData.java
@@ -1,17 +1,15 @@
/*
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * 遵循Apache License, Version 2.0("许可证");
+ * 除非遵守许可证,否则不得使用本文件。
+ * 您可以在以下地址获取许可证副本:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * 除非适用法律要求或书面同意,软件
+ * 按"原样"分发,不附带任何明示或暗示的保证或条件。
+ * 请参阅许可证,了解具体的权限和限制。
*/
package net.micode.notes.gtask.data;
@@ -24,59 +22,96 @@ import net.micode.notes.tool.GTaskStringUtils;
import org.json.JSONException;
import org.json.JSONObject;
-
+/**
+ * 元数据类,继承自Task,用于处理与Google Tasks(GTask)相关的元数据信息
+ * 主要功能:管理GTask的关联ID和元数据信息的JSON序列化/反序列化
+ */
public class MetaData extends Task {
private final static String TAG = MetaData.class.getSimpleName();
+ // 关联的GTask全局唯一标识符(GID)
private String mRelatedGid = null;
+ /**
+ * 设置元数据信息
+ * @param gid GTask的唯一标识符(GID)
+ * @param metaInfo 包含元数据的JSON对象
+ */
public void setMeta(String gid, JSONObject metaInfo) {
try {
+ // 在元数据JSON中添加GTASK_ID字段,值为传入的gid
metaInfo.put(GTaskStringUtils.META_HEAD_GTASK_ID, gid);
} catch (JSONException e) {
Log.e(TAG, "failed to put related gid");
}
+ // 将元数据JSON转换为字符串,存储到Task的notes字段
setNotes(metaInfo.toString());
+ // 设置Task的名称为元数据专用名称(常量定义)
setName(GTaskStringUtils.META_NOTE_NAME);
}
+ /**
+ * 获取关联的GTask的GID
+ * @return 关联的GID,若未设置则返回null
+ */
public String getRelatedGid() {
return mRelatedGid;
}
+ /**
+ * 判断元数据是否值得保存(检查notes字段是否存在)
+ * @return true if notes字段不为null,否则false
+ */
@Override
public boolean isWorthSaving() {
return getNotes() != null;
}
+ /**
+ * 从远程JSON数据中解析并设置内容(覆写父类方法)
+ * @param js 包含远程数据的JSON对象
+ */
@Override
public void setContentByRemoteJSON(JSONObject js) {
- super.setContentByRemoteJSON(js);
+ super.setContentByRemoteJSON(js); // 先调用父类实现
if (getNotes() != null) {
try {
+ // 将notes字段解析为JSON对象
JSONObject metaInfo = new JSONObject(getNotes().trim());
+ // 从中提取GTASK_ID作为关联的GID
mRelatedGid = metaInfo.getString(GTaskStringUtils.META_HEAD_GTASK_ID);
} catch (JSONException e) {
Log.w(TAG, "failed to get related gid");
- mRelatedGid = null;
+ mRelatedGid = null; // 解析失败时清空GID
}
}
}
+ /**
+ * 禁止从本地JSON设置内容(覆写父类方法,抛出异常防止调用)
+ * @param js 本地JSON对象(未使用)
+ */
@Override
public void setContentByLocalJSON(JSONObject js) {
- // this function should not be called
throw new IllegalAccessError("MetaData:setContentByLocalJSON should not be called");
}
+ /**
+ * 禁止从内容获取本地JSON(覆写父类方法,抛出异常防止调用)
+ * @return 永远抛出异常,不返回有效数据
+ */
@Override
public JSONObject getLocalJSONFromContent() {
throw new IllegalAccessError("MetaData:getLocalJSONFromContent should not be called");
}
+ /**
+ * 禁止获取同步操作类型(覆写父类方法,抛出异常防止调用)
+ * @param c 数据库游标(未使用)
+ * @return 永远抛出异常,不返回有效数据
+ */
@Override
public int getSyncAction(Cursor c) {
throw new IllegalAccessError("MetaData:getSyncAction should not be called");
}
-
-}
+}
\ No newline at end of file