main
chenjianan 7 months ago
commit ce4fb6e07e

@ -31,8 +31,8 @@ import java.util.HashMap;
* @Package: net.micode.notes.data * @Package: net.micode.notes.data
* @ClassName: Contact * @ClassName: Contact
* @Description: * @Description:
* @Author: * @Author:
* @Date: 2023-12-16 17:57 * @Date: 2024-12-20 19:42
*/ */
public class Contact { public class Contact {
private static HashMap<String, String> sContactCache; private static HashMap<String, String> sContactCache;
@ -44,11 +44,11 @@ public class Contact {
+ "(SELECT raw_contact_id " + "(SELECT raw_contact_id "
+ " FROM phone_lookup" + " FROM phone_lookup"
+ " WHERE min_match = '+')"; + " WHERE min_match = '+')";
/** /**
* @method getContact * @method getContact
* @description * @description
* @date: 2023-12-16 19:24 * @date: 2024-12-20 20:02
* @author: * @author:
* @return string * @return string
*/ */
public static String getContact(Context context, String phoneNumber) { public static String getContact(Context context, String phoneNumber) {
@ -57,7 +57,7 @@ public class Contact {
} }
// 查找HashMap中是否有phoneNumber的信息 // 查找HashMap中是否有phoneNumber的信息
// 2023-12-16 19:43 // 2024-12-20 20:04
if(sContactCache.containsKey(phoneNumber)) { if(sContactCache.containsKey(phoneNumber)) {
return sContactCache.get(phoneNumber); return sContactCache.get(phoneNumber);
} }
@ -66,7 +66,7 @@ public class Contact {
PhoneNumberUtils.toCallerIDMinMatch(phoneNumber)); PhoneNumberUtils.toCallerIDMinMatch(phoneNumber));
// 查找数据库中phoneNumber的信息 // 查找数据库中phoneNumber的信息
// 2023-12-16 19:43 // 2024-12-20 20:06
Cursor cursor = context.getContentResolver().query( Cursor cursor = context.getContentResolver().query(
Data.CONTENT_URI, Data.CONTENT_URI,
new String [] { Phone.DISPLAY_NAME }, new String [] { Phone.DISPLAY_NAME },
@ -75,7 +75,7 @@ public class Contact {
null); null);
// 检查是否查询到联系人找到则将相关信息加入HashMap中未找到则处理异常 // 检查是否查询到联系人找到则将相关信息加入HashMap中未找到则处理异常
// 2023-12-16 19:41 // 2024-12-20 20:07
if (cursor != null && cursor.moveToFirst()) { if (cursor != null && cursor.moveToFirst()) {
try { try {
String name = cursor.getString(0); String name = cursor.getString(0);

@ -14,6 +14,29 @@
* limitations under the License. * limitations under the License.
*/ */
/**
*
* @ProjectName: minode
* @Package: net.micode.notes.data
* @ClassName: Notes
* @Description: Intent
URI访使
* @Author:
* @Date: 2024-12-21 19:42
*/
/*
AUTHORITY URI
TAG
TYPE_NOTETYPE_FOLDERTYPE_SYSTEM
ID_ROOT_FOLDERID_TEMPARAY_FOLDERID_CALL_RECORD_FOLDERID_TRASH_FOLER
INTENT_EXTRA_ALERT_DATEINTENT_EXTRA_BACKGROUND_ID Intent Intent
TYPE_WIDGET_INVALIDETYPE_WIDGET_2XTYPE_WIDGET_4X
*/
package net.micode.notes.data; package net.micode.notes.data;
import android.net.Uri; import android.net.Uri;
@ -46,6 +69,19 @@ public class Notes {
public static final int TYPE_WIDGET_2X = 0; public static final int TYPE_WIDGET_2X = 0;
public static final int TYPE_WIDGET_4X = 1; public static final int TYPE_WIDGET_4X = 1;
/**
* @method DataConstants
* @description MIME
* @date: 2024-12-21 20:02
* @author:
*/
/*
NOTE MIME
CALL_NOTE MIME
*/
public static class DataConstants { public static class DataConstants {
public static final String NOTE = TextNote.CONTENT_ITEM_TYPE; public static final String NOTE = TextNote.CONTENT_ITEM_TYPE;
public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE; public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE;
@ -61,6 +97,38 @@ public class Notes {
*/ */
public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data"); public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data");
/**
* @method NoteColumns
* @description ID ID
ID ID ID
IDGTask ID
* @date: 2024-12-21 20:04
* @author:
*/
/*
ID ID
PARENT_ID ID
CREATED_DATE
MODIFIED_DATE
ALERTED_DATE
SNIPPET
WIDGET_ID ID
WIDGET_TYPE
BG_COLOR_ID ID
HAS_ATTACHMENT
NOTES_COUNT
TYPE
SYNC_ID ID
LOCAL_MODIFIED
ORIGIN_PARENT_ID ID
GTASK_IDGTask ID
VERSION
TOP
*/
public interface NoteColumns { public interface NoteColumns {
/** /**
* The unique ID for a row * The unique ID for a row
@ -173,6 +241,26 @@ public class Notes {
public static final String TOP = "top"; public static final String TOP = "top";
} }
/**
* @method DataColumns
* @description IDMIME
ID
* @date: 2024-12-21 20:05
* @author:
*/
/*
ID ID
MIME_TYPE MIME
NOTE_ID ID
CREATED_DATE
MODIFIED_DATE
CONTENT
DATA1DATA2DATA3DATA4DATA5 MIME
*/
public interface DataColumns { public interface DataColumns {
/** /**
* The unique ID for a row * The unique ID for a row
@ -247,6 +335,23 @@ public class Notes {
public static final String DATA5 = "data5"; public static final String DATA5 = "data5";
} }
/**
* @method TextNote
* @description DataColumns MIME
MIME URI
* @date: 2024-12-21 20:07
* @author:
*/
/*
MODE使 DATA1
MODE_CHECK_LIST
CONTENT_TYPE MIME
CONTENT_ITEM_TYPE MIME
CONTENT_URI URI
*/
public static final class TextNote implements DataColumns { public static final class TextNote implements DataColumns {
/** /**
* Mode to indicate the text in check list mode or not * Mode to indicate the text in check list mode or not
@ -263,6 +368,23 @@ public class Notes {
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note"); public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note");
} }
/**
* @method CallNote
* @description DataColumns MIME
MIME URI
* @date: 2024-12-21 20:10
* @author:
*/
/*
CALL_DATE使 DATA1
PHONE_NUMBER使 DATA3
CONTENT_TYPE MIME
CONTENT_ITEM_TYPE MIME
CONTENT_URI URI
*/
public static final class CallNote implements DataColumns { public static final class CallNote implements DataColumns {
/** /**
* Call date for this record * Call date for this record

@ -14,6 +14,27 @@
* limitations under the License. * limitations under the License.
*/ */
/**
*
* @ProjectName: minode
* @Package: net.micode.notes.data
* @ClassName: NotesDatabaseHelper
* @Description: SQLiteOpenHelper
SQL
便
* @Author:
* @Date: 2024-12-21 22:10
*/
/*
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.data; package net.micode.notes.data;
import android.content.ContentValues; import android.content.ContentValues;
@ -207,10 +228,29 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
" WHERE " + NoteColumns.PARENT_ID + "=old." + NoteColumns.ID + ";" + " WHERE " + NoteColumns.PARENT_ID + "=old." + NoteColumns.ID + ";" +
" END"; " END";
/**
* @method NotesDatabaseHelper
* @description NotesDatabaseHelper
* @date: 2024-12-21 22:10
* @author:
*/
/*
context访 */
public NotesDatabaseHelper(Context context) { public NotesDatabaseHelper(Context context) {
super(context, DB_NAME, null, DB_VERSION); super(context, DB_NAME, null, DB_VERSION);
} }
/**
* @method createNoteTable
* @description SQL reCreateNoteTableTriggers
* @date: 2024-12-21 22:13
* @author:
*/
/*
db SQL */
public void createNoteTable(SQLiteDatabase db) { public void createNoteTable(SQLiteDatabase db) {
db.execSQL(CREATE_NOTE_TABLE_SQL); db.execSQL(CREATE_NOTE_TABLE_SQL);
reCreateNoteTableTriggers(db); reCreateNoteTableTriggers(db);
@ -218,6 +258,16 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
Log.d(TAG, "note table has been created"); Log.d(TAG, "note table has been created");
} }
/**
* @method reCreateNoteTableTriggers
* @description
* @date: 2024-12-21 22:15
* @author:
*/
/*
db SQL */
private void reCreateNoteTableTriggers(SQLiteDatabase db) { private void reCreateNoteTableTriggers(SQLiteDatabase db) {
db.execSQL("DROP TRIGGER IF EXISTS increase_folder_count_on_update"); db.execSQL("DROP TRIGGER IF EXISTS increase_folder_count_on_update");
db.execSQL("DROP TRIGGER IF EXISTS decrease_folder_count_on_update"); db.execSQL("DROP TRIGGER IF EXISTS decrease_folder_count_on_update");
@ -236,6 +286,15 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.execSQL(FOLDER_MOVE_NOTES_ON_TRASH_TRIGGER); db.execSQL(FOLDER_MOVE_NOTES_ON_TRASH_TRIGGER);
} }
/**
* @method createSystemFolder
* @description 使 ContentValues ID
* @date: 2024-12-21 22:20
* @author:
*/
/*
db */
private void createSystemFolder(SQLiteDatabase db) { private void createSystemFolder(SQLiteDatabase db) {
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
@ -271,6 +330,12 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.insert(TABLE.NOTE, null, values); db.insert(TABLE.NOTE, null, values);
} }
/**
* @method createDataTable
* @description SQL reCreateDataTableTriggers
* @date: 2024-12-21 22:23
* @author:
*/
public void createDataTable(SQLiteDatabase db) { public void createDataTable(SQLiteDatabase db) {
db.execSQL(CREATE_DATA_TABLE_SQL); db.execSQL(CREATE_DATA_TABLE_SQL);
reCreateDataTableTriggers(db); reCreateDataTableTriggers(db);
@ -278,6 +343,13 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
Log.d(TAG, "data table has been created"); Log.d(TAG, "data table has been created");
} }
/**
* @method reCreateDataTableTriggers
* @description
* @date: 2024-12-21 22:25
* @author:
*/
private void reCreateDataTableTriggers(SQLiteDatabase db) { private void reCreateDataTableTriggers(SQLiteDatabase db) {
db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_insert"); db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_insert");
db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_update"); db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_update");
@ -288,6 +360,12 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.execSQL(DATA_UPDATE_NOTE_CONTENT_ON_DELETE_TRIGGER); db.execSQL(DATA_UPDATE_NOTE_CONTENT_ON_DELETE_TRIGGER);
} }
/**
* @method getInstance
* @description NotesDatabaseHelper
* @date: 2024-12-21 22:30
* @author:
*/
static synchronized NotesDatabaseHelper getInstance(Context context) { static synchronized NotesDatabaseHelper getInstance(Context context) {
if (mInstance == null) { if (mInstance == null) {
mInstance = new NotesDatabaseHelper(context); mInstance = new NotesDatabaseHelper(context);
@ -295,12 +373,31 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
return mInstance; return mInstance;
} }
/**
* @method onCreate
* @description createNoteTable createDataTable
* @date: 2024-12-21 22:40
* @author:
*/
@Override @Override
public void onCreate(SQLiteDatabase db) { public void onCreate(SQLiteDatabase db) {
createNoteTable(db); createNoteTable(db);
createDataTable(db); createDataTable(db);
} }
/**
* @method onUpgrade
* @description
upgradeToV2upgradeToV3
* @date: 2024-12-21 22:47
* @author:
*/
/*
db
oldVersion
newVersion */
@Override @Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
boolean reCreateTriggers = false; boolean reCreateTriggers = false;
@ -339,6 +436,13 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
} }
} }
/**
* @method upgradeToV2
* @description 2
* @date: 2024-12-21 22:51
* @author:
*/
private void upgradeToV2(SQLiteDatabase db) { private void upgradeToV2(SQLiteDatabase db) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE.NOTE); db.execSQL("DROP TABLE IF EXISTS " + TABLE.NOTE);
db.execSQL("DROP TABLE IF EXISTS " + TABLE.DATA); db.execSQL("DROP TABLE IF EXISTS " + TABLE.DATA);
@ -346,6 +450,13 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
createDataTable(db); createDataTable(db);
} }
/**
* @method upgradeToV3
* @description 3使 gtask_id
* @date: 2024-12-21 22:55
* @author:
*/
private void upgradeToV3(SQLiteDatabase db) { private void upgradeToV3(SQLiteDatabase db) {
// drop unused triggers // drop unused triggers
db.execSQL("DROP TRIGGER IF EXISTS update_note_modified_date_on_insert"); db.execSQL("DROP TRIGGER IF EXISTS update_note_modified_date_on_insert");
@ -361,11 +472,25 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.insert(TABLE.NOTE, null, values); db.insert(TABLE.NOTE, null, values);
} }
/**
* @method upgradeToV4
* @description 4 version
* @date: 2024-12-21 22:57
* @author:
*/
private void upgradeToV4(SQLiteDatabase db) { private void upgradeToV4(SQLiteDatabase db) {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION
+ " INTEGER NOT NULL DEFAULT 0"); + " INTEGER NOT NULL DEFAULT 0");
} }
/**
* @method upgradeToV5
* @description 5 top
* @date: 2024-12-21 23:00
* @author:
*/
private void upgradeToV5(SQLiteDatabase db) { private void upgradeToV5(SQLiteDatabase db) {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.TOP db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.TOP
+ " INTEGER NOT NULL DEFAULT 0"); + " INTEGER NOT NULL DEFAULT 0");

@ -14,6 +14,24 @@
* limitations under the License. * limitations under the License.
*/ */
/**
*
* @ProjectName: minode
* @Package: net.micode.notes.data
* @ClassName: NotesProvider
* @Description: ContentProvider访 URI
ContentProvider onCreatequeryinsertdeleteupdate
便访
* @Author:
* @Date: 2024-12-21 23:10
*/
/*
mMatcherURI URI
mHelper访
TAG
URI_NOTEURI_NOTE_ITEM URI */
package net.micode.notes.data; package net.micode.notes.data;
@ -34,7 +52,12 @@ import net.micode.notes.data.Notes.DataColumns;
import net.micode.notes.data.Notes.NoteColumns; import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.data.NotesDatabaseHelper.TABLE; import net.micode.notes.data.NotesDatabaseHelper.TABLE;
/**
* @method NotesProvider
* @description
* @date: 2024-12-21 23:12
* @author:
*/
public class NotesProvider extends ContentProvider { public class NotesProvider extends ContentProvider {
private static final UriMatcher mMatcher; private static final UriMatcher mMatcher;
@ -80,12 +103,37 @@ public class NotesProvider extends ContentProvider {
+ " AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER + " AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER
+ " AND " + NoteColumns.TYPE + "=" + Notes.TYPE_NOTE; + " AND " + NoteColumns.TYPE + "=" + Notes.TYPE_NOTE;
/**
* @method onCreate
* @description ContentProvider NotesDatabaseHelper.getInstance
mHelper true
* @date: 2024-12-21 23:13
* @author:
*/
@Override @Override
public boolean onCreate() { public boolean onCreate() {
mHelper = NotesDatabaseHelper.getInstance(getContext()); mHelper = NotesDatabaseHelper.getInstance(getContext());
return true; return true;
} }
/**
* @method query
* @description URI:
URI_NOTE
URI_NOTE_ITEM ID
URI_DATA
URI_DATA_ITEM ID
URI_SEARCHURI_SEARCH_SUGGEST
* @date: 2024-12-21 23:15
* @author:
*/
/*uri URI
projection
selection
selectionArgs
sortOrder */
@Override @Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
String sortOrder) { String sortOrder) {
@ -147,7 +195,18 @@ public class NotesProvider extends ContentProvider {
} }
return c; return c;
} }
/**
* @method insert
* @description URI:
URI_NOTE
URI_DATA
URI
* @date: 2024-12-21 23:17
* @author:
*/
/*
uri URI
values*/
@Override @Override
public Uri insert(Uri uri, ContentValues values) { public Uri insert(Uri uri, ContentValues values) {
SQLiteDatabase db = mHelper.getWritableDatabase(); SQLiteDatabase db = mHelper.getWritableDatabase();
@ -182,6 +241,23 @@ public class NotesProvider extends ContentProvider {
return ContentUris.withAppendedId(uri, insertedId); return ContentUris.withAppendedId(uri, insertedId);
} }
/**
* @method delete
* @description URI:
URI_NOTE
URI_NOTE_ITEM ID
URI_DATA
URI_DATA_ITEM ID
URI
* @date: 2024-12-21 23:20
* @author:
*/
/*
uri URI
selection
selectionArgs
*/
@Override @Override
public int delete(Uri uri, String selection, String[] selectionArgs) { public int delete(Uri uri, String selection, String[] selectionArgs) {
int count = 0; int count = 0;
@ -227,7 +303,22 @@ public class NotesProvider extends ContentProvider {
} }
return count; return count;
} }
/**
* @method update
* @description URI:
URI_NOTE
URI_NOTE_ITEM ID
URI_DATA
URI_DATA_ITEM ID
URI
* @date: 2024-12-21 23:22
* @author:
*/
/*
uri URI
values
selection
selectionArgs */
@Override @Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
int count = 0; int count = 0;
@ -267,11 +358,30 @@ public class NotesProvider extends ContentProvider {
} }
return count; return count;
} }
/**
* @method parseSelection
* @description
* @date: 2024-12-21 23:25
* @author:
*/
/*
selection */
private String parseSelection(String selection) { private String parseSelection(String selection) {
return (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : ""); return (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : "");
} }
/**
* @method increaseNoteVersion
* @description ID
* @date: 2024-12-21 23:27
* @author:
*/
/*
id ID
selection
selectionArgs */
private void increaseNoteVersion(long id, String selection, String[] selectionArgs) { private void increaseNoteVersion(long id, String selection, String[] selectionArgs) {
StringBuilder sql = new StringBuilder(120); StringBuilder sql = new StringBuilder(120);
sql.append("UPDATE "); sql.append("UPDATE ");
@ -297,6 +407,13 @@ public class NotesProvider extends ContentProvider {
mHelper.getWritableDatabase().execSQL(sql.toString()); mHelper.getWritableDatabase().execSQL(sql.toString());
} }
/**
* @method getType
* @description MIME null
* @date: 2024-12-21 23:30
* @author:
*/
@Override @Override
public String getType(Uri uri) { public String getType(Uri uri) {
// TODO Auto-generated method stub // TODO Auto-generated method stub

@ -14,7 +14,468 @@
* limitations under the License. * limitations under the License.
*/ */
<<<<<<< HEAD
package net.micode.notes.tool; package net.micode.notes.tool;
=======
/**
*
* @ProjectName: minode
* @Package: net.micode.notes.data
* @ClassName: BackupUtils
* @Description:
便
* @Author:
*/
package net.micode.notes.tool;
public class BackupUtils {
private static final String TAG = "BackupUtils";
// Singleton stuff
private static BackupUtils sInstance; //类里面为什么可以定义自身类的对象?
/**
* @method getInstance
* @description BackupUtils
* @author:
*/
/*
context访
BackupUtils */
public static synchronized BackupUtils getInstance(Context context) {
//ynchronized 关键字,代表这个方法加锁,相当于不管哪一个线程例如线程A
//运行到这个方法时,都要检查有没有其它线程B或者C、 D等正在用这个方法(或者该类的其他同步方法)有的话要等正在使用synchronized方法的线程B或者C 、D运行完这个方法后再运行此线程A,没有的话,锁定调用者,然后直接运行。
//它包括两种用法synchronized 方法和 synchronized 块。
if (sInstance == null) {
//如果当前备份不存在,则新声明一个
sInstance = new BackupUtils(context);
}
return sInstance;
}
/**
* Following states are signs to represents backup or restore
* status
*/
// Currently, the sdcard is not mounted SD卡没有被装入手机
public static final int STATE_SD_CARD_UNMOUONTED = 0;
// The backup file not exist 备份文件夹不存在
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;
// Some run-time exception which causes restore or backup fails 超时异常
public static final int STATE_SYSTEM_ERROR = 3;
// Backup or restore success 成功存储
public static final int STATE_SUCCESS = 4;
private TextExport mTextExport;
private BackupUtils(Context context) { //初始化函数
mTextExport = new TextExport(context);
}
/**
* @method externalStorageAvailable
* @description Environment.MEDIA_MOUNTED
* @author:
*/
/*
context访
BackupUtils
Environment.MEDIA_MOUNTED
true false */
private static boolean externalStorageAvailable() { //外部存储功能是否可用
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() {
return mTextExport.exportToText();
}
/**
* @method getExportedTextFileName
* @description TextExport
TextExport exportToText
* @author:
*/
/*
context访
BackupUtils
TextExport exportToText
STATE_SUCCESS STATE_SD_CARD_UNMOUONTED
TextExport
*/
public String getExportedTextFileName() {
return mTextExport.mFileName;
}
/**
* @method getExportedTextFileDir
* @description TextExport
TextExport exportToText
* @author:
*/
/*
context访
TextExport
STATE_SUCCESS STATE_SD_CARD_UNMOUONTED
TextExport
*/
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 final int NOTE_COLUMN_ID = 0;
private static final int NOTE_COLUMN_MODIFIED_DATE = 1;
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 int DATA_COLUMN_CONTENT = 0;
private static final int DATA_COLUMN_MIME_TYPE = 1;
private static final int DATA_COLUMN_CALL_DATE = 2;
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_NOTE_DATE = 1;
private static final int FORMAT_NOTE_CONTENT = 2;
private Context mContext;
private String mFileName;
private String mFileDirectory;
/**
* @method getExportedTextFileDir
* @description
TextExport
TextExport exportToText
* @author:
*/
/*
context访
TextExport
STATE_SUCCESS STATE_SD_CARD_UNMOUONTED
*/
public TextExport(Context context) {
TEXT_FORMAT = context.getResources().getStringArray(R.array.format_for_exported_note);
mContext = context;
mFileName = ""; //为什么为空?
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) { //获取文本的组成部分
return TEXT_FORMAT[id];
}
/**
* Export the folder identified by folder id to text
*/
private void exportFolderToText(String folderId, PrintStream ps) {
// Query notes belong to this folder 通过查询parent id是文件夹id的note来选出制定ID文件夹下的Note
Cursor notesCursor = mContext.getContentResolver().query(Notes.CONTENT_NOTE_URI,
NOTE_PROJECTION, NoteColumns.PARENT_ID + "=?", new String[] {
folderId
}, null);
if (notesCursor != null) {
if (notesCursor.moveToFirst()) {
do {
// Print note's last modified date ps里面保存有这份note的日期
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
String noteId = notesCursor.getString(NOTE_COLUMN_ID);
exportNoteToText(noteId, ps); //将文件导出到text
} while (notesCursor.moveToNext());
}
notesCursor.close();
}
}
/**
* Export note identified by id to a print stream
*/
private void exportNoteToText(String noteId, PrintStream ps) {
Cursor dataCursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI,
DATA_PROJECTION, DataColumns.NOTE_ID + "=?", new String[] {
noteId
}, null);
if (dataCursor != null) { //利用光标来扫描内容区别为callnote和note两种靠ps.printline输出
if (dataCursor.moveToFirst()) {
do {
String mimeType = dataCursor.getString(DATA_COLUMN_MIME_TYPE);
if (DataConstants.CALL_NOTE.equals(mimeType)) {
// 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);
if (!TextUtils.isEmpty(phoneNumber)) { //判断是否为空字符
ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT),
phoneNumber));
}
// 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
if (!TextUtils.isEmpty(location)) {
ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT),
location));
}
} else if (DataConstants.NOTE.equals(mimeType)) {
String content = dataCursor.getString(DATA_COLUMN_CONTENT);
if (!TextUtils.isEmpty(content)) {
ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT),
content));
}
}
} while (dataCursor.moveToNext());
}
dataCursor.close();
}
// print a line separator between note
try {
ps.write(new byte[] {
Character.LINE_SEPARATOR, Character.LETTER_NUMBER
});
} catch (IOException e) {
Log.e(TAG, e.toString());
}
}
/**
* 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
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 导出文件夹,就是导出里面包含的便签
Cursor folderCursor = mContext.getContentResolver().query(
Notes.CONTENT_NOTE_URI,
NOTE_PROJECTION,
"(" + NoteColumns.TYPE + "=" + Notes.TYPE_FOLDER + " AND "
+ NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER + ") OR "
+ NoteColumns.ID + "=" + Notes.ID_CALL_RECORD_FOLDER, null, null);
if (folderCursor != null) {
if (folderCursor.moveToFirst()) {
do {
// Print folder's name
String folderName = "";
if(folderCursor.getLong(NOTE_COLUMN_ID) == Notes.ID_CALL_RECORD_FOLDER) {
folderName = mContext.getString(R.string.call_record_folder_name);
} else {
folderName = folderCursor.getString(NOTE_COLUMN_SNIPPET);
}
if (!TextUtils.isEmpty(folderName)) {
ps.println(String.format(getFormat(FORMAT_FOLDER_NAME), folderName));
}
String folderId = folderCursor.getString(NOTE_COLUMN_ID);
exportFolderToText(folderId, ps);
} while (folderCursor.moveToNext());
}
folderCursor.close();
}
// Export notes in root's folder 将根目录里的便签导出(由于不属于任何文件夹,因此无法通过文件夹导出来实现这一部分便签的导出)
Cursor noteCursor = mContext.getContentResolver().query(
Notes.CONTENT_NOTE_URI,
NOTE_PROJECTION,
NoteColumns.TYPE + "=" + +Notes.TYPE_NOTE + " AND " + NoteColumns.PARENT_ID
+ "=0", null, null);
if (noteCursor != null) {
if (noteCursor.moveToFirst()) {
do {
ps.println(String.format(getFormat(FORMAT_NOTE_DATE), DateFormat.format(
mContext.getString(R.string.format_datetime_mdhm),
noteCursor.getLong(NOTE_COLUMN_MODIFIED_DATE))));
// Query data belong to this note
String noteId = noteCursor.getString(NOTE_COLUMN_ID);
exportNoteToText(noteId, ps);
} while (noteCursor.moveToNext());
}
noteCursor.close();
}
ps.close();
return STATE_SUCCESS;
}
/**
* Get a print stream pointed to the file {@generateExportedTextFile}
*/
/**
* @method getExportToTextPrintStream
* @description
* @author:
*/
/*
context访
TextExport
noteId ID
ps
*/
private PrintStream getExportToTextPrintStream() {
File file = generateFileMountedOnSDcard(mContext, R.string.file_path,
R.string.file_name_txt_format);
if (file == null) {
Log.e(TAG, "create file to exported failed");
return null;
}
mFileName = file.getName();
mFileDirectory = mContext.getString(R.string.file_path);
PrintStream ps = null;
try {
FileOutputStream fos = new FileOutputStream(file);
ps = new PrintStream(fos); //将ps输出流输出到特定的文件目的就是导出到文件而不是直接输出
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
} catch (NullPointerException e) {
e.printStackTrace();
return null;
}
return ps;
}
}
/**
* 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) {
StringBuilder sb = new StringBuilder();
sb.append(Environment.getExternalStorageDirectory()); //外部SD卡的存储路径
sb.append(context.getString(filePathResId)); //文件的存储路径
File filedir = new File(sb.toString()); //filedir应该就是用来存储路径信息
sb.append(context.getString(
fileNameFormatResId,
DateFormat.format(context.getString(R.string.format_date_ymd),
System.currentTimeMillis())));
File file = new File(sb.toString());
try { //如果这些文件不存在,则新建
if (!filedir.exists()) {
filedir.mkdir();
}
if (!file.exists()) {
file.createNewFile();
}
return file;
} catch (SecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// try catch 异常处理
return null;
}
}
>>>>>>> 623b8465a7bfcf05a3ca2ec250315ad6977a9eb0
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;

@ -13,6 +13,33 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
<<<<<<< HEAD
=======
/*该类定义在 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 */
>>>>>>> 623b8465a7bfcf05a3ca2ec250315ad6977a9eb0
package net.micode.notes.tool; package net.micode.notes.tool;
import android.content.ContentProviderOperation; import android.content.ContentProviderOperation;
@ -33,10 +60,32 @@ import net.micode.notes.ui.NotesListAdapter.AppWidgetAttribute;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
<<<<<<< HEAD
/** /**
* DataUtils 便 * DataUtils 便
* 便便便 * 便便便
*/ */
=======
/*ID
ID
ContentResolver true false */
/**
* @method batchDeleteNotes
* @description ID
ContentProviderOperation ContentResolver
applyBatch true false
* @author:
*/
/*
ID ContentProviderOperation ContentResolver
applyBatch true false
resolver访
ids ID
true false */
>>>>>>> 623b8465a7bfcf05a3ca2ec250315ad6977a9eb0
public class DataUtils { public class DataUtils {
public static final String TAG = "DataUtils"; public static final String TAG = "DataUtils";
@ -80,6 +129,7 @@ public class DataUtils {
} }
return false; return false;
} }
<<<<<<< HEAD
/** /**
* 便 * 便
@ -88,6 +138,31 @@ public class DataUtils {
* @param srcFolderId ID * @param srcFolderId ID
* @param desFolderId ID * @param desFolderId 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*/
>>>>>>> 623b8465a7bfcf05a3ca2ec250315ad6977a9eb0
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);
@ -96,6 +171,7 @@ 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);
} }
<<<<<<< HEAD
/** /**
* 便 * 便
* @param resolver ContentResolver * @param resolver ContentResolver
@ -108,6 +184,29 @@ public class DataUtils {
Log.d(TAG, "the ids is null"); Log.d(TAG, "the ids is null");
return true; return true;
} }
=======
/**
* @method batchMoveToFolder
* @description ID ID ContentProviderOperation
ContentResolver applyBatch true false
* @author:
*/
/*
ID ID ContentProviderOperation
ContentResolver applyBatch true false
resolver访
ids ID
folderId ID
true false */
public static boolean batchMoveToFolder(ContentResolver resolver, HashSet<Long> ids, long folderId) {
if (ids == null) {
Log.d(TAG, "the ids is null");
return true;
}
>>>>>>> 623b8465a7bfcf05a3ca2ec250315ad6977a9eb0
ArrayList<ContentProviderOperation> operationList = new ArrayList<ContentProviderOperation>(); ArrayList<ContentProviderOperation> operationList = new ArrayList<ContentProviderOperation>();
for (long id : ids) { for (long id : ids) {
@ -133,6 +232,7 @@ public class DataUtils {
return false; return false;
} }
<<<<<<< HEAD
/** /**
* *
* @param resolver ContentResolver * @param resolver ContentResolver
@ -144,6 +244,32 @@ public class DataUtils {
NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>?", NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>?",
new String[] { String.valueOf(Notes.TYPE_FOLDER), String.valueOf(Notes.ID_TRASH_FOLDER)}, new String[] { String.valueOf(Notes.TYPE_FOLDER), String.valueOf(Notes.ID_TRASH_FOLDER)},
null); null);
=======
/**
*
* @param resolver ContentResolver
* @return
*/
/**
* @method getUserFolderCount
* @description ID ID
* @author:
*/
/*
getUserFolderCount(ContentResolver resolver)
ID ID
resolver访
*/
public static int getUserFolderCount(ContentResolver resolver) {
Cursor cursor =resolver.query(Notes.CONTENT_NOTE_URI,
new String[] { "COUNT(*)" },
NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>?",
new String[] { String.valueOf(Notes.TYPE_FOLDER), String.valueOf(Notes.ID_TRASH_FOLER)},
null);
>>>>>>> 623b8465a7bfcf05a3ca2ec250315ad6977a9eb0
int count = 0; int count = 0;
if(cursor != null) { if(cursor != null) {
@ -160,6 +286,7 @@ public class DataUtils {
return count; return count;
} }
<<<<<<< HEAD
/** /**
* ID便 * ID便
* @param resolver ContentResolver * @param resolver ContentResolver
@ -173,6 +300,35 @@ public class DataUtils {
NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLDER, NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLDER,
new String [] {String.valueOf(type)}, new String [] {String.valueOf(type)},
null); null);
=======
/**
* ID便
* @param resolver ContentResolver
* @param noteId 便ID
* @param type 便
* @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) {
Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId),
null,
NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER,
new String [] {String.valueOf(type)},
null);
>>>>>>> 623b8465a7bfcf05a3ca2ec250315ad6977a9eb0
boolean exist = false; boolean exist = false;
if (cursor != null) { if (cursor != null) {
@ -184,6 +340,7 @@ public class DataUtils {
return exist; return exist;
} }
<<<<<<< HEAD
/** /**
* ID便 * ID便
* @param resolver ContentResolver * @param resolver ContentResolver
@ -193,6 +350,32 @@ public class DataUtils {
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);
=======
/**
* ID便
* @param resolver ContentResolver
* @param noteId 便ID
* @return
*/
/**
* @method existInNoteDatabase
* @description ID true false
* @author:
*/
/*
ID true false
resolver访
noteId ID
true false */
public static boolean existInNoteDatabase(ContentResolver resolver, long noteId) {
Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId),
null, null, null, null);
>>>>>>> 623b8465a7bfcf05a3ca2ec250315ad6977a9eb0
boolean exist = false; boolean exist = false;
if (cursor != null) { if (cursor != null) {
@ -204,6 +387,7 @@ public class DataUtils {
return exist; return exist;
} }
<<<<<<< HEAD
/** /**
* ID * ID
* @param resolver ContentResolver * @param resolver ContentResolver
@ -213,6 +397,32 @@ public class DataUtils {
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);
=======
/**
* ID
* @param resolver ContentResolver
* @param dataId ID
* @return
*/
/**
* @method existInNoteDatabase
* @description ID true false
* @author:
*/
/*
ID true false
resolver访
dataId ID
true false
*/
public static boolean existInDataDatabase(ContentResolver resolver, long dataId) {
Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_DATA_URI, dataId),
null, null, null, null);
>>>>>>> 623b8465a7bfcf05a3ca2ec250315ad6977a9eb0
boolean exist = false; boolean exist = false;
if (cursor != null) { if (cursor != null) {
@ -224,6 +434,7 @@ public class DataUtils {
return exist; return exist;
} }
<<<<<<< HEAD
/** /**
* *
* @param resolver ContentResolver * @param resolver ContentResolver
@ -243,10 +454,48 @@ public class DataUtils {
exist = true; exist = true;
} }
cursor.close(); cursor.close();
=======
/**
*
* @param resolver ContentResolver
* @param name
* @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) {
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 + "=?",
new String[] { name }, null);
boolean exist = false;
if(cursor != null) {
if(cursor.getCount() > 0) {
exist = true;
>>>>>>> 623b8465a7bfcf05a3ca2ec250315ad6977a9eb0
} }
return exist; return exist;
} }
<<<<<<< HEAD
/** /**
* *
* @param resolver ContentResolver * @param resolver ContentResolver
@ -259,6 +508,37 @@ public class DataUtils {
NoteColumns.PARENT_ID + "=?", NoteColumns.PARENT_ID + "=?",
new String[] { String.valueOf(folderId) }, new String[] { String.valueOf(folderId) },
null); null);
=======
/**
*
* @param resolver ContentResolver
* @param folderId ID
* @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) {
Cursor c = resolver.query(Notes.CONTENT_NOTE_URI,
new String[] { NoteColumns.WIDGET_ID, NoteColumns.WIDGET_TYPE },
NoteColumns.PARENT_ID + "=?",
new String[] { String.valueOf(folderId) },
null);
>>>>>>> 623b8465a7bfcf05a3ca2ec250315ad6977a9eb0
HashSet<AppWidgetAttribute> set = null; HashSet<AppWidgetAttribute> set = null;
if (c != null) { if (c != null) {
@ -280,6 +560,7 @@ public class DataUtils {
return set; return set;
} }
<<<<<<< HEAD
/** /**
* 便ID * 便ID
* @param resolver ContentResolver * @param resolver ContentResolver
@ -292,6 +573,43 @@ public class DataUtils {
CallNote.NOTE_ID + "=? AND " + CallNote.MIME_TYPE + "=?", CallNote.NOTE_ID + "=? AND " + CallNote.MIME_TYPE + "=?",
new String [] { String.valueOf(noteId), CallNote.CONTENT_ITEM_TYPE }, new String [] { String.valueOf(noteId), CallNote.CONTENT_ITEM_TYPE },
null); null);
=======
/**
* 便ID
* @param resolver ContentResolver
* @param noteId 便ID
* @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) {
Cursor cursor = resolver.query(Notes.CONTENT_DATA_URI,
new String [] { CallNote.PHONE_NUMBER },
CallNote.NOTE_ID + "=? AND " + CallNote.MIME_TYPE + "=?",
new String [] { String.valueOf(noteId), CallNote.CONTENT_ITEM_TYPE },
null);
>>>>>>> 623b8465a7bfcf05a3ca2ec250315ad6977a9eb0
if (cursor != null && cursor.moveToFirst()) { if (cursor != null && cursor.moveToFirst()) {
try { try {
@ -305,6 +623,7 @@ public class DataUtils {
return ""; return "";
} }
<<<<<<< HEAD
/** /**
* 便ID * 便ID
* @param resolver ContentResolver * @param resolver ContentResolver
@ -319,6 +638,40 @@ public class DataUtils {
+ CallNote.PHONE_NUMBER + ",?)", + CallNote.PHONE_NUMBER + ",?)",
new String [] { String.valueOf(callDate), CallNote.CONTENT_ITEM_TYPE, phoneNumber }, new String [] { String.valueOf(callDate), CallNote.CONTENT_ITEM_TYPE, phoneNumber },
null); null);
=======
/**
* 便ID
* @param resolver ContentResolver
* @param phoneNumber
* @param callDate
* @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) {
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 + ",?)",
new String [] { String.valueOf(callDate), CallNote.CONTENT_ITEM_TYPE, phoneNumber },
null);
>>>>>>> 623b8465a7bfcf05a3ca2ec250315ad6977a9eb0
if (cursor != null) { if (cursor != null) {
if (cursor.moveToFirst()) { if (cursor.moveToFirst()) {
@ -333,6 +686,7 @@ public class DataUtils {
return 0; return 0;
} }
<<<<<<< HEAD
/** /**
* 便ID便 * 便ID便
* @param resolver ContentResolver * @param resolver ContentResolver
@ -345,6 +699,40 @@ public class DataUtils {
NoteColumns.ID + "=?", NoteColumns.ID + "=?",
new String [] { String.valueOf(noteId)}, new String [] { String.valueOf(noteId)},
null); null);
=======
/**
* 便ID便
* @param resolver ContentResolver
* @param noteId 便ID
* @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) {
Cursor cursor = resolver.query(Notes.CONTENT_NOTE_URI,
new String [] { NoteColumns.SNIPPET },
NoteColumns.ID + "=?",
new String [] { String.valueOf(noteId)},
null);
>>>>>>> 623b8465a7bfcf05a3ca2ec250315ad6977a9eb0
if (cursor != null) { if (cursor != null) {
String snippet = ""; String snippet = "";
@ -357,6 +745,7 @@ public class DataUtils {
throw new IllegalArgumentException("Note is not found with id: " + noteId); throw new IllegalArgumentException("Note is not found with id: " + noteId);
} }
<<<<<<< HEAD
/** /**
* 便 * 便
* @param snippet 便 * @param snippet 便
@ -369,10 +758,39 @@ public class DataUtils {
if (index != -1) { if (index != -1) {
snippet = snippet.substring(0, index); snippet = snippet.substring(0, index);
} }
=======
/**
* 便
* @param snippet 便
* @return 便
*/
/**
* @method getFormattedSnippet
* @description
* @author:
*/
/*
snippet
*/
public static String getFormattedSnippet(String snippet) {
if (snippet != null) {
snippet = snippet.trim();
int index = snippet.indexOf('\n');
if (index != -1) {
snippet = snippet.substring(0, index);
>>>>>>> 623b8465a7bfcf05a3ca2ec250315ad6977a9eb0
} }
return snippet; return snippet;
} }
<<<<<<< HEAD
/** /**
* 便 * 便
* @param resolver ContentResolver * @param resolver ContentResolver
@ -387,4 +805,34 @@ public class DataUtils {
null); null);
return cursor; return cursor;
} }
=======
/**
* 便
* @param resolver ContentResolver
* @param query
* @return Cursor
*/
/**
* @method searchInNoteDatabase
* @description ID Cursor
* @author:
*/
/*
ID Cursor
resolver访
query
Cursor
*/
public static Cursor searchInNoteDatabase(ContentResolver resolver, String query) {
Cursor cursor = resolver.query(Notes.CONTENT_DATA_URI,
new String[]{NoteColumns.ID},
Notes.DataColumns.CONTENT + " LIKE'%" + query +"%'",
null,
null);
return cursor;
>>>>>>> 623b8465a7bfcf05a3ca2ec250315ad6977a9eb0
} }

@ -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 字段常量

@ -14,6 +14,17 @@
* limitations under the License. * limitations under the License.
*/ */
/**
*
* @ProjectName: minode
* @Package: net.micode.notes.data
* @ClassName: ResourceParser
* @Description:
便 ID
使
* @Author:
*/
package net.micode.notes.tool; package net.micode.notes.tool;
import android.content.Context; import android.content.Context;
@ -42,6 +53,18 @@ public class ResourceParser {
public static final int BG_DEFAULT_FONT_SIZE = TEXT_MEDIUM; public static final int BG_DEFAULT_FONT_SIZE = TEXT_MEDIUM;
// 备忘录背景资源类 // 备忘录背景资源类
/**
* @method NoteBgResources
* @description ID
* @author:
*/
/*
ID
BG_EDIT_RESOURCES ID
BG_EDIT_TITLE_RESOURCES ID */
public static class NoteBgResources { public static class NoteBgResources {
private final static int [] BG_EDIT_RESOURCES = new int [] { private final static int [] BG_EDIT_RESOURCES = new int [] {
R.drawable.edit_yellow, R.drawable.edit_yellow,
@ -60,17 +83,56 @@ public class ResourceParser {
}; };
// 获取备忘录背景资源 // 获取备忘录背景资源
/**
* @method getNoteBgResource
* @description ID ID访 BG_EDIT_RESOURCES ID
* @author:
*/
/*
ID ID访 BG_EDIT_RESOURCES ID
id ID
ID
*/
public static int getNoteBgResource(int id) { public static int getNoteBgResource(int id) {
return BG_EDIT_RESOURCES[id]; return BG_EDIT_RESOURCES[id];
} }
// 获取备忘录标题背景资源 // 获取备忘录标题背景资源
/**
* @method getNoteTitleBgResource
* @description ID ID访 BG_EDIT_TITLE_RESOURCES ID
* @author:
*/
/*
ID ID访 BG_EDIT_TITLE_RESOURCES ID
id ID
ID
*/
public static int getNoteTitleBgResource(int id) { public static int getNoteTitleBgResource(int id) {
return BG_EDIT_TITLE_RESOURCES[id]; return BG_EDIT_TITLE_RESOURCES[id];
} }
} }
// 获取默认背景ID // 获取默认背景ID
/**
* @method getDefaultBgId
* @description ID
ID ID
* @author:
*/
/*
ID ID ID
context访
ID
*/
public static int getDefaultBgId(Context context) { public static int getDefaultBgId(Context context) {
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean( if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
NotesPreferenceActivity.PREFERENCE_SET_BG_COLOR_KEY, false)) { NotesPreferenceActivity.PREFERENCE_SET_BG_COLOR_KEY, false)) {
@ -81,6 +143,21 @@ public class ResourceParser {
} }
// 备忘录项目背景资源类 // 备忘录项目背景资源类
/**
* @method NoteItemBgResources
* @description ID
* @author:
*/
/*
ID
BG_FIRST_RESOURCES ID
BG_NORMAL_RESOURCES ID
BG_LAST_RESOURCES ID
BG_SINGLE_RESOURCES ID
*/
public static class NoteItemBgResources { public static class NoteItemBgResources {
private final static int [] BG_FIRST_RESOURCES = new int [] { private final static int [] BG_FIRST_RESOURCES = new int [] {
R.drawable.list_yellow_up, R.drawable.list_yellow_up,
@ -115,32 +192,116 @@ public class ResourceParser {
}; };
// 获取备忘录第一个背景资源 // 获取备忘录第一个背景资源
/**
* @method getNoteBgFirstRes
* @description ID
* @author:
*/
/*
ID
id ID
ID
*/
public static int getNoteBgFirstRes(int id) { public static int getNoteBgFirstRes(int id) {
return BG_FIRST_RESOURCES[id]; return BG_FIRST_RESOURCES[id];
} }
// 获取备忘录最后一个背景资源 // 获取备忘录最后一个背景资源
/**
* @method getNoteBgLastRes
* @description ID ID访 BG_FIRST_RESOURCES
ID
* @author:
*/
/*
ID ID访 BG_FIRST_RESOURCES ID
id ID
ID
*/
public static int getNoteBgLastRes(int id) { public static int getNoteBgLastRes(int id) {
return BG_LAST_RESOURCES[id]; return BG_LAST_RESOURCES[id];
} }
// 获取备忘录单独背景资源 // 获取备忘录单独背景资源
/**
* @method getNoteBgSingleRes
* @description ID ID访 BG_FIRST_RESOURCES
ID
* @author:
*/
/*
ID ID访 BG_LAST_RESOURCES ID
id ID
ID
*/
public static int getNoteBgSingleRes(int id) { public static int getNoteBgSingleRes(int id) {
return BG_SINGLE_RESOURCES[id]; return BG_SINGLE_RESOURCES[id];
} }
// 获取备忘录正常背景资源 // 获取备忘录正常背景资源
/**
* @method getNoteBgNormalRes
* @description ID ID访 BG_FIRST_RESOURCES
ID
* @author:
*/
/*
ID ID访 BG_SINGLE_RESOURCES ID
id ID
ID
*/
public static int getNoteBgNormalRes(int id) { public static int getNoteBgNormalRes(int id) {
return BG_NORMAL_RESOURCES[id]; return BG_NORMAL_RESOURCES[id];
} }
// 获取文件夹背景资源 // 获取文件夹背景资源
/**
* @method getFolderBgRes
* @description ID ID访 BG_FIRST_RESOURCES
ID
* @author:
*/
/*
ID ID访 BG_NORMAL_RESOURCES ID
id ID
ID
*/
public static int getFolderBgRes() { public static int getFolderBgRes() {
return R.drawable.list_folder; return R.drawable.list_folder;
} }
} }
// 小部件背景资源类 // 小部件背景资源类
/**
*
* @ProjectName: minode
* @Package: net.micode.notes.data
* @ClassName: WidgetBgResources
* @Description: ID
* @Author:
*/
/*
ID
BG_2X_RESOURCES 2x ID
BG_4X_RESOURCES 4x ID
*/
public static class WidgetBgResources { public static class WidgetBgResources {
private final static int [] BG_2X_RESOURCES = new int [] { private final static int [] BG_2X_RESOURCES = new int [] {
R.drawable.widget_2x_yellow, R.drawable.widget_2x_yellow,
@ -151,6 +312,18 @@ public class ResourceParser {
}; };
// 获取2x小部件背景资源 // 获取2x小部件背景资源
/**
* @method getWidget2xBgResource
* @description ID 2x ID访 BG_2X_RESOURCES ID
* @author:
*/
/*
ID 2x ID访 BG_2X_RESOURCES ID
id ID
2x ID
*/
public static int getWidget2xBgResource(int id) { public static int getWidget2xBgResource(int id) {
return BG_2X_RESOURCES[id]; return BG_2X_RESOURCES[id];
} }
@ -164,12 +337,39 @@ public class ResourceParser {
}; };
// 获取4x小部件背景资源 // 获取4x小部件背景资源
/**
* @method getWidget4xBgResource
* @description ID 4x ID访 BG_4X_RESOURCES ID
* @author:
*/
/*
ID 4x ID访 BG_4X_RESOURCES ID
id ID
4x ID
*/
public static int getWidget4xBgResource(int id) { public static int getWidget4xBgResource(int id) {
return BG_4X_RESOURCES[id]; return BG_4X_RESOURCES[id];
} }
} }
// 文本外观资源类 // 文本外观资源类
/**
*
* @ProjectName: minode
* @Package: net.micode.notes.data
* @ClassName: TextAppearanceResources
* @Description: ID
* @Author:
*/
/*
ID
TEXTAPPEARANCE_RESOURCES ID
*/
public static class TextAppearanceResources { public static class TextAppearanceResources {
private final static int [] TEXTAPPEARANCE_RESOURCES = new int [] { private final static int [] TEXTAPPEARANCE_RESOURCES = new int [] {
R.style.TextAppearanceNormal, R.style.TextAppearanceNormal,
@ -179,6 +379,20 @@ public class ResourceParser {
}; };
// 获取文本外观资源 // 获取文本外观资源
/**
* @method getTexAppearanceResource
* @description ID ID ID ID
访 TEXTAPPEARANCE_RESOURCES ID
* @author:
*/
/*
ID ID ID ID
访 TEXTAPPEARANCE_RESOURCES ID
id ID
ID
*/
public static int getTexAppearanceResource(int id) { public static int getTexAppearanceResource(int id) {
/** /**
* HACKME: Fix bug of store the resource id in shared preference. * HACKME: Fix bug of store the resource id in shared preference.
@ -192,6 +406,16 @@ public class ResourceParser {
} }
// 获取资源大小 // 获取资源大小
/**
* @method getResourcesSize
* @description TEXTAPPEARANCE_RESOURCES
* @author:
*/
/*
TEXTAPPEARANCE_RESOURCES
*/
public static int getResourcesSize() { public static int getResourcesSize() {
return TEXTAPPEARANCE_RESOURCES.length; return TEXTAPPEARANCE_RESOURCES.length;
} }

Loading…
Cancel
Save