();
}
- // 查找HashMap中是否已有phoneNumber信息
- if(sContactCache.containsKey(phoneNumber)) {
+ // 检查缓存中是否已有结果
+ if (sContactCache.containsKey(phoneNumber)) {
return sContactCache.get(phoneNumber);
}
+ // 生成适配CALLER_ID匹配规则的查询条件
String selection = CALLER_ID_SELECTION.replace("+",
PhoneNumberUtils.toCallerIDMinMatch(phoneNumber));
- // 查找数据库中phoneNumber的信息
+
+ // 查询联系人数据库
Cursor cursor = context.getContentResolver().query(
- Data.CONTENT_URI,
- new String [] { Phone.DISPLAY_NAME },
- selection,
- new String[] { phoneNumber },
- null);
+ Data.CONTENT_URI, // 数据URI
+ new String[] { Phone.DISPLAY_NAME }, // 查询字段(联系人显示名称)
+ selection, // 查询条件
+ new String[] { phoneNumber }, // 条件参数
+ null); // 排序方式
- // 判定查询结果
- // moveToFirst()返回第一条
if (cursor != null && cursor.moveToFirst()) {
try {
- // 找到相关信息
+ // 解析查询结果
String name = cursor.getString(0);
+ // 缓存查询结果
sContactCache.put(phoneNumber, name);
return name;
- // 异常
} catch (IndexOutOfBoundsException e) {
- Log.e(TAG, " Cursor get string error " + e.toString());
+ Log.e(TAG, "Cursor获取字符串错误: " + e.toString());
return null;
} finally {
+ // 关闭Cursor释放资源
cursor.close();
}
- // 未找到相关信息
} else {
- Log.d(TAG, "No contact matched with number:" + phoneNumber);
+ Log.d(TAG, "未找到匹配电话号码: " + phoneNumber);
return null;
}
}
diff --git a/app/src/main/java/net/micode/notes/data/Notes.java b/app/src/main/java/net/micode/notes/data/Notes.java
index 7cf0140..57bf46d 100644
--- a/app/src/main/java/net/micode/notes/data/Notes.java
+++ b/app/src/main/java/net/micode/notes/data/Notes.java
@@ -1,303 +1,175 @@
+/*
+ * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package net.micode.notes.data;
-import android.content.ContentUris;
import android.net.Uri;
-// Notes 类中定义了很多常量,这些常量大多是int型和string型
+
+/**
+ * 笔记数据模型核心类
+ * 定义笔记、文件夹的数据结构、类型标识及URI访问规范
+ * 包含系统文件夹ID、数据列定义和不同类型笔记的常量
+ */
public class Notes {
- public static final String AUTHORITY = "micode_notes";
- public static final String TAG = "Notes";
+ public static final String AUTHORITY = "micode_notes"; // 内容提供器权限标识
+ public static final String TAG = "Notes"; // 日志标签
- //以下三个常量对NoteColumns.TYPE的值进行设置时会用到
- public static final int TYPE_NOTE = 0;
- public static final int TYPE_FOLDER = 1;
- public static final int TYPE_SYSTEM = 2;
+ // 数据类型常量
+ public static final int TYPE_NOTE = 0; // 普通笔记
+ public static final int TYPE_FOLDER = 1; // 文件夹
+ public static final int TYPE_SYSTEM = 2; // 系统对象
/**
- * Following IDs are system folders' identifiers
- * {@link Notes#ID_ROOT_FOLDER } is default folder
- * {@link Notes#ID_TEMPARAY_FOLDER } is for notes belonging no folder
- * {@link Notes#ID_CALL_RECORD_FOLDER} is to store call records
+ * 系统文件夹ID定义
+ * ID_ROOT_FOLDER为默认根文件夹
+ * ID_TEMPARAY_FOLDER为无所属文件夹的临时笔记
+ * ID_CALL_RECORD_FOLDER存储通话记录
+ * ID_TRASH_FOLER为回收站文件夹
*/
public static final int ID_ROOT_FOLDER = 0;
public static final int ID_TEMPARAY_FOLDER = -1;
public static final int ID_CALL_RECORD_FOLDER = -2;
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_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_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_CALL_DATE =
-
- "net.micode.notes.call_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"; // 背景颜色ID
+ public static final String INTENT_EXTRA_WIDGET_ID = "net.micode.notes.widget_id"; // 桌面小部件ID
+ 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"; // 文件夹ID
+ public static final String INTENT_EXTRA_CALL_DATE = "net.micode.notes.call_date"; // 通话日期
- public static final int TYPE_WIDGET_INVALIDE = -1;
- public static final int TYPE_WIDGET_2X = 0;
- public static final int TYPE_WIDGET_4X = 1;
+ // 桌面小部件类型常量
+ public static final int TYPE_WIDGET_INVALIDE = -1; // 无效类型
+ public static final int TYPE_WIDGET_2X = 0; // 2x1小部件
+ public static final int TYPE_WIDGET_4X = 1; // 4x1小部件
public static class DataConstants {
- public static final String NOTE = TextNote.CONTENT_ITEM_TYPE;
- public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE;
+ public static final String NOTE = TextNote.CONTENT_ITEM_TYPE; // 文本笔记MIME类型
+ public static final String CALL_NOTE = CallNote.CONTENT_ITEM_TYPE; // 通话笔记MIME类型
}
/**
- * Uri to query all notes and folders
+ * 笔记内容URI(查询所有笔记和文件夹)
*/
- public static final Uri CONTENT_NOTE_URI = Uri.parse("content://" +
-
- AUTHORITY + "/note");//定义查询便签和文件夹的指针。
-
-// public static final Uri my_URI = ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI , 10);
+ public static final Uri CONTENT_NOTE_URI = Uri.parse("content://" + AUTHORITY + "/note");
/**
- * Uri to query data
+ * 附件数据URI(查询笔记附件)
*/
- public static final Uri CONTENT_DATA_URI = Uri.parse("content://" +
+ public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data");
- AUTHORITY + "/data");//定义查找数据的指针。
-
- // 定义NoteColumns的常量,用于后面创建数据库的表头
+ /**
+ * 笔记基本信息列定义
+ * 包含ID、父子关系、时间戳、内容摘要等字段
+ */
public interface NoteColumns {
- /**
- * The unique ID for a row
- * Type: INTEGER (long)
- */
+ /** 行唯一标识 */
public static final String ID = "_id";
-
- /**
- * The parent's id for note or folder
- * Type: INTEGER (long)
- */
- public static final String PARENT_ID = "parent_id";//为什么会有parent_id
-
- /**
- * Created data for note or folder
- * Type: INTEGER (long)
- */
+ /** 父节点ID */
+ public static final String PARENT_ID = "parent_id";
+ /** 创建时间戳 */
public static final String CREATED_DATE = "created_date";
-
- /**
- * Latest modified date
- * Type: INTEGER (long)
- */
+ /** 最后修改时间戳 */
public static final String MODIFIED_DATE = "modified_date";
-
-
- /**
- * Alert date
- * Type: INTEGER (long)
- */
+ /** 提醒时间戳 */
public static final String ALERTED_DATE = "alert_date";
-
- /**
- * Folder's name or text content of note
- * Type: TEXT
- */
+ /** 文件夹名称或笔记内容摘要 */
public static final String SNIPPET = "snippet";
-
- /**
- * Note's widget id
- * Type: INTEGER (long)
- */
+ /** 桌面小部件ID */
public static final String WIDGET_ID = "widget_id";
-
- /**
- * Note's widget type
- * Type: INTEGER (long)
- */
+ /** 桌面小部件类型 */
public static final String WIDGET_TYPE = "widget_type";
-
- /**
- * Note's background color's id
- * Type: INTEGER (long)
- */
+ /** 背景颜色资源ID */
public static final String BG_COLOR_ID = "bg_color_id";
-
- /**
- * For text note, it doesn't has attachment, for multi-media
- * note, it has at least one attachment
- * Type: INTEGER
- */
+ /** 是否包含附件 */
public static final String HAS_ATTACHMENT = "has_attachment";
-
- /**
- * Folder's count of notes
- * Type: INTEGER (long)
- */
+ /** 文件夹内笔记数量 */
public static final String NOTES_COUNT = "notes_count";
-
- /**
- * The file type: folder or note
- * Type: INTEGER
- */
+ /** 数据类型(笔记/文件夹/系统) */
public static final String TYPE = "type";
-
- /**
- * The last sync id
- * Type: INTEGER (long)
- */
- public static final String SYNC_ID = "sync_id";//同步
-
- /**
- * Sign to indicate local modified or not
- * Type: INTEGER
- */
+ /** 最后同步ID(用于同步标记) */
+ public static final String SYNC_ID = "sync_id";
+ /** 本地修改标记 */
public static final String LOCAL_MODIFIED = "local_modified";
-
- /**
- * Original parent id before moving into temporary folder
- * Type : INTEGER
- */
+ /** 移动前原始父ID(临时文件夹专用) */
public static final String ORIGIN_PARENT_ID = "origin_parent_id";
-
- /**
- * The gtask id
- * Type : TEXT
- */
+ /** Google Tasks同步ID */
public static final String GTASK_ID = "gtask_id";
-
- /**
- * The version code
- * Type : INTEGER (long)
- */
+ /** 数据版本号 */
public static final String VERSION = "version";
- }//这些常量主要是定义便签的属性的。
+ }
- // 定义DataColumns的常量,用于后面创建数据库的表头
+ /**
+ * 附件数据列定义
+ * 包含MIME类型、所属笔记ID、通用数据字段
+ */
public interface DataColumns {
- /**
- * The unique ID for a row
- * Type: INTEGER (long)
- */
+ /** 行唯一标识 */
public static final String ID = "_id";
-
- /**
- * The MIME type of the item represented by this row.
- * Type: Text
- */
+ /** MIME类型(标识附件类型) */
public static final String MIME_TYPE = "mime_type";
-
- /**
- * The reference id to note that this data belongs to
- * Type: INTEGER (long)
- */
+ /** 所属笔记ID */
public static final String NOTE_ID = "note_id";
-
- /**
- * Created data for note or folder
- * Type: INTEGER (long)
- */
+ /** 创建时间戳 */
public static final String CREATED_DATE = "created_date";
-
- /**
- * Latest modified date
- * Type: INTEGER (long)
- */
+ /** 最后修改时间戳 */
public static final String MODIFIED_DATE = "modified_date";
-
- /**
- * Data's content
- * Type: TEXT
- */
+ /** 附件内容 */
public static final String CONTENT = "content";
-
-
- /**
- * Generic data column, the meaning is {@link #MIMETYPE} specific,
- used for
- * integer data type
- * Type: INTEGER
- */
+ /** 通用数据字段1(整型) */
public static final String DATA1 = "data1";
-
- /**
- * Generic data column, the meaning is {@link #MIMETYPE} specific,
- used for
- * integer data type
- * Type: INTEGER
- */
+ /** 通用数据字段2(整型) */
public static final String DATA2 = "data2";
-
- /**
- * Generic data column, the meaning is {@link #MIMETYPE} specific,
- used for
- * TEXT data type
- * Type: TEXT
- */
+ /** 通用数据字段3(文本) */
public static final String DATA3 = "data3";
-
- /**
- * Generic data column, the meaning is {@link #MIMETYPE} specific,
- used for
- * TEXT data type
- * Type: TEXT
- */
+ /** 通用数据字段4(文本) */
public static final String DATA4 = "data4";
-
- /**
- * Generic data column, the meaning is {@link #MIMETYPE} specific,
- used for
- * TEXT data type
- * Type: TEXT
- */
+ /** 通用数据字段5(文本) */
public static final String DATA5 = "data5";
- }//主要是定义存储便签内容数据的
+ }
+
+ /**
+ * 文本笔记定义
+ * 继承DataColumns,增加清单模式标识
+ */
public static final class TextNote implements DataColumns {
- /**
- * Mode to indicate the text in check list mode or not
- * Type: Integer 1:check list mode 0: normal mode
- */
+ /** 清单模式标识(1为清单模式,0为普通模式) */
public static final String MODE = DATA1;
+ 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_ITEM_TYPE =
-
- "vnd.android.cursor.item/text_note";
-
- public static final Uri CONTENT_URI = Uri.parse("content://" +
-
- AUTHORITY + "/text_note");
- }//文本内容的数据结构
+ /** 文本笔记MIME类型定义 */
+ 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 Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note");
+ }
+ /**
+ * 通话笔记定义
+ * 继承DataColumns,增加通话日期和电话号码字段
+ */
public static final class CallNote implements DataColumns {
- /**
- * Call date for this record
- * Type: INTEGER (long)
- */
+ /** 通话时间戳 */
public static final String CALL_DATE = DATA1;
-
- /**
- * Phone number for this record
- * Type: TEXT
- */
+ /** 电话号码 */
public static final String PHONE_NUMBER = DATA3;
- 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 Uri CONTENT_URI = Uri.parse("content://" +
-
- AUTHORITY + "/call_note");
- }//电话内容的数据结构
+ /** 通话笔记MIME类型定义 */
+ 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 Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/call_note");
+ }
}
\ No newline at end of file
diff --git a/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java b/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java
index 0256bf2..ffe5d57 100644
--- a/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java
+++ b/app/src/main/java/net/micode/notes/data/NotesDatabaseHelper.java
@@ -1,22 +1,38 @@
+/*
+ * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package net.micode.notes.data;
-import android.content.ContentValues;//就是用于保存一些数据(string boolean byte double float int long short ...)信息,这些信息可以被数据库操作时使用。
-import android.content.Context;//加载和访问资源。(android中主要是这两个功能,但是这里具体不清楚)
-import android.database.sqlite.SQLiteDatabase;//主要提供了对应于添加、删除、更新、查询的操作方法: insert()、delete()、update()和query()。配合content.values
-import android.database.sqlite.SQLiteOpenHelper;//用来管理数据的创建和版本更新
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import net.micode.notes.data.Notes.DataColumns;
import net.micode.notes.data.Notes.DataConstants;
import net.micode.notes.data.Notes.NoteColumns;
-//数据库操作,用SQLOpenhelper,对一些note和文件进行数据库的操作,比如删除文件后,将文件里的note也相应删除
+
public class NotesDatabaseHelper extends SQLiteOpenHelper {
private static final String DB_NAME = "note.db";
private static final int DB_VERSION = 4;
- public interface TABLE { //接口,分成note和data,在后面的程序里分别使用过
+ public interface TABLE {
public static final String NOTE = "note";
public static final String DATA = "data";
@@ -27,179 +43,179 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
private static NotesDatabaseHelper mInstance;
private static final String CREATE_NOTE_TABLE_SQL =
- "CREATE TABLE " + TABLE.NOTE + "(" +
- NoteColumns.ID + " INTEGER PRIMARY KEY," +
- NoteColumns.PARENT_ID + " INTEGER NOT NULL DEFAULT 0," +
- NoteColumns.ALERTED_DATE + " INTEGER NOT NULL DEFAULT 0," +
- NoteColumns.BG_COLOR_ID + " INTEGER NOT NULL DEFAULT 0," +
- NoteColumns.CREATED_DATE + " INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000)," +
- NoteColumns.HAS_ATTACHMENT + " INTEGER NOT NULL DEFAULT 0," +
- NoteColumns.MODIFIED_DATE + " INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000)," +
- NoteColumns.NOTES_COUNT + " INTEGER NOT NULL DEFAULT 0," +
- NoteColumns.SNIPPET + " TEXT NOT NULL DEFAULT ''," +
- NoteColumns.TYPE + " INTEGER NOT NULL DEFAULT 0," +
- NoteColumns.WIDGET_ID + " INTEGER NOT NULL DEFAULT 0," +
- NoteColumns.WIDGET_TYPE + " INTEGER NOT NULL DEFAULT -1," +
- NoteColumns.SYNC_ID + " INTEGER NOT NULL DEFAULT 0," +
- NoteColumns.LOCAL_MODIFIED + " INTEGER NOT NULL DEFAULT 0," +
- NoteColumns.ORIGIN_PARENT_ID + " INTEGER NOT NULL DEFAULT 0," +
- NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," +
- NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0" +
- ")";//数据库中需要存储的项目的名称,就相当于创建一个表格的表头的内容。
+ "CREATE TABLE " + TABLE.NOTE + "(" +
+ NoteColumns.ID + " INTEGER PRIMARY KEY," +
+ NoteColumns.PARENT_ID + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.ALERTED_DATE + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.BG_COLOR_ID + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.CREATED_DATE + " INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000)," +
+ NoteColumns.HAS_ATTACHMENT + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.MODIFIED_DATE + " INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000)," +
+ NoteColumns.NOTES_COUNT + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.SNIPPET + " TEXT NOT NULL DEFAULT ''," +
+ NoteColumns.TYPE + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.WIDGET_ID + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.WIDGET_TYPE + " INTEGER NOT NULL DEFAULT -1," +
+ NoteColumns.SYNC_ID + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.LOCAL_MODIFIED + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.ORIGIN_PARENT_ID + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.GTASK_ID + " TEXT NOT NULL DEFAULT ''," +
+ NoteColumns.VERSION + " INTEGER NOT NULL DEFAULT 0" +
+ ")";
private static final String CREATE_DATA_TABLE_SQL =
- "CREATE TABLE " + TABLE.DATA + "(" +
- DataColumns.ID + " INTEGER PRIMARY KEY," +
- DataColumns.MIME_TYPE + " TEXT NOT NULL," +
- DataColumns.NOTE_ID + " INTEGER NOT NULL DEFAULT 0," +
- NoteColumns.CREATED_DATE + " INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000)," +
- NoteColumns.MODIFIED_DATE + " INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000)," +
- DataColumns.CONTENT + " TEXT NOT NULL DEFAULT ''," +
- DataColumns.DATA1 + " INTEGER," +
- DataColumns.DATA2 + " INTEGER," +
- DataColumns.DATA3 + " TEXT NOT NULL DEFAULT ''," +
- DataColumns.DATA4 + " TEXT NOT NULL DEFAULT ''," +
- DataColumns.DATA5 + " TEXT NOT NULL DEFAULT ''" +
- ")";//和上面的功能一样,主要是存储的项目不同
+ "CREATE TABLE " + TABLE.DATA + "(" +
+ DataColumns.ID + " INTEGER PRIMARY KEY," +
+ DataColumns.MIME_TYPE + " TEXT NOT NULL," +
+ DataColumns.NOTE_ID + " INTEGER NOT NULL DEFAULT 0," +
+ NoteColumns.CREATED_DATE + " INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000)," +
+ NoteColumns.MODIFIED_DATE + " INTEGER NOT NULL DEFAULT (strftime('%s','now') * 1000)," +
+ DataColumns.CONTENT + " TEXT NOT NULL DEFAULT ''," +
+ DataColumns.DATA1 + " INTEGER," +
+ DataColumns.DATA2 + " INTEGER," +
+ DataColumns.DATA3 + " TEXT NOT NULL DEFAULT ''," +
+ DataColumns.DATA4 + " TEXT NOT NULL DEFAULT ''," +
+ DataColumns.DATA5 + " TEXT NOT NULL DEFAULT ''" +
+ ")";
private static final String CREATE_DATA_NOTE_ID_INDEX_SQL =
- "CREATE INDEX IF NOT EXISTS note_id_index ON " +
- TABLE.DATA + "(" + DataColumns.NOTE_ID + ");";//存储便签编号的一个数据表格
+ "CREATE INDEX IF NOT EXISTS note_id_index ON " +
+ TABLE.DATA + "(" + DataColumns.NOTE_ID + ");";
/**
* Increase folder's note count when move note to the folder
*/
private static final String NOTE_INCREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER =
- "CREATE TRIGGER increase_folder_count_on_update "+
- " AFTER UPDATE OF " + NoteColumns.PARENT_ID + " ON " + TABLE.NOTE +
- " BEGIN " +
- " UPDATE " + TABLE.NOTE +
- " SET " + NoteColumns.NOTES_COUNT + "=" + NoteColumns.NOTES_COUNT + " + 1" +
- " WHERE " + NoteColumns.ID + "=new." + NoteColumns.PARENT_ID + ";" +
- " END";//在文件夹中移入一个Note之后需要更改的数据的表格。
+ "CREATE TRIGGER increase_folder_count_on_update "+
+ " AFTER UPDATE OF " + NoteColumns.PARENT_ID + " ON " + TABLE.NOTE +
+ " BEGIN " +
+ " UPDATE " + TABLE.NOTE +
+ " SET " + NoteColumns.NOTES_COUNT + "=" + NoteColumns.NOTES_COUNT + " + 1" +
+ " WHERE " + NoteColumns.ID + "=new." + NoteColumns.PARENT_ID + ";" +
+ " END";
/**
* Decrease folder's note count when move note from folder
*/
private static final String NOTE_DECREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER =
- "CREATE TRIGGER decrease_folder_count_on_update " +
- " AFTER UPDATE OF " + NoteColumns.PARENT_ID + " ON " + TABLE.NOTE +
- " BEGIN " +
- " UPDATE " + TABLE.NOTE +
- " SET " + NoteColumns.NOTES_COUNT + "=" + NoteColumns.NOTES_COUNT + "-1" +
- " WHERE " + NoteColumns.ID + "=old." + NoteColumns.PARENT_ID +
- " AND " + NoteColumns.NOTES_COUNT + ">0" + ";" +
- " END";//在文件夹中移出一个Note之后需要更改的数据的表格。
+ "CREATE TRIGGER decrease_folder_count_on_update " +
+ " AFTER UPDATE OF " + NoteColumns.PARENT_ID + " ON " + TABLE.NOTE +
+ " BEGIN " +
+ " UPDATE " + TABLE.NOTE +
+ " SET " + NoteColumns.NOTES_COUNT + "=" + NoteColumns.NOTES_COUNT + "-1" +
+ " WHERE " + NoteColumns.ID + "=old." + NoteColumns.PARENT_ID +
+ " AND " + NoteColumns.NOTES_COUNT + ">0" + ";" +
+ " END";
/**
* Increase folder's note count when insert new note to the folder
*/
private static final String NOTE_INCREASE_FOLDER_COUNT_ON_INSERT_TRIGGER =
- "CREATE TRIGGER increase_folder_count_on_insert " +
- " AFTER INSERT ON " + TABLE.NOTE +
- " BEGIN " +
- " UPDATE " + TABLE.NOTE +
- " SET " + NoteColumns.NOTES_COUNT + "=" + NoteColumns.NOTES_COUNT + " + 1" +
- " WHERE " + NoteColumns.ID + "=new." + NoteColumns.PARENT_ID + ";" +
- " END";//在文件夹中插入一个Note之后需要更改的数据的表格。
+ "CREATE TRIGGER increase_folder_count_on_insert " +
+ " AFTER INSERT ON " + TABLE.NOTE +
+ " BEGIN " +
+ " UPDATE " + TABLE.NOTE +
+ " SET " + NoteColumns.NOTES_COUNT + "=" + NoteColumns.NOTES_COUNT + " + 1" +
+ " WHERE " + NoteColumns.ID + "=new." + NoteColumns.PARENT_ID + ";" +
+ " END";
/**
* Decrease folder's note count when delete note from the folder
*/
private static final String NOTE_DECREASE_FOLDER_COUNT_ON_DELETE_TRIGGER =
- "CREATE TRIGGER decrease_folder_count_on_delete " +
- " AFTER DELETE ON " + TABLE.NOTE +
- " BEGIN " +
- " UPDATE " + TABLE.NOTE +
- " SET " + NoteColumns.NOTES_COUNT + "=" + NoteColumns.NOTES_COUNT + "-1" +
- " WHERE " + NoteColumns.ID + "=old." + NoteColumns.PARENT_ID +
- " AND " + NoteColumns.NOTES_COUNT + ">0;" +
- " END";//在文件夹中删除一个Note之后需要更改的数据的表格。
+ "CREATE TRIGGER decrease_folder_count_on_delete " +
+ " AFTER DELETE ON " + TABLE.NOTE +
+ " BEGIN " +
+ " UPDATE " + TABLE.NOTE +
+ " SET " + NoteColumns.NOTES_COUNT + "=" + NoteColumns.NOTES_COUNT + "-1" +
+ " WHERE " + NoteColumns.ID + "=old." + NoteColumns.PARENT_ID +
+ " AND " + NoteColumns.NOTES_COUNT + ">0;" +
+ " END";
/**
* Update note's content when insert data with type {@link DataConstants#NOTE}
*/
private static final String DATA_UPDATE_NOTE_CONTENT_ON_INSERT_TRIGGER =
- "CREATE TRIGGER update_note_content_on_insert " +
- " AFTER INSERT ON " + TABLE.DATA +
- " WHEN new." + DataColumns.MIME_TYPE + "='" + DataConstants.NOTE + "'" +
- " BEGIN" +
- " UPDATE " + TABLE.NOTE +
- " SET " + NoteColumns.SNIPPET + "=new." + DataColumns.CONTENT +
- " WHERE " + NoteColumns.ID + "=new." + DataColumns.NOTE_ID + ";" +
- " END";//在文件夹中对一个Note导入新的数据之后需要更改的数据的表格。
+ "CREATE TRIGGER update_note_content_on_insert " +
+ " AFTER INSERT ON " + TABLE.DATA +
+ " WHEN new." + DataColumns.MIME_TYPE + "='" + DataConstants.NOTE + "'" +
+ " BEGIN" +
+ " UPDATE " + TABLE.NOTE +
+ " SET " + NoteColumns.SNIPPET + "=new." + DataColumns.CONTENT +
+ " WHERE " + NoteColumns.ID + "=new." + DataColumns.NOTE_ID + ";" +
+ " END";
/**
* Update note's content when data with {@link DataConstants#NOTE} type has changed
*/
private static final String DATA_UPDATE_NOTE_CONTENT_ON_UPDATE_TRIGGER =
- "CREATE TRIGGER update_note_content_on_update " +
- " AFTER UPDATE ON " + TABLE.DATA +
- " WHEN old." + DataColumns.MIME_TYPE + "='" + DataConstants.NOTE + "'" +
- " BEGIN" +
- " UPDATE " + TABLE.NOTE +
- " SET " + NoteColumns.SNIPPET + "=new." + DataColumns.CONTENT +
- " WHERE " + NoteColumns.ID + "=new." + DataColumns.NOTE_ID + ";" +
- " END";//Note数据被修改后需要更改的数据的表格。
+ "CREATE TRIGGER update_note_content_on_update " +
+ " AFTER UPDATE ON " + TABLE.DATA +
+ " WHEN old." + DataColumns.MIME_TYPE + "='" + DataConstants.NOTE + "'" +
+ " BEGIN" +
+ " UPDATE " + TABLE.NOTE +
+ " SET " + NoteColumns.SNIPPET + "=new." + DataColumns.CONTENT +
+ " WHERE " + NoteColumns.ID + "=new." + DataColumns.NOTE_ID + ";" +
+ " END";
/**
* Update note's content when data with {@link DataConstants#NOTE} type has deleted
*/
private static final String DATA_UPDATE_NOTE_CONTENT_ON_DELETE_TRIGGER =
- "CREATE TRIGGER update_note_content_on_delete " +
- " AFTER delete ON " + TABLE.DATA +
- " WHEN old." + DataColumns.MIME_TYPE + "='" + DataConstants.NOTE + "'" +
- " BEGIN" +
- " UPDATE " + TABLE.NOTE +
- " SET " + NoteColumns.SNIPPET + "=''" +
- " WHERE " + NoteColumns.ID + "=old." + DataColumns.NOTE_ID + ";" +
- " END";//Note数据被删除后需要更改的数据的表格。
+ "CREATE TRIGGER update_note_content_on_delete " +
+ " AFTER delete ON " + TABLE.DATA +
+ " WHEN old." + DataColumns.MIME_TYPE + "='" + DataConstants.NOTE + "'" +
+ " BEGIN" +
+ " UPDATE " + TABLE.NOTE +
+ " SET " + NoteColumns.SNIPPET + "=''" +
+ " WHERE " + NoteColumns.ID + "=old." + DataColumns.NOTE_ID + ";" +
+ " END";
/**
* Delete datas belong to note which has been deleted
*/
private static final String NOTE_DELETE_DATA_ON_DELETE_TRIGGER =
- "CREATE TRIGGER delete_data_on_delete " +
- " AFTER DELETE ON " + TABLE.NOTE +
- " BEGIN" +
- " DELETE FROM " + TABLE.DATA +
- " WHERE " + DataColumns.NOTE_ID + "=old." + NoteColumns.ID + ";" +
- " END";//删除已删除的便签的数据后需要更改的数据的表格。
+ "CREATE TRIGGER delete_data_on_delete " +
+ " AFTER DELETE ON " + TABLE.NOTE +
+ " BEGIN" +
+ " DELETE FROM " + TABLE.DATA +
+ " WHERE " + DataColumns.NOTE_ID + "=old." + NoteColumns.ID + ";" +
+ " END";
/**
* Delete notes belong to folder which has been deleted
*/
private static final String FOLDER_DELETE_NOTES_ON_DELETE_TRIGGER =
- "CREATE TRIGGER folder_delete_notes_on_delete " +
- " AFTER DELETE ON " + TABLE.NOTE +
- " BEGIN" +
- " DELETE FROM " + TABLE.NOTE +
- " WHERE " + NoteColumns.PARENT_ID + "=old." + NoteColumns.ID + ";" +
- " END";//删除已删除的文件夹的便签后需要更改的数据的表格。
+ "CREATE TRIGGER folder_delete_notes_on_delete " +
+ " AFTER DELETE ON " + TABLE.NOTE +
+ " BEGIN" +
+ " DELETE FROM " + TABLE.NOTE +
+ " WHERE " + NoteColumns.PARENT_ID + "=old." + NoteColumns.ID + ";" +
+ " END";
/**
* Move notes belong to folder which has been moved to trash folder
*/
private static final String FOLDER_MOVE_NOTES_ON_TRASH_TRIGGER =
- "CREATE TRIGGER folder_move_notes_on_trash " +
- " AFTER UPDATE ON " + TABLE.NOTE +
- " WHEN new." + NoteColumns.PARENT_ID + "=" + Notes.ID_TRASH_FOLER +
- " BEGIN" +
- " UPDATE " + TABLE.NOTE +
- " SET " + NoteColumns.PARENT_ID + "=" + Notes.ID_TRASH_FOLER +
- " WHERE " + NoteColumns.PARENT_ID + "=old." + NoteColumns.ID + ";" +
- " END";//还原垃圾桶中便签后需要更改的数据的表格。
+ "CREATE TRIGGER folder_move_notes_on_trash " +
+ " AFTER UPDATE ON " + TABLE.NOTE +
+ " WHEN new." + NoteColumns.PARENT_ID + "=" + Notes.ID_TRASH_FOLER +
+ " BEGIN" +
+ " UPDATE " + TABLE.NOTE +
+ " SET " + NoteColumns.PARENT_ID + "=" + Notes.ID_TRASH_FOLER +
+ " WHERE " + NoteColumns.PARENT_ID + "=old." + NoteColumns.ID + ";" +
+ " END";
public NotesDatabaseHelper(Context context) {
super(context, DB_NAME, null, DB_VERSION);
- }//构造函数,传入数据库的名称和版本
+ }
public void createNoteTable(SQLiteDatabase db) {
db.execSQL(CREATE_NOTE_TABLE_SQL);
reCreateNoteTableTriggers(db);
createSystemFolder(db);
Log.d(TAG, "note table has been created");
- }//创建表格(用来存储标签属性)
+ }
private void reCreateNoteTableTriggers(SQLiteDatabase db) {
db.execSQL("DROP TRIGGER IF EXISTS increase_folder_count_on_update");
@@ -217,8 +233,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.execSQL(NOTE_INCREASE_FOLDER_COUNT_ON_INSERT_TRIGGER);
db.execSQL(FOLDER_DELETE_NOTES_ON_DELETE_TRIGGER);
db.execSQL(FOLDER_MOVE_NOTES_ON_TRASH_TRIGGER);
- }//execSQL是数据库操作的API,主要是更改行为的SQL语句。
- //在这里主要是用来重新创建上述定义的表格用的,先删除原来有的数据库的触发器再重新创建新的数据库
+ }
private void createSystemFolder(SQLiteDatabase db) {
ContentValues values = new ContentValues();
@@ -253,14 +268,14 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
values.put(NoteColumns.ID, Notes.ID_TRASH_FOLER);
values.put(NoteColumns.TYPE, Notes.TYPE_SYSTEM);
db.insert(TABLE.NOTE, null, values);
- }//创建几个系统文件夹
+ }
public void createDataTable(SQLiteDatabase db) {
db.execSQL(CREATE_DATA_TABLE_SQL);
reCreateDataTableTriggers(db);
db.execSQL(CREATE_DATA_NOTE_ID_INDEX_SQL);
Log.d(TAG, "data table has been created");
- }//创建表格(用来存储标签内容)
+ }
private void reCreateDataTableTriggers(SQLiteDatabase db) {
db.execSQL("DROP TRIGGER IF EXISTS update_note_content_on_insert");
@@ -270,22 +285,20 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
db.execSQL(DATA_UPDATE_NOTE_CONTENT_ON_INSERT_TRIGGER);
db.execSQL(DATA_UPDATE_NOTE_CONTENT_ON_UPDATE_TRIGGER);
db.execSQL(DATA_UPDATE_NOTE_CONTENT_ON_DELETE_TRIGGER);
- }//同上面的execSQL
+ }
static synchronized NotesDatabaseHelper getInstance(Context context) {
if (mInstance == null) {
mInstance = new NotesDatabaseHelper(context);
}
return mInstance;
- }//上网查是为解决同一时刻只能有一个线程执行.
- //在写程序库代码时,有时有一个类需要被所有的其它类使用,
- //但又要求这个类只能被实例化一次,是个服务类,定义一次,其它类使用同一个这个类的实例
+ }
@Override
public void onCreate(SQLiteDatabase db) {
createNoteTable(db);
createDataTable(db);
- }//实现两个表格(上面创建的两个表格)
+ }
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
@@ -318,14 +331,14 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
throw new IllegalStateException("Upgrade notes database to version " + newVersion
+ "fails");
}
- }//数据库版本的更新(数据库内容的更改)
+ }
private void upgradeToV2(SQLiteDatabase db) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE.NOTE);
db.execSQL("DROP TABLE IF EXISTS " + TABLE.DATA);
createNoteTable(db);
createDataTable(db);
- }//更新到V2版本
+ }
private void upgradeToV3(SQLiteDatabase db) {
// drop unused triggers
@@ -340,10 +353,10 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
values.put(NoteColumns.ID, Notes.ID_TRASH_FOLER);
values.put(NoteColumns.TYPE, Notes.TYPE_SYSTEM);
db.insert(TABLE.NOTE, null, values);
- }//更新到V3版本
+ }
private void upgradeToV4(SQLiteDatabase db) {
db.execSQL("ALTER TABLE " + TABLE.NOTE + " ADD COLUMN " + NoteColumns.VERSION
+ " INTEGER NOT NULL DEFAULT 0");
- }//更新到V4版本
-}
\ No newline at end of file
+ }
+}
diff --git a/app/src/main/java/net/micode/notes/data/NotesProvider.java b/app/src/main/java/net/micode/notes/data/NotesProvider.java
index 6897999..edb0a60 100644
--- a/app/src/main/java/net/micode/notes/data/NotesProvider.java
+++ b/app/src/main/java/net/micode/notes/data/NotesProvider.java
@@ -1,5 +1,22 @@
+/*
+ * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package net.micode.notes.data;
+
import android.app.SearchManager;
import android.content.ContentProvider;
import android.content.ContentUris;
@@ -16,15 +33,9 @@ import net.micode.notes.R;
import net.micode.notes.data.Notes.DataColumns;
import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.data.NotesDatabaseHelper.TABLE;
-//为存储和获取数据提供接口。可以在不同的应用程序之间共享数据
-//ContentProvider提供的方法
-//query:查询
-//insert:插入
-//update:更新
-//delete:删除
-//getType:得到数据类型
+
+
public class NotesProvider extends ContentProvider {
- // UriMatcher用于匹配Uri
private static final UriMatcher mMatcher;
private NotesDatabaseHelper mHelper;
@@ -40,9 +51,7 @@ public class NotesProvider extends ContentProvider {
private static final int URI_SEARCH_SUGGEST = 6;
static {
- // 创建UriMatcher时,调用UriMatcher(UriMatcher.NO_MATCH)表示不匹配任何路径的返回码
mMatcher = new UriMatcher(UriMatcher.NO_MATCH);
- // 把需要匹配Uri路径全部给注册上
mMatcher.addURI(Notes.AUTHORITY, "note", URI_NOTE);
mMatcher.addURI(Notes.AUTHORITY, "note/#", URI_NOTE_ITEM);
mMatcher.addURI(Notes.AUTHORITY, "data", URI_DATA);
@@ -56,40 +65,33 @@ public class NotesProvider extends ContentProvider {
* x'0A' represents the '\n' character in sqlite. For title and content in the search result,
* we will trim '\n' and white space in order to show more information.
*/
- // 声明 NOTES_SEARCH_PROJECTION
private static final String NOTES_SEARCH_PROJECTION = NoteColumns.ID + ","
- + NoteColumns.ID + " AS " + SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA + ","
- + "TRIM(REPLACE(" + NoteColumns.SNIPPET + ", x'0A','')) AS " + SearchManager.SUGGEST_COLUMN_TEXT_1 + ","
- + "TRIM(REPLACE(" + NoteColumns.SNIPPET + ", x'0A','')) AS " + SearchManager.SUGGEST_COLUMN_TEXT_2 + ","
- + R.drawable.search_result + " AS " + SearchManager.SUGGEST_COLUMN_ICON_1 + ","
- + "'" + Intent.ACTION_VIEW + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_ACTION + ","
- + "'" + Notes.TextNote.CONTENT_TYPE + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_DATA;
- // 声明NOTES_SNIPPET_SEARCH_QUERY
+ + NoteColumns.ID + " AS " + SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA + ","
+ + "TRIM(REPLACE(" + NoteColumns.SNIPPET + ", x'0A','')) AS " + SearchManager.SUGGEST_COLUMN_TEXT_1 + ","
+ + "TRIM(REPLACE(" + NoteColumns.SNIPPET + ", x'0A','')) AS " + SearchManager.SUGGEST_COLUMN_TEXT_2 + ","
+ + R.drawable.search_result + " AS " + SearchManager.SUGGEST_COLUMN_ICON_1 + ","
+ + "'" + Intent.ACTION_VIEW + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_ACTION + ","
+ + "'" + Notes.TextNote.CONTENT_TYPE + "' AS " + SearchManager.SUGGEST_COLUMN_INTENT_DATA;
+
private static String NOTES_SNIPPET_SEARCH_QUERY = "SELECT " + NOTES_SEARCH_PROJECTION
- + " FROM " + TABLE.NOTE
- + " WHERE " + NoteColumns.SNIPPET + " LIKE ?"
- + " AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER
- + " AND " + NoteColumns.TYPE + "=" + Notes.TYPE_NOTE;
+ + " FROM " + TABLE.NOTE
+ + " WHERE " + NoteColumns.SNIPPET + " LIKE ?"
+ + " AND " + NoteColumns.PARENT_ID + "<>" + Notes.ID_TRASH_FOLER
+ + " AND " + NoteColumns.TYPE + "=" + Notes.TYPE_NOTE;
@Override
- // Context只有在onCreate()中才被初始化
- // 对mHelper进行实例化
public boolean onCreate() {
mHelper = NotesDatabaseHelper.getInstance(getContext());
return true;
}
@Override
- // 查询uri在数据库中对应的位置
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
- String sortOrder) {
+ String sortOrder) {
Cursor c = null;
- // 获取可读数据库
SQLiteDatabase db = mHelper.getReadableDatabase();
String id = null;
- // 匹配查找uri
switch (mMatcher.match(uri)) {
- // 对于不同的匹配值,在数据库中查找相应的条目
case URI_NOTE:
c = db.query(TABLE.NOTE, projection, selection, selectionArgs, null, null,
sortOrder);
@@ -111,7 +113,6 @@ public class NotesProvider extends ContentProvider {
case URI_SEARCH:
case URI_SEARCH_SUGGEST:
if (sortOrder != null || projection != null) {
- // 不合法的参数异常
throw new IllegalArgumentException(
"do not specify sortOrder, selection, selectionArgs, or projection" + "with this query");
}
@@ -119,8 +120,6 @@ public class NotesProvider extends ContentProvider {
String searchString = null;
if (mMatcher.match(uri) == URI_SEARCH_SUGGEST) {
if (uri.getPathSegments().size() > 1) {
- // getPathSegments()方法得到一个String的List,
- // 在uri.getPathSegments().get(1)为第2个元素
searchString = uri.getPathSegments().get(1);
}
} else {
@@ -140,7 +139,6 @@ public class NotesProvider extends ContentProvider {
}
break;
default:
- // 抛出异常
throw new IllegalArgumentException("Unknown URI " + uri);
}
if (c != null) {
@@ -150,17 +148,13 @@ public class NotesProvider extends ContentProvider {
}
@Override
- // 插入一个uri
public Uri insert(Uri uri, ContentValues values) {
- // 获得可写的数据库
SQLiteDatabase db = mHelper.getWritableDatabase();
long dataId = 0, noteId = 0, insertedId = 0;
switch (mMatcher.match(uri)) {
- // 新增一个条目
case URI_NOTE:
insertedId = noteId = db.insert(TABLE.NOTE, null, values);
break;
- // 如果存在,查找NOTE_ID
case URI_DATA:
if (values.containsKey(DataColumns.NOTE_ID)) {
noteId = values.getAsLong(DataColumns.NOTE_ID);
@@ -173,7 +167,6 @@ public class NotesProvider extends ContentProvider {
throw new IllegalArgumentException("Unknown URI " + uri);
}
// Notify the note uri
- // notifyChange获得一个ContextResolver对象并且更新里面的内容
if (noteId > 0) {
getContext().getContentResolver().notifyChange(
ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId), null);
@@ -185,17 +178,13 @@ public class NotesProvider extends ContentProvider {
ContentUris.withAppendedId(Notes.CONTENT_DATA_URI, dataId), null);
}
- // 返回插入的uri的路径
return ContentUris.withAppendedId(uri, insertedId);
}
@Override
- // 删除一个uri
public int delete(Uri uri, String selection, String[] selectionArgs) {
- //Uri代表要操作的数据,Android上可用的每种资源 -包括 图像、视频片段、音频资源等都可以用Uri来表示。
int count = 0;
String id = null;
- // 获得可写的数据库
SQLiteDatabase db = mHelper.getWritableDatabase();
boolean deleteData = false;
switch (mMatcher.match(uri)) {
@@ -239,7 +228,6 @@ public class NotesProvider extends ContentProvider {
}
@Override
- // 更新一个uri
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
int count = 0;
String id = null;
@@ -279,12 +267,10 @@ public class NotesProvider extends ContentProvider {
return count;
}
- // 将字符串解析成规定格式
private String parseSelection(String selection) {
return (!TextUtils.isEmpty(selection) ? " AND (" + selection + ')' : "");
}
- //增加一个noteVersion
private void increaseNoteVersion(long id, String selection, String[] selectionArgs) {
StringBuilder sql = new StringBuilder(120);
sql.append("UPDATE ");
@@ -307,7 +293,6 @@ public class NotesProvider extends ContentProvider {
sql.append(selectString);
}
- // execSQL()方法可以执行insert、delete、update和CREATE TABLE之类有更改行为的SQL语句
mHelper.getWritableDatabase().execSQL(sql.toString());
}
@@ -317,4 +302,4 @@ public class NotesProvider extends ContentProvider {
return null;
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/net/micode/notes/data/data.plantuml b/app/src/main/java/net/micode/notes/data/data.plantuml
deleted file mode 100644
index 84ebcf7..0000000
--- a/app/src/main/java/net/micode/notes/data/data.plantuml
+++ /dev/null
@@ -1,218 +0,0 @@
-@startuml
-
-title __DATA's Class Diagram__\n
-
- namespace net.micode.notes {
- namespace data {
- class net.micode.notes.data.Contact {
- {static} - CALLER_ID_SELECTION : String
- {static} - TAG : String
- {static} - sContactCache : HashMap
- {static} + getContact()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace data {
- class net.micode.notes.data.Notes {
- {static} + AUTHORITY : String
- {static} + CONTENT_DATA_URI : Uri
- {static} + CONTENT_NOTE_URI : Uri
- {static} + ID_CALL_RECORD_FOLDER : int
- {static} + ID_ROOT_FOLDER : int
- {static} + ID_TEMPARAY_FOLDER : int
- {static} + ID_TRASH_FOLER : int
- {static} + INTENT_EXTRA_ALERT_DATE : String
- {static} + INTENT_EXTRA_BACKGROUND_ID : String
- {static} + INTENT_EXTRA_CALL_DATE : String
- {static} + INTENT_EXTRA_FOLDER_ID : String
- {static} + INTENT_EXTRA_WIDGET_ID : String
- {static} + INTENT_EXTRA_WIDGET_TYPE : String
- {static} + TAG : String
- {static} + TYPE_FOLDER : int
- {static} + TYPE_NOTE : int
- {static} + TYPE_SYSTEM : int
- {static} + TYPE_WIDGET_2X : int
- {static} + TYPE_WIDGET_4X : int
- {static} + TYPE_WIDGET_INVALIDE : int
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace data {
- class net.micode.notes.data.Notes.CallNote {
- {static} + CALL_DATE : String
- {static} + CONTENT_ITEM_TYPE : String
- {static} + CONTENT_TYPE : String
- {static} + CONTENT_URI : Uri
- {static} + PHONE_NUMBER : String
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace data {
- interface net.micode.notes.data.Notes.DataColumns {
- {static} + CONTENT : String
- {static} + CREATED_DATE : String
- {static} + DATA1 : String
- {static} + DATA2 : String
- {static} + DATA3 : String
- {static} + DATA4 : String
- {static} + DATA5 : String
- {static} + ID : String
- {static} + MIME_TYPE : String
- {static} + MODIFIED_DATE : String
- {static} + NOTE_ID : String
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace data {
- class net.micode.notes.data.Notes.DataConstants {
- {static} + CALL_NOTE : String
- {static} + NOTE : String
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace data {
- interface net.micode.notes.data.Notes.NoteColumns {
- {static} + ALERTED_DATE : String
- {static} + BG_COLOR_ID : String
- {static} + CREATED_DATE : String
- {static} + GTASK_ID : String
- {static} + HAS_ATTACHMENT : String
- {static} + ID : String
- {static} + LOCAL_MODIFIED : String
- {static} + MODIFIED_DATE : String
- {static} + NOTES_COUNT : String
- {static} + ORIGIN_PARENT_ID : String
- {static} + PARENT_ID : String
- {static} + SNIPPET : String
- {static} + SYNC_ID : String
- {static} + TYPE : String
- {static} + VERSION : String
- {static} + WIDGET_ID : String
- {static} + WIDGET_TYPE : String
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace data {
- class net.micode.notes.data.Notes.TextNote {
- {static} + CONTENT_ITEM_TYPE : String
- {static} + CONTENT_TYPE : String
- {static} + CONTENT_URI : Uri
- {static} + MODE : String
- {static} + MODE_CHECK_LIST : int
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace data {
- class net.micode.notes.data.NotesDatabaseHelper {
- {static} - CREATE_DATA_NOTE_ID_INDEX_SQL : String
- {static} - CREATE_DATA_TABLE_SQL : String
- {static} - CREATE_NOTE_TABLE_SQL : String
- {static} - DATA_UPDATE_NOTE_CONTENT_ON_DELETE_TRIGGER : String
- {static} - DATA_UPDATE_NOTE_CONTENT_ON_INSERT_TRIGGER : String
- {static} - DATA_UPDATE_NOTE_CONTENT_ON_UPDATE_TRIGGER : String
- {static} - DB_NAME : String
- {static} - DB_VERSION : int
- {static} - FOLDER_DELETE_NOTES_ON_DELETE_TRIGGER : String
- {static} - FOLDER_MOVE_NOTES_ON_TRASH_TRIGGER : String
- {static} - NOTE_DECREASE_FOLDER_COUNT_ON_DELETE_TRIGGER : String
- {static} - NOTE_DECREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER : String
- {static} - NOTE_DELETE_DATA_ON_DELETE_TRIGGER : String
- {static} - NOTE_INCREASE_FOLDER_COUNT_ON_INSERT_TRIGGER : String
- {static} - NOTE_INCREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER : String
- {static} - TAG : String
- {static} - mInstance : NotesDatabaseHelper
- + NotesDatabaseHelper()
- + createDataTable()
- + createNoteTable()
- + onCreate()
- + onUpgrade()
- {static} ~ getInstance()
- - createSystemFolder()
- - reCreateDataTableTriggers()
- - reCreateNoteTableTriggers()
- - upgradeToV2()
- - upgradeToV3()
- - upgradeToV4()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace data {
- interface net.micode.notes.data.NotesDatabaseHelper.TABLE {
- {static} + DATA : String
- {static} + NOTE : String
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace data {
- class net.micode.notes.data.NotesProvider {
- {static} - NOTES_SEARCH_PROJECTION : String
- {static} - NOTES_SNIPPET_SEARCH_QUERY : String
- {static} - TAG : String
- {static} - URI_DATA : int
- {static} - URI_DATA_ITEM : int
- {static} - URI_NOTE : int
- {static} - URI_NOTE_ITEM : int
- {static} - URI_SEARCH : int
- {static} - URI_SEARCH_SUGGEST : int
- {static} - mMatcher : UriMatcher
- + delete()
- + getType()
- + insert()
- + onCreate()
- + query()
- + update()
- - increaseNoteVersion()
- - parseSelection()
- }
- }
- }
-
-
- net.micode.notes.data.Notes +-down- net.micode.notes.data.Notes.CallNote
- net.micode.notes.data.Notes +-down- net.micode.notes.data.Notes.DataColumns
- net.micode.notes.data.Notes +-down- net.micode.notes.data.Notes.DataConstants
- net.micode.notes.data.Notes +-down- net.micode.notes.data.Notes.NoteColumns
- net.micode.notes.data.Notes +-down- net.micode.notes.data.Notes.TextNote
- net.micode.notes.data.Notes.CallNote .up.|> net.micode.notes.data.Notes.DataColumns
- net.micode.notes.data.Notes.TextNote .up.|> net.micode.notes.data.Notes.DataColumns
- net.micode.notes.data.NotesDatabaseHelper -up-|> android.database.sqlite.SQLiteOpenHelper
- net.micode.notes.data.NotesDatabaseHelper +-down- net.micode.notes.data.NotesDatabaseHelper.TABLE
- net.micode.notes.data.NotesProvider -up-|> android.content.ContentProvider
- net.micode.notes.data.NotesProvider o-- net.micode.notes.data.NotesDatabaseHelper : mHelper
-
-
-right footer
-
-
-PlantUML diagram generated by SketchIt! (https://bitbucket.org/pmesmeur/sketch.it)
-For more information about this tool, please contact philippe.mesmeur@gmail.com
-endfooter
-
-@enduml
diff --git a/app/src/main/java/net/micode/notes/gtask/data/MetaData.java b/app/src/main/java/net/micode/notes/gtask/data/MetaData.java
index 5b2defe..3a2050b 100644
--- a/app/src/main/java/net/micode/notes/gtask/data/MetaData.java
+++ b/app/src/main/java/net/micode/notes/gtask/data/MetaData.java
@@ -24,7 +24,7 @@ import net.micode.notes.tool.GTaskStringUtils;
import org.json.JSONException;
import org.json.JSONObject;
-/** 元数据类 */
+
public class MetaData extends Task {
private final static String TAG = MetaData.class.getSimpleName();
diff --git a/app/src/main/java/net/micode/notes/gtask/data/Node.java b/app/src/main/java/net/micode/notes/gtask/data/Node.java
index 7416241..63950e0 100644
--- a/app/src/main/java/net/micode/notes/gtask/data/Node.java
+++ b/app/src/main/java/net/micode/notes/gtask/data/Node.java
@@ -19,7 +19,7 @@ package net.micode.notes.gtask.data;
import android.database.Cursor;
import org.json.JSONObject;
-/** 同步google task用的任务节点抽象类,信息储存实体,json可序列化对象 */
+
public abstract class Node {
public static final int SYNC_ACTION_NONE = 0;
diff --git a/app/src/main/java/net/micode/notes/gtask/data/SqlData.java b/app/src/main/java/net/micode/notes/gtask/data/SqlData.java
index edc2c63..d3ec3be 100644
--- a/app/src/main/java/net/micode/notes/gtask/data/SqlData.java
+++ b/app/src/main/java/net/micode/notes/gtask/data/SqlData.java
@@ -34,7 +34,7 @@ import net.micode.notes.gtask.exception.ActionFailureException;
import org.json.JSONException;
import org.json.JSONObject;
-/** 直接对接数据库的数据类 */
+
public class SqlData {
private static final String TAG = SqlData.class.getSimpleName();
@@ -54,7 +54,7 @@ public class SqlData {
public static final int DATA_CONTENT_DATA_1_COLUMN = 3;
public static final int DATA_CONTENT_DATA_3_COLUMN = 4;
- /** 此处的ctx是GTaskSyncService,只有那个服务调用了这里 */
+
private ContentResolver mContentResolver;
private boolean mIsCreate;
diff --git a/app/src/main/java/net/micode/notes/gtask/data/SqlNote.java b/app/src/main/java/net/micode/notes/gtask/data/SqlNote.java
index 05cef54..79a4095 100644
--- a/app/src/main/java/net/micode/notes/gtask/data/SqlNote.java
+++ b/app/src/main/java/net/micode/notes/gtask/data/SqlNote.java
@@ -37,7 +37,7 @@ import org.json.JSONObject;
import java.util.ArrayList;
-/** 处理JSON和数据库模式相互对接的数据类 */
+
public class SqlNote {
private static final String TAG = SqlNote.class.getSimpleName();
diff --git a/app/src/main/java/net/micode/notes/gtask/data/Task.java b/app/src/main/java/net/micode/notes/gtask/data/Task.java
index 5f93494..6a19454 100644
--- a/app/src/main/java/net/micode/notes/gtask/data/Task.java
+++ b/app/src/main/java/net/micode/notes/gtask/data/Task.java
@@ -31,7 +31,7 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
-/** 远端任务的json映射实体 */
+
public class Task extends Node {
private static final String TAG = Task.class.getSimpleName();
@@ -53,7 +53,7 @@ public class Task extends Node {
mParent = null;
mMetaInfo = null;
}
- /** 构造创建给定id的动作的json */
+
public JSONObject getCreateAction(int actionId) {
JSONObject js = new JSONObject();
@@ -102,7 +102,7 @@ public class Task extends Node {
return js;
}
- /** 构造更新给定id的动作的json,actionId可能作为主键,在GTaskClient中用一个自增计数器维护 */
+
public JSONObject getUpdateAction(int actionId) {
JSONObject js = new JSONObject();
@@ -134,7 +134,7 @@ public class Task extends Node {
return js;
}
- /** 用远端返回的json设置各种状态 */
+
public void setContentByRemoteJSON(JSONObject js) {
if (js != null) {
try {
@@ -174,7 +174,7 @@ public class Task extends Node {
}
}
}
- /** 根据本地json设置状态 */
+
public void setContentByLocalJSON(JSONObject js) {
if (js == null || !js.has(GTaskStringUtils.META_HEAD_NOTE)
|| !js.has(GTaskStringUtils.META_HEAD_DATA)) {
@@ -203,7 +203,7 @@ public class Task extends Node {
e.printStackTrace();
}
}
- /** 自身mMetaInfo信息序列化为json */
+
public JSONObject getLocalJSONFromContent() {
String name = getName();
try {
@@ -246,7 +246,7 @@ public class Task extends Node {
return null;
}
}
- /** 写入元数据 */
+
public void setMetaInfo(MetaData metaData) {
if (metaData != null && metaData.getNotes() != null) {
try {
@@ -257,7 +257,7 @@ public class Task extends Node {
}
}
}
- /** 对于游标处的数据,应该做出什么样的同步动作 */
+
public int getSyncAction(Cursor c) {
try {
JSONObject noteInfo = null;
@@ -310,7 +310,7 @@ public class Task extends Node {
return SYNC_ACTION_ERROR;
}
- /** 数据是否有效且值得保存 */
+
public boolean isWorthSaving() {
return mMetaInfo != null || (getName() != null && getName().trim().length() > 0)
|| (getNotes() != null && getNotes().trim().length() > 0);
diff --git a/app/src/main/java/net/micode/notes/gtask/data/TaskList.java b/app/src/main/java/net/micode/notes/gtask/data/TaskList.java
index 1a58218..4ea21c5 100644
--- a/app/src/main/java/net/micode/notes/gtask/data/TaskList.java
+++ b/app/src/main/java/net/micode/notes/gtask/data/TaskList.java
@@ -29,7 +29,7 @@ import org.json.JSONObject;
import java.util.ArrayList;
-/** 任务表 */
+
public class TaskList extends Node {
private static final String TAG = TaskList.class.getSimpleName();
@@ -333,11 +333,11 @@ public class TaskList extends Node {
return this.mChildren;
}
-// public void setIndex(int index) {
-// this.mIndex = index;
-// }
+ public void setIndex(int index) {
+ this.mIndex = index;
+ }
-// public int getIndex() {
-// return this.mIndex;
-// }
+ public int getIndex() {
+ return this.mIndex;
+ }
}
diff --git a/app/src/main/java/net/micode/notes/gtask/data/data.plantuml b/app/src/main/java/net/micode/notes/gtask/data/data.plantuml
deleted file mode 100644
index 1308c97..0000000
--- a/app/src/main/java/net/micode/notes/gtask/data/data.plantuml
+++ /dev/null
@@ -1,225 +0,0 @@
-@startuml
-
-title __DATA's Class Diagram__\n
-
- namespace net.micode.notes {
- namespace gtask.data {
- class net.micode.notes.gtask.data.MetaData {
- {static} - TAG : String
- - mRelatedGid : String
- + getLocalJSONFromContent()
- + getRelatedGid()
- + getSyncAction()
- + isWorthSaving()
- + setContentByLocalJSON()
- + setContentByRemoteJSON()
- + setMeta()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace gtask.data {
- abstract class net.micode.notes.gtask.data.Node {
- {static} + SYNC_ACTION_ADD_LOCAL : int
- {static} + SYNC_ACTION_ADD_REMOTE : int
- {static} + SYNC_ACTION_DEL_LOCAL : int
- {static} + SYNC_ACTION_DEL_REMOTE : int
- {static} + SYNC_ACTION_ERROR : int
- {static} + SYNC_ACTION_NONE : int
- {static} + SYNC_ACTION_UPDATE_CONFLICT : int
- {static} + SYNC_ACTION_UPDATE_LOCAL : int
- {static} + SYNC_ACTION_UPDATE_REMOTE : int
- - mDeleted : boolean
- - mGid : String
- - mLastModified : long
- - mName : String
- + Node()
- {abstract} + getCreateAction()
- + getDeleted()
- + getGid()
- + getLastModified()
- {abstract} + getLocalJSONFromContent()
- + getName()
- {abstract} + getSyncAction()
- {abstract} + getUpdateAction()
- {abstract} + setContentByLocalJSON()
- {abstract} + setContentByRemoteJSON()
- + setDeleted()
- + setGid()
- + setLastModified()
- + setName()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace gtask.data {
- class net.micode.notes.gtask.data.SqlData {
- {static} + DATA_CONTENT_COLUMN : int
- {static} + DATA_CONTENT_DATA_1_COLUMN : int
- {static} + DATA_CONTENT_DATA_3_COLUMN : int
- {static} + DATA_ID_COLUMN : int
- {static} + DATA_MIME_TYPE_COLUMN : int
- {static} + PROJECTION_DATA : String[]
- {static} - INVALID_ID : int
- {static} - TAG : String
- - mContentResolver : ContentResolver
- - mDataContent : String
- - mDataContentData1 : long
- - mDataContentData3 : String
- - mDataId : long
- - mDataMimeType : String
- - mDiffDataValues : ContentValues
- - mIsCreate : boolean
- + SqlData()
- + SqlData()
- + commit()
- + getContent()
- + getId()
- + setContent()
- - loadFromCursor()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace gtask.data {
- class net.micode.notes.gtask.data.SqlNote {
- {static} + ALERTED_DATE_COLUMN : int
- {static} + BG_COLOR_ID_COLUMN : int
- {static} + CREATED_DATE_COLUMN : int
- {static} + GTASK_ID_COLUMN : int
- {static} + HAS_ATTACHMENT_COLUMN : int
- {static} + ID_COLUMN : int
- {static} + LOCAL_MODIFIED_COLUMN : int
- {static} + MODIFIED_DATE_COLUMN : int
- {static} + NOTES_COUNT_COLUMN : int
- {static} + ORIGIN_PARENT_ID_COLUMN : int
- {static} + PARENT_ID_COLUMN : int
- {static} + PROJECTION_NOTE : String[]
- {static} + SNIPPET_COLUMN : int
- {static} + SYNC_ID_COLUMN : int
- {static} + TYPE_COLUMN : int
- {static} + VERSION_COLUMN : int
- {static} + WIDGET_ID_COLUMN : int
- {static} + WIDGET_TYPE_COLUMN : int
- {static} - INVALID_ID : int
- {static} - TAG : String
- - mAlertDate : long
- - mBgColorId : int
- - mContentResolver : ContentResolver
- - mContext : Context
- - mCreatedDate : long
- - mDataList : ArrayList
- - mDiffNoteValues : ContentValues
- - mHasAttachment : int
- - mId : long
- - mIsCreate : boolean
- - mModifiedDate : long
- - mOriginParent : long
- - mParentId : long
- - mSnippet : String
- - mType : int
- - mVersion : long
- - mWidgetId : int
- - mWidgetType : int
- + SqlNote()
- + SqlNote()
- + SqlNote()
- + commit()
- + getContent()
- + getId()
- + getParentId()
- + getSnippet()
- + isNoteType()
- + resetLocalModified()
- + setContent()
- + setGtaskId()
- + setParentId()
- + setSyncId()
- - loadDataContent()
- - loadFromCursor()
- - loadFromCursor()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace gtask.data {
- class net.micode.notes.gtask.data.Task {
- {static} - TAG : String
- - mCompleted : boolean
- - mMetaInfo : JSONObject
- - mNotes : String
- + Task()
- + getCompleted()
- + getCreateAction()
- + getLocalJSONFromContent()
- + getNotes()
- + getParent()
- + getPriorSibling()
- + getSyncAction()
- + getUpdateAction()
- + isWorthSaving()
- + setCompleted()
- + setContentByLocalJSON()
- + setContentByRemoteJSON()
- + setMetaInfo()
- + setNotes()
- + setParent()
- + setPriorSibling()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace gtask.data {
- class net.micode.notes.gtask.data.TaskList {
- {static} - TAG : String
- - mChildren : ArrayList
- - mIndex : int
- + TaskList()
- + addChildTask()
- + addChildTask()
- + findChildTaskByGid()
- + getChilTaskByGid()
- + getChildTaskByIndex()
- + getChildTaskCount()
- + getChildTaskIndex()
- + getChildTaskList()
- + getCreateAction()
- + getIndex()
- + getLocalJSONFromContent()
- + getSyncAction()
- + getUpdateAction()
- + moveChildTask()
- + removeChildTask()
- + setContentByLocalJSON()
- + setContentByRemoteJSON()
- + setIndex()
- }
- }
- }
-
-
- net.micode.notes.gtask.data.MetaData -up-|> net.micode.notes.gtask.data.Task
- net.micode.notes.gtask.data.Task -up-|> net.micode.notes.gtask.data.Node
- net.micode.notes.gtask.data.Task o-- net.micode.notes.gtask.data.TaskList : mParent
- net.micode.notes.gtask.data.Task o-- net.micode.notes.gtask.data.Task : mPriorSibling
- net.micode.notes.gtask.data.TaskList -up-|> net.micode.notes.gtask.data.Node
-
-
-right footer
-
-
-PlantUML diagram generated by SketchIt! (https://bitbucket.org/pmesmeur/sketch.it)
-For more information about this tool, please contact philippe.mesmeur@gmail.com
-endfooter
-
-@enduml
diff --git a/app/src/main/java/net/micode/notes/gtask/exception/ActionFailureException.java b/app/src/main/java/net/micode/notes/gtask/exception/ActionFailureException.java
index f0d26d0..15504be 100644
--- a/app/src/main/java/net/micode/notes/gtask/exception/ActionFailureException.java
+++ b/app/src/main/java/net/micode/notes/gtask/exception/ActionFailureException.java
@@ -15,7 +15,7 @@
*/
package net.micode.notes.gtask.exception;
-/**自定义事件失败连接异常*/
+
public class ActionFailureException extends RuntimeException {
private static final long serialVersionUID = 4425249765923293627L;
diff --git a/app/src/main/java/net/micode/notes/gtask/exception/NetworkFailureException.java b/app/src/main/java/net/micode/notes/gtask/exception/NetworkFailureException.java
index d7c6010..b08cfb1 100644
--- a/app/src/main/java/net/micode/notes/gtask/exception/NetworkFailureException.java
+++ b/app/src/main/java/net/micode/notes/gtask/exception/NetworkFailureException.java
@@ -15,7 +15,7 @@
*/
package net.micode.notes.gtask.exception;
-/**自定义网络连接异常*/
+
public class NetworkFailureException extends Exception {
private static final long serialVersionUID = 2107610287180234136L;
diff --git a/app/src/main/java/net/micode/notes/gtask/exception/exception.plantuml b/app/src/main/java/net/micode/notes/gtask/exception/exception.plantuml
deleted file mode 100644
index 5861db2..0000000
--- a/app/src/main/java/net/micode/notes/gtask/exception/exception.plantuml
+++ /dev/null
@@ -1,38 +0,0 @@
-@startuml
-
-title __EXCEPTION's Class Diagram__\n
-
- namespace net.micode.notes {
- namespace gtask.exception {
- class net.micode.notes.gtask.exception.ActionFailureException {
- {static} - serialVersionUID : long
- + ActionFailureException()
- + ActionFailureException()
- + ActionFailureException()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace gtask.exception {
- class net.micode.notes.gtask.exception.NetworkFailureException {
- {static} - serialVersionUID : long
- + NetworkFailureException()
- + NetworkFailureException()
- + NetworkFailureException()
- }
- }
- }
-
-
-
-
-right footer
-
-
-PlantUML diagram generated by SketchIt! (https://bitbucket.org/pmesmeur/sketch.it)
-For more information about this tool, please contact philippe.mesmeur@gmail.com
-endfooter
-
-@enduml
diff --git a/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java b/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java
index 5c99037..56c8e5e 100644
--- a/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java
+++ b/app/src/main/java/net/micode/notes/gtask/remote/GTaskASyncTask.java
@@ -23,14 +23,12 @@ import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
-import android.os.Build;
-import android.support.annotation.RequiresApi;
import net.micode.notes.R;
import net.micode.notes.ui.NotesListActivity;
import net.micode.notes.ui.NotesPreferenceActivity;
-/** 异步GTask后台同步任务 */
+
public class GTaskASyncTask extends AsyncTask {
private static int GTASK_SYNC_NOTIFICATION_ID = 5234235;
@@ -46,7 +44,7 @@ public class GTaskASyncTask extends AsyncTask {
private GTaskManager mTaskManager;
private OnCompleteListener mOnCompleteListener;
- /** 构造函数,同步完成后会调用listener */
+
public GTaskASyncTask(Context context, OnCompleteListener listener) {
mContext = context;
mOnCompleteListener = listener;
@@ -58,20 +56,18 @@ public class GTaskASyncTask extends AsyncTask {
public void cancelSync() {
mTaskManager.cancelSync();
}
- /** 报告任务进度用的,这里没用 */
+
public void publishProgess(String message) {
publishProgress(new String[] {
message
});
}
- /** 上拉横幅提醒content字符串 */
- @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
- private void showNotification(int tickerId, String content) {
-
-
-// Notification notification = new Notification(R.drawable.notification, mContext
-// .getString(tickerId), System.currentTimeMillis());
+ private void showNotification(int tickerId, String content) {
+ Notification notification = new Notification(R.drawable.notification, mContext
+ .getString(tickerId), System.currentTimeMillis());
+ notification.defaults = Notification.DEFAULT_LIGHTS;
+ notification.flags = Notification.FLAG_AUTO_CANCEL;
PendingIntent pendingIntent;
if (tickerId != R.string.ticker_success) {
pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
@@ -81,18 +77,9 @@ public class GTaskASyncTask extends AsyncTask {
pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
NotesListActivity.class), 0);
}
- Notification.Builder bd = new Notification.Builder(mContext)
- .setSmallIcon(R.drawable.notification)
- .setContentTitle(mContext.getString(R.string.app_name))
- .setContentText(content)
- .setContentIntent(pendingIntent)
- .setWhen(System.currentTimeMillis())
- .setTicker(mContext.getString(tickerId));
- Notification notification = bd.build();
- notification.defaults = Notification.DEFAULT_LIGHTS;
- notification.flags = Notification.FLAG_AUTO_CANCEL;
// notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content,
// pendingIntent);
+ notification.contentIntent = pendingIntent;
mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);
}
@@ -102,8 +89,7 @@ public class GTaskASyncTask extends AsyncTask {
.getSyncAccountName(mContext)));
return mTaskManager.sync(mContext, this);
}
- /** 显示同步便签中 */
- @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
+
@Override
protected void onProgressUpdate(String... progress) {
showNotification(R.string.ticker_syncing, progress[0]);
@@ -111,7 +97,7 @@ public class GTaskASyncTask extends AsyncTask {
((GTaskSyncService) mContext).sendBroadcast(progress[0]);
}
}
- /** 任务执行结束后调用,横幅报告执行结果,开新线程跑listener */
+
@Override
protected void onPostExecute(Integer result) {
if (result == GTaskManager.STATE_SUCCESS) {
diff --git a/app/src/main/java/net/micode/notes/gtask/remote/GTaskClient.java b/app/src/main/java/net/micode/notes/gtask/remote/GTaskClient.java
index c4df1c4..c67dfdf 100644
--- a/app/src/main/java/net/micode/notes/gtask/remote/GTaskClient.java
+++ b/app/src/main/java/net/micode/notes/gtask/remote/GTaskClient.java
@@ -60,7 +60,7 @@ import java.util.zip.GZIPInputStream;
import java.util.zip.Inflater;
import java.util.zip.InflaterInputStream;
-/** 网络层工具类,对接谷歌日历/任务 */
+
public class GTaskClient {
private static final String TAG = GTaskClient.class.getSimpleName();
@@ -101,14 +101,14 @@ public class GTaskClient {
mAccount = null;
mUpdateArray = null;
}
- /** 拿单例 */
+
public static synchronized GTaskClient getInstance() {
if (mInstance == null) {
mInstance = new GTaskClient();
}
return mInstance;
}
- /** 实现登录,如果超过5min就重新登录,返回登录是否成功 */
+
public boolean login(Activity activity) {
// we suppose that the cookie would expire after 5 minutes
// then we need to re-login
@@ -163,7 +163,7 @@ public class GTaskClient {
mLoggedin = true;
return true;
}
- /** 登录谷歌账号,invalidateToken指定是否释放令牌(应用程序有责任在令牌失效时释放令牌),使用了麻烦的AccountManager机制 */
+
private String loginGoogleAccount(Activity activity, boolean invalidateToken) {
String authToken;
AccountManager accountManager = AccountManager.get(activity);
@@ -224,7 +224,7 @@ public class GTaskClient {
}
return true;
}
- /** 用给定的令牌登录谷歌任务(GTask),返回是否登录成功,写入mClientVersion,cookie可能会写入mHttpClient */
+
private boolean loginGtask(String authToken) {
int timeoutConnection = 10000;
int timeoutSocket = 15000;
@@ -279,18 +279,18 @@ public class GTaskClient {
return true;
}
- /** 自增计数器生成action id */
+
private int getActionId() {
return mActionId++;
}
- /** 构造urlencoded的form请求头 */
+
private HttpPost createHttpPost() {
HttpPost httpPost = new HttpPost(mPostUrl);
httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
httpPost.setHeader("AT", "1");
return httpPost;
}
- /** 处理HTTP gzip / deflate 压缩,返回请求正文 */
+
private String getResponseContent(HttpEntity entity) throws IOException {
String contentEncoding = null;
if (entity.getContentEncoding() != null) {
@@ -322,7 +322,7 @@ public class GTaskClient {
input.close();
}
}
- /** 把json序列化为字符串,然后以form形式发送(application/json不行吗) */
+
private JSONObject postRequest(JSONObject js) throws NetworkFailureException {
if (!mLoggedin) {
Log.e(TAG, "please login first");
@@ -359,7 +359,7 @@ public class GTaskClient {
throw new ActionFailureException("error occurs when posting request");
}
}
- /** 构造一个Task请求,如果成功则写入task的mGid */
+
public void createTask(Task task) throws NetworkFailureException {
commitUpdate();
try {
@@ -385,7 +385,7 @@ public class GTaskClient {
throw new ActionFailureException("create task: handing jsonobject failed");
}
}
- /** 构造并向远端发送任务表,将gid结果写回 */
+
public void createTaskList(TaskList tasklist) throws NetworkFailureException {
commitUpdate();
try {
@@ -411,7 +411,7 @@ public class GTaskClient {
throw new ActionFailureException("create tasklist: handing jsonobject failed");
}
}
- /** 提交现有更新操作 */
+
public void commitUpdate() throws NetworkFailureException {
if (mUpdateArray != null) {
try {
@@ -432,7 +432,7 @@ public class GTaskClient {
}
}
}
- /** 增加一条更新操作动作 */
+
public void addUpdateNode(Node node) throws NetworkFailureException {
if (node != null) {
// too many update items may result in an error
@@ -446,7 +446,7 @@ public class GTaskClient {
mUpdateArray.put(node.getUpdateAction(getActionId()));
}
}
- /** 向远端报告一个移动任务动作,将任务task从preParent移动到curParent中 */
+
public void moveTask(Task task, TaskList preParent, TaskList curParent)
throws NetworkFailureException {
commitUpdate();
@@ -485,7 +485,7 @@ public class GTaskClient {
throw new ActionFailureException("move task: handing jsonobject failed");
}
}
- /** 删除一个节点 */
+
public void deleteNode(Node node) throws NetworkFailureException {
commitUpdate();
try {
@@ -508,7 +508,7 @@ public class GTaskClient {
throw new ActionFailureException("delete node: handing jsonobject failed");
}
}
- /** 从云端拉下来所有任务表,包装成json */
+
public JSONArray getTaskLists() throws NetworkFailureException {
if (!mLoggedin) {
Log.e(TAG, "please login first");
@@ -546,7 +546,7 @@ public class GTaskClient {
throw new ActionFailureException("get task lists: handing jasonobject failed");
}
}
- /** 用gid拿任务表 */
+
public JSONArray getTaskList(String listGid) throws NetworkFailureException {
commitUpdate();
try {
diff --git a/app/src/main/java/net/micode/notes/gtask/remote/GTaskManager.java b/app/src/main/java/net/micode/notes/gtask/remote/GTaskManager.java
index cfb5da0..d2b4082 100644
--- a/app/src/main/java/net/micode/notes/gtask/remote/GTaskManager.java
+++ b/app/src/main/java/net/micode/notes/gtask/remote/GTaskManager.java
@@ -47,7 +47,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
-/** 管理同步任务的单例工具类 */
+
public class GTaskManager {
private static final String TAG = GTaskManager.class.getSimpleName();
@@ -98,7 +98,7 @@ public class GTaskManager {
mGidToNid = new HashMap();
mNidToGid = new HashMap();
}
- /** 线程安全地获取单例 */
+
public static synchronized GTaskManager getInstance() {
if (mInstance == null) {
mInstance = new GTaskManager();
@@ -110,7 +110,7 @@ public class GTaskManager {
// used for getting authtoken
mActivity = activity;
}
- /** 执行同步 */
+
public int sync(Context context, GTaskASyncTask asyncTask) {
if (mSyncing) {
Log.d(TAG, "Sync is in progress");
@@ -167,7 +167,7 @@ public class GTaskManager {
return mCancelled ? STATE_SYNC_CANCELLED : STATE_SUCCESS;
}
- /** 下载任务表,塞到mGTaskHashMap里 */
+
private void initGTaskList() throws NetworkFailureException {
if (mCancelled)
return;
@@ -246,7 +246,7 @@ public class GTaskManager {
throw new ActionFailureException("initGTaskList: handing JSONObject failed");
}
}
- /** */
+
private void syncContent() throws NetworkFailureException {
int syncType;
Cursor c = null;
diff --git a/app/src/main/java/net/micode/notes/gtask/remote/GTaskSyncService.java b/app/src/main/java/net/micode/notes/gtask/remote/GTaskSyncService.java
index 15f2acf..cca36f7 100644
--- a/app/src/main/java/net/micode/notes/gtask/remote/GTaskSyncService.java
+++ b/app/src/main/java/net/micode/notes/gtask/remote/GTaskSyncService.java
@@ -22,7 +22,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
-/** 同步功能的后台服务 */
+
public class GTaskSyncService extends Service {
public final static String ACTION_STRING_NAME = "sync_action_type";
diff --git a/app/src/main/java/net/micode/notes/gtask/remote/remote.plantuml b/app/src/main/java/net/micode/notes/gtask/remote/remote.plantuml
deleted file mode 100644
index 6292caf..0000000
--- a/app/src/main/java/net/micode/notes/gtask/remote/remote.plantuml
+++ /dev/null
@@ -1,159 +0,0 @@
-@startuml
-
-title __REMOTE's Class Diagram__\n
-
- namespace net.micode.notes {
- namespace gtask.remote {
- class net.micode.notes.gtask.remote.GTaskASyncTask {
- {static} - GTASK_SYNC_NOTIFICATION_ID : int
- - mContext : Context
- - mNotifiManager : NotificationManager
- + GTaskASyncTask()
- + cancelSync()
- + publishProgess()
- # doInBackground()
- # onPostExecute()
- # onProgressUpdate()
- - showNotification()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace gtask.remote {
- interface net.micode.notes.gtask.remote.GTaskASyncTask.OnCompleteListener {
- {abstract} + onComplete()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace gtask.remote {
- class net.micode.notes.gtask.remote.GTaskClient {
- {static} - GTASK_GET_URL : String
- {static} - GTASK_POST_URL : String
- {static} - GTASK_URL : String
- {static} - TAG : String
- - mAccount : Account
- - mActionId : int
- - mClientVersion : long
- - mGetUrl : String
- - mHttpClient : DefaultHttpClient
- {static} - mInstance : GTaskClient
- - mLastLoginTime : long
- - mLoggedin : boolean
- - mPostUrl : String
- - mUpdateArray : JSONArray
- + addUpdateNode()
- + commitUpdate()
- + createTask()
- + createTaskList()
- + deleteNode()
- {static} + getInstance()
- + getSyncAccount()
- + getTaskList()
- + getTaskLists()
- + login()
- + moveTask()
- + resetUpdateArray()
- - GTaskClient()
- - createHttpPost()
- - getActionId()
- - getResponseContent()
- - loginGoogleAccount()
- - loginGtask()
- - postRequest()
- - tryToLoginGtask()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace gtask.remote {
- class net.micode.notes.gtask.remote.GTaskManager {
- {static} + STATE_INTERNAL_ERROR : int
- {static} + STATE_NETWORK_ERROR : int
- {static} + STATE_SUCCESS : int
- {static} + STATE_SYNC_CANCELLED : int
- {static} + STATE_SYNC_IN_PROGRESS : int
- {static} - TAG : String
- - mActivity : Activity
- - mCancelled : boolean
- - mContentResolver : ContentResolver
- - mContext : Context
- - mGTaskHashMap : HashMap
- - mGTaskListHashMap : HashMap
- - mGidToNid : HashMap
- {static} - mInstance : GTaskManager
- - mLocalDeleteIdMap : HashSet
- - mMetaHashMap : HashMap
- - mNidToGid : HashMap
- - mSyncing : boolean
- + cancelSync()
- {static} + getInstance()
- + getSyncAccount()
- + setActivityContext()
- + sync()
- - GTaskManager()
- - addLocalNode()
- - addRemoteNode()
- - doContentSync()
- - initGTaskList()
- - refreshLocalSyncId()
- - syncContent()
- - syncFolder()
- - updateLocalNode()
- - updateRemoteMeta()
- - updateRemoteNode()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace gtask.remote {
- class net.micode.notes.gtask.remote.GTaskSyncService {
- {static} + ACTION_CANCEL_SYNC : int
- {static} + ACTION_INVALID : int
- {static} + ACTION_START_SYNC : int
- {static} + ACTION_STRING_NAME : String
- {static} + GTASK_SERVICE_BROADCAST_IS_SYNCING : String
- {static} + GTASK_SERVICE_BROADCAST_NAME : String
- {static} + GTASK_SERVICE_BROADCAST_PROGRESS_MSG : String
- {static} - mSyncProgress : String
- {static} - mSyncTask : GTaskASyncTask
- {static} + cancelSync()
- {static} + getProgressString()
- {static} + isSyncing()
- + onBind()
- + onCreate()
- + onLowMemory()
- + onStartCommand()
- + sendBroadcast()
- {static} + startSync()
- - cancelSync()
- - startSync()
- }
- }
- }
-
-
- net.micode.notes.gtask.remote.GTaskASyncTask -up-|> android.os.AsyncTask
- net.micode.notes.gtask.remote.GTaskASyncTask o-- net.micode.notes.gtask.remote.GTaskASyncTask.OnCompleteListener : mOnCompleteListener
- net.micode.notes.gtask.remote.GTaskASyncTask o-- net.micode.notes.gtask.remote.GTaskManager : mTaskManager
- net.micode.notes.gtask.remote.GTaskASyncTask +-down- net.micode.notes.gtask.remote.GTaskASyncTask.OnCompleteListener
- net.micode.notes.gtask.remote.GTaskManager o-- net.micode.notes.gtask.data.TaskList : mMetaList
- net.micode.notes.gtask.remote.GTaskSyncService -up-|> android.app.Service
-
-
-right footer
-
-
-PlantUML diagram generated by SketchIt! (https://bitbucket.org/pmesmeur/sketch.it)
-For more information about this tool, please contact philippe.mesmeur@gmail.com
-endfooter
-
-@enduml
diff --git a/app/src/main/java/net/micode/notes/model/Note.java b/app/src/main/java/net/micode/notes/model/Note.java
index 26ce8f2..6706cf6 100644
--- a/app/src/main/java/net/micode/notes/model/Note.java
+++ b/app/src/main/java/net/micode/notes/model/Note.java
@@ -50,10 +50,8 @@ public class Note {
values.put(NoteColumns.TYPE, Notes.TYPE_NOTE);
values.put(NoteColumns.LOCAL_MODIFIED, 1);
values.put(NoteColumns.PARENT_ID, folderId);
- //将数据写入数据库表格
Uri uri = context.getContentResolver().insert(Notes.CONTENT_NOTE_URI, values);
- //ContentResolver()主要是实现外部应用对ContentProvider中的数据
- //进行添加、删除、修改和查询操作
+
long noteId = 0;
try {
noteId = Long.valueOf(uri.getPathSegments().get(1));
@@ -66,42 +64,42 @@ public class Note {
}
return noteId;
}
- //定义两个变量用来存储便签的数据,一个是存储便签属性、一个是存储便签内容
+
public Note() {
mNoteDiffValues = new ContentValues();
mNoteData = new NoteData();
}
- //设置数据库表格的标签属性数据
+
public void setNoteValue(String key, String value) {
mNoteDiffValues.put(key, value);
mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1);
mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
}
- //设置数据库表格的标签文本内容的数据
+
public void setTextData(String key, String value) {
mNoteData.setTextData(key, value);
}
- //设置文本数据的ID
+
public void setTextDataId(long id) {
mNoteData.setTextDataId(id);
}
- //得到文本数据的ID
+
public long getTextDataId() {
return mNoteData.mTextDataId;
}
- //设置电话号码数据的ID
+
public void setCallDataId(long id) {
mNoteData.setCallDataId(id);
}
- //得到电话号码数据的ID
+
public void setCallData(String key, String value) {
mNoteData.setCallData(key, value);
}
- //判断是否是本地修改
+
public boolean isLocalModified() {
return mNoteDiffValues.size() > 0 || mNoteData.isLocalModified();
}
- //判断数据是否同步
+
public boolean syncNote(Context context, long noteId) {
if (noteId <= 0) {
throw new IllegalArgumentException("Wrong note id:" + noteId);
@@ -131,14 +129,14 @@ public class Note {
return true;
}
- //定义一个基本的便签内容的数据类,主要包含文本数据和电话号码数据
+
private class NoteData {
private long mTextDataId;
- //文本数据
+
private ContentValues mTextDataValues;
private long mCallDataId;
- //电话号码数据
+
private ContentValues mCallDataValues;
private static final String TAG = "NoteData";
@@ -149,7 +147,7 @@ public class Note {
mTextDataId = 0;
mCallDataId = 0;
}
- //下面是上述几个函数的具体实现
+
boolean isLocalModified() {
return mTextDataValues.size() > 0 || mCallDataValues.size() > 0;
}
@@ -179,20 +177,18 @@ public class Note {
mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1);
mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
}
- //下面函数的作用是将新的数据通过Uri的操作存储到数据库
+
Uri pushIntoContentResolver(Context context, long noteId) {
/**
* Check for safety
*/
- //判断数据是否合法
if (noteId <= 0) {
throw new IllegalArgumentException("Wrong note id:" + noteId);
}
ArrayList operationList = new ArrayList();
ContentProviderOperation.Builder builder = null;
- //数据库的操作列表
- //把文本数据存入DataColumns
+
if(mTextDataValues.size() > 0) {
mTextDataValues.put(DataColumns.NOTE_ID, noteId);
if (mTextDataId == 0) {
@@ -214,7 +210,7 @@ public class Note {
}
mTextDataValues.clear();
}
- //把电话号码数据存入DataColumns
+
if(mCallDataValues.size() > 0) {
mCallDataValues.put(DataColumns.NOTE_ID, noteId);
if (mCallDataId == 0) {
@@ -236,7 +232,7 @@ public class Note {
}
mCallDataValues.clear();
}
- //存储过程中的异常处理
+
if (operationList.size() > 0) {
try {
ContentProviderResult[] results = context.getContentResolver().applyBatch(
diff --git a/app/src/main/java/net/micode/notes/model/WorkingNote.java b/app/src/main/java/net/micode/notes/model/WorkingNote.java
index a7317e0..be081e4 100644
--- a/app/src/main/java/net/micode/notes/model/WorkingNote.java
+++ b/app/src/main/java/net/micode/notes/model/WorkingNote.java
@@ -61,7 +61,7 @@ public class WorkingNote {
private boolean mIsDeleted;
private NoteSettingChangedListener mNoteSettingStatusListener;
- // 声明 DATA_PROJECTION字符串数组
+
public static final String[] DATA_PROJECTION = new String[] {
DataColumns.ID,
DataColumns.CONTENT,
@@ -71,7 +71,7 @@ public class WorkingNote {
DataColumns.DATA3,
DataColumns.DATA4,
};
- // 声明 NOTE_PROJECTION字符串数组
+
public static final String[] NOTE_PROJECTION = new String[] {
NoteColumns.PARENT_ID,
NoteColumns.ALERTED_DATE,
@@ -115,7 +115,6 @@ public class WorkingNote {
}
// Existing note construct
- // WorkingNote的构造函数
private WorkingNote(Context context, long noteId, long folderId) {
mContext = context;
mNoteId = noteId;
@@ -125,12 +124,11 @@ public class WorkingNote {
loadNote();
}
- // 加载Note,通过数据库调用query函数找到第一个条目
private void loadNote() {
Cursor cursor = mContext.getContentResolver().query(
ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mNoteId), NOTE_PROJECTION, null,
null, null);
- // 若存在,储存相应信息
+
if (cursor != null) {
if (cursor.moveToFirst()) {
mFolderId = cursor.getLong(NOTE_PARENT_ID_COLUMN);
@@ -142,21 +140,19 @@ public class WorkingNote {
}
cursor.close();
} else {
- // 若不存在,报错
Log.e(TAG, "No note with id:" + mNoteId);
throw new IllegalArgumentException("Unable to find note with id " + mNoteId);
}
loadNoteData();
}
- // 加载NoteData
+
private void loadNoteData() {
Cursor cursor = mContext.getContentResolver().query(Notes.CONTENT_DATA_URI, DATA_PROJECTION,
DataColumns.NOTE_ID + "=?", new String[] {
String.valueOf(mNoteId)
}, null);
- // 查到信息不为空
+
if (cursor != null) {
- // 查看第一项是否存在
if (cursor.moveToFirst()) {
do {
String type = cursor.getString(DATA_MIME_TYPE_COLUMN);
@@ -169,7 +165,7 @@ public class WorkingNote {
} else {
Log.d(TAG, "Wrong note type with type:" + type);
}
- } while (cursor.moveToNext());//查阅所有项,直到为空
+ } while (cursor.moveToNext());
}
cursor.close();
} else {
@@ -177,7 +173,7 @@ public class WorkingNote {
throw new IllegalArgumentException("Unable to find note's data with id " + mNoteId);
}
}
- // 创建空的Note(context,id,widget,bgcolor)
+
public static WorkingNote createEmptyNote(Context context, long folderId, int widgetId,
int widgetType, int defaultBgColorId) {
WorkingNote note = new WorkingNote(context, folderId);
@@ -190,10 +186,10 @@ public class WorkingNote {
public static WorkingNote load(Context context, long id) {
return new WorkingNote(context, id, 0);
}
- // 保存Note
+
public synchronized boolean saveNote() {
- if (isWorthSaving()) {//是否值得保存
- if (!existInDatabase()) {// 是否存在数据库中
+ if (isWorthSaving()) {
+ if (!existInDatabase()) {
if ((mNoteId = Note.getNewNoteId(mContext, mFolderId)) == 0) {
Log.e(TAG, "Create new note fail with id:" + mNoteId);
return false;
@@ -215,13 +211,12 @@ public class WorkingNote {
return false;
}
}
- // 是否在数据库中存在
+
public boolean existInDatabase() {
return mNoteId > 0;
}
- // 是否值得保存
+
private boolean isWorthSaving() {
- // 被删除或不在数据库中或内容为空或本地已保存过
if (mIsDeleted || (!existInDatabase() && TextUtils.isEmpty(mContent))
|| (existInDatabase() && !mNote.isLocalModified())) {
return false;
@@ -229,11 +224,11 @@ public class WorkingNote {
return true;
}
}
- // 设置mNoteSettingStatusListener
+
public void setOnSettingStatusChangedListener(NoteSettingChangedListener l) {
mNoteSettingStatusListener = l;
}
- // 设置AlertDate,若 mAlertDate与data不同,则更改mAlertDate并设定NoteValue
+
public void setAlertDate(long date, boolean set) {
if (date != mAlertDate) {
mAlertDate = date;
@@ -243,18 +238,17 @@ public class WorkingNote {
mNoteSettingStatusListener.onClockAlertChanged(date, set);
}
}
- // 设定删除标记(mark)
+
public void markDeleted(boolean mark) {
mIsDeleted = mark;
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
&& mWidgetType != Notes.TYPE_WIDGET_INVALIDE && mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onWidgetChanged();
- // 调用mNoteSettingStatusListener的 onWidgetChanged方法
}
}
- // 设定背景颜色(id)
+
public void setBgColorId(int id) {
- if (id != mBgColorId) {//条件id!=mBgColorId
+ if (id != mBgColorId) {
mBgColorId = id;
if (mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onBackgroundColorChanged();
@@ -262,9 +256,9 @@ public class WorkingNote {
mNote.setNoteValue(NoteColumns.BG_COLOR_ID, String.valueOf(id));
}
}
- // 设定检查列表模式(mode)
+
public void setCheckListMode(int mode) {
- if (mMode != mode) {//条件mMode!=mode
+ if (mMode != mode) {
if (mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onCheckListModeChanged(mMode, mode);
}
@@ -272,85 +266,82 @@ public class WorkingNote {
mNote.setTextData(TextNote.MODE, String.valueOf(mMode));
}
}
- // 设定WidgetType(type)
+
public void setWidgetType(int type) {
- if (type != mWidgetType) {//条件type!=mWidgetType
+ if (type != mWidgetType) {
mWidgetType = type;
mNote.setNoteValue(NoteColumns.WIDGET_TYPE, String.valueOf(mWidgetType));
- // 调用Note的setNoteValue方法更改WidgetType
}
}
- // 设定WidgetId(id)
+
public void setWidgetId(int id) {
- if (id != mWidgetId) {//条件id!=mWidgetId
+ if (id != mWidgetId) {
mWidgetId = id;
mNote.setNoteValue(NoteColumns.WIDGET_ID, String.valueOf(mWidgetId));
- // 调用Note的setNoteValue方法更改WidgetId
}
}
- // 设定WorkingTex(text)
+
public void setWorkingText(String text) {
- if (!TextUtils.equals(mContent, text)) {//条件 mContent, text内容不同
+ if (!TextUtils.equals(mContent, text)) {
mContent = text;
mNote.setTextData(DataColumns.CONTENT, mContent);
- // 调用Note的setTextData方法更改WorkingText
}
}
- // 转变mNote的CallData及CallNote信息(phoneNumber,calldate)
+
public void convertToCallNote(String phoneNumber, long callDate) {
mNote.setCallData(CallNote.CALL_DATE, String.valueOf(callDate));
mNote.setCallData(CallNote.PHONE_NUMBER, phoneNumber);
mNote.setNoteValue(NoteColumns.PARENT_ID, String.valueOf(Notes.ID_CALL_RECORD_FOLDER));
}
- // 判断是否有时钟题型
+
public boolean hasClockAlert() {
return (mAlertDate > 0 ? true : false);
}
- // 获取Content
+
public String getContent() {
return mContent;
}
- // 获取AlertDate
+
public long getAlertDate() {
return mAlertDate;
}
- // 获取ModifiedDate
+
public long getModifiedDate() {
return mModifiedDate;
}
- // 获取背景颜色来源id
+
public int getBgColorResId() {
return NoteBgResources.getNoteBgResource(mBgColorId);
}
- // 获取背景颜色id
+
public int getBgColorId() {
return mBgColorId;
}
- // 获取标题背景颜色i
+
public int getTitleBgResId() {
return NoteBgResources.getNoteTitleBgResource(mBgColorId);
}
- // 获取CheckListMode
+
public int getCheckListMode() {
return mMode;
}
- // 获取便签id
+
public long getNoteId() {
return mNoteId;
}
- // 获取文件夹id
+
public long getFolderId() {
return mFolderId;
}
- // 获取WidgetId
+
public int getWidgetId() {
return mWidgetId;
}
- // 获取WidgetType
+
public int getWidgetType() {
return mWidgetType;
}
- // 创建接口 NoteSettingChangedListener,便签更新监视,为NoteEditActivity提供接口
+
public interface NoteSettingChangedListener {
/**
* Called when the background color of current note has just changed
diff --git a/app/src/main/java/net/micode/notes/model/model.plantuml b/app/src/main/java/net/micode/notes/model/model.plantuml
deleted file mode 100644
index d49b02c..0000000
--- a/app/src/main/java/net/micode/notes/model/model.plantuml
+++ /dev/null
@@ -1,133 +0,0 @@
-@startuml
-
-title __MODEL's Class Diagram__\n
-
- namespace net.micode.notes {
- namespace model {
- class net.micode.notes.model.Note {
- {static} - TAG : String
- - mNoteDiffValues : ContentValues
- + Note()
- {static} + getNewNoteId()
- + getTextDataId()
- + isLocalModified()
- + setCallData()
- + setCallDataId()
- + setNoteValue()
- + setTextData()
- + setTextDataId()
- + syncNote()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace model {
- class net.micode.notes.model.Note.NoteData {
- {static} - TAG : String
- - mCallDataId : long
- - mCallDataValues : ContentValues
- - mTextDataId : long
- - mTextDataValues : ContentValues
- + NoteData()
- ~ isLocalModified()
- ~ pushIntoContentResolver()
- ~ setCallData()
- ~ setCallDataId()
- ~ setTextData()
- ~ setTextDataId()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace model {
- class net.micode.notes.model.WorkingNote {
- {static} + DATA_PROJECTION : String[]
- {static} + NOTE_PROJECTION : String[]
- {static} - DATA_CONTENT_COLUMN : int
- {static} - DATA_ID_COLUMN : int
- {static} - DATA_MIME_TYPE_COLUMN : int
- {static} - DATA_MODE_COLUMN : int
- {static} - NOTE_ALERTED_DATE_COLUMN : int
- {static} - NOTE_BG_COLOR_ID_COLUMN : int
- {static} - NOTE_MODIFIED_DATE_COLUMN : int
- {static} - NOTE_PARENT_ID_COLUMN : int
- {static} - NOTE_WIDGET_ID_COLUMN : int
- {static} - NOTE_WIDGET_TYPE_COLUMN : int
- {static} - TAG : String
- - mAlertDate : long
- - mBgColorId : int
- - mContent : String
- - mContext : Context
- - mFolderId : long
- - mIsDeleted : boolean
- - mMode : int
- - mModifiedDate : long
- - mNoteId : long
- - mWidgetId : int
- - mWidgetType : int
- + convertToCallNote()
- {static} + createEmptyNote()
- + existInDatabase()
- + getAlertDate()
- + getBgColorId()
- + getBgColorResId()
- + getCheckListMode()
- + getContent()
- + getFolderId()
- + getModifiedDate()
- + getNoteId()
- + getTitleBgResId()
- + getWidgetId()
- + getWidgetType()
- + hasClockAlert()
- {static} + load()
- + markDeleted()
- + saveNote()
- + setAlertDate()
- + setBgColorId()
- + setCheckListMode()
- + setOnSettingStatusChangedListener()
- + setWidgetId()
- + setWidgetType()
- + setWorkingText()
- - WorkingNote()
- - WorkingNote()
- - isWorthSaving()
- - loadNote()
- - loadNoteData()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace model {
- interface net.micode.notes.model.WorkingNote.NoteSettingChangedListener {
- {abstract} + onBackgroundColorChanged()
- {abstract} + onCheckListModeChanged()
- {abstract} + onClockAlertChanged()
- {abstract} + onWidgetChanged()
- }
- }
- }
-
-
- net.micode.notes.model.Note o-- net.micode.notes.model.Note.NoteData : mNoteData
- net.micode.notes.model.Note +-down- net.micode.notes.model.Note.NoteData
- net.micode.notes.model.WorkingNote o-- net.micode.notes.model.Note : mNote
- net.micode.notes.model.WorkingNote o-- net.micode.notes.model.WorkingNote.NoteSettingChangedListener : mNoteSettingStatusListener
- net.micode.notes.model.WorkingNote +-down- net.micode.notes.model.WorkingNote.NoteSettingChangedListener
-
-
-right footer
-
-
-PlantUML diagram generated by SketchIt! (https://bitbucket.org/pmesmeur/sketch.it)
-For more information about this tool, please contact philippe.mesmeur@gmail.com
-endfooter
-
-@enduml
diff --git a/app/src/main/java/net/micode/notes/tool/BackupUtils.java b/app/src/main/java/net/micode/notes/tool/BackupUtils.java
index 87c8b0b..39f6ec4 100644
--- a/app/src/main/java/net/micode/notes/tool/BackupUtils.java
+++ b/app/src/main/java/net/micode/notes/tool/BackupUtils.java
@@ -40,10 +40,9 @@ public class BackupUtils {
private static final String TAG = "BackupUtils";
// Singleton stuff
private static BackupUtils sInstance;
- //它包括两种用法:synchronized 方法和 synchronized 块。
+
public static synchronized BackupUtils getInstance(Context context) {
if (sInstance == null) {
- //如果当前备份不存在,则新声明一个
sInstance = new BackupUtils(context);
}
return sInstance;
@@ -54,28 +53,22 @@ public class BackupUtils {
* 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);
}
- //外部存储功能是否可用
+
private static boolean externalStorageAvailable() {
return Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState());
}
@@ -140,7 +133,6 @@ public class BackupUtils {
}
private String getFormat(int id) {
- //获取文本的组成部分
return TEXT_FORMAT[id];
}
@@ -149,7 +141,6 @@ public class BackupUtils {
*/
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
@@ -159,14 +150,12 @@ public class BackupUtils {
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();
@@ -183,7 +172,6 @@ public class BackupUtils {
}, null);
if (dataCursor != null) {
- //利用光标来扫描内容,区别为callnote和note两种,靠ps.printline输出
if (dataCursor.moveToFirst()) {
do {
String mimeType = dataCursor.getString(DATA_COLUMN_MIME_TYPE);
@@ -194,7 +182,6 @@ public class BackupUtils {
String location = dataCursor.getString(DATA_COLUMN_CONTENT);
if (!TextUtils.isEmpty(phoneNumber)) {
- //判断是否为空字符
ps.println(String.format(getFormat(FORMAT_NOTE_CONTENT),
phoneNumber));
}
@@ -232,7 +219,6 @@ public class BackupUtils {
* Note will be exported as text which is user readable
*/
public int exportToText() {
- //总函数,调用上面的exportFolder和exportNote
if (!externalStorageAvailable()) {
Log.d(TAG, "Media was not mounted");
return STATE_SD_CARD_UNMOUONTED;
@@ -244,7 +230,6 @@ public class BackupUtils {
return STATE_SYSTEM_ERROR;
}
// First export folder and its notes
- // 导出文件夹,就是导出里面包含的便签
Cursor folderCursor = mContext.getContentResolver().query(
Notes.CONTENT_NOTE_URI,
NOTE_PROJECTION,
@@ -273,7 +258,6 @@ public class BackupUtils {
}
// Export notes in root's folder
- // 将根目录里的便签导出
Cursor noteCursor = mContext.getContentResolver().query(
Notes.CONTENT_NOTE_URI,
NOTE_PROJECTION,
@@ -314,7 +298,6 @@ public class BackupUtils {
try {
FileOutputStream fos = new FileOutputStream(file);
ps = new PrintStream(fos);
- //将ps输出流输出到特定的文件,目的就是导出到文件,而不是直接输出
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
@@ -331,16 +314,16 @@ public class BackupUtils {
*/
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(Environment.getExternalStorageDirectory());
+ sb.append(context.getString(filePathResId));
+ File filedir = new File(sb.toString());
sb.append(context.getString(
fileNameFormatResId,
DateFormat.format(context.getString(R.string.format_date_ymd),
System.currentTimeMillis())));
File file = new File(sb.toString());
- try {//如果这些文件不存在,则新建
+ try {
if (!filedir.exists()) {
filedir.mkdir();
}
@@ -353,7 +336,7 @@ public class BackupUtils {
} catch (IOException e) {
e.printStackTrace();
}
- // try catch 异常处理
+
return null;
}
}
diff --git a/app/src/main/java/net/micode/notes/tool/DataUtils.java b/app/src/main/java/net/micode/notes/tool/DataUtils.java
index 0fbdfbc..2a14982 100644
--- a/app/src/main/java/net/micode/notes/tool/DataUtils.java
+++ b/app/src/main/java/net/micode/notes/tool/DataUtils.java
@@ -37,7 +37,6 @@ import java.util.HashSet;
public class DataUtils {
public static final String TAG = "DataUtils";
- //直接删除多个笔记
public static boolean batchDeleteNotes(ContentResolver resolver, HashSet ids) {
if (ids == null) {
Log.d(TAG, "the ids is null");
@@ -47,22 +46,19 @@ public class DataUtils {
Log.d(TAG, "no id is in the hashset");
return true;
}
- //提供一个任务列表
+
ArrayList operationList = new ArrayList();
for (long id : ids) {
if(id == Notes.ID_ROOT_FOLDER) {
Log.e(TAG, "Don't delete system folder root");
continue;
}
- //如果发现是根文件夹,则不删除
ContentProviderOperation.Builder builder = ContentProviderOperation
.newDelete(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id));
- //用newDelete实现删除功能
operationList.add(builder.build());
}
try {
ContentProviderResult[] results = resolver.applyBatch(Notes.AUTHORITY, operationList);
- //数据库事务,数据库事务是由一组数据库操作序列组成,事务作为一个整体被执行
if (results == null || results.length == 0 || results[0] == null) {
Log.d(TAG, "delete notes failed, ids:" + ids.toString());
return false;
@@ -82,7 +78,6 @@ public class DataUtils {
values.put(NoteColumns.ORIGIN_PARENT_ID, srcFolderId);
values.put(NoteColumns.LOCAL_MODIFIED, 1);
resolver.update(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id), values, null, null);
- //对需要移动的便签进行数据更新,然后用update实现
}
public static boolean batchMoveToFolder(ContentResolver resolver, HashSet ids,
@@ -96,14 +91,13 @@ public class DataUtils {
for (long id : ids) {
ContentProviderOperation.Builder builder = ContentProviderOperation
.newUpdate(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, id));
- //通过withAppendedId方法,为该Uri加上ID
builder.withValue(NoteColumns.PARENT_ID, folderId);
builder.withValue(NoteColumns.LOCAL_MODIFIED, 1);
operationList.add(builder.build());
- }//将ids里包含的每一列的数据逐次加入到operationList中,等待最后的批量处理
+ }
try {
- ContentProviderResult[] results = resolver.applyBatch(Notes.AUTHORITY, operationList);//applyBatch一次性处理一个操作列表
+ ContentProviderResult[] results = resolver.applyBatch(Notes.AUTHORITY, operationList);
if (results == null || results.length == 0 || results[0] == null) {
Log.d(TAG, "delete notes failed, ids:" + ids.toString());
return false;
@@ -125,7 +119,7 @@ public class DataUtils {
new String[] { "COUNT(*)" },
NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>?",
new String[] { String.valueOf(Notes.TYPE_FOLDER), String.valueOf(Notes.ID_TRASH_FOLER)},
- null);//条件:源文件不为trash folder
+ null);
int count = 0;
if(cursor != null) {
@@ -143,15 +137,15 @@ public class DataUtils {
}
public static boolean visibleInNoteDatabase(ContentResolver resolver, long noteId, int type) {
- Cursor cursor = resolver.query(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId),//通过withAppendedId方法,为该Uri加上ID
+ 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);//条件:type符合,且不属于垃圾文件夹
+ null);
boolean exist = false;
if (cursor != null) {
- if (cursor.getCount() > 0) {//用getcount函数判断cursor是否为空
+ if (cursor.getCount() > 0) {
exist = true;
}
cursor.close();
@@ -193,7 +187,6 @@ public class DataUtils {
" 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) {
@@ -209,7 +202,7 @@ public class DataUtils {
new String[] { NoteColumns.WIDGET_ID, NoteColumns.WIDGET_TYPE },
NoteColumns.PARENT_ID + "=?",
new String[] { String.valueOf(folderId) },
- null);//条件:父ID是传入的folderId;
+ null);
HashSet set = null;
if (c != null) {
@@ -218,14 +211,13 @@ public class DataUtils {
do {
try {
AppWidgetAttribute widget = new AppWidgetAttribute();
- widget.widgetId = c.getInt(0); //0对应的NoteColumns.WIDGET_ID
- widget.widgetType = c.getInt(1); //1对应的NoteColumns.WIDGET_TYPE
+ widget.widgetId = c.getInt(0);
+ widget.widgetType = c.getInt(1);
set.add(widget);
} catch (IndexOutOfBoundsException e) {
Log.e(TAG, e.toString());
}
} while (c.moveToNext());
- //查询下一条
}
c.close();
}
@@ -258,7 +250,7 @@ public class DataUtils {
+ CallNote.PHONE_NUMBER + ",?)",
new String [] { String.valueOf(callDate), CallNote.CONTENT_ITEM_TYPE, phoneNumber },
null);
- //通过数据库操作,查询条件是(callDate和phoneNumber匹配传入参数的值
+
if (cursor != null) {
if (cursor.moveToFirst()) {
try {
@@ -277,7 +269,7 @@ public class DataUtils {
new String [] { NoteColumns.SNIPPET },
NoteColumns.ID + "=?",
new String [] { String.valueOf(noteId)},
- null);//条件:noteId
+ null);
if (cursor != null) {
String snippet = "";
@@ -289,7 +281,7 @@ public class DataUtils {
}
throw new IllegalArgumentException("Note is not found with id: " + noteId);
}
- //对字符串进行格式处理,将字符串两头的空格去掉,同时将换行符去掉
+
public static String getFormattedSnippet(String snippet) {
if (snippet != null) {
snippet = snippet.trim();
diff --git a/app/src/main/java/net/micode/notes/tool/GTaskStringUtils.java b/app/src/main/java/net/micode/notes/tool/GTaskStringUtils.java
index 5811aeb..666b729 100644
--- a/app/src/main/java/net/micode/notes/tool/GTaskStringUtils.java
+++ b/app/src/main/java/net/micode/notes/tool/GTaskStringUtils.java
@@ -15,7 +15,7 @@
*/
package net.micode.notes.tool;
-/** 字符串常量命名空间类 */
+
public class GTaskStringUtils {
public final static String GTASK_JSON_ACTION_ID = "action_id";
diff --git a/app/src/main/java/net/micode/notes/tool/ResourceParser.java b/app/src/main/java/net/micode/notes/tool/ResourceParser.java
index 5a4344c..1ad3ad6 100644
--- a/app/src/main/java/net/micode/notes/tool/ResourceParser.java
+++ b/app/src/main/java/net/micode/notes/tool/ResourceParser.java
@@ -21,17 +21,7 @@ import android.preference.PreferenceManager;
import net.micode.notes.R;
import net.micode.notes.ui.NotesPreferenceActivity;
-/**资源分析器
- * 实现:主要应用R.java这个类,包括
- * R.i:组件资源引用
- * R.drawable:图片资源
- * R.layout:布局资源
- * R.menu:菜单资源
- * R.String:文字资源
- * R.style:主题资源
- * @BG_DEFAULT_COLOR 默认背景颜色(黄)
- * BG_DEFAULT_FONT_SIZE 默认文本大小(中)
- */
+
public class ResourceParser {
public static final int YELLOW = 0;
@@ -74,7 +64,7 @@ public class ResourceParser {
return BG_EDIT_TITLE_RESOURCES[id];
}
}
- //直接获取默认的背景颜色。
+
public static int getDefaultBgId(Context context) {
if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
NotesPreferenceActivity.PREFERENCE_SET_BG_COLOR_KEY, false)) {
@@ -171,7 +161,7 @@ public class ResourceParser {
R.style.TextAppearanceLarge,
R.style.TextAppearanceSuper
};
- //容错函数,防止输入的id大于资源总量,若错误,则自动返回默认的设置结果
+
public static int getTexAppearanceResource(int id) {
/**
* HACKME: Fix bug of store the resource id in shared preference.
diff --git a/app/src/main/java/net/micode/notes/tool/tool.plantuml b/app/src/main/java/net/micode/notes/tool/tool.plantuml
deleted file mode 100644
index f93d4c9..0000000
--- a/app/src/main/java/net/micode/notes/tool/tool.plantuml
+++ /dev/null
@@ -1,220 +0,0 @@
-@startuml
-
-title __TOOL's Class Diagram__\n
-
- namespace net.micode.notes {
- namespace tool {
- class net.micode.notes.tool.BackupUtils {
- {static} + STATE_BACKUP_FILE_NOT_EXIST : int
- {static} + STATE_DATA_DESTROIED : int
- {static} + STATE_SD_CARD_UNMOUONTED : int
- {static} + STATE_SUCCESS : int
- {static} + STATE_SYSTEM_ERROR : int
- {static} - TAG : String
- {static} - sInstance : BackupUtils
- + exportToText()
- + getExportedTextFileDir()
- + getExportedTextFileName()
- {static} + getInstance()
- - BackupUtils()
- {static} - externalStorageAvailable()
- {static} - generateFileMountedOnSDcard()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace tool {
- class net.micode.notes.tool.BackupUtils.TextExport {
- {static} - DATA_COLUMN_CALL_DATE : int
- {static} - DATA_COLUMN_CONTENT : int
- {static} - DATA_COLUMN_MIME_TYPE : int
- {static} - DATA_COLUMN_PHONE_NUMBER : int
- {static} - DATA_PROJECTION : String[]
- {static} - FORMAT_FOLDER_NAME : int
- {static} - FORMAT_NOTE_CONTENT : int
- {static} - FORMAT_NOTE_DATE : int
- {static} - NOTE_COLUMN_ID : int
- {static} - NOTE_COLUMN_MODIFIED_DATE : int
- {static} - NOTE_COLUMN_SNIPPET : int
- {static} - NOTE_PROJECTION : String[]
- - TEXT_FORMAT : String[]
- - mContext : Context
- - mFileDirectory : String
- - mFileName : String
- + TextExport()
- + exportToText()
- - exportFolderToText()
- - exportNoteToText()
- - getExportToTextPrintStream()
- - getFormat()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace tool {
- class net.micode.notes.tool.DataUtils {
- {static} + TAG : String
- {static} + batchDeleteNotes()
- {static} + batchMoveToFolder()
- {static} + checkVisibleFolderName()
- {static} + existInDataDatabase()
- {static} + existInNoteDatabase()
- {static} + getCallNumberByNoteId()
- {static} + getFolderNoteWidget()
- {static} + getFormattedSnippet()
- {static} + getNoteIdByPhoneNumberAndCallDate()
- {static} + getSnippetById()
- {static} + getUserFolderCount()
- {static} + moveNoteToFoler()
- {static} + visibleInNoteDatabase()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace tool {
- class net.micode.notes.tool.GTaskStringUtils {
- {static} + FOLDER_CALL_NOTE : String
- {static} + FOLDER_DEFAULT : String
- {static} + FOLDER_META : String
- {static} + GTASK_JSON_ACTION_ID : String
- {static} + GTASK_JSON_ACTION_LIST : String
- {static} + GTASK_JSON_ACTION_TYPE : String
- {static} + GTASK_JSON_ACTION_TYPE_CREATE : String
- {static} + GTASK_JSON_ACTION_TYPE_GETALL : String
- {static} + GTASK_JSON_ACTION_TYPE_MOVE : String
- {static} + GTASK_JSON_ACTION_TYPE_UPDATE : String
- {static} + GTASK_JSON_CHILD_ENTITY : String
- {static} + GTASK_JSON_CLIENT_VERSION : String
- {static} + GTASK_JSON_COMPLETED : String
- {static} + GTASK_JSON_CREATOR_ID : String
- {static} + GTASK_JSON_CURRENT_LIST_ID : String
- {static} + GTASK_JSON_DEFAULT_LIST_ID : String
- {static} + GTASK_JSON_DELETED : String
- {static} + GTASK_JSON_DEST_LIST : String
- {static} + GTASK_JSON_DEST_PARENT : String
- {static} + GTASK_JSON_DEST_PARENT_TYPE : String
- {static} + GTASK_JSON_ENTITY_DELTA : String
- {static} + GTASK_JSON_ENTITY_TYPE : String
- {static} + GTASK_JSON_GET_DELETED : String
- {static} + GTASK_JSON_ID : String
- {static} + GTASK_JSON_INDEX : String
- {static} + GTASK_JSON_LAST_MODIFIED : String
- {static} + GTASK_JSON_LATEST_SYNC_POINT : String
- {static} + GTASK_JSON_LISTS : String
- {static} + GTASK_JSON_LIST_ID : String
- {static} + GTASK_JSON_NAME : String
- {static} + GTASK_JSON_NEW_ID : String
- {static} + GTASK_JSON_NOTES : String
- {static} + GTASK_JSON_PARENT_ID : String
- {static} + GTASK_JSON_PRIOR_SIBLING_ID : String
- {static} + GTASK_JSON_RESULTS : String
- {static} + GTASK_JSON_SOURCE_LIST : String
- {static} + GTASK_JSON_TASKS : String
- {static} + GTASK_JSON_TYPE : String
- {static} + GTASK_JSON_TYPE_GROUP : String
- {static} + GTASK_JSON_TYPE_TASK : String
- {static} + GTASK_JSON_USER : String
- {static} + META_HEAD_DATA : String
- {static} + META_HEAD_GTASK_ID : String
- {static} + META_HEAD_NOTE : String
- {static} + META_NOTE_NAME : String
- {static} + MIUI_FOLDER_PREFFIX : String
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace tool {
- class net.micode.notes.tool.ResourceParser {
- {static} + BG_DEFAULT_COLOR : int
- {static} + BG_DEFAULT_FONT_SIZE : int
- {static} + BLUE : int
- {static} + GREEN : int
- {static} + RED : int
- {static} + TEXT_LARGE : int
- {static} + TEXT_MEDIUM : int
- {static} + TEXT_SMALL : int
- {static} + TEXT_SUPER : int
- {static} + WHITE : int
- {static} + YELLOW : int
- {static} + getDefaultBgId()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace tool {
- class net.micode.notes.tool.ResourceParser.NoteBgResources {
- {static} - BG_EDIT_RESOURCES : int[]
- {static} - BG_EDIT_TITLE_RESOURCES : int[]
- {static} + getNoteBgResource()
- {static} + getNoteTitleBgResource()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace tool {
- class net.micode.notes.tool.ResourceParser.NoteItemBgResources {
- {static} - BG_FIRST_RESOURCES : int[]
- {static} - BG_LAST_RESOURCES : int[]
- {static} - BG_NORMAL_RESOURCES : int[]
- {static} - BG_SINGLE_RESOURCES : int[]
- {static} + getFolderBgRes()
- {static} + getNoteBgFirstRes()
- {static} + getNoteBgLastRes()
- {static} + getNoteBgNormalRes()
- {static} + getNoteBgSingleRes()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace tool {
- class net.micode.notes.tool.ResourceParser.TextAppearanceResources {
- {static} - TEXTAPPEARANCE_RESOURCES : int[]
- {static} + getResourcesSize()
- {static} + getTexAppearanceResource()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace tool {
- class net.micode.notes.tool.ResourceParser.WidgetBgResources {
- {static} - BG_2X_RESOURCES : int[]
- {static} - BG_4X_RESOURCES : int[]
- {static} + getWidget2xBgResource()
- {static} + getWidget4xBgResource()
- }
- }
- }
-
-
- net.micode.notes.tool.BackupUtils o-- net.micode.notes.tool.BackupUtils.TextExport : mTextExport
- net.micode.notes.tool.BackupUtils +-down- net.micode.notes.tool.BackupUtils.TextExport
- net.micode.notes.tool.ResourceParser +-down- net.micode.notes.tool.ResourceParser.NoteBgResources
- net.micode.notes.tool.ResourceParser +-down- net.micode.notes.tool.ResourceParser.NoteItemBgResources
- net.micode.notes.tool.ResourceParser +-down- net.micode.notes.tool.ResourceParser.TextAppearanceResources
- net.micode.notes.tool.ResourceParser +-down- net.micode.notes.tool.ResourceParser.WidgetBgResources
-
-
-right footer
-
-
-PlantUML diagram generated by SketchIt! (https://bitbucket.org/pmesmeur/sketch.it)
-For more information about this tool, please contact philippe.mesmeur@gmail.com
-endfooter
-
-@enduml
diff --git a/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java b/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java
index da81fa3..85723be 100644
--- a/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java
+++ b/app/src/main/java/net/micode/notes/ui/AlarmAlertActivity.java
@@ -39,45 +39,36 @@ import net.micode.notes.tool.DataUtils;
import java.io.IOException;
-/** 时间到期,显示闹钟定时弹窗 */
+
public class AlarmAlertActivity extends Activity implements OnClickListener, OnDismissListener {
- private long mNoteId;//文本在数据库存储中的ID号
- private String mSnippet;//闹钟提示时出现的文本片段
+ private long mNoteId;
+ private String mSnippet;
private static final int SNIPPET_PREW_MAX_LEN = 60;
MediaPlayer mPlayer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- //Bundle类型的数据与Map类型的数据相似,都是以key-value的形式存储数据的
- //onsaveInstanceState方法是用来保存Activity的状态的
- //能从onCreate的参数savedInsanceState中获得状态数据
requestWindowFeature(Window.FEATURE_NO_TITLE);
- //界面显示——无标题
+
final Window win = getWindow();
win.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
if (!isScreenOn()) {
- win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
- //保持窗体点亮
+ win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON
- //将窗体点亮
| WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON
- //允许窗体点亮时锁屏
| WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR);
- }//在手机锁屏后如果到了闹钟提示时间,点亮屏幕
+ }
Intent intent = getIntent();
try {
mNoteId = Long.valueOf(intent.getData().getPathSegments().get(1));
mSnippet = DataUtils.getSnippetById(this.getContentResolver(), mNoteId);
- //根据ID从数据库中获取标签的内容;
- //getContentResolver()是实现数据共享,实例存储。
mSnippet = mSnippet.length() > SNIPPET_PREW_MAX_LEN ? mSnippet.substring(0,
SNIPPET_PREW_MAX_LEN) + getResources().getString(R.string.notelist_string_info)
: mSnippet;
- //判断标签片段是否达到符合长度
} catch (IllegalArgumentException e) {
e.printStackTrace();
return;
@@ -86,25 +77,20 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
mPlayer = new MediaPlayer();
if (DataUtils.visibleInNoteDatabase(getContentResolver(), mNoteId, Notes.TYPE_NOTE)) {
showActionDialog();
- //弹出对话框
playAlarmSound();
- //闹钟提示音激发
} else {
finish();
- //完成闹钟动作
}
}
private boolean isScreenOn() {
- //判断屏幕是否锁屏,调用系统函数判断,最后返回值是布尔类型
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
return pm.isScreenOn();
}
private void playAlarmSound() {
- //闹钟提示音激发
Uri url = RingtoneManager.getActualDefaultRingtoneUri(this, RingtoneManager.TYPE_ALARM);
- //调用系统的铃声管理URI,得到闹钟提示音
+
int silentModeStreams = Settings.System.getInt(getContentResolver(),
Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0);
@@ -115,19 +101,12 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
}
try {
mPlayer.setDataSource(this, url);
- //方法:setDataSource(Context context, Uri uri)
- //解释:无返回值,设置多媒体数据来源【根据 Uri】
mPlayer.prepare();
- //准备同步
mPlayer.setLooping(true);
- //设置是否循环播放
mPlayer.start();
- //开始播放
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- //e.printStackTrace()函数功能是抛出异常, 还将显示出更深的调用信息
- //System.out.println(e),这个方法打印出异常,并且输出在哪里出现的异常
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
@@ -143,52 +122,36 @@ public class AlarmAlertActivity extends Activity implements OnClickListener, OnD
private void showActionDialog() {
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
dialog.setTitle(R.string.app_name);
- //为对话框设置标题
dialog.setMessage(mSnippet);
- //为对话框设置内容
dialog.setPositiveButton(R.string.notealert_ok, this);
- //给对话框添加"Yes"按钮
if (isScreenOn()) {
dialog.setNegativeButton(R.string.notealert_enter, this);
- }//对话框添加"No"按钮
+ }
dialog.show().setOnDismissListener(this);
}
public void onClick(DialogInterface dialog, int which) {
switch (which) {
- //用which来选择click后下一步的操作
case DialogInterface.BUTTON_NEGATIVE:
- //这是取消操作
Intent intent = new Intent(this, NoteEditActivity.class);
- //实现两个类间的数据传输
intent.setAction(Intent.ACTION_VIEW);
- //设置动作属性
intent.putExtra(Intent.EXTRA_UID, mNoteId);
- //实现key-value对
- //EXTRA_UID为key;mNoteId为键
startActivity(intent);
- //开始动作
break;
default:
- //这是确定操作
break;
}
}
public void onDismiss(DialogInterface dialog) {
- //忽略
stopAlarmSound();
- //停止闹钟声音
finish();
- //完成该动作
}
private void stopAlarmSound() {
- if (mPlayer != null) {
+ if (mPlayer != null) {
mPlayer.stop();
- //停止播放
mPlayer.release();
- //释放MediaPlayer对象
mPlayer = null;
}
}
diff --git a/app/src/main/java/net/micode/notes/ui/AlarmInitReceiver.java b/app/src/main/java/net/micode/notes/ui/AlarmInitReceiver.java
index 86f82db..f221202 100644
--- a/app/src/main/java/net/micode/notes/ui/AlarmInitReceiver.java
+++ b/app/src/main/java/net/micode/notes/ui/AlarmInitReceiver.java
@@ -27,26 +27,24 @@ import android.database.Cursor;
import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.NoteColumns;
-/** 系统开机时处理已有的便签 */
+
public class AlarmInitReceiver extends BroadcastReceiver {
private static final String [] PROJECTION = new String [] {
NoteColumns.ID,
NoteColumns.ALERTED_DATE
};
- //对数据库的操作,调用标签ID和闹钟时间
+
private static final int COLUMN_ID = 0;
private static final int COLUMN_ALERTED_DATE = 1;
@Override
public void onReceive(Context context, Intent intent) {
long currentDate = System.currentTimeMillis();
- // System.currentTimeMillis()产生一个当前的毫秒级时间戳
Cursor c = context.getContentResolver().query(Notes.CONTENT_NOTE_URI,
PROJECTION,
NoteColumns.ALERTED_DATE + ">? AND " + NoteColumns.TYPE + "=" + Notes.TYPE_NOTE,
new String[] { String.valueOf(currentDate) },
- //将long变量currentDate转化为字符串
null);
if (c != null) {
@@ -62,6 +60,6 @@ public class AlarmInitReceiver extends BroadcastReceiver {
} while (c.moveToNext());
}
c.close();
- }//根据数据库里的闹钟时间创建一个闹钟机制
+ }
}
}
diff --git a/app/src/main/java/net/micode/notes/ui/AlarmReceiver.java b/app/src/main/java/net/micode/notes/ui/AlarmReceiver.java
index 846b11f..54e503b 100644
--- a/app/src/main/java/net/micode/notes/ui/AlarmReceiver.java
+++ b/app/src/main/java/net/micode/notes/ui/AlarmReceiver.java
@@ -19,14 +19,12 @@ package net.micode.notes.ui;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
-/** 循环等待有note需要提醒用户的广播*/
+
public class AlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
intent.setClass(context, AlarmAlertActivity.class);
- //启动AlarmAlertActivity
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- //要新建一个栈装入启动的activity
context.startActivity(intent);
}
}
diff --git a/app/src/main/java/net/micode/notes/ui/DateTimePicker.java b/app/src/main/java/net/micode/notes/ui/DateTimePicker.java
index 3f81ec4..496b0cd 100644
--- a/app/src/main/java/net/micode/notes/ui/DateTimePicker.java
+++ b/app/src/main/java/net/micode/notes/ui/DateTimePicker.java
@@ -27,10 +27,9 @@ import android.text.format.DateFormat;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.NumberPicker;
-/** 图形化日历时间选择器*/
+
public class DateTimePicker extends FrameLayout {
- //FrameLayout是布局模板之一
- //所有的子元素全部在屏幕的右上方
+
private static final boolean DEFAULT_ENABLE_STATE = true;
private static final int HOURS_IN_HALF_DAY = 12;
@@ -46,15 +45,13 @@ public class DateTimePicker extends FrameLayout {
private static final int MINUT_SPINNER_MAX_VAL = 59;
private static final int AMPM_SPINNER_MIN_VAL = 0;
private static final int AMPM_SPINNER_MAX_VAL = 1;
- //初始化控件
+
private final NumberPicker mDateSpinner;
private final NumberPicker mHourSpinner;
private final NumberPicker mMinuteSpinner;
private final NumberPicker mAmPmSpinner;
- //NumberPicker是数字选择器
- //这里定义的四个变量全部是在设置闹钟时需要选择的变量(如日期、时、分、上午或者下午)
private Calendar mDate;
- //定义了Calendar类型的变量mDate,用于操作时间
+
private String[] mDateDisplayValues = new String[DAYS_IN_ALL_WEEK];
private boolean mIsAm;
@@ -74,48 +71,41 @@ public class DateTimePicker extends FrameLayout {
updateDateControl();
onDateTimeChanged();
}
- };//OnValueChangeListener,这是时间改变监听器,这里主要是对日期的监听
- //将现在日期的值传递给mDate;updateDateControl是同步操作
+ };
+
private NumberPicker.OnValueChangeListener mOnHourChangedListener = new NumberPicker.OnValueChangeListener() {
- //这里是对小时的监听
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
boolean isDateChanged = false;
Calendar cal = Calendar.getInstance();
- //声明一个Calendar的变量cal,便于后续的操作
if (!mIs24HourView) {
if (!mIsAm && oldVal == HOURS_IN_HALF_DAY - 1 && newVal == HOURS_IN_HALF_DAY) {
cal.setTimeInMillis(mDate.getTimeInMillis());
cal.add(Calendar.DAY_OF_YEAR, 1);
isDateChanged = true;
- //这里是对于12小时制时,晚上11点和12点交替时对日期的更改
} else if (mIsAm && oldVal == HOURS_IN_HALF_DAY && newVal == HOURS_IN_HALF_DAY - 1) {
cal.setTimeInMillis(mDate.getTimeInMillis());
cal.add(Calendar.DAY_OF_YEAR, -1);
isDateChanged = true;
}
- //这里是对于12小时制时,凌晨11点和12点交替时对日期的更改
if (oldVal == HOURS_IN_HALF_DAY - 1 && newVal == HOURS_IN_HALF_DAY ||
oldVal == HOURS_IN_HALF_DAY && newVal == HOURS_IN_HALF_DAY - 1) {
mIsAm = !mIsAm;
updateAmPmControl();
- }//这里是对于12小时制时,中午11点和12点交替时对AM和PM的更改
+ }
} else {
if (oldVal == HOURS_IN_ALL_DAY - 1 && newVal == 0) {
cal.setTimeInMillis(mDate.getTimeInMillis());
cal.add(Calendar.DAY_OF_YEAR, 1);
isDateChanged = true;
- //这里是对于24小时制时,晚上11点和12点交替时对日期的更改
} else if (oldVal == 0 && newVal == HOURS_IN_ALL_DAY - 1) {
cal.setTimeInMillis(mDate.getTimeInMillis());
cal.add(Calendar.DAY_OF_YEAR, -1);
isDateChanged = true;
}
- }//这里是对于12小时制时,凌晨11点和12点交替时对日期的更改
+ }
int newHour = mHourSpinner.getValue() % HOURS_IN_HALF_DAY + (mIsAm ? 0 : HOURS_IN_HALF_DAY);
- //通过数字选择器对newHour的赋值
mDate.set(Calendar.HOUR_OF_DAY, newHour);
- //通过set函数将新的Hour值传给mDate
onDateTimeChanged();
if (isDateChanged) {
setCurrentYear(cal.get(Calendar.YEAR));
@@ -127,12 +117,10 @@ public class DateTimePicker extends FrameLayout {
private NumberPicker.OnValueChangeListener mOnMinuteChangedListener = new NumberPicker.OnValueChangeListener() {
@Override
- //这里是对 分钟(Minute)改变的监听
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
int minValue = mMinuteSpinner.getMinValue();
int maxValue = mMinuteSpinner.getMaxValue();
int offset = 0;
- //设置offset,作为小时改变的一个记录数据
if (oldVal == maxValue && newVal == minValue) {
offset += 1;
} else if (oldVal == minValue && newVal == maxValue) {
@@ -157,7 +145,6 @@ public class DateTimePicker extends FrameLayout {
};
private NumberPicker.OnValueChangeListener mOnAmPmChangedListener = new NumberPicker.OnValueChangeListener() {
- //对AM和PM的监听
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
mIsAm = !mIsAm;
@@ -178,22 +165,19 @@ public class DateTimePicker extends FrameLayout {
public DateTimePicker(Context context) {
this(context, System.currentTimeMillis());
- }//通过对数据库的访问,获取当前的系统时间
+ }
public DateTimePicker(Context context, long date) {
this(context, date, DateFormat.is24HourFormat(context));
- }//上面函数的得到的是1970至今的秒数,需要DateFormat转化格式
+ }
public DateTimePicker(Context context, long date, boolean is24HourView) {
super(context);
- //获取系统时间
mDate = Calendar.getInstance();
mInitialising = true;
mIsAm = getCurrentHourOfDay() >= HOURS_IN_HALF_DAY;
inflate(context, R.layout.datetime_picker, this);
- //如果当前Activity里用到别的layout,比如对话框layout
- //还要设置这个layout上的其他组件的内容,就必须用inflate()方法先将对话框的layout找出来
- //然后再用findViewById()找到它上面的其它组件
+
mDateSpinner = (NumberPicker) findViewById(R.id.date);
mDateSpinner.setMinValue(DATE_SPINNER_MIN_VAL);
mDateSpinner.setMaxValue(DATE_SPINNER_MAX_VAL);
@@ -267,7 +251,7 @@ public class DateTimePicker extends FrameLayout {
cal.setTimeInMillis(date);
setCurrentDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH),
cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE));
- }//实现函数功能——设置当前的时间,参数是date
+ }
/**
* Set the current date
@@ -285,7 +269,7 @@ public class DateTimePicker extends FrameLayout {
setCurrentDay(dayOfMonth);
setCurrentHour(hourOfDay);
setCurrentMinute(minute);
- }//实现函数功能——设置当前的时间,参数是各详细的变量
+ }
/**
* Get current year
@@ -462,7 +446,7 @@ public class DateTimePicker extends FrameLayout {
mDateSpinner.setDisplayedValues(mDateDisplayValues);
mDateSpinner.setValue(DAYS_IN_ALL_WEEK / 2);
mDateSpinner.invalidate();
- }// 对于星期几的算法
+ }
private void updateAmPmControl() {
if (mIs24HourView) {
@@ -472,7 +456,7 @@ public class DateTimePicker extends FrameLayout {
mAmPmSpinner.setValue(index);
mAmPmSpinner.setVisibility(View.VISIBLE);
}
- }// 对于上下午操作的算法
+ }
private void updateHourControl() {
if (mIs24HourView) {
@@ -482,7 +466,7 @@ public class DateTimePicker extends FrameLayout {
mHourSpinner.setMinValue(HOUR_SPINNER_MIN_VAL_12_HOUR_VIEW);
mHourSpinner.setMaxValue(HOUR_SPINNER_MAX_VAL_12_HOUR_VIEW);
}
- }// 对于小时的算法
+ }
/**
* Set the callback that indicates the 'Set' button has been pressed.
diff --git a/app/src/main/java/net/micode/notes/ui/DateTimePickerDialog.java b/app/src/main/java/net/micode/notes/ui/DateTimePickerDialog.java
index 5692d01..2c47ba4 100644
--- a/app/src/main/java/net/micode/notes/ui/DateTimePickerDialog.java
+++ b/app/src/main/java/net/micode/notes/ui/DateTimePickerDialog.java
@@ -28,29 +28,22 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.text.format.DateFormat;
import android.text.format.DateUtils;
-/** 日期时间选择器对话框*/
+
public class DateTimePickerDialog extends AlertDialog implements OnClickListener {
private Calendar mDate = Calendar.getInstance();
- //创建一个Calendar类型的变量 mDate,方便时间的操作
private boolean mIs24HourView;
private OnDateTimeSetListener mOnDateTimeSetListener;
- //声明一个时间日期滚动选择控件 mOnDateTimeSetListener
private DateTimePicker mDateTimePicker;
- //DateTimePicker控件,控件一般用于让用户可以从日期列表中选择单个值。
- //运行时,单击控件边上的下拉箭头,会显示为两个部分:一个下拉列表,一个用于选择日期的
public interface OnDateTimeSetListener {
void OnDateTimeSet(AlertDialog dialog, long date);
}
public DateTimePickerDialog(Context context, long date) {
- //对该界面对话框的实例化
super(context);
- //对数据库的操作
mDateTimePicker = new DateTimePicker(context);
setView(mDateTimePicker);
- //添加一个子视图
mDateTimePicker.setOnDateTimeChangedListener(new OnDateTimeChangedListener() {
public void onDateTimeChanged(DateTimePicker view, int year, int month,
int dayOfMonth, int hourOfDay, int minute) {
@@ -59,20 +52,15 @@ public class DateTimePickerDialog extends AlertDialog implements OnClickListener
mDate.set(Calendar.DAY_OF_MONTH, dayOfMonth);
mDate.set(Calendar.HOUR_OF_DAY, hourOfDay);
mDate.set(Calendar.MINUTE, minute);
- //将视图中的各选项设置为系统当前时间
updateTitle(mDate.getTimeInMillis());
}
});
mDate.setTimeInMillis(date);
- //得到系统时间
mDate.set(Calendar.SECOND, 0);
- //将秒数设置为0
mDateTimePicker.setCurrentDate(mDate.getTimeInMillis());
setButton(context.getString(R.string.datetime_dialog_ok), this);
setButton2(context.getString(R.string.datetime_dialog_cancel), (OnClickListener)null);
- //设置按钮
set24HourView(DateFormat.is24HourFormat(this.getContext()));
- //时间标准化打印
updateTitle(mDate.getTimeInMillis());
}
@@ -82,7 +70,7 @@ public class DateTimePickerDialog extends AlertDialog implements OnClickListener
public void setOnDateTimeSetListener(OnDateTimeSetListener callBack) {
mOnDateTimeSetListener = callBack;
- }//将时间日期滚动选择控件实例化
+ }
private void updateTitle(long date) {
int flag =
@@ -91,12 +79,12 @@ public class DateTimePickerDialog extends AlertDialog implements OnClickListener
DateUtils.FORMAT_SHOW_TIME;
flag |= mIs24HourView ? DateUtils.FORMAT_24HOUR : DateUtils.FORMAT_24HOUR;
setTitle(DateUtils.formatDateTime(this.getContext(), date, flag));
- }//android开发中常见日期管理工具类(API)——DateUtils:按照上下午显示时间
+ }
public void onClick(DialogInterface arg0, int arg1) {
if (mOnDateTimeSetListener != null) {
mOnDateTimeSetListener.OnDateTimeSet(this, mDate.getTimeInMillis());
}
- }//第一个参数arg0是接收到点击事件的对话框
- //第二个参数arg1是该对话框上的按钮
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/java/net/micode/notes/ui/DropdownMenu.java b/app/src/main/java/net/micode/notes/ui/DropdownMenu.java
index a5a6173..613dc74 100644
--- a/app/src/main/java/net/micode/notes/ui/DropdownMenu.java
+++ b/app/src/main/java/net/micode/notes/ui/DropdownMenu.java
@@ -26,22 +26,18 @@ import android.widget.PopupMenu;
import android.widget.PopupMenu.OnMenuItemClickListener;
import net.micode.notes.R;
-/** 下拉菜单显示*/
+
public class DropdownMenu {
private Button mButton;
private PopupMenu mPopupMenu;
- //声明一个下拉菜单
private Menu mMenu;
public DropdownMenu(Context context, Button button, int menuId) {
mButton = button;
mButton.setBackgroundResource(R.drawable.dropdown_icon);
- //设置这个view的背景
mPopupMenu = new PopupMenu(context, mButton);
mMenu = mPopupMenu.getMenu();
mPopupMenu.getMenuInflater().inflate(menuId, mMenu);
- //MenuInflater是用来实例化Menu目录下的Menu布局文件
- //根据ID来确认menu的内容选项
mButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mPopupMenu.show();
@@ -52,14 +48,14 @@ public class DropdownMenu {
public void setOnDropdownMenuItemClickListener(OnMenuItemClickListener listener) {
if (mPopupMenu != null) {
mPopupMenu.setOnMenuItemClickListener(listener);
- }//设置菜单的监听
+ }
}
public MenuItem findItem(int id) {
return mMenu.findItem(id);
- }//对于菜单选项的初始化,根据索引搜索菜单需要的选项
+ }
public void setTitle(CharSequence title) {
mButton.setText(title);
- }//布局文件,设置标题
-}
\ No newline at end of file
+ }
+}
diff --git a/app/src/main/java/net/micode/notes/ui/FoldersListAdapter.java b/app/src/main/java/net/micode/notes/ui/FoldersListAdapter.java
index ad168fc..96b77da 100644
--- a/app/src/main/java/net/micode/notes/ui/FoldersListAdapter.java
+++ b/app/src/main/java/net/micode/notes/ui/FoldersListAdapter.java
@@ -30,13 +30,10 @@ import net.micode.notes.data.Notes.NoteColumns;
public class FoldersListAdapter extends CursorAdapter {
- //FoldersListAdapter继承了CursorAdapter的类
- //便签数据库和用户的交互
- //以folder的形式展现给用户
public static final String [] PROJECTION = {
NoteColumns.ID,
NoteColumns.SNIPPET
- };//调用数据库中便签的ID和片段
+ };
public static final int ID_COLUMN = 0;
public static final int NAME_COLUMN = 1;
@@ -44,13 +41,12 @@ public class FoldersListAdapter extends CursorAdapter {
public FoldersListAdapter(Context context, Cursor c) {
super(context, c);
// TODO Auto-generated constructor stub
- }//数据库操作
+ }
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
- //ViewGroup是容器
return new FolderListItem(context);
- }//创建一个文件夹,对于各文件夹中子标签的初始化
+ }
@Override
public void bindView(View view, Context context, Cursor cursor) {
@@ -59,22 +55,20 @@ public class FoldersListAdapter extends CursorAdapter {
.getString(R.string.menu_move_parent_folder) : cursor.getString(NAME_COLUMN);
((FolderListItem) view).bind(folderName);
}
- }//将各个布局文件绑定起来
+ }
public String getFolderName(Context context, int position) {
Cursor cursor = (Cursor) getItem(position);
return (cursor.getLong(ID_COLUMN) == Notes.ID_ROOT_FOLDER) ? context
.getString(R.string.menu_move_parent_folder) : cursor.getString(NAME_COLUMN);
- }//根据数据库中标签的ID得到标签的各项内容
+ }
private class FolderListItem extends LinearLayout {
private TextView mName;
public FolderListItem(Context context) {
super(context);
- //操作数据库
inflate(context, R.layout.folder_list_item, this);
- //根据布局文件的名字等信息将其找出来
mName = (TextView) findViewById(R.id.tv_folder_name);
}
diff --git a/app/src/main/java/net/micode/notes/ui/LoginActivity.java b/app/src/main/java/net/micode/notes/ui/LoginActivity.java
deleted file mode 100644
index fc750e8..0000000
--- a/app/src/main/java/net/micode/notes/ui/LoginActivity.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package net.micode.notes.ui;
-import net.micode.notes.R;
-import android.app.Activity;
-import android.content.Intent; // 导入 Intent 类
-import android.os.Bundle; // 导入 Bundle 类
-import android.view.View;
-import android.widget.Button;
-import android.widget.EditText;
-import android.app.ProgressDialog;
-
-import android.widget.Toast;
-
-public class LoginActivity extends Activity {
- private EditText accountEdit;
- private EditText passwordEdit; // 修正变量名
- private Button login;
- private Button cancel;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.login);
-
- // 初始化控件
- accountEdit = findViewById(R.id.account);
- passwordEdit = findViewById(R.id.password);
- login = findViewById(R.id.login);
- cancel = findViewById(R.id.cancel);
-
- // 设置取消按钮点击事件监听器
- cancel.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Toast.makeText(LoginActivity.this, R.string.app_already_quit, Toast.LENGTH_LONG).show();
- finish();
- }
- });
-
- // 设置登录按钮点击事件监听器
- login.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String account = accountEdit.getText().toString();
- String password = passwordEdit.getText().toString();
-
- if (account.equals("sqr") && password.equals("123456")) {
- // 如果登录成功,显示进度条,然后跳转到下一个界面
- ProgressDialog progressDialog = new ProgressDialog(LoginActivity.this);
- progressDialog.setTitle(getString(R.string.Loading)); // 使用 getString 获取字符串资源
- progressDialog.setMessage("Loading...");
- progressDialog.setCancelable(true);
- progressDialog.show();
- Intent intent = new Intent(LoginActivity.this, NotesListActivity.class);
- startActivity(intent);
- finish();
- } else {
- // 如果登录失败,显示提示信息
- Toast.makeText(LoginActivity.this, R.string.invalid, Toast.LENGTH_SHORT).show();
- }
- }
- });
- }
-}
diff --git a/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java b/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
index eda6b90..0bbc25d 100644
--- a/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
+++ b/app/src/main/java/net/micode/notes/ui/NoteEditActivity.java
@@ -74,8 +74,6 @@ import java.util.regex.Pattern;
public class NoteEditActivity extends Activity implements OnClickListener,
NoteSettingChangedListener, OnTextViewChangeListener {
- //该类主要是针对标签的编辑
- //继承了系统内部许多和监听有关的类
private class HeadViewHolder {
public TextView tvModified;
@@ -85,8 +83,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
public ImageView ibSetBgColor;
}
- //使用Map实现数据存储
- //put将指定值和指定键相连
+
private static final Map sBgSelectorBtnsMap = new HashMap();
static {
sBgSelectorBtnsMap.put(R.id.iv_bg_yellow, ResourceParser.YELLOW);
@@ -126,22 +123,20 @@ public class NoteEditActivity extends Activity implements OnClickListener,
private HeadViewHolder mNoteHeaderHolder;
private View mHeadViewPanel;
- //私有化一个界面操作mHeadViewPanel,对表头的操作
+
private View mNoteBgColorSelector;
- //私有化一个界面操作mNoteBgColorSelector,对背景颜色的操作
+
private View mFontSizeSelector;
- //私有化一个界面操作mFontSizeSelector,对标签字体的操作
+
private EditText mNoteEditor;
- //声明编辑控件,对文本操作
+
private View mNoteEditorPanel;
- //私有化一个界面操作mNoteEditorPanel,文本编辑的控制板
- //private WorkingNote mWorkingNote;
- public WorkingNote mWorkingNote;
- //对模板WorkingNote的初始化
+
+ private WorkingNote mWorkingNote;
+
private SharedPreferences mSharedPrefs;
- //私有化SharedPreferences的数据存储方式
private int mFontSizeId;
- //用于操作字体的大小
+
private static final String PREFERENCE_FONT_SIZE = "pref_font_size";
private static final int SHORTCUT_ICON_TITLE_MAX_LEN = 10;
@@ -182,7 +177,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
Log.d(TAG, "Restoring from killed activity");
}
- }//为防止内存不足时程序的终止,在这里有一个保存现场的函数
+ }
private boolean initActivityState(Intent intent) {
/**
@@ -193,7 +188,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
if (TextUtils.equals(Intent.ACTION_VIEW, intent.getAction())) {
long noteId = intent.getLongExtra(Intent.EXTRA_UID, 0);
mUserQuery = "";
- //如果用户实例化标签时,系统并未给出标签ID,根据键值查找ID
+
/**
* Starting from the searched result
*/
@@ -201,31 +196,26 @@ public class NoteEditActivity extends Activity implements OnClickListener,
noteId = Long.parseLong(intent.getStringExtra(SearchManager.EXTRA_DATA_KEY));
mUserQuery = intent.getStringExtra(SearchManager.USER_QUERY);
}
- //如果ID在数据库中未找到
+
if (!DataUtils.visibleInNoteDatabase(getContentResolver(), noteId, Notes.TYPE_NOTE)) {
Intent jump = new Intent(this, NotesListActivity.class);
startActivity(jump);
- //程序将跳转到上面声明的intent——jump
showToast(R.string.error_note_not_exist);
finish();
return false;
} else {
- //ID在数据库中找到
mWorkingNote = WorkingNote.load(this, noteId);
if (mWorkingNote == null) {
Log.e(TAG, "load note failed with note id" + noteId);
- //打印出红色的错误信息
finish();
return false;
}
}
- //setSoftInputMode——软键盘输入模式
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN
| WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
} else if(TextUtils.equals(Intent.ACTION_INSERT_OR_EDIT, intent.getAction())) {
// New note
- // 用户可以通过receive(接受)intent,通过getAction得到的字符串,来决定做什么
long folderId = intent.getLongExtra(Notes.INTENT_EXTRA_FOLDER_ID, 0);
int widgetId = intent.getIntExtra(Notes.INTENT_EXTRA_WIDGET_ID,
AppWidgetManager.INVALID_APPWIDGET_ID);
@@ -250,7 +240,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
finish();
return false;
}
- //将电话号码与手机的号码簿相关
} else {
mWorkingNote = WorkingNote.createEmptyNote(this, folderId, widgetId,
widgetType, bgResId);
@@ -259,7 +248,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
} else {
mWorkingNote = WorkingNote.createEmptyNote(this, folderId, widgetId, widgetType,
bgResId);
- }//创建一个新的WorkingNote
+ }
getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
@@ -280,10 +269,8 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
private void initNoteScreen() {
- //对界面的初始化操作
mNoteEditor.setTextAppearance(this, TextAppearanceResources
.getTexAppearanceResource(mFontSizeId));
- //设置外观
if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) {
switchToListMode(mWorkingNote.getContent());
} else {
@@ -307,20 +294,18 @@ public class NoteEditActivity extends Activity implements OnClickListener,
*/
showAlertHeader();
}
- //设置闹钟的显示
+
private void showAlertHeader() {
if (mWorkingNote.hasClockAlert()) {
long time = System.currentTimeMillis();
if (time > mWorkingNote.getAlertDate()) {
mNoteHeaderHolder.tvAlertDate.setText(R.string.note_alert_expired);
- //如果系统时间大于了闹钟设置的时间,那么闹钟失效
} else {
mNoteHeaderHolder.tvAlertDate.setText(DateUtils.getRelativeTimeSpanString(
mWorkingNote.getAlertDate(), time, DateUtils.MINUTE_IN_MILLIS));
}
mNoteHeaderHolder.tvAlertDate.setVisibility(View.VISIBLE);
mNoteHeaderHolder.ivAlertIcon.setVisibility(View.VISIBLE);
- //显示闹钟开启的图标
} else {
mNoteHeaderHolder.tvAlertDate.setVisibility(View.GONE);
mNoteHeaderHolder.ivAlertIcon.setVisibility(View.GONE);
@@ -344,29 +329,26 @@ public class NoteEditActivity extends Activity implements OnClickListener,
if (!mWorkingNote.existInDatabase()) {
saveNote();
}
- //在创建一个新的标签时,先在数据库中匹配
- //如果不存在,那么先在数据库中存储
outState.putLong(Intent.EXTRA_UID, mWorkingNote.getNoteId());
Log.d(TAG, "Save working note id: " + mWorkingNote.getNoteId() + " onSaveInstanceState");
}
@Override
- //MotionEvent是对屏幕触控的传递机制
public boolean dispatchTouchEvent(MotionEvent ev) {
if (mNoteBgColorSelector.getVisibility() == View.VISIBLE
&& !inRangeOfView(mNoteBgColorSelector, ev)) {
mNoteBgColorSelector.setVisibility(View.GONE);
return true;
- }//颜色选择器在屏幕上可见
+ }
if (mFontSizeSelector.getVisibility() == View.VISIBLE
&& !inRangeOfView(mFontSizeSelector, ev)) {
mFontSizeSelector.setVisibility(View.GONE);
return true;
- }//字体大小选择器在屏幕上可见
+ }
return super.dispatchTouchEvent(ev);
}
- //对屏幕触控的坐标进行操作
+
private boolean inRangeOfView(View view, MotionEvent ev) {
int []location = new int[2];
view.getLocationOnScreen(location);
@@ -378,7 +360,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
|| ev.getY() > (y + view.getHeight())) {
return false;
}
- //如果触控的位置超出了给定的范围,返回false
return true;
}
@@ -396,13 +377,13 @@ public class NoteEditActivity extends Activity implements OnClickListener,
for (int id : sBgSelectorBtnsMap.keySet()) {
ImageView iv = (ImageView) findViewById(id);
iv.setOnClickListener(this);
- }//对标签各项属性内容的初始化
+ }
mFontSizeSelector = findViewById(R.id.font_size_selector);
for (int id : sFontSizeBtnsMap.keySet()) {
View view = findViewById(id);
view.setOnClickListener(this);
- };//对字体大小的选择
+ };
mSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
mFontSizeId = mSharedPrefs.getInt(PREFERENCE_FONT_SIZE, ResourceParser.BG_DEFAULT_FONT_SIZE);
/**
@@ -424,7 +405,7 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
clearSettingState();
}
- //和桌面小工具的同步
+
private void updateWidget() {
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
if (mWorkingNote.getWidgetType() == Notes.TYPE_WIDGET_2X) {
@@ -500,7 +481,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
@Override
- //对选择菜单的准备
public boolean onPrepareOptionsMenu(Menu menu) {
if (isFinishing()) {
return true;
@@ -509,7 +489,6 @@ public class NoteEditActivity extends Activity implements OnClickListener,
menu.clear();
if (mWorkingNote.getFolderId() == Notes.ID_CALL_RECORD_FOLDER) {
getMenuInflater().inflate(R.menu.call_note_edit, menu);
- // MenuInflater是用来实例化Menu目录下的Menu布局文件的
} else {
getMenuInflater().inflate(R.menu.note_edit, menu);
}
@@ -527,68 +506,45 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
@Override
- //动态改变菜单选项内容
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- //根据菜单的id来编剧相关项目
case R.id.menu_new_note:
createNewNote();
- //创建一个新的便签
break;
case R.id.menu_delete:
- //删除便签
AlertDialog.Builder builder = new AlertDialog.Builder(this);
- //创建关于删除操作的对话框
builder.setTitle(getString(R.string.alert_title_delete));
- // 设置标签的标题为alert_title_delete
builder.setIcon(android.R.drawable.ic_dialog_alert);
- //设置对话框图标
builder.setMessage(getString(R.string.alert_message_delete_note));
- //设置对话框内容
builder.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
- //建立按键监听器
public void onClick(DialogInterface dialog, int which) {
- //点击所触发事件
deleteCurrentNote();
- // 删除单签便签
finish();
}
});
- //添加“YES”按钮
builder.setNegativeButton(android.R.string.cancel, null);
- //添加“NO”的按钮
builder.show();
- //显示对话框
break;
case R.id.menu_font_size:
- //字体大小的编辑
mFontSizeSelector.setVisibility(View.VISIBLE);
- // 将字体选择器置为可见
findViewById(sFontSelectorSelectionMap.get(mFontSizeId)).setVisibility(View.VISIBLE);
- // 通过id找到相应的大小
break;
case R.id.menu_list_mode:
- //选择列表模式
mWorkingNote.setCheckListMode(mWorkingNote.getCheckListMode() == 0 ?
TextNote.MODE_CHECK_LIST : 0);
break;
case R.id.menu_share:
- //菜单共享
getWorkingText();
sendTo(this, mWorkingNote.getContent());
- // 用sendto函数将运行文本发送到遍历的本文内
break;
case R.id.menu_send_to_desktop:
- //发送到桌面
sendToDesktop();
break;
case R.id.menu_alert:
- //创建提醒器
setReminder();
break;
case R.id.menu_delete_remind:
- //删除日期提醒
mWorkingNote.setAlertDate(0, false);
break;
default:
@@ -596,37 +552,28 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
return true;
}
- //建立事件提醒器
+
private void setReminder() {
DateTimePickerDialog d = new DateTimePickerDialog(this, System.currentTimeMillis());
- // 建立修改时间日期的对话框
d.setOnDateTimeSetListener(new OnDateTimeSetListener() {
public void OnDateTimeSet(AlertDialog dialog, long date) {
- mWorkingNote.setAlertDate(date , true);
- //选择提醒的日期
+ mWorkingNote.setAlertDate(date , true);
}
- });
- //建立时间日期的监听器
+ });
d.show();
- //显示对话框
}
/**
* Share note to apps that support {@link Intent#ACTION_SEND} action
* and {@text/plain} type
*/
- //共享便签
private void sendTo(Context context, String info) {
Intent intent = new Intent(Intent.ACTION_SEND);
- //建立intent链接选项
intent.putExtra(Intent.EXTRA_TEXT, info);
- //将需要传递的便签信息放入text文件中
intent.setType("text/plain");
- //编辑连接器的类型
context.startActivity(intent);
- //在acti中进行链接
}
- //创建一个新的便签
+
private void createNewNote() {
// Firstly, save current editing notes
saveNote();
@@ -634,72 +581,56 @@ public class NoteEditActivity extends Activity implements OnClickListener,
// For safety, start a new NoteEditActivity
finish();
Intent intent = new Intent(this, NoteEditActivity.class);
- //设置链接器
intent.setAction(Intent.ACTION_INSERT_OR_EDIT);
- //该活动定义为创建或编辑
intent.putExtra(Notes.INTENT_EXTRA_FOLDER_ID, mWorkingNote.getFolderId());
- //将运行便签的id添加到INTENT_EXTRA_FOLDER_ID标记中
startActivity(intent);
- //开始activity并链接
}
- //删除当前便签
+
private void deleteCurrentNote() {
if (mWorkingNote.existInDatabase()) {
- //假如当前运行的便签内存有数据
HashSet ids = new HashSet();
long id = mWorkingNote.getNoteId();
if (id != Notes.ID_ROOT_FOLDER) {
ids.add(id);
- //如果不是头文件夹建立一个hash表把便签id存起来
} else {
Log.d(TAG, "Wrong note id, should not happen");
- //否则报错
}
if (!isSyncMode()) {
- //在非同步模式情况下
- //删除操作
if (!DataUtils.batchDeleteNotes(getContentResolver(), ids)) {
Log.e(TAG, "Delete Note error");
}
} else {
- //同步模式
- //移动至垃圾文件夹的操作
if (!DataUtils.batchMoveToFolder(getContentResolver(), ids, Notes.ID_TRASH_FOLER)) {
Log.e(TAG, "Move notes to trash folder error, should not happens");
}
}
}
mWorkingNote.markDeleted(true);
- //将这些标签的删除标记置为true
}
- //判断是否为同步模式
+
private boolean isSyncMode() {
return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0;
}
- //设置提醒时间
+
public void onClockAlertChanged(long date, boolean set) {
/**
* User could set clock to an unsaved note, so before setting the
* alert clock, we should save the note first
*/
if (!mWorkingNote.existInDatabase()) {
- //首先保存已有的便签
saveNote();
}
if (mWorkingNote.getNoteId() > 0) {
- Intent intent = new Intent(this, AlarmReceiver.class);
+ Intent intent = new Intent(this, AlarmReceiver.class);
intent.setData(ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mWorkingNote.getNoteId()));
- //若有有运行的便签就是建立一个链接器将标签id都存在uri中
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, 0);
AlarmManager alarmManager = ((AlarmManager) getSystemService(ALARM_SERVICE));
- //设置提醒管理器
showAlertHeader();
if(!set) {
alarmManager.cancel(pendingIntent);
} else {
alarmManager.set(AlarmManager.RTC_WAKEUP, date, pendingIntent);
}
- //如果用户设置了时间,就通过提醒管理器设置一个监听事项
} else {
/**
* There is the condition that user has input nothing (the note is
@@ -710,22 +641,22 @@ public class NoteEditActivity extends Activity implements OnClickListener,
showToast(R.string.error_note_empty_for_clock);
}
}
- //Widget发生改变的所触发的事件
+
public void onWidgetChanged() {
updateWidget();
}
- //删除编辑文本框所触发的事件
+
public void onEditTextDelete(int index, String text) {
int childCount = mEditTextList.getChildCount();
if (childCount == 1) {
return;
}
- //通过id把编辑框存在便签编辑框中
+
for (int i = index + 1; i < childCount; i++) {
((NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text))
.setIndex(i - 1);
}
- //删除特定位置的视图
+
mEditTextList.removeViewAt(index);
NoteEditText edit = null;
if(index == 0) {
@@ -735,15 +666,12 @@ public class NoteEditActivity extends Activity implements OnClickListener,
edit = (NoteEditText) mEditTextList.getChildAt(index - 1).findViewById(
R.id.et_edit_text);
}
- //通过id把编辑框存在空的NoteEditText中
int length = edit.length();
edit.append(text);
edit.requestFocus();
- //请求优先完成该此编辑
edit.setSelection(length);
- //定位到length位置
}
- //进入编辑文本框所触发的事件
+
public void onEditTextEnter(int index, String text) {
/**
* Should not happen, check for debug
@@ -754,68 +682,53 @@ public class NoteEditActivity extends Activity implements OnClickListener,
View view = getListItem(text, index);
mEditTextList.addView(view, index);
- //建立一个新的视图并添加到编辑文本框内
NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text);
edit.requestFocus();
- //请求优先完成该此编辑
edit.setSelection(0);
- //定位到起始位置
for (int i = index + 1; i < mEditTextList.getChildCount(); i++) {
((NoteEditText) mEditTextList.getChildAt(i).findViewById(R.id.et_edit_text))
.setIndex(i);
}
- //遍历子文本框并设置对应对下标
}
- //切换至列表模式
+
private void switchToListMode(String text) {
mEditTextList.removeAllViews();
String[] items = text.split("\n");
int index = 0;
- //清空所有视图,初始化下标
for (String item : items) {
if(!TextUtils.isEmpty(item)) {
mEditTextList.addView(getListItem(item, index));
index++;
- //遍历所有文本单元并添加到文本框中
}
}
mEditTextList.addView(getListItem("", index));
mEditTextList.getChildAt(index).findViewById(R.id.et_edit_text).requestFocus();
- //优先请求此操作
+
mNoteEditor.setVisibility(View.GONE);
- //便签编辑器不可见
mEditTextList.setVisibility(View.VISIBLE);
- //将文本编辑框置为可见
}
- //获取高亮效果
+
private Spannable getHighlightQueryResult(String fullText, String userQuery) {
SpannableString spannable = new SpannableString(fullText == null ? "" : fullText);
- //新建一个效果选项
if (!TextUtils.isEmpty(userQuery)) {
mPattern = Pattern.compile(userQuery);
- //将用户的询问进行解析
Matcher m = mPattern.matcher(fullText);
- //建立一个状态机检查Pattern并进行匹配
int start = 0;
while (m.find(start)) {
spannable.setSpan(
new BackgroundColorSpan(this.getResources().getColor(
R.color.user_query_highlight)), m.start(), m.end(),
Spannable.SPAN_INCLUSIVE_EXCLUSIVE);
- //设置背景颜色
start = m.end();
- //更新起始位置
}
}
return spannable;
}
- //获取列表项
+
private View getListItem(String item, int index) {
View view = LayoutInflater.from(this).inflate(R.layout.note_edit_list_item, null);
- //创建一个视图
final NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text);
edit.setTextAppearance(this, TextAppearanceResources.getTexAppearanceResource(mFontSizeId));
- //创建一个文本编辑框并设置可见性
CheckBox cb = ((CheckBox) view.findViewById(R.id.cb_edit_item));
cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@@ -826,15 +739,12 @@ public class NoteEditActivity extends Activity implements OnClickListener,
}
}
});
- //建立一个打钩框并设置监听器
if (item.startsWith(TAG_CHECKED)) {
- //选择勾选
cb.setChecked(true);
edit.setPaintFlags(edit.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
item = item.substring(TAG_CHECKED.length(), item.length()).trim();
} else if (item.startsWith(TAG_UNCHECKED)) {
- //选择不勾选
cb.setChecked(false);
edit.setPaintFlags(Paint.ANTI_ALIAS_FLAG | Paint.DEV_KERN_TEXT_FLAG);
item = item.substring(TAG_UNCHECKED.length(), item.length()).trim();
@@ -843,78 +753,61 @@ public class NoteEditActivity extends Activity implements OnClickListener,
edit.setOnTextViewChangeListener(this);
edit.setIndex(index);
edit.setText(getHighlightQueryResult(item, mUserQuery));
- //运行编辑框的监听器对该行为作出反应,并设置下标及文本内容
return view;
}
- //便签内容发生改变所触发的事件
+
public void onTextChange(int index, boolean hasText) {
if (index >= mEditTextList.getChildCount()) {
Log.e(TAG, "Wrong index, should not happen");
return;
- //越界报错
}
if(hasText) {
mEditTextList.getChildAt(index).findViewById(R.id.cb_edit_item).setVisibility(View.VISIBLE);
} else {
mEditTextList.getChildAt(index).findViewById(R.id.cb_edit_item).setVisibility(View.GONE);
}
- //如果内容不为空则将其子编辑框可见性置为可见,否则不可见
}
- //检查模式和列表模式的切换
+
public void onCheckListModeChanged(int oldMode, int newMode) {
if (newMode == TextNote.MODE_CHECK_LIST) {
switchToListMode(mNoteEditor.getText().toString());
- //检查模式切换到列表模式
} else {
if (!getWorkingText()) {
mWorkingNote.setWorkingText(mWorkingNote.getContent().replace(TAG_UNCHECKED + " ",
""));
}
- //若是获取到文本就改变其检查标记
mNoteEditor.setText(getHighlightQueryResult(mWorkingNote.getContent(), mUserQuery));
mEditTextList.setVisibility(View.GONE);
mNoteEditor.setVisibility(View.VISIBLE);
- //修改文本编辑器的内容和可见性
}
}
- //设置勾选选项表并返回是否勾选的标记
+
private boolean getWorkingText() {
boolean hasChecked = false;
- //初始化check标记
if (mWorkingNote.getCheckListMode() == TextNote.MODE_CHECK_LIST) {
- // 若模式为CHECK_LIST
StringBuilder sb = new StringBuilder();
- //创建可变字符串
for (int i = 0; i < mEditTextList.getChildCount(); i++) {
View view = mEditTextList.getChildAt(i);
- //遍历所有子编辑框的视图
NoteEditText edit = (NoteEditText) view.findViewById(R.id.et_edit_text);
if (!TextUtils.isEmpty(edit.getText())) {
- //若文本不为空
if (((CheckBox) view.findViewById(R.id.cb_edit_item)).isChecked()) {
- //该选项框已打钩
sb.append(TAG_CHECKED).append(" ").append(edit.getText()).append("\n");
hasChecked = true;
- //扩展字符串为已打钩并把标记置true
} else {
sb.append(TAG_UNCHECKED).append(" ").append(edit.getText()).append("\n");
- //扩展字符串添加未打钩
}
}
}
mWorkingNote.setWorkingText(sb.toString());
- //利用编辑好的字符串设置运行便签的内容
} else {
mWorkingNote.setWorkingText(mNoteEditor.getText().toString());
- // 若不是该模式直接用编辑器中的内容设置运行中标签的内容
}
return hasChecked;
}
- //保存便签
+
private boolean saveNote() {
getWorkingText();
boolean saved = mWorkingNote.saveNote();
- //运行 getWorkingText()之后保存
if (saved) {
/**
* There are two modes from List view to edit view, open one note,
@@ -924,11 +817,10 @@ public class NoteEditActivity extends Activity implements OnClickListener,
* {@link #RESULT_OK} is used to identify the create/edit state
*/
setResult(RESULT_OK);
- //一是创建后保存,二是修改后保存
}
return saved;
}
- //将便签发送至桌面
+
private void sendToDesktop() {
/**
* Before send message to home, we should make sure that current
@@ -937,16 +829,12 @@ public class NoteEditActivity extends Activity implements OnClickListener,
*/
if (!mWorkingNote.existInDatabase()) {
saveNote();
- //若不存在数据也就是新的标签就保存起来先
}
if (mWorkingNote.getNoteId() > 0) {
- //若是有内容
Intent sender = new Intent();
Intent shortcutIntent = new Intent(this, NoteEditActivity.class);
- //建立发送到桌面的连接器
shortcutIntent.setAction(Intent.ACTION_VIEW);
- //链接为一个视图
shortcutIntent.putExtra(Intent.EXTRA_UID, mWorkingNote.getNoteId());
sender.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent);
sender.putExtra(Intent.EXTRA_SHORTCUT_NAME,
@@ -954,12 +842,9 @@ public class NoteEditActivity extends Activity implements OnClickListener,
sender.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(this, R.drawable.icon_app));
sender.putExtra("duplicate", true);
- //将便签的相关信息都添加到要发送的文件里
sender.setAction("com.android.launcher.action.INSTALL_SHORTCUT");
- //设置sneder的行为是发送
showToast(R.string.info_note_enter_desktop);
sendBroadcast(sender);
- //显示到桌面
} else {
/**
* There is the condition that user has input nothing (the note is
@@ -968,23 +853,26 @@ public class NoteEditActivity extends Activity implements OnClickListener,
*/
Log.e(TAG, "Send to desktop error");
showToast(R.string.error_note_empty_for_send_to_desktop);
- //空便签直接报错
}
}
- //编辑小图标的标题
+
private String makeShortcutIconTitle(String content) {
content = content.replace(TAG_CHECKED, "");
content = content.replace(TAG_UNCHECKED, "");
return content.length() > SHORTCUT_ICON_TITLE_MAX_LEN ? content.substring(0,
SHORTCUT_ICON_TITLE_MAX_LEN) : content;
- //直接设置为content中的内容并返回,有勾选和未勾选2种
- }
- //显示提示的视图
+ }
+
private void showToast(int resId) {
showToast(resId, Toast.LENGTH_SHORT);
}
- //持续显示提示的试图
+
private void showToast(int resId, int duration) {
Toast.makeText(this, resId, duration).show();
}
+
+
+ public void OnOpenMenu(View view) {
+ openOptionsMenu();
+ }
}
diff --git a/app/src/main/java/net/micode/notes/ui/NoteEditText.java b/app/src/main/java/net/micode/notes/ui/NoteEditText.java
index 1fcbd16..2afe2a8 100644
--- a/app/src/main/java/net/micode/notes/ui/NoteEditText.java
+++ b/app/src/main/java/net/micode/notes/ui/NoteEditText.java
@@ -36,7 +36,7 @@ import net.micode.notes.R;
import java.util.HashMap;
import java.util.Map;
-//继承edittext,设置便签设置文本框
+
public class NoteEditText extends EditText {
private static final String TAG = "NoteEditText";
private int mIndex;
@@ -45,7 +45,7 @@ public class NoteEditText extends EditText {
private static final String SCHEME_TEL = "tel:" ;
private static final String SCHEME_HTTP = "http:" ;
private static final String SCHEME_EMAIL = "mailto:" ;
- ///建立一个字符和整数的hash表,用于链接电话,网站,还有邮箱
+
private static final Map sSchemaActionResMap = new HashMap();
static {
sSchemaActionResMap.put(SCHEME_TEL, R.string.note_link_tel);
@@ -56,20 +56,17 @@ public class NoteEditText extends EditText {
/**
* Call by the {@link NoteEditActivity} to delete or add edit text
*/
- //在NoteEditActivity中删除或添加文本的操作,可以看做是一个文本是否被变的标记
public interface OnTextViewChangeListener {
/**
* Delete current edit text when {@link KeyEvent#KEYCODE_DEL} happens
* and the text is null
*/
- //处理删除按键时的操作
void onEditTextDelete(int index, String text);
/**
* Add edit text after current edit text when {@link KeyEvent#KEYCODE_ENTER}
* happen
*/
- //处理进入按键时的操作
void onEditTextEnter(int index, String text);
/**
@@ -79,50 +76,44 @@ public class NoteEditText extends EditText {
}
private OnTextViewChangeListener mOnTextViewChangeListener;
- //根据context设置文本
+
public NoteEditText(Context context) {
super(context, null);
- //用super引用父类变量
mIndex = 0;
}
- //设置当前光标
+
public void setIndex(int index) {
mIndex = index;
}
- //初始化文本修改标记
+
public void setOnTextViewChangeListener(OnTextViewChangeListener listener) {
mOnTextViewChangeListener = listener;
}
- //AttributeSet 百度了一下是自定义空控件属性,用于维护便签动态变化的属性
- //初始化便签
+
public NoteEditText(Context context, AttributeSet attrs) {
super(context, attrs, android.R.attr.editTextStyle);
}
- // 根据defstyle自动初始化
+
public NoteEditText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
@Override
- //view里的函数,处理手机屏幕的所有事件
- /** event:为手机屏幕触摸事件封装类的对象,其中封装了该事件的所有信息*/
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
- //重写了需要处理屏幕被按下的事件
case MotionEvent.ACTION_DOWN:
- //更新当前坐标值
+
int x = (int) event.getX();
int y = (int) event.getY();
x -= getTotalPaddingLeft();
y -= getTotalPaddingTop();
x += getScrollX();
y += getScrollY();
- //用布局控件layout根据x,y的新值设置新的位置
+
Layout layout = getLayout();
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);
- //更新光标新的位置
Selection.setSelection(getText(), off);
break;
}
@@ -131,136 +122,96 @@ public class NoteEditText extends EditText {
}
@Override
- //处理用户按下一个键盘按键时会触发的事件
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
- //根据按键的 Unicode 编码值来处理
case KeyEvent.KEYCODE_ENTER:
- //“进入”按键
if (mOnTextViewChangeListener != null) {
return false;
}
break;
case KeyEvent.KEYCODE_DEL:
- //“删除”按键
mSelectionStartBeforeDelete = getSelectionStart();
break;
default:
break;
}
- //继续执行父类的其他点击事件
return super.onKeyDown(keyCode, event);
}
@Override
- //处理用户松开一个键盘按键时会触发的事件
public boolean onKeyUp(int keyCode, KeyEvent event) {
switch(keyCode) {
- //根据按键的 Unicode 编码值来处理,有删除和进入2种操作
case KeyEvent.KEYCODE_DEL:
if (mOnTextViewChangeListener != null) {
- //若是被修改过
if (0 == mSelectionStartBeforeDelete && mIndex != 0) {
- //若之前有被修改并且文档不为空
mOnTextViewChangeListener.onEditTextDelete(mIndex, getText().toString());
- //利用上文OnTextViewChangeListener对KEYCODE_DEL按键情况的删除函数进行删除
return true;
}
} else {
Log.d(TAG, "OnTextViewChangeListener was not seted");
- //其他情况报错,文档的改动监听器并没有建立
}
break;
case KeyEvent.KEYCODE_ENTER:
- //同上也是分为监听器是否建立2种情况
if (mOnTextViewChangeListener != null) {
int selectionStart = getSelectionStart();
- //获取当前位置
String text = getText().subSequence(selectionStart, length()).toString();
- //获取当前文本
setText(getText().subSequence(0, selectionStart));
- //根据获取的文本设置当前文本
mOnTextViewChangeListener.onEditTextEnter(mIndex + 1, text);
- //当{@link KeyEvent#KEYCODE_ENTER}添加新文本
} else {
Log.d(TAG, "OnTextViewChangeListener was not seted");
- //其他情况报错,文档的改动监听器并没有建立
}
break;
default:
break;
}
- //继续执行父类的其他按键弹起的事件
return super.onKeyUp(keyCode, event);
}
@Override
- //当焦点发生变化时,会自动调用该方法来处理焦点改变的事件
- /** focused:触发该事件的View是否获得了焦点,当该控件获得焦点时,Focused等于true,否则等于false。
- * direction:焦点移动的方向,用数值表示
- * rect:在触发事件的View的坐标系中,前一个获得焦点的矩形区域,如果不可用则为null
- * */
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
if (mOnTextViewChangeListener != null) {
- //若监听器已经建立
if (!focused && TextUtils.isEmpty(getText())) {
- //获取到焦点并且文本不为空
mOnTextViewChangeListener.onTextChange(mIndex, false);
- //mOnTextViewChangeListener子函数,置false隐藏事件选项
} else {
mOnTextViewChangeListener.onTextChange(mIndex, true);
- //mOnTextViewChangeListener子函数,置true显示事件选项
}
}
- //继续执行父类的其他焦点变化的事件
super.onFocusChanged(focused, direction, previouslyFocusedRect);
}
@Override
- //生成上下文菜单
protected void onCreateContextMenu(ContextMenu menu) {
if (getText() instanceof Spanned) {
- //有文本存在
int selStart = getSelectionStart();
int selEnd = getSelectionEnd();
- //获取文本开始和结尾位置
int min = Math.min(selStart, selEnd);
int max = Math.max(selStart, selEnd);
- //获取开始到结尾的最大值和最小值
-
+
final URLSpan[] urls = ((Spanned) getText()).getSpans(min, max, URLSpan.class);
- //设置url的信息的范围值
if (urls.length == 1) {
int defaultResId = 0;
for(String schema: sSchemaActionResMap.keySet()) {
- //获取计划表中所有的key值
if(urls[0].getURL().indexOf(schema) >= 0) {
- //若url可以添加则在添加后将defaultResId置为key所映射的值
defaultResId = sSchemaActionResMap.get(schema);
break;
}
}
if (defaultResId == 0) {
- //defaultResId == 0则说明url并没有添加任何东西,所以置为连接其他SchemaActionResMap的值
defaultResId = R.string.note_link_other;
}
- //建立菜单
menu.add(0, 0, 0, defaultResId).setOnMenuItemClickListener(
new OnMenuItemClickListener() {
- //新建按键监听器
public boolean onMenuItemClick(MenuItem item) {
// goto a new intent
urls[0].onClick(NoteEditText.this);
- //根据相应的文本设置菜单的按键
return true;
}
});
}
}
- //继续执行父类的其他菜单创建的事件
super.onCreateContextMenu(menu);
}
}
diff --git a/app/src/main/java/net/micode/notes/ui/NoteItemData.java b/app/src/main/java/net/micode/notes/ui/NoteItemData.java
index f5f99cc..0f5a878 100644
--- a/app/src/main/java/net/micode/notes/ui/NoteItemData.java
+++ b/app/src/main/java/net/micode/notes/ui/NoteItemData.java
@@ -25,21 +25,21 @@ import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.tool.DataUtils;
-/** 列表元素数据模型,属于模型层 */
+
public class NoteItemData {
static final String [] PROJECTION = new String [] {
- NoteColumns.ID,
- NoteColumns.ALERTED_DATE,
- NoteColumns.BG_COLOR_ID,
- NoteColumns.CREATED_DATE,
- NoteColumns.HAS_ATTACHMENT,
- NoteColumns.MODIFIED_DATE,
- NoteColumns.NOTES_COUNT,
- NoteColumns.PARENT_ID,
- NoteColumns.SNIPPET,
- NoteColumns.TYPE,
- NoteColumns.WIDGET_ID,
- NoteColumns.WIDGET_TYPE,
+ NoteColumns.ID,
+ NoteColumns.ALERTED_DATE,
+ NoteColumns.BG_COLOR_ID,
+ NoteColumns.CREATED_DATE,
+ NoteColumns.HAS_ATTACHMENT,
+ NoteColumns.MODIFIED_DATE,
+ NoteColumns.NOTES_COUNT,
+ NoteColumns.PARENT_ID,
+ NoteColumns.SNIPPET,
+ NoteColumns.TYPE,
+ NoteColumns.WIDGET_ID,
+ NoteColumns.WIDGET_TYPE,
};
private static final int ID_COLUMN = 0;
@@ -75,9 +75,8 @@ public class NoteItemData {
private boolean mIsOnlyOneItem;
private boolean mIsOneNoteFollowingFolder;
private boolean mIsMultiNotesFollowingFolder;
- /** 构造函数:从游标处拿一条数据放到实例里 */
+
public NoteItemData(Context context, Cursor cursor) {
- //get转换格式
mId = cursor.getLong(ID_COLUMN);
mAlertDate = cursor.getLong(ALERTED_DATE_COLUMN);
mBgColorId = cursor.getInt(BG_COLOR_ID_COLUMN);
@@ -92,7 +91,7 @@ public class NoteItemData {
mType = cursor.getInt(TYPE_COLUMN);
mWidgetId = cursor.getInt(WIDGET_ID_COLUMN);
mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN);
- //初始化电话号码的信息
+
mPhoneNumber = "";
if (mParentId == Notes.ID_CALL_RECORD_FOLDER) {
mPhoneNumber = DataUtils.getCallNumberByNoteId(context.getContentResolver(), mId);
@@ -109,7 +108,7 @@ public class NoteItemData {
}
checkPostion(cursor);
}
- /** 判断位置,可能可以用来合并同类便签 */
+
private void checkPostion(Cursor cursor) {
mIsLastItem = cursor.isLast() ? true : false;
mIsFirstItem = cursor.isFirst() ? true : false;
@@ -120,13 +119,12 @@ public class NoteItemData {
if (mType == Notes.TYPE_NOTE && !mIsFirstItem) {
int position = cursor.getPosition();
if (cursor.moveToPrevious()) {
- // 判断当前元素的上一个元素(如果是文件夹就是当前元素的父元素)
if (cursor.getInt(TYPE_COLUMN) == Notes.TYPE_FOLDER
|| cursor.getInt(TYPE_COLUMN) == Notes.TYPE_SYSTEM) {
if (cursor.getCount() > (position + 1)) {
- mIsMultiNotesFollowingFolder = true; // 文件夹里有多个note
+ mIsMultiNotesFollowingFolder = true;
} else {
- mIsOneNoteFollowingFolder = true; // 文件夹里只有一个note
+ mIsOneNoteFollowingFolder = true;
}
}
if (!cursor.moveToNext()) {
@@ -135,7 +133,7 @@ public class NoteItemData {
}
}
}
- // 以下是各种数据的只读接口
+
public boolean isOneFollowingFolder() {
return mIsOneNoteFollowingFolder;
}
@@ -147,7 +145,7 @@ public class NoteItemData {
public boolean isLast() {
return mIsLastItem;
}
- /** 拿联系人名 */
+
public String getCallName() {
return mName;
}
@@ -215,7 +213,7 @@ public class NoteItemData {
public boolean hasAlert() {
return (mAlertDate > 0);
}
- //若数据父id为保存至文件夹模式的id且满足电话号码单元不为空,则isCallRecord为true
+
public boolean isCallRecord() {
return (mParentId == Notes.ID_CALL_RECORD_FOLDER && !TextUtils.isEmpty(mPhoneNumber));
}
diff --git a/app/src/main/java/net/micode/notes/ui/NotesListActivity.java b/app/src/main/java/net/micode/notes/ui/NotesListActivity.java
index e8235d8..2fa42ce 100644
--- a/app/src/main/java/net/micode/notes/ui/NotesListActivity.java
+++ b/app/src/main/java/net/micode/notes/ui/NotesListActivity.java
@@ -16,6 +16,7 @@
package net.micode.notes.ui;
+import android.R.menu;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@@ -59,7 +60,6 @@ import android.widget.ListView;
import android.widget.PopupMenu;
import android.widget.TextView;
import android.widget.Toast;
-
import net.micode.notes.R;
import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.NoteColumns;
@@ -77,9 +77,8 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
-/** 总入口,DONE */
+
public class NotesListActivity extends Activity implements OnClickListener, OnItemLongClickListener {
- public static int secret_mode = 0;
private static final int FOLDER_NOTE_LIST_QUERY_TOKEN = 0;
private static final int FOLDER_LIST_QUERY_TOKEN = 1;
@@ -105,6 +104,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
private ListView mNotesListView;
private Button mAddNewNote;
+ private Button mMenuSet;
private boolean mDispatch;
@@ -137,10 +137,8 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
private final static int REQUEST_CODE_NEW_NODE = 103;
@Override
- //创建类
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // 调用父类的onCreate函数
setContentView(R.layout.note_list);
initResources();
@@ -151,26 +149,21 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
}
@Override
- // 返回一些子模块完成的数据交给主Activity处理
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- // 结果值和要求值符合要求
if (resultCode == RESULT_OK
&& (requestCode == REQUEST_CODE_OPEN_NODE || requestCode == REQUEST_CODE_NEW_NODE)) {
mNotesListAdapter.changeCursor(null);
} else {
super.onActivityResult(requestCode, resultCode, data);
- // 调用 Activity 的onActivityResult()
}
}
private void setAppInfoFromRawRes() {
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
- //SharedPreferences类,它是一个轻量级的存储类,特别适合用于保存软件配置参数。
if (!sp.getBoolean(PREFERENCE_ADD_INTRODUCTION, false)) {
StringBuilder sb = new StringBuilder();
InputStream in = null;
try {
- // 把资源文件放到应用程序下,在应用中使用getResources获取资源后,以openRawResource方法打开这个文件。
in = getResources().openRawResource(R.raw.introduction);
if (in != null) {
InputStreamReader isr = new InputStreamReader(in);
@@ -197,13 +190,12 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
}
}
}
- // 创建空的WorkingNote
+
WorkingNote note = WorkingNote.createEmptyNote(this, Notes.ID_ROOT_FOLDER,
AppWidgetManager.INVALID_APPWIDGET_ID, Notes.TYPE_WIDGET_INVALIDE,
ResourceParser.RED);
note.setWorkingText(sb.toString());
if (note.saveNote()) {
- // 更新保存note的信息
sp.edit().putBoolean(PREFERENCE_ADD_INTRODUCTION, true).commit();
} else {
Log.e(TAG, "Save introduction note error");
@@ -217,36 +209,39 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
super.onStart();
startAsyncNotesListQuery();
}
- // 初始化资源
+
private void initResources() {
- mContentResolver = this.getContentResolver(); // 类似数据库句柄
- mBackgroundQueryHandler = new BackgroundQueryHandler(this.getContentResolver()); // 后台查询任务
+ mContentResolver = this.getContentResolver();
+ mBackgroundQueryHandler = new BackgroundQueryHandler(this.getContentResolver());
mCurrentFolderId = Notes.ID_ROOT_FOLDER;
- mNotesListView = (ListView) findViewById(R.id.notes_list); // 创建NotesList视图(CTRL跟进)
+ mNotesListView = (ListView) findViewById(R.id.notes_list);
mNotesListView.addFooterView(LayoutInflater.from(this).inflate(R.layout.note_list_footer, null),
- null, false); // 用于通知用户列表划到底了的视图元素
- mNotesListView.setOnItemClickListener(new OnListItemClickListener()); // 点击监听
- mNotesListView.setOnItemLongClickListener(this); // 长按监听
- mNotesListAdapter = new NotesListAdapter(this); // ListView的元素管理器
+ null, false);
+ mNotesListView.setOnItemClickListener(new OnListItemClickListener());
+ mNotesListView.setOnItemLongClickListener(this);
+ mNotesListAdapter = new NotesListAdapter(this);
mNotesListView.setAdapter(mNotesListAdapter);
- mAddNewNote = (Button) findViewById(R.id.btn_new_note); // 拿"写便签"按钮
+ mAddNewNote = (Button) findViewById(R.id.btn_new_note);
mAddNewNote.setOnClickListener(this);
- mAddNewNote.setOnTouchListener(new NewNoteOnTouchListener()); // 新建便签
+ mAddNewNote.setOnTouchListener(new NewNoteOnTouchListener());
+ mMenuSet = (Button) findViewById(R.id.btn_set);
mDispatch = false;
mDispatchY = 0;
mOriginY = 0;
- mTitleBar = (TextView) findViewById(R.id.tv_title_bar); // 书签图标
+ mTitleBar = (TextView) findViewById(R.id.tv_title_bar);
mState = ListEditState.NOTE_LIST;
mModeCallBack = new ModeCallback();
}
- // 继承自ListView.MultiChoiceModeListener 和 OnMenuItemClickListener
+
private class ModeCallback implements ListView.MultiChoiceModeListener, OnMenuItemClickListener {
private DropdownMenu mDropDownMenu;
private ActionMode mActionMode;
+ private Menu menu;
private MenuItem mMoveMenu;
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
getMenuInflater().inflate(R.menu.note_list_options, menu);
+ this.menu = menu;
menu.findItem(R.id.delete).setOnMenuItemClickListener(this);
mMoveMenu = menu.findItem(R.id.move);
if (mFocusNoteDataItem.getParentId() == Notes.ID_CALL_RECORD_FOLDER
@@ -260,6 +255,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
mNotesListAdapter.setChoiceMode(true);
mNotesListView.setLongClickable(false);
mAddNewNote.setVisibility(View.GONE);
+ mMenuSet.setVisibility(View.GONE);
View customView = LayoutInflater.from(NotesListActivity.this).inflate(
R.layout.note_list_dropdown_menu, null);
@@ -277,13 +273,12 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
});
return true;
}
- // 更新菜单
+
private void updateMenu() {
int selectedCount = mNotesListAdapter.getSelectedCount();
// Update dropdown menu
String format = getResources().getString(R.string.menu_select_title, selectedCount);
mDropDownMenu.setTitle(format);
- // 更改标题
MenuItem item = mDropDownMenu.findItem(R.id.action_select_all);
if (item != null) {
if (mNotesListAdapter.isAllSelected()) {
@@ -308,13 +303,36 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
public void onDestroyActionMode(ActionMode mode) {
mNotesListAdapter.setChoiceMode(false);
+ mNotesListView.clearChoices();
+ mNotesListView.setItemChecked(0,true);
+ mNotesListView.setItemChecked(0,false);
+
mNotesListView.setLongClickable(true);
+ System.out.println("-----------------onDestroyActionMode------------------");
+ mNotesListAdapter.notifyDataSetChanged();
+// closeOptionsMenu();
+// mNotesListView.invalidate();
mAddNewNote.setVisibility(View.VISIBLE);
- }
+ mMenuSet.setVisibility(View.VISIBLE);
+
+
+
+// mNotesListView.setChoiceMode(ListView.CHOICE_MODE_NONE);
+
+// menu.clear();
+// menu.close();
+ }
+
+
public void finishActionMode() {
mActionMode.finish();
+ mActionMode = null;
+ mNotesListAdapter.setChoiceMode(false);
+ mNotesListView.setLongClickable(true);
}
+
+
public void onItemCheckedStateChanged(ActionMode mode, int position, long id,
boolean checked) {
@@ -355,6 +373,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
return true;
}
}
+
private class NewNoteOnTouchListener implements OnTouchListener {
@@ -421,35 +440,10 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
private void startAsyncNotesListQuery() {
String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ? ROOT_FOLDER_SELECTION
: NORMAL_SELECTION;
- if(secret_mode == 0) {
- mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
- Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[]{
- String.valueOf(mCurrentFolderId)
- }, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
- }
- else{
- String str1 = "123";
- String [] PROJECTION = new String [] { //定义一个新的PROJECTION数组,只换掉SNIPPET
- NoteColumns.ID,
- NoteColumns.ALERTED_DATE,
- NoteColumns.BG_COLOR_ID,
- NoteColumns.CREATED_DATE,
- NoteColumns.HAS_ATTACHMENT,
- NoteColumns.MODIFIED_DATE,
- NoteColumns.NOTES_COUNT,
- NoteColumns.PARENT_ID,
-// NoteColumns.SNIPPET,
- str1,
- NoteColumns.TYPE,
- NoteColumns.WIDGET_ID,
- NoteColumns.WIDGET_TYPE,
- };
- mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
- Notes.CONTENT_NOTE_URI, PROJECTION, selection, new String[]{
- String.valueOf(mCurrentFolderId)
- }, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
-
- }
+ mBackgroundQueryHandler.startQuery(FOLDER_NOTE_LIST_QUERY_TOKEN, null,
+ Notes.CONTENT_NOTE_URI, NoteItemData.PROJECTION, selection, new String[] {
+ String.valueOf(mCurrentFolderId)
+ }, NoteColumns.TYPE + " DESC," + NoteColumns.MODIFIED_DATE + " DESC");
}
private final class BackgroundQueryHandler extends AsyncQueryHandler {
@@ -581,6 +575,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) {
mState = ListEditState.CALL_RECORD_FOLDER;
mAddNewNote.setVisibility(View.GONE);
+ mMenuSet.setVisibility(View.GONE);
} else {
mState = ListEditState.SUB_FOLDER;
}
@@ -700,8 +695,9 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
}
@Override
- //按返回键时根据情况更改类中的数据
public void onBackPressed() {
+
+ System.out.println("-------onBackPressed---00000");
switch (mState) {
case SUB_FOLDER:
mCurrentFolderId = Notes.ID_ROOT_FOLDER;
@@ -713,17 +709,19 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
mCurrentFolderId = Notes.ID_ROOT_FOLDER;
mState = ListEditState.NOTE_LIST;
mAddNewNote.setVisibility(View.VISIBLE);
+ mMenuSet.setVisibility(View.VISIBLE);
mTitleBar.setVisibility(View.GONE);
startAsyncNotesListQuery();
break;
case NOTE_LIST:
+ System.out.println("-------onBackPressed---");
super.onBackPressed();
break;
default:
break;
}
}
- //根据不同类型的widget更新插件,通过intent传送数据
+
private void updateWidget(int appWidgetId, int appWidgetType) {
Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
if (appWidgetType == Notes.TYPE_WIDGET_2X) {
@@ -742,7 +740,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
sendBroadcast(intent);
setResult(RESULT_OK, intent);
}
- //声明监听器,建立菜单,包括名称,视图,删除操作,更改名称操作
+
private final OnCreateContextMenuListener mFolderOnCreateContextMenuListener = new OnCreateContextMenuListener() {
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
if (mFocusNoteDataItem != null) {
@@ -763,7 +761,6 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
}
@Override
- //针对menu中不同的选择进行不同的处理
public boolean onContextItemSelected(MenuItem item) {
if (mFocusNoteDataItem == null) {
Log.e(TAG, "The long click data item is null");
@@ -772,10 +769,8 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
switch (item.getItemId()) {
case MENU_FOLDER_VIEW:
openFolder(mFocusNoteDataItem);
- //打开对应文件
break;
case MENU_FOLDER_DELETE:
- //设置确认是否删除的对话框
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(getString(R.string.alert_title_delete));
builder.setIcon(android.R.drawable.ic_dialog_alert);
@@ -788,7 +783,6 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
});
builder.setNegativeButton(android.R.string.cancel, null);
builder.show();
- //显示对话框
break;
case MENU_FOLDER_CHANGE_NAME:
showCreateOrModifyFolderDialog(false);
@@ -803,25 +797,11 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
menu.clear();
- if (secret_mode == 1) {
- MenuItem secretMenuItem = menu.findItem(R.id.menu_secret);
- if (secretMenuItem != null) {
- secretMenuItem.setVisible(false);
- }
- } else {
- MenuItem quitSecretMenuItem = menu.findItem(R.id.menu_quit_secret);
- if (quitSecretMenuItem != null) {
- quitSecretMenuItem.setVisible(false);
- }
- }
-
if (mState == ListEditState.NOTE_LIST) {
getMenuInflater().inflate(R.menu.note_list, menu);
// set sync or sync_cancel
- MenuItem syncMenuItem = menu.findItem(R.id.menu_sync);
- if (syncMenuItem != null) {
- syncMenuItem.setTitle(GTaskSyncService.isSyncing() ? R.string.menu_sync_cancel : R.string.menu_sync); // 使用同步服务
- }
+ menu.findItem(R.id.menu_sync).setTitle(
+ GTaskSyncService.isSyncing() ? R.string.menu_sync_cancel : R.string.menu_sync);
} else if (mState == ListEditState.SUB_FOLDER) {
getMenuInflater().inflate(R.menu.sub_folder, menu);
} else if (mState == ListEditState.CALL_RECORD_FOLDER) {
@@ -832,52 +812,9 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
return true;
}
-
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- case R.id.menu_secret: { //进入私密模式
- secret_mode = 1;
- AlertDialog.Builder dialog = new AlertDialog.Builder(NotesListActivity.this);
- dialog.setTitle("重要提醒");
- dialog.setMessage("您确认进入私密模式吗?");
- dialog.setCancelable(false);
- dialog.setPositiveButton("确认", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- startAsyncNotesListQuery();
- Toast.makeText(NotesListActivity.this,"您已进入私密模式",Toast.LENGTH_SHORT).show();
- }
- });
- dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which){}
- });
- dialog.show();
- startAsyncNotesListQuery();
- Toast.makeText(this,"您已进入私密模式",Toast.LENGTH_SHORT).show();
- break;
- }
- case R.id.menu_quit_secret:{ //退出私密模式
- secret_mode = 0;
- AlertDialog.Builder dialog = new AlertDialog.Builder(NotesListActivity.this);
- dialog.setTitle("重要提醒");
- dialog.setMessage("您确认退出私密模式吗?");
- dialog.setCancelable(false);
- dialog.setPositiveButton("确认", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- startAsyncNotesListQuery();
- Toast.makeText(NotesListActivity.this,"您已退出私密模式",Toast.LENGTH_SHORT).show();
- }
- });
- dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which){}
- });
- dialog.show();
- break;
- }
case R.id.menu_new_folder: {
showCreateOrModifyFolderDialog(true);
break;
@@ -916,12 +853,11 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
}
@Override
- //直接调用startSearch函数
public boolean onSearchRequested() {
startSearch(null, false, null /* appData */, false);
return true;
}
- //实现将便签导出到文本功能
+
private void exportNoteToText() {
final BackupUtils backup = BackupUtils.getInstance(NotesListActivity.this);
new AsyncTask() {
@@ -963,17 +899,17 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
}.execute();
}
- //判断是否正在同步
+
private boolean isSyncMode() {
return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0;
}
- //跳转到PreferenceActivity界面
+
private void startPreferenceActivity() {
Activity from = getParent() != null ? getParent() : this;
Intent intent = new Intent(from, NotesPreferenceActivity.class);
from.startActivityIfNeeded(intent, -1);
}
- /* 列表内容点击事件 */
+
private class OnListItemClickListener implements OnItemClickListener {
public void onItemClick(AdapterView> parent, View view, int position, long id) {
@@ -1014,7 +950,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
}
}
- //查询目标文件
+
private void startQueryDestinationFolders() {
String selection = NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>? AND " + NoteColumns.ID + "<>?";
selection = (mState == ListEditState.NOTE_LIST) ? selection:
@@ -1032,11 +968,7 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
},
NoteColumns.MODIFIED_DATE + " DESC");
}
- //长按某一项时进行的操作
- /**
- * 长按的是便签,则通过ActionMode菜单实现;
- * 长按的是文件夹,则通过ContextMenu菜单实现;
- * */
+
public boolean onItemLongClick(AdapterView> parent, View view, int position, long id) {
if (view instanceof NotesListItem) {
mFocusNoteDataItem = ((NotesListItem) view).getItemData();
@@ -1053,4 +985,8 @@ public class NotesListActivity extends Activity implements OnClickListener, OnIt
}
return false;
}
+
+ public void OnOpenMenu(View view) {
+ openOptionsMenu();
+ }
}
diff --git a/app/src/main/java/net/micode/notes/ui/NotesListAdapter.java b/app/src/main/java/net/micode/notes/ui/NotesListAdapter.java
index 9090bf9..51c9cb9 100644
--- a/app/src/main/java/net/micode/notes/ui/NotesListAdapter.java
+++ b/app/src/main/java/net/micode/notes/ui/NotesListAdapter.java
@@ -30,64 +30,56 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
-/** 绑定数据库的数据到主界面列表里面的视图元素上,DONE */
+
public class NotesListAdapter extends CursorAdapter {
private static final String TAG = "NotesListAdapter";
private Context mContext;
private HashMap mSelectedIndex;
- private int mNotesCount;//便签数
- private boolean mChoiceMode;// 选择模式标记
- //桌面widget属性,ID,TYPE
+ private int mNotesCount;
+ private boolean mChoiceMode;
+
public static class AppWidgetAttribute {
public int widgetId;
public int widgetType;
};
- //初始化便签链接器
+
public NotesListAdapter(Context context) {
super(context, null);
- mSelectedIndex = new HashMap(); // 推测是多选用的
+ mSelectedIndex = new HashMap();
mContext = context;
mNotesCount = 0;
}
@Override
- //新建一个视图来存储光标所指向的数据
public View newView(Context context, Cursor cursor, ViewGroup parent) {
return new NotesListItem(context);
}
@Override
- //将已经存在的视图和鼠标指向的数据进行捆绑
public void bindView(View view, Context context, Cursor cursor) {
if (view instanceof NotesListItem) {
- //若view是NotesListItem的一个实例
NoteItemData itemData = new NoteItemData(context, cursor);
((NotesListItem) view).bind(context, itemData, mChoiceMode,
isSelectedItem(cursor.getPosition()));
- //则新建一个项目选项并且用bind跟将view和鼠标,内容,便签数据捆绑在一起
}
}
- //设置勾选框
+
public void setCheckedItem(final int position, final boolean checked) {
mSelectedIndex.put(position, checked);
- //根据定位和是否勾选设置下标
notifyDataSetChanged();
- //在修改后刷新activity
}
- //判断单选按钮是否勾选
+
public boolean isInChoiceMode() {
return mChoiceMode;
}
- //设置单项选项框
+
public void setChoiceMode(boolean mode) {
mSelectedIndex.clear();
mChoiceMode = mode;
}
- //设置全部选项
+
public void selectAll(boolean checked) {
Cursor cursor = getCursor();
- //获取光标位置
- //遍历所有光标可用的位置在判断为便签类型之后勾选单项框
for (int i = 0; i < getCount(); i++) {
if (cursor.moveToPosition(i)) {
if (NoteItemData.getNoteType(cursor) == Notes.TYPE_NOTE) {
@@ -96,36 +88,29 @@ public class NotesListAdapter extends CursorAdapter {
}
}
}
- //建立选择项的下标列表
+
public HashSet getSelectedItemIds() {
HashSet itemSet = new HashSet();
- //建立hash表
for (Integer position : mSelectedIndex.keySet()) {
- //遍历所有的关键
if (mSelectedIndex.get(position) == true) {
- //若光标位置可用
Long id = getItemId(position);
if (id == Notes.ID_ROOT_FOLDER) {
- //原文件不需要添加
Log.d(TAG, "Wrong item id, should not happen");
} else {
itemSet.add(id);
}
- //则将id该下标假如选项集合中
}
}
return itemSet;
}
- //建立桌面widget选项表
+
public HashSet getSelectedWidget() {
HashSet itemSet = new HashSet();
for (Integer position : mSelectedIndex.keySet()) {
if (mSelectedIndex.get(position) == true) {
Cursor c = (Cursor) getItem(position);
- //以上4句和getSelectedItemIds一样
if (c != null) {
- //光标位置可用的话就建立新的Widget属性并编辑下标和类型,最后添加到选项集中
AppWidgetAttribute widget = new AppWidgetAttribute();
NoteItemData item = new NoteItemData(mContext, c);
widget.widgetId = item.getWidgetId();
@@ -142,31 +127,27 @@ public class NotesListAdapter extends CursorAdapter {
}
return itemSet;
}
- //获取选项的个数
+
public int getSelectedCount() {
Collection values = mSelectedIndex.values();
- //首先获取选项下标的值
if (null == values) {
return 0;
}
Iterator iter = values.iterator();
- //初始化叠加器
int count = 0;
while (iter.hasNext()) {
if (true == iter.next()) {
- //若value值为真计数+1
count++;
}
}
return count;
}
- //判断是否全部勾选
+
public boolean isAllSelected() {
int checkedCount = getSelectedCount();
return (checkedCount != 0 && checkedCount == mNotesCount);
- //获取选项数看是否等于便签的个数
}
- //判断是否为选项表
+
public boolean isSelectedItem(final int position) {
if (null == mSelectedIndex.get(position)) {
return false;
@@ -175,36 +156,29 @@ public class NotesListAdapter extends CursorAdapter {
}
@Override
- //在activity内容发生局部变动的时候回调该函数计算便签的数量
protected void onContentChanged() {
super.onContentChanged();
- //执行基类函数
calcNotesCount();
}
@Override
- //在activity光标发生局部变动的时候回调该函数计算便签的数量
public void changeCursor(Cursor cursor) {
super.changeCursor(cursor);
- //执行基类函数
calcNotesCount();
}
- //计算便签个数
+
private void calcNotesCount() {
mNotesCount = 0;
for (int i = 0; i < getCount(); i++) {
- //获取总数同时遍历
Cursor c = (Cursor) getItem(i);
if (c != null) {
if (NoteItemData.getNoteType(c) == Notes.TYPE_NOTE) {
mNotesCount++;
- //若该位置不为空并且文本类型为便签就+1
}
} else {
Log.e(TAG, "Invalid cursor");
return;
}
- //否则报错
}
}
}
diff --git a/app/src/main/java/net/micode/notes/ui/NotesListItem.java b/app/src/main/java/net/micode/notes/ui/NotesListItem.java
index 40ea8ee..1221e80 100644
--- a/app/src/main/java/net/micode/notes/ui/NotesListItem.java
+++ b/app/src/main/java/net/micode/notes/ui/NotesListItem.java
@@ -29,43 +29,38 @@ import net.micode.notes.data.Notes;
import net.micode.notes.tool.DataUtils;
import net.micode.notes.tool.ResourceParser.NoteItemBgResources;
-/** 便签列表的单元素,视图类,DONE */
+
public class NotesListItem extends LinearLayout {
- private ImageView mAlert;//闹钟图片
- private TextView mTitle;//标题
- private TextView mTime;//时间
+ private ImageView mAlert;
+ private TextView mTitle;
+ private TextView mTime;
private TextView mCallName;
- private NoteItemData mItemData;//标签数据
- private CheckBox mCheckBox;//勾选框
- //初始化基本信息
+ private NoteItemData mItemData;
+ private CheckBox mCheckBox;
+
public NotesListItem(Context context) {
super(context);
inflate(context, R.layout.note_item, this);
- //inflate(膨胀): 可用于渲染一个xml中定义的布局控件
mAlert = (ImageView) findViewById(R.id.iv_alert_icon);
mTitle = (TextView) findViewById(R.id.tv_title);
mTime = (TextView) findViewById(R.id.tv_time);
mCallName = (TextView) findViewById(R.id.tv_name);
mCheckBox = (CheckBox) findViewById(android.R.id.checkbox);
- //findViewById用于从contentView中查找指定ID的View
}
- /** 将数据类NoteItemData绑定到本View上用于显示 */
+
public void bind(Context context, NoteItemData data, boolean choiceMode, boolean checked) {
if (choiceMode && data.getType() == Notes.TYPE_NOTE) {
- mCheckBox.setVisibility(View.VISIBLE);//设置可见
- mCheckBox.setChecked(checked);//勾选
+ mCheckBox.setVisibility(View.VISIBLE);
+ mCheckBox.setChecked(checked);
} else {
mCheckBox.setVisibility(View.GONE);
}
mItemData = data;
- //设置控件属性,根据data的id和父id是否与保存到文件夹的id一致来决定
if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) {
mCallName.setVisibility(View.GONE);
mAlert.setVisibility(View.VISIBLE);
- //设置该textview的style
mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem);
- //settext为设置内容
mTitle.setText(context.getString(R.string.call_record_folder_name)
+ context.getString(R.string.format_folder_files_count, data.getNotesCount()));
mAlert.setImageResource(R.drawable.call_record);
@@ -74,7 +69,6 @@ public class NotesListItem extends LinearLayout {
mCallName.setText(data.getCallName());
mTitle.setTextAppearance(context,R.style.TextAppearanceSecondaryItem);
mTitle.setText(DataUtils.getFormattedSnippet(data.getSnippet()));
- //关于闹钟的设置
if (data.hasAlert()) {
mAlert.setImageResource(R.drawable.clock);
mAlert.setVisibility(View.VISIBLE);
@@ -84,7 +78,7 @@ public class NotesListItem extends LinearLayout {
} else {
mCallName.setVisibility(View.GONE);
mTitle.setTextAppearance(context, R.style.TextAppearancePrimaryItem);
- //设置title格式
+
if (data.getType() == Notes.TYPE_FOLDER) {
mTitle.setText(data.getSnippet()
+ context.getString(R.string.format_folder_files_count,
@@ -100,27 +94,24 @@ public class NotesListItem extends LinearLayout {
}
}
}
- //设置内容,获取相关时间,从data里编辑的日期中获取
mTime.setText(DateUtils.getRelativeTimeSpanString(data.getModifiedDate()));
setBackground(data);
}
- /** 根据data的文件属性来设置背景 */
+
private void setBackground(NoteItemData data) {
int id = data.getBgColorId();
- //若是note型文件,则4种情况,对于4种不同情况的背景来源
if (data.getType() == Notes.TYPE_NOTE) {
- //单个数据并且只有一个子文件夹
if (data.isSingle() || data.isOneFollowingFolder()) {
setBackgroundResource(NoteItemBgResources.getNoteBgSingleRes(id));
- } else if (data.isLast()) {//是最后一个数据
+ } else if (data.isLast()) {
setBackgroundResource(NoteItemBgResources.getNoteBgLastRes(id));
- } else if (data.isFirst() || data.isMultiFollowingFolder()) {//是一个数据并有多个子文件夹
+ } else if (data.isFirst() || data.isMultiFollowingFolder()) {
setBackgroundResource(NoteItemBgResources.getNoteBgFirstRes(id));
} else {
setBackgroundResource(NoteItemBgResources.getNoteBgNormalRes(id));
}
- } else {//若不是note直接调用文件夹的来源
+ } else {
setBackgroundResource(NoteItemBgResources.getFolderBgRes());
}
}
diff --git a/app/src/main/java/net/micode/notes/ui/NotesPreferenceActivity.java b/app/src/main/java/net/micode/notes/ui/NotesPreferenceActivity.java
index 14fd7ac..07c5f7e 100644
--- a/app/src/main/java/net/micode/notes/ui/NotesPreferenceActivity.java
+++ b/app/src/main/java/net/micode/notes/ui/NotesPreferenceActivity.java
@@ -47,78 +47,66 @@ import net.micode.notes.data.Notes;
import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.gtask.remote.GTaskSyncService;
-/** 显示首选项界面的Activity */
+
public class NotesPreferenceActivity extends PreferenceActivity {
public static final String PREFERENCE_NAME = "notes_preferences";
- //优先名
+
public static final String PREFERENCE_SYNC_ACCOUNT_NAME = "pref_key_account_name";
- //同步账号
+
public static final String PREFERENCE_LAST_SYNC_TIME = "pref_last_sync_time";
- //同步时间
+
public static final String PREFERENCE_SET_BG_COLOR_KEY = "pref_key_bg_random_appear";
- //同步颜色
+
private static final String PREFERENCE_SYNC_ACCOUNT_KEY = "pref_sync_account_key";
- //同步密码
+
private static final String AUTHORITIES_FILTER_KEY = "authorities";
- //本地密码
+
private PreferenceCategory mAccountCategory;
- //账户分组
+
private GTaskReceiver mReceiver;
- //同步任务接收器
+
private Account[] mOriAccounts;
- //账户
+
private boolean mHasAddedAccount;
- //账户的hash标记
@Override
- //创建一个activity在函数里要完成设置
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
- //先执行父类的创建函数
+
/* using the app icon for navigation */
getActionBar().setDisplayHomeAsUpEnabled(true);
- //给左上角图标的左边加上一个返回的图标
+
addPreferencesFromResource(R.xml.preferences);
- //添加xml来源
mAccountCategory = (PreferenceCategory) findPreference(PREFERENCE_SYNC_ACCOUNT_KEY);
- //根据同步账户关键码来初始化分组
mReceiver = new GTaskReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction(GTaskSyncService.GTASK_SERVICE_BROADCAST_NAME);
registerReceiver(mReceiver, filter);
- //初始化同步组件
+
mOriAccounts = null;
View header = LayoutInflater.from(this).inflate(R.layout.settings_header, null);
- //获取listvivew,ListView的作用:用于列出所有选择
getListView().addHeaderView(header, null, true);
- //在listview组件上方添加其他组件
}
@Override
- //activity交互功能的实现,用于接受用户的输入
protected void onResume() {
super.onResume();
- //先执行父类交互实现
+
// need to set sync account automatically if user has added a new
// account
if (mHasAddedAccount) {
- //若用户新加了账户则自动设置同步账户
Account[] accounts = getGoogleAccounts();
- //获取google同步账户
if (mOriAccounts != null && accounts.length > mOriAccounts.length) {
- //若原账户不为空且当前账户有增加
for (Account accountNew : accounts) {
boolean found = false;
for (Account accountOld : mOriAccounts) {
if (TextUtils.equals(accountOld.name, accountNew.name)) {
- //更新账户
found = true;
break;
}
}
if (!found) {
setSyncAccount(accountNew.name);
- //若是没有找到旧的账户,那么同步账号中就只添加新账户
break;
}
}
@@ -126,45 +114,35 @@ public class NotesPreferenceActivity extends PreferenceActivity {
}
refreshUI();
- //刷新标签界面
}
@Override
- //删除一个activity
protected void onDestroy() {
if (mReceiver != null) {
unregisterReceiver(mReceiver);
- //注销接收器
}
super.onDestroy();
- //执行父类的销毁动作
}
- //重新设置账户的信息
+
private void loadAccountPreference() {
mAccountCategory.removeAll();
- //销毁所有的分组
+
Preference accountPref = new Preference(this);
- //建立首选项
final String defaultAccount = getSyncAccountName(this);
accountPref.setTitle(getString(R.string.preferences_account_title));
accountPref.setSummary(getString(R.string.preferences_account_summary));
- //设置首选项的大标题和小标题
accountPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
- //建立监听器
if (!GTaskSyncService.isSyncing()) {
if (TextUtils.isEmpty(defaultAccount)) {
// the first time to set account
- //若是第一次建立账户显示选择账户提示对话框
showSelectAccountAlertDialog();
} else {
// if the account has already been set, we need to promp
// user about the risk
- //若是已经建立则显示修改对话框并进行修改操作
showChangeAccountConfirmAlertDialog();
}
} else {
- //若在没有同步的情况下,则在toast中显示不能修改
Toast.makeText(NotesPreferenceActivity.this,
R.string.preferences_toast_cannot_change_account, Toast.LENGTH_SHORT)
.show();
@@ -173,25 +151,21 @@ public class NotesPreferenceActivity extends PreferenceActivity {
}
});
- //根据新建首选项编辑新的账户分组
mAccountCategory.addPreference(accountPref);
}
- //设置按键的状态和最后同步的时间
+
private void loadSyncButton() {
Button syncButton = (Button) findViewById(R.id.preference_sync_button);
TextView lastSyncTimeView = (TextView) findViewById(R.id.prefenerece_sync_status_textview);
- //获取同步按钮控件和最终同步时间的的窗口
+
// set button state
- //设置按钮的状态
if (GTaskSyncService.isSyncing()) {
- //若是在同步状态下
syncButton.setText(getString(R.string.preferences_button_sync_cancel));
syncButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
GTaskSyncService.cancelSync(NotesPreferenceActivity.this);
}
});
- //设置按钮显示的文本为“取消同步”以及监听器
} else {
syncButton.setText(getString(R.string.preferences_button_sync_immediately));
syncButton.setOnClickListener(new View.OnClickListener() {
@@ -199,60 +173,50 @@ public class NotesPreferenceActivity extends PreferenceActivity {
GTaskSyncService.startSync(NotesPreferenceActivity.this);
}
});
- //若是不同步则设置按钮显示的文本为“立即同步”以及对应监听器
}
syncButton.setEnabled(!TextUtils.isEmpty(getSyncAccountName(this)));
- //设置按键可用还是不可用
// set last sync time
- // 设置最终同步时间
if (GTaskSyncService.isSyncing()) {
- //若是在同步的情况下
lastSyncTimeView.setText(GTaskSyncService.getProgressString());
lastSyncTimeView.setVisibility(View.VISIBLE);
- //根据当前同步服务器设置时间显示框的文本以及可见性
} else {
- //若是非同步情况
long lastSyncTime = getLastSyncTime(this);
if (lastSyncTime != 0) {
lastSyncTimeView.setText(getString(R.string.preferences_last_sync_time,
DateFormat.format(getString(R.string.preferences_last_sync_time_format),
lastSyncTime)));
lastSyncTimeView.setVisibility(View.VISIBLE);
- //则根据最后同步时间的信息来编辑时间显示框的文本内容和可见性
} else {
- //若时间为空直接设置为不可见状态
lastSyncTimeView.setVisibility(View.GONE);
}
}
}
- //刷新标签界面
+
private void refreshUI() {
loadAccountPreference();
loadSyncButton();
}
- //显示账户选择的对话框并进行相关设置
+
private void showSelectAccountAlertDialog() {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
- //创建一个新的对话框
View titleView = LayoutInflater.from(this).inflate(R.layout.account_dialog_title, null);
TextView titleTextView = (TextView) titleView.findViewById(R.id.account_dialog_title);
titleTextView.setText(getString(R.string.preferences_dialog_select_account_title));
TextView subtitleTextView = (TextView) titleView.findViewById(R.id.account_dialog_subtitle);
subtitleTextView.setText(getString(R.string.preferences_dialog_select_account_tips));
- //设置标题以及子标题的内容
+
dialogBuilder.setCustomTitle(titleView);
dialogBuilder.setPositiveButton(null, null);
- //设置对话框的自定义标题,建立一个YES的按钮
+
Account[] accounts = getGoogleAccounts();
String defAccount = getSyncAccountName(this);
- //获取同步账户信息
+
mOriAccounts = accounts;
mHasAddedAccount = false;
if (accounts.length > 0) {
- //若账户不为空
CharSequence[] items = new CharSequence[accounts.length];
final CharSequence[] itemMapping = items;
int checkedItem = -1;
@@ -260,107 +224,83 @@ public class NotesPreferenceActivity extends PreferenceActivity {
for (Account account : accounts) {
if (TextUtils.equals(account.name, defAccount)) {
checkedItem = index;
- //在账户列表中查询到所需账户
}
items[index++] = account.name;
}
dialogBuilder.setSingleChoiceItems(items, checkedItem,
- //在对话框建立一个单选的复选框
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
setSyncAccount(itemMapping[which].toString());
dialog.dismiss();
- //取消对话框
refreshUI();
}
- //设置点击后执行的事件,包括检录新同步账户和刷新标签界面
});
- //建立对话框网络版的监听器
}
View addAccountView = LayoutInflater.from(this).inflate(R.layout.add_account_text, null);
dialogBuilder.setView(addAccountView);
- //给新加账户对话框设置自定义样式
final AlertDialog dialog = dialogBuilder.show();
- //显示对话框
addAccountView.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mHasAddedAccount = true;
- //将新加账户的hash置true
Intent intent = new Intent("android.settings.ADD_ACCOUNT_SETTINGS");
- //建立网络建立组件
intent.putExtra(AUTHORITIES_FILTER_KEY, new String[] {
"gmail-ls"
});
startActivityForResult(intent, -1);
- //跳回上一个选项
dialog.dismiss();
}
});
- //建立新加账户对话框的监听器
}
- //显示账户选择对话框以及相关操作
+
private void showChangeAccountConfirmAlertDialog() {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
- //创建一个新的对话框
+
View titleView = LayoutInflater.from(this).inflate(R.layout.account_dialog_title, null);
TextView titleTextView = (TextView) titleView.findViewById(R.id.account_dialog_title);
titleTextView.setText(getString(R.string.preferences_dialog_change_account_title,
getSyncAccountName(this)));
TextView subtitleTextView = (TextView) titleView.findViewById(R.id.account_dialog_subtitle);
subtitleTextView.setText(getString(R.string.preferences_dialog_change_account_warn_msg));
- //根据同步修改的账户信息设置标题以及子标题的内容
dialogBuilder.setCustomTitle(titleView);
- //设置对话框的自定义标题
+
CharSequence[] menuItemArray = new CharSequence[] {
getString(R.string.preferences_menu_change_account),
getString(R.string.preferences_menu_remove_account),
getString(R.string.preferences_menu_cancel)
};
- //定义一些标记字符串
dialogBuilder.setItems(menuItemArray, new DialogInterface.OnClickListener() {
- //设置对话框要显示的一个list,用于显示几个命令时,即change,remove,cancel
public void onClick(DialogInterface dialog, int which) {
- //按键功能,由which来决定
if (which == 0) {
- //进入账户选择对话框
showSelectAccountAlertDialog();
} else if (which == 1) {
- //删除账户并且跟新便签界面
removeSyncAccount();
refreshUI();
}
}
});
dialogBuilder.show();
- //显示对话框
}
- //获取Google账户
+
private Account[] getGoogleAccounts() {
AccountManager accountManager = AccountManager.get(this);
return accountManager.getAccountsByType("com.google");
}
- //设置同步账户
+
private void setSyncAccount(String account) {
if (!getSyncAccountName(this).equals(account)) {
- //假如该账号不在同步账号列表中
SharedPreferences settings = getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
- //编辑共享的首选项
if (account != null) {
editor.putString(PREFERENCE_SYNC_ACCOUNT_NAME, account);
} else {
editor.putString(PREFERENCE_SYNC_ACCOUNT_NAME, "");
}
- //将该账号加入到首选项中
-
editor.commit();
- //提交修改的数据
-
+ // clean up last sync time
setLastSyncTime(this, 0);
- //将最后同步时间清零
// clean up local gtask related info
new Thread(new Runnable() {
@@ -371,31 +311,24 @@ public class NotesPreferenceActivity extends PreferenceActivity {
getContentResolver().update(Notes.CONTENT_NOTE_URI, values, null, null);
}
}).start();
- //重置当地同步任务的信息
Toast.makeText(NotesPreferenceActivity.this,
getString(R.string.preferences_toast_success_set_accout, account),
Toast.LENGTH_SHORT).show();
- //将toast的文本信息置为“设置账户成功”并显示出来
}
}
- //删除同步账户
+
private void removeSyncAccount() {
SharedPreferences settings = getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
- //设置共享首选项
-
if (settings.contains(PREFERENCE_SYNC_ACCOUNT_NAME)) {
editor.remove(PREFERENCE_SYNC_ACCOUNT_NAME);
- //假如当前首选项中有账户就删除
}
if (settings.contains(PREFERENCE_LAST_SYNC_TIME)) {
editor.remove(PREFERENCE_LAST_SYNC_TIME);
- //删除当前首选项中有账户时间
}
editor.commit();
- //提交更新后的数据
-
+
// clean up local gtask related info
new Thread(new Runnable() {
public void run() {
@@ -405,56 +338,49 @@ public class NotesPreferenceActivity extends PreferenceActivity {
getContentResolver().update(Notes.CONTENT_NOTE_URI, values, null, null);
}
}).start();
- //重置当地同步任务的信息
}
- //获取同步账户名
+
public static String getSyncAccountName(Context context) {
SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME,
Context.MODE_PRIVATE);
return settings.getString(PREFERENCE_SYNC_ACCOUNT_NAME, "");
}
- //设置最终同步时间
+
public static void setLastSyncTime(Context context, long time) {
SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME,
Context.MODE_PRIVATE);
SharedPreferences.Editor editor = settings.edit();
- // 从共享首选项中找到相关账户并获取其编辑器
editor.putLong(PREFERENCE_LAST_SYNC_TIME, time);
editor.commit();
- //编辑最终同步时间并提交更新
}
- //获取最终同步时间
+
public static long getLastSyncTime(Context context) {
SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME,
Context.MODE_PRIVATE);
return settings.getLong(PREFERENCE_LAST_SYNC_TIME, 0);
}
- //接收同步信息
+
private class GTaskReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
refreshUI();
if (intent.getBooleanExtra(GTaskSyncService.GTASK_SERVICE_BROADCAST_IS_SYNCING, false)) {
- //获取随广播而来的Intent中的同步服务的数据
TextView syncStatus = (TextView) findViewById(R.id.prefenerece_sync_status_textview);
syncStatus.setText(intent
.getStringExtra(GTaskSyncService.GTASK_SERVICE_BROADCAST_PROGRESS_MSG));
- //通过获取的数据在设置系统的状态
}
}
}
- //处理菜单选项
+
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
- //根据选项的id选择,这里只有一个主页
case android.R.id.home:
Intent intent = new Intent(this, NotesListActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
return true;
- //在主页情况下在创建连接组件intent,发出清空的信号并开始一个相应的activity
default:
return false;
}
diff --git a/app/src/main/java/net/micode/notes/ui/ui.plantuml b/app/src/main/java/net/micode/notes/ui/ui.plantuml
deleted file mode 100644
index 2f10be5..0000000
--- a/app/src/main/java/net/micode/notes/ui/ui.plantuml
+++ /dev/null
@@ -1,631 +0,0 @@
-@startuml
-
-title __UI's Class Diagram__\n
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.AlarmAlertActivity {
- ~ mPlayer : MediaPlayer
- {static} - SNIPPET_PREW_MAX_LEN : int
- - mNoteId : long
- - mSnippet : String
- + onClick()
- + onDismiss()
- # onCreate()
- - isScreenOn()
- - playAlarmSound()
- - showActionDialog()
- - stopAlarmSound()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.AlarmInitReceiver {
- {static} - COLUMN_ALERTED_DATE : int
- {static} - COLUMN_ID : int
- {static} - PROJECTION : String[]
- + onReceive()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.AlarmReceiver {
- + onReceive()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.DateTimePicker {
- {static} - AMPM_SPINNER_MAX_VAL : int
- {static} - AMPM_SPINNER_MIN_VAL : int
- {static} - DATE_SPINNER_MAX_VAL : int
- {static} - DATE_SPINNER_MIN_VAL : int
- {static} - DAYS_IN_ALL_WEEK : int
- {static} - DEFAULT_ENABLE_STATE : boolean
- {static} - HOURS_IN_ALL_DAY : int
- {static} - HOURS_IN_HALF_DAY : int
- {static} - HOUR_SPINNER_MAX_VAL_12_HOUR_VIEW : int
- {static} - HOUR_SPINNER_MAX_VAL_24_HOUR_VIEW : int
- {static} - HOUR_SPINNER_MIN_VAL_12_HOUR_VIEW : int
- {static} - HOUR_SPINNER_MIN_VAL_24_HOUR_VIEW : int
- {static} - MINUT_SPINNER_MAX_VAL : int
- {static} - MINUT_SPINNER_MIN_VAL : int
- - mAmPmSpinner : NumberPicker
- - mDate : Calendar
- - mDateDisplayValues : String[]
- - mDateSpinner : NumberPicker
- - mHourSpinner : NumberPicker
- - mInitialising : boolean
- - mIs24HourView : boolean
- - mIsAm : boolean
- - mIsEnabled : boolean
- - mMinuteSpinner : NumberPicker
- - mOnAmPmChangedListener : OnValueChangeListener
- - mOnDateChangedListener : OnValueChangeListener
- - mOnHourChangedListener : OnValueChangeListener
- - mOnMinuteChangedListener : OnValueChangeListener
- + DateTimePicker()
- + DateTimePicker()
- + DateTimePicker()
- + getCurrentDateInTimeMillis()
- + getCurrentDay()
- + getCurrentHourOfDay()
- + getCurrentMinute()
- + getCurrentMonth()
- + getCurrentYear()
- + is24HourView()
- + isEnabled()
- + set24HourView()
- + setCurrentDate()
- + setCurrentDate()
- + setCurrentDay()
- + setCurrentHour()
- + setCurrentMinute()
- + setCurrentMonth()
- + setCurrentYear()
- + setEnabled()
- + setOnDateTimeChangedListener()
- - getCurrentHour()
- - onDateTimeChanged()
- - updateAmPmControl()
- - updateDateControl()
- - updateHourControl()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- interface net.micode.notes.ui.DateTimePicker.OnDateTimeChangedListener {
- {abstract} + onDateTimeChanged()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.DateTimePickerDialog {
- - mDate : Calendar
- - mIs24HourView : boolean
- + DateTimePickerDialog()
- + onClick()
- + set24HourView()
- + setOnDateTimeSetListener()
- - updateTitle()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- interface net.micode.notes.ui.DateTimePickerDialog.OnDateTimeSetListener {
- {abstract} + OnDateTimeSet()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.DropdownMenu {
- - mButton : Button
- - mMenu : Menu
- - mPopupMenu : PopupMenu
- + DropdownMenu()
- + findItem()
- + setOnDropdownMenuItemClickListener()
- + setTitle()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.FoldersListAdapter {
- {static} + ID_COLUMN : int
- {static} + NAME_COLUMN : int
- {static} + PROJECTION : String[]
- + FoldersListAdapter()
- + bindView()
- + getFolderName()
- + newView()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.FoldersListAdapter.FolderListItem {
- - mName : TextView
- + FolderListItem()
- + bind()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.NoteEditActivity {
- {static} + TAG_CHECKED : String
- {static} + TAG_UNCHECKED : String
- {static} - PREFERENCE_FONT_SIZE : String
- {static} - SHORTCUT_ICON_TITLE_MAX_LEN : int
- {static} - TAG : String
- - mEditTextList : LinearLayout
- - mFontSizeId : int
- - mFontSizeSelector : View
- - mHeadViewPanel : View
- - mNoteBgColorSelector : View
- - mNoteEditor : EditText
- - mNoteEditorPanel : View
- - mPattern : Pattern
- - mSharedPrefs : SharedPreferences
- - mUserQuery : String
- {static} - sBgSelectorBtnsMap : Map
- {static} - sBgSelectorSelectionMap : Map
- {static} - sFontSelectorSelectionMap : Map
- {static} - sFontSizeBtnsMap : Map
- + dispatchTouchEvent()
- + onBackPressed()
- + onBackgroundColorChanged()
- + onCheckListModeChanged()
- + onClick()
- + onClockAlertChanged()
- + onEditTextDelete()
- + onEditTextEnter()
- + onOptionsItemSelected()
- + onPrepareOptionsMenu()
- + onTextChange()
- + onWidgetChanged()
- # onCreate()
- # onNewIntent()
- # onPause()
- # onRestoreInstanceState()
- # onResume()
- # onSaveInstanceState()
- - clearSettingState()
- - createNewNote()
- - deleteCurrentNote()
- - getHighlightQueryResult()
- - getListItem()
- - getWorkingText()
- - inRangeOfView()
- - initActivityState()
- - initNoteScreen()
- - initResources()
- - isSyncMode()
- - makeShortcutIconTitle()
- - saveNote()
- - sendTo()
- - sendToDesktop()
- - setReminder()
- - showAlertHeader()
- - showToast()
- - showToast()
- - switchToListMode()
- - updateWidget()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.NoteEditActivity.HeadViewHolder {
- + ibSetBgColor : ImageView
- + ivAlertIcon : ImageView
- + tvAlertDate : TextView
- + tvModified : TextView
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.NoteEditText {
- {static} - SCHEME_EMAIL : String
- {static} - SCHEME_HTTP : String
- {static} - SCHEME_TEL : String
- {static} - TAG : String
- - mIndex : int
- - mSelectionStartBeforeDelete : int
- {static} - sSchemaActionResMap : Map
- + NoteEditText()
- + NoteEditText()
- + NoteEditText()
- + onKeyDown()
- + onKeyUp()
- + onTouchEvent()
- + setIndex()
- + setOnTextViewChangeListener()
- # onCreateContextMenu()
- # onFocusChanged()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- interface net.micode.notes.ui.NoteEditText.OnTextViewChangeListener {
- {abstract} + onEditTextDelete()
- {abstract} + onEditTextEnter()
- {abstract} + onTextChange()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.NoteItemData {
- {static} ~ PROJECTION : String[]
- {static} - ALERTED_DATE_COLUMN : int
- {static} - BG_COLOR_ID_COLUMN : int
- {static} - CREATED_DATE_COLUMN : int
- {static} - HAS_ATTACHMENT_COLUMN : int
- {static} - ID_COLUMN : int
- {static} - MODIFIED_DATE_COLUMN : int
- {static} - NOTES_COUNT_COLUMN : int
- {static} - PARENT_ID_COLUMN : int
- {static} - SNIPPET_COLUMN : int
- {static} - TYPE_COLUMN : int
- {static} - WIDGET_ID_COLUMN : int
- {static} - WIDGET_TYPE_COLUMN : int
- - mAlertDate : long
- - mBgColorId : int
- - mCreatedDate : long
- - mHasAttachment : boolean
- - mId : long
- - mIsFirstItem : boolean
- - mIsLastItem : boolean
- - mIsMultiNotesFollowingFolder : boolean
- - mIsOneNoteFollowingFolder : boolean
- - mIsOnlyOneItem : boolean
- - mModifiedDate : long
- - mName : String
- - mNotesCount : int
- - mParentId : long
- - mPhoneNumber : String
- - mSnippet : String
- - mType : int
- - mWidgetId : int
- - mWidgetType : int
- + NoteItemData()
- + getAlertDate()
- + getBgColorId()
- + getCallName()
- + getCreatedDate()
- + getFolderId()
- + getId()
- + getModifiedDate()
- {static} + getNoteType()
- + getNotesCount()
- + getParentId()
- + getSnippet()
- + getType()
- + getWidgetId()
- + getWidgetType()
- + hasAlert()
- + hasAttachment()
- + isCallRecord()
- + isFirst()
- + isLast()
- + isMultiFollowingFolder()
- + isOneFollowingFolder()
- + isSingle()
- - checkPostion()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.NotesListActivity {
- {static} + NOTES_LISTVIEW_SCROLL_RATE : int
- {static} - FOLDER_LIST_QUERY_TOKEN : int
- {static} - FOLDER_NOTE_LIST_QUERY_TOKEN : int
- {static} - MENU_FOLDER_CHANGE_NAME : int
- {static} - MENU_FOLDER_DELETE : int
- {static} - MENU_FOLDER_VIEW : int
- {static} - NORMAL_SELECTION : String
- {static} - PREFERENCE_ADD_INTRODUCTION : String
- {static} - REQUEST_CODE_NEW_NODE : int
- {static} - REQUEST_CODE_OPEN_NODE : int
- {static} - ROOT_FOLDER_SELECTION : String
- {static} - TAG : String
- - mAddNewNote : Button
- - mContentResolver : ContentResolver
- - mCurrentFolderId : long
- - mDispatch : boolean
- - mDispatchY : int
- - mFolderOnCreateContextMenuListener : OnCreateContextMenuListener
- - mNotesListView : ListView
- - mOriginY : int
- - mTitleBar : TextView
- + onBackPressed()
- + onClick()
- + onContextItemSelected()
- + onContextMenuClosed()
- + onItemLongClick()
- + onOptionsItemSelected()
- + onPrepareOptionsMenu()
- + onSearchRequested()
- # onActivityResult()
- # onCreate()
- # onStart()
- - batchDelete()
- - createNewNote()
- - deleteFolder()
- - exportNoteToText()
- - hideSoftInput()
- - initResources()
- - isSyncMode()
- - openFolder()
- - openNode()
- - setAppInfoFromRawRes()
- - showCreateOrModifyFolderDialog()
- - showFolderListMenu()
- - showSoftInput()
- - startAsyncNotesListQuery()
- - startPreferenceActivity()
- - startQueryDestinationFolders()
- - updateWidget()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.NotesListActivity.BackgroundQueryHandler {
- + BackgroundQueryHandler()
- # onQueryComplete()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- enum ListEditState {
- CALL_RECORD_FOLDER
- NOTE_LIST
- SUB_FOLDER
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.NotesListActivity.ModeCallback {
- - mActionMode : ActionMode
- - mMoveMenu : MenuItem
- + finishActionMode()
- + onActionItemClicked()
- + onCreateActionMode()
- + onDestroyActionMode()
- + onItemCheckedStateChanged()
- + onMenuItemClick()
- + onPrepareActionMode()
- - updateMenu()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.NotesListActivity.NewNoteOnTouchListener {
- + onTouch()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.NotesListActivity.OnListItemClickListener {
- + onItemClick()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.NotesListAdapter {
- {static} - TAG : String
- - mChoiceMode : boolean
- - mContext : Context
- - mNotesCount : int
- - mSelectedIndex : HashMap
- + NotesListAdapter()
- + bindView()
- + changeCursor()
- + getSelectedCount()
- + getSelectedItemIds()
- + getSelectedWidget()
- + isAllSelected()
- + isInChoiceMode()
- + isSelectedItem()
- + newView()
- + selectAll()
- + setCheckedItem()
- + setChoiceMode()
- # onContentChanged()
- - calcNotesCount()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.NotesListAdapter.AppWidgetAttribute {
- + widgetId : int
- + widgetType : int
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.NotesListItem {
- - mAlert : ImageView
- - mCallName : TextView
- - mCheckBox : CheckBox
- - mTime : TextView
- - mTitle : TextView
- + NotesListItem()
- + bind()
- + getItemData()
- - setBackground()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.NotesPreferenceActivity {
- {static} + PREFERENCE_LAST_SYNC_TIME : String
- {static} + PREFERENCE_NAME : String
- {static} + PREFERENCE_SET_BG_COLOR_KEY : String
- {static} + PREFERENCE_SYNC_ACCOUNT_NAME : String
- {static} - AUTHORITIES_FILTER_KEY : String
- {static} - PREFERENCE_SYNC_ACCOUNT_KEY : String
- - mAccountCategory : PreferenceCategory
- - mHasAddedAccount : boolean
- - mOriAccounts : Account[]
- {static} + getLastSyncTime()
- {static} + getSyncAccountName()
- + onOptionsItemSelected()
- {static} + setLastSyncTime()
- # onCreate()
- # onDestroy()
- # onResume()
- - getGoogleAccounts()
- - loadAccountPreference()
- - loadSyncButton()
- - refreshUI()
- - removeSyncAccount()
- - setSyncAccount()
- - showChangeAccountConfirmAlertDialog()
- - showSelectAccountAlertDialog()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace ui {
- class net.micode.notes.ui.NotesPreferenceActivity.GTaskReceiver {
- + onReceive()
- }
- }
- }
-
-
- net.micode.notes.ui.AlarmAlertActivity .up.|> android.content.DialogInterface.OnClickListener
- net.micode.notes.ui.AlarmAlertActivity .up.|> android.content.DialogInterface.OnDismissListener
- net.micode.notes.ui.AlarmAlertActivity -up-|> android.app.Activity
- net.micode.notes.ui.AlarmInitReceiver -up-|> android.content.BroadcastReceiver
- net.micode.notes.ui.AlarmReceiver -up-|> android.content.BroadcastReceiver
- net.micode.notes.ui.DateTimePicker -up-|> android.widget.FrameLayout
- net.micode.notes.ui.DateTimePicker o-- net.micode.notes.ui.DateTimePicker.OnDateTimeChangedListener : mOnDateTimeChangedListener
- net.micode.notes.ui.DateTimePicker +-down- net.micode.notes.ui.DateTimePicker.OnDateTimeChangedListener
- net.micode.notes.ui.DateTimePickerDialog .up.|> android.content.DialogInterface.OnClickListener
- net.micode.notes.ui.DateTimePickerDialog -up-|> android.app.AlertDialog
- net.micode.notes.ui.DateTimePickerDialog o-- net.micode.notes.ui.DateTimePicker : mDateTimePicker
- net.micode.notes.ui.DateTimePickerDialog o-- net.micode.notes.ui.DateTimePickerDialog.OnDateTimeSetListener : mOnDateTimeSetListener
- net.micode.notes.ui.DateTimePickerDialog +-down- net.micode.notes.ui.DateTimePickerDialog.OnDateTimeSetListener
- net.micode.notes.ui.FoldersListAdapter -up-|> android.widget.CursorAdapter
- net.micode.notes.ui.FoldersListAdapter +-down- net.micode.notes.ui.FoldersListAdapter.FolderListItem
- net.micode.notes.ui.FoldersListAdapter.FolderListItem -up-|> android.widget.LinearLayout
- net.micode.notes.ui.NoteEditActivity .up.|> android.view.View.OnClickListener
- net.micode.notes.ui.NoteEditActivity .up.|> net.micode.notes.model.WorkingNote.NoteSettingChangedListener
- net.micode.notes.ui.NoteEditActivity .up.|> net.micode.notes.ui.NoteEditText.OnTextViewChangeListener
- net.micode.notes.ui.NoteEditActivity -up-|> android.app.Activity
- net.micode.notes.ui.NoteEditActivity o-- net.micode.notes.ui.NoteEditActivity.HeadViewHolder : mNoteHeaderHolder
- net.micode.notes.ui.NoteEditActivity o-- net.micode.notes.model.WorkingNote : mWorkingNote
- net.micode.notes.ui.NoteEditActivity +-down- net.micode.notes.ui.NoteEditActivity.HeadViewHolder
- net.micode.notes.ui.NoteEditText -up-|> android.widget.EditText
- net.micode.notes.ui.NoteEditText o-- net.micode.notes.ui.NoteEditText.OnTextViewChangeListener : mOnTextViewChangeListener
- net.micode.notes.ui.NoteEditText +-down- net.micode.notes.ui.NoteEditText.OnTextViewChangeListener
- net.micode.notes.ui.NotesListActivity .up.|> android.view.View.OnClickListener
- net.micode.notes.ui.NotesListActivity .up.|> android.widget.AdapterView.OnItemLongClickListener
- net.micode.notes.ui.NotesListActivity -up-|> android.app.Activity
- net.micode.notes.ui.NotesListActivity o-- net.micode.notes.ui.NotesListActivity.BackgroundQueryHandler : mBackgroundQueryHandler
- net.micode.notes.ui.NotesListActivity o-- net.micode.notes.ui.NoteItemData : mFocusNoteDataItem
- net.micode.notes.ui.NotesListActivity o-- net.micode.notes.ui.NotesListActivity.ModeCallback : mModeCallBack
- net.micode.notes.ui.NotesListActivity o-- net.micode.notes.ui.NotesListAdapter : mNotesListAdapter
- net.micode.notes.ui.NotesListActivity o-- net.micode.notes.ui.NotesListActivity.ListEditState : mState
- net.micode.notes.ui.NotesListActivity +-down- net.micode.notes.ui.NotesListActivity.BackgroundQueryHandler
- net.micode.notes.ui.NotesListActivity +-down- net.micode.notes.ui.NotesListActivity.ListEditState
- net.micode.notes.ui.NotesListActivity +-down- net.micode.notes.ui.NotesListActivity.ModeCallback
- net.micode.notes.ui.NotesListActivity +-down- net.micode.notes.ui.NotesListActivity.NewNoteOnTouchListener
- net.micode.notes.ui.NotesListActivity +-down- net.micode.notes.ui.NotesListActivity.OnListItemClickListener
- net.micode.notes.ui.NotesListActivity.BackgroundQueryHandler -up-|> android.content.AsyncQueryHandler
- net.micode.notes.ui.NotesListActivity.ModeCallback .up.|> android.view.MenuItem.OnMenuItemClickListener
- net.micode.notes.ui.NotesListActivity.ModeCallback .up.|> android.widget.AbsListView.MultiChoiceModeListener
- net.micode.notes.ui.NotesListActivity.ModeCallback o-- net.micode.notes.ui.DropdownMenu : mDropDownMenu
- net.micode.notes.ui.NotesListActivity.NewNoteOnTouchListener .up.|> android.view.View.OnTouchListener
- net.micode.notes.ui.NotesListActivity.OnListItemClickListener .up.|> android.widget.AdapterView.OnItemClickListener
- net.micode.notes.ui.NotesListAdapter -up-|> android.widget.CursorAdapter
- net.micode.notes.ui.NotesListAdapter +-down- net.micode.notes.ui.NotesListAdapter.AppWidgetAttribute
- net.micode.notes.ui.NotesListItem -up-|> android.widget.LinearLayout
- net.micode.notes.ui.NotesListItem o-- net.micode.notes.ui.NoteItemData : mItemData
- net.micode.notes.ui.NotesPreferenceActivity -up-|> android.preference.PreferenceActivity
- net.micode.notes.ui.NotesPreferenceActivity o-- net.micode.notes.ui.NotesPreferenceActivity.GTaskReceiver : mReceiver
- net.micode.notes.ui.NotesPreferenceActivity +-down- net.micode.notes.ui.NotesPreferenceActivity.GTaskReceiver
- net.micode.notes.ui.NotesPreferenceActivity.GTaskReceiver -up-|> android.content.BroadcastReceiver
-
-
-right footer
-
-
-PlantUML diagram generated by SketchIt! (https://bitbucket.org/pmesmeur/sketch.it)
-For more information about this tool, please contact philippe.mesmeur@gmail.com
-endfooter
-
-@enduml
diff --git a/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider.java b/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider.java
index 4d78e78..ec6f819 100644
--- a/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider.java
+++ b/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider.java
@@ -32,9 +32,6 @@ import net.micode.notes.tool.ResourceParser;
import net.micode.notes.ui.NoteEditActivity;
import net.micode.notes.ui.NotesListActivity;
-/**
- * 继承自AppWidgetProvider类,创建桌面小部件
- */
public abstract class NoteWidgetProvider extends AppWidgetProvider {
public static final String [] PROJECTION = new String [] {
NoteColumns.ID,
diff --git a/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider_2x.java b/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider_2x.java
index a70cefc..adcb2f7 100644
--- a/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider_2x.java
+++ b/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider_2x.java
@@ -23,9 +23,7 @@ import net.micode.notes.R;
import net.micode.notes.data.Notes;
import net.micode.notes.tool.ResourceParser;
-/**
- * 2X2桌面小部件
- */
+
public class NoteWidgetProvider_2x extends NoteWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
diff --git a/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider_4x.java b/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider_4x.java
index b3777b2..c12a02e 100644
--- a/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider_4x.java
+++ b/app/src/main/java/net/micode/notes/widget/NoteWidgetProvider_4x.java
@@ -23,9 +23,7 @@ import net.micode.notes.R;
import net.micode.notes.data.Notes;
import net.micode.notes.tool.ResourceParser;
-/**
- * 4X4桌面小部件
- */
+
public class NoteWidgetProvider_4x extends NoteWidgetProvider {
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
diff --git a/app/src/main/java/net/micode/notes/widget/widget.plantuml b/app/src/main/java/net/micode/notes/widget/widget.plantuml
deleted file mode 100644
index 74f43c6..0000000
--- a/app/src/main/java/net/micode/notes/widget/widget.plantuml
+++ /dev/null
@@ -1,61 +0,0 @@
-@startuml
-
-title __WIDGET's Class Diagram__\n
-
- namespace net.micode.notes {
- namespace widget {
- abstract class net.micode.notes.widget.NoteWidgetProvider {
- {static} + COLUMN_BG_COLOR_ID : int
- {static} + COLUMN_ID : int
- {static} + COLUMN_SNIPPET : int
- {static} + PROJECTION : String[]
- {static} - TAG : String
- + onDeleted()
- {abstract} # getBgResourceId()
- {abstract} # getLayoutId()
- {abstract} # getWidgetType()
- # update()
- - getNoteWidgetInfo()
- - update()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace widget {
- class net.micode.notes.widget.NoteWidgetProvider_2x {
- + onUpdate()
- # getBgResourceId()
- # getLayoutId()
- # getWidgetType()
- }
- }
- }
-
-
- namespace net.micode.notes {
- namespace widget {
- class net.micode.notes.widget.NoteWidgetProvider_4x {
- + onUpdate()
- # getBgResourceId()
- # getLayoutId()
- # getWidgetType()
- }
- }
- }
-
-
- net.micode.notes.widget.NoteWidgetProvider -up-|> android.appwidget.AppWidgetProvider
- net.micode.notes.widget.NoteWidgetProvider_2x -up-|> net.micode.notes.widget.NoteWidgetProvider
- net.micode.notes.widget.NoteWidgetProvider_4x -up-|> net.micode.notes.widget.NoteWidgetProvider
-
-
-right footer
-
-
-PlantUML diagram generated by SketchIt! (https://bitbucket.org/pmesmeur/sketch.it)
-For more information about this tool, please contact philippe.mesmeur@gmail.com
-endfooter
-
-@enduml
diff --git a/app/src/main/res/color/primary_text_dark.xml b/app/src/main/res/color/primary_text_dark.xml
index 7c85459..8ad98e3 100644
--- a/app/src/main/res/color/primary_text_dark.xml
+++ b/app/src/main/res/color/primary_text_dark.xml
@@ -1,4 +1,4 @@
-
+
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index c1eddb2..d750e65 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -63,6 +63,7 @@
\ No newline at end of file
diff --git a/app/src/test/java/net/micode/notes/ExampleUnitTest.java b/app/src/test/java/net/micode/notes/ExampleUnitTest.java
deleted file mode 100644
index 296adc2..0000000
--- a/app/src/test/java/net/micode/notes/ExampleUnitTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package net.micode.notes;
-
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * Example local unit test, which will execute on the development machine (host).
- *
- * @see Testing documentation
- */
-public class ExampleUnitTest {
- @Test
- public void addition_isCorrect() {
- assertEquals(4, 2 + 2);
- }
-}
\ No newline at end of file
diff --git a/app/src/test/java/net/micode/notes/notes.plantuml b/app/src/test/java/net/micode/notes/notes.plantuml
deleted file mode 100644
index a6dfacb..0000000
--- a/app/src/test/java/net/micode/notes/notes.plantuml
+++ /dev/null
@@ -1,14 +0,0 @@
-@startuml
-
-title __NOTES's Class Diagram__\n
-
-
-
-right footer
-
-
-PlantUML diagram generated by SketchIt! (https://bitbucket.org/pmesmeur/sketch.it)
-For more information about this tool, please contact philippe.mesmeur@gmail.com
-endfooter
-
-@enduml
diff --git a/assets/c.jpg b/assets/c.jpg
deleted file mode 100644
index f7e0726..0000000
Binary files a/assets/c.jpg and /dev/null differ
diff --git a/build.gradle b/build.gradle
index 3dada64..0e6d3a1 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,16 +1,25 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
- google()
- mavenCentral()
+ maven { url 'https://maven.aliyun.com/repository/central' }
+ maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
+ maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
+ maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' }
+ maven { url 'https://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
+ jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:7.0.4'
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
+ classpath 'com.android.tools.build:gradle:4.2.1'
}
}
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
\ No newline at end of file
+allprojects {
+ repositories {
+ maven { url 'https://maven.aliyun.com/repository/central' }
+ maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
+ maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
+ maven { url 'https://maven.aliyun.com/nexus/content/repositories/google' }
+ maven { url 'https://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
+ jcenter()
+ }
+}
diff --git a/drawio/1-5-1功能层次图.drawio b/drawio/1-5-1功能层次图.drawio
deleted file mode 100644
index a8bd562..0000000
--- a/drawio/1-5-1功能层次图.drawio
+++ /dev/null
@@ -1,202 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/drawio/1-5-1功能层次图.png b/drawio/1-5-1功能层次图.png
deleted file mode 100644
index 230be6c..0000000
Binary files a/drawio/1-5-1功能层次图.png and /dev/null differ
diff --git a/drawio/2-4-10.drawio b/drawio/2-4-10.drawio
deleted file mode 100644
index f99eec2..0000000
--- a/drawio/2-4-10.drawio
+++ /dev/null
@@ -1,99 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/drawio/2-4-1小米便签系统包图.drawio b/drawio/2-4-1小米便签系统包图.drawio
deleted file mode 100644
index 9656f88..0000000
--- a/drawio/2-4-1小米便签系统包图.drawio
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/drawio/2-4-2.drawio b/drawio/2-4-2.drawio
deleted file mode 100644
index e094263..0000000
--- a/drawio/2-4-2.drawio
+++ /dev/null
@@ -1,49 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/drawio/2-4-3.drawio b/drawio/2-4-3.drawio
deleted file mode 100644
index 9b83b7e..0000000
--- a/drawio/2-4-3.drawio
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/drawio/2-4-4.drawio b/drawio/2-4-4.drawio
deleted file mode 100644
index f15497a..0000000
--- a/drawio/2-4-4.drawio
+++ /dev/null
@@ -1,191 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/drawio/2-4-5.drawio b/drawio/2-4-5.drawio
deleted file mode 100644
index 2f5c90f..0000000
--- a/drawio/2-4-5.drawio
+++ /dev/null
@@ -1,83 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/drawio/2-4-6.drawio b/drawio/2-4-6.drawio
deleted file mode 100644
index 59b6074..0000000
--- a/drawio/2-4-6.drawio
+++ /dev/null
@@ -1,142 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/drawio/2-4-7.drawio b/drawio/2-4-7.drawio
deleted file mode 100644
index 77773ad..0000000
--- a/drawio/2-4-7.drawio
+++ /dev/null
@@ -1,70 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/drawio/2-4-8.drawio b/drawio/2-4-8.drawio
deleted file mode 100644
index 53a8bd7..0000000
--- a/drawio/2-4-8.drawio
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/drawio/2-4-9.drawio b/drawio/2-4-9.drawio
deleted file mode 100644
index 8771d0a..0000000
--- a/drawio/2-4-9.drawio
+++ /dev/null
@@ -1,63 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/drawio/3个文档对应图片/1-5-1功能层次图.png b/drawio/3个文档对应图片/1-5-1功能层次图.png
deleted file mode 100644
index 46d4247..0000000
Binary files a/drawio/3个文档对应图片/1-5-1功能层次图.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-3-1功能层次图.png b/drawio/3个文档对应图片/2-3-1功能层次图.png
deleted file mode 100644
index 46d4247..0000000
Binary files a/drawio/3个文档对应图片/2-3-1功能层次图.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-10.png b/drawio/3个文档对应图片/2-4-10.png
deleted file mode 100644
index f2d02b1..0000000
Binary files a/drawio/3个文档对应图片/2-4-10.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-11.png b/drawio/3个文档对应图片/2-4-11.png
deleted file mode 100644
index 1076fc9..0000000
Binary files a/drawio/3个文档对应图片/2-4-11.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-12.png b/drawio/3个文档对应图片/2-4-12.png
deleted file mode 100644
index 61a8ad4..0000000
Binary files a/drawio/3个文档对应图片/2-4-12.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-1小米便签系统包图.png b/drawio/3个文档对应图片/2-4-1小米便签系统包图.png
deleted file mode 100644
index d406f3f..0000000
Binary files a/drawio/3个文档对应图片/2-4-1小米便签系统包图.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-2.png b/drawio/3个文档对应图片/2-4-2.png
deleted file mode 100644
index 2c01b6b..0000000
Binary files a/drawio/3个文档对应图片/2-4-2.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-21.png b/drawio/3个文档对应图片/2-4-21.png
deleted file mode 100644
index 0f4b2be..0000000
Binary files a/drawio/3个文档对应图片/2-4-21.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-22.png b/drawio/3个文档对应图片/2-4-22.png
deleted file mode 100644
index 96e2c3e..0000000
Binary files a/drawio/3个文档对应图片/2-4-22.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-23.png b/drawio/3个文档对应图片/2-4-23.png
deleted file mode 100644
index ae78653..0000000
Binary files a/drawio/3个文档对应图片/2-4-23.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-24.png b/drawio/3个文档对应图片/2-4-24.png
deleted file mode 100644
index 4c664bb..0000000
Binary files a/drawio/3个文档对应图片/2-4-24.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-25.png b/drawio/3个文档对应图片/2-4-25.png
deleted file mode 100644
index f812385..0000000
Binary files a/drawio/3个文档对应图片/2-4-25.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-26.png b/drawio/3个文档对应图片/2-4-26.png
deleted file mode 100644
index 059dff0..0000000
Binary files a/drawio/3个文档对应图片/2-4-26.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-27.png b/drawio/3个文档对应图片/2-4-27.png
deleted file mode 100644
index e628926..0000000
Binary files a/drawio/3个文档对应图片/2-4-27.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-28.png b/drawio/3个文档对应图片/2-4-28.png
deleted file mode 100644
index eab5134..0000000
Binary files a/drawio/3个文档对应图片/2-4-28.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-29.png b/drawio/3个文档对应图片/2-4-29.png
deleted file mode 100644
index 1a0b196..0000000
Binary files a/drawio/3个文档对应图片/2-4-29.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-3.png b/drawio/3个文档对应图片/2-4-3.png
deleted file mode 100644
index 3f6c3e0..0000000
Binary files a/drawio/3个文档对应图片/2-4-3.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-30.png b/drawio/3个文档对应图片/2-4-30.png
deleted file mode 100644
index f282296..0000000
Binary files a/drawio/3个文档对应图片/2-4-30.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-31.png b/drawio/3个文档对应图片/2-4-31.png
deleted file mode 100644
index 70d1e8d..0000000
Binary files a/drawio/3个文档对应图片/2-4-31.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-32.png b/drawio/3个文档对应图片/2-4-32.png
deleted file mode 100644
index 5c3a8a3..0000000
Binary files a/drawio/3个文档对应图片/2-4-32.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-33.png b/drawio/3个文档对应图片/2-4-33.png
deleted file mode 100644
index 72e5323..0000000
Binary files a/drawio/3个文档对应图片/2-4-33.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-34.png b/drawio/3个文档对应图片/2-4-34.png
deleted file mode 100644
index 362c983..0000000
Binary files a/drawio/3个文档对应图片/2-4-34.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-35.png b/drawio/3个文档对应图片/2-4-35.png
deleted file mode 100644
index 9864658..0000000
Binary files a/drawio/3个文档对应图片/2-4-35.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-36.png b/drawio/3个文档对应图片/2-4-36.png
deleted file mode 100644
index af58d95..0000000
Binary files a/drawio/3个文档对应图片/2-4-36.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-37.png b/drawio/3个文档对应图片/2-4-37.png
deleted file mode 100644
index c450627..0000000
Binary files a/drawio/3个文档对应图片/2-4-37.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-38.png b/drawio/3个文档对应图片/2-4-38.png
deleted file mode 100644
index 6a22956..0000000
Binary files a/drawio/3个文档对应图片/2-4-38.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-39.png b/drawio/3个文档对应图片/2-4-39.png
deleted file mode 100644
index 0d4f11b..0000000
Binary files a/drawio/3个文档对应图片/2-4-39.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-4.png b/drawio/3个文档对应图片/2-4-4.png
deleted file mode 100644
index 444b4d9..0000000
Binary files a/drawio/3个文档对应图片/2-4-4.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-40.png b/drawio/3个文档对应图片/2-4-40.png
deleted file mode 100644
index c139f38..0000000
Binary files a/drawio/3个文档对应图片/2-4-40.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-41.png b/drawio/3个文档对应图片/2-4-41.png
deleted file mode 100644
index cab61c6..0000000
Binary files a/drawio/3个文档对应图片/2-4-41.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-42.png b/drawio/3个文档对应图片/2-4-42.png
deleted file mode 100644
index da06e5d..0000000
Binary files a/drawio/3个文档对应图片/2-4-42.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-43.png b/drawio/3个文档对应图片/2-4-43.png
deleted file mode 100644
index 903321f..0000000
Binary files a/drawio/3个文档对应图片/2-4-43.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-44.png b/drawio/3个文档对应图片/2-4-44.png
deleted file mode 100644
index 3e06fd3..0000000
Binary files a/drawio/3个文档对应图片/2-4-44.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-45.png b/drawio/3个文档对应图片/2-4-45.png
deleted file mode 100644
index ea8dea1..0000000
Binary files a/drawio/3个文档对应图片/2-4-45.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-46.png b/drawio/3个文档对应图片/2-4-46.png
deleted file mode 100644
index c70160c..0000000
Binary files a/drawio/3个文档对应图片/2-4-46.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-47.png b/drawio/3个文档对应图片/2-4-47.png
deleted file mode 100644
index 21f0363..0000000
Binary files a/drawio/3个文档对应图片/2-4-47.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-48.png b/drawio/3个文档对应图片/2-4-48.png
deleted file mode 100644
index e8f5a4d..0000000
Binary files a/drawio/3个文档对应图片/2-4-48.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-49.png b/drawio/3个文档对应图片/2-4-49.png
deleted file mode 100644
index 523f099..0000000
Binary files a/drawio/3个文档对应图片/2-4-49.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-5.png b/drawio/3个文档对应图片/2-4-5.png
deleted file mode 100644
index 01939ad..0000000
Binary files a/drawio/3个文档对应图片/2-4-5.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-50.png b/drawio/3个文档对应图片/2-4-50.png
deleted file mode 100644
index 5fa8017..0000000
Binary files a/drawio/3个文档对应图片/2-4-50.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-51.png b/drawio/3个文档对应图片/2-4-51.png
deleted file mode 100644
index 49235e6..0000000
Binary files a/drawio/3个文档对应图片/2-4-51.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-52.png b/drawio/3个文档对应图片/2-4-52.png
deleted file mode 100644
index 02b91c9..0000000
Binary files a/drawio/3个文档对应图片/2-4-52.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-53.png b/drawio/3个文档对应图片/2-4-53.png
deleted file mode 100644
index 73162cc..0000000
Binary files a/drawio/3个文档对应图片/2-4-53.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-54.png b/drawio/3个文档对应图片/2-4-54.png
deleted file mode 100644
index 8c30327..0000000
Binary files a/drawio/3个文档对应图片/2-4-54.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-55.png b/drawio/3个文档对应图片/2-4-55.png
deleted file mode 100644
index 1582b1b..0000000
Binary files a/drawio/3个文档对应图片/2-4-55.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-56.png b/drawio/3个文档对应图片/2-4-56.png
deleted file mode 100644
index b5f120b..0000000
Binary files a/drawio/3个文档对应图片/2-4-56.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-57.png b/drawio/3个文档对应图片/2-4-57.png
deleted file mode 100644
index d3fd49c..0000000
Binary files a/drawio/3个文档对应图片/2-4-57.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-58.png b/drawio/3个文档对应图片/2-4-58.png
deleted file mode 100644
index f7b42ce..0000000
Binary files a/drawio/3个文档对应图片/2-4-58.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-59.png b/drawio/3个文档对应图片/2-4-59.png
deleted file mode 100644
index 0e46fa5..0000000
Binary files a/drawio/3个文档对应图片/2-4-59.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-6.png b/drawio/3个文档对应图片/2-4-6.png
deleted file mode 100644
index 3596023..0000000
Binary files a/drawio/3个文档对应图片/2-4-6.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-60.png b/drawio/3个文档对应图片/2-4-60.png
deleted file mode 100644
index e5631d6..0000000
Binary files a/drawio/3个文档对应图片/2-4-60.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-61.png b/drawio/3个文档对应图片/2-4-61.png
deleted file mode 100644
index 103a0e1..0000000
Binary files a/drawio/3个文档对应图片/2-4-61.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-62.png b/drawio/3个文档对应图片/2-4-62.png
deleted file mode 100644
index addfd15..0000000
Binary files a/drawio/3个文档对应图片/2-4-62.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-63.png b/drawio/3个文档对应图片/2-4-63.png
deleted file mode 100644
index 475521b..0000000
Binary files a/drawio/3个文档对应图片/2-4-63.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-64.png b/drawio/3个文档对应图片/2-4-64.png
deleted file mode 100644
index a6fa2a3..0000000
Binary files a/drawio/3个文档对应图片/2-4-64.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-7.png b/drawio/3个文档对应图片/2-4-7.png
deleted file mode 100644
index c55d680..0000000
Binary files a/drawio/3个文档对应图片/2-4-7.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-8.png b/drawio/3个文档对应图片/2-4-8.png
deleted file mode 100644
index 58821ce..0000000
Binary files a/drawio/3个文档对应图片/2-4-8.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/2-4-9.png b/drawio/3个文档对应图片/2-4-9.png
deleted file mode 100644
index 11220a0..0000000
Binary files a/drawio/3个文档对应图片/2-4-9.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-3-1.png b/drawio/3个文档对应图片/3-3-1.png
deleted file mode 100644
index 4b7a528..0000000
Binary files a/drawio/3个文档对应图片/3-3-1.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-3-2.png b/drawio/3个文档对应图片/3-3-2.png
deleted file mode 100644
index 2b77d32..0000000
Binary files a/drawio/3个文档对应图片/3-3-2.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-4-1.png b/drawio/3个文档对应图片/3-4-1.png
deleted file mode 100644
index fed865b..0000000
Binary files a/drawio/3个文档对应图片/3-4-1.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-4-10.png b/drawio/3个文档对应图片/3-4-10.png
deleted file mode 100644
index e2c0372..0000000
Binary files a/drawio/3个文档对应图片/3-4-10.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-4-2.png b/drawio/3个文档对应图片/3-4-2.png
deleted file mode 100644
index 8891ed9..0000000
Binary files a/drawio/3个文档对应图片/3-4-2.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-4-3.png b/drawio/3个文档对应图片/3-4-3.png
deleted file mode 100644
index 8a0c2ec..0000000
Binary files a/drawio/3个文档对应图片/3-4-3.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-4-4.png b/drawio/3个文档对应图片/3-4-4.png
deleted file mode 100644
index 1fd1d9a..0000000
Binary files a/drawio/3个文档对应图片/3-4-4.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-4-5.png b/drawio/3个文档对应图片/3-4-5.png
deleted file mode 100644
index 1fd1d9a..0000000
Binary files a/drawio/3个文档对应图片/3-4-5.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-4-6.png b/drawio/3个文档对应图片/3-4-6.png
deleted file mode 100644
index d083b32..0000000
Binary files a/drawio/3个文档对应图片/3-4-6.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-4-7.png b/drawio/3个文档对应图片/3-4-7.png
deleted file mode 100644
index d083b32..0000000
Binary files a/drawio/3个文档对应图片/3-4-7.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-4-8.png b/drawio/3个文档对应图片/3-4-8.png
deleted file mode 100644
index a3f569a..0000000
Binary files a/drawio/3个文档对应图片/3-4-8.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-4-9.png b/drawio/3个文档对应图片/3-4-9.png
deleted file mode 100644
index e2c0372..0000000
Binary files a/drawio/3个文档对应图片/3-4-9.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-5-1.png b/drawio/3个文档对应图片/3-5-1.png
deleted file mode 100644
index b828578..0000000
Binary files a/drawio/3个文档对应图片/3-5-1.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-5-10.png b/drawio/3个文档对应图片/3-5-10.png
deleted file mode 100644
index afd35d6..0000000
Binary files a/drawio/3个文档对应图片/3-5-10.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-5-11.png b/drawio/3个文档对应图片/3-5-11.png
deleted file mode 100644
index caee086..0000000
Binary files a/drawio/3个文档对应图片/3-5-11.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-5-12.png b/drawio/3个文档对应图片/3-5-12.png
deleted file mode 100644
index 28ddbf2..0000000
Binary files a/drawio/3个文档对应图片/3-5-12.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-5-13.png b/drawio/3个文档对应图片/3-5-13.png
deleted file mode 100644
index c209dc0..0000000
Binary files a/drawio/3个文档对应图片/3-5-13.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-5-2.png b/drawio/3个文档对应图片/3-5-2.png
deleted file mode 100644
index e8402b2..0000000
Binary files a/drawio/3个文档对应图片/3-5-2.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-5-3.png b/drawio/3个文档对应图片/3-5-3.png
deleted file mode 100644
index 0f21d52..0000000
Binary files a/drawio/3个文档对应图片/3-5-3.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-5-4.png b/drawio/3个文档对应图片/3-5-4.png
deleted file mode 100644
index 6790e98..0000000
Binary files a/drawio/3个文档对应图片/3-5-4.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-5-5.png b/drawio/3个文档对应图片/3-5-5.png
deleted file mode 100644
index 14956d5..0000000
Binary files a/drawio/3个文档对应图片/3-5-5.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-5-6.png b/drawio/3个文档对应图片/3-5-6.png
deleted file mode 100644
index 5b651df..0000000
Binary files a/drawio/3个文档对应图片/3-5-6.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-5-7.png b/drawio/3个文档对应图片/3-5-7.png
deleted file mode 100644
index d309570..0000000
Binary files a/drawio/3个文档对应图片/3-5-7.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-5-8.png b/drawio/3个文档对应图片/3-5-8.png
deleted file mode 100644
index d147351..0000000
Binary files a/drawio/3个文档对应图片/3-5-8.png and /dev/null differ
diff --git a/drawio/3个文档对应图片/3-5-9.png b/drawio/3个文档对应图片/3-5-9.png
deleted file mode 100644
index f6fd9f1..0000000
Binary files a/drawio/3个文档对应图片/3-5-9.png and /dev/null differ
diff --git a/gradle.properties b/gradle.properties
index fbf26e6..39018db 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,13 +1,16 @@
-# Project-wide Gradle settings.
-# IDE (e.g. Android Studio) users:
-# Gradle settings configured through the IDE *will override*
-# any settings specified in this file.
+## Project-wide Gradle settings.
+#
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
+#
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
-org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
+# Default value: -Xmx1024m -XX:MaxPermSize=256m
+# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
+#
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
\ No newline at end of file
+# org.gradle.parallel=true
+#Thu May 04 14:08:34 GMT+08:00 2017
+
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index e708b1c..13372ae 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 5d2ad9c..7f05b4c 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Tue Dec 21 19:46:41 CST 2021
+#Sat May 05 06:31:36 CST 2018
distributionBase=GRADLE_USER_HOME
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip
distributionPath=wrapper/dists
-zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-7.5-bin.zip
diff --git a/gradlew b/gradlew
index 4f906e0..9d82f78 100644
--- a/gradlew
+++ b/gradlew
@@ -1,20 +1,4 @@
-#!/usr/bin/env sh
-
-#
-# Copyright 2015 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
+#!/usr/bin/env bash
##############################################################################
##
@@ -22,38 +6,20 @@
##
##############################################################################
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn () {
+warn ( ) {
echo "$*"
}
-die () {
+die ( ) {
echo
echo "$*"
echo
@@ -64,7 +30,6 @@ die () {
cygwin=false
msys=false
darwin=false
-nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@@ -75,13 +40,27 @@ case "`uname`" in
MINGW* )
msys=true
;;
- NONSTOP* )
- nonstop=true
- ;;
esac
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
@@ -106,7 +85,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -126,11 +105,10 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin or MSYS, switch paths to Windows format before running java
-if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
@@ -156,30 +134,27 @@ if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=`expr $i + 1`
+ i=$((i+1))
done
case $i in
- 0) set -- ;;
- 1) set -- "$args0" ;;
- 2) set -- "$args0" "$args1" ;;
- 3) set -- "$args0" "$args1" "$args2" ;;
- 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
}
-APP_ARGS=`save "$@"`
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-exec "$JAVACMD" "$@"
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 107acd3..8a0b282 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,19 +1,3 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -24,23 +8,20 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
-@rem Resolve any "." and ".." in APP_HOME to make it shorter.
-for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto execute
+if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -54,7 +35,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto execute
+if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -64,14 +45,34 @@ echo location of your Java installation.
goto fail
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
diff --git a/import-summary.txt b/import-summary.txt
new file mode 100644
index 0000000..cd1d3d6
--- /dev/null
+++ b/import-summary.txt
@@ -0,0 +1,36 @@
+ECLIPSE ANDROID PROJECT IMPORT SUMMARY
+======================================
+
+Ignored Files:
+--------------
+The following files were *not* copied into the new Gradle project; you
+should evaluate whether these are still needed in your project and if
+so manually move them:
+
+* .gitignore
+* NOTICE
+* README.md
+
+Moved Files:
+------------
+Android Gradle projects use a different directory structure than ADT
+Eclipse projects. Here's how the projects were restructured:
+
+* AndroidManifest.xml => app\src\main\AndroidManifest.xml
+* res\ => app\src\main\res\
+* src\ => app\src\main\java\
+
+Next Steps:
+-----------
+You can now build the project. The Gradle project needs network
+connectivity to download dependencies.
+
+Bugs:
+-----
+If for some reason your project does not build, and you determine that
+it is due to a bug or limitation of the Eclipse to Gradle importer,
+please file a bug at http://b.android.com with category
+Component-Tools.
+
+(This import summary is for your information only, and can be deleted
+after import once you are satisfied with the results.)
diff --git a/settings.gradle b/settings.gradle
index 92189b9..e7b4def 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,10 +1 @@
-dependencyResolutionManagement {
- repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
- repositories {
- google()
- mavenCentral()
- jcenter() // Warning: this repository is going to shut down soon
- }
-}
-rootProject.name = "MiCode"
include ':app'