李秋锦——提交注释

pull/7/head
名称 6 months ago
parent 2c22ada31e
commit bb06a39cee

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/src.iml" filepath="$PROJECT_DIR$/.idea/src.iml" />
</modules>
</component>
</project>

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/app/src/main/java/net/micode/notes/data/Notes.java" charset="GBK" />
<file url="PROJECT" charset="GBK" />
</component>
</project>

@ -1,10 +1,7 @@
# 小米便签
**小组成员**:张国良(组长) 李秋锦 龚豪
# 小米便签_Note1
#### 任务介绍
2024年软件工程实验——小米便签实现功能分析
2023软件工程大作业——小米便签实现功能分析
1. 实现源码的分析构建,了解基础的架构设计;
2. 对部分初始功能实现完善;
3. 内容加密:对用户在便签上写的内容进行加密,综合运用信息安全技术;
@ -20,3 +17,32 @@
7. 录音为音频便签文件保存到本地;
8. 便签内容模糊搜索和文本过滤
9. 便签内容一键清除与重写
#### 未完成功能:
1. 登陆注册以及密码验证;
2. 账户数据同步备份;
3. 文本导出以及账户设置;
#### 软件架构
后续补充~
#### 使用说明
1. 配置安装Android Studio后运行即可。参考文章https://blog.csdn.net/qq_38436214/article/details/105073213
2. 小米便签初步分析以及架构流程。参考文章https://www.cnblogs.com/appletree24/p/17180883.html#noteslistitemjava
#### 参与贡献
1. Fork 本仓库
2. 新建 Feat_xxx 分支
3. 提交代码
4. 新建 Pull Request
#### 特技
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

@ -1,4 +1,4 @@
#Mon Jun 03 18:57:13 CST 2024
#Fri Jun 14 17:22:29 CST 2024
C\:\\RGDL\\ReadCodeAndAnalyse\\src\\Notesmaster\\app\\build\\intermediates\\incremental\\mergeDebugResources\\stripped.dir\\layout\\account_dialog_title.xml=C\:\\RGDL\\ReadCodeAndAnalyse\\src\\Notesmaster\\app\\build\\intermediates\\merged_res\\debug\\layout_account_dialog_title.xml.flat
C\:\\RGDL\\ReadCodeAndAnalyse\\src\\Notesmaster\\app\\build\\intermediates\\incremental\\mergeDebugResources\\stripped.dir\\layout\\acticity_word.xml=C\:\\RGDL\\ReadCodeAndAnalyse\\src\\Notesmaster\\app\\build\\intermediates\\merged_res\\debug\\layout_acticity_word.xml.flat
C\:\\RGDL\\ReadCodeAndAnalyse\\src\\Notesmaster\\app\\build\\intermediates\\incremental\\mergeDebugResources\\stripped.dir\\layout\\activity_splash.xml=C\:\\RGDL\\ReadCodeAndAnalyse\\src\\Notesmaster\\app\\build\\intermediates\\merged_res\\debug\\layout_activity_splash.xml.flat

@ -1,4 +1,4 @@
#Mon Jun 03 18:57:31 CST 2024
#Fri Jun 14 17:25:48 CST 2024
base.0=C\:\\RGDL\\ReadCodeAndAnalyse\\src\\Notesmaster\\app\\build\\intermediates\\dex\\debug\\mergeDexDebug\\classes.dex
path.0=classes.dex
renamed.0=classes.dex

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" default="true" project-jdk-name="20" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/notes.iml" filepath="$PROJECT_DIR$/notes.iml" />
</modules>
</component>
</project>

