Signed-off-by: lilium-saber <WR364999428@hotmail.com>
master
lilium-saber 2 years ago
parent 798854d76f
commit e8a5e6c146

@ -36,20 +36,22 @@ public class Notes { // 定义类,给模块的其他类提供变量定义
public static final int ID_CALL_RECORD_FOLDER = -2; public static final int ID_CALL_RECORD_FOLDER = -2;
public static final int ID_TRASH_FOLER = -3; public static final int ID_TRASH_FOLER = -3;
public static final String INTENT_EXTRA_ALERT_DATE = "net.micode.notes.alert_date"; public static final String INTENT_EXTRA_ALERT_DATE = "net.micode.notes.alert_date";// 设置提醒日期
public static final String INTENT_EXTRA_BACKGROUND_ID = "net.micode.notes.background_color_id"; public static final String INTENT_EXTRA_BACKGROUND_ID = "net.micode.notes.background_color_id";
public static final String INTENT_EXTRA_WIDGET_ID = "net.micode.notes.widget_id"; public static final String INTENT_EXTRA_WIDGET_ID = "net.micode.notes.widget_id";
public static final String INTENT_EXTRA_WIDGET_TYPE = "net.micode.notes.widget_type"; public static final String INTENT_EXTRA_WIDGET_TYPE = "net.micode.notes.widget_type";
public static final String INTENT_EXTRA_FOLDER_ID = "net.micode.notes.folder_id"; public static final String INTENT_EXTRA_FOLDER_ID = "net.micode.notes.folder_id";
public static final String INTENT_EXTRA_CALL_DATE = "net.micode.notes.call_date"; public static final String INTENT_EXTRA_CALL_DATE = "net.micode.notes.call_date";
public static final String INTENT_EXTRA_LOCK = "net.micode.notes.lock";// 设置锁
public static final int TYPE_WIDGET_INVALIDE = -1; public static final int TYPE_WIDGET_INVALIDE = -1;
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;
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; // 获取通话记录
} }
/** /**
@ -199,6 +201,23 @@ public class Notes { // 定义类,给模块的其他类提供变量定义
* </P> * </P>
*/ */
public static final String VERSION = "version"; // 版本名称 public static final String VERSION = "version"; // 版本名称
/*
* The lock status
* <P>
* Type : INTEGER (long)
* </P>
*/
public static final String LOCKED = "locked"; // 锁定状态 ****
/*
* The picture
* <P>
* Type : BLOB
* </P>
*/
public static final String PICTURE = "picture"; // 图片****
} }
public interface DataColumns { // 定义数据变量接口 public interface DataColumns { // 定义数据变量接口
@ -296,7 +315,7 @@ public class Notes { // 定义类,给模块的其他类提供变量定义
public static final String DATA5 = "data5"; public static final String DATA5 = "data5";
} }
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
* <P> * <P>
@ -308,14 +327,14 @@ public class Notes { // 定义类,给模块的其他类提供变量定义
public static final int MODE_CHECK_LIST = 1; // 列表检查模式 public static final int MODE_CHECK_LIST = 1; // 列表检查模式
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/text_note"; public static final String CONTENT_TYPE = "vnd.android.cursor.dir/text_note";// 访问数据表类型,
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/text_note"; public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/text_note";// 访问数据表类型
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note");// 访问数据表uri public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note");// 访问数据表uri
} }
public static final class CallNote implements DataColumns { public static final class CallNote implements DataColumns { // 定义电话记录数据列, implements是实现接口
/** /**
* Call date for this record * Call date for this record
* <P> * <P>
@ -332,9 +351,9 @@ public class Notes { // 定义类,给模块的其他类提供变量定义
*/ */
public static final String PHONE_NUMBER = DATA3; // 呼叫号码 public static final String PHONE_NUMBER = DATA3; // 呼叫号码
public static final String CONTENT_TYPE = "vnd.android.cursor.dir/call_note"; public static final String CONTENT_TYPE = "vnd.android.cursor.dir/call_note";// 访问电话记录类型
public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/call_note"; public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/call_note";// 访问电话记录类型
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/call_note");// 访问电话记录uri public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/call_note");// 访问电话记录uri
} }

