diff --git a/src/Notes-master3/.gradle/8.0/executionHistory/executionHistory.bin b/src/Notes-master3/.gradle/8.0/executionHistory/executionHistory.bin index 5cc131e..e87d0f1 100644 Binary files a/src/Notes-master3/.gradle/8.0/executionHistory/executionHistory.bin and b/src/Notes-master3/.gradle/8.0/executionHistory/executionHistory.bin differ diff --git a/src/Notes-master3/.gradle/8.0/executionHistory/executionHistory.lock b/src/Notes-master3/.gradle/8.0/executionHistory/executionHistory.lock index e410bdf..ad0f0f6 100644 Binary files a/src/Notes-master3/.gradle/8.0/executionHistory/executionHistory.lock and b/src/Notes-master3/.gradle/8.0/executionHistory/executionHistory.lock differ diff --git a/src/Notes-master3/.gradle/8.0/fileHashes/fileHashes.bin b/src/Notes-master3/.gradle/8.0/fileHashes/fileHashes.bin index 73c095e..f331409 100644 Binary files a/src/Notes-master3/.gradle/8.0/fileHashes/fileHashes.bin and b/src/Notes-master3/.gradle/8.0/fileHashes/fileHashes.bin differ diff --git a/src/Notes-master3/.gradle/8.0/fileHashes/fileHashes.lock b/src/Notes-master3/.gradle/8.0/fileHashes/fileHashes.lock index fc55f66..35ef93b 100644 Binary files a/src/Notes-master3/.gradle/8.0/fileHashes/fileHashes.lock and b/src/Notes-master3/.gradle/8.0/fileHashes/fileHashes.lock differ diff --git a/src/Notes-master3/.gradle/8.0/fileHashes/resourceHashesCache.bin b/src/Notes-master3/.gradle/8.0/fileHashes/resourceHashesCache.bin index cb28049..f827232 100644 Binary files a/src/Notes-master3/.gradle/8.0/fileHashes/resourceHashesCache.bin and b/src/Notes-master3/.gradle/8.0/fileHashes/resourceHashesCache.bin differ diff --git a/src/Notes-master3/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/src/Notes-master3/.gradle/buildOutputCleanup/buildOutputCleanup.lock index b14768d..d46ad7d 100644 Binary files a/src/Notes-master3/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/src/Notes-master3/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/src/Notes-master3/.gradle/file-system.probe b/src/Notes-master3/.gradle/file-system.probe index 1215c76..b90a908 100644 Binary files a/src/Notes-master3/.gradle/file-system.probe and b/src/Notes-master3/.gradle/file-system.probe differ diff --git a/src/Notes-master3/app/build/intermediates/apk/debug/app-debug.apk b/src/Notes-master3/app/build/intermediates/apk/debug/app-debug.apk index b7679ca..7e67352 100644 Binary files a/src/Notes-master3/app/build/intermediates/apk/debug/app-debug.apk and b/src/Notes-master3/app/build/intermediates/apk/debug/app-debug.apk differ diff --git a/src/Notes-master3/app/build/intermediates/dex/debug/mergeDexDebug/classes.dex b/src/Notes-master3/app/build/intermediates/dex/debug/mergeDexDebug/classes.dex index ce46325..01ca583 100644 Binary files a/src/Notes-master3/app/build/intermediates/dex/debug/mergeDexDebug/classes.dex and b/src/Notes-master3/app/build/intermediates/dex/debug/mergeDexDebug/classes.dex differ diff --git a/src/Notes-master3/app/build/intermediates/incremental/packageDebug/tmp/debug/dex-renamer-state.txt b/src/Notes-master3/app/build/intermediates/incremental/packageDebug/tmp/debug/dex-renamer-state.txt index 2d78756..bcfc43e 100644 --- a/src/Notes-master3/app/build/intermediates/incremental/packageDebug/tmp/debug/dex-renamer-state.txt +++ b/src/Notes-master3/app/build/intermediates/incremental/packageDebug/tmp/debug/dex-renamer-state.txt @@ -1,4 +1,4 @@ -#Fri Dec 08 20:44:22 GMT+08:00 2023 +#Sat Dec 09 09:02:30 GMT+08:00 2023 base.0=C\:\\Android\\Notes-master3\\app\\build\\intermediates\\dex\\debug\\mergeDexDebug\\classes.dex path.0=classes.dex renamed.0=classes.dex diff --git a/src/Notes-master3/app/build/intermediates/javac/debug/classes/net/micode/notes/model/Note$NoteData.class b/src/Notes-master3/app/build/intermediates/javac/debug/classes/net/micode/notes/model/Note$NoteData.class index cd94543..65219ec 100644 Binary files a/src/Notes-master3/app/build/intermediates/javac/debug/classes/net/micode/notes/model/Note$NoteData.class and b/src/Notes-master3/app/build/intermediates/javac/debug/classes/net/micode/notes/model/Note$NoteData.class differ diff --git a/src/Notes-master3/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/model/Note$NoteData.dex b/src/Notes-master3/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/model/Note$NoteData.dex index 94f6c69..25cf795 100644 Binary files a/src/Notes-master3/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/model/Note$NoteData.dex and b/src/Notes-master3/app/build/intermediates/project_dex_archive/debug/out/net/micode/notes/model/Note$NoteData.dex differ diff --git a/src/Notes-master3/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/Note$NoteData.class.uniqueId1 b/src/Notes-master3/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/Note$NoteData.class.uniqueId1 deleted file mode 100644 index a78f613..0000000 Binary files a/src/Notes-master3/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/Note$NoteData.class.uniqueId1 and /dev/null differ diff --git a/src/Notes-master3/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/Note.class.uniqueId3 b/src/Notes-master3/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/Note.class.uniqueId3 deleted file mode 100644 index edd0fcd..0000000 Binary files a/src/Notes-master3/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/Note.class.uniqueId3 and /dev/null differ diff --git a/src/Notes-master3/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/WorkingNote$NoteSettingChangedListener.class.uniqueId2 b/src/Notes-master3/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/WorkingNote$NoteSettingChangedListener.class.uniqueId2 deleted file mode 100644 index 15f1f77..0000000 Binary files a/src/Notes-master3/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/WorkingNote$NoteSettingChangedListener.class.uniqueId2 and /dev/null differ diff --git a/src/Notes-master3/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/WorkingNote.class.uniqueId0 b/src/Notes-master3/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/WorkingNote.class.uniqueId0 deleted file mode 100644 index f428211..0000000 Binary files a/src/Notes-master3/app/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/WorkingNote.class.uniqueId0 and /dev/null differ diff --git a/src/Notes-master3/app/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin b/src/Notes-master3/app/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin index 9c34a3d..dd72c52 100644 Binary files a/src/Notes-master3/app/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin and b/src/Notes-master3/app/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin differ diff --git a/src/Notes-master3/app/src/main/java/net/micode/notes/tool/BackupUtils.java b/src/Notes-master3/app/src/main/java/net/micode/notes/tool/BackupUtils.java index 39f6ec4..eb9db4c 100644 --- a/src/Notes-master3/app/src/main/java/net/micode/notes/tool/BackupUtils.java +++ b/src/Notes-master3/app/src/main/java/net/micode/notes/tool/BackupUtils.java @@ -14,38 +14,38 @@ * limitations under the License. */ -package net.micode.notes.tool; - -import android.content.Context; -import android.database.Cursor; -import android.os.Environment; -import android.text.TextUtils; -import android.text.format.DateFormat; -import android.util.Log; - -import net.micode.notes.R; -import net.micode.notes.data.Notes; -import net.micode.notes.data.Notes.DataColumns; -import net.micode.notes.data.Notes.DataConstants; -import net.micode.notes.data.Notes.NoteColumns; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; - - -public class BackupUtils { - private static final String TAG = "BackupUtils"; +package net.micode.notes.tool;// 声明包 + +import android.content.Context;// 导入 Android 的 Context 类 +import android.database.Cursor;// 导入 Android 的 Cursor 类 +import android.os.Environment;// 导入 Android 的 Environment 类 +import android.text.TextUtils;// 导入 Android 的 TextUtils 类 +import android.text.format.DateFormat;// 导入 Android 的 DateFormat 类 +import android.util.Log;// 导入 Android 的 Log 类 + +import net.micode.notes.R;// 导入便签应用的资源类 +import net.micode.notes.data.Notes;// 导入便签应用的 Notes 类 +import net.micode.notes.data.Notes.DataColumns; // 导入便签应用的数据列类 +import net.micode.notes.data.Notes.DataConstants;// 导入便签应用的数据常量类 +import net.micode.notes.data.Notes.NoteColumns;// 导入便签应用的便签列类 + +import java.io.File;// 导入文件类 +import java.io.FileNotFoundException;// 导入文件未找到异常类 +import java.io.FileOutputStream;// 导入文件输出流类 +import java.io.IOException;// 导入 IO 异常类 +import java.io.PrintStream;// 导入打印流类 + + +public class BackupUtils { // 备份工具类定义开始 + private static final String TAG = "BackupUtils";// 定义日志标签 // Singleton stuff - private static BackupUtils sInstance; + private static BackupUtils sInstance; // 单例模式 - public static synchronized BackupUtils getInstance(Context context) { - if (sInstance == null) { - sInstance = new BackupUtils(context); + public static synchronized BackupUtils getInstance(Context context) {// 获取单例实例的方法 + if (sInstance == null) {// 如果实例为空 + sInstance = new BackupUtils(context);// 创建新的实例 } - return sInstance; + return sInstance;// 返回实例 } /** @@ -53,62 +53,62 @@ public class BackupUtils { * status */ // Currently, the sdcard is not mounted - public static final int STATE_SD_CARD_UNMOUONTED = 0; + public static final int STATE_SD_CARD_UNMOUONTED = 0;// 表示当前 SD 卡未挂载 // The backup file not exist - public static final int STATE_BACKUP_FILE_NOT_EXIST = 1; + public static final int STATE_BACKUP_FILE_NOT_EXIST = 1;// 备份文件不存在 // The data is not well formated, may be changed by other programs - public static final int STATE_DATA_DESTROIED = 2; + public static final int STATE_DATA_DESTROIED = 2;// 数据格式损毁,可能被其他程序修改 // Some run-time exception which causes restore or backup fails - public static final int STATE_SYSTEM_ERROR = 3; + public static final int STATE_SYSTEM_ERROR = 3;// 一些运行时异常导致恢复或备份失败 // Backup or restore success - public static final int STATE_SUCCESS = 4; + public static final int STATE_SUCCESS = 4;// 备份或恢复成功 - private TextExport mTextExport; + private TextExport mTextExport;// 文本导出实例 private BackupUtils(Context context) { - mTextExport = new TextExport(context); + mTextExport = new TextExport(context);// 初始化文本导出实例 } - private static boolean externalStorageAvailable() { + private static boolean externalStorageAvailable() {// 检查外部存储是否可用 return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()); } - public int exportToText() { - return mTextExport.exportToText(); + public int exportToText() {// 导出到文本方法 + return mTextExport.exportToText();// 调用文本导出实例的导出方法 } - public String getExportedTextFileName() { - return mTextExport.mFileName; + public String getExportedTextFileName() {// 获取导出的文本文件名 + return mTextExport.mFileName;// 返回导出的文本文件名 } - public String getExportedTextFileDir() { - return mTextExport.mFileDirectory; + public String getExportedTextFileDir() {// 获取导出的文本文件目录 + return mTextExport.mFileDirectory;// 返回导出的文本文件目录 } - private static class TextExport { - private static final String[] NOTE_PROJECTION = { - NoteColumns.ID, - NoteColumns.MODIFIED_DATE, - NoteColumns.SNIPPET, - NoteColumns.TYPE + private static class TextExport {// 定义文本导出类 + private static final String[] NOTE_PROJECTION = {// 笔记投影数组 + NoteColumns.ID,// 笔记 ID + NoteColumns.MODIFIED_DATE, // 修改日期 + NoteColumns.SNIPPET,// 笔记片段 + NoteColumns.TYPE // 笔记类型 }; - private static final int NOTE_COLUMN_ID = 0; + private static final int NOTE_COLUMN_ID = 0;// ID 列索引 - private static final int NOTE_COLUMN_MODIFIED_DATE = 1; + private static final int NOTE_COLUMN_MODIFIED_DATE = 1;// 修改日期列索引 - private static final int NOTE_COLUMN_SNIPPET = 2; + private static final int NOTE_COLUMN_SNIPPET = 2;// 碎片列索引 - private static final String[] DATA_PROJECTION = { - DataColumns.CONTENT, - DataColumns.MIME_TYPE, - DataColumns.DATA1, - DataColumns.DATA2, - DataColumns.DATA3, - DataColumns.DATA4, + private static final String[] DATA_PROJECTION = {// 数据投影数组 + DataColumns.CONTENT,// 内容 + DataColumns.MIME_TYPE,// MIME 类型 + DataColumns.DATA1,// 数据 1 + DataColumns.DATA2,// 数据 2 + DataColumns.DATA3,// 数据 3 + DataColumns.DATA4,// 数据 4 }; - private static final int DATA_COLUMN_CONTENT = 0; + private static final int DATA_COLUMN_CONTENT = 0;// 定义数据列的常量 private static final int DATA_COLUMN_MIME_TYPE = 1; @@ -117,15 +117,15 @@ public class BackupUtils { private static final int DATA_COLUMN_PHONE_NUMBER = 4; private final String [] TEXT_FORMAT; - private static final int FORMAT_FOLDER_NAME = 0; + private static final int FORMAT_FOLDER_NAME = 0;// 定义文本格式的常量 private static final int FORMAT_NOTE_DATE = 1; private static final int FORMAT_NOTE_CONTENT = 2; - private Context mContext; + private Context mContext;// 上下文和文件路径相关变量 private String mFileName; private String mFileDirectory; - public TextExport(Context context) { + public TextExport(Context context) {// 构造函数 TEXT_FORMAT = context.getResources().getStringArray(R.array.format_for_exported_note); mContext = context; mFileName = ""; @@ -134,26 +134,26 @@ public class BackupUtils { private String getFormat(int id) { return TEXT_FORMAT[id]; - } + }// 获取指定格式的文本 /** * Export the folder identified by folder id to text */ - private void exportFolderToText(String folderId, PrintStream ps) { + private void exportFolderToText(String folderId, PrintStream ps) {// 将文件夹导出为文本 // Query notes belong to this folder Cursor notesCursor = mContext.getContentResolver().query(Notes.CONTENT_NOTE_URI, NOTE_PROJECTION, NoteColumns.PARENT_ID + "=?", new String[] { - folderId - }, null); + folderId + }, null); // 查询属于该文件夹的便签 if (notesCursor != null) { if (notesCursor.moveToFirst()) { do { - // Print note's last modified date + // Print note's last modified date// 打印便签的最后修改日期 ps.println(String.format(getFormat(FORMAT_NOTE_DATE), DateFormat.format( mContext.getString(R.string.format_datetime_mdhm), notesCursor.getLong(NOTE_COLUMN_MODIFIED_DATE)))); - // Query data belong to this note + // Query data belong to this note// 查询属于该便签的数据 String noteId = notesCursor.getString(NOTE_COLUMN_ID); exportNoteToText(noteId, ps); } while (notesCursor.moveToNext()); @@ -165,10 +165,10 @@ public class BackupUtils { /** * Export note identified by id to a print stream */ - private void exportNoteToText(String noteId, PrintStream ps) { + private void exportNoteToText(String noteId, PrintStream ps) {// 将便签导出为文本 Cursor dataCursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI, DATA_PROJECTION, DataColumns.NOTE_ID + "=?", new String[] { - noteId + noteId }, null); if (dataCursor != null) { @@ -176,7 +176,7 @@ public class BackupUtils { do { String mimeType = dataCursor.getString(DATA_COLUMN_MIME_TYPE); if (DataConstants.CALL_NOTE.equals(mimeType)) { - // Print phone number + // Print phone number// 打印电话号码 String phoneNumber = dataCursor.getString(DATA_COLUMN_PHONE_NUMBER); long callDate = dataCursor.getLong(DATA_COLUMN_CALL_DATE); String location = dataCursor.getString(DATA_COLUMN_CONTENT); @@ -185,11 +185,11 @@ public class BackupUtils { ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT), phoneNumber)); } - // Print call date + // Print call date// 打印通话日期 ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT), DateFormat .format(mContext.getString(R.string.format_datetime_mdhm), callDate))); - // Print call attachment location + // Print call attachment location// 打印通话附件位置 if (!TextUtils.isEmpty(location)) { ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT), location)); @@ -205,7 +205,7 @@ public class BackupUtils { } dataCursor.close(); } - // print a line separator between note + // print a line separator between note// 在便签之间加上一行分隔符 try { ps.write(new byte[] { Character.LINE_SEPARATOR, Character.LETTER_NUMBER @@ -218,18 +218,18 @@ public class BackupUtils { /** * Note will be exported as text which is user readable */ - public int exportToText() { + public int exportToText() {// 检查外部存储是否可用 if (!externalStorageAvailable()) { Log.d(TAG, "Media was not mounted"); return STATE_SD_CARD_UNMOUONTED; } - + // 获取导出文本的打印流 PrintStream ps = getExportToTextPrintStream(); if (ps == null) { Log.e(TAG, "get print stream error"); return STATE_SYSTEM_ERROR; } - // First export folder and its notes + // First export folder and its notes// 首先导出文件夹及其笔记 Cursor folderCursor = mContext.getContentResolver().query( Notes.CONTENT_NOTE_URI, NOTE_PROJECTION, @@ -240,7 +240,7 @@ public class BackupUtils { if (folderCursor != null) { if (folderCursor.moveToFirst()) { do { - // Print folder's name + // Print folder's 打印文件夹名称 String folderName = ""; if(folderCursor.getLong(NOTE_COLUMN_ID) == Notes.ID_CALL_RECORD_FOLDER) { folderName = mContext.getString(R.string.call_record_folder_name); @@ -257,7 +257,7 @@ public class BackupUtils { folderCursor.close(); } - // Export notes in root's folder + // Export notes in root's folder// 导出根文件夹中的笔记 Cursor noteCursor = mContext.getContentResolver().query( Notes.CONTENT_NOTE_URI, NOTE_PROJECTION, diff --git a/src/Notes-master3/app/src/main/java/net/micode/notes/tool/DataUtils.java b/src/Notes-master3/app/src/main/java/net/micode/notes/tool/DataUtils.java index 2a14982..371c5d4 100644 --- a/src/Notes-master3/app/src/main/java/net/micode/notes/tool/DataUtils.java +++ b/src/Notes-master3/app/src/main/java/net/micode/notes/tool/DataUtils.java @@ -35,78 +35,78 @@ import java.util.ArrayList; import java.util.HashSet; -public class DataUtils { +public class DataUtils {// 定义日志标签 public static final String TAG = "DataUtils"; - public static boolean batchDeleteNotes(ContentResolver resolver, HashSet ids) { + public static boolean batchDeleteNotes(ContentResolver resolver, HashSet ids) {// 批量删除笔记的方法 if (ids == null) { - Log.d(TAG, "the ids is null"); + Log.d(TAG, "the ids is null");// 记录日志,ids 为空 return true; } if (ids.size() == 0) { - Log.d(TAG, "no id is in the hashset"); + Log.d(TAG, "no id is in the hashset");// 记录日志,ids 集合中没有 ID return true; } - ArrayList operationList = new ArrayList(); - for (long id : ids) { + ArrayList operationList = new ArrayList();// 创建操作列表 + for (long id : ids) {// 遍历需要删除的 ID,并创建对应的删除操作 if(id == Notes.ID_ROOT_FOLDER) { Log.e(TAG, "Don't delete system folder root"); - continue; + continue;// 如果是系统文件夹的 ID,则跳过不执行删除操作 } ContentProviderOperation.Builder builder = ContentProviderOperation - .newDelete(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id)); - operationList.add(builder.build()); + .newDelete(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id));// 创建删除操作 + operationList.add(builder.build());// 将操作添加到操作列表 } try { - ContentProviderResult[] results = resolver.applyBatch(Notes.AUTHORITY, operationList); + ContentProviderResult[] results = resolver.applyBatch(Notes.AUTHORITY, operationList);// 应用批量操作 if (results == null || results.length == 0 || results[0] == null) { - Log.d(TAG, "delete notes failed, ids:" + ids.toString()); + Log.d(TAG, "delete notes failed, ids:" + ids.toString());// 记录日志,删除失败 return false; } return true; } catch (RemoteException e) { - Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage())); + Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));// 记录远程异常日志 } catch (OperationApplicationException e) { - Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage())); + Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));// 记录操作异常日志 } return false; } - public static void moveNoteToFoler(ContentResolver resolver, long id, long srcFolderId, long desFolderId) { - ContentValues values = new ContentValues(); - values.put(NoteColumns.PARENT_ID, desFolderId); - values.put(NoteColumns.ORIGIN_PARENT_ID, srcFolderId); - values.put(NoteColumns.LOCAL_MODIFIED, 1); - resolver.update(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id), values, null, null); + public static void moveNoteToFoler(ContentResolver resolver, long id, long srcFolderId, long desFolderId) {// 移动笔记到文件夹的方法 + ContentValues values = new ContentValues();// 创建内容值对象 + values.put(NoteColumns.PARENT_ID, desFolderId);// 设置父文件夹 ID + values.put(NoteColumns.ORIGIN_PARENT_ID, srcFolderId);// 设置原始父文件夹 ID + values.put(NoteColumns.LOCAL_MODIFIED, 1);// 设置本地修改标志 + resolver.update(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id), values, null, null);// 执行更新操作 } - public static boolean batchMoveToFolder(ContentResolver resolver, HashSet ids, - long folderId) { + public static boolean batchMoveToFolder(ContentResolver resolver, HashSet ids,// 批量移动笔记到文件夹的方法 + long folderId) { if (ids == null) { - Log.d(TAG, "the ids is null"); + Log.d(TAG, "the ids is null");// 记录日志,ids 为空 return true; } - ArrayList operationList = new ArrayList(); + ArrayList operationList = new ArrayList();// 遍历需要移动的笔记 ID,并创建对应的更新操作 for (long id : ids) { ContentProviderOperation.Builder builder = ContentProviderOperation - .newUpdate(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id)); - builder.withValue(NoteColumns.PARENT_ID, folderId); - builder.withValue(NoteColumns.LOCAL_MODIFIED, 1); - operationList.add(builder.build()); + .newUpdate(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id));// 创建更新操作 + builder.withValue(NoteColumns.PARENT_ID, folderId);// 设置父文件夹 ID + builder.withValue(NoteColumns.LOCAL_MODIFIED, 1);// 设置本地修改标志 + operationList.add(builder.build());// 将操作添加到操作列表 } try { - ContentProviderResult[] results = resolver.applyBatch(Notes.AUTHORITY, operationList); + ContentProviderResult[] results = resolver.applyBatch(Notes.AUTHORITY, operationList);// 应用批量操作 if (results == null || results.length == 0 || results[0] == null) { - Log.d(TAG, "delete notes failed, ids:" + ids.toString()); + Log.d(TAG, "delete notes failed, ids:" + ids.toString());// 记录日志,删除失败 return false; } return true; } catch (RemoteException e) { - Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage())); + Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));// 记录远程异常日志 } catch (OperationApplicationException e) { - Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage())); + Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));// 记录操作异常日志 } return false; } @@ -114,9 +114,9 @@ public class DataUtils { /** * Get the all folder count except system folders {@link Notes#TYPE_SYSTEM}} */ - public static int getUserFolderCount(ContentResolver resolver) { + public static int getUserFolderCount(ContentResolver resolver) {// 获取用户文件夹数量(排除系统文件夹) Cursor cursor =resolver.query(Notes.CONTENT_NOTE_URI, - new String[] { "COUNT(*)" }, + new String[] { "COUNT(*)" },// 查询结果为数量 NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>?", new String[] { String.valueOf(Notes.TYPE_FOLDER), String.valueOf(Notes.ID_TRASH_FOLER)}, null); @@ -125,26 +125,26 @@ public class DataUtils { if(cursor != null) { if(cursor.moveToFirst()) { try { - count = cursor.getInt(0); + count = cursor.getInt(0);// 获取数量 } catch (IndexOutOfBoundsException e) { - Log.e(TAG, "get folder count failed:" + e.toString()); + Log.e(TAG, "get folder count failed:" + e.toString());// 记录日志,获取数量失败 } finally { - cursor.close(); + cursor.close();// 关闭游标 } } } return count; } - public static boolean visibleInNoteDatabase(ContentResolver resolver, long noteId, int type) { + public static boolean visibleInNoteDatabase(ContentResolver resolver, long noteId, int type) {// 查询指定ID的笔记,根据类型和父ID条件进行筛选 Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId), null, - NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER, + NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER,// 传入需要查找的类型 new String [] {String.valueOf(type)}, null); boolean exist = false; - if (cursor != null) { + if (cursor != null) {// 判断是否存在记录 if (cursor.getCount() > 0) { exist = true; } @@ -154,11 +154,11 @@ public class DataUtils { } public static boolean existInNoteDatabase(ContentResolver resolver, long noteId) { - Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId), + Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId),// 查询指定ID的笔记 null, null, null, null); boolean exist = false; - if (cursor != null) { + if (cursor != null) {// 判断是否存在记录 if (cursor.getCount() > 0) { exist = true; } @@ -167,12 +167,12 @@ public class DataUtils { return exist; } - public static boolean existInDataDatabase(ContentResolver resolver, long dataId) { + public static boolean existInDataDatabase(ContentResolver resolver, long dataId) {// 查询指定ID的数据 Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_DATA_URI, dataId), null, null, null, null); boolean exist = false; - if (cursor != null) { + if (cursor != null) {// 判断是否存在记录 if (cursor.getCount() > 0) { exist = true; } @@ -181,14 +181,14 @@ public class DataUtils { return exist; } - public static boolean checkVisibleFolderName(ContentResolver resolver, String name) { + public static boolean checkVisibleFolderName(ContentResolver resolver, String name) {// 查询非回收站中特定名称的文件夹笔记 Cursor cursor = resolver.query(Notes.CONTENT_NOTE_URI, null, NoteColumns.TYPE + "=" + Notes.TYPE_FOLDER + - " AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER + - " AND " + NoteColumns.SNIPPET + "=?", + " AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER + + " AND " + NoteColumns.SNIPPET + "=?",// 传入需要查找的名称 new String[] { name }, null); boolean exist = false; - if(cursor != null) { + if(cursor != null) {// 判断是否存在记录 if(cursor.getCount() > 0) { exist = true; } @@ -197,10 +197,10 @@ public class DataUtils { return exist; } - public static HashSet getFolderNoteWidget(ContentResolver resolver, long folderId) { + public static HashSet getFolderNoteWidget(ContentResolver resolver, long folderId) {// 获取文件夹笔记的小部件数据 Cursor c = resolver.query(Notes.CONTENT_NOTE_URI, new String[] { NoteColumns.WIDGET_ID, NoteColumns.WIDGET_TYPE }, - NoteColumns.PARENT_ID + "=?", + NoteColumns.PARENT_ID + "=?",// 传入文件夹ID new String[] { String.valueOf(folderId) }, null); @@ -224,15 +224,15 @@ public class DataUtils { return set; } - public static String getCallNumberByNoteId(ContentResolver resolver, long noteId) { + public static String getCallNumberByNoteId(ContentResolver resolver, long noteId) {// 通过笔记ID获取电话号码 Cursor cursor = resolver.query(Notes.CONTENT_DATA_URI, new String [] { CallNote.PHONE_NUMBER }, - CallNote.NOTE_ID + "=? AND " + CallNote.MIME_TYPE + "=?", + CallNote.NOTE_ID + "=? AND " + CallNote.MIME_TYPE + "=?",// 传入笔记ID和MIME类型 new String [] { String.valueOf(noteId), CallNote.CONTENT_ITEM_TYPE }, null); if (cursor != null && cursor.moveToFirst()) { - try { + try {// 返回电话号码 return cursor.getString(0); } catch (IndexOutOfBoundsException e) { Log.e(TAG, "Get call number fails " + e.toString()); @@ -243,17 +243,17 @@ public class DataUtils { return ""; } - public static long getNoteIdByPhoneNumberAndCallDate(ContentResolver resolver, String phoneNumber, long callDate) { + public static long getNoteIdByPhoneNumberAndCallDate(ContentResolver resolver, String phoneNumber, long callDate) {// 通过电话号码和通话日期获取笔记ID Cursor cursor = resolver.query(Notes.CONTENT_DATA_URI, new String [] { CallNote.NOTE_ID }, CallNote.CALL_DATE + "=? AND " + CallNote.MIME_TYPE + "=? AND PHONE_NUMBERS_EQUAL(" - + CallNote.PHONE_NUMBER + ",?)", + + CallNote.PHONE_NUMBER + ",?)",// 传入通话日期、MIME类型和电话号码 new String [] { String.valueOf(callDate), CallNote.CONTENT_ITEM_TYPE, phoneNumber }, null); if (cursor != null) { if (cursor.moveToFirst()) { - try { + try {// 返回笔记ID return cursor.getLong(0); } catch (IndexOutOfBoundsException e) { Log.e(TAG, "Get call note id fails " + e.toString()); @@ -264,10 +264,10 @@ public class DataUtils { return 0; } - public static String getSnippetById(ContentResolver resolver, long noteId) { + public static String getSnippetById(ContentResolver resolver, long noteId) {// 通过笔记ID获取摘要内容 Cursor cursor = resolver.query(Notes.CONTENT_NOTE_URI, new String [] { NoteColumns.SNIPPET }, - NoteColumns.ID + "=?", + NoteColumns.ID + "=?",// 传入笔记ID new String [] { String.valueOf(noteId)}, null); @@ -282,7 +282,7 @@ public class DataUtils { throw new IllegalArgumentException("Note is not found with id: " + noteId); } - public static String getFormattedSnippet(String snippet) { + public static String getFormattedSnippet(String snippet) {// 对摘要内容进行格式化处理 if (snippet != null) { snippet = snippet.trim(); int index = snippet.indexOf('\n'); diff --git a/src/Notes-master3/app/src/main/java/net/micode/notes/tool/ResourceParser.java b/src/Notes-master3/app/src/main/java/net/micode/notes/tool/ResourceParser.java index 1ad3ad6..2de1a4d 100644 --- a/src/Notes-master3/app/src/main/java/net/micode/notes/tool/ResourceParser.java +++ b/src/Notes-master3/app/src/main/java/net/micode/notes/tool/ResourceParser.java @@ -41,19 +41,19 @@ public class ResourceParser { public static class NoteBgResources { private final static int [] BG_EDIT_RESOURCES = new int [] { - R.drawable.edit_yellow, - R.drawable.edit_blue, - R.drawable.edit_white, - R.drawable.edit_green, - R.drawable.edit_red + R.drawable.edit_yellow, + R.drawable.edit_blue, + R.drawable.edit_white, + R.drawable.edit_green, + R.drawable.edit_red }; private final static int [] BG_EDIT_TITLE_RESOURCES = new int [] { - R.drawable.edit_title_yellow, - R.drawable.edit_title_blue, - R.drawable.edit_title_white, - R.drawable.edit_title_green, - R.drawable.edit_title_red + R.drawable.edit_title_yellow, + R.drawable.edit_title_blue, + R.drawable.edit_title_white, + R.drawable.edit_title_green, + R.drawable.edit_title_red }; public static int getNoteBgResource(int id) { @@ -76,35 +76,35 @@ public class ResourceParser { public static class NoteItemBgResources { private final static int [] BG_FIRST_RESOURCES = new int [] { - R.drawable.list_yellow_up, - R.drawable.list_blue_up, - R.drawable.list_white_up, - R.drawable.list_green_up, - R.drawable.list_red_up + R.drawable.list_yellow_up, + R.drawable.list_blue_up, + R.drawable.list_white_up, + R.drawable.list_green_up, + R.drawable.list_red_up }; private final static int [] BG_NORMAL_RESOURCES = new int [] { - R.drawable.list_yellow_middle, - R.drawable.list_blue_middle, - R.drawable.list_white_middle, - R.drawable.list_green_middle, - R.drawable.list_red_middle + R.drawable.list_yellow_middle, + R.drawable.list_blue_middle, + R.drawable.list_white_middle, + R.drawable.list_green_middle, + R.drawable.list_red_middle }; private final static int [] BG_LAST_RESOURCES = new int [] { - R.drawable.list_yellow_down, - R.drawable.list_blue_down, - R.drawable.list_white_down, - R.drawable.list_green_down, - R.drawable.list_red_down, + R.drawable.list_yellow_down, + R.drawable.list_blue_down, + R.drawable.list_white_down, + R.drawable.list_green_down, + R.drawable.list_red_down, }; private final static int [] BG_SINGLE_RESOURCES = new int [] { - R.drawable.list_yellow_single, - R.drawable.list_blue_single, - R.drawable.list_white_single, - R.drawable.list_green_single, - R.drawable.list_red_single + R.drawable.list_yellow_single, + R.drawable.list_blue_single, + R.drawable.list_white_single, + R.drawable.list_green_single, + R.drawable.list_red_single }; public static int getNoteBgFirstRes(int id) { @@ -130,11 +130,11 @@ public class ResourceParser { public static class WidgetBgResources { private final static int [] BG_2X_RESOURCES = new int [] { - R.drawable.widget_2x_yellow, - R.drawable.widget_2x_blue, - R.drawable.widget_2x_white, - R.drawable.widget_2x_green, - R.drawable.widget_2x_red, + R.drawable.widget_2x_yellow, + R.drawable.widget_2x_blue, + R.drawable.widget_2x_white, + R.drawable.widget_2x_green, + R.drawable.widget_2x_red, }; public static int getWidget2xBgResource(int id) { @@ -142,11 +142,11 @@ public class ResourceParser { } private final static int [] BG_4X_RESOURCES = new int [] { - R.drawable.widget_4x_yellow, - R.drawable.widget_4x_blue, - R.drawable.widget_4x_white, - R.drawable.widget_4x_green, - R.drawable.widget_4x_red + R.drawable.widget_4x_yellow, + R.drawable.widget_4x_blue, + R.drawable.widget_4x_white, + R.drawable.widget_4x_green, + R.drawable.widget_4x_red }; public static int getWidget4xBgResource(int id) { @@ -156,10 +156,10 @@ public class ResourceParser { public static class TextAppearanceResources { private final static int [] TEXTAPPEARANCE_RESOURCES = new int [] { - R.style.TextAppearanceNormal, - R.style.TextAppearanceMedium, - R.style.TextAppearanceLarge, - R.style.TextAppearanceSuper + R.style.TextAppearanceNormal, + R.style.TextAppearanceMedium, + R.style.TextAppearanceLarge, + R.style.TextAppearanceSuper }; public static int getTexAppearanceResource(int id) {