@ -1,19 +1,3 @@
/*
* 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
*
* 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.data;
import android.content.Context;
@ -26,50 +10,50 @@ import android.util.Log;
import java.util.HashMap;
public class Contact {
private static HashMap<String, String> sContactCache;
private static final String TAG = "Contact";
private static HashMap<String, String> sContactCache; // 联系人缓存
private static final String TAG = "Contact"; // 标记为联系人
private static final String CALLER_ID_SELECTION = "PHONE_NUMBERS_EQUAL(" + Phone.NUMBER
+ ",?) AND " + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'"
+ " AND " + Data.RAW_CONTACT_ID + " IN "
+ ",?) AND " + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'" // 选择ID的查询条件
+ " AND " + Data.RAW_CONTACT_ID + " IN "
+ "(SELECT raw_contact_id "
+ " FROM phone_lookup"
+ " WHERE min_match = '+')";
+ " WHERE min_match = '+')"; // 原始联系人ID查询条件
//TODO
//识别电话号码
public static String getContact(Context context, String phoneNumber) {
if(sContactCache == null) {
sContactCache = new HashMap<String, String>();
public static String getContact(Context context, String phoneNumber) { // 获取联系人信息
if(sContactCache == null) { // 如果联系人缓存为空
sContactCache = new HashMap<String, String>(); // 创建联系人缓存
}
if(sContactCache.containsKey(phoneNumber)) {
return sContactCache.get(phoneNumber);
if(sContactCache.containsKey(phoneNumber)) { // 如果联系人缓存包含该电话号码
return sContactCache.get(phoneNumber); // 返回缓存中的联系人信息
}
String selection = CALLER_ID_SELECTION.replace("+",
PhoneNumberUtils.toCallerIDMinMatch(phoneNumber));
PhoneNumberUtils.toCallerIDMinMatch(phoneNumber)); // 替换查询条件中的+
Cursor cursor = context.getContentResolver().query(
Data.CONTENT_URI,
new String [] { Phone.DISPLAY_NAME },
selection,
new String[] { phoneNumber },
null);
null); // 通过内容解析器查询联系人信息
if (cursor != null && cursor.moveToFirst()) {
if (cursor != null && cursor.moveToFirst()) { // 如果查询结果不为空且移动到第一条记录
try {
String name = cursor.getString(0);
sContactCache.put(phoneNumber, name);
return name;
String name = cursor.getString(0); // 获取联系人姓名
sContactCache.put(phoneNumber, name); // 将联系人信息放入缓存
return name; // 返回联系人姓名
} catch (IndexOutOfBoundsException e) {
Log.e(TAG, " Cursor get string error " + e.toString());
return null;
Log.e(TAG, " Cursor get string error " + e.toString()); // 捕获索引越界异常并记录日志
return null; // 返回空值
} finally {
cursor.close();
cursor.close(); // 关闭游标
}
} else {
Log.d(TAG, "No contact matched with number:" + phoneNumber);
return null;
Log.d(TAG, "No contact matched with number:" + phoneNumber); // 记录日志,未找到匹配的联系人
return null; // 返回空值
}
}
}

@ -19,15 +19,11 @@ import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class DataFetch extends AppCompatActivity {
/***
*
* @param strFile
* @return
*/
// 判断文件是否存在
public boolean fileIsExists(Context context, String strFile) {
boolean fileExistFlag;
try{
context.openFileInput(strFile);
context.openFileInput(strFile); // 打开文件输入流
fileExistFlag = true;
} catch (FileNotFoundException e){
fileExistFlag = false;
@ -35,45 +31,35 @@ public class DataFetch extends AppCompatActivity {
return fileExistFlag;
}
/**
*
* @param context
* @param file_name
* @param key
*/
// 文件内容写函数
public void writeFile(Context context, String file_name, String key){
try {
FileOutputStream fos = context.openFileOutput(file_name, Context.MODE_PRIVATE);
OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
osw.write(key);
osw.flush();
FileOutputStream fos = context.openFileOutput(file_name, Context.MODE_PRIVATE); // 打开文件输出流
OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8"); // 创建输出流写入器
osw.write(key); // 写入内容
osw.flush(); // 刷新写入器
fos.flush(); //输出缓冲区中所有的内容
osw.close();
fos.close();
osw.close(); // 关闭写入器
fos.close(); // 关闭输出流
} catch (Exception e) {
e.printStackTrace();
}
}
/**
*
* @param context
* @param filename
*/
// 文件内容读取函数
public String readFile(Context context, String filename) {
try {
FileInputStream fis = context.openFileInput(filename);
InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
FileInputStream fis = context.openFileInput(filename); // 打开文件输入流
InputStreamReader isr = new InputStreamReader(fis, "UTF-8"); // 创建输入流读取器
char[] input = new char[fis.available()]; //available()用于获取filename内容的长度,但是对中文有问题建议使用BufferReader
isr.read(input); //读取并存储到input中
isr.close();
isr.close(); // 关闭读取器
fis.close();//读取完成后关闭
String str = new String(input);
return str;
String str = new String(input); // 将字符数组转换为字符串
return str; // 返回读取的字符串
} catch (Exception e) {
e.printStackTrace();
e.printStackTrace(); // 打印异常信息
}
return "error";
return "error"; // 返回错误信息
}
}

@ -20,9 +20,9 @@ import android.net.Uri;
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
@ -42,9 +42,9 @@ public class Notes {
public static final String INTENT_EXTRA_FOLDER_ID = "net.micode.notes.folder_id";
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;
public static final int TYPE_WIDGET_2X = 0;
public static final int TYPE_WIDGET_4X = 1;
public static class DataConstants {
public static final String NOTE = TextNote.CONTENT_ITEM_TYPE;
@ -246,15 +246,15 @@ public class Notes {
* Mode to indicate the text in check list mode or not
* <P> Type: Integer 1:check list mode 0: normal mode </P>
*/
public static final String MODE = DATA1;
public static final String MODE = DATA1; // 用于指示文本是否处于检查列表模式的模式
public static final int MODE_CHECK_LIST = 1;
public static final int MODE_CHECK_LIST = 1; // 检查列表模式的值为1
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/text_note";
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";
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/text_note"; // 内容类型为文本笔记的项目类型
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note");
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note"); // 内容URI
}
public static final class CallNote implements DataColumns {
@ -262,18 +262,18 @@ public class Notes {
* Call date for this record
* <P> Type: INTEGER (long) </P>
*/
public static final String CALL_DATE = DATA1;
public static final String CALL_DATE = DATA1; // 该记录的通话日期
/**
* Phone number for this record
* <P> Type: TEXT </P>
*/
public static final String PHONE_NUMBER = DATA3;
public static final String PHONE_NUMBER = DATA3; // 该记录的电话号码
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/call_note";
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";
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/call_note"; // 内容类型为通话笔记的项目类型
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/call_note");
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/call_note"); // 内容URI
}
}

@ -81,13 +81,15 @@ public class NotesProvider extends ContentProvider {
@Override
public boolean onCreate() {
// 在创建时,获取数据库帮助类的实例
mHelper = NotesDatabaseHelper.getInstance(getContext());
return true;
}
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder) {
String sortOrder) {
// 查询方法用于查询URI、投影、选择、选择参数和排序
Cursor c = null;
SQLiteDatabase db = mHelper.getReadableDatabase();
String id = null;
@ -149,6 +151,7 @@ public class NotesProvider extends ContentProvider {
@Override
public Uri insert(Uri uri, ContentValues values) {
// 插入方法用于插入URI和内容值
SQLiteDatabase db = mHelper.getWritableDatabase();
long dataId = 0, noteId = 0, insertedId = 0;
switch (mMatcher.match(uri)) {
@ -166,13 +169,13 @@ public class NotesProvider extends ContentProvider {
default:
throw new IllegalArgumentException("Unknown URI " + uri);
}
// Notify the note uri
// 通知笔记URI
if (noteId > 0) {
getContext().getContentResolver().notifyChange(
ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId), null);
}
// Notify the data uri
// 通知数据URI
if (dataId > 0) {
getContext().getContentResolver().notifyChange(
ContentUris.withAppendedId(Notes.CONTENT_DATA_URI, dataId), null);
@ -183,6 +186,7 @@ public class NotesProvider extends ContentProvider {
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
// 删除方法用于删除URI、选择和选择参数
int count = 0;
String id = null;
SQLiteDatabase db = mHelper.getWritableDatabase();
@ -229,6 +233,7 @@ public class NotesProvider extends ContentProvider {
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
// 更新方法用于更新URI、内容值、选择和选择参数
int count = 0;
String id = null;
SQLiteDatabase db = mHelper.getWritableDatabase();
@ -268,10 +273,12 @@ public class NotesProvider extends ContentProvider {
}
private String parseSelection(String selection) {
// 解析选择方法,用于解析选择
return (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : "");
}
private void increaseNoteVersion(long id, String selection, String[] selectionArgs) {
// 定义一个方法,用于增加笔记版本号
StringBuilder sql = new StringBuilder(120);
sql.append("UPDATE ");
sql.append(TABLE.NOTE);
@ -279,6 +286,7 @@ public class NotesProvider extends ContentProvider {
sql.append(NoteColumns.VERSION);
sql.append("=" + NoteColumns.VERSION + "+1 ");
// 添加更新的条件
if (id > 0 || !TextUtils.isEmpty(selection)) {
sql.append(" WHERE ");
}
@ -293,6 +301,7 @@ public class NotesProvider extends ContentProvider {
sql.append(selectString);
}
// 执行SQL查询
mHelper.getWritableDatabase().execSQL(sql.toString());
}

@ -24,12 +24,12 @@ import net.micode.notes.tool.GTaskStringUtils;
import org.json.JSONException;
import org.json.JSONObject;
// 元数据类,继承自任务类
public class MetaData extends Task {
private final static String TAG = MetaData.class.getSimpleName();
private String mRelatedGid = null;
// 设置元数据信息
public void setMeta(String gid, JSONObject metaInfo) {
try {
metaInfo.put(GTaskStringUtils.META_HEAD_GTASK_ID, gid);
@ -39,7 +39,7 @@ public class MetaData extends Task {
setNotes(metaInfo.toString());
setName(GTaskStringUtils.META_NOTE_NAME);
}
// 获取相关的GID
public String getRelatedGid() {
return mRelatedGid;
}
@ -48,7 +48,7 @@ public class MetaData extends Task {
public boolean isWorthSaving() {
return getNotes() != null;
}
// 设置元数据信息
@Override
public void setContentByRemoteJSON(JSONObject js) {
super.setContentByRemoteJSON(js);
@ -62,7 +62,7 @@ public class MetaData extends Task {
}
}
}
// 不应调用此函数
@Override
public void setContentByLocalJSON(JSONObject js) {
// this function should not be called

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" packagePrefix="net.micode.notes" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Loading…
Cancel
Save