@ -42,7 +42,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { // 该类为便签SQ
private static NotesDatabaseHelper mInstance; // 创建NotesDatabaseHelper类对象 private static NotesDatabaseHelper mInstance; // 创建NotesDatabaseHelper类对象
private static final String CREATE_NOTE_TABLE_SQL = // SQL语句创建便签表包含ID、最后修改日期、背景颜色、便签数等在Notes类中的内容 private static final String CREATE_NOTE_TABLE_SQL = // SQL语句创建便签表包含ID、父ID、提醒日期、背景颜色ID、创建日期、是否有附件、修改日期、便签数、便签内容、便签类型、便签小部件ID、便签小部件类型、同步ID、本地修改时间、原始ID、便签的同步状态、版本号
"CREATE TABLE " + TABLE.NOTE + "(" + "CREATE TABLE " + TABLE.NOTE + "(" +
NoteColumns.ID + " INTEGER PRIMARY KEY," + NoteColumns.ID + " INTEGER PRIMARY KEY," +
NoteColumns.PARENT_ID + " INTEGER NOT NULL DEFAULT 0," + NoteColumns.PARENT_ID + " INTEGER NOT NULL DEFAULT 0," +
@ -61,6 +61,10 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { // 该类为便签SQ
NoteColumns.ORIGIN_PARENT_ID + " INTEGER NOT NULL DEFAULT 0," + NoteColumns.ORIGIN_PARENT_ID + " INTEGER NOT NULL DEFAULT 0," +
NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," + NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," +
NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0" + NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0" +
NoteColumns.LOCKED + " INTEGER NOT NULL DEFAULT 0" +
NoteColumns.PICTURE_URI + " TEXT NOT NULL DEFAULT ''," +
")"; ")";
private static final String CREATE_DATA_TABLE_SQL = // 创建数据表的SQL语句 private static final String CREATE_DATA_TABLE_SQL = // 创建数据表的SQL语句
@ -286,14 +290,14 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { // 该类为便签SQ
db.execSQL(DATA_UPDATE_NOTE_CONTENT_ON_DELETE_TRIGGER); // 重新创建被删除的触发器 db.execSQL(DATA_UPDATE_NOTE_CONTENT_ON_DELETE_TRIGGER); // 重新创建被删除的触发器
} }
static synchronized NotesDatabaseHelper getInstance(Context context) { static synchronized NotesDatabaseHelper getInstance(Context context) { // synchronized是同步的意思同步方法用于返回NotesDatabaseHelper的对象实例mInstance
if (mInstance == null) { if (mInstance == null) {
mInstance = new NotesDatabaseHelper(context); mInstance = new NotesDatabaseHelper(context);
} }
return mInstance; return mInstance;
} // 静态同步方法用于返回NotesDatabaseHelper的对象实例mInstance } // 静态同步方法用于返回NotesDatabaseHelper的对象实例mInstance
@Override @Override // 重写方法
public void onCreate(SQLiteDatabase db) { public void onCreate(SQLiteDatabase db) {
createNoteTable(db); // 创建便签表 createNoteTable(db); // 创建便签表
createDataTable(db); // 创建数据表 createDataTable(db); // 创建数据表
@ -339,7 +343,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper { // 该类为便签SQ
createDataTable(db); createDataTable(db);
} }
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");
db.execSQL("DROP TRIGGER IF EXISTS update_note_modified_date_on_delete"); db.execSQL("DROP TRIGGER IF EXISTS update_note_modified_date_on_delete");

@ -70,7 +70,7 @@ public class NotesProvider extends ContentProvider {// uri操作相关类
+ "TRIM(REPLACE(" + NoteColumns.SNIPPET + ", x'0A','')) AS " + SearchManager.SUGGEST_COLUMN_TEXT_2 + "," + "TRIM(REPLACE(" + NoteColumns.SNIPPET + ", x'0A','')) AS " + SearchManager.SUGGEST_COLUMN_TEXT_2 + ","
+ R.drawable.search_result + " AS " + SearchManager.SUGGEST_COLUMN_ICON_1 + "," + R.drawable.search_result + " AS " + SearchManager.SUGGEST_COLUMN_ICON_1 + ","
+ "'" + Intent.ACTION_VIEW + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_ACTION + "," + "'" + Intent.ACTION_VIEW + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_ACTION + ","
+ "'" + Notes.TextNote.CONTENT_TYPE + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_DATA; // ... + "'" + Notes.TextNote.CONTENT_TYPE + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_DATA; // 设置搜索结果的显示方式
private static String NOTES_SNIPPET_SEARCH_QUERY = "SELECT " + NOTES_SEARCH_PROJECTION private static String NOTES_SNIPPET_SEARCH_QUERY = "SELECT " + NOTES_SEARCH_PROJECTION
+ " FROM " + TABLE.NOTE + " FROM " + TABLE.NOTE
@ -147,7 +147,7 @@ public class NotesProvider extends ContentProvider {// uri操作相关类
} }
@Override @Override
public Uri insert(Uri uri, ContentValues values) { // uri表示要插入的urivalues表示要插入的数据 public Uri insert(Uri uri, ContentValues values) { // uri表示要插入的urivalues表示要插入的数据,返回插入数据的uri
SQLiteDatabase db = mHelper.getWritableDatabase(); // 打开或创建一个数据库 SQLiteDatabase db = mHelper.getWritableDatabase(); // 打开或创建一个数据库
long dataId = 0, noteId = 0, insertedId = 0; long dataId = 0, noteId = 0, insertedId = 0;
switch (mMatcher.match(uri)) { // 匹配uri switch (mMatcher.match(uri)) { // 匹配uri
@ -181,7 +181,7 @@ public class NotesProvider extends ContentProvider {// uri操作相关类
} }
@Override @Override
public int delete(Uri uri, String selection, String[] selectionArgs) { // 表示要删除的uri、SQL中的WHERE与参数 public int delete(Uri uri, String selection, String[] selectionArgs) { // 表示要删除的uri、SQL中的WHERE与参数,返回删除的记录数
int count = 0; // 表示删除记录数 int count = 0; // 表示删除记录数
String id = null; String id = null;
SQLiteDatabase db = mHelper.getWritableDatabase(); // 打开数据库 SQLiteDatabase db = mHelper.getWritableDatabase(); // 打开数据库

Loading…
Cancel
Save