main
liuyuxia 7 months ago
parent f3aa50205a
commit 2c9401767f

@ -14,468 +14,7 @@
* limitations under the License.
*/
<<<<<<< HEAD
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.database.Cursor;
@ -727,7 +266,7 @@ public class BackupUtils {
+ NoteColumns.ID + "=" + Notes.ID_CALL_RECORD_FOLDER, null, null);
if (folderCursor != null) {
if (folderCursor.moveToFirst( ) {
if (folderCursor.moveToFirst()) {
do {
// 打印文件夹名称
String folderName = "";
@ -759,78 +298,78 @@ public class BackupUtils {
ps.println(String.format(getFormat(FORMAT_NOTE_DATE), DateFormat.format(
mContext.getString(R.string.format_datetime_mdhm),
noteCursor.getLong(NOTE_COLUMN_MODIFIED_DATE))));
// 查询属于该便签的数据
// 查询
// 属于该便签的数据
String noteId = noteCursor.getString(NOTE_COLUMN_ID);
exportNoteToText(noteId, ps);
} while (noteCursor.moveToNext());
}
noteCursor.close();
}
ps.close();
return STATE_SUCCESS;
}
} while (noteCursor.moveToNext());
}
noteCursor.close();
}
ps.close();
/**
*
* @return
*/
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);
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
} catch (NullPointerException e) {
e.printStackTrace();
return null;
}
return ps;
}
return STATE_SUCCESS;
}
/**
* SD
* @param context
* @param filePathResId ID
* @param fileNameFormatResId ID
* @return
*
* @return
*/
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) {
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);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
return null;
} catch (NullPointerException e) {
e.printStackTrace();
return null;
}
return ps;
}
}
/**
* SD
* @param context
* @param filePathResId ID
* @param fileNameFormatResId ID
* @return
*/
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 null;
return file;
} catch (SecurityException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// 异常处理
return null;
}

@ -13,33 +13,6 @@
* See the License for the specific language governing permissions and
* 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;
import android.content.ContentProviderOperation;
@ -60,38 +33,16 @@ import net.micode.notes.ui.NotesListAdapter.AppWidgetAttribute;
import java.util.ArrayList;
import java.util.HashSet;
<<<<<<< HEAD
/**
* 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 static final String TAG = "DataUtils";
/**
* 便
* @param resolver ContentResolver
* @param resolver ContentResolverContentProvider
* @param ids 便ID
* @return truefalse
*/
@ -129,40 +80,14 @@ public class DataUtils {
}
return false;
}
<<<<<<< HEAD
/**
* 便
* @param resolver ContentResolver
* @param resolver ContentResolverContentProvider
* @param id 便ID
* @param srcFolderId 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) {
ContentValues values = new ContentValues();
values.put(NoteColumns.PARENT_ID, desFolderId);
@ -171,10 +96,9 @@ desFolderId目标文件夹 ID*/
resolver.update(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id), values, null, null);
}
<<<<<<< HEAD
/**
* 便
* @param resolver ContentResolver
* @param resolver ContentResolverContentProvider
* @param ids 便ID
* @param folderId ID
* @return truefalse
@ -184,29 +108,6 @@ desFolderId目标文件夹 ID*/
Log.d(TAG, "the ids is null");
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>();
for (long id : ids) {
@ -232,10 +133,9 @@ public static boolean batchMoveToFolder(ContentResolver resolver, HashSet<Long>
return false;
}
<<<<<<< HEAD
/**
*
* @param resolver ContentResolver
* @param resolver ContentResolverContentProvider
* @return
*/
public static int getUserFolderCount(ContentResolver resolver) {
@ -244,32 +144,6 @@ public static boolean batchMoveToFolder(ContentResolver resolver, HashSet<Long>
NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>?",
new String[] { String.valueOf(Notes.TYPE_FOLDER), String.valueOf(Notes.ID_TRASH_FOLDER)},
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;
if(cursor != null) {
@ -286,10 +160,9 @@ public static int getUserFolderCount(ContentResolver resolver) {
return count;
}
<<<<<<< HEAD
/**
* ID便
* @param resolver ContentResolver
* @param resolver ContentResolverContentProvider
* @param noteId 便ID
* @param type 便
* @return truefalse
@ -300,35 +173,6 @@ public static int getUserFolderCount(ContentResolver resolver) {
NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLDER,
new String [] {String.valueOf(type)},
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;
if (cursor != null) {
@ -340,42 +184,15 @@ public static boolean visibleInNoteDatabase(ContentResolver resolver, long noteI
return exist;
}
<<<<<<< HEAD
/**
* ID便
* @param resolver ContentResolver
* @param resolver ContentResolverContentProvider
* @param noteId 便ID
* @return truefalse
*/
public static boolean existInNoteDatabase(ContentResolver resolver, long noteId) {
Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId),
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;
if (cursor != null) {
@ -387,42 +204,15 @@ public static boolean existInNoteDatabase(ContentResolver resolver, long noteId)
return exist;
}
<<<<<<< HEAD
/**
* ID
* @param resolver ContentResolver
* @param resolver ContentResolverContentProvider
* @param dataId ID
* @return truefalse
*/
public static boolean existInDataDatabase(ContentResolver resolver, long dataId) {
Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_DATA_URI, dataId),
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;
if (cursor != null) {
@ -434,10 +224,9 @@ public static boolean existInDataDatabase(ContentResolver resolver, long dataId)
return exist;
}
<<<<<<< HEAD
/**
*
* @param resolver ContentResolver
* @param resolver ContentResolverContentProvider
* @param name
* @return truefalse
*/
@ -450,55 +239,16 @@ public static boolean existInDataDatabase(ContentResolver resolver, long dataId)
boolean exist = false;
if(cursor != null) {
if(cursor.getCount() > 0) {
exist = true;
exist = true;
}
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;
}
<<<<<<< HEAD
/**
*
* @param resolver ContentResolver
* @param resolver ContentResolverContentProvider
* @param folderId ID
* @return
*/
@ -508,37 +258,6 @@ public static boolean checkVisibleFolderName(ContentResolver resolver, String na
NoteColumns.PARENT_ID + "=?",
new String[] { String.valueOf(folderId) },
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;
if (c != null) {
@ -560,10 +279,9 @@ public static HashSet<AppWidgetAttribute> getFolderNoteWidget(ContentResolver re
return set;
}
<<<<<<< HEAD
/**
* 便ID
* @param resolver ContentResolver
* @param resolver ContentResolverContentProvider
* @param noteId 便ID
* @return
*/
@ -573,43 +291,6 @@ public static HashSet<AppWidgetAttribute> getFolderNoteWidget(ContentResolver re
CallNote.NOTE_ID + "=? AND " + CallNote.MIME_TYPE + "=?",
new String [] { String.valueOf(noteId), CallNote.CONTENT_ITEM_TYPE },
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()) {
try {
@ -623,10 +304,9 @@ public static String getCallNumberByNoteId(ContentResolver resolver, long noteId
return "";
}
<<<<<<< HEAD
/**
* 便ID
* @param resolver ContentResolver
* @param resolver ContentResolverContentProvider
* @param phoneNumber
* @param callDate
* @return 便ID
@ -638,40 +318,6 @@ public static String getCallNumberByNoteId(ContentResolver resolver, long noteId
+ CallNote.PHONE_NUMBER + ",?)",
new String [] { String.valueOf(callDate), CallNote.CONTENT_ITEM_TYPE, phoneNumber },
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.moveToFirst()) {
@ -686,10 +332,9 @@ public static long getNoteIdByPhoneNumberAndCallDate(ContentResolver resolver, S
return 0;
}
<<<<<<< HEAD
/**
* 便ID便
* @param resolver ContentResolver
* @param resolver ContentResolverContentProvider
* @param noteId 便ID
* @return 便
*/
@ -699,40 +344,6 @@ public static long getNoteIdByPhoneNumberAndCallDate(ContentResolver resolver, S
NoteColumns.ID + "=?",
new String [] { String.valueOf(noteId)},
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) {
String snippet = "";
@ -745,7 +356,6 @@ public static String getSnippetById(ContentResolver resolver, long noteId) {
throw new IllegalArgumentException("Note is not found with id: " + noteId);
}
<<<<<<< HEAD
/**
* 便
* @param snippet 便
@ -758,42 +368,13 @@ public static String getSnippetById(ContentResolver resolver, long noteId) {
if (index != -1) {
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;
}
<<<<<<< HEAD
/**
* 便
* @param resolver ContentResolver
* @param resolver ContentResolverContentProvider
* @param query
* @return Cursor
*/
@ -805,34 +386,4 @@ public static String getFormattedSnippet(String snippet) {
null);
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,169 +14,245 @@
* 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;
// 该类用于定义 Google 任务相关的 JSON 字段常量
/**
* GTaskStringUtils Google JSON
* Google API JSON
*/
public class GTaskStringUtils {
/**
* JSON ID
*/
public final static String GTASK_JSON_ACTION_ID = "action_id";
/**
* JSON
*/
public final static String GTASK_JSON_ACTION_LIST = "action_list";
/**
* JSON
*/
public final static String GTASK_JSON_ACTION_TYPE = "action_type";
/**
* JSON
*/
public final static String GTASK_JSON_ACTION_TYPE_CREATE = "create";
/**
* JSON
*/
public final static String GTASK_JSON_ACTION_TYPE_GETALL = "get_all";
/**
* JSON
*/
public final static String GTASK_JSON_ACTION_TYPE_MOVE = "move";
/**
* JSON
*/
public final static String GTASK_JSON_ACTION_TYPE_UPDATE = "update";
/**
* JSON ID
*/
public final static String GTASK_JSON_CREATOR_ID = "creator_id";
/**
* JSON
*/
public final static String GTASK_JSON_CHILD_ENTITY = "child_entity";
/**
* JSON
*/
public final static String GTASK_JSON_CLIENT_VERSION = "client_version";
/**
* JSON
*/
public final static String GTASK_JSON_COMPLETED = "completed";
/**
* JSON ID
*/
public final static String GTASK_JSON_CURRENT_LIST_ID = "current_list_id";
/**
* JSON ID
*/
public final static String GTASK_JSON_DEFAULT_LIST_ID = "default_list_id";
/**
* JSON
*/
public final static String GTASK_JSON_DELETED = "deleted";
/**
* JSON
*/
public final static String GTASK_JSON_DEST_LIST = "dest_list";
/**
* JSON
*/
public final static String GTASK_JSON_DEST_PARENT = "dest_parent";
/**
* JSON
*/
public final static String GTASK_JSON_DEST_PARENT_TYPE = "dest_parent_type";
/**
* JSON
*/
public final static String GTASK_JSON_ENTITY_DELTA = "entity_delta";
/**
* JSON
*/
public final static String GTASK_JSON_ENTITY_TYPE = "entity_type";
/**
* JSON
*/
public final static String GTASK_JSON_GET_DELETED = "get_deleted";
/**
* JSON ID
*/
public final static String GTASK_JSON_ID = "id";
/**
* JSON
*/
public final static String GTASK_JSON_INDEX = "index";
/**
* JSON
*/
public final static String GTASK_JSON_LAST_MODIFIED = "last_modified";
/**
* JSON
*/
public final static String GTASK_JSON_LATEST_SYNC_POINT = "latest_sync_point";
/**
* JSON ID
*/
public final static String GTASK_JSON_LIST_ID = "list_id";
/**
* JSON
*/
public final static String GTASK_JSON_LISTS = "lists";
/**
* JSON
*/
public final static String GTASK_JSON_NAME = "name";
/**
* JSON ID
*/
public final static String GTASK_JSON_NEW_ID = "new_id";
/**
* JSON 便
*/
public final static String GTASK_JSON_NOTES = "notes";
/**
* JSON ID
*/
public final static String GTASK_JSON_PARENT_ID = "parent_id";
/**
* JSON ID
*/
public final static String GTASK_JSON_PRIOR_SIBLING_ID = "prior_sibling_id";
/**
* JSON
*/
public final static String GTASK_JSON_RESULTS = "results";
/**
* JSON
*/
public final static String GTASK_JSON_SOURCE_LIST = "source_list";
/**
* JSON
*/
public final static String GTASK_JSON_TASKS = "tasks";
/**
* JSON
*/
public final static String GTASK_JSON_TYPE = "type";
/**
* JSON
*/
public final static String GTASK_JSON_TYPE_GROUP = "GROUP";
/**
* JSON
*/
public final static String GTASK_JSON_TYPE_TASK = "TASK";
/**
* JSON
*/
public final static String GTASK_JSON_USER = "user";
/**
* MIUI
*/
public final static String MIUI_FOLDER_PREFFIX = "[MIUI_Notes]";
/**
*
*/
public final static String FOLDER_DEFAULT = "Default";
/**
*
*/
public final static String FOLDER_CALL_NOTE = "Call_Note";
/**
*
*/
public final static String FOLDER_META = "METADATA";
/**
* Google ID
*/
public final static String META_HEAD_GTASK_ID = "meta_gid";
/**
* 便
*/
public final static String META_HEAD_NOTE = "meta_note";
/**
*
*/
public final static String META_HEAD_DATA = "meta_data";
/**
* 便
*/
public final static String META_NOTE_NAME = "[META INFO] DON'T UPDATE AND DELETE";
}

@ -15,16 +15,7 @@
*/
/**
*
* @ProjectName: minode
* @Package: net.micode.notes.data
* @ClassName: ResourceParser
* @Description:
便 ID
使
* @Author:
*/
package net.micode.notes.tool;
import android.content.Context;
@ -33,40 +24,43 @@ import android.preference.PreferenceManager;
import net.micode.notes.R;
import net.micode.notes.ui.NotesPreferenceActivity;
// 资源解析器类
/**
* 便
*/
public class ResourceParser {
public static final int YELLOW = 0;
public static final int BLUE = 1;
public static final int WHITE = 2;
public static final int GREEN = 3;
public static final int RED = 4;
/**
* 便
*/
public static final int YELLOW = 0; // 黄色
public static final int BLUE = 1; // 蓝色
public static final int WHITE = 2; // 白色
public static final int GREEN = 3; // 绿色
public static final int RED = 4; // 红色
/**
* ID
*/
public static final int BG_DEFAULT_COLOR = YELLOW;
public static final int TEXT_SMALL = 0;
public static final int TEXT_MEDIUM = 1;
public static final int TEXT_LARGE = 2;
public static final int TEXT_SUPER = 3;
/**
*
*/
public static final int TEXT_SMALL = 0; // 小
public static final int TEXT_MEDIUM = 1; // 中
public static final int TEXT_LARGE = 2; // 大
public static final int TEXT_SUPER = 3; // 超大
/**
* ID
*/
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 {
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_blue,
R.drawable.edit_white,
@ -74,7 +68,7 @@ BG_EDIT_TITLE_RESOURCES存储不同颜色的笔记编辑标题背景资源 ID
R.drawable.edit_red
};
private final static int [] BG_EDIT_TITLE_RESOURCES = new int [] {
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,
@ -82,57 +76,30 @@ BG_EDIT_TITLE_RESOURCES存储不同颜色的笔记编辑标题背景资源 ID
R.drawable.edit_title_red
};
// 获取备忘录背景资源
/**
* @method getNoteBgResource
* @description ID ID访 BG_EDIT_RESOURCES ID
* @author:
*/
/*
ID ID访 BG_EDIT_RESOURCES ID
id ID
ID
*/
/**
* 便ID
* @param id ID
* @return ID
*/
public static int getNoteBgResource(int 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
*/
/**
* 便ID
* @param id ID
* @return ID
*/
public static int getNoteTitleBgResource(int id) {
return BG_EDIT_TITLE_RESOURCES[id];
}
}
// 获取默认背景ID
/**
* @method getDefaultBgId
* @description ID
ID ID
* @author:
*/
/*
ID ID ID
context访
ID
*/
/**
* ID
* @param context
* @return ID
*/
public static int getDefaultBgId(Context context) {
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
NotesPreferenceActivity.PREFERENCE_SET_BG_COLOR_KEY, false)) {
@ -142,24 +109,11 @@ context上下文对象用于访问偏好设置。
}
}
// 备忘录项目背景资源类
/**
* @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 {
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_blue_up,
R.drawable.list_white_up,
@ -167,7 +121,7 @@ BG_SINGLE_RESOURCES存储不同颜色的笔记项单个背景资源 ID 的数
R.drawable.list_red_up
};
private final static int [] BG_NORMAL_RESOURCES = new int [] {
private final static int[] BG_NORMAL_RESOURCES = new int[]{
R.drawable.list_yellow_middle,
R.drawable.list_blue_middle,
R.drawable.list_white_middle,
@ -175,15 +129,15 @@ BG_SINGLE_RESOURCES存储不同颜色的笔记项单个背景资源 ID 的数
R.drawable.list_red_middle
};
private final static int [] BG_LAST_RESOURCES = new int [] {
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_red_down
};
private final static int [] BG_SINGLE_RESOURCES = new int [] {
private final static int[] BG_SINGLE_RESOURCES = new int[]{
R.drawable.list_yellow_single,
R.drawable.list_blue_single,
R.drawable.list_white_single,
@ -191,144 +145,73 @@ BG_SINGLE_RESOURCES存储不同颜色的笔记项单个背景资源 ID 的数
R.drawable.list_red_single
};
// 获取备忘录第一个背景资源
/**
* @method getNoteBgFirstRes
* @description ID
* @author:
*/
/*
ID
id ID
ID
*/
/**
* 便ID
* @param id ID
* @return ID
*/
public static int getNoteBgFirstRes(int 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
*/
/**
* 便ID
* @param id ID
* @return ID
*/
public static int getNoteBgLastRes(int 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
*/
* 便ID
* @param id ID
* @return ID
*/
public static int getNoteBgSingleRes(int 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
*/
/**
* 便ID
* @param id ID
* @return ID
*/
public static int getNoteBgNormalRes(int 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
*/
/**
* ID
* @return ID
*/
public static int getFolderBgRes() {
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 {
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_blue,
R.drawable.widget_2x_white,
R.drawable.widget_2x_green,
R.drawable.widget_2x_red,
R.drawable.widget_2x_red
};
// 获取2x小部件背景资源
/**
* @method getWidget2xBgResource
* @description ID 2x ID访 BG_2X_RESOURCES ID
* @author:
*/
/*
ID 2x ID访 BG_2X_RESOURCES ID
id ID
2x ID
*/
/**
* 2xID
* @param id ID
* @return ID
*/
public static int getWidget2xBgResource(int id) {
return BG_2X_RESOURCES[id];
}
private final static int [] BG_4X_RESOURCES = new int [] {
private final static int[] BG_4X_RESOURCES = new int[]{
R.drawable.widget_4x_yellow,
R.drawable.widget_4x_blue,
R.drawable.widget_4x_white,
@ -336,86 +219,43 @@ id小部件背景颜色的 ID。
R.drawable.widget_4x_red
};
// 获取4x小部件背景资源
/**
* @method getWidget4xBgResource
* @description ID 4x ID访 BG_4X_RESOURCES ID
* @author:
*/
/*
ID 4x ID访 BG_4X_RESOURCES ID
id ID
4x ID
*/
/**
* 4xID
* @param id ID
* @return ID
*/
public static int getWidget4xBgResource(int 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 {
private final static int [] TEXTAPPEARANCE_RESOURCES = new int [] {
private final static int[] TEXTAPPEARANCE_RESOURCES = new int[]{
R.style.TextAppearanceNormal,
R.style.TextAppearanceMedium,
R.style.TextAppearanceLarge,
R.style.TextAppearanceSuper
};
// 获取文本外观资源
/**
* @method getTexAppearanceResource
* @description ID ID ID ID
访 TEXTAPPEARANCE_RESOURCES ID
* @author:
*/
/*
ID ID ID ID
访 TEXTAPPEARANCE_RESOURCES ID
id ID
ID
*/
/**
* ID
* @param id ID
* @return ID
*/
public static int getTexAppearanceResource(int id) {
/**
* HACKME: Fix bug of store the resource id in shared preference.
* The id may larger than the length of resources, in this case,
* return the {@link ResourceParser#BG_DEFAULT_FONT_SIZE}
*/
if (id >= TEXTAPPEARANCE_RESOURCES.length) {
return BG_DEFAULT_FONT_SIZE;
return TEXTAPPEARANCE_RESOURCES[BG_DEFAULT_FONT_SIZE];
}
return TEXTAPPEARANCE_RESOURCES[id];
}
// 获取资源大小
/**
* @method getResourcesSize
* @description TEXTAPPEARANCE_RESOURCES
* @author:
*/
/*
TEXTAPPEARANCE_RESOURCES
*/
/**
*
* @return
*/
public static int getResourcesSize() {
return TEXTAPPEARANCE_RESOURCES.length;
}

Loading…
Cancel
Save