diff --git a/doc/修改文件夹名称用例文档.docx b/doc/修改文件夹名称用例文档.docx new file mode 100644 index 0000000..351075c Binary files /dev/null and b/doc/修改文件夹名称用例文档.docx differ diff --git a/doc/实践模板-开源软件泛读、标注和维护报告文档.docx b/doc/实践模板-开源软件泛读、标注和维护报告文档.docx index 1663b78..a28e436 100644 Binary files a/doc/实践模板-开源软件泛读、标注和维护报告文档.docx and b/doc/实践模板-开源软件泛读、标注和维护报告文档.docx differ diff --git a/src/xiaomi/.idea/sonarlint/issuestore/0/4/0443b0f98e2a8a605b866a1b1bef7e47c8c8ea8e b/src/xiaomi/.idea/sonarlint/issuestore/0/4/0443b0f98e2a8a605b866a1b1bef7e47c8c8ea8e new file mode 100644 index 0000000..ead3490 --- /dev/null +++ b/src/xiaomi/.idea/sonarlint/issuestore/0/4/0443b0f98e2a8a605b866a1b1bef7e47c8c8ea8e @@ -0,0 +1,29 @@ + +g +java:S1301"KReplace this "switch" statement by "if" statements to increase readability.(۫ +X +java:S18749"=Remove this use of "FLAG_SHOW_WHEN_LOCKED"; it is deprecated.( +Q +java:S1874=";Remove this use of "FLAG_TURN_SCREEN_ON"; it is deprecated.( +Z +java:S1874?"?Remove this use of "FLAG_LAYOUT_INSET_DECOR"; it is deprecated.( +H +java:S1874["2Remove this use of "isScreenOn"; it is deprecated.( +O +java:S1874e":Remove this use of "setAudioStreamType"; it is deprecated.(0 +U +java:S1874g":Remove this use of "setAudioStreamType"; it is deprecated.(Ũ +` +java:S2147q"ECombine this catch with the one at line 110, which has the same body.( +[ +java:S2147t"ECombine this catch with the one at line 113, which has the same body.( +[ +java:S2147w"ECombine this catch with the one at line 116, which has the same body.(ﭣ +M +java:S1135o"2Complete the task associated to this TODO comment.(̐ +M +java:S1135r"2Complete the task associated to this TODO comment.(̐ +M +java:S1135u"2Complete the task associated to this TODO comment.(̐ +M +java:S1135x"2Complete the task associated to this TODO comment.(̐ \ No newline at end of file diff --git a/src/xiaomi/.idea/sonarlint/issuestore/0/8/08962fe591286696ecd017e3adc4630c1217309b b/src/xiaomi/.idea/sonarlint/issuestore/0/8/08962fe591286696ecd017e3adc4630c1217309b new file mode 100644 index 0000000..280a82e --- /dev/null +++ b/src/xiaomi/.idea/sonarlint/issuestore/0/8/08962fe591286696ecd017e3adc4630c1217309b @@ -0,0 +1,11 @@ + +t +java:S2293)"YReplace the type specification in this constructor call with the diamond operator ("<>").( +P +java:S1118":Add a private constructor to hide the implicit public one.( +q +java:S3252!"VUse static access with "android.provider.ContactsContract$DataColumns" for "MIMETYPE".( +r +java:S3252""\Use static access with "android.provider.ContactsContract$DataColumns" for "RAW_CONTACT_ID".( +t +java:S32524"^Use static access with "android.provider.ContactsContract$ContactsColumns" for "DISPLAY_NAME".( \ No newline at end of file diff --git a/src/xiaomi/.idea/sonarlint/issuestore/1/9/19661b4b3ff75e064358871f8409e1a1eef63bf6 b/src/xiaomi/.idea/sonarlint/issuestore/1/9/19661b4b3ff75e064358871f8409e1a1eef63bf6 new file mode 100644 index 0000000..2b0284e --- /dev/null +++ b/src/xiaomi/.idea/sonarlint/issuestore/1/9/19661b4b3ff75e064358871f8409e1a1eef63bf6 @@ -0,0 +1,9 @@ + +m +java:S37764"RRefactor this method to reduce its Cognitive Complexity from 16 to the 15 allowed.( +O +java:S1874@"9Remove this use of "setTextAppearance"; it is deprecated.( +O +java:S1874G"9Remove this use of "setTextAppearance"; it is deprecated.( +O +java:S1874Q"9Remove this use of "setTextAppearance"; it is deprecated.( \ No newline at end of file diff --git a/src/xiaomi/.idea/sonarlint/issuestore/1/a/1a4e3da7b86cbac8cbaa0189939fbddcc15fe216 b/src/xiaomi/.idea/sonarlint/issuestore/1/a/1a4e3da7b86cbac8cbaa0189939fbddcc15fe216 new file mode 100644 index 0000000..1adb464 --- /dev/null +++ b/src/xiaomi/.idea/sonarlint/issuestore/1/a/1a4e3da7b86cbac8cbaa0189939fbddcc15fe216 @@ -0,0 +1,16 @@ + +V java:S125"").(ə +o +java:S2293d"YReplace the type specification in this constructor call with the diamond operator ("<>").( +o +java:S2293t"YReplace the type specification in this constructor call with the diamond operator ("<>").(Ȫ +J +java:S1066\"/Merge this if statement with the enclosing one.(ڧ + +java:S1319c"mThe return type of this method should be an interface such as "Set" rather than the implementation "HashSet".( + +java:S1319s"mThe return type of this method should be an interface such as "Set" rather than the implementation "HashSet".( +j +java:S1104*"TMake widgetId a static final constant or non-public and provide accessors if needed.(ǎ +q +java:S1104+"VMake widgetType a static final constant or non-public and provide accessors if needed.(漬 +C +java:S5411f"(Use a primitive boolean expression here.(ɯ +C +java:S5411v"(Use a primitive boolean expression here.(ɯ +D +java:S5411"(Use a primitive boolean expression here.( +7 +java:S1116,"Remove this empty statement.( +D +java:S1874/".Remove this use of ""; it is deprecated.( +J +java:S2864e"4Iterate over the "entrySet" instead of the "keySet".(਷ +B +java:S1125f"'Remove the unnecessary boolean literal.(ɯ +J +java:S2864u"4Iterate over the "entrySet" instead of the "keySet".(਷ +B +java:S1125v"'Remove the unnecessary boolean literal.(ɯ +B +java:S1168"+Return an empty collection instead of null.( +C +java:S1125"'Remove the unnecessary boolean literal.( \ No newline at end of file diff --git a/src/xiaomi/.idea/sonarlint/issuestore/4/1/41b8b7f348f46f3b57551e41c1bbe95463dbc90e b/src/xiaomi/.idea/sonarlint/issuestore/4/1/41b8b7f348f46f3b57551e41c1bbe95463dbc90e new file mode 100644 index 0000000..7181765 --- /dev/null +++ b/src/xiaomi/.idea/sonarlint/issuestore/4/1/41b8b7f348f46f3b57551e41c1bbe95463dbc90e @@ -0,0 +1,13 @@ + +f +java:S11929"KDefine a constant instead of duplicating this literal "content://" 4 times.( +U +java:S11181":Add a private constructor to hide the implicit public one.(͓ +^ +java:S1214@"CMove constants defined in this interfaces to another class or enum.(⸫ +Z +java:S1214"CMove constants defined in this interfaces to another class or enum.( +V +java:S1118":Add a private constructor to hide the implicit public one.( +Q +java:S1118":Add a private constructor to hide the implicit public one.(߀ \ No newline at end of file diff --git a/src/xiaomi/.idea/sonarlint/issuestore/9/b/9b151666a10c2718f853e6607b8d80e85becee16 b/src/xiaomi/.idea/sonarlint/issuestore/9/b/9b151666a10c2718f853e6607b8d80e85becee16 index 72d562c..940b772 100644 --- a/src/xiaomi/.idea/sonarlint/issuestore/9/b/9b151666a10c2718f853e6607b8d80e85becee16 +++ b/src/xiaomi/.idea/sonarlint/issuestore/9/b/9b151666a10c2718f853e6607b8d80e85becee16 @@ -1,72 +1,74 @@ w -java:S2293"YReplace the type specification in this constructor call with the diamond operator ("<>").(艥8۪1 +java:S2293"YReplace the type specification in this constructor call with the diamond operator ("<>").(艥81 n -java:S1301"KReplace this "switch" statement by "if" statements to increase readability.(ד8۪1 +java:S1301"KReplace this "switch" statement by "if" statements to increase readability.(ד81 > -java:S1116e"Remove this empty statement.(8Ū۪1 +java:S1116e"Remove this empty statement.(81 h -java:S1124"EReorder the modifiers to comply with the Java Language Specification.(8Ǫ۪1 +java:S1124"EReorder the modifiers to comply with the Java Language Specification.(81 b -java:S1124"EReorder the modifiers to comply with the Java Language Specification.(Ѿk8Ǫ۪1 +java:S1124"EReorder the modifiers to comply with the Java Language Specification.(Ѿk81 u -java:S3776"RRefactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.(8Ѫ۪1 +java:S3776"RRefactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.(81 9 -java:S3626"Remove this redundant jump.(݅8Ѫ۪1 +java:S3626"Remove this redundant jump.(݅81 9 -java:S3626"Remove this redundant jump.(݅8Ѫ۪1 +java:S3626"Remove this redundant jump.(݅81 9 -java:S3626"Remove this redundant jump.(݅8Ҫ۪1 +java:S3626"Remove this redundant jump.(݅81 W -java:S1874"9Remove this use of "PreferenceManager"; it is deprecated.(­8ժ۪1 +java:S1874"9Remove this use of "PreferenceManager"; it is deprecated.(­81 a -java:S1874"CRemove this use of "getDefaultSharedPreferences"; it is deprecated.(­8֪۪1 +java:S1874"CRemove this use of "getDefaultSharedPreferences"; it is deprecated.(­81 U -java:S1135"2Complete the task associated to this TODO comment.(̐8ު۪1 +java:S1135"2Complete the task associated to this TODO comment.(̐81 M -java:S2093"*Change this "try" to a try-with-resources.(8ު۪1 +java:S2093"*Change this "try" to a try-with-resources.(81 v -java:S1450"XRemove the "mMoveMenu" field and declare it as a local variable in the relevant methods.(8۪1 +java:S1450"XRemove the "mMoveMenu" field and declare it as a local variable in the relevant methods.(81 u -java:S3252"RUse static access with "android.widget.AbsListView" for "MultiChoiceModeListener".(8۪1 +java:S3252"RUse static access with "android.widget.AbsListView" for "MultiChoiceModeListener".(81 U -java:S1135"2Complete the task associated to this TODO comment.(8۪1 +java:S1135"2Complete the task associated to this TODO comment.(81 U -java:S1135"2Complete the task associated to this TODO comment.(8۪1 +java:S1135"2Complete the task associated to this TODO comment.(81 \ -java:S1874"9Remove this use of "getDefaultDisplay"; it is deprecated.(ĸ8۪1 +java:S1874"9Remove this use of "getDefaultDisplay"; it is deprecated.(ĸ81 T -java:S1874"1Remove this use of "getHeight"; it is deprecated.(8۪1 +java:S1874"1Remove this use of "getHeight"; it is deprecated.(81 ? -java:S1116"Remove this empty statement.(8۪1 +java:S1116"Remove this empty statement.(81 p -java:S3776"RRefactor this method to reduce its Cognitive Complexity from 20 to the 15 allowed.(8۪1 +java:S3776"RRefactor this method to reduce its Cognitive Complexity from 20 to the 15 allowed.(81 J -java:S1874".Remove this use of ""; it is deprecated.(?8۪1 -F java:S108")Either remove or fill this block of code.(ʥ8۪1 +java:S1874".Remove this use of ""; it is deprecated.(?81 +F java:S108")Either remove or fill this block of code.(ʥ81 +h +java:S1874"JDon't override a deprecated method or explicitly mark it as "@Deprecated".(Ϳ8߬1 R -java:S1874"/Remove this use of "execute"; it is deprecated.(嫏8۪1 +java:S1874"/Remove this use of "execute"; it is deprecated.(嫏81 o -java:S3776"RRefactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.(#8۪1 +java:S3776"RRefactor this method to reduce its Cognitive Complexity from 17 to the 15 allowed.(#81 U -java:S1135"2Complete the task associated to this TODO comment.(8۪ͫ1 +java:S1135"2Complete the task associated to this TODO comment.(8Ƶ1 e -java:S1126"BReplace this if-then-else statement by a single method invocation.(玒8Ϋ۪1 +java:S1126"BReplace this if-then-else statement by a single method invocation.(玒8ǵ1 U -java:S1135"2Complete the task associated to this TODO comment.(8Ы۪1 +java:S1135"2Complete the task associated to this TODO comment.(8ǵ1 Q -java:S1874".Remove this use of ""; it is deprecated.(Ч8۪1 +java:S1874".Remove this use of ""; it is deprecated.(Ч8ֵ1 m -java:S1874"JDon't override a deprecated method or explicitly mark it as "@Deprecated".(ች8۪1 +java:S1874"JDon't override a deprecated method or explicitly mark it as "@Deprecated".(ች81 R -java:S1874"/Remove this use of "execute"; it is deprecated.(嫏8۪1 +java:S1874"/Remove this use of "execute"; it is deprecated.(嫏8ٵ1 o -java:S3776"RRefactor this method to reduce its Cognitive Complexity from 18 to the 15 allowed.(b8۪1 +java:S3776"RRefactor this method to reduce its Cognitive Complexity from 18 to the 15 allowed.(b8۵1 C -java:S3398"%Move this method into "ModeCallback".(8۪1 +java:S3398"%Move this method into "ModeCallback".(8ൔ1 H -java:S3398"%Move this method into "ModeCallback".(8۪1 +java:S3398"%Move this method into "ModeCallback".(8ൔ1 R -java:S3398"/Move this method into "BackgroundQueryHandler".(8۪1 +java:S3398"/Move this method into "BackgroundQueryHandler".(8ൔ1 N -java:S3398"0Move this method into "OnListItemClickListener".(8۪1 \ No newline at end of file +java:S3398"0Move this method into "OnListItemClickListener".(8ൔ1 \ No newline at end of file diff --git a/src/xiaomi/.idea/sonarlint/issuestore/d/6/d63b8495246ee14beb91a1f887d1ff4a009634d3 b/src/xiaomi/.idea/sonarlint/issuestore/d/6/d63b8495246ee14beb91a1f887d1ff4a009634d3 new file mode 100644 index 0000000..c100822 --- /dev/null +++ b/src/xiaomi/.idea/sonarlint/issuestore/d/6/d63b8495246ee14beb91a1f887d1ff4a009634d3 @@ -0,0 +1,11 @@ + +s +java:S4144"\Update this method so that its implementation is not identical to "getParentId" on line 185.( +> +java:S1125T"(Remove the unnecessary boolean literals.( +m +java:S3776p"RRefactor this method to reduce its Cognitive Complexity from 18 to the 15 allowed.( +C +java:S1125q"(Remove the unnecessary boolean literals.( +> +java:S1125r"(Remove the unnecessary boolean literals.( \ No newline at end of file diff --git a/src/xiaomi/.idea/sonarlint/issuestore/index.pb b/src/xiaomi/.idea/sonarlint/issuestore/index.pb index 104075c..d1e682a 100644 --- a/src/xiaomi/.idea/sonarlint/issuestore/index.pb +++ b/src/xiaomi/.idea/sonarlint/issuestore/index.pb @@ -6,4 +6,18 @@ Tapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/DropdownMenu < build.gradle,f\0\f07866736216be0ee2aba49e392191aeae700a35 @ -local.properties,0\7\0712df971a99ac4d2fccb8e0fb19f377f3374cca \ No newline at end of file +local.properties,0\7\0712df971a99ac4d2fccb8e0fb19f377f3374cca + +Qapp/src/main/java/com/example/notes_master/src/net/micode/notes/data/Contact.java,0\8\08962fe591286696ecd017e3adc4630c1217309b + +`app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/remote/GTaskASyncTask.java,1\a\1a4e3da7b86cbac8cbaa0189939fbddcc15fe216 + +Zapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/AlarmAlertActivity.java,0\4\0443b0f98e2a8a605b866a1b1bef7e47c8c8ea8e + +Tapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NoteItemData.java,d\6\d63b8495246ee14beb91a1f887d1ff4a009634d3 + +Xapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListAdapter.java,3\2\32e993b9c4de8af917eefa04505aeda3d70c1aff + +Oapp/src/main/java/com/example/notes_master/src/net/micode/notes/data/Notes.java,4\1\41b8b7f348f46f3b57551e41c1bbe95463dbc90e + +Uapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListItem.java,1\9\19661b4b3ff75e064358871f8409e1a1eef63bf6 \ No newline at end of file diff --git a/src/xiaomi/.idea/sonarlint/securityhotspotstore/0/4/0443b0f98e2a8a605b866a1b1bef7e47c8c8ea8e b/src/xiaomi/.idea/sonarlint/securityhotspotstore/0/4/0443b0f98e2a8a605b866a1b1bef7e47c8c8ea8e new file mode 100644 index 0000000..e69de29 diff --git a/src/xiaomi/.idea/sonarlint/securityhotspotstore/0/8/08962fe591286696ecd017e3adc4630c1217309b b/src/xiaomi/.idea/sonarlint/securityhotspotstore/0/8/08962fe591286696ecd017e3adc4630c1217309b new file mode 100644 index 0000000..e69de29 diff --git a/src/xiaomi/.idea/sonarlint/securityhotspotstore/1/9/19661b4b3ff75e064358871f8409e1a1eef63bf6 b/src/xiaomi/.idea/sonarlint/securityhotspotstore/1/9/19661b4b3ff75e064358871f8409e1a1eef63bf6 new file mode 100644 index 0000000..e69de29 diff --git a/src/xiaomi/.idea/sonarlint/securityhotspotstore/1/a/1a4e3da7b86cbac8cbaa0189939fbddcc15fe216 b/src/xiaomi/.idea/sonarlint/securityhotspotstore/1/a/1a4e3da7b86cbac8cbaa0189939fbddcc15fe216 new file mode 100644 index 0000000..e69de29 diff --git a/src/xiaomi/.idea/sonarlint/securityhotspotstore/3/2/32e993b9c4de8af917eefa04505aeda3d70c1aff b/src/xiaomi/.idea/sonarlint/securityhotspotstore/3/2/32e993b9c4de8af917eefa04505aeda3d70c1aff new file mode 100644 index 0000000..e69de29 diff --git a/src/xiaomi/.idea/sonarlint/securityhotspotstore/4/1/41b8b7f348f46f3b57551e41c1bbe95463dbc90e b/src/xiaomi/.idea/sonarlint/securityhotspotstore/4/1/41b8b7f348f46f3b57551e41c1bbe95463dbc90e new file mode 100644 index 0000000..e69de29 diff --git a/src/xiaomi/.idea/sonarlint/securityhotspotstore/d/6/d63b8495246ee14beb91a1f887d1ff4a009634d3 b/src/xiaomi/.idea/sonarlint/securityhotspotstore/d/6/d63b8495246ee14beb91a1f887d1ff4a009634d3 new file mode 100644 index 0000000..e69de29 diff --git a/src/xiaomi/.idea/sonarlint/securityhotspotstore/index.pb b/src/xiaomi/.idea/sonarlint/securityhotspotstore/index.pb index 104075c..d675dbb 100644 --- a/src/xiaomi/.idea/sonarlint/securityhotspotstore/index.pb +++ b/src/xiaomi/.idea/sonarlint/securityhotspotstore/index.pb @@ -6,4 +6,18 @@ Tapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/DropdownMenu < build.gradle,f\0\f07866736216be0ee2aba49e392191aeae700a35 @ -local.properties,0\7\0712df971a99ac4d2fccb8e0fb19f377f3374cca \ No newline at end of file +local.properties,0\7\0712df971a99ac4d2fccb8e0fb19f377f3374cca + +Qapp/src/main/java/com/example/notes_master/src/net/micode/notes/data/Contact.java,0\8\08962fe591286696ecd017e3adc4630c1217309b + +`app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/remote/GTaskASyncTask.java,1\a\1a4e3da7b86cbac8cbaa0189939fbddcc15fe216 + +Zapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/AlarmAlertActivity.java,0\4\0443b0f98e2a8a605b866a1b1bef7e47c8c8ea8e + +Tapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NoteItemData.java,d\6\d63b8495246ee14beb91a1f887d1ff4a009634d3 + +Oapp/src/main/java/com/example/notes_master/src/net/micode/notes/data/Notes.java,4\1\41b8b7f348f46f3b57551e41c1bbe95463dbc90e + +Xapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListAdapter.java,3\2\32e993b9c4de8af917eefa04505aeda3d70c1aff + +Uapp/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListItem.java,1\9\19661b4b3ff75e064358871f8409e1a1eef63bf6 \ No newline at end of file diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/data/Contact.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/data/Contact.java index c23f25c..6c3eb7b 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/data/Contact.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/data/Contact.java @@ -24,14 +24,14 @@ import android.telephony.PhoneNumberUtils; import android.util.Log; import java.util.HashMap; - +//联系人数据库 public class Contact { private static HashMap 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 " + + ",?) AND " + Data.MIMETYPE + "='" + Phone.CONTENT_ITEM_TYPE + "'" + + " AND " + Data.RAW_CONTACT_ID + " IN " + "(SELECT raw_contact_id " + " FROM phone_lookup" + " WHERE min_match = '+')"; diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/data/Notes.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/data/Notes.java index 922e27b..17785c9 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/data/Notes.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/data/Notes.java @@ -17,6 +17,7 @@ package com.example.notes_master.src.net.micode.notes.data; import android.net.Uri; +//便签数据库,用于记录便签相关属性和数据 public class Notes { public static final String AUTHORITY = "micode_notes"; public static final String TAG = "Notes"; diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/data/NotesDatabaseHelper.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/data/NotesDatabaseHelper.java index cba747b..9b6109d 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/data/NotesDatabaseHelper.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/data/NotesDatabaseHelper.java @@ -26,7 +26,7 @@ import com.example.notes_master.src.net.micode.notes.data.Notes.DataColumns; import com.example.notes_master.src.net.micode.notes.data.Notes.DataConstants; import com.example.notes_master.src.net.micode.notes.data.Notes.NoteColumns; - +//数据库帮助类,用于辅助创建、处理数据库的条目 public class NotesDatabaseHelper extends SQLiteOpenHelper { private static final String DB_NAME = "note.db"; @@ -43,168 +43,168 @@ 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"; + "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"; + "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"; + "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"; + "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"; + "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"; + "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"; + "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); diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/data/NotesProvider.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/data/NotesProvider.java index 6ddb6f9..7f9bb9d 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/data/NotesProvider.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/data/NotesProvider.java @@ -35,7 +35,7 @@ import com.example.notes_master.src.net.micode.notes.data.NotesDatabaseHelper.TA import net.micode.notes.R; - +//便签信息提供类 public class NotesProvider extends ContentProvider { private static final UriMatcher mMatcher; @@ -67,18 +67,18 @@ public class NotesProvider extends ContentProvider { * we will trim '\n' and white space in order to show more information. */ 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; + + 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 public boolean onCreate() { @@ -88,7 +88,7 @@ public class NotesProvider extends ContentProvider { @Override 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; diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/MetaData.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/MetaData.java index f385387..9a41d67 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/MetaData.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/MetaData.java @@ -24,7 +24,7 @@ import com.example.notes_master.src.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/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/Node.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/Node.java index cd60175..e1c2448 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/Node.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/Node.java @@ -19,7 +19,7 @@ package com.example.notes_master.src.net.micode.notes.gtask.data; import android.database.Cursor; import org.json.JSONObject; - +//同步任务的管理节点,用于设置、保存同步动作的信息 public abstract class Node { public static final int SYNC_ACTION_NONE = 0; diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/SqlData.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/SqlData.java index c126914..8ac2029 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/SqlData.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/SqlData.java @@ -34,7 +34,7 @@ import com.example.notes_master.src.net.micode.notes.gtask.exception.ActionFailu import org.json.JSONException; import org.json.JSONObject; - +//数据库中基本数据,方法包括读取数据、获取数据库中数据、提交数据到数据库 public class SqlData { private static final String TAG = SqlData.class.getSimpleName(); diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/SqlNote.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/SqlNote.java index 571b59c..961cf67 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/SqlNote.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/SqlNote.java @@ -37,7 +37,7 @@ import org.json.JSONObject; import java.util.ArrayList; - +//数据库中便签数据,方法包括读取便签内容、从数据库中获取便签数据、设置便签内容、提交便签到数据库 public class SqlNote { private static final String TAG = SqlNote.class.getSimpleName(); diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/Task.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/Task.java index 080914e..fd4b5aa 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/Task.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/Task.java @@ -31,7 +31,7 @@ import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; - +//同步任务,将创建、更新和同步动作包装成JSON对象,用本地和远程的JSON对节点内容进行设置,获取同步信息,进行本地和远程的同步 public class Task extends Node { private static final String TAG = Task.class.getSimpleName(); diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/TaskList.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/TaskList.java index 1e10576..7236f43 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/TaskList.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/data/TaskList.java @@ -29,7 +29,7 @@ import org.json.JSONObject; import java.util.ArrayList; - +//同步任务列表,将Task组织成同步任务列表进行管理 public class TaskList extends Node { private static final String TAG = TaskList.class.getSimpleName(); diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/exception/ActionFailureException.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/exception/ActionFailureException.java index 4512efc..b5eab31 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/exception/ActionFailureException.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/exception/ActionFailureException.java @@ -15,7 +15,7 @@ */ package com.example.notes_master.src.net.micode.notes.gtask.exception; - +//动作失败异常 public class ActionFailureException extends RuntimeException { private static final long serialVersionUID = 4425249765923293627L; diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/exception/NetworkFailureException.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/exception/NetworkFailureException.java index 9db2d5e..0d5cbe3 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/exception/NetworkFailureException.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/exception/NetworkFailureException.java @@ -15,7 +15,7 @@ */ package com.example.notes_master.src.net.micode.notes.gtask.exception; - +//网络失败异常 public class NetworkFailureException extends Exception { private static final long serialVersionUID = 2107610287180234136L; diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/remote/GTaskASyncTask.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/remote/GTaskASyncTask.java index 73c6326..7540409 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/remote/GTaskASyncTask.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/remote/GTaskASyncTask.java @@ -32,7 +32,7 @@ import com.example.notes_master.src.net.micode.notes.ui.NotesPreferenceActivity; import net.micode.notes.R; - +//GTask异步任务,方法包括任务同步和取消,显示同步任务的进程、通知和结果 public class GTaskASyncTask extends AsyncTask { private static int GTASK_SYNC_NOTIFICATION_ID = 5234235; diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/remote/GTaskClient.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/remote/GTaskClient.java index c23c012..20ac34f 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/remote/GTaskClient.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/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; - +//GTask客户端,提供登录Google账户,创建任务和任务列表,添加和删除节点,提交、重置更新,获取任务列表等功能 public class GTaskClient { private static final String TAG = GTaskClient.class.getSimpleName(); diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/remote/GTaskManager.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/remote/GTaskManager.java index 3155476..ea7e70a 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/remote/GTaskManager.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/remote/GTaskManager.java @@ -47,7 +47,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Map; - +//GTask管理者,提供同步本地和远端的任务,初始化任务列表,同步内容、文件夹,添加、更新本地和远端节点,刷新本地同步任务ID等功能 public class GTaskManager { private static final String TAG = GTaskManager.class.getSimpleName(); diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/remote/GTaskSyncService.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/remote/GTaskSyncService.java index 771e477..3fb9ced 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/gtask/remote/GTaskSyncService.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/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; - +//GTask同步服务,用于提供同步服务(开始、取消同步),发送广播 public class GTaskSyncService extends Service { public final static String ACTION_STRING_NAME = "sync_action_type"; diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/model/Note.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/model/Note.java index bdb6f68..9b2a689 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/model/Note.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/model/Note.java @@ -32,8 +32,7 @@ import com.example.notes_master.src.net.micode.notes.data.Notes.NoteColumns; import com.example.notes_master.src.net.micode.notes.data.Notes.TextNote; import java.util.ArrayList; - - +//单个便签项 public class Note { private ContentValues mNoteDiffValues; private NoteData mNoteData; diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/model/WorkingNote.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/model/WorkingNote.java index 5aebcc3..b8cd403 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/model/WorkingNote.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/model/WorkingNote.java @@ -31,7 +31,7 @@ import com.example.notes_master.src.net.micode.notes.data.Notes.NoteColumns; import com.example.notes_master.src.net.micode.notes.data.Notes.TextNote; import com.example.notes_master.src.net.micode.notes.tool.ResourceParser.NoteBgResources; - +//当前活动便签项 public class WorkingNote { // Note for the working note private Note mNote; diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/tool/BackupUtils.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/tool/BackupUtils.java index 5e2536a..ba48c6e 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/tool/BackupUtils.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/tool/BackupUtils.java @@ -36,7 +36,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; - +//备份工具类,用于数据备份读取、显示 public class BackupUtils { private static final String TAG = "BackupUtils"; // Singleton stuff diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/tool/DataUtils.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/tool/DataUtils.java index c1a7276..18f778e 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/tool/DataUtils.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/tool/DataUtils.java @@ -34,7 +34,7 @@ import com.example.notes_master.src.net.micode.notes.ui.NotesListAdapter.AppWidg import java.util.ArrayList; import java.util.HashSet; - +//便签数据处理工具类,封装如查找、移动、删除数据等工作 public class DataUtils { public static final String TAG = "DataUtils"; public static boolean batchDeleteNotes(ContentResolver resolver, HashSet ids) { diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/tool/GTaskStringUtils.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/tool/GTaskStringUtils.java index 13cffec..eb161cc 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/tool/GTaskStringUtils.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/tool/GTaskStringUtils.java @@ -15,7 +15,7 @@ */ package com.example.notes_master.src.net.micode.notes.tool; - +//同步中使用的字符串工具类,为JSONObject提供string对象 public class GTaskStringUtils { public final static String GTASK_JSON_ACTION_ID = "action_id"; diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/tool/ResourceParser.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/tool/ResourceParser.java index fef303c..7cb66e3 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/tool/ResourceParser.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/tool/ResourceParser.java @@ -22,7 +22,7 @@ import android.preference.PreferenceManager; import com.example.notes_master.src.net.micode.notes.ui.NotesPreferenceActivity; import net.micode.notes.R; - +//界面元素的解析工具类,利用R.java这个类获取资源供程序调用 public class ResourceParser { public static final int YELLOW = 0; diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/AlarmAlertActivity.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/AlarmAlertActivity.java index e49916a..9f36b10 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/AlarmAlertActivity.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/AlarmAlertActivity.java @@ -41,7 +41,7 @@ import net.micode.notes.R; import java.io.IOException; - +//闹铃提醒界面 public class AlarmAlertActivity extends AppCompatActivity implements OnClickListener, OnDismissListener { private long mNoteId; private String mSnippet; diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/AlarmInitReceiver.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/AlarmInitReceiver.java index 4a000e2..61bbbf1 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/AlarmInitReceiver.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/AlarmInitReceiver.java @@ -27,7 +27,7 @@ import android.database.Cursor; import com.example.notes_master.src.net.micode.notes.data.Notes; import com.example.notes_master.src.net.micode.notes.data.Notes.NoteColumns; - +//闹铃提醒启动消息接收器 public class AlarmInitReceiver extends BroadcastReceiver { private static final String [] PROJECTION = new String [] { diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/AlarmReceiver.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/AlarmReceiver.java index a7b9439..ad23d18 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/AlarmReceiver.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/AlarmReceiver.java @@ -19,7 +19,7 @@ package com.example.notes_master.src.net.micode.notes.ui; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; - +//闹铃提醒接收器 public class AlarmReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/DateTimePicker.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/DateTimePicker.java index c1246b0..1b0a322 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/DateTimePicker.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/DateTimePicker.java @@ -26,7 +26,7 @@ import net.micode.notes.R; import java.text.DateFormatSymbols; import java.util.Calendar; - +//设置提醒时间的部件 public class DateTimePicker extends FrameLayout { private static final boolean DEFAULT_ENABLE_STATE = true; diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/DateTimePickerDialog.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/DateTimePickerDialog.java index fe84031..9a9abe6 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/DateTimePickerDialog.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/DateTimePickerDialog.java @@ -28,7 +28,7 @@ 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(); diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/DropdownMenu.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/DropdownMenu.java index 2a929b4..e1cc628 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/DropdownMenu.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/DropdownMenu.java @@ -26,7 +26,7 @@ import android.widget.PopupMenu; import android.widget.PopupMenu.OnMenuItemClickListener; import net.micode.notes.R; - +//下拉菜单界面 public class DropdownMenu { private Button mButton; private PopupMenu mPopupMenu; diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/FoldersListAdapter.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/FoldersListAdapter.java index db34ace..e0b8586 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/FoldersListAdapter.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/FoldersListAdapter.java @@ -29,7 +29,7 @@ import com.example.notes_master.src.net.micode.notes.data.Notes.NoteColumns; import net.micode.notes.R; - +//文件夹列表适配器(链接数据库) public class FoldersListAdapter extends CursorAdapter { public static final String [] PROJECTION = { NoteColumns.ID, diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NoteEditActivity.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NoteEditActivity.java index 6229cba..04f8a28 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NoteEditActivity.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NoteEditActivity.java @@ -73,7 +73,7 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; - +//便签编辑活动 public class NoteEditActivity extends AppCompatActivity implements OnClickListener, NoteSettingChangedListener, OnTextViewChangeListener { private class HeadViewHolder { diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NoteEditText.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NoteEditText.java index 3a11689..e18dc34 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NoteEditText.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NoteEditText.java @@ -35,7 +35,7 @@ import net.micode.notes.R; import java.util.HashMap; import java.util.Map; - +//便签的文本编辑界面 public class NoteEditText extends androidx.appcompat.widget.AppCompatEditText { private static final String TAG = "NoteEditText"; private int mIndex; diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NoteItemData.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NoteItemData.java index c76ac25..aa1a8a5 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NoteItemData.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NoteItemData.java @@ -25,7 +25,7 @@ import com.example.notes_master.src.net.micode.notes.data.Notes; import com.example.notes_master.src.net.micode.notes.data.Notes.NoteColumns; import com.example.notes_master.src.net.micode.notes.tool.DataUtils; - +//便签项数据 public class NoteItemData { static final String [] PROJECTION = new String [] { NoteColumns.ID, @@ -77,20 +77,20 @@ public class NoteItemData { private boolean mIsMultiNotesFollowingFolder; public NoteItemData(Context context, Cursor cursor) { - mId = cursor.getLong(ID_COLUMN); - mAlertDate = cursor.getLong(ALERTED_DATE_COLUMN); - mBgColorId = cursor.getInt(BG_COLOR_ID_COLUMN); - mCreatedDate = cursor.getLong(CREATED_DATE_COLUMN); - mHasAttachment = (cursor.getInt(HAS_ATTACHMENT_COLUMN) > 0) ? true : false; - mModifiedDate = cursor.getLong(MODIFIED_DATE_COLUMN); - mNotesCount = cursor.getInt(NOTES_COUNT_COLUMN); - mParentId = cursor.getLong(PARENT_ID_COLUMN); - mSnippet = cursor.getString(SNIPPET_COLUMN); + mId = cursor.getLong(ID_COLUMN);//0 + mAlertDate = cursor.getLong(ALERTED_DATE_COLUMN);//1 + mBgColorId = cursor.getInt(BG_COLOR_ID_COLUMN);//2 + mCreatedDate = cursor.getLong(CREATED_DATE_COLUMN);//3 + mHasAttachment = (cursor.getInt(HAS_ATTACHMENT_COLUMN) > 0) ? true : false;//4 + mModifiedDate = cursor.getLong(MODIFIED_DATE_COLUMN);//5 + mNotesCount = cursor.getInt(NOTES_COUNT_COLUMN);//6 + mParentId = cursor.getLong(PARENT_ID_COLUMN);//7 + mSnippet = cursor.getString(SNIPPET_COLUMN);//8 mSnippet = mSnippet.replace(NoteEditActivity.TAG_CHECKED, "").replace( NoteEditActivity.TAG_UNCHECKED, ""); - mType = cursor.getInt(TYPE_COLUMN); - mWidgetId = cursor.getInt(WIDGET_ID_COLUMN); - mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN); + mType = cursor.getInt(TYPE_COLUMN);//9 + mWidgetId = cursor.getInt(WIDGET_ID_COLUMN);//10 + mWidgetType = cursor.getInt(WIDGET_TYPE_COLUMN);//11 mPhoneNumber = ""; if (mParentId == Notes.ID_CALL_RECORD_FOLDER) { @@ -218,6 +218,11 @@ public class NoteItemData { return (mParentId == Notes.ID_CALL_RECORD_FOLDER && !TextUtils.isEmpty(mPhoneNumber)); } + /** + * 从游标对象中获取便签类型 + * @param cursor + * @return + */ public static int getNoteType(Cursor cursor) { return cursor.getInt(TYPE_COLUMN); } diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListActivity.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListActivity.java index 8ed8a56..54086c0 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListActivity.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListActivity.java @@ -13,9 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package com.example.notes_master.src.net.micode.notes.ui; - import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; @@ -80,78 +78,49 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashSet; - - - +//主界面 public class NotesListActivity extends AppCompatActivity implements OnClickListener, OnItemLongClickListener { - private static final int FOLDER_NOTE_LIST_QUERY_TOKEN = 0; - - private static final int FOLDER_LIST_QUERY_TOKEN = 1; - - private static final int MENU_FOLDER_DELETE = 0; - - private static final int MENU_FOLDER_VIEW = 1; - - private static final int MENU_FOLDER_CHANGE_NAME = 2; - + private static final int FOLDER_NOTE_LIST_QUERY_TOKEN = 0;//查询文件夹中的便签列表 + private static final int FOLDER_LIST_QUERY_TOKEN = 1;//查询文件夹列表 + private static final int MENU_FOLDER_DELETE = 0;//删除文件夹 + private static final int MENU_FOLDER_VIEW = 1;//查看文件夹 + private static final int MENU_FOLDER_CHANGE_NAME = 2;//修改文件夹名字 private static final String PREFERENCE_ADD_INTRODUCTION = "net.micode.notes.introduction"; - private enum ListEditState { NOTE_LIST, SUB_FOLDER, CALL_RECORD_FOLDER }; - private ListEditState mState; - private BackgroundQueryHandler mBackgroundQueryHandler; - private NotesListAdapter mNotesListAdapter; - private ListView mNotesListView; - private Button mAddNewNote; - private boolean mDispatch; - private int mOriginY; - private int mDispatchY; - private TextView mTitleBar; - private long mCurrentFolderId; - private ContentResolver mContentResolver; - private ModeCallback mModeCallBack; - - private static final String TAG = "NotesListActivity"; - + private static final String TAG = "NotesListActivity";//打印日志时作标签 public static final int NOTES_LISTVIEW_SCROLL_RATE = 30; - private NoteItemData mFocusNoteDataItem; - private static final String NORMAL_SELECTION = NoteColumns.PARENT_ID + "=?"; - private static final String ROOT_FOLDER_SELECTION = "(" + NoteColumns.TYPE + "<>" + Notes.TYPE_SYSTEM + " AND " + NoteColumns.PARENT_ID + "=?)" + " OR (" + NoteColumns.ID + "=" + Notes.ID_CALL_RECORD_FOLDER + " AND " + NoteColumns.NOTES_COUNT + ">0)"; - private final static int REQUEST_CODE_OPEN_NODE = 102; private final static int REQUEST_CODE_NEW_NODE = 103; - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.note_list); initResources(); - /** * Insert an introduction when user firstly use this application */ setAppInfoFromRawRes(); } - @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK @@ -161,14 +130,16 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe super.onActivityResult(requestCode, resultCode, data); } } - + //当用户第一次使用小米便签时,把默认的欢迎便签保存到界面上 private void setAppInfoFromRawRes() { SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); - if (!sp.getBoolean(PREFERENCE_ADD_INTRODUCTION, false)) { + if (!sp.getBoolean(PREFERENCE_ADD_INTRODUCTION, false)) {//"net.micode.notes.introduction" StringBuilder sb = new StringBuilder(); InputStream in = null; + // 把资源文件放到应用程序的/raw/raw下,那么就可以在应用中使用getResources获取资源后, + // 以openRawResource方法(不带后缀的资源文件名)打开这个文件。 try { - in = getResources().openRawResource(R.raw.introduction); + in = getResources().openRawResource(R.raw.introduction);//该文件内容:Welcome to use MIUI notes! if (in != null) { InputStreamReader isr = new InputStreamReader(in); BufferedReader br = new BufferedReader(isr); @@ -194,12 +165,13 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe } } } - + // 创建空的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"); @@ -207,27 +179,26 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe } } } - @Override protected void onStart() { super.onStart(); startAsyncNotesListQuery(); } - + // 初始化资源 private void initResources() { - mContentResolver = this.getContentResolver(); + mContentResolver = this.getContentResolver();// 获取应用程序的数据,得到类似数据表的东西 mBackgroundQueryHandler = new BackgroundQueryHandler(this.getContentResolver()); - mCurrentFolderId = Notes.ID_ROOT_FOLDER; - mNotesListView = (ListView) findViewById(R.id.notes_list); + mCurrentFolderId = Notes.ID_ROOT_FOLDER;//0 + mNotesListView = (ListView) findViewById(R.id.notes_list);// 绑定XML中的ListView,作为Item的容器 mNotesListView.addFooterView(LayoutInflater.from(this).inflate(R.layout.note_list_footer, null), null, false); - mNotesListView.setOnItemClickListener(new OnListItemClickListener()); - mNotesListView.setOnItemLongClickListener(this); + mNotesListView.setOnItemClickListener(new OnListItemClickListener());//单击监听器 + mNotesListView.setOnItemLongClickListener(this);//长按监听器 mNotesListAdapter = new NotesListAdapter(this); mNotesListView.setAdapter(mNotesListAdapter); mAddNewNote = (Button) findViewById(R.id.btn_new_note); - mAddNewNote.setOnClickListener(this); - mAddNewNote.setOnTouchListener(new NewNoteOnTouchListener()); + mAddNewNote.setOnClickListener(this);//“添加便签”按钮的监听器 + mAddNewNote.setOnTouchListener(new NewNoteOnTouchListener());//给按钮绑定自定义的触摸监听器 mDispatch = false; mDispatchY = 0; mOriginY = 0; @@ -235,16 +206,28 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe mState = ListEditState.NOTE_LIST; mModeCallBack = new ModeCallback(); } - + //内部类 + /** + * 私有类`ModeCallback`实现了`ListView.MultiChoiceModeListener`和`OnMenuItemClickListener`接口, + * 它用于处理多选模式下的操作和菜单项点击事件。 + */ private class ModeCallback implements ListView.MultiChoiceModeListener, OnMenuItemClickListener { - private DropdownMenu mDropDownMenu; - private ActionMode mActionMode; - private MenuItem mMoveMenu; - + private DropdownMenu mDropDownMenu; // 下拉菜单对象 + private ActionMode mActionMode; // 操作模式对象 + private MenuItem mMoveMenu; // 移动菜单项对象 + /** + * 当操作模式创建时调用。 + * @param mode 提供操作模式的ActionMode对象 + * @param menu 操作模式的菜单 + * @return 返回true表示操作模式已创建 + */ public boolean onCreateActionMode(ActionMode mode, Menu menu) { - getMenuInflater().inflate(R.menu.note_list_options, menu); - menu.findItem(R.id.delete).setOnMenuItemClickListener(this); - mMoveMenu = menu.findItem(R.id.move); + //通过调用 getMenuInflater().inflate() 方法加载菜单布局文件 R.menu.note_list_options, + // 并将菜单项添加到 menu 中。 + getMenuInflater().inflate(R.menu.note_list_options, menu); // 加载菜单布局文件 + menu.findItem(R.id.delete).setOnMenuItemClickListener(this); // 设置删除菜单项的点击监听器 + mMoveMenu = menu.findItem(R.id.move); // 获取移动菜单项 + // 根据条件设置移动菜单项的可见性和点击监听器 if (mFocusNoteDataItem.getParentId() == Notes.ID_CALL_RECORD_FOLDER || DataUtils.getUserFolderCount(mContentResolver) == 0) { mMoveMenu.setVisible(false); @@ -253,31 +236,33 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe mMoveMenu.setOnMenuItemClickListener(this); } mActionMode = mode; - mNotesListAdapter.setChoiceMode(true); - mNotesListView.setLongClickable(false); - mAddNewNote.setVisibility(View.GONE); - - View customView = LayoutInflater.from(NotesListActivity.this).inflate( - R.layout.note_list_dropdown_menu, null); + mNotesListAdapter.setChoiceMode(true); // 设置列表适配器的选择模式为多选模式 + mNotesListView.setLongClickable(false); // 禁用列表视图的长按点击功能 + mAddNewNote.setVisibility(View.GONE); // 设置添加新笔记按钮不可见 + // 创建自定义视图并设置给操作模式 + View customView = LayoutInflater.from(NotesListActivity.this) + .inflate(R.layout.note_list_dropdown_menu, null); mode.setCustomView(customView); + // 创建下拉菜单对象并设置下拉菜单项的点击监听器 mDropDownMenu = new DropdownMenu(NotesListActivity.this, (Button) customView.findViewById(R.id.selection_menu), R.menu.note_list_dropdown); - mDropDownMenu.setOnDropdownMenuItemClickListener(new PopupMenu.OnMenuItemClickListener(){ + mDropDownMenu.setOnDropdownMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { mNotesListAdapter.selectAll(!mNotesListAdapter.isAllSelected()); updateMenu(); return true; } - }); return true; } - + /** + * 更新菜单项和下拉菜单。 + */ private void updateMenu() { - int selectedCount = mNotesListAdapter.getSelectedCount(); - // Update dropdown menu - String format = getResources().getString(R.string.menu_select_title, selectedCount); + int selectedCount = mNotesListAdapter.getSelectedCount(); // 获取选中的项数 + // 更新下拉菜单标题 + 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) { @@ -286,58 +271,81 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe item.setTitle(R.string.menu_deselect_all); } else { item.setChecked(false); - item.setTitle(R.string.menu_select_all); + item.setTitle(R.string.menu_select_all);//全选 } } } - + /** + * 当操作模式准备就绪时调用。 + * @param mode 提供操作模式的ActionMode对象 + * @param menu 操作模式的菜单 + * @return 返回true表示操作模式已准备就绪 + */ public boolean onPrepareActionMode(ActionMode mode, Menu menu) { - // TODO Auto-generated method stub + // TODO: 添加准备操作模式的逻辑(如果有的话) return false; } - + /** + * 当操作模式的菜单项被点击时调用。 + * @param mode 提供操作模式的ActionMode对象 + * @param item 被点击的菜单项 + * @return 返回true表示菜单项点击事件已处理 + */ public boolean onActionItemClicked(ActionMode mode, MenuItem item) { - // TODO Auto-generated method stub + // TODO: 处理菜单项的点击事件 return false; } - + /** + * 当操作模式结束时调用的方法。 + * @param mode 提供操作模式的ActionMode对象 + */ public void onDestroyActionMode(ActionMode mode) { - mNotesListAdapter.setChoiceMode(false); - mNotesListView.setLongClickable(true); - mAddNewNote.setVisibility(View.VISIBLE); + mNotesListAdapter.setChoiceMode(false); // 取消多选模式 + mNotesListView.setLongClickable(true); // 启用列表视图的长按点击功能 + mAddNewNote.setVisibility(View.VISIBLE); // 设置添加新笔记按钮可见 } - + /** + * 结束操作模式,退出多选模式。 + */ public void finishActionMode() { mActionMode.finish(); } - - public void onItemCheckedStateChanged(ActionMode mode, int position, long id, - boolean checked) { + /** + * 当列表项的选择状态改变时调用,更新HashMap中相应项的值。 + * @param mode 提供选择模式的ActionMode对象 + * @param position 被选中或取消选中的项的适配器位置 + * @param id 被选中或取消选中的项的适配器ID + * @param checked true表示项现在被选中,false表示项现在取消选中 + */ + public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { mNotesListAdapter.setCheckedItem(position, checked); updateMenu(); } - + /** + * 当菜单项被点击时调用。 + * @param item 被点击的菜单项 + * @return 返回true表示菜单项点击事件已处理 + */ public boolean onMenuItemClick(MenuItem item) { if (mNotesListAdapter.getSelectedCount() == 0) { Toast.makeText(NotesListActivity.this, getString(R.string.menu_select_none), - Toast.LENGTH_SHORT).show(); + Toast.LENGTH_SHORT).show(); // 如果没有选中项,显示提示消息 return true; } - switch (item.getItemId()) { case R.id.delete: AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this); builder.setTitle(getString(R.string.alert_title_delete)); builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setMessage(getString(R.string.alert_message_delete_notes, - mNotesListAdapter.getSelectedCount())); + mNotesListAdapter.getSelectedCount())); builder.setPositiveButton(android.R.string.ok, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, - int which) { - batchDelete(); - } - }); + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int which) { + batchDelete(); + } + }); builder.setNegativeButton(android.R.string.cancel, null); builder.show(); break; @@ -350,12 +358,12 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe return true; } } - private class NewNoteOnTouchListener implements OnTouchListener { public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { + // 获取屏幕显示 Display display = getWindowManager().getDefaultDisplay(); int screenHeight = display.getHeight(); int newNoteViewHeight = mAddNewNote.getHeight(); @@ -364,6 +372,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe /** * Minus TitleBar's height */ + // 如果当前状态是ListEditState.SUB_FOLDER,则减去标题栏的高度 if (mState == ListEditState.SUB_FOLDER) { eventY -= mTitleBar.getHeight(); start -= mTitleBar.getHeight(); @@ -377,6 +386,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe * Notice that, if the background of the button changes, the formula should * also change. This is very bad, just for the UI designer's strong requirement. */ + // 如果点击的是"New Note"按钮的透明部分(根据特定的公式判断),则将事件分发给按钮后面的列表视图 if (event.getY() < (event.getX() * (-0.12) + 94)) { View view = mNotesListView.getChildAt(mNotesListView.getChildCount() - 1 - mNotesListView.getFooterViewsCount()); @@ -392,6 +402,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe break; } case MotionEvent.ACTION_MOVE: { + // 如果之前已经进行了事件分发,则根据手指移动的距离更新事件的位置,并将事件继续分发给列表视图 if (mDispatch) { mDispatchY += (int) event.getY() - mOriginY; event.setLocation(event.getX(), mDispatchY); @@ -400,6 +411,7 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe break; } default: { + // 如果之前已经进行了事件分发,则将事件的位置更新,并停止事件的分发 if (mDispatch) { event.setLocation(event.getX(), mDispatchY); mDispatch = false; @@ -410,31 +422,47 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe } return false; } - - }; - + } private void startAsyncNotesListQuery() { - String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ? ROOT_FOLDER_SELECTION - : NORMAL_SELECTION; - 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"); + // 检查当前文件夹ID是否为根文件夹ID,确定查询的条件 + String selection = (mCurrentFolderId == Notes.ID_ROOT_FOLDER) ? ROOT_FOLDER_SELECTION : NORMAL_SELECTION; + // 使用BackgroundQueryHandler开始异步查询 + // 参数1:查询令牌,用于标识查询的唯一性 + // 参数2:对象,用于传递额外的数据给查询结果的回调方法 + // 参数3:查询的URI,指定要查询的数据表的内容URI + // 参数4:查询的投影,指定要查询的列 + // 参数5:查询的选择条件 + // 参数6:选择条件中的占位符的值 + // 参数7:查询的排序方式 + 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 { public BackgroundQueryHandler(ContentResolver contentResolver) { super(contentResolver); } - + /** + * token 参数表示查询操作的标识符,用于区分不同的查询操作。 + * cookie 参数是一个可选的对象,用于在发起查询时传递额外的数据,在查询完成后原样返回,可以用于标识查询操作的上下文或其他需要的信息。 + * cursor 参数是查询返回的结果集,它是一个游标对象(Cursor),用于遍历查询结果的数据。 + * @param token the token to identify the query, passed in from + * {@link #startQuery}. + * @param cookie the cookie object passed in from {@link #startQuery}. + * @param cursor The cursor holding the results from the query. + */ @Override protected void onQueryComplete(int token, Object cookie, Cursor cursor) { switch (token) { - case FOLDER_NOTE_LIST_QUERY_TOKEN: + case FOLDER_NOTE_LIST_QUERY_TOKEN://0 对文件夹内的笔记列表进行查询操作 mNotesListAdapter.changeCursor(cursor); break; - case FOLDER_LIST_QUERY_TOKEN: - if (cursor != null && cursor.getCount() > 0) { + case FOLDER_LIST_QUERY_TOKEN://1 对文件夹列表进行查询操作 + if (cursor != null && cursor.getCount() > 0) {//有文件夹 showFolderListMenu(cursor); } else { Log.e(TAG, "Query folder failed"); @@ -445,10 +473,9 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe } } } - private void showFolderListMenu(Cursor cursor) { AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this); - builder.setTitle(R.string.menu_title_select_folder); + builder.setTitle(R.string.menu_title_select_folder);//选择文件夹 final FoldersListAdapter adapter = new FoldersListAdapter(this, cursor); builder.setAdapter(adapter, new DialogInterface.OnClickListener() { @@ -458,46 +485,47 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe Toast.makeText( NotesListActivity.this, getString(R.string.format_move_notes_to_folder, - mNotesListAdapter.getSelectedCount(), + mNotesListAdapter.getSelectedCount(),//选中的要移到的便签数量 adapter.getFolderName(NotesListActivity.this, which)), - Toast.LENGTH_SHORT).show(); + Toast.LENGTH_SHORT).show();//当把文件夹中的便签移到文件夹外时,显示Toast消息“”已将所选+n+条便签移到上一级文件夹 mModeCallBack.finishActionMode(); } }); builder.show(); } - private void createNewNote() { + // 创建一个Intent对象,指定目标为NoteEditActivity,并设置操作为ACTION_INSERT_OR_EDIT Intent intent = new Intent(this, NoteEditActivity.class); intent.setAction(Intent.ACTION_INSERT_OR_EDIT); + // 将当前文件夹ID作为额外的INTENT_EXTRA_FOLDER_ID数据传递给Intent intent.putExtra(Notes.INTENT_EXTRA_FOLDER_ID, mCurrentFolderId); + // 启动NoteEditActivity,并获取结果 this.startActivityForResult(intent, REQUEST_CODE_NEW_NODE); } - private void batchDelete() { + // 创建一个异步任务 new AsyncTask>() { protected HashSet doInBackground(Void... unused) { + // 获取选中笔记项关联的小部件信息 HashSet widgets = mNotesListAdapter.getSelectedWidget(); if (!isSyncMode()) { - // if not synced, delete notes directly - if (DataUtils.batchDeleteNotes(mContentResolver, mNotesListAdapter - .getSelectedItemIds())) { + // 如果不处于同步模式,直接删除选中的笔记 + if (DataUtils.batchDeleteNotes(mContentResolver, mNotesListAdapter.getSelectedItemIds())) { + // 删除成功 } else { Log.e(TAG, "Delete notes error, should not happens"); } } else { - // in sync mode, we'll move the deleted note into the trash - // folder - if (!DataUtils.batchMoveToFolder(mContentResolver, mNotesListAdapter - .getSelectedItemIds(), Notes.ID_TRASH_FOLER)) { + // 如果处于同步模式,将选中的笔记移动到回收站文件夹 + if (!DataUtils.batchMoveToFolder(mContentResolver, mNotesListAdapter.getSelectedItemIds(), Notes.ID_TRASH_FOLER)) { Log.e(TAG, "Move notes to trash folder error, should not happens"); } } return widgets; } - @Override protected void onPostExecute(HashSet widgets) { + // 更新与选中笔记关联的小部件 if (widgets != null) { for (AppWidgetAttribute widget : widgets) { if (widget.widgetId != AppWidgetManager.INVALID_APPWIDGET_ID @@ -506,28 +534,30 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe } } } + // 完成操作模式,退出多选模式 mModeCallBack.finishActionMode(); } }.execute(); } - private void deleteFolder(long folderId) { + // 检查文件夹ID是否为根文件夹的ID,如果是,则记录错误日志并返回 if (folderId == Notes.ID_ROOT_FOLDER) { Log.e(TAG, "Wrong folder id, should not happen " + folderId); return; } - + // 创建HashSet来存储要删除的文件夹ID HashSet ids = new HashSet(); ids.add(folderId); - HashSet widgets = DataUtils.getFolderNoteWidget(mContentResolver, - folderId); + // 获取与文件夹关联的小部件信息 + HashSet widgets = DataUtils.getFolderNoteWidget(mContentResolver, folderId); + // 如果不处于同步模式,直接删除文件夹 if (!isSyncMode()) { - // if not synced, delete folder directly DataUtils.batchDeleteNotes(mContentResolver, ids); } else { - // in sync mode, we'll move the deleted folder into the trash folder + // 在同步模式下,将被删除的文件夹移动到回收站文件夹 DataUtils.batchMoveToFolder(mContentResolver, ids, Notes.ID_TRASH_FOLER); } + // 更新与该文件夹关联的小部件 if (widgets != null) { for (AppWidgetAttribute widget : widgets) { if (widget.widgetId != AppWidgetManager.INVALID_APPWIDGET_ID @@ -537,63 +567,75 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe } } } - private void openNode(NoteItemData data) { + // 创建一个Intent对象,指定目标为NoteEditActivity,并设置操作为ACTION_VIEW Intent intent = new Intent(this, NoteEditActivity.class); intent.setAction(Intent.ACTION_VIEW); + // 将笔记项的ID作为额外的UID数据传递给Intent intent.putExtra(Intent.EXTRA_UID, data.getId()); + // 启动NoteEditActivity,并获取结果 this.startActivityForResult(intent, REQUEST_CODE_OPEN_NODE); } - private void openFolder(NoteItemData data) { + // 将当前文件夹ID设置为给定数据项的ID mCurrentFolderId = data.getId(); + // 启动异步查询以获取当前文件夹下的笔记列表 startAsyncNotesListQuery(); + // 根据文件夹ID设置状态和标题栏的文本 if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) { mState = ListEditState.CALL_RECORD_FOLDER; mAddNewNote.setVisibility(View.GONE); - } else { - mState = ListEditState.SUB_FOLDER; - } - if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) { mTitleBar.setText(R.string.call_record_folder_name); } else { + mState = ListEditState.SUB_FOLDER; mTitleBar.setText(data.getSnippet()); } + // 显示标题栏 mTitleBar.setVisibility(View.VISIBLE); } - public void onClick(View v) { switch (v.getId()) { case R.id.btn_new_note: + // 点击“新建笔记”按钮时,调用createNewNote()方法 createNewNote(); break; default: break; } } - private void showSoftInput() { + // 获取输入法管理器实例 InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + // 检查输入法管理器是否为空 if (inputMethodManager != null) { + // 切换显示软键盘 + // 参数1:显示软键盘的标志,使用SHOW_FORCED表示强制显示 + // 参数2:指定额外的标志,此处为0 inputMethodManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0); } } - private void hideSoftInput(View view) { + // 获取输入法管理器实例 InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + // 隐藏软键盘 inputMethodManager.hideSoftInputFromWindow(view.getWindowToken(), 0); } - private void showCreateOrModifyFolderDialog(final boolean create) { + // 创建AlertDialog.Builder实例 final AlertDialog.Builder builder = new AlertDialog.Builder(this); + // 加载布局文件dialog_edit_text.xml作为对话框的内容视图 View view = LayoutInflater.from(this).inflate(R.layout.dialog_edit_text, null); + // 获取布局文件中的EditText控件 final EditText etName = (EditText) view.findViewById(R.id.et_foler_name); + // 显示软键盘 showSoftInput(); + // 根据create参数确定对话框的标题和EditText的初始文本 if (!create) { if (mFocusNoteDataItem != null) { etName.setText(mFocusNoteDataItem.getSnippet()); builder.setTitle(getString(R.string.menu_folder_change_name)); } else { + // 如果长按的数据项mFocusNoteDataItem为null,记录错误日志并返回 Log.e(TAG, "The long click data item is null"); return; } @@ -601,27 +643,35 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe etName.setText(""); builder.setTitle(this.getString(R.string.menu_create_folder)); } - + // 设置对话框的确定按钮 builder.setPositiveButton(android.R.string.ok, null); + // 设置对话框的取消按钮,并在点击时隐藏软键盘 builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { hideSoftInput(etName); } }); - + // 创建对话框并显示 final Dialog dialog = builder.setView(view).show(); + // 获取对话框中的确定按钮 final Button positive = (Button)dialog.findViewById(android.R.id.button1); + // 设置确定按钮的点击事件监听器 positive.setOnClickListener(new OnClickListener() { public void onClick(View v) { + // 隐藏软键盘 hideSoftInput(etName); + // 获取输入的文件夹名称 String name = etName.getText().toString(); + // 检查文件夹名称是否已存在 if (DataUtils.checkVisibleFolderName(mContentResolver, name)) { Toast.makeText(NotesListActivity.this, getString(R.string.folder_exist, name), Toast.LENGTH_LONG).show(); etName.setSelection(0, etName.length()); return; } + // 根据create参数确定是修改文件夹还是创建新文件夹 if (!create) { + // 修改文件夹 if (!TextUtils.isEmpty(name)) { ContentValues values = new ContentValues(); values.put(NoteColumns.SNIPPET, name); @@ -629,31 +679,29 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe values.put(NoteColumns.LOCAL_MODIFIED, 1); mContentResolver.update(Notes.CONTENT_NOTE_URI, values, NoteColumns.ID + "=?", new String[] { - String.valueOf(mFocusNoteDataItem.getId()) + String.valueOf(mFocusNoteDataItem.getId()) }); } } else if (!TextUtils.isEmpty(name)) { + // 创建新文件夹 ContentValues values = new ContentValues(); values.put(NoteColumns.SNIPPET, name); values.put(NoteColumns.TYPE, Notes.TYPE_FOLDER); mContentResolver.insert(Notes.CONTENT_NOTE_URI, values); } + // 关闭对话框 dialog.dismiss(); } }); - + // 如果EditText的文本为空,禁用确定按钮 if (TextUtils.isEmpty(etName.getText())) { positive.setEnabled(false); } - /** - * When the name edit text is null, disable the positive button - */ + // EditText文本改变时,根据文本是否为空来启用或禁用确定按钮 etName.addTextChangedListener(new TextWatcher() { public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub - } - public void onTextChanged(CharSequence s, int start, int before, int count) { if (TextUtils.isEmpty(etName.getText())) { positive.setEnabled(false); @@ -661,24 +709,27 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe positive.setEnabled(true); } } - public void afterTextChanged(Editable s) { // TODO Auto-generated method stub - } }); } - + /** + * 按返回键时根据情况更改类中的数据 + */ @Override public void onBackPressed() { + // 根据当前的状态进行处理 switch (mState) { case SUB_FOLDER: + // 如果当前状态是SUB_FOLDER,则回退到根文件夹 mCurrentFolderId = Notes.ID_ROOT_FOLDER; mState = ListEditState.NOTE_LIST; startAsyncNotesListQuery(); mTitleBar.setVisibility(View.GONE); break; case CALL_RECORD_FOLDER: + // 如果当前状态是CALL_RECORD_FOLDER,则回退到根文件夹 mCurrentFolderId = Notes.ID_ROOT_FOLDER; mState = ListEditState.NOTE_LIST; mAddNewNote.setVisibility(View.VISIBLE); @@ -686,62 +737,73 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe startAsyncNotesListQuery(); break; case NOTE_LIST: + // 如果当前状态是NOTE_LIST,则调用父类的onBackPressed方法 super.onBackPressed(); break; default: break; } } - private void updateWidget(int appWidgetId, int appWidgetType) { + // 创建一个广播意图,用于更新小部件 Intent intent = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE); + // 根据小部件类型设置接收广播的类 if (appWidgetType == Notes.TYPE_WIDGET_2X) { intent.setClass(this, NoteWidgetProvider_2x.class); } else if (appWidgetType == Notes.TYPE_WIDGET_4X) { intent.setClass(this, NoteWidgetProvider_4x.class); } else { + // 未支持的小部件类型,记录错误日志并返回 Log.e(TAG, "Unspported widget type"); return; } - + // 将小部件ID作为额外数据添加到意图中 intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, new int[] { - appWidgetId + appWidgetId }); - + // 发送广播意图,通知小部件进行更新 sendBroadcast(intent); + // 设置结果为RESULT_OK,表示更新小部件成功 setResult(RESULT_OK, intent); } - private final OnCreateContextMenuListener mFolderOnCreateContextMenuListener = new OnCreateContextMenuListener() { public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { + // 检查当前焦点的笔记数据项是否为null if (mFocusNoteDataItem != null) { + // 设置上下文菜单的标题为焦点笔记数据项的摘要 menu.setHeaderTitle(mFocusNoteDataItem.getSnippet()); + // 添加菜单项到上下文菜单 + // 参数解释:(groupId, itemId, order, title) menu.add(0, MENU_FOLDER_VIEW, 0, R.string.menu_folder_view); menu.add(0, MENU_FOLDER_DELETE, 0, R.string.menu_folder_delete); menu.add(0, MENU_FOLDER_CHANGE_NAME, 0, R.string.menu_folder_change_name); } } }; - @Override public void onContextMenuClosed(Menu menu) { + // 当上下文菜单关闭时调用该方法 if (mNotesListView != null) { + // 将mNotesListView的OnCreateContextMenuListener设置为null,以取消菜单监听器 mNotesListView.setOnCreateContextMenuListener(null); } super.onContextMenuClosed(menu); } - @Override public boolean onContextItemSelected(MenuItem item) { + // 当上下文菜单项被选中时调用该方法 if (mFocusNoteDataItem == null) { + // 检查焦点笔记数据项是否为null Log.e(TAG, "The long click data item is null"); return false; } switch (item.getItemId()) { case MENU_FOLDER_VIEW: + // 如果选中的菜单项是MENU_FOLDER_VIEW,则打开文件夹 openFolder(mFocusNoteDataItem); break; case MENU_FOLDER_DELETE: + // 如果选中的菜单项是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); @@ -756,65 +818,80 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe builder.show(); break; case MENU_FOLDER_CHANGE_NAME: + // 如果选中的菜单项是MENU_FOLDER_CHANGE_NAME,则显示创建或修改文件夹的对话框 showCreateOrModifyFolderDialog(false); break; default: break; } - return true; } @Override public boolean onPrepareOptionsMenu(Menu menu) { - menu.clear(); + // 当准备显示选项菜单时调用该方法 + menu.clear(); // 清空菜单项 + // 根据当前状态(mState)选择要显示的菜单项 if (mState == ListEditState.NOTE_LIST) { + // 如果状态为NOTE_LIST,则从资源文件中填充note_list菜单项 getMenuInflater().inflate(R.menu.note_list, menu); - // set sync or sync_cancel + // 根据同步状态设置菜单项的标题为“sync”或“sync_cancel” menu.findItem(R.id.menu_sync).setTitle( GTaskSyncService.isSyncing() ? R.string.menu_sync_cancel : R.string.menu_sync); } else if (mState == ListEditState.SUB_FOLDER) { + // 如果状态为SUB_FOLDER,则从资源文件中填充sub_folder菜单项 getMenuInflater().inflate(R.menu.sub_folder, menu); } else if (mState == ListEditState.CALL_RECORD_FOLDER) { + // 如果状态为CALL_RECORD_FOLDER,则从资源文件中填充call_record_folder菜单项 getMenuInflater().inflate(R.menu.call_record_folder, menu); } else { + // 如果状态不是上述已定义的状态,则记录错误日志 Log.e(TAG, "Wrong state:" + mState); } return true; } - @Override public boolean onOptionsItemSelected(MenuItem item) { + // 当选项菜单项被选中时调用该方法 switch (item.getItemId()) { case R.id.menu_new_folder: { + // 如果选中的菜单项是menu_new_folder,则显示创建或修改文件夹的对话框 showCreateOrModifyFolderDialog(true); break; } case R.id.menu_export_text: { + // 如果选中的菜单项是menu_export_text,则导出笔记为文本文件 exportNoteToText(); break; } case R.id.menu_sync: { + // 如果选中的菜单项是menu_sync,则根据同步模式进行相应操作 if (isSyncMode()) { if (TextUtils.equals(item.getTitle(), getString(R.string.menu_sync))) { + // 如果菜单项标题为"menu_sync",则启动同步服务 GTaskSyncService.startSync(this); } else { + // 如果菜单项标题为"menu_sync_cancel",则取消同步服务 GTaskSyncService.cancelSync(this); } } else { + // 如果不是同步模式,则启动首选项活动 startPreferenceActivity(); } break; } case R.id.menu_setting: { + // 如果选中的菜单项是menu_setting,则启动首选项活动 startPreferenceActivity(); break; } case R.id.menu_new_note: { + // 如果选中的菜单项是menu_new_note,则创建新的笔记 createNewNote(); break; } case R.id.menu_search: + // 如果选中的菜单项是menu_search,则启动搜索 onSearchRequested(); break; default: @@ -822,85 +899,79 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe } return true; } - @Override public boolean onSearchRequested() { - startSearch(null, false, null /* appData */, false); + // 当搜索请求时调用该方法 + startSearch(null, false, null /* appData */, false); // 启动搜索 return true; } - private void exportNoteToText() { + // 获取BackupUtils的实例 final BackupUtils backup = BackupUtils.getInstance(NotesListActivity.this); + // 创建一个异步任务 new AsyncTask() { - @Override protected Integer doInBackground(Void... unused) { + // 在后台线程中执行导出笔记为文本的操作 return backup.exportToText(); } - @Override protected void onPostExecute(Integer result) { + // 在后台线程执行完毕后,在主线程中根据导出结果显示相应的对话框 if (result == BackupUtils.STATE_SD_CARD_UNMOUONTED) { + // 如果导出失败,SD卡未挂载,则显示失败对话框 AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this); - builder.setTitle(NotesListActivity.this - .getString(R.string.failed_sdcard_export)); - builder.setMessage(NotesListActivity.this - .getString(R.string.error_sdcard_unmounted)); + builder.setTitle(NotesListActivity.this.getString(R.string.failed_sdcard_export)); + builder.setMessage(NotesListActivity.this.getString(R.string.error_sdcard_unmounted)); builder.setPositiveButton(android.R.string.ok, null); builder.show(); } else if (result == BackupUtils.STATE_SUCCESS) { + // 如果导出成功,则显示成功对话框,并显示导出的文件位置 AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this); - builder.setTitle(NotesListActivity.this - .getString(R.string.success_sdcard_export)); + builder.setTitle(NotesListActivity.this.getString(R.string.success_sdcard_export)); builder.setMessage(NotesListActivity.this.getString( - R.string.format_exported_file_location, backup - .getExportedTextFileName(), backup.getExportedTextFileDir())); + R.string.format_exported_file_location, backup.getExportedTextFileName(), + backup.getExportedTextFileDir())); builder.setPositiveButton(android.R.string.ok, null); builder.show(); } else if (result == BackupUtils.STATE_SYSTEM_ERROR) { + // 如果导出失败,发生系统错误,则显示失败对话框 AlertDialog.Builder builder = new AlertDialog.Builder(NotesListActivity.this); - builder.setTitle(NotesListActivity.this - .getString(R.string.failed_sdcard_export)); - builder.setMessage(NotesListActivity.this - .getString(R.string.error_sdcard_export)); + builder.setTitle(NotesListActivity.this.getString(R.string.failed_sdcard_export)); + builder.setMessage(NotesListActivity.this.getString(R.string.error_sdcard_export)); builder.setPositiveButton(android.R.string.ok, null); builder.show(); } } - - }.execute(); + }.execute(); // 执行异步任务 } - private boolean isSyncMode() { return NotesPreferenceActivity.getSyncAccountName(this).trim().length() > 0; } - 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) { if (view instanceof NotesListItem) { NoteItemData item = ((NotesListItem) view).getItemData(); - if (mNotesListAdapter.isInChoiceMode()) { - if (item.getType() == Notes.TYPE_NOTE) { + if (mNotesListAdapter.isInChoiceMode()) {//处于选择状态 + if (item.getType() == Notes.TYPE_NOTE) {//是便签被选中,则修改它的被选择的状态 position = position - mNotesListView.getHeaderViewsCount(); mModeCallBack.onItemCheckedStateChanged(null, position, id, !mNotesListAdapter.isSelectedItem(position)); } return; } - + //以下是不处于选择模式 switch (mState) { case NOTE_LIST: - if (item.getType() == Notes.TYPE_FOLDER + if (item.getType() == Notes.TYPE_FOLDER//是文件夹被选中,则打开文件夹 || item.getType() == Notes.TYPE_SYSTEM) { openFolder(item); - } else if (item.getType() == Notes.TYPE_NOTE) { + } else if (item.getType() == Notes.TYPE_NOTE) {//是便签被选中,则打开该便签 openNode(item); } else { Log.e(TAG, "Wrong note type in NOTE_LIST"); @@ -919,14 +990,15 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe } } } - } private void startQueryDestinationFolders() { + // 构建查询条件 String selection = NoteColumns.TYPE + "=? AND " + NoteColumns.PARENT_ID + "<>? AND " + NoteColumns.ID + "<>?"; - selection = (mState == ListEditState.NOTE_LIST) ? selection: - "(" + selection + ") OR (" + NoteColumns.ID + "=" + Notes.ID_ROOT_FOLDER + ")"; - + // 根据当前的列表编辑状态(mState)确定最终的查询条件 + selection = (mState == ListEditState.NOTE_LIST) ? selection : + "(" + selection + ") OR (" + NoteColumns.ID + "=" + Notes.ID_ROOT_FOLDER + ")"; + // 启动后台查询操作 mBackgroundQueryHandler.startQuery(FOLDER_LIST_QUERY_TOKEN, null, Notes.CONTENT_NOTE_URI, @@ -939,18 +1011,24 @@ public class NotesListActivity extends AppCompatActivity implements OnClickListe }, NoteColumns.MODIFIED_DATE + " DESC"); } - public boolean onItemLongClick(AdapterView parent, View view, int position, long id) { + // 检查长按的视图是否为NotesListItem if (view instanceof NotesListItem) { + // 获取长按的笔记项数据 mFocusNoteDataItem = ((NotesListItem) view).getItemData(); + // 检查笔记项类型是否为Note类型且不在选择模式下 if (mFocusNoteDataItem.getType() == Notes.TYPE_NOTE && !mNotesListAdapter.isInChoiceMode()) { + // 启动操作模式(ActionMode)以支持多选操作 if (mNotesListView.startActionMode(mModeCallBack) != null) { + // 更新选中项的状态,并执行长按反馈(震动) mModeCallBack.onItemCheckedStateChanged(null, position, id, true); mNotesListView.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); } else { + // 启动操作模式失败 Log.e(TAG, "startActionMode fails"); } } else if (mFocusNoteDataItem.getType() == Notes.TYPE_FOLDER) { + // 如果笔记项类型为Folder类型,则设置上下文菜单监听器 mNotesListView.setOnCreateContextMenuListener(mFolderOnCreateContextMenuListener); } } diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListAdapter.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListAdapter.java index 44bd3c8..18d8ce4 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListAdapter.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListAdapter.java @@ -30,12 +30,12 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; - +//便签列表适配器(链接数据库) public class NotesListAdapter extends CursorAdapter { private static final String TAG = "NotesListAdapter"; private Context mContext; private HashMap mSelectedIndex; - private int mNotesCount; + private int mNotesCount;//文件夹外的便签数量 private boolean mChoiceMode; public static class AppWidgetAttribute { @@ -55,6 +55,13 @@ public class NotesListAdapter extends CursorAdapter { return new NotesListItem(context); } + /** + * 在 bindView() 方法中,您可以获取 Cursor 中的数据,并将其设置到相应的界面元素上,例如 TextView、ImageView 等。 + * @param view Existing view, returned earlier by newView + * @param context Interface to application's global information + * @param cursor The cursor from which to get the data. The cursor is already + * moved to the correct position. + */ @Override public void bindView(View view, Context context, Cursor cursor) { if (view instanceof NotesListItem) { @@ -128,12 +135,18 @@ public class NotesListAdapter extends CursorAdapter { return itemSet; } + /** + *返回选中的便签个数(mSelectedIndex的value为true的元素个数) + * @return + */ public int getSelectedCount() { - Collection values = mSelectedIndex.values(); + Collection values = mSelectedIndex.values();//在 HashMap 中,每个键都关联一个值。 + // values 方法返回的是所有键值对中的值组成的集合,而不包括键。 + // 该集合是一个 Collection 类型,可以遍历、迭代或进行其他操作。 if (null == values) { return 0; } - Iterator iter = values.iterator(); + Iterator iter = values.iterator();//返回一个迭代器对象(Iterator类型)用于遍历集合中的元素 int count = 0; while (iter.hasNext()) { if (true == iter.next()) { @@ -164,15 +177,15 @@ public class NotesListAdapter extends CursorAdapter { @Override public void changeCursor(Cursor cursor) { super.changeCursor(cursor); - calcNotesCount(); + calcNotesCount();//为了给mNotesCount赋值,也就是计算出便签数量 } private void calcNotesCount() { - mNotesCount = 0; - for (int i = 0; i < getCount(); i++) { + mNotesCount = 0;//便签数量先赋为0 + for (int i = 0; i < getCount(); i++) {//getCount()方法是CursorAdapter中的方法,用于返回游标集中元素个数 Cursor c = (Cursor) getItem(i); if (c != null) { - if (NoteItemData.getNoteType(c) == Notes.TYPE_NOTE) { + if (NoteItemData.getNoteType(c) == Notes.TYPE_NOTE) {//0。是单纯的便签就便签数量++ mNotesCount++; } } else { diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListItem.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListItem.java index 188d3af..3eae743 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListItem.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesListItem.java @@ -30,7 +30,7 @@ import com.example.notes_master.src.net.micode.notes.tool.ResourceParser.NoteIte import net.micode.notes.R; - +//便签列表项 public class NotesListItem extends LinearLayout { private ImageView mAlert; private TextView mTitle; diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesPreferenceActivity.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesPreferenceActivity.java index 1119400..f38b82e 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesPreferenceActivity.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/ui/NotesPreferenceActivity.java @@ -46,7 +46,7 @@ import com.example.notes_master.src.net.micode.notes.gtask.remote.GTaskSyncServi import net.micode.notes.R; - +//便签同步的设置界面 public class NotesPreferenceActivity extends PreferenceActivity { public static final String PREFERENCE_NAME = "notes_preferences"; diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/widget/NoteWidgetProvider.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/widget/NoteWidgetProvider.java index c2a74ea..21f43c2 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/widget/NoteWidgetProvider.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/widget/NoteWidgetProvider.java @@ -32,7 +32,7 @@ import com.example.notes_master.src.net.micode.notes.ui.NoteEditActivity; import com.example.notes_master.src.net.micode.notes.ui.NotesListActivity; import net.micode.notes.R; - +//桌面挂件 public abstract class NoteWidgetProvider extends AppWidgetProvider { public static final String [] PROJECTION = new String [] { NoteColumns.ID, diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/widget/NoteWidgetProvider_2x.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/widget/NoteWidgetProvider_2x.java index 506b650..8de7a8a 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/widget/NoteWidgetProvider_2x.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/widget/NoteWidgetProvider_2x.java @@ -23,7 +23,7 @@ import com.example.notes_master.src.net.micode.notes.data.Notes; import com.example.notes_master.src.net.micode.notes.tool.ResourceParser; import net.micode.notes.R; - +//2倍大小的桌面挂件 public class NoteWidgetProvider_2x extends NoteWidgetProvider { @Override diff --git a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/widget/NoteWidgetProvider_4x.java b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/widget/NoteWidgetProvider_4x.java index 7f01bd5..22ca395 100644 --- a/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/widget/NoteWidgetProvider_4x.java +++ b/src/xiaomi/app/src/main/java/com/example/notes_master/src/net/micode/notes/widget/NoteWidgetProvider_4x.java @@ -24,7 +24,7 @@ import com.example.notes_master.src.net.micode.notes.tool.ResourceParser; import net.micode.notes.R; - +//4倍大小的桌面挂件 public class NoteWidgetProvider_4x extends NoteWidgetProvider { @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {