main
qijingxi 7 months ago
parent 256c40451a
commit 351c102dcf

@ -14,6 +14,19 @@
* limitations under the License. * limitations under the License.
*/ */
/**
*
* @ProjectName: minode
* @Package: net.micode.notes.data
* @ClassName: BackupUtils
* @Description:
便
* @Author:
*/
package net.micode.notes.tool; package net.micode.notes.tool;
public class BackupUtils { public class BackupUtils {
@ -21,6 +34,16 @@
// Singleton stuff // Singleton stuff
private static BackupUtils sInstance; //类里面为什么可以定义自身类的对象? private static BackupUtils sInstance; //类里面为什么可以定义自身类的对象?
/**
* @method getInstance
* @description BackupUtils
* @author:
*/
/*
context访
BackupUtils */
public static synchronized BackupUtils getInstance(Context context) { public static synchronized BackupUtils getInstance(Context context) {
//ynchronized 关键字,代表这个方法加锁,相当于不管哪一个线程例如线程A //ynchronized 关键字,代表这个方法加锁,相当于不管哪一个线程例如线程A
//运行到这个方法时,都要检查有没有其它线程B或者C、 D等正在用这个方法(或者该类的其他同步方法)有的话要等正在使用synchronized方法的线程B或者C 、D运行完这个方法后再运行此线程A,没有的话,锁定调用者,然后直接运行。 //运行到这个方法时,都要检查有没有其它线程B或者C、 D等正在用这个方法(或者该类的其他同步方法)有的话要等正在使用synchronized方法的线程B或者C 、D运行完这个方法后再运行此线程A,没有的话,锁定调用者,然后直接运行。
@ -53,18 +76,67 @@
mTextExport = new TextExport(context); mTextExport = new TextExport(context);
} }
/**
* @method externalStorageAvailable
* @description Environment.MEDIA_MOUNTED
* @author:
*/
/*
context访
BackupUtils
Environment.MEDIA_MOUNTED
true false */
private static boolean externalStorageAvailable() { //外部存储功能是否可用 private static boolean externalStorageAvailable() { //外部存储功能是否可用
return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()); return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
} }
/**
* @method exportToText
* @description TextExport exportToText
* @author:
*/
/*
context访
BackupUtils
TextExport exportToText
STATE_SUCCESS STATE_SD_CARD_UNMOUONTED */
public int exportToText() { public int exportToText() {
return mTextExport.exportToText(); return mTextExport.exportToText();
} }
/**
* @method getExportedTextFileName
* @description TextExport
TextExport exportToText
* @author:
*/
/*
context访
BackupUtils
TextExport exportToText
STATE_SUCCESS STATE_SD_CARD_UNMOUONTED
TextExport
*/
public String getExportedTextFileName() { public String getExportedTextFileName() {
return mTextExport.mFileName; return mTextExport.mFileName;
} }
/**
* @method getExportedTextFileDir
* @description TextExport
TextExport exportToText
* @author:
*/
/*
context访
TextExport
STATE_SUCCESS STATE_SD_CARD_UNMOUONTED
TextExport
*/
public String getExportedTextFileDir() { public String getExportedTextFileDir() {
return mTextExport.mFileDirectory; return mTextExport.mFileDirectory;
} }
@ -109,6 +181,20 @@
private String mFileName; private String mFileName;
private String mFileDirectory; private String mFileDirectory;
/**
* @method getExportedTextFileDir
* @description
TextExport
TextExport exportToText
* @author:
*/
/*
context访
TextExport
STATE_SUCCESS STATE_SD_CARD_UNMOUONTED
*/
public TextExport(Context context) { public TextExport(Context context) {
TEXT_FORMAT = context.getResources().getStringArray(R.array.format_for_exported_note); TEXT_FORMAT = context.getResources().getStringArray(R.array.format_for_exported_note);
mContext = context; mContext = context;
@ -116,6 +202,21 @@
mFileDirectory = ""; mFileDirectory = "";
} }
/**
* @method getFormat
* @description ID TEXT_FORMAT
* @author:
*/
/*
context访
TextExport
ID TEXT_FORMAT
id ID
STATE_SUCCESS STATE_SD_CARD_UNMOUONTED
*/
private String getFormat(int id) { //获取文本的组成部分 private String getFormat(int id) { //获取文本的组成部分
return TEXT_FORMAT[id]; return TEXT_FORMAT[id];
} }
@ -202,6 +303,21 @@
/** /**
* Note will be exported as text which is user readable * Note will be exported as text which is user readable
*/ */
/**
* @method exportToText
* @description MIME
* @author:
*/
/*
context访
TextExport
noteId ID
ps
STATE_SUCCESS STATE_SD_CARD_UNMOUONTED
*/
public int exportToText() { //总函数调用上面的exportFolder和exportNote public int exportToText() { //总函数调用上面的exportFolder和exportNote
if (!externalStorageAvailable()) { if (!externalStorageAvailable()) {
Log.d(TAG, "Media was not mounted"); Log.d(TAG, "Media was not mounted");
@ -269,6 +385,24 @@
/** /**
* Get a print stream pointed to the file {@generateExportedTextFile} * Get a print stream pointed to the file {@generateExportedTextFile}
*/ */
/**
* @method getExportToTextPrintStream
* @description
* @author:
*/
/*
context访
TextExport
noteId ID
ps
*/
private PrintStream getExportToTextPrintStream() { private PrintStream getExportToTextPrintStream() {
File file = generateFileMountedOnSDcard(mContext, R.string.file_path, File file = generateFileMountedOnSDcard(mContext, R.string.file_path,
R.string.file_name_txt_format); R.string.file_name_txt_format);
@ -296,6 +430,19 @@
/** /**
* Generate the text file to store imported data * Generate the text file to store imported data
*/ */
/**
* @method generateFileMountedOnSDcard
* @description ID
* @author:
*/
/*
ID
context访
filePathResId ID
fileNameFormatResId ID
*/
private static File generateFileMountedOnSDcard(Context context, int filePathResId, int fileNameFormatResId) { private static File generateFileMountedOnSDcard(Context context, int filePathResId, int fileNameFormatResId) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(Environment.getExternalStorageDirectory()); //外部SD卡的存储路径 sb.append(Environment.getExternalStorageDirectory()); //外部SD卡的存储路径

@ -14,6 +14,29 @@
* limitations under the License. * limitations under the License.
*/ */
/*该类定义在 net.micode.notes.tool 包下并导入了Android和Java的一些核心类。这些导入的类提供了对内容提供者操作、日志记录、游标以及存储值的支持。 */ /*该类定义在 net.micode.notes.tool 包下并导入了Android和Java的一些核心类。这些导入的类提供了对内容提供者操作、日志记录、游标以及存储值的支持。 */
/**
*
* @ProjectName: minode
* @Package: net.micode.notes.data
* @ClassName: DataUtils
* @Description:
便
* @Author:
*/
/*
DB_NAME
DB_VERSION
TABLE
TAG
mInstance
CREATE_NOTE_TABLE_SQLCREATE_DATA_TABLE_SQL SQL
NOTE_INCREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER SQL */
package net.micode.notes.tool; package net.micode.notes.tool;
/*定义了一个公共类 DataUtils并创建了一个常量 TAG 用于日志记录。 */ /*定义了一个公共类 DataUtils并创建了一个常量 TAG 用于日志记录。 */
import android.content.ContentProviderOperation; import android.content.ContentProviderOperation;
@ -37,6 +60,22 @@ import java.util.HashSet;
/*ID /*ID
ID ID
ContentResolver true false */ ContentResolver true false */
/**
* @method batchDeleteNotes
* @description ID
ContentProviderOperation ContentResolver
applyBatch true false
* @author:
*/
/*
ID ContentProviderOperation ContentResolver
applyBatch true false
resolver访
ids ID
true false */
public class DataUtils { public class DataUtils {
public static final String TAG = "DataUtils"; public static final String TAG = "DataUtils";
public static boolean batchDeleteNotes(ContentResolver resolver, HashSet<Long> ids) { public static boolean batchDeleteNotes(ContentResolver resolver, HashSet<Long> ids) {
@ -76,6 +115,26 @@ public class DataUtils {
/* /*
ID */ ID */
/*查询非系统文件夹的数量。异常处理用于确保在查询失败时释放游标资源。 */ /*查询非系统文件夹的数量。异常处理用于确保在查询失败时释放游标资源。 */
/*ID
ID
ContentResolver true false */
/**
* @method moveNoteToFoler
* @description ID ID ID ID ID
ContentResolver update
* @author:
*/
/*
ID ID ID ID ID
ContentResolver update
resolver访
id ID
srcFolderId ID
desFolderId ID*/
public static void moveNoteToFoler(ContentResolver resolver, long id, long srcFolderId, long desFolderId) { public static void moveNoteToFoler(ContentResolver resolver, long id, long srcFolderId, long desFolderId) {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(NoteColumns.PARENT_ID, desFolderId); values.put(NoteColumns.PARENT_ID, desFolderId);
@ -84,22 +143,22 @@ public class DataUtils {
resolver.update(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id), values, null, null); resolver.update(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id), values, null, null);
} }
/**
* @method: batchMoveToFolder /**
* @description: idsfolderId * @method batchMoveToFolder
* @date: 2024/12/26 3:32 * @description ID ID ContentProviderOperation
* @author: zhoukexing ContentResolver applyBatch true false
* @param: [resolver, ids, folderId] * @author:
* @return: boolean */
*/
/*检查数据库中是否存在特定类型的可见笔记。 */ /*
/** ID ID ContentProviderOperation
* 便 ContentResolver applyBatch true false
* @param resolver ContentResolver
* @param ids 便ID resolver访
* @param folderId ID ids ID
* @return folderId ID
*/ true false */
public static boolean batchMoveToFolder(ContentResolver resolver, HashSet<Long> ids, long folderId) { public static boolean batchMoveToFolder(ContentResolver resolver, HashSet<Long> ids, long folderId) {
if (ids == null) { if (ids == null) {
Log.d(TAG, "the ids is null"); Log.d(TAG, "the ids is null");
@ -135,6 +194,19 @@ public static boolean batchMoveToFolder(ContentResolver resolver, HashSet<Long>
* @param resolver ContentResolver * @param resolver ContentResolver
* @return * @return
*/ */
/**
* @method getUserFolderCount
* @description ID ID
* @author:
*/
/*
getUserFolderCount(ContentResolver resolver)
ID ID
resolver访
*/
public static int getUserFolderCount(ContentResolver resolver) { public static int getUserFolderCount(ContentResolver resolver) {
Cursor cursor =resolver.query(Notes.CONTENT_NOTE_URI, Cursor cursor =resolver.query(Notes.CONTENT_NOTE_URI,
new String[] { "COUNT(*)" }, new String[] { "COUNT(*)" },
@ -164,6 +236,20 @@ public static int getUserFolderCount(ContentResolver resolver) {
* @param type 便 * @param type 便
* @return * @return
*/ */
/**
* @method visibleInNoteDatabase
* @description ID true false
* @author:
*/
/*
ID true false
resolver访
noteId ID
type
true false */
public static boolean visibleInNoteDatabase(ContentResolver resolver, long noteId, int type) { public static boolean visibleInNoteDatabase(ContentResolver resolver, long noteId, int type) {
Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId), Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId),
null, null,
@ -187,6 +273,21 @@ public static boolean visibleInNoteDatabase(ContentResolver resolver, long noteI
* @param noteId 便ID * @param noteId 便ID
* @return * @return
*/ */
/**
* @method existInNoteDatabase
* @description ID true false
* @author:
*/
/*
ID true false
resolver访
noteId ID
true false */
public static boolean existInNoteDatabase(ContentResolver resolver, long noteId) { 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),
null, null, null, null); null, null, null, null);
@ -207,6 +308,21 @@ public static boolean existInNoteDatabase(ContentResolver resolver, long noteId)
* @param dataId ID * @param dataId ID
* @return * @return
*/ */
/**
* @method existInNoteDatabase
* @description ID true false
* @author:
*/
/*
ID true false
resolver访
dataId ID
true false
*/
public static boolean existInDataDatabase(ContentResolver resolver, long dataId) { public static boolean existInDataDatabase(ContentResolver resolver, long dataId) {
Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_DATA_URI, dataId), Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_DATA_URI, dataId),
null, null, null, null); null, null, null, null);
@ -227,6 +343,25 @@ public static boolean existInDataDatabase(ContentResolver resolver, long dataId)
* @param name * @param name
* @return * @return
*/ */
/**
* @method checkVisibleFolderName
* @description ID true false
* @author:
*/
/*
ID true false
resolver访
dataId ID
true false ID ID true false
resolver访
name
true false
*/
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, Cursor cursor = resolver.query(Notes.CONTENT_NOTE_URI, null,
NoteColumns.TYPE + "=" + Notes.TYPE_FOLDER + NoteColumns.TYPE + "=" + Notes.TYPE_FOLDER +
@ -249,6 +384,23 @@ public static boolean checkVisibleFolderName(ContentResolver resolver, String na
* @param folderId ID * @param folderId ID
* @return * @return
*/ */
/**
* @method getFolderNoteWidget
* @description ID ID
AppWidgetAttribute HashSet
* @author:
*/
/*
ID ID
AppWidgetAttribute HashSet
resolver访
folderId ID
HashSet
*/
public static HashSet<AppWidgetAttribute> getFolderNoteWidget(ContentResolver resolver, long folderId) { public static HashSet<AppWidgetAttribute> getFolderNoteWidget(ContentResolver resolver, long folderId) {
Cursor c = resolver.query(Notes.CONTENT_NOTE_URI, Cursor c = resolver.query(Notes.CONTENT_NOTE_URI,
new String[] { NoteColumns.WIDGET_ID, NoteColumns.WIDGET_TYPE }, new String[] { NoteColumns.WIDGET_ID, NoteColumns.WIDGET_TYPE },
@ -282,6 +434,29 @@ public static HashSet<AppWidgetAttribute> getFolderNoteWidget(ContentResolver re
* @param noteId 便ID * @param noteId 便ID
* @return * @return
*/ */
/**
* @method getCallNumberByNoteId
* @description ID ID
* @author:
*/
/*
ID ID
AppWidgetAttribute HashSet
ID ID
resolver访
noteId ID
resolver访
folderId ID
HashSet
*/
public static String getCallNumberByNoteId(ContentResolver resolver, long noteId) { public static String getCallNumberByNoteId(ContentResolver resolver, long noteId) {
Cursor cursor = resolver.query(Notes.CONTENT_DATA_URI, Cursor cursor = resolver.query(Notes.CONTENT_DATA_URI,
new String [] { CallNote.PHONE_NUMBER }, new String [] { CallNote.PHONE_NUMBER },
@ -308,6 +483,24 @@ public static String getCallNumberByNoteId(ContentResolver resolver, long noteId
* @param callDate * @param callDate
* @return 便ID * @return 便ID
*/ */
/**
* @method getNoteIdByPhoneNumberAndCallDate
* @description ID ID
ID ID 0
* @author:
*/
/*
ID ID
ID ID 0
resolver访
phoneNumber
callDate
ID
*/
public static long getNoteIdByPhoneNumberAndCallDate(ContentResolver resolver, String phoneNumber, long callDate) { public static long getNoteIdByPhoneNumberAndCallDate(ContentResolver resolver, String phoneNumber, long callDate) {
Cursor cursor = resolver.query(Notes.CONTENT_DATA_URI, Cursor cursor = resolver.query(Notes.CONTENT_DATA_URI,
new String [] { CallNote.NOTE_ID }, new String [] { CallNote.NOTE_ID },
@ -335,6 +528,26 @@ public static long getNoteIdByPhoneNumberAndCallDate(ContentResolver resolver, S
* @param noteId 便ID * @param noteId 便ID
* @return 便 * @return 便
*/ */
/**
* @method getSnippetById
* @description ID ID
IllegalArgumentException
* @author:
*/
/*
ID ID
ID ID 0
ID ID
IllegalArgumentException
resolver访
noteId ID
*/
public static String getSnippetById(ContentResolver resolver, long noteId) { public static String getSnippetById(ContentResolver resolver, long noteId) {
Cursor cursor = resolver.query(Notes.CONTENT_NOTE_URI, Cursor cursor = resolver.query(Notes.CONTENT_NOTE_URI,
new String [] { NoteColumns.SNIPPET }, new String [] { NoteColumns.SNIPPET },
@ -358,6 +571,21 @@ public static String getSnippetById(ContentResolver resolver, long noteId) {
* @param snippet 便 * @param snippet 便
* @return 便 * @return 便
*/ */
/**
* @method getFormattedSnippet
* @description
* @author:
*/
/*
snippet
*/
public static String getFormattedSnippet(String snippet) { public static String getFormattedSnippet(String snippet) {
if (snippet != null) { if (snippet != null) {
snippet = snippet.trim(); snippet = snippet.trim();
@ -375,6 +603,21 @@ public static String getFormattedSnippet(String snippet) {
* @param query * @param query
* @return Cursor * @return Cursor
*/ */
/**
* @method searchInNoteDatabase
* @description ID Cursor
* @author:
*/
/*
ID Cursor
resolver访
query
Cursor
*/
public static Cursor searchInNoteDatabase(ContentResolver resolver, String query) { public static Cursor searchInNoteDatabase(ContentResolver resolver, String query) {
Cursor cursor = resolver.query(Notes.CONTENT_DATA_URI, Cursor cursor = resolver.query(Notes.CONTENT_DATA_URI,
new String[]{NoteColumns.ID}, new String[]{NoteColumns.ID},

@ -14,6 +14,74 @@
* limitations under the License. * limitations under the License.
*/ */
/**
*
* @ProjectName: minode
* @Package: net.micode.notes.data
* @ClassName: GTaskStringUtils
* @Author:
*/
/*
GTaskGoogle Tasks JSON
GTASK JSON
GTASK_JSON_ACTION_ID GTask ID
GTASK_JSON_ACTION_LIST GTask
GTASK_JSON_ACTION_TYPE GTask
GTASK_JSON_ACTION_TYPE_CREATE
GTASK_JSON_ACTION_TYPE_GETALL
GTASK_JSON_ACTION_TYPE_MOVE
GTASK_JSON_ACTION_TYPE_UPDATE
GTASK_JSON_CREATOR_ID ID
GTASK_JSON_CHILD_ENTITY
GTASK_JSON_CLIENT_VERSION
GTASK_JSON_COMPLETED
GTASK_JSON_CURRENT_LIST_ID ID
GTASK_JSON_DEFAULT_LIST_ID ID
GTASK_JSON_DELETED
GTASK_JSON_DEST_LIST
GTASK_JSON_DEST_PARENT
GTASK_JSON_DEST_PARENT_TYPE
GTASK_JSON_ENTITY_DELTA
GTASK_JSON_ENTITY_TYPE
GTASK_JSON_GET_DELETED
GTASK_JSON_ID ID
GTASK_JSON_INDEX
GTASK_JSON_LAST_MODIFIED
GTASK_JSON_LATEST_SYNC_POINT
GTASK_JSON_LIST_ID ID
GTASK_JSON_LISTS
GTASK_JSON_NAME
GTASK_JSON_NEW_ID ID
GTASK_JSON_NOTES
GTASK_JSON_PARENT_ID ID
GTASK_JSON_PRIOR_SIBLING_ID ID
GTASK_JSON_RESULTS
GTASK_JSON_SOURCE_LIST
GTASK_JSON_TASKS
GTASK_JSON_TYPE
GTASK_JSON_TYPE_GROUP
GTASK_JSON_TYPE_TASK
GTASK_JSON_USER
MIUI_FOLDER_PREFFIX MIUI
FOLDER_DEFAULT
FOLDER_CALL_NOTE
FOLDER_META
META_HEAD_GTASK_ID GTask ID
META_HEAD_NOTE
META_HEAD_DATA
META_NOTE_NAME
GTask JSON 便 JSON
便
*/
package net.micode.notes.tool; package net.micode.notes.tool;
// 该类用于定义 Google 任务相关的 JSON 字段常量 // 该类用于定义 Google 任务相关的 JSON 字段常量

Loading…
Cancel
Save