Compare commits

..

No commits in common. 'fd203c4f0a1d0e211eaa7dad3aaf48be3899585e' and 'aba3d0dc8c35703d419f547c3b570334dce7a332' have entirely different histories.

@ -22,7 +22,7 @@
<activity
android:name=".ui.NotesListActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:label="Notes"
android:launchMode="singleTop"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar"
android:uiOptions="splitActionBarWhenNarrow"
@ -43,8 +43,15 @@
android:name=".ui.NoteEditActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleTop"
android:theme="@style/Theme.AppCompat.Light.DarkActionBar">
android:theme="@style/NoteTheme">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/text_note" />
<data android:mimeType="vnd.android.cursor.item/call_note" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.INSERT_OR_EDIT" />

@ -22,42 +22,57 @@ import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.provider.ContactsContract.Data;
import android.telephony.PhoneNumberUtils;
import android.util.Log;
import java.util.HashMap;
// 该代码是一个名为Contact的类用于获取联系人信息。
//代码中定义了一个静态的HashMap变量sContactCache用于缓存联系人信息。sContactCache的键是电话号码值是联系人姓名。
//定义了一个字符串常量CALLER_ID_SELECTION用于查询联系人信息的条件。该条件是通过拼接字符串而得到的包含了查询电话号码相等、数据类型为电话号码、联系人ID在指定范围内等条件。
//代码中定义了一个静态方法getContact用于根据电话号码获取联系人姓名。
public class Contact {
private static HashMap<String, String> sContactCache;
private static final String TAG = "Contact";
private static final String CALLER_ID_SELECTION = "PHONE_NUMBERS_EQUAL(" + Phone.NUMBER
+ ",?) AND " + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'"
+ " AND " + Data.RAW_CONTACT_ID + " IN "
private static HashMap<String, String> sContactCache; // 缓存联系人信息
private static final String TAG = "Contact";//标签
private static final String CALLER_ID_SELECTION = "PHONE_NUMBERS_EQUAL(" + Phone.NUMBER
+ ",?) AND " + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'"
+ " AND " + Data.RAW_CONTACT_ID + " IN "
+ "(SELECT raw_contact_id "
+ " FROM phone_lookup"
+ " WHERE min_match = '+')";
+ " WHERE min_match = '+')"; // 查询联系人信息的条件
/**
*
* @param context
* @param phoneNumber
* @return null
*/
// 该方法首先检查缓存中是否已有该电话号码对应的联系人姓名,如果有则返回缓存中的值。如果缓存中没有该电话号码对应的联系人姓名,则通过查询数据库来获取联系人姓名。
// 查询数据库的条件是根据电话号码生成的CALLER_ID_SELECTION。如果查询结果不为空且移动到第一条记录则从结果中提取联系人姓名并将其存入缓存中。如果查询结果为空则返回null。
public static String getContact(Context context, String phoneNumber) {
if(sContactCache == null) {
if (sContactCache == null) {
sContactCache = new HashMap<String, String>();
}
if(sContactCache.containsKey(phoneNumber)) {
return sContactCache.get(phoneNumber);
// 查找HashMap中是否已有phoneNumber信息
if (sContactCache.containsKey(phoneNumber)) {
return sContactCache.get(phoneNumber);//直接根据键值(电话号码)找到姓名
}
String selection = CALLER_ID_SELECTION.replace("+",
PhoneNumberUtils.toCallerIDMinMatch(phoneNumber));
PhoneNumberUtils.toCallerIDMinMatch(phoneNumber));//最小匹配原则查找电话号码
// 查找数据库中phoneNumber的信息
Cursor cursor = context.getContentResolver().query(
Data.CONTENT_URI,
new String [] { Phone.DISPLAY_NAME },
new String[] { Phone.DISPLAY_NAME },
selection,
new String[] { phoneNumber },
null);
// 判定查询结果
if (cursor != null && cursor.moveToFirst()) {
try {
// 找到相关信息
String name = cursor.getString(0);
sContactCache.put(phoneNumber, name);
sContactCache.put(phoneNumber, name);//放入缓存块
return name;
} catch (IndexOutOfBoundsException e) {
Log.e(TAG, " Cursor get string error " + e.toString());
@ -66,7 +81,8 @@ public class Contact {
cursor.close();
}
} else {
Log.d(TAG, "No contact matched with number:" + phoneNumber);
// 未找到相关信息
Log.d(TAG, "No contact matched with number:" + phoneNumber);//给出反馈信息
return null;
}
}

@ -17,7 +17,7 @@
package net.micode.notes.data;
import android.net.Uri;
public class Notes {
public class Notes {//定义Nodes类初始化参数都赋值成静态量
public static final String AUTHORITY = "micode_notes";
public static final String TAG = "Notes";
public static final int TYPE_NOTE = 0;
@ -54,14 +54,14 @@ public class Notes {
/**
* Uri to query all notes and folders
*/
public static final Uri CONTENT_NOTE_URI = Uri.parse("content://" + AUTHORITY + "/note");
public static final Uri CONTENT_NOTE_URI = Uri.parse("content://" + AUTHORITY + "/note");//指定笔记的路径
/**
* Uri to query data
*/
public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data");
public static final Uri CONTENT_DATA_URI = Uri.parse("content://" + AUTHORITY + "/data");//用于指定数据的路径,类似上面
public interface NoteColumns {
public interface NoteColumns {//定义笔记集ID、父集ID、创建日期修改日期等等列名称以及类型做初始化
/**
* The unique ID for a row
* <P> Type: INTEGER (long) </P>
@ -167,7 +167,7 @@ public class Notes {
public static final String VERSION = "version";
}
public interface DataColumns {
public interface DataColumns {//定义接口给每行数据ID类型所属笔记集ID内容数据等等做定义
/**
* The unique ID for a row
* <P> Type: INTEGER (long) </P>
@ -241,20 +241,20 @@ public class Notes {
public static final String DATA5 = "data5";
}
public static final class TextNote implements DataColumns {
public static final class TextNote implements DataColumns {//实现DataColumn接口为数据库查询操作提供数据列名称
/**
* Mode to indicate the text in check list mode or not
* <P> Type: Integer 1:check list mode 0: normal mode </P>
*/
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");
public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/text_note");//指定路径
}
public static final class CallNote implements DataColumns {

@ -27,7 +27,7 @@ import net.micode.notes.data.Notes.DataConstants;
import net.micode.notes.data.Notes.NoteColumns;
public class NotesDatabaseHelper extends SQLiteOpenHelper {
public class NotesDatabaseHelper extends SQLiteOpenHelper { //定义数据库相关的名称以及标签
private static final String DB_NAME = "note.db";
private static final int DB_VERSION = 4;
@ -42,7 +42,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
private static NotesDatabaseHelper mInstance;
private static final String CREATE_NOTE_TABLE_SQL =
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," +
@ -85,7 +85,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
/**
* Increase folder's note count when move note to the folder
*/
private static final String NOTE_INCREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER =
private static final String NOTE_INCREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER =//设置触发器在笔记集更新的时候增加数量1
"CREATE TRIGGER increase_folder_count_on_update "+
" AFTER UPDATE OF " + NoteColumns.PARENT_ID + " ON " + TABLE.NOTE +
" BEGIN " +
@ -97,7 +97,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
/**
* Decrease folder's note count when move note from folder
*/
private static final String NOTE_DECREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER =
private static final String NOTE_DECREASE_FOLDER_COUNT_ON_UPDATE_TRIGGER =//类似的设置触发器在笔记集更新的时候减少数量1
"CREATE TRIGGER decrease_folder_count_on_update " +
" AFTER UPDATE OF " + NoteColumns.PARENT_ID + " ON " + TABLE.NOTE +
" BEGIN " +
@ -110,7 +110,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
/**
* Increase folder's note count when insert new note to the folder
*/
private static final String NOTE_INCREASE_FOLDER_COUNT_ON_INSERT_TRIGGER =
private static final String NOTE_INCREASE_FOLDER_COUNT_ON_INSERT_TRIGGER =//设置触发器在笔记集创建的时候增加数量1
"CREATE TRIGGER increase_folder_count_on_insert " +
" AFTER INSERT ON " + TABLE.NOTE +
" BEGIN " +
@ -122,7 +122,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
/**
* Decrease folder's note count when delete note from the folder
*/
private static final String NOTE_DECREASE_FOLDER_COUNT_ON_DELETE_TRIGGER =
private static final String NOTE_DECREASE_FOLDER_COUNT_ON_DELETE_TRIGGER =//设置触发器,在笔记集删除文件的时候-1
"CREATE TRIGGER decrease_folder_count_on_delete " +
" AFTER DELETE ON " + TABLE.NOTE +
" BEGIN " +
@ -135,7 +135,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
/**
* Update note's content when insert data with type {@link DataConstants#NOTE}
*/
private static final String DATA_UPDATE_NOTE_CONTENT_ON_INSERT_TRIGGER =
private static final String DATA_UPDATE_NOTE_CONTENT_ON_INSERT_TRIGGER =//设置触发器用于在笔记中数据更改时进行相应ID字段等的更新
"CREATE TRIGGER update_note_content_on_insert " +
" AFTER INSERT ON " + TABLE.DATA +
" WHEN new." + DataColumns.MIME_TYPE + "='" + DataConstants.NOTE + "'" +
@ -210,14 +210,14 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
super(context, DB_NAME, null, DB_VERSION);
}
public void createNoteTable(SQLiteDatabase db) {
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) {
private void reCreateNoteTableTriggers(SQLiteDatabase db) {//重置触发器
db.execSQL("DROP TRIGGER IF EXISTS increase_folder_count_on_update");
db.execSQL("DROP TRIGGER IF EXISTS decrease_folder_count_on_update");
db.execSQL("DROP TRIGGER IF EXISTS decrease_folder_count_on_delete");
@ -301,7 +301,7 @@ public class NotesDatabaseHelper extends SQLiteOpenHelper {
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {//用于检查并进行数据库版本的更新,保障版本控制
boolean reCreateTriggers = false;
boolean skipV2 = false;

@ -35,7 +35,7 @@ import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.data.NotesDatabaseHelper.TABLE;
public class NotesProvider extends ContentProvider {
public class NotesProvider extends ContentProvider {//定义URL以及匹配规则
private static final UriMatcher mMatcher;
private NotesDatabaseHelper mHelper;
@ -86,12 +86,12 @@ public class NotesProvider extends ContentProvider {
}
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,//执行数据库查询操作
String sortOrder) {
Cursor c = null;
SQLiteDatabase db = mHelper.getReadableDatabase();
String id = null;
switch (mMatcher.match(uri)) {
switch (mMatcher.match(uri)) {//匹配数据库查询关键字
case URI_NOTE:
c = db.query(TABLE.NOTE, projection, selection, selectionArgs, null, null,
sortOrder);
@ -148,7 +148,7 @@ public class NotesProvider extends ContentProvider {
}
@Override
public Uri insert(Uri uri, ContentValues values) {
public Uri insert(Uri uri, ContentValues values) {//insert向数据库中插入一条数据信息值
SQLiteDatabase db = mHelper.getWritableDatabase();
long dataId = 0, noteId = 0, insertedId = 0;
switch (mMatcher.match(uri)) {
@ -182,7 +182,8 @@ public class NotesProvider extends ContentProvider {
}
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
public int delete(Uri uri, String selection, String[] selectionArgs) {//实现删除操作
/*这两个参数通常在一起使用以定义一个特定的删除操作。selection 定义了哪些数据应该被删除,而 selectionArgs 为 selection 中的占位符提供了具体的值。*/
int count = 0;
String id = null;
SQLiteDatabase db = mHelper.getWritableDatabase();
@ -228,7 +229,7 @@ public class NotesProvider extends ContentProvider {
}
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {//更新
int count = 0;
String id = null;
SQLiteDatabase db = mHelper.getWritableDatabase();

@ -24,8 +24,8 @@ import net.micode.notes.tool.GTaskStringUtils;
import org.json.JSONException;
import org.json.JSONObject;
public class MetaData extends Task {
//主要是定义用于处理元数据
public class MetaData extends Task {//继承task是task的子类
private final static String TAG = MetaData.class.getSimpleName();
private String mRelatedGid = null;
@ -34,7 +34,7 @@ public class MetaData extends Task {
try {
metaInfo.put(GTaskStringUtils.META_HEAD_GTASK_ID, gid);
} catch (JSONException e) {
Log.e(TAG, "failed to put related gid");
Log.e(TAG, "failed to put related gid");//记录错误日志
}
setNotes(metaInfo.toString());
setName(GTaskStringUtils.META_NOTE_NAME);
@ -47,10 +47,10 @@ public class MetaData extends Task {
@Override
public boolean isWorthSaving() {
return getNotes() != null;
}
}//用于判断数据是否值得保存
@Override
public void setContentByRemoteJSON(JSONObject js) {
public void setContentByRemoteJSON(JSONObject js) {//用远程的json设置内容基础操作元
super.setContentByRemoteJSON(js);
if (getNotes() != null) {
try {
@ -64,9 +64,9 @@ public class MetaData extends Task {
}
@Override
public void setContentByLocalJSON(JSONObject js) {
public void setContentByLocalJSON(JSONObject js) {//这几个函数都是通过一部分已知的项推算其他未知的
// this function should not be called
throw new IllegalAccessError("MetaData:setContentByLocalJSON should not be called");
throw new IllegalAccessError("MetaData:setContentByLocalJSON should not be called");//抛出了IllegalAccessError异常表明它不应该被直接调用
}
@Override

@ -20,7 +20,7 @@ import android.database.Cursor;
import org.json.JSONObject;
public abstract class Node {
public abstract class Node {//主要定义一些获取属性值的方法
public static final int SYNC_ACTION_NONE = 0;
public static final int SYNC_ACTION_ADD_REMOTE = 1;
@ -38,6 +38,7 @@ public abstract class Node {
public static final int SYNC_ACTION_UPDATE_CONFLICT = 7;
public static final int SYNC_ACTION_ERROR = 8;
//为不同的同步类型添加调用编号
private String mGid;
@ -45,7 +46,7 @@ public abstract class Node {
private long mLastModified;
private boolean mDeleted;
private boolean mDeleted;//设置基础值,定义获取参数的方法
public Node() {
mGid = null;
@ -64,9 +65,9 @@ public abstract class Node {
public abstract JSONObject getLocalJSONFromContent();
public abstract int getSyncAction(Cursor c);
public abstract int getSyncAction(Cursor c);//根据当前指针刷新缓冲区
public void setGid(String gid) {
public void setGid(String gid) {//定义各项简单查询操作的返回值
this.mGid = gid;
}
@ -82,7 +83,7 @@ public abstract class Node {
this.mDeleted = deleted;
}
public String getGid() {
public String getGid() {//this保证指向的还是当前的对象
return this.mGid;
}

@ -71,9 +71,9 @@ public class SqlData {
private ContentValues mDiffDataValues;
public SqlData(Context context) {
public SqlData(Context context) {//初始化对象,用于存储数据
mContentResolver = context.getContentResolver();
mIsCreate = true;
mIsCreate = true;//一类型的变量为true
mDataId = INVALID_ID;
mDataMimeType = DataConstants.NOTE;
mDataContent = "";
@ -82,14 +82,14 @@ public class SqlData {
mDiffDataValues = new ContentValues();
}
public SqlData(Context context, Cursor c) {
public SqlData(Context context, Cursor c) {//同样是存储数据另外定义支持冲cursor读入
mContentResolver = context.getContentResolver();
mIsCreate = false;
mIsCreate = false;//二类型的变量为false
loadFromCursor(c);
mDiffDataValues = new ContentValues();
}
private void loadFromCursor(Cursor c) {
private void loadFromCursor(Cursor c) {//上面用到的从cursor读取的函数从存储的各个列获取数据
mDataId = c.getLong(DATA_ID_COLUMN);
mDataMimeType = c.getString(DATA_MIME_TYPE_COLUMN);
mDataContent = c.getString(DATA_CONTENT_COLUMN);
@ -97,9 +97,9 @@ public class SqlData {
mDataContentData3 = c.getString(DATA_CONTENT_DATA_3_COLUMN);
}
public void setContent(JSONObject js) throws JSONException {
long dataId = js.has(DataColumns.ID) ? js.getLong(DataColumns.ID) : INVALID_ID;
if (mIsCreate || mDataId != dataId) {
public void setContent(@androidx.annotation.NonNull JSONObject js) throws JSONException {//获取json类型的参数并且根据它更新自定义的数据单元中的值
long dataId = js.has(DataColumns.ID) ? js.getLong(DataColumns.ID) : INVALID_ID;//如果有id直接赋值没有则需要在获取
if (mIsCreate || mDataId != dataId) {//初始未设置的数据单元通过它设置内容通过cursor产生的数据元可通过它完成更新
mDiffDataValues.put(DataColumns.ID, dataId);
}
mDataId = dataId;
@ -131,7 +131,7 @@ public class SqlData {
}
public JSONObject getContent() throws JSONException {
if (mIsCreate) {
if (mIsCreate) {//同样的只有通过cursor产生的数据单元可通过这个函数获取数据
Log.e(TAG, "it seems that we haven't created this in database yet");
return null;
}
@ -144,7 +144,7 @@ public class SqlData {
return js;
}
public void commit(long noteId, boolean validateVersion, long version) {
public void commit(long noteId, boolean validateVersion, long version) {//提交数据,并且打上类似于标签的版本号以及验证值
if (mIsCreate) {
if (mDataId == INVALID_ID && mDiffDataValues.containsKey(DataColumns.ID)) {
@ -162,10 +162,10 @@ public class SqlData {
} else {
if (mDiffDataValues.size() > 0) {
int result = 0;
if (!validateVersion) {
if (!validateVersion) { // 不验证版本的情况下直接使用ContentResolver更新指定ID的数据
result = mContentResolver.update(ContentUris.withAppendedId(
Notes.CONTENT_DATA_URI, mDataId), mDiffDataValues, null, null);
} else {
} else { // 需要验证版本的情况下使用ContentResolver进行条件更新操作
result = mContentResolver.update(ContentUris.withAppendedId(
Notes.CONTENT_DATA_URI, mDataId), mDiffDataValues,
" ? in (SELECT " + NoteColumns.ID + " FROM " + TABLE.NOTE

@ -122,7 +122,7 @@ public class SqlNote {
private ArrayList<SqlData> mDataList;
public SqlNote(Context context) {
public SqlNote(Context context) {//定义数据单元存储数据
mContext = context;
mContentResolver = context.getContentResolver();
mIsCreate = true;
@ -135,7 +135,7 @@ public class SqlNote {
mParentId = 0;
mSnippet = "";
mType = Notes.TYPE_NOTE;
mWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;
mWidgetId = AppWidgetManager.INVALID_APPWIDGET_ID;//直接从设置的属性中获取值
mWidgetType = Notes.TYPE_WIDGET_INVALIDE;
mOriginParent = 0;
mVersion = 0;
@ -147,14 +147,14 @@ public class SqlNote {
mContext = context;
mContentResolver = context.getContentResolver();
mIsCreate = false;
loadFromCursor(c);
loadFromCursor(c);//从cursor中直接获取变量值
mDataList = new ArrayList<SqlData>();
if (mType == Notes.TYPE_NOTE)
loadDataContent();
mDiffNoteValues = new ContentValues();
}
public SqlNote(Context context, long id) {
public SqlNote(Context context, long id) {//根据id初始化数据单元
mContext = context;
mContentResolver = context.getContentResolver();
mIsCreate = false;
@ -175,7 +175,7 @@ public class SqlNote {
}, null);
if (c != null) {
c.moveToNext();
loadFromCursor(c);
loadFromCursor(c);//通过调用减少重复代码编写
} else {
Log.w(TAG, "loadFromCursor: cursor = null");
}
@ -185,7 +185,7 @@ public class SqlNote {
}
}
private void loadFromCursor(Cursor c) {
private void loadFromCursor(Cursor c) {//直接使用get获得变量值
mId = c.getLong(ID_COLUMN);
mAlertDate = c.getLong(ALERTED_DATE_COLUMN);
mBgColorId = c.getInt(BG_COLOR_ID_COLUMN);
@ -200,7 +200,7 @@ public class SqlNote {
mVersion = c.getLong(VERSION_COLUMN);
}
private void loadDataContent() {
private void loadDataContent() {//这个函数判别查询的数据是否存在,并且读取到数据列表中存储
Cursor c = null;
mDataList.clear();
try {
@ -210,12 +210,12 @@ public class SqlNote {
}, null);
if (c != null) {
if (c.getCount() == 0) {
Log.w(TAG, "it seems that the note has not data");
Log.w(TAG, "it seems that the note has not data");//遇到文件为空抛出对应的异常
return;
}
while (c.moveToNext()) {
SqlData data = new SqlData(mContext, c);
mDataList.add(data);
mDataList.add(data);//向Datalist中加入读取到的数据
}
} else {
Log.w(TAG, "loadDataContent: cursor = null");
@ -226,7 +226,8 @@ public class SqlNote {
}
}
public boolean setContent(JSONObject js) {
public boolean setContent(JSONObject js) {//设置数据单元中变量的值
//如果所需的值存在,直接赋值使用,否则再先进行一步读取
try {
JSONObject note = js.getJSONObject(GTaskStringUtils.META_HEAD_NOTE);
if (note.getInt(NoteColumns.TYPE) == Notes.TYPE_SYSTEM) {
@ -359,7 +360,7 @@ public class SqlNote {
return true;
}
public JSONObject getContent() {
public JSONObject getContent() {//直接读取的方式将所需的数据读到对应变量
try {
JSONObject js = new JSONObject();
@ -412,6 +413,7 @@ public class SqlNote {
mDiffNoteValues.put(NoteColumns.PARENT_ID, id);
}
//定义一些简单的获取取值的方法
public void setGtaskId(String gid) {
mDiffNoteValues.put(NoteColumns.GTASK_ID, gid);
}
@ -440,7 +442,7 @@ public class SqlNote {
return mType == Notes.TYPE_NOTE;
}
public void commit(boolean validateVersion) {
public void commit(boolean validateVersion) {//将数据做一定修改提交
if (mIsCreate) {
if (mId == INVALID_ID && mDiffNoteValues.containsKey(NoteColumns.ID)) {
mDiffNoteValues.remove(NoteColumns.ID);

@ -32,7 +32,7 @@ import org.json.JSONException;
import org.json.JSONObject;
public class Task extends Node {
public class Task extends Node {//继承Node类的属性
private static final String TAG = Task.class.getSimpleName();
private boolean mCompleted;
@ -54,7 +54,7 @@ public class Task extends Node {
mMetaInfo = null;
}
public JSONObject getCreateAction(int actionId) {
public JSONObject getCreateAction(int actionId) {//创建一个初始的任务对象,并对它赋初值
JSONObject js = new JSONObject();
try {
@ -103,7 +103,7 @@ public class Task extends Node {
return js;
}
public JSONObject getUpdateAction(int actionId) {
public JSONObject getUpdateAction(int actionId) {//更新任务
JSONObject js = new JSONObject();
try {
@ -120,7 +120,7 @@ public class Task extends Node {
// entity_delta
JSONObject entity = new JSONObject();
entity.put(GTaskStringUtils.GTASK_JSON_NAME, getName());
if (getNotes() != null) {
if (getNotes() != null) {//如果笔记不为空,更新笔记
entity.put(GTaskStringUtils.GTASK_JSON_NOTES, getNotes());
}
entity.put(GTaskStringUtils.GTASK_JSON_DELETED, getDeleted());
@ -135,11 +135,11 @@ public class Task extends Node {
return js;
}
public void setContentByRemoteJSON(JSONObject js) {
public void setContentByRemoteJSON(JSONObject js) {//通过远端的json设置内容的值
if (js != null) {
try {
// id
if (js.has(GTaskStringUtils.GTASK_JSON_ID)) {
if (js.has(GTaskStringUtils.GTASK_JSON_ID)) {//如果值已经被json对象所具备则直接进行设置
setGid(js.getString(GTaskStringUtils.GTASK_JSON_ID));
}
@ -175,7 +175,7 @@ public class Task extends Node {
}
}
public void setContentByLocalJSON(JSONObject js) {
public void setContentByLocalJSON(JSONObject js) {//通过本地的json文件来设置内容
if (js == null || !js.has(GTaskStringUtils.META_HEAD_NOTE)
|| !js.has(GTaskStringUtils.META_HEAD_DATA)) {
Log.w(TAG, "setContentByLocalJSON: nothing is avaiable");
@ -204,7 +204,7 @@ public class Task extends Node {
}
}
public JSONObject getLocalJSONFromContent() {
public JSONObject getLocalJSONFromContent() {//通过本地的内容生成json文件
String name = getName();
try {
if (mMetaInfo == null) {
@ -216,7 +216,7 @@ public class Task extends Node {
JSONObject js = new JSONObject();
JSONObject note = new JSONObject();
JSONArray dataArray = new JSONArray();
JSONArray dataArray = new JSONArray();//声明所有所要用到的变量
JSONObject data = new JSONObject();
data.put(DataColumns.CONTENT, name);
dataArray.put(data);
@ -227,7 +227,7 @@ public class Task extends Node {
} else {
// synced task
JSONObject note = mMetaInfo.getJSONObject(GTaskStringUtils.META_HEAD_NOTE);
JSONArray dataArray = mMetaInfo.getJSONArray(GTaskStringUtils.META_HEAD_DATA);
JSONArray dataArray = mMetaInfo.getJSONArray(GTaskStringUtils.META_HEAD_DATA);//提取出所有的信息
for (int i = 0; i < dataArray.length(); i++) {
JSONObject data = dataArray.getJSONObject(i);
@ -258,11 +258,11 @@ public class Task extends Node {
}
}
public int getSyncAction(Cursor c) {
public int getSyncAction(Cursor c) {//同步缓存
try {
JSONObject noteInfo = null;
if (mMetaInfo != null && mMetaInfo.has(GTaskStringUtils.META_HEAD_NOTE)) {
noteInfo = mMetaInfo.getJSONObject(GTaskStringUtils.META_HEAD_NOTE);
noteInfo = mMetaInfo.getJSONObject(GTaskStringUtils.META_HEAD_NOTE);//更新到最新的笔记信息
}
if (noteInfo == null) {
@ -311,14 +311,14 @@ public class Task extends Node {
return SYNC_ACTION_ERROR;
}
public boolean isWorthSaving() {
public boolean isWorthSaving() {//只要有信息就认为是值得保存的返回true
return mMetaInfo != null || (getName() != null && getName().trim().length() > 0)
|| (getNotes() != null && getNotes().trim().length() > 0);
}
public void setCompleted(boolean completed) {
this.mCompleted = completed;
}
}//进行前面使用过的调用函数返回值的对应
public void setNotes(String notes) {
this.mNotes = notes;

@ -30,17 +30,17 @@ import org.json.JSONObject;
import java.util.ArrayList;
public class TaskList extends Node {
public class TaskList extends Node {//同Task一样继承了Node
private static final String TAG = TaskList.class.getSimpleName();
private int mIndex;
private ArrayList<Task> mChildren;
private ArrayList<Task> mChildren;//内部含有一个Task的列是任务的序列
public TaskList() {
super();
mChildren = new ArrayList<Task>();
mIndex = 1;
mIndex = 1;//初始化
}
public JSONObject getCreateAction(int actionId) {
@ -74,7 +74,7 @@ public class TaskList extends Node {
return js;
}
public JSONObject getUpdateAction(int actionId) {
public JSONObject getUpdateAction(int actionId) {//更新行动与Task中定义的基本一样
JSONObject js = new JSONObject();
try {
@ -104,7 +104,7 @@ public class TaskList extends Node {
}
public void setContentByRemoteJSON(JSONObject js) {
if (js != null) {
if (js != null) {//类似的通过远端更新内容
try {
// id
if (js.has(GTaskStringUtils.GTASK_JSON_ID)) {
@ -129,7 +129,7 @@ public class TaskList extends Node {
}
}
public void setContentByLocalJSON(JSONObject js) {
public void setContentByLocalJSON(JSONObject js) {//通过本地文件更新内容
if (js == null || !js.has(GTaskStringUtils.META_HEAD_NOTE)) {
Log.w(TAG, "setContentByLocalJSON: nothing is avaiable");
}
@ -215,26 +215,26 @@ public class TaskList extends Node {
return SYNC_ACTION_ERROR;
}
//以上都与task定义类似
public int getChildTaskCount() {
return mChildren.size();
}
public boolean addChildTask(Task task) {
boolean ret = false;
if (task != null && !mChildren.contains(task)) {
if (task != null && !mChildren.contains(task)) {//任务不为空,并且还不在列表中,则将其加入
ret = mChildren.add(task);
if (ret) {
if (ret) {//成功加入以后继续设置关系
// need to set prior sibling and parent
task.setPriorSibling(mChildren.isEmpty() ? null : mChildren
.get(mChildren.size() - 1));
task.setParent(this);
task.setParent(this);//设置任务的父子关系
}
}
return ret;
}
public boolean addChildTask(Task task, int index) {
public boolean addChildTask(Task task, int index) {//更进一步的实现在指定索引位置插入任务
if (index < 0 || index > mChildren.size()) {
Log.e(TAG, "add child task: invalid index");
return false;
@ -260,9 +260,9 @@ public class TaskList extends Node {
return true;
}
public boolean removeChildTask(Task task) {
public boolean removeChildTask(Task task) {//移除子任务
boolean ret = false;
int index = mChildren.indexOf(task);
int index = mChildren.indexOf(task);//查找其索引
if (index != -1) {
ret = mChildren.remove(task);
@ -281,7 +281,7 @@ public class TaskList extends Node {
return ret;
}
public boolean moveChildTask(Task task, int index) {
public boolean moveChildTask(Task task, int index) {//定向移除对应位置的任务
if (index < 0 || index >= mChildren.size()) {
Log.e(TAG, "move child task: invalid index");
@ -299,7 +299,7 @@ public class TaskList extends Node {
return (removeChildTask(task) && addChildTask(task, index));
}
public Task findChildTaskByGid(String gid) {
public Task findChildTaskByGid(String gid) {//通过Gid查找任务
for (int i = 0; i < mChildren.size(); i++) {
Task t = mChildren.get(i);
if (t.getGid().equals(gid)) {
@ -309,7 +309,7 @@ public class TaskList extends Node {
return null;
}
public int getChildTaskIndex(Task task) {
public int getChildTaskIndex(Task task) {//获取任务对应的索引
return mChildren.indexOf(task);
}
@ -323,7 +323,7 @@ public class TaskList extends Node {
public Task getChilTaskByGid(String gid) {
for (Task task : mChildren) {
if (task.getGid().equals(gid))
if (task.getGid().equals(gid))//找到一个gid相符的即为所要的任务
return task;
}
return null;

@ -15,18 +15,26 @@
*/
package net.micode.notes.gtask.exception;
/**
* @method: ActionFailureException
* @description:ActionFailureException RuntimeException
*
* serialVersionUID
* @date: 11:05
* @author: Xia Yanbo
*/
public class ActionFailureException extends RuntimeException {
private static final long serialVersionUID = 4425249765923293627L;
private static final long serialVersionUID = 4425249765923293627L;//序列化,用于验证版本一致性
//构造方法
public ActionFailureException() {
super();
super();//用构造方法赋初值,调用父类无参数的构造方法
}
//构造方法
public ActionFailureException(String paramString) {
super(paramString);
super(paramString);//调用父类有参数的构造方法
}
//构造方法
public ActionFailureException(String paramString, Throwable paramThrowable) {
super(paramString, paramThrowable);
}

@ -14,20 +14,32 @@
* limitations under the License.
*/
package net.micode.notes.gtask.exception;
package net.micode.notes.gtask.exception;//调用完成异常处理
/**
* @method: NetworkFailureException
* @description:NetworkFailureException Exception
*
* //定义了私有参数serialVersionUID是序列化用于验证版本一致性
* @date: 11:07
* @author: Xia Yanbo
* @param:
* @param:
* @param:
*/
public class NetworkFailureException extends Exception {
private static final long serialVersionUID = 2107610287180234136L;
private static final long serialVersionUID = 2107610287180234136L;//序列化,用于验证版本一致性
//构造方法
public NetworkFailureException() {
super();
super();//用构造方法赋初值,调用父类无参数的构造方法
}
//构造方法
public NetworkFailureException(String paramString) {
super(paramString);
super(paramString);//调用父类有参数的构造方法
}
//构造方法
public NetworkFailureException(String paramString, Throwable paramThrowable) {
super(paramString, paramThrowable);
}
}

@ -29,10 +29,21 @@ import net.micode.notes.ui.NotesListActivity;
import net.micode.notes.ui.NotesPreferenceActivity;
/**
* @method: GTaskASyncTask
* @description:GTaskASyncTask AsyncTask
*
* 4
* mcontext 访context
* mOnCompleteListener
* mNotifiManager mTaskManager
* @date: 9:01
* @author: Xia Yanbo
*/
public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
private static int GTASK_SYNC_NOTIFICATION_ID = 5234235;
private static int GTASK_SYNC_NOTIFICATION_ID = 5234235;//序列化,用于验证版本
//声明定义一个接口OnCompleteListener实现放在后面
public interface OnCompleteListener {
void onComplete();
}
@ -44,7 +55,16 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
private GTaskManager mTaskManager;
private OnCompleteListener mOnCompleteListener;
/**
* @method: GTaskASyncTask
* @description:GTaskASyncTask
* @date: 16:11
* @author: Xia Yanbo
* @param: mcontext 访context
* @param: mOnCompleteListener
* @param: mNotifiManager
* @param: mTaskManager
*/
public GTaskASyncTask(Context context, OnCompleteListener listener) {
mContext = context;
mOnCompleteListener = listener;
@ -52,22 +72,42 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
.getSystemService(Context.NOTIFICATION_SERVICE);
mTaskManager = GTaskManager.getInstance();
}
/**
* @method: GTaskASyncTask
* @description:
* @date: 8:32
* @author: Xia Yanbo
*/
public void cancelSync() {
mTaskManager.cancelSync();
}
/**
* @method: GTaskASyncTask
* @description:
* @date: 8:33
* @author: Xia Yanbo
* @param: message
*/
public void publishProgess(String message) {
publishProgress(new String[] {
message
});
}
/**
* @method: GTaskASyncTask
* @description:
* @date: 8:35
* @author: Xia Yanbo
* @param:tickerIdID
* @param:content
* @return:NULL
*/
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;
notification.flags = Notification.FLAG_AUTO_CANCEL;//打上标识,用于判断发送报错信息和通知操作等
PendingIntent pendingIntent;
if (tickerId != R.string.ticker_success) {
pendingIntent = PendingIntent.getActivity(mContext, 0, new Intent(mContext,
@ -79,24 +119,43 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
}
// notification.setLatestEventInfo(mContext, mContext.getString(R.string.app_name), content,
// pendingIntent);
mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);
mNotifiManager.notify(GTASK_SYNC_NOTIFICATION_ID, notification);//直接调用父类的方法
}
/**
* @method: GTaskASyncTask
* @description:
* @date: 8:46
* @author: Xia Yanbo
* @return:
*/
@Override
protected Integer doInBackground(Void... unused) {
publishProgess(mContext.getString(R.string.sync_progress_login, NotesPreferenceActivity
.getSyncAccountName(mContext)));
.getSyncAccountName(mContext)));//获取用户的状态信息
return mTaskManager.sync(mContext, this);
}
/**
* @method: GTaskASyncTask
* @description:
* @date: 8:50
* @author: Xia Yanbo
* @param:Progress
*/
@Override
protected void onProgressUpdate(String... progress) {
showNotification(R.string.ticker_syncing, progress[0]);
if (mContext instanceof GTaskSyncService) {
showNotification(R.string.ticker_syncing, progress[0]);//显示正在进行同步操作的通知
if (mContext instanceof GTaskSyncService) {//检查是否是GTaskSyncService的实例。
((GTaskSyncService) mContext).sendBroadcast(progress[0]);
// 如果是就调用该服务的sendBroadcast方法发送广播通知其他组件同步的进度。
}
}
/**
* @method: GTaskASyncTask
* @description:
* @date: 8:57
* @author: Xia Yanbo
* @param:result
*/
@Override
protected void onPostExecute(Integer result) {
if (result == GTaskManager.STATE_SUCCESS) {
@ -111,7 +170,7 @@ public class GTaskASyncTask extends AsyncTask<Void, String, Integer> {
showNotification(R.string.ticker_cancel, mContext
.getString(R.string.error_sync_cancelled));
}
if (mOnCompleteListener != null) {
if (mOnCompleteListener != null) {//如果监听到了报文,创建一个新的线程来通知任务完成(减少主进程时间浪费)
new Thread(new Runnable() {
public void run() {

@ -33,78 +33,102 @@ import net.micode.notes.data.Notes.TextNote;
import java.util.ArrayList;
/**
* @classname: Note
* @description:便便
* 便
* @date: 2024/1/2 21:31
* @author: Xia Yanbo
*/
public class Note {
private ContentValues mNoteDiffValues;
private NoteData mNoteData;
private static final String TAG = "Note";
/**
* Create a new note id for adding a new note to databases
* @classname: Note
* @description:便
* @date: 2024/1/2 20:36
* @author: Xia Yanbo
* @param:context
* @param:folderId id
* @return:noteIDid
*/
public static synchronized long getNewNoteId(Context context, long folderId) {
public static synchronized long getNewNoteId(Context context, long folderId) {//控制类的所有实例的并发访问
// Create a new note in the database
//初始化变量的信息
ContentValues values = new ContentValues();
long createdTime = System.currentTimeMillis();
values.put(NoteColumns.CREATED_DATE, createdTime);
values.put(NoteColumns.MODIFIED_DATE, createdTime);
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);
values.put(NoteColumns.CREATED_DATE, createdTime);//创建时间
values.put(NoteColumns.MODIFIED_DATE, createdTime);//修改时间
values.put(NoteColumns.TYPE, Notes.TYPE_NOTE);//便签类型
values.put(NoteColumns.LOCAL_MODIFIED, 1);//本地修改位,表示在本地被修改过与否
values.put(NoteColumns.PARENT_ID, folderId);//所属包的id
Uri uri = context.getContentResolver().insert(Notes.CONTENT_NOTE_URI, values);//插入新的便签记录(标记)
long noteId = 0;
try {
noteId = Long.valueOf(uri.getPathSegments().get(1));
} catch (NumberFormatException e) {
noteId = Long.valueOf(uri.getPathSegments().get(1));//获取新笔记纪录的id
} catch (NumberFormatException e) {//获取失败报错
Log.e(TAG, "Get note id error :" + e.toString());
noteId = 0;
}
//如果noteid为-1抛出id错误的信息
if (noteId == -1) {
throw new IllegalStateException("Wrong note id:" + noteId);
}
return noteId;
}
//初始化定义两个变量用来存储便签的数据,一个是存储便签属性、一个是存储便签内容
public Note() {
mNoteDiffValues = new ContentValues();
mNoteData = new NoteData();
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());
mNoteDiffValues.put(key, value);//键值id
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);
}
//设置通话数据
public void setCallData(String key, String value) {
mNoteData.setCallData(key, value);
}
//判断本地的文件有没有被修改
public boolean isLocalModified() {
return mNoteDiffValues.size() > 0 || mNoteData.isLocalModified();
}
/**
* @classname: Note
* @methodname syncNote
* @description:便
* @date: 2024/1/2 20:54
* @author: Xia Yanbo
* @param:context
* @param:noteid便id
* @return:boolean
*/
public boolean syncNote(Context context, long noteId) {
if (noteId <= 0) {
throw new IllegalArgumentException("Wrong note id:" + noteId);
}
//没有修改过则不需要更新
if (!isLocalModified()) {
return true;
}
@ -112,7 +136,7 @@ public class Note {
/**
* In theory, once data changed, the note should be updated on {@link NoteColumns#LOCAL_MODIFIED} and
* {@link NoteColumns#MODIFIED_DATE}. For data safety, though update note fails, we also update the
* note data info
* note data info
*/
if (context.getContentResolver().update(
ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId), mNoteDiffValues, null,
@ -120,8 +144,8 @@ public class Note {
Log.e(TAG, "Update note error, should not happen");
// Do not return, fall through
}
mNoteDiffValues.clear();
mNoteDiffValues.clear();//清除属性
//如果笔记在本地被修改过并且推送至ContentResolver失败则返回false
if (mNoteData.isLocalModified()
&& (mNoteData.pushIntoContentResolver(context, noteId) == null)) {
return false;
@ -131,86 +155,97 @@ public class Note {
}
private class NoteData {
private long mTextDataId;
private ContentValues mTextDataValues;
private long mTextDataId;//文本数据的id
private long mCallDataId;
private ContentValues mTextDataValues;//存储文本数据的键值对
private ContentValues mCallDataValues;
private long mCallDataId;//通话数据的id
private static final String TAG = "NoteData";
private ContentValues mCallDataValues;//存储通话数据
private static final String TAG = "NoteData";//记录标签,为日志记录打上标签。
//给新来的见证便签的键值以及id
public NoteData() {
mTextDataValues = new ContentValues();
mCallDataValues = new ContentValues();
mTextDataId = 0;
mCallDataId = 0;
}
//比较文本大小,确定是否被修改过
boolean isLocalModified() {
return mTextDataValues.size() > 0 || mCallDataValues.size() > 0;
}
//设置文本数据的id
void setTextDataId(long id) {
if(id <= 0) {
throw new IllegalArgumentException("Text data id should larger than 0");
}
mTextDataId = id;
}
//设置通话数据的id
void setCallDataId(long id) {
if (id <= 0) {
throw new IllegalArgumentException("Call data id should larger than 0");
}
mCallDataId = id;
}
//设置通话数据的id
void setCallData(String key, String value) {
mCallDataValues.put(key, value);
mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1);
mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
}
//设置文本数据
void setTextData(String key, String value) {
mTextDataValues.put(key, value);
mNoteDiffValues.put(NoteColumns.LOCAL_MODIFIED, 1);
mNoteDiffValues.put(NoteColumns.MODIFIED_DATE, System.currentTimeMillis());
}
/**
* @classname: NoteData
* @methodname pushIntoContentResolver
* @description:
* @date: 2024/1/2 21:10
* @author: Xia Yanbo
* @param:noteId便id
* @param:context
* @return:uri
*/
Uri pushIntoContentResolver(Context context, long noteId) {
/**
* Check for safety
*/
//检查笔记的id是否正确
if (noteId <= 0) {
throw new IllegalArgumentException("Wrong note id:" + noteId);
}
//创建行动列表
ArrayList<ContentProviderOperation> operationList = new ArrayList<ContentProviderOperation>();
ContentProviderOperation.Builder builder = null;
//如果文本数据不为空,进行更新操作
if(mTextDataValues.size() > 0) {
mTextDataValues.put(DataColumns.NOTE_ID, noteId);
// 如果文本数据ID为0说明是新插入的数据
if (mTextDataId == 0) {
mTextDataValues.put(DataColumns.MIME_TYPE, TextNote.CONTENT_ITEM_TYPE);
Uri uri = context.getContentResolver().insert(Notes.CONTENT_DATA_URI,
mTextDataValues);
mTextDataValues);//设置对应的关键键值,插入新的文本数据
try {
setTextDataId(Long.valueOf(uri.getPathSegments().get(1)));
} catch (NumberFormatException e) {
setTextDataId(Long.valueOf(uri.getPathSegments().get(1)));//获取数据的id
} catch (NumberFormatException e) {//获取失败打印错误信息
Log.e(TAG, "Insert new text data fail with noteId" + noteId);
mTextDataValues.clear();
return null;
}
} else {
} else {//创建一个更新操作,并设置更新的数据和条件
builder = ContentProviderOperation.newUpdate(ContentUris.withAppendedId(
Notes.CONTENT_DATA_URI, mTextDataId));
builder.withValues(mTextDataValues);
operationList.add(builder.build());
operationList.add(builder.build());//将更新操作添加到操作列表中
}
mTextDataValues.clear();
}
//同理如果通信数据不为空,进行更新操作
if(mCallDataValues.size() > 0) {
mCallDataValues.put(DataColumns.NOTE_ID, noteId);
if (mCallDataId == 0) {
@ -232,19 +267,19 @@ public class Note {
}
mCallDataValues.clear();
}
//行动列表非空
if (operationList.size() > 0) {
try {
try { // 使用内容解析器ContentResolver的applyBatch方法来批量执行操作列表中的操作
ContentProviderResult[] results = context.getContentResolver().applyBatch(
Notes.AUTHORITY, operationList);
return (results == null || results.length == 0 || results[0] == null) ? null
: ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId);
: ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, noteId);//返回操作完成后的结果
} catch (RemoteException e) {
Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
return null;
} catch (OperationApplicationException e) {
Log.e(TAG, String.format("%s: %s", e.toString(), e.getMessage()));
return null;
return null;//报错反馈
}
}
return null;

@ -31,37 +31,43 @@ import net.micode.notes.data.Notes.NoteColumns;
import net.micode.notes.data.Notes.TextNote;
import net.micode.notes.tool.ResourceParser.NoteBgResources;
/**
* @classname: WorkingNote
* @description:便便便
* 便
* @date: 2024/1/4 11:03
* @author: Xia Yanbo
*/
public class WorkingNote {
// Note for the working note
private Note mNote;
private Note mNote;//便签对象
// Note Id
private long mNoteId;
private long mNoteId;//便签的id
// Note content
public String mContent;
private String mContent;//内容字符串
// Note mode
private int mMode;
private long mAlertDate;
private int mMode;//便签所处的模式(任务清单/普通)
private long mModifiedDate;
private long mAlertDate;//提醒时间
private int mBgColorId;
private long mModifiedDate;//修改日期
private int mWidgetId;
private int mBgColorId;//背景颜色
private int mWidgetType;
private int mWidgetId;//小插件的id号
private long mFolderId;
private int mWidgetType;//小插件的类型
private Context mContext;
private long mFolderId;//所属便签包的id号
private static final String TAG = "WorkingNote";
private Context mContext;//便签的上下文
private boolean mIsDeleted;
private static final String TAG = "WorkingNote";//用于接收日志的标签
private NoteSettingChangedListener mNoteSettingStatusListener;
private boolean mIsDeleted;//表示是否已经被删除
private NoteSettingChangedListener mNoteSettingStatusListener;//设置一个监听器,监听便签设置的改变
//定义数据的字段
public static final String[] DATA_PROJECTION = new String[] {
DataColumns.ID,
DataColumns.CONTENT,
@ -71,7 +77,7 @@ public class WorkingNote {
DataColumns.DATA3,
DataColumns.DATA4,
};
//定义便签的字段
public static final String[] NOTE_PROJECTION = new String[] {
NoteColumns.PARENT_ID,
NoteColumns.ALERTED_DATE,
@ -80,7 +86,7 @@ public class WorkingNote {
NoteColumns.WIDGET_TYPE,
NoteColumns.MODIFIED_DATE
};
//数据相关的参数
private static final int DATA_ID_COLUMN = 0;
private static final int DATA_CONTENT_COLUMN = 1;
@ -88,7 +94,7 @@ public class WorkingNote {
private static final int DATA_MIME_TYPE_COLUMN = 2;
private static final int DATA_MODE_COLUMN = 3;
//便签相关的参数
private static final int NOTE_PARENT_ID_COLUMN = 0;
private static final int NOTE_ALERTED_DATE_COLUMN = 1;
@ -102,19 +108,38 @@ public class WorkingNote {
private static final int NOTE_MODIFIED_DATE_COLUMN = 5;
// New note construct
/**
* @classname: WorkingNote
* @methodname WorkingNote
* @description:便
* @date: 2024/1/3 19:26
* @author: Xia Yanbo
* @param:context
* @param:folderIdid
*/
private WorkingNote(Context context, long folderId) {
mContext = context;
mAlertDate = 0;
mModifiedDate = System.currentTimeMillis();
mFolderId = folderId;
mNote = new Note();
mNoteId = 0;
mNoteId = 0;//初始化笔记id为0
mIsDeleted = false;
mMode = 0;
mWidgetType = Notes.TYPE_WIDGET_INVALIDE;
}
// Existing note construct
/**
* @classname: WorkingNote
* @methodname WorkingNote
* @description:使
* @date: 2024/1/3 21:33
* @author: Xia Yanbo
* @param:context
* @param:noteIdid
* @param:folderIdid
*/
private WorkingNote(Context context, long noteId, long folderId) {
mContext = context;
mNoteId = noteId;
@ -123,14 +148,23 @@ public class WorkingNote {
mNote = new Note();
loadNote();
}
/**
* @classname: WorkingNote
* @methodname loadNote
* @description:/便
* @date: 2024/1/3 21:34
* @author: Xia Yanbo
*/
private void loadNote() {
//查询数据库获取与给定笔记id关联的笔记
Cursor cursor = mContext.getContentResolver().query(
ContentUris.withAppendedId(Notes.CONTENT_NOTE_URI, mNoteId), NOTE_PROJECTION, null,
null, null);
if (cursor != null) {
//如果cursor不为空移动到结果集的第一行
if (cursor.moveToFirst()) {
//从结果集获取各个属性值
mFolderId = cursor.getLong(NOTE_PARENT_ID_COLUMN);
mBgColorId = cursor.getInt(NOTE_BG_COLOR_ID_COLUMN);
mWidgetId = cursor.getInt(NOTE_WIDGET_ID_COLUMN);
@ -139,33 +173,43 @@ public class WorkingNote {
mModifiedDate = cursor.getLong(NOTE_MODIFIED_DATE_COLUMN);
}
cursor.close();
} else {
} else {//如果找不到关联的笔记抛出异常
Log.e(TAG, "No note with id:" + mNoteId);
throw new IllegalArgumentException("Unable to find note with id " + mNoteId);
}
// 调用loadNoteData方法继续加载与笔记相关的其他数据标记
loadNoteData();
}
/**
* @classname: WorkingNote
* @methodname loadNoteData
* @description:便
* @date: 2024/1/3 21:48
* @author: Xia Yanbo
*/
private void loadNoteData() {
//查询数据库获取与给定笔记id关联的笔记
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);
String type = cursor.getString(DATA_MIME_TYPE_COLUMN);//获取当前笔记的类型
//如果笔记是普通的笔记获取笔记内容、模式、id等参数完成赋值
if (DataConstants.NOTE.equals(type)) {
mContent = cursor.getString(DATA_CONTENT_COLUMN);
mMode = cursor.getInt(DATA_MODE_COLUMN);
mNote.setTextDataId(cursor.getLong(DATA_ID_COLUMN));
} else if (DataConstants.CALL_NOTE.equals(type)) {
} else if (DataConstants.CALL_NOTE.equals(type)) {//如果数据是通话数据从数据行中直接获取数据id
mNote.setCallDataId(cursor.getLong(DATA_ID_COLUMN));
} else {
Log.d(TAG, "Wrong note type with type:" + type);
}
} while (cursor.moveToNext());
} while (cursor.moveToNext());//光标移动到下一行
}
cursor.close();
} else {
@ -173,7 +217,7 @@ public class WorkingNote {
throw new IllegalArgumentException("Unable to find note's data with id " + mNoteId);
}
}
//创建一个空的便签设置属性以及资源的id号等等信息
public static WorkingNote createEmptyNote(Context context, long folderId, int widgetId,
int widgetType, int defaultBgColorId) {
WorkingNote note = new WorkingNote(context, folderId);
@ -182,15 +226,17 @@ public class WorkingNote {
note.setWidgetType(widgetType);
return note;
}
//读取便签的内容
public static WorkingNote load(Context context, long id) {
return new WorkingNote(context, id, 0);
}
public synchronized boolean saveNote() {
//检查笔记是否有保存的价值
if (isWorthSaving()) {
if (!existInDatabase()) {
if ((mNoteId = Note.getNewNoteId(mContext, mFolderId)) == 0) {
// 如果不在数据库里根据包的id和上下文获取一个新的笔记ID如果获取失败则返回false并记录日志
if ((mNoteId = Note.getNewNoteId(mContext, mFolderId)) == 0) {//获取失败返回的id是0
Log.e(TAG, "Create new note fail with id:" + mNoteId);
return false;
}
@ -200,6 +246,7 @@ public class WorkingNote {
/**
* Update widget content if there exist any widget of this note
*
*/
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
&& mWidgetType != Notes.TYPE_WIDGET_INVALIDE
@ -211,12 +258,13 @@ 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;
@ -224,11 +272,11 @@ public class WorkingNote {
return true;
}
}
//设置笔记设置状态的监听器为工作状态
public void setOnSettingStatusChangedListener(NoteSettingChangedListener l) {
mNoteSettingStatusListener = l;
}
//设置提醒的日期
public void setAlertDate(long date, boolean set) {
if (date != mAlertDate) {
mAlertDate = date;
@ -238,7 +286,7 @@ public class WorkingNote {
mNoteSettingStatusListener.onClockAlertChanged(date, set);
}
}
//删除标记值
public void markDeleted(boolean mark) {
mIsDeleted = mark;
if (mWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID
@ -247,6 +295,7 @@ public class WorkingNote {
}
}
//设置背景的颜色id
public void setBgColorId(int id) {
if (id != mBgColorId) {
mBgColorId = id;
@ -256,9 +305,10 @@ public class WorkingNote {
mNote.setNoteValue(NoteColumns.BG_COLOR_ID, String.valueOf(id));
}
}
//设置任务清单模式
public void setCheckListMode(int mode) {
if (mMode != mode) {
//进行任务清单模式必要组件的的设置
if (mNoteSettingStatusListener != null) {
mNoteSettingStatusListener.onCheckListModeChanged(mMode, mode);
}
@ -266,7 +316,7 @@ public class WorkingNote {
mNote.setTextData(TextNote.MODE, String.valueOf(mMode));
}
}
//设定组件相关的类型id等信息
public void setWidgetType(int type) {
if (type != mWidgetType) {
mWidgetType = type;
@ -280,24 +330,25 @@ public class WorkingNote {
mNote.setNoteValue(NoteColumns.WIDGET_ID, String.valueOf(mWidgetId));
}
}
//设置当前工作便签的文本
public void setWorkingText(String text) {
if (!TextUtils.equals(mContent, text)) {
mContent = text;
mContent = text;//文本不一样时更新内容
mNote.setTextData(DataColumns.CONTENT, mContent);
}
}
//将便签转化为通话便签
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);
}
//根据需要,返回对应的参数值
public String getContent() {
return mContent;
}
@ -341,7 +392,13 @@ public class WorkingNote {
public int getWidgetType() {
return mWidgetType;
}
/**
* @classname: WorkingNote
* @description:便
*
* @date: 2024/1/4 9:22
* @author: Xia Yanbo
*/
public interface NoteSettingChangedListener {
/**
* Called when the background color of current note has just changed
@ -355,6 +412,7 @@ public class WorkingNote {
/**
* Call when user create note from widget
*
*/
void onWidgetChanged();

@ -43,7 +43,6 @@ import android.os.Environment;
import android.preference.PreferenceManager;
import android.provider.DocumentsContract;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.Spannable;
import android.text.SpannableString;
@ -98,7 +97,7 @@ import java.util.regex.Pattern;
* @author: Xia Yanbo
*/
public class NoteEditActivity extends AppCompatActivity implements OnClickListener,
public class NoteEditActivity extends Activity implements OnClickListener,
NoteSettingChangedListener, OnTextViewChangeListener {
//定义视图组件的基本数据(后面出现在了操作菜可选项里)
private class HeadViewHolder {

@ -1,4 +1,4 @@
/*
/*
* Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@ -36,16 +36,23 @@ import net.micode.notes.R;
import java.util.HashMap;
import java.util.Map;
/**
* @classname: NoteEditText
* @description:NoteEditText EditText
*
*
* @date: 2023/12/24 9:22
* @author: Xia Yanbo
*/
public class NoteEditText extends EditText {
private static final String TAG = "NoteEditText";
private int mIndex;
private static final String TAG = "NoteEditText";//标签,分类接收特定信息
private int mIndex;//声明文本的索引
private int mSelectionStartBeforeDelete;
//声明字符串常量,标志电话、网址、邮件
private static final String SCHEME_TEL = "tel:" ;
private static final String SCHEME_HTTP = "http:" ;
private static final String SCHEME_EMAIL = "mailto:" ;
//设置映射,将文本内容拼接成完整的网址
private static final Map<String, Integer> sSchemaActionResMap = new HashMap<String, Integer>();
static {
sSchemaActionResMap.put(SCHEME_TEL, R.string.note_link_tel);
@ -55,53 +62,65 @@ 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
* delete
*/
void onEditTextDelete(int index, String text);
/**
* Add edit text after current edit text when {@link KeyEvent#KEYCODE_ENTER}
* happen
* enter
*/
void onEditTextEnter(int index, String text);
/**
* Hide or show item option when text change
*
*/
void onTextChange(int index, boolean hasText);
}
//声明文本视图变化的监听器
private OnTextViewChangeListener mOnTextViewChangeListener;
//实例化NoteEditText对象
public NoteEditText(Context context) {
super(context, null);
mIndex = 0;
}
//为本本编辑设置一个索引
public void setIndex(int index) {
mIndex = index;
}
//直接调用父类,定义好文本视图变化的监听器
public void setOnTextViewChangeListener(OnTextViewChangeListener listener) {
mOnTextViewChangeListener = listener;
}
//NoteEditText的构造函数通过文本编辑风格的参数集实例化
public NoteEditText(Context context, AttributeSet attrs) {
super(context, attrs, android.R.attr.editTextStyle);
}
//NoteEditText的构造函数通过文本编辑风格的参数集实例化支持用户自定义风格
public NoteEditText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
super(context, attrs, defStyle);//允许自定义风格
// TODO Auto-generated constructor stub
}
/**
* @classname: NoteEditText
* @methodname onTouchEvent
* @description:
* @date: 2023/12/24 10:05
* @author: Xia Yanbo
* @param:event
* @return:boolean
*/
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
switch (event.getAction()) {//对动作事件进行分类的判别
case MotionEvent.ACTION_DOWN:
int x = (int) event.getX();
@ -112,15 +131,24 @@ public class NoteEditText extends EditText {
y += getScrollY();
Layout layout = getLayout();
int line = layout.getLineForVertical(y);
int off = layout.getOffsetForHorizontal(line, x);
int line = layout.getLineForVertical(y);//直接获取行数
int off = layout.getOffsetForHorizontal(line, x);//从边界起数获得偏移
Selection.setSelection(getText(), off);
break;
}
return super.onTouchEvent(event);
return super.onTouchEvent(event);//再调用父类的方法进行后续的处理
}
/**
* @classname: NoteEditText
* @methodname onKeyDown
* @description:
* @date: 2023/12/24 10:15
* @author: Xia Yanbo
* @param:keyCode
* @param:event
* @return:boolean
*/
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
@ -137,7 +165,16 @@ public class NoteEditText extends EditText {
}
return super.onKeyDown(keyCode, event);
}
/**
* @classname: NoteEditText
* @methodname onKeyUp
* @description:
* @date: 2023/12/24 10:15
* @author: Xia Yanbo
* @param:keyCode
* @param:event
* @return:boolean
*/
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
switch(keyCode) {
@ -166,11 +203,20 @@ public class NoteEditText extends EditText {
}
return super.onKeyUp(keyCode, event);
}
/**
* @classname: NoteEditText
* @methodname onFocusChanged
* @description:
* @date: 2023/12/24 10:25
* @author: Xia Yanbo
* @param:focused
* @param:direction
* @param:reviouslyFocusedRect
*/
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
if (mOnTextViewChangeListener != null) {
if (!focused && TextUtils.isEmpty(getText())) {
if (!focused && TextUtils.isEmpty(getText())) {//当没有输入,关注的视图也发生改变,设置隐藏
mOnTextViewChangeListener.onTextChange(mIndex, false);
} else {
mOnTextViewChangeListener.onTextChange(mIndex, true);
@ -178,19 +224,27 @@ public class NoteEditText extends EditText {
}
super.onFocusChanged(focused, direction, previouslyFocusedRect);
}
/**
* @classname: NoteEditText
* @methodname onCreateContextMenu
* @description:
* @date: 2023/12/24 10:34
* @author: Xia Yanbo
* @param:contextMenu
*/
@Override
protected void onCreateContextMenu(ContextMenu menu) {
if (getText() instanceof Spanned) {
int selStart = getSelectionStart();
int selEnd = getSelectionEnd();
if (getText() instanceof Spanned) {//检查文本的类型 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);
//获取选择的文本范围内获取所有的 URLSpan 对象。URLSpan 是用于表示文本中的链接的。
final URLSpan[] urls = ((Spanned) getText()).getSpans(min, max, URLSpan.class);//获取范围
if (urls.length == 1) {
int defaultResId = 0;
//根据URL获取资源
for(String schema: sSchemaActionResMap.keySet()) {
if(urls[0].getURL().indexOf(schema) >= 0) {
defaultResId = sSchemaActionResMap.get(schema);
@ -201,9 +255,10 @@ public class NoteEditText extends EditText {
if (defaultResId == 0) {
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);
@ -212,6 +267,6 @@ public class NoteEditText extends EditText {
});
}
}
super.onCreateContextMenu(menu);
super.onCreateContextMenu(menu);//调用父类方法
}
}

@ -31,7 +31,6 @@ import android.database.Cursor;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
@ -79,7 +78,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashSet;
public class NotesListActivity extends AppCompatActivity implements OnClickListener, OnItemLongClickListener {
public class NotesListActivity extends Activity implements OnClickListener, OnItemLongClickListener {
//首页背景变换
private int mode = -1;
private static final int FOLDER_NOTE_LIST_QUERY_TOKEN = 0;
@ -127,8 +126,6 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
public static final int NOTES_LISTVIEW_SCROLL_RATE = 30;
private NoteItemData mFocusNoteDataItem;
//表示是否在私密模式
public static int secret_mode = 0;
private static final String NORMAL_SELECTION = NoteColumns.PARENT_ID + "=?";
@ -418,35 +415,10 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
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 = "444";
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 {
@ -803,10 +775,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
} else {
Log.e(TAG, "Wrong state:" + mState);
}
if(secret_mode == 1)
menu.findItem(R.id.menu_secret).setVisible(false);
else
menu.findItem(R.id.menu_quit_secret).setVisible(false);
if(mode==-1){//decade
menu.findItem(R.id.menu_decade).setVisible(false);
}
@ -854,53 +823,6 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe
else if(item.getItemId()==R.id.menu_search) {
onSearchRequested();
}
else if(item.getItemId()==R.id.menu_secret)
{//进入私密模式
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) {
Toast.makeText(NotesListActivity.this,"您已进入私密模式",Toast.LENGTH_SHORT).show();
secret_mode = 1;
startAsyncNotesListQuery();
}
});
dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which){}
});
dialog.show();
startAsyncNotesListQuery();
}
else if(item.getItemId()==R.id.menu_quit_secret)
{ //退出私密模式
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) {
secret_mode = 0;
Toast.makeText(NotesListActivity.this,"您已退出私密模式",Toast.LENGTH_SHORT).show();
startAsyncNotesListQuery();
}
});
dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which){}
});
dialog.show();
}
return true;
}

@ -15,7 +15,7 @@
limitations under the License.
-->
<FrameLayout xmlns:tools="http://schemas.android.com/tools"
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/list_background"
@ -61,7 +61,6 @@
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@drawable/bg_btn_set_color" />
</LinearLayout>
<LinearLayout
@ -396,8 +395,8 @@
android:layout_marginRight="6dip"
android:layout_marginBottom="-7dip"
android:src="@drawable/selected" />
</FrameLayout>
</FrameLayout>
</LinearLayout>
<ImageButton
android:id="@+id/add_img_btn"
@ -406,8 +405,5 @@
android:layout_marginLeft="7dp"
android:layout_marginTop="600dp"
android:layout_marginBottom="7dp"
android:background="@android:drawable/ic_menu_camera"
android:visibility="visible"
tools:visibility="visible" />
android:src="@android:drawable/ic_menu_gallery" />
</FrameLayout>

@ -44,12 +44,4 @@
<item
android:id="@+id/menu_zio"
android:title="@string/menu_zio"/>
<item
android:id="@+id/menu_secret"
android:title="@string/menu_secret"/>
<item
android:id="@+id/menu_quit_secret"
android:title="@string/menu_quit_secret"/>
</menu>

@ -1,7 +0,0 @@
<resources>
<style name="ThemeOverlay.Notesmaster.FullscreenContainer" parent="">
<item name="fullscreenBackgroundColor">@color/light_blue_900</item>
<item name="fullscreenTextColor">@color/light_blue_A400</item>
</style>
</resources>

@ -71,6 +71,8 @@
<string name="alert_message_delete_note">确认要删除该条便签吗?</string>
<string name="alert_message_delete_folder">确认删除文件夹及所包含的便签吗?</string>
<string name="format_move_notes_to_folder">已将所选 %1$d 条便签移到 %2$s 文件夹</string>
<string name="menu_secret">私密模式</string>
<string name="menu_quit_secret">退出私密模式</string>
<!-- export text -->
<string name="error_sdcard_unmounted">SD卡被占用不能操作</string>
<string name="error_sdcard_export">导出文本时发生错误请检查SD卡</string>

@ -1,6 +0,0 @@
<resources>
<declare-styleable name="FullscreenAttrs">
<attr name="fullscreenBackgroundColor" format="color" />
<attr name="fullscreenTextColor" format="color" />
</declare-styleable>
</resources>

@ -17,9 +17,4 @@
<resources>
<color name="user_query_highlight">#335b5b5b</color>
<color name="light_blue_600">#FF039BE5</color>
<color name="light_blue_900">#FF01579B</color>
<color name="light_blue_A200">#FF40C4FF</color>
<color name="light_blue_A400">#FF00B0FF</color>
<color name="black_overlay">#66000000</color>
</resources>

@ -40,8 +40,6 @@
<!-- notes list string -->
<!--首页背景切换-->
<string name="menu_secret">secret model</string>
<string name="menu_quit_secret">quit secret model</string>
<string name="menu_decade">Background: decade</string>
<string name="menu_zio">Background: zio</string>

@ -16,22 +16,18 @@
-->
<resources>
<style name="TextAppearanceSuper">
<item name="android:textSize">@dimen/text_font_size_super</item>
<item name="android:textColorLink">#0000ff</item>
</style>
<style name="TextAppearanceLarge">
<item name="android:textSize">@dimen/text_font_size_large</item>
<item name="android:textColorLink">#0000ff</item>
</style>
<style name="TextAppearanceMedium">
<item name="android:textSize">@dimen/text_font_size_medium</item>
<item name="android:textColorLink">#0000ff</item>
</style>
<style name="TextAppearanceNormal">
<item name="android:textSize">@dimen/text_font_size_normal</item>
<item name="android:textColorLink">#0000ff</item>
@ -53,7 +49,7 @@
</style>
<style name="HighlightTextAppearancePrimary">
<item name="android:textSize">@dimen/text_font_size_normal</item>
<item name="android:textSize">@dimen/text_font_size_normal</item>
<item name="android:textColor">@color/primary_text_dark</item>
</style>
@ -67,16 +63,7 @@
</style>
<style name="NoteActionBarStyle" parent="@android:style/Widget.Holo.Light.ActionBar.Solid">
<!-- <item name="android:displayOptions" /> -->
<item name="android:displayOptions" />
<item name="android:visibility">visible</item>
</style>
<style name="Widget.Theme.Notesmaster.ActionBar.Fullscreen" parent="Widget.AppCompat.ActionBar">
<item name="android:background">@color/black_overlay</item>
</style>
<style name="Widget.Theme.Notesmaster.ButtonBar.Fullscreen" parent="">
<item name="android:background">@color/black_overlay</item>
<item name="android:buttonBarStyle">?android:attr/buttonBarStyle</item>
</style>
</resources>

@ -1,16 +0,0 @@
<resources>
<style name="Theme.Notesmaster" parent="Theme.AppCompat.Light" />
<style name="Theme.Notesmaster.Fullscreen" parent="Theme.Notesmaster">
<item name="android:actionBarStyle">@style/Widget.Theme.Notesmaster.ActionBar.Fullscreen
</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowBackground">@null</item>
</style>
<style name="ThemeOverlay.Notesmaster.FullscreenContainer" parent="">
<item name="fullscreenBackgroundColor">@color/light_blue_600</item>
<item name="fullscreenTextColor">@color/light_blue_A200</item>
</style>
</resources>
Loading…
Cancel
Save